SurplusAuctionHouse

Git Source

Inherits: Authorizable, Modifiable, Disableable, ISurplusAuctionHouse

This contract enables the sell of system coins in exchange for protocol tokens

A percentage of the protocol tokens raised in the auction are sent to a receiver, the rest is burnt

State Variables

AUCTION_HOUSE_TYPE

Type of the auction house

bytes32 public constant AUCTION_HOUSE_TYPE = bytes32('SURPLUS');

_auctions

Raw data of an auction

mapping(uint256 _auctionId => Auction) public _auctions;

auctionsStarted

Total amount of surplus auctions created

uint256 public auctionsStarted;

safeEngine

Address of the SAFEEngine contract

ISAFEEngine public safeEngine;

protocolToken

Address of the ProtocolToken contract

IProtocolToken public protocolToken;

_params

Getter for the unpacked contract parameters struct

SurplusAuctionHouseParams public _params;

Functions

auctions

Data of an auction

function auctions(uint256 _id) external view returns (Auction memory _auction);

Parameters

NameTypeDescription
_iduint256Id of the auction

Returns

NameTypeDescription
_auctionAuctionAuction data struct

params

Getter for the contract parameters struct

function params() external view returns (SurplusAuctionHouseParams memory _sahParams);

Returns

NameTypeDescription
_sahParamsSurplusAuctionHouseParamsAuction house parameters struct

constructor

constructor(
  address _safeEngine,
  address _protocolToken,
  SurplusAuctionHouseParams memory _sahParams
) Authorizable(msg.sender) validParams;

Parameters

NameTypeDescription
_safeEngineaddressAddress of the SAFEEngine contract
_protocolTokenaddressAddress of the protocol governance token
_sahParamsSurplusAuctionHouseParamsInitial valid SurplusAuctionHouse parameters struct

_onContractDisable

Internal virtual method to be called when the contract is disabled

Transfer all system coins back to the caller's address (usually the AccountingEngine)

function _onContractDisable() internal override;

startAuction

Start a new surplus auction

function startAuction(
  uint256 _amountToSell,
  uint256 _initialBid
) external isAuthorized whenEnabled returns (uint256 _id);

Parameters

NameTypeDescription
_amountToSelluint256Total amount of system coins to sell [rad]
_initialBiduint256Initial protocol token bid [wad]

Returns

NameTypeDescription
_iduint256ID of the started auction

restartAuction

Restart an auction if no bids were submitted for it

function restartAuction(uint256 _id) external;

Parameters

NameTypeDescription
_iduint256ID of the auction to restart

increaseBidSize

Submit a higher protocol token bid for the same amount of system coins

function increaseBidSize(uint256 _id, uint256 _bid) external whenEnabled;

Parameters

NameTypeDescription
_iduint256ID of the auction you want to submit the bid for
_biduint256New bid submitted [wad]

settleAuction

Settle/finish an auction

function settleAuction(uint256 _id) external whenEnabled;

Parameters

NameTypeDescription
_iduint256ID of the auction to settle

terminateAuctionPrematurely

Terminate an auction prematurely.

function terminateAuctionPrematurely(uint256 _id) external whenDisabled;

Parameters

NameTypeDescription
_iduint256ID of the auction to settle/terminate

_modifyParameters

Internal function to be overriden with custom logic to modify parameters

This function is set to revert if not overriden

function _modifyParameters(bytes32 _param, bytes memory _data) internal override;

_validateParameters

Internal function to be overriden with custom logic to validate parameters

function _validateParameters() internal view override;