Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

what is the math formula behind getAmountIn ?

Open
#3 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
solidity
Domain
blockchain

Research direction

Start by reading src/blindBackrun.sol at line 83 and compare the getAmountIn formula with the pool-update equations and price-equality condition in the issue. Trace each variable and fee factor, then document the algebraic derivation so the formula's result can be checked against the code.

Written by the indexing model from the issue text.

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

Dominant language
Solidity
Stars
385
Forks
100
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flashbots/simple-blind-arbitrage

All issues in flashbots/simple-blind-arbitrage

Similar issues

More Blockchain issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.