Skip to main content

IDepositRedemptionVault

Git Source

Title: IDepositRedemptionVault

Interface for a contract that can manage the redemption of receipt tokens for their deposit

Functions

authorizeFacility

Authorize a facility

function authorizeFacility(address facility_) external;

Parameters

NameTypeDescription
facility_addressThe address of the facility to authorize

deauthorizeFacility

Deauthorize a facility

function deauthorizeFacility(address facility_) external;

Parameters

NameTypeDescription
facility_addressThe address of the facility to deauthorize

isAuthorizedFacility

Check if a facility is authorized

function isAuthorizedFacility(address facility_) external view returns (bool isAuthorized);

Parameters

NameTypeDescription
facility_addressThe address of the facility to check

Returns

NameTypeDescription
isAuthorizedboolTrue if the facility is authorized

getAuthorizedFacilities

Get all authorized facilities

function getAuthorizedFacilities() external view returns (address[] memory facilities);

Returns

NameTypeDescription
facilitiesaddress[]Array of authorized facility addresses

getUserRedemption

Gets the details of a user's redemption

function getUserRedemption(address user_, uint16 redemptionId_)
external
view
returns (UserRedemption memory redemption);

Parameters

NameTypeDescription
user_addressThe address of the user
redemptionId_uint16The ID of the redemption

Returns

NameTypeDescription
redemptionUserRedemptionThe details of the redemption

getUserRedemptionCount

Gets the number of redemptions a user has started

function getUserRedemptionCount(address user_) external view returns (uint16 count);

Parameters

NameTypeDescription
user_addressThe address of the user

Returns

NameTypeDescription
countuint16The number of redemptions

getUserRedemptions

Gets all redemptions for a user

function getUserRedemptions(address user_) external view returns (UserRedemption[] memory);

Parameters

NameTypeDescription
user_addressThe address of the user

Returns

NameTypeDescription
<none>UserRedemption[]redemptions The array of redemptions

startRedemption

Starts a redemption of a quantity of deposit tokens

function startRedemption(IERC20 depositToken_, uint8 depositPeriod_, uint256 amount_, address facility_)
external
returns (uint16 redemptionId);

Parameters

NameTypeDescription
depositToken_IERC20The address of the deposit token
depositPeriod_uint8The period of the deposit in months
amount_uint256The amount of deposit tokens to redeem
facility_addressThe facility to handle this redemption

Returns

NameTypeDescription
redemptionIduint16The ID of the user redemption

startRedemption

Starts a redemption based on a position ID, using the position's conversion expiry

function startRedemption(uint256 positionId_, uint256 amount_) external returns (uint16 redemptionId);

Parameters

NameTypeDescription
positionId_uint256The ID of the position to redeem from
amount_uint256The amount of deposit tokens to redeem

Returns

NameTypeDescription
redemptionIduint16The ID of the user redemption

cancelRedemption

Cancels a redemption of a quantity of deposit tokens

function cancelRedemption(uint16 redemptionId_, uint256 amount_) external;

Parameters

NameTypeDescription
redemptionId_uint16The ID of the user redemption
amount_uint256The amount of deposit tokens to cancel

finishRedemption

Finishes a redemption of a quantity of deposit tokens

This function does not take an amount as an argument, because the amount is determined by the redemption

function finishRedemption(uint16 redemptionId_) external returns (uint256 actualAmount);

Parameters

NameTypeDescription
redemptionId_uint16The ID of the user redemption

Returns

NameTypeDescription
actualAmountuint256The quantity of deposit tokens transferred to the caller

borrowAgainstRedemption

Borrow the maximum amount against an active redemption

function borrowAgainstRedemption(uint16 redemptionId_) external returns (uint256 actualAmount);

Parameters

NameTypeDescription
redemptionId_uint16The ID of the redemption to borrow against

Returns

NameTypeDescription
actualAmountuint256The quantity of underlying assets transferred to the recipient

previewBorrowAgainstRedemption

Preview the maximum amount that can be borrowed against an active redemption

function previewBorrowAgainstRedemption(address user_, uint16 redemptionId_)
external
view
returns (uint256 principal, uint256 interest, uint48 dueDate);

Parameters

NameTypeDescription
user_addressThe address of the user
redemptionId_uint16The ID of the redemption to borrow against

Returns

NameTypeDescription
principaluint256The principal amount that can be borrowed
interestuint256The interest amount that will be charged
dueDateuint48The due date of the loan

repayLoan

Repay a loan

function repayLoan(uint16 redemptionId_, uint256 amount_, uint256 maxSlippage_) external;

Parameters

NameTypeDescription
redemptionId_uint16The ID of the redemption
amount_uint256The amount to repay
maxSlippage_uint256The maximum slippage allowed for the repayment

previewExtendLoan

Preview the interest payable for extending a loan

function previewExtendLoan(address user_, uint16 redemptionId_, uint8 months_)
external
view
returns (uint48 newDueDate, uint256 interestPayable);

Parameters

NameTypeDescription
user_addressThe address of the user
redemptionId_uint16The ID of the redemption
months_uint8The number of months to extend the loan

Returns

NameTypeDescription
newDueDateuint48The new due date
interestPayableuint256The interest payable upon extension

extendLoan

Extend a loan's due date

function extendLoan(uint16 redemptionId_, uint8 months_) external;

Parameters

NameTypeDescription
redemptionId_uint16The ID of the redemption
months_uint8The number of months to extend the loan

claimDefaultedLoan

Claim a defaulted loan and collect the reward

function claimDefaultedLoan(address user_, uint16 redemptionId_) external;

Parameters

NameTypeDescription
user_addressThe address of the user
redemptionId_uint16The ID of the redemption

getRedemptionLoan

Get all loans for a redemption

function getRedemptionLoan(address user_, uint16 redemptionId_) external view returns (Loan memory loan);

Parameters

NameTypeDescription
user_addressThe address of the user
redemptionId_uint16The ID of the redemption

Returns

NameTypeDescription
loanLoanThe loan

setMaxBorrowPercentage

Set the maximum borrow percentage for an asset-facility combination

function setMaxBorrowPercentage(IERC20 asset_, address facility_, uint16 percent_) external;

Parameters

NameTypeDescription
asset_IERC20The address of the asset
facility_addressThe address of the facility
percent_uint16The maximum borrow percentage

getMaxBorrowPercentage

Get the maximum borrow percentage for an asset-facility combination

function getMaxBorrowPercentage(IERC20 asset_, address facility_) external view returns (uint16 percent);

Parameters

NameTypeDescription
asset_IERC20The address of the asset
facility_addressThe address of the facility

Returns

NameTypeDescription
percentuint16The maximum borrow percentage (100e2 == 100%)

setAnnualInterestRate

Set the annual interest rate for an asset-facility combination

function setAnnualInterestRate(IERC20 asset_, address facility_, uint16 rate_) external;

Parameters

NameTypeDescription
asset_IERC20The address of the asset
facility_addressThe address of the facility
rate_uint16The annual interest rate (100e2 == 100%)

getAnnualInterestRate

Get the annual interest rate for an asset-facility combination

function getAnnualInterestRate(IERC20 asset_, address facility_) external view returns (uint16 rate);

Parameters

NameTypeDescription
asset_IERC20The address of the asset
facility_addressThe address of the facility

Returns

NameTypeDescription
rateuint16The annual interest rate, in terms of 100e2

setClaimDefaultRewardPercentage

Set the reward percentage when a claiming a defaulted loan

function setClaimDefaultRewardPercentage(uint16 percent_) external;

Parameters

NameTypeDescription
percent_uint16The claim default reward percentage

getClaimDefaultRewardPercentage

Get the claim default reward percentage

function getClaimDefaultRewardPercentage() external view returns (uint16 percent);

Returns

NameTypeDescription
percentuint16The claim default reward percentage, in terms of 100e2

Events

RedemptionStarted

event RedemptionStarted(
address indexed user,
uint16 indexed redemptionId,
address indexed depositToken,
uint8 depositPeriod,
uint256 amount,
address facility
);

RedemptionFinished

event RedemptionFinished(
address indexed user,
uint16 indexed redemptionId,
address indexed depositToken,
uint8 depositPeriod,
uint256 amount
);

RedemptionCancelled

event RedemptionCancelled(
address indexed user,
uint16 indexed redemptionId,
address indexed depositToken,
uint8 depositPeriod,
uint256 amount,
uint256 remainingAmount
);

LoanCreated

event LoanCreated(address indexed user, uint16 indexed redemptionId, uint256 amount, address facility);

LoanRepaid

event LoanRepaid(address indexed user, uint16 indexed redemptionId, uint256 principal, uint256 interest);

LoanExtended

event LoanExtended(address indexed user, uint16 indexed redemptionId, uint256 newDueDate);

LoanDefaulted

event LoanDefaulted(
address indexed user,
uint16 indexed redemptionId,
uint256 principal,
uint256 interest,
uint256 remainingCollateral
);

FacilityAuthorized

event FacilityAuthorized(address indexed facility);

FacilityDeauthorized

event FacilityDeauthorized(address indexed facility);

AnnualInterestRateSet

event AnnualInterestRateSet(address indexed asset, address indexed facility, uint16 rate);

MaxBorrowPercentageSet

event MaxBorrowPercentageSet(address indexed asset, address indexed facility, uint16 percent);

ClaimDefaultRewardPercentageSet

event ClaimDefaultRewardPercentageSet(uint16 percent);

Errors

RedemptionVault_InvalidDepositManager

error RedemptionVault_InvalidDepositManager(address depositManager);

RedemptionVault_ZeroAmount

error RedemptionVault_ZeroAmount();

RedemptionVault_InvalidRedemptionId

error RedemptionVault_InvalidRedemptionId(address user, uint16 redemptionId);

RedemptionVault_InvalidAmount

error RedemptionVault_InvalidAmount(address user, uint16 redemptionId, uint256 amount);

RedemptionVault_TooEarly

error RedemptionVault_TooEarly(address user, uint16 redemptionId, uint48 redeemableAt);

RedemptionVault_AlreadyRedeemed

error RedemptionVault_AlreadyRedeemed(address user, uint16 redemptionId);

RedemptionVault_ZeroAddress

error RedemptionVault_ZeroAddress();

RedemptionVault_OutOfBounds

error RedemptionVault_OutOfBounds(uint16 rate);

RedemptionVault_UnpaidLoan

error RedemptionVault_UnpaidLoan(address user, uint16 redemptionId);

RedemptionVault_InvalidFacility

error RedemptionVault_InvalidFacility(address facility);

RedemptionVault_FacilityExists

error RedemptionVault_FacilityExists(address facility);

RedemptionVault_FacilityNotRegistered

error RedemptionVault_FacilityNotRegistered(address facility);

RedemptionVault_InterestRateNotSet

error RedemptionVault_InterestRateNotSet(address asset, address facility);

RedemptionVault_LoanAmountExceeded

error RedemptionVault_LoanAmountExceeded(address user, uint16 redemptionId, uint256 amount);

RedemptionVault_LoanIncorrectState

error RedemptionVault_LoanIncorrectState(address user, uint16 redemptionId);

RedemptionVault_InvalidLoan

error RedemptionVault_InvalidLoan(address user, uint16 redemptionId);

RedemptionVault_MaxSlippageExceeded

error RedemptionVault_MaxSlippageExceeded(
address user, uint16 redemptionId, uint256 actualAmount, uint256 maxAmount
);

Structs

UserRedemption

Data structure for a redemption of a receipt token

struct UserRedemption {
address depositToken;
uint8 depositPeriod;
uint48 redeemableAt;
uint256 amount;
address facility;
uint256 positionId;
}

Properties

NameTypeDescription
depositTokenaddressThe address of the deposit token
depositPerioduint8The period of the deposit in months
redeemableAtuint48The timestamp at which the redemption can be finished
amountuint256The amount of deposit tokens to redeem
facilityaddressThe facility that handles this redemption
positionIduint256The position ID for position-based redemptions (type(uint256).max without a position)

Loan

Data structure for a loan against a redemption

struct Loan {
uint256 initialPrincipal;
uint256 principal;
uint256 interest;
uint48 dueDate;
bool isDefaulted;
}

Properties

NameTypeDescription
initialPrincipaluint256The initial principal amount borrowed
principaluint256The principal owed
interestuint256The interest owed
dueDateuint48The timestamp when the loan is due
isDefaultedboolWhether the loan has defaulted