# Clearing rate

Generally speaking, the clearing rate is determined by sorting revealed bids and offers and passing the result into an (on-chain) algorithm that searches for an interest rate where supply meets demand. The logic can be found in the internal function `_calculateClearingPrice`, which runs our clearing price algorithm that seeks to maximize the total volume matched between borrowers and lenders at any given interest rate.     &#x20;

### Second-price auction

In practice, there will typically be a range of interest rates that lead to the same equilibrium. Say, for example, the most competitive bid eligible for matching is 3.5% and the most competitive offer eligible for matching is 3.0%. In this example, any interest rate between 3.0% and 3.5% will result the same allocation. A simple solution would be to split the difference by setting the clearing rate at the midpoint between 3.0% and 3.5% (e.g. 3.25%).  This solution, however, is vulnerable to situations where participants could be incentivized to manipulate the clearing price slightly in their favor by systematically "shading" their bids/offers. To avoid this type of strategic behavior, the Protocol takes the average between the *second* most competitive bid and *second* most competitive offer in determining the clearing rate following [McAffee 1992](https://www.sciencedirect.com/science/article/abs/pii/002205319290091U). By implementing this solution, participants are encouraged to report bid/offer their true valuations.


---

# 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://docs.term.finance/protocol/term-auctions/complete-auction/clearing-rate.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.
