🖥️
Term Finance v1 Developer Documentation
  • Overview
  • Term Finance Protocol
    • Term Repo
      • Term Auction Group
        • Initialization Parameters
        • Administrative Functions
      • Term Servicer Group
        • Initialization Parameters
        • Administrative Functions
      • Term Repo Token
        • Initialization Parameters
        • Administrative Functions
    • Protocol Contracts
      • Price Feeds
    • Conventions
    • Terminology
  • Access Controls
    • Upgradeability
  • Deployed Contracts
    • Smart Contract Audits
    • Formal Verification
    • [Ethereum]
    • [Avalanche]
  • Protocol Security
    • Smart Contract Monitoring
    • Front-End Security
  • Solidity API - latest
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.5.31
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.5.32
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.6.0
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • Solidity API - 0.9.0
    • Term Repo Class
      • Term Auction Group
        • TermAuction.sol
        • TermAuctionBidLocker.sol
        • TermAuctionOfferLocker.sol
      • Term Servicer Group
        • TermRepoServicer.sol
        • TermRepoLocker.sol
        • TermRepoCollateralManager.sol
        • TermRepoRolloverManager.sol
      • TermRepoToken.sol
    • Protocol Class
      • TermController.sol
      • TermEventEmitter.sol
      • TermInitializer.sol
      • TermPriceConsumerV3.sol
  • DeFiSafety - detailed report
  • Github Repo
  • Periphery Contracts
    • Blue Sheets
      • Core Architecture
      • Core Functionality
      • Administration
      • Deployed Contracts
        • Smart Contract Audits
        • [Ethereum]
      • Solidity API - latest
        • RepoTokenLinkedList.sol#RepoTokenLinkedList
        • RepoTokenLinkedList.sol#RepoTokenLinkedListStorageV1
        • RepoTokenLinkedListEventEmitter.sol
        • TermDiscountRateAdapter.sol
    • Github Repo
    • Term Strategy Vaults
      • Core Architecture
        • Yearn V3 Framework
        • Term Integration
      • Core Functionality
        • YearnV3 Base Operations
        • Term Protocol Operations
          • Core Integration
          • Portfolio Valuation
          • Protocol Interactions
          • Portfolio Constraints
      • Administration
        • Yearn Roles & Governance
        • Term Vault Governance
      • Configuration Guide
      • Deployed Contracts
        • Smart Contract Audits
        • [Ethereum]
      • Solidity API - latest
        • RepoTokenList.sol#RepoTokenList
        • RepoTokenList.sol#RepoTokenListData
        • RepoTokenList.sol#RepoTokenListNode
        • RepoTokenUtils.sol#RepoTokenUtils
        • Strategy.sol#Strategy
        • TermAuctionList.sol#TermAuctionList
        • TermAuctionList.sol#PendingOffer
        • TermAuctionList.sol#TermAuctionListData
        • TermAuctionList.sol#TermAuctionListNode
        • TermDiscountRateAdapter.sol#TermDiscountRateAdapter
        • TermVaultEventEmitter.sol#TermVaultEventEmitter
        • TermFinanceVaultWrappedVotesToken.sol#TermFinanceVaultWrappedVotesToken
    • Github Repo
Powered by GitBook
On this page
  • Overview
  • Deposit Management (_deployFunds)
  • Withdrawal Management (_freeFunds)
  • Portfolio Reporting and Valuation (_harvestAndReport)
  1. Periphery Contracts
  2. Term Strategy Vaults
  3. Core Functionality
  4. Term Protocol Operations

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

  1. _deployFunds: Handles deposit management.

  2. _freeFunds: Manages withdrawals.

  3. _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.

_redeemRepoTokens() is a helper method that redeems matured loans and sweeps idle assets (if any) into the idle asset vault pending deployment into fixed rate loans on Term.

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.

_redeemRepoTokens() is a helper method that redeems matured loans, withdraws requested funds and sweeps idle assets (if any) into the idle asset vault pending deployment into fixed rate loans on Term. This implementation:

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().

_redeemRepoTokens() is a helper method that redeems matured loans and sweeps idle assets (if any) into the idle asset vault pending deployment into fixed rate loans on Term. This implementation of _harvestAndReport():

Last updated 4 months ago