----> TX ├─ Signatures[len=1] │ └─ 4UJPHEtrmksnNrX2DemwZHkyPDsYwtNgLvezzymzULjbuRB6QSEnFwig46rTD3j3kBUw1jFnaRRVi9FTUBG1UWiP ├─ Message │ ├─ Version: legacy │ ├─ RecentBlockhash: B6D2WSyMY7oizqpa6owMKgGjJYvBtxRQ7ZFZikVifdfR │ ├─ AccountKeys[len=18] │ │ ├─ 4HuJk6uYZGy9s6DhtnfrfWwfWQC5wn1Yst3opnGhUNhy │ │ ├─ 6q8z9WAryLBviHqa8v4kBmb5q8ocd2hHCPsURKudgmew │ │ ├─ 6c8QHXj5cXurwivUND1HHZNbjSSY8EC5xhFENFZ5fmsZ │ │ ├─ HVzJiG1xNHLJAqEsoQ97MaaMMMAoiS55ZHYUMuJEP3WJ │ │ ├─ GHsnp8iphQNpoun37hsZ2bPinqHSwUcfcapWJVraKJEP │ │ ├─ pb4G12Xa5Q2buTSSsUMwMGCimxpHsnSUSVodtS1m2aX │ │ ├─ Diu1oueq563cseEYaLKXAdzeeTfML9qy9JieqHftDhbd │ │ ├─ 2EmrRzKgBvz1pbivDyNmkyQ4eZ421wwWaa9JEsSAYg3Z │ │ ├─ HkwXsG5fCCdM4pkqXTeboxjHdE8mXBofwZtbK2pPiqYX │ │ ├─ DxjAwrtoaUmrMTrHxGQzvXeVcFbFPp1wBy1cEq7pnhTX │ │ ├─ BxMtoXysGfzv8QkLThFRfguG7FtgivaL8Ahji6Uzh1v9 │ │ ├─ 2Kw6sdPWn758dYxobo8th67vYzipA4nCgR5uVaAUARH1 │ │ ├─ 4Tu7ne3XDjkQhnPvu5mG49q7T6v7VxzaUqFLdowmYv7A │ │ ├─ TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA │ │ ├─ 5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1 │ │ ├─ srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX │ │ ├─ DmiCMQpRELBiueaNK6CeKBieLqixTjqwvhc8hWUqjU5S │ │ └─ 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 │ └─ Header │ ├─ NumRequiredSignatures: 1 │ ├─ NumReadonlySignedAccounts: 0 │ └─ NumReadonlyUnsignedAccounts: 5 └─ Instructions[len=1] └─ cannot decode instruction for 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 program: instruction decoder not found └─ Program: <unknown> 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 └─ Instruction: <unknown> ├─ data[len=17 bytes] │ └─ {9, 106, 178, 8, 0, 0, 0, 0, 0, 108, 74, 128, 1, 0, 0, 0, 0}(len=17) └─ accounts[len=18] ├─ accounts[0]: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA [] ├─ accounts[1]: 6q8z9WAryLBviHqa8v4kBmb5q8ocd2hHCPsURKudgmew [WRITE] ├─ accounts[2]: 5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1 [] ├─ accounts[3]: 6c8QHXj5cXurwivUND1HHZNbjSSY8EC5xhFENFZ5fmsZ [WRITE] ├─ accounts[4]: HVzJiG1xNHLJAqEsoQ97MaaMMMAoiS55ZHYUMuJEP3WJ [WRITE] ├─ accounts[5]: GHsnp8iphQNpoun37hsZ2bPinqHSwUcfcapWJVraKJEP [WRITE] ├─ accounts[6]: pb4G12Xa5Q2buTSSsUMwMGCimxpHsnSUSVodtS1m2aX [WRITE] ├─ accounts[7]: srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX [] ├─ accounts[8]: Diu1oueq563cseEYaLKXAdzeeTfML9qy9JieqHftDhbd [WRITE] ├─ accounts[9]: 2EmrRzKgBvz1pbivDyNmkyQ4eZ421wwWaa9JEsSAYg3Z [WRITE] ├─ accounts[10]: HkwXsG5fCCdM4pkqXTeboxjHdE8mXBofwZtbK2pPiqYX [WRITE] ├─ accounts[11]: DxjAwrtoaUmrMTrHxGQzvXeVcFbFPp1wBy1cEq7pnhTX [WRITE] ├─ accounts[12]: BxMtoXysGfzv8QkLThFRfguG7FtgivaL8Ahji6Uzh1v9 [WRITE] ├─ accounts[13]: 2Kw6sdPWn758dYxobo8th67vYzipA4nCgR5uVaAUARH1 [WRITE] ├─ accounts[14]: DmiCMQpRELBiueaNK6CeKBieLqixTjqwvhc8hWUqjU5S [] ├─ accounts[15]: 4Tu7ne3XDjkQhnPvu5mG49q7T6v7VxzaUqFLdowmYv7A [WRITE] ├─ accounts[16]: 4Tu7ne3XDjkQhnPvu5mG49q7T6v7VxzaUqFLdowmYv7A [WRITE] └─ accounts[17]: 4HuJk6uYZGy9s6DhtnfrfWwfWQC5wn1Yst3opnGhUNhy [WRITE, SIGN]
BUILDING a simple swap transaction instruction all accounts seems to be alright ` poolKey := solana.PublicKey(bytesAddres)
poolsKey, err := raydium.FetchPoolKeys(rpcClient, poolKey)
if err != nil {
log.Fatalf("Error getting pool keys")
}
PoolInfo := raydium.FetchInfo(rpcClient, poolsKey)
if len(PoolInfo) > 0 {
prettyJSON, err := json.MarshalIndent(PoolInfo[0], "", " ")
if err != nil {
fmt.Println("Error marshalling to JSON:", err)
} else {
fmt.Println(string(prettyJSON))
}
} else {
fmt.Println("No pools info available.")
}
amount := 0.1 / 175.45
normalizedPrice_ := int64(float64(amount) * float64(solana.LAMPORTS_PER_SOL))
normalizedPrice := big.NewInt(normalizedPrice_)
inputToken := raydium.WSOLToken()
inputTokenAmount := raydium.NewTokenAmount(*inputToken, normalizedPrice, true)
outputToken := raydium.NewToken(poolsKey.BaseMint, poolsKey.BaseDecimals, poolsKey.ID, poolsKey.ID)
slippagePercent := raydium.NewPercent(big.NewInt(1), big.NewInt(100))
minAmountOut := raydium.ComputeAmountOutSimple(poolsKey, PoolInfo[0], *inputTokenAmount, *outputToken, *slippagePercent)
wallet := solana.MustPrivateKeyFromBase58("25Q2gX2TveYtmfrHACrSSmLVoNmAeMQC2FJsBtrSKR9j7Z76auRHSp7q5rwhv75G7rCoQZ7uSN8zsVpiVujkLwMD")
walletTokenAccounts_ := raydium.GetWalletTokenAccount(*rpcClient, wallet.PublicKey())
userKeys := raydium.UserKeys{
TokenAccounts: walletTokenAccounts_,
Owner: wallet.PublicKey(),
Payer: wallet.PublicKey(),
}
const txVersion raydium.TxVersion = 0
var computeConfig_ raydium.ComputeBudgetConfig
liquidtySwapParams := raydium.LiquiditySwapInstructionSimpleParams{
Connection: rpcClient,
PoolKeys: poolsKey,
UserKeys: userKeys,
AmountIn: *inputTokenAmount,
AmountOut: minAmountOut,
FixedSide: "in",
Config: raydium.Config{},
}
_tokenAccountIn, _tokenAccountOut := raydium.BuildTokenAccounts(liquidtySwapParams, txVersion, raydium.CacheLTA{}, computeConfig_, rpcClient)
fmt.Printf("\nToken ACCOUNTS IN: %v \n TOKEN ACCOUNT OUT: %v\n", _tokenAccountIn, _tokenAccountOut)
instrs := []solana.Instruction{}
instructions := raydium.NewSwapInstructions(
*inputTokenAmount,
minAmountOut,
raydium.MakePubKeyFromString("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),
raydium.MakePubKeyFromString(poolsKey.ID),
poolsKey.Authority,
poolsKey.OpenOrders,
poolsKey.TargetOrders,
poolsKey.BaseVault,
poolsKey.QuoteVault,
poolsKey.MarketProgramID,
poolsKey.MarketID,
poolsKey.MarketBids,
poolsKey.MarketAsks,
poolsKey.MarketEventQueue,
poolsKey.MarketBaseVault,
poolsKey.MarketQuoteVault,
poolsKey.MarketAuthority,
_tokenAccountIn,
_tokenAccountOut,
wallet.PublicKey(),
)
signers := []solana.PrivateKey{wallet}
instrs = append(instrs, instructions)
txns, err := raydium.BuildTransacion(context.Background(), rpcClient, signers, instrs...)
if err != nil {
log.Printf("ERRRRRRRRRRRRRRRRR %s\n", err)
}`