Credit Vault

v1.1

The Credit Vault implements the vault standard ERC4626, so the standard documentation can be referenced for most interfaces. Users deposit stablecoins into a vault and receive an interest-accruing deposit token. Approved borrowers can borrow from the vault and interest rates are set by admins.

Data Source

  • ERC20 standard - Security Token

  • rate (uint256) the fixed interest rate which is set by the borrower. Range value (0 - 100000)

  • stablecoin (address) stable coin token contract address which allowed to deposit to the pool and earn interest

  • maxPoolValue (uint256) max value can supply to the pool

  • poolValue (uint256) total underlying token

  • accrualTimestamp (uint256) timestamp that interest was last accrued at

  • totalBorrowed (uint256) total borrowed token

HiYield Credit Vault: Withdrawal Queue Feature

Overview

If a vault does not have enough liquidity to support a withdrawal request by a lender, the transaction will not revert. Instead, withdrawal requests will be added to a list of withdrawal requests that are filled as liquidity becomes available.

When liquidity becomes available, either through a loan repayment or a new deposit, the withdrawal queue is checked for open withdrawal requests. Withdrawal requests are processed using the First-In-First-Out (“FIFO”) method, meaning that the oldest withdrawal request is always processed first. The amount of new liquidity dictates how many withdrawals are processed. Available liquidity should be used to fulfill withdrawal requests until there are no withdrawal requests remaining, and partial fulfillments should be supported.

When a withdrawal request is filled, the USDC is held in the vault on behalf of the user. The user can then claim the USDC from the vault at any time. The USDC used to fill withdrawal requests should not be eligible for withdrawal by other users nor borrowers.

Additional Interfaces

QUEUE DETAIL

/**

* @dev Get the withdraw request detail in queue by node index

*

* @return RedeemRequest{ address redeemer; uint256 amount; }

*/

function queueDetail(uint nodeIndex) external view returns(RedeemRequest);

QUEUE PROCESS LIMIT

/**

* @dev Batch size of queue list being process at each transaction

*

* @return batch size

*/

function queueProcessLimit() external view returns(uint256);

CLAIMABLE WITHDRAW AMOUNT

/**

* @dev The amount of processed withdraw an user can claim

*

* @return amount to claim

*/

function claimableAssets(address owner) external view returns(uint256);

TOTAL UNCLAIMED WITHDRAW AMOUNT

/**

* @dev The total amount of processed withdraw users can claim

*

* @return total amount can claim

*/

function totalClaimableAssets() external view returns(uint256);

TOTAL PENDING WITHDRAW AMOUNT

/**

* @dev The total withdraw request amount in queue

*

*/

function pendingWithdrawAssets() external view returns(uint256);

CANCEL WITHDRAW REQUEST

/**

* @dev Cancel withdraw request of sender

*

*/

function cancelWithdraw(uint nodeIndex) external;

CANCEL WITHDRAW REQUESTS

/**

* @dev Cancel multi withdraw requests of sender

*

*/

function cancelWithdraws(uint256[] memory nodes) external;

GET WITHDRAW QUEUE SIZE

/**

* @dev Get the current size of queue list (total number of withdraw requests)

*

* @return the current size of queue list

*/

function getWithdrawQueueSize() external view returns(uint256);

GET WITHDRAW QUEUE DETAIL LIST

/**

* @dev Get the detail of a withdraw queue batch

*

* @param offset_ the index of the previous node, put 0 to start from first node

* @param size_ the size of the queue batch to return

*

* @returns (array of node index, array of corresponding withdraw request detail)

*/

function getWithdrawQueueDetailList(uint256 offset_, uint256 size_) external view returns(uint256[] memory, WithdrawRequest[] memory);

SET QUEUE PROCESS LIMIT

/**

* @notice Sets a new queue process limit

* @dev Admin function to set a new queue process limit

*/

function setQueueProcessLimit(uint256 limit_) virtual external;

PROCESS THE FIRST BATCH OF QUEUE

/**

* @notice process the withdrawal queue when there is available underlying token.

* Should be run by contract itself, anyone trigger this function.

*/

function queueProcess() virtual public;

BORROW FUND

/**

* @dev Method to let borrower borrow token from the pool

*

* @param receiver_ Address to receive token

* @param amount_ Amount to transfer from the pool. Token in base decimal (1e18).

*/

function borrowFund(address receiver_, uint256 amount_) external;

REPAY DEBT

/**

* @dev Borrower execute this function to repay token back to the pool

*

* @param amount_ Amount of token to repay. Token in token decimal.

*/

function repayDebt(uint256 amount_) external;

SET NEW INTEREST RATE

/**

* @dev Set new rate

*

* @param newRate_ New rate value. Rate value in range (0 - 100000)

*/

function setRate(uint256 newRate_) external;

EVENTS

event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

event Withdraw(

address indexed sender,

address indexed receiver,

address indexed owner,

uint256 assets,

uint256 shares

);

event BorrowFund(address, uint256);

event Repay(address, uint256);

event MaxPoolValue(uint256, uint256);

event SetQueueProcessLimit(uint256);

event AddQueue(address, uint256);

event ClaimWithdraw(address, uint256);

event CancelQueue(address, uint256);

event ProcessedQueue(uint256 indexed node, address indexed receiver, uint256 assets);

Last updated