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
_buyCouponToken
address
The address of the buy token (coupon).
_sellReserveToken
address
The address of the sell token (reserve).
_totalBuyCouponAmount
uint256
The total amount of buy tokens (coupon) for the auction.
_endTime
uint256
The end time of the auction.
_maxBids
uint256
The maximum number of bids allowed in the auction.
_beneficiary
address
The address of the auction beneficiary.
_liquidationThreshold
uint256
The percentage threshold for liquidation (e.g. 95000 = 95%).
bid
Places a bid on a portion of the pool.
Parameters
buyReserveAmount
uint256
The amount of buy tokens (reserve) to bid.
sellCouponAmount
uint256
The amount of sell tokens (coupon) to bid.
Returns
<none>
uint256
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
newBidIndex
uint256
The index of the bid to insert.
removeExcessBids
Removes excess bids from the auction.
_removeBid
Removes a bid from the linked list.
Parameters
bidIndex
uint256
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
bidIndex
uint256
The index of the bid to claim.
claimRefund
Claims a refund for a bid in a failed auction.
Parameters
bidIndex
uint256
The index of the bid to claim a refund for.
slotSize
Returns the size of a bid slot.
Returns
<none>
uint256
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
role
bytes32
The role to check for.
_authorizeUpgrade
Authorizes an upgrade to a new implementation. Can only be called by the owner of the contract.
Parameters
newImplementation
address
Address of the new implementation
Events
AuctionEnded
Auction ended event
Parameters
state
State
Auction state
totalSellReserveAmount
uint256
Total sell reserve amount. The amount of reserve tokens sold by the protocol during the auction.
totalBuyCouponAmount
uint256
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
bidIndex
uint256
Index of the bid
bidder
address
Address of the bidder
sellCouponAmount
uint256
Amount of bid coupon tokens refunded to the bidder
BidClaimed
Bid claimed event
Parameters
bidIndex
uint256
Index of the bid
bidder
address
Address of the bidder
sellCouponAmount
uint256
Amount of bid coupon tokens claimed by the bidder
BidPlaced
Bid placed event
Parameters
bidIndex
uint256
Index of the bid
bidder
address
Address of the bidder
buyReserveAmount
uint256
Amount of bid reserve tokens
sellCouponAmount
uint256
Amount of bid coupon tokens
BidRemoved
Bid removed event
Parameters
bidIndex
uint256
Index of the bid
bidder
address
Address of the bidder
buyReserveAmount
uint256
Amount of bid reserve tokens
sellCouponAmount
uint256
Amount of bid coupon tokens
BidReduced
Bid reduced event
Parameters
bidIndex
uint256
Index of the bid
bidder
address
Address of the bidder
buyReserveAmount
uint256
Amount of bid reserve tokens
sellCouponAmount
uint256
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