KyberSwap Aggregator allows users to swap tokens easily at the best rates by aggregating liquidity from different DEXs on the network. Developers integrating KyberSwap also have the option of customising fees, as well as which token they would like to accept the fees in.
In order to integrate KyberSwap's DEX Aggregator Swap into your website, you will be using the @kyberswap/aggregator-sdk. The goal of the SDK is to help you get the data you need to supply to KyberSwap smart contract's Swap function, which is invoked when users swap on your website.
Create and initialize a node directory or use an existing one, then install KyberSwap Aggregator SDK by running
yarn add @kyberswap/aggregator-sdk or
npm install @kyberswap/aggregator-sdk.
Before getting the data from KyberSwap Aggregator SDK, you need to give it parameters like the amount of input token, the minimal amount of output token, and the trade route. To get these parameters, you would need to make a request to KyberSwaps Aggregator API.
To understand how to use the Aggregator API, please visit the following link: https://docs.kyberswap.com/developer-guides/aggregator-api/overview
⚠️ If your site charges the fee in input currency, please call the API with the amount after subtracting fee. eg: If a user wants to swap 0.1 BNB, and your site wants to charge a fee of 0.8% in input currency, then your site should make a request to Aggregator API with an amount that equals 0.1 * (1 - 0.8%) = 0.0992 BNB.
Exchanges aggregated on each Network
- uniswap (v2)
- uniswap (v3)
- curve (3pool, aave, saave, hbtc, ren, sbtc, eurs, link)
- uniswap (v3)
- vvs finance
- valleyswap (v2)