# Core Functionality

### Pricing Mechanism

#### Discount Rate Determination

* Fetched via [`TermDiscountRateAdapter`](/periphery-contracts/blue-sheets/solidity-api-latest/termdiscountrateadapter.sol.md) contract
* Uses clearing rate from most recent valid auction
* Validation rules:
  * For reopening auctions (within 30 minutes), uses previous valid auction rate
  * Oracle can invalidate specific auction rates
  * Requires at least one valid auction result

#### Price Calculation

The purchase/sale price is calculated using:

* The face value of the RepoToken, adjusted by the redemptionValue,
* discounted using Actual/360 day count convention relative to the RepoToken's [`redemptionTimestamp`](/latest/term-repo-class/term-servicer-group/termreposervicer.md#redemptiontimestamp)`; and`&#x20;
* the discount rate fetched from the most recent Term Auction, retrieved via the  [`TermDiscountRateAdapter`](/periphery-contracts/blue-sheets/solidity-api-latest/termdiscountrateadapter.sol.md)`,`adjusted by a discountRateMarkup

Base Formula:

```
numerator = redemptionValue * RATE_PRECISION * 360_DAYS
denominator = RATE_PRECISION * 360_DAYS + ((rate - discountRateMarkup) * timeToMaturity)
pricePerToken = numerator / denominator
```

#### Safety Features

* Oracle role for manual intervention in case of auction rate manipulation
* Haircut mechanism to adjust valuation for bad debt
* Rate validity checks with timestamp verification of  auction results

### Listing Operations

RepoTokens must meet these criteria for listing:

* Not blacklisted (`repoTokenBlacklist[token] == false`)
* Active deployment in TermController (`isTermDeployed == true`)
* Not matured (`redemptionTimestamp > current_timestamp`)
* Amount exceeds minimum listing threshold

#### Purchase Methods

Two purchase options available:

1. `purchase(uint256 desiredAmount, address repoToken)`
   * Buy specific quantity of RepoTokens
2. `swapExactPurchaseForRepo(uint256 purchaseTokenAmount, address repoToken)`
   * Spend specific amount of purchase tokens

#### Safety Features

* Reentrancy protection on all state-modifying functions
* Pausable functionality for emergency stops
* Role-based access control for admin functions
* Blacklist capability for RepoTokens
* Minimum listing amounts based on token type


---

# 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/blue-sheets/core-functionality.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.
