简体   繁体   中英

What unit does "amountIn" have in UniswapV2Router02 contracts?

I am trying to understand the "getAmountOut"-function in this contract (it's SushiSwaps-router-contract):

https://etherscan.io/address/0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F#readContract

There are 2 parameters:

amountIn (uint256)
path (address[])

Let's say I want to compare WETH to another token. When I enter 1000 in amountIn. What unit are the 1000?

WETH has 18 decimals so would 1000 mean 0.0000000000001000 WETH?

as you can read on that contract

// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset

with that function u can find that

every token have to be declared with all their decimals, so if WETH have 18 decimals, and you want to put 1000 WETH, you need to write 1000000000000000000000

same thing for tokens

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM