-
Notifications
You must be signed in to change notification settings - Fork 177
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
feat: add support for custom gas token #310
Conversation
src/lib/assetBridger/erc20Bridger.ts
Outdated
@@ -696,6 +788,11 @@ export class Erc20Bridger extends AssetBridger< | |||
// in the future we want to do proper estimation here | |||
/* eslint-disable @typescript-eslint/no-unused-vars */ | |||
estimateL1GasLimit: async (l1Provider: Provider) => { | |||
if (!this.nativeTokenIsEth) { | |||
// measured 172867 - add some padding | |||
return BigNumber.from(200000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably won't work for L3->L2 withdrawal
@@ -706,7 +803,7 @@ export class Erc20Bridger extends AssetBridger< | |||
const isWeth = await this.isWethGateway(l1GatewayAddress, l1Provider) | |||
|
|||
// measured 157421 - add some padding | |||
return isWeth ? BigNumber.from(180000) : BigNumber.from(160000) | |||
return isWeth ? BigNumber.from(190000) : BigNumber.from(160000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably won't work for L3->L2 withdrawal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
recommend to add a comment regarding the hardcoded gas: the correct way to do is use NodeInterace.gasEstimateL1Component to calculate the L1 component + hardcoded L2 component
What's Changed
L2Network
nativeToken
AssetBridger
nativeToken
nativeTokenIsEth
which is a boolean that represents whether the Arbitrum chain that is being used with the bridger uses ETH as the native token.EthBridger
Added
getApproveGasTokenRequest
andapproveGasToken
toEthBridger
, which help approve the custom gas token to be spent by the Inbox. When adding support for a custom gas token chain, the user only needs to call this before doing the regular deposit, while the rest of the flow stays the same. The bridger object will pick between 2 separate code paths depending on the value ofnativeTokenIsEth
.These methods will throw if used on a chain that uses ETH as the gas token.
Erc20Bridger
Added
getApproveGasTokenRequest
andapproveGasToken
toEthBridger
, which help approve the custom gas token to be spent by the appropriate Gateway. When adding support for a custom gas token chain, the user only needs to call this before doing the regular deposit, while the rest of the flow stays the same. The bridger object will pick between 2 separate code paths depending on the value ofnativeTokenIsEth
.These methods will throw if used on a chain that uses ETH as the gas token.
L1ToL2MessageCreator
Updated
getTicketCreationRequest
to support custom gas token chains and have different calldata in that case.