# TermAuctionList.sol#TermAuctionList

[Git Source](https://github.com/term-finance/yearn-v3-term-vault/blob/fdab68ac51eb0929f23686f72922fed45a3d7d1d/src/TermAuctionList.sol)

## State Variables

### NULL\_NODE

```solidity
bytes32 internal constant NULL_NODE = bytes32(0);
```

## Functions

### \_getNext

*Get the next node in the list*

```solidity
function _getNext(TermAuctionListData storage listData, bytes32 current) private view returns (bytes32);
```

**Parameters**

| Name       | Type                  | Description      |
| ---------- | --------------------- | ---------------- |
| `listData` | `TermAuctionListData` | The list data    |
| `current`  | `bytes32`             | The current node |

**Returns**

| Name     | Type      | Description   |
| -------- | --------- | ------------- |
| `<none>` | `bytes32` | The next node |

### \_count

Count the number of nodes in the list

```solidity
function _count(TermAuctionListData storage listData) internal view returns (uint256 count);
```

**Parameters**

| Name       | Type                  | Description   |
| ---------- | --------------------- | ------------- |
| `listData` | `TermAuctionListData` | The list data |

**Returns**

| Name    | Type      | Description                     |
| ------- | --------- | ------------------------------- |
| `count` | `uint256` | The number of nodes in the list |

### pendingOffers

Retrieves an array of offer IDs representing the pending offers

*This function iterates through the list of offers and gathers their IDs into an array of `bytes32`. This makes it easier to process and manage the pending offers.*

```solidity
function pendingOffers(TermAuctionListData storage listData) internal view returns (bytes32[] memory offers);
```

**Parameters**

| Name       | Type                  | Description   |
| ---------- | --------------------- | ------------- |
| `listData` | `TermAuctionListData` | The list data |

**Returns**

| Name     | Type        | Description                                           |
| -------- | ----------- | ----------------------------------------------------- |
| `offers` | `bytes32[]` | An array of offer IDs representing the pending offers |

### insertPending

Inserts a new pending offer into the list data

*This function inserts a new pending offer while maintaining the list sorted by auction address. The function iterates through the list to find the correct position for the new `offerId` and updates the pointers accordingly.*

```solidity
function insertPending(TermAuctionListData storage listData, bytes32 offerId, PendingOffer memory pendingOffer)
    internal;
```

**Parameters**

| Name           | Type                  | Description                                                              |
| -------------- | --------------------- | ------------------------------------------------------------------------ |
| `listData`     | `TermAuctionListData` | The list data                                                            |
| `offerId`      | `bytes32`             | The ID of the offer to be inserted                                       |
| `pendingOffer` | `PendingOffer`        | The `PendingOffer` struct containing details of the offer to be inserted |

### removeCompleted

Removes completed or cancelled offers from the list data and processes the corresponding repoTokens

*This function iterates through the list of offers and removes those that are completed or cancelled. It processes the corresponding repoTokens by validating and inserting them if necessary. This helps maintain the list by clearing out inactive offers and ensuring repoTokens are correctly processed.*

```solidity
function removeCompleted(
    TermAuctionListData storage listData,
    RepoTokenListData storage repoTokenListData,
    ITermDiscountRateAdapter discountRateAdapter,
    address asset
) internal;
```

**Parameters**

| Name                  | Type                       | Description               |
| --------------------- | -------------------------- | ------------------------- |
| `listData`            | `TermAuctionListData`      | The list data             |
| `repoTokenListData`   | `RepoTokenListData`        | The repoToken list data   |
| `discountRateAdapter` | `ITermDiscountRateAdapter` | The discount rate adapter |
| `asset`               | `address`                  | The address of the asset  |

### getPresentValue

Calculates the total present value of all relevant offers related to a specified repoToken

*This function calculates the present value of offers in the list. If `repoTokenToMatch` is provided, it will filter the calculations to include only the specified repoToken. If `repoTokenToMatch` is not provided, it will aggregate the present value of all repoTokens in the list. This provides flexibility for both aggregate and specific token evaluations.*

```solidity
function getPresentValue(
    TermAuctionListData storage listData,
    RepoTokenListData storage repoTokenListData,
    ITermDiscountRateAdapter discountRateAdapter,
    uint256 purchaseTokenPrecision,
    address repoTokenToMatch
) internal view returns (uint256 totalValue);
```

**Parameters**

| Name                     | Type                       | Description                                      |
| ------------------------ | -------------------------- | ------------------------------------------------ |
| `listData`               | `TermAuctionListData`      | The list data                                    |
| `repoTokenListData`      | `RepoTokenListData`        | The repoToken list data                          |
| `discountRateAdapter`    | `ITermDiscountRateAdapter` | The discount rate adapter                        |
| `purchaseTokenPrecision` | `uint256`                  | The precision of the purchase token              |
| `repoTokenToMatch`       | `address`                  | The address of the repoToken to match (optional) |

**Returns**

| Name         | Type      | Description                           |
| ------------ | --------- | ------------------------------------- |
| `totalValue` | `uint256` | The total present value of the offers |

### getCumulativeOfferData

Get cumulative offer data for a specified repoToken

*offer processed, but auctionClosed not yet called and auction is new so repoToken not on List and wont be picked up checking repoTokendiscountRates to make sure we are not double counting on re-openings*

*This function calculates cumulative data for all offers in the list. The `repoToken` and `newOfferAmount` parameters are optional and provide flexibility to include the newOfferAmount for a specified repoToken in the calculation. If `repoToken` is set to `address(0)` or `newOfferAmount` is `0`, the function calculates the cumulative data without adjustments.*

```solidity
function getCumulativeOfferData(
    TermAuctionListData storage listData,
    RepoTokenListData storage repoTokenListData,
    ITermDiscountRateAdapter discountRateAdapter,
    address repoToken,
    uint256 newOfferAmount,
    uint256 purchaseTokenPrecision
) internal view returns (uint256 cumulativeWeightedTimeToMaturity, uint256 cumulativeOfferAmount, bool found);
```

**Parameters**

| Name                     | Type                       | Description                                      |
| ------------------------ | -------------------------- | ------------------------------------------------ |
| `listData`               | `TermAuctionListData`      | The list data                                    |
| `repoTokenListData`      | `RepoTokenListData`        | The repoToken list data                          |
| `discountRateAdapter`    | `ITermDiscountRateAdapter` | The discount rate adapter                        |
| `repoToken`              | `address`                  | The address of the repoToken (optional)          |
| `newOfferAmount`         | `uint256`                  | The new offer amount for the specified repoToken |
| `purchaseTokenPrecision` | `uint256`                  | The precision of the purchase token              |

**Returns**

| Name                               | Type      | Description                                           |
| ---------------------------------- | --------- | ----------------------------------------------------- |
| `cumulativeWeightedTimeToMaturity` | `uint256` | The cumulative weighted time to maturity              |
| `cumulativeOfferAmount`            | `uint256` | The cumulative repoToken amount                       |
| `found`                            | `bool`    | Whether the specified repoToken was found in the list |


---

# 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/solidity-api-latest/termauctionlist.sol-termauctionlist.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.
