raydium-io / raydium-sdk-V2-demo

Open-source Typescript SDK demos
48 stars 31 forks source link

The amm/swap handling fee is too high. When I use https://raydium.io/ it is very low. Is there any way to optimize it? #19

Closed miaoluyao closed 4 months ago

miaoluyao commented 4 months ago

If the priority fee I use is too low, has expired: block height exceeded will appear.(If the computeBudgetConfig parameter is not passed, "has expired: block height exceeded." will also appear.) How should I set a reasonable prioritization fee?

Below is a comparison of the two transactions

raydium.io solscan 0.000022186 SOL

raydium-sdk-V2-demo 0.060005 SOL

cruzshia commented 4 months ago

you can check realtime average fees in here if you want to go through smoothly, better set equal or higher than 'high' level.

image
miaoluyao commented 4 months ago

computeBudgetConfig: { units: 600000, microLamports: 89025, }, Is that so?

cruzshia commented 4 months ago

yes, if it's still too slow, you also can watch avg fees here. note: sol * 10**9 = microlamports https://solanacompass.com/

image
miaoluyao commented 4 months ago

image

const getFeesInfo = async () => { try { const response = await axios.get('https://solanacompass.com/api/fees?cacheFreshTime=' + (5 60 1000)); const json = response.data; const { avg } = json?.[15] ?? {};

if (!avg) {
  return undefined;
}
return Math.ceil(avg);

} catch (error) { console.error('Error fetching fees info:', error); return undefined; } }; const microLamports = await getFeesInfo();

Thanks