liquidator

package
v0.0.0-...-55fa119 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

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

View Source
const ModuleName = "liquidator"

ModuleName name of module

View Source
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 NewHandler

func NewHandler(keeper Keeper) sdk.Handler

Handle all liquidator messages.

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

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

func NewAppModule(keeper Keeper) AppModule

NewAppModule creates a new AppModule object

func (AppModule) BeginBlock

func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) sdk.Tags

BeginBlock module begin-block

func (AppModule) EndBlock

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) Name

func (AppModule) Name() string

Name module name

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

NewHandler module handler

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler module querier

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute module querier route name

func (AppModule) RegisterInvariants

func (AppModule) RegisterInvariants(_ sdk.InvariantRouter)

RegisterInvariants register module invariants

func (AppModule) Route

func (AppModule) Route() string

Route module message route name

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic app module basics object

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis default genesis state

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name get module name

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 CollateralParams struct {
	Denom       string  // Coin name of collateral type
	AuctionSize sdk.Int // Max amount of collateral to sell off in any one auction. Known as lump in Maker.

}

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 NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, subspace params.Subspace, cdpKeeper cdpKeeper, auctionKeeper auctionKeeper, bankKeeper bankKeeper) Keeper

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) LiquidatorModuleParams

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)

func (Keeper) StartDebtAuction

func (k Keeper) StartDebtAuction(ctx sdk.Context) (auction.ID, sdk.Error)

StartDebtAuction sells off minted gov coin to raise set amounts of stable coin. Known as Vow.flop in maker result: minted gov coin moved to highest bidder, stable coin moved to moduleAccount

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

GetSigners returns the addresses of signers that must sign.

func (MsgSeizeAndStartCollateralAuction) Route

Route return the message type used for routing the message.

func (MsgSeizeAndStartCollateralAuction) Type

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)

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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