CarmineOptions / derisk-research

MIT License
4 stars 14 forks source link

ODHack: Compute available liquidity at StarkNets Uniswap V2 AMMs for any given token at any given price level #97

Closed lukaspetrasek closed 1 month ago

lukaspetrasek commented 2 months ago

"Compute available liquidity at Starknets Uniswap V2 AMMs for any given token at any given price level.

Let's choose, for example, the STRK-USDC pair and assume the current price is 2 USDC per 1 STRK. We're interested in the amounts of USDC that we'll be able to swap for STRK at Haiko while not pushing the price by more than 5% in a scenario where the STRK price falls to, e.g., 1.9 USDC, 1.8 USDC, ... 1 USDC, etc.

In order to achieve this, we want to transform the AMM liquidity into an orderbook-like structure, i.e. bids: [(price_0, quantity_0), (price_1, quantity_1), ...] and asks: [(price_0, quantity_0), (price_1, quantity_1), ...].

Steps: 1) Get data for MySwap, JediSwap, 10KSwap and SithSwap pools. Feel free to add more AMMs. 2) Transform the data to an orderbook-like structure. 3) Save the data in a database. 4) Load the stored data and for any given price (use price as a parameter), compute how much of the token A (parameter) can be swapped for token B (parameter) while not pushing the price further by more than 5% (parameter)."

Definition of Done The code functions well, is documented and tested. The transformation is correct. The transformed data is being saved in a database.

vibenedict commented 2 months ago

Hi, can i jump on this issue

Teri-anric commented 2 months ago

Hi, Iā€™m interested in this task, I have experience in this area and I worked on the same task before but with different AMM. As an implementation, I will transform data to order book structure and save it to db.

lukaspetrasek commented 2 months ago

Hi, assigning @Teri-anric , because this task is complex and they provided a better description of the approach.

@Teri-anric Let me know if everything is clear and whether you'll be working on the issue. If you have any questions, please ask here. Since this task is quite complex, we can even schedule an introductory call. What is you TG handler please? šŸ™šŸ¼

Consider joining our TG group. See also our contributor guidelines.

lukaspetrasek commented 2 months ago

@Teri-anric Check out the current implementation here: https://github.com/CarmineOptions/derisk-research/blob/master/src/swap_amm.py#L369 for hints on where to get data.