Skip to content
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

fix(v4-sdk): V4 planner accommodates exactOut + granular take/settles #97

Merged
merged 13 commits into from
Sep 20, 2024

Conversation

ewilz
Copy link
Member

@ewilz ewilz commented Sep 12, 2024

No description provided.

@ewilz ewilz requested a review from a team as a code owner September 12, 2024 18:10
@ewilz ewilz requested a review from zhongeric September 12, 2024 18:11
Copy link

graphite-app bot commented Sep 12, 2024

Graphite Automations

"Request reviewers once CI passes on sdks monorepo" took an action on this PR • (09/12/24)

1 reviewer was added and 1 assignee was added to this PR based on 's automation.

Copy link
Collaborator

@marktoda marktoda left a comment

Choose a reason for hiding this comment

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

quick approval to unblock since requires 2

@ewilz ewilz changed the title fix(v4-sdk): V4 planner accommodates exactOut fix(v4-sdk): V4 planner accommodates exactOut + granular take/settles Sep 19, 2024

describe('RouterPlanner', () => {
let planner: V4Planner

beforeEach(() => {
planner = new V4Planner()
// console.log(planner)
Copy link
Member

Choose a reason for hiding this comment

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

do you need this still?

Comment on lines +106 to +109
const FULL_DELTA_AMOUNT = 0
const MSG_SENDER = '0x0000000000000000000000000000000000000001'
const ADDRESS_THIS = '0x0000000000000000000000000000000000000002'

Copy link
Member

Choose a reason for hiding this comment

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

ooh nice I made an ActionsConstant utils file, I can put these in there later when my PR gets merged

Copy link
Member Author

Choose a reason for hiding this comment

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

yah feel free to move around. this file is def pretty cray

? {
currencyOut,
path: encodeRouteToPath(trade.route, exactOutput),
amountInMaximum: trade.maximumAmountIn(slippageTolerance ?? new Percent(0)).quotient.toString(),
Copy link
Member

Choose a reason for hiding this comment

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

it looks like on 128 we check that slippageTolerance is required? so can we just pass it in directly here?

Copy link
Member Author

Choose a reason for hiding this comment

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

typescript gets mad

Copy link
Member

Choose a reason for hiding this comment

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

hahah ok got it

const actionType = trade.tradeType === TradeType.EXACT_INPUT ? Actions.SWAP_EXACT_IN : Actions.SWAP_EXACT_OUT
const exactOutput = trade.tradeType === TradeType.EXACT_OUTPUT

if (exactOutput) invariant(!!slippageTolerance, 'ExactOut requires slippageTolerance')
Copy link
Member

Choose a reason for hiding this comment

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

how come we only check this for exactOuput? just curious

Copy link
Member Author

Choose a reason for hiding this comment

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

good question I can leave a comment. on exactInput sometimes we do agg slippage checks so we don't need to know slippage, but we enver do that on exactOutput

])
}

addSettle(currency: Currency, payerIsUser: boolean, amount?: BigNumber): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we add comment headers?

Copy link
Contributor

@codyborn codyborn left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@snreynolds snreynolds left a comment

Choose a reason for hiding this comment

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

looks good

@ewilz ewilz merged commit 984b0f1 into main Sep 20, 2024
7 checks passed
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.

4 participants