Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas margin 10% #45

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/contracts/vaultMulticall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,25 @@ const vaultMulticall = async <T extends unknown>(values: VaultMulticallInput): P
} as T
}

// Even though ethers tries to find the best price for gas, sometimes it's
// not enough and the transaction breaks down and users lose money for gas.
// Adding 10% to the gas limit

if (isSoloCall) {
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
Loading