getLiquidityPair

function getLiquidityPair(
    address _tokenA,
    address _tokenB,
    uint256 _amountIn
) external view returns (
    uint256 amountA,
    uint256 amountB
)

νŽ˜μ–΄ 토큰을 톡해 각 ν† ν°μ˜ λΉ„μœ¨μ„ 얻을 λ•Œ μ‚¬μš©(νŽ˜μ–΄μŠ€ν…Œμ΄ν‚Ή)

Parameters

TypeValueDescription

address

_tokenA

LP 토큰A μ£Όμ†Œ

address

_tokenB

LP 토큰B μ£Όμ†Œ

uint256

_amountIn

μ–»μœΌλ €λŠ” μˆ˜λŸ‰

Return Values

TypeValueDescription

uint256

amountA

tokenA의 개수

uint256

amountB

tokenB의 개수

β€»Reservesλ₯Ό ν†΅ν•œ μ—°μ‚° 방법

uint amountB = (amountA*reserveB) / reserveA;

Example

// μœ λ™μ„±ν’€μ„ ν†΅ν•œ 토큰 개수 μ–»κΈ°
await ComputeContract.connect(accounts[0]).getLiquidityPair(
    mockToken0Contract.address,
    mockToken1Contract.address,
    1000000
)

// κ²°κ³Ό (토큰A, 토큰B 개수)
[ BigNumber { value: "1000000" }, BigNumber { value: "500000" } ]

2023.01.11

Last updated