📖
KLAYLibrary
  • Welcome to KLAYLibrary
    • 수수료
    • 용어 설명
  • Features
    • Fully Decentralized
    • 자동화된 유동성 공급자
    • Referral Program
    • Flash Settlement
  • Tokenomics
    • Rationale
    • Overview
    • Rules
      • FAQ
    • Initial Launch Plan
  • Use Guides
    • 주문 하기
      • 지정가 주문
      • 시장가 주문
      • 지정가 주문의 옵션
    • 수동 Claim
    • 인센티브 수령
  • Trading Pairs
    • Tick Size
  • Contracts
    • Library
    • OrderBookViewer
    • TradeRecorder
  • Disclaimer
    • 위험 및 보안
    • 이용 약관
  • Contact Us
  • Link
    • KLAYLibrary
Powered by GitBook
On this page
  1. Features

Flash Settlement

무자본으로 수익을 창출할 수 있는 전략

PreviousReferral ProgramNextTokenomics

Last updated 1 year ago

외부 트랜잭션에 의해 동작하는 블록체인의 특성 상 가격이 크게 변동할 때, 매도 주문과 매수 주문이 겹치는 예외 상황이 발생할 수 있습니다. 이런 경우, flash settlement을 실행하여 사용자는 네트워크의 가스비만을 부담하고 자본 없이 매수 및 매도 주문을 실행하여 차액을 이익으로 얻을 수 있습니다. 이는 빠르게 변동하는 시장에서 유용한 전략 중 하나로 활용될 수 있습니다.

아래 상황에서는 KLAY의 가격이 급등하여 ALP가 제시한 매수 호가 아래에 매도 주문이 걸려 있습니다. 이런 경우, flash settlement을 실행하여 무자본 상태에서 차익 거래를 진행할 수 있습니다.

가격
수량
Flash Settlement 시 차익
수수료

0.1703

0.02

(0.1825-0.1703)*0.02

매수, 매도 taker fee

0.1702

0.01

(0.1825-0.1702)*0.01

매수, 매도 taker fee

0.1701

0.0.1

(0.1825-0.1701)*0.01

매수, 매도 taker fee

단, 차익이 지불하는 수수료와 가스비보다 더 큰 이득을 가져다주는지를 신중히 판단한 후에 실행해야 합니다.

예제) Hardhat 프레임워크를 이용한 flash settlement

const ethers = require('ethers') 

abi =[
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "id",
          "type": "uint256"
        }
      ],
      "name": "estimateFSProfit",
      "outputs": [
        {
          "internalType": "address",
          "name": "token",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "amount",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "uint256",
          "name": "id",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "allowanceRatio6",
          "type": "uint256"
        }
      ],
      "name": "flashSettlement",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }
]

const contractAddress = '0x...';
library = await ethers.getContractAt(abi, contractAddress);

id = 0
ratio = 5e5

const profitEstimation = await library.estimateFSProfit(id);
console.log(profitEstimation);

// An amount considered to be large enough to compensate the gas consumption
const compensationThreshold = 0;


if (profitEstimation[1] > minProfitThreshold) {
  await library.flashSettlement(id, ratio);
}