# Emergency Governance Contract

The Emergency Governance Contract underpins Maven Finance's dedication to a secure and stable ecosystem.&#x20;

Designed to handle unexpected or disruptive circumstances, this contract provides a framework for crisis management in the realm of decentralized governance.

During an emergency, this contract allows for the immediate enactment of contingency plans, bypassing the standard, lengthier voting procedures.&#x20;

From mitigating threats and hacks to responding swiftly to market volatility, the Emergency Governance Contract ensures Maven Finance can quickly adapt to any given situation.

### Emergency Governance Entrypoints

#### triggerEmergencyControl

`function triggerEmergencyControl(string title, string description)`

Creates an emergency control action which other community members may vote for.&#x20;

Any community member may call this entrypoint provided they have sufficient staked MVN balance and pay a small fee.

{% hint style="info" %}
Only one emergency control may be active at any time
{% endhint %}

| Param Name  | Type   | Description                           |
| ----------- | ------ | ------------------------------------- |
| title       | string | The title of the emergency control    |
| description | string | Explain the reasons for the emergency |

#### voteForEmergencyControl

`function voteForEmergencyControl()`

Vote for an active emergency control.&#x20;

{% hint style="info" %}
Users may require a minimum amount of staked MVN before they can vote.
{% endhint %}

### Housekeeping **Entrypoints**

#### setAdmin

`function setAdmin(address newAdminAddress)`

Sets a new admin address for the contract

{% hint style="info" %}
Can be called only by the admin or the governance contract address
{% endhint %}

| Param Name      | Type    | Description                  |
| --------------- | ------- | ---------------------------- |
| newAdminAddress | address | The address of the new admin |

#### setGovernance

`function setGovernance(address newGovernanceAddress)`

Sets a new governance contract address

{% hint style="info" %}
Can be called only by the admin or the governance contract address
{% endhint %}

| Param Name           | Type    | Description                                |
| -------------------- | ------- | ------------------------------------------ |
| newGovernanceAddress | address | The address of the new governance contract |

#### updateMetadata

`function updateMetadata(string key, bytes hash)`

Replace the hash of the contract metadata based on the provided key

{% hint style="info" %}
Can be called only by the admin (i.e. the governance proxy contract)
{% endhint %}

| Param Name | Type   | Description                                  |
| ---------- | ------ | -------------------------------------------- |
| key        | string | The key in the metadata bigmap to be updated |
| hash       | bytes  | The hash of the metadata key                 |

#### updateConfig

`function updateConfig(nat newConfigValue, emergencyGovernanceConfigActionType emergencyGovernanceConfigAction)`

Updates the config variables on the Emergency Governance Contract

{% hint style="info" %}
Can be called only by the admin (i.e. the governance proxy contract)
{% endhint %}

<table><thead><tr><th width="232">Param Name</th><th width="364.3333333333333">Type</th><th>Description</th></tr></thead><tbody><tr><td>newConfigValue</td><td>nat</td><td>The new value of the config parameter</td></tr><tr><td>emergencyGovernanceConfigAction</td><td>emergencyGovernanceConfigActionType: <br>| unit ConfigVoteExpiryDays<br>| unit ConfigRequiredFeeMutez<br>| unit ConfigStakedMvnPercentRequired<br>| unit ConfigMinStakedMvnForVoting<br>| unit ConfigMinStakedMvnToTrigger<br>| unit ConfigProposalTitleMaxLength<br>| unit ConfigProposalDescMaxLength</td><td>The variant config variable to be updated</td></tr></tbody></table>

#### updateWhitelistContracts

`function updateWhitelistContracts(address whitelistContractAddress, updateType update)`

Add, update or remove a whitelist contract in the whitelistContracts map in the storage

{% hint style="info" %}
Can be called only by the admin (i.e. the governance proxy contract)
{% endhint %}

| Param Name               | Type                | Description                                                          |                 |                                                                                                                 |
| ------------------------ | ------------------- | -------------------------------------------------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------- |
| whitelistContractAddress | address             | The contract address to be updated in the whitelist contracts bigmap |                 |                                                                                                                 |
| updateType               | <p>updateType: <br> | unit Update  <br>                                                    | unit Remove</p> | Specifies whether the whitelistContractAddress should be updated or removed from the whitelist contracts bigmap |

#### updateGeneralContracts

`function updateGeneralContracts(string generalContractName, address generalContractAddress, updateType update)`

Add, update or remove a general contract in the generalContracts map in the storage

{% hint style="info" %}
Can be called only by the admin (i.e. the governance proxy contract)
{% endhint %}

| Param Name             | Type                | Description                                                                                                       |                 |                                                                                                             |
| ---------------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------- |
| generalContractName    | string              | The identifier key to be set in the general contracts bigmap which will be the general contract name in camelcase |                 |                                                                                                             |
| generalContractAddress | address             | The contract address to be updated in the general contracts bigmap                                                |                 |                                                                                                             |
| updateType             | <p>updateType: <br> | unit Update <br>                                                                                                  | unit Remove</p> | Specifies whether the generalContractAddress should be updated or removed from the general contracts bigmap |

#### mistakenTransfer

`function mistakenTransfer(transferActionType transferList)`

Transfers any mav or token that may have mistakenly been sent to this contract

{% hint style="info" %}
Can be called only by the admin or the governance satellite contract
{% endhint %}

<table><thead><tr><th width="196.33333333333331">Param Name</th><th width="331">Type</th><th>Description</th></tr></thead><tbody><tr><td>transferList</td><td><p>transferActionType:</p><p>list(address to_, <br>nat tokenAmount, <br>token tokenType)</p></td><td>A list of transfers of tokens to recipients</td></tr><tr><td>to_</td><td>address</td><td>The recipient of the mistaken transfer</td></tr><tr><td>tokenAmount</td><td>nat</td><td>The amount of tokens to be transferred</td></tr><tr><td>token</td><td>tokenType: <br>| unit Mav <br>| (address tokenContractAddress) Fa12 <br>| (address tokenContractAddress, nat tokenId)  MRC-20</td><td>The token type of the token to be transferred, corresponding to either Tez, Mav, MRC-10 OR MRC-20</td></tr></tbody></table>

#### setLambda

`function setLambda(string lambdaName, bytes func_bytes)`

Sets a lambda in the contract with the given bytes and name

{% hint style="info" %}
Can be called only by the admin (i.e. the governance proxy contract)
{% endhint %}

<table><thead><tr><th width="249.33333333333331">Param Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>lambdaName</td><td>string</td><td>The name of the lambda to be set</td></tr><tr><td>func_bytes</td><td>bytes</td><td>The data of the lambda in Michelson bytes format</td></tr></tbody></table>

### View Methods

#### getAdmin

`function getAdmin()`

Returns the contract admin

#### getGovernanceAddress

`function getGovernanceAddress()`

Returns the contract governance address

#### getConfig

`function getConfig()`

Returns the contract configuration parameters

#### getWhitelistContractOpt

`function getWhitelistContractOpt(address contractAddress)`

Returns unit if contract address is whitelisted, else returns none

#### getGeneralContractOpt

`function getGeneralContractOpt(string contractName)`

Returns the contract address if the contract name is found, else returns none

#### getEmergencyGovernanceOpt

`function getEmergencyGovernanceOpt(nat emergencyGovernanceId)`

Returns the record of an emergency governance, else returns none

#### getEmergencyGovernanceVoterOpt

`function getDelegateOpt(nat emergencyGovernanceId * address userAddress)`

Returns the user's vote amount (in staked MVN) and timestamp of the vote for a given emergency governance, else returns none

#### getCurrentEmergencyGovernanceId

`function getCurrentEmergencyGovernanceId()`

Returns the current emergency governance id

#### getNextEmergencyGovernanceId

`function getNextEmergencyGovernanceId()`

Returns the next emergency governance id

#### getLambdaOpt

`function getLambdaOpt(string lambdaName)`

Returns a lambda in the contract for the given lambda name, else returns none
