Skip to content

feat: l2 token approval flow #2260

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

feat: l2 token approval flow #2260

wants to merge 3 commits into from

Conversation

grasphoper
Copy link
Contributor

@grasphoper grasphoper commented May 16, 2025

Overview

Some L2 -> L1 bridge objects sometimes require ERC20s to be approved to their associated bridge contracts. Example: Hyperlane requires ezETH to be approved for spending by a HYPERLANE_ROUTER.

This is why we implement a token approval flow for L2 bridges similar to L1 token approval flow.

Approval + xERC20 rebalancing test after change:

rebalance

token approval happened on a prev. relayer run.

Signed-off-by: Ihor Farion <[email protected]>
@grasphoper grasphoper changed the title feat: introduce l2 token approval flow for the l2Bridges that need it feat: l2 token approval flow May 16, 2025
I can of course just introduce a new key for L2 token approvals, but it seems redundant. Instead, the key could be smth like:
`bridgeAllowance_${chainId}_${token}_${userAddress}_targetContract:${targetContract}`;
*/
const allowance = await erc20.allowance(senderAddress.toAddress(), bridgeAddress.toAddress());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment relates to cache operations in a similar L1 token approval fn.

// Bridges that require specific approvals should override this method.
public requiredTokenApprovals(): { token: EvmAddress; bridge: EvmAddress }[] {
return [];
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think returning EvmAddresses is fine here

@grasphoper grasphoper marked this pull request as ready for review May 21, 2025 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant