Skip to main content

IYieldDepositFacility

Git Source

Interface for the Yield Facility that can be used to mint yield-bearing deposits

Functions

createPosition

Creates a position for a yield-bearing deposit

*The implementing contract is expected to handle the following:

  • Validating that the asset is supported
  • Depositing the asset into the deposit manager and minting the receipt token
  • Creating a new position in the DEPOS module*
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
receiptTokenIduint256The ID of the receipt token
actualAmountuint256The quantity of receipt tokens minted to the depositor

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

previewClaimYield

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

*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
  • Returning the total amount of yield that would be claimed*
function previewClaimYield(address account_, uint256[] memory positionIds_)
external
view
returns (uint256 yield, IERC20 asset);

Parameters

NameTypeDescription
account_addressThe address to preview the yield for
positionIds_uint256[]An array of position ids that will be claimed

Returns

NameTypeDescription
yielduint256The amount of yield that would be claimed
assetIERC20The address of the asset that will be received

claimYield

Claims the yield for the given positions

*The implementing contract is expected to handle the following:

  • Validating that the caller 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
  • Transferring the yield to the caller
  • Emitting an event*
function claimYield(uint256[] memory positionIds_) external returns (uint256 yield);

Parameters

NameTypeDescription
positionIds_uint256[]An array of position ids that will be claimed

Returns

NameTypeDescription
yielduint256The amount of yield that was claimed

setYieldFee

Sets the percentage of yield that will be taken as a fee

*The implementing contract is expected to handle the following:

  • Validating that the caller has the correct role
  • Setting the yield fee*
function setYieldFee(uint16 yieldFee_) external;

Parameters

NameTypeDescription
yieldFee_uint16The percentage of yield that will be taken as a fee, in terms of 100e2

getYieldFee

Returns the percentage of yield that will be taken as a fee

function getYieldFee() external view returns (uint16 yieldFee);

Returns

NameTypeDescription
yieldFeeuint16The percentage of yield that will be taken as a fee, in terms of 100e2

Events

CreatedDeposit

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

ClaimedYield

event ClaimedYield(address indexed asset, address indexed depositor, uint256 yield);

YieldFeeSet

event YieldFeeSet(uint16 yieldFee);

RateSnapshotTaken

event RateSnapshotTaken(address indexed vault, uint48 timestamp, uint256 rate);

Errors

YDF_InvalidArgs

error YDF_InvalidArgs(string reason_);

YDF_NotOwner

error YDF_NotOwner(uint256 positionId_);

YDF_InvalidToken

error YDF_InvalidToken(address token_, uint8 periodMonths_);

YDF_Unsupported

error YDF_Unsupported(uint256 positionId_);

YDF_NoRateSnapshot

error YDF_NoRateSnapshot(address vault_, uint48 timestamp_);

Structs

CreatePositionParams

Parameters for the createPosition function

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

Properties

NameTypeDescription
assetIERC20The address of the asset
periodMonthsuint8The period of the deposit
amountuint256The amount of asset to deposit
wrapPositionboolWhether the position should be wrapped
wrapReceiptboolWhether the receipt token should be wrapped