# Start Here

Zivoe's Official Documentation

***

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="image">Cover image</th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td></td><td><strong>User Docs</strong></td><td></td><td><a href="/files/RHGcYMp6Ctx6fqkqTK4D">/files/RHGcYMp6Ctx6fqkqTK4D</a></td><td><a href="/pages/OcpRTY8g6Fh4MovtOQrR">/pages/OcpRTY8g6Fh4MovtOQrR</a></td></tr><tr><td></td><td><strong>Developer Docs</strong></td><td></td><td><a href="/files/CUdNXSdMtdqiPjfVHeei">/files/CUdNXSdMtdqiPjfVHeei</a></td><td><a href="/pages/yXUxLVe1QvdzsbzxgkXi">/pages/yXUxLVe1QvdzsbzxgkXi</a></td></tr></tbody></table>

***


# Disclaimer

Important Disclaimer

This document is provided primarily to describe the functionality, architecture, and user interactions related to the Zivoe Protocol. It should be noted, however, that the details contained within are inherently subject to alteration, as they depict an ongoing and evolving project, not a finalized product or system.

While this document outlines the current design and operation of the Zivoe Protocol, it is not intended to serve as a legally binding representation of Zivoe's development plans or business activities. The information included here is designed to educate and inform, and does not constitute a binding commitment on the part of Zivoe with respect to the future performance or specific functionalities of the protocol.

By engaging with this document, readers implicitly accept the inherent uncertainties of an evolving project and agree to not hold Zivoe or any of its contributors accountable for any changes that may transpire. Use or reference of this document signifies acceptance of these conditions.

As this document remains subject to continual changes and updates without prior notification, readers are encouraged to regularly visit our official GitBook page to stay informed of the latest revisions and developments.


# Introduction

Zivoe is a tokenization protocol providing on-chain access to short-duration private credit. Depositors supply stablecoins to a vault that finances diversified credit portfolios.

### Why Zivoe?

* **Private credit yield:** Access yields generated by short-duration private credit portfolios, designed to be uncorrelated with broader crypto and financial markets.
* **Auto-compounding:** Returns accrue continuously to the price of the vault token, compounding automatically without the need to claim or restake.
* **Composable by design:** Depositors receive a vault token (zVLT) built on the ERC-4626 standard, enabling composability across the broader DeFi ecosystem.
* **Professional risk management:** Zivoe's team comes from leading TradFi and DeFi institutions including JPMorgan Chase, Wells Fargo, Capital One, Experian, and Maple Finance, with over 40 years of collective experience managing credit risk.
* **Structural protections:** Assets financed through the protocol are held in dedicated special purpose vehicles (SPVs) designed to segregate assets and help protect depositor funds.

***

### How It Works?

* **Deposit** stablecoins (USDC or USDT) through Zivoe's platform.
* **Receive** vault tokens (zVLT) representing your proportional position in the assets being financed.
* **Earn** as the underlying credit portfolios generate repayments, with returns accruing continuously to the price of zVLT.
* **Redeem** your vault tokens for stablecoins, reflecting your initial deposit plus any yield accrued.

***

### Navigating These Docs

**User Documentation** - Learn how Zivoe works and how to participate in the protocol. You're in this section now.

[**Developer Documentation**](/developer-docs/core-contracts) - A deeper look at the technology behind Zivoe, including smart contracts and system architecture.


# Yield Strategy

Zivoe finances and purchases interests in short-duration private credit portfolios originated by established lending partners.

### How It Works

Zivoe connects on-chain liquidity to private credit markets through participation agreements with established originators. The vault deploys capital directly into underlying loans alongside the originator, and holders of Zivoe's vault token (zVLT) earn yield as borrowers within these portfolios make repayments.

**Participation Agreement**

1. The zVLT vault provides capital to originators through loan participation agreements, under which the vault funds a portion of each underlying loan.
2. Originators originate and service the loans, while the vault shares in portfolio performance proportionally to its participation amount.
3. These participations are held in special purpose vehicles (SPVs) structured to segregate assets, which serve as collateral for the on-chain structure.
4. As borrowers make repayments, cash flows return to Zivoe and accrue to holders of zVLT, reflected directly in the token's price.

**Credit Facility**

1. Zivoe lends USDC to vetted originators through on-chain credit facilities.
2. Originators convert this on-chain liquidity to fiat and use it to finance consumer or business loans.
3. These portfolios are held in Bankruptcy-Remote Special Purpose Vehicles (BK-SPVs), which serve as collateral for the on-chain credit facilities.
4. &#x20;As these portfolios generate returns that capital is returned to Zivoe where it accrues to holders of zVLT, reflected directly in the token's price.

***

### Why Private Credit?

Private credit has become one of the largest and fastest-growing segments of alternative finance, exceeding $2 trillion globally. These markets supply essential capital to consumers and small businesses underserved by traditional lenders, generating yield tied to real economic activity.

Zivoe focuses on short-duration strategies within this market, which combine:

* **Recurring cash flows:** Short repayment cycles generate frequent, recurring cash flows, allowing capital to be redeployed continuously and performance to be observed earlier than in longer-dated credit strategies.
* **Diversification:** Portfolios are composed of thousands of underlying borrowers or merchants, reducing concentration risk.
* **Attractive risk-adjusted returns:** Private credit strategies have historically outperformed traditional fixed-income markets on a risk-adjusted basis.

By tokenizing access to these markets, Zivoe opens a historically institution-only asset class with enhanced transparency.

***

### Yield & Liquidity Model

* **Yield:** Returns are generated through participation agreements and direct lending operations. As principal and interest are repaid, capital is continually redeployed into new loans, allowing portfolio earnings to compound over time. Yield is reflected through price appreciation of zVLT as the underlying assets accrue income.
* **Incentives:** Additional incentives may be made available to depositors in the form of points or ZVE, Zivoe's governance token.
* **Management Fee:** Zivoe earns a 15% share of revenue generated by the protocol to fund operations and maintain protocol infrastructure.
* **Liquidity:** zVLT redemptions are processed directly by Zivoe. Holders may request redemption by contacting <investors@zivoe.com>, with proceeds settled in stablecoins following processing. Because deployed capital is invested in short-duration credit assets, redemption timing may vary based on available protocol liquidity.


# Deposit & Earn

How to deposit stablecoins, receive zVLT, and track your position.

### How To Start Earning

#### **1. Launch App & Connect Wallet**

Navigate to the [Deposit](https://app.zivoe.com/) page of Zivoe's app. Click "Connect Wallet" and connect with your web3 wallet (e.g., MetaMask, Phantom, Rabby).

#### **2. Deposit Stablecoins**

In the deposit window, select the stablecoin you want to deposit (USDC or USDT), input an amount, and click "Deposit." This creates a transaction for you to sign in your wallet. Once the transaction confirms, vault tokens (zVLT) will appear in your wallet, representing your position in the vault.

#### **3. Track Your Position**

Visit the "Portfolio" page to monitor your position. As the underlying credit portfolios generate repayments, returns accrue continuously to the token's price, increasing the value of your zVLT over time.

#### **4. Redeem**

When you are ready to exit your position, you can redeem your vault tokens (zVLT) for stablecoins, reflecting your initial deposit plus any yield accrued. To initiate a redemption, contact <investors@zivoe.com> and our team will process your request.

Learn more about how to [Redeem & Claim Yield](https://docs.zivoe.com/user-docs/redeem-and-claim-yield)

***

{% hint style="info" %}
Click here to start depositing: [app.zivoe.com](https://app.zivoe.com)
{% endhint %}


# Redeem & Claim Yield

How to redeem zVLT for stablecoins, including your accrued yield.

### **How Redemptions Work**

zVLT is a yield-bearing vault token. As the underlying credit portfolios generate repayments, returns accrue continuously to the token's price. There are no separate yield claims or distributions; your full return is captured in the value of your zVLT when you redeem.

**Requesting a redemption.** To redeem zVLT for stablecoins, contact <investors@zivoe.com> with your wallet address and the amount you wish to redeem. Our team will confirm receipt and process the request.

**Settlement.** Redemption proceeds are settled in stablecoins at the prevailing zVLT price. Because protocol capital is deployed into short-duration private credit assets, processing timelines may vary depending on available liquidity. We aim to keep depositors informed of expected timing throughout the process.

**Questions.** For anything related to redemptions or your position, reach out to <investors@zivoe.com>.


# ZVE Token

⚠️ The ZVE Token is not trading on any exchanges yet, beware of scams.

ZVE is the native governance token of the Zivoe ecosystem. It empowers holders to participate in protocol governance, shape key decisions, and contribute to the future direction of the protocol.

| **Ticker**                        | ZVE                                        |
| --------------------------------- | ------------------------------------------ |
| **Type**                          | ERC20                                      |
| **Total Supply (Fixed)**          | 25,000,000                                 |
| **Token** **Contract (Ethereum)** | 0xe412D46a0fBD567332b7689cFFfE1F8A4f19A9d2 |
| **Vesting Contract (Ethereum)**   | 0x520f2b5766176fd94B62507C848599B6251168F6 |

### Governance <a href="#governance" id="governance"></a>

Zivoe is governed through an on-chain voting system driven by ZVE token holders. ZVE holders have the ability to propose and vote on a defined set of actions through the Zivoe Improvement Proposal (ZIP) process.

Examples of proposals that may be governed via ZIPs include:

* Adjusting protocol reward rates
* Approving integrations with new contracts
* Updating protocol configuration parameters
* Activating or modifying the protocol fee switch
* Directing protocol managed assets

Proposals undergo an on-chain voting process where members vote For, Against, or Abstain. Voting power is directly linked to the number of ZVE tokens held, with 1 ZVE equating to 1 vote. To encourage participation from all token holders, we've made it possible for you to vote whether you are holding ZVE in your wallet, staking it, and even while its still vesting to your wallet.&#x20;

***

### Token Distribution <a href="#governance" id="governance"></a>

The distribution of ZVE is as follows:

| **Category**                                          | **Tokens** | **% of Total Supply** |
| ----------------------------------------------------- | ---------- | --------------------- |
| Founders, Team, & Advisors                            | 6,500,000  | 26.00%                |
| Future Team                                           | 1,000,000  | 4.00%                 |
| Seed Round                                            | 4,350,000  | 17.40%                |
| KOL Round                                             | 125,000    | 0.50%                 |
| Foundation                                            | 3,025,000  | 12.10%                |
| ITO Airdrop                                           | 1,250,000  | 5.00%                 |
| Community (Treasury, Incentives, Market Making, etc.) | 8,750,000  | 35.00%                |

**Vesting**

Vested tokens enter circulating supply when they have been claimed from the vesting contract.&#x20;

| **Category**               | **Tokens** | **% of Total Supply** | **Vesting Details**                                                                   |
| -------------------------- | ---------- | --------------------- | ------------------------------------------------------------------------------------- |
| ITO Airdrop                | 1,250,000  | 5.00%                 | 12 month linear vesting                                                               |
| Founders, Team, & Advisors | 6,500,000  | 26.00%                | 12 month cliff, 36 month linear vesting thereafter                                    |
| Seed Round                 | 4,350,000  | 17.40%                | 12 month cliff, 36 month linear vesting thereafter                                    |
| KOL Round                  | 125,000    | 0.50%                 | 25% unlocked at TGE, followed by a 12 month cliff, 48 month linear vesting thereafter |


# Contract Addresses

⚠️ All contracts are deployed on Ethereum Mainnet

### Primary Contracts

<table data-header-hidden><thead><tr><th width="183.66015625">Contract</th><th width="150.4765625">Abbreviation</th><th>Address</th></tr></thead><tbody><tr><td><strong>Contract</strong></td><td><strong>Abbreviation</strong></td><td><strong>Address</strong></td></tr><tr><td>Zivoe Vault</td><td>zVLT</td><td><a href="https://etherscan.io/address/0x94BaBe9Ee75C38034920bC6ed42748E8eEFbedd4">0x94BaBe9Ee75C38034920bC6ed42748E8eEFbedd4</a></td></tr><tr><td>Zivoe Router</td><td>zRTR</td><td><a href="https://etherscan.io/address/0x420909Ba4B361853703668E19461b3a5DEa2C3b6">0x420909Ba4B361853703668E19461b3a5DEa2C3b6</a></td></tr><tr><td>Instant Redemptions</td><td>OCR_Cycle</td><td><a href="https://etherscan.io/address/0x12e46e69623350ab3ae6d52cab86a152a078ad6f">0x12e46e69623350ab3ae6d52cab86a152a078ad6f</a></td></tr><tr><td>Lending</td><td>OCC_Cycle</td><td><a href="https://etherscan.io/address/0x161c42fb3ca3bae7755124b56d48a88bceccc17f">0x161c42fb3ca3bae7755124b56d48a88bceccc17f</a></td></tr><tr><td>Treasury</td><td>DAO</td><td><a href="https://etherscan.io/address/0xB65a66621D7dE34afec9b9AC0755133051550dD7">0xB65a66621D7dE34afec9b9AC0755133051550dD7</a></td></tr></tbody></table>

### Zivoe Governance Token

<table data-header-hidden><thead><tr><th width="185.95703125">Contract</th><th width="151.83203125">Abbreviation</th><th>Address</th></tr></thead><tbody><tr><td><strong>Contract</strong></td><td><strong>Abbreviation</strong></td><td><strong>Address</strong></td></tr><tr><td>Zivoe Governance Token</td><td>ZVE</td><td><a href="https://etherscan.io/address/0xe412D46a0fBD567332b7689cFFfE1F8A4f19A9d2">0xe412D46a0fBD567332b7689cFFfE1F8A4f19A9d2</a></td></tr><tr><td>ZVE Staking</td><td>stZVE</td><td><a href="https://etherscan.io/address/0xb397Aa1D78109115dCC57B907dCD9d61Bb6b2DCE">0xb397Aa1D78109115dCC57B907dCD9d61Bb6b2DCE</a></td></tr><tr><td>ZVE Vesting</td><td>vestZVE</td><td><a href="https://etherscan.io/address/0x520f2b5766176fd94B62507C848599B6251168F6">0x520f2b5766176fd94B62507C848599B6251168F6</a></td></tr><tr><td>ZVE Emissions Controller</td><td>OCE ZVE</td><td><a href="https://etherscan.io/address/0xBE26238bCE96A517C619C2B3140ef5c69625c7be">0xBE26238bCE96A517C619C2B3140ef5c69625c7be</a></td></tr></tbody></table>

### Tranches <a href="#governance" id="governance"></a>

<table data-header-hidden><thead><tr><th width="183.66015625">Contract</th><th width="150.4765625">Abbreviation</th><th>Address</th></tr></thead><tbody><tr><td><strong>Contract</strong></td><td><strong>Abbreviation</strong></td><td><strong>Address</strong></td></tr><tr><td>Initial Tranche Offering</td><td>ITO</td><td><a href="https://etherscan.io/address/0xE590233c22E81A79a1768aB8c8597b7a55C52Aba">0xE590233c22E81A79a1768aB8c8597b7a55C52Aba</a></td></tr><tr><td>Tranches</td><td>ZVT</td><td><a href="https://etherscan.io/address/0x6282b480F0b989F0B603f821a840d964bc4715A8">0x6282b480F0b989F0B603f821a840d964bc4715A8</a></td></tr><tr><td>Tranche Token Redemption Locker</td><td>OCR</td><td><a href="https://etherscan.io/address/0xd4b4E69B484635be0F8e19bb859564570f29C6D2">0xd4b4E69B484635be0F8e19bb859564570f29C6D2</a></td></tr><tr><td>Senior Tranche Token </td><td>zSTT</td><td><a href="https://etherscan.io/address/0x7aA5Bf30042b2145B9F0629ea68De55B42ad3BB6">0x7aA5Bf30042b2145B9F0629ea68De55B42ad3BB6</a></td></tr><tr><td>Junior Tranche Token</td><td>zJTT</td><td><a href="https://etherscan.io/address/0xA923FA389de41C4FC56bd3b9a99c142c81ab6dd0">0xA923FA389de41C4FC56bd3b9a99c142c81ab6dd0</a></td></tr><tr><td>zSTT Staking</td><td>stSTT</td><td><a href="https://etherscan.io/address/0x0D45c292baCdC47CE850E4c83a2FA2e8509DEd5D">0x0D45c292baCdC47CE850E4c83a2FA2e8509DEd5D</a></td></tr><tr><td>zJTT Staking</td><td>stJTT</td><td><a href="https://etherscan.io/address/0xcacdB1A5a11F824E02De4CA6E7b2D12BB278aA7c">0xcacdB1A5a11F824E02De4CA6E7b2D12BB278aA7c</a></td></tr><tr><td>Tranche Conversion (Upgrade)</td><td>OCT_Convert</td><td><a href="https://etherscan.io/address/0x6E300A96E5d6b015E1761488A85E4341bd4B321e">0x6E300A96E5d6b015E1761488A85E4341bd4B321e</a></td></tr></tbody></table>

### Governance & Accounting <a href="#governance" id="governance"></a>

<table data-header-hidden><thead><tr><th width="176.83984375">Contract</th><th width="158.74609375">Abbreviation</th><th>Address</th></tr></thead><tbody><tr><td><strong>Contract</strong></td><td><strong>Abbreviation</strong></td><td><strong>Address</strong></td></tr><tr><td>Governor</td><td>GOV</td><td><a href="https://etherscan.io/address/0x94Ac60103B6b0df0cd828086B16EfF2A3e32a71e">0x94Ac60103B6b0df0cd828086B16EfF2A3e32a71e</a></td></tr><tr><td>Timelock Controller</td><td>TLC</td><td><a href="https://etherscan.io/address/0xE1A68a0404426d6BBc459794e576640dEE3FC916">0xE1A68a0404426d6BBc459794e576640dEE3FC916</a></td></tr><tr><td>Globals</td><td>GBL</td><td><a href="https://etherscan.io/address/0xEa537eB0bBcC7783bDF7c595bF9371984583dA66">0xEa537eB0bBcC7783bDF7c595bF9371984583dA66</a></td></tr><tr><td>Yield Distribution Locker</td><td>YDL</td><td><a href="https://etherscan.io/address/0xfB7920B55887840643e20952f22Eb18dDC474B2B">0xfB7920B55887840643e20952f22Eb18dDC474B2B</a></td></tr></tbody></table>

### Yield Generation <a href="#governance" id="governance"></a>

<table data-header-hidden><thead><tr><th width="207.7265625">Contract</th><th width="148.3671875">Abbreviation</th><th>Address</th></tr></thead><tbody><tr><td><strong>Contract</strong></td><td><strong>Abbreviation</strong></td><td><strong>Address</strong></td></tr><tr><td>USDC Lending Locker</td><td>OCC_USDC</td><td><a href="https://etherscan.io/address/0xfAb4e880467e26ED46F00c669C28fEaC58262698">0xfAb4e880467e26ED46F00c669C28fEaC58262698</a></td></tr><tr><td>alUSD / FRAXBP</td><td>OCY_Convex_A</td><td><a href="https://etherscan.io/address/0x2C0508D0C6340D7D9a383109d6171c3cbf41e427">0x2C0508D0C6340D7D9a383109d6171c3cbf41e427</a></td></tr><tr><td>PYUSD / USDC</td><td>OCY_Convex_C</td><td><a href="https://etherscan.io/address/0x0DF8Aa43a6919926Be6ED15c956329f2cd4B9DF6">0x0DF8Aa43a6919926Be6ED15c956329f2cd4B9DF6</a></td></tr><tr><td>OUSD</td><td>OCY_OUSD</td><td><a href="https://etherscan.io/address/0xDCfb9865Ab023174e88849aC6c187843686ae1d6">0xDCfb9865Ab023174e88849aC6c187843686ae1d6</a></td></tr><tr><td>Uniswap v2 / Sushi Liquidity Pool Manager</td><td>OCL ZVE</td><td><a href="https://etherscan.io/address/0x067683698F65Bd903D393B85Aa3fc119D76b8425">0x067683698F65Bd903D393B85Aa3fc119D76b8425</a></td></tr></tbody></table>

### Utilities <a href="#governance" id="governance"></a>

<table data-header-hidden><thead><tr><th width="199.7734375">Contract</th><th width="154.14453125">Abbreviation</th><th>Address</th></tr></thead><tbody><tr><td><strong>Contract</strong></td><td><strong>Abbreviation</strong></td><td><strong>Address</strong></td></tr><tr><td>1inch v5 Swapper - YDL</td><td>OCT_YDL</td><td><a href="https://etherscan.io/address/0x6172f8103d156c49532E610232d33F0796E6EF87">0x6172f8103d156c49532E610232d33F0796E6EF87</a></td></tr><tr><td>1inch v5 Swapper - DAO</td><td>OCT_DAO</td><td><a href="https://etherscan.io/address/0xd702332915fDDf588793D54d63872a97ad78d108">0xd702332915fDDf588793D54d63872a97ad78d108</a></td></tr><tr><td>1inch v5 Swapper - ZVL</td><td>OCT_ZVL</td><td><a href="https://etherscan.io/address/0x79D68D40Ef6F1DC7B220Ef0A6Df02e753DCe396f">0x79D68D40Ef6F1DC7B220Ef0A6Df02e753DCe396f</a></td></tr></tbody></table>

### Deprecated Contracts


# Core Contracts

List of Core Contracts

<table><thead><tr><th width="236" data-type="content-ref">Contract</th><th>Description</th></tr></thead><tbody><tr><td><a href="/pages/sBKyh72vSwAzCcKOrHJh">/pages/sBKyh72vSwAzCcKOrHJh</a></td><td>Escrows capital from liquidity providers, governance then allocates this to lockers.</td></tr><tr><td><a href="/pages/TUQrzv2wSICWqS4j548s">/pages/TUQrzv2wSICWqS4j548s</a></td><td>Stores global values utilized by all core contracts.</td></tr><tr><td><a href="/pages/4fr8Z3EE3SyXye2Ubjwn">/pages/4fr8Z3EE3SyXye2Ubjwn</a></td><td>Implements governance modules from OpenZeppelin for governance.</td></tr><tr><td><a href="/pages/l0sWRjNPmnxpv7sklwAv">/pages/l0sWRjNPmnxpv7sklwAv</a></td><td>Conducts the Initial Tranche Offering ("ITO").</td></tr><tr><td><a href="/pages/LU7piu2cyX4Xrgvw1qpm">/pages/LU7piu2cyX4Xrgvw1qpm</a></td><td>An abstract base contract, inherited by all lockers.</td></tr><tr><td><a href="/pages/iVkZJLTSihlTUzGYyq3Y">/pages/iVkZJLTSihlTUzGYyq3Y</a></td><td>A mathematics contract, which handles accounting features in tandem with ZivoeYDL.</td></tr><tr><td><a href="/pages/bzuYTstdGFzfkdJmeuDO">/pages/bzuYTstdGFzfkdJmeuDO</a></td><td>A multi-rewards staking contract for $zJTT/$zSTT/$ZVE.</td></tr><tr><td><a href="/pages/YKe0QQ70EIY42ZdImdB6">/pages/YKe0QQ70EIY42ZdImdB6</a></td><td>A multi-rewards staking contract for internal $ZVE vesting schedules.</td></tr><tr><td><a href="/pages/0SgvJDw5XY5XxnPpjM3M">/pages/0SgvJDw5XY5XxnPpjM3M</a></td><td>$ZVE, the native protocol token, used for governance and staking.</td></tr><tr><td><a href="/pages/CLmfwnjHKyOWxWRjVwYS">/pages/CLmfwnjHKyOWxWRjVwYS</a></td><td>Handles ongoing deposits to the DAO in exchange for $zJTT/$zSTT.</td></tr><tr><td><a href="/pages/nHNoO7AoycSzNexvK1WJ">/pages/nHNoO7AoycSzNexvK1WJ</a></td><td>Utilized to launch two tranche tokens (senior and junior, $zSTT/$zJTT).</td></tr><tr><td><a href="/pages/0jP8m33SvrH7vM5VrPQV">/pages/0jP8m33SvrH7vM5VrPQV</a></td><td>Handles yield distribution accounting for the Zivoe protocol.</td></tr><tr><td><a href="/pages/EWPUMHAJOiZy0RW8V1kP">/pages/EWPUMHAJOiZy0RW8V1kP</a></td><td>ERC-4626 Tokenized Vault (undelrying asset is $zSTT)</td></tr><tr><td><a href="/pages/sWDlHs2Bpqbh4K76tav0">/pages/sWDlHs2Bpqbh4K76tav0</a></td><td>Interface for the ZivoeVault</td></tr></tbody></table>


# ZivoeDAO.sol

DAO -> Decentralized Autonomous Organization

## Introduction

This contract escrows assets for the Zivoe protocol and is governed by TimelockController (effectively $ZVE Governance).

This contract has the following responsibilities:

* Push assets (ERC20, ERC721, ERC1155) to a locker.
* Pull assets (ERC20, ERC721, ERC1155) from a locker.
* Enforce a whitelist of "lockers" (ZivoeLockers).

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-522&t=P90hTl415XLXLxHf-4>" %}

#### State Variables

<table><thead><tr><th width="129.33333333333331">Type</th><th width="153">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr></tbody></table>

## Sections

[#write-functions](#write-functions "mention")

* [#push](#push "mention") - Pushes an ERC20 token from ZivoeDAO to locker.
* [#pull](#pull "mention") - Pulls ERC20 from locker to ZivoeDAO.
* [#pullpartial](#pullpartial "mention") - Pulls specific amount of ERC20 from locker to ZivoeDAO.
* [#pushmulti](#pushmulti "mention") - Pushes ERC20(s) from locker to ZivoeDAO.
* [#pullmulti](#pullmulti "mention") - Pulls ERC20(s) from locker to ZivoeDAO.
* [#pullmultipartial](#pullmultipartial "mention") - Pulls specific amount(s) of ERC20(s) from locker to ZivoeDAO.
* [#pusherc721](#pusherc721 "mention") - Pushes an NFT from ZivoeDAO to locker.
* [#pushmultierc721](#pushmultierc721 "mention") - Pushes NFT(s) from ZivoeDAO to locker.
* [#pullerc721](#pullerc721 "mention") - Pulls an NFT from locker to ZivoeDAO.
* [#pushmultierc721](#pushmultierc721 "mention") - Pulls NFT(s) from locker to ZivoeDAO.
* [#pusherc1155](#pusherc1155 "mention") - Pushes ERC1155 assets from ZivoeDAO to locker.
* [#pullerc1155](#pullerc1155 "mention") - Pulls ERC1155 assets from locker to ZivoeDAO.

[#events](#events "mention")

* [#pushed](#pushed "mention")
* [#pulled](#pulled "mention")
* [#pulledpartial](#pulledpartial "mention")
* [#pushederc721](#pushederc721 "mention")
* [#pullederc721](#pullederc721 "mention")
* [#pushederc1155](#pushederc1155 "mention")
* [#pullederc1155](#pullederc1155 "mention")

##

## Write Functions

#### `push()`

Pushes an ERC20 token from ZivoeDAO to locker.

```solidity
function push(
    address locker, 
    address asset, 
    uint256 amount, 
    bytes calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="119.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to push an ERC20 token to.</td></tr><tr><td>address</td><td>asset</td><td>The ERC20 token to push.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to push.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#pushed](#pushed "mention") event

#### `pull()`

Pulls ERC20 from locker to ZivoeDAO.

```solidity
function pull(
    address locker, 
    address asset, 
    bytes calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="119.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to pull from.</td></tr><tr><td>address</td><td>asset</td><td>The asset to pull.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#pulled](#pulled "mention") event

#### `pullPartial()`

Pulls specific amount of ERC20 from locker to ZivoeDAO.

```solidity
function pullPartial(
    address locker, 
    address asset, 
    uint256 amount, 
    bytes calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="119.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to pull from.</td></tr><tr><td>address</td><td>asset</td><td>The asset to pull.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount to pull (may not refer to "asset", but rather a different asset within the locker).</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#pulledpartial](#pulledpartial "mention") event

#### `pushMulti()`

Pushes ERC20(s) from locker to ZivoeDAO.

```solidity
function pushMulti(
    address locker, 
    address[] calldata assets, 
    uint256[] calldata amounts, 
    bytes[] calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="140.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to push capital to.</td></tr><tr><td>address[]</td><td>assets</td><td>The assets to push to locker.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amount of "asset" to push.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#pushed](#pushed "mention") event (multiple times)

#### `pullMulti()`

Pulls ERC20(s) from locker to ZivoeDAO.

```solidity
function pullMulti(
    address locker, 
    address[] calldata assets, 
    bytes[] calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="125.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to pull from.</td></tr><tr><td>address[]</td><td>assets</td><td>The assets to pull.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#pulled](#pulled "mention") event (multiple times)

#### `pullMultiPartial()`

Pulls specific amount(s) of ERC20(s) from locker to ZivoeDAO.

```solidity
function pullMultiPartial(
    address locker, 
    address[] calldata assets, 
    uint256[] calldata amounts, 
    bytes[] calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="126.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to pull from.</td></tr><tr><td>address[]</td><td>assets</td><td>The asset(s) to pull.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amount(s) to pull (may not refer to "asset", rather a different asset within the locker).</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#pulledpartial](#pulledpartial "mention") event (multiple times)

#### `pushERC721()`

Pushes an NFT from ZivoeDAO to locker.

```solidity
function pushERC721(
    address locker, 
    address asset, 
    uint256 tokenId, 
    bytes calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="119.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to push an NFT to.</td></tr><tr><td>address</td><td>asset</td><td>The NFT contract.</td></tr><tr><td>uint256</td><td>tokenId</td><td>The NFT tokenId to push.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>

Emits the [#pushederc721](#pushederc721 "mention")

#### `pushMultiERC721()`

Pushes NFT(s) from ZivoeDAO to locker.

```solidity
function pushMultiERC721(
    address locker, 
    address[] calldata assets, 
    uint[] calldata tokenIds, 
    bytes[] calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="140.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to push NFTs to.</td></tr><tr><td>address[]</td><td>assets</td><td>The NFT contract(s).</td></tr><tr><td>uint256[]</td><td>tokenIds</td><td>The NFT tokenId(s) to push.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying data for the transaction(s).</td></tr></tbody></table>

Emits the [#pushederc721](#pushederc721 "mention") event (multiple times)

#### `pullERC721()`

Pulls an NFT from locker to ZivoeDAO.

```solidity
function pullERC721(
    address locker, 
    address asset, 
    uint tokenId, 
    bytes calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="119.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to pull from.</td></tr><tr><td>address</td><td>asset</td><td>The NFT contract.</td></tr><tr><td>uint256</td><td>amount</td><td>The NFT tokenId to pull.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>

Emits the [#pullederc721](#pullederc721 "mention")

#### `pullMultiERC721()`

Pulls NFT(s) from locker to ZivoeDAO.

```solidity
function pullMultiERC721(
    address locker,
    address[] calldata assets,
    uint[] calldata tokenIds,
    bytes[] calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="126.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to pull from.</td></tr><tr><td>address[]</td><td>assets</td><td>The NFT contract(s).</td></tr><tr><td>uint256[]</td><td>tokenIds</td><td>The NFT tokenId(s) to pull.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying data for the transaction(s).</td></tr></tbody></table>

Emits the [#pullederc721](#pullederc721 "mention") event (multiple times)

#### `pushERC1155()`

Pushes ERC1155 assets from ZivoeDAO to locker.

```solidity
function pushERC1155Batch(
    address locker,
    address asset,
    uint256[] calldata ids, 
    uint256[] calldata amounts,
    bytes calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to push ERC1155 assets to.</td></tr><tr><td>address</td><td>asset</td><td>The ERC1155 asset to push to locker.</td></tr><tr><td>uint256[]</td><td>ids</td><td>The ids of "assets" to push.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amounts of "assets" to push.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>

Emits the [#pushederc1155](#pushederc1155 "mention") event

#### `pullERC1155()`

Pulls ERC1155 assets from locker to ZivoeDAO.

```solidity
function pullERC1155Batch(
    address locker,
    address asset,
    uint256[] calldata ids, 
    uint256[] calldata amounts,
    bytes calldata data
) external onlyOwner nonReentrant;
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to pull from.</td></tr><tr><td>address</td><td>asset</td><td>The ERC1155 asset to pull.</td></tr><tr><td>uint256[]</td><td>ids</td><td>The ids of "assets" to pull.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amounts of "assets" to pull.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>

Emits the [#pullederc1155](#pullederc1155 "mention") event

## Events

#### **`Pushed()`**

Emitted during [#push](#push "mention") and [#pushmulti](#pushmulti "mention")

```solidity
event Pushed(
    address indexed locker, 
    address indexed asset, 
    uint256 amount, 
    bytes data
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker receiving "asset".</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The asset being pushed.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "asset" being pushed.</td></tr><tr><td>bytes</td><td>False</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`Pulled()`**

Emitted during [#pull](#pull "mention") and [#pullmulti](#pullmulti "mention")

```solidity
event Pulled(
    address indexed locker, 
    address indexed asset, 
    bytes data
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker "asset" is pulled from.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The asset being pulled.</td></tr><tr><td>bytes</td><td>False</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`PulledPartial()`**

Emitted during [#pullpartial](#pullpartial "mention") and [#pullmultipartial](#pullmultipartial "mention")

```solidity
event PulledPartial(
    address indexed locker, 
    address indexed asset, 
    uint256 amount, 
    bytes data
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker "asset" is pulled from.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The asset being pulled.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "asset" being pulled (or could represent a percentage, in basis points).</td></tr><tr><td>bytes</td><td>False</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`PushedERC721()`**

Emitted during [#pusherc721](#pusherc721 "mention") and [#pushmultierc721](#pushmultierc721 "mention")

```solidity
event PushedERC721(
    address indexed locker, 
    address indexed asset, 
    uint256 indexed tokenId, 
    bytes data
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker receiving "asset".</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The ERC721 contract.</td></tr><tr><td></td><td></td><td>tokenId</td><td>The ID for a given "asset" / NFT.</td></tr><tr><td>bytes</td><td>False</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>

#### **`PulledERC721()`**

Emitted during [#pullerc721](#pullerc721 "mention") and [#pullmultierc721](#pullmultierc721 "mention")

```solidity
event PulledERC721(
    address indexed locker, 
    address indexed asset, 
    uint256 indexed tokenId, 
    bytes data
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker "assets" are pulled from.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The ERC721 contract.</td></tr><tr><td>uint256</td><td>True</td><td>tokenId</td><td>The ID for a given "asset" / NFT.</td></tr><tr><td>bytes</td><td>False</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>

#### **`PushedERC1155()`**

Emitted during [#pusherc1155](#pusherc1155 "mention")

```solidity
event PushedERC1155(
    address indexed locker, 
    address indexed asset, 
    uint256[] ids, 
    uint256[] amounts, 
    bytes data
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker receiving "asset".</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The ERC1155 contract.</td></tr><tr><td>uint256[]</td><td>False</td><td>ids</td><td>The IDs for a given "asset" (ERC1155), corresponds to "amounts".</td></tr><tr><td>uint256[]</td><td>False</td><td>amounts</td><td>The amount of "id" to transfer.</td></tr><tr><td>bytes</td><td>False</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>

#### **`PulledERC1155()`**

Emitted during [#pullerc1155](#pullerc1155 "mention")

```solidity
event PulledERC1155(
    address indexed locker, 
    address indexed asset, 
    uint256[] ids, 
    uint256[] amounts, 
    bytes data
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker "asset" is pulled from.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The ERC1155 contract.</td></tr><tr><td>uint256[]</td><td>False</td><td>ids</td><td>The IDs for a given "asset" (ERC1155), corresponds to "amounts".</td></tr><tr><td>uint256[]</td><td>False</td><td>amounts</td><td>The amount of "id" to transfer.</td></tr><tr><td>bytes</td><td>False</td><td>data</td><td>Accompanying data for the transaction.</td></tr></tbody></table>


# ZivoeGlobals.sol

Global Variables for Zivoe Protocol

## Introduction

This contract contains global variables for the Zivoe protocol.

This contract has the following responsibilities:

* Maintain accounting of all defaults within the system in aggregate.
* Handle ZVL AccessControl (switching to other wallets).
* Whitelist management for "keepers" which are allowed to execute proposals within the TLC in advance.&#x20;
* Whitelist management for "lockers" which ZivoeDAO can push/pull to.
* Whitelist management for "stablecoins" which are accepted in other Zivoe contracts.
* View function for standardized ERC20 precision handling.
* View function for adjusting the supplies of tranches (accounting purposes).

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-521&t=GTshLGL9pENazLTc-4>" %}

#### State Variables

<table><thead><tr><th width="190">Type</th><th width="184.33333333333331">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>DAO</td><td>The ZivoeDAO contract.</td></tr><tr><td>address</td><td>ITO</td><td>The ZivoeITO contract.</td></tr><tr><td>address</td><td>stJTT</td><td>The ZivoeRewards ($stJTT) contract.</td></tr><tr><td>address</td><td>stSTT</td><td>The ZivoeRewards ($stSTT) contract.</td></tr><tr><td>address</td><td>stZVE</td><td>The ZivoeRewards ($stZVE) contract.</td></tr><tr><td>address</td><td>vestZVE</td><td>The ZivoeRewardsVesting ($vestZVE) vesting contract.</td></tr><tr><td>address</td><td>YDL</td><td>The ZivoeYDL contract.</td></tr><tr><td>address</td><td>zJTT</td><td>The ZivoeTrancheToken ($zJTT) contract.</td></tr><tr><td>address</td><td>zSTT</td><td>The ZivoeTrancheToken ($zSTT) contract.</td></tr><tr><td>address</td><td>ZVE</td><td>The ZivoeToken ($ZVE) contract.</td></tr><tr><td>address</td><td>ZVL</td><td>The Zivoe Laboratory.</td></tr><tr><td>address</td><td>ZVT</td><td>The ZivoeTranches contract.</td></tr><tr><td>address</td><td>GOV</td><td>The Governor contract.</td></tr><tr><td>address</td><td>TLC</td><td>The TimelockController contract.</td></tr><tr><td>address</td><td>proposedZVL</td><td>Interim contract for 2FA ZVL access control transfer.</td></tr><tr><td>uint256</td><td>defaults</td><td>Tracks net defaults in the system.</td></tr><tr><td>mapping(address => bool)</td><td>isDepositor</td><td>Whitelist for depositors, responsible for depositing rewards.</td></tr><tr><td>mapping(address => bool)</td><td>isKeeper</td><td>Whitelist for keepers, responsible for pre-initiating actions.</td></tr><tr><td>mapping(address => bool)</td><td>isLocker</td><td>Whitelist for lockers, for ZivoeDAO interactions and accounting accessibility.</td></tr><tr><td>mapping(address => bool)</td><td>stablecoinWhitelist</td><td>Whitelist for accepted stablecoins throughout Zivoe (e.g. ZVT or YDL).</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#adjustedsupplies](#adjustedsupplies "mention") - Returns total circulating supply of zSTT and zJTT adjusted for defaults.
* [#standardize](#standardize "mention") - Handles WEI standardization of a given asset amount (i.e. 6 decimal precision => 18 decimal precision).

[#write-functions](#write-functions "mention")

* [#decreasedefaults](#decreasedefaults "mention") - Call when a default is resolved, decreases net defaults system-wide.
* [#increasedefaults](#increasedefaults "mention") - Call when a default occurs, increases net defaults system-wide.
* [#initializeglobals](#initializeglobals "mention") - Initialze state variables (perform after all contracts have been deployed).
* [#proposezvl](#proposezvl "mention") - Proposes ZVL access control to another account.
* [#acceptzvl](#acceptzvl "mention") - Accept transfer of ZVL access control.
* [#updateisdepositor](#updateisdepositor "mention") - Updates the depositor whitelist.
* [#updateiskeeper](#updateiskeeper "mention") - Updates the keeper whitelist.
* [#updateislocker](#updateislocker "mention") - Modifies the locker whitelist.
* [#updatestablecoinwhitelist](#updatestablecoinwhitelist "mention") - Modifies the stablecoin whitelist.

[#events](#events "mention")

* [#defaultsdecreased](#defaultsdecreased "mention")
* [#defaultsincreased](#defaultsincreased "mention")
* [#transferredzvl](#transferredzvl "mention")
* [#updateddepositorstatus](#updateddepositorstatus "mention")
* [#updatedkeeperstatus](#updatedkeeperstatus "mention")
* [#updatedlockerstatus](#updatedlockerstatus "mention")
* [#updatedstablecoinwhitelist](#updatedstablecoinwhitelist "mention")

## Read Functions

#### `adjustedSupplies()`

Returns total circulating supply of zSTT and zJTT adjusted for defaults.

```solidity
function adjustedSupplies() external view returns (
    uint256 zSTTAdjustedSupply, 
    uint256 zJTTAdjustedSupply
);
```

*Returns*

<table><thead><tr><th width="126.33333333333331">Type</th><th width="210">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>zSTTAdjustedSupply</td><td><code>zSTT.totalSupply()</code> adjusted for defaults.</td></tr><tr><td>uint256</td><td>zJTTAdjustedSupply</td><td><code>zJTT.totalSupply()</code> adjusted for defaults.</td></tr></tbody></table>

#### `standardize()`

Handles WEI standardization of a given asset amount (i.e. 6 decimal precision => 18 decimal precision).

```solidity
function standardize(
    uint256 amount, 
    address asset
) external view returns (uint256 standardizedAmount);
```

<table><thead><tr><th width="135.33333333333331">Type</th><th width="115">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of a given "asset".</td></tr><tr><td>address</td><td>asset</td><td>The asset (ERC-20) from which to standardize the amount to WEI.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="140.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>standardizedAmount</td><td>The input "amount" standardized to 18 decimals.</td></tr></tbody></table>

## Write Functions

#### `decreaseDefaults()`

Call when a default is resolved, decreases net defaults system-wide.

```solidity
function decreaseDefaults(uint256 amount) external;
```

<table><thead><tr><th width="134.33333333333331">Type</th><th width="139">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to decrease defaults.</td></tr></tbody></table>

Emits the [#defaultsdecreased](#defaultsdecreased "mention") event

#### `increaseDefaults()`

Call when a default occurs, increases net defaults system-wide.

```solidity
function increaseDefaults(uint256 amount) external;
```

<table><thead><tr><th width="138.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to increase defaults.</td></tr></tbody></table>

Emits the [#defaultsincreased](#defaultsincreased "mention") event

#### `initializeGlobals()`

Initialze state variables (perform after all contracts have been deployed).

```solidity
function initializeGlobals(
    address[] calldata globals, 
    address[] calldata stablecoins
) external onlyOwner;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="143">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>globals</td><td>Array of addresses representing all core system contracts.</td></tr><tr><td>address[]</td><td>stablecoins</td><td>Array of stablecoins representing initial acceptable stablecoins.</td></tr></tbody></table>

Emits the [#transferredzvl](#transferredzvl "mention") event

#### `proposeZVL()`

Proposes ZVL access control to another account.

```solidity
function proposeZVL(address _proposedZVL) external onlyZVL;
```

<table><thead><tr><th width="148.33333333333331">Type</th><th width="162">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_propsedZVL</td><td>The proposed address for ZVL.</td></tr></tbody></table>

#### `acceptZVL()`

Accept transfer of ZVL access control.

```solidity
function acceptZVL() external;
```

Emits the [#transferredzvl](#transferredzvl "mention") event

#### `updateIsDepositor()`

Updates the depositor whitelist.

```solidity
function updateIsDepositor(address depositor, bool status) external onlyZVL;
```

<table><thead><tr><th width="130.33333333333331">Type</th><th width="135">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>keeper</td><td>The address of the depositor.</td></tr><tr><td>bool</td><td>status</td><td>The status to assign to the "depositor" (true = allowed, false = restricted).</td></tr></tbody></table>

Emits the [#updateddepositorstatus](#updateddepositorstatus "mention")

#### `updateIsKeeper()`

Updates the keeper whitelist.

```solidity
function updateIsKeeper(address keeper, bool status) external onlyZVL;
```

<table><thead><tr><th width="130.33333333333331">Type</th><th width="135">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>keeper</td><td>The address of the keeper.</td></tr><tr><td>bool</td><td>status</td><td>The status to assign to the "keeper" (true = allowed, false = restricted).</td></tr></tbody></table>

Emits the [#updatedkeeperstatus](#updatedkeeperstatus "mention") event

#### `updateIsLocker()`

Modifies the locker whitelist.

```solidity
function updateIsLocker(address locker, bool status) external onlyZVL;
```

<table><thead><tr><th width="138.33333333333331">Type</th><th width="130">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>locker</td><td>The locker to update.</td></tr><tr><td>bool</td><td>status</td><td>The status to assign to the "locker" (true = permitted, false = prohibited).</td></tr></tbody></table>

Emits the [#updatedlockerstatus](#updatedlockerstatus "mention") event

#### `updateStableCoinWhitelist()`

Modifies the stablecoin whitelist.

```solidity
function updateStablecoinWhitelist(
    address stablecoin, 
    bool allowed
) external onlyZVL;
```

<table><thead><tr><th width="137.33333333333331">Type</th><th width="153">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>stablecoin</td><td>The stablecoin to update.</td></tr><tr><td>bool</td><td>allowed</td><td>The value to assign (true = permitted, false = prohibited).</td></tr></tbody></table>

Emits the [#updatedstablecoinwhitelist](#updatedstablecoinwhitelist "mention") event

## Events

#### **`DefaultsDecreased()`**

Emitted during [#decreasedefaults](#decreasedefaults "mention")

```solidity
event DefaultsDecreased(
    address indexed locker, 
    uint256 amount, 
    uint256 updatedDefaults
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker updating the default amount.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>Amount of defaults decreased.</td></tr><tr><td>uint256</td><td>False</td><td>updatedDefaults</td><td>Total default(s) in system after event.</td></tr></tbody></table>

#### **`DefaultsIncreased()`**

Emitted during [#increasedefaults](#increasedefaults "mention")

```solidity
event DefaultsIncreased(
    address indexed locker, 
    uint256 amount, 
    uint256 updatedDefaults
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker updating the default amount.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>Amount of defaults increased.</td></tr><tr><td>uint256</td><td>False</td><td>updatedDefaults</td><td>Total default(s) in system after event.</td></tr></tbody></table>

#### **`TransferredZVL()`**

Emitted during [#initializeglobals](#initializeglobals "mention") and [#acceptzvl](#acceptzvl "mention")

```solidity
event TransferredZVL(address indexed controller);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>controller</td><td>The address representing ZVL.</td></tr></tbody></table>

#### **`UpdatedDepositorStatus()`**

Emitted during [#updateisdepositor](#updateisdepositor "mention")

```solidity
event UpdatedDepositorStatus(address indexed depositor, bool status);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>depositor</td><td>The address whose status as a despositor is being modified.</td></tr><tr><td>bool</td><td>False</td><td>status</td><td>The new status of "depositor".</td></tr></tbody></table>

#### **`UpdatedKeeperStatus()`**

Emitted during [#updateiskeeper](#updateiskeeper "mention")

```solidity
event UpdatedKeeperStatus(address indexed account, bool status);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The address whose status as a keeper is being modified.</td></tr><tr><td>bool</td><td>False</td><td>status</td><td>The new status of "account".</td></tr></tbody></table>

#### **`UpdatedLockerStatus()`**

Emitted during [#updateislocker](#updateislocker "mention")

```solidity
event UpdatedLockerStatus(address indexed locker, bool status);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="106">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>locker</td><td>The locker whose status as a locker is being modified.</td></tr><tr><td>bool</td><td>False</td><td>status</td><td>The new status of "locker".</td></tr></tbody></table>

#### **`UpdatedStablecoinWhitelist()`**

Emitted during [#updatestablecoinwhitelist](#updatestablecoinwhitelist "mention")

```solidity
event UpdatedStablecoinWhitelist(address indexed asset, bool allowed);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>asset</td><td>The stablecoin to update.</td></tr><tr><td>bool</td><td>False</td><td>allowed</td><td>The boolean value to assign.</td></tr></tbody></table>


# ZivoeGovernorV2.sol

Zivoe Governance, Proposal Management

## Introduction

This contract is the governance contract.

This contract has the following responsibilities:

* Proposals are made here.
* Voting is conducted here.
* Increase voting power of stakers and vesters.
* Execute proposals.
* Interface with TimelockController (external contract) to facilitate execution.

#### This contract was adopted from the OpenZeppelin Governance Libary.

For further documentation: <https://docs.openzeppelin.com/contracts/4.x/api/governance>


# ZivoeITO.sol

ITO -> Initial Tranche Offering

## Introduction

This contract will facilitate the Zivoe ITO ("Initial Tranche Offering").

This contract has the following responsibilities:

* Permissioned by $zJTT and $zSTT to call mint() when an account deposits.
* Escrow $zJTT and $zSTT until the ITO concludes.
* Facilitate claiming of $zJTT and $zSTT when the ITO concludes.
* Vest $ZVE simulatenously during claiming (based on $pZVE credits).
* Migrate deposits to ZivoeDAO after the ITO concludes.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-532&t=dZRdvPyeQ9UUEbrY-4>" %}

#### State Variables

<table><thead><tr><th width="195.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address[]</td><td>stablecoins</td><td>Stablecoin(s) allowed for <code>juniorDeposit()</code> or <code>seniorDeposit()</code>.</td></tr><tr><td>uint256</td><td>end</td><td>The unix when the ITO ends (airdrop is claimable).</td></tr><tr><td>uint256</td><td>snapshotSTT</td><td>Snapshot of senior tranche token supply after migrateDeposits().</td></tr><tr><td>uint256</td><td>snapshotJTT</td><td>Snapshot of junior tranche token supply after migrateDeposits().</td></tr><tr><td>bool</td><td>migrated</td><td>Triggers (true) when ITO concludes and assets migrate to ZivoeDAO.</td></tr><tr><td>mapping(address => bool)</td><td>airdropClaimed</td><td>Tracks if an account has claimed their airdrop.</td></tr><tr><td>mapping(address => uint256)</td><td>juniorCredits</td><td>Tracks $pZVE (credits) from <code>juniorDeposit()</code>.</td></tr><tr><td>mapping(address => uint256)</td><td>seniorCredits</td><td>Tracks $pZVE (credits) from <code>seniorDeposit()</code>.</td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr></tbody></table>

## **Sections**

[#write-functions](#write-functions "mention")

* [#commence](#commence "mention") - Starts the ITO.
* [#claimairdrop](#claimairdrop "mention") - Claim $zSTT, $zJTT, and begin a vesting schedule for $ZVE.
* [#depositjunior](#depositjunior "mention") - Deposit stablecoins, mint Zivoe Junior Tranche ($zJTT) tokens and increase airdrop credits.
* [#depositsenior](#depositsenior "mention") - Deposit stablecoins, mint Zivoe Senior Tranche ($zSTT) tokens and increase airdrop credits.
* [#migratedeposits](#migratedeposits "mention") - Migrate tokens to ZivoeDAO.

[#events](#events "mention")

* [#airdropclaimed](#airdropclaimed "mention")
* [#depositsmigrated](#depositsmigrated "mention")
* [#itocommenced](#itocommenced "mention")
* [#juniordeposit](#juniordeposit "mention")
* [#seniordeposit](#seniordeposit "mention")

## Write Functions

#### `commence()`

Starts the ITO.

```solidity
function commence() external;
```

Emits the [#itocommenced](#itocommenced "mention") event.

#### `claimAirdrop()`

Claim $zSTT, $zJTT, and begin a vesting schedule for $ZVE.

```solidity
function claimAirdrop(address depositor) external returns (
    uint256 zSTTClaimed, 
    uint256 zJTTClaimed, 
    uint256 ZVEVested
);
```

<table><thead><tr><th width="124.33333333333331">Type</th><th width="126">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>depositor</td><td>The address to claim for, generally <code>_msgSender()</code></td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="117.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>zSTTClaimed</td><td>Amount of $zSTT airdropped.</td></tr><tr><td>uint256</td><td>zJTTClaimed</td><td>Amount of $zJTT airdropped.</td></tr><tr><td>uint256</td><td>ZVEVested</td><td>Amount of $ZVE vested.</td></tr></tbody></table>

Emits the [#airdropclaimed](#airdropclaimed "mention") event.

#### `depositJunior()`

Deposit stablecoins, mint Zivoe Junior Tranche ($zJTT) tokens and increase airdrop credits.

```solidity
function depositJunior(uint256 amount, address asset) external; 
```

<table><thead><tr><th width="139.33333333333331">Type</th><th width="145">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to deposit.</td></tr><tr><td>uint256</td><td>asset</td><td>The asset to deposit.</td></tr></tbody></table>

Emits the [#juniordeposit](#juniordeposit "mention") event.

#### `depositSenior()`

Deposit stablecoins, mint Zivoe Senior Tranche ($zSTT) tokens and increase airdrop credits.

```solidity
function depositSenior(uint256 amount, address asset) external;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="136">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to deposit.</td></tr><tr><td>uint256</td><td>asset</td><td>The asset to deposit.</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

Emits the [#seniordeposit](#seniordeposit "mention") event.

#### `migrateDeposits()`

Migrate tokens to ZivoeDAO.

```solidity
function migrateDeposits() external;
```

Emits the [#depositsmigrated](#depositsmigrated "mention") event.

## Events

#### **`AirdropClaimed()`**

Emitted during [#claimairdrop](#claimairdrop "mention")

```solidity
event AirdropClaimed(
    address indexed account, 
    uint256 zSTTClaimed, 
    uint256 zJTTClaimed, 
    uint256 ZVEVested
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account claiming their airdrop.</td></tr><tr><td>uint256</td><td>False</td><td>zSTTClaimed</td><td>The amount of Zivoe Senior Tranche ($zSTT) tokens received.</td></tr><tr><td>uint256</td><td>False</td><td>zJTTClaimed</td><td>The amount of Zivoe Junior Tranche ($zJTT) tokens received.</td></tr><tr><td>uint256</td><td>False</td><td>ZVEVested</td><td>The amount of Zivoe ($ZVE) tokens received.</td></tr></tbody></table>

#### **`DepositsMigrated()`**

Emitted during [#migratedeposits](#migratedeposits "mention")

```solidity
event DepositsMigrated(uint256 DAI, uint256 FRAX, uint256 USDC, uint256 USDT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>DAI</td><td>Total amount of DAI migrated from the ITO to ZivoeDAO and ZVL.</td></tr><tr><td>uint256</td><td>False</td><td>FRAX</td><td>Total amount of FRAX migrated from the ITO to ZivoeDAO and ZVL.</td></tr><tr><td>uint256</td><td>False</td><td>USDC</td><td>Total amount of USDC migrated from the ITO to ZivoeDAO and ZVL.</td></tr><tr><td>uint256</td><td>False</td><td>USDT</td><td>Total amount of USDT migrated from the ITO to ZivoeDAO and ZVL.</td></tr></tbody></table>

#### **`ITOCommenced()`**

Emitted during [#commence](#commence "mention")

```solidity
event ITOCommenced(uint256 start, uint256 end);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>start</td><td>The unix when the ITO starts.</td></tr><tr><td>uint256</td><td>False</td><td>end</td><td>The unix when the ITO ends (airdrop is claimable).</td></tr></tbody></table>

#### **`JuniorDeposit()`**

Emitted during [#depositjunior](#depositjunior "mention")

```solidity
event JuniorDeposit(
    address indexed account, 
    address indexed asset, 
    uint256 amount, 
    uint256 credits, 
    uint256 trancheTokens
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account depositing stablecoins to senior tranche.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The stablecoin deposited.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of stablecoins deposited.</td></tr><tr><td>uint256</td><td>False</td><td>credits</td><td>The amount of credits earned.</td></tr><tr><td>uint256</td><td>False</td><td>trancheTokens</td><td>The amount of Zivoe Junior Tranche ($zJTT) tokens minted.</td></tr></tbody></table>

#### **`SeniorDeposit()`**

Emitted during [#depositsenior](#depositsenior "mention")

```solidity
event SeniorDeposit(
    address indexed account, 
    address indexed asset, 
    uint256 amount, 
    uint256 credits, 
    uint256 trancheTokens
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account depositing stablecoins to senior tranche.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The stablecoin deposited.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of stablecoins deposited.</td></tr><tr><td>uint256</td><td>False</td><td>credits</td><td>The amount of credits earned.</td></tr><tr><td>uint256</td><td>False</td><td>trancheTokens</td><td>The amount of Zivoe Senior Tranche ($zSTT) tokens minted.</td></tr></tbody></table>


# ZivoeLocker.sol

Abstract Locker Contract

## Introduction

This contract standardizes communication between the DAO and lockers.

*Note: This is an abstract contract and is inherited by Lockers, see* [Lockers](/developer-docs/lockers)

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for calling `pushToLocker()`.
* [#canpull](#canpull "mention") - Permission for calling `pullFromLocker()`.
* [#canpullpartial](#canpullpartial "mention") - Permission for calling `pullFromLockerPartial()`.
* [#canpushmulti](#canpushmulti "mention") - Permission for calling `pushToLockerMulti()`.
* [#canpullmulti](#canpullmulti "mention") - Permission for calling `pullFromLockerMulti()`.
* [#canpullmultipartial](#canpullmultipartial "mention") - Permission for calling `pullFromLockerMultiPartial()`.
* [#canpusherc721](#canpusherc721 "mention") - Permission for calling `pushFromLockerERC721()`.
* [#canpullerc721](#canpullerc721 "mention") - Permission for calling `pullFromLockerERC721()`.
* [#canpushmultierc721](#canpushmultierc721 "mention") - Permission for calling `pushFromLockerMultiERC721()`.
* [#canpullmultierc721](#canpullmultierc721 "mention") - Permission for calling `pullFromLockerMultiERC721()`.
* [#canpusherc1155](#canpusherc1155 "mention") - Permission for calling `pushToLockerERC1155()`.
* [#canpullerc1155](#canpullerc1155 "mention") - Permission for calling `pullFromLockerERC1155()`.

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - Migrates specific amount of ERC20 from owner() to locker.
* [#pullfromlocker](#pullfromlocker "mention") - Migrates entire ERC20 balance from locker to owner().
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - Migrates specific amount of ERC20 from locker to owner().
* [#pushtolockermulti](#pushtolockermulti "mention") - Migrates specific amounts of ERC20s from owner() to locker.
* [#pullfromlockermulti](#pullfromlockermulti "mention") - Migrates full amount of ERC20s from locker to owner().
* [#pullfromlockermultipartial](#pullfromlockermultipartial "mention") - Migrates specific amounts of ERC20s from locker to owner().
* [#pushtolockererc721](#pushtolockererc721 "mention") - Migrates an ERC721 from owner() to locker.
* [#pullfromlockererc721](#pullfromlockererc721 "mention") - Migrates an ERC721 from locker to owner().
* [#pushtolockermultierc721](#pushtolockermultierc721 "mention") - Migrates ERC721s from owner() to locker.
* [#pullfromlockermultierc721](#pullfromlockermultierc721 "mention") - Migrates ERC721s from locker to owner().
* [#pushtolockererc1155](#pushtolockererc1155 "mention") - Migrates ERC1155 assets from owner() to locker.
* [#pullfromlockererc1155](#pullfromlockererc1155 "mention") - Migrates ERC1155 assets from locker to owner().

## Read Functions

#### `canPush()`

Permission for calling `pushToLocker()`.

```solidity
function canPush() public virtual view returns (bool);
```

#### `canPull()`

Permission for calling `pullFromLocker()`.

```solidity
function canPull() public virtual view returns (bool);
```

#### `canPullPartial()`

Permission for calling `pullFromLockerPartial()`.

```solidity
function canPullPartial() public virtual view returns (bool);
```

#### `canPushMulti()`

Permission for calling `pushToLockerMulti()`.

```solidity
function canPushMulti() public virtual view returns (bool);
```

#### `canPullMulti()`

Permission for calling `pullFromLockerMulti()`.

```solidity
function canPullMulti() public virtual view returns (bool);
```

#### `canPullMultiPartial()`

Permission for calling `pullFromLockerMultiPartial()`.

```solidity
function canPullMultiPartial() public virtual view returns (bool);
```

#### `canPushERC721()`

Permission for calling `pushFromLockerERC721()`.

```solidity
function canPushERC721() public virtual view returns (bool);
```

#### `canPullERC721()`

Permission for calling `pullFromLockerERC721()`.

```solidity
function canPullERC721() public virtual view returns (bool);
```

#### `canPushMultiERC721()`

Permission for calling `pushFromLockerMultiERC721()`.

```solidity
function canPushMultiERC721() public virtual view returns (bool);
```

#### `canPullMultiERC721()`

Permission for calling `pullFromLockerMultiERC721()`.

```solidity
function canPullMultiERC721() public virtual view returns (bool);
```

#### `canPushERC1155()`

Permission for calling `pushToLockerERC1155()`.

```solidity
function canPushERC1155() public virtual view returns (bool);
```

#### `canPullERC1155()`

Permission for calling `pullFromLockerERC1155()`.

```solidity
function canPullERC1155() public virtual view returns (bool);
```

## Write Functions

#### `pushToLocker()`

Migrates specific amount of ERC20 from owner() to locker.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pullFromLocker()`

Migrates entire ERC20 balance from locker to owner().

```solidity
function pullFromLocker(
    address asset, 
    bytes calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pullFromLockerPartial()`

Migrates specific amount of ERC20 from locker to owner().

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pushToLockerMulti()`

Migrates specific amounts of ERC20s from owner() to locker.

```solidity
function pushToLockerMulti(
    address[] calldata assets, 
    uint256[] calldata amounts, 
    bytes[] calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>assets</td><td>The assets to migrate.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amounts of "assets" to migrate, corresponds to "assets" by position in array.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pullFromLockerMulti()`

Migrates full amount of ERC20s from locker to owner().

```solidity
function pullFromLockerMulti(
    address[] calldata assets, 
    bytes[] calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>assets</td><td>The assets to migrate.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pullFromLockerMultiPartial()`

Migrates specific amounts of ERC20s from locker to owner().

```solidity
function pullFromLockerMultiPartial(
    address[] calldata assets, 
    uint256[] calldata amounts, 
    bytes[] calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>assets</td><td>The assets to migrate.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amounts of "assets" to migrate, corresponds to "assets" by position in array.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pushToLockerERC721()`

Migrates an ERC721 from owner() to locker.

```solidity
 function pushToLockerERC721(
     address asset,
     uint256 tokenId,
     bytes calldata data
 ) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The NFT contract.</td></tr><tr><td>uint256</td><td>tokenId</td><td>The ID of the NFT to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pullFromLockerERC721()`

Migrates an ERC721 from locker to owner().

```solidity
function pullFromLockerERC721(
    address asset,
    uint256 tokenId,
    bytes calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The NFT contract.</td></tr><tr><td>uint256</td><td>tokenId</td><td>The ID of the NFT to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pushToLockerMultiERC721()`

Migrates ERC721s from owner() to locker.

```solidity
function pushToLockerMultiERC721(
    address[] calldata assets, 
    uint256[] calldata tokenIds, 
    bytes[] calldata data
) external virutal onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>assets</td><td>The NFT contracts.</td></tr><tr><td>uint256[]</td><td>tokenIds</td><td>The IDs of the NFTs to migrate.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pullFromLockerMultiERC721()`

Migrates ERC721s from locker to owner().

```solidity
function pullFromLockerMultiERC721(
    address[] calldata assets,
    uint256[] calldata tokenIds,
    bytes[] calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>assets</td><td>The NFT contracts.</td></tr><tr><td>uint256[]</td><td>tokenIds</td><td>The IDs of the NFTs to migrate.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pushToLockerERC1155()`

Migrates ERC1155 assets from owner() to locker.

```solidity
function pushToLockerERC1155(
    address asset,
    uint256[] calldata ids,
    uint256[] calldata amounts,
    bytes calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The ERC1155 contract.</td></tr><tr><td>uint256[]</td><td>ids</td><td>The IDs of the assets within the ERC1155 to migrate.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amounts to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `pullFromLockerERC1155()`

Migrates ERC1155 assets from locker to owner().

```solidity
function pullFromLockerERC1155(
    address asset,
    uint256[] calldata ids,
    uint256[] calldata amounts,
    bytes calldata data
) external virtual onlyOwner;
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="183">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The ERC1155 conract.</td></tr><tr><td>uint256[]</td><td>ids</td><td>The IDs of the assets within the ERC1155 to migrate.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amounts to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>


# ZivoeMath.sol

Mathematics for Yield Distributions

## Introduction

This contract facilitates mathematics, intended solely for the YDL.

*Note: This contract is deployed and tracked via ZivoeYDL, see* [ZivoeYDL.sol](/developer-docs/core-contracts/zivoeydl.sol) and for further information on the derivation of the equations, see [Broken mention](broken://pages/LArq3pPT9c3aAHXILOS5)

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr><tr><td>uint256</td><td>WAD</td><td>Private constant, <code>10**18</code></td></tr><tr><td>uint256</td><td>RAY</td><td>Private constant, <code>10**27</code></td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#ema](#ema "mention") - Calculates the current EMA (exponential moving average).
* [#juniorproportion](#juniorproportion "mention") - Calculates proportion of yield attributable to junior tranche.
* [#seniorproportion](#seniorproportion "mention") - Calculates proportion of yield distributble which is attributable to the senior tranche.
* [#seniorproportionbase](#seniorproportionbase "mention") - Calculates proportion of yield attributed to senior tranche (no extenuating circumstances).
* [#seniorproportionshortfall](#seniorproportionshortfall "mention") - Calculates proportion of yield attributed to senior tranche (shortfall occurence).
* [#yieldtarget](#yieldtarget "mention") - Calculates amount of annual yield required to meet target rate for both tranches.

## Read Functions

#### `ema()`

Calculates the current EMA (exponential moving average).

```solidity
function ema(
    uint256 bV, 
    uint256 cV, 
    uint256 N
) external pure returns (uint256 eV);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>bV</td><td>The base value (typically an EMA from prior calculations).</td></tr><tr><td>uint256</td><td>cV</td><td>The current value, which is factored into bV.</td></tr><tr><td>uint256</td><td>N</td><td>Number of steps to average over.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>eV</td><td>EMA-based value given prior and current conditions.</td></tr></tbody></table>

#### `juniorProportion()`

Calculates proportion of yield attributable to junior tranche.

```solidity
function juniorProportion(
    uint256 eSTT,
    uint256 eJTT, 
    uint256 sP,
    uint256 Q
) external pure returns (uint256 jP);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>eSTT</td><td>ema-based supply of zSTT (units = WEI)</td></tr><tr><td>uint256</td><td>eJTT</td><td>ema-based supply of zJTT (units = WEI)</td></tr><tr><td>uint256</td><td>sP</td><td>Proportion of yield attributable to seniors (units = RAY)</td></tr><tr><td>uint256</td><td>Q</td><td>senior to junior tranche target ratio (units = BIPS)</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>jP</td><td>Yield attributable to junior tranche in RAY.</td></tr></tbody></table>

#### `seniorProportion()`

Calculates proportion of yield distributable which is attributable to the senior tranche.

```solidity
function seniorProportion(
    uint256 yD,
    uint256 yT,
    uint256 eSTT, 
    uint256 eJTT, 
    uint256 Y, 
    uint256 Q, 
    uint256 T
) external pure returns (uint256 sP);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>yD</td><td>yield distributable (units = WEI)</td></tr><tr><td>uint256</td><td>yT</td><td>ema-based yield target (units = WEI)</td></tr><tr><td>uint256</td><td>eSTT</td><td>ema-based supply of zSTT (units = WEI)</td></tr><tr><td>uint256</td><td>eJTT</td><td>ema-based supply of zJTT (units = WEI)</td></tr><tr><td>uint256</td><td>Y</td><td>target annual yield for senior tranche (units = BIPS)</td></tr><tr><td>uint256</td><td>Q</td><td>multiple of Y (units = BIPS)</td></tr><tr><td>uint256</td><td>T</td><td># of days between distributions (units = integer)</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>sP</td><td>Proportion of yD attributable to senior tranche.</td></tr></tbody></table>

#### `seniorProportionBase()`

Calculates proportion of yield attributed to senior tranche (no extenuating circumstances).

```solidity
function seniorProportionBase(
    uint256 yD, 
    uint256 eSTT, 
    uint256 Y, 
    uint256 T
) public pure returns (uint256 sPB);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>yD</td><td>yield distributable (units = WEI)</td></tr><tr><td>uint256</td><td>eSTT</td><td>ema-based supply of zSTT (units = WEI)</td></tr><tr><td>uint256</td><td>Y</td><td>target annual yield for senior tranche (units = BIPS)</td></tr><tr><td>uint256</td><td>T</td><td># of days between distributions (units = integer)</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>sPB</td><td>Proportion of yield attributed to senior tranche in RAY.</td></tr></tbody></table>

#### `seniorProportionShortfall()`

Calculates proportion of yield attributed to senior tranche (shortfall occurence).

```solidity
function seniorProportionShortfall(
    uint256 eSTT, 
    uint256 eJTT, 
    uint256 Q
) public pure returns (uint256 sPS);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>eSTT</td><td>ema-based supply of zSTT (units = WEI)</td></tr><tr><td>uint256</td><td>eJTT</td><td>ema-based supply of zJTT (units = WEI)</td></tr><tr><td>uint256</td><td>Q</td><td>multiple of Y (units = BIPS)</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>sPS</td><td>Proportion of yield attributed to senior tranche in RAY.</td></tr></tbody></table>

#### `yieldTarget()`

Calculates amount of annual yield required to meet target rate for both tranches.

```solidity
function yieldTarget(
    uint256 eSTT,
    uint256 eJTT, 
    uint256 Y, 
    uint256 Q, 
    uint256 T
) public pure returns (uint256 yT);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>eSTT</td><td>ema-based supply of zSTT (units = WEI)</td></tr><tr><td>uint256</td><td>eJTT</td><td>ema-based supply of zJTT (units = WEI)</td></tr><tr><td>uint256</td><td>Y</td><td>target annual yield for senior tranche (units = BIPS)</td></tr><tr><td>uint256</td><td>Q</td><td>multiple of Y (units = BIPS)</td></tr><tr><td>uint256</td><td>T</td><td># of days between distributions (units = integer)</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>yT</td><td>yield target for the senior and junior tranche combined.</td></tr></tbody></table>


# ZivoeRewards.sol

Staking for Native Protocol Token(s)

## Introduction

This contract facilitates staking and yield distribution.&#x20;

This contract has the following responsibilities:

* Allows staking and unstaking of modular "stakingToken".
* Allows claiming yield distributed / "deposited" to this contract.
* Allows multiple assets to be added as "rewardToken" for distributions.
* Vests rewardTokens linearly overtime to stakers.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-545&t=pDUTkdcLtKqLuNYh-4>" %}

#### State Variables

<table><thead><tr><th width="212.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address[]</td><td>rewardTokens</td><td>Array of ERC20 tokens distributed as rewards (if present).</td></tr><tr><td>uint256</td><td>_totalSupply</td><td>Total supply of (non-transferrable) LP tokens for reards contract.</td></tr><tr><td>mapping(address => <a data-mention href="#reward">#reward</a>)</td><td>rewardData</td><td>Contains rewards information for each rewardToken.</td></tr><tr><td>mapping(address => mapping(address => (uint256))</td><td>accountRewardPerTokenPaid</td><td>The order is account -> rewardAsset -> amount.</td></tr><tr><td>mapping(address => mapping(address => (uint256))</td><td>rewards</td><td>The order is account -> rewardAsset -> amount.</td></tr><tr><td>mapping(address => uint256)</td><td>_balances</td><td>Contains LP token balance of each account (is 1:1 ratio with amount deposited).</td></tr><tr><td>IERC20</td><td>stakingToken</td><td>IERC20 wrapper for the stakingToken (deposited to receive LP tokens).</td></tr></tbody></table>

#### `Reward`

This struct stores information for reward tokens.

<table><thead><tr><th width="162">Type</th><th width="243">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>rewardsDuration</td><td>How long rewards take to vest, e.g. 30 days.</td></tr><tr><td>uint256</td><td>periodFinish</td><td>When current rewards will finish vesting.</td></tr><tr><td>uint256</td><td>rewardRate</td><td>Rewards emitted per second.</td></tr><tr><td>uint256</td><td>lastUpdateTime</td><td>Last time this data struct was updated.</td></tr><tr><td>uint256</td><td>rewardPerTokenStored</td><td>Last snapshot of rewardPerToken taken.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#balanceof](#balanceof "mention") - Returns the amount of tokens owned by "account", received when depositing via `stake()`.
* [#getrewardforduration](#getrewardforduration "mention") - Returns the total amount of rewards being distributed to everyone for current rewardsDuration.
* [#totalsupply](#totalsupply "mention") - Returns the amount of tokens in existence; these are minted and burned when depositing or withdrawing.
* [#viewaccountrewardpertokenpaid](#viewaccountrewardpertokenpaid "mention") - Returns the last snapshot of rewardPerTokenStored taken for a reward asset.
* [#viewrewards](#viewrewards "mention") - Returns the rewards earned of a specific rewardToken for an address.
* [#earned](#earned "mention") - Provides information on the rewards available for claim.
* [#lasttimerewardapplicable](#lasttimerewardapplicable "mention") - Helper function for assessing distribution timelines.
* [#rewardpertoken](#rewardpertoken "mention") - Cumulative amount of rewards distributed per LP token.

[#write-functions](#write-functions "mention")

* [#addreward](#addreward "mention") - Adds a new asset as a reward to this contract.
* [#depositreward](#depositreward "mention") - Deposits a reward to this contract for distribution.
* [#fullwithdraw](#fullwithdraw "mention") - Simultaneously calls `withdraw()` and `getRewards()` for convenience.
* [#stake](#stake "mention") - Stakes the specified amount of stakingToken to this contract.
* [#stakefor](#stakefor "mention") - Stakes the specified amount of stakingToken to this contract, awarded to someone else.
* [#getrewards](#getrewards "mention") - Claim rewards for all possible \_rewardTokens.
* [#withdraw](#withdraw "mention") - Withdraws the specified amount of stakingToken from this contract.

[#events](#events "mention")

* [#rewardadded](#rewardadded "mention")
* [#rewarddeposited](#rewarddeposited "mention")
* [#rewarddistributed](#rewarddistributed "mention")
* [#staked](#staked "mention")
* [#stakedfor](#stakedfor "mention")
* [#withdrawn](#withdrawn "mention")

## Read Functions

#### `balanceOf()`

Returns the amount of tokens owned by "account", received when depositing via `stake()`.

```solidity
function balanceOf(
    address account
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of tokens owned by "account".</td></tr></tbody></table>

#### `getRewardForDuration()`

Returns the total amount of rewards being distributed to everyone for current rewardsDuration.

```solidity
function getRewardForDuration(
    address _rewardsToken
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="151">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of rewards being distributed.</td></tr></tbody></table>

#### `totalSupply()`

Returns the amount of tokens in existence; these are minted and burned when depositing or withdrawing.

```solidity
function totalSupply() external view returns (uint256 amount);
```

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of tokens in existence.</td></tr></tbody></table>

#### `viewAccountRewardPerTokenPaid()`

Returns the last snapshot of rewardPerTokenStored taken for a reward asset.

```solidity
function viewAccountRewardPerTokenPaid(
    address account, 
    address rewardAsset
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="157">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr><tr><td>address</td><td>rewardAsset</td><td>The reward token for which we want to return the rewardPerTokenstored.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The latest up-to-date value of rewardPerTokenStored.</td></tr></tbody></table>

#### `viewRewards()`

Returns the rewards earned of a specific rewardToken for an address.

```solidity
function viewRewards(
    address account,
    address rewardAsset
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="144">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr><tr><td>address</td><td>rewardAsset</td><td>The asset earned as a reward.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of rewards earned.</td></tr></tbody></table>

#### `earned()`

Provides information on the rewards available for claim.

```solidity
function earned(
    address account, 
    address _rewardsToken
) public view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="156">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of rewards earned.</td></tr></tbody></table>

#### `lastTimeRewardApplicable()`

Helper function for assessing distribution timelines.

```solidity
function lastTimeRewardApplicable(
    address _rewardsToken
) public view returns (uint256 timestamp); 
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="155">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>timestamp</td><td>The most recent time (in UNIX format) at which rewards are available for distribution.</td></tr></tbody></table>

#### `rewardPerToken()`

Cumulative amount of rewards distributed per LP token.

```solidity
function rewardPerToken(
    address _rewardsToken
) public view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="168">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The cumulative amount of rewards distributed per LP token.</td></tr></tbody></table>

## Write Functions

#### `addReward()`

Adds a new asset as a reward to this contract.

```solidity
function addReward(
    address _rewardsToken, 
    uint256 _rewardsDuration
) external;
```

<table><thead><tr><th width="160">Type</th><th width="201.33333333333331">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed</td></tr><tr><td>uint256</td><td>_rewardsDuration</td><td>How long rewards take to vest, e.g. 30 days (denoted in seconds).</td></tr></tbody></table>

Emits the [#rewardadded](#rewardadded "mention") event

#### `depositReward()`

Deposits a reward to this contract for distribution.

```solidity
function depositReward(
    address _rewardsToken, 
    uint256 reward
) external updateReward(address(0)) nonReentrant;
```

<table><thead><tr><th width="149.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr><tr><td>uint256</td><td>reward</td><td>The amount of the _rewardsToken to deposit.</td></tr></tbody></table>

Emits the [#rewarddeposited](#rewarddeposited "mention") event

#### `fullWithdraw()`

Simultaneously calls `withdraw()` and `getRewards()` for convenience.

```solidity
function fullWithdraw() external;
```

Emits the [#withdrawn](#withdrawn "mention") and [#rewarddistributed](#rewarddistributed "mention") event(s)

#### `stake()`

Stakes the specified amount of stakingToken to this contract.

```solidity
function stake(uint256 amount) external nonReentrant updateReward(_msgSender());
```

<table><thead><tr><th width="149.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of the _rewardTokens to deposit.</td></tr></tbody></table>

Emits the [#staked](#staked "mention") event

#### `stakeFor()`

Stakes the specified amount of stakingToken to this contract, awarded to someone else.

```solidity
function stakeFor(
    uint256 amount, 
    address account
) external nonReentrant updateReward(account);
```

<table><thead><tr><th width="149.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of the _rewardsToken to deposit.</td></tr><tr><td>address</td><td>account</td><td>The account to stake for (that ultimately receives the stake).</td></tr></tbody></table>

Emits the [#stakedfor](#stakedfor "mention") event

#### `getRewards()`

Claim rewards for all possible \_rewardTokens.

```solidity
function getRewards() public updateReward(_msgSender());
```

Emits the [#rewarddistributed](#rewarddistributed "mention") event

#### `withdraw()`

Withdraws the specified amount of stakingToken from this contract.

```solidity
function withdraw(uint256 amount) public nonReentrant updateReward(_msgSender());
```

<table><thead><tr><th width="149.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of the _rewardsToken to withdraw.</td></tr></tbody></table>

Emits the [#withdrawn](#withdrawn "mention") event

## Events

#### **`RewardAdded()`**

Emitted during [#addreward](#addreward "mention")

```solidity
event RewardAdded(address indexed reward);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>reward</td><td>The asset that's being distributed.</td></tr></tbody></table>

#### **`RewardDeposited()`**

Emitted during [#depositreward](#depositreward "mention")

```solidity
event RewardDeposited(
    address indexed reward, 
    uint256 amount, 
    address indexed depositor
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>reward</td><td>The asset that's being deposited.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount deposited.</td></tr><tr><td>address</td><td>True</td><td>depositor</td><td>The _msgSender() who deposited said reward.</td></tr></tbody></table>

#### **`RewardDistributed()`**

Emitted during [#getrewardat](#getrewardat "mention")

```solidity
event RewardDistributed(
    address indexed account, 
    address indexed rewardsToken, 
    uint256 reward
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="140">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account receiving a reward.</td></tr><tr><td>address</td><td>True</td><td>rewardsToken</td><td>The ERC20 asset distributed as a reward.</td></tr><tr><td>uint256</td><td>False</td><td>reward</td><td>The amount of "rewardsToken" distributed.</td></tr></tbody></table>

#### **`Staked()`**

Emitted during [#stake](#stake "mention")

```solidity
event Staked(address indexed account, uint256 amount);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account staking "stakingToken".</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "stakingToken" staked.</td></tr></tbody></table>

#### **`StakedFor()`**

Emitted during [#stakefor](#stakefor "mention")

```solidity
event StakedFor(
    address indexed account, 
    uint256 amount, 
    address indexed by
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account receiveing the staked position of "stakingToken".</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "stakingToken" staked.</td></tr><tr><td>address</td><td>True</td><td>by</td><td>The account facilitating the staking.</td></tr></tbody></table>

#### **`Withdrawn()`**

Emitted during [#withdraw](#withdraw "mention")

```solidity
event Withdrawn(address indexed account, uint256 amount);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account withdrawing "stakingToken".</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "stakingToken" to withdraw.</td></tr></tbody></table>


# ZivoeRewardsVesting.sol

Vesting $ZVE Linearly

## Introduction

This contract facilitates staking and yield distribution, as well as vesting tokens.

This contract has the following responsibilities:

* Allows creation of vesting schedules (and revocation) for "vestingToken".&#x20;
* Allows unstaking of vested tokens.
* Allows claiming yield distributed / "deposited" to this contract.
* Allows multiple assets to be added as "rewardToken" for distributions (except for "vestingToken").
* Vests rewardTokens linearly overtime to stakers.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-546&t=zWYnaX4jJkLHscwT-4>" %}

#### State Variables

<table><thead><tr><th width="212.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>vestingToken</td><td>The token vesting, in this case Zivoe ($ZVE).</td></tr><tr><td>address[]</td><td>rewardTokens</td><td>Array of ERC20 tokens distributed as rewards (if present).</td></tr><tr><td>uint256</td><td>vestingTokenAllocated</td><td>The amount of vestingToken currently allocated.</td></tr><tr><td>uint256</td><td>_totalSupply</td><td>Total supply of (non-transferrable) LP tokens for reards contract.</td></tr><tr><td>mapping(address => <a data-mention href="#reward">#reward</a>)</td><td>rewardData</td><td>Contains rewards information for each rewardToken.</td></tr><tr><td>mapping(address => bool)</td><td>vestingScheduleSet</td><td>Tracks if a wallet has been assigned a schedule.</td></tr><tr><td>mapping(address => <a data-mention href="#vestingschedule">#vestingschedule</a>)</td><td>vestingScheduleOf</td><td>Tracks the vesting schedule of accounts.</td></tr><tr><td>mapping(address => mapping(address => (uint256))</td><td>accountRewardPerTokenPaid</td><td>The order is account -> rewardAsset -> amount.</td></tr><tr><td>mapping(address => mapping(address => (uint256))</td><td>rewards</td><td>The order is account -> rewardAsset -> amount.</td></tr><tr><td>mapping(address => uint256)</td><td>_balances</td><td>Contains LP token balance of each account (is 1:1 ratio with amount deposited).</td></tr><tr><td>IERC20</td><td>stakingToken</td><td>IERC20 wrapper for the stakingToken (deposited to receive LP tokens).</td></tr></tbody></table>

#### `Reward`

This struct stores information for reward tokens.

<table><thead><tr><th width="137.33333333333331">Type</th><th width="254">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>rewardsDuration</td><td>How long rewards take to vest, e.g. 30 days.</td></tr><tr><td>uint256</td><td>periodFinish</td><td>When current rewards will finish vesting.</td></tr><tr><td>uint256</td><td>rewardRate</td><td>Rewards emitted per second.</td></tr><tr><td>uint256</td><td>lastUpdateTime</td><td>Last time this data struct was updated.</td></tr><tr><td>uint256</td><td>rewardPerTokenStored</td><td>Last snapshot of rewardPerToken taken.</td></tr></tbody></table>

#### `VestingSchedule`

This struct stores information for vesting schedules.

<table><thead><tr><th width="144.33333333333331">Type</th><th width="205">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>start</td><td>The block.timestamp at which tokens will start vesting.</td></tr><tr><td>uint256</td><td>cliff</td><td>The block.timestamp at which tokens are first claimable.</td></tr><tr><td>uint256</td><td>end</td><td>The block.timestamp at which tokens will stop vesting (finished).</td></tr><tr><td>uint256</td><td>totalVesting</td><td>The total amount to vest.</td></tr><tr><td>uint256</td><td>totalWithdrawn</td><td>The total amount withdrawn so far.</td></tr><tr><td>uint256</td><td>vestingPerSecond</td><td>The amount of vestingToken that vests per second.</td></tr><tr><td>bool</td><td>revokable</td><td>Whether or not this vesting schedule can be revoked.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#balanceof](#balanceof "mention") - Returns the amount of tokens owned by "account", received when depositing via `stake()`.
* [#getrewardforduration](#getrewardforduration "mention") - Returns the total amount of rewards being distributed to everyone for current rewardsDuration.
* [#totalsupply](#totalsupply "mention") - Returns the amount of tokens in existence; these are minted and burned when depositing or withdrawing.
* [#viewaccountrewardpertokenpaid](#viewaccountrewardpertokenpaid "mention") - Returns the last snapshot of rewardPerTokenStored taken for a reward asset.
* [#viewrewards](#viewrewards "mention") - Returns the rewards earned of a specific rewardToken for an address.
* [#viewschedule](#viewschedule "mention") - Provides information for a vesting schedule. See [#vestingschedule](#vestingschedule "mention")
* [#amountwithdrawable](#amountwithdrawable "mention") - Returns the amount of $ZVE tokens a user can withdraw.
* [#earned](#earned "mention") - Provides information on the rewards available for claim.
* [#lasttimerewardapplicable](#lasttimerewardapplicable "mention") - Helper function for assessing distribution timelines.
* [#rewardpertoken](#rewardpertoken "mention") - Cumulative amount of rewards distributed per LP token.

[#write-functions](#write-functions "mention")

* [#addreward](#addreward "mention") - Adds a new asset as a reward to this contract.
* [#depositreward](#depositreward "mention") - Deposits a reward to this contract for distribution.
* [#fullwithdraw](#fullwithdraw "mention") - Simultaneously calls `withdraw()` and `getRewards()` for convenience.
* [#createvestingschedule](#createvestingschedule "mention") - Sets the vestingSchedule for an account.
* [#revokevestingschedule](#revokevestingschedule "mention") - Ends vesting schedule for a given account (if revokable).
* [#getrewards](#getrewards "mention") - Claim rewards for all possible \_rewardTokens.
* [#withdraw](#withdraw "mention") - Withdraws the specified amount of stakingToken from this contract.

[#events](#events "mention")

* [#rewardadded](#rewardadded "mention")
* [#rewarddeposited](#rewarddeposited "mention")
* [#rewarddistributed](#rewarddistributed "mention")
* [#staked](#staked "mention")
* [#vestingschedulecreated](#vestingschedulecreated "mention")
* [#vestingschedulerevoked](#vestingschedulerevoked "mention")
* [#withdrawn](#withdrawn "mention")

## Read Functions

#### `balanceOf()`

Returns the amount of tokens owned by "account", received when depositing via `stake()`.

```solidity
function balanceOf(
    address account
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of tokens owned by "account".</td></tr></tbody></table>

#### `getRewardForDuration()`

Returns the total amount of rewards being distributed to everyone for current rewardsDuration.

```solidity
function getRewardForDuration(
    address _rewardsToken
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="151">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of rewards being distributed.</td></tr></tbody></table>

#### `totalSupply()`

Returns the amount of tokens in existence; these are minted and burned when depositing or withdrawing.

```solidity
function totalSupply() external view returns (uint256 amount);
```

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of tokens in existence.</td></tr></tbody></table>

#### `viewAccountRewardPerTokenPaid()`

Returns the last snapshot of rewardPerTokenStored taken for a reward asset.

```solidity
function viewAccountRewardPerTokenPaid(
    address account, 
    address rewardAsset
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="157">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr><tr><td>address</td><td>rewardAsset</td><td>The reward token for which we want to return the rewardPerTokenstored.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The latest up-to-date value of rewardPerTokenStored.</td></tr></tbody></table>

#### `viewRewards()`

Returns the rewards earned of a specific rewardToken for an address.

```solidity
function viewRewards(
    address account,
    address rewardAsset
) external view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="144">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr><tr><td>address</td><td>rewardAsset</td><td>The asset earned as a reward.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of rewards earned.</td></tr></tbody></table>

#### `viewSchedule()`

Provides information for a vesting schedule. See [#vestingschedule](#vestingschedule "mention")

```solidity
function viewSchedule(address account) external view returns (
    uint256 start, 
    uint256 cliff, 
    uint256 end, 
    uint256 totalVesting, 
    uint256 totalWithdrawn, 
    uint256 vestingPerSecond, 
    bool revokable
);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="144">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="178">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>start</td><td>The block.timestamp at which tokens will start vesting.</td></tr><tr><td>uint256</td><td>cliff</td><td>The block.timestamp at which tokens are first claimable.</td></tr><tr><td>uint256</td><td>end</td><td>The block.timestamp at which tokens will stop vesting (finished).</td></tr><tr><td>uint256</td><td>totalVesting</td><td>The total amount to vest.</td></tr><tr><td>uint256</td><td>totalWithdrawn</td><td>The total amount withdrawn so far.</td></tr><tr><td>uint256</td><td>vestingPerSecond</td><td>The amount of vestingToken that vests per second.</td></tr><tr><td>bool</td><td>revokable</td><td>Whether or not this vesting schedule can be revoked.</td></tr></tbody></table>

#### `amountWithdrawable()`

Returns the amount of $ZVE tokens a user can withdraw.

```solidity
function amountWithdrawable(
    address account
) public view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="144">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to be withdrawn from.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>Withdrawable amount of $ZVE tokens.</td></tr></tbody></table>

#### `earned()`

Provides information on the rewards available for claim.

```solidity
function earned(
    address account, 
    address _rewardsToken
) public view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="156">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to view information of.</td></tr><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of rewards earned.</td></tr></tbody></table>

#### `lastTimeRewardApplicable()`

Helper function for assessing distribution timelines.

```solidity
function lastTimeRewardApplicable(
    address _rewardsToken
) public view returns (uint256 timestamp); 
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="155">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>timestamp</td><td>The most recent time (in UNIX format) at which rewards are available for distribution.</td></tr></tbody></table>

#### `rewardPerToken()`

Cumulative amount of rewards distributed per LP token.

```solidity
function rewardPerToken(
    address _rewardsToken
) public view returns (uint256 amount);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="168">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The cumulative amount of rewards distributed per LP token.</td></tr></tbody></table>

## Write Functions

#### `addReward()`

Adds a new asset as a reward to this contract.

```solidity
function addReward(
    address _rewardsToken, 
    uint256 _rewardsDuration
) external;
```

<table><thead><tr><th width="160">Type</th><th width="201.33333333333331">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed</td></tr><tr><td>uint256</td><td>_rewardsDuration</td><td>How long rewards take to vest, e.g. 30 days (denoted in seconds).</td></tr></tbody></table>

Emits the [#rewardadded](#rewardadded "mention") event

#### `depositReward()`

Deposits a reward to this contract for distribution.

```solidity
function depositReward(
    address _rewardsToken, 
    uint256 reward
) external updateReward(address(0)) nonReentrant;
```

<table><thead><tr><th width="149.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_rewardsToken</td><td>The asset that's being distributed.</td></tr><tr><td>uint256</td><td>reward</td><td>The amount of the _rewardsToken to deposit.</td></tr></tbody></table>

Emits the [#rewarddeposited](#rewarddeposited "mention") event

#### `fullWithdraw()`

Simultaneously calls `withdraw()` and `getRewards()` for convenience.

```solidity
function fullWithdraw() external;
```

Emits the [#withdrawn](#withdrawn "mention") and [#rewarddistributed](#rewarddistributed "mention") event(s)

#### `createVestingSchedule()`

Sets the vestingSchedule for an account.

```solidity
function createVestingSchedule(
    address account,
    uint256 daysToCliff, 
    uint256 daysToVest, 
    uint256 amountToVest, 
    bool revokable
) external onlyZVLorITO;
```

<table><thead><tr><th width="95">Type</th><th width="158.33333333333331">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account vesting $ZVE</td></tr><tr><td>uint256</td><td>daysToCliff</td><td>The number of days before vesting is claimable (a.k.a. cliff period).</td></tr><tr><td>uint256</td><td>daysToVest</td><td>The number of days for the entire vesting period, from beginning to end.</td></tr><tr><td>uint256</td><td>amountToVest</td><td>The amount of tokens being vested.</td></tr><tr><td>bool</td><td>revokable</td><td>If the vested amount can be revoked.</td></tr></tbody></table>

Emits the [#vestingschedulecreated](#vestingschedulecreated "mention") and [#staked](#staked "mention") event

#### `revokeVestingSchedule()`

Ends vesting schedule for a given account (if revokable).

```solidity
function revokeVestingSchedule(
    address account
) external updateReward(account) onlyZVLOrITO nonReentrant;
```

<table><thead><tr><th width="130.33333333333331">Type</th><th width="134">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The acount to revoke a vesting schedule for.</td></tr></tbody></table>

Emits the [#vestingschedulerevoked](#vestingschedulerevoked "mention") event

#### `getRewards()`

Claim rewards for all possible \_rewardTokens.

```solidity
function getRewards() public updateReward(_msgSender());
```

Emits the [#rewarddistributed](#rewarddistributed "mention") event

#### `withdraw()`

Withdraws the specified amount of stakingToken from this contract.

```solidity
function withdraw(uint256 amount) public nonReentrant updateReward(_msgSender());
```

<table><thead><tr><th width="149.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount of the _rewardsToken to withdraw.</td></tr></tbody></table>

Emits the [#withdrawn](#withdrawn "mention") event

## Events

#### **`RewardAdded()`**

Emitted during [#addreward](#addreward "mention")

```solidity
event RewardAdded(address indexed reward);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>reward</td><td>The asset that's being distributed.</td></tr></tbody></table>

#### **`RewardDeposited()`**

Emitted during [#depositreward](#depositreward "mention")

```solidity
event RewardDeposited(
    address indexed reward, 
    uint256 amount, 
    address indexed depositor
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>reward</td><td>The asset that's being deposited.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount deposited.</td></tr><tr><td>address</td><td>True</td><td>depositor</td><td>The _msgSender() who deposited said reward.</td></tr></tbody></table>

#### **`RewardDistributed()`**

Emitted during [#getrewardat](#getrewardat "mention")

```solidity
event RewardDistributed(
    address indexed account, 
    address indexed rewardsToken, 
    uint256 reward
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="142">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account receiving a reward.</td></tr><tr><td>address</td><td>True</td><td>rewardsToken</td><td>The ERC20 asset distributed as a reward.</td></tr><tr><td>uint256</td><td>False</td><td>reward</td><td>The amount of "rewardsToken" distributed.</td></tr></tbody></table>

#### **`Staked()`**

Emitted during [#createvestingschedule](#createvestingschedule "mention")

```solidity
event Staked(address indexed account, uint256 amount);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account staking "stakingToken".</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "stakingToken" staked.</td></tr></tbody></table>

#### **`VestingScheduleCreated()`**

Emitted during [#createvestingschedule](#createvestingschedule "mention")

```solidity
event VestingScheduleCreated(
    address indexed account, 
    uint256 start, 
    uint256 cliff, 
    uint256 end, 
    uint256 totalVesting, 
    uint256 vestingPerSecond, 
    bool revokable
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account that was given a vesting schedule.</td></tr><tr><td>uint256</td><td>False</td><td>start</td><td>The block.timestamp at which tokens will start vesting.</td></tr><tr><td>uint256</td><td>False</td><td>cliff</td><td>The block.timestamp at which tokens are first claimable.</td></tr><tr><td>uint256</td><td>False</td><td>end</td><td>The block.timestamp at which tokens will stop vesting (finished).</td></tr><tr><td>uint256</td><td>False</td><td>totalVesting</td><td>The total amount to vest.</td></tr><tr><td>uint256</td><td>False</td><td>vestingPerSecond</td><td>The amount of vestingToken that vests per second.</td></tr><tr><td>bool</td><td>False</td><td>revokable</td><td>Whether or not this vesting schedule can be revoked.</td></tr></tbody></table>

#### **`VestingScheduleRevoked()`**

Emitted during [#revokevestingschedule](#revokevestingschedule "mention")

```solidity
event VestingScheduleRevoked(
    address indexed account, 
    uint256 amountRevoked, 
    uint256 cliff, 
    uint256 end, 
    uint256 totalVesting, 
    bool revokable
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account that was revoked a vesting schedule.</td></tr><tr><td>uint256</td><td>False</td><td>amountRevoked</td><td>The amount of tokens revoked.</td></tr><tr><td>uint256</td><td>False</td><td>cliff</td><td>The updated value for cliff.</td></tr><tr><td>uint256</td><td>False</td><td>end</td><td>The updated value for end.</td></tr><tr><td>uint256</td><td>False</td><td>totalVesting</td><td>The total amount to vested (claimable).</td></tr><tr><td>bool</td><td>False</td><td>revokable</td><td>The final revokable status of schedule (always false after revocation).</td></tr></tbody></table>

#### **`Withdrawn()`**

Emitted during [#withdraw](#withdraw "mention")

```solidity
event Withdrawn(address indexed account, uint256 amount);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account withdrawing "stakingToken".</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "stakingToken" to withdraw.</td></tr></tbody></table>


# ZivoeToken.sol

Native Governance Token

## Introduction

This ERC20 contract represents the Zivoe ($ZVE) token.

This contract should support the following functionalities:

* Burnable.
* Fixed supply of 25,000,000 $ZVE.
* Facilitates voting by inheriting the ERC20Votes module.

**This contract was adopted from the OpenZeppelin ERC20 Library.**

For further documentation: <https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#ERC20Votes>

## **Sections**

[#write-functions](#write-functions "mention")

* [#burn](#burn "mention")

## Write Functions

`burn()`

Burns $ZVE tokens.

```solidity
function burn(uint256 amount) external virtual;
```


# ZivoeTranches.sol

Minting Tranche Tokens

## Introduction

This contract will facilitate ongoing liquidity provision to Zivoe tranches - Junior, Senior.

This contract will be permissioned by $zJTT and $zSTT to call mint().

This contract will support a whitelist for stablecoins to provide as liquidity.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-548&t=mlIM9OTwAGZpiUIg-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>uint256</td><td>maxTrancheRatioBIPS</td><td>This ratio represents the maximum size allowed for junior tranche, relative to senior tranche. A value of 2,000 represent 20%, thus junior tranche at maximum can be 20% the size of senior tranche.</td></tr><tr><td>uint256</td><td>minZVEPerJTTMint</td><td>These two values control the min/max $ZVE minted per stablecoin deposited to ZivoeTranches.</td></tr><tr><td>uint256</td><td>maxZVEPerJTTMint</td><td>These two values control the min/max $ZVE minted per stablecoin deposited to ZivoeTranches.</td></tr><tr><td>uint256</td><td>lowerRatioIncentiveBIPS</td><td>Basis points ratio between zJTT.totalSupply():zSTT.totalSupply() for maximum rewards (affects above slope).</td></tr><tr><td>uint256</td><td>upperRatioIncentiveBIPS</td><td>Basis points ratio between zJTT.totalSupply():zSTT.totalSupply() for maximum rewards (affects above slope).</td></tr><tr><td>bool</td><td>tranchesUnlocked</td><td>Prevents contract from supporting functionality until unlocked.</td></tr><tr><td>bool</td><td>paused</td><td>Temporary mechanism for pausing deposits.</td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#isjunioropen](#isjunioropen "mention") - Checks if stablecoins deposits into the Junior Tranche are open.
* [#rewardzvejuniordeposit](#rewardzvejuniordeposit "mention") - Returns the total rewards in $ZVE for a certain junior tranche deposit amount.
* [#rewardzveseniordeposit](#rewardzveseniordeposit "mention") - Returns the total rewards in $ZVE for a certain senior tranche deposit amount.

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - This pulls capital from the DAO, does any necessary pre-conversions, and escrows ZVE for incentives.
* [#depositjunior](#depositjunior "mention") - Deposit stablecoins into the junior tranche. Mints Zivoe Junior Tranche ($zJTT) tokens in 1:1 ratio.
* [#depositsenior](#depositsenior "mention") - Deposit stablecoins into the senior tranche. Mints Zivoe Senior Tranche ($zSTT) tokens in 1:1 ratio.
* [#switchpause](#switchpause "mention") - Pauses or unpauses the contract, enabling or disabling depositJunior() and depositSenior().
* [#updatelowerratioincentivebips](#updatelowerratioincentivebips "mention") - Updates the lower ratio between tranches for minting incentivization model.
* [#updatemaxtrancheratio](#updatemaxtrancheratio "mention") - Updates the maximum size of junior tranche, relative to senior tranche.
* [#updatemaxzveperjttmint](#updatemaxzveperjttmint "mention") - Updates the maximum $ZVE minted per stablecoin deposited to ZivoeTranches.
* [#updateminzveperjttmint](#updateminzveperjttmint "mention") - Updates the minimum $ZVE minted per stablecoin deposited to ZivoeTranches.
* [#updateupperratioincentivebips](#updateupperratioincentivebips "mention") - Updates the upper ratio between tranches for minting incentivization model.
* [#unlock](#unlock "mention") - Unlocks this contract for distributions, sets some initial variables.

[#events](#events "mention")

* [#juniordeposit](#juniordeposit "mention")
* [#seniordeposit](#seniordeposit "mention")
* [#updatedlowerratioincentivebips](#updatedlowerratioincentivebips "mention")
* [#updatedmaxtrancheratiobips](#updatedmaxtrancheratiobips "mention")
* [#updatedmaxzveperjttmint](#updatedmaxzveperjttmint "mention")
* [#updatedminzveperjttmint](#updatedminzveperjttmint "mention")
* [#updatedupperratioincentivebips](#updatedupperratioincentivebips "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `isJuniorOpen()`

Checks if stablecoins deposits into the Junior Tranche are open.

```solidity
function isJuniorOpen(
    uint256 amount,
    address asset
) public view returns (bool open);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to deposit.</td></tr><tr><td>address</td><td>asset</td><td>The asset (stablecoin) to deposit.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>bool</td><td>open</td><td>Will return "true" if deposits into the Junior Tranche are open.</td></tr></tbody></table>

#### `rewardZVEJuniorDeposit()`

Returns the total rewards in $ZVE for a certain junior tranche deposit amount.

```solidity
function rewardZVEJuniorDeposit(
    uint256 deposit
) public view returns (uint256 reward);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>deposit</td><td>The amount supplied to the junior tranche.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>reward</td><td>The rewards in $ZVE to be received.</td></tr></tbody></table>

#### `rewardZVESeniorDeposit()`

Returns the total rewards in $ZVE for a certain senior tranche deposit amount.

```solidity
function rewardZVESeniorDeposit(
    uint256 deposit
) public view returns (uint256 reward);
```

<table><thead><tr><th width="143.33333333333331">Type</th><th width="120">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>deposit</td><td>The amount supplied to the senior tranche.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="148.33333333333331">Type</th><th width="121">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>reward</td><td>The rewards in $ZVE to be received.</td></tr></tbody></table>

## Write Functions

#### `pushToLocker()`

This pulls capital from the DAO, does any necessary pre-conversions, and escrows ZVE for incentives.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override onlyOwner;
```

<table><thead><tr><th width="178.33333333333331">Type</th><th width="177">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>asset</td><td>The asset to pull from the DAO.</td></tr><tr><td>address</td><td>amount</td><td>The amount of asset to pull from the DAO.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `depositBoth()`

Deposit stablecoins to both tranches simultaneously

```solidity
function depositBoth(
    uint256 amountSenior, 
    address assetSenior, 
    uint256 amountJunior, 
    address assetJunior
) external;
```

<table><thead><tr><th width="122">Type</th><th width="173.66666666666669">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amountSenior</td><td>The amount to deposit to senior tranche</td></tr><tr><td>address</td><td>assetSenior</td><td>The asset to deposit to senior tranche</td></tr><tr><td>uint256</td><td>amountJunior</td><td>The amount to deposit to senior tranche</td></tr><tr><td>address</td><td>assetJunior</td><td>The asset to deposit to senior tranche</td></tr></tbody></table>

#### `depositBothInverse()`

Deposit stablecoins to both tranches simultaneously, inverse order

```solidity
function depositBothInverse(
    uint256 amountSenior, 
    address assetSenior, 
    uint256 amountJunior, 
    address assetJunior
) external;
```

<table><thead><tr><th width="122">Type</th><th width="173.66666666666669">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amountSenior</td><td>The amount to deposit to senior tranche</td></tr><tr><td>address</td><td>assetSenior</td><td>The asset to deposit to senior tranche</td></tr><tr><td>uint256</td><td>amountJunior</td><td>The amount to deposit to senior tranche</td></tr><tr><td>address</td><td>assetJunior</td><td>The asset to deposit to senior tranche</td></tr></tbody></table>

#### `depositJunior()`

Deposit stablecoins into the junior tranche. Mints Zivoe Junior Tranche ($zJTT) tokens in 1:1 ratio.

```solidity
function depositJunior(
    uint256 amount, 
    address asset
) external notPaused nonReentrant;
```

<table><thead><tr><th width="122">Type</th><th width="173.66666666666669">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to deposit.</td></tr><tr><td>address</td><td>asset</td><td>The asset (stablecoin) to deposit.</td></tr></tbody></table>

Emits the [#juniordeposit](#juniordeposit "mention") event

#### `depositSenior()`

Deposit stablecoins into the senior tranche. Mints Zivoe Senior Tranche ($zSTT) tokens in 1:1 ratio.

```solidity
function depositSenior(
    uint256 amount, 
    address asset
) external notPaused nonReentrant;
```

<table><thead><tr><th width="127.66666666666669">Type</th><th width="147">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to deposit.</td></tr><tr><td>asset</td><td>asset</td><td>The asset (stablecoin) to deposit.</td></tr></tbody></table>

Emits the [#seniordeposit](#seniordeposit "mention") event

#### `switchPause()`

Pauses or unpauses the contract, enabling or disabling depositJunior() and depositSenior().

```solidity
function switchPause() external;
```

#### `updateLowerRatioIncentiveBIPS()`

Updates the lower ratio between tranches for minting incentivization model.

```solidity
function updateLowerRatioIncentiveBIPS(
    uint256 _lowerRatioIncentiveBIPS
) external onlyGovernance;
```

<table><thead><tr><th width="127.66666666666669">Type</th><th width="235">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_lowerRatioIncentiveBIPS</td><td>The lower ratio to incentivize minting.</td></tr></tbody></table>

Emits the [#updatedlowerratioincentivebips](#updatedlowerratioincentivebips "mention") event

#### `updateMaxTrancheRatio()`

Updates the maximum size of junior tranche, relative to senior tranche.

```solidity
function updateMaxTrancheRatio(uint256 ratio) external onlyGovernance;
```

<table><thead><tr><th width="127.66666666666669">Type</th><th width="147">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>ratio</td><td>The new ratio value.</td></tr></tbody></table>

Emits the [#updatedmaxtrancheratiobips](#updatedmaxtrancheratiobips "mention") event

#### `updateMaxZVEPerJTTMint()`

Updates the maximum $ZVE minted per stablecoin deposited to ZivoeTranches.

```solidity
function updateMaxZVEPerJTTMint(uint256 max) external onlyGovernance;
```

<table><thead><tr><th width="127.66666666666669">Type</th><th width="147">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>max</td><td>Maximum $ZVE minted per stablecoin.</td></tr></tbody></table>

Emits the [#updatedmaxzveperjttmint](#updatedmaxzveperjttmint "mention")

#### `updateMinZVEPerJTTMint()`

Updates the minimum $ZVE minted per stablecoin deposited to ZivoeTranches.

```solidity
function updateMinZVEPerJTTMint(uint256 min) external onlyGovernance;
```

<table><thead><tr><th width="127.66666666666669">Type</th><th width="147">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>min</td><td>Minimum $ZVE minted per stablecoin.</td></tr></tbody></table>

Emits the [#updatedminzveperjttmint](#updatedminzveperjttmint "mention") event

#### `updateUpperRatioIncentiveBIPS()`

Updates the upper ratio between tranches for minting incentivization model.

```solidity
function updateUpperRatioIncentiveBIPS(
    uint256 _upperRatioIncentiveBIPS
) external onlyGovernance;
```

<table><thead><tr><th width="127.66666666666669">Type</th><th width="227">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_upperRatioIncentivBIPS</td><td>The upper ratio to incentivize minting.</td></tr></tbody></table>

Emits the [#updatedupperratioincentivebips](#updatedupperratioincentivebips "mention") event

#### `unlock()`

Unlocks this contract for distributions, sets some initial variables.

```solidity
function unlock() external;
```

## Events

#### **`JuniorDeposit()`**

Emitted during [#depositjunior](#depositjunior "mention")

```solidity
event JuniorDeposit(
    address indexed account, 
    address indexed asset, 
    uint256 amount, 
    uint256 incentives
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account depositing stablecoins to junior tranche.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The stablecoind deposited.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of stablecoins deposited.</td></tr><tr><td>uint256</td><td>False</td><td>incentives</td><td>The amount of incentives ($ZVE) distributed.</td></tr></tbody></table>

#### **`SeniorDeposit()`**

Emitted during [#depositsenior](#depositsenior "mention")

```solidity
event SeniorDeposit(
    address indexed account, 
    address indexed asset, 
    uint256 amount, 
    uint256 incentives
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account depositing stablecoins to senior tranche.</td></tr><tr><td>address</td><td>True</td><td>asset</td><td>The stablecoind deposited.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of stablecoins deposited.</td></tr><tr><td>uint256</td><td>False</td><td>incentives</td><td>The amount of incentives ($ZVE) distributed.</td></tr></tbody></table>

#### **`UpdatedLowerRatioIncentiveBIPS()`**

Emitted during [#updatelowerratioincentivebips](#updatelowerratioincentivebips "mention")

```solidity
event UpdatedLowerRatioIncentiveBIPS(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of lowerRatioJTT.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of lowerRatioJTT.</td></tr></tbody></table>

#### **`UpdatedMaxTrancheRatioBIPS()`**

Emitted during [#updatemaxtrancheratio](#updatemaxtrancheratio "mention")

```solidity
event UpdatedMaxTrancheRatioBIPS(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of maxTrancheRatioBIPS.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of maxTrancheRatioBIPS.</td></tr></tbody></table>

#### **`UpdatedMaxZVEPerJTTMint()`**

Emitted during [#updatemaxzveperjttmint](#updatemaxzveperjttmint "mention")

```solidity
event UpdatedMaxZVEPerJTTMint(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of maxZVEPerJTTMint.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of maxZVEPerJTTMint.</td></tr></tbody></table>

#### **`UpdatedMinZVEPerJTTMint()`**

Emitted during [#updateminzveperjttmint](#updateminzveperjttmint "mention")

```solidity
event UpdatedMinZVEPerJTTMint(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of minZVEPerJTTMint.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of minZVEPerJTTMint.</td></tr></tbody></table>

#### **`UpdatedUpperRatioIncentiveBIPS()`**

Emitted during [#updateupperratioincentivebips](#updateupperratioincentivebips "mention")

```solidity
event UpdatedUpperRatioIncentiveBIPS(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of upperRatioJTT.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of upperRatioJTT.</td></tr></tbody></table>


# ZivoeTrancheToken.sol

Native Tranche Token

## Introduction

This ERC20 contract outlines the tranche token functionality.

This contract should support the following functionalities:

* Mintable.
* Burnable.
* Inherit the ownable library to handle temporary minterRole management.

**This contract was adopted from the OpenZeppelin ERC20 Library.**

For further documentation, see: <https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#ERC20>

#### State Variables

<table><thead><tr><th width="205.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>mapping(address => bool)</td><td>_isMinter</td><td>Whitelist for accessibility to mint() function, exposed in isMinter() view function.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#isminter](#isminter "mention") - Returns the whitelist status of account for accessibility to `mint()` function.

[#write-functions](#write-functions "mention")

* [#burn](#burn "mention") - Burns $zTT (Zivoe Tranche Tokens).
* [#changeminterrole](#changeminterrole "mention") - Update an account's permission for access to `mint()` function.
* [#mint](#mint "mention") - Mints $zTT (Zivoe Tranche Tokens).

[#events](#events "mention")

* &#x20;[#minterupdated](#minterupdated "mention")

## Read Functions

#### `isMinter()`

Returns the whitelist status of account for accessibility to `mint()` function.

```solidity
function isMinter(address account) external view returns (bool minter);
```

<table><thead><tr><th width="139.33333333333331">Type</th><th width="145">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The amount to deposit.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="139.33333333333331">Type</th><th width="145">Name</th><th>Description</th></tr></thead><tbody><tr><td>bool</td><td>minter</td><td>Returns true if account is allowed to access the <code>mint()</code> function.</td></tr></tbody></table>

## Write Functions

#### `burn()`

Burns $zTT (Zivoe Tranche Tokens).

```solidity
function burn(uint256 amount) external;
```

<table><thead><tr><th width="139.33333333333331">Type</th><th width="145">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The number of $zTT tokens to burn.</td></tr></tbody></table>

#### `changeMinterRole()`

Update an account's permission for access to `mint()` function.

```solidity
function changeMinterRole(address account, bool allowed) external onlyOwner;
```

<table><thead><tr><th width="139.33333333333331">Type</th><th width="145">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to change permission for.</td></tr><tr><td>bool</td><td>allowed</td><td>The permission to give account (true = permitted, false = prohibited).</td></tr></tbody></table>

Emits the [#minterupdated](#minterupdated "mention") event.

#### `mint()`

Mints $zTT (Zivoe Tranche Tokens).

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

<table><thead><tr><th width="139.33333333333331">Type</th><th width="145">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account to mint tokens for.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of $zTT tokens to mint for account.</td></tr></tbody></table>

## Events

#### **`MinterUpdated()`**

Emitted during [#changeminterrole](#changeminterrole "mention")

```solidity
event MinterUpdated(address indexed account, bool allowed);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>account</td><td>The account who is receiving or losing the minter role.</td></tr><tr><td>bool</td><td>False</td><td>allowed</td><td>If true, account receives minter privlidges, if false the account loses minter privlidges.</td></tr></tbody></table>


# ZivoeYDL.sol

YDL -> Yield Distribution Locker

## Introduction

This contract manages the accounting for distributing yield across multiple contracts.

This contract has the following responsibilities:

* Escrows yield in between distribution periods.
* Manages accounting for yield distribution.
* Supports modification of certain state variables for governance purposes.
* Tracks historical values using EMA (exponential moving average) on 30-day basis.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-547&t=qclDyOdCku2fPByD-4>" %}

#### State Variables

<table><thead><tr><th width="194.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td><a data-mention href="#recipients">#recipients</a></td><td>protocolRecipients</td><td>Tracks the distributions for protocol earnings.</td></tr><tr><td><a data-mention href="#recipients">#recipients</a></td><td>residualRecipients</td><td>Tracks the distributions for residual earnings.</td></tr><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>distributedAsset</td><td>The "stablecoin" that will be distributed via YDL.</td></tr><tr><td>uint256</td><td>emaSTT</td><td>Weighted moving average for senior tranche size, a.k.a. zSTT.totalSupply().</td></tr><tr><td>uint256</td><td>emaJTT</td><td>Weighted moving average for junior tranche size, a.k.a. zJTT.totalSupply().</td></tr><tr><td>uint256</td><td>distributionCounter</td><td>Number of calls to distributeYield().</td></tr><tr><td>uint256</td><td>lastDistribution</td><td>Used for timelock constraint to call distributeYield().</td></tr><tr><td>uint256</td><td>targetAPYBIPS</td><td>The target annualized yield for senior tranche.</td></tr><tr><td>uint256</td><td>targetRatioBIPS</td><td>The target ratio of junior to senior tranche.</td></tr><tr><td>uint256</td><td>protocolEarningsRateBIPS</td><td>The protocol earnings rate.</td></tr><tr><td>uint256</td><td>daysBetweenDistributions</td><td>Number of days between yield distributions.</td></tr><tr><td>uint256</td><td>retrospectiveDistributions</td><td>Retrospective moving average period.</td></tr><tr><td>bool</td><td>unlocked</td><td>Prevents contract from supporting functionality until unlocked.</td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr><tr><td>uint256</td><td>RAY</td><td>Private constant, <code>10**27</code></td></tr><tr><td><a data-mention href="/pages/iVkZJLTSihlTUzGYyq3Y">/pages/iVkZJLTSihlTUzGYyq3Y</a></td><td>MATH</td><td>Refers to the ZivoeMath contract,</td></tr></tbody></table>

#### `Recipients`

This struct stores information for distributions of yield (used for earnings and residual).

<table><thead><tr><th width="145.33333333333331">Type</th><th width="168">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>recipients</td><td>An array of addresses that will benefit from protocol earnings.</td></tr><tr><td>uint256[]</td><td>proportion</td><td>An array of weights in BIPS for each specific recipient above.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#earningstrancheuse](#earningstrancheuse "mention") - Calculates the distribution of yield ("earnings") for the four primary groups.
* [#viewdistributions](#viewdistributions "mention") - View distribution information for protocol and residual earnings recipients.

[#write-functions](#write-functions "mention")

* [#distributeyield](#distributeyield "mention") - Distributes available yield within this contract to appropriate entities.
* [#returnasset](#returnasset "mention") - Returns an asset to DAO if not `distributedAsset()`.
* [#unlock](#unlock "mention") - Unlocks this contract for distributions, initializes values.
* [#updatedistributedasset](#updatedistributedasset "mention") - Updates the distributed asset for this particular contract.
* [#updateprotocolearningsratebips](#updateprotocolearningsratebips "mention") - Updates the state variable "protocolEarningsRateBIPS".
* [#updaterecipients](#updaterecipients "mention") - Updates the protocolRecipients or residualRecipients.
* [#updatetargetapybips](#updatetargetapybips "mention") - Updates the state variable "targetAPYBIPS".
* [#updatetargetratiobips](#updatetargetratiobips "mention") - Updates the state variable "targetRatioBIPS".

[#events](#events "mention")

* [#assetreturned](#assetreturned "mention")
* [#updateddistributedasset](#updateddistributedasset "mention")
* [#updatedprotocolearningsratebips](#updatedprotocolearningsratebips "mention")
* [#updatedprotocolrecipients](#updatedprotocolrecipients "mention")
* [#updatedresidualrecipients](#updatedresidualrecipients "mention")
* [#updatedtargetapybips](#updatedtargetapybips "mention")
* [#updatedtargetratiobips](#updatedtargetratiobips "mention")
* [#yielddistributed](#yielddistributed "mention")
* [#yielddistributedsingle](#yielddistributedsingle "mention")

## Read Functions

#### `earningsTrancheuse()`

Calculates the distribution of yield ("earnings") for the four primary groups.

```solidity
function earningsTrancheuse(
    uint256 yP, 
    uint256 yD
) public view returns (
    uint256[] memory protocol, 
    uint256 senior, 
    uint256 junior, 
    uint256[] memory residual
);
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>yP</td><td>Yield for the protocol.</td></tr><tr><td>uint256</td><td>yD</td><td>Yield for the remaining three groups.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="160.33333333333331">Type</th><th width="181">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256[]</td><td>protocol</td><td>Protocol earnings.</td></tr><tr><td>uint256</td><td>senior</td><td>Senior tranche earnings.</td></tr><tr><td>uint256</td><td>junior</td><td>Junior tranche earnings.</td></tr><tr><td>uint256[]</td><td>residual</td><td>Residual earnings.</td></tr></tbody></table>

#### `viewDistributions()`

View distribution information for protocol and residual earnings recipients.

```solidity
function viewDistributions() external view returns (
    address[] memory protocolEarningsRecipients, 
    uint256[] memory protocolEarningsProportion, 
    address[] memory residualEarningsRecipients, 
    uint256[] memory residualEarningsProportion
);
```

*Returns*

<table><thead><tr><th width="160.33333333333331">Type</th><th width="181">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>protocolEarningsRecipients</td><td>The destinations for protocol earnings distributions.</td></tr><tr><td>uint256[]</td><td>protocolEarningsProportion</td><td>The proportions for protocol earnings distributions.</td></tr><tr><td>address[]</td><td>residualEarningsRecipients</td><td>The destinations for residual earnings distributions.</td></tr><tr><td>uint256[]</td><td>residualEarningsProportion</td><td>The proportions for residual earnings distributions.</td></tr></tbody></table>

## Write Functions

#### `distributeYield()`

Distributes available yield within this contract to appropriate entities.

```solidity
function distributeYield() external;
```

Emits the [#yielddistributed](#yielddistributed "mention") and [#yielddistributedsingle](#yielddistributedsingle "mention") event(s)

#### `returnAsset()`

Returns an asset to DAO if not `distributedAsset()`.

```solidity
function returnAsset(address asset) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to return.</td></tr></tbody></table>

Emits the [#assetreturned](#assetreturned "mention") event

#### `unlock()`

Unlocks this contract for distributions, initializes values.

```solidity
function unlock() external;
```

#### `updateDistributedAsset()`

Updates the distributed asset for this particular contract.

```solidity
function updateDistributedAsset(address _distributedAsset) external nonReentrant;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>_distributedAsset</td><td>The new value for distributed asset.</td></tr></tbody></table>

Emits the [#updateddistributedasset](#updateddistributedasset "mention") event

#### `updateProtocolEarningsRateBIPS()`

Updates the state variable "protocolEarningsRateBIPS".

```solidity
function updateProtocolEarningsRateBIPS(uint256 _protocolEarningsRateBIPS) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_protocolEarningsRateBIPS</td><td>The new value for protocolEarningsRateBIPS.</td></tr></tbody></table>

Emits the [#updatedprotocolearningsratebips](#updatedprotocolearningsratebips "mention") event

#### `updateRecipients()`

Updates the protocolRecipients or residualRecipients.

```solidity
function updateRecipients(
    address[] memory recipients, 
    uint256[] memory proportions, 
    bool protocol
) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>recipients</td><td>An array of addresses to which protocol earnings will be distributed.</td></tr><tr><td>uint256[]</td><td>proportions</td><td>An array of ratios relative to the recipients - in BIPS. Sum should equal to 10000.</td></tr><tr><td>bool</td><td>protocol</td><td>Specifiy "true" to update protocol earnings, or "false" to update residual earnings.</td></tr></tbody></table>

Emits the [#updatedprotocolrecipients](#updatedprotocolrecipients "mention") and [#updatedresidualrecipients](#updatedresidualrecipients "mention") event(s)

#### `updateTargetAPYBIPS()`

Updates the state variable "targetAPYBIPS".

```solidity
function updateTargetAPYBIPS(uint256 _targetAPYBIPS) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_targetAPYBIPS</td><td>The new value for targetAPYBIPS.</td></tr></tbody></table>

Emits the [#updatedtargetapybips](#updatedtargetapybips "mention") event

#### `updateTargetRatioBIPS()`

Updates the state variable "targetRatioBIPS".

```solidity
function updateTargetRatioBIPS(uint256 _targetRatioBIPS) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_targetRatioBIPS</td><td>The new value for targetRatioBIPS.</td></tr></tbody></table>

Emits the [#updatedtargetratiobips](#updatedtargetratiobips "mention") event

## Events

#### **`AssetReturned()`**

Emitted during [#returnasset](#returnasset "mention")

```solidity
event AssetReturned(address indexed asset, uint256 amount);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>asset</td><td>The asset returned.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of "asset" returned to DAO.</td></tr></tbody></table>

#### **`UpdatedDistributedAsset()`**

Emitted during [#updatedistributedasset](#updatedistributedasset "mention")

```solidity
event UpdatedDistributedAsset(address indexed oldAsset, address indexed newAsset);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>oldAsset</td><td>The old value of distributedAsset.</td></tr><tr><td>address</td><td>True</td><td>newAsset</td><td>The new value of distributedAsset.</td></tr></tbody></table>

#### **`UpdatedProtocolEarningsRateBIPS()`**

Emitted during [#updateprotocolearningsratebips](#updateprotocolearningsratebips "mention")

```solidity
event UpdatedProtocolEarningsRateBIPS(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of protocolEarningsRateBIPS.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of protocolEarningsRateBIPS.</td></tr></tbody></table>

#### **`UpdatedProtocolRecipients()`**

Emitted during [#updaterecipients](#updaterecipients "mention")

```solidity
event UpdatedProtocolRecipients(address[] recipients, uint256[] proportion);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>False</td><td>recipients</td><td>The new recipients to receive protocol earnings.</td></tr><tr><td>uint256[]</td><td>False</td><td>proportion</td><td>The proportion distributed across recipients.</td></tr></tbody></table>

#### **`UpdatedResidualRecipients()`**

Emitted during [#updaterecipients](#updaterecipients "mention")

```solidity
event UpdatedResidualRecipients(address[] recipients, uint256[] proportion);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>False</td><td>recipients</td><td>The new recipients to receive residual earnings.</td></tr><tr><td>uint256[]</td><td>False</td><td>proportion</td><td>The proportion distributed across recipients.</td></tr></tbody></table>

#### **`UpdatedTargetAPYBIPS()`**

Emitted during [#updatetargetapybips](#updatetargetapybips "mention")

```solidity
event UpdatedTargetAPYBIPS(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of targetAPYBIPS.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of targetAPYBIPS.</td></tr></tbody></table>

#### **`UpdatedTargetRatioBIPS()`**

Emitted during [#updatedtargetratiobips](#updatedtargetratiobips "mention")

```solidity
event UpdatedTargetRatioBIPS(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of targetRatioBIPS.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of targetRatioBIPS.</td></tr></tbody></table>

#### **`YieldDistributed()`**

Emitted during [#distributeyield](#distributeyield "mention")

```solidity
event YieldDistributed(
    uint256[] protocol, 
    uint256 senior, 
    uint256 junior, 
    uint256[] residual
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256[]</td><td>False</td><td>protocol</td><td>The amount of earnings distributed to protocol earnings recipients.</td></tr><tr><td>uint256</td><td>False</td><td>senior</td><td>The amount of earnings distributed to the senior tranche.</td></tr><tr><td>uint256</td><td>False</td><td>junior</td><td>The amount of earnings distributed to the junior tranche.</td></tr><tr><td>uint256[]</td><td>False</td><td>residual</td><td>The amount of earnings distributed to residual earnings recipients.</td></tr></tbody></table>

#### **`YieldDistributedSingle()`**

Emitted during [#distributeyield](#distributeyield "mention")

```solidity
event YieldDistributedSingle(
    address indexed asset, 
    address indexed recipient, 
    uint256 amount
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>asset</td><td>The "asset" being distributed.</td></tr><tr><td>address</td><td>True</td><td>recipient</td><td>The recipient of the distribution.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount distributed</td></tr></tbody></table>


# ZivoeVault.sol

ERC-4626 Vault ($zVLT)

## Introduction

Implements an ERC-4626 vault using zSTT as the underlying asset and auto-stakes into stSTT

This contract has the following features:

* Allows user to mint by depositing zSTT (alternatively,  burn for zSTT)
* Interfaces with a router that automates stablecoin deposits, so users can simply interact with the router and deposit USDT, USDC, etc. to mint **zVLT** tokens
* Auto-compunds yield with `compound()` function to claim any outstanding yield (generally in the form of a stablecoin, USDC) which occurs by minting more zSTT and staking into stSTT

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=4440-557&t=NrqSUJrfnafVBXIu-4>" %}

#### State Variables

<table><thead><tr><th width="194.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>IERC20</td><td>zSTT</td><td>The address of the zSTT token (underlying asset)</td></tr><tr><td>IZivoeRewards</td><td>stSTT</td><td>The address of the ZivoeRewards staking contract</td></tr><tr><td>IZivoeTranches</td><td>ZVT</td><td>The address of the ZivoeTranches contract</td></tr><tr><td>IZivoeGlobals</td><td>GBL</td><td>The address of the ZivoeGlobals contract</td></tr></tbody></table>

## Read Functions

#### `totalAssets()`

Overrides totalAssets(), returns staked amount of zSTT (represented by stSTT)

```solidity
function totalAssets() public view override returns (uint256);
```

*Returns*

<table><thead><tr><th width="160.33333333333331">Type</th><th width="181">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>-</td><td>stSTT balance held in the vault.</td></tr></tbody></table>

## Write Functions

#### `_deposit()`

Overrides \_deposit(), handles staking deposited zSTT (to receive stSTT)

```solidity
function _deposit(
    address caller, 
    address receiver, 
    uint256 assets, 
    uint256 shares
) internal override;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>caller</td><td>The caller of the function.</td></tr><tr><td>address</td><td>receiver</td><td>The receiver of shares.</td></tr><tr><td>uint256</td><td>assets</td><td>The amount of assets to deposit.</td></tr><tr><td>uint256</td><td>shares</td><td>The amount of shares to receive.</td></tr></tbody></table>

#### `_withdraw()`

Overrides \_withdraw(), handles unstaking stSTT (to receive zSTT)

```solidity
function _withdraw(
    address caller, 
    address receiver, 
    address owner, 
    uint256 assets, 
    uint256 shares
) internal override;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>caller</td><td>The caller of the function.</td></tr><tr><td>address</td><td>receiver</td><td>The receiver of shares.</td></tr><tr><td>address</td><td>owner</td><td>The owner of shares.</td></tr><tr><td>uint256</td><td>assets</td><td>The amount of assets to deposit.</td></tr><tr><td>uint256</td><td>shares</td><td>The amount of shares to receive.</td></tr></tbody></table>

#### `compound()`

Claims rewards from stSTT, mints zSTT with USDC, and stakes the zSTT

```solidity
function compound(address stablecoin) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>stablecoin</td><td>The stablecoin to be compounded.</td></tr></tbody></table>

#### `passThrough()`

Returns any external tokens to the DAO.

```solidity
function passThrough(IERC20 asset) external
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="176">Name</th><th>Description</th></tr></thead><tbody><tr><td>IERC20</td><td>asset</td><td>The asset to pass through.</td></tr></tbody></table>


# ZivoeRouter.sol

Interfaces with ZivoeVault

## Introduction

This contract facilitates batched transactions for deposits and withdrawals to ZivoeVault.

This contract has the following features:

* Allows users to mint `zVLT` tokens by depositing stablecoins
* Allows users to deposit using the permit function for gas efficiency

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=4508-629&t=NrqSUJrfnafVBXIu-4>" %}

#### State Variables

<table><thead><tr><th width="194.33333333333331">Type</th><th width="179">Name</th><th>Description</th></tr></thead><tbody><tr><td>IERC20</td><td>zSTT</td><td>The zSTT token address</td></tr><tr><td>IERC20</td><td>ZVE</td><td>The ZVE token address</td></tr><tr><td>IZivoeTranches</td><td>ZVT</td><td>The ZivoeTranches contract address</td></tr><tr><td>IZivoeVault</td><td>VLT</td><td>The ZivoeVault contract address</td></tr></tbody></table>

## Write Functions

#### `depositVault()`

Allows a user to deposit USDC (or any approved stablecoin), mint zSTT, deposit into ZivoeVault, and receive vault tokens.

```solidity
function depositVault(
    address stablecoin, 
    uint256 amount
) external nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>adress</td><td>stablecoin</td><td>The stablecoin to deposit.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of stableocin to deposit.</td></tr></tbody></table>

#### `depositWithPermit()`

Allows a user to deposit USDC (or any approved stablecoin) using a permit, mint zSTT, deposit into ZivoeVault, and receive vault tokens.

```solidity
function depositWithPermit(
    address owner, 
    address stablecoin, 
    uint256 amount, 
    uint256 deadline, 
    uint8 v, 
    bytes32 r, 
    bytes32 s
) external nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>owner</td><td>The owner of the assets to be deposited.</td></tr><tr><td>address</td><td>stablecoin</td><td>The stablecoin to deposit.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of stablecoin to deposit.</td></tr><tr><td>uint256</td><td>deadline</td><td>The permit signature expiration time.</td></tr><tr><td>uint8</td><td>v</td><td>The recovery byte of the permit signature.</td></tr><tr><td>bytes32</td><td>r</td><td>The first 32 bytes of the permit signature.</td></tr><tr><td>bytes32</td><td>s</td><td>The second 32 bytes of the permit signature.</td></tr></tbody></table>


# Lockers

List of Lockers

<table><thead><tr><th width="210" data-type="content-ref">Contract</th><th>Description</th></tr></thead><tbody><tr><td><a href="/pages/sjebJQJX5P6v3SkD7Af3">/pages/sjebJQJX5P6v3SkD7Af3</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>C</strong>redit (<em>direct loans</em>)</td></tr><tr><td><a href="/pages/EamrcGDY2DnFIEfqHpdc">/pages/EamrcGDY2DnFIEfqHpdc</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>E</strong>xponential (<em>exponentially decaying $ZVE emissions schedule</em>)</td></tr><tr><td><a href="/pages/86yd7NxbG4jC26aoq510">/pages/86yd7NxbG4jC26aoq510</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>L</strong>iquidity (<em>for liquidity provisioning</em>)</td></tr><tr><td><a href="/pages/VEVusWycKL5u8enBaN52">/pages/VEVusWycKL5u8enBaN52</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>R</strong>edemptions (<em>for redeeming capital</em>)</td></tr><tr><td><a href="/pages/ly9nF9rPV6iYDHIX9UM1">/pages/ly9nF9rPV6iYDHIX9UM1</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>T</strong>reasury (<em>for tranche conversions, to DAO</em>)</td></tr><tr><td><a href="/pages/A00Ihnu6bnaEiXFfJYoR">/pages/A00Ihnu6bnaEiXFfJYoR</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>T</strong>reasury (<em>for asset conversions, to DAO</em>)</td></tr><tr><td><a href="/pages/Tr7CYktu0D0dFkwNPeLK">/pages/Tr7CYktu0D0dFkwNPeLK</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>T</strong>reasury (<em>for asset conversions, to YDL</em>)</td></tr><tr><td><a href="/pages/R3bWnFy8q0NLU5OPiRSB">/pages/R3bWnFy8q0NLU5OPiRSB</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>T</strong>reasury (<em>for claiming $ZVE, to ZVL</em>)</td></tr><tr><td><a href="/pages/Y66qLC8XJUUXwDSEEtsy">/pages/Y66qLC8XJUUXwDSEEtsy</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>Y</strong>ield (<em>for yield generation, Convex</em>)</td></tr><tr><td><a href="/pages/qr6vCsx8EodCYIQ2EqI4">/pages/qr6vCsx8EodCYIQ2EqI4</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>Y</strong>ield (<em>for yield generation, Convex</em>)</td></tr><tr><td><a href="/pages/CzbhT0DmAmDKX7sHSoOm">/pages/CzbhT0DmAmDKX7sHSoOm</a></td><td><strong>O</strong>n <strong>C</strong>hain <strong>Y</strong>ield (<em>for yield generation, OUSD</em>)</td></tr><tr><td><a href="/pages/Ff7MKbHmclhfVlXOYdYm">/pages/Ff7MKbHmclhfVlXOYdYm</a></td><td>Facilitates swaps via 1INCH v5 protocol.</td></tr></tbody></table>


# OCC\_Modular.sol

OCC -> On-Chain Credit (Loan Management System)

## Introduction

OCC stands for "On-Chain Credit".

A "Bullet" loan is an interest-only loan, with principal repaid in full at the end.

An "Amortization" loan is a principal and interest loan, with consistent payments until fully "Repaid".

This locker is responsible for handling accounting of loans.

This locker is responsible for handling payments and distribution of payments.

This locker is responsible for handling defaults and liquidations (if needed).

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-549&t=20BBLjcVYjmjSO7L-4>" %}

#### State Variables

<table><thead><tr><th width="186.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>stablecoin</td><td>The stablecoin for this OCC contract.</td></tr><tr><td>address</td><td>underwriter</td><td>The entity that is allowed to underwrite (a.k.a. issue) loans.</td></tr><tr><td>address</td><td>OCT_YDL</td><td>Facilitates swaps and forwards distributedAsset() to YDL.</td></tr><tr><td>uint256</td><td>combineCounter</td><td>Incrementor for "combinations" mapping.</td></tr><tr><td>uint256</td><td>loanCounter</td><td>Incrementor for "loans" mapping.</td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr><tr><td>mapping(uint256 => <a data-mention href="#combine">#combine</a>)</td><td>combinations</td><td>Mapping of approved loan combinations.</td></tr><tr><td>mapping(uint256 => bool)</td><td>conversionToAmortization</td><td>Mapping of loans approved for conversion to amortization payment schedule.</td></tr><tr><td>mapping(uint256 => bool)</td><td>conversionToBullet</td><td>Mapping of loans approved for conversion to bullet payment schedule.</td></tr><tr><td>mapping(uint256 => uint256)</td><td>extensions</td><td>Mapping of loans approved for extension, key is the loan ID, output is paymentIntervals extension.</td></tr><tr><td>mapping(uint256 => <a data-mention href="#loan">#loan</a>)</td><td>loans</td><td>Mapping of loans and their information, key is the ID of the loan, output is the Loan struct information.</td></tr><tr><td>mapping(uint256 => uint256)</td><td>refinancing</td><td>Mapping of loans approved for refinancing, key is the ID of the loan, output is APR it can refinance to.</td></tr></tbody></table>

#### `Loan`

This struct stores information for loans.

<table><thead><tr><th width="165.33333333333331">Type</th><th width="238">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>borrower</td><td>The address that receives capital when the loan is funded.</td></tr><tr><td>uint256</td><td>principalOwed</td><td>The amount of principal still owed on the loan.</td></tr><tr><td>uint256</td><td>APR</td><td>The annualized percentage rate charged on the outstanding principal.</td></tr><tr><td>uint256</td><td>APRLateFee</td><td>The APR charged on the outstanding principal if payment is late.</td></tr><tr><td>uint256</td><td>paymentDueBy</td><td>The timestamp (in seconds) for when the next payment is due.</td></tr><tr><td>uint256</td><td>paymentsRemaining</td><td>The number of payments remaining until the loan is "Repaid".</td></tr><tr><td>uint256</td><td>term</td><td>The number of paymentIntervals that will occur (e.g. 12, 24).</td></tr><tr><td>uint256</td><td>paymentInterval</td><td>The interval of time between payments (in seconds).</td></tr><tr><td>uint256</td><td>offerExpiry</td><td>The block.timestamp at which the offer for this loan expires.</td></tr><tr><td>uint256</td><td>gracePeriod</td><td>The number of seconds a borrower has to makePayment() before default.</td></tr><tr><td>int8</td><td>paymentSchedule</td><td>The payment schedule of the loan (0 = "Bullet" or 1 = "Amortization").</td></tr><tr><td><a data-mention href="#loanstate">#loanstate</a></td><td>state</td><td>The state of the loan.</td></tr></tbody></table>

#### `Combine`

This struct stores information for loan combinations.

<table><thead><tr><th width="165.33333333333331">Type</th><th width="196">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256[]</td><td>loans</td><td>The loans approved for combination.</td></tr><tr><td>uint256</td><td>term</td><td>The term of the resulting combined loan.</td></tr><tr><td>uint256</td><td>paymentInterval</td><td>The paymentInterval of the resulting combined loan.</td></tr><tr><td>uint256</td><td>gracePeriod</td><td>The gracePeriod of the resulting combined loan.</td></tr><tr><td>uint256</td><td>expires</td><td>The expiration of this combination.</td></tr><tr><td>int8</td><td>paymentSchedule</td><td>The paymentSchedule of the resulting combined loan.</td></tr><tr><td>bool</td><td>valid</td><td>The validity of the combination (if it can be executed).</td></tr></tbody></table>

#### `LoanState`

This enumerator tracks loan states.

<table><thead><tr><th width="141">State</th><th>Description</th></tr></thead><tbody><tr><td>Null</td><td>Default state, loan isn't offered yet.</td></tr><tr><td>Offered</td><td>Loan offer has been created, not accepted (it could have passed expiry date).</td></tr><tr><td>Active</td><td>Loan has been accepted, is currently receiving payments.</td></tr><tr><td>Repaid</td><td>Loan was accepted, and has been fully repaid.</td></tr><tr><td>Defaulted</td><td>Loan has defaulted, payments were missed, gracePeriod passed, and markDefault() called.</td></tr><tr><td>Cancelled</td><td>Loan offer was created, then cancelled prior to acceptance.</td></tr><tr><td>Resolved</td><td>Loan was accepted, then there was a default, then the full amount of principal was repaid.</td></tr><tr><td>Combined</td><td>Loan was accepted, then combined with other loans while active.</td></tr></tbody></table>

#### `LoanSchedule`

This enumerator tracks the payment schedule type for a loan.

<table><thead><tr><th width="186">State</th><th>Description</th></tr></thead><tbody><tr><td>Bullet</td><td>An interest-only loan, with principal repaid in full at the end.</td></tr><tr><td>Amortization</td><td>A principal and interest loan, with consistent payments until fully "Repaid".</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#loaninfo](#loaninfo "mention") - Returns information for a given loan. Refer to [#loan](#loan "mention")
* [#amountowed](#amountowed "mention") - Returns information for amount owed on next payment of a particular loan

[#write-functions-core](#write-functions-core "mention")

* [#acceptoffer](#acceptoffer "mention") - Funds and initiates a loan.
* [#callloan](#callloan "mention") - Pays off the loan in full, plus additional interest for paymentInterval.
* [#canceloffer](#canceloffer "mention") - Cancels a loan offer.
* [#createoffer](#createoffer "mention") - Create a loan offer.
* [#makepayment](#makepayment "mention") - Make a payment on a loan. Anyone is allowed to make a payment on someone's loan.
* [#markdefault](#markdefault "mention") - Mark a loan insolvent if a payment hasn't been made beyond the corresponding grace period.
* [#markrepaid](#markrepaid "mention") - Underwriter specifies a loan has been repaid fully via interest deposits in terms of off-chain debt.
* [#processpayment](#processpayment "mention") - Process a payment for a loan, on behalf of another borrower.
* [#resolvedefault](#resolvedefault "mention") - Make a full (or partial) payment to resolve an insolvent loan.
* [#supplyinterest](#supplyinterest "mention") - Supply interest to a repaid loan (for arbitrary interest repayment).
* [#updateoctydl](#updateoctydl "mention") - Updates the OCT\_YDL endpoint.

[#write-functions-loan-management](#write-functions-loan-management "mention")

* [#applycombine](#applycombine "mention") - Combines multiple loans into a single loan.
* [#applyconversiontoamortization](#applyconversiontoamortization "mention") - Converts a loan to amortization payment schedule.
* [#applyconversionbullet](#applyconversionbullet "mention") - Converts a loan to bullet payment schedule.
* [#applyextension](#applyextension "mention") - Applies an extension to a loan.
* [#applyrefinance](#applyrefinance "mention") - Refinances a loan.
* [#approvecombine](#approvecombine "mention") - Approves a borrower for combining loans.
* [#approveconversiontoamortization](#approveconversiontoamortization "mention") - Approves a loan for conversion to amortization payment schedule.
* [#approveconversiontobullet](#approveconversiontobullet "mention") - Approves a loan for conversion to bullet payment schedule.
* [#approveextension](#approveextension "mention") - Approves an extension for a loan.
* [#approverefinance](#approverefinance "mention") - Approves a loan for refinancing.
* [#unapprovecombine](#unapprovecombine "mention") - Unapproves a borrower for combining loans.
* [#unapproveconversiontoamortization](#unapproveconversiontoamortization "mention") - Unapproves a loan for conversion to amortization payment schedule.
* [#unapproveconversionbullet](#unapproveconversionbullet "mention") - Unapproves a loan for conversion to bullet payment schedule.
* [#unapproveextension](#unapproveextension "mention") - Unapproves an extension for a loan.
* [#unapproverefinance](#unapproverefinance "mention") - Unapproves a loan for refinancing.

[#events](#events "mention")

* [#combineapplied](#combineapplied "mention")
* [#combineapproved](#combineapproved "mention")
* [#combineloancreated](#combineloancreated "mention")
* [#combineunapproved](#combineunapproved "mention")
* [#conversiontoamortizationapplied](#conversiontoamortizationapplied "mention")
* [#conversiontoamortizationapproved](#conversiontoamortizationapproved "mention")
* [#conversiontoamortizationunapproved](#conversiontoamortizationunapproved "mention")
* [#conversiontobulletapplied](#conversiontobulletapplied "mention")
* [#converesiontobulletapproved](#converesiontobulletapproved "mention")
* [#conversiontobulletunapproved](#conversiontobulletunapproved "mention")
* [#defaultmarked](#defaultmarked "mention")
* [#defaultresolved](#defaultresolved "mention")
* [#extensionapplied](#extensionapplied "mention")
* [#extensionapproved](#extensionapproved "mention")
* [#extensionunapproved](#extensionunapproved "mention")
* [#interestsupplied](#interestsupplied "mention")
* [#loancalled](#loancalled "mention")
* [#offeraccepted](#offeraccepted "mention")
* [#offercancelled](#offercancelled "mention")
* [#offercreated](#offercreated "mention")
* [#paymentmade](#paymentmade "mention")
* [#refinanceapplied](#refinanceapplied "mention")
* [#refinanceapproved](#refinanceapproved "mention")
* [#refinanceunapproved](#refinanceunapproved "mention")
* [#repaidmarked](#repaidmarked "mention")
* [#updatedoctydl](#updatedoctydl "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `loanInfo()`

Returns information for a given loan. Refer to [#loan](#loan "mention")

```solidity
function loanInfo(uint256 id) public view returns (
    address borrower, 
    int8 paymentSchedule,
    uint256[10] memory details
);
```

<table><thead><tr><th width="122.33333333333331">Type</th><th width="118">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="182.33333333333331">Type</th><th width="210">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>borrower</td><td>The borrower of the loan.</td></tr><tr><td>int8</td><td>paymentSchedule</td><td>The structure of the payment schedule.</td></tr><tr><td>uint256[10]</td><td>details</td><td>Loan details. Refer to code block below ...</td></tr></tbody></table>

```
/// @return info The remaining information for the loan:
///                  info[0] = principalOwed
///                  info[1] = APR
///                  info[2] = APRLateFee
///                  info[3] = paymentDueBy
///                  info[4] = paymentsRemaining
///                  info[5] = term
///                  info[6] = paymentInterval
///                  info[7] = offerExpiry
///                  info[8] = gracePeriod
///                  info[9] = loanState
```

#### `amountOwed()`

Returns information for amount owed on next payment of a particular loan

```solidity
function amountOwed(uint256 id) public view returns (
    uint256 principal, 
    uint256 interest,
    uint256 lateFee, 
    uint256 total
);
```

<table><thead><tr><th width="122.33333333333331">Type</th><th width="118">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>principal</td><td>The amount of principal owed.</td></tr><tr><td>uint256</td><td>interest</td><td>The amount of interest owed.</td></tr><tr><td>uint256</td><td>lateFee</td><td>The amount of late fees owed.</td></tr><tr><td>uint256</td><td>total</td><td>Full amount owed, combining principal plus interest.</td></tr></tbody></table>

## Write Functions - Core

#### `acceptOffer()`

Funds and initiates a loan.

```solidity
function acceptOffer(uint256 id) external nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan to pay off early.</td></tr></tbody></table>

Emits the [#offeraccepted](#offeraccepted "mention") event

#### `callLoan()`

Pays off the loan in full, plus additional interest for paymentInterval.

```solidity
function callLoan(uint256 id) external nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan to pay off early.</td></tr></tbody></table>

Emits the [#loancalled](#loancalled "mention") event

#### `cancelOffer()`

Cancels a loan offer.

```solidity
function cancelOffer(uint256 id) isUnderwriter external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr></tbody></table>

Emits the [#offercancelled](#offercancelled "mention") event

#### `createOffer()`

Create a loan offer.

```solidity
function createOffer(
    address borrower,
    uint256 borrowAmount,
    uint256 APR,
    uint256 APRLateFee,
    uint256 term,
    uint256 paymentInterval,
    uint256 gracePeriod,
    int8 paymentSchedule
) isUnderwriter external;
```

<table><thead><tr><th width="173.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>borrower</td><td>The address to borrow (that receives the loan)</td></tr><tr><td>uint256</td><td>borrowAmount</td><td>The amount to borrow (in other words, initial principal).</td></tr><tr><td>uint256</td><td>APR</td><td>The annualized percentage rate charged on the outstanding principal.</td></tr><tr><td>uint256</td><td>APRLateFee</td><td>The APR charged for late payments.</td></tr><tr><td>uint256</td><td>term</td><td>The term or "duration" of the loan (number of paymentIntervals that will occur).</td></tr><tr><td>uint256</td><td>paymentInterval</td><td>The interval of time between payments (in seconds).</td></tr><tr><td>uint256</td><td>gracePeriod</td><td>The number of seconds a borrower has to makePayment() before loan could default.</td></tr><tr><td>int8</td><td>paymentSchedule</td><td>The payment schedule type ("Bullet" or "Amortization").</td></tr></tbody></table>

Emits the [#offercreated](#offercreated "mention") event

#### `makePayment()`

Make a payment on a loan. Anyone is allowed to make a payment on someone's loan.

```solidity
function makePayment(uint256 id) external nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr></tbody></table>

Emits the [#paymentmade](#paymentmade "mention") event

#### `markDefault()`

Mark a loan insolvent if a payment hasn't been made beyond the corresponding grace period.

```solidity
function markDefault(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr></tbody></table>

Emits the [#defaultmarked](#defaultmarked "mention") event

#### `markRepaid()`

Underwriter specifies a loan has been repaid fully via interest deposits in terms of off-chain debt.

```solidity
function markRepaid(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr></tbody></table>

Emits the [#repaidmarked](#repaidmarked "mention") event

#### `processPayment()`

Process a payment for a loan, on behalf of another borrower.

```solidity
function processPayment(uint256 id) external nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr></tbody></table>

Emits the [#paymentmade](#paymentmade "mention") event

#### `resolveDefault()`

Make a full (or partial) payment to resolve an insolvent loan.

```solidity
function resolveDefault(uint256 id, uint256 amount) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of principal to pay down.</td></tr></tbody></table>

Emits the [#defaultresolved](#defaultresolved "mention") event

#### `supplyInterest()`

Supply interest to a repaid loan (for arbitrary interest repayment).

```solidity
function supplyInterest(uint256 id, uint256 amount) external nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the loan.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of interest to supply.</td></tr></tbody></table>

Emits the [#interestsupplied](#interestsupplied "mention") event

#### `updateOCTYDL()`

Updates the OCT\_YDL endpoint.

```solidity
function updateOCTYDL(address _OCT_YDL) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td><code>_OCT_YDL</code></td><td>The new address for OCT_YDL.</td></tr></tbody></table>

Emits the [#updatedoctydl](#updatedoctydl "mention") event

## Write Functions - Loan Management

#### `applyCombine()`

Combines multiple loans into a single loan.

```solidity
function applyCombine(uint256 id) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID to reference from "combinations" mapping.</td></tr></tbody></table>

Emits the [#combineapplied](#combineapplied "mention") and [#combineloancreated](#combineloancreated "mention") event(s)

#### `applyConversionToAmortization()`

Converts a loan to amortization payment schedule.

```solidity
function applyConversionToAmortization(uint256 id) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#conversiontoamortizationapplied](#conversiontoamortizationapplied "mention") event

#### `applyConversionBullet()`

Converts a loan to bullet payment schedule.

```solidity
function applyConversionToBullet(uint256 id) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#conversiontobulletapplied](#conversiontobulletapplied "mention") event

#### `applyExtension()`

Applies an extension to a loan.

```solidity
function applyExtension(uint256 id) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#extensionapplied](#extensionapplied "mention") event

#### `applyRefinance()`

Refinances a loan.

```solidity
function applyRefinance(uint256 id) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#refinanceapplied](#refinanceapplied "mention")

#### `approveCombine()`

Approves a borrower for combining loans.

```solidity
function approveCombine(
    uint256[] calldata loanIDs, 
    uint256 term,
    uint256 paymentInterval, 
    uint256 gracePeriod,
    int8 paymentSchedule
) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="172">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256[]</td><td>loanIDs</td><td>The IDs of the loans that can be combined.</td></tr><tr><td>uint256</td><td>term</td><td>The term that loans can be combined into.</td></tr><tr><td>uint256</td><td>paymentInterval</td><td>The paymentInterval that loans can be combined into.</td></tr><tr><td>uint256</td><td>gracePeriod</td><td>The number of seconds a borrower has to makePayment() before loan could default.</td></tr><tr><td>int8</td><td>paymentSchedule</td><td>The payment schedule of the loan (0 = "Bullet" or 1 = "Amortization").</td></tr></tbody></table>

Emits the [#combineapproved](#combineapproved "mention") event

#### `approveConversionToAmortization()`

Approves a loan for conversion to amortization payment schedule.

```solidity
function approveConversionToAmortization(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#conversiontoamortizationapproved](#conversiontoamortizationapproved "mention") event

#### `approveConversionToBullet()`

Approves a loan for conversion to bullet payment schedule.

```solidity
function approveConversionToBullet(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#conversiontobulletapproved](#conversiontobulletapproved "mention") event

#### `approveExtension()`

Approves an extension for a loan.

```solidity
function approveExtension(uint256 id, uint256 intervals) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr><tr><td>uint256</td><td>intervals</td><td>The amount of intervals to approve for extension.</td></tr></tbody></table>

Emits the [#extensionapproved](#extensionapproved "mention") event

#### `approveRefinance()`

Approves a loan for refinancing.

```solidity
function approveRefinance(uint256 id, uint256 apr) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr><tr><td>uint256</td><td>APR</td><td>The APR the loan can refinance to.</td></tr></tbody></table>

Emits the [#refinanceapproved](#refinanceapproved "mention") event

#### `unapproveCombine()`

Unapproves a borrower for combining loans.

```solidity
function unapproveCombine(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="137.33333333333331">Type</th><th width="161">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the combine to unapprove.</td></tr></tbody></table>

Emits the [#combineunapproved](#combineunapproved "mention") event

#### `unapproveConversionToAmortization()`

Unapproves a loan for conversion to amortization payment schedule.

```solidity
function unapproveConversionToAmortization(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the  [#conversiontoamortizationunapproved](#conversiontoamortizationunapproved "mention") event

#### `unapproveConversionBullet()`

Unapproves a loan for conversion to bullet payment schedule.

```solidity
function unapproveConversionToBullet(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#conversiontobulletunapproved](#conversiontobulletunapproved "mention") event

#### `unapproveExtension()`

Unapproves an extension for a loan.

```solidity
function unapproveExtension(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#extensionunapproved](#extensionunapproved "mention") event

#### `unapproveRefinance()`

Unapproves a loan for refinancing.

```solidity
function unapproveRefinance(uint256 id) external isUnderwriter;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="119">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID for the loan.</td></tr></tbody></table>

Emits the [#refinanceunapproved](#refinanceunapproved "mention") event

###

## Events

#### **`CombineApplied()`**

Emitted during [#applycombine](#applycombine "mention")

```solidity
event CombineApplied(
    address indexed borrower, 
    uint256[] loanIDs, 
    uint256 term,
    uint256 paymentInterval,
    uint256 gracePeriod,
    int8 indexed paymentSchedule
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>borrower</td><td>The borrower combining their loans.</td></tr><tr><td>uint256[]</td><td>False</td><td>loanIDs</td><td>The IDs of the loans that were combined.</td></tr><tr><td>uint256</td><td>False</td><td>term</td><td>The resulting term of the combined loan.</td></tr><tr><td>uint256</td><td>False</td><td>paymentInterval</td><td>The resulting paymentInterval of the combined loan.</td></tr><tr><td>uint256</td><td>False</td><td>gracePeriod</td><td>The resulting gracePeriod of the combined loan.</td></tr><tr><td>int8</td><td>True</td><td>paymentSchedule</td><td>The payment schedule of the combined loan (0 = "Bullet" or 1 = "Amortization").</td></tr></tbody></table>

#### **`CombineApproved()`**

Emitted during [#approvecombine](#approvecombine "mention")

```solidity
event CombineApproved(
    uint256 indexed id, 
    uint256[] loanIDs,
    uint256 term,
    uint256 paymentInterval, 
    uint256 gracePeriod,
    uint256 expires,
    int8 indexed paymentSchedule
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the combination approval in "combinations" mapping.</td></tr><tr><td>uint256[]</td><td>False</td><td>loanIDs</td><td>The IDs of the loans that can be combined.</td></tr><tr><td>uint256</td><td>False</td><td>term</td><td>The resulting term of the combined loan that is permitted.</td></tr><tr><td>uint256</td><td>False</td><td>paymentInterval</td><td>The resulting paymentInterval of the combined loan.</td></tr><tr><td>uint256</td><td>False</td><td>gracePeriod</td><td>The resulting gracePeriod of the combined loan that is permitted.</td></tr><tr><td>uint256</td><td>False</td><td>expires</td><td>The expiration of this combination.</td></tr><tr><td>int8</td><td>True</td><td>paymentSchedule</td><td>The payment schedule of the combined loan (0 = "Bullet" or 1 = "Amortization").</td></tr></tbody></table>

#### **`CombineLoanCreated()`**

Emitted during [#applycombine](#applycombine "mention")

```solidity
event CombineLoanCreated(
    address indexed borrower,
    uint256 indexed id,
    uint256 borrowAmount,
    uint256 APR,
    uint256 APRLateFee,
    uint256 paymentDueBy,
    uint256 term,
    uint256 paymentInterval,
    uint256 gracePeriod,
    int8 indexed paymentSchedule
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>borrower</td><td>The address borrowing (that will receive the loan).</td></tr><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the loan offer created.</td></tr><tr><td>uint256</td><td>False</td><td>borrowAmount</td><td>The amount to borrow (in other words, initial principal).</td></tr><tr><td>uint256</td><td>False</td><td>APR</td><td>The annualized percentage rate charged on the outstanding principal.</td></tr><tr><td>uint256</td><td>False</td><td>APRLateFee</td><td>The APR charged for late payments.</td></tr><tr><td>uint256</td><td>False</td><td>paymentDueBy</td><td>The timestamp (in seconds) for when the next payment is due.</td></tr><tr><td>uint256</td><td>False</td><td>term</td><td>The term or "duration" of the loan (number of paymentIntervals that will occur).</td></tr><tr><td>uint256</td><td>False</td><td>paymentInterval</td><td>The interval of time between payments (in seconds).</td></tr><tr><td>uint256</td><td>False</td><td>gracePeriod</td><td>The number of seconds a borrower has to makePayment() before loan could default.</td></tr><tr><td>int8</td><td>True</td><td>paymentSchedule</td><td>The payment schedule of the combined loan (0 = "Bullet" or 1 = "Amortization").</td></tr></tbody></table>

#### **`CombineUnapproved()`**

Emitted during [#unapprovecombine](#unapprovecombine "mention")

```solidity
event CombineUnapproved(uint256 id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the combine to unapprove.</td></tr></tbody></table>

#### **`ConversionToAmortizationApplied()`**

Emitted during [#applyconversiontoamortization](#applyconversiontoamortization "mention")

```solidity
event ConversionToAmortizationApplied(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID converted to amortization payment schedule.</td></tr></tbody></table>

#### **`ConversionToAmortizationApproved()`**

Emitted during [#approveconversiontoamortization](#approveconversiontoamortization "mention")

```solidity
event ConversionToAmortizationApproved(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID approved for conversion.</td></tr></tbody></table>

#### **`ConversionToAmortizationUnapproved()`**

Emitted during [#unapproveconversiontoamortization](#unapproveconversiontoamortization "mention")

```solidity
event ConversionToAmortizationUnapproved(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID unapproved for conversion.</td></tr></tbody></table>

#### **`ConversionToBulletApplied()`**

Emitted during [#applyconversionbullet](#applyconversionbullet "mention")

```solidity
event ConversionToBulletApplied(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID converted to bullet payment schedule.</td></tr></tbody></table>

#### **`ConversionToBulletApproved()`**

Emitted during [#approveconversiontobullet](#approveconversiontobullet "mention")

```solidity
event ConversionToBulletApproved(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID approved for conversion.</td></tr></tbody></table>

#### **`ConversionToBulletUnapproved()`**

Emitted during [#unapproveconversionbullet](#unapproveconversionbullet "mention")

```solidity
event ConversionToBulletUnapproved(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID unapproved for conversion.</td></tr></tbody></table>

#### **`DefaultMarked()`**

Emitted during [#markdefault](#markdefault "mention")

```solidity
event DefaultMarked(uint256 indexed id, uint256 principalDefaulted);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the loan which is now "defaulted".</td></tr><tr><td>uint256</td><td>False</td><td>principalDefaulted</td><td>The amount defaulted on.</td></tr></tbody></table>

#### **`DefaultResolved()`**

Emitted during [#resolvedefault](#resolvedefault "mention")

```solidity
event DefaultResolved(
    uint256 indexed id, 
    uint256 amount, 
    address indexed payee, 
    bool resolved
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The identifier for the loan in default that is resolved (or partially).</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of principal paid back.</td></tr><tr><td>address</td><td>True</td><td>payee</td><td>The address responsible for resolving the default.</td></tr><tr><td>bool</td><td>False</td><td>resolved</td><td>Denotes if the loan is fully resolved (false if partial).</td></tr></tbody></table>

#### **`ExtensionApplied()`**

Emitted during [#applyextension](#applyextension "mention")

```solidity
event ExtensionApplied(uint256 indexed id, uint256 intervals);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The identifier of the loan extending its payment schedule.</td></tr><tr><td>uint256</td><td>False</td><td>interval</td><td>The number of intervals the loan is extended for.</td></tr></tbody></table>

#### **`ExtensionApproved()`**

Emitted during [#approveextension](#approveextension "mention")

```solidity
event ExtensionApproved(uint256 indexed id, uint256 intervals);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The identifier of the loan receiving approval for extension.</td></tr><tr><td>uint256</td><td>False</td><td>intervals</td><td>The number of intervals the approved loan may be extended.</td></tr></tbody></table>

#### **`ExtensionUnapproved()`**

Emitted during [#unapproveextension](#unapproveextension "mention")

```solidity
event ExtensionUnapproved(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The identifier of the loan losing approval for extension.</td></tr></tbody></table>

#### **`InterestSupplied()`**

Emitted during [#supplyinterest](#supplyinterest "mention")

```solidity
event InterestSupplied(
    uint256 indexed id, 
    uint256 amount, 
    address indexed payee
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The identifier for the loan that is supplied additional interest.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of interest supplied.</td></tr><tr><td>address</td><td>True</td><td>payee</td><td>The address responsible for supplying additional interest.</td></tr></tbody></table>

#### **`LoanCalled()`**

Emitted during [#callloan](#callloan "mention")

```solidity
event LoanCalled(
    uint256 indexed id, 
    uint256 amount, 
    uint256 principal, 
    uint256 interest, 
    uint256 lateFee
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the loan which was called.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The total amount of the payment.</td></tr><tr><td>uint256</td><td>False</td><td>principal</td><td>The principal portion of "amount" paid.</td></tr><tr><td>uint256</td><td>False</td><td>interest</td><td>The interest portion of "amount" paid.</td></tr><tr><td>uint256</td><td>False</td><td>lateFee</td><td>The lateFee portion of "amount" paid.</td></tr></tbody></table>

#### **`OfferAccepted()`**

Emitted during [#acceptoffer](#acceptoffer "mention")

```solidity
event OfferAccepted(
    uint256 indexed id, 
    uint256 principal, 
    address indexed borrower, 
    uint256 paymentDueBy
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the offer accepted.</td></tr><tr><td>uint256</td><td>False</td><td>principal</td><td>The amount of stablecoin lent out.</td></tr><tr><td>address</td><td>True</td><td>borrower</td><td>The address borrowing the amount (principal).</td></tr><tr><td>uint256</td><td>False</td><td>paymentDueBy</td><td>Timestamp (unix seconds) by which next payment is due.</td></tr></tbody></table>

#### **`OfferCancelled()`**

Emitted during [#canceloffer](#canceloffer "mention")

```solidity
event OfferCancelled(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the loan offer cancelled.</td></tr></tbody></table>

#### **`OfferCreated()`**

Emitted during [#createoffer](#createoffer "mention")

```solidity
event OfferCreated(
    address indexed borrower,
    uint256 indexed id,
    uint256 borrowAmount,
    uint256 APR,
    uint256 APRLateFee,
    uint256 term,
    uint256 paymentInterval,
    uint256 offerExpiry,
    uint256 gracePeriod,
    int8 indexed paymentSchedule
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>borrower</td><td>The address borrowing (that will receive the loan).</td></tr><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the loan offer created.</td></tr><tr><td>uint256</td><td>False</td><td>borrowAmount</td><td>The amount to borrow (in other words, initial principal).</td></tr><tr><td>uint256</td><td>False</td><td>APR</td><td>The annualized percentage rate charged on the outstanding principal.</td></tr><tr><td>uint256</td><td>False</td><td>APRLateFee</td><td>The APR charged for late payments.</td></tr><tr><td>uint256</td><td>False</td><td>term</td><td>The term or "duration" of the loan (number of paymentIntervals that will occur).</td></tr><tr><td>uint256</td><td>False</td><td>paymentInterval</td><td>The interval of time between payments (in seconds).</td></tr><tr><td>uint256</td><td>False</td><td>offerExpiry</td><td>The block.timestamp at which the offer for this loan expires (hardcoded 2 weeks).</td></tr><tr><td>uint256</td><td>False</td><td>gracePeriod</td><td>The number of seconds a borrower has to makePayment() before loan could default.</td></tr><tr><td>int8</td><td>True</td><td>paymentSchedule</td><td>The payment schedule type ("Bullet" or "Amortization").</td></tr></tbody></table>

#### **`PaymentMade()`**

Emitted during [#makepayment](#makepayment "mention") and [#processpayment](#processpayment "mention")

```solidity
event PaymentMade(
    uint256 indexed id, 
    address indexed payee, 
    uint256 amount, 
    uint256 principal, 
    uint256 interest, 
    uint256 lateFee, 
    uint256 nextPaymentDue
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the loan on which payment is made.</td></tr><tr><td>address</td><td>True</td><td>payee</td><td>The address which made payment on the loan.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The total amount of the payment.</td></tr><tr><td>uint256</td><td>False</td><td>principal</td><td>The principal portion of "amount" paid.</td></tr><tr><td>uint256</td><td>False</td><td>interest</td><td>The interest portion of "amount" paid.</td></tr><tr><td>uint256</td><td>False</td><td>lateFee</td><td>The lateFee portion of "amount" paid.</td></tr><tr><td>uint256</td><td>False</td><td>nextPaymentDue</td><td>The timestamp by which next payment is due.</td></tr></tbody></table>

#### **`RefinanceApplied()`**

Emitted during [#applyrefinance](#applyrefinance "mention")

```solidity
event RefinanceApplied(uint256 indexed id, uint256 APRNew, uint256 APRPrior);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID refinancing its APR.</td></tr><tr><td>uint256</td><td>False</td><td>APRNew</td><td>The new APR of the loan.</td></tr><tr><td>uint256</td><td>False</td><td>APRPrior</td><td>The prior APR of the loan.</td></tr></tbody></table>

#### **`RefinanceApproved()`**

Emitted during [#approverefinance](#approverefinance "mention")

```solidity
event RefinanceApproved(uint256 indexed id, uint256 APR);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID approved for refinance.</td></tr><tr><td>uint256</td><td>False</td><td>APR</td><td>The APR the loan is approved to refinance to.</td></tr></tbody></table>

#### **`RefinanceUnapproved()`**

Emitted during [#unapproverefinance](#unapproverefinance "mention")

```solidity
event RefinanceUnapproved(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The loan ID unapproved for refinance.</td></tr></tbody></table>

#### **`RepaidMarked()`**

Emitted during [#markrepaid](#markrepaid "mention")

```solidity
event RepaidMarked(uint256 indexed id);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>Identifier for the loan which is now "repaid".</td></tr></tbody></table>

#### **`UpdatedOCTYDL()`**

Emitted during [#updateoctydl](#updateoctydl "mention")

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>


# OCE\_ZVE.sol

OCE -> On-Chain Emissions ($ZVE, Exponential Decay)

## Introduction

This contract facilitates an exponential decay emissions schedule for $ZVE.

This contract has the following responsibilities:

* Handles accounting (with governable variables) to support emissions schedule.
* Forwards $ZVE to all ZivoeRewards contracts at will (stZVE, stSTT, stJTT).

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-555&t=PV4UgJW2ZCG870d3-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="195">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>uint256</td><td>exponentialDecayPerSecond</td><td>The rate of decay per second.</td></tr><tr><td>uint256</td><td>lastDistribution</td><td>The block.timestamp value of last distribution.</td></tr><tr><td>uint256[3]</td><td>distributionRatioBIPS</td><td>Determines distribution between rewards contract, in BIPS.<br><code>distributionRatioBIPS[0] => stZVE</code><br><code>distributionRatioBIPS[1] => stSTT</code><br><code>distributionRatioBIPS[2] => stJTT</code></td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr><tr><td>uint256</td><td>RAY</td><td>Private constant, <code>10**27</code></td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#decay](#decay "mention") - Returns the amount remaining after a decay.
* [#rmul](#rmul "mention") - Multiplies two variables and returns value, truncated by RAY precision.
* [#rpow](#rpow "mention") - `rpow(uint256 x, uint256 n, uint256 b)`, used for exponentiation in drip

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - Allocates ZVE from the DAO to this locker for emissions.
* [#forwardemissions](#forwardemissions "mention") - Forwards $ZVE available for distribution.
* [#updatedistributionratiobips](#updatedistributionratiobips "mention") - Updates the distribution between rewards contract, in BIPS.
* [#updateexponentialdecaypersecond](#updateexponentialdecaypersecond "mention") - Updates the exponentialDecayPerSecond variable with provided input.

[#events](#events "mention")

* [#updateddistributionratiobips](#updateddistributionratiobips "mention")
* [#emissionsforwarded](#emissionsforwarded "mention")
* [#updatedexponentialdecaypersecond](#updatedexponentialdecaypersecond "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `decay()`

Returns the amount remaining after a decay.

```solidity
function decay(
    uint256 top, 
    uint256 dur
) public view returns (uint256);
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>top</td><td>The amount decaying.</td></tr><tr><td>uint256</td><td>dur</td><td>The seconds of decay.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td><code>n/a</code></td><td>The amount remaining after a decay.</td></tr></tbody></table>

#### `rmul()`

Multiplies two variables and returns value, truncated by RAY precision.

```solidity
function rmul(
    uint256 x, 
    uint256 y
) internal pure returns (uint256 z);
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>x</td><td>First value to multiply.</td></tr><tr><td>uint256</td><td>y</td><td>Second value to multiply.</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>z</td><td>Resulting value of x * y, truncated by RAY precision.</td></tr></tbody></table>

#### `rpow()`

`rpow(uint256 x, uint256 n, uint256 b)`, used for exponentiation in drip, is a fixed-point arithmetic function that raises x to the power n. It is implemented in Solidity assembly as a repeated squaring algorithm. x and the returned value are to be interpreted as fixed-point integers with scaling factor b. For example, if b == 100, this specifies two decimal digits of precision and the normal decimal value 2.1 would be represented as 210; rpow(210, 2, 100) returns 441 (the two-decimal digit fixed-point representation of 2.1^2 = 4.41). In the current implementation, 10^27 is passed for b, making x and the rpow result both of type RAY in standard MCD fixed-point terminology. rpow's formal invariants include "no overflow" as well as constraints on gas usage.

```solidity
function rpow(
    uint256 x, 
    uint256 n, 
    uint256 b
) internal pure returns (uint256 z);
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="128">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>x</td><td>The base value.</td></tr><tr><td>uint256</td><td>n</td><td>The power to raise "x" by.</td></tr><tr><td>uint256</td><td>b</td><td>The scaling factor, a.k.a. resulting precision of "z".</td></tr></tbody></table>

*Returns*

<table><thead><tr><th width="170.33333333333331">Type</th><th width="134">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>z</td><td>Resulting value of x^n, scaled by factor b.</td></tr></tbody></table>

## Write Functions

#### `pushToLocker()`

Allocates ZVE from the DAO to this locker for emissions.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override onlyOwner;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to push to this locker (in this case $ZVE).</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of $ZVE to push to this locker.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `forwardEmissions()`

Forwards $ZVE available for distribution.

```solidity
function forwardEmissions() external nonReentrant;
```

Emits the [#emissionsforwarded](#emissionsforwarded "mention") event.

#### `updateDistributionRatioBIPS()`

Updates the distribution between rewards contract, in BIPS.

```solidity
function updateDistributionRatioBIPS(
    uint256[3] calldata _distributionRatioBIPS
) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256[3]</td><td>_distributionRatioBIPS</td><td>The updated values for the state variable distributionRatioBIPS.</td></tr></tbody></table>

Emits the [#updateddistributionratiobips](#updateddistributionratiobips "mention") event.

#### `updateExponentialDecayPerSecond()`

Updates the exponentialDecayPerSecond variable with provided input.

```solidity
function updateExponentialDecayPerSecond(
    uint256 _exponentialDecayPerSecond
) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="177">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_exponentialDecayPerSecond</td><td>The updated value for exponentialDecayPerSecond state variable.</td></tr></tbody></table>

Emits the [#updatedexponentialdecaypersecond](#updatedexponentialdecaypersecond "mention") event.

## Events

#### **`UpdatedDistributionRatioBIPS()`**

Emitted during [#updatedistributionratiobips](#updatedistributionratiobips "mention")

```solidity
event UpdatedDistributionRatioBIPS(
    uint256[3] oldRatios, 
    uint256[3] newRatios
);
```

<table><thead><tr><th width="133.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256[3]</td><td>False</td><td>oldRatios</td><td>The old distribution ratios.</td></tr><tr><td>uint256[3]</td><td>False</td><td>newRatios</td><td>The new distribution ratios.</td></tr></tbody></table>

#### **`EmissionsForwarded()`**

Emitted during [#forwardemissions](#forwardemissions "mention")

```solidity
event EmissionsForwarded(uint256 stZVE, uint256 stJTT, uint256 stSTT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>stZVE</td><td>The amount of $ZVE emitted to the $ZVE rewards contract.</td></tr><tr><td>uint256</td><td>False</td><td>stJTT</td><td>The amount of $ZVE emitted to the $zJTT rewards contract.</td></tr><tr><td>uint256</td><td>False</td><td>stSTT</td><td>The amount of $ZVE emitted to the $zSTT rewards contract.</td></tr></tbody></table>

#### **`UpdatedExponentialDecayPerSecond()`**

Emitted during [#updateexponentialdecaypersecond](#updateexponentialdecaypersecond "mention")

```solidity
event UpdatedExponentialDecayPerSecond(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of exponentialDecayPerSecond.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of exponentialDecayPerSecond.</td></tr></tbody></table>


# OCL\_ZVE.sol

OCL -> On-Chain Liquidity (Sushi, Uniswap)

## Introduction

This contract manages liquidity provisioning for a Uniswap V2 or Sushi pool.

This contract has the following responsibilities:

* Allocate capital to a $ZVE/pairAsset pool.
* Remove capital from a $ZVE/pairAsset pool.
* Forward yield (profits) every 30 days to the YDL with compounding mechanisms.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-554&t=vXeIOKXdTNwoFfFp-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>factory</td><td>Address for the Factory (Uniswap v2 or Sushi).</td></tr><tr><td>address</td><td>pairAsset</td><td>ERC20 that will be paired with $ZVE for Sushi pool.</td></tr><tr><td>address</td><td>router</td><td>Address for the Router (Uniswap v2 or Sushi).</td></tr><tr><td>address</td><td>OCT_YDL</td><td>Facilitates swaps and forwards distributedAsset() to YDL.</td></tr><tr><td>uint256</td><td>basis</td><td>The basis used for forwardYield() accounting.</td></tr><tr><td>uint256</td><td>compoundingRateBIPS</td><td>The % of returns to retain, in BIPS.</td></tr><tr><td>uint256</td><td>nextYieldDistribution</td><td>Determines next available forwardYield() call.</td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpushmulti](#canpushmulti "mention") - Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#fetchbasis](#fetchbasis "mention") - Returns amount of pairAsset redeemable with current LP position.

[#write-functions](#write-functions "mention")

* [#pushtolockermulti](#pushtolockermulti "mention") - This pulls capital from the DAO and adds liquidity into a $ZVE/pairAsset pool.
* [#pullfromlocker](#pullfromlocker "mention") - This burns all LP tokens owned by the contract from the $ZVE/pairAsset pool and returns them to the DAO.
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - This burns LP tokens from the $ZVE/pairAsset pool and returns them to the DAO.
* [#forwardyield](#forwardyield "mention") - This forwards yield to the YDL in the form of pairAsset.
* [#updatecompoundingratebips](#updatecompoundingratebips "mention") - Updates the compounding rate of this contract.
* [#updateoctydl](#updateoctydl "mention") - Updates the OCT\_YDL endpoint.

[#events](#events "mention")

* [#liquiditytokensburned](#liquiditytokensburned "mention")
* [#liquiditytokensminted](#liquiditytokensminted "mention")
* [#updatedcompoundingratebips](#updatedcompoundingratebips "mention")
* [#updatedoctydl](#updatedoctydl "mention")
* [#yieldforwarded](#yieldforwarded "mention")

## Read Functions

#### `canPushMulti()`

Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPushMulti() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `fetchBasis()`

Returns amount of pairAsset redeemable with current LP position.

```solidity
function pairAssetConvertible() public view returns (uint256 amout, uint256 lp);
```

*Returns*

<table><thead><tr><th width="159.33333333333331">Type</th><th width="177">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>Current pairAsset harvestable.</td></tr><tr><td>uint256</td><td>lp</td><td>Current ZVE/pairAsset LP tokens.</td></tr></tbody></table>

## Write Functions

#### `pushToLockerMulti()`

This pulls capital from the DAO and adds liquidity into a $ZVE/pairAsset pool.

<pre class="language-solidity"><code class="lang-solidity">function pushToLockerMulti(
<strong>    address[] calldata assets, 
</strong><strong>    uint256[] calldata amounts, 
</strong><strong>    bytes[] calldata data
</strong>) external override onlyOwner nonReentrant;
</code></pre>

<table><thead><tr><th width="159.33333333333331">Type</th><th width="177">Name</th><th>Description</th></tr></thead><tbody><tr><td>address[]</td><td>assets</td><td>The assets to pull from the DAO.</td></tr><tr><td>uint256[]</td><td>amounts</td><td>The amount to pull of each asset respectively.</td></tr><tr><td>bytes[]</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#liquiditytokensminted](#liquiditytokensminted "mention") event

#### `pullFromLocker()`

This burns all LP tokens owned by the contract from the $ZVE/pairAsset pool and returns them to the DAO.

```solidity
function pullFromLocker(
    address asset, 
    bytes calldata data
) external override onlyOwner nonReentrant;
```

<table><thead><tr><th width="159.33333333333331">Type</th><th width="177">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to burn.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#liquiditytokensburned](#liquiditytokensburned "mention") event

#### `pullFromLockerPartial()`

This burns LP tokens from the $ZVE/pairAsset pool and returns them to the DAO.

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override onlyOwner nonReentrant;
```

<table><thead><tr><th width="159.33333333333331">Type</th><th width="177">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to burn.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to burn.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#liquiditytokensburned](#liquiditytokensburned "mention") event

#### `forwardYield()`

This forwards yield to the YDL in the form of pairAsset. Requires that the block timestamp is greater than `nextYieldDistribution` variable, see above.

```solidity
function forwardYield() external;
```

Emits the [#yieldforwarded](#yieldforwarded "mention") event

#### `updateCompoundingRateBIPS()`

Updates the compounding rate of this contract. A value of 2,000 represent 20% of the earnings stays in this contract, compounding.

```solidity
function updateCompoundingRateBIPS(uint256 _compoundingRateBIPS) external;
```

<table><thead><tr><th width="159.33333333333331">Type</th><th width="218">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_compoundingRateBIPS</td><td>The new compounding rate value.</td></tr></tbody></table>

Emits the [#updatedcompoundingratebips](#updatedcompoundingratebips "mention") event

#### `updateOCTYDL()`

Updates the OCT\_YDL endpoint.

```solidity
function updateOCTYDL(address _OCT_YDL) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td><code>_OCT_YDL</code></td><td>The new address for OCT_YDL.</td></tr></tbody></table>

Emits the [#updatedoctydl](#updatedoctydl "mention") event

## Events

#### **`LiquidityTokensBurned()`**

Emitted during [#pullfromlocker](#pullfromlocker "mention"), [#pullfromlockerpartial](#pullfromlockerpartial "mention"), and [#forwardyield](#forwardyield "mention")

```solidity
event LiquidityTokensBurned(
    uint256 amountBurned, 
    uint256 claimedZVE, 
    uint256 claimedPairAsset
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="165">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>amountBurned</td><td>Amount of liquidity tokens burned.</td></tr><tr><td>uint256</td><td>False</td><td>claimedZVE</td><td>Amount of ZVE claimed.</td></tr><tr><td>uint256</td><td>False</td><td>claimedPairAsset</td><td>Amount of pairAsset claimed.</td></tr></tbody></table>

#### **`LiquidityTokensMinted()`**

Emitted during [#pushtolockermulti](#pushtolockermulti "mention")

```solidity
event LiquidityTokensMinted(
    uint256 amountMinted, 
    uint256 depositedZVE, 
    uint256 depositedPairAsset
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="185">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>amountMinted</td><td>Amount of liquidity tokens minted.</td></tr><tr><td>uint256</td><td>False</td><td>depositedZVE</td><td>Amount of ZVE deposited.</td></tr><tr><td>uint256</td><td>False</td><td>depositedPairAsset</td><td>Amount of pairAsset deposited.</td></tr></tbody></table>

#### **`UpdatedCompoundingRateBIPS()`**

Emitted during [#updatecompoundingratebips](#updatecompoundingratebips "mention")

```solidity
event UpdatedCompoundingRateBIPS(uint256 oldValue, uint256 newValue);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>oldValue</td><td>The old value of compoundingRateBIPS.</td></tr><tr><td>uint256</td><td>False</td><td>newValue</td><td>The new value of compoundingRateBIPS.</td></tr></tbody></table>

#### **`UpdatedOCTYDL()`**

Emitted during [#updateoctydl](#updateoctydl "mention")

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>

#### **`YieldForwarded()`**

Emitted during [#forwardyield](#forwardyield "mention")

```solidity
event YieldForwarded(address indexed asset, uint256 amount);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>asset</td><td>The "asset" being distributed.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount distributed.</td></tr></tbody></table>


# OCR\_Modular.sol

OCR -> On-Chain Redemption

## Introduction

OCR stands for "On-Chain Redemption".

This locker is responsible for handling redemptions of tranche tokens to stablecoins.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-550&t=uVYkxvhAjxnKHa2E-4>" %}

#### State Variables

<table><thead><tr><th width="182.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>stablecoin</td><td>The stablecoin redeemable in this contract.</td></tr><tr><td>uint256</td><td>epoch</td><td>The timestamp of current epoch.</td></tr><tr><td>uint256</td><td>epochDiscountJunior</td><td>Redemption discount for $zJTT (junior tranche).</td></tr><tr><td>uint256</td><td>epochDiscountSenior</td><td>Redemption discount for $zSTT (senior tranche).</td></tr><tr><td>uint256</td><td>redemptionsAllowedJunior</td><td>Redemptions allowed for $zJTT (junior tranche).</td></tr><tr><td>uint256</td><td>redemptionsAllowedSenior</td><td>Redemptions allowed for $zSTT (senior tranche).</td></tr><tr><td>uint256</td><td>redemptionsFeeBIPS</td><td>Fee for redemptions (in BIPS).</td></tr><tr><td>uint256</td><td>redemptionsQueuedJunior</td><td>Redemptions queued for $zJTT (junior tranche).</td></tr><tr><td>uint256</td><td>redemptionsQueuedSenior</td><td>Redemptions queued for $zSTT (senior tranche).</td></tr><tr><td>uint256</td><td>requestCounter</td><td>Increments with new requests.</td></tr><tr><td>uint256</td><td>BIPS</td><td>Private constant, <code>10000</code></td></tr><tr><td>uint256</td><td>RAY</td><td>Private constant, <code>10**27</code></td></tr><tr><td>mapping(uint256 => <a data-mention href="#request">#request</a>)</td><td>requests</td><td>Mapping of all requests.</td></tr></tbody></table>

#### Request

This struct stores information for redemptions requests.

<table><thead><tr><th width="137.33333333333331">Type</th><th width="206">Variable</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>account</td><td>The account making the request</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of the request ($zSTT and $zJTT)</td></tr><tr><td>uint256</td><td>unlocks</td><td>The timestamp after which this request may be processed</td></tr><tr><td>bool</td><td>seniorElseJunior</td><td>The tranche this request is for (true = Senior, false = Junior)</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - This pulls capital from the DAO.
* [#pullfromlocker](#pullfromlocker "mention") - Migrates entire ERC20 balance from locker to `owner()`.
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - Migrates specific amount of ERC20 from locker to `owner()`.
* [#createrequest](#createrequest "mention") - Creates a redemptions request.
* [#destroyrequest](#destroyrequest "mention") - Destroys a redemption request.
* [#processrequest](#processrequest "mention") - Processes a redemption request.
* [#tickepoch](#tickepoch "mention") - This function will start a new epoch.
* [#updateredemptionsfeebips](#updateredemptionsfeebips "mention") - Updates the state variable "redemptionFeeBips".

[#events](#events "mention")

* [#epochticked](#epochticked "mention")
* [#requestcreated](#requestcreated "mention")
* [#requestdestroyed](#requestdestroyed "mention")
* [#requestprocessed](#requestprocessed "mention")
* [#updatedredemptionsfeebips](#updatedredemptionsfeebips "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`pushToLocker()`**

This pulls capital from the DAO.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override _tickEpoch onlyOwner nonReentrant;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to pull from the DAO.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of asset to pull from the DAO.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLocker()`**

Migrates entire ERC20 balance from locker to `owner()`.

```solidity
function pullFromLocker(address asset, bytes calldata data) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLockerPartial()`**

Migrates specific amount of ERC20 from locker to `owner()`.

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external;

```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`createRequest()`**

Creates a redemptions request.

```solidity
function createRequest(
    uint256 amount, 
    bool seniorElseJunior
) external _tickEpoch nonReentrant;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>amount</td><td>The amount to deposit for the request.</td></tr><tr><td>uint256</td><td>seniorElseJunior</td><td>he tranche to deposit for (true = Senior, false = Junior).</td></tr></tbody></table>

Emits the [#requestcreated](#requestcreated "mention") event

#### **`destroyRequest()`**

Destroys a redemption request.

```solidity
function destroyRequest(uint256 id) external _tickEpoch nonReentrant;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the request to destroy.</td></tr></tbody></table>

Emits the [#requestdestroyed](#requestdestroyed "mention") event

#### **`processRequest()`**

Processes a redemption request.

```solidity
function processRequest(uint256 id) external _tickEpoch nonReentrant;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>id</td><td>The ID of the request to process.</td></tr></tbody></table>

Emits the [#requestprocessed](#requestprocessed "mention") event

#### **`tickEpoch()`**

This function will start a new epoch.

```solidity
function tickEpoch() public;
```

Emits the [#epochticked](#epochticked "mention") event

#### **`updateRedemptionsFeeBIPS()`**

Updates the state variable "redemptionFeeBips".

```solidity
function updateRedemptionsFeeBIPS(
    uint256 _redemptionsFeeBIPS
) external _tickEpoch;
```

<table><thead><tr><th width="170.33333333333331">Type</th><th width="204">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>_redemptionsFee</td><td>The new value for redemptionsFeeBIPS (in BIPS).</td></tr></tbody></table>

Emits the [#updatedredemptionsfeebips](#updatedredemptionsfeebips "mention") event

## Events

#### **`EpochTicked()`**

Emitted during [#tickepoch](#tickepoch "mention")

```solidity
event EpochTicked(
    uint256 epoch, 
    uint256 redemptionsAllowedJunior, 
    uint256 redemptionsAllowedSenior,
    uint256 epochDiscountJunior, 
    uint256 epochDiscountSenior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="238">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>epoch</td><td>The timestamp of the start of this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>redemptionsAllowedJunior</td><td>Redemptions allowed for $zJTT (junior tranche) for this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>redemptionsAllowedSenior</td><td>Redemptions allowed for $zSTT (senior tranche) for this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>epochDiscountJunior</td><td>Redemption discount for $zJTT (junior tranche) for this epoch.</td></tr><tr><td>uint256</td><td>False</td><td>epochDiscountSenior</td><td>Redemption discount for $zSTT (senior tranche) for this epoch.</td></tr></tbody></table>

#### **`RequestCreated()`**

Emitted during [#createrequest](#createrequest "mention")

```solidity
event RequestCreated(
    uint256 indexed id, 
    address indexed account, 
    uint256 amount, 
    bool indexed seniorElseJunior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="170">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the request created.</td></tr><tr><td>address</td><td>True</td><td>account</td><td>The account creating a request.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount deposited for the request ($zJTT or $zSTT).</td></tr><tr><td>bool</td><td>True</td><td>seniorElseJunior</td><td>The tranche deposited for (true = Senior, false = Junior).</td></tr></tbody></table>

#### **`RequestDestroyed()`**

Emitted during [#destroyrequest](#destroyrequest "mention")

```solidity
event RequestDestroyed(
    uint256 indexed id, 
    address indexed account, 
    uint256 amount, 
    bool indexed seniorElseJunior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="170">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the request destroyed.</td></tr><tr><td>address</td><td>True</td><td>account</td><td>The account destroying the request.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount returned from the request ($zJTT or $zSTT).</td></tr><tr><td>bool</td><td>True</td><td>seniorElseJunior</td><td>The tranche deposited for (true = Senior, false = Junior).</td></tr></tbody></table>

#### **`RequestProcessed()`**

Emitted during [#processrequest](#processrequest "mention")

```solidity
event RequestProcessed(
    uint256 indexed id, 
    address indexed account, 
    uint256 burnAmount, 
    uint256 redeemAmount, 
    bool indexed seniorElseJunior
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="170">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>True</td><td>id</td><td>The ID of the request processed.</td></tr><tr><td>address</td><td>True</td><td>account</td><td>The account receiving the redeemed tokens.</td></tr><tr><td>uint256</td><td>False</td><td>burnAmount</td><td>The amount of tranche tokens ($zJTT or $zSTT) burned from the request.</td></tr><tr><td>uint256</td><td>False</td><td>redeemAmount</td><td>The amount reddeemed from the processed request.</td></tr><tr><td>bool</td><td>True</td><td>seniorElseJunior</td><td>The tranche deposited for (true = Senior, false = Junior).</td></tr></tbody></table>

#### **`UpdatedRedemptionsFeeBIPS()`**

Emitted during [#updateredemptionsfee](#updateredemptionsfee "mention")&#x20;

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>


# OCT\_DAO.sol

OCT -> On-Chain Treasury

## Introduction

This contract converts assets and forwards them to the DAO.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-551&t=jZJr6JcVe580ciW3-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpushmulti](#canpushmulti "mention") - Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullmulti](#canpullmulti "mention") - Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartialmulti](#canpullpartialmulti "mention") - Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#convertandforward](#convertandforward "mention") - Converts an asset and forwards it to the DAO.

[#events](#events "mention")

* [#assetconvertedforwarded](#assetconvertedforwarded "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPushMulti()`

Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPushMulti() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullMulti()`

Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullMulti() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `canPullPartialMulti()`

Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullPartialMulti() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`convertAndForward()`**

Converts an asset and forwards it to the DAO.

```solidity
function convertAndForward(
    address asset, 
    address toAsset, 
    bytes calldata data
) external nonReentrant;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to convert.</td></tr><tr><td>uint256</td><td>toAsset</td><td>The ERC20 that we are converting "asset" to.</td></tr><tr><td>bytes</td><td>data</td><td>The payload containing conversion data, consumed by 1INCH_V5.</td></tr></tbody></table>

Emits the [#assetconvertedforwarded](#assetconvertedforwarded "mention") event

## Events

#### **`AssetConvertedForwarded()`**

Emitted during [#convertandforward](#convertandforward "mention")

```solidity
event AssetConvertedForwarded(
    address indexed asset, 
    address indexed toAsset, 
    uint256 amountFrom, 
    uint256 amountTo
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>asset</td><td>The "asset" being converted.</td></tr><tr><td>address</td><td>True</td><td>toAsset</td><td>The ERC20 that we are converting "asset" to.</td></tr><tr><td>uint256</td><td>False</td><td>amountFrom</td><td>The amount being converted.</td></tr><tr><td>uint256</td><td>False</td><td>amountTo</td><td>The amount received from conversion.</td></tr></tbody></table>


# OCT\_Convert.sol

OCT -> On-Chain Treasury

## Introduction

This contract converts zJTT to zSTT, and allows zSTT withdrawals.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=4504-604&t=NrqSUJrfnafVBXIu-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>mapping(address => bool)</td><td>isDepositor</td><td>Whitelist for converters, managed by keepers.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpushmulti](#canpushmulti "mention") - Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullmulti](#canpullmulti "mention") - Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartialmulti](#canpullpartialmulti "mention") - Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [updateWhitelist](#updatewhitelist) - Updates whitelist.
* [convertTranche](#converttranche) - Converts zJTT to zSTT.
* [withdrawTranche](#withdrawtranche) - Converts zSTT to stablecoins.

[#events](#events "mention")

* [TrancheConverted](#trancheconverted)
* [TrancheWithdrawn](#tranchewithdrawn)

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPushMulti()`

Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPushMulti() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullMulti()`

Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullMulti() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `canPullPartialMulti()`

Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullPartialMulti() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`updateWhitelist()`**

Updates whitelist.

```solidity
function updateWhitelist(
    address user, 
    bool status
) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>user</td><td>The address to add/remove from whitelist.</td></tr><tr><td>bool</td><td>status</td><td>The new status of user (true = accepted, false = rejected).</td></tr></tbody></table>

#### **`convertTranche()`**

Converts zJTT to zSTT.

```solidity
function convertTranche(
    uint amount, 
    address stablecoin
) external nonReentrant;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint</td><td>amount</td><td>The amount of stablecoin to use for conversion.</td></tr><tr><td>address</td><td>stablecoin</td><td>The stablecoin to use for conversion (will be transferred here from ZivoeDAO)</td></tr></tbody></table>

Emits the [TrancheConverted](#trancheconverted) event

#### **`withdrawTranche()`**

Converts zSTT to stablecoins.

```solidity
function withdrawTranche(
    uint amount, 
    address stablecoin
) external nonReentrant;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint</td><td>amount</td><td>The amount of stablecoin to use for conversion.</td></tr><tr><td>address</td><td>stablecoin</td><td>The stablecoin to use for conversion (will be transferred here from ZivoeDAO)</td></tr></tbody></table>

Emits the [TrancheWithdrawn](#tranchewithdrawn) event

## Events

#### **`TrancheConverted()`**

Emitted during [convertTranche](#converttranche)

```solidity
event TrancheConverted(
    address stablecoin,
    address caller,
    uint amount
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>False</td><td>stablecoin</td><td>The stablecoin converted.</td></tr><tr><td>address</td><td>False</td><td>caller</td><td>The caller of the function.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount being converted.</td></tr></tbody></table>

#### **`TrancheWithdrawn()`**

Emitted during [withdrawTranche](#withdrawtranche)

```solidity
event TrancheWithdrawn(
    address stablecoin,
    address caller,
    uint amount
);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>False</td><td>stablecoin</td><td>The stablecoin withdrawn.</td></tr><tr><td>address</td><td>False</td><td>caller</td><td>The caller of the function.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount being withdrawn.</td></tr></tbody></table>


# OCT\_YDL.sol

OCT -> On-Chain Treasury

## Introduction

This contract converts assets and forwards them to the YDL.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-552&t=8fVk5MSL8V4T10SB-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpushmulti](#canpushmulti "mention") - Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullmulti](#canpullmulti "mention") - Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartialmulti](#canpullpartialmulti "mention") - Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#convertandforward](#convertandforward "mention") - Converts an asset to YDL.distributedAsset() and forwards it.

[#events](#events "mention")

* [#assetconvertedforwarded](#assetconvertedforwarded "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPushMulti()`

Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPushMulti() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullMulti()`

Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullMulti() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `canPullPartialMulti()`

Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullPartialMulti() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`convertAndForward()`**

Converts an asset to YDL.distributedAsset() and forwards it.

```solidity
function convertAndForward(address asset, bytes calldata data) external; 
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to convert.</td></tr><tr><td>bytes</td><td>data</td><td>The payload containing conversion data, consumed by 1INCH_V5.</td></tr></tbody></table>

Emits the [#assetconvertedforwarded](#assetconvertedforwarded "mention") event

## Events

#### **`AssetConvertedForwarded()`**

Emitted during [#convertandforward](#convertandforward "mention")

<pre class="language-solidity"><code class="lang-solidity">event AssetConvertedForwarded(
<strong>    address indexed asset, 
</strong>    address indexed distributedAsset, 
    uint256 amountFrom, 
    uint256 amountTo
);
</code></pre>

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="163">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>asset</td><td>The "asset" being converted.</td></tr><tr><td>address</td><td>True</td><td>distributedAsset</td><td>The ERC20 that we are converting "asset" to, based on YDL.distributedAsset().</td></tr><tr><td>uint256</td><td>False</td><td>amountFrom</td><td>The amount being converted.</td></tr><tr><td>uint256</td><td>False</td><td>amountTo</td><td>The amount of distibutedAsset received.</td></tr></tbody></table>


# OCT\_ZVL.sol

OCT -> On-Chain Treasury

## Introduction

This contract escrows ZVE and enables ZVL to claim directly.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-553&t=tsUhI5QP0YXxkQhH-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpushmulti](#canpushmulti "mention") - Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullmulti](#canpullmulti "mention") - Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartialmulti](#canpullpartialmulti "mention") - Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#claim](#claim "mention") - Claims $ZVE.

[#events](#events "mention")

* [#claimed](#claimed "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPushMulti()`

Permission for owner to call `pushToLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPushMulti() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullMulti()`

Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullMulti() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

#### `canPullPartialMulti()`

Permission for owner to call `pullFromLockerMultiPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPullPartialMulti() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`claim()`**

Claims $ZVE.

```solidity
function claim() external nonReentrant;
```

Emits the [#claimed](#claimed "mention") event

## Events

#### **`Claimed()`**

Emitted during [#claim](#claim "mention")

```solidity
event Claimed(address indexed asset, uint256 amount);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>asset</td><td>The "asset" being claimed.</td></tr><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount being claimed.</td></tr></tbody></table>


# OCY\_Convex\_A.sol

OCY -> On-Chain Yield

## Introduction

This contract allocates stablecoins to the alUSD/FRAXBP meta-pool and stakes the LP tokens on Convex.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-556&t=bUmz9pxeLaM3pkRO-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="233">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>OCT_YDL</td><td>The OCT_YDL contract.</td></tr><tr><td>address</td><td>FRAX</td><td>Index 0, BasePool</td></tr><tr><td>address</td><td>USDC</td><td>Index 1, BasePool</td></tr><tr><td>address</td><td>alUSD</td><td>Index 0, MetaPool</td></tr><tr><td>address</td><td>CRV</td><td>Native Reward #1</td></tr><tr><td>address</td><td>CVX</td><td>Native Reward #2</td></tr><tr><td>address</td><td>convexDeposit</td><td>Convex information.</td></tr><tr><td>address</td><td>convexRewards</td><td>Convex information.</td></tr><tr><td>address</td><td>convexPoolToken</td><td>Convex information.</td></tr><tr><td>uint256</td><td>convexPoolID</td><td>Convex information.</td></tr><tr><td>address</td><td>curveBasePool</td><td>Curve information.</td></tr><tr><td>address</td><td>curveBasePoolToken</td><td>Index 1, MetaPool</td></tr><tr><td>address</td><td>curveMetaPool</td><td>MetaPool &#x26; Token</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullmulti](#canpullmulti "mention") - Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - Migrates specific amount of ERC20 from owner() to locker.
* [#pullfromlocker](#pullfromlocker "mention") - Migrates entire ERC20 balance from locker to `owner()`.
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - Migrates specific amount of ERC20 from locker to `owner()`.
* [#claimrewards](#claimrewards "mention") - Claims rewards and forward them to the OCT\_YDL.
* [#updateoctydl](#updateoctydl "mention") - Updates the OCT\_YDL endpoint.

[#events](#events "mention")

* [#updatedoctydl](#updatedoctydl "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullMulti()`

Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullMulti() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`pushToLocker()`**

Migrates specific amount of ERC20 from owner() to locker.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override onlyOwner;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLocker()`**

Migrates entire ERC20 balance from locker to `owner()`.

```solidity
function pullFromLocker(address asset, bytes calldata data) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLockerPartial()`**

Migrates specific amount of ERC20 from locker to `owner()`.

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external;

```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `claimRewards()`

Claims rewards and forward them to the OCT\_YDL.

```solidity
function claimRewards(bool extra) public nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>bool</td><td>extra</td><td>Flag for claiming extra rewards.</td></tr></tbody></table>

#### `updateOCTYDL()`

Updates the OCT\_YDL endpoint.

```solidity
function updateOCTYDL(address _OCT_YDL) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td><code>_OCT_YDL</code></td><td>The new address for OCT_YDL.</td></tr></tbody></table>

Emits the [#updatedoctydl](#updatedoctydl "mention") event

## Events

#### **`UpdatedOCTYDL()`**

Emitted during [#updateoctydl](#updateoctydl "mention")

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>


# OCY\_Convex\_B.sol

OCY -> On-Chain Yield

## Introduction

This contract allocates stablecoins to the sUSD base-pool and stakes the LP tokens on Convex.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-557&t=Bq2wCoSwtQrw54UU-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>OCT_YDL</td><td>The OCT_YDL contract.</td></tr><tr><td>address</td><td>DAI</td><td>Index 0, BasePool</td></tr><tr><td>address</td><td>USDC</td><td>Index 1, BasePool</td></tr><tr><td>address</td><td>USDT</td><td>Index 2, BasePool</td></tr><tr><td>address</td><td>sUSD</td><td>Index 3, BasePool</td></tr><tr><td>address</td><td>CRV</td><td>Native Reward #1</td></tr><tr><td>address</td><td>CVX</td><td>Native Reward #2</td></tr><tr><td>address</td><td>convexDeposit</td><td>Convex information.</td></tr><tr><td>address</td><td>convexPoolToken</td><td>Convex information.</td></tr><tr><td>address</td><td>convexRewards</td><td>Convex information.</td></tr><tr><td>uint256</td><td>convexPoolID</td><td>Convex information.</td></tr><tr><td>address</td><td>curveBasePool</td><td>Curve information.</td></tr><tr><td>address</td><td>curveBasePoolToken</td><td>Curve information.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - Migrates specific amount of ERC20 from owner() to locker.
* [#pullfromlocker](#pullfromlocker "mention") - Migrates entire ERC20 balance from locker to `owner()`.
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - Migrates specific amount of ERC20 from locker to `owner()`.
* [#claimrewards](#claimrewards "mention") - Claims rewards and forward them to the OCT\_YDL.
* [#updateoctydl](#updateoctydl "mention") - Updates the OCT\_YDL endpoint.

[#events](#events "mention")

* [#updatedoctydl](#updatedoctydl "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`pushToLocker()`**

Migrates specific amount of ERC20 from owner() to locker.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override onlyOwner;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLocker()`**

Migrates entire ERC20 balance from locker to `owner()`.

```solidity
function pullFromLocker(address asset, bytes calldata data) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLockerPartial()`**

Migrates specific amount of ERC20 from locker to `owner()`.

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external;

```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `claimRewards()`

Claims rewards and forward them to the OCT\_YDL.

```solidity
function claimRewards(bool extra) public nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>bool</td><td>extra</td><td>Flag for claiming extra rewards.</td></tr></tbody></table>

#### `updateOCTYDL()`

Updates the OCT\_YDL endpoint.

```solidity
function updateOCTYDL(address _OCT_YDL) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td><code>_OCT_YDL</code></td><td>The new address for OCT_YDL.</td></tr></tbody></table>

Emits the [#updatedoctydl](#updatedoctydl "mention") event

## Events

#### **`UpdatedOCTYDL()`**

Emitted during [#updateoctydl](#updateoctydl "mention")

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>


# OCY\_Convex\_C.sol

OCY -> On-Chain Yield

## Introduction

This contract allocates stablecoins to the PYUSD/USDC base-pool and stakes the LP tokens on Convex.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=3669-517&t=GGmnscukHZOA4SPt-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="200">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>OCT_YDL</td><td>The OCT_YDL contract.</td></tr><tr><td>address</td><td>PYUSD</td><td>Index 0, BasePool</td></tr><tr><td>address</td><td>USDC</td><td>Index 1, BasePool</td></tr><tr><td>address</td><td>sUSD</td><td>Index 3, BasePool</td></tr><tr><td>address</td><td>CRV</td><td>Native Reward #1</td></tr><tr><td>address</td><td>CVX</td><td>Native Reward #2</td></tr><tr><td>address</td><td>convexDeposit</td><td>Convex information.</td></tr><tr><td>address</td><td>convexPoolToken</td><td>Convex information.</td></tr><tr><td>address</td><td>convexRewards</td><td>Convex information.</td></tr><tr><td>uint256</td><td>convexPoolID</td><td>Convex information.</td></tr><tr><td>address</td><td>curveBasePool</td><td>Curve information.</td></tr><tr><td>address</td><td>curveBasePoolToken</td><td>Curve information.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullmulti](#canpullmulti "mention") - Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - Migrates specific amount of ERC20 from owner() to locker.
* [#pullfromlocker](#pullfromlocker "mention") - Migrates entire ERC20 balance from locker to `owner()`.
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - Migrates specific amount of ERC20 from locker to `owner()`.
* [#claimrewards](#claimrewards "mention") - Claims rewards and forward them to the OCT\_YDL.
* [#updateoctydl](#updateoctydl "mention") - Updates the OCT\_YDL endpoint.

[#events](#events "mention")

* [#updatedoctydl](#updatedoctydl "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullMulti()`

Permission for owner to call `pullFromLockerMulti()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullMulti() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`pushToLocker()`**

Migrates specific amount of ERC20 from owner() to locker.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override onlyOwner;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLocker()`**

Migrates entire ERC20 balance from locker to `owner()`.

```solidity
function pullFromLocker(address asset, bytes calldata data) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### **`pullFromLockerPartial()`**

Migrates specific amount of ERC20 from locker to `owner()`.

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external;

```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

#### `claimRewards()`

Claims rewards and forward them to the OCT\_YDL.

```solidity
function claimRewards(bool extra) public nonReentrant;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>bool</td><td>extra</td><td>Flag for claiming extra rewards.</td></tr></tbody></table>

#### `updateOCTYDL()`

Updates the OCT\_YDL endpoint.

```solidity
function updateOCTYDL(address _OCT_YDL) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td><code>_OCT_YDL</code></td><td>The new address for OCT_YDL.</td></tr></tbody></table>

Emits the [#updatedoctydl](#updatedoctydl "mention") event

## Events

#### **`UpdatedOCTYDL()`**

Emitted during [#updateoctydl](#updateoctydl "mention")

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>


# OCY\_OUSD.sol

OCY -> On-Chain Yield

## Introduction

This contract escrows OUSD and handles accounting for yield distributions.

{% embed url="<https://www.figma.com/board/qjuQ0uGQl9QD7KeBwyf73d/Zivoe-Visualization?node-id=207-558&t=xMaSm0a03jWFmwbH-4>" %}

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="150">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>GBL</td><td>The ZivoeGlobals contract.</td></tr><tr><td>address</td><td>OUSD</td><td>Origin Dollar contract.</td></tr><tr><td>address</td><td>OCT_YDL</td><td>The OCT_YDL contract.</td></tr><tr><td>uint256</td><td>basis</td><td>The basis of OUSD for distribution accounting.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#canpush](#canpush "mention") - Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpull](#canpull "mention") - Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)
* [#canpullpartial](#canpullpartial "mention") - Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

[#write-functions](#write-functions "mention")

* [#pushtolocker](#pushtolocker "mention") - Migrates specific amount of ERC20 from owner() to locker.
* [#pullfromlocker](#pullfromlocker "mention") - Migrates entire ERC20 balance from locker to `owner()`.
* [#pullfromlockerpartial](#pullfromlockerpartial "mention") - Migrates specific amount of ERC20 from locker to `owner()`.
* [#rebase](#rebase "mention") - Ensures this locker has opted-in for the OUSD rebase.
* [#updateoctydl](#updateoctydl "mention") - Updates the OCT\_YDL endpoint.
* [#forwardyield](#forwardyield "mention") - Forwards excess basis to OCT\_YDL for conversion.

[#events](#events "mention")

* [#basisadjusted](#basisadjusted "mention")
* [#updatedoctydl](#updatedoctydl "mention")
* [#yieldforwarded](#yieldforwarded "mention")

## Read Functions

#### `canPush()`

Permission for owner to call `pushToLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
 function canPush() public override pure returns (bool) { return true; }
```

#### `canPull()`

Permission for owner to call `pullFromLocker()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPull() public override pure returns (bool) { return true; }
```

#### `canPullPartial()`

Permission for owner to call `pullFromLockerPartial()`. See [ZivoeLocker.sol](/developer-docs/core-contracts/zivoelocker.sol)

```solidity
function canPullPartial() public override pure returns (bool) { return true; }
```

## Write Functions

#### **`pushToLocker()`**

Migrates specific amount of ERC20 from owner() to locker.

```solidity
function pushToLocker(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external override onlyOwner;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#basisadjusted](#basisadjusted "mention") event

#### **`pullFromLocker()`**

Migrates entire ERC20 balance from locker to `owner()`.

```solidity
function pullFromLocker(address asset, bytes calldata data) external;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#basisadjusted](#basisadjusted "mention") event

#### **`pullFromLockerPartial()`**

Migrates specific amount of ERC20 from locker to `owner()`.

```solidity
function pullFromLockerPartial(
    address asset, 
    uint256 amount, 
    bytes calldata data
) external;

```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>asset</td><td>The asset to migrate.</td></tr><tr><td>uint256</td><td>amount</td><td>The amount of "asset" to migrate.</td></tr><tr><td>bytes</td><td>data</td><td>Accompanying transaction data.</td></tr></tbody></table>

Emits the [#basisadjusted](#basisadjusted "mention") event

#### `rebase()`

Ensures this locker has opted-in for the OUSD rebase.

```solidity
function rebase() public;
```

#### `updateOCTYDL()`

Updates the OCT\_YDL endpoint.

```solidity
function updateOCTYDL(address _OCT_YDL) external;
```

<table><thead><tr><th width="171.33333333333331">Type</th><th width="184">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td><code>_OCT_YDL</code></td><td>The new address for OCT_YDL.</td></tr></tbody></table>

Emits the [#updatedoctydl](#updatedoctydl "mention") event

#### `forwardYield()`

Forwards excess basis to OCT\_YDL for conversion.

```solidity
function forwardYield() public nonReentrant;
```

Emits the [#yieldforwarded](#yieldforwarded "mention") event

## Events

#### **`BasisAdjusted()`**

Emitted during [#pushtolocker](#pushtolocker "mention"), [#pullfromlocker](#pullfromlocker "mention"), and [#pullfromlockerpartial](#pullfromlockerpartial "mention")

```solidity
event BasisAdjusted(uint256 priorBasis, uint256 newBasis);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>priorBasis</td><td>The prior value of basis.</td></tr><tr><td>uint256</td><td>False</td><td>newBasis</td><td>The new value of basis.</td></tr></tbody></table>

#### **`UpdatedOCTYDL()`**

Emitted during [#updateoctydl](#updateoctydl "mention")

```solidity
event UpdatedOCTYDL(address indexed newOCT, address indexed oldOCT);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>True</td><td>newOCT</td><td>The new OCT_YDL contract.</td></tr><tr><td>address</td><td>True</td><td>oldOCT</td><td>The old OCT_YDL contract.</td></tr></tbody></table>

#### **`YieldForwarded()`**

Emitted during [#forwardyield](#forwardyield "mention")

```solidity
event YieldForwarded(uint256 amount, uint256 newBasis);
```

<table><thead><tr><th width="127.33333333333331">Type</th><th width="98">Indexed</th><th width="132">Name</th><th>Description</th></tr></thead><tbody><tr><td>uint256</td><td>False</td><td>amount</td><td>The amount of OUSD forwarded.</td></tr><tr><td>uint256</td><td>False</td><td>newBasis</td><td>The new basis value.</td></tr></tbody></table>


# ZivoeSwapper.sol

1INCH v5 Integration

## Introduction

OneInchPrototype contract integrates with 1INCH to support custom data input.

#### State Variables

<table><thead><tr><th width="144.33333333333331">Type</th><th width="163">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>router1INCH_V5</td><td>The 1INCH v5 Router.</td></tr><tr><td>uint256</td><td>_ONE_FOR_ZERO_MASK</td><td>Private constant</td></tr><tr><td>uint256</td><td>_REVERSE_MASK</td><td>Private constant</td></tr></tbody></table>

#### OrderRFQ

This struct contains information for an OrderRFQ type transaction.

<table><thead><tr><th width="144.33333333333331">Type</th><th width="233">Name</th></tr></thead><tbody><tr><td>uint256</td><td>info</td></tr><tr><td>address</td><td>makerAsset</td></tr><tr><td>address</td><td>takerAsset</td></tr><tr><td>address</td><td>maker</td></tr><tr><td>address</td><td>allowedSender</td></tr><tr><td>uint256</td><td>makingAmount</td></tr><tr><td>uint256</td><td>takingAmount</td></tr></tbody></table>

#### SwapDescription

This struct contains information for a swap type transaction.

<table><thead><tr><th width="144.33333333333331">Type</th><th width="233">Name</th><th>Description</th></tr></thead><tbody><tr><td>IERC20</td><td>srcToken</td><td>Source token.</td></tr><tr><td>IERC20</td><td>dstToken</td><td>Destination token.</td></tr><tr><td>address payable</td><td>srcReceiver</td><td>Source receiver.</td></tr><tr><td>address payable</td><td>dstReceiver</td><td>Destination receiver.</td></tr><tr><td>uint256</td><td>amount</td><td>Amount of srcToken.</td></tr><tr><td>uint256</td><td>minReturnAmount</td><td>Minimum amount returnable of dstToken.</td></tr><tr><td>uint256</td><td>flags</td><td>Additional flags for swap.</td></tr></tbody></table>

## **Sections**

[#read-functions](#read-functions "mention")

* [#handle\_validation\_12aa3caf](#handle_validation_12aa3caf "mention") - Will validate the data retrieved from 1inch API triggering a `swap()` function in 1inch router. The swap() function will execute a swap through multiple sources.
* [#handle\_validation\_e449022e](#handle_validation_e449022e "mention") - Will validate the data retrieved from 1inch API triggering an `uniswapV3Swap()` function in 1inch router. The `uniswapV3Swap()` function will execute a swap through Uniswap V3 pools.
* [#handle\_validation\_0502b1c5](#handle_validation_0502b1c5 "mention") - Will validate the data retrieved from 1inch API triggering an unoswap() function in 1inch router.
* [#handle\_validation\_3eca9c0a](#handle_validation_3eca9c0a "mention") - Will validate the data retrieved from 1inch API triggering a `fillOrderRFQ()` function in 1inch router.

[#write-functions](#write-functions "mention")

* [#convertasset](#convertasset "mention") - Executes a conversion via 1INCH v5.

## Read Functions

#### `handle_validation_12aa3caf()`

Will validate the data retrieved from 1inch API triggering a `swap()` function in 1inch router. The swap() function will execute a swap through multiple sources.

```solidity
function handle_validation_12aa3caf(
    bytes calldata data, 
    address assetIn, 
    address assetOut, 
    uint256 amountIn
) internal view;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>bytes</td><td>data</td><td>Payload for 1INCH v5 router, data regarding swap.</td></tr><tr><td>address</td><td>assetIn</td><td>The asset that will be converted.</td></tr><tr><td>address</td><td>assetOut</td><td>The asset that "assetIn" will be converted to.</td></tr><tr><td>uint256</td><td>amountIn</td><td>The amount of "assetIn" that will be converted.</td></tr></tbody></table>

#### `handle_validation_e449022e()`

Will validate the data retrieved from 1inch API triggering an `uniswapV3Swap()` function in 1inch router. The `uniswapV3Swap()` function will execute a swap through Uniswap V3 pools.

```solidity
function handle_validation_e449022e(
    bytes calldata data,
    address assetIn,
    address assetOut,
    uint256 amountIn
) internal;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>bytes</td><td>data</td><td>Payload for 1INCH v5 router, data regarding swap.</td></tr><tr><td>address</td><td>assetIn</td><td>The asset that will be converted.</td></tr><tr><td>address</td><td>assetOut</td><td>The asset that "assetIn" will be converted to.</td></tr><tr><td>uint256</td><td>amountIn</td><td>The amount of "assetIn" that will be converted.</td></tr></tbody></table>

#### `handle_validation_0502b1c5()`

Will validate the data retrieved from 1inch API triggering an unoswap() function in 1inch router.

```solidity
function handle_validation_0502b1c5(
    bytes calldata data, 
    address assetIn, 
    address assetOut, 
    uint256 amountIn
) internal view;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>bytes</td><td>data</td><td>Payload for 1INCH v5 router, data regarding swap.</td></tr><tr><td>address</td><td>assetIn</td><td>The asset that will be converted.</td></tr><tr><td>address</td><td>assetOut</td><td>The asset that "assetIn" will be converted to.</td></tr><tr><td>uint256</td><td>amountIn</td><td>The amount of "assetIn" that will be converted.</td></tr></tbody></table>

#### `handle_validation_3eca9c0a()`

Will validate the data retrieved from 1inch API triggering a `fillOrderRFQ()` function in 1inch router.

```solidity
function handle_validation_3eca9c0a(
    bytes calldata data, 
    address assetIn, 
    address assetOut, 
    uint256 amountIn
) internal pure;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>bytes</td><td>data</td><td>Payload for 1INCH v5 router, data regarding swap.</td></tr><tr><td>address</td><td>assetIn</td><td>The asset that will be converted.</td></tr><tr><td>address</td><td>assetOut</td><td>The asset that "assetIn" will be converted to.</td></tr><tr><td>uint256</td><td>amountIn</td><td>The amount of "assetIn" that will be converted.</td></tr></tbody></table>

## Write Functions

#### `convertAsset()`

Executes a conversion via 1INCH v5.

```solidity
function convertAsset(
    address assetIn,
    address assetOut,
    uint256 amountIn,
    bytes calldata data
) internal;
```

<table><thead><tr><th width="156.33333333333331">Type</th><th width="160">Name</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>assetIn</td><td>The asset that will be converted.</td></tr><tr><td>address</td><td>assetOut</td><td>The asset that "assetIn" will be converted to.</td></tr><tr><td>uint256</td><td>amountIn</td><td>The amount of "assetIn" that will be converted.</td></tr><tr><td>bytes</td><td>data</td><td>Payload for 1INCH v5 router, data regarding swap.</td></tr></tbody></table>


# Audits

Official Audit Reports

### Reports

| Auditor              | Code Audited   | Report Link                                                                                                                                                            |
| -------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Runtime Verification | Vault          | <https://amp.runtimeverification.com/public-report/zivoe-vault>                                                                                                        |
| Sherlock             | Core + Lockers | [`04-25-2024 Sherlock`](https://github.com/sherlock-protocol/sherlock-reports/blob/main/audits/2024.04.25%20-%20Final%20-%20Zivoe%20Audit%20Report.pdf)                |
| Runtime Verification | Lockers        | [`08-18-2023 Runtime Verification (Locker Contracts)`](https://github.com/runtimeverification/publications/blob/main/reports/smart-contracts/Zivoe_Core_Contracts.pdf) |
| Runtime Verification | Core           | [`07-10-2023 Runtime Verification (Core Contracts)`](https://github.com/runtimeverification/publications/blob/main/reports/smart-contracts/Zivoe_Core_Contracts.pdf)   |


# Terms Of Use / Privacy Policy

{% file src="/files/msXjONOGkDS9avMNHg9u" %}


# Reg S Compliance

{% file src="/files/tnp29PG2oYn8VS40d4jq" %}


