diff --git a/experiments/notebooks/borrow-and-repay/README.md b/experiments/notebooks/borrow-and-repay/README.md new file mode 100644 index 0000000..f7c4542 --- /dev/null +++ b/experiments/notebooks/borrow-and-repay/README.md @@ -0,0 +1,20 @@ +# Borrow and Repay + +Mento stable assets can currently come into existence by buying them from Mento, through Granda Mento and as validator rewards. Giving users the ability to lock collateral in IRPs (individual reserve positions) and mint stable assets against it, would introduce a new mechanism with parameters to modulate the inflation of stable assets. It would allow for more exotic reserve assets to be used as collateral with granularly set minimum reserve ratios and caps, which serve to further diversify the makeup of reserves. IRPs can also make it possible to mint Mento stable assets locally on different chains but still have them tied into the base reserve the lives on the Celo blockchain. + +In the context of debt-based stability protocols, liquidation serves as a mechanism to contract the stable asset supply in order to increase the overall collateralization of the protocol. + +The core innovation of Mento IRPs compared to the Maker-type model is that instead of triggering auction-based fire sales of collateral whenever a position becomes undercollateralized, collateral is simply returned to the base reserve in case of a liquidation. This is possible through leveraging the buy&sell feature of Mento that can handle the contraction of stable assets if necessary such that fire sale auctions as in Maker-type models are not required. + +Such a mechanism can be achieved using a keeper model, in which agents are incentivize to execute liquidations on IRPs, transferring the confiscated collateral to the base reserve, and no other change needs to happen to the protocol. + +But a more interesting approach is to expose a method on IRPs that would allow the `exchange` to redeem a variable amount of the underlying collateral only as long as the IRP is undercollateralized. This could allow a mechanism where Mento pays out Celo not only from the reserve but also by dipping into IRPs using an off-chain routing mechanism. Which would still need to be incentivize but in a way similar to how Liquity uses kickback rate for frontends. + +Trading with Mento Buy&Sell could happen in two ways: + +- Direct trading with funds from the base reserve (what’s happening currently) +- Provide one or more IRPs that can be drained of collateral as part of the trade transaction and an address for getting a kickback from the spread of the swap. + +This incentivizes applications that consume Mento (Valora, celoterminal, etc) to take on the role of keepers. It would also allow arbitrageurs to essentially become keepers without having to add complexity to their setup; they can get a discount when buying Celo from Mento if they route the order through liquidatable IRPs. + +Depending on the collateral backing the IRP we would require Mento’s Exchange to support trading with any of the supported reserve collateral, or otherwise require a liquid market to convert to Celo. diff --git a/experiments/notebooks/1_mento1.ipynb b/experiments/notebooks/buy-and-sell/1_mento1.ipynb similarity index 98% rename from experiments/notebooks/1_mento1.ipynb rename to experiments/notebooks/buy-and-sell/1_mento1.ipynb index 4b7b7c5..fd42fb2 100644 --- a/experiments/notebooks/1_mento1.ipynb +++ b/experiments/notebooks/buy-and-sell/1_mento1.ipynb @@ -76,7 +76,7 @@ "# Import the setup module:\n", "# * sets up the Python path\n", "# * runs shared notebook-configuration methods, such as loading IPython modules\n", - "import setup\n", + "import ..setup\n", "\n", "# External dependencies\n", "import copy\n", @@ -430,6 +430,12 @@ "px.line(df, x='timestep', y='mento_rate', facet_col='subset')" ] }, + { + "cell_type": "markdown", + "id": "f28fb681", + "metadata": {}, + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -447,10 +453,13 @@ } ], "metadata": { + "interpreter": { + "hash": "36c3e847213eb5698cc66aeaad5916352a550e6fce59fcba6a957699abbd22fe" + }, "kernelspec": { "display_name": "mento2-model", "language": "python", - "name": "mento2-model" + "name": "python3" }, "language_info": { "codemirror_mode": { diff --git a/experiments/notebooks/buy-and-sell/README.md b/experiments/notebooks/buy-and-sell/README.md new file mode 100644 index 0000000..71add81 --- /dev/null +++ b/experiments/notebooks/buy-and-sell/README.md @@ -0,0 +1,5 @@ +# Buy-and-sell + +**Context:** Buy-and-sell is the nickname for the current Mento mechanism which uses an AMM between the market and the reserve and allows the market to buy or sell CELO for a stable asset amount equivalent with the off-chain fiat price of CELO. This enables an arbitrage loop which keeps the stable assets pegged to their fiat counterparts. + +We will use this section of the repo as the base to simulation additions to the existing protocol, the first of which is a circuit beaker. diff --git a/experiments/notebooks/buy-and-sell/setup.py b/experiments/notebooks/buy-and-sell/setup.py new file mode 100644 index 0000000..6342e3a --- /dev/null +++ b/experiments/notebooks/buy-and-sell/setup.py @@ -0,0 +1,32 @@ +""" +jupyter & IPython setup +""" +import sys +import pandas as pd +from IPython import get_ipython +# pylint: disable=invalid-name + +ipython = get_ipython() + +# Find performance bottlenecks by timing Python cell execution +# ipython.magic("...") is equivalent to % in Jupyter cell +ipython.magic("load_ext autotime") +ipython.magic("load_ext line_profiler") + +# Reload all modules (except those excluded by %aimport) +# every time before executing the Python code typed +# See https://ipython.org/ipython-doc/stable/config/extensions/autoreload.html +ipython.magic("load_ext autoreload") +ipython.magic("autoreload 2") + +# Append the root directory to Python path, +# this allows you to store notebooks in `experiments/notebooks/` sub-directory +# and access model Python modules +sys.path.append("../../..") +sys.path.append("../../../..") + +# Configure Pandas to raise for chained assignment, rather than warn, so that we can fix the issue! +pd.options.mode.chained_assignment = 'raise' + +# Set plotly as the default plotting backend for pandas +pd.options.plotting.backend = "plotly" diff --git a/experiments/notebooks/collateral-farming/README.md b/experiments/notebooks/collateral-farming/README.md new file mode 100644 index 0000000..f73227b --- /dev/null +++ b/experiments/notebooks/collateral-farming/README.md @@ -0,0 +1,35 @@ +# Collateral Farming + +[Colab Notebook with first simulation](https://colab.research.google.com/drive/1CvZ2FN7gV5SNstNjRk4knyc6SzycrCF5?usp=sharing) + +Main idea: Allow users to earn rewards by committing collateral to the reserve. + +An illustration of the mechanics of collateral farming: + +- Assume the core reserve holds 90M CELO and assume the first collateral provider (CP#1) commits 10M additional CELO to the reserve, then CP#1 receives 10M CP (collateral provider) tokens. +- During a contraction, 10% of the inflowing cStables flow into CP#1s position and 10% of the outflowing CELOs flow out of CP#1s position. +- During expansions, cStables flow out of CP#1s position unless there are no cStables left in the position, at which point they get minted by the reserve and position of CP#1 remains untouched. +- To keep CP-tokens fungible, additional CPs have to provide capital in the same proportion as the current CPs positions, for example 20% of the position value in cUSD and 80% in CELO. +- That means that if another CP, let’s call her CP#2, is providing collateral, this collateral must be provided in the same proportion as the current position of CP#1. +- CP#1 gets incentivized to participate by +- Receiving mento trading fees (spread) on pro-rata basis +- Receiving collateral farming incentives: +- CP-tokens can be locked up for extended periods of time (1M, 3M, 6M, 1Y, 5Y, 10Y) which leads to the CP receiving rewards from Mento. +- The incentivized long lockup periods for CP-tokens lead to protocol owned collateral beyond the original reserve collateral +- Sources of collateral farming rewards: Yield of staked collateral, excess collateral, Mento token + +Properties of collateral farming: + +- As long as cStables are pegged, neither expansions nor contractions change the value of a CP position. During contractions for example, X USD worth of cStables are flowing in and X USD of CELO is flowing out - which amounts to value neutrality. This value neutrality is intuitive as the value of debt created equals the additional asset value deposited. +- The risk that CPs take is mainly a cStables price risk - if there are more contractions than expansions, a CP ends up with more cStables than she started out with and if those cStables are trading below a price of one, the CP makes a loss. +- Additionally, CPs take a relative price change risk. However, in contrast to a liquidity provider setup in which relative price changes always lead to impermanent loss, relative price changes of cStables and CELO in the collateral provider setup can also lead to an “impermanent gain” compared to a buy and hold portfolio. +- The collateral provider mechanism is a generalization of the Mento1.0 setup; If no one becomes a CP, we are back to a single-reserve actor setup + +Collateral farming - what it achieves: + +- It allows to attract additional collateral today to be well prepared for tomorrow (intertemporal value transfer) +- It allows to lock in additional collateral that would otherwise likely be withdrawn during future bad reserve states (good-to-bad state value transfer) +- It helps with absorbing cStables demand shocks as part of the contraction amounts end up with CPs +- It helps with long-term overcollateralization as it incentives the provision of additional reserve collateral +- It transfers cStables to CPs in the worst-case scenario of a permanent depeg (transfer from risk-averse user group to risk-seeking user group who signed up for that risk). +- Creates innovative new earning opportunities for defi users and thereby fosters engagement and growth. CPs rewards can be expected to be sustainable income as they are a compensation for solving an actual problem - taking worst-case scenario risk. diff --git a/experiments/notebooks/interaction-farming/README.md b/experiments/notebooks/interaction-farming/README.md new file mode 100644 index 0000000..2995f48 --- /dev/null +++ b/experiments/notebooks/interaction-farming/README.md @@ -0,0 +1,24 @@ +# Interaction farming + +**Main idea**: Allow users to earn by committing funds to a contract that guarantees healthy, on-chain protocol interactions at any time. + +**Context**: During crisis times, one cannot rely on profit opportunities to be taken even if they are present. This is critical since even if the correct incentives are present and sufficient collateral and liquidity are available, an incentives-driven system will fail if profit opportunities are not actually taken. + +Mechanics explained: + +- Interaction providers (IPs) can commit funds to an “interactions contract” (IC) in return for IP-tokens. +- This interaction contract takes profit opportunities across mento and DEXs in a way that is beneficial to the cStables stability and general price efficiency on chain. +- The IC receives privileged access to certain reserve interactions such that arbitrage profit opportunities are better democratized and MEV is reduced +- The interactions that this contract triggers are defined by a convex optimization problem. +- Convex min objective, convex inequality constraints, affine equ. constraints +- Guaranteed execution, off-chain optimization and on-chain proof: Everyone can provide the solution to this optimization problem to the contract that then checks the validity of this solution by checking the KKT conditions. Executing this contract will be rather cheap (checking a set of linear equations and inequalities), so everyone who has an incentive to keep Mento healthy, like CPs, has a strong incentive to trigger IC execution - it only needs one bot to trigger this for the entirety of the capital in the IC contract to be put to productive use. +- IP tokens received by interaction providers can be long-term locked / farmed similarly to the CP of collateral providers: +- For sources of rewards, see CPs +- As with CPs, funds to the IC have to be provided in the same proportions as current contract holdings of the other ICs in order to achieve IP-token fungibility. As with LP-tokens and CP-tokens, IP-tokens are redeemable for funds in the IP contract on a pro-rata basis. + +Guaranteed interactions via “Interaction Farming” - what it achieves: + +- “Guaranteed” healthy stability protocol interactions - also during crisis periods / black-swan events +- Increased on-chain market efficiency +- Increased user participation and democratization of arbitrage profits +- Innovative new earning opportunities for defi users and which fosters engagement and growth. IP rewards can be expected to be sustainable income as they are a compensation for solving an actual problem - guaranteeing healthy protocol interactions, also during crisis periods.