raydium-io / raydium-sdk-V2

Open-source Typescript SDK for Raydium
GNU General Public License v3.0
38 stars 38 forks source link

how to compute pool size #40

Closed TechSkieur closed 1 week ago

TechSkieur commented 1 week ago

The question comes from one line of code I found somewhere from internet, it's a way of computing pool size:

const poolSize = new TokenAmount(quoteToken, poolState.swapQuoteInAmount, true);

I don't quite get it why computing like this. Could you explain to me?

According to my understanding, if quote token is WSOL, swapQuoteInAmount indicates how many SOL gets swapped into Pool? So it's like let's say when pool gets created, initial SOL liquidity is 10 SOL, now with time being, SOL liquidity in the pool increases to 20 SOL => swapQuoteInAmount would be something like 10 SOL. I guess my understanding on field swapQuoteInAmount is somewhat wrong...

thanks for answering

TechSkieur commented 1 week ago

@cruzshia could you help to answer my latest question..thanks..

cruzshia commented 1 week ago

I don't know where you found these code and it's not provided by us, so I can't explain it. further more, I suggest you read code from our official demo repo and relative code from sdk repo, thanks. https://github.com/raydium-io/raydium-sdk-V2-demo/blob/master/src/clmm/swap.ts https://github.com/raydium-io/raydium-sdk-V2-demo/blob/master/src/amm/swap.ts https://github.com/raydium-io/raydium-sdk-V2-demo/blob/master/src/cpmm/swap.ts

both amm/clmm/cpmm has provided getPoolInfoFromRpc method in sdk, you can check them to get all needed pool info.

TechSkieur commented 1 week ago

okay @cruzshia thanks, just one quick question, is my understanding on swapQuoteInAmount correct or wrong? What's your insights on this field