AMM Math
Last updated
If you have absolutely no background on this topic, the above video would be useful to set the stage.
Else for quick reference:
The trick is to identify if we are calculating for the increasing or decreasing asset
In the wild reference; buyQuote, sellQuote: https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L699