Modeling Uniswap in cadCAD

We are working on a cadCAD model of Uniswap and using the same data I decided to plot a few charts to illustrate how bonding curves in action. Here’s “Visualizing bonding curves: the Uniswap case” :slight_smile:


download

Left chart
DAI and ETH balances of the Uniswap smart contract move along the curve. The area of the green rectangle is constant with every move, except fees make the curve move up and to the right a little bit with each trade. The curve moves more - up or down, but always along the same diagonal - when liquidity is added to or removed from the pool (= UNI mints/burns, upper-right chart).

Both of these conservations - the area and the diagonal - are somewhat approximated in the video because we are looking at aggregated daily activity, not individual transactions.

Middle-right chart
How 3 different strategies performed over time since the first day Uniswap was live. It hints at the effects of impermanent loss, eg. until Dec-16 liquidity providers had performed worse than “50/50 hodlers”.

Bottom-right chart
My take on adding another dimension to the excellent analysis done here. It shows how liquidity providers fared compared to 50/50 holders depending on the initial date of the comparison. It confirms the intuition that because ETH/DAI has been going mostly sideways in the past year or so, with sudden spikes and drops here and there, impermanent loss is frequent but doesn’t last long.

Next steps
The cadCAD model is in our GitHub. Some cool next steps would be to model actual user behavior (so far we’ve merely mapped actual events to simplified action models for backtesting the mechanisms implementation), so that we can simulate some interesting “what if” scenarios (what if fees where higher/lower/dynamic? what if ETH skyrocketed or plummeted? …) . If you want to help, reply to this thread and we’ll coordinate.

You can find the data and the code for this analysis on this Kaggle notebook

3 Likes