raydium-io / raydium-amm

Constant product AMM integrated with the OpenBook CLOB
Apache License 2.0
73 stars 61 forks source link

fix the broken parsing #13

Closed piotrostr closed 2 months ago

piotrostr commented 2 months ago

this might require some more work but I got it makes the deserialization of the given liquidity pool data yield the right values

RainRaydium commented 2 months ago

this might require some more work but I got it makes the deserialization of the given liquidity pool data yield the right values

There is no need to update.Please use the new version layout..

piotrostr commented 2 months ago

@RainRaydium you mean the Raydium V3 that is in beta? https://beta.raydium.io/

I was targeting the current Raydium LP program (675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8)

piotrostr commented 2 months ago

this could be documented somewhere since the examples provided in the https://github.com/raydium-io/raydium-library client are not working out-of-the-box

grebenyuksv commented 1 week ago

new version layout

what do you mean, @RainRaydium? LIQUIDITY_STATE_LAYOUT_V5? https://github.com/raydium-io/raydium-library/blob/master/client/src/main.rs#L204-L205

I sort of don't believe that the example from https://github.com/raydium-io/raydium-library/blob/master/client/src/main.rs#L204-L205 just doesn't work. What am I doing wrong? 🤔

The alignment of swap_pc_in_amount doesn't seem to match the on-chain data from that pool id:

image

Rust assumes the offset of swap_pc_in_amount inside StateData is 0x70, but it seems to be 0x68 on chain. I've tried different Rust versions from 1.73 to 1.79 on an M2 MacBook and in the official rust:1.x.0-slim Docker containers.

The TS example from https://github.com/raydium-io/raydium-sdk-V2-demo/blob/master/src/amm/swap.ts works.

grebenyuksv commented 1 week ago

Did you understand that answer, @piotrostr ? Is there a pool where the example from raydium-library works out of the box? The V3 UI transactions seem to be calling routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS, which interacts with that same 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8, e.g. https://solscan.io/tx/4jpWim3DejJobmP7PXnHqQB3yvV6CGkzkbcLABhRULekFhR74e97qVCGgSmNPyNJ1mCwyeCVDpBSNcCdFhefMpkJ 🤔