raydium-io / raydium-sdk-V2-demo

Open-source Typescript SDK demos
48 stars 31 forks source link

Program Error: "Instruction #3 Failed - The program expected this account to be already initialized" #61

Closed YoungHorn1999 closed 2 months ago

YoungHorn1999 commented 3 months ago

I run yarn dev trade/routeSwap.ts, swap 3B5wuUrMEi5yATD7on46hKfej3pfmd7t1RKgrsN3pump to SOL, the tx is on chain, and the code don't throw error, but the solscan always show this error: Program Error: "Instruction #3 Failed - The program expected this account to be already initialized" how can I make the tx success WechatIMG513

cruzshia commented 3 months ago

update sdk to 0.1.40-alpha should work, pushed to master

YoungHorn1999 commented 3 months ago

It seems like there is not have the 0.1.40-alpha yet?

截屏2024-07-13 14 02 10
cruzshia commented 3 months ago

https://github.com/raydium-io/raydium-sdk-V2-demo/commit/719eaf4d92295d6d26530d58b509a429868b012b

YoungHorn1999 commented 3 months ago

719eaf4

thank u so much, it works for almost token now. I meet a new error in routeSwap, when I swap BdV3mqyMwwy7NiFS7pY45qz18zcQTF5xjRQWLsscrtqp to sol by the routeSwap, found 1 pool, but the code throw error show there don't have route

WechatIMG514

cruzshia commented 2 months ago

please upgrade sdk to version 0.1.42-alpha and see code below to set log visible, I added some logs to show what happened. this error might caused by input amount too small (makes output amount to 0) or insufficient pool liquidity. you can upgrade sdk and set larger input amount and try again. https://github.com/raydium-io/raydium-sdk-V2-demo/commit/9bc0d2da9e8a7093e326994bb446182884d0c148#diff-1cccd777077d6bd8943af4b047c4edd63f9c08d450ea1c051d4f73d55b6ca429R27

YoungHorn1999 commented 2 months ago

after upgrade, I swap the token BdV3mqyMwwy7NiFS7pY45qz18zcQTF5xjRQWLsscrtqp and the value is 0.000123u, why it deposit 1sol to create token account, it's too much, it seems like have some problem? WechatIMG516

cruzshia commented 2 months ago

Please provide txId

YoungHorn1999 commented 2 months ago

3M5EhdzFBkpXjnME3hT8JtFhXEVQ7uJ3w8NHzwQ5muZB7oCNrxNaHJASL9BFPr1VMsoERHQaAUhh8mnRAsPtcg69

YoungHorn1999 commented 2 months ago

Normally, it should only deposit 0.002SOL to create token account, but it deposit 1SOL

cruzshia commented 2 months ago

discuss here https://github.com/raydium-io/raydium-sdk-V2-demo/issues/63

YoungHorn1999 commented 2 months ago

I think there have a bug causes the deposit amount to be proportional to the transaction amount. When the money in the wallet is less than the deposit amount, the transaction will fail. the tx in the pic is 4uxNNxXQfzKNBgWUHkUJfGpT6Dp2tmgWfsESiha5fcVUS6fucrqzMvgPn5uVxgcBeErV6BC7SzHhsFWmy1r4hid9 1721046018409