> For the complete documentation index, see [llms.txt](https://docs.term.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.term.finance/protocol/term-auctions/complete-auction/clearing-rate.md).

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