ICollateralAuctionHouse

Git Source

Inherits: IAuthorizable, IDisableable, IModifiable

Functions

AUCTION_HOUSE_TYPE

Type of the auction house

function AUCTION_HOUSE_TYPE() external view returns (bytes32 _auctionHouseType);

Returns

NameTypeDescription
_auctionHouseTypebytes32Bytes32 representation of the auction house type

auctions

Data of an auction

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

Parameters

NameTypeDescription
_auctionIduint256Id of the auction

Returns

NameTypeDescription
_auctionAuctionAuction data struct

_auctions

Unpacked data of an auction

function _auctions(uint256 _auctionId)
  external
  view
  returns (
    uint256 _amountToSell,
    uint256 _amountToRaise,
    uint256 _initialTimestamp,
    address _forgoneCollateralReceiver,
    address _auctionIncomeRecipient
  );

Parameters

NameTypeDescription
_auctionIduint256Id of the auction

Returns

NameTypeDescription
_amountToSelluint256How much collateral is sold in an auction [wad]
_amountToRaiseuint256Total/max amount of coins to raise [rad]
_initialTimestampuint256Time when the auction was created
_forgoneCollateralReceiveraddressWho receives leftover collateral that is not sold in the auction (usually the liquidated SAFE)
_auctionIncomeRecipientaddressWho receives the coins raised by the auction (usually the AccountingEngine)

params

Getter for the contract parameters struct

function params() external view returns (CollateralAuctionHouseParams memory _cahParams);

Returns

NameTypeDescription
_cahParamsCollateralAuctionHouseParamsAuction house parameters struct

_params

Getter for the unpacked contract parameters struct

function _params()
  external
  view
  returns (uint256 _minimumBid, uint256 _minDiscount, uint256 _maxDiscount, uint256 _perSecondDiscountUpdateRate);

Returns

NameTypeDescription
_minimumBiduint256Minimum acceptable bid [wad]
_minDiscountuint256Minimum discount at which collateral is being sold [wad %]
_maxDiscountuint256Maximum discount at which collateral is being sold [wad %]
_perSecondDiscountUpdateRateuint256Rate at which the discount will be updated in an auction [ray]

safeEngine

Address of the SAFEEngine contract

function safeEngine() external view returns (ISAFEEngine _safeEngine);

liquidationEngine

Address of the LiquidationEngine contract

function liquidationEngine() external view returns (ILiquidationEngine _liquidationEngine);

oracleRelayer

Address of the OracleRelayer contract

function oracleRelayer() external view returns (IOracleRelayer _oracleRelayer);

collateralType

The collateral type of the auctions created by this contract

function collateralType() external view returns (bytes32 _cType);

Returns

NameTypeDescription
_cTypebytes32Bytes32 representation of the collateral type

auctionsStarted

Total amount of collateral auctions created

function auctionsStarted() external view returns (uint256 _auctionsStarted);

getAuctionDiscount

Calculates the current discount of an auction

function getAuctionDiscount(uint256 _id) external view returns (uint256 _auctionDiscount);

Parameters

NameTypeDescription
_iduint256Id of the auction

Returns

NameTypeDescription
_auctionDiscountuint256Current discount of the auction [wad %]

getCollateralBought

Calculates the amount of collateral that will be bought with a given bid

function getCollateralBought(
  uint256 _id,
  uint256 _wad
) external view returns (uint256 _collateralBought, uint256 _adjustedBid);

Parameters

NameTypeDescription
_iduint256Id of the auction
_waduint256Bid amount [wad]

Returns

NameTypeDescription
_collateralBoughtuint256Amount of collateral that will be bought [wad]
_adjustedBiduint256Adjusted bid amount [wad]

buyCollateral

Buys collateral from an auction

function buyCollateral(uint256 _id, uint256 _wad) external returns (uint256 _boughtCollateral, uint256 _adjustedBid);

Parameters

NameTypeDescription
_iduint256Id of the auction
_waduint256Bid amount [wad]

Returns

NameTypeDescription
_boughtCollateraluint256Amount of collateral that was bought [wad]
_adjustedBiduint256Adjusted bid amount [wad]

startAuction

Starts a new collateral auction

function startAuction(
  address _forgoneCollateralReceiver,
  address _auctionIncomeRecipient,
  uint256 _amountToRaise,
  uint256 _collateralToSell
) external returns (uint256 _id);

Parameters

NameTypeDescription
_forgoneCollateralReceiveraddressWho receives leftover collateral that is not sold in the auction (usually the liquidated SAFE)
_auctionIncomeRecipientaddressWho receives the coins raised by the auction (usually the AccountingEngine)
_amountToRaiseuint256Total/max amount of coins to raise [rad]
_collateralToSelluint256How much collateral is sold in an auction [wad]

Returns

NameTypeDescription
_iduint256Id of the started auction

terminateAuctionPrematurely

Terminates an auction prematurely

Transfers collateral and coins to the authorized caller address

function terminateAuctionPrematurely(uint256 _auctionId) external;

Parameters

NameTypeDescription
_auctionIduint256Id of the auction

Events

StartAuction

Emitted when a new auction is started

event StartAuction(
  uint256 indexed _id,
  address indexed _auctioneer,
  uint256 _blockTimestamp,
  uint256 _amountToSell,
  uint256 _amountToRaise
);

Parameters

NameTypeDescription
_iduint256Id of the auction
_auctioneeraddressAddress who started the auction
_blockTimestampuint256Time when the auction was started
_amountToSelluint256How much collateral is sold in an auction [wad]
_amountToRaiseuint256Total/max amount of coins to raise [rad]

BuyCollateral

Emitted when a bid is made in an auction

event BuyCollateral(
  uint256 indexed _id, address _bidder, uint256 _blockTimestamp, uint256 _raisedAmount, uint256 _soldAmount
);

Parameters

NameTypeDescription
_iduint256Id of the auction
_bidderaddressWho made the bid
_blockTimestampuint256Time when the bid was made
_raisedAmountuint256Amount of coins raised in the bid [rad]
_soldAmountuint256Amount of collateral sold in the bid [wad]

SettleAuction

Emitted when an auction is settled

An auction is settled when either all collateral is sold or all coins are raised

event SettleAuction(
  uint256 indexed _id, uint256 _blockTimestamp, address _leftoverReceiver, uint256 _leftoverCollateral
);

Parameters

NameTypeDescription
_iduint256Id of the auction
_blockTimestampuint256Time when the auction was settled
_leftoverReceiveraddressWho receives leftover collateral that is not sold in the auction (usually the liquidated SAFE)
_leftoverCollateraluint256Amount of leftover collateral that is not sold in the auction [wad]

TerminateAuctionPrematurely

Emitted when an auction is terminated prematurely

event TerminateAuctionPrematurely(
  uint256 indexed _id, uint256 _blockTimestamp, address _leftoverReceiver, uint256 _leftoverCollateral
);

Parameters

NameTypeDescription
_iduint256Id of the auction
_blockTimestampuint256Time when the auction was terminated
_leftoverReceiveraddressWho receives leftover collateral that is not sold in the auction (usually the liquidated SAFE)
_leftoverCollateraluint256Amount of leftover collateral that is not sold in the auction [wad]

Errors

CAH_InvalidRedemptionPriceProvided

Throws when the redemption price is invalid

error CAH_InvalidRedemptionPriceProvided();

CAH_CollateralOracleInvalidValue

Throws when the collateral price is invalid

error CAH_CollateralOracleInvalidValue();

CAH_NoCollateralForSale

Throws when trying to start an auction without collateral to sell

error CAH_NoCollateralForSale();

CAH_NothingToRaise

Throws when trying to start an auction without coins to raise

error CAH_NothingToRaise();

CAH_DustyAuction

Throws when trying to start an auction with a dusty amount to raise

error CAH_DustyAuction();

CAH_InexistentAuction

Throws when trying to bid in a nonexistent auction

error CAH_InexistentAuction();

CAH_InvalidBid

Throws when trying to bid an invalid amount

error CAH_InvalidBid();

CAH_NullBoughtAmount

Throws when the resulting bid amount is null

error CAH_NullBoughtAmount();

CAH_InvalidLeftToRaise

Throws when the resulting bid leftover to raise is invalid

error CAH_InvalidLeftToRaise();

Structs

CollateralAuctionHouseParams

struct CollateralAuctionHouseParams {
  uint256 minimumBid;
  uint256 minDiscount;
  uint256 maxDiscount;
  uint256 perSecondDiscountUpdateRate;
}

Auction

struct Auction {
  uint256 amountToSell;
  uint256 amountToRaise;
  uint256 initialTimestamp;
  address forgoneCollateralReceiver;
  address auctionIncomeRecipient;
}