Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7881

Send custom routePlan to Juptier API /swap

$
0
0

Hello dear friends hope everybody is good today ?When following : https://station.jup.ag/docs/apis/swap-api#guide-for-v6-swap-api-code-exampleI can't send my transaction to a jito bundle or normal

  • Get a quote like this :
{  inputMint: 'So11111111111111111111111111111111111111112',    inAmount: '10000000',  outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',  outAmount: '1953696',  otherAmountThreshold: '1953696',  swapMode: 'ExactIn',  slippageBps: 0,  platformFee: null,  priceImpactPct: '0',  routePlan: [ { swapInfo: [Object], percent: 100 } ],  contextSlot: 300046736,  timeTaken: 0.010705948}
  • Custom quote (RoutePlan), outputMint , etc .... :
{  inputMint: 'So11111111111111111111111111111111111111112',  inAmount: '10000000',  outputMint: 'So11111111111111111111111111111111111111112',  outAmount: '10000000',  otherAmountThreshold: '9000000',  swapMode: 'ExactIn',  slippageBps: 0,  platformFee: null,  priceImpactPct: '0',  routePlan: [    { swapInfo: [Object], percent: 100 },    { swapInfo: [Object], percent: 100 }  ],  contextSlot: 300046736,  timeTaken: 0.010705948}
  • Sending to a Jito URL : https://URL/v1/transactions with
  await fetch('https://quote-api.jup.ag/v6/swap', {    method: 'POST',    headers: {'Content-Type': 'application/json'    },    body: JSON.stringify({      quoteResponse : MyQUOTE,      userPublicKey: wallet.publicKey.toString(),      wrapAndUnwrapSol: false,      prioritizationFeeLamports: {            jitoTipLamports: 10000,          }    })  })).json();

Don't work and return error :

  • TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined from transaction.sign([wallet.payer]);
const swapTransactionBuf = Buffer.from(swapTransaction, 'base64');    var transaction = VersionedTransaction.deserialize(swapTransactionBuf);  const wallet = new Wallet(Keypair.fromSecretKey(bs58.decode('5qHsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXbfDvBf')));  transaction.sign([wallet.payer]);

A simple quote before swap work good but not when changing quote fetched


Viewing all articles
Browse latest Browse all 7881

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>