-
Notifications
You must be signed in to change notification settings - Fork 9
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
[WIP] V3 nested pool support #442
Conversation
…rrently failing, assuming because of router.
…g, possibly due to router.
…portional 258 remove liquidity nested proportional
// Address of the highest level pool (which contains BPTs of other pools), i.e. the pool we wish to join | ||
const parentPool = nestedPoolState.pools.reduce((max, curr) => | ||
curr.level > max.level ? curr : max, | ||
); | ||
// query function input, `tokensIn` array, must have all tokens from child pools | ||
// and all tokens that are not BPTs from the nested pool (parent pool). | ||
const mainTokens = nestedPoolState.mainTokens.map( | ||
(t) => new Token(input.chainId, t.address, t.decimals), | ||
); | ||
// This will add 0 amount for any tokensIn the user hasn't included | ||
const maxAmountsIn = getAmounts(mainTokens, input.amountsIn, 0n); | ||
|
||
// Query the router to get the onchain amount | ||
// Note - tokens do not have to be sorted, user preference is fine |
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.
Excellent job explaining the trickier parts / nuances with these comments 👏
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.
Minor inconsequential suggestion, but might make sense to have only one test file that runs both .buildCall
and .buildCallWithPermit2
for the addLiquidityNestedV3 ( unless I'm missing good reason is better to split? )
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.
Goes back to what we were discussing in our last meeting - I thought it was quite hard to follow approvals, etc in the other tests where everything is nested deeply and this was an attempt to make it easier to understand.
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.
🚢 Full steam ahead, captain!
Still to do:
Closes #257