# Sifchain Liquidity Pool Subsystem ## Notations | Name | Description | Dynamic Characteristic | Symbol | |----|----|----|----| | Time | Timesteps | | $t$ | | Period | Time period | | $T$ | | Liquidity Pools | Number of liquidity pools | | ${n_{LP}}$ | | Liquidity Pool Identifier | Reference to a particular liquidity pool | | $i, j, k$ | | Rowan | Number of Rowan tokens in liquidity pool | | $\mathbf{S_L}$ | | M-Tokens | Number of M-tokens in liquidity pool | | $\mathbf{M_L}$ | | Swap Fee | Fees for swapping in a liquidity pool | | $f_{swap}$ | | Swap Volume | Volume of swaps in a liquidity pool | | $v_{swap}$ | | Rowan Price | Price of Rowan in a liquidity pool | | $P_S$ | | M-Token Price | Price of M-token in a liquidity pool | | $P_M$ | | Liquidity Provider | Reference to a liquidity provider | | $\pi$ | | Liquidity Provider | Reference to the liquidity provider subsystem | | $\Pi$ | | Liquidity Provider Reward | Reward earned by a liquidity provider | | $\mathbf{R_{\pi}}$ | | Liquidity Provider System Reward | Reward earned by the liquidity provider system | | $\mathbf{R_{\Pi}}$ | | Liquidity Provider's Cost of Operation | Operational cost incurred by a liquidity provider | | $C_{\Pi}$ | | Liquidity Provider System ROI | Return on investment of the liquidity provider system | | $\Omega_{\Pi}$ | | Awarded Subsidies | Proto rewards- tokens awarded to LPs and Validators | | $\mathbf{S_P}$ | | Observed Ratio | Ratio of supply tokens in Liquidity Pool to the total supply | | $\rho_l$ | | Target Ratio | Target ratio of supply tokens in Liquidity Pool to the total supply | | $\gamma_l$ | | Swap fee parameter | Control parameter on the liquidity subsystem's swap fee | | $\lambda_l$ | ## Roles A liquidity pool consists of two primary actors: - **Liquidity Providers** who provide Rowan or N-tokens for a given duration of time to earn rewards. - **Swappers** who participate in the liquidity pool to swap Rowan for N-tokens or vice versa. ## Actions ![](https://i.imgur.com/AYTYVwc.png) ### Add and remove liquidity The Rowan price $P_S$ is defined as the units of Rowan $\mathbf{S}$ that can be bought per unit of M-token $\mathbf{M}$. $$P_S = \frac{\mathbf{S_L}}{\mathbf{M_L}}$$ Adding liquidity can be modeled as adding (m, s) such that $$ P^{+}_S = P_S $$ $$ P^{+}_S = \frac{\mathbf{S_L}+s}{\mathbf{M_L}+m} = \frac{\mathbf{S_L}}{\mathbf{M_L}} = P_S$$ where - $P_S$ is the Rowan price at the current state, - $P^+_S$ is the Rowan price at the next state, - $s > 0$ is the amount of Rowan added through the action; $\mathbf{s} = \mathbf{\Delta S}$ - $m > 0$ is the amount of M-tokens required to make the action; $\mathbf{m} = \mathbf{\Delta M}$ Removing liquidity can be modeled as removing (m, s) such that $$ P^{+}_S = \frac{\mathbf{S_L}+s}{\mathbf{M_L}+m} = \frac{\mathbf{S_L}}{\mathbf{M_L}} = P_S$$ where - $P_S$ is the Rowan price at the current state, - $P^+_S$ is the Rowan price at the next state, - $s<0$ is some fraction of S; the amount of Rowan removed through the action; $\mathbf{s} = \mathbf{\Delta S}$ - $m<0$ is some fraction of M; the amount of M-tokens removed through the action $\mathbf{m} = \mathbf{\Delta M}$ ### Swapping A swap is defined as an exchange of M-tokens for Rowan or vice versa, while preserving the Continuous Liquidity Provider (CLP) formula. #### Parameterized Swap Fees Consider a prior state (M, S). A swapper deposits $\mathbf{m} = \Delta \mathbf{M}$ to obtain $s = f(m; M, S)$ computed using the CLP model. We need to design a parametrized swap fee policy in order to modulate the fee according to the dynamic rebalancing policy. We choose a parameter $\lambda_l$ such that - at $\lambda_l = 0$, the swapper incurs no fee to swap akin to the Constant Marker Maker Model (idealized Uniswap) - at $0< \lambda_l \leq 1$, the swapper incurs a combination slip-based fee to swap - at $\lambda_l > 1$, the swapper incurs a magnifed slip-based fee In the Constant Market Maker Model, the next state after a swap is $$\mathbf {S_{L,cmm}^+} = \mathbf {S_L} - \frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}$$ In the Continuous Liquidity Pool Model, the next state after a swap is $$\mathbf {S_{L,clp}^+} = \mathbf {S_L} - \frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2}$$ In the case of the Constant Product Market Maker, the amount of tokens returned to the swapper who provided $\mathbf m$ is $\frac{\mathbf{m}\mathbf{S_L}}{(\mathbf{m}+\mathbf{M_L})}$, whereas in the case of the slip based fee it is $\frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2}$. Given that we want a parametrization that allows for both of these rules to be realized, we can express the Parametrized Continuous Liquidity Provider Model as follows: $$\mathbf {S_{L,param}^+} = \mathbf {S_L} - \frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}} + \lambda_l \left( \frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}} - \frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2} \right)$$ Note that - if ${\lambda_l} = 0$ then we recover the Constant Product Market Maker $\mathbf {S_{L,cmm}}$ equation - if ${\lambda_l} = 1$ the we recover the Continuous Liquidity Provider $\mathbf {S_{L,clp}}$ equation. Furthermore, this is analytically equivalent to: $$\mathbf {S_{L,param}^+} = \mathbf {S_L} - (1-\lambda_l) \frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}} - \lambda_l\frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2}$$ That means the the quantity of tokens recieved by the swapper is: $$\mathbf {S_L}-\mathbf {S_{L,param}^+}=(1-\lambda_l) \frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}} + \lambda_l\frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2}$$ Furthermore, we can interpret the Constant Product Market Maker rule as being "without fees" (the slippage is not a fee). Thus, any fee rule such as the Continuous Liquidity Provider rule can be interpreted relative to what the swapper would have recieved under the Constant Product Market Maker, giving the difference which is the "fee". In this framing, the fee for the Continuous Liquidity Provider rule is $$(\mathbf {S_{L,cmm}^+}-\mathbf {S_L})-(\mathbf {S_{L,clp}^+}-\mathbf {S_L})=\mathbf {S_{L,cmm}^+}-\mathbf {S_{L,clp}^+}\\=\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}} - \frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2}\\=\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}\left(1 - \frac{\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})} \right) >0$$ The $\lambda_l$ term needs to parameterize the fee directly such that - when $\lambda_l = 0$ we have no fee - when $\lambda_l = 1$ we have the slip based fee - when $\lambda_l >1$ we have maginified (or suppresed) version of the slip-based fee. $$(\mathbf {S_{L,cmm}^+}-\mathbf {S_L})-(\mathbf {S_{L,param}^+}-\mathbf {S_L})=\mathbf {S_{L,cmm}^+}-\mathbf {S_{L,param}^+}\\=\lambda_l\left(\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}} - \frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2}\right)\\=\lambda_l\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}\left(1 - \frac{\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})} \right) >0$$ for any parameter $\lambda_l>0$ where $m, M_L, S_L >0$. This gives the **Parametrized Swap Fee** for this Liquidity Provider system $$f_{swap} = \lambda_l\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}\left(1 - \frac{\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})} \right) $$ #### Cases **No fees at $\lambda_l = 0$** $$f_{swap, \lambda_l=0} = 0$$ **Combination Slip-Based Fee at $0< \lambda \leq 1$** $$f_{swap, 0< \lambda_l \leq 1} = \lambda_l\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}\left(1 - \frac{\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})} \right)$$ **Magnified Slip-Based Fee at $\lambda_l > 1$** $$f_{swap, \lambda_l > 1} = \lambda_l\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}\left(1 - \frac{\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})} \right)$$ The Rebalancing Policy for Sifchain thus must provide instructions as to whether fees should rise or fall by providing an increase or decrease in $\lambda$ of the form $\lambda^+ = \lambda +\Delta \lambda$ where $\Delta \lambda$ is determined as a function of the overall system state including token supply, tokens staked in the validator subsystem and locked across the liquidity pools. Plugging in the slip-based fee $f_{swap} = \lambda\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}\left(1 - \frac{\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})} \right)$, the resulting Rowan obtained by the swapper is $$\mathbf {S_L}-\mathbf {S_{L,param}^+}=(1-\lambda_l) \frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}} + \lambda_l\frac{\mathbf{m}\mathbf{S_L}\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})^2}$$ ![](https://i.imgur.com/A5yYQTR.jpg) We can define an invariant $I$ in this subsystem to represent the conservation of the $\mathbf{M_L},\mathbf{S_L}$ relationship. $$I = f(f_{swap}, \mathbf{S_L}, \mathbf{M_L})$$ ### Create and destroy pool A user can list a new pool with their choice of M-token and its ratio with Rowan. To create a pool, the user must provide the initial liquidity in its specified Rowan:M-token ratio. Under reasonable grounds, a pool can be removed or destroyed from Sifchain. ## State variables **Definition 1: Rowan in Liquidity Provider Subsystem $\mathbf{S_L}$** The amount of Rowan in locked up as liquidity in all the liquidity pools of the Liquidity Provider Subsystem in the current state. **Definition 2: Rowan in Validator Subsystem $\mathbf{S_V}$** The amount of Rowan currently staked by all validators in the Validator Subsystem in the current state. **Definition 3: Rowan in Circulating Supply $\mathbf{S_C}$** Circulating supply. This contains all the Rowan circulating in the system, including the stock availed through the accumulation of swap fees. **Definition 4: Liquidity Provider Rewards $\mathbf{R_\pi}$** Rewards earned by the liquidity provider are a function of the swap fees and the dynamic rebalacing parameter. ## Metrics **Definition 5: M-token Supply** The amount of M-tokens in the liquidity pool in the current state. **Definition 6: Swap Fees** Fees incurred by swapper while making a Rowan/M-token swap. Sifchain implements a *paramterized slip-based fee* for swaps, computed using the Continuous Liquidity Provider (CLP) model. The parameter $\lambda$ The swap fee is a function of the swap volume and the demand for a pool's liquidity. $$f_{swap} = \lambda\frac{\mathbf m \mathbf{S_L}}{\mathbf m+\mathbf{M_L}}\left(1 - \frac{\mathbf{M_L}}{(\mathbf{m}+\mathbf{M_L})} \right)$$ **Definition 7: Liquidity Provider System Revenue** We can define the revenue per period of the liquidity provider subsystem as a function of the swap fee policy and the volume of swaps that occur in that period. $$R_{\Pi, T} = \sum{{f_{swap}*v_{swap, T}}}$$ **Definition 8: Liquidity Provider System ROI** We can define the ROI per period of the liquidity provider subsystem as a function of the revenue generated in that period and the cost of providing liquidity. $$\Omega_{\Pi, T} = \frac{R_{\Pi, T}}{C_{\Pi, T}}$$