function getSwapAmountsIn( uint _amountOut, address[] memory _path) public view virtual returns (uint[] memory amounts)
Swap μ λ°μ μ μλ ν ν° κ°μλ₯Ό λ£μ μ λ³κ²½λμ΄μΌ ν ν ν° κ°μλ₯Ό μ»μ λ μ¬μ©
(TO->FROM)
Parameters
β»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