Open Zeddex opened 5 months ago
I'm getting error "invalid transaction: Transaction failed to sanitize accounts offsets correctly" making Jupiter swap.
string tokenIn = "SOL"; string tokenOut = "PONKE"; decimal amount = 0.001m;
public class JupiterSwap { public IRpcClient RpcClient { get; } = ClientFactory.GetClient(Cluster.MainNet); public IDexAggregator Dex { get; } public Wallet Wallet { get; } public JupiterSwap(IRpcClient rpcClient, Wallet wallet) { Wallet = wallet; RpcClient = rpcClient; Dex = new JupiterDexAg(Wallet.Account); } public async Task<string> MakeSwap(string tokenIn, string tokenOut, decimal inputAmount) { TokenData tokenA = await Dex.GetTokenBySymbol(tokenIn); TokenData tokenB = await Dex.GetTokenBySymbol(tokenOut); SwapQuoteAg swapQuote = await Dex.GetSwapQuote( tokenA.MintAddress, tokenB.MintAddress, DecimalUtil.ToUlong(inputAmount, tokenA.Decimals) ); var quoteOutput = DecimalUtil.FromBigInteger(swapQuote.OutputAmount, tokenB.Decimals); await Console.Out.WriteLineAsync($"Output Amount: {quoteOutput} {tokenOut}"); await Console.Out.WriteLineAsync(string.Join(" -> ", swapQuote.RoutePlan.Select(p => p.SwapInfo.Label))); var swapTransaction = await Dex.Swap(swapQuote); swapTransaction.Sign(Wallet.Account); var txSignature = await RpcClient.SendTransactionAsync(swapTransaction.Serialize()); return txSignature.Result; } }
I had the same problem
I'm getting error "invalid transaction: Transaction failed to sanitize accounts offsets correctly" making Jupiter swap.