Skip to content

Commit

Permalink
[defence-for-gas-limit] gas margin 10%
Browse files Browse the repository at this point in the history
  • Loading branch information
Cast0001 committed Dec 11, 2023
1 parent fa50194 commit df6b27d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/contracts/vaultMulticall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,17 @@ const vaultMulticall = async <T extends unknown>(values: VaultMulticallInput): P
const { method, args } = params[0]

// @ts-ignore: no types to describe
return contract[method](...args)
const estimatedGas = await contract[method].estimateGas(...args)
const gasLimit = estimatedGas * 110n / 100n

// @ts-ignore: no types to describe
return contract[method](...args, { gasLimit })
}

return contract.multicall(calls) as T
const estimatedGas = await contract.multicall.estimateGas(calls)
const gasLimit = estimatedGas * 110n / 100n

return contract.multicall(calls, { gasLimit }) as T
}


Expand Down

0 comments on commit df6b27d

Please sign in to comment.