Discord
@b/uniswap
Simulation
41
1
Public

Uniswap Protocol

Exploring the uniswap protocol for automated liquidity provisioning on Ethereum.

About Uniswap

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:

  1. Two automated market makers running the uniswap protocol
  2. An arbitrage agent that compares the price between the automated market maker. The agent arbitrages any differences.
  3. 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.

Global Parameters

"ts_deposit_liquidity" : timestep that the liquidity provider deposits liquidity "ts_reclaim_liquidity" : timestep that the liquidity provider burns ls shares and receives tokens from uniswap "amm_fees" : trading fees that the amm takes on each trade "amm_init_a" : initial token reserve a for amm "amm_init_b" : initial token reserve b for amm "amm_two_init_a" : initial token reserve a for amm_two "amm_two_init_b" : initial token reserve b for amm_two ... (can be multiple amms) "fee_limit" : if arb is less than this limit, wont execute "steps" : number of steps to run simulation

Takeaways

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