Mellow backtesting SDK & datasets

New Challenges

  • Transaction costs (even though gas prices in 2022 fell compared to 2021, it is imperative to consider gas costs and other losses when making transactions)
  • In distributed and open networks, the behavior of the system and the experience of using the software is determined not only by the strategist. There are a lot of different effects that should be taken into account while building a strategy: other participants’ actions, hacker attacks, and market manipulations (JIT attacks, flash loan attacks, etc.)
  • It is necessary to reproduce invariants and other algorithm parts that are often used in existing DeFi protocols (with the growth of Uniswap seems everyone knows x*y=k)

Mellow SDK

Use cases

  • LP-ing to Uniswap V2
  • Passive LP-ing to Uniswap V3
  • Active LP-ing to Uniswap V3

LPing to Uniswap V2

LPing to Uniswap V3

Active LPing in Uniswap V3

How to work with SDK


python3 -m venv .venv
source .venv/bin/activate
pip install mellow_strategy_sdk

Choose WBTC/WETH 0.3% pool

pool_num = 1
pool = Pool(

Download data

data = RawDataUniV3(pool=pool, data_dir='data').load_from_folder()

Use standard strategy

  • Hold — buy & hold strategy
  • UniV3Passive — mint to specified interval&wait
  • StrategyByAddress — backtests actions in the pool at the wallet address
v2_strat = UniV3Passive(


bt = Backtest(strategy=v2_strat)
portfolio_history, rebalance_history, uni_history = bt.backtest(df=data.swaps)

The Grand Plan



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store