Simple Tree Simulation
Since there are some subtle nuances to consider when thinking about Liquidity Trees, for educational purposes, we simplify the configuration. This is so we can clearly demonstrate the underpinning principles on how liquidity trees work and how they generate returns. Thus, we will be: (a) using a Simple Tree; (b) using stablecoins (ie, USDC and USDT) to control for impermanent loss. From an educational standpoint, we do this so to not obfuscate the these Liquidity Tree principles when communicating.
In Fig 1 we outline the three main paths that one can consider when investing into a Liquidity Tree; which are as follows:
- Path #1: single-sided deposit into parent pool and mint parent LP tokens (ie, the standard way of investing into a single AMM pool)
- Path #2: single-sided deposit into child pool and mint child LP tokens
- Path #3: single-sided deposit into parent pool and mint index tokens (ie, what we call a SwapIndexMint); next, perform a single-sided deposit of index tokens into child pool and mint tree LP tokens
The third path is the most interesting, as our investment is now making a return from both the parent and child liquidity pool (LP), thus generating higher yield. We are effectively investing into an LP, taking a fully collateralized loan from that investment and reinvesting it. Therefore earning yield from both our original investment and the fully collateralized loan. The following scripts demonstrate this principle via assuming: (a) infinite supply of index tokens (part 1); and (b) finite supply of index tokens (part 2).
To run following scripts, you must first install the uniswappy
package via
> git clone https://github.com/defipy-devs/uniswappy
> pip install .
or
> pip install uniswappy