# ZivoeGlobals.sol

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