Floor tick values

This commit is contained in:
Austin Chen 2022-06-07 08:54:17 -07:00
parent 4b09640e60
commit 538ae323d7
2 changed files with 3 additions and 7 deletions

View File

@ -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))
}

View File

@ -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)