getSwapAmountsIn


function getSwapAmountsIn(    uint _amountOut,     address[] memory _path) public view virtual returns (uint[] memory amounts)

Swap μ‹œ 받을 수 μžˆλŠ” 토큰 개수λ₯Ό 넣을 μ‹œ λ³€κ²½λ˜μ–΄μ•Ό ν•  토큰 개수λ₯Ό 얻을 λ•Œ μ‚¬μš© 
(TO->FROM)

Parameters

Return Values

β€»Reservesλ₯Ό ν†΅ν•œ μ—°μ‚° 방법
//수수료 μ‚¬μš© μœ λ¬΄μ— 따라 swapFee 지정(30 = 0.03%)uint numerator = (reserveIn*amountOut)*10000;uint denominator = (reserveOut-amountOut)*(10000-swapFee);amountIn = (numerator / denominator)+1;

Example
// swap 토큰 개수 μ–»κΈ°await routerContract.getSwapAmountsIn(    5000    [mockToken0Contract.address, mockToken1Contract.address])// κ²°κ³Ό[ BigNumber { value: "10031" }, BigNumber { value: "5000" } ]

2023.01.02

Last updated