Auction
This contract manages the coupon auctions that the pool uses to sell the underlying ETH in exchange for USDC. It is not yet deployed on testnet.
State Variables
pool
Pool contract associated with the auction
beneficiary
Auction beneficiary, usually the pool contract
buyCouponToken
Auction buy coupon token
sellReserveToken
Auction sell reserve token
endTime
Auction end time
totalBuyCouponAmount
Total buy coupon amount
liquidationThreshold
Liquidation threshold
state
Auction state, either BIDDING, SUCCEEDED, FAILED_UNDERSOLD, or FAILED_LIQUIDATION
bids
Mapping to store all bids by their index
bidCount
Total number of bids
lastBidIndex
Index of the last bid
highestBidIndex
The index of the highest bid in the sorted list
maxBids
MaxBids
lowestBidIndex
Index of the lowest bid
currentCouponAmount
Aggregated buy amount (coupon) for the auction
totalSellReserveAmount
Aggregated sell amount (reserve) for the auction
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
initialize
Initializes the Auction contract.
Parameters
Name | Type | Description |
---|---|---|
|
| The address of the buy token (coupon). |
|
| The address of the sell token (reserve). |
|
| The total amount of buy tokens (coupon) for the auction. |
|
| The end time of the auction. |
|
| The maximum number of bids allowed in the auction. |
|
| The address of the auction beneficiary. |
|
| The percentage threshold for liquidation (e.g. 95000 = 95%). |
bid
Places a bid on a portion of the pool.
Parameters
Name | Type | Description |
---|---|---|
|
| The amount of buy tokens (reserve) to bid. |
|
| The amount of sell tokens (coupon) to bid. |
Returns
Name | Type | Description |
---|---|---|
|
| The index of the bid. |
insertSortedBid
Inserts the bid into the linked list based on the price (buyAmount/sellAmount) in descending order, then by sellAmount.
Parameters
Name | Type | Description |
---|---|---|
|
| The index of the bid to insert. |
removeExcessBids
Removes excess bids from the auction.
_removeBid
Removes a bid from the linked list.
Parameters
Name | Type | Description |
---|---|---|
|
| The index of the bid to remove. |
endAuction
Ends the auction and transfers the reserve to the auction.
claimBid
Claims the tokens for a winning bid.
Parameters
Name | Type | Description |
---|---|---|
|
| The index of the bid to claim. |
claimRefund
Claims a refund for a bid in a failed auction.
Parameters
Name | Type | Description |
---|---|---|
|
| The index of the bid to claim a refund for. |
slotSize
Returns the size of a bid slot.
Returns
Name | Type | Description |
---|---|---|
|
| uint256 The size of a bid slot. |
auctionActive
Modifier to check if the auction is still active.
auctionExpired
Modifier to check if the auction has expired.
auctionSucceeded
Modifier to check if the auction succeeded.
auctionFailed
Modifier to check if the auction has failed. This happens if the auction didn't succeed to generate enough coupon tokens or the amount of reserve tokens sold exceeds the allowed threshold.
onlyRole
Modifier to check if the caller has the specified role.
Parameters
Name | Type | Description |
---|---|---|
|
| The role to check for. |
_authorizeUpgrade
Authorizes an upgrade to a new implementation. Can only be called by the owner of the contract.
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the new implementation |
Events
AuctionEnded
Auction ended event
Parameters
Name | Type | Description |
---|---|---|
|
| Auction state |
|
| Total sell reserve amount. The amount of reserve tokens sold by the protocol during the auction. |
|
| Total buy coupon amount. The amount of coupon tokens bought by the protocol from the bidders during the auction. |
BidRefundClaimed
Bid refund claimed event
Parameters
Name | Type | Description |
---|---|---|
|
| Index of the bid |
|
| Address of the bidder |
|
| Amount of bid coupon tokens refunded to the bidder |
BidClaimed
Bid claimed event
Parameters
Name | Type | Description |
---|---|---|
|
| Index of the bid |
|
| Address of the bidder |
|
| Amount of bid coupon tokens claimed by the bidder |
BidPlaced
Bid placed event
Parameters
Name | Type | Description |
---|---|---|
|
| Index of the bid |
|
| Address of the bidder |
|
| Amount of bid reserve tokens |
|
| Amount of bid coupon tokens |
BidRemoved
Bid removed event
Parameters
Name | Type | Description |
---|---|---|
|
| Index of the bid |
|
| Address of the bidder |
|
| Amount of bid reserve tokens |
|
| Amount of bid coupon tokens |
BidReduced
Bid reduced event
Parameters
Name | Type | Description |
---|---|---|
|
| Index of the bid |
|
| Address of the bidder |
|
| Amount of bid reserve tokens |
|
| Amount of bid coupon tokens |
Errors
AccessDenied
Access denied error
AuctionFailed
Auction failed error
NothingToClaim
Nothing to claim error
AlreadyClaimed
Already claimed error
AuctionHasEnded
Auction has ended error
AuctionNotEnded
Auction not ended error
BidAmountTooLow
Bid amount too low error
InvalidSellAmount
Invalid sell amount error
AuctionStillOngoing
Auction still ongoing error
AuctionAlreadyEnded
Auction already ended error
Structs
Bid
Bid struct
Enums
State
Auction state
Last updated