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