-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
Conversation
…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
…ation chain only if changing refund address to msg.sender and there are valid pool rebalance routes
@@ -372,7 +373,8 @@ export class BundleDataClient { | |||
if ( | |||
fill.blockNumber < blockRanges[chainIndex][0] || | |||
fill.blockNumber > blockRanges[chainIndex][1] || | |||
isZeroValueFillOrSlowFillRequest(fill) | |||
isZeroValueFillOrSlowFillRequest(fill) || | |||
invalidOutputToken(fill) |
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.
What's the intention with this check? invalidOutputToken()
is only checking against 0x0, but no fill should ever set that.
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.
My thinking was that technically you can send a fill with an output token equal to the zero address (contract allows it) and now it can match with a deposit with the zero address-- and we don't want that. Thoughts?
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.
Should this check even be in getApproximateRefundsForBlockRange
? Would this not filter out valid deposits with 0x0 as the output token?
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.
@bmzig my thinking was that in getApproximateRefundsForBlockRange
like in this loadDataFromScratch
function, there is a possibility to match a fill with an outputToken = 0x0
with a deposit.
So that's why this check exists there now. WDYT?
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.
Yep. That makes sense. I think we do want this here, then.
src/utils/DepositUtils.ts
Outdated
@@ -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; |
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.
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.
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.
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 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.
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 |
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 aPoolRebalanceRoute
mapping. Implements this UMIP changeThis change should be backwards compatible as all tokens that can be deposited are mapped to PoolRebalanceRoutes
The changes include:
outputToken = 0x0
but there are not sufficient PoolRebalanceRoutes to resolve the outputToken