# Reserve Auctions

## Overview

Moonwell Reserve Auctions is an automated onchain system that facilitates the exchange of reserve tokens for WELL tokens. The system offers a unique opportunity for searchers to bid and sell WELL tokens at a discounted rate.

## Auction Structure

### Structure

* **Total Duration:** Each auction cycle lasts 2 weeks
* **Mini-Auction Periods:** Divided into 56 separate 6-hour mini-auctions
* **Market Separation**: Each market has its own dedicated auction contract

### Dynamic Pricing System

* **Starting Price**: Each 6-hour mini-auction begins with a premium above market price
* **Price Decay**: The premium declines linearly throughout the period
* **Ending Price**: By the end of each mini-auction, price reaches maximum discount
* **Key Parameters**:
  * `startingPremium`: Initial premium rate (>100%, represented as >1e18)
  * `maxDiscount`: Maximum discount reached (<100%, represented as <1e18)

## Participation Guide

### 1. Monitoring Auction Opportunities

#### **How to check for active auctions:**

* Query the `saleStartTime` and `saleWindow` in the ReserveAutomation contract
* Use `getCurrentPeriodStartTime()` to identify the current mini-auction period
* Check available reserves with `getCurrentPeriodRemainingReserves()`

#### **Best time to participate:**

* Early in the period: Higher reserve availability but lower discount
* Later in the period: Better discount but risk of depleted reserves

### 2. Preparing to Bid

#### **Before bidding, calculate the expected output:**

* Use `getAmountOut(uint256 amountWellIn)`to calculate how many reserve tokens you'll receive for a given WELL amount
* Prices are determined using Chainlink price feeds for both WELL and the reserve asset

### 3. Placing a Bid

* Ensure you have sufficient WELL tokens in your wallet
* Approve the ReserveAutomation contract to spend your WELL tokens
* Call `getReserves(uint256, uint256)`with your desired WELL amount and the expected reserve amount
* Reserve tokens are transferred immediately after the transaction succeeds

### 4. Best Practices

* Monitor Chainlink price feeds to identify optimal bidding opportunities
* Check remaining reserves in the current period before bidding
* Be aware of the current discount rate based on time elapsed
* Ensure you have sufficient WELL tokens before bidding

## Technical Details

### Price Calculation Workflow

1. **Oracle Price Retrieval**:
   * System fetches normalized prices (18 decimals) from Chainlink oracles for both WELL and reserve assets
2. **Calculate Current Discount Rate**:

```
decayDelta = startingPremium - maxDiscount
periodDuration = periodEnd - periodStart
timeRemaining = periodEnd - block.timestampe
currentDiscount = maxDiscount + (decayDelta * timeRemaining) / periodDuration
```

3. **Calculate Final Amount**:

```
// Convert WELL to USD value
wellAmountUSD = amountWellIn * normalizedWellPrice

// Apply discount to reserve asset price
discountedReservePrice = normalizedReservePrice * currentDiscount / 1e18

// Calculate output amount
amountOut = wellAmountUSD / discountedReservePrice
```

### Contract Addresses

### Base

<table><thead><tr><th width="130.05859375">Market</th><th width="490.70703125">Address</th><th>Explorer</th></tr></thead><tbody><tr><td>USDC</td><td>0x8373155335839e3D078f3F224E8B6618Fc26eF17</td><td><a href="https://basescan.org/address/0x8373155335839e3D078f3F224E8B6618Fc26eF17">View</a></td></tr><tr><td>USDBC</td><td>0x89b89c30E2f60Bd30059c3924eF5b8c0Fcd1B64A</td><td><a href="https://basescan.org/address/0x89b89c30E2f60Bd30059c3924eF5b8c0Fcd1B64A">View</a></td></tr><tr><td>DAI</td><td>0x9f2ca3c6Cd1dddb7aD473a0a893C3104E2af15Ad</td><td><a href="https://basescan.org/address/0x9f2ca3c6Cd1dddb7aD473a0a893C3104E2af15Ad">View</a></td></tr><tr><td>WETH</td><td>0x064D8Cb3B7a22F4cFBdd602eBC7E722Bb71405D8</td><td><a href="https://basescan.org/address/0x064D8Cb3B7a22F4cFBdd602eBC7E722Bb71405D8">View</a></td></tr><tr><td>cbETH</td><td>0x48bc4876D33Db30929c373c3B949b66CB8d641F3</td><td><a href="https://basescan.org/address/0x48bc4876D33Db30929c373c3B949b66CB8d641F3">View</a></td></tr><tr><td>wstETH</td><td>0xbd22DaFeF550094A32f388CD256FE133a0A14387</td><td><a href="https://basescan.org/address/0xbd22DaFeF550094A32f388CD256FE133a0A14387">View</a></td></tr><tr><td>rETH</td><td>0xEfE30785362225106367039971d82715dcB35192</td><td><a href="https://basescan.org/address/0xEfE30785362225106367039971d82715dcB35192">View</a></td></tr><tr><td>AERO</td><td>0xc7840e86A0aa22c23BCbC153CE61f6009733bf2C</td><td><a href="https://basescan.org/address/0xc7840e86A0aa22c23BCbC153CE61f6009733bf2C">View</a></td></tr><tr><td>weETH</td><td>0x75494780E76bB41c0fDf29DBA4b2Ce82501c12b0</td><td><a href="https://basescan.org/address/0x75494780E76bB41c0fDf29DBA4b2Ce82501c12b0">View</a></td></tr><tr><td>cbBTC</td><td>0x83D37e3df05F1507667AF4dfc83Ec8A38Cf2dA08</td><td><a href="https://basescan.org/address/0x83D37e3df05F1507667AF4dfc83Ec8A38Cf2dA08">View</a></td></tr><tr><td>EURC</td><td>0x7bBe5972e01BAc64fE3AD7EFfBa6D164f0a1F15f</td><td><a href="https://basescan.org/address/0x7bBe5972e01BAc64fE3AD7EFfBa6D164f0a1F15f">View </a></td></tr><tr><td>wrsETH</td><td>0xe34D7D109B97e1b1DAc9A9920e6A6769814Ac7eE</td><td><a href="https://basescan.org/address/0xe34D7D109B97e1b1DAc9A9920e6A6769814Ac7eE">View</a></td></tr><tr><td>USDS</td><td>0xA078017f827DC7B8540C98A3bF7b2153B2aF6cB3</td><td><a href="https://basescan.org/address/0xA078017f827DC7B8540C98A3bF7b2153B2aF6cB3">View</a></td></tr><tr><td>TBTC</td><td>0x84C74431200Bcd3Ba4b557024734891857b43354</td><td><a href="https://basescan.org/address/0x84C74431200Bcd3Ba4b557024734891857b43354">View</a></td></tr><tr><td>LBTC</td><td>0xf8f7b937a4CC6Cc16b600B3611ce0c1152a5b3F9</td><td><a href="https://basescan.org/address/0xf8f7b937a4CC6Cc16b600B3611ce0c1152a5b3F9">View</a></td></tr></tbody></table>

### OP Mainnet

<table><thead><tr><th>Market</th><th width="492.328125">Address</th><th>Explorer</th></tr></thead><tbody><tr><td>USDC</td><td>0x475d7c6999dc27E640d260aBf9f2fA9333E472CF</td><td><a href="https://optimistic.etherscan.io/address/0x475d7c6999dc27E640d260aBf9f2fA9333E472CF">View</a></td></tr><tr><td>USDT</td><td>0x9E58891D8DF4e6Dd8bAfD3082A59B72C51202841</td><td><a href="https://optimistic.etherscan.io/address/0x9E58891D8DF4e6Dd8bAfD3082A59B72C51202841">View</a></td></tr><tr><td>DAI</td><td>0xE6Aea947c0F082c5Dc751BB9C7f44Ce059590962</td><td><a href="https://optimistic.etherscan.io/address/0xE6Aea947c0F082c5Dc751BB9C7f44Ce059590962">View</a></td></tr><tr><td>WETH</td><td>0x080D64570a58FF87E14CC5Cb91d1aaB26b15CFDc</td><td><a href="https://optimistic.etherscan.io/address/0x080D64570a58FF87E14CC5Cb91d1aaB26b15CFDc">View</a></td></tr><tr><td>cbETH</td><td>0x8455D94e412A498Df8727D904252892Fb111a4cD</td><td><a href="https://optimistic.etherscan.io/address/0x8455D94e412A498Df8727D904252892Fb111a4cD">View</a></td></tr><tr><td>wstETH</td><td>0x01c369a6238226702E48C9C3fBB1de33F4b05D74</td><td><a href="https://optimistic.etherscan.io/address/0x01c369a6238226702E48C9C3fBB1de33F4b05D74">View</a></td></tr><tr><td>rETH</td><td>0x9E530e9F3f9b1046e223cc3eB97fA0bBab5Dd993</td><td><a href="https://optimistic.etherscan.io/address/0x9E530e9F3f9b1046e223cc3eB97fA0bBab5Dd993">View</a></td></tr><tr><td>OP</td><td>0x6427D36153dE11b694d70604B0715790769024f7</td><td><a href="https://optimistic.etherscan.io/address/0x6427D36153dE11b694d70604B0715790769024f7">View</a></td></tr><tr><td>VELO</td><td>0x589F59fBDB5952920fA557c924F6f5CFf184b155</td><td><a href="https://optimistic.etherscan.io/address/0x589F59fBDB5952920fA557c924F6f5CFf184b155">View</a></td></tr><tr><td>weETH</td><td>0x3B40085872eaEA59CF39FCafFb3dc36085aE48f6</td><td><a href="https://optimistic.etherscan.io/address/0x3B40085872eaEA59CF39FCafFb3dc36085aE48f6">View</a></td></tr><tr><td>wrsETH</td><td>0xFfF466528fE1a18b95Fa910C96540A70EC2727FB</td><td><a href="https://optimistic.etherscan.io/address/0xFfF466528fE1a18b95Fa910C96540A70EC2727FB">View</a></td></tr><tr><td>WBTC</td><td>0x78a9C06188195CEE3cBf67303a1708cb8765b9ec</td><td><a href="https://optimistic.etherscan.io/address/0x78a9C06188195CEE3cBf67303a1708cb8765b9ec">View</a></td></tr></tbody></table>

### Frequently Asked Questions

<details>

<summary><strong>What is the benefit of participating in reserve auctions?</strong></summary>

Participants can acquire reserve tokens at potentially discounted rates compared to market prices, with discounts improving as each mini-auction progresses.

</details>

<details>

<summary><strong>How is the price determined in an auction?</strong></summary>

Prices are derived from Chainlink oracle feeds for both WELL and reserve tokens, with a dynamic discount that increases linearly throughout each 6-hour mini-auction period.

</details>

<details>

<summary><strong>Can I participate in multiple auctions simultaneously?</strong></summary>

Yes, each market has its own auction contract, allowing you to participate in multiple auctions across different reserve assets.

</details>

<details>

<summary><strong>What happens if the reserves run out during an auction period?</strong></summary>

You'll need to wait for the next mini-auction period when new reserves become available.

</details>

<details>

<summary><strong>Is there a minimum or maximum bid amount?</strong></summary>

There is no enforced minimum or maximum, but transaction costs should be considered for smaller bids, and larger bids may be limited by available reserves.

</details>
