Skip to main content

IConvertibleDepositFacility

Git Source

Title: IConvertibleDepositFacility

Interface for a contract that can perform functions related to convertible deposit (CD) tokens

Functions

createPosition

Creates a convertible deposit position

The implementing contract is expected to handle the following:

  • Validating that the asset is supported
  • Validating that the caller has the correct role
  • Depositing the asset
  • Minting the receipt token
  • Creating a new position in the DEPOS module
  • Emitting an event
function createPosition(CreatePositionParams calldata params_)
external
returns (uint256 positionId, uint256 receiptTokenId, uint256 actualAmount);

Parameters

NameTypeDescription
params_CreatePositionParamsThe parameters for the position creation

Returns

NameTypeDescription
positionIduint256The ID of the new position
receiptTokenIduint256
actualAmountuint256

deposit

Deposits the given amount of the underlying asset in exchange for a receipt token. This function can be used to mint additional receipt tokens on a 1:1 basis, without creating a new position.

function deposit(IERC20 asset_, uint8 periodMonths_, uint256 amount_, bool wrapReceipt_)
external
returns (uint256 receiptTokenId, uint256 actualAmount);

Parameters

NameTypeDescription
asset_IERC20The address of the asset
periodMonths_uint8The period of the deposit
amount_uint256The amount of asset to deposit
wrapReceipt_boolWhether the receipt token should be wrapped

Returns

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

convert

Converts receipt tokens to OHM before conversion expiry

The implementing contract is expected to handle the following:

  • Validating that the caller is the owner of all of the positions
  • Validating that the token in the position is a supported receipt token
  • Validating that all of the positions are valid
  • Validating that the conversion expiry for all of the positions has not passed
  • Burning the receipt tokens
  • Minting OHM to account_
  • Transferring the deposit token to the treasury
  • Emitting an event
function convert(uint256[] memory positionIds_, uint256[] memory amounts_, bool wrappedReceipt_)
external
returns (uint256 receiptTokenIn, uint256 convertedTokenOut);

Parameters

NameTypeDescription
positionIds_uint256[]An array of position ids that will be converted
amounts_uint256[]An array of amounts of receipt tokens to convert
wrappedReceipt_boolWhether the receipt tokens to use are wrapped as ERC20s

Returns

NameTypeDescription
receiptTokenInuint256The total amount of receipt tokens converted
convertedTokenOutuint256The amount of OHM minted during conversion

previewConvert

Preview the amount of receipt tokens and OHM that would be converted

The implementing contract is expected to handle the following:

  • Validating that account_ is the owner of all of the positions
  • Validating that token in the position is a supported receipt token
  • Validating that all of the positions are valid
  • Validating that the conversion expiry for all of the positions has not passed
  • Returning the total amount of receipt tokens and OHM that would be converted
function previewConvert(address account_, uint256[] memory positionIds_, uint256[] memory amounts_)
external
view
returns (uint256 receiptTokenIn, uint256 convertedTokenOut);

Parameters

NameTypeDescription
account_addressThe address to preview the conversion for
positionIds_uint256[]An array of position ids that will be converted
amounts_uint256[]An array of amounts of receipt tokens to convert

Returns

NameTypeDescription
receiptTokenInuint256The total amount of receipt tokens converted
convertedTokenOutuint256The amount of OHM minted during conversion

previewClaimYield

Preview the amount of yield that would be claimed for the given asset

function previewClaimYield(IERC20 asset_) external view returns (uint256 assets);

Parameters

NameTypeDescription
asset_IERC20The address of the asset

Returns

NameTypeDescription
assetsuint256The amount of assets that would be claimed

claimYield

Claim the yield accrued for the given asset

function claimYield(IERC20 asset_) external returns (uint256 assets);

Parameters

NameTypeDescription
asset_IERC20The address of the asset

Returns

NameTypeDescription
assetsuint256The amount of assets that were claimed

claimYield

Claim the yield accrued for the given asset

function claimYield(IERC20 asset_, uint256 amount_) external returns (uint256 assets);

Parameters

NameTypeDescription
asset_IERC20The address of the asset
amount_uint256The amount to claim

Returns

NameTypeDescription
assetsuint256The amount of assets that were claimed

claimAllYield

Claim the yield accrued for all assets and deposit periods

function claimAllYield() external;

convertedToken

The address of the token that is converted to by the facility

function convertedToken() external view returns (address);

Events

CreatedDeposit

event CreatedDeposit(
address indexed asset,
address indexed depositor,
uint256 indexed positionId,
uint8 periodMonths,
uint256 depositAmount
);

ConvertedDeposit

event ConvertedDeposit(
address indexed asset,
address indexed depositor,
uint8 periodMonths,
uint256 depositAmount,
uint256 convertedAmount
);

ClaimedYield

event ClaimedYield(address indexed asset, uint256 amount);

ClaimAllYieldFailed

event ClaimAllYieldFailed();

Errors

CDF_InvalidArgs

error CDF_InvalidArgs(string reason_);

CDF_NotOwner

error CDF_NotOwner(uint256 positionId_);

CDF_PositionExpired

error CDF_PositionExpired(uint256 positionId_);

CDF_InvalidAmount

error CDF_InvalidAmount(uint256 positionId_, uint256 amount_);

CDF_InvalidToken

error CDF_InvalidToken(uint256 positionId_, address token_, uint8 periodMonths_);

CDF_Unsupported

error CDF_Unsupported(uint256 positionId_);

Structs

CreatePositionParams

Parameters for the createPosition function

struct CreatePositionParams {
IERC20 asset;
uint8 periodMonths;
address depositor;
uint256 amount;
uint256 conversionPrice;
bool wrapPosition;
bool wrapReceipt;
}

Properties

NameTypeDescription
assetIERC20The address of the asset
periodMonthsuint8The period of the deposit
depositoraddressThe address to create the position for
amountuint256The amount of asset to deposit
conversionPriceuint256The amount of asset tokens required to receive 1 OHM (scale: asset token decimals)
wrapPositionboolWhether the position should be wrapped
wrapReceiptboolWhether the receipt token should be wrapped