types

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 13 Imported by: 14

Documentation

Index

Constants

View Source
const (
	EventTypeCreateCdp         = "create_cdp"
	EventTypeCdpDeposit        = "cdp_deposit"
	EventTypeCdpDraw           = "cdp_draw"
	EventTypeCdpRepay          = "cdp_repayment"
	EventTypeCdpClose          = "cdp_close"
	EventTypeCdpWithdrawal     = "cdp_withdrawal"
	EventTypeCdpLiquidation    = "cdp_liquidation"
	EventTypeBeginBlockerFatal = "cdp_begin_block_error"

	AttributeKeyCdpID      = "cdp_id"
	AttributeKeyDeposit    = "deposit"
	AttributeValueCategory = "cdp"
	AttributeKeyError      = "error_message"
)

Event types for cdp module

View Source
const (
	// ModuleName The name that will be used throughout the module
	ModuleName = "cdp"

	// StoreKey Top level store key where all module items will be stored
	StoreKey = ModuleName

	// RouterKey Top level router key
	RouterKey = ModuleName

	// QuerierRoute Top level query string
	QuerierRoute = ModuleName

	// DefaultParamspace default name for parameter store
	DefaultParamspace = ModuleName

	// LiquidatorMacc module account for liquidator
	LiquidatorMacc = "liquidator"
)
View Source
const (
	QueryGetCdp                     = "cdp"
	QueryGetCdps                    = "cdps"
	QueryGetCdpDeposits             = "deposits"
	QueryGetCdpsByCollateralization = "ratio"          // legacy query, maintained for REST API
	QueryGetCdpsByCollateralType    = "collateralType" // legacy query, maintained for REST API
	QueryGetParams                  = "params"
	QueryGetAccounts                = "accounts"
	RestOwner                       = "owner"
	RestCollateralType              = "collateral-type"
	RestRatio                       = "ratio"
)

Querier routes for the cdp module

Variables

View Source
var (
	// ErrCdpAlreadyExists error for duplicate cdps
	ErrCdpAlreadyExists = sdkerrors.Register(ModuleName, 2, "cdp already exists")
	// ErrInvalidCollateralLength error for invalid collateral input length
	ErrInvalidCollateralLength = sdkerrors.Register(ModuleName, 3, "only one collateral type per cdp")
	// ErrCollateralNotSupported error for unsupported collateral
	ErrCollateralNotSupported = sdkerrors.Register(ModuleName, 4, "collateral not supported")
	// ErrDebtNotSupported error for unsupported debt
	ErrDebtNotSupported = sdkerrors.Register(ModuleName, 5, "debt not supported")
	// ErrExceedsDebtLimit error for attempted draws that exceed debt limit
	ErrExceedsDebtLimit = sdkerrors.Register(ModuleName, 6, "proposed debt increase would exceed debt limit")
	// ErrInvalidCollateralRatio error for attempted draws that are below liquidation ratio
	ErrInvalidCollateralRatio = sdkerrors.Register(ModuleName, 7, "proposed collateral ratio is below liquidation ratio")
	// ErrCdpNotFound error cdp not found
	ErrCdpNotFound = sdkerrors.Register(ModuleName, 8, "cdp not found")
	// ErrDepositNotFound error for deposit not found
	ErrDepositNotFound = sdkerrors.Register(ModuleName, 9, "deposit not found")
	// ErrInvalidDeposit error for invalid deposit
	ErrInvalidDeposit = sdkerrors.Register(ModuleName, 10, "invalid deposit")
	// ErrInvalidPayment error for invalid payment
	ErrInvalidPayment = sdkerrors.Register(ModuleName, 11, "invalid payment")
	//ErrDepositNotAvailable error for withdrawing deposits in liquidation
	ErrDepositNotAvailable = sdkerrors.Register(ModuleName, 12, "deposit in liquidation")
	// ErrInvalidWithdrawAmount error for invalid withdrawal amount
	ErrInvalidWithdrawAmount = sdkerrors.Register(ModuleName, 13, "withdrawal amount exceeds deposit")
	//ErrCdpNotAvailable error for depositing to a CDP in liquidation
	ErrCdpNotAvailable = sdkerrors.Register(ModuleName, 14, "cannot modify cdp in liquidation")
	// ErrBelowDebtFloor error for creating a cdp with debt below the minimum
	ErrBelowDebtFloor = sdkerrors.Register(ModuleName, 15, "proposed cdp debt is below minimum")
	// ErrLoadingAugmentedCDP error loading augmented cdp
	ErrLoadingAugmentedCDP = sdkerrors.Register(ModuleName, 16, "augmented cdp could not be loaded from cdp")
	// ErrInvalidDebtRequest error for invalid principal input length
	ErrInvalidDebtRequest = sdkerrors.Register(ModuleName, 17, "only one principal type per cdp")
	// ErrDenomPrefixNotFound error for denom prefix not found
	ErrDenomPrefixNotFound = sdkerrors.Register(ModuleName, 18, "denom prefix not found")
	// ErrPricefeedDown error for when a price for the input denom is not found
	ErrPricefeedDown = sdkerrors.Register(ModuleName, 19, "no price found for collateral")
	// ErrInvalidCollateral error for when the input collateral denom does not match the expected collateral denom
	ErrInvalidCollateral = sdkerrors.Register(ModuleName, 20, "invalid collateral for input collateral type")
	// ErrAccountNotFound error for when no account is found for an input address
	ErrAccountNotFound = sdkerrors.Register(ModuleName, 21, "account not found")
	// ErrInsufficientBalance error for when an account does not have enough funds
	ErrInsufficientBalance = sdkerrors.Register(ModuleName, 22, "insufficient balance")
	// ErrNotLiquidatable error for when an cdp is not liquidatable
	ErrNotLiquidatable = sdkerrors.Register(ModuleName, 23, "cdp collateral ratio not below liquidation ratio")
)
View Source
var (
	CdpIDKeyPrefix             = []byte{0x01}
	CdpKeyPrefix               = []byte{0x02}
	CollateralRatioIndexPrefix = []byte{0x03}
	CdpIDKey                   = []byte{0x04}
	DebtDenomKey               = []byte{0x05}
	GovDenomKey                = []byte{0x06}
	DepositKeyPrefix           = []byte{0x07}
	PrincipalKeyPrefix         = []byte{0x08}
	PricefeedStatusKeyPrefix   = []byte{0x10}
	PreviousAccrualTimePrefix  = []byte{0x12}
	InterestFactorPrefix       = []byte{0x13}
)

KVStore key prefixes

View Source
var (
	KeyGlobalDebtLimit      = []byte("GlobalDebtLimit")
	KeyCollateralParams     = []byte("CollateralParams")
	KeyDebtParam            = []byte("DebtParam")
	KeyCircuitBreaker       = []byte("CircuitBreaker")
	KeyDebtThreshold        = []byte("DebtThreshold")
	KeyDebtLot              = []byte("DebtLot")
	KeySurplusThreshold     = []byte("SurplusThreshold")
	KeySurplusLot           = []byte("SurplusLot")
	DefaultGlobalDebt       = sdk.NewCoin(DefaultStableDenom, sdk.ZeroInt())
	DefaultCircuitBreaker   = false
	DefaultCollateralParams = CollateralParams{}
	DefaultDebtParam        = DebtParam{
		Denom:            "usdx",
		ReferenceAsset:   "usd",
		ConversionFactor: sdk.NewInt(6),
		DebtFloor:        sdk.NewInt(10000000),
	}
	DefaultCdpStartingID    = uint64(1)
	DefaultDebtDenom        = "debt"
	DefaultGovDenom         = "ukava"
	DefaultStableDenom      = "usdx"
	DefaultSurplusThreshold = sdk.NewInt(500000000000)
	DefaultDebtThreshold    = sdk.NewInt(100000000000)
	DefaultSurplusLot       = sdk.NewInt(10000000000)
	DefaultDebtLot          = sdk.NewInt(10000000000)
)

Parameter keys

View Source
var MaxSortableDec = sdk.OneDec().Quo(sdk.SmallestDec())

MaxSortableDec largest sortable sdk.Dec

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func CdpKey

func CdpKey(denomByte byte, cdpID uint64) []byte

CdpKey key of a specific cdp in the store

func CollateralRatioBytes

func CollateralRatioBytes(ratio sdk.Dec) []byte

CollateralRatioBytes returns the liquidation ratio as sortable bytes

func CollateralRatioIterKey

func CollateralRatioIterKey(denomByte byte, ratio sdk.Dec) []byte

CollateralRatioIterKey returns the key for iterating over cdps by denom and liquidation ratio

func CollateralRatioKey

func CollateralRatioKey(denomByte byte, cdpID uint64, ratio sdk.Dec) []byte

CollateralRatioKey returns the key for querying a cdp by its liquidation ratio

func DenomIterKey

func DenomIterKey(denomByte byte) []byte

DenomIterKey returns the key for iterating over cdps of a certain denom in the store

func DepositIterKey

func DepositIterKey(cdpID uint64) []byte

DepositIterKey returns the prefix key for iterating over deposits to a cdp

func DepositKey

func DepositKey(cdpID uint64, depositor sdk.AccAddress) []byte

DepositKey key of a specific deposit in the store

func GetCdpIDBytes

func GetCdpIDBytes(cdpID uint64) (cdpIDBz []byte)

GetCdpIDBytes returns the byte representation of the cdpID

func GetCdpIDFromBytes

func GetCdpIDFromBytes(bz []byte) (cdpID uint64)

GetCdpIDFromBytes returns cdpID in uint64 format from a byte array

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable Key declaration for parameters

func ParseDecBytes

func ParseDecBytes(db []byte) (sdk.Dec, error)

ParseDecBytes parses a []byte encoded using SortableDecBytes back to sdk.Dec

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the necessary types for cdp module

func RelativePow

func RelativePow(x sdk.Int, n sdk.Int, b sdk.Int) (z sdk.Int)

RelativePow raises x to the power of n, where x (and the result, z) are scaled by factor b. For example, RelativePow(210, 2, 100) = 441 (2.1^2 = 4.41) Only defined for positive ints.

func SortableDecBytes

func SortableDecBytes(dec sdk.Dec) []byte

SortableDecBytes returns a byte slice representation of a Dec that can be sorted. Left and right pads with 0s so there are 18 digits to left and right of the decimal point. For this reason, there is a maximum and minimum value for this, enforced by ValidSortableDec.

func SplitCdpKey

func SplitCdpKey(key []byte) (byte, uint64)

SplitCdpKey returns the component parts of a cdp key

func SplitCollateralRatioIterKey

func SplitCollateralRatioIterKey(key []byte) (denom byte, ratio sdk.Dec)

SplitCollateralRatioIterKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio

func SplitCollateralRatioKey

func SplitCollateralRatioKey(key []byte) (denom byte, cdpID uint64, ratio sdk.Dec)

SplitCollateralRatioKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio

func SplitDenomIterKey

func SplitDenomIterKey(key []byte) byte

SplitDenomIterKey returns the component part of a key for iterating over cdps by denom

func SplitDepositIterKey

func SplitDepositIterKey(key []byte) (cdpID uint64)

SplitDepositIterKey returns the component parts of a key for iterating over deposits on a cdp

func SplitDepositKey

func SplitDepositKey(key []byte) (uint64, sdk.AccAddress)

SplitDepositKey returns the component parts of a deposit key

func ValidSortableDec

func ValidSortableDec(dec sdk.Dec) bool

ValidSortableDec sdk.Dec can't have precision of less than 10^-18

Types

type AccountKeeper added in v0.5.0

type AccountKeeper interface {
	IterateAccounts(ctx sdk.Context, cb func(account authexported.Account) (stop bool))
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) authexported.Account
}

AccountKeeper expected interface for the account keeper (noalias)

type AuctionKeeper

type AuctionKeeper interface {
	StartSurplusAuction(ctx sdk.Context, seller string, lot sdk.Coin, bidDenom string) (uint64, error)
	StartDebtAuction(ctx sdk.Context, buyer string, bid sdk.Coin, initialLot sdk.Coin, debt sdk.Coin) (uint64, error)
	StartCollateralAuction(ctx sdk.Context, seller string, lot sdk.Coin, maxBid sdk.Coin, lotReturnAddrs []sdk.AccAddress, lotReturnWeights []sdk.Int, debt sdk.Coin) (uint64, error)
}

AuctionKeeper expected interface for the auction keeper (noalias)

type AugmentedCDP

type AugmentedCDP struct {
	CDP                    `json:"cdp" yaml:"cdp"`
	CollateralValue        sdk.Coin `json:"collateral_value" yaml:"collateral_value"`               // collateral's market value in debt coin
	CollateralizationRatio sdk.Dec  `json:"collateralization_ratio" yaml:"collateralization_ratio"` // current collateralization ratio
}

AugmentedCDP provides additional information about an active CDP

func NewAugmentedCDP

func NewAugmentedCDP(cdp CDP, collateralValue sdk.Coin, collateralizationRatio sdk.Dec) AugmentedCDP

NewAugmentedCDP creates a new AugmentedCDP object

func (AugmentedCDP) String

func (augCDP AugmentedCDP) String() string

String implements fmt.stringer

type AugmentedCDPs

type AugmentedCDPs []AugmentedCDP

AugmentedCDPs a collection of AugmentedCDP objects

func (AugmentedCDPs) String

func (augcdps AugmentedCDPs) String() string

String implements stringer

type CDP

type CDP struct {
	ID              uint64         `json:"id" yaml:"id"`                             // unique id for cdp
	Owner           sdk.AccAddress `json:"owner" yaml:"owner"`                       // Account that authorizes changes to the CDP
	Type            string         `json:"type" yaml:"type"`                         // string representing the unique collateral type of the CDP
	Collateral      sdk.Coin       `json:"collateral" yaml:"collateral"`             // Amount of collateral stored in this CDP
	Principal       sdk.Coin       `json:"principal" yaml:"principal"`               // Amount of debt drawn using the CDP
	AccumulatedFees sdk.Coin       `json:"accumulated_fees" yaml:"accumulated_fees"` // Fees accumulated since the CDP was opened or debt was last repaid
	FeesUpdated     time.Time      `json:"fees_updated" yaml:"fees_updated"`         // The time when fees were last updated
	InterestFactor  sdk.Dec        `json:"interest_factor" yaml:"interest_factor"`   // the interest factor when fees were last calculated for this CDP
}

CDP is the state of a single collateralized debt position.

func NewCDP

func NewCDP(id uint64, owner sdk.AccAddress, collateral sdk.Coin, collateralType string, principal sdk.Coin, time time.Time, interestFactor sdk.Dec) CDP

NewCDP creates a new CDP object

func NewCDPWithFees added in v0.11.0

func NewCDPWithFees(id uint64, owner sdk.AccAddress, collateral sdk.Coin, collateralType string, principal, fees sdk.Coin, time time.Time, interestFactor sdk.Dec) CDP

NewCDPWithFees creates a new CDP object, for use during migration

func (CDP) GetNormalizedPrincipal added in v0.15.0

func (cdp CDP) GetNormalizedPrincipal() (sdk.Dec, error)

GetNormalizedPrincipal returns the total cdp principal divided by the interest factor.

Multiplying the normalized principal by the current global factor gives the current debt (ie including all interest, ie a synced cdp). The normalized principal is effectively how big the principal would have been if it had been borrowed at time 0 and not touched since.

An error is returned if the cdp interest factor is in an invalid state.

func (CDP) GetTotalPrincipal added in v0.11.0

func (cdp CDP) GetTotalPrincipal() sdk.Coin

GetTotalPrincipal returns the total principle for the cdp

func (CDP) String

func (cdp CDP) String() string

String implements fmt.stringer

func (CDP) Validate added in v0.8.0

func (cdp CDP) Validate() error

Validate performs a basic validation of the CDP fields.

type CDPHooks added in v0.13.0

type CDPHooks interface {
	AfterCDPCreated(ctx sdk.Context, cdp CDP)
	BeforeCDPModified(ctx sdk.Context, cdp CDP)
}

CDPHooks event hooks for other keepers to run code in response to CDP modifications

type CDPs

type CDPs []CDP

CDPs a collection of CDP objects

func (CDPs) String

func (cdps CDPs) String() string

String implements stringer

func (CDPs) Validate added in v0.8.0

func (cdps CDPs) Validate() error

Validate validates each CDP

type CollateralParam

type CollateralParam struct {
	Denom                            string   `json:"denom" yaml:"denom"` // Coin name of collateral type
	Type                             string   `json:"type" yaml:"type"`
	LiquidationRatio                 sdk.Dec  `json:"liquidation_ratio" yaml:"liquidation_ratio"`     // The ratio (Collateral (priced in stable coin) / Debt) under which a CDP will be liquidated
	DebtLimit                        sdk.Coin `json:"debt_limit" yaml:"debt_limit"`                   // Maximum amount of debt allowed to be drawn from this collateral type
	StabilityFee                     sdk.Dec  `json:"stability_fee" yaml:"stability_fee"`             // per second stability fee for loans opened using this collateral
	AuctionSize                      sdk.Int  `json:"auction_size" yaml:"auction_size"`               // Max amount of collateral to sell off in any one auction.
	LiquidationPenalty               sdk.Dec  `json:"liquidation_penalty" yaml:"liquidation_penalty"` // percentage penalty (between [0, 1]) applied to a cdp if it is liquidated
	Prefix                           byte     `json:"prefix" yaml:"prefix"`
	SpotMarketID                     string   `json:"spot_market_id" yaml:"spot_market_id"`                                           // marketID of the spot price of the asset from the pricefeed - used for opening CDPs, depositing, withdrawing
	LiquidationMarketID              string   `json:"liquidation_market_id" yaml:"liquidation_market_id"`                             // marketID of the pricefeed used for liquidation
	KeeperRewardPercentage           sdk.Dec  `json:"keeper_reward_percentage" yaml:"keeper_reward_percentage"`                       // the percentage of a CDPs collateral that gets rewarded to a keeper that liquidates the position
	CheckCollateralizationIndexCount sdk.Int  `json:"check_collateralization_index_count" yaml:"check_collateralization_index_count"` // the number of cdps that will be checked for liquidation in the begin blocker
	ConversionFactor                 sdk.Int  `json:"conversion_factor" yaml:"conversion_factor"`                                     // factor for converting internal units to one base unit of collateral
}

CollateralParam governance parameters for each collateral type within the cdp module

func NewCollateralParam added in v0.11.0

func NewCollateralParam(
	denom, ctype string, liqRatio sdk.Dec, debtLimit sdk.Coin, stabilityFee sdk.Dec, auctionSize sdk.Int,
	liqPenalty sdk.Dec, prefix byte, spotMarketID, liquidationMarketID string, keeperReward sdk.Dec, checkIndexCount sdk.Int, conversionFactor sdk.Int) CollateralParam

NewCollateralParam returns a new CollateralParam

func (CollateralParam) String

func (cp CollateralParam) String() string

String implements fmt.Stringer

type CollateralParams

type CollateralParams []CollateralParam

CollateralParams array of CollateralParam

func (CollateralParams) String

func (cps CollateralParams) String() string

String implements fmt.Stringer

type DebtParam

type DebtParam struct {
	Denom            string  `json:"denom" yaml:"denom"`
	ReferenceAsset   string  `json:"reference_asset" yaml:"reference_asset"`
	ConversionFactor sdk.Int `json:"conversion_factor" yaml:"conversion_factor"`
	DebtFloor        sdk.Int `json:"debt_floor" yaml:"debt_floor"` // minimum active loan size, used to prevent dust
}

DebtParam governance params for debt assets

func NewDebtParam added in v0.11.0

func NewDebtParam(denom, refAsset string, conversionFactor, debtFloor sdk.Int) DebtParam

NewDebtParam returns a new DebtParam

func (DebtParam) String

func (dp DebtParam) String() string

type DebtParams

type DebtParams []DebtParam

DebtParams array of DebtParam

func (DebtParams) String

func (dps DebtParams) String() string

String implements fmt.Stringer

type Deposit

type Deposit struct {
	CdpID     uint64         `json:"cdp_id" yaml:"cdp_id"`       //  cdpID of the cdp
	Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` //  Address of the depositor
	Amount    sdk.Coin       `json:"amount" yaml:"amount"`       //  Deposit amount
}

Deposit defines an amount of coins deposited by an account to a cdp

func NewDeposit

func NewDeposit(cdpID uint64, depositor sdk.AccAddress, amount sdk.Coin) Deposit

NewDeposit creates a new Deposit object

func (Deposit) Empty

func (d Deposit) Empty() bool

Empty returns whether a deposit is empty.

func (Deposit) Equals

func (d Deposit) Equals(comp Deposit) bool

Equals returns whether two deposits are equal.

func (Deposit) String

func (d Deposit) String() string

String implements fmt.Stringer

func (Deposit) Validate added in v0.8.0

func (d Deposit) Validate() error

Validate performs a basic validation of the deposit fields.

type Deposits

type Deposits []Deposit

Deposits a collection of Deposit objects

func (Deposits) String

func (ds Deposits) String() string

String implements fmt.Stringer

func (Deposits) SumCollateral

func (ds Deposits) SumCollateral() (sum sdk.Int)

SumCollateral returns the total amount of collateral in the input deposits

func (Deposits) Validate added in v0.8.0

func (ds Deposits) Validate() error

Validate validates each deposit

type GenesisAccumulationTime added in v0.13.0

type GenesisAccumulationTime struct {
	CollateralType           string    `json:"collateral_type" yaml:"collateral_type"`
	PreviousAccumulationTime time.Time `json:"previous_accumulation_time" yaml:"previous_accumulation_time"`
	InterestFactor           sdk.Dec   `json:"interest_factor" yaml:"interest_factor"`
}

GenesisAccumulationTime stores the previous distribution time and its corresponding denom

func NewGenesisAccumulationTime added in v0.13.0

func NewGenesisAccumulationTime(ctype string, prevTime time.Time, factor sdk.Dec) GenesisAccumulationTime

NewGenesisAccumulationTime returns a new GenesisAccumulationTime

func (GenesisAccumulationTime) Validate added in v0.13.0

func (gat GenesisAccumulationTime) Validate() error

Validate performs validation of GenesisAccumulationTime

type GenesisAccumulationTimes added in v0.13.0

type GenesisAccumulationTimes []GenesisAccumulationTime

GenesisAccumulationTimes slice of GenesisAccumulationTime

func (GenesisAccumulationTimes) Validate added in v0.13.0

func (gats GenesisAccumulationTimes) Validate() error

Validate performs validation of GenesisAccumulationTimes

type GenesisState

type GenesisState struct {
	Params                    Params                   `json:"params" yaml:"params"`
	CDPs                      CDPs                     `json:"cdps" yaml:"cdps"`
	Deposits                  Deposits                 `json:"deposits" yaml:"deposits"`
	StartingCdpID             uint64                   `json:"starting_cdp_id" yaml:"starting_cdp_id"`
	DebtDenom                 string                   `json:"debt_denom" yaml:"debt_denom"`
	GovDenom                  string                   `json:"gov_denom" yaml:"gov_denom"`
	PreviousAccumulationTimes GenesisAccumulationTimes `json:"previous_accumulation_times" yaml:"previous_accumulation_times"`
	TotalPrincipals           GenesisTotalPrincipals   `json:"total_principals" yaml:"total_principals"`
}

GenesisState is the state that must be provided at genesis.

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns a default genesis state

func NewGenesisState added in v0.5.0

func NewGenesisState(params Params, cdps CDPs, deposits Deposits, startingCdpID uint64,
	debtDenom, govDenom string, prevAccumTimes GenesisAccumulationTimes,
	totalPrincipals GenesisTotalPrincipals) GenesisState

NewGenesisState returns a new genesis state

func (GenesisState) Equal

func (gs GenesisState) Equal(gs2 GenesisState) bool

Equal checks whether two gov GenesisState structs are equivalent

func (GenesisState) IsEmpty

func (gs GenesisState) IsEmpty() bool

IsEmpty returns true if a GenesisState is empty

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic validation of genesis data returning an error for any failed validation criteria.

type GenesisTotalPrincipal added in v0.13.0

type GenesisTotalPrincipal struct {
	CollateralType string  `json:"collateral_type" yaml:"collateral_type"`
	TotalPrincipal sdk.Int `json:"total_principal" yaml:"total_principal"`
}

GenesisTotalPrincipal stores the total principal and its corresponding collateral type

func NewGenesisTotalPrincipal added in v0.13.0

func NewGenesisTotalPrincipal(ctype string, principal sdk.Int) GenesisTotalPrincipal

NewGenesisTotalPrincipal returns a new GenesisTotalPrincipal

func (GenesisTotalPrincipal) Validate added in v0.13.0

func (gtp GenesisTotalPrincipal) Validate() error

Validate performs validation of GenesisTotalPrincipal

type GenesisTotalPrincipals added in v0.13.0

type GenesisTotalPrincipals []GenesisTotalPrincipal

GenesisTotalPrincipals slice of GenesisTotalPrincipal

func (GenesisTotalPrincipals) Validate added in v0.13.0

func (gtps GenesisTotalPrincipals) Validate() error

Validate performs validation of GenesisTotalPrincipals

type MsgCreateCDP

type MsgCreateCDP struct {
	Sender         sdk.AccAddress `json:"sender" yaml:"sender"`
	Collateral     sdk.Coin       `json:"collateral" yaml:"collateral"`
	Principal      sdk.Coin       `json:"principal" yaml:"principal"`
	CollateralType string         `json:"collateral_type" yaml:"collateral_type"`
}

MsgCreateCDP creates a cdp

func NewMsgCreateCDP

func NewMsgCreateCDP(sender sdk.AccAddress, collateral sdk.Coin, principal sdk.Coin, collateralType string) MsgCreateCDP

NewMsgCreateCDP returns a new MsgPlaceBid.

func (MsgCreateCDP) GetSignBytes

func (msg MsgCreateCDP) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgCreateCDP) GetSigners

func (msg MsgCreateCDP) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgCreateCDP) Route

func (msg MsgCreateCDP) Route() string

Route return the message type used for routing the message.

func (MsgCreateCDP) String

func (msg MsgCreateCDP) String() string

String implements the Stringer interface

func (MsgCreateCDP) Type

func (msg MsgCreateCDP) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgCreateCDP) ValidateBasic

func (msg MsgCreateCDP) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgDeposit

type MsgDeposit struct {
	Depositor      sdk.AccAddress `json:"depositor" yaml:"depositor"`
	Owner          sdk.AccAddress `json:"owner" yaml:"owner"`
	Collateral     sdk.Coin       `json:"collateral" yaml:"collateral"`
	CollateralType string         `json:"collateral_type" yaml:"collateral_type"`
}

MsgDeposit deposit collateral to an existing cdp.

func NewMsgDeposit

func NewMsgDeposit(owner sdk.AccAddress, depositor sdk.AccAddress, collateral sdk.Coin, collateralType string) MsgDeposit

NewMsgDeposit returns a new MsgDeposit

func (MsgDeposit) GetSignBytes

func (msg MsgDeposit) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgDeposit) GetSigners

func (msg MsgDeposit) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgDeposit) Route

func (msg MsgDeposit) Route() string

Route return the message type used for routing the message.

func (MsgDeposit) String

func (msg MsgDeposit) String() string

String implements the Stringer interface

func (MsgDeposit) Type

func (msg MsgDeposit) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgDeposit) ValidateBasic

func (msg MsgDeposit) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgDrawDebt

type MsgDrawDebt struct {
	Sender         sdk.AccAddress `json:"sender" yaml:"sender"`
	CollateralType string         `json:"collateral_type" yaml:"collateral_type"`
	Principal      sdk.Coin       `json:"principal" yaml:"principal"`
}

MsgDrawDebt draw debt off of collateral in cdp

func NewMsgDrawDebt

func NewMsgDrawDebt(sender sdk.AccAddress, collateralType string, principal sdk.Coin) MsgDrawDebt

NewMsgDrawDebt returns a new MsgDrawDebt

func (MsgDrawDebt) GetSignBytes

func (msg MsgDrawDebt) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgDrawDebt) GetSigners

func (msg MsgDrawDebt) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgDrawDebt) Route

func (msg MsgDrawDebt) Route() string

Route return the message type used for routing the message.

func (MsgDrawDebt) String

func (msg MsgDrawDebt) String() string

String implements the Stringer interface

func (MsgDrawDebt) Type

func (msg MsgDrawDebt) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgDrawDebt) ValidateBasic

func (msg MsgDrawDebt) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgLiquidate added in v0.13.0

type MsgLiquidate struct {
	Keeper         sdk.AccAddress `json:"keeper" yaml:"keeper"`
	Borrower       sdk.AccAddress `json:"borrower" yaml:"borrower"`
	CollateralType string         `json:"collateral_type" yaml:"collateral_type"`
}

MsgLiquidate attempts to liquidate a borrower's cdp

func NewMsgLiquidate added in v0.13.0

func NewMsgLiquidate(keeper, borrower sdk.AccAddress, ctype string) MsgLiquidate

NewMsgLiquidate returns a new MsgLiquidate

func (MsgLiquidate) GetSignBytes added in v0.13.0

func (msg MsgLiquidate) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgLiquidate) GetSigners added in v0.13.0

func (msg MsgLiquidate) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgLiquidate) Route added in v0.13.0

func (msg MsgLiquidate) Route() string

Route return the message type used for routing the message.

func (MsgLiquidate) String added in v0.13.0

func (msg MsgLiquidate) String() string

String implements the Stringer interface

func (MsgLiquidate) Type added in v0.13.0

func (msg MsgLiquidate) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgLiquidate) ValidateBasic added in v0.13.0

func (msg MsgLiquidate) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgRepayDebt

type MsgRepayDebt struct {
	Sender         sdk.AccAddress `json:"sender" yaml:"sender"`
	CollateralType string         `json:"collateral_type" yaml:"collateral_type"`
	Payment        sdk.Coin       `json:"payment" yaml:"payment"`
}

MsgRepayDebt repay debt drawn off the collateral in a CDP

func NewMsgRepayDebt

func NewMsgRepayDebt(sender sdk.AccAddress, collateralType string, payment sdk.Coin) MsgRepayDebt

NewMsgRepayDebt returns a new MsgRepayDebt

func (MsgRepayDebt) GetSignBytes

func (msg MsgRepayDebt) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgRepayDebt) GetSigners

func (msg MsgRepayDebt) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgRepayDebt) Route

func (msg MsgRepayDebt) Route() string

Route return the message type used for routing the message.

func (MsgRepayDebt) String

func (msg MsgRepayDebt) String() string

String implements the Stringer interface

func (MsgRepayDebt) Type

func (msg MsgRepayDebt) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgRepayDebt) ValidateBasic

func (msg MsgRepayDebt) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgWithdraw

type MsgWithdraw struct {
	Depositor      sdk.AccAddress `json:"depositor" yaml:"depositor"`
	Owner          sdk.AccAddress `json:"owner" yaml:"owner"`
	Collateral     sdk.Coin       `json:"collateral" yaml:"collateral"`
	CollateralType string         `json:"collateral_type" yaml:"collateral_type"`
}

MsgWithdraw withdraw collateral from an existing cdp.

func NewMsgWithdraw

func NewMsgWithdraw(owner sdk.AccAddress, depositor sdk.AccAddress, collateral sdk.Coin, collateralType string) MsgWithdraw

NewMsgWithdraw returns a new MsgDeposit

func (MsgWithdraw) GetSignBytes

func (msg MsgWithdraw) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgWithdraw) GetSigners

func (msg MsgWithdraw) GetSigners() []sdk.AccAddress

GetSigners returns the addresses of signers that must sign.

func (MsgWithdraw) Route

func (msg MsgWithdraw) Route() string

Route return the message type used for routing the message.

func (MsgWithdraw) String

func (msg MsgWithdraw) String() string

String implements the Stringer interface

func (MsgWithdraw) Type

func (msg MsgWithdraw) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgWithdraw) ValidateBasic

func (msg MsgWithdraw) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MultiCDPHooks added in v0.13.0

type MultiCDPHooks []CDPHooks

MultiCDPHooks combine multiple cdp hooks, all hook functions are run in array sequence

func NewMultiCDPHooks added in v0.13.0

func NewMultiCDPHooks(hooks ...CDPHooks) MultiCDPHooks

NewMultiCDPHooks returns a new MultiCDPHooks

func (MultiCDPHooks) AfterCDPCreated added in v0.13.0

func (h MultiCDPHooks) AfterCDPCreated(ctx sdk.Context, cdp CDP)

AfterCDPCreated runs before a cdp is created

func (MultiCDPHooks) BeforeCDPModified added in v0.13.0

func (h MultiCDPHooks) BeforeCDPModified(ctx sdk.Context, cdp CDP)

BeforeCDPModified runs before a cdp is modified

type Params

type Params struct {
	CollateralParams        CollateralParams `json:"collateral_params" yaml:"collateral_params"`
	DebtParam               DebtParam        `json:"debt_param" yaml:"debt_param"`
	GlobalDebtLimit         sdk.Coin         `json:"global_debt_limit" yaml:"global_debt_limit"`
	SurplusAuctionThreshold sdk.Int          `json:"surplus_auction_threshold" yaml:"surplus_auction_threshold"`
	SurplusAuctionLot       sdk.Int          `json:"surplus_auction_lot" yaml:"surplus_auction_lot"`
	DebtAuctionThreshold    sdk.Int          `json:"debt_auction_threshold" yaml:"debt_auction_threshold"`
	DebtAuctionLot          sdk.Int          `json:"debt_auction_lot" yaml:"debt_auction_lot"`
	CircuitBreaker          bool             `json:"circuit_breaker" yaml:"circuit_breaker"`
}

Params governance parameters for cdp module

func DefaultParams

func DefaultParams() Params

DefaultParams returns default params for cdp module

func NewParams

func NewParams(
	debtLimit sdk.Coin, collateralParams CollateralParams, debtParam DebtParam, surplusThreshold,
	surplusLot, debtThreshold, debtLot sdk.Int, breaker bool,
) Params

NewParams returns a new params object

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of auth module's parameters. nolint

func (Params) String

func (p Params) String() string

String implements fmt.Stringer

func (Params) Validate

func (p Params) Validate() error

Validate checks that the parameters have valid values.

type PricefeedKeeper

type PricefeedKeeper interface {
	GetCurrentPrice(sdk.Context, string) (pftypes.CurrentPrice, error)
	GetParams(sdk.Context) pftypes.Params
	// These are used for testing TODO replace mockApp with keeper in tests to remove these
	SetParams(sdk.Context, pftypes.Params)
	SetPrice(sdk.Context, sdk.AccAddress, string, sdk.Dec, time.Time) (pftypes.PostedPrice, error)
	SetCurrentPrices(sdk.Context, string) error
}

PricefeedKeeper defines the expected interface for the pricefeed (noalias)

type QueryCdpDeposits

type QueryCdpDeposits struct {
	CollateralType string         // get CDPs with this collateral type
	Owner          sdk.AccAddress // get CDPs belonging to this owner
}

QueryCdpDeposits params for query /cdp/deposits

func NewQueryCdpDeposits

func NewQueryCdpDeposits(owner sdk.AccAddress, collateralType string) QueryCdpDeposits

NewQueryCdpDeposits returns QueryCdpDeposits

type QueryCdpParams

type QueryCdpParams struct {
	CollateralType string         // get CDPs with this collateral type
	Owner          sdk.AccAddress // get CDPs belonging to this owner
}

QueryCdpParams params for query /cdp/cdp

func NewQueryCdpParams

func NewQueryCdpParams(owner sdk.AccAddress, collateralType string) QueryCdpParams

NewQueryCdpParams returns QueryCdpParams

type QueryCdpsByCollateralTypeParams added in v0.11.0

type QueryCdpsByCollateralTypeParams struct {
	CollateralType string // get CDPs with this collateral type
}

QueryCdpsByCollateralTypeParams params for query /cdp/cdps/{denom}

func NewQueryCdpsByCollateralTypeParams added in v0.11.0

func NewQueryCdpsByCollateralTypeParams(collateralType string) QueryCdpsByCollateralTypeParams

NewQueryCdpsByCollateralTypeParams returns QueryCdpsByCollateralTypeParams

type QueryCdpsByRatioParams

type QueryCdpsByRatioParams struct {
	CollateralType string
	Ratio          sdk.Dec // get CDPs below this collateral:debt ratio
}

QueryCdpsByRatioParams params for query /cdp/cdps/ratio

func NewQueryCdpsByRatioParams

func NewQueryCdpsByRatioParams(collateralType string, ratio sdk.Dec) QueryCdpsByRatioParams

NewQueryCdpsByRatioParams returns QueryCdpsByRatioParams

type QueryCdpsParams

type QueryCdpsParams struct {
	Page           int            `json:"page" yaml:"page"`
	Limit          int            `json:"limit" yaml:"limit"`
	CollateralType string         `json:"collateral_type" yaml:"collateral_type"`
	Owner          sdk.AccAddress `json:"owner" yaml:"owner"`
	ID             uint64         `json:"id" yaml:"id"`
	Ratio          sdk.Dec        `json:"ratio" yaml:"ratio"`
}

QueryCdpsParams is the params for a filtered CDP query

func NewQueryCdpsParams

func NewQueryCdpsParams(page, limit int, collateralType string, owner sdk.AccAddress, id uint64, ratio sdk.Dec) QueryCdpsParams

NewQueryCdpsParams creates a new QueryCdpsParams

type SupplyKeeper

type SupplyKeeper interface {
	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, name string) supplyexported.ModuleAccountI

	// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
	SetModuleAccount(sdk.Context, supplyexported.ModuleAccountI)

	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
	BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error
	MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
	GetSupply(ctx sdk.Context) (supply supplyexported.SupplyI)
}

SupplyKeeper defines the expected supply keeper for module accounts (noalias)

Jump to

Keyboard shortcuts

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