-
Notifications
You must be signed in to change notification settings - Fork 71
improve(ZkSync_SpokePool): Read l2Bridge dynamically #1094
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
base: master
Are you sure you want to change the base?
Conversation
zkSync ERC20s are typically explicit about the L2 bridge to use, but Lens ERC20s are not. Lens WETH does supplies a valid l2Bridge address that can be used to withdraw from the chain.
function withdraw( | ||
address _l1Receiver, | ||
address _l2Token, | ||
uint256 _amount | ||
) external; | ||
function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external; | ||
} |
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 is being reflowed by the commit hook. Not sure when that was implemented.
// Elastic chain bridged tokens advertise custom bridge interface via the l2Bridge() getter. | ||
address l2Bridge = IZkErc20(l2TokenAddress).l2Bridge(); | ||
if (l2Bridge != address(0)) { | ||
ZkBridgeLike(l2Bridge).withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); |
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.
tbd catch andrevert to zkErc20Bridge? These tokens are managed by governance, so there's some control over which interfaces the ERC20s implement.
@@ -166,7 +166,13 @@ contract ZkSync_SpokePool is SpokePool, CircleCCTPAdapter { | |||
zkUSDCBridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | |||
} | |||
} else { | |||
zkErc20Bridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | |||
// Elastic chain bridged tokens advertise custom bridge interface via the l2Bridge() getter. |
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.
See:
- http://explorer.lens.xyz/address/0xE5ecd226b3032910CEaa43ba92EE8232f8237553#contract#read-proxy
- https://era.zksync.network/token/0x4b9eb6c0b6ea15176bbf62841c6b2a8a398cb656#readProxyContract
- https://era.zksync.network/token/0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4#readProxyContract
- https://era.zksync.network/token/0xbbeb516fb02a01611cbbe0453fe3c580d7281011#readProxyContract
@@ -166,7 +166,13 @@ contract ZkSync_SpokePool is SpokePool, CircleCCTPAdapter { | |||
zkUSDCBridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | |||
} | |||
} else { | |||
zkErc20Bridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | |||
// Elastic chain bridged tokens advertise custom bridge interface via the l2Bridge() getter. | |||
address l2Bridge = IZkErc20(l2TokenAddress).l2Bridge(); |
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.
todo: Add test
zkSync ERC20s are typically explicit about the L2 bridge to use, but Lens ERC20s are not. Lens WETH does supplies a valid l2Bridge address that can be used to withdraw from the chain.