# CellarMigrationAdaptor

[Git Source](https://github.com/Ion-Protocol/nucleus-boring-vault/blob/cc0b494b83e17b9b169a73b96050d2810b690477/src/migration/CellarMigrationAdaptor.sol)

## State Variables

### boringVault

```solidity
BoringVault internal immutable boringVault;
```

### accountant

```solidity
AccountantWithRateProviders internal immutable accountant;
```

### teller

```solidity
TellerWithMultiAssetSupport internal immutable teller;
```

## Functions

### constructor

```solidity
constructor(address _boringVault, address _accountant, address _teller);
```

### identifier

*Identifier unique to this adaptor for a shared registry. Normally the identifier would just be the address of this contract, but this Identifier is needed during Cellar Delegate Call Operations, so getting the address of the adaptor is more difficult.*

```solidity
function identifier() public pure virtual returns (bytes32);
```

### deposit

Function Cellars call to deposit users funds into holding position.

```solidity
function deposit(uint256, bytes memory, bytes memory) public virtual;
```

### withdraw

Function Cellars call to withdraw funds from positions to send to users.

```solidity
function withdraw(uint256 assets, address receiver, bytes memory, bytes memory configurationData) public virtual;
```

**Parameters**

| Name                | Type      | Description                                     |
| ------------------- | --------- | ----------------------------------------------- |
| `assets`            | `uint256` | in terms of accountant's base asset             |
| `receiver`          | `address` | the address that should receive withdrawn funds |
| `<none>`            | `bytes`   |                                                 |
| `configurationData` | `bytes`   |                                                 |

### balanceOf

Function Cellars use to determine `assetOf` balance of an adaptor position.

```solidity
function balanceOf(bytes memory) public view virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description                                  |
| -------- | --------- | -------------------------------------------- |
| `<none>` | `uint256` | assets of the position in terms of `assetOf` |

### withdrawableFrom

Functions Cellars use to determine the withdrawable balance from an adaptor position.

accepts adaptorData and configurationData

*Debt positions MUST return 0 for their `withdrawableFrom`*

```solidity
function withdrawableFrom(bytes memory, bytes memory configurationData) public view virtual returns (uint256);
```

**Returns**

| Name     | Type      | Description                                                |
| -------- | --------- | ---------------------------------------------------------- |
| `<none>` | `uint256` | withdrawable balance of the position in terms of `assetOf` |

### assetOf

Function Cellars use to determine the underlying ERC20 asset of a position.

```solidity
function assetOf(bytes memory) public view virtual returns (ERC20);
```

**Returns**

| Name     | Type    | Description                              |
| -------- | ------- | ---------------------------------------- |
| `<none>` | `ERC20` | the underlying ERC20 asset of a position |

### assetsUsed

When positions are added to the Registry, this function can be used in order to figure out what assets this adaptor needs to price, and confirm pricing is properly setup.

```solidity
function assetsUsed(bytes memory adaptorData) public view virtual returns (ERC20[] memory assets);
```

### isDebt

Functions Registry/Cellars use to determine if this adaptor reports debt values.

*returns true if this adaptor reports debt values.*

```solidity
function isDebt() public view virtual returns (bool);
```

### deposit

Allows strategist to perform a bulkDeposit into Teller.

```solidity
function deposit(ERC20 depositAsset, uint256 depositAmount, uint256 minimumMint) external;
```

### withdraw

Allows strategist to perform a bulkWithdraw from Teller.

```solidity
function withdraw(ERC20 withdrawAsset, uint256 shareAmount, uint256 minimumAssets) external;
```

### \_maxAvailable

Helper function that allows adaptor calls to use the max available of an ERC20 asset by passing in type(uint256).max

```solidity
function _maxAvailable(ERC20 token, uint256 amount) internal view virtual returns (uint256);
```

**Parameters**

| Name     | Type      | Description                                                                                                          |
| -------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
| `token`  | `ERC20`   | the ERC20 asset to work with                                                                                         |
| `amount` | `uint256` | when `type(uint256).max` is used, this function returns `token`s `balanceOf` otherwise this function returns amount. |

### \_revokeExternalApproval

Helper function that checks if `spender` has any more approval for `asset`, and if so revokes it.

```solidity
function _revokeExternalApproval(ERC20 asset, address spender) internal;
```

### \_externalReceiverCheck

Helper function that validates external receivers are allowed.

```solidity
function _externalReceiverCheck(address receiver) internal view;
```

## Errors

### CellarMigrationAdaptor\_\_ExternalReceiverBlocked

Attempted to specify an external receiver during a Cellar `callOnAdaptor` call.

```solidity
error CellarMigrationAdaptor__ExternalReceiverBlocked();
```

### CellarMigrationAdaptor\_\_UserDepositsNotAllowed

Attempted to deposit to a position where user deposits were not allowed.

```solidity
error CellarMigrationAdaptor__UserDepositsNotAllowed();
```

### CellarMigrationAdaptor\_\_UserWithdrawsNotAllowed

Attempted to withdraw from a position where user withdraws were not allowed.

```solidity
error CellarMigrationAdaptor__UserWithdrawsNotAllowed();
```
