Commit 68518d7c authored by Noah Zinsmeister's avatar Noah Zinsmeister Committed by GitHub

fix[migrate]: use proper slippage check (#1821)

parent 2c9c99b8
...@@ -209,33 +209,13 @@ function V2PairMigration({ ...@@ -209,33 +209,13 @@ function V2PairMigration({
tickUpper, tickUpper,
amount0: token0Value.quotient, amount0: token0Value.quotient,
amount1: token1Value.quotient, amount1: token1Value.quotient,
useFullPrecision: false, // we don't want full precision as this is used to calculate slippage amounts useFullPrecision: true, // we want full precision for the theoretical position
}) })
: undefined : undefined
const v3Amount0Min = useMemo( const { amount0: v3Amount0Min, amount1: v3Amount1Min } = useMemo(
() => () => (position ? position.mintAmountsWithSlippage(allowedSlippage) : { amount0: undefined, amount1: undefined }),
position && [position, allowedSlippage]
CurrencyAmount.fromRawAmount(
token0,
JSBI.divide(
JSBI.multiply(position.amount0.quotient, JSBI.BigInt(10000 - JSBI.toNumber(allowedSlippage.numerator))),
JSBI.BigInt(10000)
)
),
[token0, position, allowedSlippage]
)
const v3Amount1Min = useMemo(
() =>
position &&
CurrencyAmount.fromRawAmount(
token1,
JSBI.divide(
JSBI.multiply(position.amount1.quotient, JSBI.BigInt(10000 - JSBI.toNumber(allowedSlippage.numerator))),
JSBI.BigInt(10000)
)
),
[token1, position, allowedSlippage]
) )
const refund0 = useMemo( const refund0 = useMemo(
...@@ -336,8 +316,8 @@ function V2PairMigration({ ...@@ -336,8 +316,8 @@ function V2PairMigration({
fee: feeAmount, fee: feeAmount,
tickLower, tickLower,
tickUpper, tickUpper,
amount0Min: `0x${v3Amount0Min.quotient.toString(16)}`, amount0Min: `0x${v3Amount0Min.toString(16)}`,
amount1Min: `0x${v3Amount1Min.quotient.toString(16)}`, amount1Min: `0x${v3Amount1Min.toString(16)}`,
recipient: account, recipient: account,
deadline: deadlineToUse, deadline: deadlineToUse,
refundAsETH: true, // hard-code this for now refundAsETH: true, // hard-code this for now
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment