Warden
Search…
⌃K

Advance Usage

For even more use cases, let's see how to use it here.

Payment Use Case

Assuming you want the buyer to pay with any tokens on BSC, ex. BNB, CAKE. Then your system will swap any token to be the stablecoin (ex. BUSD) for your merchants.
You can request user to swap their token on Warden Best Rate Swap and then send the stablecoin to the merchant, or yourself as a payment gateway by utilizing the last parameter of the swap method. No need for new solidity contract deployment.
const swap = await wardenClient.swap(
srcAddr,
destAddr,
amountIn,
minAmountOut,
quote,
undefined,
undefined,
merchantAccount) // 👈 specify receiver account to receive token after swapped

Understanding Different Swap Type

Warden Best Rate API have 2 types of response for trading depending on the many factors including gas price. getQuote will determine which type is better by including gas fee factor into the calculation.

1. Strategies Type.

Basic type. It selects the best path for the best price.
Sample Response

2. Split Type.

The split type not only selects the best path for the trade, but it also determines other paths that are most appropriate for your overall trading volume. Example for split trades available: 40:60 and 20:80. It generally gives the better rate, but will use more gas. So it is not suitable for a small swap.
Sample response
Note that, even it is not recommended, you can disable the split type by setting enableSplit to false in the options. It could speed up the rate calculation but giving worse rate overall.
const quote = await wardenClient.getQuote(
srcAddr,
destAddr,
amountIn,
gasPrice,
{ enableSplit: false }
)