Skip to content

feat: Find price impact of swap#90

Open
secretshardul wants to merge 1 commit intoproject-serum:masterfrom
cykura:price-impact
Open

feat: Find price impact of swap#90
secretshardul wants to merge 1 commit intoproject-serum:masterfrom
cykura:price-impact

Conversation

@secretshardul
Copy link
Contributor

Pseudo-code in #86

  1. Low impact (blue color)

image

  1. High impact (red color)

image

Values match with numbers shown by Raydium

@secretshardul
Copy link
Contributor Author

Merged in cyclos-prod


// Use last route item to find impact
const route = useRoute(fromMint, toMint);
const impact = usePriceImpact(route?.at(-1));

Choose a reason for hiding this comment

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

const impact = usePriceImpact(route?.[route?.length - 1]);

Array.at() is experimental and causing issues

@matt-scientist
Copy link

Looks like this only goes through 1 market - for a transitive swap (A -> B + B -> C) wouldn't you have to sum price impact against both markets?

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