> For the complete documentation index, see [llms.txt](https://docs.mavenfinance.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mavenfinance.io/smart-contracts/smart-contracts-overview/treasury-contract.md).

# Treasury Contract

Driving Financial Operations with the Treasury Contract

The Treasury Contract is a cornerstone of the Maven Finance ecosystem. It manages the platform's reserve of funds, effectively acting as the financial hub of Maven Finance.&#x20;

Ensuring the platform's financial stability, this contract is responsible for safeguarding the assets that fuel Maven Finance's array of DeFi services.

As Maven Finance expands its operations, this Treasury Contract plays a key role in facilitating transactions, disbursing funds, and managing inflow from various sources. Multiple Treasury Contracts may be deployed, each with its own mandate of managing the funds within.&#x20;

From operational expenditures to community incentives, the Treasury Contract stands as the financial gatekeeper of the Maven Finance ecosystem.

### Treasury Entrypoints

#### transfer

`function transfer(transferActionType transferList)`

Transfers tokens from the Treasury to the specified receiver address

{% hint style="info" %}
Can be called only be whitelisted addresses set by governance
{% 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 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 Mav, MRC-10, or MRC-20</td></tr></tbody></table>

#### mintMvnAndTransfer

`function mintMvnAndTransfer(address receiverAddress, nat mintAmount)`

Mints new MVN Tokens and transfers them to the address specified

{% hint style="info" %}
Can be called only be whitelisted addresses set by governance
{% endhint %}

| Param Name      | Type    | Description                                      |
| --------------- | ------- | ------------------------------------------------ |
| receiverAddress | address | The address to receive the new minted MVN tokens |
| mintAmount      | nat     | The amount of MVN tokens to be minted            |

### Staking Entrypoints

#### updateTokenOperators

`function updateTokenOperators(address tokenContractAddress, list(updateOperatorVariantType updateOperatorVariant) updateOperatorsList)`

Updates the operators for the specified token for the Treasury Contract

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

<table><thead><tr><th width="234.33333333333331">Param Name</th><th width="286">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenContractAddress</td><td>address</td><td>The address of the token contract to update operators on</td></tr><tr><td>updateOperatorsList</td><td>list(updateOperatorVariantType updateOperatorVariant)</td><td>A list of updateOperators transactions to be processed</td></tr><tr><td>updateOperatorVariant</td><td>updateOperatorVariantType:<br>| operatorParameterType Add_operator<br>| operatorParameterType Remove_operator</td><td>Specify whether an operator should be added or removed</td></tr><tr><td>Add_operator</td><td>operatorParameterType:<br>address owner,<br>address operator,<br>nat tokenId</td><td>Authorises an operator to act on behalf of the owner for the given token id</td></tr><tr><td>Remove_operator</td><td>operatorParameterType:<br>address owner,<br>address operator,<br>nat tokenId</td><td>Removes the authority of an operator to act on behalf of the owner for the given token id</td></tr><tr><td>owner</td><td>address</td><td>Address of the user to set the operator on</td></tr><tr><td>operator</td><td>address</td><td>Address of the operator to be authorized</td></tr><tr><td>tokenId</td><td>nat</td><td>Id of the token where the operator will be set</td></tr></tbody></table>

#### stakeTokens

`function stakeTokens(address stakingContractAddress, nat stakeAmount)`

Stakes the amount of tokens specified from the Treasury to the Staking Contract Address (e.g. Doorman Contract)

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

| Param Name             | Type    | Description                                  |
| ---------------------- | ------- | -------------------------------------------- |
| stakingContractAddress | address | The contract address of the Staking Contract |
| stakeAmount            | nat     | The amount of tokens to be staked            |

#### unstakeTokens

`function unstakeTokens(address stakingContractAddress, nat unstakeAmount)`

Unstakes the given amount of tokens from the Staking Contract Address (e.g. Doorman Contract) to the Treasury

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

| Param Name             | Type    | Description                                  |
| ---------------------- | ------- | -------------------------------------------- |
| stakingContractAddress | address | The contract address of the Staking Contract |
| unstakeAmount          | nat     | The amount of tokens to be unstaked          |

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

#### setBaker

`function setBaker(option(key_hash) baker)`

Sets a baker for the Treasury

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

| Param Name | Type              | Description           |
| ---------- | ----------------- | --------------------- |
| baker      | option(key\_hash) | Key hash of the baker |

#### setName

`function setName(string treasuryName)`

Sets a reference name for the Treasury

{% hint style="info" %}
Can be called only by the admin&#x20;
{% endhint %}

| Param Name   | Type   | Description                             |
| ------------ | ------ | --------------------------------------- |
| treasuryName | string | Reference name of the Treasury 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
{% endhint %}

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

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

#### updateWhitelistTokenContracts

`function updateWhitelistTokenContracts(address whitelistTokenContractAddress, updateType update)`

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

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

<table><thead><tr><th width="232.33333333333331">Param Name</th><th width="150">Type</th><th>Description</th></tr></thead><tbody><tr><td>whitelistTokenContractAddress</td><td>address</td><td>The token contract address to be updated in the whitelist token contracts bigmap</td></tr><tr><td>updateType</td><td>updateType: <br>| unit Update  <br>| unit Remove</td><td>Specifies whether the whitelistTokenContractAddress should be updated or removed from the whitelist token contracts bigmap</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>

### BreakGlass **Entrypoints**

#### pauseAll

`function pauseAll()`

Pauses all entrypoints in the contract.&#x20;

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

#### unpauseAll

`function unpauseAll()`

Unpauses all entrypoints in the contract.&#x20;

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

#### togglePauseEntrypoint

`function togglePauseEntrypoint(treasuryPausableEntrypointType targetEntrypoint, unit empty)`

Toggles the pausing of a specific entrypoint in the contract

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

<table><thead><tr><th width="184.33333333333331">Param Name</th><th width="313">Type</th><th>Description</th></tr></thead><tbody><tr><td>targetEntrypoint</td><td>treasuryPausableEntrypointType: <br>| bool Transfer <br>| bool MintMvnAndTransfer <br>| bool StakeMvn <br>| bool UnstakeMvn </td><td>The target entrypoint to be paused, and its corresponding pause boolean. If the boolean is set to True, the entrypoint will be paused. </td></tr><tr><td>empty</td><td>unit</td><td>A null param used to prettify interactions with this entrypoint on blockchain explorers such as better-call-dev</td></tr></tbody></table>

### View Methods

#### getAdmin

`function getAdmin()`

Returns the contract admin

#### getGovernanceAddress

`function getGovernanceAddress()`

Returns the contract governance address

#### getName

`function getName()`

Returns the reference name for the Treasury Contract

#### getBreakGlassConfig

`function getBreakGlassConfig()`

Returns the break glass config parameters (which shows the pause status of entrypoints)

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

#### getWhitelistTokenContractOpt

`function getWhitelistTokenContractOpt(address contractAddress)`

Returns unit if token contract address is whitelisted, else returns none

#### getLambdaOpt

`function getLambdaOpt(string lambdaName)`

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