flashbots / flashbots/simple-blind-arbitrage
what is the math formula behind getAmountIn ?
- Dominant language
- Solidity
- Stars
- 385
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
I am struggling to figure out how can we deduce the formula used in `getAmountIn`. Basically here if we want to maximize our profit those two pools must have almost the same price at final stage. Hence we have:
```
(x1 + delta_x1) / (y1 - delta_y1) = (x2 - delta_x2) / (y2 + delta_y1)
```
Also we know how the pair pool is updating accordingly after swap:
```
(x1 + 0.997 * delta_x1) (y1 - delta_y1) = x1y1
(x2 - delta_x2)(y2 + 0.997 * delta_y1) = x2y2
```
Based on equations mentioned above, i just have no clue how can i simplify it to the formula in the code. Do i miss anything here ?
https://github.com/flashbots/simple-blind-arbitrage/blob/62582059a26f3852949e71a49821ee3c613f2f27/src/blindBackrun.sol#L83
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.