-
Notifications
You must be signed in to change notification settings - Fork 4
Technical Steps
Keno Dressel edited this page Nov 18, 2021
·
9 revisions
- Select ExactIn or ExactOut (depends on which number the user entered and which number is calculated)
- Find all existing pairs by search for direct T1<-->T2 trades or via defined base pairs (eg. T1 --> WETH + WETH --> T2)
- Search all existing trade pairs for a path via the sdk with a maximum of 3 total trades
- the sdk maps the trade request from the interface to actual contract calls in the router
A very condensed example can be seen here: https://github.com/jklepatch/eattheblocks/blob/master/screencast/217-uniswap-v2/javascript/index.js
- Select ExactIn or ExactOut (depends on which number the user entered and which number is calculated)
- Check if there is a pair that maps this exact trade
- Execute trade directly via
swapExactETHForTokens
,swapExactTokensForETH
orswapTokensForExactTokens
- Grant the router an allowance for the desired token amount(s)
- Call
addLiquidity
oraddLiquidityETH
with the according ratio defined by the pool - Ratio can be obtained
getAmountsIn
- Call
removeLiquidity
orremoveLiquidityETH