v0_11

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: 7 Imported by: 0

Documentation

Index

Constants

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"

	// SavingsRateMacc module account for savings rate
	SavingsRateMacc = "savings"
)

Variables

View Source
var (
	KeyGlobalDebtLimit        = []byte("GlobalDebtLimit")
	KeyCollateralParams       = []byte("CollateralParams")
	KeyDebtParam              = []byte("DebtParam")
	KeyDistributionFrequency  = []byte("DistributionFrequency")
	KeyCircuitBreaker         = []byte("CircuitBreaker")
	KeyDebtThreshold          = []byte("DebtThreshold")
	KeyDebtLot                = []byte("DebtLot")
	KeySurplusThreshold       = []byte("SurplusThreshold")
	KeySurplusLot             = []byte("SurplusLot")
	KeySavingsRateDistributed = []byte("SavingsRateDistributed")
	DefaultGlobalDebt         = sdk.NewCoin(DefaultStableDenom, sdk.ZeroInt())
	DefaultCircuitBreaker     = false
	DefaultCollateralParams   = CollateralParams{}
	DefaultDebtParam          = DebtParam{
		Denom:            "usdx",
		ReferenceAsset:   "usd",
		ConversionFactor: sdk.NewInt(6),
		DebtFloor:        sdk.NewInt(10000000),
		SavingsRate:      sdk.MustNewDecFromStr("0.95"),
	}
	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)
	DefaultPreviousDistributionTime     = tmtime.Canonical(time.Unix(0, 0))
	DefaultSavingsDistributionFrequency = time.Hour * 12
	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"`
	Collateral      sdk.Coin       `json:"collateral" yaml:"collateral"` // Amount of collateral stored in this CDP
	Principal       sdk.Coin       `json:"principal" yaml:"principal"`
	AccumulatedFees sdk.Coin       `json:"accumulated_fees" yaml:"accumulated_fees"`
	FeesUpdated     time.Time      `json:"fees_updated" yaml:"fees_updated"` // Amount of stable coin drawn from 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, fees sdk.Coin, time time.Time) CDP

NewCDP creates a new CDP object

func NewCDPWithFees added in v0.13.0

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

NewCDPWithFees creates a new CDP object, for use during migration

func (CDP) String

func (cdp CDP) String() string

String implements fmt.stringer

func (CDP) Validate

func (cdp CDP) Validate() error

Validate performs stateless validation of cdp object state

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
	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, 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
	SavingsRate      sdk.Dec `json:"savings_rate" yaml:"savings_rate"` // the percentage of stability fees that are redirected to savings rate
}

DebtParam governance params for debt assets

func NewDebtParam

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

NewDebtParam returns a new DebtParam

func (DebtParam) String

func (dp DebtParam) String() string

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 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"`
	PreviousDistributionTime time.Time `json:"previous_distribution_time" yaml:"previous_distribution_time"`
	SavingsRateDistributed   sdk.Int   `json:"savings_rate_distributed" yaml:"savings_rate_distributed"`
}

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, previousDistTime time.Time, savingsRateDist sdk.Int) 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 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"`
	SavingsDistributionFrequency time.Duration    `json:"savings_distribution_frequency" yaml:"savings_distribution_frequency"`
	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, distributionFreq time.Duration, breaker bool,
) Params

NewParams returns a new params object

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.

Jump to

Keyboard shortcuts

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