🖥️
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
  • Total Asset Value Calculation
  • Total Value Implementation
  1. Periphery Contracts
  2. Term Strategy Vaults
  3. Core Functionality
  4. Term Protocol Operations

Portfolio Valuation

Total Asset Value Calculation

The Term Strategy Vault's implementation of _harvestAndReport() calculates the total asset value by invoking _totalAssetValue(). This function updates the totalAssets value in the BaseStrategy and provides a comprehensive view of the portfolio’s value. It aggregates three components:

  1. Idle Liquidity: The balance of idle funds held within the idle vault.

  2. Repo Token Holdings: The present value of active repoToken positions, discounted using rates from the discountRateAdapter.

  3. Pending Auction Offers: The present value of any pending auction offers, assuming those offers are filled.

Total Value Implementation

The _totalAssetValue() function aggregates these components to calculate the total portfolio value:

function _totalAssetValue(uint256 liquidBalance) internal view returns (uint256) {        
    return
        liquidBalance +  // Yearn vault + idle balance
        repoTokenListData.getPresentValue(  // Active repo token positions
            strategyState.discountRateAdapter,
            PURCHASE_TOKEN_PRECISION
        ) +
        termAuctionListData.getPresentValue(  // Pending auction offers
            repoTokenListData,
            strategyState.discountRateAdapter,
            PURCHASE_TOKEN_PRECISION,
            address(0)
        );
}

Key Components

1. Repo Token Holdings

  • Managed by the RepoTokenListData struct:

    struct RepoTokenListData {
        address head;
        mapping(address => RepoTokenListNode) nodes;
        mapping(address => uint256) discountRates;
        mapping(address => uint256) collateralTokenParams;
    }
  • Purpose:

    • Maintains a linked list of repo tokens held by the vault.

    • Tracks discount rates and collateral parameters for each token.


2. Discount Rate Adapter

  • Interface: ITermDiscountRateAdapter

  • Purpose:

    • Serves as an interest rate oracle for Term repoTokens.

    • Applies redemption haircuts to account for bad debt risks.


3. Pending Offers

  • Managed by the TermAuctionListData struct:

    struct TermAuctionListData {
        bytes32 head;
        mapping(bytes32 => TermAuctionListNode) nodes;
        mapping(bytes32 => PendingOffer) offers;
    }
  • Purpose:

    • Tracks all pending auction offers.

    • Estimates the present value of pending offers, assuming they are filled.

Present Value Calculation

The portfolio valuation uses:

  • RepoToken face value adjusted by redemptionValue

  • Actual/360 day count convention from current time to redemptionTimestamp

  • Market rates from Term auctions plus configurable markup

Base Formula:

timeLeftToMaturityDayFraction = ((redemptionTimestamp - block.timestamp) * purchaseTokenPrecision) / THREESIXTY_DAYCOUNT_SECONDS;

presentValue = (repoTokenAmountInBaseAssetPrecision * purchaseTokenPrecision) / 
    (purchaseTokenPrecision + (discountRate * timeLeftToMaturityDayFraction / RATE_PRECISION));

Last updated 4 months ago