diff --git a/docs/basics/bonding.md b/docs/basics/bonding.md deleted file mode 100644 index 556660c..0000000 --- a/docs/basics/bonding.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Bonds - -Olympus bonds are a financial primitive that allow transacting assets,often between a protocol and individual stakeholders,over a specified time-period and at completely market-driven prices. In other words, Olympus bonds are a market-driven pricing mechanism for any two ERC-20 tokens that does not rely on third parties like oracles. - -Reserve Bonds are an application of this primitive, which sells OHM at a discount to acquire Treasury assets. External Bonds represent the primary mechanism for Olympus Treasury inflows. - -When purchasing a bond, purchasers commit a capital sum upfront in return for OHM upon maturity. Thus, a bond’s profit is uncertain and dependent on the price of OHM at the time of maturity. - -When viewing a current bond offering, a positive discount indicates that the bond is currently offering OHM at a discount to its current market price. A negative discount indicates that the bond is currently offering OHM at a premium to its current market price. - -This variable discount rate is how a bond market internally governs its supply by responding to demand. This ensures that a bond market’s supply is sold over the specified period of time. \ No newline at end of file diff --git a/docs/basics/bophades.md b/docs/basics/bophades.md deleted file mode 100644 index 3770c0e..0000000 --- a/docs/basics/bophades.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -sidebar_position: 1 -sidebar_label: "Bophades / Default" ---- - -# A Design Pattern for Better Protocol Development - -Today, most projects take a process-centric approach towards protocol development: each smart contract is developed to manage a process along a chain of logic that is triggered when external interactions occur. - -This is generally the most intuitive approach because it’s how our brain thinks when designing systems: one step in logic at a time. However, there’s an inherent issue in building a protocol this way. Over time, as the protocol evolves, more “steps in logic” are added across the system, creating long and convoluted chains of processes that look like this: - -![[MakerDAO’s protocol architecture.](https://docs.makerdao.com/)](/gitbook/assets/default-maker-dao.png) - -[MakerDAO’s protocol architecture.](https://docs.makerdao.com/) - -or this: - -![[Aave’s protocol architecture.](https://docs.aave.com/developers/v/2.0/the-core-protocol/protocol-overview)](/gitbook/assets/default-aave.png) - -[Aave’s protocol architecture.](https://docs.aave.com/developers/v/2.0/the-core-protocol/protocol-overview) - -When protocols are architected in these “web-like” structures, they can be difficult to understand, as they break a simple interaction into multiple layers of abstract logic. When contracts are developed this way, it’s difficult to track down where the calls are coming from or going to—it’s easy to get lost in the web of logic. This puts a huge burden on a user trying to understand the system, often requiring them to read an excessive amount of documentation just to figure out what’s going on behind the scenes. - -This pattern can be frustrating to deal with, and discouraging developers from contributing to the existing codebase or integrating with the protocol. And when they do, it increases the potential for bugs and unintended behavior to occur. - ---- - -The core philosophy of Default is to shift the focus of writing contracts away from organizing contracts around processes, and towards organizing contracts around data models. In particular, what data models exist as protocol dependencies, and how they can be modified. - -The goal is to turn a protocol from looking something like this: - -![before-default](/gitbook/assets/before-default.png) - -into something look like this: - -![after-default](/gitbook/assets/after-default.png) - -With a consistent contract architecture, developers can make certain assumptions around the intended behavior for any given contract in the protocol even if they are unfamiliar with the code. This model also limits the maximum depth of dependencies to a single contract, removing the potential for long or circular dependency chains to form. - -The idea to separate data and business logic isn’t novel; it just hasn’t been applied to smart contract development yet. Default is inspired by existing design patterns in other areas of computing that are more mature, like computer operating systems and web development. - -# The Default Framework - ---- - -In Default, contracts are either Modules or Policies, which are essentially the “front-end” and “back-end” of a protocol: Modules are the back-end, and Policies are the front-end. - -Modules are **internal-facing contracts** that store shared state across the protocol. You can think of them as microservices: each Module is responsible for managing a particular data model within the larger system. Modules can only be accessed through whitelisted Policy contracts, and have no dependencies of their own. Modules can only modify their own internal state. - -Policies are **external-facing contracts** that receive inbound calls to the protocol, and routes all the necessary updates to data models via Modules. Policies effectively act as intermediaries between external interactions and internal state changes, creating a buffer where all protocol business logic is composed. - -While modules describe *what* data models exist within the protocol and *how* they can be modified, policy contracts contain the context for *why* those changes happen. This separation of *what* and *why* in the protocol allows for greater flexibility in design while retaining some properties of immutability, which dramatically simplifies protocol development. - ---- - -One example of a module could be an ERC20 token: ERC20 contracts define a self-contained data model around token account balances (i.e. `balanceOf`). The `transfer()`, `mint()`, and `burn()` functions define how account balances can be changed, while the `totalSupply()` function provides useful metadata about balances, such as the aggregate amount of balances in existence. - -Notice that changes in an ERC20 contract are limited to its internal state: nothing happens outside the contract when account balances are modified. This makes ERC20’s generic enough to be applicable for a wide variety of use cases, like managing vault deposits, facilitating token swaps, or distributing mining rewards for a protocol. - -There is an interesting case about this example: Module functions should not be called by any contracts except Policies. However, users should be able to interact directly with the ERC20 via transfer(). How is this case handled? - -The ultimate distinction lies in *permissioned* versus *permissionless* state changes. When a contract needs to enforce certain permissionless guarantees, those functions should be atomic in the contract and called directly by the user. Default is mostly applicable to permissioned functions, like `mint()` and `burn()`. Interesting cases like `transferFrom()` emerge—should external integrations be permissioned or permissionless? This is up to the protocol to decide. - -## Protocol Organization and Upgradability - -Default views the entire contract set as a cohesive unit: rather than upgrading an individual contract’s code, it’s better to just upgrade the protocol’s *contract set.* In Default, there is a special contract registry that manages the contract set called the Kernel. This means that all changes to the protocol are made within in a single contract, unifying the model of upgradability. - -In this paradigm, each contract in the protocol remains immutable, but the set of contracts that make up a protocol can change. This makes Default incredibly easy to work with; developers only need to understand a single contract—the Kernel—before they can begin building a protocol using the framework. - -### Kernel.sol - -There are a limited number of actions that the Kernel can take to update the protocol. These actions are: - -**1. Approving a policy** - -**2. Terminating a policy** - -**3. Installing a module** - -**4. Upgrading a module** - -Each of these actions is executed on a “target”, which is the address of the contract on which the action is being performed. This combination of an action and a target is submitted as an “instruction” in the Kernel: approve 0xc199e... as a Policy, install 0x410f... as a Module, etc. - -Policies are a*pproved* or *terminated* via simple whitelist in the Kernel. The whitelist is represented as a mapping of contract addresses to a boolean that represents whether that policy is authorized to interact with modules. Once a policy is terminated, it is no longer authorized to call modules, effectively deprecating the feature. - -Modules can be *installed* or *upgraded* with a directory in the Kernel. Each module is mapping their address to a three letter keycode in the Kernel, which is used to reference the underlying data model of the module from within Policies. For example, a token module might have the keycode “TOKEN”, while a treasury module might have the keycode “TRSRY”. Once installed, a module cannot be removed, only upgraded. - -This to ensure some backwards compatibility for contract dependencies in Policy contracts: once a keycode is mapped to a module in the Kernel, it will always point to an existing data model. Keycodes are three letters to discourage module bloat as well as reduce potential confusion around dependency names. - ---- - -### The Executor - -In the Kernel.sol contract code, there’s one action that hasn’t been discussed: changing the executor. In the Kernel, the executor is the address with the permission to execute instructions—you can think of the executor as the “owner” of the Kernel contract. - -The initial “executor” is the deployer of a Kernel contract, but can be changed to another address to include possibilities for on-chain governance via `changeExecutor()`. For convenience, Default has an optional module that can be installed in any Kernel called “GPU”, which enables a protocol to execute multiple instructions in the same transaction, simplifying multi-contract migrations. - ---- - -By defining all the protocol changes in a single contract, Default is a very lightweight and simple framework to adopt. Developers only need to understand how the Kernel works before building any type of protocol on top: whether they are DeFi protocols, NFT marketplaces, or DAO tooling. - -You can view a sample template for a Default protocol here: - -[GitHub - fullyallocated/Default: Protocol Development & Upgradability Framework](https://github.com/fullyallocated/Default) - -### What’s Next? - -Default is still an emerging standard. If you are interested in providing feedback or using it to build your protocol, please [reach out on Twitter](http://Twitter.com/fullyallocated). We’d love to hear your thoughts and ideas. diff --git a/docs/basics/inverse-bonds.md b/docs/basics/inverse-bonds.md deleted file mode 100644 index 09d8f3e..0000000 --- a/docs/basics/inverse-bonds.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -sidebar_position: 5 -sidebar_label: Inverse Bonds ---- - -# Inverse Bonds ([OIP-76](https://forum.olympusdao.finance/d/1020-oip-76-create-inverse-bond-policy-lever)) - -## What are inverse bonds? - -As their name suggests, one can think of inverse bonds as doing the "inverse" of what a regular bond does: instead of taking a treasury asset in exchange for OHM, **it takes in OHM in exchange for an asset from the treasury**. Inverse bonds have been introduced as a protocol lever in [OIP-76](https://snapshot.org/#/olympusdao.eth/proposal/0xa544837835f3c4e681efba18d33623d4eb2acedec352dfc3c926a45902cd3612) as a way to support the price of OHM when it is below the (liquid) backing per OHM, and with the launch of RBS, they’ve become an integral part of Olympus’ monetary policy. - -Unlike reserve bonds, they vest instantly, and are the core mechanism of absorbing sell pressure from the market. - -## Example - -- `ETH` inverse bond -- `$120` backing per OHM -- `$100` market price of OHM -- `$100` bond price -- `$105` payout per bond (`5%` premium over the market price of OHM) - -Here, the treasury receives $10 worth of OHM and delivers the user $10.50 worth of ETH.The backing per OHM also increases in that scenario, benefitting all remaining OHM holders. diff --git a/docs/basics/migration.md b/docs/basics/migration.md index b019c97..18a24e3 100644 --- a/docs/basics/migration.md +++ b/docs/basics/migration.md @@ -1,7 +1,3 @@ ---- -sidebar_position: 8 ---- - # V2 Migration ## Why do I need to migrate? diff --git a/docs/basics/readme.md b/docs/basics/readme.md deleted file mode 100644 index 4af403f..0000000 --- a/docs/basics/readme.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -sidebar_position: 1 -sidebar_label: "Basics" -slug: /basics/readme ---- - -# Introduction - -## What is Olympus? - -Olympus is a protocol on the Ethereum blockchain with the goal of establishing OHM as a crypto-native reserve currency. It operates by way of autonomous and dynamic monetary policy, with market operations supported by the Olympus Treasury as a core component of the protocol. - -OHM serves a need in the market between fiat stablecoins and volatile crypto assets, providing relative stability and scalability underpinned by the protocol’s Range Bound Stability (“RBS”) system. RBS is the major implementation of Olympus’ autonomous monetary policy. - -:::info -[Read more about RBS here](../treasury/range-bound.md) -::: - -What are reserve currencies designed to achieve? - -* Deep liquidity: reserve currencies are highly liquid and can be easily exchanged for other assets, products and services -* Serve as a unit of account: Other assets are denominated in the currency -* Preserve purchasing power: Provides its holders a stable, low volatility asset that grows at a steady rate over the medium-to- long-term. - -Olympus DAO’s efforts in Treasury management, development of on-chain governance structures and prudent use of Olympus’ liquidity and Treasury assets will help to strengthen OHM’s stability to usher in the growth of the Olympus network economy. diff --git a/docs/contracts/allocators.md b/docs/contracts-old/allocators.md similarity index 100% rename from docs/contracts/allocators.md rename to docs/contracts-old/allocators.md diff --git a/docs/contracts/audits.md b/docs/contracts-old/audits.md similarity index 100% rename from docs/contracts/audits.md rename to docs/contracts-old/audits.md diff --git a/docs/contracts/bonds.md b/docs/contracts-old/bonds.md similarity index 100% rename from docs/contracts/bonds.md rename to docs/contracts-old/bonds.md diff --git a/docs/contracts/dao.md b/docs/contracts-old/dao.md similarity index 100% rename from docs/contracts/dao.md rename to docs/contracts-old/dao.md diff --git a/docs/contracts/equations.md b/docs/contracts-old/equations.md similarity index 100% rename from docs/contracts/equations.md rename to docs/contracts-old/equations.md diff --git a/docs/contracts/glossary.md b/docs/contracts-old/glossary.md similarity index 100% rename from docs/contracts/glossary.md rename to docs/contracts-old/glossary.md diff --git a/docs/contracts/interactions.md b/docs/contracts-old/interactions.md similarity index 100% rename from docs/contracts/interactions.md rename to docs/contracts-old/interactions.md diff --git a/docs/contracts/interactions.mmd b/docs/contracts-old/interactions.mmd similarity index 100% rename from docs/contracts/interactions.mmd rename to docs/contracts-old/interactions.mmd diff --git a/docs/contracts/interactions.svg b/docs/contracts-old/interactions.svg similarity index 100% rename from docs/contracts/interactions.svg rename to docs/contracts-old/interactions.svg diff --git a/docs/contracts/policy.md b/docs/contracts-old/policy.md similarity index 100% rename from docs/contracts/policy.md rename to docs/contracts-old/policy.md diff --git a/docs/contracts/range-bound-stability.md b/docs/contracts-old/range-bound-stability.md similarity index 100% rename from docs/contracts/range-bound-stability.md rename to docs/contracts-old/range-bound-stability.md diff --git a/docs/contracts/staking.md b/docs/contracts-old/staking.md similarity index 100% rename from docs/contracts/staking.md rename to docs/contracts-old/staking.md diff --git a/docs/contracts/tokens.md b/docs/contracts-old/tokens.md similarity index 100% rename from docs/contracts/tokens.md rename to docs/contracts-old/tokens.md diff --git a/docs/contracts/treasury.md b/docs/contracts-old/treasury.md similarity index 100% rename from docs/contracts/treasury.md rename to docs/contracts-old/treasury.md diff --git a/docs/governance/index.md b/docs/governance/00_dao.md similarity index 96% rename from docs/governance/index.md rename to docs/governance/00_dao.md index 0755943..ee425d2 100644 --- a/docs/governance/index.md +++ b/docs/governance/00_dao.md @@ -1,5 +1,5 @@ --- -sidebar_position: 1 +slug: /governance/dao --- # Governance & DAO diff --git a/docs/governance/council.md b/docs/governance/01_council.md similarity index 97% rename from docs/governance/council.md rename to docs/governance/01_council.md index 19b1697..4673854 100644 --- a/docs/governance/council.md +++ b/docs/governance/01_council.md @@ -1,7 +1,3 @@ ---- -sidebar_position: 2 ---- - # Council All proposals, whether being consistent with the general direction of the DAO, a change in policy, or a pivot to a certain strategy or framework are voted for by the community. Any member of the community can create a proposal on the forum for discussion before being posted to snapshot for a governance vote. [Olympus Governance Council (OGC)](https://forum.olympusdao.finance/d/1156-oip-91-olympus-governance-council) will be initially comprised of 7 veteran community members who are primarily responsible for facilitating off-chain processes. These can include, but are not limited to, establishing strategic vision, coordinating working groups to execute on community-approved initiatives, and proposing strategic initiatives to the community via OIP. diff --git a/docs/governance/policy.md b/docs/governance/02_policy.md similarity index 96% rename from docs/governance/policy.md rename to docs/governance/02_policy.md index 72428f8..e70e6dd 100644 --- a/docs/governance/policy.md +++ b/docs/governance/02_policy.md @@ -1,7 +1,3 @@ ---- -sidebar_position: 3 ---- - # Policy Team & Policy Framework The policy team is composed of about 20 members of the Olympus community who have displayed sufficient knowledge of the protocol and a curiosity to continue to learn as the protocol grows in size and complexity. Policy is largely guided by the [policy framework](https://forum.olympusdao.finance/d/622-oip-56-olympusdao-policy-framework-v2). diff --git a/docs/governance/treasury-process.md b/docs/governance/03_dao-processes/00_treasury-process.md similarity index 100% rename from docs/governance/treasury-process.md rename to docs/governance/03_dao-processes/00_treasury-process.md diff --git a/docs/governance/policy-process.md b/docs/governance/03_dao-processes/01_policy-process.md similarity index 100% rename from docs/governance/policy-process.md rename to docs/governance/03_dao-processes/01_policy-process.md diff --git a/docs/governance/grant-process.md b/docs/governance/03_dao-processes/02_grant-process.md similarity index 100% rename from docs/governance/grant-process.md rename to docs/governance/03_dao-processes/02_grant-process.md diff --git a/docs/governance/03_dao-processes/_category_.json b/docs/governance/03_dao-processes/_category_.json new file mode 100644 index 0000000..0e4d99a --- /dev/null +++ b/docs/governance/03_dao-processes/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "DAO Process", + "position": 3, + "collapsed": true +} \ No newline at end of file diff --git a/docs/literature-content/papers.md b/docs/literature-content/papers.md deleted file mode 100644 index c8393bc..0000000 --- a/docs/literature-content/papers.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -sidebar_position: 2 ---- - -# Papers - -[Zeus - Liquid Interest Rate Markets Through Olympus Bonds](https://hackmd.io/@HMyg0dxkQ96YOMpI30o8PA/mbga) - -[Zeus - Stabilizing Currency Through a Protocol Enforced Range](https://ohm.fyi/gentle-pegging) - -[DeFi Liquidity Management via Optimal Control: Ohm as a Case Study](https://web.stanford.edu/~guillean/papers/ohm-staking.pdf) diff --git a/docs/overview/00_intro.md b/docs/overview/00_intro.md new file mode 100644 index 0000000..fdc8543 --- /dev/null +++ b/docs/overview/00_intro.md @@ -0,0 +1,14 @@ + +# What is Olympus Protocol? + +Olympus is a protocol on the Ethereum blockchain with the goal of establishing OHM as a crypto-native reserve currency. It conducts autonomous and dynamic monetary policy, with market operations supported by the protocol-owned Olympus Treasury. + +OHM serves a need in the market gap between fiat stablecoins and volatile crypto assets, providing relative stability and scalability underpinned by the protocol’s Range Bound Stability (“RBS”) system. RBS is the flagship system of Olympus’ autonomous monetary policy. + +## What are reserve currencies designed to achieve? + +* Deep liquidity: reserve currencies are highly liquid and can be easily exchanged for other assets, products and services +* Serve as a unit of account: Other assets are denominated in the currency +* Preserve purchasing power: Provides its holders a stable, low volatility asset that grows at a steady rate over the medium-to- long-term. + +Olympus DAO’s efforts in Treasury management, development of on-chain governance structures and prudent use of Olympus’ liquidity and Treasury assets will help to strengthen OHM’s stability to usher in the growth of the Olympus network economy. diff --git a/docs/basics/staking.md b/docs/overview/01_staking.md similarity index 82% rename from docs/basics/staking.md rename to docs/overview/01_staking.md index 0f8b2bf..ee55665 100644 --- a/docs/basics/staking.md +++ b/docs/overview/01_staking.md @@ -1,13 +1,9 @@ ---- -sidebar_position: 1 ---- - # Staking -OHM holders can choose to stake OHM for gOHM, which receives the Base Staking Rate (“BSR”). During Olympus’ bootstrapping phase, this rate was intended to reflect the expected growth of the network. The BSR now serves as a demand driver for OHM as well as a reference rate against which productive economic activity (lending, liquidity provision, etc.) is measured. Furthermore, it acts as a foundation for OHM bonds to develop a yield curve across different expiries. +OHM holders can choose to stake OHM for gOHM, which receives the Base Staking Rate (“BSR”). During Olympus’ bootstrapping phase, this rate was intended to reflect the expected growth of the network. The BSR now serves as a demand driver for OHM as well as a reference rate against which productive economic activity (lending, liquidity provision, etc.) is measured. Furthermore, it acts as a foundation for OHM bonds to develop a yield curve across different expiries. The BSR is set by governance. -$$ -gOHM = OHM*Index -$$ + gOHM = OHM * Index + +where `Index` is an increasing number based on the BSR. \ No newline at end of file diff --git a/docs/overview/02_bonding.md b/docs/overview/02_bonding.md new file mode 100644 index 0000000..54e9d73 --- /dev/null +++ b/docs/overview/02_bonding.md @@ -0,0 +1,39 @@ +# Bonds + +## Overview +Olympus bonds are a financial primitive that allow transacting assets, often between the protocol and individual stakeholders, over a specified time-period and at completely market-driven prices. In other words, Olympus bonds are a market-driven pricing mechanism for any two ERC-20 tokens that does not rely on third parties like oracles. + +## Bond mechanics +Bonds are a financial primitive that allow transacting assets, often between the protocol and individual stakeholders, over a specified time-period and at completely market-driven prices. The bonds pricing mechanism is dictated by a modified dutch auction, called a Sequential Dutch Auction (SDA), which is solely driven by market actors and does not rely on oracles. + + +### Purchasing a bond +When purchasing a bond, purchasers commit a capital sum upfront in return for OHM upon maturity. Thus, a bond’s profit is uncertain and dependent on the price of OHM at the time of maturity. + +Bond payouts are dictated by their current discount percentage. A **positive** discount percentage indicates that the bond is offering a price less than the market price. Likewise, a **negative** discount percentage on a bond is offering a price greater than the market price. + +This variable discount rate is how a bond market internally governs its supply by responding to demand. This ensures that a bond market’s supply is sold over the specified period of time. + +:::info +More information on bonds can be found in the +[Bond Protocol documentation](https://docs.bondprotocol.finance/) +::: + +## Types of Olympus bonds + +### Reserve Bonds +Reserve Bonds are bonds which sell OHM at a discount to acquire treasury reserve assets. Reserve bonds serve a dual purpose, of not only stabilizing OHM price in bullish market conditions, but also accumulating the profits from these bonds as treasury reserves. These accumulated reserves are later used to stabilize the price in bearish conditions using Inverse Bonds, described below. + +### Inverse Bonds +Inverse Bonds are bonds which sell Reserve assets (generally USD stablecoins) in exchange for OHM, the inverse to Reserve Bonds. Like Reserve Bonds, these bonds are used to stabilize the OHM price. +Unlike reserve bonds, they vest instantly, and are the core mechanism of absorbing sell pressure from the market. + +### OHM Bonds +OHM bonds are bonds which sell OHM for OHM. The purpose of these is to transition off of gOHM staking, which is perpetual and fully liquid, into a time-locked, semi-liquid form of staking. + +More information on OHM bonds can be found in the whitepaper: +[Liquid Interest Rate Markets through Olympus Bonds](https://hackmd.io/@HMyg0dxkQ96YOMpI30o8PA/mbga) + +### Liquidity Bonds +Liquidity Bonds are similar to Reserve Bonds, except that they bond in Liquidity Provider (LP) tokens issued by an AMM. These bonds are used when there is a need to accumulate more liquidity. + diff --git a/docs/treasury/index.md b/docs/overview/03_treasury.md similarity index 75% rename from docs/treasury/index.md rename to docs/overview/03_treasury.md index f34c49a..0a94ff0 100644 --- a/docs/treasury/index.md +++ b/docs/overview/03_treasury.md @@ -1,14 +1,10 @@ ---- -sidebar_position: 1 ---- - # Treasury -The Olympus Treasury is a key function of the protocol. The Treasury represents all assets owned and controlled by the protocol. +The Treasury is a key component of the Olympus protocol. The Treasury represents all assets owned and controlled by the protocol. The primary responsibility of the Treasury is to ensure OHM liquidity on open markets and stabilize OHM with direct market operations in certain situations. Secondarily, the treasury manages a set of strategic assets for the long term benefit of the protocol. -The main assets, reserves and OHM liquidity positions, are called protocol reserve assets and are held in the on-chain treasury contract, protocol controlled assets are managed via secondary contracts (called allocators) and assets that cannot be managed via contracts are managed by the Olympus DAO via multisigs and are called DAO controlled assets. +The main assets, reserves and OHM liquidity positions, are called protocol reserve assets and are held in the on-chain treasury contract. Protocol controlled assets are managed via secondary contracts (called allocators) and assets that cannot be managed via contracts are managed by the Olympus DAO via multisigs and are called DAO controlled assets. :::info A full list of Olympus assets is available on the [Olympus Treasury Dashboard](https://app.olympusdao.finance/#/dashboard) diff --git a/docs/overview/04_pol.md b/docs/overview/04_pol.md new file mode 100644 index 0000000..2fb5ac1 --- /dev/null +++ b/docs/overview/04_pol.md @@ -0,0 +1,7 @@ +# Protocol Owned Liquidity + +## Overview + +Olympus pioneered the concept of Protocol Owned Liquidity (POL), and the Olympus protocol has always owned a substantial amount of the OHM liquidity. This ensures users and protocols are always able to swap OHM, regardless of market conditions and external events. + +The Olympus treasury keeps OHM liquidity on decentralized exchanges. With RBS, the balance between reserves and liquidity is algorithmic, with the goal to optimize the liquidity depth and reserves for robustness and long term market stability. diff --git a/docs/overview/05_range-bound.md b/docs/overview/05_range-bound.md new file mode 100644 index 0000000..c522dd1 --- /dev/null +++ b/docs/overview/05_range-bound.md @@ -0,0 +1,68 @@ +# Range Bound Stability + +## Overview + +The Olympus Protocol automatically executes market operations to absorb volatility in the market price of OHM in relation to its reserve assets. This system is called Range-Bound Stability (RBS). The initial system design operates against individual reserve assets in isolation, and has been deployed to stabilize the price of OHM against DAI. The mechanism was originally defined in the [Stabilizing Currency Through a Protocol-Enforced Range](https://docs.google.com/document/u/2/d/e/2PACX-1vSIufbgAxAAtZkITd_s57o5AmyhAnk6iYbLYvN-ATL59hQ5nC2t2BTPvA8X9DYzFa-i3PRw9ARrAS9E/pub) white paper by Zeus et al. + +![Visualization of Range](/gitbook/assets/range-denoted.png) + +RBS involves deploying treasury reserves in a downward trending market and selling OHM for reserves in an upward trending market to stabilize price. The nature of these actions causes contraction and growth of the network depending on the market environment to enforce stability. + +Liquidity is a key aspect of the Olympus system and the vast majority of OHM liquidity is [Protocol-Owned](./pol). In addition to the market operations performed by RBS, the protocol enacts policies to balance the amount of reserves deployed in liquidity and the treasury for RBS to maintain sufficient pricing depth. + +:::info +Details can be found in these resources: +- [Whitepaper](https://ohm.fyi/gentle-pegging) +- [Initial spec](https://docs.google.com/document/d/1AdPex_lMpSC_3U8UEU4hiSZIT1O1FekoCujRtYEJ0ig) +- [Video overview](https://www.loom.com/share/f3b053ad02674383908d53783eccb37e) +::: + +## RBS System Specification and Requirements + +The following specification was used to implement the RBS V1 system. It provides a succint summary of the system operates. The implementation of the concepts can be found in the Technical Guides section of the docs. + +1. Calculate and maintain a moving average price for OHM against a specified reserve asset for a configurable duration. The MA price should be updated each system epoch. +2. Calculate lower and upper bounds for the price OHM against a specified reserve asset, both “wall” and “cushion” components, from the moving average price and configurable spread variables. The price levels are calculated as: + + Lower Wall = MA * (1 - Wall Spread) + Lower Cushion = MA * (1 - Cushion Spread) + Upper Cushion = MA * (1 + Cushion Spread) + Upper Wall = MA * (1 + Wall Spread) + + where Cushion Spread < Wall Spread + + such that LW < LC < MA < UC < UW + +3. Allow users to swap OHM for reserves at the lower wall price (WL) and reserves for OHM at the upper wall price (WH) up to the specified capacity of the current walls. + + a. Capacity of the lower wall (bid) in reserves should be the amount of reserves in the Olympus Treasury multiplied by a configured bid factor (percent of reserves to use for each wall). + + Bid Capacity = Bid Factor * Reserves + + b. Capacity of the upper wall (ask) in OHM should be the capacity of the lower wall (bid) divided by the upper wall price and scaled up by the difference in spread from the lower wall to the upper wall. + + Ask Capacity = Bid Capacity * (1 + 2 * Wall Spread) + + c. When the capacity of either wall is depleted, the system should not allow additional swaps on that side until it is regenerated. + + d. When the capacity of the upper wall (ask) is depleted, the system should not reinstate a new wall with additional capacity until the current price is observed to be below the MA price for a X out of the last Y system epochs, where X and Y are configured parameters representing the regeneration threshold (X) and total number of observations (Y). Additionally, the wall should not regenerate until a minimum configured amount of time has past. + +4. Deploy a bond market to sell OHM for reserves when the current price of OHM against the reserve asset is greater than or equal to the upper cushion price at the system epoch with a capacity equal to the configured percentage of the upper wall capacity to use for the cushion. + + a. If a bond market is active on a system epoch, the system should close the market if the current price of OHM against the reserve is back below the upper cushion price or has exceeded the upper wall price. + + b. The bond market should be closed if the upper wall capacity is depleted. + + c. The bond market should be instant-swap with no vesting. + + d. The bond market should start at the upper wall price and have a minimum price of the upper cushion price. + +5. Deploy a bond market to buy OHM with reserves when the current price of OHM against the reserve asset is less than or equal to the lower cushion price at the system epoch with a capacity equal to the configured percentage of the lower wall capacity to use for the cushion. + + a. If a bond market is active on a system epoch, the system should close the market if the current price of OHM against the reserve is back above the lower cushion price or has gone below the lower wall price. + + b. The bond market should be closed if the lower wall capacity is depleted. + + c. The bond market should be instant-swap with no vesting. + + d. The bond market should start at the lower wall price and have a minimum price of the lower cushion price. diff --git a/docs/overview/06_flex-loans.md b/docs/overview/06_flex-loans.md new file mode 100644 index 0000000..99bde3a --- /dev/null +++ b/docs/overview/06_flex-loans.md @@ -0,0 +1,7 @@ +# Flex Loans + +Flex Loans is a whitelisted product offering for protocols to grow their protocol-owned liquidity through an interest free loan against perfect collateral. By depositing gOHM as a collateral asset, the borrower is able to borrow up to 100% LTV in OHM and pair this with another token to create a liquidity pair. Since the loan is in the same denomination there is no risk of liquidation and the loan will lower in LTV% as the gOHM collateral continues to receive the underlying rebases. + +Once whitelisted by Olympus, the borrower deposits gOHM into Flex Loan contract along with the other half of the intended LP token. The contract then borrows against the deposited gOHM and pairs the resulting OHM with the provided token to create an LP pair at the designated DEX of their choosing. At the moment, LP strategies for Balancer, Uniswap, Sushiswap and Curve are available. + +Repayment of the loan is possible at any moment and can either be done by paying back the OHM debt directly (from the LP position itself, or externally supplied) or by using part of the supplied gOHM collateral. diff --git a/docs/technical-guides/index.md b/docs/technical-guides/index.md deleted file mode 100644 index 588e2be..0000000 --- a/docs/technical-guides/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -sidebar_position: 1 -sidebar_label: Technical Guides ---- - -# Technical Guides - -We have two separate subsections here explaining how to interact with the website and how to interact directly with the contracts diff --git a/docs/technical/00_overview.md b/docs/technical/00_overview.md new file mode 100644 index 0000000..0531c55 --- /dev/null +++ b/docs/technical/00_overview.md @@ -0,0 +1,77 @@ +--- +sidebar_position: 0 +--- + +# Contracts Overview + +Olympus V3 is the current and latest iteration of the Olympus protocol. It is a foundation for the future of the protocol, utilizing the [Default Framework](https://github.com/fullyallocated/Default) to allow extensibility at the base layer via fully onchain governance mechanisms. There are a few major pieces to V3: the core registry (Kernel), treasury, minter, governor, and finally, the range-bound stability (RBS) system. + +## Default Framework: Kernel, Modules and Policies Summary +Olympus V3 uses the [Default Framework](https://github.com/fullyallocated/Default) to configure the protocol’s smart contracts and authorized addresses within the system. In this framework, all contract dependencies and authorizations are managed via “Actions” in the Kernel.sol contract. These actions are as follows: + +- Installing a Module +- Upgrading a Module +- Activating a Policy +- Deactivating a Policy +- Changing the Executor + - Executor is the address able to call major Kernel functions +- Migrating the Kernel + +All non-Kernel smart contracts in the protocol are either *Module Contracts* or *Policy Contracts*, which you can think of as the protocol's "back-end” and “front-end” logic, respectively. In some ways, this shares similarities to the "core" vs. "periphery" design pattern used by protocols like Uniswap: core contracts (Modules) define the core system capabilities, while periphery contracts (Policies) expose the interfaces that enable EOAs use to interact with the protocol's various features. + +#### Ownership Model: The Executor + +While most protocols have ownership defined at the contract level, Default's philosophy is to define ownership at the protocol level, within the Kernel. This is the function of the Kernel's Executor—it is the address that has the ability to execute actions within the Kernel. In Default, the executor defaults to the Deployer, but this can be set to any address using the Kernel Action _ChangeExecutor_: it's entirely possible to have a Kernel managed by a single wallet, or a multisig, but it can also be a contract. In Olympus V3, the Kernel's owner will be the Governance (Policy) contract. + +#### Kernel Migration + +The last and final action that can be performed by the Kernel is `MigrateKernel`. This action is particularly sensitive and should only be done the utmost care attention to detail. In Default, any contract that is installed or configured in a Kernel.sol needs to have an internal variable that points to the contract address of instance of the Kernel it is intended for. As a result, the same instance of a Module or a Policy cannot be reused across other Kernels. However, there may be circumstances in the future where new changes are made to the Kernel, like new Actions that are developed, gas optimizations found, or security improvements made that warrant porting the protocol contracts to a new instance of a Kernel without redeploying the contracts. + +The `MigrateKernel` Action reconfigures the internal variable for each contract registered in the Kernel, which will brick it. There are no forseeable plans to use this action in Olympus V3, but it's important to be aware of its' existence. + +### Modules + +Modules are **internal-facing smart contracts** that store shared state across the protocol, and are used as dependencies for Policies within the protocol. A module is a mix of a microservice and a data model: each Module is responsible for managing a particular data model within the system. Modules should have no dependencies of their own, and their logic should be limited to modifying their own internal state: in other words, a Module contract should not read from or the modify state of an external contract. By and large, EOAs should never call module contracts directly — if ever. + + +In Default protocols, Module contracts are referenced internally as 5 byte uppercase `KEYCODE` representing their underlying data models. For example, an ERC20 token module might have the keycode `TOKEN`, while a Treasury module might have the keycode `TRSRY`. This abstraction is intended to help clarify and distinguish where side effects occur when the protocol experiences external interactions, which should simplify both reading, writing and auditing its business logic. + +In Olympus V3, we have the following Modules: + +- `MINTR` — The Minter Module, a wrapper for the `OHM` ERC20 contract. Used for minting and burning OHM. A wrapper is used to allow the legacy ERC20 to fit in the Default architecture. +- `TRSRY` — The Treasury Module, used for depositing and withdrawing assets within the protocol. Also manages token debt allocated to policies. +- `PRICE` — Used to store historical price oracle data. Used for the functionality of the Range-Bound Stability (RBS) system. +- `RANGE` — Stores range information for the RBS system. +- `INSTR` — The Instructions Module, used for storing batched Kernel instructions for convenient proposal execution in the Parthenon policy. +- `ROLES` — The Roles module is for allowing policies to define roles, assign addresses to those roles, and for the designated `rolesAdmin` to manage those roles. + +In addition, Modules have a `VERSION()` and optional initialization logic `INIT()` thats called when the Module is integrated into the Kernel, which is mainly used when an existing module is upgraded and its state needs to be migrated. + +Modules often have permissioned functions which should only be called by authorized Policy contracts, such as minting tokens or withdrawing treasury funds. These functions include a `permissioned` modifier to ensure only authorized Policy contracts can call access them. + +### Policies + +While Module contracts define _where_ protocol side effects occur, Policy contracts define _how_ they occur. Policy contracts are **external-facing contracts** that intercept inbound calls to the protocol, then compose & route all the changes made in the protocol to the corresponding Modules. As a result, Policy contracts do have external dependencies, which are the Kernel Modules that they read and write from. + +In Default protocols, Policies must declare their dependencies to the Kernel as part of the contracts state. You will notice that each Policy contract has two functions `configureDependencies()`, which return a list of Kernel modules by their Keycode, and `requestPermissions()`, which the function selectors of the privileged functions they need to call from within the contract logic. + +Policies are not "stateless": they can store their own state. However, unlike Modules, the state in Policies should only be used internally, and never as part of another contract's logic. One mental model you can use is that Policies store local state in the protocol, while Modules store global state: if you find that any state is re-used across multiple Policies, it should most likely be abstracted into a Module. + +The following Policies are included in Olympus V3: + +Range-Bound Stability (RBS) policies: +- `Operator.sol` — Main policy for the Range-Bound Stability system. Inputs market orders, spins up bond markets and facilitates swaps with the treasury in line with the RBS spec (#Range-Bound Stability (RBS) system). +- `BondCallback.sol` — Used as a callback for bond markets. Allows bond markets to mint OHM for payouts. +- `Heart.sol` — Contract to allow easy access for keepers to call RBS keeper functions. +- `PriceConfig.sol` — Used for a specified role to adjust parameters in the `PRICE` module + +Governance policies (NOTE: Still have not been deployed): +- `Parthenon.sol` - Governor contract specially made for Default, modeled after Proof-of-Stake. +- `VohmVault.sol` - Policy for distributing voting power to vote lockers. + +General protocol and management policies: +- `TreasuryCustodian.sol` — Utility policy for allowing a specified role to modify `TRSRY` state in abnormal circumstances. Used for granting and removing approvals and managing debt. +- `Distributor.sol` - Contract for handling rebase emissions for OHM stakers. +- `RolesAdmin.sol` - Policy for managing the `ROLES` module. +- `Emergency.sol` - Emergency contract to shutdown and restart core systems in special cases. +- ` diff --git a/docs/technical/01_addresses.md b/docs/technical/01_addresses.md new file mode 100644 index 0000000..531ef96 --- /dev/null +++ b/docs/technical/01_addresses.md @@ -0,0 +1,130 @@ +# Contract Addresses + +## Olympus V3 Contracts + +### Mainnet + +| Contract | Address | +| --- | --- | +Kernel | [0x2286d7f9639e8158FaD1169e76d1FbC38247f54b](https://etherscan.io/address/0x2286d7f9639e8158FaD1169e76d1FbC38247f54b) + +#### Modules + +| Contract | Address | +| --- | --- | +TRSRY | [0xa8687A15D4BE32CC8F0a8a7B9704a4C3993D9613](https://etherscan.io/address/0xa8687A15D4BE32CC8F0a8a7B9704a4C3993D9613) +MINTR | [0xa90bFe53217da78D900749eb6Ef513ee5b6a491e](https://etherscan.io/address/0xa90bFe53217da78D900749eb6Ef513ee5b6a491e) +PRICE | [0x9Ded6A8B099c57BBEb9F81b76400a5a9C63a6880](https://etherscan.io/address/0x9Ded6A8B099c57BBEb9F81b76400a5a9C63a6880) +RANGE | [0xb212D9584cfc56EFf1117F412Fe0bBdc53673954](https://etherscan.io/address/0xb212D9584cfc56EFf1117F412Fe0bBdc53673954) +ROLES | [0x6CAfd730Dc199Df73C16420C4fCAb18E3afbfA59](https://etherscan.io/address/0x6CAfd730Dc199Df73C16420C4fCAb18E3afbfA59) + +#### Policies + +| Contract | Address | +| --- | --- | +BondCallback | [0xbf2B6E99B0E8D4c96b946c182132f5752eAa55C6](https://etherscan.io/address/0xbf2B6E99B0E8D4c96b946c182132f5752eAa55C6) +Operator | [0xbb47C3FFf4eF85703907d3ffca30de278b85df3f](https://etherscan.io/address/0xbb47C3FFf4eF85703907d3ffca30de278b85df3f) +Heart | [0xeaf46BD21dd9b263F28EEd7260a269fFba9ace6E](https://etherscan.io/address/0xeaf46BD21dd9b263F28EEd7260a269fFba9ace6E) +PriceConfig | [0x3019ff96bd8308D1B66846b795E0AeeFbDf14ba5](https://etherscan.io/address/0x3019ff96bd8308D1B66846b795E0AeeFbDf14ba5) +RolesAdmin | [0xb216d714d91eeC4F7120a732c11428857C659eC8](https://etherscan.io/address/0xb216d714d91eeC4F7120a732c11428857C659eC8) +TreasuryCustodian | [0xC9518AC915e46D707585116451Dc19c164513Ccf](https://etherscan.io/address/0xC9518AC915e46D707585116451Dc19c164513Ccf) +Distributor | [0x27e606fdb5C922F8213dC588A434BF7583697866](https://etherscan.io/address/0x27e606fdb5C922F8213dC588A434BF7583697866) +Emergency | [0x9229b0b6FA4A58D67Eb465567DaA2c6A34714A75](https://etherscan.io/address/0x9229b0b6FA4A58D67Eb465567DaA2c6A34714A75) + + +### Goerli Testnet + +| Contract | Address | +| --- | --- | +Kernel | `0xDb7cf68154bd422dF5196D90285ceA057786b4c3` + +#### Modules + +| Contract | Address | +| --- | --- | +TRSRY | `0xD8C59cFe5afbDB83D904E56D379028a2f6A07a2D` +MINTR | `0xa192fFBF73858831a137DD098a706139Ca96AbD5` +PRICE | `0x9cdb21200774E6C94B71653da213DcE6c1a31F72` +RANGE | `0x446f06f8Df7d5f627B073c6349b948B95c1f9185` +ROLES | `0xe9a9d80CE3eE32FFf7279dce4c2962eC8098f71B` + +#### Policies + +| Contract | Address | +| --- | --- | +BondCallback | `0xC1545804Fb804fdC7756e8e40c91B7581b2a2856` +Heart | `0xf3B2Df0F05C344DAc837e104fd20e77168DAc556` +Operator | `0x8C9Dc385790ee7a20289B7ED98CdaC499D3aef9D` +PriceConfig | `0x58f06599748155bCd7aE2d1e28e09A5a841a0D82` +TreasuryCustodian | `0x3DAE418f8B6382b3d3d0cb9008924BA83D2e0E87` +Distributor | `0x2716a1451BDE2B011f0D10ad6599e411d54Ec491` +RolesAdmin | `0x54FfCA586cD1B01E96a5682DF93a55d7Ef91EFF0` +Emergency | `0x196a59fB453da942f062Be4407D923129c759435` +Faucet (Testnet only) | `0xA247156a39169c0FAFf979F57361CC734e82e3d0` + +#### Dependencies + +| Contract | Address | +| --- | --- | +OHM Token | `0x0595328847AF962F951a4f8F8eE9A3Bf261e4f6b` +DAI Token | `0x41e38e70a36150D08A8c97aEC194321b5eB545A5` +OHM-DAI Balancer LP Pool | `0xd8833594420dB3D6589c1098dbDd073f52419Dba` +WETH Token (for keeper rewards) | `0x0Bb7509324cE409F7bbC4b701f932eAca9736AB7` +Mock OHM/ETH Price Feed | `0x022710a589C9796dce59A0C52cA4E36f0a5e991A` +Mock DAI/ETH Price Feed | `0xdC8E4eD326cFb730a759312B6b1727C6Ef9ca233` +Bond Auctioneer | `0x007F7A1cb838A872515c8ebd16bE4b14Ef43a222` +Bond Teller | `0x007F7735baF391e207E3aA380bb53c4Bd9a5Fed6` +Bond Aggregator | `0x007A66A2a13415DB3613C1a4dd1C942A285902d1` + +#### Privileged Testnet Accounts (Multi-sigs) + +| Contract | Address | +| --- | --- | +Executor | `0x84C0C005cF574D0e5C602EA7b366aE9c707381E0` +Guardian | `0x84C0C005cF574D0e5C602EA7b366aE9c707381E0` +Policy | `0x3dC18017cf8d8F4219dB7A8B93315fEC2d15B8a7` +Emergency | `0x3dC18017cf8d8F4219dB7A8B93315fEC2d15B8a7` + +## Periphery Contracts + +### Flex Loans +| Contract | Address | +| --- | --- | +Flex Loan contract (Incur Debt) | `0xd9d87586774Fb9d036fa95A5991474513Ff6C96E` +Curve Strategy | `0x4B152CCB613Ee248df9bb98195bC505665D6C4b2` +Uniswap Strategy | `0x39D1984051759830F0C0Ae979b4aEd776CF481E0` +Sushiswap Strategy | `0x0692bDcAa767Dc62C420B7893a1045E657771324` +Balancer Strategy | `0x48BdC486C9DF31848C62FDc85c5c77d4Be013cDC` + + +## Legacy/Old Contracts + +| Contract | Address | +| --- | --- | +OHM V2 | `0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5` +sOHM V2 | `0x04906695D6D12CF5459975d7C3C03356E4Ccd460` +gOHM | `0x0ab87046fBb341D058F17CBC4c1133F25a20a52f` +Staking | `0xB63cac384247597756545b500253ff8E607a8020` +Treasury V2 | `0x9A315BdF513367C0377FB36545857d12e85813Ef` +TreasuryExtender | `0xb32Ad041f23eAfd682F57fCe31d3eA4fd92D17af` +Distributor | `0xeeeb97A127a342656191E0313DF33D58D06B2E05` +BondDepositoryV2 | `0x9025046c6fb25Fb39e720d97a8FD881ED69a1Ef6` +Authority | `0x1c21F8EA7e39E2BA00BC12d2968D63F4acb38b7A` +YieldDirector | `0x2604170762A1dD22BB4F96C963043Cd4FC358f18` +OP Market Creator (for inverse bonds) (old) | `0xb1fA0Ac44d399b778B14af0AAF4bCF8af3437ad1` + +## Allocators + +| Contract | Address | +| --- | --- | +AaveAllocatorV2 | `0x0D33c811D0fcC711BcB388DFB3a152DE445bE66F` +FxsAllocatorV2 | `0x0f953D861347414698F34B75dbFd6e7dF1A73493` +BtrflyAllocator | `0xC8431fEb345B46c30A4576c1b5faF080fdc54e2f` +LUSDAllocatorV2 | `0x2C1700F38C38C32595CFeF3D6B0B275bC2D2a578` + +## Multisigs + +| Contract | Address | +| --- | --- | +DAO | `0x245cc372C84B3645Bf0Ffe6538620B04a217988B` +Policy | `0x0cf30dc0d48604A301dF8010cdc028C055336b2E` \ No newline at end of file diff --git a/docs/technical/02_contract-docs/Kernel.md b/docs/technical/02_contract-docs/Kernel.md new file mode 100644 index 0000000..e40d310 --- /dev/null +++ b/docs/technical/02_contract-docs/Kernel.md @@ -0,0 +1,405 @@ +# Kernel + + + + + +Main contract that acts as a central component registry for the protocol. + +*The kernel manages modules and policies. The kernel is mutated via predefined Actions,which are input from any address assigned as the executor. The executor can be changed as needed.* + +## Methods + +### activePolicies + +```solidity +function activePolicies(uint256) external view returns (contract Policy) +``` + +List of all active policies + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Policy | undefined | + +### allKeycodes + +```solidity +function allKeycodes(uint256) external view returns (Keycode) +``` + +Array of all modules currently installed. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### executeAction + +```solidity +function executeAction(enum Actions action_, address target_) external nonpayable +``` + +Main kernel function. Initiates state changes to kernel depending on Action passed in. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| action_ | enum Actions | undefined | +| target_ | address | undefined | + +### executor + +```solidity +function executor() external view returns (address) +``` + +Address that is able to initiate Actions in the kernel. Can be assigned to a multisig or governance contract. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### getDependentIndex + +```solidity +function getDependentIndex(Keycode, contract Policy) external view returns (uint256) +``` + +Helper for module dependent arrays. Prevents the need to loop through array. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | +| _1 | contract Policy | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getKeycodeForModule + +```solidity +function getKeycodeForModule(contract Module) external view returns (Keycode) +``` + +Mapping of keycode to module address. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | contract Module | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### getModuleForKeycode + +```solidity +function getModuleForKeycode(Keycode) external view returns (contract Module) +``` + +Mapping of module address to keycode. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Module | undefined | + +### getPolicyIndex + +```solidity +function getPolicyIndex(contract Policy) external view returns (uint256) +``` + +Helper to get active policy quickly. Prevents need to loop through array. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | contract Policy | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### isPolicyActive + +```solidity +function isPolicyActive(contract Policy policy_) external view returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | contract Policy | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### moduleDependents + +```solidity +function moduleDependents(Keycode, uint256) external view returns (contract Policy) +``` + +Mapping of a keycode to all of its policy dependents. Used to efficiently reconfigure policy dependencies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | +| _1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Policy | undefined | + +### modulePermissions + +```solidity +function modulePermissions(Keycode, contract Policy, bytes4) external view returns (bool) +``` + +Module <> Policy Permissions. + +*Keycode -> Policy -> Function Selector -> bool for permission* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | +| _1 | contract Policy | undefined | +| _2 | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### ActionExecuted + +```solidity +event ActionExecuted(enum Actions indexed action_, address indexed target_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| action_ `indexed` | enum Actions | undefined | +| target_ `indexed` | address | undefined | + +### PermissionsUpdated + +```solidity +event PermissionsUpdated(Keycode indexed keycode_, contract Policy indexed policy_, bytes4 funcSelector_, bool granted_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ `indexed` | Keycode | undefined | +| policy_ `indexed` | contract Policy | undefined | +| funcSelector_ | bytes4 | undefined | +| granted_ | bool | undefined | + + + +## Errors + +### InvalidKeycode + +```solidity +error InvalidKeycode(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + +### Kernel_InvalidModuleUpgrade + +```solidity +error Kernel_InvalidModuleUpgrade(Keycode module_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| module_ | Keycode | undefined | + +### Kernel_ModuleAlreadyInstalled + +```solidity +error Kernel_ModuleAlreadyInstalled(Keycode module_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| module_ | Keycode | undefined | + +### Kernel_OnlyExecutor + +```solidity +error Kernel_OnlyExecutor(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Kernel_PolicyAlreadyActivated + +```solidity +error Kernel_PolicyAlreadyActivated(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### Kernel_PolicyNotActivated + +```solidity +error Kernel_PolicyNotActivated(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### TargetNotAContract + +```solidity +error TargetNotAContract(address target_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| target_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/Module.md b/docs/technical/02_contract-docs/Module.md new file mode 100644 index 0000000..96b204b --- /dev/null +++ b/docs/technical/02_contract-docs/Module.md @@ -0,0 +1,129 @@ +# Module + + + + + +Base level extension of the kernel. Modules act as independent state components to be interacted with and mutated through policies. + +*Modules are installed and uninstalled via the executor.* + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/Policy.md b/docs/technical/02_contract-docs/Policy.md new file mode 100644 index 0000000..5a0398a --- /dev/null +++ b/docs/technical/02_contract-docs/Policy.md @@ -0,0 +1,134 @@ +# Policy + + + + + +Policies are application logic and external interface for the kernel and installed modules. + +*Policies are activated and deactivated in the kernel by the executor.Module dependencies and function permissions must be defined in appropriate functions.* + +## Methods + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] requests) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/_category_.json b/docs/technical/02_contract-docs/_category_.json new file mode 100644 index 0000000..8dca162 --- /dev/null +++ b/docs/technical/02_contract-docs/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Contract Documentation", + "position": 2, + "collapsed": true +} \ No newline at end of file diff --git a/docs/technical/02_contract-docs/modules/INSTR/INSTRv1.md b/docs/technical/02_contract-docs/modules/INSTR/INSTRv1.md new file mode 100644 index 0000000..46e5031 --- /dev/null +++ b/docs/technical/02_contract-docs/modules/INSTR/INSTRv1.md @@ -0,0 +1,255 @@ +# INSTRv1 + + + + + +Caches and executes batched instructions for protocol upgrades in the Kernel. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### getInstructions + +```solidity +function getInstructions(uint256 instructionsId_) external nonpayable returns (struct Instruction[]) +``` + +View function for retrieving a list of Instructions in an outside contract. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| instructionsId_ | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Instruction[] | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### store + +```solidity +function store(Instruction[] instructions_) external nonpayable returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| instructions_ | Instruction[] | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### storedInstructions + +```solidity +function storedInstructions(uint256, uint256) external view returns (enum Actions action, address target) +``` + +All stored instructions per count in totalInstructions + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | +| _1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| action | enum Actions | undefined | +| target | address | undefined | + +### totalInstructions + +```solidity +function totalInstructions() external view returns (uint256) +``` + +Counter of total instructions + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + + + +## Events + +### InstructionsStored + +```solidity +event InstructionsStored(uint256 instructionsId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| instructionsId | uint256 | undefined | + + + +## Errors + +### INSTR_InstructionsCannotBeEmpty + +```solidity +error INSTR_InstructionsCannotBeEmpty() +``` + + + + + + +### INSTR_InvalidAction + +```solidity +error INSTR_InvalidAction() +``` + + + + + + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/modules/INSTR/OlympusInstructions.md b/docs/technical/02_contract-docs/modules/INSTR/OlympusInstructions.md new file mode 100644 index 0000000..a2ed24f --- /dev/null +++ b/docs/technical/02_contract-docs/modules/INSTR/OlympusInstructions.md @@ -0,0 +1,287 @@ +# OlympusInstructions + + + + + +Caches and executes batched instructions for protocol upgrades in the Kernel. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### getInstructions + +```solidity +function getInstructions(uint256 instructionsId_) external view returns (struct Instruction[]) +``` + +View function for retrieving a list of Instructions in an outside contract. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| instructionsId_ | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Instruction[] | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### store + +```solidity +function store(Instruction[] instructions_) external nonpayable returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| instructions_ | Instruction[] | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### storedInstructions + +```solidity +function storedInstructions(uint256, uint256) external view returns (enum Actions action, address target) +``` + +All stored instructions per count in totalInstructions + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | +| _1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| action | enum Actions | undefined | +| target | address | undefined | + +### totalInstructions + +```solidity +function totalInstructions() external view returns (uint256) +``` + +Counter of total instructions + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + + + +## Events + +### InstructionsStored + +```solidity +event InstructionsStored(uint256 instructionsId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| instructionsId | uint256 | undefined | + + + +## Errors + +### INSTR_InstructionsCannotBeEmpty + +```solidity +error INSTR_InstructionsCannotBeEmpty() +``` + + + + + + +### INSTR_InvalidAction + +```solidity +error INSTR_InvalidAction() +``` + + + + + + +### InvalidKeycode + +```solidity +error InvalidKeycode(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### TargetNotAContract + +```solidity +error TargetNotAContract(address target_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| target_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/modules/MINTR/MINTRv1.md b/docs/technical/02_contract-docs/modules/MINTR/MINTRv1.md new file mode 100644 index 0000000..397b18c --- /dev/null +++ b/docs/technical/02_contract-docs/modules/MINTR/MINTRv1.md @@ -0,0 +1,381 @@ +# MINTRv1 + + + + + +Wrapper for minting and burning functions of OHM token. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### activate + +```solidity +function activate() external nonpayable +``` + +Re-activate minting and burning after shutdown. + + + + +### active + +```solidity +function active() external view returns (bool) +``` + +Status of the minter. If false, minting and burning OHM is disabled. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### burnOhm + +```solidity +function burnOhm(address from_, uint256 amount_) external nonpayable +``` + +Burn OHM from an address. Must have approval. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from_ | address | undefined | +| amount_ | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Emergency shutdown of minting and burning. + + + + +### decreaseMintApproval + +```solidity +function decreaseMintApproval(address policy_, uint256 amount_) external nonpayable +``` + +Decrease approval for specific withdrawer addresses + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | +| amount_ | uint256 | undefined | + +### increaseMintApproval + +```solidity +function increaseMintApproval(address policy_, uint256 amount_) external nonpayable +``` + +Increase approval for specific withdrawer addresses + +*Policies must explicity request how much they want approved before withdrawing.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | +| amount_ | uint256 | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### mintApproval + +```solidity +function mintApproval(address) external view returns (uint256) +``` + +Mapping of who is approved for minting. + +*minter -> amount. Infinite approval is max(uint256).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### mintOhm + +```solidity +function mintOhm(address to_, uint256 amount_) external nonpayable +``` + +Mint OHM to an address. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| amount_ | uint256 | undefined | + +### ohm + +```solidity +function ohm() external view returns (contract OlympusERC20Token) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract OlympusERC20Token | undefined | + + + +## Events + +### Burn + +```solidity +event Burn(address indexed policy_, address indexed from_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| from_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DecreaseMintApproval + +```solidity +event DecreaseMintApproval(address indexed policy_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| newAmount_ | uint256 | undefined | + +### IncreaseMintApproval + +```solidity +event IncreaseMintApproval(address indexed policy_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| newAmount_ | uint256 | undefined | + +### Mint + +```solidity +event Mint(address indexed policy_, address indexed to_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| to_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### MINTR_NotActive + +```solidity +error MINTR_NotActive() +``` + + + + + + +### MINTR_NotApproved + +```solidity +error MINTR_NotApproved() +``` + + + + + + +### MINTR_ZeroAmount + +```solidity +error MINTR_ZeroAmount() +``` + + + + + + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/modules/MINTR/OlympusMinter.md b/docs/technical/02_contract-docs/modules/MINTR/OlympusMinter.md new file mode 100644 index 0000000..9cc2a20 --- /dev/null +++ b/docs/technical/02_contract-docs/modules/MINTR/OlympusMinter.md @@ -0,0 +1,381 @@ +# OlympusMinter + + + + + +Wrapper for minting and burning functions of OHM token. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### activate + +```solidity +function activate() external nonpayable +``` + +Re-activate minting and burning after shutdown. + + + + +### active + +```solidity +function active() external view returns (bool) +``` + +Status of the minter. If false, minting and burning OHM is disabled. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### burnOhm + +```solidity +function burnOhm(address from_, uint256 amount_) external nonpayable +``` + +Burn OHM from an address. Must have approval. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from_ | address | undefined | +| amount_ | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Emergency shutdown of minting and burning. + + + + +### decreaseMintApproval + +```solidity +function decreaseMintApproval(address policy_, uint256 amount_) external nonpayable +``` + +Decrease approval for specific withdrawer addresses + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | +| amount_ | uint256 | undefined | + +### increaseMintApproval + +```solidity +function increaseMintApproval(address policy_, uint256 amount_) external nonpayable +``` + +Increase approval for specific withdrawer addresses + +*Policies must explicity request how much they want approved before withdrawing.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | +| amount_ | uint256 | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### mintApproval + +```solidity +function mintApproval(address) external view returns (uint256) +``` + +Mapping of who is approved for minting. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### mintOhm + +```solidity +function mintOhm(address to_, uint256 amount_) external nonpayable +``` + +Mint OHM to an address. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| amount_ | uint256 | undefined | + +### ohm + +```solidity +function ohm() external view returns (contract OlympusERC20Token) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract OlympusERC20Token | undefined | + + + +## Events + +### Burn + +```solidity +event Burn(address indexed policy_, address indexed from_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| from_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DecreaseMintApproval + +```solidity +event DecreaseMintApproval(address indexed policy_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| newAmount_ | uint256 | undefined | + +### IncreaseMintApproval + +```solidity +event IncreaseMintApproval(address indexed policy_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| newAmount_ | uint256 | undefined | + +### Mint + +```solidity +event Mint(address indexed policy_, address indexed to_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| to_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### MINTR_NotActive + +```solidity +error MINTR_NotActive() +``` + + + + + + +### MINTR_NotApproved + +```solidity +error MINTR_NotApproved() +``` + + + + + + +### MINTR_ZeroAmount + +```solidity +error MINTR_ZeroAmount() +``` + + + + + + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/modules/PRICE/OlympusPrice.md b/docs/technical/02_contract-docs/modules/PRICE/OlympusPrice.md new file mode 100644 index 0000000..7fef578 --- /dev/null +++ b/docs/technical/02_contract-docs/modules/PRICE/OlympusPrice.md @@ -0,0 +1,602 @@ +# OlympusPrice + + + + + +Price oracle data storage contract. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### changeMovingAverageDuration + +```solidity +function changeMovingAverageDuration(uint48 movingAverageDuration_) external nonpayable +``` + +Change the moving average window (duration) + +*Changing the moving average duration will erase the current observations array and require the initialize function to be called again. Ensure that you have saved the existing data and can re-populate before calling this function.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| movingAverageDuration_ | uint48 | - Moving average duration in seconds, must be a multiple of observation frequency | + +### changeObservationFrequency + +```solidity +function changeObservationFrequency(uint48 observationFrequency_) external nonpayable +``` + +Change the observation frequency of the moving average (i.e. how often a new observation is taken) + +*Changing the observation frequency clears existing observation data since it will not be taken at the right time intervals. Ensure that you have saved the existing data and/or can re-populate before calling this function.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| observationFrequency_ | uint48 | - Observation frequency in seconds, must be a divisor of the moving average duration | + +### changeUpdateThresholds + +```solidity +function changeUpdateThresholds(uint48 ohmEthUpdateThreshold_, uint48 reserveEthUpdateThreshold_) external nonpayable +``` + +Change the update thresholds for the price feeds + +*The update thresholds should be set based on the update threshold of the chainlink oracles.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| ohmEthUpdateThreshold_ | uint48 | - Maximum allowed time between OHM/ETH price feed updates | +| reserveEthUpdateThreshold_ | uint48 | - Maximum allowed time between Reserve/ETH price feed updates | + +### cumulativeObs + +```solidity +function cumulativeObs() external view returns (uint256) +``` + +Running sum of observations to calculate the moving average price from + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + +Number of decimals in the price values provided by the contract. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### getCurrentPrice + +```solidity +function getCurrentPrice() external view returns (uint256) +``` + +Get the current price of OHM in the Reserve asset from the price feeds + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getLastPrice + +```solidity +function getLastPrice() external view returns (uint256) +``` + +Get the last stored price observation of OHM in the Reserve asset + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getMovingAverage + +```solidity +function getMovingAverage() external view returns (uint256) +``` + +Get the moving average of OHM in the Reserve asset over the defined window (see movingAverageDuration and observationFrequency). + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### initialize + +```solidity +function initialize(uint256[] startObservations_, uint48 lastObservationTime_) external nonpayable +``` + +Initialize the price moduleAccess restricted to activated policies + +*This function must be called after the Price module is deployed to activate it and after updating the observationFrequency or movingAverageDuration (in certain cases) in order for the Price module to function properly.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| startObservations_ | uint256[] | - Array of observations to initialize the moving average with. Must be of length numObservations. | +| lastObservationTime_ | uint48 | - Unix timestamp of last observation being provided (in seconds). | + +### initialized + +```solidity +function initialized() external view returns (bool) +``` + +Whether the price module is initialized (and therefore active). + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### lastObservationTime + +```solidity +function lastObservationTime() external view returns (uint48) +``` + +Unix timestamp of last observation (in seconds). + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### movingAverageDuration + +```solidity +function movingAverageDuration() external view returns (uint48) +``` + +Duration (in seconds) over which the moving average is calculated. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### nextObsIndex + +```solidity +function nextObsIndex() external view returns (uint32) +``` + +Index of the next observation to make. The current value at this index is the oldest observation. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint32 | undefined | + +### numObservations + +```solidity +function numObservations() external view returns (uint32) +``` + +Number of observations used in the moving average calculation. Computed from movingAverageDuration / observationFrequency. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint32 | undefined | + +### observationFrequency + +```solidity +function observationFrequency() external view returns (uint48) +``` + +Frequency (in seconds) that observations should be stored. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### observations + +```solidity +function observations(uint256) external view returns (uint256) +``` + +Array of price observations. Check nextObsIndex to determine latest data point. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### ohmEthPriceFeed + +```solidity +function ohmEthPriceFeed() external view returns (contract AggregatorV2V3Interface) +``` + +OHM/ETH price feed + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract AggregatorV2V3Interface | undefined | + +### ohmEthUpdateThreshold + +```solidity +function ohmEthUpdateThreshold() external view returns (uint48) +``` + +Maximum expected time between OHM/ETH price feed updates + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### reserveEthPriceFeed + +```solidity +function reserveEthPriceFeed() external view returns (contract AggregatorV2V3Interface) +``` + +Reserve/ETH price feed + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract AggregatorV2V3Interface | undefined | + +### reserveEthUpdateThreshold + +```solidity +function reserveEthUpdateThreshold() external view returns (uint48) +``` + +Maximum expected time between OHM/ETH price feed updates + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### updateMovingAverage + +```solidity +function updateMovingAverage() external nonpayable +``` + +Trigger an update of the moving average. Permissioned. + +*This function does not have a time-gating on the observationFrequency on this contract. It is set on the Heart policy contract. The Heart beat frequency should be set to the same value as the observationFrequency.* + + + + +## Events + +### MovingAverageDurationChanged + +```solidity +event MovingAverageDurationChanged(uint48 movingAverageDuration_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| movingAverageDuration_ | uint48 | undefined | + +### NewObservation + +```solidity +event NewObservation(uint256 timestamp_, uint256 price_, uint256 movingAverage_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| timestamp_ | uint256 | undefined | +| price_ | uint256 | undefined | +| movingAverage_ | uint256 | undefined | + +### ObservationFrequencyChanged + +```solidity +event ObservationFrequencyChanged(uint48 observationFrequency_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| observationFrequency_ | uint48 | undefined | + +### UpdateThresholdsChanged + +```solidity +event UpdateThresholdsChanged(uint48 ohmEthUpdateThreshold_, uint48 reserveEthUpdateThreshold_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| ohmEthUpdateThreshold_ | uint48 | undefined | +| reserveEthUpdateThreshold_ | uint48 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### Price_AlreadyInitialized + +```solidity +error Price_AlreadyInitialized() +``` + + + + + + +### Price_BadFeed + +```solidity +error Price_BadFeed(address priceFeed) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| priceFeed | address | undefined | + +### Price_InvalidParams + +```solidity +error Price_InvalidParams() +``` + + + + + + +### Price_NotInitialized + +```solidity +error Price_NotInitialized() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/modules/PRICE/PRICEv1.md b/docs/technical/02_contract-docs/modules/PRICE/PRICEv1.md new file mode 100644 index 0000000..28658ab --- /dev/null +++ b/docs/technical/02_contract-docs/modules/PRICE/PRICEv1.md @@ -0,0 +1,602 @@ +# PRICEv1 + + + + + +Price oracle data storage + +*The Olympus Price Oracle contract provides a standard interface for OHM price data against a reserve asset. It also implements a moving average price calculation (same as a TWAP) on the price feed data over a configured duration and observation frequency. The data provided by this contract is used by the Olympus Range Operator to perform market operations. The Olympus Price Oracle is updated each epoch by the Olympus Heart contract.* + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### changeMovingAverageDuration + +```solidity +function changeMovingAverageDuration(uint48 movingAverageDuration_) external nonpayable +``` + +Change the moving average window (duration) + +*Changing the moving average duration will erase the current observations array and require the initialize function to be called again. Ensure that you have saved the existing data and can re-populate before calling this function.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| movingAverageDuration_ | uint48 | - Moving average duration in seconds, must be a multiple of observation frequency | + +### changeObservationFrequency + +```solidity +function changeObservationFrequency(uint48 observationFrequency_) external nonpayable +``` + +Change the observation frequency of the moving average (i.e. how often a new observation is taken) + +*Changing the observation frequency clears existing observation data since it will not be taken at the right time intervals. Ensure that you have saved the existing data and/or can re-populate before calling this function.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| observationFrequency_ | uint48 | - Observation frequency in seconds, must be a divisor of the moving average duration | + +### changeUpdateThresholds + +```solidity +function changeUpdateThresholds(uint48 ohmEthUpdateThreshold_, uint48 reserveEthUpdateThreshold_) external nonpayable +``` + +Change the update thresholds for the price feeds + +*The update thresholds should be set based on the update threshold of the chainlink oracles.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| ohmEthUpdateThreshold_ | uint48 | - Maximum allowed time between OHM/ETH price feed updates | +| reserveEthUpdateThreshold_ | uint48 | - Maximum allowed time between Reserve/ETH price feed updates | + +### cumulativeObs + +```solidity +function cumulativeObs() external view returns (uint256) +``` + +Running sum of observations to calculate the moving average price from + +*See getMovingAverage()* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + +Number of decimals in the price values provided by the contract. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### getCurrentPrice + +```solidity +function getCurrentPrice() external view returns (uint256) +``` + +Get the current price of OHM in the Reserve asset from the price feeds + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getLastPrice + +```solidity +function getLastPrice() external view returns (uint256) +``` + +Get the last stored price observation of OHM in the Reserve asset + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getMovingAverage + +```solidity +function getMovingAverage() external view returns (uint256) +``` + +Get the moving average of OHM in the Reserve asset over the defined window (see movingAverageDuration and observationFrequency). + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### initialize + +```solidity +function initialize(uint256[] startObservations_, uint48 lastObservationTime_) external nonpayable +``` + +Initialize the price moduleAccess restricted to activated policies + +*This function must be called after the Price module is deployed to activate it and after updating the observationFrequency or movingAverageDuration (in certain cases) in order for the Price module to function properly.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| startObservations_ | uint256[] | - Array of observations to initialize the moving average with. Must be of length numObservations. | +| lastObservationTime_ | uint48 | - Unix timestamp of last observation being provided (in seconds). | + +### initialized + +```solidity +function initialized() external view returns (bool) +``` + +Whether the price module is initialized (and therefore active). + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### lastObservationTime + +```solidity +function lastObservationTime() external view returns (uint48) +``` + +Unix timestamp of last observation (in seconds). + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### movingAverageDuration + +```solidity +function movingAverageDuration() external view returns (uint48) +``` + +Duration (in seconds) over which the moving average is calculated. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### nextObsIndex + +```solidity +function nextObsIndex() external view returns (uint32) +``` + +Index of the next observation to make. The current value at this index is the oldest observation. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint32 | undefined | + +### numObservations + +```solidity +function numObservations() external view returns (uint32) +``` + +Number of observations used in the moving average calculation. Computed from movingAverageDuration / observationFrequency. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint32 | undefined | + +### observationFrequency + +```solidity +function observationFrequency() external view returns (uint48) +``` + +Frequency (in seconds) that observations should be stored. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### observations + +```solidity +function observations(uint256) external view returns (uint256) +``` + +Array of price observations. Check nextObsIndex to determine latest data point. + +*Observations are stored in a ring buffer where the moving average is the sum of all observations divided by the number of observations. Observations can be cleared by changing the movingAverageDuration or observationFrequency and must be re-initialized.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### ohmEthPriceFeed + +```solidity +function ohmEthPriceFeed() external view returns (contract AggregatorV2V3Interface) +``` + +OHM/ETH price feed + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract AggregatorV2V3Interface | undefined | + +### ohmEthUpdateThreshold + +```solidity +function ohmEthUpdateThreshold() external view returns (uint48) +``` + +Maximum expected time between OHM/ETH price feed updates + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### reserveEthPriceFeed + +```solidity +function reserveEthPriceFeed() external view returns (contract AggregatorV2V3Interface) +``` + +Reserve/ETH price feed + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract AggregatorV2V3Interface | undefined | + +### reserveEthUpdateThreshold + +```solidity +function reserveEthUpdateThreshold() external view returns (uint48) +``` + +Maximum expected time between OHM/ETH price feed updates + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint48 | undefined | + +### updateMovingAverage + +```solidity +function updateMovingAverage() external nonpayable +``` + +Trigger an update of the moving average. Permissioned. + +*This function does not have a time-gating on the observationFrequency on this contract. It is set on the Heart policy contract. The Heart beat frequency should be set to the same value as the observationFrequency.* + + + + +## Events + +### MovingAverageDurationChanged + +```solidity +event MovingAverageDurationChanged(uint48 movingAverageDuration_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| movingAverageDuration_ | uint48 | undefined | + +### NewObservation + +```solidity +event NewObservation(uint256 timestamp_, uint256 price_, uint256 movingAverage_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| timestamp_ | uint256 | undefined | +| price_ | uint256 | undefined | +| movingAverage_ | uint256 | undefined | + +### ObservationFrequencyChanged + +```solidity +event ObservationFrequencyChanged(uint48 observationFrequency_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| observationFrequency_ | uint48 | undefined | + +### UpdateThresholdsChanged + +```solidity +event UpdateThresholdsChanged(uint48 ohmEthUpdateThreshold_, uint48 reserveEthUpdateThreshold_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| ohmEthUpdateThreshold_ | uint48 | undefined | +| reserveEthUpdateThreshold_ | uint48 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### Price_AlreadyInitialized + +```solidity +error Price_AlreadyInitialized() +``` + + + + + + +### Price_BadFeed + +```solidity +error Price_BadFeed(address priceFeed) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| priceFeed | address | undefined | + +### Price_InvalidParams + +```solidity +error Price_InvalidParams() +``` + + + + + + +### Price_NotInitialized + +```solidity +error Price_NotInitialized() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/modules/RANGE/OlympusRange.md b/docs/technical/02_contract-docs/modules/RANGE/OlympusRange.md new file mode 100644 index 0000000..fe15473 --- /dev/null +++ b/docs/technical/02_contract-docs/modules/RANGE/OlympusRange.md @@ -0,0 +1,602 @@ +# OlympusRange + + + + + +Olympus Range data storage module + +*The Olympus Range contract stores information about the Olympus Range market operations status. It provides a standard interface for Range data, including range prices and capacities of each range side. The data provided by this contract is used by the Olympus Range Operator to perform market operations. The Olympus Range Data is updated each epoch by the Olympus Range Operator contract.* + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### ONE_HUNDRED_PERCENT + +```solidity +function ONE_HUNDRED_PERCENT() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### ONE_PERCENT + +```solidity +function ONE_PERCENT() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### active + +```solidity +function active(bool high_) external view returns (bool) +``` + +Get the status of a side of the range (whether it is active or not). + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get status for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### capacity + +```solidity +function capacity(bool high_) external view returns (uint256) +``` + +Get the capacity for a side of the range. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get capacity for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### lastActive + +```solidity +function lastActive(bool high_) external view returns (uint256) +``` + +Get the timestamp when the range was last active. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get timestamp for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### market + +```solidity +function market(bool high_) external view returns (uint256) +``` + +Get the market ID for a side of the range. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get market for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### ohm + +```solidity +function ohm() external view returns (contract ERC20) +``` + +OHM token contract address + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### price + +```solidity +function price(bool wall_, bool high_) external view returns (uint256) +``` + +Get the price for the wall or cushion for a side of the range. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wall_ | bool | - Specifies the band to get the price for (true = wall, false = cushion). | +| high_ | bool | - Specifies the side of the range to get the price for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### range + +```solidity +function range() external view returns (struct RANGEv1.Range) +``` + +Get the full Range data in a struct. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | RANGEv1.Range | undefined | + +### regenerate + +```solidity +function regenerate(bool high_, uint256 capacity_) external nonpayable +``` + +Regenerate a side of the range to a specific capacity.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to regenerate (true = high side, false = low side). | +| capacity_ | uint256 | - Amount to set the capacity to (OHM tokens for high side, Reserve tokens for low side). | + +### reserve + +```solidity +function reserve() external view returns (contract ERC20) +``` + +Reserve token contract address + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### setSpreads + +```solidity +function setSpreads(uint256 cushionSpread_, uint256 wallSpread_) external nonpayable +``` + +Set the wall and cushion spreads.Access restricted to activated policies. + +*The new spreads will not go into effect until the next time updatePrices() is called.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionSpread_ | uint256 | - Percent spread to set the cushions at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%). | +| wallSpread_ | uint256 | - Percent spread to set the walls at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%). | + +### setThresholdFactor + +```solidity +function setThresholdFactor(uint256 thresholdFactor_) external nonpayable +``` + +Set the threshold factor for when a wall is considered "down".Access restricted to activated policies. + +*The new threshold factor will not go into effect until the next time regenerate() is called for each side of the wall.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| thresholdFactor_ | uint256 | - Percent of capacity that the wall should close below, assumes 2 decimals (i.e. 1000 = 10%). | + +### spread + +```solidity +function spread(bool wall_) external view returns (uint256) +``` + +Get the spread for the wall or cushion band. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wall_ | bool | - Specifies the band to get the spread for (true = wall, false = cushion). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### thresholdFactor + +```solidity +function thresholdFactor() external view returns (uint256) +``` + +Threshold factor for the change, a percent in 2 decimals (i.e. 1000 = 10%). Determines how much of the capacity must be spent before the side is taken down. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### updateCapacity + +```solidity +function updateCapacity(bool high_, uint256 capacity_) external nonpayable +``` + +Update the capacity for a side of the range.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to update capacity for (true = high side, false = low side). | +| capacity_ | uint256 | - Amount to set the capacity to (OHM tokens for high side, Reserve tokens for low side). | + +### updateMarket + +```solidity +function updateMarket(bool high_, uint256 market_, uint256 marketCapacity_) external nonpayable +``` + +Update the market ID (cushion) for a side of the range.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to update market for (true = high side, false = low side). | +| market_ | uint256 | - Market ID to set for the side. | +| marketCapacity_ | uint256 | - Amount to set the last market capacity to (OHM tokens for high side, Reserve tokens for low side). | + +### updatePrices + +```solidity +function updatePrices(uint256 movingAverage_) external nonpayable +``` + +Update the prices for the low and high sides.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| movingAverage_ | uint256 | - Current moving average price to set range prices from. | + + + +## Events + +### CushionDown + +```solidity +event CushionDown(bool high_, uint256 timestamp_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | + +### CushionUp + +```solidity +event CushionUp(bool high_, uint256 timestamp_, uint256 capacity_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | +| capacity_ | uint256 | undefined | + +### PricesChanged + +```solidity +event PricesChanged(uint256 wallLowPrice_, uint256 cushionLowPrice_, uint256 cushionHighPrice_, uint256 wallHighPrice_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wallLowPrice_ | uint256 | undefined | +| cushionLowPrice_ | uint256 | undefined | +| cushionHighPrice_ | uint256 | undefined | +| wallHighPrice_ | uint256 | undefined | + +### SpreadsChanged + +```solidity +event SpreadsChanged(uint256 cushionSpread_, uint256 wallSpread_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionSpread_ | uint256 | undefined | +| wallSpread_ | uint256 | undefined | + +### ThresholdFactorChanged + +```solidity +event ThresholdFactorChanged(uint256 thresholdFactor_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| thresholdFactor_ | uint256 | undefined | + +### WallDown + +```solidity +event WallDown(bool high_, uint256 timestamp_, uint256 capacity_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | +| capacity_ | uint256 | undefined | + +### WallUp + +```solidity +event WallUp(bool high_, uint256 timestamp_, uint256 capacity_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | +| capacity_ | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### RANGE_InvalidParams + +```solidity +error RANGE_InvalidParams() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/modules/RANGE/RANGEv1.md b/docs/technical/02_contract-docs/modules/RANGE/RANGEv1.md new file mode 100644 index 0000000..0c1e30d --- /dev/null +++ b/docs/technical/02_contract-docs/modules/RANGE/RANGEv1.md @@ -0,0 +1,568 @@ +# RANGEv1 + + + + + + + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### active + +```solidity +function active(bool high_) external view returns (bool) +``` + +Get the status of a side of the range (whether it is active or not). + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get status for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### capacity + +```solidity +function capacity(bool high_) external view returns (uint256) +``` + +Get the capacity for a side of the range. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get capacity for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### lastActive + +```solidity +function lastActive(bool high_) external view returns (uint256) +``` + +Get the timestamp when the range was last active. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get timestamp for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### market + +```solidity +function market(bool high_) external view returns (uint256) +``` + +Get the market ID for a side of the range. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to get market for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### ohm + +```solidity +function ohm() external view returns (contract ERC20) +``` + +OHM token contract address + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### price + +```solidity +function price(bool wall_, bool high_) external view returns (uint256) +``` + +Get the price for the wall or cushion for a side of the range. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wall_ | bool | - Specifies the band to get the price for (true = wall, false = cushion). | +| high_ | bool | - Specifies the side of the range to get the price for (true = high side, false = low side). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### range + +```solidity +function range() external view returns (struct RANGEv1.Range) +``` + +Get the full Range data in a struct. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | RANGEv1.Range | undefined | + +### regenerate + +```solidity +function regenerate(bool high_, uint256 capacity_) external nonpayable +``` + +Regenerate a side of the range to a specific capacity.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to regenerate (true = high side, false = low side). | +| capacity_ | uint256 | - Amount to set the capacity to (OHM tokens for high side, Reserve tokens for low side). | + +### reserve + +```solidity +function reserve() external view returns (contract ERC20) +``` + +Reserve token contract address + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### setSpreads + +```solidity +function setSpreads(uint256 cushionSpread_, uint256 wallSpread_) external nonpayable +``` + +Set the wall and cushion spreads.Access restricted to activated policies. + +*The new spreads will not go into effect until the next time updatePrices() is called.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionSpread_ | uint256 | - Percent spread to set the cushions at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%). | +| wallSpread_ | uint256 | - Percent spread to set the walls at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%). | + +### setThresholdFactor + +```solidity +function setThresholdFactor(uint256 thresholdFactor_) external nonpayable +``` + +Set the threshold factor for when a wall is considered "down".Access restricted to activated policies. + +*The new threshold factor will not go into effect until the next time regenerate() is called for each side of the wall.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| thresholdFactor_ | uint256 | - Percent of capacity that the wall should close below, assumes 2 decimals (i.e. 1000 = 10%). | + +### spread + +```solidity +function spread(bool wall_) external view returns (uint256) +``` + +Get the spread for the wall or cushion band. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wall_ | bool | - Specifies the band to get the spread for (true = wall, false = cushion). | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### thresholdFactor + +```solidity +function thresholdFactor() external view returns (uint256) +``` + +Threshold factor for the change, a percent in 2 decimals (i.e. 1000 = 10%). Determines how much of the capacity must be spent before the side is taken down. + +*A threshold is required so that a wall is not "active" with a capacity near zero, but unable to be depleted practically (dust).* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### updateCapacity + +```solidity +function updateCapacity(bool high_, uint256 capacity_) external nonpayable +``` + +Update the capacity for a side of the range.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to update capacity for (true = high side, false = low side). | +| capacity_ | uint256 | - Amount to set the capacity to (OHM tokens for high side, Reserve tokens for low side). | + +### updateMarket + +```solidity +function updateMarket(bool high_, uint256 market_, uint256 marketCapacity_) external nonpayable +``` + +Update the market ID (cushion) for a side of the range.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Specifies the side of the range to update market for (true = high side, false = low side). | +| market_ | uint256 | - Market ID to set for the side. | +| marketCapacity_ | uint256 | - Amount to set the last market capacity to (OHM tokens for high side, Reserve tokens for low side). | + +### updatePrices + +```solidity +function updatePrices(uint256 movingAverage_) external nonpayable +``` + +Update the prices for the low and high sides.Access restricted to activated policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| movingAverage_ | uint256 | - Current moving average price to set range prices from. | + + + +## Events + +### CushionDown + +```solidity +event CushionDown(bool high_, uint256 timestamp_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | + +### CushionUp + +```solidity +event CushionUp(bool high_, uint256 timestamp_, uint256 capacity_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | +| capacity_ | uint256 | undefined | + +### PricesChanged + +```solidity +event PricesChanged(uint256 wallLowPrice_, uint256 cushionLowPrice_, uint256 cushionHighPrice_, uint256 wallHighPrice_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wallLowPrice_ | uint256 | undefined | +| cushionLowPrice_ | uint256 | undefined | +| cushionHighPrice_ | uint256 | undefined | +| wallHighPrice_ | uint256 | undefined | + +### SpreadsChanged + +```solidity +event SpreadsChanged(uint256 cushionSpread_, uint256 wallSpread_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionSpread_ | uint256 | undefined | +| wallSpread_ | uint256 | undefined | + +### ThresholdFactorChanged + +```solidity +event ThresholdFactorChanged(uint256 thresholdFactor_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| thresholdFactor_ | uint256 | undefined | + +### WallDown + +```solidity +event WallDown(bool high_, uint256 timestamp_, uint256 capacity_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | +| capacity_ | uint256 | undefined | + +### WallUp + +```solidity +event WallUp(bool high_, uint256 timestamp_, uint256 capacity_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | undefined | +| timestamp_ | uint256 | undefined | +| capacity_ | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### RANGE_InvalidParams + +```solidity +error RANGE_InvalidParams() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/modules/ROLES/OlympusRoles.md b/docs/technical/02_contract-docs/modules/ROLES/OlympusRoles.md new file mode 100644 index 0000000..945c9e6 --- /dev/null +++ b/docs/technical/02_contract-docs/modules/ROLES/OlympusRoles.md @@ -0,0 +1,338 @@ +# OlympusRoles + + + + + +Module that holds multisig roles needed by various policies. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### ensureValidRole + +```solidity +function ensureValidRole(bytes32 role_) external pure +``` + +Function that checks if role is valid (all lower case) + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + +### hasRole + +```solidity +function hasRole(address, bytes32) external view returns (bool) +``` + +Mapping for if an address has a policy-defined role. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### removeRole + +```solidity +function removeRole(bytes32 role_, address addr_) external nonpayable +``` + +Function to revoke policy-defined roles from some address. Can only be called by admin. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| addr_ | address | undefined | + +### requireRole + +```solidity +function requireRole(bytes32 role_, address caller_) external view +``` + +"Modifier" to restrict policy function access to certain addresses with a role. + +*Roles are defined in the policy and granted by the ROLES admin.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| caller_ | address | undefined | + +### saveRole + +```solidity +function saveRole(bytes32 role_, address addr_) external nonpayable +``` + +Function to grant policy-defined roles to some address. Can only be called by admin. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| addr_ | address | undefined | + + + +## Events + +### RoleGranted + +```solidity +event RoleGranted(bytes32 indexed role_, address indexed addr_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ `indexed` | bytes32 | undefined | +| addr_ `indexed` | address | undefined | + +### RoleRevoked + +```solidity +event RoleRevoked(bytes32 indexed role_, address indexed addr_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ `indexed` | bytes32 | undefined | +| addr_ `indexed` | address | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### ROLES_AddressAlreadyHasRole + +```solidity +error ROLES_AddressAlreadyHasRole(address addr_, bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| addr_ | address | undefined | +| role_ | bytes32 | undefined | + +### ROLES_AddressDoesNotHaveRole + +```solidity +error ROLES_AddressDoesNotHaveRole(address addr_, bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| addr_ | address | undefined | +| role_ | bytes32 | undefined | + +### ROLES_InvalidRole + +```solidity +error ROLES_InvalidRole(bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + +### ROLES_RequireRole + +```solidity +error ROLES_RequireRole(bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + +### ROLES_RoleDoesNotExist + +```solidity +error ROLES_RoleDoesNotExist(bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + + diff --git a/docs/technical/02_contract-docs/modules/ROLES/ROLESv1.md b/docs/technical/02_contract-docs/modules/ROLES/ROLESv1.md new file mode 100644 index 0000000..110df4f --- /dev/null +++ b/docs/technical/02_contract-docs/modules/ROLES/ROLESv1.md @@ -0,0 +1,338 @@ +# ROLESv1 + + + + + + + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### ensureValidRole + +```solidity +function ensureValidRole(bytes32 role_) external pure +``` + +Function that checks if role is valid (all lower case) + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + +### hasRole + +```solidity +function hasRole(address, bytes32) external view returns (bool) +``` + +Mapping for if an address has a policy-defined role. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | bytes32 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### removeRole + +```solidity +function removeRole(bytes32 role_, address addr_) external nonpayable +``` + +Function to revoke policy-defined roles from some address. Can only be called by admin. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| addr_ | address | undefined | + +### requireRole + +```solidity +function requireRole(bytes32 role_, address caller_) external nonpayable +``` + +"Modifier" to restrict policy function access to certain addresses with a role. + +*Roles are defined in the policy and granted by the ROLES admin.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| caller_ | address | undefined | + +### saveRole + +```solidity +function saveRole(bytes32 role_, address addr_) external nonpayable +``` + +Function to grant policy-defined roles to some address. Can only be called by admin. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| addr_ | address | undefined | + + + +## Events + +### RoleGranted + +```solidity +event RoleGranted(bytes32 indexed role_, address indexed addr_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ `indexed` | bytes32 | undefined | +| addr_ `indexed` | address | undefined | + +### RoleRevoked + +```solidity +event RoleRevoked(bytes32 indexed role_, address indexed addr_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ `indexed` | bytes32 | undefined | +| addr_ `indexed` | address | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### ROLES_AddressAlreadyHasRole + +```solidity +error ROLES_AddressAlreadyHasRole(address addr_, bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| addr_ | address | undefined | +| role_ | bytes32 | undefined | + +### ROLES_AddressDoesNotHaveRole + +```solidity +error ROLES_AddressDoesNotHaveRole(address addr_, bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| addr_ | address | undefined | +| role_ | bytes32 | undefined | + +### ROLES_InvalidRole + +```solidity +error ROLES_InvalidRole(bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + +### ROLES_RequireRole + +```solidity +error ROLES_RequireRole(bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + +### ROLES_RoleDoesNotExist + +```solidity +error ROLES_RoleDoesNotExist(bytes32 role_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | + + diff --git a/docs/technical/02_contract-docs/modules/ROLES/RolesConsumer.md b/docs/technical/02_contract-docs/modules/ROLES/RolesConsumer.md new file mode 100644 index 0000000..7950134 --- /dev/null +++ b/docs/technical/02_contract-docs/modules/ROLES/RolesConsumer.md @@ -0,0 +1,32 @@ +# RolesConsumer + + + + + +Abstract contract to have the `onlyRole` modifier + +*Inheriting this automatically makes ROLES module a dependency* + +## Methods + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + + + + diff --git a/docs/technical/02_contract-docs/modules/TRSRY/OlympusTreasury.md b/docs/technical/02_contract-docs/modules/TRSRY/OlympusTreasury.md new file mode 100644 index 0000000..9fa2f5c --- /dev/null +++ b/docs/technical/02_contract-docs/modules/TRSRY/OlympusTreasury.md @@ -0,0 +1,594 @@ +# OlympusTreasury + + + + + +Treasury holds all other assets under the control of the protocol. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### activate + +```solidity +function activate() external nonpayable +``` + +Re-activate withdrawals after shutdown. + + + + +### active + +```solidity +function active() external view returns (bool) +``` + +Status of the treasury. If false, no withdrawals or debt can be incurred. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Emergency shutdown of withdrawals. + + + + +### debtApproval + +```solidity +function debtApproval(address, contract ERC20) external view returns (uint256) +``` + +Mapping of who is approved to incur debt. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decreaseDebtorApproval + +```solidity +function decreaseDebtorApproval(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Decrease approval for someone to withdraw reserves as debt. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### decreaseWithdrawApproval + +```solidity +function decreaseWithdrawApproval(address withdrawer_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Decrease approval for specific withdrawer addresses + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### getReserveBalance + +```solidity +function getReserveBalance(contract ERC20 token_) external view returns (uint256) +``` + +Get total balance of assets inside the treasury + any debt taken out against those assets. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### increaseDebtorApproval + +```solidity +function increaseDebtorApproval(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Increase approval for someone to accrue debt in order to withdraw reserves. + +*Debt will generally be taken by contracts to allocate treasury funds in yield sources.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### increaseWithdrawApproval + +```solidity +function increaseWithdrawApproval(address withdrawer_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Increase approval for specific withdrawer addresses + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### incurDebt + +```solidity +function incurDebt(contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Pre-approved policies can get a loan to perform operations with treasury assets. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### repayDebt + +```solidity +function repayDebt(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Repay a debtor debt. + +*Only confirmed to safely handle standard and non-standard ERC20s.Can have unforeseen consequences with ERC777. Be careful with ERC777 as reserve.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### reserveDebt + +```solidity +function reserveDebt(contract ERC20, address) external view returns (uint256) +``` + +Debt for particular token and debtor address + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | +| _1 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### setDebt + +```solidity +function setDebt(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +An escape hatch for setting debt in special cases, like swapping reserves to another token. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### totalDebt + +```solidity +function totalDebt(contract ERC20) external view returns (uint256) +``` + +Total debt for token across all withdrawals. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### withdrawApproval + +```solidity +function withdrawApproval(address, contract ERC20) external view returns (uint256) +``` + +Mapping of who is approved for withdrawal. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### withdrawReserves + +```solidity +function withdrawReserves(address to_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Allow withdrawal of reserve funds from pre-approved addresses. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + + + +## Events + +### DebtIncurred + +```solidity +event DebtIncurred(contract ERC20 indexed token_, address indexed policy_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ `indexed` | contract ERC20 | undefined | +| policy_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DebtRepaid + +```solidity +event DebtRepaid(contract ERC20 indexed token_, address indexed policy_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ `indexed` | contract ERC20 | undefined | +| policy_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DebtSet + +```solidity +event DebtSet(contract ERC20 indexed token_, address indexed policy_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ `indexed` | contract ERC20 | undefined | +| policy_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DecreaseDebtorApproval + +```solidity +event DecreaseDebtorApproval(address indexed debtor_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### DecreaseWithdrawApproval + +```solidity +event DecreaseWithdrawApproval(address indexed withdrawer_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### IncreaseDebtorApproval + +```solidity +event IncreaseDebtorApproval(address indexed debtor_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### IncreaseWithdrawApproval + +```solidity +event IncreaseWithdrawApproval(address indexed withdrawer_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### Withdrawal + +```solidity +event Withdrawal(address indexed policy_, address indexed withdrawer_, contract ERC20 indexed token_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| withdrawer_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### TRSRY_NoDebtOutstanding + +```solidity +error TRSRY_NoDebtOutstanding() +``` + + + + + + +### TRSRY_NotActive + +```solidity +error TRSRY_NotActive() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/modules/TRSRY/TRSRYv1.md b/docs/technical/02_contract-docs/modules/TRSRY/TRSRYv1.md new file mode 100644 index 0000000..f00d71c --- /dev/null +++ b/docs/technical/02_contract-docs/modules/TRSRY/TRSRYv1.md @@ -0,0 +1,594 @@ +# TRSRYv1 + + + + + +Treasury holds all other assets under the control of the protocol. + + + +## Methods + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### activate + +```solidity +function activate() external nonpayable +``` + +Re-activate withdrawals after shutdown. + + + + +### active + +```solidity +function active() external view returns (bool) +``` + +Status of the treasury. If false, no withdrawals or debt can be incurred. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Emergency shutdown of withdrawals. + + + + +### debtApproval + +```solidity +function debtApproval(address, contract ERC20) external view returns (uint256) +``` + +Mapping of who is approved to incur debt. + +*debtor -> token -> amount. Infinite approval is max(uint256).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decreaseDebtorApproval + +```solidity +function decreaseDebtorApproval(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Decrease approval for someone to withdraw reserves as debt. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### decreaseWithdrawApproval + +```solidity +function decreaseWithdrawApproval(address withdrawer_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Decrease approval for specific withdrawer addresses + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### getReserveBalance + +```solidity +function getReserveBalance(contract ERC20 token_) external view returns (uint256) +``` + +Get total balance of assets inside the treasury + any debt taken out against those assets. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### increaseDebtorApproval + +```solidity +function increaseDebtorApproval(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Increase approval for someone to accrue debt in order to withdraw reserves. + +*Debt will generally be taken by contracts to allocate treasury funds in yield sources.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### increaseWithdrawApproval + +```solidity +function increaseWithdrawApproval(address withdrawer_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Increase approval for specific withdrawer addresses + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### incurDebt + +```solidity +function incurDebt(contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Pre-approved policies can get a loan to perform operations with treasury assets. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### repayDebt + +```solidity +function repayDebt(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Repay a debtor debt. + +*Only confirmed to safely handle standard and non-standard ERC20s.Can have unforeseen consequences with ERC777. Be careful with ERC777 as reserve.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### reserveDebt + +```solidity +function reserveDebt(contract ERC20, address) external view returns (uint256) +``` + +Debt for particular token and debtor address + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | +| _1 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### setDebt + +```solidity +function setDebt(address debtor_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +An escape hatch for setting debt in special cases, like swapping reserves to another token. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### totalDebt + +```solidity +function totalDebt(contract ERC20) external view returns (uint256) +``` + +Total debt for token across all withdrawals. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### withdrawApproval + +```solidity +function withdrawApproval(address, contract ERC20) external view returns (uint256) +``` + +Mapping of who is approved for withdrawal. + +*withdrawer -> token -> amount. Infinite approval is max(uint256).* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### withdrawReserves + +```solidity +function withdrawReserves(address to_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Allow withdrawal of reserve funds from pre-approved addresses. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + + + +## Events + +### DebtIncurred + +```solidity +event DebtIncurred(contract ERC20 indexed token_, address indexed policy_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ `indexed` | contract ERC20 | undefined | +| policy_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DebtRepaid + +```solidity +event DebtRepaid(contract ERC20 indexed token_, address indexed policy_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ `indexed` | contract ERC20 | undefined | +| policy_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DebtSet + +```solidity +event DebtSet(contract ERC20 indexed token_, address indexed policy_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ `indexed` | contract ERC20 | undefined | +| policy_ `indexed` | address | undefined | +| amount_ | uint256 | undefined | + +### DecreaseDebtorApproval + +```solidity +event DecreaseDebtorApproval(address indexed debtor_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### DecreaseWithdrawApproval + +```solidity +event DecreaseWithdrawApproval(address indexed withdrawer_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### IncreaseDebtorApproval + +```solidity +event IncreaseDebtorApproval(address indexed debtor_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| debtor_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### IncreaseWithdrawApproval + +```solidity +event IncreaseWithdrawApproval(address indexed withdrawer_, contract ERC20 indexed token_, uint256 newAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| withdrawer_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| newAmount_ | uint256 | undefined | + +### Withdrawal + +```solidity +event Withdrawal(address indexed policy_, address indexed withdrawer_, contract ERC20 indexed token_, uint256 amount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| withdrawer_ `indexed` | address | undefined | +| token_ `indexed` | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + +### TRSRY_NoDebtOutstanding + +```solidity +error TRSRY_NoDebtOutstanding() +``` + + + + + + +### TRSRY_NotActive + +```solidity +error TRSRY_NotActive() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/modules/VOTES/OlympusVotes.md b/docs/technical/02_contract-docs/modules/VOTES/OlympusVotes.md new file mode 100644 index 0000000..afe6e1d --- /dev/null +++ b/docs/technical/02_contract-docs/modules/VOTES/OlympusVotes.md @@ -0,0 +1,876 @@ +# OlympusVotes + + + + + +Votes module is the ERC20 token that represents voting power in the network. + + + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### allowance + +```solidity +function allowance(address, address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### asset + +```solidity +function asset() external view returns (contract ERC20) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### balanceOf + +```solidity +function balanceOf(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### convertToAssets + +```solidity +function convertToAssets(uint256 shares) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### convertToShares + +```solidity +function convertToShares(uint256 assets) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### deposit + +```solidity +function deposit(uint256 assets_, address receiver_) external nonpayable returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets_ | uint256 | undefined | +| receiver_ | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### gOHM + +```solidity +function gOHM() external view returns (contract ERC20) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### lastActionTimestamp + +```solidity +function lastActionTimestamp(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### lastDepositTimestamp + +```solidity +function lastDepositTimestamp(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxDeposit + +```solidity +function maxDeposit(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxMint + +```solidity +function maxMint(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxRedeem + +```solidity +function maxRedeem(address owner) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxWithdraw + +```solidity +function maxWithdraw(address owner) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### mint + +```solidity +function mint(uint256 shares_, address receiver_) external nonpayable returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares_ | uint256 | undefined | +| receiver_ | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### nonces + +```solidity +function nonces(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + +### previewDeposit + +```solidity +function previewDeposit(uint256 assets) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewMint + +```solidity +function previewMint(uint256 shares) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewRedeem + +```solidity +function previewRedeem(uint256 shares) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewWithdraw + +```solidity +function previewWithdraw(uint256 assets) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### redeem + +```solidity +function redeem(uint256 shares_, address receiver_, address owner_) external nonpayable returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares_ | uint256 | undefined | +| receiver_ | address | undefined | +| owner_ | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### resetActionTimestamp + +```solidity +function resetActionTimestamp(address _wallet) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _wallet | address | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalAssets + +```solidity +function totalAssets() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to_, uint256 amt_) external nonpayable returns (bool) +``` + +Transfers are locked for this token. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| amt_ | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from_, address to_, uint256 amount_) external nonpayable returns (bool) +``` + +TransferFrom is only allowed by permissioned policies. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from_ | address | undefined | +| to_ | address | undefined | +| amount_ | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### withdraw + +```solidity +function withdraw(uint256 assets_, address receiver_, address owner_) external nonpayable returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets_ | uint256 | undefined | +| receiver_ | address | undefined | +| owner_ | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| amount | uint256 | undefined | + +### Deposit + +```solidity +event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller `indexed` | address | undefined | +| owner `indexed` | address | undefined | +| assets | uint256 | undefined | +| shares | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| amount | uint256 | undefined | + +### Withdraw + +```solidity +event Withdraw(address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller `indexed` | address | undefined | +| receiver `indexed` | address | undefined | +| owner `indexed` | address | undefined | +| assets | uint256 | undefined | +| shares | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/modules/VOTES/VOTESv1.md b/docs/technical/02_contract-docs/modules/VOTES/VOTESv1.md new file mode 100644 index 0000000..5655d5b --- /dev/null +++ b/docs/technical/02_contract-docs/modules/VOTES/VOTESv1.md @@ -0,0 +1,876 @@ +# VOTESv1 + + + + + + + + + +## Methods + +### DOMAIN_SEPARATOR + +```solidity +function DOMAIN_SEPARATOR() external view returns (bytes32) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | undefined | + +### INIT + +```solidity +function INIT() external nonpayable +``` + +Initialization function for the module + +*This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.* + + +### KEYCODE + +```solidity +function KEYCODE() external pure returns (Keycode) +``` + +5 byte identifier for a module. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | Keycode | undefined | + +### VERSION + +```solidity +function VERSION() external pure returns (uint8 major, uint8 minor) +``` + +Returns which semantic version of a module is being implemented. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| major | uint8 | - Major version upgrade indicates breaking change to the interface. | +| minor | uint8 | - Minor version change retains backward-compatible interface. | + +### allowance + +```solidity +function allowance(address, address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### approve + +```solidity +function approve(address spender, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| spender | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### asset + +```solidity +function asset() external view returns (contract ERC20) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### balanceOf + +```solidity +function balanceOf(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### convertToAssets + +```solidity +function convertToAssets(uint256 shares) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### convertToShares + +```solidity +function convertToShares(uint256 assets) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### decimals + +```solidity +function decimals() external view returns (uint8) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### deposit + +```solidity +function deposit(uint256 assets, address receiver) external nonpayable returns (uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | +| receiver | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +### gOHM + +```solidity +function gOHM() external view returns (contract ERC20) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### lastActionTimestamp + +```solidity +function lastActionTimestamp(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### lastDepositTimestamp + +```solidity +function lastDepositTimestamp(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxDeposit + +```solidity +function maxDeposit(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxMint + +```solidity +function maxMint(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxRedeem + +```solidity +function maxRedeem(address owner) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### maxWithdraw + +```solidity +function maxWithdraw(address owner) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### mint + +```solidity +function mint(uint256 shares, address receiver) external nonpayable returns (uint256 assets) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | +| receiver | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +### name + +```solidity +function name() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### nonces + +```solidity +function nonces(address) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### permit + +```solidity +function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner | address | undefined | +| spender | address | undefined | +| value | uint256 | undefined | +| deadline | uint256 | undefined | +| v | uint8 | undefined | +| r | bytes32 | undefined | +| s | bytes32 | undefined | + +### previewDeposit + +```solidity +function previewDeposit(uint256 assets) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewMint + +```solidity +function previewMint(uint256 shares) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewRedeem + +```solidity +function previewRedeem(uint256 shares) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### previewWithdraw + +```solidity +function previewWithdraw(uint256 assets) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### redeem + +```solidity +function redeem(uint256 shares, address receiver, address owner) external nonpayable returns (uint256 assets) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | +| receiver | address | undefined | +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | + +### resetActionTimestamp + +```solidity +function resetActionTimestamp(address wallet_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wallet_ | address | undefined | + +### symbol + +```solidity +function symbol() external view returns (string) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | string | undefined | + +### totalAssets + +```solidity +function totalAssets() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### totalSupply + +```solidity +function totalSupply() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### transfer + +```solidity +function transfer(address to, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### transferFrom + +```solidity +function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from | address | undefined | +| to | address | undefined | +| amount | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### withdraw + +```solidity +function withdraw(uint256 assets, address receiver, address owner) external nonpayable returns (uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets | uint256 | undefined | +| receiver | address | undefined | +| owner | address | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| shares | uint256 | undefined | + + + +## Events + +### Approval + +```solidity +event Approval(address indexed owner, address indexed spender, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| owner `indexed` | address | undefined | +| spender `indexed` | address | undefined | +| amount | uint256 | undefined | + +### Deposit + +```solidity +event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller `indexed` | address | undefined | +| owner `indexed` | address | undefined | +| assets | uint256 | undefined | +| shares | uint256 | undefined | + +### Transfer + +```solidity +event Transfer(address indexed from, address indexed to, uint256 amount) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| from `indexed` | address | undefined | +| to `indexed` | address | undefined | +| amount | uint256 | undefined | + +### Withdraw + +```solidity +event Withdraw(address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller `indexed` | address | undefined | +| receiver `indexed` | address | undefined | +| owner `indexed` | address | undefined | +| assets | uint256 | undefined | +| shares | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Module_PolicyNotPermitted + +```solidity +error Module_PolicyNotPermitted(address policy_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/BondCallback.md b/docs/technical/02_contract-docs/policies/BondCallback.md new file mode 100644 index 0000000..fd82145 --- /dev/null +++ b/docs/technical/02_contract-docs/policies/BondCallback.md @@ -0,0 +1,426 @@ +# BondCallback + + + +> Olympus Bond Callback + + + + + +## Methods + +### MINTR + +```solidity +function MINTR() external view returns (contract MINTRv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract MINTRv1 | undefined | + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### TRSRY + +```solidity +function TRSRY() external view returns (contract TRSRYv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract TRSRYv1 | undefined | + +### aggregator + +```solidity +function aggregator() external view returns (contract IBondAggregator) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract IBondAggregator | undefined | + +### amountsForMarket + +```solidity +function amountsForMarket(uint256 id_) external view returns (uint256 in_, uint256 out_) +``` + +Returns the number of quote tokens received and payout tokens paid out for a market + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id_ | uint256 | ID of the market | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| in_ | uint256 | Amount of quote tokens bonded to the market | +| out_ | uint256 | Amount of payout tokens paid out to the market | + +### approvedMarkets + +```solidity +function approvedMarkets(address, uint256) external view returns (bool) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | +| _1 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### batchToTreasury + +```solidity +function batchToTreasury(contract ERC20[] tokens_) external nonpayable +``` + +Send tokens to the TRSRY in a batch + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokens_ | contract ERC20[] | - Array of tokens to send | + +### blacklist + +```solidity +function blacklist(address teller_, uint256 id_) external nonpayable +``` + +Remove a market ID on a teller from the whitelist + +*Shutdown function in case there's an issue with the teller* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| teller_ | address | Address of the Teller contract which serves the market | +| id_ | uint256 | ID of the market to remove from whitelist | + +### callback + +```solidity +function callback(uint256 id_, uint256 inputAmount_, uint256 outputAmount_) external nonpayable +``` + +Send payout tokens to Teller while allowing market owners to perform custom logic on received or paid out tokensMarket ID on Teller must be whitelisted + +*Must transfer the output amount of payout tokens back to the TellerShould check that the quote tokens have been transferred to the contract in the _callback function* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id_ | uint256 | ID of the market | +| inputAmount_ | uint256 | Amount of quote tokens bonded to the market | +| outputAmount_ | uint256 | Amount of payout tokens to be paid out to the market | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### ohm + +```solidity +function ohm() external view returns (contract ERC20) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### operator + +```solidity +function operator() external view returns (contract Operator) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Operator | undefined | + +### priorBalances + +```solidity +function priorBalances(contract ERC20) external view returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] requests) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### setOperator + +```solidity +function setOperator(contract Operator operator_) external nonpayable +``` + +Sets the operator contract for the callback to use to report bond purchasesMust be set before the callback is used + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| operator_ | contract Operator | - Address of the Operator contract | + +### whitelist + +```solidity +function whitelist(address teller_, uint256 id_) external nonpayable +``` + +Whitelist a teller and market ID combinationMust be callback owner + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| teller_ | address | Address of the Teller contract which serves the market | +| id_ | uint256 | ID of the market | + + + + +## Errors + +### Callback_InvalidParams + +```solidity +error Callback_InvalidParams() +``` + + + + + + +### Callback_MarketNotSupported + +```solidity +error Callback_MarketNotSupported(uint256 id) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id | uint256 | undefined | + +### Callback_TokensNotReceived + +```solidity +error Callback_TokensNotReceived() +``` + + + + + + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/Distributor.md b/docs/technical/02_contract-docs/policies/Distributor.md new file mode 100644 index 0000000..a8b0754 --- /dev/null +++ b/docs/technical/02_contract-docs/policies/Distributor.md @@ -0,0 +1,472 @@ +# Distributor + + + + + + + + + +## Methods + +### MINTR + +```solidity +function MINTR() external view returns (contract MINTRv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract MINTRv1 | undefined | + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### TRSRY + +```solidity +function TRSRY() external view returns (contract TRSRYv1) +``` + +Modules + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract TRSRYv1 | undefined | + +### addPool + +```solidity +function addPool(uint256 index_, address pool_) external nonpayable +``` + +Adds a liquidity pool to the list of pools to be minted into + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| index_ | uint256 | The index in the pools array to add the liquidity pool to. | +| pool_ | address | The address of the liquidity pool to add. | + +### bounty + +```solidity +function bounty() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### distribute + +```solidity +function distribute() external nonpayable +``` + +Send the epoch's reward to the staking contract, and mint rewards to Uniswap V2 pools. This removes opportunity cost for liquidity providers by sending rebase rewards directly into the liquidity pool. NOTE: This does not add additional emissions (user could be staked instead and get the same tokens). + + + + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### nextRewardFor + +```solidity +function nextRewardFor(address who_) external view returns (uint256) +``` + +Returns the next reward for the given address based on their OHM balance. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| who_ | address | The address to get the next reward for. | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | uint256 The next reward for the given address. | + +### pools + +```solidity +function pools(uint256) external view returns (address) +``` + +Policy state + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### removePool + +```solidity +function removePool(uint256 index_, address pool_) external nonpayable +``` + +Removes a liquidity pool from the list of pools to be minted into + +*This function is only available to an authorized user.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| index_ | uint256 | The index in the pools array of the liquidity pool to remove. | +| pool_ | address | The address of the liquidity pool to remove. | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] permissions) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| permissions | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### retrieveBounty + +```solidity +function retrieveBounty() external nonpayable returns (uint256) +``` + +Mints the bounty (if > 0) to the staking contract for distribution. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | uint256 The amount of OHM minted as a bounty. | + +### rewardRate + +```solidity +function rewardRate() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### setBounty + +```solidity +function setBounty(uint256 bounty_) external nonpayable +``` + +Adjusts the bounty + +*This function is only available to an authorized user.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| bounty_ | uint256 | The new bounty amount in OHM (9 decimals). | + +### setPools + +```solidity +function setPools(address[] pools_) external nonpayable +``` + +Sets the Uniswap V2 pools to be minted into + +*This function is only available to an authorized user.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| pools_ | address[] | The array of Uniswap V2 pools. | + +### setRewardRate + +```solidity +function setRewardRate(uint256 newRewardRate_) external nonpayable +``` + +Sets the new OHM reward rate to mint and distribute per epoch + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newRewardRate_ | uint256 | The new rate to set (9 decimals, i.e. 10_000_000 / 1_000_000_000 = 1%) | + +### triggerRebase + +```solidity +function triggerRebase() external nonpayable +``` + +Trigger rebases via distributor. There is an error in Staking's `stake` function which pulls forward part of the rebase for the next epoch. This path triggers a rebase by calling `unstake` (which does not have the issue). The patch also restricts `distribute` to only be able to be called from a tx originating in this function. + + + + + + + +## Errors + +### Distributor_AdjustmentLimit + +```solidity +error Distributor_AdjustmentLimit() +``` + + + + + + +### Distributor_AdjustmentUnderflow + +```solidity +error Distributor_AdjustmentUnderflow() +``` + + + + + + +### Distributor_InvalidConstruction + +```solidity +error Distributor_InvalidConstruction() +``` + + + + + + +### Distributor_NoRebaseOccurred + +```solidity +error Distributor_NoRebaseOccurred() +``` + + + + + + +### Distributor_NotPermissioned + +```solidity +error Distributor_NotPermissioned() +``` + + + + + + +### Distributor_NotUnlocked + +```solidity +error Distributor_NotUnlocked() +``` + + + + + + +### Distributor_OnlyStaking + +```solidity +error Distributor_OnlyStaking() +``` + + + + + + +### Distributor_SanityCheck + +```solidity +error Distributor_SanityCheck() +``` + + + + + + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/Emergency.md b/docs/technical/02_contract-docs/policies/Emergency.md new file mode 100644 index 0000000..57e8a6d --- /dev/null +++ b/docs/technical/02_contract-docs/policies/Emergency.md @@ -0,0 +1,271 @@ +# Emergency + + + + + + + + + +## Methods + +### MINTR + +```solidity +function MINTR() external view returns (contract MINTRv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract MINTRv1 | undefined | + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### TRSRY + +```solidity +function TRSRY() external view returns (contract TRSRYv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract TRSRYv1 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] requests) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### restart + +```solidity +function restart() external nonpayable +``` + +Restart treasury withdrawals and minting after shutdown + + + + +### restartMinting + +```solidity +function restartMinting() external nonpayable +``` + +Restart minting after shutdown + + + + +### restartWithdrawals + +```solidity +function restartWithdrawals() external nonpayable +``` + +Restart treasury withdrawals after shutdown + + + + +### shutdown + +```solidity +function shutdown() external nonpayable +``` + +Emergency shutdown of treasury withdrawals and minting + + + + +### shutdownMinting + +```solidity +function shutdownMinting() external nonpayable +``` + +Emergency shutdown of minting + + + + +### shutdownWithdrawals + +```solidity +function shutdownWithdrawals() external nonpayable +``` + +Emergency shutdown of treasury withdrawals + + + + + + +## Events + +### Status + +```solidity +event Status(bool treasury_, bool minter_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| treasury_ | bool | undefined | +| minter_ | bool | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/IStaking.md b/docs/technical/02_contract-docs/policies/IStaking.md new file mode 100644 index 0000000..1ec448c --- /dev/null +++ b/docs/technical/02_contract-docs/policies/IStaking.md @@ -0,0 +1,40 @@ +# IStaking + + + + + +Define Inline Interfaces + + + +## Methods + +### unstake + +```solidity +function unstake(address _to, uint256 _amount, bool _trigger, bool _rebasing) external nonpayable returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _to | address | undefined | +| _amount | uint256 | undefined | +| _trigger | bool | undefined | +| _rebasing | bool | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + + + + diff --git a/docs/technical/02_contract-docs/policies/OlympusHeart.md b/docs/technical/02_contract-docs/policies/OlympusHeart.md new file mode 100644 index 0000000..1707276 --- /dev/null +++ b/docs/technical/02_contract-docs/policies/OlympusHeart.md @@ -0,0 +1,410 @@ +# OlympusHeart + + + +> Olympus Heart + +Olympus Heart (Policy) Contract + +*The Olympus Heart contract provides keeper rewards to call the heart beat function which fuels Olympus market operations. The Heart orchestrates state updates in the correct order to ensure market operations use up to date information.* + +## Methods + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### activate + +```solidity +function activate() external nonpayable +``` + +Turns the heart on and resets the beatAccess restricted + +*This function is used to restart the heart after a pause* + + +### active + +```solidity +function active() external view returns (bool) +``` + +Status of the Heart, false = stopped, true = beating + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### beat + +```solidity +function beat() external nonpayable +``` + +Beats the heartOnly callable when enough time has passed since last beat (determined by frequency variable)This function is incentivized with a token reward (see rewardToken and reward variables). + +*Triggers price oracle update and market operations* + + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Turns the heart offAccess restricted + +*Emergency stop function for the heart* + + +### frequency + +```solidity +function frequency() external view returns (uint256) +``` + +Heart beat frequency, in seconds + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### lastBeat + +```solidity +function lastBeat() external view returns (uint256) +``` + +Timestamp of the last beat (UTC, in seconds) + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] permissions) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| permissions | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### resetBeat + +```solidity +function resetBeat() external nonpayable +``` + +Unlocks the cycle if stuck on one side, eject functionAccess restricted + + + + +### reward + +```solidity +function reward() external view returns (uint256) +``` + +Reward for beating the Heart (in reward token decimals) + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### rewardToken + +```solidity +function rewardToken() external view returns (contract ERC20) +``` + +Reward token address that users are sent for beating the Heart + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### setRewardTokenAndAmount + +```solidity +function setRewardTokenAndAmount(contract ERC20 token_, uint256 reward_) external nonpayable +``` + +Sets the reward token and amount for the beat functionAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | - New reward token address | +| reward_ | uint256 | - New reward amount, in units of the reward token | + +### withdrawUnspentRewards + +```solidity +function withdrawUnspentRewards(contract ERC20 token_) external nonpayable +``` + +Withdraws unspent balance of provided token to senderAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | + + + +## Events + +### Beat + +```solidity +event Beat(uint256 timestamp_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| timestamp_ | uint256 | undefined | + +### RewardIssued + +```solidity +event RewardIssued(address to_, uint256 rewardAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| rewardAmount_ | uint256 | undefined | + +### RewardUpdated + +```solidity +event RewardUpdated(contract ERC20 token_, uint256 rewardAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | +| rewardAmount_ | uint256 | undefined | + + + +## Errors + +### Heart_BeatAvailable + +```solidity +error Heart_BeatAvailable() +``` + + + + + + +### Heart_BeatStopped + +```solidity +error Heart_BeatStopped() +``` + + + + + + +### Heart_InvalidParams + +```solidity +error Heart_InvalidParams() +``` + + + + + + +### Heart_OutOfCycle + +```solidity +error Heart_OutOfCycle() +``` + + + + + + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/OlympusPriceConfig.md b/docs/technical/02_contract-docs/policies/OlympusPriceConfig.md new file mode 100644 index 0000000..be5f479 --- /dev/null +++ b/docs/technical/02_contract-docs/policies/OlympusPriceConfig.md @@ -0,0 +1,217 @@ +# OlympusPriceConfig + + + + + + + + + +## Methods + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### changeMovingAverageDuration + +```solidity +function changeMovingAverageDuration(uint48 movingAverageDuration_) external nonpayable +``` + +Change the moving average window (duration) + +*Setting the window to a larger number of observations than the current window will clear the data in the current window and require the initialize function to be called again. Ensure that you have saved the existing data and can re-populate before calling this function with a number of observations larger than have been recorded.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| movingAverageDuration_ | uint48 | Moving average duration in seconds, must be a multiple of observation frequency | + +### changeObservationFrequency + +```solidity +function changeObservationFrequency(uint48 observationFrequency_) external nonpayable +``` + +Change the observation frequency of the moving average (i.e. how often a new observation is taken) + +*Changing the observation frequency clears existing observation data since it will not be taken at the right time intervals. Ensure that you have saved the existing data and/or can re-populate before calling this function.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| observationFrequency_ | uint48 | Observation frequency in seconds, must be a divisor of the moving average duration | + +### changeUpdateThresholds + +```solidity +function changeUpdateThresholds(uint48 ohmEthUpdateThreshold_, uint48 reserveEthUpdateThreshold_) external nonpayable +``` + +Change the update thresholds for the price feeds + +*The update thresholds should be set based on the update threshold of the chainlink oracles.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| ohmEthUpdateThreshold_ | uint48 | - Maximum allowed time between OHM/ETH price feed updates | +| reserveEthUpdateThreshold_ | uint48 | - Maximum allowed time between Reserve/ETH price feed updates | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### initialize + +```solidity +function initialize(uint256[] startObservations_, uint48 lastObservationTime_) external nonpayable +``` + +Initialize the price moduleAccess restricted to approved policies + +*This function must be called after the Price module is deployed to activate it and after updating the observationFrequency or movingAverageDuration (in certain cases) in order for the Price module to function properly.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| startObservations_ | uint256[] | Array of observations to initialize the moving average with. Must be of length numObservations. | +| lastObservationTime_ | uint48 | Unix timestamp of last observation being provided (in seconds). | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] permissions) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| permissions | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/Operator.md b/docs/technical/02_contract-docs/policies/Operator.md new file mode 100644 index 0000000..df4bb6c --- /dev/null +++ b/docs/technical/02_contract-docs/policies/Operator.md @@ -0,0 +1,808 @@ +# Operator + + + +> Olympus Range Operator + +Olympus Range Operator (Policy) Contract + +*The Olympus Range Operator performs market operations to enforce OlympusDAO's OHM price range guidance policies against a specific reserve asset. The Operator is maintained by a keeper-triggered function on the Olympus Heart contract, which orchestrates state updates in the correct order to ensure market operations use up to date information. When the price of OHM against the reserve asset exceeds the cushion spread, the Operator deploys bond markets to support the price. The Operator also offers zero slippage swaps at prices dictated by the wall spread from the moving average. These market operations are performed up to a specific capacity before the market must stabilize to regenerate the capacity.* + +## Methods + +### ONE_HUNDRED_PERCENT + +```solidity +function ONE_HUNDRED_PERCENT() external view returns (uint32) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint32 | undefined | + +### ONE_PERCENT + +```solidity +function ONE_PERCENT() external view returns (uint32) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint32 | undefined | + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### activate + +```solidity +function activate() external nonpayable +``` + +Activate the OperatorAccess restricted + +*Restart function for the Operator after a pause.* + + +### active + +```solidity +function active() external view returns (bool) +``` + +Whether the Operator is active + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### auctioneer + +```solidity +function auctioneer() external view returns (contract IBondSDA) +``` + +Auctioneer contract used for cushion bond market deployments + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract IBondSDA | undefined | + +### bondPurchase + +```solidity +function bondPurchase(uint256 id_, uint256 amountOut_) external nonpayable +``` + +Records a bond purchase and updates capacity correctlyAccess restricted (BondCallback) + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| id_ | uint256 | ID of the bond market | +| amountOut_ | uint256 | Amount of capacity expended | + +### callback + +```solidity +function callback() external view returns (contract IBondCallback) +``` + +Callback contract used for cushion bond market payouts + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract IBondCallback | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### config + +```solidity +function config() external view returns (struct IOperator.Config) +``` + +Returns the config variable of the Operator as a Config struct + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | IOperator.Config | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Deactivate the OperatorAccess restricted + +*Emergency pause function for the Operator. Prevents market operations from occurring.* + + +### deactivateCushion + +```solidity +function deactivateCushion(bool high_) external nonpayable +``` + +Manually close a cushion bond marketAccess restricted + +*Emergency shutdown function for Cushions* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | Whether to deactivate the high or low side cushion (true = high, false = low) | + +### fullCapacity + +```solidity +function fullCapacity(bool high_) external view returns (uint256) +``` + +Returns the full capacity of the specified wall (if it was regenerated now) + +*Calculates the capacity to deploy for a wall based on the amount of reserves owned by the treasury and the reserve factor.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Whether to return the full capacity for the high or low wall | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getAmountOut + +```solidity +function getAmountOut(contract ERC20 tokenIn_, uint256 amountIn_) external view returns (uint256) +``` + +Returns the amount to be received from a swap + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIn_ | contract ERC20 | - Token to swap into the wall - If OHM: swap at the low wall price for Reserve - If Reserve: swap at the high wall price for OHM | +| amountIn_ | uint256 | - Amount of tokenIn to swap | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | Amount of opposite token received | + +### initialize + +```solidity +function initialize() external nonpayable +``` + +Initialize the Operator to begin market operationsAccess restrictedCan only be called once + +*This function executes actions required to start operations that cannot be done prior to the Operator policy being approved by the Kernel.* + + +### initialized + +```solidity +function initialized() external view returns (bool) +``` + +Whether the Operator has been initialized + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### ohm + +```solidity +function ohm() external view returns (contract ERC20) +``` + +OHM token contract + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### ohmDecimals + +```solidity +function ohmDecimals() external view returns (uint8) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### operate + +```solidity +function operate() external nonpayable +``` + +Executes market operations logic.Access restricted + +*This function is triggered by a keeper on the Heart contract.* + + +### regenerate + +```solidity +function regenerate(bool high_) external nonpayable +``` + +Regenerate the wall for a sideAccess restricted + +*This function is an escape hatch to trigger out of cycle regenerations and may be useful when doing migrations of Treasury funds* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | Whether to regenerate the high side or low side (true = high, false = low) | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] requests) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### reserve + +```solidity +function reserve() external view returns (contract ERC20) +``` + +Reserve token contract + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### reserveDecimals + +```solidity +function reserveDecimals() external view returns (uint8) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint8 | undefined | + +### setBondContracts + +```solidity +function setBondContracts(contract IBondSDA auctioneer_, contract IBondCallback callback_) external nonpayable +``` + +Set the contracts that the Operator deploys bond markets with.Access restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| auctioneer_ | contract IBondSDA | - Address of the bond auctioneer to use. | +| callback_ | contract IBondCallback | - Address of the callback to use. | + +### setCushionFactor + +```solidity +function setCushionFactor(uint32 cushionFactor_) external nonpayable +``` + +Set the cushion factorAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionFactor_ | uint32 | - Percent of wall capacity that the operator will deploy in the cushion, assumes 2 decimals (i.e. 1000 = 10%) | + +### setCushionParams + +```solidity +function setCushionParams(uint32 duration_, uint32 debtBuffer_, uint32 depositInterval_) external nonpayable +``` + +Set the parameters used to deploy cushion bond marketsAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| duration_ | uint32 | - Duration of cushion bond markets in seconds | +| debtBuffer_ | uint32 | - Percentage over the initial debt to allow the market to accumulate at any one time. Percent with 3 decimals, e.g. 1_000 = 1 %. See IBondSDA for more info. | +| depositInterval_ | uint32 | - Target frequency of deposits in seconds. Determines max payout of the bond market. See IBondSDA for more info. | + +### setRegenParams + +```solidity +function setRegenParams(uint32 wait_, uint32 threshold_, uint32 observe_) external nonpayable +``` + +Set the wall regeneration parametersAccess restricted + +*We must see Threshold number of price points that meet our criteria within the last Observe number of price points to regenerate a wall.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wait_ | uint32 | - Minimum duration to wait to reinstate a wall in seconds | +| threshold_ | uint32 | - Number of price points on other side of moving average to reinstate a wall | +| observe_ | uint32 | - Number of price points to observe to determine regeneration | + +### setReserveFactor + +```solidity +function setReserveFactor(uint32 reserveFactor_) external nonpayable +``` + +Set the reserve factorAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| reserveFactor_ | uint32 | - Percent of treasury reserves to deploy as capacity for market operations, assumes 2 decimals (i.e. 1000 = 10%) | + +### setSpreads + +```solidity +function setSpreads(uint256 cushionSpread_, uint256 wallSpread_) external nonpayable +``` + +Set the wall and cushion spreadsAccess restricted + +*Interface for externally setting these values on the RANGE module* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionSpread_ | uint256 | - Percent spread to set the cushions at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%) | +| wallSpread_ | uint256 | - Percent spread to set the walls at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%) | + +### setThresholdFactor + +```solidity +function setThresholdFactor(uint256 thresholdFactor_) external nonpayable +``` + +Set the threshold factor for when a wall is considered "down"Access restricted + +*Interface for externally setting this value on the RANGE module* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| thresholdFactor_ | uint256 | - Percent of capacity that the wall should close below, assumes 2 decimals (i.e. 1000 = 10%) | + +### status + +```solidity +function status() external view returns (struct IOperator.Status) +``` + +Returns the status variable of the Operator as a Status struct + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | IOperator.Status | undefined | + +### swap + +```solidity +function swap(contract ERC20 tokenIn_, uint256 amountIn_, uint256 minAmountOut_) external nonpayable returns (uint256 amountOut) +``` + +Swap at the current wall prices + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIn_ | contract ERC20 | - Token to swap into the wall - OHM: swap at the low wall price for Reserve - Reserve: swap at the high wall price for OHM | +| amountIn_ | uint256 | - Amount of tokenIn to swap | +| minAmountOut_ | uint256 | - Minimum amount of opposite token to receive | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| amountOut | uint256 | - Amount of opposite token received | + + + +## Events + +### CushionFactorChanged + +```solidity +event CushionFactorChanged(uint32 cushionFactor_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionFactor_ | uint32 | undefined | + +### CushionParamsChanged + +```solidity +event CushionParamsChanged(uint32 duration_, uint32 debtBuffer_, uint32 depositInterval_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| duration_ | uint32 | undefined | +| debtBuffer_ | uint32 | undefined | +| depositInterval_ | uint32 | undefined | + +### RegenParamsChanged + +```solidity +event RegenParamsChanged(uint32 wait_, uint32 threshold_, uint32 observe_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wait_ | uint32 | undefined | +| threshold_ | uint32 | undefined | +| observe_ | uint32 | undefined | + +### ReserveFactorChanged + +```solidity +event ReserveFactorChanged(uint32 reserveFactor_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| reserveFactor_ | uint32 | undefined | + +### Swap + +```solidity +event Swap(contract ERC20 indexed tokenIn_, contract ERC20 indexed tokenOut_, uint256 amountIn_, uint256 amountOut_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIn_ `indexed` | contract ERC20 | undefined | +| tokenOut_ `indexed` | contract ERC20 | undefined | +| amountIn_ | uint256 | undefined | +| amountOut_ | uint256 | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Operator_AlreadyInitialized + +```solidity +error Operator_AlreadyInitialized() +``` + + + + + + +### Operator_AmountLessThanMinimum + +```solidity +error Operator_AmountLessThanMinimum(uint256 amountOut, uint256 minAmountOut) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| amountOut | uint256 | undefined | +| minAmountOut | uint256 | undefined | + +### Operator_Inactive + +```solidity +error Operator_Inactive() +``` + + + + + + +### Operator_InsufficientCapacity + +```solidity +error Operator_InsufficientCapacity() +``` + + + + + + +### Operator_InvalidParams + +```solidity +error Operator_InvalidParams() +``` + + + + + + +### Operator_NotInitialized + +```solidity +error Operator_NotInitialized() +``` + + + + + + +### Operator_WallDown + +```solidity +error Operator_WallDown() +``` + + + + + + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/Parthenon.md b/docs/technical/02_contract-docs/policies/Parthenon.md new file mode 100644 index 0000000..f45f1c2 --- /dev/null +++ b/docs/technical/02_contract-docs/policies/Parthenon.md @@ -0,0 +1,740 @@ +# Parthenon + + + + + +Parthenon, OlympusDAO's on-chain governance system. + +*The Parthenon policy is also the Kernel's Executor.* + +## Methods + +### ACTIVATION_DEADLINE + +```solidity +function ACTIVATION_DEADLINE() external view returns (uint256) +``` + +Amount of time a submitted proposal can exist before activation can no longer be triggered. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### ACTIVATION_TIMELOCK + +```solidity +function ACTIVATION_TIMELOCK() external view returns (uint256) +``` + +Amount of time a submitted proposal must exist before triggering activation. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### COLLATERAL_DURATION + +```solidity +function COLLATERAL_DURATION() external view returns (uint256) +``` + +Amount of time a non-executed proposal must wait for the proposal to go through. + +*This is inclusive of the voting period (so the deadline is really ~4 days, assuming a 3 day voting window).* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### COLLATERAL_MINIMUM + +```solidity +function COLLATERAL_MINIMUM() external view returns (uint256) +``` + +The minimum amount of VOTES the proposer must post in collateral to submit + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### COLLATERAL_REQUIREMENT + +```solidity +function COLLATERAL_REQUIREMENT() external view returns (uint256) +``` + +The amount of VOTES a proposer needs to post in collateral in order to submit a proposal + +*This number is expressed as a percentage of total supply in basis points: 500 = 5% of the supply* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### EXECUTION_DEADLINE + +```solidity +function EXECUTION_DEADLINE() external view returns (uint256) +``` + +Amount of time after the proposal is activated (NOT AFTER PASSED) when it can be activated (otherwise proposal will go stale). + +*This is inclusive of the voting period (so the deadline is really ~4 days, assuming a 3 day voting window).* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### EXECUTION_THRESHOLD + +```solidity +function EXECUTION_THRESHOLD() external view returns (uint256) +``` + +Net votes required to execute a proposal on chain as a percentage of total registered votes. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### EXECUTION_TIMELOCK + +```solidity +function EXECUTION_TIMELOCK() external view returns (uint256) +``` + +Required time for a proposal before it can be activated. + +*This amount should be greater than 0 to prevent flash loan attacks.* + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### INSTR + +```solidity +function INSTR() external view returns (contract INSTRv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract INSTRv1 | undefined | + +### VOTES + +```solidity +function VOTES() external view returns (contract VOTESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract VOTESv1 | undefined | + +### VOTING_PERIOD + +```solidity +function VOTING_PERIOD() external view returns (uint256) +``` + +The period of time a proposal has for voting + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### WARMUP_PERIOD + +```solidity +function WARMUP_PERIOD() external view returns (uint256) +``` + +Amount of time a wallet must wait after depositing before they can vote. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### _max + +```solidity +function _max(uint256 a, uint256 b) external pure returns (uint256) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| a | uint256 | undefined | +| b | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### activateProposal + +```solidity +function activateProposal(uint256 proposalId_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId_ | uint256 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### executeProposal + +```solidity +function executeProposal(uint256 proposalId_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId_ | uint256 | undefined | + +### getProposalMetadata + +```solidity +function getProposalMetadata(uint256) external view returns (address submitter, uint256 submissionTimestamp, uint256 collateralAmt, uint256 activationTimestamp, uint256 totalRegisteredVotes, uint256 yesVotes, uint256 noVotes, bool isExecuted, bool isCollateralReturned) +``` + +Return a proposal metadata object for a given proposal id. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| submitter | address | undefined | +| submissionTimestamp | uint256 | undefined | +| collateralAmt | uint256 | undefined | +| activationTimestamp | uint256 | undefined | +| totalRegisteredVotes | uint256 | undefined | +| yesVotes | uint256 | undefined | +| noVotes | uint256 | undefined | +| isExecuted | bool | undefined | +| isCollateralReturned | bool | undefined | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### reclaimCollateral + +```solidity +function reclaimCollateral(uint256 proposalId_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId_ | uint256 | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] requests) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### submitProposal + +```solidity +function submitProposal(Instruction[] instructions_, string title_, string proposalURI_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| instructions_ | Instruction[] | undefined | +| title_ | string | undefined | +| proposalURI_ | string | undefined | + +### vote + +```solidity +function vote(uint256 proposalId_, bool approve_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId_ | uint256 | undefined | +| approve_ | bool | undefined | + + + +## Events + +### CollateralReclaimed + +```solidity +event CollateralReclaimed(uint256 proposalId, uint256 tokensReclaimed_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId | uint256 | undefined | +| tokensReclaimed_ | uint256 | undefined | + +### ProposalActivated + +```solidity +event ProposalActivated(uint256 proposalId, uint256 timestamp) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId | uint256 | undefined | +| timestamp | uint256 | undefined | + +### ProposalExecuted + +```solidity +event ProposalExecuted(uint256 proposalId) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId | uint256 | undefined | + +### ProposalSubmitted + +```solidity +event ProposalSubmitted(uint256 proposalId, string title, string proposalURI) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId | uint256 | undefined | +| title | string | undefined | +| proposalURI | string | undefined | + +### VotesCast + +```solidity +event VotesCast(uint256 proposalId, address voter, bool approve, uint256 userVotes) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| proposalId | uint256 | undefined | +| voter | address | undefined | +| approve | bool | undefined | +| userVotes | uint256 | undefined | + + + +## Errors + +### CollateralAlreadyReturned + +```solidity +error CollateralAlreadyReturned() +``` + + + + + + +### DepositedAfterActivation + +```solidity +error DepositedAfterActivation() +``` + + + + + + +### ExecutionTimelockStillActive + +```solidity +error ExecutionTimelockStillActive() +``` + + + + + + +### ExecutionWindowExpired + +```solidity +error ExecutionWindowExpired() +``` + + + + + + +### ExecutorNotSubmitter + +```solidity +error ExecutorNotSubmitter() +``` + + + + + + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### NotAuthorized + +```solidity +error NotAuthorized() +``` + + + + + + +### NotEnoughVotesToExecute + +```solidity +error NotEnoughVotesToExecute() +``` + + + + + + +### PastVotingPeriod + +```solidity +error PastVotingPeriod() +``` + + + + + + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + +### ProposalAlreadyActivated + +```solidity +error ProposalAlreadyActivated() +``` + + + + + + +### ProposalAlreadyExecuted + +```solidity +error ProposalAlreadyExecuted() +``` + + + + + + +### ProposalIsNotActive + +```solidity +error ProposalIsNotActive() +``` + + + + + + +### UnableToActivate + +```solidity +error UnableToActivate() +``` + + + + + + +### UnmetCollateralDuration + +```solidity +error UnmetCollateralDuration() +``` + + + + + + +### UserAlreadyVoted + +```solidity +error UserAlreadyVoted() +``` + + + + + + +### UserHasNoVotes + +```solidity +error UserHasNoVotes() +``` + + + + + + +### WarmupNotCompleted + +```solidity +error WarmupNotCompleted() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/policies/RolesAdmin.md b/docs/technical/02_contract-docs/policies/RolesAdmin.md new file mode 100644 index 0000000..cb0bd68 --- /dev/null +++ b/docs/technical/02_contract-docs/policies/RolesAdmin.md @@ -0,0 +1,303 @@ +# RolesAdmin + + + + + +The RolesAdmin Policy grants and revokes Roles in the ROLES module. + + + +## Methods + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### admin + +```solidity +function admin() external view returns (address) +``` + +Special role that is responsible for assigning policy-defined roles to addresses. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### grantRole + +```solidity +function grantRole(bytes32 role_, address wallet_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| wallet_ | address | undefined | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### newAdmin + +```solidity +function newAdmin() external view returns (address) +``` + +Proposed new admin. Address must call `pullRolesAdmin` to become the new roles admin. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | address | undefined | + +### pullNewAdmin + +```solidity +function pullNewAdmin() external nonpayable +``` + + + + + + +### pushNewAdmin + +```solidity +function pushNewAdmin(address newAdmin_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newAdmin_ | address | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] requests) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### revokeRole + +```solidity +function revokeRole(bytes32 role_, address wallet_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| role_ | bytes32 | undefined | +| wallet_ | address | undefined | + + + +## Events + +### NewAdminPulled + +```solidity +event NewAdminPulled(address indexed newAdmin_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newAdmin_ `indexed` | address | undefined | + +### NewAdminPushed + +```solidity +event NewAdminPushed(address indexed newAdmin_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newAdmin_ `indexed` | address | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### OnlyAdmin + +```solidity +error OnlyAdmin() +``` + + + + + + +### OnlyNewAdmin + +```solidity +error OnlyNewAdmin() +``` + + + + + + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/TreasuryCustodian.md b/docs/technical/02_contract-docs/policies/TreasuryCustodian.md new file mode 100644 index 0000000..71643c5 --- /dev/null +++ b/docs/technical/02_contract-docs/policies/TreasuryCustodian.md @@ -0,0 +1,342 @@ +# TreasuryCustodian + + + + + + + + + +## Methods + +### ROLES + +```solidity +function ROLES() external view returns (contract ROLESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ROLESv1 | undefined | + +### TRSRY + +```solidity +function TRSRY() external view returns (contract TRSRYv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract TRSRYv1 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### decreaseDebt + +```solidity +function decreaseDebt(contract ERC20 token_, address debtor_, uint256 amount_) external nonpayable +``` + +Allow authorized addresses to decrease debt in special cases + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | +| debtor_ | address | undefined | +| amount_ | uint256 | undefined | + +### grantDebtorApproval + +```solidity +function grantDebtorApproval(address for_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Allow an address to incur `amount_` of debt from the treasury + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| for_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### grantWithdrawerApproval + +```solidity +function grantWithdrawerApproval(address for_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Allow an address to withdraw `amount_` from the treasury + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| for_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### increaseDebt + +```solidity +function increaseDebt(contract ERC20 token_, address debtor_, uint256 amount_) external nonpayable +``` + +Allow authorized addresses to increase debt in special cases + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | +| debtor_ | address | undefined | +| amount_ | uint256 | undefined | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### reduceDebtorApproval + +```solidity +function reduceDebtorApproval(address for_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Lower an address's debtor approval + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| for_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### reduceWithdrawerApproval + +```solidity +function reduceWithdrawerApproval(address for_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Lower an address's withdrawer approval + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| for_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] requests) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| requests | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### revokePolicyApprovals + +```solidity +function revokePolicyApprovals(address policy_, contract ERC20[] tokens_) external nonpayable +``` + +Anyone can call to revoke a deactivated policy's approvals. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ | address | undefined | +| tokens_ | contract ERC20[] | undefined | + +### withdrawReservesTo + +```solidity +function withdrawReservesTo(address to_, contract ERC20 token_, uint256 amount_) external nonpayable +``` + +Custodian can withdraw reserves to an address. + +*Used for withdrawing assets to a MS or other address in special cases.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| token_ | contract ERC20 | undefined | +| amount_ | uint256 | undefined | + + + +## Events + +### ApprovalRevoked + +```solidity +event ApprovalRevoked(address indexed policy_, contract ERC20[] tokens_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| policy_ `indexed` | address | undefined | +| tokens_ | contract ERC20[] | undefined | + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### PolicyStillActive + +```solidity +error PolicyStillActive() +``` + + + + + + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + + diff --git a/docs/technical/02_contract-docs/policies/VohmVault.md b/docs/technical/02_contract-docs/policies/VohmVault.md new file mode 100644 index 0000000..ea4aa7f --- /dev/null +++ b/docs/technical/02_contract-docs/policies/VohmVault.md @@ -0,0 +1,260 @@ +# VohmVault + + + + + +Policy to mint and burn VOTES to arbitrary addresses + + + +## Methods + +### VESTING_PERIOD + +```solidity +function VESTING_PERIOD() external view returns (uint256) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### VOTES + +```solidity +function VOTES() external view returns (contract VOTESv1) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract VOTESv1 | undefined | + +### changeKernel + +```solidity +function changeKernel(contract Kernel newKernel_) external nonpayable +``` + +Function used by kernel when migrating to a new kernel. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| newKernel_ | contract Kernel | undefined | + +### configureDependencies + +```solidity +function configureDependencies() external nonpayable returns (Keycode[] dependencies) +``` + +Define module dependencies for this policy. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| dependencies | Keycode[] | - Keycode array of module dependencies. | + +### deposit + +```solidity +function deposit(uint256 assets_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets_ | uint256 | undefined | + +### gOHM + +```solidity +function gOHM() external view returns (contract ERC20) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract ERC20 | undefined | + +### isActive + +```solidity +function isActive() external view returns (bool) +``` + +Easily accessible indicator for if a policy is activated or not. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + +### kernel + +```solidity +function kernel() external view returns (contract Kernel) +``` + + + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | contract Kernel | undefined | + +### mint + +```solidity +function mint(uint256 shares_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares_ | uint256 | undefined | + +### redeem + +```solidity +function redeem(uint256 shares_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| shares_ | uint256 | undefined | + +### requestPermissions + +```solidity +function requestPermissions() external view returns (struct Permissions[] permissions) +``` + +Function called by kernel to set module function permissions. + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| permissions | Permissions[] | - Array of keycodes and function selectors for requested permissions. | + +### withdraw + +```solidity +function withdraw(uint256 assets_) external nonpayable +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| assets_ | uint256 | undefined | + + + + +## Errors + +### KernelAdapter_OnlyKernel + +```solidity +error KernelAdapter_OnlyKernel(address caller_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| caller_ | address | undefined | + +### Policy_ModuleDoesNotExist + +```solidity +error Policy_ModuleDoesNotExist(Keycode keycode_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| keycode_ | Keycode | undefined | + +### VohmVault_NotVested + +```solidity +error VohmVault_NotVested() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/policies/interfaces/IHeart.md b/docs/technical/02_contract-docs/policies/interfaces/IHeart.md new file mode 100644 index 0000000..40de7cd --- /dev/null +++ b/docs/technical/02_contract-docs/policies/interfaces/IHeart.md @@ -0,0 +1,209 @@ +# IHeart + + + + + + + + + +## Methods + +### activate + +```solidity +function activate() external nonpayable +``` + +Turns the heart on and resets the beatAccess restricted + +*This function is used to restart the heart after a pause* + + +### beat + +```solidity +function beat() external nonpayable +``` + +Beats the heartOnly callable when enough time has passed since last beat (determined by frequency variable)This function is incentivized with a token reward (see rewardToken and reward variables). + +*Triggers price oracle update and market operations* + + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Turns the heart offAccess restricted + +*Emergency stop function for the heart* + + +### frequency + +```solidity +function frequency() external view returns (uint256) +``` + +Heart beat frequency, in seconds + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### resetBeat + +```solidity +function resetBeat() external nonpayable +``` + +Unlocks the cycle if stuck on one side, eject functionAccess restricted + + + + +### setRewardTokenAndAmount + +```solidity +function setRewardTokenAndAmount(contract ERC20 token_, uint256 reward_) external nonpayable +``` + +Sets the reward token and amount for the beat functionAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | - New reward token address | +| reward_ | uint256 | - New reward amount, in units of the reward token | + +### withdrawUnspentRewards + +```solidity +function withdrawUnspentRewards(contract ERC20 token_) external nonpayable +``` + +Withdraws unspent balance of provided token to senderAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | + + + +## Events + +### Beat + +```solidity +event Beat(uint256 timestamp_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| timestamp_ | uint256 | undefined | + +### RewardIssued + +```solidity +event RewardIssued(address to_, uint256 rewardAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| to_ | address | undefined | +| rewardAmount_ | uint256 | undefined | + +### RewardUpdated + +```solidity +event RewardUpdated(contract ERC20 token_, uint256 rewardAmount_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| token_ | contract ERC20 | undefined | +| rewardAmount_ | uint256 | undefined | + + + +## Errors + +### Heart_BeatAvailable + +```solidity +error Heart_BeatAvailable() +``` + + + + + + +### Heart_BeatStopped + +```solidity +error Heart_BeatStopped() +``` + + + + + + +### Heart_InvalidParams + +```solidity +error Heart_InvalidParams() +``` + + + + + + +### Heart_OutOfCycle + +```solidity +error Heart_OutOfCycle() +``` + + + + + + + diff --git a/docs/technical/02_contract-docs/policies/interfaces/IOperator.md b/docs/technical/02_contract-docs/policies/interfaces/IOperator.md new file mode 100644 index 0000000..63d6bdf --- /dev/null +++ b/docs/technical/02_contract-docs/policies/interfaces/IOperator.md @@ -0,0 +1,488 @@ +# IOperator + + + + + + + + + +## Methods + +### activate + +```solidity +function activate() external nonpayable +``` + +Activate the OperatorAccess restricted + +*Restart function for the Operator after a pause.* + + +### config + +```solidity +function config() external view returns (struct IOperator.Config) +``` + +Returns the config variable of the Operator as a Config struct + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | IOperator.Config | undefined | + +### deactivate + +```solidity +function deactivate() external nonpayable +``` + +Deactivate the OperatorAccess restricted + +*Emergency pause function for the Operator. Prevents market operations from occurring.* + + +### deactivateCushion + +```solidity +function deactivateCushion(bool high_) external nonpayable +``` + +Manually close a cushion bond marketAccess restricted + +*Emergency shutdown function for Cushions* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | Whether to deactivate the high or low side cushion (true = high, false = low) | + +### fullCapacity + +```solidity +function fullCapacity(bool high_) external view returns (uint256) +``` + +Returns the full capacity of the specified wall (if it was regenerated now) + +*Calculates the capacity to deploy for a wall based on the amount of reserves owned by the treasury and the reserve factor.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | - Whether to return the full capacity for the high or low wall | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | undefined | + +### getAmountOut + +```solidity +function getAmountOut(contract ERC20 tokenIn_, uint256 amountIn_) external view returns (uint256) +``` + +Returns the amount to be received from a swap + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIn_ | contract ERC20 | - Token to swap into the wall - If OHM: swap at the low wall price for Reserve - If Reserve: swap at the high wall price for OHM | +| amountIn_ | uint256 | - Amount of tokenIn to swap | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | Amount of opposite token received | + +### initialize + +```solidity +function initialize() external nonpayable +``` + +Initialize the Operator to begin market operationsAccess restrictedCan only be called once + +*This function executes actions required to start operations that cannot be done prior to the Operator policy being approved by the Kernel.* + + +### operate + +```solidity +function operate() external nonpayable +``` + +Executes market operations logic.Access restricted + +*This function is triggered by a keeper on the Heart contract.* + + +### regenerate + +```solidity +function regenerate(bool high_) external nonpayable +``` + +Regenerate the wall for a sideAccess restricted + +*This function is an escape hatch to trigger out of cycle regenerations and may be useful when doing migrations of Treasury funds* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| high_ | bool | Whether to regenerate the high side or low side (true = high, false = low) | + +### setBondContracts + +```solidity +function setBondContracts(contract IBondSDA auctioneer_, contract IBondCallback callback_) external nonpayable +``` + +Set the contracts that the Operator deploys bond markets with.Access restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| auctioneer_ | contract IBondSDA | - Address of the bond auctioneer to use. | +| callback_ | contract IBondCallback | - Address of the callback to use. | + +### setCushionFactor + +```solidity +function setCushionFactor(uint32 cushionFactor_) external nonpayable +``` + +Set the cushion factorAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionFactor_ | uint32 | - Percent of wall capacity that the operator will deploy in the cushion, assumes 2 decimals (i.e. 1000 = 10%) | + +### setCushionParams + +```solidity +function setCushionParams(uint32 duration_, uint32 debtBuffer_, uint32 depositInterval_) external nonpayable +``` + +Set the parameters used to deploy cushion bond marketsAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| duration_ | uint32 | - Duration of cushion bond markets in seconds | +| debtBuffer_ | uint32 | - Percentage over the initial debt to allow the market to accumulate at any one time. Percent with 3 decimals, e.g. 1_000 = 1 %. See IBondSDA for more info. | +| depositInterval_ | uint32 | - Target frequency of deposits in seconds. Determines max payout of the bond market. See IBondSDA for more info. | + +### setRegenParams + +```solidity +function setRegenParams(uint32 wait_, uint32 threshold_, uint32 observe_) external nonpayable +``` + +Set the wall regeneration parametersAccess restricted + +*We must see Threshold number of price points that meet our criteria within the last Observe number of price points to regenerate a wall.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wait_ | uint32 | - Minimum duration to wait to reinstate a wall in seconds | +| threshold_ | uint32 | - Number of price points on other side of moving average to reinstate a wall | +| observe_ | uint32 | - Number of price points to observe to determine regeneration | + +### setReserveFactor + +```solidity +function setReserveFactor(uint32 reserveFactor_) external nonpayable +``` + +Set the reserve factorAccess restricted + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| reserveFactor_ | uint32 | - Percent of treasury reserves to deploy as capacity for market operations, assumes 2 decimals (i.e. 1000 = 10%) | + +### setSpreads + +```solidity +function setSpreads(uint256 cushionSpread_, uint256 wallSpread_) external nonpayable +``` + +Set the wall and cushion spreadsAccess restricted + +*Interface for externally setting these values on the RANGE module* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionSpread_ | uint256 | - Percent spread to set the cushions at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%) | +| wallSpread_ | uint256 | - Percent spread to set the walls at above/below the moving average, assumes 2 decimals (i.e. 1000 = 10%) | + +### setThresholdFactor + +```solidity +function setThresholdFactor(uint256 thresholdFactor_) external nonpayable +``` + +Set the threshold factor for when a wall is considered "down"Access restricted + +*Interface for externally setting this value on the RANGE module* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| thresholdFactor_ | uint256 | - Percent of capacity that the wall should close below, assumes 2 decimals (i.e. 1000 = 10%) | + +### status + +```solidity +function status() external view returns (struct IOperator.Status) +``` + +Returns the status variable of the Operator as a Status struct + + + + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | IOperator.Status | undefined | + +### swap + +```solidity +function swap(contract ERC20 tokenIn_, uint256 amountIn_, uint256 minAmountOut_) external nonpayable returns (uint256 amountOut) +``` + +Swap at the current wall prices + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIn_ | contract ERC20 | - Token to swap into the wall - OHM: swap at the low wall price for Reserve - Reserve: swap at the high wall price for OHM | +| amountIn_ | uint256 | - Amount of tokenIn to swap | +| minAmountOut_ | uint256 | - Minimum amount of opposite token to receive | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| amountOut | uint256 | - Amount of opposite token received | + + + +## Events + +### CushionFactorChanged + +```solidity +event CushionFactorChanged(uint32 cushionFactor_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| cushionFactor_ | uint32 | undefined | + +### CushionParamsChanged + +```solidity +event CushionParamsChanged(uint32 duration_, uint32 debtBuffer_, uint32 depositInterval_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| duration_ | uint32 | undefined | +| debtBuffer_ | uint32 | undefined | +| depositInterval_ | uint32 | undefined | + +### RegenParamsChanged + +```solidity +event RegenParamsChanged(uint32 wait_, uint32 threshold_, uint32 observe_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| wait_ | uint32 | undefined | +| threshold_ | uint32 | undefined | +| observe_ | uint32 | undefined | + +### ReserveFactorChanged + +```solidity +event ReserveFactorChanged(uint32 reserveFactor_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| reserveFactor_ | uint32 | undefined | + +### Swap + +```solidity +event Swap(contract ERC20 indexed tokenIn_, contract ERC20 indexed tokenOut_, uint256 amountIn_, uint256 amountOut_) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| tokenIn_ `indexed` | contract ERC20 | undefined | +| tokenOut_ `indexed` | contract ERC20 | undefined | +| amountIn_ | uint256 | undefined | +| amountOut_ | uint256 | undefined | + + + +## Errors + +### Operator_AlreadyInitialized + +```solidity +error Operator_AlreadyInitialized() +``` + + + + + + +### Operator_AmountLessThanMinimum + +```solidity +error Operator_AmountLessThanMinimum(uint256 amountOut, uint256 minAmountOut) +``` + + + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| amountOut | uint256 | undefined | +| minAmountOut | uint256 | undefined | + +### Operator_Inactive + +```solidity +error Operator_Inactive() +``` + + + + + + +### Operator_InsufficientCapacity + +```solidity +error Operator_InsufficientCapacity() +``` + + + + + + +### Operator_InvalidParams + +```solidity +error Operator_InvalidParams() +``` + + + + + + +### Operator_NotInitialized + +```solidity +error Operator_NotInitialized() +``` + + + + + + +### Operator_WallDown + +```solidity +error Operator_WallDown() +``` + + + + + + + diff --git a/docs/technical/03_publications/00_papers.md b/docs/technical/03_publications/00_papers.md new file mode 100644 index 0000000..6f8d5e1 --- /dev/null +++ b/docs/technical/03_publications/00_papers.md @@ -0,0 +1,8 @@ +# Protocol Related Papers + +[Zeus, indigo - Liquid Interest Rate Markets Through Olympus Bonds](/main/technical/publications/bonds) + +[Zeus et al - Stabilizing Currency Through a Protocol Enforced Range](https://ohm.fyi/gentle-pegging) + +[Gauntlet - DeFi Liquidity Management via Optimal Control: Ohm as a Case Study](https://web.stanford.edu/~guillean/papers/ohm-staking.pdf) +- [Related Tweet Thread](https://twitter.com/tarunchitra/status/1495807277978341385) diff --git a/docs/technical/03_publications/01_ohm-bond-paper.md b/docs/technical/03_publications/01_ohm-bond-paper.md new file mode 100644 index 0000000..e221444 --- /dev/null +++ b/docs/technical/03_publications/01_ohm-bond-paper.md @@ -0,0 +1,217 @@ +--- +slug: /technical/publications/bonds +--- + +# Liquid Interest Rate Markets through Olympus Bonds + +By Zeus and Indigo, Olympus DAO + + +# Abstract + +In this paper, we will highlight some disadvantages of the existing Olympus model on a long-term timeframe and the importance of resilience and the ability to thrive in a steady-state. We present potential changes to the model to better address periods of slower growth or contraction, namely an emphasis on the bond mechanism to drive not only treasury flows, but market structure and behavior as well. This paper proposes an evolution from the existing staking-centric model in favor of a bond-centric model, where incentives lie primarily in holding future-dated OHM (commonly known as bonds). This structure adds assurances for the network, enables the development of liquid interest rate markets to facilitate healthy credit markets, and promotes closer alignment with network participants. + + +# Background + +All currency and money, be it USD or BTC, are ultimately backed by collective faith. As a society, we choose to imbue resilient systems with our belief in value itself, and utilize that system to exchange within an economy. OHM’s path to currency has been, and will continue to be, marked by trials of extreme conditions and behaviors; only through fire can it prove its resilience and antifragility. + +Olympus, like any currency issuer, has two main tools at its disposal. + +1. Liquidity +2. Interest Rates + + +We see the treasury’s control over liquidity manifested most intuitively as ownership of liquidity pools and the ability to increase or decrease liquidity through reserves. The protocol can always generate or diminish liquidity, either by purchasing or selling liquidity shares on the open market with OHM or reserves, or by creating or destroying liquidity shares directly with the addition or removal of OHM and reserves. Though the treasury has been passive to date, it is worthwhile to note that it can take active control over not only market liquidity, but pricing as well – as the dominant owner of the market, the treasury has the power to set market price. + +The treasury also influences liquidity through bond sales. However, unlike traditional supply/demand-agnostic automated market maker (AMM) liquidity, bond liquidity is isolated and directional. Bonds that accept reserves and pay OHM only provide supply and satisfy demand, whereas bonds that accept OHM and pay reserves only provide demand and satisfy supply. + +We see the treasury’s control over rates in the form of the staking reward rate, which creates a target rate of growth and baseline OHM-denominated rate of return for the network; opportunities yielding more than this will be undertaken, while opportunities yielding less will not. This has historically been manifested in bond yields, which will trade at some market-driven premium to the staking risk-free rate. The premium paid to bonders over stakers is most easily explained as a cost of illiquidity (though transaction fees and capacity play a role as well). + +The existing structure of the Olympus market is characterized by aggressive targeted growth denoted by the staking reward rate. High staking yields facilitate high bond capacities, allowing the treasury to rapidly bootstrap itself. This configuration was extremely successful for the early days of the network as it targeted zero-to-one growth. Given the strong macroeconomic tailwinds of 2021, the configured rates proved to be appropriate in matching network growth with supply growth; though volatility was experienced throughout, the protocol was successful in maintaining relatively consistent pricing throughout the year. + +A few shifts diminished the efficacy of this model. First and foremost, a proliferation of copycat projects (“forks”) adopted it based on the belief that it inherently generates value. As early projects with no real purpose or long-term intentions, these forks maximized (and marketed) the native token yields, pulling liquidity and mindshare away as it appeared to work in the short term. This inappropriate utilization of the model led to suboptimal outcomes, which in turn cast doubt upon Olympus itself; as with any tool, success is derived from the way and the reason it is used. With these forks came a tidal wave of (often unsophisticated) new investors who, misunderstanding the dynamics of the model (in large part due to the marketing of these forks), overleveraged Olympus, leading to a debt unwind and liquidity crunch. Both of these dynamics were further exacerbated by a macroeconomic shift out of an easy money environment, creating an additional headwind that compounded the previous dynamics and led to a compression in the monetary premium of the network. + +While we believe these to be transient, they have exposed weaknesses in the existing model; mostly in regards to staking. Staking serves two purposes: to protect holders from dilution, and to keep supply off of the market while the treasury conducts market operations. However, the generalized rebasing structure may not be the best suited to accomplish these goals. + +# Proposed Changes + +We begin with the addition of **internal bonds**. These are similar to the **external bonds** we know today; a user trades a quote token with the protocol in return for an amount of OHM in the future. Internal bonds differ from external bonds in that the quote token (the token given to the protocol) is OHM rather than an external asset (i.e. DAI, ETH, etc). For each 1 OHM deposited, the depositor is given a note giving claim to X OHM at Y date, where X is assumed to be greater than 1. + +Bonds are tokenized, both as unique ERC-1155’s and as composable ERC20’s. The NFT approach is appropriate for fixed-term bonds, where each deposit has a different expiration; the ERC20 approach is appropriate for fixed-expiration bonds, where each deposit expires at the same time. Internal bonds will focus on fixed-expiration, as ERC20’s more easily enable liquid secondary markets in which users can pool OHM alongside a bond token (i.e. OHM-Mar’22) to allow trading to and from different expiries. This is a crucial component to the overall approach; we will explore the implications and benefits of this in a later section. + +In concert with tokenized bonds, the base staking reward rate is reduced. This does not necessarily mean that previous yields are no longer available; rather, this means that to access them, a user must enter a bond position and take on risk of illiquidity. It also means that holders can compete with each other for higher rates, allowing the market to drive real interest rates. Whether OHM yields less or more becomes a decision made by the market. + +Within this structure, we can think of the staking reward rate as the baseline rate of return within the Olympus economy; activities (bonds, lending, yield farming, etc) will only find participants if their yields are greater than sOHM. With internal bonds providing an alternative to staking, ideally available beyond just Ethereum to enable wide participation, lower sOHM yields are to the benefit of both holders and the protocol. Holders benefit from greater utility, as opportunities that were previously unable to compete with astronomical staking yields are now viable. Meanwhile, the protocol’s cost of capital can be reduced, as staking’s no-strings-attached expense to holders (where beneficiaries can be short-term players) is diminished. + +## Tokenization + +Bond tokenization carries massive implications for the market structure and behavior of Olympus. Today, we see two contrasting dynamics: + +- Staking is completely liquid (there is infinite liquidity and zero slippage between sOHM and OHM, which the protocol keeps liquid against external assets like DAI and ETH) and yields at a protocol-dictated rate. +- Bonds are completely illiquid and yield at a fixed but market-dictated rate (determined by the discount, which floats based on supply and demand, at the time of purchase). + +The liquid nature of staking is beneficial, as illiquidity carries a premium in any market and we want to minimize cost for the protocol. At the same time, the inconsistency of bond rates is beneficial, as it leaves the ultimate decision of rates onto market participants who, with enough participation, will compete them down to their optimally efficient point. Bond tokenization and secondary markets combine the benefits of both while discarding their negatives. + +With liquid secondary bond markets, we retain the illiquidity of bonds on a protocol level, but not an individual level; while that supply is locked, it may not be the bond originator who takes on the illiquidity. Instead, a bond holder can sell their exposure to LPs in exchange for liquid OHM. The protocol still gets what it wants while removing a burden from the holder; with this, the illiquidity premium should diminish. + +By offloading the bulk of staking activity onto internal bonds, we also pull in market-dictated rates; interest rates on OHM are thrust into a competitive, protocol facilitated environment (as opposed to a protocol mandated environment, as with sOHM yields) in which players can extract and diminish yields by optimizing their individual strategies. Rates should fall naturally over time to efficient levels as the market matures. + +Tokenization across multiple expiries also forgoes the infinite liquidity seen with sOHM today, which provides segmentation benefits that we will discuss in a later section. + +## Liquidity + +The dynamic generally seen with external bonds is: a participant unstakes an amount of OHM, sells it on the market for the treasury’s desired asset, and bonds that asset in exchange for a greater amount of OHM. It can be viewed as an arbitrage opportunity allowing holders willing to take on illiquidity to expand their position in the network. + +With this, we see that the treasury’s ability to issue bonds is capped by the downward pressure they produce. We will not be able to build highly liquid secondary bond markets so long as bonds are scarce as a result of an external capital constraint. If we were to aim for 30% of OHM supply paired against bond tokens, the treasury would need to sell at least 30% of supply. This would both realize a significant amount of market cap (and likely depress valuation as a result) and dilute existing holders. Not only that; this must be repeated each time the bond in the pair expires. + +Internal bonds fix the former; by allowing holders to give their OHM to the treasury directly (instead of selling for a different asset first) we are able to generate infinite bond liquidity relative to the supply of OHM. In the previous hypothetical, 30% of market cap no longer needs to be realized. Rather, 30% of supply must simply be willing to take on a pseudo-illiquid position. Those who do also become the beneficiaries of the dilution that these bonds produce. + + + +## Segmentation + +A bond-centric approach creates enormous benefits around risk management and supply segmentation. To understand this, we first need to understand what the end result of this system looks like. An illustrative state in a bond-centric approach, where OHM supply is ~10 million: + +- 1.0 million OHM is paired against external assets in protocol-owned liquidity. + +- 1.0 million OHM is staked as sOHM, earning yield at 100% APY. + +- 1.0 million OHM is staked or deployed in various opportunities earning, on average, greater than 100% APY paid in external assets (this could be lower if depositors place a premium on non-OHM yields). + +- 5.0 million OHM is locked into bonds, originating from OHM and other assets (once created, they are indistinguishable). That supply is broken down into: + + +- 1.0 million in March 3rd expiration; + +- 1.0 million in June 3rd expiration; + +- 1.0 million in September 3rd expiration; + +- 1.0 million in December 3rd 2022 expiration; + +- 1.0 million in December 3rd 2023 expiration; + +- ~2.0 million OHM is paired with bond tokens to create secondary markets. The ratio of ohm pooled against a given expiry sets the implied price of the bond as dictated by the market. Those pools are: + + - 0.61 million OHM : 0.73 million OHM-Mar’22 + + - 0.50 million OHM : 0.73 million OHM-Jun’22 + + - 0.43 million OHM : 0.73 million OHM-Sep’22 + + - 0.34 million OHM : 0.73 million OHM-Dec’22 + + - 0.12 million OHM : 0.73 million OHM-Dec’23 + + +![](https://lh6.googleusercontent.com/m3j7BdHsb-oBaIHcsI_XI0P-clMbevWxwxChq5faXmoUif7LyCn4ZdBCuvNW9p_-myOaHqEi025Kko4jPu1fQugnlqsPxztpas78iUcHPVQrBH7GlXqIm_KRotiwgSRM3rfuQFWW) + +Illustrative scenarios: + +1. Alice wants to quickly purchase Dec‘22 bonds with 100k OHM. There is only 340k OHM paired against bonds representing 730k OHM at maturity in December 2022. In other words, the market is valuing the December maturity at a 54% discount, implying a yield of 115% in the one year interim period. Suppose Alice purchases bonds with all 100k OHM. This action “skews” the prevailing yield curve, changing the discount from 54% to 22% and lowering implied yield from 115% to 28% (an extreme scenario). As Alice bids, liquidity is potentially unlocked from two sources. Bob, who currently holds Dec’22 bonds, sells them to buy Jun’22, Sep’22, or Dec’23 bonds, capturing the yield curve imbalance that the buyer has created. Additionally, the protocol can begin to sell more Dec’22 bonds and fewer other expirations. + +2. Alice wants to quickly sell Dec’22 bonds for 100k OHM. There is only 340k OHM in the liquidity pool, and the pool trades in line with the yield curve. As Alice sells, liquidity can be unlocked from other players, who sell their short term bonds and purchase Dec’22 to capture the skew in the yield curve. However, other players could instead choose to cooperatively play PvP, refusing to provide new liquidity unless the Dec’22 market is highly discounted. Alice is forced to accept the discount or slow/stop her selling. + +3. Alice has taken out $50m debt against Dec’22 bonds worth $100m. OHM falls 10% against DAI, leading the market to view this position as at risk. The market has three options: they can bid the December expiry, increasing the value of Alice’s collateral and potentially averting her liquidation; they can build up liquidity, reducing the impact of, and capitalizing on the volume generated by, the potential liquidation; they can remove liquidity. Removing liquidity will hurt the credit rating of the market, deterring future lenders and raising the future borrow cost of all players. However, in this situation, lenders have over-provided against weak collateral, building bad debt with insolvency risk. If liquidity providers for Dec’22 remove their liquidity, Dec’22 bonds become illiquid and are thus unavailable for use by liquidators to recoup the loan principal. + + +It is important to understand that liquidity for bonds is guaranteed at expiration, but can only be expected prior to maturity. We can expect responsive liquidity during normal conditions, as profit motivated actors fill market inefficiencies and maintain the yield curve to maximize their individual returns. However, segmentation allows the market to circuit break itself in extreme circumstances. Liquidity and quality of execution may diminish during large directional flows, increasing volatility of a specific market segment but diminishing volatility in the market as a whole. + + + +## Yield Curves + +This system is in large part reliant on the formation and analysis of yield curves. By allowing independent pricing of the same asset along multiple timeframes, the market can price in varying expectations manifested as variable yields and visualized by the yield curve. + +Yield curves should be driven by the expected return of compounding short term bonds (i.e. one quarter out). A six month bond should yield approximately three month yield squared. A twelve month should yield three month4 or six month2. With this, expectations on future yields become important, as it drives the outcome of compounding over some time frame. + +We can extrapolate yields from bond prices with the following equation: + +$$ +APYbond =p^{-1/n} -1 +$$ + +where $p = {present value \over future value}$ and $n = bondtenor in years$. + +For example, a six month bond discounted 50% implies an annualized yield of 300%. + + +With this in mind, let’s go back to the previous example: + +- 2 million OHM is paired with bond tokens to create secondary markets. It is December 3, 2021. Those pools are: + +- 0.61m OHM : 0.73m OHM-Mar3 +- 0.50m OHM : 0.73m OHM-Jun3 +- 0.41m OHM : 0.73m OHM-Sep3 + +- 0.33m OHM : 0.73m OHM-Dec3’22 + +- 0.12m OHM : 0.73m OHM-Dec3’23 + + +Here is that yield curve: + +![](https://lh3.googleusercontent.com/4N-_aoVY4k6mhURU4AEcgZ9oftWKno_BuTQpWY4LXXcX1fEh0UAWbgR9bOiUt2VlRWKS35cHD0eOQ3ZtkpYHoTzMRFSVfaTI5Wku4mXhSfVHlADLZBT5tepEiB7EKj98ywTyZtTo) + +This is the most intuitive shape. This curve should form in environments where rates are expected to remain constant across the measured timeframe. As expirations extend further out, yields increase because there is greater illiquidity to compensate for. On this curve, an arbitrageur could sell December 2022 bonds and buy September 2022 bonds, correcting the slight deviation from the curve and securing a greater position when they reach expiration. Thus, we should expect to rarely see significant deviations from the curve, given the bond token is adequately liquid for rate-arbitrage. + +Here is a different scenario: + +![](https://lh5.googleusercontent.com/OZ8DJdL-qaExxE9eKNjNf0DQTNQz-CWCN4ahsJSlF20KNGCilkmIZU_utQM9Nu0LbbpvqzpnBsb6NmbuD3eHsFd46VWMIO4mv3iI0nF0ErRxlD-WFpElf1F28H02BcvirgEGLKiZ) + +In this case, the market is pricing in diminishing rates over time. The expectation is that short term yields will be lower in 2023 than they were in 2022. Thus, December ‘23 bonds should trade at a lower annualized yield because the nominal yield earned will still be greater than a short-term compounding strategy. + +There is a reasonable expectation that early on, these markets operate inefficiently. Many expirations may deviate from the correct yield curve, sometimes by significant margins. They may even form yield curves that do not accurately reflect the state of the market. However, this inefficiency creates opportunity for sophisticated actors to capitalize on, generating new activity and bringing new participants into the ecosystem. Over time, as competition over rate-arbitrage opportunities picks up, we can expect yields to compress to their optimal levels based on the present and future risk-free rate of return (the staking reward rate). + + + +# Implications + +One of the most significant components of this system is the market power it imbues to the protocol. In the current environment, 100% of OHM supply is effectively liquid at any given time, and thus the protocol must account for scenarios in which 100% of supply fights against it. This feeds the concept of risk-free value; the point at which the protocol has greater capital than the market has capitalization. The bond-first structure shifts this dynamic in favor of the protocol. Now, not only is a significant portion of total supply illiquid and unable to interfere with the treasury’s objectives; the treasury now knows exactly when supply will become liquid, and can influence the rate at which supply becomes illiquid. + +This structure creates a massive sink and utility for supply – bond token liquidity. This is a relatively risk-free endeavor; there is impermanent loss involved, but it can be quantified and is not particularly significant until deep discounts (i.e. an 0.8 : 1 pool would experience 1.1% IL upon its’ return to peg). Trading fees should be more than enough to compensate for IL, and if not, conservative incentives will fill the gap. Bond token LP is a productive activity that generates value for the ecosystem, unlike vanilla staking, and thus even with an incentive expense this can be viewed as a step forward. + +We can expect yields to depress over time as competition ramps up. This is to the detriment of an individual player but to the benefit of the protocol. + + + +# Vaults + +We can expect to see the formation of bond vaults. These protocols will provide open automated bond strategies to market participants, abstracting away the market competition to offer a simple interface akin to staking today. A vault would accept user deposits of OHM, and deploy that OHM into various expiries and strategies along yield and risk curves. + +For example, a vault may choose to hold 10% of its deposited capital in sOHM, generating the lowest yield but offering the greatest liquidity. This can be thought of as liquid cash-on-hand, used to honor redemptions when users withdraw from the vault. Under normal circumstances, this will be more than enough to ensure users can withdraw without notice whenever they desire. An additional 40% of deposits might be used to purchase near-dated bonds, which should intuitively be the most liquid on secondary markets. Even in the case where secondary markets dry up for these bonds, they will expire within a short period of time and thus are relatively safe. The remainder would be deployed into longer dated bonds, which carry the greatest illiquidity risk but also offer the greatest yields. The yield for depositors in the vault becomes the aggregate return of all of these positions. + +Vault systems do carry the risk of bank run. Since vault deposits are converted into positions with varying levels of illiquidity, in the case where all depositors seek to withdraw, they may find themselves unable. This is not necessarily the case; if secondary markets remain liquid for bond tokens at fair pricing, a vault will remain perfectly solvent even in a mass withdrawal. However, in a more systemic event, secondary markets may begin to break down and this becomes a real concern. + +The main counter to this concern is the persistent availability of native staking. Those who find this illiquidity risk unacceptable are more than welcome to simply remain in the protocol facilitated environment, where liquidity back to OHM is guaranteed. The tradeoff for this safety is, of course, a lower expected return. While vaults can have some benefit of increased liquidity over an individually run bond strategy, this should not be considered the main purpose of participation. Rather, vaults should serve the purpose of automating strategies for less active participants, or those looking to leverage economies of scale. + +The rise of these service protocols, which cannot be guaranteed but is to be expected, will be interesting at the very least. In a perfect world, they will generate greater participation in bond markets, contributing large-scale competitive forces that keep markets liquid and efficient. + + + +# Repurchase Markets + +The vault structure may create demand for OHM repo markets. At a high level, these repo markets would allow a participant to borrow liquid OHM against an illiquid bond (or vice versa), likely for a short period of time. + +For example, suppose a vault is fielding mass withdrawals, and has depleted its liquid reserves (sOHM and closest-dated bonds). It is now faced with a short list of choices. It can: +- Provide depositors with bond tokens. +- Remove bond token liquidity to provide liquid OHM, but reduce liquidity in the overall bond market and risk systemic yield curve imbalances. +- Refuse to honor withdrawals for a period of time. +- Borrow liquid OHM against bond tokens to honor short-time liabilities, to be paid back with interest at a future date. + +Refusal to honor withdrawals, or servicing of withdrawals with illiquid or pseudo-illiquid positions, is likely to be accompanied by dissent from the vault users. Removing bond token liquidity may be viable, but it risks creating systemic issues that are harmful to the network and, by extension, the vault. Repo markets provide a viable alternative at the cost of interest. + +As with vaults, it remains to be seen whether such services will ultimately be offered. There are abundant implementation questions when it comes to these topics (though there are promising projects addressing these questions already). This should, however, highlight the expansive potential of this structure. + +# Drawbacks and Tradeoffs + +This proposed system adds a great amount of complexity. With that complexity comes productivity and value, but it is reliant on efficient markets maintained by competition among network participants. Without competition, markets will likely trade at less-than-optimal rates, participation in the network becomes more difficult, and the entire thing does more harm than good. While this does not seem like the most likely outcome by any means, it is something that should be strongly countered through thorough preparation and the continued maturation of Olympus market prior to large-scale introduction. + +This is also self-referential to a moderate degree. There is far more circular activity generated than within the current structure. Over a long time frame, this is important; crucial, really. We want circularity; activity should flow from one place to another without leaving the econohmy. However, self-referential dynamics are something that must be earned. + +# In Conclusion + +Through the proposed structure of this paper as well as its natural second-order effects (to be discussed in an additional paper), the mental model of the network changes. Yields go from perpetual projection to fixed sum and fixed time-period. The concept of risk-free value and a singular floor erode in favor of continuous treasury utilization. Behavior around staking and participation shift from “what can the network do for me?” to “what can I do for the network?” Though in the case of the latter they moreso become one and the same, it's meant to highlight a point. The way in which we think about Olympus must evolve if and when this is implemented. + +Most of these concerns should be remedied with time and maturity. The intent of this paper is not to push it through tomorrow. This is a marathon, not a sprint. This can act as a guiding light for months and potentially years to come. It’s not going to come together soon, nor is it all going to come together at the same time. What we seek to build with this system is a well-regulated interest rate market for OHM, providing guidance for bond discounts and lending markets and an outlet for healthy market competition. We can make progress prior to the items in this paper, and we can make progress after the items in this paper. We should focus on the end result we are seeking, determine whether this is a viable and constructive path toward those results, and begin executing if the answer is yes. diff --git a/docs/technical/03_publications/_category_.json b/docs/technical/03_publications/_category_.json new file mode 100644 index 0000000..a2b7a5c --- /dev/null +++ b/docs/technical/03_publications/_category_.json @@ -0,0 +1,5 @@ +{ + "label": "Publications", + "position": 3, + "collapsed": true +} \ No newline at end of file diff --git a/docs/technical/04_audits.md b/docs/technical/04_audits.md new file mode 100644 index 0000000..a419ec0 --- /dev/null +++ b/docs/technical/04_audits.md @@ -0,0 +1,23 @@ +# Audits + +## Olympus V1 +| Auditor | Link | +| --- | --- | +| PeckShield | [Link](https://github.com/peckshield/publications/blob/master/audit_reports/PeckShield-Audit-Report-OlympusDAO-v1.0.pdf) +| Omniscia | [Link](https://omniscia.io/olympusdao-algorithmic-currency-protocol) + +## Olympus V2 + +| Auditor | Link | +| --- | --- | +Omniscia | [Link](https://omniscia.io/olympus-dao-protocol-v2/) + + +## Olympus V3 + +| Auditor | Link | +| --- | --- | +Spearbit | [Link](/OlympusDAO-1.pdf) +CodeArena | [Link](https://code4rena.com/reports/2022-08-olympus/) +KebabSec (remediation) | [Link](https://hackmd.io/@12og4u7y8i/rk5PeIiEs) +KebabSec (finalization) | [Link](https://hackmd.io/@12og4u7y8i/Sk56otcBs) \ No newline at end of file diff --git a/docs/treasury/pol.md b/docs/treasury/pol.md deleted file mode 100644 index de4ad44..0000000 --- a/docs/treasury/pol.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Protocol Owned Liquidity - -Olympus pioneered the concept of protocol owned liquidity, and the Olympus protocol has always owned a substantial amount of the OHM liquidity. This ensures users and protocols are always able to swap OHM, regardless of market conditions and external events. - -The Olympus treasury keeps OHM liquidity on decentralized exchanges. With RBS the balance between reserves and liquidity is algorithmic, with the goal to optimize the liquidity depth and reserves for robustness and long term market stability. diff --git a/docs/treasury/range-bound.md b/docs/treasury/range-bound.md deleted file mode 100644 index 540f975..0000000 --- a/docs/treasury/range-bound.md +++ /dev/null @@ -1,133 +0,0 @@ ---- -sidebar_position: 2 -sidebar_label: Range Bound Stability ---- - -# Range Bound Stability - -This document codifies the requirements for a system to implement the Range-Bound Stability model defined in the [recent paper](https://docs.google.com/document/u/2/d/e/2PACX-1vSIufbgAxAAtZkITd_s57o5AmyhAnk6iYbLYvN-ATL59hQ5nC2t2BTPvA8X9DYzFa-i3PRw9ARrAS9E/pub) by Zeus et al. - ---- - -## Components - -System is comprised of three components: - -1. the range setter - - price data (from oracle) - - moving average period length (from governance) - - spread (from governance) - - treasury data (from oracle) - - depth (from governance, % reserves) - - regeneration rate (from governance) -2. the treasury balancer - - asset data (from oracle) - - liquidity/reserve balance (from governance) - - offering length/reoffering period length (governance) - - vesting speed (closest liquid expiration?) - - bond depo integration -3. the liquidity maintainer - - pool list (need to verify) - ---- - -the range setter keeps track of a moving average of price -spanning Tma days. it applies a spread Sw to that moving average -to determine a range (MA _ 1-Sw, MA _ 1+Sw). it calculates the -amount to buy B at the range low using treasury T and the depth -factor Fb, and the amount to sell at the range high by scaling -the bid up by 2x radius and dividing by price at top of the -range (B _ (1+ (2 _ Sw)) / (MA \* 1+Sw)). it accepts trades at -range (low, high) up to depth (low, high). depth is regenerated -if price sits on the opposite side of the MA for Tt epochs in a -Tr period (ie 18 out of 21 epochs). - ---- - -the treasury balancer maintains a balance of liquidity and -reserve assets. when assets in liquidity change (as a result -of trading activity) or assets in reserves change (as a result -of range activity), this ratio is skewed. the balancer creates -bond markets to correct this skew (ie underweight reserves, -create bond market selling ohm for dai. overweight reserves, -create bond market selling dai for ohm). - ---- - -the liquidity maintainer maintains liquidity by minting -into xyk liquidity pools. it keeps a list of verified -pools to which it mints tokens at the staking reward rate -and calls the sync() function to update the pools virtual -balances. - ---- - -![range-denoted](/gitbook/assets/range-denoted.png) - -## Requirements - -### Protocol-enforced Range - -1. Calculate and maintain a moving average price for OHM against a specified reserve asset for a configurable duration. The MA price should be updated each system epoch. -2. Calculate lower and upper bounds for the price OHM against a specified reserve asset, both “wall” and “cushion” components, from the moving average price and configurable spread variables. - - -3. Allow users to swap OHM for reserves at the lower wall price (WL) and reserves for OHM at the upper wall price (WH) up to the specified capacity of the current walls. - - a. Capacity of the lower wall (bid) in reserves should be the amount of reserves in the Olympus Treasury multiplied by a configured bid factor (percent of reserves to use for each wall). - - b. Capacity of the upper wall (ask) in OHM should be the capacity of the lower wall (bid) divided by the upper wall price and scaled up by the difference in spread from the lower wall to the upper wall. - - c. When the capacity of either wall is depleted, the system should not allow additional swaps on that side until it is regenerated. - - d. When the capacity of the upper wall (ask) is depleted, the system should not reinstate a new wall with additional capacity until the current price is observed to be below the MA price for a X out of the last Y system epochs, where X and Y are configured parameters representing the regeneration threshold (X) and total number of observations (Y). Additionally, the wall should not regenerate until a minimum configured amount of time has past. - -4. Deploy a bond market to sell OHM for reserves when the current price of OHM against the reserve asset is greater than or equal to the upper cushion price at the system epoch with a capacity equal to the configured percentage of the upper wall capacity to use for the cushion. - - a. If a bond market is active on a system epoch, the system should close the market if the current price of OHM against the reserve is back below the upper cushion price or has exceeded the upper wall price. - - b. The bond market should be closed if the upper wall capacity is depleted. - - c. The bond market should be instant-swap with no vesting. - - d. The bond market should start at the upper wall price and have a minimum price of the upper cushion price. - -5. Deploy a bond market to buy OHM with reserves when the current price of OHM against the reserve asset is less than or equal to the lower cushion price at the system epoch with a capacity equal to the configured percentage of the lower wall capacity to use for the cushion. - - a. If a bond market is active on a system epoch, the system should close the market if the current price of OHM against the reserve is back above the lower cushion price or has gone below the lower wall price. - - b. The bond market should be closed if the lower wall capacity is depleted. - - c. The bond market should be instant-swap with no vesting. - - d. The bond market should start at the lower wall price and have a minimum price of the lower cushion price. - -### Treasury Rebalancing - -1. Maintain a configured target percent of the treasury’s reserve assets in the specified OHM-reserve liquidity pool for the reserve. - - a. The system should maintain this balance through the use of time-weighted automated market maker (TWAMM) orders that are executed over a configured amount of time and interval. - - b. The system should check the current percentage of treasury-owned reserves in the liquidity pool each system epoch and input TWAMM orders to correct imbalances that exceed a configured threshold. If an order is active on a system epoch, it should determine whether to close or continue the order before issuing a new one. - -### User-provided Range (Wall of Ohmies) - -1. Allows users to stake OHM, the reserve asset, or both to provide funds for a second wall at the cushion prices. - - a. The stake should be locked on deposit. - - b. Users should be able to unlock their stake which starts a configurable cooldown period. Once the cooldown period expires, they can withdraw their stake. - -2. Maintain a target ratio of value between the two assets in the pool to provide sufficient capital for both walls to support the range. - - a. The system should incentivize users to balance the ratio to the target by incentivizing them to provide the mix of tokens that moves the system closest to the target ratio. - - b. The target ratio should adjust based on the movement of price inside the range to avoid staker dilution from new staker incentives on price movements within the range. - -3. Allow users to withdraw their stake and receive a system defined mix of OHM and the reserve asset according to what will best help it correct to the target ratio. The system defined mix of assets prevents manipulation of incentives and circular incentive calculations on withdrawals. - -4. Pay a protocol defined token as a reward for staking. - - a. Allow the protocol to configure the rewards issued per day. - - b. Only users with locked stakes should receive diff --git a/docs/user-guides/00_using-website/_category_.json b/docs/user-guides/00_using-website/_category_.json new file mode 100644 index 0000000..898852f --- /dev/null +++ b/docs/user-guides/00_using-website/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Using The Web App", + "collapsed": true +} \ No newline at end of file diff --git a/docs/using-the-website/bonds/bond_example.mdx b/docs/user-guides/00_using-website/bonds/bond_example.mdx similarity index 100% rename from docs/using-the-website/bonds/bond_example.mdx rename to docs/user-guides/00_using-website/bonds/bond_example.mdx diff --git a/docs/using-the-website/bonds/index.mdx b/docs/user-guides/00_using-website/bonds/index.mdx similarity index 98% rename from docs/using-the-website/bonds/index.mdx rename to docs/user-guides/00_using-website/bonds/index.mdx index c304643..2065cc9 100644 --- a/docs/using-the-website/bonds/index.mdx +++ b/docs/user-guides/00_using-website/bonds/index.mdx @@ -1,9 +1,9 @@ --- sidebar_position: 2 -sidebar_label: Purchase A Bond (1, 1) +sidebar_label: Purchase A Bond --- -# Purchasing A Bond (1, 1) +# Purchasing A Bond Bonds allow users to buy OHM from the protocol at a discount by trading it against i\) liquidity \(LP tokens\) or ii\) other assets. The former are called [liquidity bonds](../../contracts/glossary#liquidity-bonds) and the latter [reserve bonds](../../contracts/glossary#reserve-bonds). diff --git a/docs/using-the-website/staking.mdx b/docs/user-guides/00_using-website/staking.mdx similarity index 99% rename from docs/using-the-website/staking.mdx rename to docs/user-guides/00_using-website/staking.mdx index 7d44c87..3fb2169 100644 --- a/docs/using-the-website/staking.mdx +++ b/docs/user-guides/00_using-website/staking.mdx @@ -1,9 +1,10 @@ --- sidebar_position: 1 --- + import { YouTube } from 'mdx-embed'; -# Stake Your OHM (3, 3) +# Stake Your OHM Staking allows you to earn OHM passively via auto-compounding. By staking your OHM with OlympusDAO, you receive sOHM (staked OHM) in return at a 1:1 ratio. After that, your sOHM balance will increase automatically on every epoch based on the current APY. diff --git a/docs/user-guides/01_using-etherscan/_category_.json b/docs/user-guides/01_using-etherscan/_category_.json new file mode 100644 index 0000000..98465a9 --- /dev/null +++ b/docs/user-guides/01_using-etherscan/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Using Etherscan", + "collapsed": true +} \ No newline at end of file diff --git a/docs/using-etherscan/staking.md b/docs/user-guides/01_using-etherscan/staking.md similarity index 99% rename from docs/using-etherscan/staking.md rename to docs/user-guides/01_using-etherscan/staking.md index 6b30e3c..08a88cd 100644 --- a/docs/using-etherscan/staking.md +++ b/docs/user-guides/01_using-etherscan/staking.md @@ -1,4 +1,4 @@ -# Stake Your OHM \(3, 3\) +# Stake Your OHM Sometimes, the Olympus website might not be accessible due to [hosting issues](https://twitter.com/FleekHQ/status/1416505712222609411). Fear not, you can still interact with the Olympus contracts to perform certain actions such as staking. In this guide, we will show you how to stake OHM tokens via [Etherscan](https://etherscan.io/). diff --git a/docs/using-etherscan/unstaking.md b/docs/user-guides/01_using-etherscan/unstaking.md similarity index 100% rename from docs/using-etherscan/unstaking.md rename to docs/user-guides/01_using-etherscan/unstaking.md diff --git a/docs/utility/governance.md b/docs/utility/governance.md deleted file mode 100644 index 4c31944..0000000 --- a/docs/utility/governance.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -sidebar_position: 4 -sidebar_label: Governance ---- - -# Governance - -How to use your ohm in governance diff --git a/docs/utility/index.md b/docs/utility/index.md deleted file mode 100644 index f5d34fa..0000000 --- a/docs/utility/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -sidebar_position: 1 -sidebar_label: Utility ---- - -# Utility - -This section is about Ohm's Utility diff --git a/docs/utility/lending-collateral.md b/docs/utility/lending-collateral.md deleted file mode 100644 index 233598f..0000000 --- a/docs/utility/lending-collateral.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -sidebar_position: 3 -sidebar_label: Lend / Collateral ---- - -# Lending - -lending & collateral things diff --git a/docs/utility/providing-liquidity.md b/docs/utility/providing-liquidity.md deleted file mode 100644 index 492899f..0000000 --- a/docs/utility/providing-liquidity.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -sidebar_position: 2 -sidebar_label: "LP" ---- - -# LP - -about lping diff --git a/docs/utility/staking.md b/docs/utility/staking.md deleted file mode 100644 index 0706190..0000000 --- a/docs/utility/staking.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -sidebar_position: 1 -sidebar_label: Staking / Ohm Bonds ---- - -# Staking - -staking stuff diff --git a/docusaurus.config.js b/docusaurus.config.js index 079cdaf..bcf9602 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -12,7 +12,7 @@ const config = { tagline: "", url: "https://docs.olympusdao.finance", baseUrl: "/", - onBrokenLinks: "throw", + onBrokenLinks: "warn", onBrokenMarkdownLinks: "warn", favicon: "img/favicon.svg", @@ -116,11 +116,11 @@ const config = { style: "dark", links: [ { - title: "Docs", + title: "Documentation", items: [ { - label: "Protocol Docs", - to: "/main/basics/readme", + label: "Protocol Documentation", + to: "/main/overview/intro", }, ], }, diff --git a/sidebars.js b/sidebars.js index 4f272da..c5b354a 100644 --- a/sidebars.js +++ b/sidebars.js @@ -21,33 +21,14 @@ const sidebars = { main: [ { type: "category", - label: "Basics", + label: "Overview", collapsible: true, - collapsed: true, - link: { - type: "doc", - id: "basics/readme", - }, - items: [ - "basics/bonding", - "basics/inverse-bonds", - "basics/staking", - "basics/bophades" - ], - }, - { - type: "category", - label: "Treasury", - collapsible: true, - collapsed: true, + collapsed: false, link: { type: "doc", - id: "treasury/index", + id: "overview/intro", }, - items: [ - "treasury/pol", - "treasury/range-bound", - ], + items: [{ type: "autogenerated", dirName: "overview" }], }, { type: "category", @@ -56,64 +37,24 @@ const sidebars = { collapsed: true, link: { type: "doc", - id: "governance/index", + id: "governance/dao", }, - items: [ - "governance/council", - "governance/policy", - { - type: "category", - label: "DAO Processes", - collapsible: true, - collapsed: true, - items: [ - "governance/treasury-process", - "governance/policy-process", - "governance/grant-process", - ] - } - ], + items: [{ type: "autogenerated", dirName: "governance" }], }, { type: "category", - label: "Technical Guides", + label: "Technical", collapsible: true, collapsed: true, - // link: { - // type: "doc", - // id: "technical-guides/index", - // }, - items: [ - // { - // type: "category", - // label: "Using the Website", - // collapsible: true, - // collapsed: true, - // items: [ - // "using-the-website/staking", - // { - // type: "category", - // label: "Purchase A Bond (1, 1)", - // collapsible: true, - // collapsed: false, - // link: { - // type: "doc", - // id: "using-the-website/bonds/index", - // }, - // items: [{ type: "doc", id: "using-the-website/bonds/bond_example" }], - // }, - // "basics/migration", - // ], - // }, - { - type: "category", - label: "Contracts", - collapsible: true, - collapsed: true, - items: [{ type: "autogenerated", dirName: "contracts" }], - } - ], + items: [{ type: "autogenerated", dirName: "technical" }], }, + //{ + // type: "category", + // label: "User Guides", + // collapsible: true, + // collapsed: false, + // items: [{ type: "autogenerated", dirName: "user-guides" }], + //}, // { // type: "category", // label: "Get Involved", diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 057580a..5ffd7d9 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -16,44 +16,50 @@ import { BookOpenIcon, ChatBubbleLeftIcon, CodeBracketIcon, - BuildingLibraryIcon + BuildingLibraryIcon, + MapIcon } from "@heroicons/react/24/outline"; export const actions = [ { - title: "Basics", - href: "#", + title: "Overview", icon: InformationCircleIcon, - to: "./main/basics/readme", - text: `Olympus Protocol core concepts`, + to: "./main/overview/intro", + text: `What is Olympus Protocol?`, }, { - title: "Treasury", - href: "#", + title: "Governance", icon: BuildingLibraryIcon, - to: "./main/treasury/pol", - text: `All about Olympus Treasury`, + to: "./main/governance/dao", + text: `An overview of Olympus Governance`, }, { - title: "Governance", - href: "#", + title: "Technical", icon: BookOpenIcon, - to: "./main/governance", - text: `An overview of Olympus Governance`, + to: "./main/technical/overview", + text: `Technical information and documentation`, + } + /* + { + title: "User Guides", + icon: MapIcon, + to: "./main/user-guides/using-website/staking", + text: `How to interact with the protocol`, }, + */ ]; export const github = [ { - title: "olympus-contracts", + title: "olympus-v3", + href: "https://github.com/OlympusDAO/olympus-v3", + icon: CodeBracketIcon, + }, + { + title: "olympus-contracts (OLD)", href: "https://github.com/OlympusDAO/olympus-contracts", icon: CodeBracketIcon, }, - // { - // title: "Bophades Framework", - // href: "https://github.com/OlympusDAO/bophades2", - // icon: CodeBracketIcon, - // }, { title: "olympus-frontend", href: "https://github.com/OlympusDAO/olympus-frontend", @@ -72,19 +78,9 @@ export const github = [ export const Guides = [ { - title: "Treasury", - text: "The Treasury represents all assets owned and controlled by the protocol", - to: "./main/treasury/pol", - }, - { - title: "Inverse Bonds", - text: "Inverse bonds have been introduced as a protocol lever in OIP-76 as a way to support the price of OHM when it is below the backing per OHM", - to: "./main/basics/inverse-bonds", - }, - { - title: "Staking your OHM", - text: "Learn how to stake to earn OHM passively via auto-compounding", - to: "./main/using-the-website/staking", + title: "What is Olympus Protocol?", + text: "An overview of the Olympus protocol", + to: "./main/overview/intro", }, ]; diff --git a/static/OlympusDAO-1.pdf b/static/OlympusDAO-1.pdf new file mode 100644 index 0000000..488eb6d Binary files /dev/null and b/static/OlympusDAO-1.pdf differ diff --git a/static/img/ohm-pilled.png b/static/img/ohm-pilled.png new file mode 100644 index 0000000..436605f Binary files /dev/null and b/static/img/ohm-pilled.png differ