# 3Pool Convex Meta Vault

Abstract ERC-4626 vaults with DAI, USDC or USDT asset invested in Curve's [3Pool](https://curve.fi/3pool), and then the 3Pool LP token (3Crv) is invested in an underlying 3Pool-based (3Crv) Meta Vault.

## Capabilities

* [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) compliant tokenized vault.
* [ERC-20](https://eips.ethereum.org/EIPS/eip-20) compliant token.
* Invests DAI, USDC or USDT in Curve's 3Pool and then invests the 3Crv LP token in an underlying ERC4626 vault.
* Sandwich attack protection on ERC4626 operations `deposit`, `mint`, `withdraw` and `redeem`.
* Vault operations are pausable by the `Governor`.
* Emergency asset recovery by the `Governor`. This will be removed after 2 months.
* Vault configuration is controlled by a protocol `Governor`. This includes:
  * Setting the slippage limits for mint, deposit, redeem and withdraw.
* Initially the `Governor` can upgrade the contracts via a proxy without a time delay. After 6 weeks, this will be changed to a one week time delay.

## Contract Interface

See the metavaults github repository for [contract diagrams](https://github.com/mstable/metavaults/tree/main/contracts/vault/liquidity/curve#diagrams) and [process diagrams](https://github.com/mstable/metavaults/tree/main/contracts/vault/liquidity/curve#processes).

See [general-erc-4626-vault-interface](https://developers.mstable.org/meta-vaults/general-erc-4626-vault-interface "mention") for the standard ERC-4626 functions.

### Variables

#### BASIS\_SCALE

```solidity
uint256 BASIS_SCALE
```

Basis points calculation scale. 100% = 10000. 1% = 100

#### redeemSlippage

```solidity
uint256 redeemSlippage
```

Redeem slippage in basis points i.e. 1% = 100

#### depositSlippage

```solidity
uint256 depositSlippage
```

Deposit slippage in basis points i.e. 1% = 100

#### withdrawSlippage

```solidity
uint256 withdrawSlippage
```

Withdraw slippage in basis points i.e. 1% = 100

#### mintSlippage

```solidity
uint256 mintSlippage
```

Mint slippage in basis points i.e. 1% = 100

#### assetScale

```solidity
uint256 assetScale
```

Scale of one asset. eg 1e18 if asset has 18 decimal places.

#### assetFromUsdScale

```solidity
uint256 assetFromUsdScale
```

Converts USD value with 18 decimals back down to asset/vault scale. For example, convert 18 decimal USD value back down to USDC which only has 6 decimal places. Will be 1 for DAI, 1e12 for USDC and USDT.

#### threeCrvTokenScale

```solidity
uint256 threeCrvTokenScale
```

Scale of the Curve.fi 3Crv token. 1e18 = 18 decimal places

#### metaVault

```solidity
contract IERC4626Vault metaVault
```

Address of the underlying Meta Vault that implements ERC-4626.

#### assetPoolIndex

```solidity
uint256 assetPoolIndex
```

The index of underlying asset DAI, USDC or USDT in 3Pool. DAI = 0, USDC = 1 and USDT = 2

### Functions

#### liquidateVault

```solidity
function liquidateVault(uint256 minAssets) external
```

Governor liquidates all the vault's assets and send to the governor. Only to be used in an emergency. eg whitehat protection against a hack.

**Parameters**

<table><thead><tr><th width="127.33333333333331">Name</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td>minAssets</td><td>uint256</td><td>Minimum amount of asset tokens to receive from removing liquidity from the Curve 3Pool. This provides sandwich attack protection.</td></tr></tbody></table>

#### resetAllowances

```solidity
function resetAllowances() external
```

Approves Curve's 3Pool contract to transfer assets (DAI, USDC or USDT) from this vault. Also approves the underlying Meta Vault to transfer 3Crv from this vault.

#### setRedeemSlippage

```solidity
function setRedeemSlippage(uint256 _slippage) external
```

Governor function to set redeem slippage.

**Parameters**

<table><thead><tr><th width="135.33333333333331">Name</th><th width="103">Type</th><th>Description</th></tr></thead><tbody><tr><td>_slippage</td><td>uint256</td><td>Redeem slippage to apply as basis points i.e. 1% = 100</td></tr></tbody></table>

#### setDepositSlippage

```solidity
function setDepositSlippage(uint256 _slippage) external
```

Governor function to set deposit slippage.

**Parameters**

<table><thead><tr><th width="126.33333333333331">Name</th><th width="120">Type</th><th>Description</th></tr></thead><tbody><tr><td>_slippage</td><td>uint256</td><td>Deposit slippage to apply as basis points i.e. 1% = 100</td></tr></tbody></table>

#### setWithdrawSlippage

```solidity
function setWithdrawSlippage(uint256 _slippage) external
```

Governor function to set withdraw slippage.

**Parameters**

<table><thead><tr><th width="149.33333333333331">Name</th><th width="93">Type</th><th>Description</th></tr></thead><tbody><tr><td>_slippage</td><td>uint256</td><td>Withdraw slippage to apply as basis points i.e. 1% = 100</td></tr></tbody></table>

#### setMintSlippage

```solidity
function setMintSlippage(uint256 _slippage) external
```

Governor function to set mint slippage.

**Parameters**

<table><thead><tr><th width="135">Name</th><th width="91.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>_slippage</td><td>uint256</td><td>Mint slippage to apply as basis points i.e. 1% = 100</td></tr></tbody></table>
