magicblock-labs / magicblock-labs/Solana.Unity-SDK
Jupiter swap failed - Transaction failed to sanitize accounts offsets correctly
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 199
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
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 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;
}
}
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with MakeSwap and trace Dex.Swap through transaction signing, Serialize(), and SendTransactionAsync. No file or test is named, so first reproduce the Jupiter swap with the provided SOL, PONKE, and amount values and inspect the serialized transaction and RPC response. Done means the transaction sanitization failure is explained and the affected swap path is corrected or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100