KyberSwap provides an iFrame option for integrators that require swap functionality to be embedded directly into their website or dApp.
{% hint style="success" %}
In order to ensure the security of user's fund when interacting with the KyberSwap iFrame, KyberSwap requires integrator domains to be whitelisted. By doing so, integrators can protect their users from cross-domain attacks.
Please contact our Head of BD [email protected]
, if you would like to get your domain whitelisted. Upon whitelisting, you will then be provided with the base domain for iFrame integration.
To accompany the domain, KyberSwap also implements a clientId
field that enables us to continuously improve the KyberSwap Widget by understanding how swaps are being utilized. As a developer integrating with our widget, please add your clientID (i.e. company name) to the clientId
field to enable us to serve you better.
{% endhint %}
Params | Required | Description |
---|---|---|
clientId | Yes | ID of the client integrating the iFrame. |
chainId | No | The chainId for the transaction. Full list can be found here. |
inputCurrency | Yes | The token that the user is selling. |
outputCurrency | Yes | The token that the user is buying. |
features | No | Token swap mode(s) to enable in iFrame. Separated by , .swap : Market order facilitated by the KyberSwap Aggregator.limit : Limit order facilitated by KyberSwap Limit Order.cross-chain : Cross-chain swaps facilitated by Squid and KyberSwap. |
tab | No | Token swap mode to be loaded when iFrame is first loaded. |
feeReceiver | Optional | Address to receive fee (if chargeFeeBy is not empty) |
feeAmount | Optional | Fee amount to be collected If isInBps = true , feeAmount is the % of fees that we will take with base unit = 10000 (i.e. feeAmount = 10 and isInBps = true then fee = 0.1%)If isInBps = false , feeAmount is the amount of tokens that we will take as fees (i.e. feeAmount =10 and isInBps = false then fee = 10 wei) |
isInBps | Optional | If true, fee is taken in BPS |
chargeFeeBy | Optional | Indicates whether fee is charged by input token currency_in or output token currency_out . Default is empty whereby no fee is charged. |
Sample code:
<iframe
style={{ margin: 'auto' }}
width="500px"
height="900px"
src="{customDomain}?clientId={yourClientId}&tab=swap&inputCurrency=ETH&outputCurrency=0xe4DDDfe67E7164b0FE14E218d80dC4C08eDC01cB&isInBps=1&chargeFeeBy=currency_in&feeReceiver=0xDcFCD5dD752492b95ac8C1964C83F992e7e39FA9&feeAmount=500&chainId=42161"
/>