improve(ZkSync_SpokePool): Read l2Bridge dynamically#1094
Draft
improve(ZkSync_SpokePool): Read l2Bridge dynamically#1094
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.
pxrl
commented
Sep 2, 2025
contracts/ZkSync_SpokePool.sol
Outdated
Comment on lines
+11
to
+12
| function withdraw( | ||
| address _l1Receiver, | ||
| address _l2Token, | ||
| uint256 _amount | ||
| ) external; | ||
| function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This is being reflowed by the commit hook. Not sure when that was implemented.
pxrl
commented
Sep 2, 2025
| // 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); |
Contributor
Author
There was a problem hiding this comment.
tbd catch andrevert to zkErc20Bridge? These tokens are managed by governance, so there's some control over which interfaces the ERC20s implement.
pxrl
commented
Sep 2, 2025
| } | ||
| } else { | ||
| zkErc20Bridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | ||
| // Elastic chain bridged tokens advertise custom bridge interface via the l2Bridge() getter. |
Contributor
Author
There was a problem hiding this comment.
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
pxrl
commented
Sep 2, 2025
| } else { | ||
| zkErc20Bridge.withdraw(withdrawalRecipient, l2TokenAddress, amountToReturn); | ||
| // Elastic chain bridged tokens advertise custom bridge interface via the l2Bridge() getter. | ||
| address l2Bridge = IZkErc20(l2TokenAddress).l2Bridge(); |
Contributor
Author
|
(nb. currently waiting on feedback from Matter Labs to confirm this strategy is OK) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.