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
  • Code
  • Address
  • Events, Read-Only Functions, and State-Changing Functions

Was this helpful?

  1. DEVELOPERS
  2. Contract
  3. V3

V3Estimator

PreviousV3MigratorNextPositionMigrator

Last updated 1 year ago

Was this helpful?

This contract estimates v3 swap amounts

Code

Github Link: (Will be updated after official launch)

Address

  • Cypress :

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

Read-Only Functions

estimatePos

function estimatePos(
    struct IUniswapV3Pool pool, 
    address token, 
    uint256 amountIn
) external view returns (
    uint256 amountOut, 
    uint160 sqrtPriceX96After
)

Parameters:

Name
Type
Description

pool

contract IUniswapV3Pool

The address of the pool

token

address

The token being swapped in

amountIn

uint256

The desired input amount

Return Values:

Name
Type
Description

amountOut

uint256

The amount of the token that would be received

sqrtPriceX96After

uint160

The sqrt price after the swap

estimateNeg

function estimateNeg(
    contract IUniswapV3Pool pool, 
    address token, 
    uint256 amountOut
) external view returns (
    uint256 amountIn, 
    uint160 sqrtPriceX96After
)

Parameters:

Name
Type
Description

pool

contract IUniswapV3Pool

The address of the pool

token

address

The token being swapped out

amountOut

uint256

The desired output amount

Name
Type
Description

amountIn

uint256

The amount required as the input for the swap in order to receive amountOut

sqrtPriceX96After

uint160

The sqrt price after the swap

estimate

function estimate(
    contract IUniswapV3Pool pool,
    bool zeroForOne,
    int256 amountSpecified
) public view returns (int256 amount0, int256 amount1, uint160 sqrtPriceX96After) {

Parameters:

Name
Type
Description

pool

contract IUniswapV3Pool

The address of the pool

zeroForOne

bool

Is swap direction 0 -> 1?

amountSpecified

int256

The specified amount of token

Name
Type
Description

amount0

int256

The changed amount of token0

amount1

int256

The changed amount of token1

sqrtPriceX96After

uint160

The sqrt price after the swap

Return Values:

Return Values:

0x09067f1b4E1a1CD08C91519D811F3D04c69a5a5f
​
​
​
​