raydium-sdk icon indicating copy to clipboard operation
raydium-sdk copied to clipboard

Perform a swap with raydium sdk

Open ValGuibs opened this issue 5 months ago • 17 comments

I have tried many times with several methods, but I still cannot swap from a token A to a token B, for example exchange 1SOL to X USDC with a slippage and fees choice. What is the simplest method to swap with raydium please? It's really complicated, there are no docs...

ValGuibs avatar Jan 14 '24 19:01 ValGuibs

baffling isn't it.

de-ltd avatar Jan 14 '24 20:01 de-ltd

I'm encountering the same issue here. This SDK is extremely complicated. Honestly, I've never come across such a disorganized, idiotic library in my life. It seems like no one knows anything about it.

ertan2002 avatar Jan 19 '24 22:01 ertan2002

Finally I made it :D really what was that.

ertan2002 avatar Jan 22 '24 09:01 ertan2002

Finally I made it :D really what was that. @ertan2002

Would you mind sharing your code so that i can see what i am doing wrong?

I've been trying for a couple of weeks now and it's really difficult when there is no documentation. I have been getting stuck at the makeSwapInstruction. Its throwing this error when i try to send the transaction:

"WalletProviderBase.tsx:63 WalletSendTransactionError: Transaction instruction index 0 has undefined program id"

Thanks in advance!

filipkossoIT avatar Jan 22 '24 18:01 filipkossoIT

Finally I made it :D really what was that. @ertan2002

Would you mind sharing your code so that i can see what i am doing wrong?

I've been trying for a couple of weeks now and it's really difficult when there is no documentation. I have been getting stuck at the makeSwapInstruction. Its throwing this error when i try to send the transaction:

"WalletProviderBase.tsx:63 WalletSendTransactionError: Transaction instruction index 0 has undefined program id"

Thanks in advance!

Hi filip

I think you are doing a front-end project and trying to connect your wallet. Unfortunately I am doing a backend proejct and directly perform a swap. So I don't have any idea regarding swapping with a user wallet.

But have you seen a demo project? https://github.com/raydium-io/raydium-frontend

I am using this demo project https://github.com/raydium-io/raydium-sdk-V1-demo it needs a lot of configuration in my case but it is a backend and does not require any wallet approvement.

When I search a demo app, I came across some samples, maybe it will help you

https://abbylow.medium.com/learn-to-build-a-swap-application-with-solana-wallet-adapter-and-raydium-sdk-part-1-20588b9b1ad https://abbylow.medium.com/learn-to-build-a-swap-application-with-solana-wallet-adapter-and-raydium-sdk-part-2-244705cb72a3

https://github.com/abbylow/raydium-swap/

and here is two videos https://www.youtube.com/watch?v=ePJbSv8-9fk https://www.youtube.com/watch?v=zai8CX6OwTg

and actually I find a good documentation https://www.soldev.app/course and the guy on the youtube made a serie for this documentation https://www.youtube.com/watch?v=HavGDGUTmgs&list=PLmAMfj0qP2wwfnuRJQge2ss4sJxnhIqyt

So I read and watch the videos parallel. It is quite useful and learnt a lot of things

hope this helps.

ertan2002 avatar Jan 22 '24 23:01 ertan2002

@ertan2002 Awesome thanks!

i've been checking Abbys tutorial but it was built with an old version and with the intention of only swapping between SOL and RAY. So i could not get much further there.

But thanks for all the other links, I appreciate it! Gonna be reading up on it and hopefully, I can solve it. Probably easiest to try and copy as much as possible from the Raydium frontend at the start until i get it working.

filipkossoIT avatar Jan 23 '24 18:01 filipkossoIT

@filipkossoIT Hi I think, I can help you. Just give me your telegram address. I'll show you what I did and maybe it'll give you an idea to connect with a wallet. Because somehow the logic and codes must be same.

Abby used the makeSwapTransaction method but I've used makeSwapInstructionSimple. So as you said, probably Abby's sdk is old one.

I have not tried with a wallet yet. here is a lesson with wallet https://www.soldev.app/course/interact-with-wallets

But I suggest you to start this tutorial from beginning. I've really loved this tutorial and the videos.

ertan2002 avatar Jan 24 '24 00:01 ertan2002

@ertan2002 hey! We're looking for making a swap on backend via Raydium and we certainly need some help. Can you please contact me on Telegram? t.me/vladissa_skinwalker

VladissaVortex avatar Jan 24 '24 13:01 VladissaVortex

@ertan2002 Hey man, I am also interested. Is there a way to contact you?

CVB91 avatar Jan 24 '24 19:01 CVB91

@filipkossoIT Hi I think, I can help you. Just give me your telegram address. I'll show you what I did and maybe it'll give you an idea to connect with a wallet. Because somehow the logic and codes must be same.

Abby used the makeSwapTransaction method but I've used makeSwapInstructionSimple. So as you said, probably Abby's sdk is old one.

I have not tried with a wallet yet. here is a lesson with wallet https://www.soldev.app/course/interact-with-wallets

But I suggest you to start this tutorial from beginning. I've really loved this tutorial and the videos.

I really appreciate it thanks! My TG handle is @filip_kossoIT

Seems like Raydium themself are using makeSwapInstructionSimple so you are most likely right, ill try with that Do you use Liquidity.makeSwapInstructionSimple or TradeV2.makeSwapInstructionSimple? If its the same in the frontend as in the backend when using it

filipkossoIT avatar Jan 24 '24 19:01 filipkossoIT

@ertan2002 , @filipkossoIT , @CVB91, @ValGuibs , @de-ltd , I have created a telegram conversation where you (and all other subsequent interested parties) can figure out how to do this. I think it will make communication easier:

https://t.me/+grk6IHdT4m83YmEy

VladissaVortex avatar Jan 25 '24 17:01 VladissaVortex

Hey folks, finally figured out Raydium SDK swaps. Here is the repo, check it out: precious-void/raydium-swap.

precious-void avatar Jan 28 '24 19:01 precious-void

thanks @shtelzerartem why you don't use jupiter instead raydium ?

thuthuatna avatar Feb 07 '24 11:02 thuthuatna

Company calls itself decentralized and open source yet the SDK so complex with 0 docs so that very few devs can front run everybody, classic!

zitounao avatar Mar 03 '24 21:03 zitounao

This is by far the worst in-production-use has-a-repo makes-tons-of-money SDK I've literally ever seen in my entire coding existence. props to the team for making it work. thanks for a headache today

stephengardner avatar Mar 14 '24 00:03 stephengardner

Hey guys, you can try this one if you're struggling! It's an example of swapping SOL to USDC. Edit the parameters in swapConfig.ts.

https://github.com/chainstacklabs/raydium-sdk-swap-example-typescript

soos3d avatar Mar 19 '24 17:03 soos3d

hey guys is there any raydium sdk for python?

CryptoDeployer avatar May 06 '24 18:05 CryptoDeployer