Offerings

Accrued Interest Pool Offering

Data Structures

  • ERC20 standard - Security Token

  • AIConfig (struct) the pool config info

    • Struct AIConfig (uint96 startDay, uint96 endDay, uint16 rate, uint8 status, uint40 expectedTerm)

  • maxPoolValue (uint256) max amount of debt token that can be minted for sales

  • stableCoin (address) the stable coin address accepted by the pool

  • debTokenValue (uint256)

  • receivingAccount (address)

  • poolValue (uint256) current total debt token sales

  • debtProceeds (uint256) current total stable coin repaid for user to withdraw

  • rewards (RewardsInterface) HiYield rewards contract

  • accrualTimestamp (uint256)

  • poolName (string)

  • status (enum)

ValueDescription

0

Open - deposit enabled, redeem enabled

1

Closed - deposit disabled, redeem enabled

2

Matured - deposit disabled, redeem enabled

Accrued Interest Pool Lending Market Extensions

  • controller (ControllerInterface) HiYield Lending Market controller contract

  • isolatedPool (IIsolatedPool) HiYield Lending Market isolated pool for this pool

Interfaces

GET RATE

/**

* @dev Returns latest debt token value

*/

function rate() external view returns(uint256);

GET STABLE COIN

/**

* @dev Token address allowed to deposit to the pool

*/

function stableCoin() external view returns(IERC20);

GET POOL INFO

/**

* @dev Returns the state of pool

*

* @return

* - total underlying token

* - available balance on the pool

* - total borrowed

* - last timestamp accrued

* - pool ratio underlying token / HY token

*/

function poolInfo() external view returns(uint256, uint256, uint256, uint256, uint256);

GET POOL DETAIL

/**

* @dev Returns pool detail

*

* @return

* - AIConfig ( start day, end day, rate, status, expectedTerm )

* - stablecoin address

* - receiving account

* - debt token value

* - total pool owed

* - pool name

*/

function poolDetail() external view returns(AIConfig memory, address, address, uint256, uint256, string memory);

GET ACTUAL TERM

/**

* @dev Returns actualTerm is calculated as dayMatured - startDay. This is for data tracking simplicity

*/

function getActualTerm() external view returns(uint256);

GET USER INFO BY ADDRESS

/**

* @dev Returns the state of specific lender address

*

* @return

* - HY_token balance

* - origin + interest

*/

function getInfoByAddress(address lender_) external view returns(uint256, uint256);

GET POOL CONFIG

/**

* @dev Return the pool config value.

*/

function aiConfig() view external returns(uint96 startDay, uint96 endDay, uint16 rate, uint8 status, uint40 expectedTerm);

DEPOSIT (BUY DEBT)

/**

* @dev This is called by users when sending stablecoins into the pool to purchase debtTokens

*

* @param amount_ Amount stablecoins to purchases debtTokens. Token decimals.

*/

function deposit(uint256 amount_) external;

REPAY DEBT

/**

* @dev This is called by the Admin when depositing debt repayments into the pool and can be called at

* any time.

*

* @param amount_ Amount stablecoins to purchases debtTokens. Token decimals.

*/

function repayDebt(uint256 amount_) external;

WITHDRAW (REDEEM)

/**

* @dev Users call this to claim their share of interest and principal repayments.

* @return Return (redeem token address, underlying token redeem amount)

*/

function withdraw(uint256 amount_) external returns(address, uint);

ADMIN SET NAME

/**

* @dev Update pool's name. Admin only

*/

function setName(string memory name_) external;

ADMIN SET EXPECTED TERM

/**

* @dev Update expected term. Admin only

*/

function setExpectedTerm(uint40 term_) external;

ADMIN SET RECEIVING ACCOUNT

/**

* @dev Update account to receive funds. Admin only

*/

function setReceivingAccount(address receivingAccount_) external;

ADMIN SET RATE

/**

* @dev Update pool rate. Admin only

*/

function setRate(uint16 rate_) external;

ADMIN SET POOL STATUS

/**

* @dev Update pool's status. Admin only

*

* @param status_ New pool status

* @param newDebtTokenValue_ Set to new debt token value when pool matured. Optional.

*/

function setPoolStatus(DPStatus status_, uint256 newDebtTokenValue_) external;

Lending Market AI Pool extended methods:

ADMIN MINT ALL SALES

/**

* @dev Mint max sales debt token. Admin only

*/

function mintSales() external;

CONTROLLER UNWIND WITHDRAW

/**

* @dev Controller call this to unwind isolated pool

* @return Return (redeem token address, underlying token redeem amount)

*/

function unwindWithdraw(address to_, uint256 amount_) external returns(address, uint);

Workflow Diagrams

This section has a series of diagrams to illustrate the key functions of the Accrued Interest Pool

accrueInterest
  • lastDebtTokenValue = debtTokenValue + (block.timestamp - accrualTimestamp) * aiConfig.rate * BASE / (UPPER_BOUND * SECONDS_IN_YEAR)

  • accrualTimestamp = block.timestamp

Buy Debt Workflow

Repay Debt Workflow

Redeem Workflow

Compliance

Data Structures

  • KYCStatus (address => KStatus) mapping of address which already did KYC

ValueDescription

0

Empty

1

Pending

2

Approved

3

Rejected

Interfaces

CHECK IF TRANSFER IS ALLOWED

/**

* @dev checks that the transfer is compliant.

* default compliance always returns true

* READ ONLY FUNCTION, this function cannot be used to increment

* counters, emit events, ...

* @param _from The address of the sender

* @param _to The address of the receiver

* @param _amount The amount of tokens involved in the transfer

*/

function canTransfer(address _from, address _to, uint256 _amount) external view returns (bool);

GET USER KYC STATUS

function getUserStatus(address account) view external returns(KStatus);

CALL AFTER TRANSFERRED

/**

* @dev function called whenever tokens are transferred

* from one wallet to another

* this function can update state variables in the compliance contract

* these state variables being used by `canTransfer` to decide if a transfer

* is compliant or not depending on the values stored in these state variables and on

* the parameters of the compliance smart contract

* @param _from The address of the sender

* @param _to The address of the receiver

* @param _amount The amount of tokens involved in the transfer

*/

function transferred(address _from, address _to, uint256 _amount) external;

CALL AFTER TRANSFERRED (NOT IN USE)

/**

* @dev function called whenever tokens are transferred

* from one wallet to another

* this function can update state variables in the compliance contract

* these state variables being used by `canTransfer` to decide if a transfer

* is compliant or not depending on the values stored in these state variables and on

* the parameters of the compliance smart contract

* @param _from The address of the sender

* @param _to The address of the receiver

* @param _amount The amount of tokens involved in the transfer

*/

function transferred(address _from, address _to, uint256 _amount) external;

TOKEN CREATED (NOT IN USE)

/**

* @dev function called whenever tokens are created

* on a wallet

* this function can update state variables in the compliance contract

* these state variables being used by `canTransfer` to decide if a transfer

* is compliant or not depending on the values stored in these state variables and on

* the parameters of the compliance smart contract

* @param _to The address of the receiver

* @param _amount The amount of tokens involved in the transfer

*/

function created(address _to, uint256 _amount) external;

TOKEN DESTROYED (NOT IN USE)

/**

* @dev function called whenever tokens are destroyed

* this function can update state variables in the compliance contract

* these state variables being used by `canTransfer` to decide if a transfer

* is compliant or not depending on the values stored in these state variables and on

* the parameters of the compliance smart contract

* @param _from The address of the receiver

* @param _amount The amount of tokens involved in the transfer

*/

function destroyed(address _from, uint256 _amount) external;

ADMIN SET USER KYC STATUS

function setUser(address account, KStatus status) external;

ADMIN SET MULTI USERS KYC STATUS

function setUsers(address[] memory accounts, KStatus[] memory status) external;

Rewards

Data Structures

  • poolRewards (address => PoolRewardsData) mapping rewards data for each pool

  • isSupported (address => bool) checking pools supported by this contract

Interfaces

GET UNCLAIMED REWARDS FOR EACH POOL

interface RewardsInterface {

/**

* @dev Returns claimable rewards of a pool

*

* @return rewardTokens addresses list

* @return unclaimedAmounts_ of each reward token

*/

function claimableRewards(address pool_) external view returns(address[] memory, uint256[] memory);

GET THE SUPPORT STATE OF A POOL

/**

* @dev Returns the support state of the pool

*/

function isPoolSupported(address pool_) external view returns(bool);

INCREASE POOL REWARDS

/**

* @dev Increase claimable rewards for a pool. Anyone can call

*/

function increaseRewards(address pool_, address[] memory rewardTokens_, uint256[] memory rewardAmounts_) external;

ADMIN ADD POOL

/**

* @dev Add pool to the whitelist that allowed receiving rewards. Admin only

*/

function addPool(address pool_, address[] memory rewardTokens_) external;

ADMIN UPDATE POOL

/**

* @dev Update reward tokens whitelist for a pool. Admin only

*/

function updatePool(address pool_, address[] memory rewardTokens_) external;

ADMIN REMOVE POOL

/**

* @dev Remove the pool from whitelist. Admin only

*/

function removePool(address pool_) external;

POOL CLAIM REWARDS FOR USER

/**

* @dev Pool claim rewards for the user. Whitelisted pool only

*

* @param to_ The receiver of rewards, should be the AI Pool user who call redeem

* @param amount_ The debt token amount that user redeemed

* @param supply_ The debt token total supply

*/

function claimRewards(address to_, uint256 amount_, uint256 supply_) external;

POOL TRANSFER REWARDS TO ANOTHER SUPPORTED POOL

function transferRewards(address to_, uint256 amount_, uint256 supply_) external;

Last updated