Skip to content

Commit

Permalink
recalculate limit preset ticks every time price moves
Browse files Browse the repository at this point in the history
  • Loading branch information
benwolski committed Jan 17, 2025
1 parent f123468 commit f060391
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions src/components/Trade/Limit/LimitRate/LimitRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,39 @@ export default function LimitRate(props: propsIF) {
updateURL({ update: [['limitTick', newTopOfBookLimit]] });
setPriceInputFieldBlurred(true);
}
setOnePercentTickValue(
isSellTokenBase
? pinTickToTickLower(
currentPoolPriceTick - 1 * 100,
gridSize,
)
: pinTickToTickUpper(
currentPoolPriceTick + 1 * 100,
gridSize,
),
);
setFivePercentTickValue(
isSellTokenBase
? pinTickToTickLower(
currentPoolPriceTick - 5 * 100,
gridSize,
)
: pinTickToTickUpper(
currentPoolPriceTick + 5 * 100,
gridSize,
),
);
setTenPercentTickValue(
isSellTokenBase
? pinTickToTickLower(
currentPoolPriceTick - 10 * 100,
gridSize,
)
: pinTickToTickUpper(
currentPoolPriceTick + 10 * 100,
gridSize,
),
);
}
})();
}, [currentPoolPriceTick, isSellTokenBase, gridSize, selectedPreset]);
Expand All @@ -181,20 +214,6 @@ export default function LimitRate(props: propsIF) {
? pinTickToTickLower(lowTick, gridSize)
: pinTickToTickUpper(highTick, gridSize);

switch (percent) {
case 1:
setOnePercentTickValue(pinnedTick);
break;
case 5:
setFivePercentTickValue(pinnedTick);
break;
case 10:
setTenPercentTickValue(pinnedTick);
break;
default:
break;
}

setLimitTick(pinnedTick);
updateURL({ update: [['limitTick', pinnedTick]] });
setPriceInputFieldBlurred(true);
Expand Down

0 comments on commit f060391

Please sign in to comment.