# 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:

```solidity
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:

  ```solidity
  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:

  ```solidity
  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:

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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.term.finance/periphery-contracts/curated-vaults/core-functionality/term-protocol-operations/portfolio-valuation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
