> For the complete documentation index, see [llms.txt](https://developers.term.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.term.finance/periphery-contracts/blue-sheets/core-functionality.md).

# 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`
* 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
