KLAYswap
English
English
  • Introduction
  • Protocol Overview
  • Core Concept
  • KLAYswap Advantages
  • Risk & Security
  • Privacy Policy
  • Audit
  • TOKENOMICS
    • KSP
      • KSP TOKENOMICS
      • Automation of KSP distribution rate
        • Voting policy on passing governance
        • KSP distribution ratio reflection policy
      • KSP Allocation
  • PRODUCT
    • SWAP
    • Single-side Deposit
      • Detailed policy of Single Deposit
    • Pair Deposit
    • V3 Pair Deposit
      • V2 to V3 Migration
        • V2 to V3 Migration Guide
        • V2 to V3 Migration Policy
      • V3 Pair Deposit
        • V3 Deposit Guide
        • V3 pair Deposit Policy
      • V3 to V3 Migration
        • V3 to V3 Migration Guide
        • V3 to V3 Migration Policy
      • V3 Pair Withdraw
        • V3 Withdraw Guide
        • V3 Withdraw Policy
    • Plus Deposit
      • Detailed policy of Plus Deposit
    • Long/Short Position Deposit
      • Open and Close Long/Short Positions
        • Open Short Positions
        • Open Long Positions
        • Remove Long Position
        • Remove Short Position
      • Position Deposit Details Policy
    • KSP Staking & Voting
      • Staking, Pool Voting Policy
    • Governance
      • Governance Voting Policy
    • Drops
    • Ecopot
    • Pool Airdrop
    • APR & APY
      • TVL
      • Pool
      • Staking
    • Interest rate
  • DEVELOPERS
    • Contract
      • Factory
      • Exchange
      • PoolVoting
      • VotingKSP
      • Treasury
      • Distribution
      • Governor
      • SinglePool
      • SinglePool Factory
      • PlusPool
      • PlusPool Factory
      • Store
      • Utils
      • Single/Plus Utils
      • Helper
      • EcoPotVoting
      • EcoPot
      • V3
        • V3Factory
        • V3Pool
        • NonfungiblePositionManager
        • NonfungibleTokenPositionDescriptor
        • V3SwapRouter
        • V3Migrator
        • V3Estimator
        • PositionMigrator
        • V3Treasury
        • V3AirdropOperator
        • UniversalRouter
    • Airdrop
      • Set Airdrop Operator
      • Start Airdrop
    • EcoPot
      • Set EcoPot
      • Start EcoPot
  • HOW-TO GUIDES
    • KLAYswap Guide
    • How to add liquidity on KLAYswap
    • [Burrito Wallet] How to deposit assets using mobile devices?
    • How to create a liquidity pool on KLAYswap
    • How to stake and vote on KLAYswap
    • How to deposit assets
      • Deposit Klaytn-based assets
      • Deposit Ethereum-based assets
      • Deposit XRP
    • FAQ
  • KLAYswap
  • Orbit Bridge
  • KLAYswap git
  • Orbit Bridge git
  • KLAYswap audit report
Powered by GitBook
On this page

Was this helpful?

  1. DEVELOPERS
  2. Contract

Utils

PreviousStoreNextSingle/Plus Utils

Last updated 2 years ago

Was this helpful?

This contract can check asset details and swap estimates of KLAYswap service

Address

  • Cypress :

Read-Only Functions

getPoolData

function getPoolData(address lp) public view returns (
        uint miningRate,
        uint rateDecimals,
        address tokenA,
        uint reserveA,
        address tokenB,
        uint reserveB,
        uint airdropCount,
        address[] memory airdropTokens,
        uint[] memory airdropSettings 
    )
  • Amount of TokenA held by LP

  • Airdrop only between startBlock and endBlock of blocks in the network

  • Parameters

    • miningRate : KSP distribution ratio numerator value

    • rateDecimals : KSP distribution ratio denominator

      • 예) Daily KSP distribution ratio

        • miningRate - 130323276365080043, rateDecimals - 10000000000000000

        • 130323276365080043 / 10000000000000000 = 13.03...%

    • tokenA : LP tokenA

    • reserveA : Amount of tokenA held by LP

    • tokenB : LP tokenB

    • reserveB : Amount of tokenB held by LP

    • airdropCount : Number of airdrop plans in progress at LP

    • airdropTokens : Airdrop token address array

    • airdropSettings : Airdrop info array

      • [0]: blockAmount, [1]: startBlock, [2]: endBlock

  • airdropSettings Data format

    • 예) TokenA, TokenB Airdrop

      • airdropTokens = [ TokenA address, TokenB address]

      • airdropSettings = [ TokenA blockAmount, TokenA startBlock, TokenA endBlock, TokenB blockAmount, TokenB startBlock, TokenB endBlock ]

getPendingReward

function getPendingReward(address lp, address user) public view returns ( 
    uint kspReward, 
    uint airdropCount, 
    address[] memory airdropTokens, 
    uint[] memory airdropRewards 
)
  • User's claimable reward information

  • Parameters

    • kspReward : Claimable KSP

    • airdropCount : Number of airdrop plans the LP has

    • airdropTokens : Airdrop token address array

    • airdropRewards : Arrangement of Airdrop token amount Information claimable

  • airdrop data format

    • 예) TokenA, TokenB Airdrop

      • airdropTokens = [ TokenA address, TokenB address]

      • airdropSettings = [ TokenA reward, TokenB reward ]

estimateSwap

function estimateSwap(
    address tokenIn, 
    address tokenOut, 
    uint amountIn, 
    address[] memory path
) public view returns (uint amountOut)
  • KLAYswap swap estimate lookup function

  • Input Parameters

    • tokenIn : Token address to be exchanged

    • tokenOut : Token address to receive

    • amountIn : Token amount to be exchanged

    • path : exchange route

  • example

    • KLAY -> KSP

      • tokenIn = KLAY token address

      • tokenOut = KSP token address

      • amountIn = 1e18 ( = 1 KLAY )

      • path = []

    • KLAY -> ORC -> KSP

      • tokenIn = KLAY token address

      • tokenOut = KSP token address

      • amountIn = 1e18 ( = 1 KLAY )

      • path = ["{ORC token Address}"]

0x7A74B3be679E194E1D6A0C29A343ef8D2a5AC876