4

I am currently using the Raydium SDK to perform token swaps. I use the Percent class from the sdk to create the slippage value which I then use in my transaction, but it seems that this Percent class only accepts whole number...

So as it is now the slippage can only be 1%, 2%, 3%...

Is there another method to rather have decimal slippage values instead of whole numbers?

Here is just an example of the percent object I create, where slippageBps is a number, such that if slippageBps was 5 then it would be 5 percent,

import { Percent } from '@raydium-io/raydium-sdk'
const slippage = new Percent(slippageBps, 100);

1 Answer 1

3

The Percent class works as a fraction and thus if I just increase the denominator the percent values can become more accurate.

const slippage = new Percent(25, 10000);

This would yield a percentage value of 0.25%.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.