Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 3.53 KB

File metadata and controls

32 lines (21 loc) · 3.53 KB

iFrame Alternative

Overview

KyberSwap provides an iFrame option for integrators that require swap functionality to be embedded directly into their website or dApp.

{% hint style="success" %}

Note on integrations: clientID and domain whitelisting

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 %}

Parameters

ParamsRequiredDescription
clientIdYesID of the client integrating the iFrame.
chainIdNoThe chainId for the transaction. Full list can be found here.
inputCurrencyYesThe token that the user is selling.
outputCurrencyYesThe token that the user is buying.
featuresNoToken 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.
tabNoToken swap mode to be loaded when iFrame is first loaded.
feeReceiverOptionalAddress to receive fee (if chargeFeeBy is not empty)
feeAmountOptionalFee 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)
isInBpsOptionalIf true, fee is taken in BPS
chargeFeeByOptionalIndicates whether fee is charged by input token currency_in or output token currency_out.

Default is empty whereby no fee is charged.

Adding the iFrame to your site

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"
    />