Skip to main content

IDepositManager

Git Source

Inherits: IAssetManager

Title: Deposit Manager

Defines an interface for a policy that manages deposits on behalf of other contracts. It is meant to be used by the facilities, and is not an end-user policy. Key terms for the contract:

  • Asset: an ERC20 asset that can be deposited into the contract
  • Asset vault: an optional ERC4626 vault that assets are deposited into
  • Asset period: the combination of an asset and deposit period

Functions

borrowingWithdraw

Borrows funds from deposits

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Validating borrowing limits and capacity
  • Transferring the underlying asset from the contract to the recipient
  • Updating borrowing state
  • Checking solvency
function borrowingWithdraw(BorrowingWithdrawParams calldata params_) external returns (uint256 actualAmount);

Parameters

NameTypeDescription
params_BorrowingWithdrawParamsThe parameters for the borrowing withdrawal

Returns

NameTypeDescription
actualAmountuint256The quantity of underlying assets transferred to the recipient

borrowingRepay

Repays borrowed funds

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Transferring the underlying asset from the payer to the contract
  • Updating borrowing state
  • Checking solvency
function borrowingRepay(BorrowingRepayParams calldata params_) external returns (uint256 actualAmount);

Parameters

NameTypeDescription
params_BorrowingRepayParamsThe parameters for the borrowing repayment

Returns

NameTypeDescription
actualAmountuint256The quantity of underlying assets received from the payer

borrowingDefault

Defaults on a borrowed amount

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Burning the receipt tokens from the payer for the default amount
  • Updating borrowing state
  • Updating liabilities
function borrowingDefault(BorrowingDefaultParams calldata params_) external;

getBorrowedAmount

Gets the current borrowed amount for an operator

function getBorrowedAmount(IERC20 asset_, address operator_) external view returns (uint256 borrowed);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
operator_addressThe address of the operator

Returns

NameTypeDescription
borroweduint256The current borrowed amount for the operator

getBorrowingCapacity

Gets the available borrowing capacity for an operator

function getBorrowingCapacity(IERC20 asset_, address operator_) external view returns (uint256 capacity);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
operator_addressThe address of the operator

Returns

NameTypeDescription
capacityuint256The available borrowing capacity for the operator

deposit

Deposits the given amount of the underlying asset in exchange for a receipt token

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Transferring the underlying asset from the depositor to the contract
  • Minting the receipt token to the depositor
  • Updating the amount of deposited funds
function deposit(DepositParams calldata params_) external returns (uint256 receiptTokenId, uint256 actualAmount);

Parameters

NameTypeDescription
params_DepositParamsThe parameters for the deposit

Returns

NameTypeDescription
receiptTokenIduint256The ID of the receipt token
actualAmountuint256The quantity of receipt tokens minted to the depositor

maxClaimYield

Returns the maximum yield that can be claimed for an asset and operator pair

function maxClaimYield(IERC20 asset_, address operator_) external view returns (uint256 yieldAssets);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
operator_addressThe address of the operator

Returns

NameTypeDescription
yieldAssetsuint256The amount of yield that can be claimed

claimYield

Claims the yield from the underlying asset This does not burn receipt tokens, but should reduce the amount of shares the caller has in the vault.

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Transferring the underlying asset from the contract to the recipient
  • Updating the amount of deposited funds
  • Checking solvency
function claimYield(IERC20 asset_, address recipient_, uint256 amount_) external returns (uint256 actualAmount);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
recipient_addressThe recipient of the claimed yield
amount_uint256The amount to claim yield for

Returns

NameTypeDescription
actualAmountuint256The quantity of underlying assets transferred to the recipient

withdraw

Withdraws the given amount of the underlying asset

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Burning the receipt token
  • Transferring the underlying asset from the contract to the recipient
  • Updating the amount of deposited funds
function withdraw(WithdrawParams calldata params_) external returns (uint256 actualAmount);

Parameters

NameTypeDescription
params_WithdrawParamsThe parameters for the withdrawal

Returns

NameTypeDescription
actualAmountuint256The quantity of underlying assets transferred to the recipient

getOperatorLiabilities

Returns the liabilities for an asset and operator pair

function getOperatorLiabilities(IERC20 asset_, address operator_) external view returns (uint256 liabilities);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
operator_addressThe address of the operator

Returns

NameTypeDescription
liabilitiesuint256The quantity of assets that the contract is custodying for the operator's depositors

setOperatorName

Sets the name of an operator. This is included in the name and symbol of receipt tokens.

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Setting the operator name
  • Emitting an event
function setOperatorName(address operator_, string calldata name_) external;

getOperatorName

Returns the name of an operator

function getOperatorName(address operator_) external view returns (string memory name);

Parameters

NameTypeDescription
operator_addressThe address of the operator

Returns

NameTypeDescription
namestringThe name of the operator or an empty string

addAsset

Adds a new asset

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Configuring the asset
  • Emitting an event
function addAsset(IERC20 asset_, IERC4626 vault_, uint256 depositCap_, uint256 minimumDeposit_) external;

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
vault_IERC4626The address of the ERC4626 vault to deposit the asset into (or the zero address)
depositCap_uint256The deposit cap of the asset
minimumDeposit_uint256The minimum deposit amount for the asset

setAssetDepositCap

Sets the deposit cap for an asset

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Setting the deposit cap for the asset
  • Emitting an event
function setAssetDepositCap(IERC20 asset_, uint256 depositCap_) external;

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
depositCap_uint256The deposit cap to set for the asset

setAssetMinimumDeposit

Sets the minimum deposit for an asset

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Setting the minimum deposit for the asset
  • Emitting an event
function setAssetMinimumDeposit(IERC20 asset_, uint256 minimumDeposit_) external;

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
minimumDeposit_uint256The minimum deposit to set for the asset

addAssetPeriod

Adds a new asset period

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Creating a new receipt token
  • Emitting an event
function addAssetPeriod(IERC20 asset_, uint8 depositPeriod_, address operator_)
external
returns (uint256 receiptTokenId);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
depositPeriod_uint8The deposit period, in months
operator_addressThe address of the operator

Returns

NameTypeDescription
receiptTokenIduint256The ID of the new receipt token

disableAssetPeriod

Disables an asset period, which prevents new deposits

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Disabling the asset period
  • Emitting an event
function disableAssetPeriod(IERC20 asset_, uint8 depositPeriod_, address operator_) external;

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
depositPeriod_uint8The deposit period, in months
operator_addressThe address of the operator

enableAssetPeriod

Enables an asset period, which allows new deposits

The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Enabling the asset period
  • Emitting an event
function enableAssetPeriod(IERC20 asset_, uint8 depositPeriod_, address operator_) external;

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
depositPeriod_uint8The deposit period, in months
operator_addressThe address of the operator

getAssetPeriod

Returns the asset period for an asset, period and operator

function getAssetPeriod(IERC20 asset_, uint8 depositPeriod_, address operator_)
external
view
returns (AssetPeriod memory configuration);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
depositPeriod_uint8The deposit period, in months
operator_addressThe address of the operator

Returns

NameTypeDescription
configurationAssetPeriodThe asset period

getAssetPeriod

Returns the asset period from a receipt token ID

function getAssetPeriod(uint256 tokenId_) external view returns (AssetPeriod memory configuration);

Parameters

NameTypeDescription
tokenId_uint256The ID of the receipt token

Returns

NameTypeDescription
configurationAssetPeriodThe asset period

isAssetPeriod

Returns whether a deposit asset, period and operator combination are configured

A asset period that is disabled will not accept further deposits

function isAssetPeriod(IERC20 asset_, uint8 depositPeriod_, address operator_)
external
view
returns (AssetPeriodStatus memory status);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
depositPeriod_uint8The deposit period, in months
operator_addressThe address of the operator

Returns

NameTypeDescription
statusAssetPeriodStatusThe status of the asset period

getAssetPeriods

Gets all configured asset periods

function getAssetPeriods() external view returns (AssetPeriod[] memory assetPeriods);

Returns

NameTypeDescription
assetPeriodsAssetPeriod[]Array of configured asset periods

getReceiptTokenId

Returns the ID of the receipt token for an asset period and operator

The ID returned is not a guarantee that the asset period is configured or enabled. isAssetPeriod should be used for that purpose.

function getReceiptTokenId(IERC20 asset_, uint8 depositPeriod_, address operator_)
external
view
returns (uint256 receiptTokenId);

Parameters

NameTypeDescription
asset_IERC20The address of the underlying asset
depositPeriod_uint8The deposit period, in months
operator_addressThe address of the operator

Returns

NameTypeDescription
receiptTokenIduint256The ID of the receipt token

getReceiptToken

Convenience function that returns both receipt token ID and wrapped token address

function getReceiptToken(IERC20 asset_, uint8 depositPeriod_, address operator_)
external
view
returns (uint256 tokenId, address wrappedToken);

Parameters

NameTypeDescription
asset_IERC20The asset contract
depositPeriod_uint8The deposit period in months
operator_addressThe operator address

Returns

NameTypeDescription
tokenIduint256The receipt token ID
wrappedTokenaddressThe address of the wrapped ERC20 token (0x0 if not created yet)

getReceiptTokenManager

Gets the receipt token manager

function getReceiptTokenManager() external view returns (IReceiptTokenManager manager);

Returns

NameTypeDescription
managerIReceiptTokenManagerThe receipt token manager contract

getReceiptTokenIds

Gets all receipt token IDs owned by this contract

function getReceiptTokenIds() external view returns (uint256[] memory tokenIds);

Returns

NameTypeDescription
tokenIdsuint256[]Array of receipt token IDs

Events

OperatorYieldClaimed

event OperatorYieldClaimed(
address indexed asset, address indexed depositor, address indexed operator, uint256 amount
);

OperatorNameSet

event OperatorNameSet(address indexed operator, string name);

AssetPeriodConfigured

event AssetPeriodConfigured(
uint256 indexed receiptTokenId, address indexed asset, address indexed operator, uint8 depositPeriod
);

AssetPeriodEnabled

event AssetPeriodEnabled(
uint256 indexed receiptTokenId, address indexed asset, address indexed operator, uint8 depositPeriod
);

AssetPeriodDisabled

event AssetPeriodDisabled(
uint256 indexed receiptTokenId, address indexed asset, address indexed operator, uint8 depositPeriod
);

TokenRescued

event TokenRescued(address indexed token, uint256 amount);

BorrowingWithdrawal

event BorrowingWithdrawal(
address indexed asset, address indexed operator, address indexed recipient, uint256 amount
);

BorrowingRepayment

event BorrowingRepayment(address indexed asset, address indexed operator, address indexed payer, uint256 amount);

BorrowingDefault

event BorrowingDefault(address indexed asset, address indexed operator, address indexed payer, uint256 amount);

Errors

DepositManager_InvalidParams

error DepositManager_InvalidParams(string reason);

DepositManager_Insolvent

Error if the action would leave the contract insolvent (liabilities > assets + borrowed)

error DepositManager_Insolvent(
address asset, uint256 requiredAssets, uint256 depositedSharesInAssets, uint256 borrowedAmount
);

Parameters

NameTypeDescription
assetaddressThe address of the underlying asset
requiredAssetsuint256The quantity of asset liabilities
depositedSharesInAssetsuint256The quantity of assets that the deposited shares represent
borrowedAmountuint256The quantity of assets that are currently borrowed

DepositManager_ZeroAddress

error DepositManager_ZeroAddress();

DepositManager_OutOfBounds

error DepositManager_OutOfBounds();

DepositManager_CannotRescueAsset

error DepositManager_CannotRescueAsset(address token);

DepositManager_OperatorNameNotSet

error DepositManager_OperatorNameNotSet(address operator);

DepositManager_OperatorNameSet

error DepositManager_OperatorNameSet(address operator);

DepositManager_OperatorNameInvalid

error DepositManager_OperatorNameInvalid();

DepositManager_OperatorNameInUse

error DepositManager_OperatorNameInUse(string name);

DepositManager_InvalidAssetPeriod

error DepositManager_InvalidAssetPeriod(address asset, uint8 depositPeriod, address operator);

DepositManager_AssetPeriodExists

error DepositManager_AssetPeriodExists(address asset, uint8 depositPeriod, address operator);

DepositManager_AssetPeriodEnabled

error DepositManager_AssetPeriodEnabled(address asset, uint8 depositPeriod, address operator);

DepositManager_AssetPeriodDisabled

error DepositManager_AssetPeriodDisabled(address asset, uint8 depositPeriod, address operator);

DepositManager_BorrowingLimitExceeded

error DepositManager_BorrowingLimitExceeded(address asset, address operator, uint256 requested, uint256 available);

DepositManager_BorrowedAmountExceeded

error DepositManager_BorrowedAmountExceeded(address asset, address operator, uint256 amount, uint256 borrowed);

Structs

DepositParams

Parameters for the deposit function

struct DepositParams {
IERC20 asset;
uint8 depositPeriod;
address depositor;
uint256 amount;
bool shouldWrap;
}

Properties

NameTypeDescription
assetIERC20The underlying ERC20 asset
depositPerioduint8The deposit period, in months
depositoraddressThe depositor
amountuint256The amount to deposit
shouldWrapboolWhether the receipt token should be wrapped

WithdrawParams

Parameters for the withdraw function

struct WithdrawParams {
IERC20 asset;
uint8 depositPeriod;
address depositor;
address recipient;
uint256 amount;
bool isWrapped;
}

Properties

NameTypeDescription
assetIERC20The underlying ERC20 asset
depositPerioduint8The deposit period, in months
depositoraddressThe depositor that is holding the receipt tokens
recipientaddressThe recipient of the withdrawn asset
amountuint256The amount to withdraw
isWrappedboolWhether the receipt token is wrapped

AssetPeriod

An asset period configuration, representing an asset and period combination

struct AssetPeriod {
bool isEnabled;
uint8 depositPeriod;
address asset;
address operator;
}

Properties

NameTypeDescription
isEnabledboolWhether the asset period is enabled for new deposits
depositPerioduint8The deposit period, in months
assetaddressThe underlying ERC20 asset
operatoraddressThe operator that can issue this receipt token

AssetPeriodStatus

Status of an asset period

struct AssetPeriodStatus {
bool isConfigured;
bool isEnabled;
}

Properties

NameTypeDescription
isConfiguredboolWhether the asset period is configured
isEnabledboolWhether the asset period is enabled for new deposits

BorrowingWithdrawParams

Parameters for borrowing withdrawal operations

struct BorrowingWithdrawParams {
IERC20 asset;
address recipient;
uint256 amount;
}

Properties

NameTypeDescription
assetIERC20The underlying ERC20 asset
recipientaddressThe recipient of the borrowed funds
amountuint256The amount to borrow

BorrowingRepayParams

Parameters for borrowing repayment operations

struct BorrowingRepayParams {
IERC20 asset;
address payer;
uint256 amount;
uint256 maxAmount;
}

Properties

NameTypeDescription
assetIERC20The underlying ERC20 asset
payeraddressThe address making the repayment
amountuint256The amount of principal to repay
maxAmountuint256The maximum amount that can be repaid

BorrowingDefaultParams

Parameters for borrowing default operations

struct BorrowingDefaultParams {
IERC20 asset;
uint8 depositPeriod;
address payer;
uint256 amount;
}

Properties

NameTypeDescription
assetIERC20The underlying ERC20 asset
depositPerioduint8The deposit period, in months
payeraddressThe address making the default
amountuint256The amount to default