Core Integration
Overview
Term Strategy integrates seamlessly with Yearn V3's vault mechanics by implementing the three required BaseStrategy hooks: _deployFunds
, _freeFunds
, and _harvestAndReport
. These hooks enable Term Strategy Vaults to manage deposits, withdrawals, and portfolio valuation while aligning with Yearn's operational framework.
Required BaseStrategy Hooks
_deployFunds
: Handles deposit management._freeFunds
: Manages withdrawals._harvestAndReport
: Calculates total portfolio value for profit and share accounting.
Deposit Management (_deployFunds)
The _deployFunds
function sweeps idle assets and redeems matured loans for deployment into fixed-rate loans on Term. The implementation ensures efficient use of capital while maintaining compatibility with Yearn's vault mechanics.
function _deployFunds(uint256 _amount) internal override whenNotPaused {
if (depositLock) {
revert DepositPaused();
}
_redeemRepoTokens(0);
}
Term Strategy Vault Implementation:
Redeem Matured Loans: Automatically redeems any matured loans first.
Sweep Idle Assets: Deposited and idle assets are swept into the idle liquidity vault pending deployment.
Withdrawal Management (_freeFunds)
The _freeFunds
function facilitates withdrawals by redeeming matured loans and withdrawing the requested funds from the idle liquidity vault. Like _deployFunds
, it leverages _redeemRepoTokens()
to automate portfolio adjustments.
function _freeFunds(uint256 _amount) internal override whenNotPaused {
_redeemRepoTokens(_amount);
}
Term Strategy Vault Implementation:
Redeem Matured Loans: Withdrawals prioritize the redemption of matured loans.
Withdraw Requested Funds: Required amounts are withdrawn from the idle liquidity vault.
Portfolio Reporting and Valuation (_harvestAndReport)
The _harvestAndReport
function calculates the total portfolio value, which is critical for vault profit and share accounting. It redeems matured loans and sweeps assets for comprehensive portfolio valuation.
function _harvestAndReport() internal override whenNotPaused returns (uint256) {
_redeemRepoTokens(0);
return _totalAssetValue(_totalLiquidBalance());
}
Term Strategy Vault Implementation:
Redeem Matured Positions: Sweeps and redeems matured loans.
Calculate Total Value: Returns
_totalAssetValue
, which includes:Present value of all Term repoTokens.
Present value of open auction offers.
Liquidity Management: Tends to the portfolio during valuation by leveraging
_redeemRepoTokens()
.
Last updated