KLAYswap
한국어
한국어
  • 소개
  • 프로토콜 개요
  • 핵심 개념
  • 클레이스왑의 장점
  • 위험 & 보안
  • 개인정보처리방침
  • 보안 감사
  • Tokenomics
    • KSP
      • KSP Tokenomics
      • KSP 분배율 자동화
        • 거버넌스 통과 투표 정책
        • KSP 분배율 반영 정책
      • KSP Allocation
  • Product
    • 스왑
    • 단일 예치
      • 단일예치 상세정책
    • 일반 페어 예치(V2)
    • 집중화 페어 예치(V3)
      • V2 to V3 마이그레이션
        • V2 to V3 마이그레이션 가이드
        • V2 to V3 마이그레이션 상세 정책
      • 집중화 페어 풀(V3) 예치
        • 집중화 페어 예치(V3) 가이드
        • 집중화 페어 예치(V3) 상세 정책
      • V3 to V3 마이그레이션
        • V3 to V3 마이그레이션 가이드
        • V3 to V3 마이그레이션 상세 정책
      • 집중화 페어 예치(V3) 출금
        • 집중화 풀(V3) 출금 가이드
        • 집중화 풀(V3) 출금 상세 정책
    • 플러스 예치
      • 플러스 예치 상세 정책
    • 롱/숏 포지션 예치
      • 롱/숏 포지션 오픈과 종료
        • 롱 포지션 오픈
        • 숏 포지션 오픈
        • 롱 포지션 종료
        • 숏 포지션 종료
      • 포지션 예치 상세 정책
    • KSP 스테이킹 & 보팅
      • 스테이킹, 풀 투표 정책
    • 거버넌스
      • 거버넌스 투표 정책
    • Drops(드랍스)
    • Ecopot(에코팟)
    • 풀에어드랍
    • APR & APY
      • TVL
      • Pool
      • Staking
    • 이자율 모델
  • 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
      • Airdrop Operator 권한 획득
      • Airdrop 계획 진행
    • EcoPot
      • EcoPot Operator 권한 획득
      • EcoPot 계획 진행
  • HOW-TO GUIDES
    • 클레이스왑 가이드
    • 서비스에 연결하기
      • [클립] PC에서 연결하기
      • [클립] 모바일에서 연결하기
      • [카이카스] PC에서 연결하기
    • 활용할 자산 입금하기
      • 클레이튼 자산 입금하기
      • 이더리움/BSC 자산 입금하기
      • 리플 자산 입금하기
    • 풀에 예치하기
      • [클립] PC에서 단일 예치하기
      • [부리또월렛] 모바일에서 단일 예치하기
      • [클립] PC에서 일반 페어 예치 하기
      • [클립] 모바일에서 일반 페어 예치 하기
      • [카이카스] PC에서 일반 페어 예치하기
      • [클립] PC에서 플러스 페어 예치하기
      • [공통] 활용할 자산 선택하기
    • 풀에서 출금하기
      • [클립] PC에서 단일 예치출금하기
      • [클립] PC에서 플러스 예치 출금하기
    • KSP 스테이킹 & 풀 투표하기
      • [클립] PC에서 KSP 스테이킹 하기
      • [클립] 모바일에서 KSP 스테이킹 하기
      • [카이카스] PC에서 KSP 스테이킹 하기
      • [클립] PC에서 풀 투표 하기
      • [클립] 모바일에서 풀 투표 하기
      • [카이카스] PC에서 풀 투표 하기
    • 보상 수령하기
    • FAQ
      • 클레이스왑은 어떤 서비스인가요?
      • 클레이(KLAY) & 클레이스왑(KSP)은 무엇인가요?
      • 유동성 풀(Liquidity pool)이 무엇인가요?
      • 유동성 풀의 예치방법, 특징이 무엇인가요?
      • 왜 클레이스왑에서 예치해야 하나요?
      • 획득한 보상은 어떻게 활용하나요?
  • KLAYswap
  • Orbit Bridge
  • KLAYswap git
  • Orbit Bridge git
  • KLAYswap audit report
Powered by GitBook
On this page
  • Code
  • Address
  • Events, Read-Only Functions, and State-Changing Functions

Was this helpful?

  1. Developers
  2. Contract

Exchange

This is a smart contract to expand KIP7 that is created with every liquidity pair. The Factory deploys this as new pool creation is requested. Although the Factory actually stores the two tokens of a pair and swapping takes place through it, the Exchange Contract must be called for liquidity to be provided or taken.

Code

Github Link: (Will be updated after official launch)

Address

Contract adress after production is deployed (scope link)

Events, Read-Only Functions, and State-Changing Functions

Events

Transfer

event Transfer(address indexed from, address indexed to, uint amount);
  • KIP7 Standard

  • Event log of Transfer/Mint/Burn

Approval

event Approval(address indexed holder, address indexed spender, uint amount);
  • KIP7 Standard

  • Event log of Approvals

ChangeMiningRate

event ChangeMiningRate(uint _mining);
  • Event log of mining rate change

ChangeFee

event ChangeFee(uint _fee);
  • Event log of trading fee rate changes

UpdateMiningIndex

event UpdateMiningIndex(uint lastMined, uint miningIndex);
  • Event log of pairs’ mining index changes

  • lastMined : Factory.mined() value at the time index is updated

  • miningIndex : pairs’ miningIndex value at the time

GiveReward

event GiveReward(address user, uint amount, uint lastIndex, uint rewardSum);
  • Event log of when mined KSP is claimed and distributed

  • user : address of the user who claimed

  • amount : the amount of KSP claimed

  • lastIndex : index result of the pair of the wallet after claiming

  • rewardSum : The amount of KSP that has been accrued so far

ExchangePos

event ExchangePos(address tokenA, uint amountA, address tokenB, uint amountB);
  • Event log of POS transactions

  • tokenA : Token address delivered by the user

  • amountA : the amount of tokens delivered by the user

  • tokenB : token address received by user

  • amountB : the amount of tokens received by the user

ExchangeNeg

event ExchangeNeg(address tokenA, uint amountA, address tokenB, uint amountB);
  • Event log of NEG transactions

  • tokenA : token address delivered by the user

  • amountA : the amount of tokens delivered by the user

  • tokenB : token address received by the user

  • amountB : the amount of tokens received by the user

AddLiquidity

event AddLiquidity(address user, address tokenA, uint amountA, address tokenB, uint amountB, uint liquidity);
  • Event log of liquidity additions

  • liquidity : the amount of LP tokens minted due to additional liquidity

RemoveLiquidity

event RemoveLiquidity(address user, address tokenA, uint amountA, address tokenB, uint amountB, uint liquidity);
  • Event log of liquidity removals

  • liquidity : the amount of LP tokens burned due to liquidity removal

Read-Only Functions

name

  • KlaySwap LP

symbol

  • "KSLP" + " " + symbolA + "-" + symbolB

decimals

  • 18

totalSupply

  • mint/burn depending on liquidity addition/removal

balanceOf

  • Number of LP tokens held by each address

allowance

  • Status of approval to spender for each address

factory

  • The factory address where the LP smart contract is deployed

tokenA

  • The first token address composed of the pair

  • When KLAY is one part of the pair, tokenA == 0x0

tokenB

  • The second token address composed of the pair

fee

  • Transaction fee for the pair

  • It is a value between 0 and 100, in units of 0.01%

  • 1 == 0.01%, 100 == 1%

mining

  • The mining rate of the pair

  • It is a value between 0 and 100, in units of 1%

  • e.g. If mining is 10, the pair has claim authority for 10% of the quantity mined per block in the factory.

lastMined

  • Factory.mined() value at the last time the pair updated the index

userRewardSum

  • mapping(address => uint )

  • Stores the cumulatively claimed KSP quantity value for each user

getCurrentPool

function getCurrentPool() public view returns (uint, uint)
  • Returns the liquidity quantity of the two assets in the current pool

estimatePos

function estimatePos(address token, uint amount) public view returns (uint)
  • When a request is made to sell the amount of the corresponding token through a POS transaction, the expected receiving amount of the opposite token is returned.

estimateNeg

function estimateNeg(address token, uint amount) public view returns (uint)
  • When a request is made to purchase the amount of the corresponding token through a NEG transaction, the expected payment amount of the opposite token is returned.

State-Changing Functions

transfer

function transfer(address _to, uint _value) public returns (bool)
  • KIP7 Standard

  • Method for KSP token transfer

transferFrom

function transferFrom(address _from, address _to, uint _value) public returns (bool)
  • KIP7 Standard

  • Method to transfer tokens on behalf of the approved wallet

approve

function approve(address _spender, uint _value) public returns (bool)
  • KIP7 Standard

  • Method to approve transfer as much as value to the spender

updateMiningIndex

function updateMiningIndex() public
  • Method to update the value of the pair contract based on the current Factory.mined() value

  • Anyone can call in real time. Even if no one calls it, it calls itself if necessary.

claimReward

function claimReward() public
  • Method that a user calls to claim the claimable KSP that has accumulated for the pair

  • When called, KSP is claimed from the Factory and paid to msg.sender

  • Even if the method is not called directly, it is automatically called when the LP token balance of the user’s wallet changes.

    • When liquidity is added

    • When liquidity is removed

    • When LP tokens are sent

    • When LP tokens are received

addKlayLiquidity

function addKlayLiquidity(uint amount) public payable
  • Method used to provide liquidity when tokenA is KLAY

  • Liquidity of the KLAY msg.value and tokenB amount is provided.

  • After liquidity is provided, the LP token corresponding to the pool share is minted in the msg.sender wallet.

  • If the pair ratio is wrong, as much liquidity as possible is supplied at the current pair ratio, and the remaining tokens are returned to msg.sender.

  • If there is claimable KSP when called, the claim proceeds to msg.sender.

addKlayLiquidityWithLimit

function addKlayLiquidityWithLimit(uint amount, uint minAmountA, uint minAmountB) public payable
  • Method used to provide liquidity when tokenA is KLAY

  • Liquidity of the KLAY msg.value and tokenB amount is provided.

  • Set the minimum amount of tokenA and tokenB to be used for liquidity supply using minAmountA, minAmountB.

  • After liquidity is provided, the LP token corresponding to the pool share is minted in the msg.sender wallet.

  • If the pair ratio is wrong, as much liquidity as possible is supplied at the current pair ratio, and the remaining tokens are returned to msg.sender.

  • If there is claimable KSP when called, the claim proceeds to msg.sender.

addKctLiquidity

function addKctLiquidity(uint amountA, uint amountB) public
  • Method used to provide liquidity when tokenA is KIP7 standard token

  • Liquidity of the number of tokenA amountA and tokenB amountB is provided.

  • After liquidity is provided, the LP token corresponding to the pool share is minted in the msg.sender wallet.

  • If the pair ratio is wrong, as much liquidity as possible is supplied at the current pair ratio, and the remaining tokens are returned to msg.sender.

  • If there is claimable KSP when called, the claim proceeds to msg.sender.

addKctLiquidityWithLimit

function addKctLiquidityWithLimit(uint amountA, uint amountB, uint minAmountA, uint minAmountB) public
  • Method used to provide liquidity when tokenA is KIP7 standard token

  • Liquidity of the number of tokenA amountA and tokenB amountB is provided.

  • Set the minimum amount of tokenA and tokenB to be used for liquidity supply using minAmountA, minAmountB.

  • After liquidity is provided, the LP token corresponding to the pool share is minted in the msg.sender wallet.

  • If the pair ratio is wrong, as much liquidity as possible is supplied at the current pair ratio, and the remaining tokens are returned to msg.sender.

  • If there is claimable KSP when called, the claim proceeds to msg.sender.

removeLiquidity

function removeLiquidity(uint amount) public
  • Returns the amount of LP tokens, and distributes the corresponding tokenA and tokenB to the msg.sender wallet

  • The returned LP token amount is burned

  • If there is claimable KSP when called, the claim proceeds to msg.sender.

removeLiquidityWithLimit

function removeLiquidityWithLimit(uint amount, uint minAmountA, uint minAmountB) public
  • Returns the amount of LP tokens, and distributes the corresponding tokenA and tokenB to the msg.sender wallet

  • Set the minimum amount for the returned tokenA and tokenB amounts by using minAmountA, minAmountB.

  • The returned LP token amount is burned

  • If there is claimable KSP when called, the claim proceeds to msg.sender.

PreviousFactoryNextPoolVoting

Last updated 2 years ago

Was this helpful?