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

V3 price impact for nested pools #478

Merged
merged 9 commits into from
Nov 7, 2024

Conversation

johngrantuk
Copy link
Member

@johngrantuk johngrantuk commented Nov 5, 2024

Also refactors nested add/remove to have different pool state for V2/V3. V3 use a new poolState requiring tokens with underlying info:

export type PoolTokenWithUnderlying = MinimalToken & {
    underlyingToken: MinimalToken | null;
};

type NestedPoolBase = {
    id: Hex;
    address: Address;
    type: PoolType;
    level: number; // 0 is the bottom and the highest level is the top
};

export type NestedPoolV2 = NestedPoolBase & {
    tokens: MinimalToken[]; // each token should have at least one
};

export type NestedPoolV3 = NestedPoolBase & {
    tokens: PoolTokenWithUnderlying[]; // each token should have at least one
};

type NestedPoolStateBase = {
    protocolVersion: 1 | 2 | 3;
    mainTokens: {
        address: Address;
        decimals: number;
    }[];
};

export type NestedPoolStateV2 = NestedPoolStateBase & {
    protocolVersion: 1 | 2;
    pools: NestedPoolV2[];
};

export type NestedPoolStateV3 = NestedPoolStateBase & {
    protocolVersion: 3;
    pools: NestedPoolV3[];
};

@johngrantuk johngrantuk linked an issue Nov 5, 2024 that may be closed by this pull request
@johngrantuk johngrantuk marked this pull request as ready for review November 5, 2024 14:41
Copy link
Member

@brunoguerios brunoguerios left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@johngrantuk johngrantuk merged commit 0454cae into main Nov 7, 2024
4 checks passed
@johngrantuk johngrantuk deleted the 440-v3-price-impact-for-nested-pools branch November 7, 2024 09:34
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.

V3 Price Impact for Nested Pools
2 participants