Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 3.82 KB

integrating-the-kyberswap-liquidity-widget.md

File metadata and controls

70 lines (51 loc) · 3.82 KB
description
Zap into a Liquidity Protocol With Minimal Code

Integrating The KyberSwap Liquidity Widget

Installing the Liquidity Widget

To get started, install the widgets library using npm or Yarn.

{% embed url="https://www.npmjs.com/package/@kyberswap/liquidity-widgets" %}

npm:

npm i @kyberswap/widgets

Yarn:

yarn add @kyberswap/widgets

Adding the Liquidity widget to your app

Embed the React component in your application with this piece of code:

import { LiquidityWidget } from "@kyberswap/liquidity-widgets";

<LiquidityWidget
  theme={{
    text: "#FFFFFF",
    subText: "#B6AECF",
    icons: "#a9a9a9",
    layer1: "#27262C",
    dialog: "#27262C",
    layer2: "#363046",
    stroke: "#363046",
    chartRange: "#5DC5D2",
    chartArea: "#457F89",
    accent: "#5DC5D2",
    warning: "#F4B452",
    error: "#FF5353",
    success: "#189470",
    fontFamily: "Kanit, Sans-serif",
    borderRadius: "20px",
    buttonRadius: "16px",
    boxShadow: "0px 4px 4px rgba(0, 0, 0, 0.04)",
  }}
  provider={ethersProvider}
  chainId={56}
  poolType={PoolType.DEX_PANCAKESWAPV3}
  poolAddress="0x36696169c63e42cd08ce11f5deebbcebae652050"
  onDismiss={() => {
    console.log("Dismiss");
  }}
  source="zap-widget-demo"
/>

Liquidity Widget Props

PropertyDescriptionTypeDefault Value
themeCustomize theme for Liquidity WidgetThemedefaultTheme
providerWeb3Provider to interact with blockchainWeb3Provider | undefinedundefined
chainIdRequired. A unique identifier that represents a blockchain network. number--
poolAddressRequired. SmartContract address of poolAddress--
poolTypeRequired. Type of Poolenum

  • DEX_UNISWAPV3
  • DEX_PANCAKESWAPV3
positionIdOptional, in case “Increasing Liquidity into an existing position”, pass the position id. The position should belong to the poolAddress. Otherwise, it considers as “Adding Liquidity into a new position”String | undefinedundefined
sourceRequired. To identify the dapp that integrating with liquidity widgetstring--
feeAddressOptional, Wallet Address if you want to charge zap feeAddress--
feePcmfee percentage in per cent mille (0.001% or 1 in 100,000). Ignored if feeAddress is empty. From 0 to 100,000 inclusively. Example: 1 for 0.001%.number--
includedSourcesList of liquidty sources you want to includes from your zap, separate by commaKyberSwap Aggregator Dex ID--
excludedSourcesList of liquidity sources that you want to exclude from your zap, separate by commaKyberSwap Aggregator Dex ID--
onDismissCallback function when click cancel or close widget() => void--
onTxSubmitCallback function when tx was submited (txHash: string) => void--