Documentation ¶
Overview ¶
Package Liquidator settles bad debt from undercollateralized CDPs by seizing them and raising funds through auctions.
Notes
- Missing the debt queue thing from Vow
- seized collateral and usdx are stored in the module account, but debt (aka Sin) is stored in keeper
- The boundary between the liquidator and the cdp modules is messy.
- The CDP type is used in liquidator
- cdp knows about seizing
- seizing of a CDP is split across each module
- recording of debt is split across modules
- liquidator needs get access to stable and gov denoms from the cdp module
TODO
- Is returning unsold collateral to the CDP owner rather than the CDP a problem? It could prevent the CDP from becoming safe again.
- Add some kind of more complete test
- Add constants for the module and route names
- tags
- custom error types, codespace
Index ¶
- Constants
- func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
- func NewHandler(keeper Keeper) sdk.Handler
- func NewQuerier(keeper Keeper) sdk.Querier
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type AppModule
- func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) sdk.Tags
- func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) ([]abci.ValidatorUpdate, sdk.Tags)
- func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
- func (AppModule) Name() string
- func (am AppModule) NewHandler() sdk.Handler
- func (am AppModule) NewQuerierHandler() sdk.Querier
- func (AppModule) QuerierRoute() string
- func (AppModule) RegisterInvariants(_ sdk.InvariantRouter)
- func (AppModule) Route() string
- type AppModuleBasic
- type CollateralParams
- type GenesisState
- type Keeper
- func (k Keeper) GetParams(ctx sdk.Context) LiquidatorModuleParams
- func (k Keeper) GetSeizedDebt(ctx sdk.Context) SeizedDebt
- func (k Keeper) SeizeAndStartCollateralAuction(ctx sdk.Context, owner sdk.AccAddress, collateralDenom string) (auction.ID, sdk.Error)
- func (k Keeper) StartDebtAuction(ctx sdk.Context) (auction.ID, sdk.Error)
- type LiquidatorModuleParams
- type MsgSeizeAndStartCollateralAuction
- func (msg MsgSeizeAndStartCollateralAuction) GetSignBytes() []byte
- func (msg MsgSeizeAndStartCollateralAuction) GetSigners() []sdk.AccAddress
- func (msg MsgSeizeAndStartCollateralAuction) Route() string
- func (msg MsgSeizeAndStartCollateralAuction) Type() string
- func (msg MsgSeizeAndStartCollateralAuction) ValidateBasic() sdk.Error
- type MsgStartDebtAuction
- type SeizedDebt
Constants ¶
const ModuleName = "liquidator"
ModuleName name of module
const (
QueryGetOutstandingDebt = "outstanding_debt" // Get the outstanding seized debt
)
Variables ¶
This section is empty.
Functions ¶
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
InitGenesis sets the genesis state in the keeper.
func NewQuerier ¶
func RegisterCodec ¶
RegisterCodec registers concrete types on the codec.
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis performs basic validation of genesis data returning an error for any failed validation criteria.
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule app module type
func NewAppModule ¶
NewAppModule creates a new AppModule object
func (AppModule) BeginBlock ¶
BeginBlock module begin-block
func (AppModule) EndBlock ¶
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) ([]abci.ValidatorUpdate, sdk.Tags)
EndBlock module end-block
func (AppModule) ExportGenesis ¶
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
ExportGenesis module export genesis
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
InitGenesis module init-genesis
func (AppModule) NewHandler ¶
NewHandler module handler
func (AppModule) NewQuerierHandler ¶
NewQuerierHandler module querier
func (AppModule) QuerierRoute ¶
QuerierRoute module querier route name
func (AppModule) RegisterInvariants ¶
func (AppModule) RegisterInvariants(_ sdk.InvariantRouter)
RegisterInvariants register module invariants
type AppModuleBasic ¶
type AppModuleBasic struct{}
AppModuleBasic app module basics object
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis() json.RawMessage
DefaultGenesis default genesis state
func (AppModuleBasic) RegisterCodec ¶
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
RegisterCodec register module codec
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
ValidateGenesis module validate genesis
type CollateralParams ¶
type GenesisState ¶
type GenesisState struct {
LiquidatorModuleParams LiquidatorModuleParams `json:"params"`
}
GenesisState is the state that must be provided at genesis.
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState returns a default genesis state TODO pick better values
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState
ExportGenesis returns a GenesisState for a given context and keeper.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func (Keeper) GetSeizedDebt ¶
func (k Keeper) GetSeizedDebt(ctx sdk.Context) SeizedDebt
func (Keeper) SeizeAndStartCollateralAuction ¶
func (k Keeper) SeizeAndStartCollateralAuction(ctx sdk.Context, owner sdk.AccAddress, collateralDenom string) (auction.ID, sdk.Error)
SeizeAndStartCollateralAuction pulls collateral out of a CDP and sells it in an auction for stable coin. Excess collateral goes to the original CDP owner. Known as Cat.bite in maker result: stable coin is transferred to module account, collateral is transferred from module account to buyer, (and any excess collateral is transferred to original CDP owner)
type LiquidatorModuleParams ¶
type LiquidatorModuleParams struct { DebtAuctionSize sdk.Int //SurplusAuctionSize sdk.Int CollateralParams []CollateralParams }
func (LiquidatorModuleParams) GetCollateralParams ¶
func (p LiquidatorModuleParams) GetCollateralParams(collateralDenom string) CollateralParams
type MsgSeizeAndStartCollateralAuction ¶
type MsgSeizeAndStartCollateralAuction struct { Sender sdk.AccAddress // only needed to pay the tx fees CdpOwner sdk.AccAddress CollateralDenom string }
func (MsgSeizeAndStartCollateralAuction) GetSignBytes ¶
func (msg MsgSeizeAndStartCollateralAuction) GetSignBytes() []byte
GetSignBytes gets the canonical byte representation of the Msg.
func (MsgSeizeAndStartCollateralAuction) GetSigners ¶
func (msg MsgSeizeAndStartCollateralAuction) GetSigners() []sdk.AccAddress
GetSigners returns the addresses of signers that must sign.
func (MsgSeizeAndStartCollateralAuction) Route ¶
func (msg MsgSeizeAndStartCollateralAuction) Route() string
Route return the message type used for routing the message.
func (MsgSeizeAndStartCollateralAuction) Type ¶
func (msg MsgSeizeAndStartCollateralAuction) Type() string
Type returns a human-readable string for the message, intended for utilization within tags.
func (MsgSeizeAndStartCollateralAuction) ValidateBasic ¶
func (msg MsgSeizeAndStartCollateralAuction) ValidateBasic() sdk.Error
ValidateBasic does a simple validation check that doesn't require access to any other information.
type MsgStartDebtAuction ¶
type MsgStartDebtAuction struct {
Sender sdk.AccAddress // only needed to pay the tx fees
}
func (MsgStartDebtAuction) GetSignBytes ¶
func (msg MsgStartDebtAuction) GetSignBytes() []byte
func (MsgStartDebtAuction) GetSigners ¶
func (msg MsgStartDebtAuction) GetSigners() []sdk.AccAddress
func (MsgStartDebtAuction) Route ¶
func (msg MsgStartDebtAuction) Route() string
func (MsgStartDebtAuction) Type ¶
func (msg MsgStartDebtAuction) Type() string
func (MsgStartDebtAuction) ValidateBasic ¶
func (msg MsgStartDebtAuction) ValidateBasic() sdk.Error
type SeizedDebt ¶
type SeizedDebt struct { Total sdk.Int // Total debt seized from CDPs. Known as Awe in maker. SentToAuction sdk.Int // Portion of seized debt that has had a (reverse) auction was started for it. Known as Ash in maker. }
func (SeizedDebt) Available ¶
func (sd SeizedDebt) Available() sdk.Int
Available gets the seized debt that has not been sent for auction. Known as Woe in maker.
func (SeizedDebt) Settle ¶
func (sd SeizedDebt) Settle(amount sdk.Int) (SeizedDebt, sdk.Error)