# Introduction

<figure><img src="https://4283470523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0w4CbdfgJSQ1R3M9z4f%2Fuploads%2FeCMBlKaCKFs4J4vDiUdw%2Fdocs%20banner.png?alt=media&amp;token=a96da109-f08f-49fa-b66b-87ad6d0c945a" alt=""><figcaption></figcaption></figure>

## Overview

Essence Finance aims to realize a vision of issuing a stablecoin that is both highly scalable and truly decentralized.

Essence Finance is unlocking a new paradigm for decentralized finance, one focused on providing users with a stable and decentralized method of storing and transferring value, without sacrificing the core principles of decentralization and security.

### Tokens

The Essence Ecosystem uses a dual token model consisting of:

* **CHI:** A fully collateralized, yet scalable, decentralized stablecoin pegged to the US dollar.
* **ZEN:** A dual utility token serving as the governance token and beneficiary of protocol growth.

### End Goal

Our goal is to issue a scalable, truly decentralized stablecoin capable of various use cases in the decentralized finance (DeFi) ecosystem, enabling us to cater to a broader range of needs within the DeFi ecosystem.


# Peg Stabilty

CHI's peg stability is achieved through the use of arbitrage, allowing for an extremely tight peg around $1. This is done through direct redeemability, meaning CHI can always be minted or redeemed for $1 of collateral. This mechanism ensures that CHI's price stays close to its target of $1, with any deviation from this price creating an opportunity for arbitrage.

> For example, if CHI is trading on secondary markets above $1, then an arbitrageur can mint CHI for $1 and sell it on the secondary market for a profit. Conversely, if CHI is trading below $1, then an arbitrageur can buy the cheap CHI and redeem it for $1 of collateral, making a profit in the process. This arbitrage mechanism helps to keep CHI's price anchored to its target of $1.

Essence can also deploy PCV (Protocol Controlled Value) to secondary markets to provide liquidity for CHI, allowing extremely deep liquidity and reinforcing CHI's peg.&#x20;

### Peg Stability Module&#x20;

Our Peg Stability Module (PSM) at launch will be using USDC to ensure a smooth launch. We will gradually transition over to use an ETH PSM which is currently unheard of in the stablecoin space and would be a revolutionary step for decentralized stablecoins.&#x20;

<figure><img src="https://4283470523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0w4CbdfgJSQ1R3M9z4f%2Fuploads%2Fo6gDktK4zQnT8ipEOPNQ%2Fchi%20psm%20diagram.png?alt=media&amp;token=758467fa-894e-40aa-bca1-50ada73cb8d0" alt=""><figcaption></figcaption></figure>


# Collateralization

{% hint style="info" %}
ZEN, our governance token, is ***not*** and ***will never be*** counted collateral or used to back CHI.\
&#x20;\
On the analytics page, CHI is displayed as an asset. However, user-owned CHI is ***not*** backed by CHI. Instead, it is the protocol-owned CHI that, if removed, would only be burned. It will never be used to claim PCV, effectively canceling it out.
{% endhint %}

The collateralization ratio is determined by the Protocol Controlled Value (PCV) and the amount of CHI in circulation. The formula is:

***Value of collateral  /  CHI in circulation \* 100%***

> For example, if the protocol holds $100 worth of collateral and there are 75 CHI tokens in circulation, the collateralization ratio would be calculated as 100/75\*100 = 133%.

**The formula ignores "Protocol controlled CHI" because any CHI that the protocol holds will never be sold for PCV, only burned.**

{% hint style="info" %}
Essence will maintain a **fully collateralized state**, ie the minimum collateral ratio will be 100%. CHI will always be **1:1** redeemable with the PCV, meaning holders of CHI can always redeem CHI for $1 of collateral.
{% endhint %}

***

## Overcollateralized

The protocol can become overcollateralized, meaning the value of the collateral (PCV) **exceeds** the circulating supply of CHI. This comes from the PCV **yield** and **appreciation of PCV** with

1. Partial allocation towards ZEN buybacks to help align the incentives of ZEN holders with the rest of the **Essence** ecosystem
2. The remainder serving as a buffer to absorb volatility and earn yield.

The market-bought ZEN is allocated towards the following in governance-controlled ratios:

* Burning
* DAO Treasury
* Staking rewards
* Bribing on Solidly forks

Overcollateralization occurs when the PCV appreciates in value or earns yield, causing an increase in the value of the PCV.


# Decentralization

The role of CHI is to fill the need of a truly decentralized stablecoin, that can still scale effectively. There are currently very few options, with LUSD being the only truly decentralized option, however, they have issues with scalability due to requiring over-collateralization.

### Our Approach

As you may be thinking, 1:1 USDC backing is not "truly decentralized". Our end goal is for CHI to be backed solely by decentralized assets like ETH, but due to price volatility it would be difficult to maintain 100% collateralization at launch.

The protocol will need to be overcollateralized to allow for volatile assets. Our plan for Essence is to launch CHI whilst being backed 1:1 with a stablecoin, then deploying the collateral to earn a yield, slowly building up our collateralization level.

As the collateralization level increases, Essence can gradually gain exposure to more volatile assets i.e. ETH. If ETH appreciates in value, this would further increase the collateralization level, allowing for an increased buffer against future volatility.

### End Goal

Essence will eventually be 100% collateralized by solely decentralized assets, and rely on trust-minimized oracles (Chainlink) for maintaining CHI peg; i.e CHI can be minted/redeemed for $1 of ETH.

After conducting thorough research and analysis of past successes and failures of stable asset approaches in DeFi we believe that this is the best strategy to accomplish our end goal of true decentralization, whilst still ensuring CHI stability and safety for CHI holders.

### Safety

The strategy adopted to achieve full decentralization is centered around sustainability and effectiveness while minimizing risk for CHI holders. Essence has implemented robust safety mechanisms to safeguard CHI against black swan events. In the initial stages, responsive PCV (Protocol Controlled Value) management will be integrated. For instance, if the collateralization ratio approaches 100% and Essence holds significant exposure to volatile assets, those assets can be converted to stablecoins.

Essence’s ultimate goal is a genuinely decentralized stablecoin. However, decisions will always prioritize the safety of CHI holders and stakeholders. Steps toward decentralization—such as allocating PCV heavily to volatile assets like Ethereum—will only be taken when they do not pose critical risks to CHI holders. We recognize that achieving true decentralization will take time, and we are committed to patiently working toward that goal without taking premature actions that would jeopardize the safety of the protocol.


# ZEN

Essence is a community-driven protocol with ZEN holders being the collective stewards of the PCV and the Essence ecosystem. ZEN holders have skin in the game as the direct beneficiaries and risk bearers of PCV performance, aligning ZEN holders and CHI holders to ensure a productive ecosystem.

## Value Accrual&#x20;

If the protocol is [Collateralization](/protocol/collateralization#overcollateralized), CHI is minted and used to buy back ZEN, accruing value to the price of ZEN.&#x20;

## Protocol Revenue&#x20;

The protocol can become overcollateralized through the PCV appreciating in value or earning yield, both of which increase the total value of the PCV and put the protocol in an overcollateralized state.\
In this case, the ZEN brought back would be passed on to xZEN stakers.


# Distribution

<div data-full-width="false"><figure><img src="https://4283470523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FD0w4CbdfgJSQ1R3M9z4f%2Fuploads%2F6GNpdBXoG9ocaW08982e%2Ftoken%20dis%20zen.png?alt=media&amp;token=80ef6175-33f9-48c8-b9f3-99f4f65c4747" alt=""><figcaption></figcaption></figure></div>

<table><thead><tr><th>Allocated To</th><th>Allocation</th><th data-hidden></th></tr></thead><tbody><tr><td>Community </td><td>55% (Distributed over 3 years)</td><td></td></tr><tr><td>Core Team </td><td>20% (Locked: vested over 3 years)</td><td></td></tr><tr><td>Treasury </td><td>12% (Locked: vested over 1 years)</td><td></td></tr><tr><td>Future Airdrops</td><td>8% (Locked: vested over 1 years)</td><td></td></tr><tr><td>Initial Liquidity</td><td>5% (Used to provide initial liquidity)</td><td></td></tr><tr><td><strong>Total Supply</strong></td><td><strong>1,000,000,000</strong></td><td></td></tr></tbody></table>

### Community&#x20;

Essence will reserve 55% of the token supply for liquidity programs and community incentives. ZEN tokens will be distributed through a variety of yield opportunities, specifically designed for our liquidity providers.

### Core Team&#x20;

Our Core Team and key contributors will receive 20% of the **total** token supply. This arrangement ensures that their ongoing commitment to Essence Finance aligns with the interests of our community.&#x20;

20% of the team’s allocation will be locked as xZEN, and the remaining 80% will be locked and vested linearly over the 3-year period.

### Treasury&#x20;

Essence will set aside 12% of the ZEN supply for the Essence DAO Treasury. These funds are reserved for various purposes, potentially including the compensation for Security Bug Bounties, conducting audits for new smart contracts, and providing grants to protocols within the Essence Ecosystem.

### Future Airdrops

To reward those who supported Essence, 8% of the token supply will be allocated towards future airdrops.&#x20;

*There is no set date or criteria for the ZEN airdrop, but providing LP to any CHI pool on Tokan, continued or new CHI LP providing on Velodrome, minting CHI and xZEN stakers will be part of the criteria.*

### Initial Liquidity

To kickstart initial DEX liquidity, 5% of the ZEN supply will be allocated to provide liquidity. This will help to promote price stability for ZEN and ensure smooth trading experiences at launch .


# Stake

xZEN is a non-transferable escrowed governance token. ZEN can be converted into xZEN at a 1:1 ratio, which can then be staked to earn a yield generated from PCV productivity.

### Earn Yield

Staking xZEN will earn a yield generated by the protocol. This yield can be earned in the form of additional xZEN tokens or other tokens that are part of the protocol's ecosystem.

The yield earned through xZEN staking is a real yield and not inflationary rewards. This is generated through productive use of the PCV reserves, ensuring the stability and sustainability of the ecosystem in the long run.

### Governance&#x20;

By holding xZEN, which serves as the governance token, community members can participate in voting for official proposals. The more xZEN held, the greater the voting power of the user. To calculate the voting power, both the user's wallet holdings and staked xZEN balances are considered.&#x20;

xZEN in the process of being redeemed is not counted.

### Redeeming

The process of converting xZEN to ZEN involves vesting, which allows users to select the duration of the process. The conversion ratio increases proportionally to the vesting duration chosen by the user. \
For example, the minimum vesting duration of 30 days will provide a conversion ratio of 1:0.25, while the maximum vesting duration of 6 months will provide a ratio of 1:1.


# Protocol Controlled Value (PCV)

Protocol Controlled Value (PCV), is a subset of Total Value Locked. However, instead of allowing users to temporarily lock tokens in return for rewards, the protocol inherits ownership of the tokens. The protocol is able to use this capital to pursue its objectives, such as maintaining the stability of the peg, providing liquidity, and generating yield.

{% hint style="info" %}
Essence can even maintain balances in governance tokens of integrating platforms and leverage these tokens to contribute to the governance process throughout the ecosystem.
{% endhint %}

### Liquidity&#x20;

Many DeFi protocols are heavily reliant on mercenary liquidity, with them offering high rewards and incentives. However, this approach is unsustainable in the long run, as liquidity providers are only loyal as long as the rewards are active. As a result, capital can quickly disappear, often being detrimental to the protocol's long term success.

By providing our own liquidity instead of relying on external sources, Essence avoids the pitfalls of mercenary liquidity. This results in stable and long-term liquidity for the Essence ecosystem, ensuring the protocol's long-term stability and sustainability. In short, PCV enables Essence to provide a reliable source of liquidity that is aligned with the protocol's goals and objectives, rather than being subjected to the whims of external liquidity providers.

### Direct Redeemabilty

All CHI is redeemable directly for PCV reserves. This is the key to allowing CHI to scale effectively while staying decentralized. If a stablecoin can always be purchased for $1 and sold for $1, it can scale to arbitrary supply and meet the demands of a growing DeFi ecosystem. Transparent on-chain redemptions offer a key value boost over centralized alternatives such as USDC or USDT,  which helps to maintain the stability of the Essence ecosystem, as users can be confident in the underlying value of CHI.

<br>


# PCV Management

PCV (Protocol Controlled Value) is the aggregate amount of all the funds held by the protocol on its various PCV Deposits, collectively managed by all the Essence DAO Token holders, through protocol governance.

Through governance proposals, anyone can suggest new yield strategies, PCV deployments, if approved, new PCV Deposits will be deployed to implement them.

There are three different types of PCV movements:

* Manual
* Automated
* Guardian

{% content-ref url="/pages/ZRq5DCUhmNcfA1emB4RH" %}
[Access Control](/governance/access-control)
{% endcontent-ref %}

***

## Manual PCV Movements

Through governance, ZEN holders can vote to move PCV from one location to another.

The movement of PCV between deposits can be performed by any smart-contract with the PCV\_CONTROLLER role, including the DAO Governor (see Access Control)

If a desired PCV deployment does not have a PCV deposit, it can be escrowed in the DAO's Timelock.

***

## Automated PCV Movements

In certain cases PCV needs to be automatically moved between deposits when one deposit runs low on reserves, such as the Peg Stability Module (PSM).

Protocol infrastructure can trigger these moves through contracts like the PCVDripController which can incentivize condition movements, or directly move them as a PCV\_CONTROLLER.

***

## Guardian PCV Movements

The PCV Guardian can move PCV instantly between "safe" PCV deposits which are pre-approved by the DAO. For instance to save funds held on a compromised PCV deposit, or to move yield farming rewards to a suitable deposit where they can be delegated to vote in other DAO's.


# PCV Deposits

The PCV Deposit is a standard interface implemented across the Essence protocol codebase.

A PCV Deposit is a contract that holds funds on behalf of the protocol. There are multiple types (implementations) of PCV Deposits, and each type of PCV Deposit can be instantiated multiple times on-chain. Collectively, all the funds deposited across various PCV Deposits constitute the Protocol Controlled Value.

A PCV Deposit manages only one type of token, and if additional tokens are available on the deposit (e.g. rewards from deploying PCV to a DEX), they are ignored in accounting and cannot be used and so will most likely be moved somewhere else.

### Interface <a href="#interface" id="interface"></a>

The following methods must be implemented on all PCV Deposits :

```solidity
// Accounting
function balanceReportedIn() external view returns (address);
function balance() external view returns (uint256);
function resistantBalanceAndChi() external view returns (uint256, uint256);

// Enter / Exit
function deposit() external;
function withdraw(address to, uint256 amount) external;

// Movements 
function withdrawERC20(address token, address to, uint256 amount) external;
function withdrawETH(address payable to, uint256 amount) external;
```

**Accounting**

The methods `balanceReportedIn()`, `balance()`, and `resistantBalanceAndChi()` are used for accounting and compatibility. These `view` methods are used in the Collateralization Oracle to determine the aggregated amount of PCV and CHI the protocol controls.

`balanceReportedIn()` is the address of the token managed and reported by a deposit.

`balance()` reports the instantaneous balance of a PCVDeposit. The instantaneous balance can be subject to in-block atomic manipulations (e.g. using flashloans).

`resistantBalanceAndChi()` reports the manipulation-resistant balance of a PCVDeposit, as well as the protocol-owned CHI controlled by the contract. This method is often based on "ideal balances" computed using Oracle prices, and not reading the actual balances in the current block.

**Enter / Exit**

The `deposit()` method is called after tokens have been sent to the PCV Deposit to deploy those tokens into the "strategy" implemented by the contract.

The `withdraw()` method is called by a PCV Controller to withdraw tokens from the "strategy" implemented by the contract.

The `withdrawERC20()` method is called by a PCV Controller to withdraw ERC20 tokens held in the PCV Deposit.

**Movements**

The `withdrawETH()` and `withdrawERC20()` methods are called by a PCV Controller to send the ETH and ERC20 held on the PCV Deposit somewhere else.

These methods can move any tokens and not just the token used in accounting by the PCV Deposit so, for instance, they can be used to move rewards earned by the contract. These functions are restricted to the role `PCV_CONTROLLER`.

Some PCV Deposits are meant to hold funds over the long term, and some are meant to be used in a transitory manner, to enter or exit a yield strategy/liquidity pool.


# Essence DAO

The Decentralized Autonomous Organization driving Essence's upgrades

A core principle of Essence is its fully decentralized design and minimal dependence on any centralized assets or protocols. The Essence DAO is responsible for utilizing all of the flexible and power features of Essence to continually enhance the protocol in an ever-changing DeFi space.

**EssenceDAO is controlled by xZEN holders. (Subject to the Governance Phases)**

***

## Responsibilities&#x20;

Essence's design and implementation minimizes the governance for activities related to peg maintenance. Beyond the inherent need for initial protocol tuning, the Essence DAO is primarily responsible for two things: upgrades and integrations.

Parameter tuning and changes that Essence DAO can make:

* Grant/Revoke roles
* Change PCV allocations
* Adjust rewards from the staking pool
* Upgrade oracles and other contracts throughout the system

***

## Design

The Essence DAO is built on the OpenZepplin Governor and TimelockController.

Parameters:

* 3% Quorum
* .25% proposal threshold
* 12 hour voting delay
* 36 hour voting period
* 24 hour timelock delay
* Essence DAO is controlled by xZEN

Essence implements a flexible access control system. The Timelock is appointed as a Governor, but it does not have to be the only one, or remain Governor forever. Essence can appoint autonomous Governors to adjust parameters and PCV based on market conditions. Additionally, a tiered governance structure can be implemented where certain changes require higher quorum thresholds and longer times.

Ultimately, the Essence DAO (i.e xZEN holders) makes all of these decisions as the protocol evolves.


# Governance Phases

Essence Finance is set to adopt a staggered approach to decentralization, ultimately aiming for complete autonomy and governance steered by the community through the Essence DAO. The timeline provided for each stage is an estimate; the true length may vary based on variables like the community’s size, engagement in voting, and the progress of development. In the first three stages, the transition to subsequent stages will hinge on the judgment of the multisig, particularly its evaluation of any potential safety issues.

### Governance Phases

| Phase                           | Governance Plan                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>Phase 1: </p><p>Launch</p>   | <p>Community members can suggest initiatives and vote on them. A multisig of Essence Finance team members will enact the vote results. Initially, the multisig will require 2 -of - 3 signers.</p><p>Post-launch, the DAO may form new committees to enhance or maintain the ecosystem, with engineering, growth, and strategy committees expected to be proposed early on.</p>        |
| <p>Phase 2: </p><p>1 month</p>  | Community participants are empowered to put forward proposals, which will be followed by votes to gauge community sentiment. The multisig will grow to incorporate signers from outside the Essence Finance team, increasing the number of signatories to a 3-of-5 configuration.                                                                                                      |
| <p>Phase 3: </p><p>3 months</p> | Proposals and voting within the community will transition to being binding. However, the multisig will hold a veto right, especially on matters that may pose safety risks to users. At this phase, decisions regarding the protocol and products will become officially binding, whereas the multisig will continue to oversee treasury management and other critical safety matters. |
| <p>Phase 4: </p><p>9 months</p> | The shift towards binding community votes will progress, with protocol and product-related decisions taking precedence. The multisig’s veto authority will be phased out entirely. In this stage, community members will also gain the right to nominate and elect new multisig participants.                                                                                          |
| <p>Phase 5:</p><p>15 months</p> | Complete decentralization will be achieved, with the DAO being fully constituted and governed by the community, where all decisions are determined through community voting.                                                                                                                                                                                                           |


# Access Control

Essence uses access control to define the system's contract responsibilities.

These are:

* Governor
* Minter
* PCV Controller
* Guardian

The Essence Core contract manages access control.

## How do they work&#x20;

### Governor

The Governor role has the most authority in the Essence Protocol. It grants and revokes all other roles on the platform. It manages a multitude of protocol parameters unique to each contract.&#x20;

Implementing Governor as a role and not as a single contract grants Essence the flexibility to appoint automated governance contracts or different tiers of governance with varying degrees of difficulty for execution criteria.

***

### Minter

Minters create (mint) CHI and add it to any address. Minting can be a reward for the actions of supporting the peg.

***

### PCV Controller

PCV Controller can move PCV from any contract and redeploy it elsewhere. This is done to reweigh the peg, facilitate integrations, or protect against adverse conditions.

***

### Guardian

The guardian enables quick feature shutdowns during unforeseen events. It can revoke any role from the above described role types. It can also shut off additional protocol functionality. It cannot manage PCV or mint CHI.

{% content-ref url="/pages/AT4eRU19EAiQyIz2sgIU" %}
[Roles](/governance/roles)
{% endcontent-ref %}


# Roles

GOVERN\_ROLE is the admin of the following roles:

* MINTER\_ROLE
* PCV\_CONTROLLER\_ROLE
* GUARDIAN\_ROLE

## Powers

Important powers in the system, and what handles them:

* Minting of CHI - handled by any contract with role: MINTER\_ROLE
* Moving of funds around - handled by any contract with role: PCV\_CONTROLLER
* Granting and revoking roles - handled by any contract with role: GOVERN\_ROLE
* Vetoing of proposals and actions - handled by any contract with role: GUARDIAN\_ROLE&#x20;

***

## Access Control Summary&#x20;

### GOVERN\_ROLE

The ultimate power in the Essence DAO

#### Holders

* EssenceDAOTimelock

#### Admins

* None/Itself

#### Powers

***

### MINTER\_ROLE

#### Holders

* PCVEquityMinter
* FixedPricePSM
* StablePCVDeposit

#### Admins

* GOVERN\_ROLE

#### Powers

Gives the holder the ability to mint CHI.

***

### PCV\_CONTROLLER\_ROLE

#### Holders

* EssenceDAOTimelock

#### Admins

* GOVERN\_ROLE

#### Powers

Gives the holder the ability to move PCV around.

***

### GUARDIAN\_ROLE

#### Holders

* Multisig

#### Admins

* GOVERN\_ROLE

#### Powers

* Acts as a protector of the system; has the power to veto DAO proposals, and has the ability to pause and unpause many parts of the system


# Contract Addresses

Scroll Contracts

### Core <a href="#core" id="core"></a>

<table><thead><tr><th width="217">Name</th><th>Address</th></tr></thead><tbody><tr><td>Core</td><td><br>0x463a02e3dfD1CA2A5bF90Dc938B784eD1eA5D24C<br></td></tr><tr><td>Chi</td><td><br>0x2fC5cf65Fd0a660801f119832B2158756968266D<br></td></tr><tr><td>Zen</td><td><br>0x188B158CAf5Ea252012dbD6030AfC030329C4961<br></td></tr><tr><td>xZen</td><td><br>0xb97CB8d98e5Fa6a8F6F9dfb1eEDe9DaEdC3B7E58<br></td></tr><tr><td>xZenRewards</td><td><br>0x6da65104F848f02848a895b89775d6E6918af8A3<br></td></tr><tr><td>PCVEquityMinter</td><td><br>0xD1C6d0e8eFB021eD6f1feaBB2A0f43b69917c321<br></td></tr></tbody></table>

### DAO <a href="#pcv" id="pcv"></a>

<table><thead><tr><th width="220">Name</th><th>Address</th></tr></thead><tbody><tr><td>EssenceDao</td><td><br>0xc687498e75dFa157914F22F8E11224D472753b3e<br></td></tr><tr><td>TimeLock</td><td><br>0x09aBEB2e4e57ab9e1b4A15e997b96503Eaa8bA1a<br></td></tr></tbody></table>

### Peg & PCV <a href="#pcv" id="pcv"></a>

<table><thead><tr><th width="225">Name</th><th>Address</th></tr></thead><tbody><tr><td>FixedPricePSM</td><td><br>0x725964f80bbC5153b07fC70d9B9806aFCA60B811<br></td></tr><tr><td>StablePCVDeposit</td><td><br>0xCab41BD27c09334785d4c3597d83210fab9d162a<br></td></tr><tr><td>ERC20Holding</td><td><br>0xcAa2c8C115CB7F60aE7dfbF519a08D26D1E37962<br></td></tr></tbody></table>

### Collateralization <a href="#collateralization" id="collateralization"></a>

<table><thead><tr><th width="228">Name</th><th>Address</th></tr></thead><tbody><tr><td>CollateralizationOracle</td><td><p></p><p>0x4a848233740b8C351748814D8E297C1c463dAE99<br></p></td></tr></tbody></table>

### Oracle <a href="#oracle" id="oracle"></a>

<table><thead><tr><th width="305">Name</th><th>Address</th></tr></thead><tbody><tr><td>ChainLinkOracleWrapper | USDC</td><td><br>0x4547B614B911e61a3e0479EE8c5A3c058E500ec2<br></td></tr></tbody></table>

### Others <a href="#oracle" id="oracle"></a>

<table><thead><tr><th width="305">Name</th><th>Address</th></tr></thead><tbody><tr><td>VolatileNonePcv #1</td><td><br>0x811835cF85852B5defE994CAfc88C55F1c4D2492<br></td></tr><tr><td>VolatileNonePcv #2</td><td><br>0x951c307010bdA5727177c7c3a56d998BD9035d6b<br></td></tr></tbody></table>


# Audits

List of formal audits performed on contracts for FEI Protocol V2

Built on top of FEI Protocol's V2 codebase, all contracts utilized are fully audited and have been in production for over 2 years without any exploits. Multiple thorough audits have been conducted by the best in the industry, including OpenZeppelin and ConsenSys:

ConsenSys: <https://consensys.net/diligence/audits/2021/09/fei-protocol-v2-phase-1/>

OpenZepplin: <https://blog.openzeppelin.com/fei-audit-2/>


# Smart Contracts API


# Chi

## Functions

### constructor

```solidity
function constructor(
    address core
) public
```

Chi token constructor

#### Parameters

| Name   | Type    | Description                   |
| ------ | ------- | ----------------------------- |
| `core` | address | Chi Core address to reference |

### mint

```solidity
function mint(
    address account,
    uint256 amount
) external
```

mint CHI tokens

#### Parameters

| Name      | Type    | Description            |
| --------- | ------- | ---------------------- |
| `account` | address | the account to mint to |
| `amount`  | uint256 | the amount to mint     |

### \_transfer

```solidity
function _transfer(
    address sender,
    address recipient,
    uint256 amount
) internal
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `sender`    | address |             |
| `recipient` | address |             |
| `amount`    | uint256 |             |

{% content-ref url="/spaces/D0w4CbdfgJSQ1R3M9z4f/pages/QBx9i80DUEPnRi0k3enS" %}
[IChi](/development/smart-contracts/chi/ichi)
{% endcontent-ref %}


# IChi

## Functions

### mint

```solidity
function mint(
    address account,
    uint256 amount
) external
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `account` | address |             |
| `amount`  | uint256 |             |

#### Parameters

## Events

### Minting

```solidity
event Minting(
    address _to,
    address _minter,
    uint256 _amount
)
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `_to`     | address |             |
| `_minter` | address |             |
| `_amount` | uint256 |             |


# Minter


# IPCVEquityMinter

## Functions

### setCollateralizationOracle

```solidity
function setCollateralizationOracle(
    contract ICollateralizationOracle newCollateralizationOracle
) external
```

#### Parameters

| Name                         | Type                              | Description |
| ---------------------------- | --------------------------------- | ----------- |
| `newCollateralizationOracle` | contract ICollateralizationOracle |             |

### collateralizationOracle

```solidity
function collateralizationOracle() external returns (contract ICollateralizationOracle)
```

## Events

### CollateralizationOracleUpdate

```solidity
event CollateralizationOracleUpdate(
    address oldCollateralizationOracle,
    address newCollateralizationOracle
)
```

#### Parameters

| Name                         | Type    | Description |
| ---------------------------- | ------- | ----------- |
| `oldCollateralizationOracle` | address |             |
| `newCollateralizationOracle` | address |             |


# PCVEquityMinter

A ChiTimedMinter that mints based on a percentage of PCV equity

## Functions

### constructor

```solidity
function constructor(
    address _core,
    address _target,
    uint256 _incentive,
    uint256 _frequency,
    contract ICollateralizationOracle _collateralizationOracle,
    uint256 _aprBasisPoints,
    uint256 _maxAPRBasisPoints,
    uint256 _chiMintingLimitPerSecond
) public
```

constructor for PCVEquityMinter @param \_core the Core address to reference @param \_target the target to receive minted CHI @param \_incentive the incentive amount for calling buy paid in CHI @param \_frequency the frequency buybacks happen @param \_collateralizationOracle the collateralization oracle used for PCV equity calculations @param \_aprBasisPoints the APR paid out from pcv equity per year expressed in basis points

#### Parameters

| Name                        | Type                              | Description |
| --------------------------- | --------------------------------- | ----------- |
| `_core`                     | address                           |             |
| `_target`                   | address                           |             |
| `_collateralizationOracle`  | contract ICollateralizationOracle |             |
| `_chiMintingLimitPerSecond` | uint256                           |             |

### mint

```solidity
function mint() public
```

triggers a minting of CHI based on the PCV equity

### mintAmount

```solidity
function mintAmount() public returns (uint256)
```

### setCollateralizationOracle

```solidity
function setCollateralizationOracle(
    contract ICollateralizationOracle newCollateralizationOracle
) external
```

set the collateralization oracle

#### Parameters

| Name                         | Type                              | Description |
| ---------------------------- | --------------------------------- | ----------- |
| `newCollateralizationOracle` | contract ICollateralizationOracle |             |

### \_setCollateralizationOracle

```solidity
function _setCollateralizationOracle(
    contract ICollateralizationOracle newCollateralizationOracle
) internal
```

#### Parameters

| Name                         | Type                              | Description |
| ---------------------------- | --------------------------------- | ----------- |
| `newCollateralizationOracle` | contract ICollateralizationOracle |             |

### \_afterMint

```solidity
function _afterMint() internal
```


# RateLimitedMinter

## Functions

### constructor

```solidity
function constructor(
    uint256 _chiLimitPerSecond,
    uint256 _mintingBufferCap,
    bool _doPartialMint
) internal
```

#### Parameters

| Name                 | Type    | Description |
| -------------------- | ------- | ----------- |
| `_chiLimitPerSecond` | uint256 |             |
| `_mintingBufferCap`  | uint256 |             |
| `_doPartialMint`     | bool    |             |

### \_mintChi

```solidity
function _mintChi(
    address to,
    uint256 amount
) internal
```

override the CHI minting behavior to enforce a rate limit

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |


# Core


# Core

maintains roles, access control, chi, zen, genesisGroup, and the ZEN treasury

## Functions

### init

```solidity
function init() external
```

### setChi

```solidity
function setChi(
    address token
) external
```

sets Chi address to a new address

#### Parameters

| Name    | Type    | Description     |
| ------- | ------- | --------------- |
| `token` | address | new chi address |

### setZen

```solidity
function setZen(
    address token
) external
```

sets Zen address to a new address

#### Parameters

| Name    | Type    | Description     |
| ------- | ------- | --------------- |
| `token` | address | new zen address |

### allocateZen

```solidity
function allocateZen(
    address to,
    uint256 amount
) external
```

sends ZEN tokens from treasury to an address

#### Parameters

| Name     | Type    | Description                |
| -------- | ------- | -------------------------- |
| `to`     | address | the address to send ZEN to |
| `amount` | uint256 | the amount of ZEN to send  |

### \_setChi

```solidity
function _setChi(
    address token
) internal
```

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `token` | address |             |

### \_setZen

```solidity
function _setZen(
    address token
) internal
```

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `token` | address |             |


# ICore

## Functions

### init

```solidity
function init() external
```

### setChi

```solidity
function setChi(
    address token
) external
```

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `token` | address |             |

### setZen

```solidity
function setZen(
    address token
) external
```

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `token` | address |             |

### allocateZen

```solidity
function allocateZen(
    address to,
    uint256 amount
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### chi

```solidity
function chi() external returns (contract IChi)
```

### zen

```solidity
function zen() external returns (contract IERC20)
```

## Events

### ChiUpdate

```solidity
event ChiUpdate(
    address _chi
)
```

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `_chi`        | address |             |
| ### ZenUpdate |         |             |

```solidity
event ZenUpdate(
    address _zen
)
```

#### Parameters

| Name   | Type    | Description |
| ------ | ------- | ----------- |
| `_zen` | address |             |

### ZenAllocation

```solidity
event ZenAllocation(
    address _to,
    uint256 _amount
)
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `_to`     | address |             |
| `_amount` | uint256 |             |


# IPermissions

## Functions

### createRole

```solidity
function createRole(
    bytes32 role,
    bytes32 adminRole
) external
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `role`      | bytes32 |             |
| `adminRole` | bytes32 |             |

### grantMinter

```solidity
function grantMinter(
    address minter
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `minter` | address |             |

### grantBurner

```solidity
function grantBurner(
    address burner
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `burner` | address |             |

### grantPCVController

```solidity
function grantPCVController(
    address pcvController
) external
```

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| `pcvController` | address |             |

### grantGovernor

```solidity
function grantGovernor(
    address governor
) external
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `governor` | address |             |

### grantGuardian

```solidity
function grantGuardian(
    address guardian
) external
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `guardian` | address |             |

### revokeMinter

```solidity
function revokeMinter(
    address minter
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `minter` | address |             |

### revokeBurner

```solidity
function revokeBurner(
    address burner
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `burner` | address |             |

### revokePCVController

```solidity
function revokePCVController(
    address pcvController
) external
```

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| `pcvController` | address |             |

### revokeGovernor

```solidity
function revokeGovernor(
    address governor
) external
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `governor` | address |             |

### revokeGuardian

```solidity
function revokeGuardian(
    address guardian
) external
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `guardian` | address |             |

### revokeOverride

```solidity
function revokeOverride(
    bytes32 role,
    address account
) external
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `role`    | bytes32 |             |
| `account` | address |             |

### GUARDIAN\_ROLE

```solidity
function GUARDIAN_ROLE() external returns (bytes32)
```

### GOVERN\_ROLE

```solidity
function GOVERN_ROLE() external returns (bytes32)
```

### BURNER\_ROLE

```solidity
function BURNER_ROLE() external returns (bytes32)
```

### MINTER\_ROLE

```solidity
function MINTER_ROLE() external returns (bytes32)
```

### PCV\_CONTROLLER\_ROLE

```solidity
function PCV_CONTROLLER_ROLE() external returns (bytes32)
```


# IPermissionsRead

## Functions

### isBurner

```solidity
function isBurner(
    address _address
) external returns (bool)
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `_address` | address |             |

### isMinter

```solidity
function isMinter(
    address _address
) external returns (bool)
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `_address` | address |             |

### isGovernor

```solidity
function isGovernor(
    address _address
) external returns (bool)
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `_address` | address |             |

### isGuardian

```solidity
function isGuardian(
    address _address
) external returns (bool)
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `_address` | address |             |

### isPCVController

```solidity
function isPCVController(
    address _address
) external returns (bool)
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `_address` | address |             |


# Permissions

## Functions

### constructor

```solidity
function constructor() public
```

### createRole

```solidity
function createRole(
    bytes32 role,
    bytes32 adminRole
) external
```

creates a new role to be maintained

can also be used to update admin of existing role

#### Parameters

| Name        | Type    | Description                  |
| ----------- | ------- | ---------------------------- |
| `role`      | bytes32 | the new role id              |
| `adminRole` | bytes32 | the admin role id for `role` |

### grantMinter

```solidity
function grantMinter(
    address minter
) external
```

grants minter role to address

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `minter` | address | new minter  |

### grantBurner

```solidity
function grantBurner(
    address burner
) external
```

grants burner role to address

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `burner` | address | new burner  |

### grantPCVController

```solidity
function grantPCVController(
    address pcvController
) external
```

grants controller role to address

#### Parameters

| Name            | Type    | Description    |
| --------------- | ------- | -------------- |
| `pcvController` | address | new controller |

### grantGovernor

```solidity
function grantGovernor(
    address governor
) external
```

grants governor role to address

#### Parameters

| Name       | Type    | Description  |
| ---------- | ------- | ------------ |
| `governor` | address | new governor |

### grantGuardian

```solidity
function grantGuardian(
    address guardian
) external
```

grants guardian role to address

#### Parameters

| Name       | Type    | Description  |
| ---------- | ------- | ------------ |
| `guardian` | address | new guardian |

### revokeMinter

```solidity
function revokeMinter(
    address minter
) external
```

revokes minter role from address

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `minter` | address | ex minter   |

### revokeBurner

```solidity
function revokeBurner(
    address burner
) external
```

revokes burner role from address

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `burner` | address | ex burner   |

### revokePCVController

```solidity
function revokePCVController(
    address pcvController
) external
```

revokes pcvController role from address

#### Parameters

| Name            | Type    | Description      |
| --------------- | ------- | ---------------- |
| `pcvController` | address | ex pcvController |

### revokeGovernor

```solidity
function revokeGovernor(
    address governor
) external
```

revokes governor role from address

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `governor` | address | ex governor |

### revokeGuardian

```solidity
function revokeGuardian(
    address guardian
) external
```

revokes guardian role from address

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `guardian` | address | ex guardian |

### revokeOverride

```solidity
function revokeOverride(
    bytes32 role,
    address account
) external
```

revokes a role from address

#### Parameters

| Name      | Type    | Description                         |
| --------- | ------- | ----------------------------------- |
| `role`    | bytes32 | the role to revoke                  |
| `account` | address | the address to revoke the role from |

### isMinter

```solidity
function isMinter(
    address _address
) external returns (bool)
```

checks if address is a minter

#### Parameters

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| `_address` | address | address to check |

#### Return Values

| Name  | Type | Description                |
| ----- | ---- | -------------------------- |
| `[0]` | bool | true \_address is a minter |

### isBurner

```solidity
function isBurner(
    address _address
) external returns (bool)
```

checks if address is a burner

#### Parameters

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| `_address` | address | address to check |

#### Return Values

| Name  | Type | Description                |
| ----- | ---- | -------------------------- |
| `[0]` | bool | true \_address is a burner |

### isPCVController

```solidity
function isPCVController(
    address _address
) external returns (bool)
```

checks if address is a controller

#### Parameters

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| `_address` | address | address to check |

#### Return Values

| Name  | Type | Description                    |
| ----- | ---- | ------------------------------ |
| `[0]` | bool | true \_address is a controller |

### isGovernor

```solidity
function isGovernor(
    address _address
) public returns (bool)
```

checks if address is a governor

#### Parameters

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| `_address` | address | address to check |

#### Return Values

| Name  | Type | Description                  |
| ----- | ---- | ---------------------------- |
| `[0]` | bool | true \_address is a governor |

### isGuardian

```solidity
function isGuardian(
    address _address
) public returns (bool)
```

checks if address is a guardian

#### Parameters

| Name       | Type    | Description      |
| ---------- | ------- | ---------------- |
| `_address` | address | address to check |

#### Return Values

| Name  | Type | Description                  |
| ----- | ---- | ---------------------------- |
| `[0]` | bool | true \_address is a guardian |

### \_setupGovernor

```solidity
function _setupGovernor(
    address governor
) internal
```

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `governor` | address |             |


# ZenRoles


# Dao


# Governor


# EssenceDAO

## Functions

### constructor

```solidity
function constructor(
    contract ERC20VotesComp zen,
    contract ICompoundTimelock timelock,
    address guardian
) public
```

#### Parameters

| Name       | Type                       | Description |
| ---------- | -------------------------- | ----------- |
| `zen`      | contract ERC20VotesComp    |             |
| `timelock` | contract ICompoundTimelock |             |
| `guardian` | address                    |             |

### votingDelay

```solidity
function votingDelay() public returns (uint256)
```

module:user-config

Delay, in number of block, between the proposal is created and the vote starts. This can be increassed to leave time for users to buy voting power, of delegate it, before the voting of a proposal starts.

### votingPeriod

```solidity
function votingPeriod() public returns (uint256)
```

module:user-config

Delay, in number of blocks, between the vote start and vote ends.

NOTE: The {votingDelay} can delay the start of the vote. This must be considered when setting the voting duration compared to the voting delay.

### quorum

```solidity
function quorum(
    uint256 
) public returns (uint256)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \`\` | uint256 |             |

### proposalThreshold

```solidity
function proposalThreshold() public returns (uint256)
```

Part of the Governor Bravo's interface: *"The number of votes required in order for a voter to become a proposer"*.

### setVotingDelay

```solidity
function setVotingDelay(
    uint256 newVotingDelay
) public
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `newVotingDelay` | uint256 |             |

### setVotingPeriod

```solidity
function setVotingPeriod(
    uint256 newVotingPeriod
) public
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `newVotingPeriod` | uint256 |             |

### setQuorum

```solidity
function setQuorum(
    uint256 newQuorum
) public
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `newQuorum` | uint256 |             |

### setProposalThreshold

```solidity
function setProposalThreshold(
    uint256 newProposalThreshold
) public
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newProposalThreshold` | uint256 |             |

### \_\_rollback

```solidity
function __rollback(
    uint256 eta
) external
```

one-time option to roll back the DAO to old GovernorAlpha

guardian-only, and expires after the deadline. This function is here as a fallback in case something goes wrong.

#### Parameters

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| `eta` | uint256 |             |

### \_\_executeRollback

```solidity
function __executeRollback() external
```

complete the rollback

### getVotes

```solidity
function getVotes(
    address account,
    uint256 blockNumber
) public returns (uint256)
```

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `account`     | address |             |
| `blockNumber` | uint256 |             |

### state

```solidity
function state(
    uint256 proposalId
) public returns (enum IGovernor.ProposalState)
```

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| `proposalId` | uint256 |             |

### propose

```solidity
function propose(
    address[] targets,
    uint256[] values,
    bytes[] calldatas,
    string description
) public returns (uint256)
```

#### Parameters

| Name          | Type       | Description |
| ------------- | ---------- | ----------- |
| `targets`     | address\[] |             |
| `values`      | uint256\[] |             |
| `calldatas`   | bytes\[]   |             |
| `description` | string     |             |

### \_execute

```solidity
function _execute(
    uint256 proposalId,
    address[] targets,
    uint256[] values,
    bytes[] calldatas,
    bytes32 descriptionHash
) internal
```

#### Parameters

| Name              | Type       | Description |
| ----------------- | ---------- | ----------- |
| `proposalId`      | uint256    |             |
| `targets`         | address\[] |             |
| `values`          | uint256\[] |             |
| `calldatas`       | bytes\[]   |             |
| `descriptionHash` | bytes32    |             |

### \_cancel

```solidity
function _cancel(
    address[] targets,
    uint256[] values,
    bytes[] calldatas,
    bytes32 descriptionHash
) internal returns (uint256)
```

#### Parameters

| Name              | Type       | Description |
| ----------------- | ---------- | ----------- |
| `targets`         | address\[] |             |
| `values`          | uint256\[] |             |
| `calldatas`       | bytes\[]   |             |
| `descriptionHash` | bytes32    |             |

### \_executor

```solidity
function _executor() internal returns (address)
```

### supportsInterface

```solidity
function supportsInterface(
    bytes4 interfaceId
) public returns (bool)
```

#### Parameters

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| `interfaceId` | bytes4 |             |

## Events

### QuorumUpdated

```solidity
event QuorumUpdated(
    uint256 oldQuorum,
    uint256 newQuorum
)
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `oldQuorum`            | uint256 |             |
| `newQuorum`            | uint256 |             |
| ### VotingDelayUpdated |         |             |

```solidity
event VotingDelayUpdated(
    uint256 oldVotingDelay,
    uint256 newVotingDelay
)
```

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `oldVotingDelay`        | uint256 |             |
| `newVotingDelay`        | uint256 |             |
| ### VotingPeriodUpdated |         |             |

```solidity
event VotingPeriodUpdated(
    uint256 oldVotingPeriod,
    uint256 newVotingPeriod
)
```

#### Parameters

| Name                         | Type    | Description |
| ---------------------------- | ------- | ----------- |
| `oldVotingPeriod`            | uint256 |             |
| `newVotingPeriod`            | uint256 |             |
| ### ProposalThresholdUpdated |         |             |

```solidity
event ProposalThresholdUpdated(
    uint256 oldProposalThreshold,
    uint256 newProposalThreshold
)
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `oldProposalThreshold` | uint256 |             |
| `newProposalThreshold` | uint256 |             |
| ### RollbackQueued     |         |             |

```solidity
event RollbackQueued(
    uint256 eta
)
```

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| `eta`        | uint256 |             |
| ### Rollback |         |             |

```solidity
event Rollback(
)
```


# Timelock


# EssenceDAOTimelock

## EssenceDAOTimelock

### Functions

#### constructor

```solidity
function constructor(
    address core_,
    address admin_,
    uint256 delay_,
    uint256 minDelay_
) public
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `core_`     | address |             |
| `admin_`    | address |             |
| `delay_`    | uint256 |             |
| `minDelay_` | uint256 |             |

#### queueTransaction

```solidity
function queueTransaction(
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
) public returns (bytes32)
```

queue a transaction, with pausability

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |

#### vetoTransactions

```solidity
function vetoTransactions(
    address[] targets,
    uint256[] values,
    string[] signatures,
    bytes[] datas,
    uint256[] etas
) public
```

veto a group of transactions

**Parameters**

| Name         | Type       | Description |
| ------------ | ---------- | ----------- |
| `targets`    | address\[] |             |
| `values`     | uint256\[] |             |
| `signatures` | string\[]  |             |
| `datas`      | bytes\[]   |             |
| `etas`       | uint256\[] |             |

#### executeTransaction

```solidity
function executeTransaction(
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
) public returns (bytes)
```

execute a transaction, with pausability

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |

#### governorSetPendingAdmin

```solidity
function governorSetPendingAdmin(
    address newAdmin
) public
```

allow a governor to set a new pending timelock admin

**Parameters**

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `newAdmin` | address |             |

#### rollback

```solidity
function rollback() external
```

one-time option to roll back the Timelock to old timelock

guardian-only, and expires after the deadline. This function is here as a fallback in case something goes wrong.

## IChiDAO

### Functions

#### updateTimelock

```solidity
function updateTimelock(
    address newTimelock
) external
```

**Parameters**

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `newTimelock` | address |             |


# OptimisticTimelock

## Functions

### constructor

```solidity
function constructor(
    address core_,
    uint256 minDelay,
    address[] proposers,
    address[] executors
) public
```

#### Parameters

| Name        | Type       | Description |
| ----------- | ---------- | ----------- |
| `core_`     | address    |             |
| `minDelay`  | uint256    |             |
| `proposers` | address\[] |             |
| `executors` | address\[] |             |

### becomeAdmin

```solidity
function becomeAdmin() public
```

allow guardian or governor to assume timelock admin roles This more elegantly achieves optimistic timelock as follows: - veto: grant self PROPOSER\_ROLE and cancel - pause proposals: revoke PROPOSER\_ROLE from target - pause execution: revoke EXECUTOR\_ROLE from target - set new proposer: revoke old proposer and add new one

```
    In addition it allows for much more granular and flexible access for multisig operators
```


# Timelock

## Functions

### constructor

```solidity
function constructor(
    address admin_,
    uint256 delay_,
    uint256 minDelay_
) public
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `admin_`    | address |             |
| `delay_`    | uint256 |             |
| `minDelay_` | uint256 |             |

### receive

```solidity
function receive() external
```

### setDelay

```solidity
function setDelay(
    uint256 delay_
) public
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `delay_` | uint256 |             |

### acceptAdmin

```solidity
function acceptAdmin() public
```

### setPendingAdmin

```solidity
function setPendingAdmin(
    address pendingAdmin_
) public
```

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| `pendingAdmin_` | address |             |

### queueTransaction

```solidity
function queueTransaction(
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
) public returns (bytes32)
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |

### cancelTransaction

```solidity
function cancelTransaction(
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
) public
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |

### \_cancelTransaction

```solidity
function _cancelTransaction(
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
) internal
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |

### executeTransaction

```solidity
function executeTransaction(
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
) public returns (bytes)
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |

### getTxHash

```solidity
function getTxHash(
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
) public returns (bytes32)
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |

### getBlockTimestamp

```solidity
function getBlockTimestamp() internal returns (uint256)
```

## Events

### NewAdmin

```solidity
event NewAdmin(
    address newAdmin
)
```

#### Parameters

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| `newAdmin`          | address |             |
| ### NewPendingAdmin |         |             |

```solidity
event NewPendingAdmin(
    address newPendingAdmin
)
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `newPendingAdmin` | address |             |
| ### NewDelay      |         |             |

```solidity
event NewDelay(
    uint256 newDelay
)
```

#### Parameters

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| `newDelay`            | uint256 |             |
| ### CancelTransaction |         |             |

```solidity
event CancelTransaction(
    bytes32 txHash,
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
)
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `txHash`               | bytes32 |             |
| `target`               | address |             |
| `value`                | uint256 |             |
| `signature`            | string  |             |
| `data`                 | bytes   |             |
| `eta`                  | uint256 |             |
| ### ExecuteTransaction |         |             |

```solidity
event ExecuteTransaction(
    bytes32 txHash,
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
)
```

#### Parameters

| Name                 | Type    | Description |
| -------------------- | ------- | ----------- |
| `txHash`             | bytes32 |             |
| `target`             | address |             |
| `value`              | uint256 |             |
| `signature`          | string  |             |
| `data`               | bytes   |             |
| `eta`                | uint256 |             |
| ### QueueTransaction |         |             |

```solidity
event QueueTransaction(
    bytes32 txHash,
    address target,
    uint256 value,
    string signature,
    bytes data,
    uint256 eta
)
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `txHash`    | bytes32 |             |
| `target`    | address |             |
| `value`     | uint256 |             |
| `signature` | string  |             |
| `data`      | bytes   |             |
| `eta`       | uint256 |             |


# External


# Decimal

## Functions

### zero

```solidity
function zero() internal returns (struct Decimal.D256)
```

### one

```solidity
function one() internal returns (struct Decimal.D256)
```

### from

```solidity
function from(
    uint256 a
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| `a`  | uint256 |             |

### ratio

```solidity
function ratio(
    uint256 a,
    uint256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| `a`  | uint256 |             |
| `b`  | uint256 |             |

### add

```solidity
function add(
    struct Decimal.D256 self,
    uint256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | uint256             |             |

### sub

```solidity
function sub(
    struct Decimal.D256 self,
    uint256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | uint256             |             |

### sub

```solidity
function sub(
    struct Decimal.D256 self,
    uint256 b,
    string reason
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name     | Type                | Description |
| -------- | ------------------- | ----------- |
| `self`   | struct Decimal.D256 |             |
| `b`      | uint256             |             |
| `reason` | string              |             |

### mul

```solidity
function mul(
    struct Decimal.D256 self,
    uint256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | uint256             |             |

### div

```solidity
function div(
    struct Decimal.D256 self,
    uint256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | uint256             |             |

### pow

```solidity
function pow(
    struct Decimal.D256 self,
    uint256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | uint256             |             |

### add

```solidity
function add(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### sub

```solidity
function sub(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### sub

```solidity
function sub(
    struct Decimal.D256 self,
    struct Decimal.D256 b,
    string reason
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name     | Type                | Description |
| -------- | ------------------- | ----------- |
| `self`   | struct Decimal.D256 |             |
| `b`      | struct Decimal.D256 |             |
| `reason` | string              |             |

### mul

```solidity
function mul(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### div

```solidity
function div(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (struct Decimal.D256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### equals

```solidity
function equals(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (bool)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### greaterThan

```solidity
function greaterThan(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (bool)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### lessThan

```solidity
function lessThan(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (bool)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### greaterThanOrEqualTo

```solidity
function greaterThanOrEqualTo(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (bool)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### lessThanOrEqualTo

```solidity
function lessThanOrEqualTo(
    struct Decimal.D256 self,
    struct Decimal.D256 b
) internal returns (bool)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |
| `b`    | struct Decimal.D256 |             |

### isZero

```solidity
function isZero(
    struct Decimal.D256 self
) internal returns (bool)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |

### asUint256

```solidity
function asUint256(
    struct Decimal.D256 self
) internal returns (uint256)
```

#### Parameters

| Name   | Type                | Description |
| ------ | ------------------- | ----------- |
| `self` | struct Decimal.D256 |             |

### getPartial

```solidity
function getPartial(
    uint256 target,
    uint256 numerator,
    uint256 denominator
) private returns (uint256)
```

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `target`      | uint256 |             |
| `numerator`   | uint256 |             |
| `denominator` | uint256 |             |

### compareTo

```solidity
function compareTo(
    struct Decimal.D256 a,
    struct Decimal.D256 b
) private returns (uint256)
```

#### Parameters

| Name | Type                | Description |
| ---- | ------------------- | ----------- |
| `a`  | struct Decimal.D256 |             |
| `b`  | struct Decimal.D256 |             |


# WETH9

## Functions

###

```solidity
function () public
```

###

```solidity
function () external
```

###

```solidity
function () public
```

###

```solidity
function (
    uint256 wad
) public
```

#### Parameters

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| `wad` | uint256 |             |

###

```solidity
function () public returns (uint256)
```

###

```solidity
function (
    address guy,
    uint256 wad
) public returns (bool)
```

#### Parameters

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| `guy` | address |             |
| `wad` | uint256 |             |

###

```solidity
function (
    address dst,
    uint256 wad
) public returns (bool)
```

#### Parameters

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| `dst` | address |             |
| `wad` | uint256 |             |

###

```solidity
function (
    address src,
    address dst,
    uint256 wad
) public returns (bool)
```

#### Parameters

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| `src` | address |             |
| `dst` | address |             |
| `wad` | uint256 |             |

## Events

### Approval

```solidity
event Approval(
    address src,
    address guy,
    uint256 wad
)
```

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| `src`        | address |             |
| `guy`        | address |             |
| `wad`        | uint256 |             |
| ### Transfer |         |             |

```solidity
event Transfer(
    address src,
    address dst,
    uint256 wad
)
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `src`       | address |             |
| `dst`       | address |             |
| `wad`       | uint256 |             |
| ### Deposit |         |             |

```solidity
event Deposit(
    address dst,
    uint256 wad
)
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `dst`          | address |             |
| `wad`          | uint256 |             |
| ### Withdrawal |         |             |

```solidity
event Withdrawal(
    address src,
    uint256 wad
)
```

#### Parameters

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| `src` | address |             |
| `wad` | uint256 |             |


# Libs


# CoreRefPauseableLib

PauseableLib is a library that can be used to pause and unpause contracts, amont other utilities.

This library should only be used on contracts that implement CoreRef.

## Functions

### \_requireUnpaused

```solidity
function _requireUnpaused(
    address _pausableCoreRefAddress
) internal
```

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `_pausableCoreRefAddress` | address |             |

### \_requirePaused

```solidity
function _requirePaused(
    address _pausableCoreRefAddress
) internal
```

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `_pausableCoreRefAddress` | address |             |

### \_ensureUnpaused

```solidity
function _ensureUnpaused(
    address _pausableCoreRefAddress
) internal
```

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `_pausableCoreRefAddress` | address |             |

### \_ensurePaused

```solidity
function _ensurePaused(
    address _pausableCoreRefAddress
) internal
```

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `_pausableCoreRefAddress` | address |             |

### \_pause

```solidity
function _pause(
    address _pauseableCoreRefAddress
) internal
```

#### Parameters

| Name                       | Type    | Description |
| -------------------------- | ------- | ----------- |
| `_pauseableCoreRefAddress` | address |             |

### \_unpause

```solidity
function _unpause(
    address _pauseableCoreRefAddress
) internal
```

#### Parameters

| Name                       | Type    | Description |
| -------------------------- | ------- | ----------- |
| `_pauseableCoreRefAddress` | address |             |


# UintArrayOps

## Functions

### sum

```solidity
function sum(
    uint256[] array
) internal returns (uint256 _sum)
```

#### Parameters

| Name    | Type       | Description |
| ------- | ---------- | ----------- |
| `array` | uint256\[] |             |

### signedDifference

```solidity
function signedDifference(
    uint256[] a,
    uint256[] b
) internal returns (int256[] _difference)
```

#### Parameters

| Name | Type       | Description |
| ---- | ---------- | ----------- |
| `a`  | uint256\[] |             |
| `b`  | uint256\[] |             |

### positiveDifference

```solidity
function positiveDifference(
    uint256[] a,
    uint256[] b
) internal returns (uint256[] _positiveDifference)
```

given two int arrays a & b, returns an array c such that c\[i] = a\[i] - b\[i], with negative values truncated to 0

#### Parameters

| Name | Type       | Description |
| ---- | ---------- | ----------- |
| `a`  | uint256\[] |             |
| `b`  | uint256\[] |             |


# Oracle


# ChainlinkOracleWrapper

Reads a Chainlink oracle value & wrap it under the standard Chi oracle interface

## Functions

### constructor

```solidity
function constructor(
    address _core,
    address _chainlinkOracle
) public
```

ChainlinkOracleWrapper constructor

#### Parameters

| Name               | Type    | Description                              |
| ------------------ | ------- | ---------------------------------------- |
| `_core`            | address | Chi Core for reference                   |
| `_chainlinkOracle` | address | reference to the target Chainlink oracle |

### \_init

```solidity
function _init() internal
```

### update

```solidity
function update() external
```

updates the oracle price

no-op, Chainlink is updated automatically

### isOutdated

```solidity
function isOutdated() external returns (bool)
```

determine if read value is stale

#### Return Values

| Name  | Type | Description                 |
| ----- | ---- | --------------------------- |
| `[0]` | bool | true if read value is stale |

### read

```solidity
function read() external returns (struct Decimal.D256, bool)
```

read the oracle price

#### Return Values

| Name  | Type                | Description            |
| ----- | ------------------- | ---------------------- |
| `[0]` | struct Decimal.D256 | oracle price           |
| `[1]` | bool                | true if price is valid |


# CompositeOracle

Reads two oracles and returns their product

## Functions

### constructor

```solidity
function constructor(
    address _core,
    contract IOracle _oracleA,
    contract IOracle _oracleB
) public
```

CompositeOracle constructor

#### Parameters

| Name       | Type             | Description              |
| ---------- | ---------------- | ------------------------ |
| `_core`    | address          |                          |
| `_oracleA` | contract IOracle | first referenced oracle  |
| `_oracleB` | contract IOracle | second referenced oracle |

### update

```solidity
function update() external
```

updates the oracle price

### isOutdated

```solidity
function isOutdated() external returns (bool)
```

determine if read value is stale

#### Return Values

| Name  | Type | Description                 |
| ----- | ---- | --------------------------- |
| `[0]` | bool | true if read value is stale |

### read

```solidity
function read() external returns (struct Decimal.D256, bool)
```

read the oracle price

#### Return Values

| Name  | Type                | Description            |
| ----- | ------------------- | ---------------------- |
| `[0]` | struct Decimal.D256 | oracle price           |
| `[1]` | bool                | true if price is valid |


# ConstantOracle

Return a constant oracle price

## Functions

### constructor

```solidity
function constructor(
    address _core,
    uint256 _priceBasisPoints
) public
```

Constant oracle constructor

#### Parameters

| Name                | Type    | Description                         |
| ------------------- | ------- | ----------------------------------- |
| `_core`             | address | Chi Core for reference              |
| `_priceBasisPoints` | uint256 | the price to report in basis points |

### update

```solidity
function update() external
```

updates the oracle price

no-op, oracle is fixed

### isOutdated

```solidity
function isOutdated() external returns (bool)
```

determine if read value is stale

always false, oracle is fixed

### read

```solidity
function read() external returns (struct Decimal.D256, bool)
```

read the oracle price

#### Return Values

| Name  | Type                | Description           |
| ----- | ------------------- | --------------------- |
| `[0]` | struct Decimal.D256 | constant oracle price |
| `[1]` | bool                | true if not paused    |


# ICollateralizationOracle


# ICollateralizationOracleWrapper


# Pcv


# IPCVDeposit

## Functions

### deposit

```solidity
function deposit() external
```

### withdraw

```solidity
function withdraw(
    address to,
    uint256 amount
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### withdrawERC20

```solidity
function withdrawERC20(
    address token,
    address to,
    uint256 amount
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `token`  | address |             |
| `to`     | address |             |
| `amount` | uint256 |             |

### withdrawETH

```solidity
function withdrawETH(
    address payable to,
    uint256 amount
) external
```

#### Parameters

| Name     | Type            | Description |
| -------- | --------------- | ----------- |
| `to`     | address payable |             |
| `amount` | uint256         |             |

## Events

### Deposit

```solidity
event Deposit(
    address _from,
    uint256 _amount
)
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `_from`        | address |             |
| `_amount`      | uint256 |             |
| ### Withdrawal |         |             |

```solidity
event Withdrawal(
    address _caller,
    address _to,
    uint256 _amount
)
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `_caller`         | address |             |
| `_to`             | address |             |
| `_amount`         | uint256 |             |
| ### WithdrawERC20 |         |             |

```solidity
event WithdrawERC20(
    address _caller,
    address _token,
    address _to,
    uint256 _amount
)
```

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| `_caller`       | address |             |
| `_token`        | address |             |
| `_to`           | address |             |
| `_amount`       | uint256 |             |
| ### WithdrawETH |         |             |

```solidity
event WithdrawETH(
    address _caller,
    address _to,
    uint256 _amount
)
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `_caller` | address |             |
| `_to`     | address |             |
| `_amount` | uint256 |             |


# IPCVDepositBalances

## Functions

### balance

```solidity
function balance() external returns (uint256)
```

gets the effective balance of "balanceReportedIn" token if the deposit were fully withdrawn

### balanceReportedIn

```solidity
function balanceReportedIn() external returns (address)
```

gets the token address in which this deposit returns its balance

### resistantBalanceAndChi

```solidity
function resistantBalanceAndChi() external returns (uint256, uint256)
```

gets the resistant token balance and protocol owned chi of this deposit


# IPCVGuardian

an interface for defining how the PCVGuardian functions

any implementation of this contract should be granted the roles of Guardian and PCVController in order to work correctly

## Functions

### isSafeAddress

```solidity
function isSafeAddress(
    address pcvDeposit
) external returns (bool)
```

returns true if the the provided address is a valid destination to withdraw funds to

#### Parameters

| Name         | Type    | Description          |
| ------------ | ------- | -------------------- |
| `pcvDeposit` | address | the address to check |

### getSafeAddresses

```solidity
function getSafeAddresses() external returns (address[])
```

returns all safe addresses

### setSafeAddress

```solidity
function setSafeAddress(
    address pcvDeposit
) external
```

governor-only method to set an address as "safe" to withdraw funds to

#### Parameters

| Name         | Type    | Description                |
| ------------ | ------- | -------------------------- |
| `pcvDeposit` | address | the address to set as safe |

### setSafeAddresses

```solidity
function setSafeAddresses(
    address[] safeAddresses
) external
```

batch version of setSafeAddress

#### Parameters

| Name            | Type       | Description                               |
| --------------- | ---------- | ----------------------------------------- |
| `safeAddresses` | address\[] | the addresses to set as safe, as calldata |

### unsetSafeAddress

```solidity
function unsetSafeAddress(
    address pcvDeposit
) external
```

governor-or-guardian-only method to un-set an address as "safe" to withdraw funds to

#### Parameters

| Name         | Type    | Description                   |
| ------------ | ------- | ----------------------------- |
| `pcvDeposit` | address | the address to un-set as safe |

### unsetSafeAddresses

```solidity
function unsetSafeAddresses(
    address[] safeAddresses
) external
```

batch version of unsetSafeAddresses

#### Parameters

| Name            | Type       | Description                     |
| --------------- | ---------- | ------------------------------- |
| `safeAddresses` | address\[] | the addresses to un-set as safe |

### withdrawToSafeAddress

```solidity
function withdrawToSafeAddress(
    address pcvDeposit,
    address safeAddress,
    uint256 amount,
    bool pauseAfter,
    bool depositAfter
) external
```

governor-or-guardian-only method to withdraw funds from a pcv deposit, by calling the withdraw() method on it

#### Parameters

| Name           | Type    | Description                                                 |
| -------------- | ------- | ----------------------------------------------------------- |
| `pcvDeposit`   | address | the address of the pcv deposit contract                     |
| `safeAddress`  | address | the destination address to withdraw to                      |
| `amount`       | uint256 | the amount to withdraw                                      |
| `pauseAfter`   | bool    | if true, the pcv contract will be paused after the withdraw |
| `depositAfter` | bool    | if true, attempts to deposit to the target PCV deposit      |

### withdrawETHToSafeAddress

```solidity
function withdrawETHToSafeAddress(
    address pcvDeposit,
    address payable safeAddress,
    uint256 amount,
    bool pauseAfter,
    bool depositAfter
) external
```

governor-or-guardian-only method to withdraw funds from a pcv deposit, by calling the withdraw() method on it

#### Parameters

| Name           | Type            | Description                                                 |
| -------------- | --------------- | ----------------------------------------------------------- |
| `pcvDeposit`   | address         | the address of the pcv deposit contract                     |
| `safeAddress`  | address payable | the destination address to withdraw to                      |
| `amount`       | uint256         | the amount of tokens to withdraw                            |
| `pauseAfter`   | bool            | if true, the pcv contract will be paused after the withdraw |
| `depositAfter` | bool            | if true, attempts to deposit to the target PCV deposit      |

### withdrawERC20ToSafeAddress

```solidity
function withdrawERC20ToSafeAddress(
    address pcvDeposit,
    address safeAddress,
    address token,
    uint256 amount,
    bool pauseAfter,
    bool depositAfter
) external
```

governor-or-guardian-only method to withdraw funds from a pcv deposit, by calling the withdraw() method on it

#### Parameters

| Name           | Type    | Description                                            |
| -------------- | ------- | ------------------------------------------------------ |
| `pcvDeposit`   | address | the deposit to pull funds from                         |
| `safeAddress`  | address | the destination address to withdraw to                 |
| `token`        | address | the token to withdraw                                  |
| `amount`       | uint256 | the amount of funds to withdraw                        |
| `pauseAfter`   | bool    | whether to pause the pcv after withdrawing             |
| `depositAfter` | bool    | if true, attempts to deposit to the target PCV deposit |

## Events

### SafeAddressAdded

```solidity
event SafeAddressAdded(
    address safeAddress
)
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `safeAddress`          | address |             |
| ### SafeAddressRemoved |         |             |

```solidity
event SafeAddressRemoved(
    address safeAddress
)
```

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `safeAddress`             | address |             |
| ### PCVGuardianWithdrawal |         |             |

```solidity
event PCVGuardianWithdrawal(
    address pcvDeposit,
    address destination,
    uint256 amount
)
```

#### Parameters

| Name                         | Type    | Description |
| ---------------------------- | ------- | ----------- |
| `pcvDeposit`                 | address |             |
| `destination`                | address |             |
| `amount`                     | uint256 |             |
| ### PCVGuardianETHWithdrawal |         |             |

```solidity
event PCVGuardianETHWithdrawal(
    address pcvDeposit,
    address destination,
    uint256 amount
)
```

#### Parameters

| Name                           | Type    | Description |
| ------------------------------ | ------- | ----------- |
| `pcvDeposit`                   | address |             |
| `destination`                  | address |             |
| `amount`                       | uint256 |             |
| ### PCVGuardianERC20Withdrawal |         |             |

```solidity
event PCVGuardianERC20Withdrawal(
    address pcvDeposit,
    address destination,
    address token,
    uint256 amount
)
```

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `pcvDeposit`  | address |             |
| `destination` | address |             |
| `token`       | address |             |
| `amount`      | uint256 |             |


# IPCVSwapper

## Functions

### swap

```solidity
function swap() external
```

### setReceivingAddress

```solidity
function setReceivingAddress(
    address _tokenReceivingAddress
) external
```

#### Parameters

| Name                     | Type    | Description |
| ------------------------ | ------- | ----------- |
| `_tokenReceivingAddress` | address |             |

### tokenSpent

```solidity
function tokenSpent() external returns (address)
```

### tokenReceived

```solidity
function tokenReceived() external returns (address)
```

### tokenReceivingAddress

```solidity
function tokenReceivingAddress() external returns (address)
```

## Events

### UpdateReceivingAddress

```solidity
event UpdateReceivingAddress(
    address oldTokenReceivingAddress,
    address newTokenReceivingAddress
)
```

#### Parameters

| Name                       | Type    | Description |
| -------------------------- | ------- | ----------- |
| `oldTokenReceivingAddress` | address |             |
| `newTokenReceivingAddress` | address |             |
| ### Swap                   |         |             |

```solidity
event Swap(
    address _caller,
    address _tokenSpent,
    address _tokenReceived,
    uint256 _amountSpent,
    uint256 _amountReceived
)
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `_caller`         | address |             |
| `_tokenSpent`     | address |             |
| `_tokenReceived`  | address |             |
| `_amountSpent`    | uint256 |             |
| `_amountReceived` | uint256 |             |


# PCVDeposit

## Functions

### withdrawERC20

```solidity
function withdrawERC20(
    address token,
    address to,
    uint256 amount
) public
```

withdraw ERC20 from the contract

#### Parameters

| Name     | Type    | Description                      |
| -------- | ------- | -------------------------------- |
| `token`  | address | address of the ERC20 to send     |
| `to`     | address | address destination of the ERC20 |
| `amount` | uint256 | quantity of ERC20 to send        |

### \_withdrawERC20

```solidity
function _withdrawERC20(
    address token,
    address to,
    uint256 amount
) internal
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `token`  | address |             |
| `to`     | address |             |
| `amount` | uint256 |             |

### withdrawETH

```solidity
function withdrawETH(
    address payable to,
    uint256 amountOut
) external
```

withdraw ETH from the contract

#### Parameters

| Name        | Type            | Description           |
| ----------- | --------------- | --------------------- |
| `to`        | address payable | address to send ETH   |
| `amountOut` | uint256         | amount of ETH to send |

### balance

```solidity
function balance() public returns (uint256)
```

gets the effective balance of "balanceReportedIn" token if the deposit were fully withdrawn

### resistantBalanceAndChi

```solidity
function resistantBalanceAndChi() public returns (uint256, uint256)
```

gets the resistant token balance and protocol owned chi of this deposit


# PCVGuardian

## Functions

### constructor

```solidity
function constructor(
    address _core,
    address[] _safeAddresses
) public
```

#### Parameters

| Name             | Type       | Description |
| ---------------- | ---------- | ----------- |
| `_core`          | address    |             |
| `_safeAddresses` | address\[] |             |

### isSafeAddress

```solidity
function isSafeAddress(
    address pcvDeposit
) public returns (bool)
```

returns true if the the provided address is a valid destination to withdraw funds to

#### Parameters

| Name         | Type    | Description          |
| ------------ | ------- | -------------------- |
| `pcvDeposit` | address | the address to check |

### getSafeAddresses

```solidity
function getSafeAddresses() public returns (address[])
```

returns all safe addresses

### setSafeAddress

```solidity
function setSafeAddress(
    address pcvDeposit
) external
```

governor-only method to set an address as "safe" to withdraw funds to

#### Parameters

| Name         | Type    | Description                |
| ------------ | ------- | -------------------------- |
| `pcvDeposit` | address | the address to set as safe |

### setSafeAddresses

```solidity
function setSafeAddresses(
    address[] _safeAddresses
) external
```

batch version of setSafeAddress

#### Parameters

| Name             | Type       | Description                               |
| ---------------- | ---------- | ----------------------------------------- |
| `_safeAddresses` | address\[] | the addresses to set as safe, as calldata |

### unsetSafeAddress

```solidity
function unsetSafeAddress(
    address pcvDeposit
) external
```

governor-or-guardian-only method to un-set an address as "safe" to withdraw funds to

#### Parameters

| Name         | Type    | Description                   |
| ------------ | ------- | ----------------------------- |
| `pcvDeposit` | address | the address to un-set as safe |

### unsetSafeAddresses

```solidity
function unsetSafeAddresses(
    address[] _safeAddresses
) external
```

batch version of unsetSafeAddresses

#### Parameters

| Name             | Type       | Description                     |
| ---------------- | ---------- | ------------------------------- |
| `_safeAddresses` | address\[] | the addresses to un-set as safe |

### withdrawToSafeAddress

```solidity
function withdrawToSafeAddress(
    address pcvDeposit,
    address safeAddress,
    uint256 amount,
    bool pauseAfter,
    bool depositAfter
) external
```

governor-or-guardian-only method to withdraw funds from a pcv deposit, by calling the withdraw() method on it

#### Parameters

| Name           | Type    | Description                                                 |
| -------------- | ------- | ----------------------------------------------------------- |
| `pcvDeposit`   | address | the address of the pcv deposit contract                     |
| `safeAddress`  | address | the destination address to withdraw to                      |
| `amount`       | uint256 | the amount to withdraw                                      |
| `pauseAfter`   | bool    | if true, the pcv contract will be paused after the withdraw |
| `depositAfter` | bool    | if true, attempts to deposit to the target PCV deposit      |

### withdrawETHToSafeAddress

```solidity
function withdrawETHToSafeAddress(
    address pcvDeposit,
    address payable safeAddress,
    uint256 amount,
    bool pauseAfter,
    bool depositAfter
) external
```

governor-or-guardian-only method to withdraw funds from a pcv deposit, by calling the withdraw() method on it

#### Parameters

| Name           | Type            | Description                                                 |
| -------------- | --------------- | ----------------------------------------------------------- |
| `pcvDeposit`   | address         | the address of the pcv deposit contract                     |
| `safeAddress`  | address payable | the destination address to withdraw to                      |
| `amount`       | uint256         | the amount of tokens to withdraw                            |
| `pauseAfter`   | bool            | if true, the pcv contract will be paused after the withdraw |
| `depositAfter` | bool            | if true, attempts to deposit to the target PCV deposit      |

### withdrawERC20ToSafeAddress

```solidity
function withdrawERC20ToSafeAddress(
    address pcvDeposit,
    address safeAddress,
    address token,
    uint256 amount,
    bool pauseAfter,
    bool depositAfter
) external
```

governor-or-guardian-only method to withdraw funds from a pcv deposit, by calling the withdraw() method on it

#### Parameters

| Name           | Type    | Description                                            |
| -------------- | ------- | ------------------------------------------------------ |
| `pcvDeposit`   | address | the deposit to pull funds from                         |
| `safeAddress`  | address | the destination address to withdraw to                 |
| `token`        | address |                                                        |
| `amount`       | uint256 | the amount of funds to withdraw                        |
| `pauseAfter`   | bool    | whether to pause the pcv after withdrawing             |
| `depositAfter` | bool    | if true, attempts to deposit to the target PCV deposit |

### \_setSafeAddress

```solidity
function _setSafeAddress(
    address anAddress
) internal
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `anAddress` | address |             |

### \_unsetSafeAddress

```solidity
function _unsetSafeAddress(
    address anAddress
) internal
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `anAddress` | address |             |


# Peg


# FixedPricePSM

## Functions

### constructor

```solidity
function constructor(
    uint256 _floor,
    uint256 _ceiling,
    struct PegStabilityModule.OracleParams _params,
    uint256 _mintFeeBasisPoints,
    uint256 _redeemFeeBasisPoints,
    uint256 _reservesThreshold,
    uint256 _chiLimitPerSecond,
    uint256 _mintingBufferCap,
    contract IERC20 _underlyingToken,
    contract IPCVDeposit _surplusTarget
) public
```

#### Parameters

| Name                    | Type                                   | Description |
| ----------------------- | -------------------------------------- | ----------- |
| `_floor`                | uint256                                |             |
| `_ceiling`              | uint256                                |             |
| `_params`               | struct PegStabilityModule.OracleParams |             |
| `_mintFeeBasisPoints`   | uint256                                |             |
| `_redeemFeeBasisPoints` | uint256                                |             |
| `_reservesThreshold`    | uint256                                |             |
| `_chiLimitPerSecond`    | uint256                                |             |
| `_mintingBufferCap`     | uint256                                |             |
| `_underlyingToken`      | contract IERC20                        |             |
| `_surplusTarget`        | contract IPCVDeposit                   |             |

### \_getMintAmountOut

```solidity
function _getMintAmountOut(
    uint256 amountIn
) internal returns (uint256 amountChiOut)
```

helper function to get mint amount out based on current market prices

will revert if price is outside of bounds and bounded PSM is being used

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `amountIn` | uint256 |             |

### \_getRedeemAmountOut

```solidity
function _getRedeemAmountOut(
    uint256 amountChiIn
) internal returns (uint256 amountTokenOut)
```

helper function to get redeem amount out based on current market prices

will revert if price is outside of bounds and bounded PSM is being used

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `amountChiIn` | uint256 |             |


# IPegStabilityModule

The Chi PSM is a contract which holds a reserve of assets in order to exchange CHI at $1 of underlying assets with a fee. `mint()` - buy CHI for $1 of underlying tokens `redeem()` - sell CHI back for $1 of the same

The contract has a reservesThreshold() of underlying meant to stand ready for redemptions. Any surplus reserves can be sent into the PCV using `allocateSurplus()`

The contract is a PCVDeposit - to track reserves OracleRef - to determine price of underlying, and RateLimitedMinter - to stop infinite mints and related issues (but this is in the implementation due to inheritance-linearization difficulties)

Inspired by MakerDAO PSM, code written without reference

## Functions

### mint

```solidity
function mint(
    address to,
    uint256 amountIn,
    uint256 minAmountOut
) external returns (uint256 amountChiOut)
```

mint `amountChiOut` CHI to address `to` for `amountIn` underlying tokens

see getMintAmountOut() to pre-calculate amount out

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountIn`     | uint256 |             |
| `minAmountOut` | uint256 |             |

### redeem

```solidity
function redeem(
    address to,
    uint256 amountChiIn,
    uint256 minAmountOut
) external returns (uint256 amountOut)
```

redeem `amountChiIn` CHI for `amountOut` underlying tokens and send to address `to`

see getRedeemAmountOut() to pre-calculate amount out

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountChiIn`  | uint256 |             |
| `minAmountOut` | uint256 |             |

### allocateSurplus

```solidity
function allocateSurplus() external
```

send any surplus reserves to the PCV allocation

### setMintFee

```solidity
function setMintFee(
    uint256 newMintFeeBasisPoints
) external
```

set the mint fee vs oracle price in basis point terms

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `newMintFeeBasisPoints` | uint256 |             |

### setRedeemFee

```solidity
function setRedeemFee(
    uint256 newRedeemFeeBasisPoints
) external
```

set the redemption fee vs oracle price in basis point terms

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `newRedeemFeeBasisPoints` | uint256 |             |

### setReservesThreshold

```solidity
function setReservesThreshold(
    uint256 newReservesThreshold
) external
```

set the ideal amount of reserves for the contract to hold for redemptions

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newReservesThreshold` | uint256 |             |

### setSurplusTarget

```solidity
function setSurplusTarget(
    contract IPCVDeposit newTarget
) external
```

set the target for sending surplus reserves

#### Parameters

| Name        | Type                 | Description |
| ----------- | -------------------- | ----------- |
| `newTarget` | contract IPCVDeposit |             |

### getMintAmountOut

```solidity
function getMintAmountOut(
    uint256 amountIn
) external returns (uint256 amountChiOut)
```

calculate the amount of CHI out for a given `amountIn` of underlying

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `amountIn` | uint256 |             |

### getRedeemAmountOut

```solidity
function getRedeemAmountOut(
    uint256 amountChiIn
) external returns (uint256 amountOut)
```

calculate the amount of underlying out for a given `amountChiIn` of CHI

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `amountChiIn` | uint256 |             |

### getMaxMintAmountOut

```solidity
function getMaxMintAmountOut() external returns (uint256)
```

the maximum mint amount out

### hasSurplus

```solidity
function hasSurplus() external returns (bool)
```

a flag for whether the current balance is above (true) or below and equal (false) to the reservesThreshold

### reservesSurplus

```solidity
function reservesSurplus() external returns (int256)
```

an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold

### reservesThreshold

```solidity
function reservesThreshold() external returns (uint256)
```

the ideal amount of reserves for the contract to hold for redemptions

### mintFeeBasisPoints

```solidity
function mintFeeBasisPoints() external returns (uint256)
```

the mint fee vs oracle price in basis point terms

### redeemFeeBasisPoints

```solidity
function redeemFeeBasisPoints() external returns (uint256)
```

the redemption fee vs oracle price in basis point terms

### underlyingToken

```solidity
function underlyingToken() external returns (contract IERC20)
```

the underlying token exchanged for CHI

### surplusTarget

```solidity
function surplusTarget() external returns (contract IPCVDeposit)
```

the PCV deposit target to send surplus reserves

### MAX\_FEE

```solidity
function MAX_FEE() external returns (uint256)
```

the max mint and redeem fee in basis points

## Events

### AllocateSurplus

```solidity
event AllocateSurplus(
    address caller,
    uint256 amount
)
```

event emitted when excess PCV is allocated

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `caller`         | address |             |
| `amount`         | uint256 |             |
| ### MaxFeeUpdate |         |             |

```solidity
event MaxFeeUpdate(
    uint256 oldMaxFee,
    uint256 newMaxFee
)
```

event emitted when a new max fee is set

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `oldMaxFee`       | uint256 |             |
| `newMaxFee`       | uint256 |             |
| ### MintFeeUpdate |         |             |

```solidity
event MintFeeUpdate(
    uint256 oldMintFee,
    uint256 newMintFee
)
```

event emitted when a new mint fee is set

#### Parameters

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| `oldMintFee`        | uint256 |             |
| `newMintFee`        | uint256 |             |
| ### RedeemFeeUpdate |         |             |

```solidity
event RedeemFeeUpdate(
    uint256 oldRedeemFee,
    uint256 newRedeemFee
)
```

event emitted when a new redeem fee is set

#### Parameters

| Name                        | Type    | Description |
| --------------------------- | ------- | ----------- |
| `oldRedeemFee`              | uint256 |             |
| `newRedeemFee`              | uint256 |             |
| ### ReservesThresholdUpdate |         |             |

```solidity
event ReservesThresholdUpdate(
    uint256 oldReservesThreshold,
    uint256 newReservesThreshold
)
```

event emitted when reservesThreshold is updated

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `oldReservesThreshold`  | uint256 |             |
| `newReservesThreshold`  | uint256 |             |
| ### SurplusTargetUpdate |         |             |

```solidity
event SurplusTargetUpdate(
    contract IPCVDeposit oldTarget,
    contract IPCVDeposit newTarget
)
```

event emitted when surplus target is updated

#### Parameters

| Name        | Type                 | Description |
| ----------- | -------------------- | ----------- |
| `oldTarget` | contract IPCVDeposit |             |
| `newTarget` | contract IPCVDeposit |             |
| ### Redeem  |                      |             |

```solidity
event Redeem(
    address to,
    uint256 amountChiIn,
    uint256 amountAssetOut
)
```

event emitted upon a redemption

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `to`             | address |             |
| `amountChiIn`    | uint256 |             |
| `amountAssetOut` | uint256 |             |
| ### Mint         |         |             |

```solidity
event Mint(
    address to,
    uint256 amountIn,
    uint256 amountChiOut
)
```

event emitted when chi gets minted

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountIn`     | uint256 |             |
| `amountChiOut` | uint256 |             |


# IPriceBound

## Functions

### setOracleFloorBasisPoints

```solidity
function setOracleFloorBasisPoints(
    uint256 newFloor
) external
```

sets the floor price in BP

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `newFloor` | uint256 |             |

### setOracleCeilingBasisPoints

```solidity
function setOracleCeilingBasisPoints(
    uint256 newCeiling
) external
```

sets the ceiling price in BP

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| `newCeiling` | uint256 |             |

### floor

```solidity
function floor() external returns (uint256)
```

get the floor price in basis points

### ceiling

```solidity
function ceiling() external returns (uint256)
```

get the ceiling price in basis points

### isPriceValid

```solidity
function isPriceValid() external returns (bool)
```

return wether the current oracle price is valid or not

## Events

### OracleFloorUpdate

```solidity
event OracleFloorUpdate(
    uint256 oldFloor,
    uint256 newFloor
)
```

event emitted when minimum floor price is updated

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `oldFloor`              | uint256 |             |
| `newFloor`              | uint256 |             |
| ### OracleCeilingUpdate |         |             |

```solidity
event OracleCeilingUpdate(
    uint256 oldCeiling,
    uint256 newCeiling
)
```

event emitted when maximum ceiling price is updated

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| `oldCeiling` | uint256 |             |
| `newCeiling` | uint256 |             |


# IPSMRouter

## Functions

### psm

```solidity
function psm() external returns (contract IPegStabilityModule)
```

reference to the PegStabilityModule that this router interacts with

### chi

```solidity
function chi() external returns (contract IChi)
```

reference to the CHI contract used.

### getMintAmountOut

```solidity
function getMintAmountOut(
    uint256 amountIn
) external returns (uint256 amountChiOut)
```

calculate the amount of CHI out for a given `amountIn` of underlying

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `amountIn` | uint256 |             |

### getRedeemAmountOut

```solidity
function getRedeemAmountOut(
    uint256 amountChiIn
) external returns (uint256 amountOut)
```

calculate the amount of underlying out for a given `amountChiIn` of CHI

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `amountChiIn` | uint256 |             |

### getMaxMintAmountOut

```solidity
function getMaxMintAmountOut() external returns (uint256)
```

the maximum mint amount out

### getMaxRedeemAmountOut

```solidity
function getMaxRedeemAmountOut() external returns (uint256)
```

the maximum redeem amount out

### mint

```solidity
function mint(
    address _to,
    uint256 _minAmountOut,
    uint256 ethAmountIn
) external returns (uint256)
```

Mints chi to the given address, with a minimum amount required

This wraps ETH and then calls into the PSM to mint the chi. We return the amount of chi minted.

#### Parameters

| Name            | Type    | Description                       |
| --------------- | ------- | --------------------------------- |
| `_to`           | address | The address to mint chi to        |
| `_minAmountOut` | uint256 | The minimum amount of chi to mint |
| `ethAmountIn`   | uint256 |                                   |

### redeem

```solidity
function redeem(
    address to,
    uint256 amountChiIn,
    uint256 minAmountOut
) external returns (uint256 amountOut)
```

Redeems chi for ETH First pull user CHI into this contract Then call redeem on the PSM to turn the CHI into weth Withdraw all weth to eth in the router Send the eth to the specified recipient

#### Parameters

| Name           | Type    | Description                           |
| -------------- | ------- | ------------------------------------- |
| `to`           | address | the address to receive the eth        |
| `amountChiIn`  | uint256 | the amount of CHI to redeem           |
| `minAmountOut` | uint256 | the minimum amount of weth to receive |


# PegStabilityModule

## Functions

### constructor

```solidity
function constructor(
    struct PegStabilityModule.OracleParams params,
    uint256 _mintFeeBasisPoints,
    uint256 _redeemFeeBasisPoints,
    uint256 _reservesThreshold,
    uint256 _chiLimitPerSecond,
    uint256 _mintingBufferCap,
    contract IERC20 _underlyingToken,
    contract IPCVDeposit _surplusTarget
) public
```

constructor

#### Parameters

| Name                    | Type                                   | Description                      |
| ----------------------- | -------------------------------------- | -------------------------------- |
| `params`                | struct PegStabilityModule.OracleParams | PSM constructor parameter struct |
| `_mintFeeBasisPoints`   | uint256                                |                                  |
| `_redeemFeeBasisPoints` | uint256                                |                                  |
| `_reservesThreshold`    | uint256                                |                                  |
| `_chiLimitPerSecond`    | uint256                                |                                  |
| `_mintingBufferCap`     | uint256                                |                                  |
| `_underlyingToken`      | contract IERC20                        |                                  |
| `_surplusTarget`        | contract IPCVDeposit                   |                                  |

### pauseRedeem

```solidity
function pauseRedeem() external
```

set secondary pausable methods to paused

### unpauseRedeem

```solidity
function unpauseRedeem() external
```

set secondary pausable methods to unpaused

### pauseMint

```solidity
function pauseMint() external
```

set secondary pausable methods to paused

### unpauseMint

```solidity
function unpauseMint() external
```

set secondary pausable methods to unpaused

### withdraw

```solidity
function withdraw(
    address to,
    uint256 amount
) external
```

withdraw assets from PSM to an external address

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### setMintFee

```solidity
function setMintFee(
    uint256 newMintFeeBasisPoints
) external
```

set the mint fee vs oracle price in basis point terms

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `newMintFeeBasisPoints` | uint256 |             |

### setRedeemFee

```solidity
function setRedeemFee(
    uint256 newRedeemFeeBasisPoints
) external
```

set the redemption fee vs oracle price in basis point terms

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `newRedeemFeeBasisPoints` | uint256 |             |

### setReservesThreshold

```solidity
function setReservesThreshold(
    uint256 newReservesThreshold
) external
```

set the ideal amount of reserves for the contract to hold for redemptions

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newReservesThreshold` | uint256 |             |

### setSurplusTarget

```solidity
function setSurplusTarget(
    contract IPCVDeposit newTarget
) external
```

set the target for sending surplus reserves

#### Parameters

| Name        | Type                 | Description |
| ----------- | -------------------- | ----------- |
| `newTarget` | contract IPCVDeposit |             |

### \_setMintFee

```solidity
function _setMintFee(
    uint256 newMintFeeBasisPoints
) internal
```

set the mint fee vs oracle price in basis point terms

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `newMintFeeBasisPoints` | uint256 |             |

### \_setRedeemFee

```solidity
function _setRedeemFee(
    uint256 newRedeemFeeBasisPoints
) internal
```

internal helper function to set the redemption fee

#### Parameters

| Name                      | Type    | Description |
| ------------------------- | ------- | ----------- |
| `newRedeemFeeBasisPoints` | uint256 |             |

### \_setReservesThreshold

```solidity
function _setReservesThreshold(
    uint256 newReservesThreshold
) internal
```

helper function to set reserves threshold

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newReservesThreshold` | uint256 |             |

### \_setSurplusTarget

```solidity
function _setSurplusTarget(
    contract IPCVDeposit newSurplusTarget
) internal
```

helper function to set the surplus target

#### Parameters

| Name               | Type                 | Description |
| ------------------ | -------------------- | ----------- |
| `newSurplusTarget` | contract IPCVDeposit |             |

### allocateSurplus

```solidity
function allocateSurplus() external
```

send any surplus reserves to the PCV allocation

### deposit

```solidity
function deposit() external
```

function to receive ERC20 tokens from external contracts

### \_redeem

```solidity
function _redeem(
    address to,
    uint256 amountChiIn,
    uint256 minAmountOut
) internal returns (uint256 amountOut)
```

internal helper method to redeem chi in exchange for an external asset

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountChiIn`  | uint256 |             |
| `minAmountOut` | uint256 |             |

### \_mint

```solidity
function _mint(
    address to,
    uint256 amountIn,
    uint256 minAmountOut
) internal returns (uint256 amountChiOut)
```

internal helper method to mint chi in exchange for an external asset

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountIn`     | uint256 |             |
| `minAmountOut` | uint256 |             |

### redeem

```solidity
function redeem(
    address to,
    uint256 amountChiIn,
    uint256 minAmountOut
) external returns (uint256 amountOut)
```

function to redeem CHI for an underlying asset We do not burn Chi; this allows the contract's balance of Chi to be used before the buffer is used In practice, this helps prevent artificial cycling of mint-burn cycles and prevents a griefing vector.

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountChiIn`  | uint256 |             |
| `minAmountOut` | uint256 |             |

### mint

```solidity
function mint(
    address to,
    uint256 amountIn,
    uint256 minAmountOut
) external returns (uint256 amountChiOut)
```

function to buy CHI for an underlying asset We first transfer any contract-owned chi, then mint the remaining if necessary

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountIn`     | uint256 |             |
| `minAmountOut` | uint256 |             |

### getMintAmountOut

```solidity
function getMintAmountOut(
    uint256 amountIn
) public returns (uint256 amountChiOut)
```

calculate the amount of CHI out for a given `amountIn` of underlying First get oracle price of token Then figure out how many dollars that amount in is worth by multiplying price \* amount. ensure decimals are normalized if on underlying they are not 18

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `amountIn` | uint256 |             |

### getRedeemAmountOut

```solidity
function getRedeemAmountOut(
    uint256 amountChiIn
) public returns (uint256 amountTokenOut)
```

calculate the amount of underlying out for a given `amountChiIn` of CHI First get oracle price of token Then figure out how many dollars that amount in is worth by multiplying price \* amount. ensure decimals are normalized if on underlying they are not 18

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `amountChiIn` | uint256 |             |

### getMaxMintAmountOut

```solidity
function getMaxMintAmountOut() external returns (uint256)
```

the maximum mint amount out

### hasSurplus

```solidity
function hasSurplus() external returns (bool)
```

a flag for whether the current balance is above (true) or below (false) the reservesThreshold

### reservesSurplus

```solidity
function reservesSurplus() public returns (int256)
```

an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold

### balance

```solidity
function balance() public returns (uint256)
```

function from PCVDeposit that must be overriden

### balanceReportedIn

```solidity
function balanceReportedIn() external returns (address)
```

returns address of token this contracts balance is reported in

### resistantBalanceAndChi

```solidity
function resistantBalanceAndChi() public returns (uint256, uint256)
```

override default behavior of not checking chi balance

### \_getMintAmountOut

```solidity
function _getMintAmountOut(
    uint256 amountIn
) internal returns (uint256 amountChiOut)
```

helper function to get mint amount out based on current market prices

will revert if price is outside of bounds and bounded PSM is being used

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `amountIn` | uint256 |             |

### \_getRedeemAmountOut

```solidity
function _getRedeemAmountOut(
    uint256 amountChiIn
) internal returns (uint256 amountTokenOut)
```

helper function to get redeem amount out based on current market prices

will revert if price is outside of bounds and bounded PSM is being used

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `amountChiIn` | uint256 |             |

### \_allocate

```solidity
function _allocate(
    uint256 amount
) internal
```

Allocates a portion of escrowed PCV to a target PCV deposit

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `amount` | uint256 |             |

### \_transfer

```solidity
function _transfer(
    address to,
    uint256 amount
) internal
```

transfer ERC20 token

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### \_transferFrom

```solidity
function _transferFrom(
    address from,
    address to,
    uint256 amount
) internal
```

transfer assets from user to this contract

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `from`   | address |             |
| `to`     | address |             |
| `amount` | uint256 |             |

### \_mintChi

```solidity
function _mintChi(
    address to,
    uint256 amount
) internal
```

mint amount of CHI to the specified user on a rate limit

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### \_validatePriceRange

```solidity
function _validatePriceRange(
    struct Decimal.D256 price
) internal
```

overriden function in the bounded PSM

#### Parameters

| Name    | Type                | Description |
| ------- | ------------------- | ----------- |
| `price` | struct Decimal.D256 |             |

## Events

### RedemptionsPaused

```solidity
event RedemptionsPaused(
    address account
)
```

event that is emitted when redemptions are paused

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `account`               | address |             |
| ### RedemptionsUnpaused |         |             |

```solidity
event RedemptionsUnpaused(
    address account
)
```

event that is emitted when redemptions are unpaused

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `account`         | address |             |
| ### MintingPaused |         |             |

```solidity
event MintingPaused(
    address account
)
```

event that is emitted when minting is paused

#### Parameters

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| `account`           | address |             |
| ### MintingUnpaused |         |             |

```solidity
event MintingUnpaused(
    address account
)
```

event that is emitted when minting is unpaused

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `account` | address |             |


# PriceBoundPSM

contract to create a price bound DAI PSM This contract will allow swaps when the price of DAI is between 98 cents and 1.02 by default These defaults are changeable by the admin and governance by calling floor and ceiling setters setOracleFloor and setOracleCeiling

## Functions

### constructor

```solidity
function constructor(
    uint256 _floor,
    uint256 _ceiling,
    struct PegStabilityModule.OracleParams _params,
    uint256 _mintFeeBasisPoints,
    uint256 _redeemFeeBasisPoints,
    uint256 _reservesThreshold,
    uint256 _chiLimitPerSecond,
    uint256 _mintingBufferCap,
    contract IERC20 _underlyingToken,
    contract IPCVDeposit _surplusTarget
) public
```

constructor

#### Parameters

| Name                    | Type                                   | Description                     |
| ----------------------- | -------------------------------------- | ------------------------------- |
| `_floor`                | uint256                                | minimum acceptable oracle price |
| `_ceiling`              | uint256                                | maximum acceptable oracle price |
| `_params`               | struct PegStabilityModule.OracleParams | PSM construction params         |
| `_mintFeeBasisPoints`   | uint256                                |                                 |
| `_redeemFeeBasisPoints` | uint256                                |                                 |
| `_reservesThreshold`    | uint256                                |                                 |
| `_chiLimitPerSecond`    | uint256                                |                                 |
| `_mintingBufferCap`     | uint256                                |                                 |
| `_underlyingToken`      | contract IERC20                        |                                 |
| `_surplusTarget`        | contract IPCVDeposit                   |                                 |

### setOracleFloorBasisPoints

```solidity
function setOracleFloorBasisPoints(
    uint256 newFloorBasisPoints
) external
```

sets the floor price in BP

#### Parameters

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| `newFloorBasisPoints` | uint256 |             |

### setOracleCeilingBasisPoints

```solidity
function setOracleCeilingBasisPoints(
    uint256 newCeilingBasisPoints
) external
```

sets the ceiling price in BP

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `newCeilingBasisPoints` | uint256 |             |

### isPriceValid

```solidity
function isPriceValid() external returns (bool)
```

return wether the current oracle price is valid or not

### \_setCeilingBasisPoints

```solidity
function _setCeilingBasisPoints(
    uint256 newCeilingBasisPoints
) internal
```

helper function to set the ceiling in basis points

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `newCeilingBasisPoints` | uint256 |             |

### \_setFloorBasisPoints

```solidity
function _setFloorBasisPoints(
    uint256 newFloorBasisPoints
) internal
```

helper function to set the floor in basis points

#### Parameters

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| `newFloorBasisPoints` | uint256 |             |

### \_validPrice

```solidity
function _validPrice(
    struct Decimal.D256 price
) internal returns (bool valid)
```

helper function to determine if price is within a valid range

#### Parameters

| Name    | Type                | Description |
| ------- | ------------------- | ----------- |
| `price` | struct Decimal.D256 |             |

### \_validatePriceRange

```solidity
function _validatePriceRange(
    struct Decimal.D256 price
) internal
```

reverts if the price is greater than or equal to the ceiling or less than or equal to the floor

#### Parameters

| Name    | Type                | Description |
| ------- | ------------------- | ----------- |
| `price` | struct Decimal.D256 |             |


# PSMRouter

the PSM router is an ungoverned, non custodial contract that allows user to seamlessly wrap and unwrap their WETH for trading against the PegStabilityModule.

## Functions

### constructor

```solidity
function constructor(
    contract IPegStabilityModule _psm,
    contract IChi _chi
) public
```

#### Parameters

| Name   | Type                         | Description |
| ------ | ---------------------------- | ----------- |
| `_psm` | contract IPegStabilityModule |             |
| `_chi` | contract IChi                |             |

### getMintAmountOut

```solidity
function getMintAmountOut(
    uint256 amountIn
) public returns (uint256 amountChiOut)
```

view only pass through function to get amount of CHI out with given amount of ETH in

#### Parameters

| Name       | Type    | Description |
| ---------- | ------- | ----------- |
| `amountIn` | uint256 |             |

### getRedeemAmountOut

```solidity
function getRedeemAmountOut(
    uint256 amountChiIn
) public returns (uint256 amountTokenOut)
```

view only pass through function to get amount of ETH out with given amount of CHI in

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `amountChiIn` | uint256 |             |

### getMaxMintAmountOut

```solidity
function getMaxMintAmountOut() external returns (uint256)
```

the maximum mint amount out

### getMaxRedeemAmountOut

```solidity
function getMaxRedeemAmountOut() external returns (uint256)
```

the maximum redeem amount out

### mint

```solidity
function mint(
    address to,
    uint256 minAmountOut,
    uint256 ethAmountIn
) external returns (uint256)
```

Mints chi to the given address, with a minimum amount required

This wraps ETH and then calls into the PSM to mint the chi. We return the amount of chi minted.

#### Parameters

| Name           | Type    | Description                       |
| -------------- | ------- | --------------------------------- |
| `to`           | address | The address to mint chi to        |
| `minAmountOut` | uint256 | The minimum amount of chi to mint |
| `ethAmountIn`  | uint256 |                                   |

### mint

```solidity
function mint(
    address to,
    uint256 minAmountOut,
    uint256 deadline,
    uint256 ethAmountIn
) external returns (uint256)
```

Mints chi to the given address, with a minimum amount required and a deadline

This wraps ETH and then calls into the PSM to mint the chi. We return the amount of chi minted.

#### Parameters

| Name           | Type    | Description                              |
| -------------- | ------- | ---------------------------------------- |
| `to`           | address | The address to mint chi to               |
| `minAmountOut` | uint256 | The minimum amount of chi to mint        |
| `deadline`     | uint256 | The deadline for this order to be filled |
| `ethAmountIn`  | uint256 |                                          |

### redeem

```solidity
function redeem(
    address to,
    uint256 amountChiIn,
    uint256 minAmountOut
) external returns (uint256)
```

Redeems chi for ETH First pull user CHI into this contract Then call redeem on the PSM to turn the CHI into weth Withdraw all weth to eth in the router Send the eth to the specified recipient

#### Parameters

| Name           | Type    | Description                           |
| -------------- | ------- | ------------------------------------- |
| `to`           | address | the address to receive the eth        |
| `amountChiIn`  | uint256 | the amount of CHI to redeem           |
| `minAmountOut` | uint256 | the minimum amount of weth to receive |

### redeem

```solidity
function redeem(
    address to,
    uint256 amountChiIn,
    uint256 minAmountOut,
    uint256 deadline
) external returns (uint256)
```

Redeems chi for ETH First pull user CHI into this contract Then call redeem on the PSM to turn the CHI into weth Withdraw all weth to eth in the router Send the eth to the specified recipient

#### Parameters

| Name           | Type    | Description                              |
| -------------- | ------- | ---------------------------------------- |
| `to`           | address | the address to receive the eth           |
| `amountChiIn`  | uint256 | the amount of CHI to redeem              |
| `minAmountOut` | uint256 | the minimum amount of weth to receive    |
| `deadline`     | uint256 | The deadline for this order to be filled |

### fallback

```solidity
function fallback() external
```

function to receive ether from the weth contract when the redeem function is called will not accept eth unless there is an active redemption.

### \_mint

```solidity
function _mint(
    address _to,
    uint256 _minAmountOut,
    uint256 _ethAmountIn
) internal returns (uint256)
```

helper function to wrap eth and handle mint call to PSM

#### Parameters

| Name            | Type    | Description |
| --------------- | ------- | ----------- |
| `_to`           | address |             |
| `_minAmountOut` | uint256 |             |
| `_ethAmountIn`  | uint256 |             |

### \_redeem

```solidity
function _redeem(
    address to,
    uint256 amountChiIn,
    uint256 minAmountOut
) internal returns (uint256 amountOut)
```

helper function to deposit user CHI, unwrap weth and send eth to the user the PSM router receives the weth, then sends it to the specified recipient.

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `to`           | address |             |
| `amountChiIn`  | uint256 |             |
| `minAmountOut` | uint256 |             |


# Refs


# CoreRef

defines some modifiers and utilities around interacting with Core

## Functions

### constructor

```solidity
function constructor(
    address coreAddress
) internal
```

#### Parameters

| Name          | Type    | Description |
| ------------- | ------- | ----------- |
| `coreAddress` | address |             |

### \_initialize

```solidity
function _initialize(
    address 
) internal
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \`\` | address |             |

### setContractAdminRole

```solidity
function setContractAdminRole(
    bytes32 newContractAdminRole
) external
```

sets a new admin role for this contract

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newContractAdminRole` | bytes32 |             |

### isContractAdmin

```solidity
function isContractAdmin(
    address _admin
) public returns (bool)
```

returns whether a given address has the admin role for this contract

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `_admin` | address |             |

### pause

```solidity
function pause() public
```

set pausable methods to paused

### unpause

```solidity
function unpause() public
```

set pausable methods to unpaused

### core

```solidity
function core() public returns (contract ICore)
```

address of the Core contract referenced

#### Return Values

| Name  | Type           | Description                  |
| ----- | -------------- | ---------------------------- |
| `[0]` | contract ICore | ICore implementation address |

### chi

```solidity
function chi() public returns (contract IChi)
```

address of the Chi contract referenced by Core

#### Return Values

| Name  | Type          | Description                 |
| ----- | ------------- | --------------------------- |
| `[0]` | contract IChi | IChi implementation address |

### zen

```solidity
function zen() public returns (contract IERC20)
```

address of the Zen contract referenced by Core

#### Return Values

| Name  | Type            | Description                   |
| ----- | --------------- | ----------------------------- |
| `[0]` | contract IERC20 | IERC20 implementation address |

### chiBalance

```solidity
function chiBalance() public returns (uint256)
```

chi balance of contract

#### Return Values

| Name  | Type    | Description     |
| ----- | ------- | --------------- |
| `[0]` | uint256 | chi amount held |

### zenBalance

```solidity
function zenBalance() public returns (uint256)
```

zen balance of contract

#### Return Values

| Name  | Type    | Description     |
| ----- | ------- | --------------- |
| `[0]` | uint256 | zen amount held |

### \_burnChiHeld

```solidity
function _burnChiHeld() internal
```

### \_mintChi

```solidity
function _mintChi(
    address to,
    uint256 amount
) internal
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### \_setContractAdminRole

```solidity
function _setContractAdminRole(
    bytes32 newContractAdminRole
) internal
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newContractAdminRole` | bytes32 |             |


# ICoreRef

## Functions

### setContractAdminRole

```solidity
function setContractAdminRole(
    bytes32 newContractAdminRole
) external
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newContractAdminRole` | bytes32 |             |

### pause

```solidity
function pause() external
```

### unpause

```solidity
function unpause() external
```

### core

```solidity
function core() external returns (contract ICore)
```

### chi

```solidity
function chi() external returns (contract IChi)
```

### zen

```solidity
function zen() external returns (contract IERC20)
```

### chiBalance

```solidity
function chiBalance() external returns (uint256)
```

### zenBalance

```solidity
function zenBalance() external returns (uint256)
```

### CONTRACT\_ADMIN\_ROLE

```solidity
function CONTRACT_ADMIN_ROLE() external returns (bytes32)
```

### isContractAdmin

```solidity
function isContractAdmin(
    address admin
) external returns (bool)
```

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `admin` | address |             |

## Events

### CoreUpdate

```solidity
event CoreUpdate(
    address oldCore,
    address newCore
)
```

#### Parameters

| Name                        | Type    | Description |
| --------------------------- | ------- | ----------- |
| `oldCore`                   | address |             |
| `newCore`                   | address |             |
| ### ContractAdminRoleUpdate |         |             |

```solidity
event ContractAdminRoleUpdate(
    bytes32 oldContractAdminRole,
    bytes32 newContractAdminRole
)
```

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `oldContractAdminRole` | bytes32 |             |
| `newContractAdminRole` | bytes32 |             |


# IOracleRef

## Functions

### updateOracle

```solidity
function updateOracle() external
```

### setOracle

```solidity
function setOracle(
    address newOracle
) external
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `newOracle` | address |             |

### setBackupOracle

```solidity
function setBackupOracle(
    address newBackupOracle
) external
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `newBackupOracle` | address |             |

### setDecimalsNormalizer

```solidity
function setDecimalsNormalizer(
    int256 newDecimalsNormalizer
) external
```

#### Parameters

| Name                    | Type   | Description |
| ----------------------- | ------ | ----------- |
| `newDecimalsNormalizer` | int256 |             |

### setDoInvert

```solidity
function setDoInvert(
    bool newDoInvert
) external
```

#### Parameters

| Name          | Type | Description |
| ------------- | ---- | ----------- |
| `newDoInvert` | bool |             |

### oracle

```solidity
function oracle() external returns (contract IOracle)
```

### backupOracle

```solidity
function backupOracle() external returns (contract IOracle)
```

### doInvert

```solidity
function doInvert() external returns (bool)
```

### decimalsNormalizer

```solidity
function decimalsNormalizer() external returns (int256)
```

### readOracle

```solidity
function readOracle() external returns (struct Decimal.D256)
```

### invert

```solidity
function invert(
    struct Decimal.D256 price
) external returns (struct Decimal.D256)
```

#### Parameters

| Name    | Type                | Description |
| ------- | ------------------- | ----------- |
| `price` | struct Decimal.D256 |             |

## Events

### OracleUpdate

```solidity
event OracleUpdate(
    address oldOracle,
    address newOracle
)
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `oldOracle`      | address |             |
| `newOracle`      | address |             |
| ### InvertUpdate |         |             |

```solidity
event InvertUpdate(
    bool oldDoInvert,
    bool newDoInvert
)
```

#### Parameters

| Name                         | Type | Description |
| ---------------------------- | ---- | ----------- |
| `oldDoInvert`                | bool |             |
| `newDoInvert`                | bool |             |
| ### DecimalsNormalizerUpdate |      |             |

```solidity
event DecimalsNormalizerUpdate(
    int256 oldDecimalsNormalizer,
    int256 newDecimalsNormalizer
)
```

#### Parameters

| Name                    | Type   | Description |
| ----------------------- | ------ | ----------- |
| `oldDecimalsNormalizer` | int256 |             |
| `newDecimalsNormalizer` | int256 |             |
| ### BackupOracleUpdate  |        |             |

```solidity
event BackupOracleUpdate(
    address oldBackupOracle,
    address newBackupOracle
)
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `oldBackupOracle` | address |             |
| `newBackupOracle` | address |             |


# IUniRef

## Functions

### setPair

```solidity
function setPair(
    address newPair
) external
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `newPair` | address |             |

### pair

```solidity
function pair() external returns (contract IUniswapV2Pair)
```

### token

```solidity
function token() external returns (address)
```

### getReserves

```solidity
function getReserves() external returns (uint256 chiReserves, uint256 tokenReserves)
```

## Events

### PairUpdate

```solidity
event PairUpdate(
    address oldPair,
    address newPair
)
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `oldPair` | address |             |
| `newPair` | address |             |


# OracleRef

defines some utilities around interacting with the referenced oracle

## Functions

### constructor

```solidity
function constructor(
    address _core,
    address _oracle,
    address _backupOracle,
    int256 _decimalsNormalizer,
    bool _doInvert
) internal
```

OracleRef constructor

#### Parameters

| Name                  | Type    | Description                                                  |
| --------------------- | ------- | ------------------------------------------------------------ |
| `_core`               | address | Chi Core to reference                                        |
| `_oracle`             | address | oracle to reference                                          |
| `_backupOracle`       | address | backup oracle to reference                                   |
| `_decimalsNormalizer` | int256  | number of decimals to normalize the oracle feed if necessary |
| `_doInvert`           | bool    | invert the oracle price if this flag is on                   |

### setOracle

```solidity
function setOracle(
    address newOracle
) external
```

sets the referenced oracle

#### Parameters

| Name        | Type    | Description                 |
| ----------- | ------- | --------------------------- |
| `newOracle` | address | the new oracle to reference |

### setDoInvert

```solidity
function setDoInvert(
    bool newDoInvert
) external
```

sets the flag for whether to invert or not

#### Parameters

| Name          | Type | Description                        |
| ------------- | ---- | ---------------------------------- |
| `newDoInvert` | bool | the new flag for whether to invert |

### setDecimalsNormalizer

```solidity
function setDecimalsNormalizer(
    int256 newDecimalsNormalizer
) external
```

sets the new decimalsNormalizer

#### Parameters

| Name                    | Type   | Description                |
| ----------------------- | ------ | -------------------------- |
| `newDecimalsNormalizer` | int256 | the new decimalsNormalizer |

### setBackupOracle

```solidity
function setBackupOracle(
    address newBackupOracle
) external
```

sets the referenced backup oracle

#### Parameters

| Name              | Type    | Description                        |
| ----------------- | ------- | ---------------------------------- |
| `newBackupOracle` | address | the new backup oracle to reference |

### invert

```solidity
function invert(
    struct Decimal.D256 price
) public returns (struct Decimal.D256)
```

invert a peg price

the inverted peg would be X per CHI

#### Parameters

| Name    | Type                | Description             |
| ------- | ------------------- | ----------------------- |
| `price` | struct Decimal.D256 | the peg price to invert |

#### Return Values

| Name  | Type                | Description                   |
| ----- | ------------------- | ----------------------------- |
| `[0]` | struct Decimal.D256 | the inverted peg as a Decimal |

### updateOracle

```solidity
function updateOracle() public
```

updates the referenced oracle

### readOracle

```solidity
function readOracle() public returns (struct Decimal.D256)
```

the peg price of the referenced oracle

the peg is defined as CHI per X with X being ETH, dollars, etc

#### Return Values

| Name  | Type                | Description          |
| ----- | ------------------- | -------------------- |
| `[0]` | struct Decimal.D256 | the peg as a Decimal |

### \_setOracle

```solidity
function _setOracle(
    address newOracle
) internal
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `newOracle` | address |             |

### \_setBackupOracle

```solidity
function _setBackupOracle(
    address newBackupOracle
) internal
```

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `newBackupOracle` | address |             |

### \_setDoInvert

```solidity
function _setDoInvert(
    bool newDoInvert
) internal
```

#### Parameters

| Name          | Type | Description |
| ------------- | ---- | ----------- |
| `newDoInvert` | bool |             |

### \_setDecimalsNormalizer

```solidity
function _setDecimalsNormalizer(
    int256 newDecimalsNormalizer
) internal
```

#### Parameters

| Name                    | Type   | Description |
| ----------------------- | ------ | ----------- |
| `newDecimalsNormalizer` | int256 |             |

### \_setDecimalsNormalizerFromToken

```solidity
function _setDecimalsNormalizerFromToken(
    address token
) internal
```

#### Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| `token` | address |             |


# UniRef

defines some utilities around interacting with Uniswap

the uniswap pair should be CHI and another asset

## Functions

### constructor

```solidity
function constructor(
    address _core,
    address _pair,
    address _oracle,
    address _backupOracle
) internal
```

UniRef constructor

#### Parameters

| Name            | Type    | Description                |
| --------------- | ------- | -------------------------- |
| `_core`         | address | Chi Core to reference      |
| `_pair`         | address | Uniswap pair to reference  |
| `_oracle`       | address | oracle to reference        |
| `_backupOracle` | address | backup oracle to reference |

### setPair

```solidity
function setPair(
    address newPair
) external
```

set the new pair contract

#### Parameters

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| `newPair` | address | the new pair |

### getReserves

```solidity
function getReserves() public returns (uint256 chiReserves, uint256 tokenReserves)
```

pair reserves with chi listed first

### \_setupPair

```solidity
function _setupPair(
    address newPair
) internal
```

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `newPair` | address |             |

### \_token

```solidity
function _token() internal returns (address)
```


# Timelocks


# ITimelockedDelegator

## IZen

### Functions

#### delegate

```solidity
function delegate(
    address delegatee
) external
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegatee` | address |             |

## ITimelockedDelegator

### Functions

#### delegate

```solidity
function delegate(
    address delegatee,
    uint256 amount
) external
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegatee` | address |             |
| `amount`    | uint256 |             |

#### undelegate

```solidity
function undelegate(
    address delegatee
) external returns (uint256)
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegatee` | address |             |

#### delegateContract

```solidity
function delegateContract(
    address delegatee
) external returns (address)
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegatee` | address |             |

#### delegateAmount

```solidity
function delegateAmount(
    address delegatee
) external returns (uint256)
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegatee` | address |             |

#### totalDelegated

```solidity
function totalDelegated() external returns (uint256)
```

#### zen

```solidity
function zen() external returns (contract IZen)
```

### Events

#### Delegate

```solidity
event Delegate(
    address _delegatee,
    uint256 _amount
)
```

**Parameters**

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `_delegatee`   | address |             |
| `_amount`      | uint256 |             |
| ### Undelegate |         |             |

```solidity
event Undelegate(
    address _delegatee,
    uint256 _amount
)
```

**Parameters**

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| `_delegatee` | address |             |
| `_amount`    | uint256 |             |


# ITokenTimelock

## Functions

### release

```solidity
function release(
    address to,
    uint256 amount
) external
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### releaseMax

```solidity
function releaseMax(
    address to
) external
```

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| `to` | address |             |

### setPendingBeneficiary

```solidity
function setPendingBeneficiary(
    address _pendingBeneficiary
) external
```

#### Parameters

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| `_pendingBeneficiary` | address |             |

### acceptBeneficiary

```solidity
function acceptBeneficiary() external
```

### lockedToken

```solidity
function lockedToken() external returns (contract IERC20)
```

### beneficiary

```solidity
function beneficiary() external returns (address)
```

### pendingBeneficiary

```solidity
function pendingBeneficiary() external returns (address)
```

### initialBalance

```solidity
function initialBalance() external returns (uint256)
```

### availableForRelease

```solidity
function availableForRelease() external returns (uint256)
```

### totalToken

```solidity
function totalToken() external returns (uint256)
```

### alreadyReleasedAmount

```solidity
function alreadyReleasedAmount() external returns (uint256)
```

## Events

### Release

```solidity
event Release(
    address _beneficiary,
    address _recipient,
    uint256 _amount
)
```

#### Parameters

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| `_beneficiary`        | address |             |
| `_recipient`          | address |             |
| `_amount`             | uint256 |             |
| ### BeneficiaryUpdate |         |             |

```solidity
event BeneficiaryUpdate(
    address _beneficiary
)
```

#### Parameters

| Name                         | Type    | Description |
| ---------------------------- | ------- | ----------- |
| `_beneficiary`               | address |             |
| ### PendingBeneficiaryUpdate |         |             |

```solidity
event PendingBeneficiaryUpdate(
    address _pendingBeneficiary
)
```

#### Parameters

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| `_pendingBeneficiary` | address |             |


# LinearTimelockedDelegator

## IVotingToken

### Functions

#### delegate

```solidity
function delegate(
    address delegatee
) external
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegatee` | address |             |

## LinearTimelockedDelegator

allows the timelocked tokens to be delegated by the beneficiary while locked

### Functions

#### constructor

```solidity
function constructor(
    address _beneficiary,
    uint256 _duration,
    address _token,
    uint256 _cliff,
    address _clawbackAdmin,
    uint256 _startTime
) public
```

LinearTimelockedDelegator constructor

**Parameters**

| Name             | Type    | Description                                                        |
| ---------------- | ------- | ------------------------------------------------------------------ |
| `_beneficiary`   | address | admin, and timelock beneficiary                                    |
| `_duration`      | uint256 | duration of the token timelock window                              |
| `_token`         | address | the token address                                                  |
| `_cliff`         | uint256 | the seconds before first claim is allowed                          |
| `_clawbackAdmin` | address | the address which can trigger a clawback                           |
| `_startTime`     | uint256 | the unix epoch for starting timelock. Use 0 to start at deployment |

#### acceptBeneficiary

```solidity
function acceptBeneficiary() public
```

accept beneficiary role over timelocked ZEN

\_setBeneficiary internal call checks msg.sender == pendingBeneficiary

#### delegate

```solidity
function delegate(
    address to
) public
```

delegate all held ZEN to the `to` address

**Parameters**

| Name | Type    | Description |
| ---- | ------- | ----------- |
| `to` | address |             |


# LinearTokenTimelock

## Functions

### constructor

```solidity
function constructor(
    address _beneficiary,
    uint256 _duration,
    address _lockedToken,
    uint256 _cliffDuration,
    address _clawbackAdmin,
    uint256 _startTime
) public
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `_beneficiary`   | address |             |
| `_duration`      | uint256 |             |
| `_lockedToken`   | address |             |
| `_cliffDuration` | uint256 |             |
| `_clawbackAdmin` | address |             |
| `_startTime`     | uint256 |             |

### \_proportionAvailable

```solidity
function _proportionAvailable(
    uint256 initialBalance,
    uint256 elapsed,
    uint256 duration
) internal returns (uint256)
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `initialBalance` | uint256 |             |
| `elapsed`        | uint256 |             |
| `duration`       | uint256 |             |


# QuadraticTimelockedDelegator

## IVotingToken

### Functions

#### delegate

```solidity
function delegate(
    address delegatee
) external
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegatee` | address |             |

## QuadraticTimelockedDelegator

allows the timelocked tokens to be delegated by the beneficiary while locked

### Functions

#### constructor

```solidity
function constructor(
    address _token,
    address _beneficiary,
    uint256 _duration,
    uint256 _cliff,
    address _clawbackAdmin,
    uint256 _startTime
) public
```

QuadraticTimelockedDelegator constructor

**Parameters**

| Name             | Type    | Description                                                        |
| ---------------- | ------- | ------------------------------------------------------------------ |
| `_token`         | address | the token address                                                  |
| `_beneficiary`   | address | admin, and timelock beneficiary                                    |
| `_duration`      | uint256 | duration of the token timelock window                              |
| `_cliff`         | uint256 | the seconds before first claim is allowed                          |
| `_clawbackAdmin` | address | the address which can trigger a clawback                           |
| `_startTime`     | uint256 | the unix epoch for starting timelock. Use 0 to start at deployment |

#### acceptBeneficiary

```solidity
function acceptBeneficiary() public
```

accept beneficiary role over timelocked ZEN

#### delegate

```solidity
function delegate(
    address to
) public
```

delegate all held ZEN to the `to` address

**Parameters**

| Name | Type    | Description |
| ---- | ------- | ----------- |
| `to` | address |             |


# QuadraticTimelockedSubdelegator

## Delegatee

### Functions

#### constructor

```solidity
function constructor(
    address _delegatee,
    address _zen
) public
```

Delegatee constructor

**Parameters**

| Name         | Type    | Description                    |
| ------------ | ------- | ------------------------------ |
| `_delegatee` | address | the address to delegate ZEN to |
| `_zen`       | address | the ZEN token address          |

#### withdraw

```solidity
function withdraw() public
```

send ZEN back to timelock and selfdestruct

## QuadtraticTimelockedSubdelegator

allows the timelocked ZEN to be delegated by the beneficiary while locked

### Functions

#### constructor

```solidity
function constructor(
    address _beneficiary,
    uint256 _duration,
    address _zen,
    uint256 _cliff,
    uint256 _startTime
) public
```

Delegatee constructor

clawback admin needs to be 0 because clawbacks can be bricked by beneficiary

**Parameters**

| Name           | Type    | Description                                       |
| -------------- | ------- | ------------------------------------------------- |
| `_beneficiary` | address | default delegate, admin, and timelock beneficiary |
| `_duration`    | uint256 | duration of the token timelock window             |
| `_zen`         | address | the ZEN token address                             |
| `_cliff`       | uint256 | the seconds before first claim is allowed         |
| `_startTime`   | uint256 | the initial time to use for timelock              |

#### delegate

```solidity
function delegate(
    address delegatee,
    uint256 amount
) public
```

delegate locked ZEN to a delegatee

**Parameters**

| Name        | Type    | Description                                                          |
| ----------- | ------- | -------------------------------------------------------------------- |
| `delegatee` | address | the target address to delegate to                                    |
| `amount`    | uint256 | the amount of ZEN to delegate. Will increment existing delegated ZEN |

#### undelegate

```solidity
function undelegate(
    address delegatee
) public returns (uint256)
```

return delegated ZEN to the timelock

**Parameters**

| Name        | Type    | Description                           |
| ----------- | ------- | ------------------------------------- |
| `delegatee` | address | the target address to undelegate from |

**Return Values**

| Name  | Type    | Description                |
| ----- | ------- | -------------------------- |
| `[0]` | uint256 | the amount of ZEN returned |

#### totalToken

```solidity
function totalToken() public returns (uint256)
```

calculate total ZEN held plus delegated

used by LinearTokenTimelock to determine the released amount

#### acceptBeneficiary

```solidity
function acceptBeneficiary() public
```

accept beneficiary role over timelocked ZEN. Delegates all held (non-subdelegated) zen to beneficiary

#### \_zenBalance

```solidity
function _zenBalance() internal returns (uint256)
```


# QuadraticTokenTimelock

## Functions

### constructor

```solidity
function constructor(
    address _beneficiary,
    uint256 _duration,
    address _lockedToken,
    uint256 _cliffDuration,
    address _clawbackAdmin,
    uint256 _startTime
) public
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `_beneficiary`   | address |             |
| `_duration`      | uint256 |             |
| `_lockedToken`   | address |             |
| `_cliffDuration` | uint256 |             |
| `_clawbackAdmin` | address |             |
| `_startTime`     | uint256 |             |

### \_proportionAvailable

```solidity
function _proportionAvailable(
    uint256 initialBalance,
    uint256 elapsed,
    uint256 duration
) internal returns (uint256)
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `initialBalance` | uint256 |             |
| `elapsed`        | uint256 |             |
| `duration`       | uint256 |             |


# TimelockedDelegator

## Delegatee

### Functions

#### constructor

```solidity
function constructor(
    address _delegatee,
    address _zen
) public
```

Delegatee constructor

**Parameters**

| Name         | Type    | Description                    |
| ------------ | ------- | ------------------------------ |
| `_delegatee` | address | the address to delegate ZEN to |
| `_zen`       | address | the ZEN token address          |

#### withdraw

```solidity
function withdraw() public
```

send ZEN back to timelock and selfdestruct

## TimelockedDelegator

allows the timelocked ZEN to be delegated by the beneficiary while locked

### Functions

#### constructor

```solidity
function constructor(
    address _zen,
    address _beneficiary,
    uint256 _duration
) public
```

Delegatee constructor

**Parameters**

| Name           | Type    | Description                                       |
| -------------- | ------- | ------------------------------------------------- |
| `_zen`         | address | the ZEN token address                             |
| `_beneficiary` | address | default delegate, admin, and timelock beneficiary |
| `_duration`    | uint256 | duration of the token timelock window             |

#### delegate

```solidity
function delegate(
    address delegatee,
    uint256 amount
) public
```

delegate locked ZEN to a delegatee

**Parameters**

| Name        | Type    | Description                                                          |
| ----------- | ------- | -------------------------------------------------------------------- |
| `delegatee` | address | the target address to delegate to                                    |
| `amount`    | uint256 | the amount of ZEN to delegate. Will increment existing delegated ZEN |

#### undelegate

```solidity
function undelegate(
    address delegatee
) public returns (uint256)
```

return delegated ZEN to the timelock

**Parameters**

| Name        | Type    | Description                           |
| ----------- | ------- | ------------------------------------- |
| `delegatee` | address | the target address to undelegate from |

**Return Values**

| Name  | Type    | Description                |
| ----- | ------- | -------------------------- |
| `[0]` | uint256 | the amount of ZEN returned |

#### totalToken

```solidity
function totalToken() public returns (uint256)
```

calculate total ZEN held plus delegated

used by LinearTokenTimelock to determine the released amount

#### acceptBeneficiary

```solidity
function acceptBeneficiary() public
```

accept beneficiary role over timelocked ZEN. Delegates all held (non-subdelegated) zen to beneficiary

#### \_zenBalance

```solidity
function _zenBalance() internal returns (uint256)
```


# TokenTimelock

## Functions

### constructor

```solidity
function constructor(
    address _beneficiary,
    uint256 _duration,
    uint256 _cliffSeconds,
    address _lockedToken,
    address _clawbackAdmin
) internal
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `_beneficiary`   | address |             |
| `_duration`      | uint256 |             |
| `_cliffSeconds`  | uint256 |             |
| `_lockedToken`   | address |             |
| `_clawbackAdmin` | address |             |

### release

```solidity
function release(
    address to,
    uint256 amount
) external
```

releases `amount` unlocked tokens to address `to`

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### releaseMax

```solidity
function releaseMax(
    address to
) external
```

releases maximum unlocked tokens to address `to`

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| `to` | address |             |

### totalToken

```solidity
function totalToken() public returns (uint256)
```

the total amount of tokens held by timelock

### alreadyReleasedAmount

```solidity
function alreadyReleasedAmount() public returns (uint256)
```

amount of tokens released to beneficiary

### availableForRelease

```solidity
function availableForRelease() public returns (uint256)
```

amount of held tokens unlocked and available for release

### setPendingBeneficiary

```solidity
function setPendingBeneficiary(
    address _pendingBeneficiary
) public
```

current beneficiary can appoint new beneficiary, which must be accepted

#### Parameters

| Name                  | Type    | Description |
| --------------------- | ------- | ----------- |
| `_pendingBeneficiary` | address |             |

### acceptBeneficiary

```solidity
function acceptBeneficiary() public
```

pending beneficiary accepts new beneficiary

### clawback

```solidity
function clawback() public
```

### passedCliff

```solidity
function passedCliff() public returns (bool)
```

### \_proportionAvailable

```solidity
function _proportionAvailable(
    uint256 initialBalance,
    uint256 elapsed,
    uint256 duration
) internal returns (uint256)
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `initialBalance` | uint256 |             |
| `elapsed`        | uint256 |             |
| `duration`       | uint256 |             |

### \_setBeneficiary

```solidity
function _setBeneficiary(
    address newBeneficiary
) internal
```

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `newBeneficiary` | address |             |

### \_setLockedToken

```solidity
function _setLockedToken(
    address tokenAddress
) internal
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `tokenAddress` | address |             |

### \_release

```solidity
function _release(
    address to,
    uint256 amount
) internal
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |


# Utils


# RateLimited

## Functions

### constructor

```solidity
function constructor(
    uint256 _maxRateLimitPerSecond,
    uint256 _rateLimitPerSecond,
    uint256 _bufferCap,
    bool _doPartialAction
) internal
```

#### Parameters

| Name                     | Type    | Description |
| ------------------------ | ------- | ----------- |
| `_maxRateLimitPerSecond` | uint256 |             |
| `_rateLimitPerSecond`    | uint256 |             |
| `_bufferCap`             | uint256 |             |
| `_doPartialAction`       | bool    |             |

### setRateLimitPerSecond

```solidity
function setRateLimitPerSecond(
    uint256 newRateLimitPerSecond
) external
```

set the rate limit per second

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `newRateLimitPerSecond` | uint256 |             |

### setBufferCap

```solidity
function setBufferCap(
    uint256 newBufferCap
) external
```

set the buffer cap

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `newBufferCap` | uint256 |             |

### buffer

```solidity
function buffer() public returns (uint256)
```

the amount of action used before hitting limit

replenishes at rateLimitPerSecond per second up to bufferCap

### \_depleteBuffer

```solidity
function _depleteBuffer(
    uint256 amount
) internal returns (uint256)
```

the method that enforces the rate limit. Decreases buffer by "amount". If buffer is <= amount either 1. Does a partial mint by the amount remaining in the buffer or 2. Reverts Depending on whether doPartialAction is true or false

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `amount` | uint256 |             |

### \_setRateLimitPerSecond

```solidity
function _setRateLimitPerSecond(
    uint256 newRateLimitPerSecond
) internal
```

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `newRateLimitPerSecond` | uint256 |             |

### \_setBufferCap

```solidity
function _setBufferCap(
    uint256 newBufferCap
) internal
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `newBufferCap` | uint256 |             |

### \_resetBuffer

```solidity
function _resetBuffer() internal
```

### \_updateBufferStored

```solidity
function _updateBufferStored() internal
```

## Events

### BufferUsed

```solidity
event BufferUsed(
    uint256 amountUsed,
    uint256 bufferRemaining
)
```

#### Parameters

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| `amountUsed`        | uint256 |             |
| `bufferRemaining`   | uint256 |             |
| ### BufferCapUpdate |         |             |

```solidity
event BufferCapUpdate(
    uint256 oldBufferCap,
    uint256 newBufferCap
)
```

#### Parameters

| Name                         | Type    | Description |
| ---------------------------- | ------- | ----------- |
| `oldBufferCap`               | uint256 |             |
| `newBufferCap`               | uint256 |             |
| ### RateLimitPerSecondUpdate |         |             |

```solidity
event RateLimitPerSecondUpdate(
    uint256 oldRateLimitPerSecond,
    uint256 newRateLimitPerSecond
)
```

#### Parameters

| Name                    | Type    | Description |
| ----------------------- | ------- | ----------- |
| `oldRateLimitPerSecond` | uint256 |             |
| `newRateLimitPerSecond` | uint256 |             |


# Zen


# IZenMinter

## IZen

### Functions

#### mint

```solidity
function mint(
    address to,
    uint256 amount
) external
```

**Parameters**

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

#### setMinter

```solidity
function setMinter(
    address newMinter
) external
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `newMinter` | address |             |

## IZenMinter

### Functions

#### poke

```solidity
function poke() external
```

#### setMinter

```solidity
function setMinter(
    address newMinter
) external
```

**Parameters**

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `newMinter` | address |             |

#### mint

```solidity
function mint(
    address to,
    uint256 amount
) external
```

**Parameters**

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

#### setZenTreasury

```solidity
function setZenTreasury(
    address newZenTreasury
) external
```

**Parameters**

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `newZenTreasury` | address |             |

#### setZenRewardsDripper

```solidity
function setZenRewardsDripper(
    address newZenRewardsDripper
) external
```

**Parameters**

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newZenRewardsDripper` | address |             |

#### setAnnualMaxInflationBasisPoints

```solidity
function setAnnualMaxInflationBasisPoints(
    uint256 newAnnualMaxInflationBasisPoints
) external
```

**Parameters**

| Name                               | Type    | Description |
| ---------------------------------- | ------- | ----------- |
| `newAnnualMaxInflationBasisPoints` | uint256 |             |

#### annualMaxInflationBasisPoints

```solidity
function annualMaxInflationBasisPoints() external returns (uint256)
```

#### idealBufferCap

```solidity
function idealBufferCap() external returns (uint256)
```

#### zenCirculatingSupply

```solidity
function zenCirculatingSupply() external returns (uint256)
```

#### totalSupply

```solidity
function totalSupply() external returns (uint256)
```

#### isPokeNeeded

```solidity
function isPokeNeeded() external returns (bool)
```

#### zenTreasury

```solidity
function zenTreasury() external returns (address)
```

#### zenRewardsDripper

```solidity
function zenRewardsDripper() external returns (address)
```

### Events

#### AnnualMaxInflationUpdate

```solidity
event AnnualMaxInflationUpdate(
    uint256 oldAnnualMaxInflationBasisPoints,
    uint256 newAnnualMaxInflationBasisPoints
)
```

**Parameters**

| Name                               | Type    | Description |
| ---------------------------------- | ------- | ----------- |
| `oldAnnualMaxInflationBasisPoints` | uint256 |             |
| `newAnnualMaxInflationBasisPoints` | uint256 |             |
| ### ZenTreasuryUpdate              |         |             |

```solidity
event ZenTreasuryUpdate(
    address oldZenTreasury,
    address newZenTreasury
)
```

**Parameters**

| Name                        | Type    | Description |
| --------------------------- | ------- | ----------- |
| `oldZenTreasury`            | address |             |
| `newZenTreasury`            | address |             |
| ### ZenRewardsDripperUpdate |         |             |

```solidity
event ZenRewardsDripperUpdate(
    address oldZenRewardsDripper,
    address newZenRewardsDripper
)
```

**Parameters**

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `oldZenRewardsDripper` | address |             |
| `newZenRewardsDripper` | address |             |


# Zen

## Functions

### constructor

```solidity
function constructor(
    address account,
    address minter_
) public
```

Construct a new Zen token

#### Parameters

| Name      | Type    | Description                                 |
| --------- | ------- | ------------------------------------------- |
| `account` | address | The initial account to grant all the tokens |
| `minter_` | address | The account with minting ability            |

### setMinter

```solidity
function setMinter(
    address minter_
) external
```

Change the minter address

#### Parameters

| Name      | Type    | Description                   |
| --------- | ------- | ----------------------------- |
| `minter_` | address | The address of the new minter |

### mint

```solidity
function mint(
    address dst,
    uint256 rawAmount
) external
```

Mint new tokens

#### Parameters

| Name        | Type    | Description                            |
| ----------- | ------- | -------------------------------------- |
| `dst`       | address | The address of the destination account |
| `rawAmount` | uint256 | The number of tokens to be minted      |

### allowance

```solidity
function allowance(
    address account,
    address spender
) external returns (uint256)
```

Get the number of tokens `spender` is approved to spend on behalf of `account`

#### Parameters

| Name      | Type    | Description                                   |
| --------- | ------- | --------------------------------------------- |
| `account` | address | The address of the account holding the funds  |
| `spender` | address | The address of the account spending the funds |

#### Return Values

| Name  | Type    | Description                   |
| ----- | ------- | ----------------------------- |
| `[0]` | uint256 | The number of tokens approved |

### approve

```solidity
function approve(
    address spender,
    uint256 rawAmount
) external returns (bool)
```

Approve `spender` to transfer up to `amount` from `src`

This will overwrite the approval amount for `spender` and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)

#### Parameters

| Name        | Type    | Description                                                     |
| ----------- | ------- | --------------------------------------------------------------- |
| `spender`   | address | The address of the account which may transfer tokens            |
| `rawAmount` | uint256 | The number of tokens that are approved (2^256-1 means infinite) |

#### Return Values

| Name  | Type | Description                           |
| ----- | ---- | ------------------------------------- |
| `[0]` | bool | Whether or not the approval succeeded |

### permit

```solidity
function permit(
    address owner,
    address spender,
    uint256 rawAmount,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
) external
```

Triggers an approval from owner to spends

#### Parameters

| Name        | Type    | Description                                                     |
| ----------- | ------- | --------------------------------------------------------------- |
| `owner`     | address | The address to approve from                                     |
| `spender`   | address | The address to be approved                                      |
| `rawAmount` | uint256 | The number of tokens that are approved (2^256-1 means infinite) |
| `deadline`  | uint256 | The time at which to expire the signature                       |
| `v`         | uint8   | The recovery byte of the signature                              |
| `r`         | bytes32 | Half of the ECDSA signature pair                                |
| `s`         | bytes32 | Half of the ECDSA signature pair                                |

### balanceOf

```solidity
function balanceOf(
    address account
) external returns (uint256)
```

Get the number of tokens held by the `account`

#### Parameters

| Name      | Type    | Description                                      |
| --------- | ------- | ------------------------------------------------ |
| `account` | address | The address of the account to get the balance of |

#### Return Values

| Name  | Type    | Description               |
| ----- | ------- | ------------------------- |
| `[0]` | uint256 | The number of tokens held |

### transfer

```solidity
function transfer(
    address dst,
    uint256 rawAmount
) external returns (bool)
```

Transfer `amount` tokens from `msg.sender` to `dst`

#### Parameters

| Name        | Type    | Description                            |
| ----------- | ------- | -------------------------------------- |
| `dst`       | address | The address of the destination account |
| `rawAmount` | uint256 | The number of tokens to transfer       |

#### Return Values

| Name  | Type | Description                           |
| ----- | ---- | ------------------------------------- |
| `[0]` | bool | Whether or not the transfer succeeded |

### transferFrom

```solidity
function transferFrom(
    address src,
    address dst,
    uint256 rawAmount
) external returns (bool)
```

Transfer `amount` tokens from `src` to `dst`

#### Parameters

| Name        | Type    | Description                            |
| ----------- | ------- | -------------------------------------- |
| `src`       | address | The address of the source account      |
| `dst`       | address | The address of the destination account |
| `rawAmount` | uint256 | The number of tokens to transfer       |

#### Return Values

| Name  | Type | Description                           |
| ----- | ---- | ------------------------------------- |
| `[0]` | bool | Whether or not the transfer succeeded |

### delegate

```solidity
function delegate(
    address delegatee
) public
```

Delegate votes from `msg.sender` to `delegatee`

#### Parameters

| Name        | Type    | Description                      |
| ----------- | ------- | -------------------------------- |
| `delegatee` | address | The address to delegate votes to |

### delegateBySig

```solidity
function delegateBySig(
    address delegatee,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
) public
```

Delegates votes from signatory to `delegatee`

#### Parameters

| Name        | Type    | Description                                        |
| ----------- | ------- | -------------------------------------------------- |
| `delegatee` | address | The address to delegate votes to                   |
| `nonce`     | uint256 | The contract state required to match the signature |
| `expiry`    | uint256 | The time at which to expire the signature          |
| `v`         | uint8   | The recovery byte of the signature                 |
| `r`         | bytes32 | Half of the ECDSA signature pair                   |
| `s`         | bytes32 | Half of the ECDSA signature pair                   |

### getCurrentVotes

```solidity
function getCurrentVotes(
    address account
) external returns (uint96)
```

Gets the current votes balance for `account`

#### Parameters

| Name      | Type    | Description                      |
| --------- | ------- | -------------------------------- |
| `account` | address | The address to get votes balance |

#### Return Values

| Name  | Type   | Description                               |
| ----- | ------ | ----------------------------------------- |
| `[0]` | uint96 | The number of current votes for `account` |

### getPriorVotes

```solidity
function getPriorVotes(
    address account,
    uint256 blockNumber
) public returns (uint96)
```

Determine the prior number of votes for an account as of a block number

Block number must be a finalized block or else this function will revert to prevent misinformation.

#### Parameters

| Name          | Type    | Description                                 |
| ------------- | ------- | ------------------------------------------- |
| `account`     | address | The address of the account to check         |
| `blockNumber` | uint256 | The block number to get the vote balance at |

#### Return Values

| Name  | Type   | Description                                               |
| ----- | ------ | --------------------------------------------------------- |
| `[0]` | uint96 | The number of votes the account had as of the given block |

### \_delegate

```solidity
function _delegate(
    address delegator,
    address delegatee
) internal
```

#### Parameters

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| `delegator` | address |             |
| `delegatee` | address |             |

### \_transferTokens

```solidity
function _transferTokens(
    address src,
    address dst,
    uint96 amount
) internal
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `src`    | address |             |
| `dst`    | address |             |
| `amount` | uint96  |             |

### \_moveDelegates

```solidity
function _moveDelegates(
    address srcRep,
    address dstRep,
    uint96 amount
) internal
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `srcRep` | address |             |
| `dstRep` | address |             |
| `amount` | uint96  |             |

### \_writeCheckpoint

```solidity
function _writeCheckpoint(
    address delegatee,
    uint32 nCheckpoints,
    uint96 oldVotes,
    uint96 newVotes
) internal
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `delegatee`    | address |             |
| `nCheckpoints` | uint32  |             |
| `oldVotes`     | uint96  |             |
| `newVotes`     | uint96  |             |

### safe32

```solidity
function safe32(
    uint256 n,
    string errorMessage
) internal returns (uint32)
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `n`            | uint256 |             |
| `errorMessage` | string  |             |

### safe96

```solidity
function safe96(
    uint256 n,
    string errorMessage
) internal returns (uint96)
```

#### Parameters

| Name           | Type    | Description |
| -------------- | ------- | ----------- |
| `n`            | uint256 |             |
| `errorMessage` | string  |             |

### add96

```solidity
function add96(
    uint96 a,
    uint96 b,
    string errorMessage
) internal returns (uint96)
```

#### Parameters

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| `a`            | uint96 |             |
| `b`            | uint96 |             |
| `errorMessage` | string |             |

### sub96

```solidity
function sub96(
    uint96 a,
    uint96 b,
    string errorMessage
) internal returns (uint96)
```

#### Parameters

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| `a`            | uint96 |             |
| `b`            | uint96 |             |
| `errorMessage` | string |             |

### getChainId

```solidity
function getChainId() internal returns (uint256)
```

## Events

### MinterChanged

```solidity
event MinterChanged(
    address minter,
    address newMinter
)
```

An event thats emitted when the minter address is changed

#### Parameters

| Name                | Type    | Description |
| ------------------- | ------- | ----------- |
| `minter`            | address |             |
| `newMinter`         | address |             |
| ### DelegateChanged |         |             |

```solidity
event DelegateChanged(
    address delegator,
    address fromDelegate,
    address toDelegate
)
```

An event thats emitted when an account changes its delegate

#### Parameters

| Name                     | Type    | Description |
| ------------------------ | ------- | ----------- |
| `delegator`              | address |             |
| `fromDelegate`           | address |             |
| `toDelegate`             | address |             |
| ### DelegateVotesChanged |         |             |

```solidity
event DelegateVotesChanged(
    address delegate,
    uint256 previousBalance,
    uint256 newBalance
)
```

An event thats emitted when a delegate account's vote balance changes

#### Parameters

| Name              | Type    | Description |
| ----------------- | ------- | ----------- |
| `delegate`        | address |             |
| `previousBalance` | uint256 |             |
| `newBalance`      | uint256 |             |
| ### Transfer      |         |             |

```solidity
event Transfer(
    address from,
    address to,
    uint256 amount
)
```

The standard EIP-20 transfer event

#### Parameters

| Name         | Type    | Description |
| ------------ | ------- | ----------- |
| `from`       | address |             |
| `to`         | address |             |
| `amount`     | uint256 |             |
| ### Approval |         |             |

```solidity
event Approval(
    address owner,
    address spender,
    uint256 amount
)
```

The standard EIP-20 approval event

#### Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| `owner`   | address |             |
| `spender` | address |             |
| `amount`  | uint256 |             |


# ZenMinter

## Functions

### constructor

```solidity
function constructor(
    address _core,
    uint256 _annualMaxInflationBasisPoints,
    address _owner,
    address _zenTreasury,
    address _zenRewardsDripper
) public
```

Zen Reserve Stabilizer constructor

#### Parameters

| Name                             | Type    | Description                                                                    |
| -------------------------------- | ------- | ------------------------------------------------------------------------------ |
| `_core`                          | address | Chi Core to reference                                                          |
| `_annualMaxInflationBasisPoints` | uint256 | the max inflation in ZEN circulating supply per year in basis points (1/10000) |
| `_owner`                         | address | the owner, capable of changing the zen minter address.                         |
| `_zenTreasury`                   | address | the zen treasury address used to exclude from circulating supply               |
| `_zenRewardsDripper`             | address | the zen rewards dripper address used to exclude from circulating supply        |

### poke

```solidity
function poke() public
```

update the rate limit per second and buffer cap

### setRateLimitPerSecond

```solidity
function setRateLimitPerSecond(
    uint256 
) external
```

no-op, reverts. Prevent admin or governor from overwriting ideal rate limit

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \`\` | uint256 |             |

### setBufferCap

```solidity
function setBufferCap(
    uint256 
) external
```

no-op, reverts. Prevent admin or governor from overwriting ideal buffer cap

#### Parameters

| Name | Type    | Description |
| ---- | ------- | ----------- |
| \`\` | uint256 |             |

### mint

```solidity
function mint(
    address to,
    uint256 amount
) external
```

mints ZEN to the target address, subject to rate limit

#### Parameters

| Name     | Type    | Description                |
| -------- | ------- | -------------------------- |
| `to`     | address | the address to send ZEN to |
| `amount` | uint256 | the amount of ZEN to send  |

### setZenTreasury

```solidity
function setZenTreasury(
    address newZenTreasury
) external
```

sets the new ZEN treasury address

#### Parameters

| Name             | Type    | Description |
| ---------------- | ------- | ----------- |
| `newZenTreasury` | address |             |

### setZenRewardsDripper

```solidity
function setZenRewardsDripper(
    address newZenRewardsDripper
) external
```

sets the new ZEN treasury rewards dripper

#### Parameters

| Name                   | Type    | Description |
| ---------------------- | ------- | ----------- |
| `newZenRewardsDripper` | address |             |

### setMinter

```solidity
function setMinter(
    address newMinter
) external
```

changes the ZEN minter address

#### Parameters

| Name        | Type    | Description            |
| ----------- | ------- | ---------------------- |
| `newMinter` | address | the new minter address |

### setAnnualMaxInflationBasisPoints

```solidity
function setAnnualMaxInflationBasisPoints(
    uint256 newAnnualMaxInflationBasisPoints
) external
```

sets the max annual inflation relative to current supply

#### Parameters

| Name                               | Type    | Description                                                   |
| ---------------------------------- | ------- | ------------------------------------------------------------- |
| `newAnnualMaxInflationBasisPoints` | uint256 | the new max inflation % denominated in basis points (1/10000) |

### idealBufferCap

```solidity
function idealBufferCap() public returns (uint256)
```

return the ideal buffer cap based on ZEN circulating supply

### zenCirculatingSupply

```solidity
function zenCirculatingSupply() public returns (uint256)
```

return the ZEN supply, subtracting locked ZEN

### totalSupply

```solidity
function totalSupply() public returns (uint256)
```

alias for zenCirculatingSupply

for compatibility with ERC-20 standard for off-chain 3rd party sites

### isPokeNeeded

```solidity
function isPokeNeeded() external returns (bool)
```

return whether a poke is needed or not i.e. is buffer cap != ideal cap

### \_mint

```solidity
function _mint(
    address to,
    uint256 amount
) internal
```

#### Parameters

| Name     | Type    | Description |
| -------- | ------- | ----------- |
| `to`     | address |             |
| `amount` | uint256 |             |

### \_setAnnualMaxInflationBasisPoints

```solidity
function _setAnnualMaxInflationBasisPoints(
    uint256 newAnnualMaxInflationBasisPoints
) internal
```

#### Parameters

| Name                               | Type    | Description |
| ---------------------------------- | ------- | ----------- |
| `newAnnualMaxInflationBasisPoints` | uint256 |             |


