v0_13

package
v0.15.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxAuctionDuration max length of auction
	DefaultMaxAuctionDuration time.Duration = 2 * 24 * time.Hour
	// DefaultBidDuration how long an auction gets extended when someone bids
	DefaultBidDuration    time.Duration = 1 * time.Hour
	CollateralAuctionType               = "collateral"
	SurplusAuctionType                  = "surplus"
	DebtAuctionType                     = "debt"
	ForwardAuctionPhase                 = "forward"
	ReverseAuctionPhase                 = "reverse"
	DefaultNextAuctionID  uint64        = 1
)

Defaults for auction params

Variables

View Source
var (
	// DefaultIncrement is the smallest percent change a new bid must have from the old one
	DefaultIncrement       sdk.Dec = sdk.MustNewDecFromStr("0.05")
	KeyBidDuration                 = []byte("BidDuration")
	KeyMaxAuctionDuration          = []byte("MaxAuctionDuration")
	KeyIncrementSurplus            = []byte("IncrementSurplus")
	KeyIncrementDebt               = []byte("IncrementDebt")
	KeyIncrementCollateral         = []byte("IncrementCollateral")
)

module variables

Functions

This section is empty.

Types

type Auction

type Auction interface {
	GetID() uint64
	WithID(uint64) Auction

	GetInitiator() string
	GetLot() sdk.Coin
	GetBidder() sdk.AccAddress
	GetBid() sdk.Coin
	GetEndTime() time.Time

	GetType() string
	GetPhase() string
}

Auction is an interface for handling common actions on auctions.

type Auctions

type Auctions []Auction

Auctions is a slice of auctions.

type BaseAuction

type BaseAuction struct {
	ID              uint64         `json:"id" yaml:"id"`
	Initiator       string         `json:"initiator" yaml:"initiator"`                 // Module name that starts the auction. Pays out Lot.
	Lot             sdk.Coin       `json:"lot" yaml:"lot"`                             // Coins that will paid out by Initiator to the winning bidder.
	Bidder          sdk.AccAddress `json:"bidder" yaml:"bidder"`                       // Latest bidder. Receiver of Lot.
	Bid             sdk.Coin       `json:"bid" yaml:"bid"`                             // Coins paid into the auction the bidder.
	HasReceivedBids bool           `json:"has_received_bids" yaml:"has_received_bids"` // Whether the auction has received any bids or not.
	EndTime         time.Time      `json:"end_time" yaml:"end_time"`                   // Current auction closing time. Triggers at the end of the block with time ≥ EndTime.
	MaxEndTime      time.Time      `json:"max_end_time" yaml:"max_end_time"`           // Maximum closing time. Auctions can close before this but never after.
}

BaseAuction is a common type shared by all Auctions.

func (BaseAuction) GetBid

func (a BaseAuction) GetBid() sdk.Coin

GetBid is a getter for auction Bid.

func (BaseAuction) GetBidder

func (a BaseAuction) GetBidder() sdk.AccAddress

GetBidder is a getter for auction Bidder.

func (BaseAuction) GetEndTime

func (a BaseAuction) GetEndTime() time.Time

GetEndTime is a getter for auction end time.

func (BaseAuction) GetID

func (a BaseAuction) GetID() uint64

GetID is a getter for auction ID.

func (BaseAuction) GetInitiator

func (a BaseAuction) GetInitiator() string

GetInitiator is a getter for auction Initiator.

func (BaseAuction) GetLot

func (a BaseAuction) GetLot() sdk.Coin

GetLot is a getter for auction Lot.

func (BaseAuction) GetType

func (a BaseAuction) GetType() string

GetType returns the auction type. Used to identify auctions in event attributes.

func (BaseAuction) String

func (a BaseAuction) String() string

func (BaseAuction) Validate

func (a BaseAuction) Validate() error

Validate verifies that the auction end time is before max end time

type CollateralAuction

type CollateralAuction struct {
	BaseAuction `json:"base_auction" yaml:"base_auction"`

	CorrespondingDebt sdk.Coin          `json:"corresponding_debt" yaml:"corresponding_debt"`
	MaxBid            sdk.Coin          `json:"max_bid" yaml:"max_bid"`
	LotReturns        WeightedAddresses `json:"lot_returns" yaml:"lot_returns"`
}

CollateralAuction is a two phase auction. Initially, in forward auction phase, bids can be placed up to a max bid. Then it switches to a reverse auction phase, where the initial amount up for auction is bid down. Unsold Lot is sent to LotReturns, being divided among the addresses by weight. Collateral auctions are normally used to sell off collateral seized from CDPs.

func NewCollateralAuction

func NewCollateralAuction(seller string, lot sdk.Coin, endTime time.Time, maxBid sdk.Coin, lotReturns WeightedAddresses, debt sdk.Coin) CollateralAuction

NewCollateralAuction returns a new collateral auction.

func (CollateralAuction) GetLotReturns

func (a CollateralAuction) GetLotReturns() WeightedAddresses

GetLotReturns returns a collateral auction's lot owners

func (CollateralAuction) GetModuleAccountCoins

func (a CollateralAuction) GetModuleAccountCoins() sdk.Coins

GetModuleAccountCoins returns the total number of coins held in the module account for this auction. It is used in genesis initialize the module account correctly.

func (CollateralAuction) GetPhase

func (a CollateralAuction) GetPhase() string

GetPhase returns the direction of a collateral auction.

func (CollateralAuction) GetType

func (a CollateralAuction) GetType() string

GetType returns the auction type. Used to identify auctions in event attributes.

func (CollateralAuction) IsReversePhase

func (a CollateralAuction) IsReversePhase() bool

IsReversePhase returns whether the auction has switched over to reverse phase or not. CollateralAuctions initially start in forward phase.

func (CollateralAuction) String

func (a CollateralAuction) String() string

func (CollateralAuction) Validate

func (a CollateralAuction) Validate() error

Validate validates the CollateralAuction fields values.

func (CollateralAuction) WithID

func (a CollateralAuction) WithID(id uint64) Auction

WithID returns an auction with the ID set.

type DebtAuction

type DebtAuction struct {
	BaseAuction `json:"base_auction" yaml:"base_auction"`

	CorrespondingDebt sdk.Coin `json:"corresponding_debt" yaml:"corresponding_debt"`
}

DebtAuction is a reverse auction that mints what it pays out. It is normally used to acquire pegged asset to cover the CDP system's debts that were not covered by selling collateral.

func NewDebtAuction

func NewDebtAuction(buyerModAccName string, bid sdk.Coin, initialLot sdk.Coin, endTime time.Time, debt sdk.Coin) DebtAuction

NewDebtAuction returns a new debt auction.

func (DebtAuction) GetModuleAccountCoins

func (a DebtAuction) GetModuleAccountCoins() sdk.Coins

GetModuleAccountCoins returns the total number of coins held in the module account for this auction. It is used in genesis initialize the module account correctly.

func (DebtAuction) GetPhase

func (a DebtAuction) GetPhase() string

GetPhase returns the direction of a debt auction, which never changes.

func (DebtAuction) GetType

func (a DebtAuction) GetType() string

GetType returns the auction type. Used to identify auctions in event attributes.

func (DebtAuction) Validate

func (a DebtAuction) Validate() error

Validate validates the DebtAuction fields values.

func (DebtAuction) WithID

func (a DebtAuction) WithID(id uint64) Auction

WithID returns an auction with the ID set.

type GenesisAuction

type GenesisAuction interface {
	Auction
	GetModuleAccountCoins() sdk.Coins
	Validate() error
}

GenesisAuction interface for auctions at genesis

type GenesisAuctions

type GenesisAuctions []GenesisAuction

GenesisAuctions is a slice of genesis auctions.

type GenesisState

type GenesisState struct {
	NextAuctionID uint64          `json:"next_auction_id" yaml:"next_auction_id"`
	Params        Params          `json:"params" yaml:"params"`
	Auctions      GenesisAuctions `json:"auctions" yaml:"auctions"`
}

GenesisState is auction state that must be provided at chain genesis.

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns the default genesis state for auction module.

func NewGenesisState

func NewGenesisState(nextID uint64, ap Params, ga GenesisAuctions) GenesisState

NewGenesisState returns a new genesis state object for auctions module.

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate validates genesis inputs. It returns error if validation of any input fails.

type Params

type Params struct {
	MaxAuctionDuration  time.Duration `json:"max_auction_duration" yaml:"max_auction_duration"` // max length of auction
	BidDuration         time.Duration `json:"bid_duration" yaml:"bid_duration"`                 // additional time added to the auction end time after each bid, capped by the expiry.
	IncrementSurplus    sdk.Dec       `json:"increment_surplus" yaml:"increment_surplus"`       // percentage change (of auc.Bid) required for a new bid on a surplus auction
	IncrementDebt       sdk.Dec       `json:"increment_debt" yaml:"increment_debt"`             // percentage change (of auc.Lot) required for a new bid on a debt auction
	IncrementCollateral sdk.Dec       `json:"increment_collateral" yaml:"increment_collateral"` // percentage change (of auc.Bid or auc.Lot) required for a new bid on a collateral auction
}

Params is the governance parameters for the auction module.

func DefaultParams

func DefaultParams() Params

DefaultParams returns the default parameters for auctions.

func NewParams

func NewParams(maxAuctionDuration, bidDuration time.Duration, incrementSurplus, incrementDebt, incrementCollateral sdk.Dec) Params

NewParams returns a new Params object.

func (Params) Validate

func (p Params) Validate() error

Validate checks that the parameters have valid values.

type SurplusAuction

type SurplusAuction struct {
	BaseAuction `json:"base_auction" yaml:"base_auction"`
}

SurplusAuction is a forward auction that burns what it receives from bids. It is normally used to sell off excess pegged asset acquired by the CDP system.

func NewSurplusAuction

func NewSurplusAuction(seller string, lot sdk.Coin, bidDenom string, endTime time.Time) SurplusAuction

NewSurplusAuction returns a new surplus auction.

func (SurplusAuction) GetModuleAccountCoins

func (a SurplusAuction) GetModuleAccountCoins() sdk.Coins

GetModuleAccountCoins returns the total number of coins held in the module account for this auction. It is used in genesis initialize the module account correctly.

func (SurplusAuction) GetPhase

func (a SurplusAuction) GetPhase() string

GetPhase returns the direction of a surplus auction, which never changes.

func (SurplusAuction) GetType

func (a SurplusAuction) GetType() string

GetType returns the auction type. Used to identify auctions in event attributes.

func (SurplusAuction) WithID

func (a SurplusAuction) WithID(id uint64) Auction

WithID returns an auction with the ID set.

type WeightedAddresses

type WeightedAddresses struct {
	Addresses []sdk.AccAddress `json:"addresses" yaml:"addresses"`
	Weights   []sdk.Int        `json:"weights" yaml:"weights"`
}

WeightedAddresses is a type for storing some addresses and associated weights.

func NewWeightedAddresses

func NewWeightedAddresses(addrs []sdk.AccAddress, weights []sdk.Int) (WeightedAddresses, error)

NewWeightedAddresses returns a new list addresses with weights.

func (WeightedAddresses) Validate

func (wa WeightedAddresses) Validate() error

Validate checks for that the weights are not negative, not all zero, and the lengths match.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL