add maxAccounts=50 to Jupiter swaps to limit txn size

This commit is contained in:
Lou-Kamades 2023-10-23 09:46:21 -05:00
parent 1c4de6fac9
commit 4cd0a70d0b
2 changed files with 3 additions and 0 deletions

View File

@ -151,6 +151,7 @@ export const fetchJupiterTransaction = async (
// This is the ATA account for the output token where the fee will be sent to. If you are swapping from SOL->USDC then this would be the USDC ATA you want to collect the fee. // This is the ATA account for the output token where the fee will be sent to. If you are swapping from SOL->USDC then this would be the USDC ATA you want to collect the fee.
// feeAccount: 'fee_account_public_key', // feeAccount: 'fee_account_public_key',
slippageBps: Math.ceil(slippage * 100), slippageBps: Math.ceil(slippage * 100),
maxAccounts: 50
}), }),
}) })
).json() ).json()

View File

@ -30,6 +30,7 @@ const fetchJupiterRoute = async (
swapMode = 'ExactIn', swapMode = 'ExactIn',
feeBps = 0, feeBps = 0,
onlyDirectRoutes = true, onlyDirectRoutes = true,
maxAccounts = 50
) => { ) => {
{ {
const paramsString = new URLSearchParams({ const paramsString = new URLSearchParams({
@ -38,6 +39,7 @@ const fetchJupiterRoute = async (
amount: amount.toString(), amount: amount.toString(),
slippageBps: Math.ceil(slippage * 100).toString(), slippageBps: Math.ceil(slippage * 100).toString(),
pfeeBps: feeBps.toString(), pfeeBps: feeBps.toString(),
maxAccounts: maxAccounts.toString(),
swapMode, swapMode,
onlyDirectRoutes: `${onlyDirectRoutes}`, onlyDirectRoutes: `${onlyDirectRoutes}`,
}).toString() }).toString()