# ZivoeITO.sol

## 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>
