Commit 81af31ee authored by Noah Zinsmeister's avatar Noah Zinsmeister

estimate gas in migrate v2

parent d3898cf9
......@@ -16,7 +16,7 @@ import { usePairContract, useV2MigratorContract } from '../../hooks/useContract'
import { NEVER_RELOAD, useSingleCallResult } from '../../state/multicall/hooks'
import { useTokenBalance } from '../../state/wallet/hooks'
import { BackArrow, ExternalLink, TYPE } from '../../theme'
import { getEtherscanLink, isAddress } from '../../utils'
import { calculateGasMargin, getEtherscanLink, isAddress } from '../../utils'
import { BodyWrapper } from '../AppBody'
import { V3_MIGRATOR_ADDRESSES } from 'constants/v3'
import { PoolState, usePool } from 'hooks/usePools'
......@@ -274,7 +274,7 @@ function V2PairMigration({
const deadlineToUse = signatureData?.deadline ?? deadline
const data = []
const data: string[] = []
// permit if necessary
if (signatureData) {
......@@ -324,8 +324,12 @@ function V2PairMigration({
)
setConfirmingMigration(true)
migrator
migrator.estimateGas
.multicall(data)
.then((gasEstimate) => {
return migrator
.multicall(data, { gasLimit: calculateGasMargin(gasEstimate) })
.then((response: TransactionResponse) => {
ReactGA.event({
category: 'Migrate',
......@@ -338,6 +342,7 @@ function V2PairMigration({
})
setPendingMigrationHash(response.hash)
})
})
.catch(() => {
setConfirmingMigration(false)
})
......
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