uni-sushi-flashloaner icon indicating copy to clipboard operation
uni-sushi-flashloaner copied to clipboard

question: shouldTrade?

Open frankandrobot opened this issue 2 years ago • 0 comments

Struggling to understand this comparison:

      const shouldTrade = spread > (
        (shouldStartEth ? ETH_TRADE : DAI_TRADE)
         / Number(
           ethers.utils.formatEther(uniswapReserves[shouldStartEth ? 1 : 0]),
         ));

It seems that we should trade when the ratio of the ETH_TRADE (or DAI_TRADE) in to the reserve in uniswap is less than the spread. That is,

  • spread = ratio of price difference
  • shouldTrade = ratio of price difference > ratio of ETH_TRADE / uniswap ETH reserve

Why is this comparison necessary?

frankandrobot avatar Jun 16 '22 05:06 frankandrobot