Floor tick values
This commit is contained in:
parent
4b09640e60
commit
538ae323d7
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user