> 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/doorman-contract.md).

# Doorman Contract

Maven Finance's Doorman Contract: Your Gateway to Staking Power

Serving as the staking contract in the platform, the Doorman's primary role is to manage and control the staking procedures and operations integral to Maven Finance's DeFi ecosystem.

The Doorman contract is responsible for facilitating the staking of MVN tokens, ensuring their conversion into staked MVN (sMVN), and managing their subsequent delegation to Satellites.&#x20;

Furthermore, it meticulously oversees the unstaking processes, ensuring that all transactions comply with the stipulated rules.&#x20;

With the Doorman contract, Maven Finance achieves a seamless, secure, and effective staking operation, thereby contributing to the robustness of its decentralized platform.

### Main **Entrypoints**

#### stake

`function stake(nat stakeAmount)`

Stake MVN tokens for the sender

| Param Name  | Type | Description             |
| ----------- | ---- | ----------------------- |
| stakeAmount | nat  | The amount to be staked |

#### unstake

`function unstake(nat unstakeAmount)`

Unstake MVN tokens for the sender

| Param Name    | Type | Description               |
| ------------- | ---- | ------------------------- |
| unstakeAmount | nat  | The amount to be unstaked |

#### exit

`function exit()`

Completely unstake all MVN tokens of the sender and reset balance to zero

#### compound

`function compound(address userAddress)`

Compounds the user exit fee and satellite rewards

| Param Name  | Type    | Description                                    |
| ----------- | ------- | ---------------------------------------------- |
| userAddress | address | The user address on which compound will be run |

#### farmClaim

`function farmClaim(set(address userAddress, nat amount), bool forceRewardFromTransfer)`

For users to claim the staked MVN rewards of a farm

{% hint style="info" %}
Can be called only by a farm contract
{% endhint %}

| Param Name              | Type    | Description                                                                                                                                            |
| ----------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| userAddress             | address | The user address on which farmClaim will be run                                                                                                        |
| amount                  | nat     | Amount of farm rewards to be claimed                                                                                                                   |
| forceRewardFromTransfer | bool    | if true, rewards will only be transferred from the farm treasury. If false, the farm treasury will be allowed to mint additional MVN tokens as rewards |

### Vault Entrypoints

#### onVaultDepositStake

`function onVaultDepositStake(address vaultOwner, address vaultAddress, nat depositAmount)`

Registers the staking of MVN from a vault owner to his vault

{% hint style="info" %}
Can be called only by the lending controller contract
{% endhint %}

| Param Name    | Type    | Description                                                                |
| ------------- | ------- | -------------------------------------------------------------------------- |
| vaultOwner    | address | The address of the vault owner                                             |
| vaultAddress  | address | The address of the vault                                                   |
| depositAmount | nat     | The amount of staked MVN to be deposited from the vault owner to the vault |

#### onVaultWithdrawStake

`function onVaultWithdrawStake(address vaultOwner, address vaultAddress, nat withdrawAmount)`

Registers the unstaking of MVN from a vault address to the vault owner

{% hint style="info" %}
Can be called only by the lending controller contract
{% endhint %}

| Param Name     | Type    | Description                                                                |
| -------------- | ------- | -------------------------------------------------------------------------- |
| vaultOwner     | address | The address of the vault owner                                             |
| vaultAddress   | address | The address of the vault                                                   |
| withdrawAmount | nat     | The amount of staked MVN to be withdrawn from the vault to the vault owner |

#### onVaultLiquidateStake

`function onVaultLiquidateStake(address vaultAddress, address liquidator, nat liquidatedAmount)`

Registers the liquidation of staked MVN from a given vault to the liquidator

{% hint style="info" %}
Can be called only by the lending controller contract
{% endhint %}

| Param Name       | Type    | Description                                                                         |
| ---------------- | ------- | ----------------------------------------------------------------------------------- |
| vaultAddress     | address | The address of the vault                                                            |
| liquidator       | address | The address of the liquidator                                                       |
| liquidatedAmount | nat     | The amount of liquidated MVN to be deposited from the vault owner to the liquidator |

### 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, doormanConfigActionType doormanConfigAction)`

Updates the config variables on the Doorman Contract

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

<table><thead><tr><th width="199.33333333333331">Param Name</th><th width="355">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>doormanConfigAction</td><td>doormanConfigActionType: <br>| unit ConfigMinMvnAmount <br>| unit Empty</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 mvn 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="190.33333333333331">Param Name</th><th width="347">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) MRC-10 <br>| (address tokenContractAddress, nat tokenId)  MRC-20</td><td>The token type of the token to be transferred, corresponding to either MVRK, MRC-10, or MRC-20</td></tr></tbody></table>

#### migrateFunds

`function migrateFunds(address receiverAddress)`

Migrates all the MVN in the Doorman Contract to another address. All the contract entrypoints must be paused for this to work

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

| Param Name      | Type    | Description                                                            |
| --------------- | ------- | ---------------------------------------------------------------------- |
| receiverAddress | address | The address of the new Doorman contract to received the migrated funds |

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

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

#### unpauseAll

`function unpauseAll()`

Unpauses all entrypoints in the contract

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

#### togglePauseEntrypoint

`function togglePauseEntrypoint(doormanPausableEntrypointType targetEntrypoint, unit empty)`

Toggles the pausing of a specific entrypoint in the contract

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

<table><thead><tr><th width="196.33333333333331">Param Name</th><th width="339">Type</th><th>Description</th></tr></thead><tbody><tr><td>targetEntrypoint</td><td>doormanPausableEntrypointType: <br>| bool Stake <br>| bool Unstake  <br>| bool Exit <br>| bool Compound <br>| bool FarmClaim <br>| bool OnVaultDepositStake <br>| bool OnVaultWithdrawStake <br>| bool OnVaultLiquidateStake</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

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

#### getBreakGlassConfig

`function getBreakGlassConfig()`

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

#### getUserStakeBalanceOpt

`function getUserStakeBalanceOpt(address userAddress)`

Returns a user stake balance record based on the provided address, else returns none

#### getUnclaimedRewards

`function getUnclaimedRewards()`

Returns the total unclaimed exit fee rewards

#### getAccumulatedFeesPerShare

`function getAccumulatedFeesPerShare()`

Returns the accumulated fees per share used in the exit fee rewards calculation

#### getStakedBalance

`function getStakedBalance(address userAddress)`

Returns the staked MVN balance of a given user, else returns 0

#### getLambdaOpt

`function getLambdaOpt(string lambdaName)`

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