diff --git a/common/calculate-swap3.ts b/common/calculate-swap3.ts index fc552e2b..5819ae8e 100644 --- a/common/calculate-swap3.ts +++ b/common/calculate-swap3.ts @@ -91,5 +91,5 @@ function toProb(tick: number) { export function fromProb(prob: number) { const ratio = prob / (1 - prob) - return Math.log(ratio) / Math.log(1.0001) + return Math.floor(Math.log(ratio) / Math.log(1.0001)) } diff --git a/web/pages/swap.tsx b/web/pages/swap.tsx index 9a22b11d..f5bbe7de 100644 --- a/web/pages/swap.tsx +++ b/web/pages/swap.tsx @@ -86,16 +86,12 @@ function PoolTable(props: { pool: Swap3Pool }) { ) } -// Stored as optimization. equal to floor(log_sqrt_1.0001(sqrtRatio)) -function tick(sqrtRatio: number) { - return Math.floor(Math.log(sqrtRatio) / Math.log(1.0001)) -} - export default function Swap() { const [pool, setPool] = useState({ liquidity: 100, sqrtRatio: 2, - tick: tick(0.1), + tick: fromProb(0.3), + ticks: [], }) const [minTick, setMinTick] = useState(0)