DebtAuctionHouse

Git Source

Inherits: Authorizable, Modifiable, Disableable, IDebtAuctionHouse

This contract enables the sell of newly minted protocol tokens in exchange for system coins to cover a protocol debt

State Variables

AUCTION_HOUSE_TYPE

Type of the auction house

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

_auctions

Unpacked data of an auction

mapping(uint256 _auctionId => Auction) public _auctions;

auctionsStarted

Total amount of debt auctions created

uint256 public auctionsStarted;

activeDebtAuctions

Total amount of simultaneous active debt auctions

uint256 public activeDebtAuctions;

safeEngine

Address of the SAFEEngine contract

ISAFEEngine public safeEngine;

protocolToken

Address of the ProtocolToken contract

IProtocolToken public protocolToken;

accountingEngine

Address of the AccountingEngine contract

address public accountingEngine;

_params

Getter for the unpacked contract parameters struct

DebtAuctionHouseParams 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 (DebtAuctionHouseParams memory _dahParams);

Returns

NameTypeDescription
_dahParamsDebtAuctionHouseParamsAuction house parameters struct

constructor

constructor(
  address _safeEngine,
  address _protocolToken,
  DebtAuctionHouseParams memory _dahParams
) Authorizable(msg.sender) validParams;

Parameters

NameTypeDescription
_safeEngineaddressAddress of the SAFEEngine contract
_protocolTokenaddressAddress of the protocol governance token
_dahParamsDebtAuctionHouseParamsInitial valid DebtAuctionHouse parameters struct

_onContractDisable

Internal virtual method to be called when the contract is disabled

Sets the accountingEngine state var to the caller's address

function _onContractDisable() internal override;

startAuction

Start a new debt auction

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

Parameters

NameTypeDescription
_incomeReceiveraddressWho receives the auction proceeds
_amountToSelluint256Initial amount of protocol tokens to be minted [wad]
_initialBiduint256Amount of debt to be sold [rad]

Returns

NameTypeDescription
_iduint256Id of the auction

restartAuction

Restart an auction if no bids were placed

An auction can be restarted if the auction expired with no bids

function restartAuction(uint256 _id) external;

Parameters

NameTypeDescription
_iduint256Id of the auction

decreaseSoldAmount

Decrease the protocol token amount you're willing to receive in exchange for providing the same amount of system coins being raised by the auction

function decreaseSoldAmount(uint256 _id, uint256 _amountToBuy) external whenEnabled;

Parameters

NameTypeDescription
_iduint256ID of the auction for which you want to submit a new bid
_amountToBuyuint256Amount of protocol tokens to buy (must be smaller than the previous proposed amount) [wad]

settleAuction

Settle an auction

Can only be called after the auction expired with a winning bid

function settleAuction(uint256 _id) external whenEnabled;

Parameters

NameTypeDescription
_iduint256Id of the auction

terminateAuctionPrematurely

Terminate an auction prematurely

Can only be called after the contract is disabled

function terminateAuctionPrematurely(uint256 _id) external whenDisabled;

Parameters

NameTypeDescription
_iduint256Id of the auction

_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;