Uniswap is a fully decentralized protocol for automated liquidity provision on Ethereum.
About This Model
This model, built in HASH, simulates the Uniswap protocol and evaluates arbitrage between two balancer pools and the gains / potential impermanent loss
You can read the HASH blog post about this model at hash.ai/blog/uniswap and https://hash.ai/blog/extending-the-uniswap-simulation.
The model comprises four types of agents:
- Two automated market makers running the uniswap protocol
- An arbitrage agent that compares the price between the automated market maker. The agent arbitrages any differences.
- A liquidity providing agent that adds liquidity to a pool and later removes it.
Running the model
With the default parameters I suggest stepping through the model to observe the price changes from steps 1-50. All the action happens in the plots tab (select it in the top right). It demonstrates price equalizing due to arbitrageur actions and gains to the liquidity provider. Then experiment with different fee/initial token allocations.
"ts_deposit_liquidity" <int>: timestep that the liquidity provider deposits liquidity "ts_reclaim_liquidity" <int>: timestep that the liquidity provider burns ls shares and receives tokens from uniswap "amm_fees" <float>: trading fees that the amm takes on each trade "amm_init_a" <float>: initial token reserve a for amm "amm_init_b" <float>: initial token reserve b for amm "amm_two_init_a" <float>: initial token reserve a for amm_two "amm_two_init_b" <float>: initial token reserve b for amm_two ... (can be multiple amms) "fee_limit" <float>: if arb is less than this limit, wont execute "steps" <int>: number of steps to run simulation
The simulation, and experiments, explores a few different concepts:
- how different fee regimes can benefit/hurt liquidity providers by capturing more money for the token reserves at the expense of reducing the overall
- A bit of a "rug pull" when the liquidity provider removes its deposit from the AMM