Skip to content

Commit

Permalink
Merge pull request #228 from lc-labs/feature/fix-zapper-gas-estimate
Browse files Browse the repository at this point in the history
Feature/fix zapper gas estimate
  • Loading branch information
akshatmittal authored Oct 20, 2023
2 parents 6df2a4f + c2d261a commit 5e16f25
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/views/issuance/components/zap/state/ui-atoms.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Token } from '@reserve-protocol/token-zapper'
import { notifyError, notifySuccess } from 'hooks/useNotification'
import { Getter, SetStateAction, Setter, atom } from 'jotai'
import { atomWithStorage } from 'jotai/utils'
import { Atom } from 'jotai/vanilla'
import mixpanel from 'mixpanel-browser'
import {
ethPriceAtom,
gasFeeAtom,
isWalletModalVisibleAtom,
rTokenAtom,
} from 'state/atoms'
import { onlyNonNullAtom } from 'utils/atoms/utils'

import { notifyError, notifySuccess } from 'hooks/useNotification'
import mixpanel from 'mixpanel-browser'
import { addTransactionAtom } from 'state/chain/atoms/transactionAtoms'
import { onlyNonNullAtom } from 'utils/atoms/utils'
import {
approvalNeededAtom,
approvalPending,
Expand Down Expand Up @@ -532,12 +531,19 @@ const signAndSendTx: ZapperAction = async (
},
})

const limit = await provider.estimateGas({
to: tx.tx.to,
data: tx.tx.data,
from: tx.tx.from,
value: tx.tx.value,
})
let limit = (
await provider.estimateGas({
to: tx.tx.to,
data: tx.tx.data,
from: tx.tx.from,
value: tx.tx.value,
})
).toBigInt() as bigint

limit = limit + limit / 10n

limit = tx.gasEstimate > limit ? tx.gasEstimate : limit

const resp = await signer.sendTransaction({
...tx.tx,
gasLimit: limit,
Expand Down

0 comments on commit 5e16f25

Please sign in to comment.