AuctionModule
Inherits: IAuctionModule, IncreAccessControl, Pausable, ReentrancyGuard
Author: webthethird
Handles auctioning tokens slashed by the SafetyModule, triggered by governance in the event of an insolvency in the vault which cannot be covered by the insurance fund
State Variables
safetyModule
SafetyModule contract which manages staked token rewards, slashing and auctions
paymentToken
Payment token used to purchase lots in auctions
_nextAuctionId
ID of the next auction
_numCompletedAuctions
_auctions
Mapping of auction IDs to auction information
_tokensSoldPerAuction
Mapping of auction IDs to the number of tokens sold in that auction
_fundsRaisedPerAuction
Mapping of auction IDs to the number of payment tokens raised in that auction
_tokenBalancesInAuction
Mapping of ERC20 tokens to the internally tracked balance of this contract
Used to enforce that only one auction may be active for a given token at a time
Functions
onlySafetyModule
Modifier for functions that should only be called by the SafetyModule
constructor
AuctionModule constructor
Parameters
Name | Type | Description |
---|---|---|
|
| SafetyModule contract to manage this contract |
|
| ERC20 token used to purchase lots in auctions |
getCurrentLotSize
Returns the current lot size of the auction
Lot size starts at auction.initialLotSize
and increases by auction.lotIncreaseIncrement
every auction.lotIncreasePeriod
seconds, unless the lot size times the number of remaining lots reaches the contract's total balance of tokens, then the size remains fixed at totalBalance / auction.remainingLots
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Current number of tokens per lot |
getRemainingLots
Returns the number of lots still available for sale in the auction
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Number of lots still available for sale |
getLotPrice
Returns the price of each lot in the auction
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Price of each lot in payment tokens |
getLotIncreaseIncrement
Returns the number of tokens by which the lot size increases each period
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Size of each lot increase |
getLotIncreasePeriod
Returns the amount of time between each lot size increase
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Number of seconds between each lot size increase |
getAuctionToken
Returns the address of the token being auctioned
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| The ERC20 token being auctioned |
getStartTime
Returns the timestamp when the auction started
The auction starts when the SafetyModule calls startAuction
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Timestamp when the auction started |
getEndTime
Returns the timestamp when the auction ends
Auction can end early if all lots are sold or if the auction is terminated by the SafetyModule
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Timestamp when the auction ends |
getTokensSold
Returns the number of tokens sold in the auction
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Number of tokens sold |
getFundsRaised
Returns the amount of funds raised in the auction
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| Number of payment tokens raised |
getNextAuctionId
Returns the ID of the next auction
Returns
Name | Type | Description |
---|---|---|
|
| ID of the next auction |
isAuctionActive
Returns whether the auction is still active
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
Returns
Name | Type | Description |
---|---|---|
|
| True if the auction is still active, false otherwise |
isAnyAuctionActive
Returns whether any auction is still active
Returns
Name | Type | Description |
---|---|---|
|
| True if any auction is still active, false otherwise |
buyLots
Buys one or more lots at the current lot size, and ends the auction if all lots are sold
The caller must approve this contract to transfer the lotPrice x numLotsToBuy in payment tokens
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
|
| Number of lots to buy |
completeAuction
Ends an auction after the time limit has been reached and approves the transfer of unsold tokens and funds raised
This function can be called by anyone, but only after the auction's end time has passed
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
paused
Indicates whether auctions are currently paused
Contract is paused if either this contract or the SafetyModule has been paused
Returns
Name | Type | Description |
---|---|---|
|
| True if paused, false otherwise |
startAuction
Starts a new auction
Only callable by the SafetyModule
Parameters
Name | Type | Description |
---|---|---|
|
| The ERC20 token to auction |
|
| Number of lots in the auction |
|
| Price of each lot of tokens in payment tokens |
|
| Initial number of tokens in each lot |
|
| Amount of tokens by which the lot size increases each period |
|
| Number of seconds between each lot size increase |
|
| Number of seconds before the auction ends if all lots are not sold |
Returns
Name | Type | Description |
---|---|---|
|
| ID of the auction |
terminateAuction
Terminates an auction early and approves the transfer of unsold tokens and funds raised
Only callable by the SafetyModule
Parameters
Name | Type | Description |
---|---|---|
|
| ID of the auction |
setPaymentToken
Sets the token required for payments in all auctions
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| ERC20 token to use for payment |
setSafetyModule
Replaces the SafetyModule contract
Only callable by governance
Parameters
Name | Type | Description |
---|---|---|
|
| Address of the new SafetyModule contract |
pause
Pause the contract
Only callable by governance
unpause
Unpause the contract
Only callable by governance
_getCurrentLotSize
_completeAuction
Structs
Auction
Struct representing an auction
Properties
Name | Type | Description |
---|---|---|
|
| Address of the token being auctioned |
|
| Whether the auction is still active |
|
| Price of each lot of tokens, denominated in payment tokens |
|
| Initial size of each lot |
|
| Total number of lots in the auction |
|
| Number of lots that have not been sold |
|
| Timestamp when the auction started |
|
| Timestamp when the auction ends |
|
| Number of seconds between each lot size increase |
|
| Amount of tokens by which the lot size increases each period |
Last updated