v0_13

package
v0.14.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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)
	DefaultSavingsRateDistributed = sdk.NewInt(0)
)

Parameter keys

Functions

This section is empty.

Types

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

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

func (cdp CDP) GetTotalPrincipal() sdk.Coin

GetTotalPrincipal returns the total principle for the cdp

func (CDP) Validate

func (cdp CDP) Validate() error

Validate performs a basic validation of the CDP fields.

type CDPs

type CDPs []CDP

CDPs a collection of CDP objects

func (CDPs) Validate

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

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

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

NewDebtParam returns a new DebtParam

type DebtParams

type DebtParams []DebtParam

DebtParams array of DebtParam

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

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

func (ds Deposits) Validate() error

Validate validates each deposit

type GenesisAccumulationTime

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

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

NewGenesisAccumulationTime returns a new GenesisAccumulationTime

func (GenesisAccumulationTime) Validate

func (gat GenesisAccumulationTime) Validate() error

Validate performs validation of GenesisAccumulationTime

type GenesisAccumulationTimes

type GenesisAccumulationTimes []GenesisAccumulationTime

GenesisAccumulationTimes slice of GenesisAccumulationTime

func (GenesisAccumulationTimes) Validate

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 NewGenesisState

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

func (gs GenesisState) Validate() error

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

type GenesisTotalPrincipal

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

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

NewGenesisTotalPrincipal returns a new GenesisTotalPrincipal

func (GenesisTotalPrincipal) Validate

func (gtp GenesisTotalPrincipal) Validate() error

Validate performs validation of GenesisTotalPrincipal

type GenesisTotalPrincipals

type GenesisTotalPrincipals []GenesisTotalPrincipal

GenesisTotalPrincipals slice of GenesisTotalPrincipal

func (GenesisTotalPrincipals) Validate

func (gtps GenesisTotalPrincipals) Validate() error

Validate performs validation of GenesisTotalPrincipals

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

func (p Params) Validate() error

Validate checks that the parameters have valid values.

Jump to

Keyboard shortcuts

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