- 
                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,swapExactTokensForETHorswapTokensForExactTokens
- Grant the router an allowance for the desired token amount(s)
- Call addLiquidityoraddLiquidityETHwith the according ratio defined by the pool
- Ratio can be obtained getAmountsIn
- Call removeLiquidityorremoveLiquidityETH