Skip to content

improve: Handle deposits referencing input/output/repayment tokens that do not map to PoolRebalanceRoutes #970

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

Merged
merged 36 commits into from
Apr 22, 2025

Conversation

nicholaspai
Copy link
Member

@nicholaspai nicholaspai commented Apr 8, 2025

Prerequisite changes needed to prepare for SpokePool that do not enforce deposit route whitelist checking. In this upcoming paradigm, deposits can be sent where the inputToken does not correspond to a PoolRebalanceRoute mapping. Implements this UMIP change

This change should be backwards compatible as all tokens that can be deposited are mapped to PoolRebalanceRoutes

The changes include:

  • changing the bundle data client's choice of repayment chain for a deposit where the inputToken and originChain, or outputToken and destinationChain, do not map to a PoolRebalanceRoute. These cases should switch repayment to the originChain.
  • building running balances based on refunds for a token that isn't mapped to a pool rebalance route
  • SpokePoolClient should gracefully handle deposits where the outputToken = 0x0 but there are not sufficient PoolRebalanceRoutes to resolve the outputToken

…ap to PoolRebalanceRoutes

Prerequisite changes needed to prepare for SpokePool that do not enforce deposit route whitelist checking

The changes include:
- changing the bundle data client's choice of repayment chain for a deposit where the inputToken and originChain do not map to a PoolRebalanceRoute
- building running balances based on refunds for a token that isn't mapped to a pool rebalance route
@nicholaspai nicholaspai requested review from pxrl and bmzig April 9, 2025 16:32
@nicholaspai nicholaspai marked this pull request as ready for review April 10, 2025 13:48
@nicholaspai nicholaspai marked this pull request as draft April 10, 2025 14:53
@nicholaspai nicholaspai removed request for bmzig and pxrl April 10, 2025 14:53
@nicholaspai nicholaspai requested a review from pxrl April 10, 2025 18:14
@nicholaspai nicholaspai changed the title improve(BundleDataClient): Ignore refunds for L2 tokens that do not map to PoolRebalanceRoutes improve: Handle deposits referencing tokens that do not map to PoolRebalanceRoutes Apr 10, 2025
@nicholaspai nicholaspai changed the title improve: Handle deposits referencing tokens that do not map to PoolRebalanceRoutes improve: Handle deposits referencing input/output/repayment tokens that do not map to PoolRebalanceRoutes Apr 10, 2025
@nicholaspai nicholaspai marked this pull request as ready for review April 11, 2025 17:08
@nicholaspai nicholaspai requested a review from bmzig April 11, 2025 18:55
@@ -208,6 +208,11 @@ export function isZeroValueDeposit(deposit: Pick<Deposit, "inputAmount" | "messa
return deposit.inputAmount.eq(0) && isMessageEmpty(deposit.message);
}

export function invalidOutputToken(deposit: Pick<DepositWithBlock, "outputToken">): boolean {
// If the output token is zero address, then it is invalid.
return deposit.outputToken === ZERO_ADDRESS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be ZERO_BYTES ? I think fwiw we already have a similar function (isZeroAddress()) used by the SpokePoolClient to determine whether it needs to sub in a valid address.

Copy link
Member Author

Choose a reason for hiding this comment

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

@nicholaspai nicholaspai requested a review from pxrl April 15, 2025 22:18
Copy link
Contributor

@bmzig bmzig left a comment

Choose a reason for hiding this comment

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

This looks good to me. I couldn't see anything wrong. A minor note: it seems like getL1TokenForDeposit and getL2TokenForDeposit will break with the contract upgrade, but the only time we use it is when calculating lp fees, which is addressed by the changes here.

@nicholaspai
Copy link
Member Author

Yeah I think this PR catches all instances where we use getL1TokenForDeposit and getL2TokenForDeposit but that's definitely a worry of mine. Thanks for reviewing

@nicholaspai nicholaspai requested a review from bmzig April 16, 2025 00:25
Copy link
Contributor

@bmzig bmzig left a comment

Choose a reason for hiding this comment

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

I had one comment about USDC.e. Intuitively I think it's alright to do, but I just wanted to verify.

@nicholaspai nicholaspai merged commit 758b83c into master Apr 22, 2025
4 checks passed
md0x pushed a commit that referenced this pull request May 2, 2025
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.

3 participants