Skip to content

Commit

Permalink
Control the use of the tick and price conversion if there's an error
Browse files Browse the repository at this point in the history
  • Loading branch information
af-afk committed Jun 8, 2024
1 parent d25ad6f commit 134c9ce
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions web/src/stores/useStakeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,26 @@ export const useStakeStore = create<StakeStore>((set) => ({
setPriceLower: (price) => {
// Make a best effort to convert the number to a sqrt price, then to a tick.
const priceN = Number(price);
const tick = getTickAtSqrtRatio(encodeSqrtPrice(priceN));
console.log("tick", tick);
let tick = 0;
try {
const newTick = getTickAtSqrtRatio(encodeSqrtPrice(priceN));
tick = newTick;
console.log("lower tick", tick);
} catch {
}
set({
tickLower: tick,
priceLower: price
});
},
setPriceUpper: (price) => {
const priceN = Number(price);
const tick = getTickAtSqrtRatio(encodeSqrtPrice(priceN));
const priceN = Number(price); let tick = 0;
try {
const newTick = getTickAtSqrtRatio(encodeSqrtPrice(priceN));
tick = newTick;
console.log("upper tick", tick);
} catch {
}
set({
tickUpper: tick,
priceUpper: price
Expand Down

0 comments on commit 134c9ce

Please sign in to comment.