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