types

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

noalias

Index

Constants

View Source
const (
	EventSwap = "swap"

	AttributeKeyOffer     = "offer"
	AttributeKeyTrader    = "trader"
	AttributeKeyRecipient = "recipient"
	AttributeKeySwapCoin  = "swap_coin"
	AttributeKeySwapFee   = "swap_fee"

	AttributeValueCategory = ModuleName
)

Market module event types

View Source
const (
	// ModuleName is the name of the market module
	ModuleName = "market"

	// StoreKey is the string store representation
	StoreKey = ModuleName

	// RouterKey is the msg router key for the market module
	RouterKey = ModuleName

	// QuerierRoute is the query router key for the market module
	QuerierRoute = ModuleName
)
View Source
const (
	QuerySwap           = "swap"
	QueryTerraPoolDelta = "terra_pool_delta"
	QueryParameters     = "parameters"
)

query endpoints supported by the oracle Querier

View Source
const DefaultParamspace = ModuleName

DefaultParamspace nolint

Variables

View Source
var (
	ErrNoEffectivePrice = sdkerrors.Register(ModuleName, 1, "no price registered with oracle")
	ErrInvalidOfferCoin = sdkerrors.Register(ModuleName, 2, "invalid offer coin")
	ErrRecursiveSwap    = sdkerrors.Register(ModuleName, 3, "recursive swap")
)

Market errors

View Source
var (
	//Terra liquidity pool(usdr unit) made available per ${poolrecoveryperiod} (usdr unit)
	ParamStoreKeyBasePool = []byte("basepool")
	// The period required to recover BasePool
	ParamStoreKeyPoolRecoveryPeriod = []byte("poolrecoveryperiod")
	// Min spread
	ParamStoreKeyMinStabilitySpread = []byte("minstabilityspread")
)

Parameter keys

View Source
var (
	DefaultBasePool           = sdk.NewDec(250000 * core.MicroUnit) // 250,000sdr = 250,000,000,000usdr
	DefaultPoolRecoveryPeriod = core.BlocksPerDay                   // 14,400
	DefaultMinStabilitySpread = sdk.NewDecWithPrec(2, 2)            // 2%
)

Default parameter values

View Source
var ModuleCdc = codec.New()

ModuleCdc defines internal Module Codec

View Source
var (
	//Keys for store prefixed
	TerraPoolDeltaKey = []byte{0x01} // key for Terra pool delta which gap between TerraPool from BasePool
)

Keys for market store Items are stored with the following key: values

- 0x01: sdk.Dec

Functions

func ParamKeyTable added in v0.4.0

func ParamKeyTable() params.KeyTable

ParamKeyTable returns the parameter key table.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec concretes types on codec codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided oracle genesis state to ensure the expected invariants holds. (i.e. params in correct bounds, no duplicate validators)

Types

type GenesisState

type GenesisState struct {
	TerraPoolDelta sdk.Dec `json:"terra_pool_delta" yaml:"terra_pool_delta"`
	Params         Params  `json:"params" yaml:"params"` // market params
}

GenesisState - all market state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(terraPoolDelta sdk.Dec, params Params) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Equal

func (data GenesisState) Equal(data2 GenesisState) bool

Equal checks whether 2 GenesisState structs are equivalent.

func (GenesisState) IsEmpty

func (data GenesisState) IsEmpty() bool

IsEmpty returns if a GenesisState is empty or has data in it

type MsgSwap

type MsgSwap struct {
	Trader    sdk.AccAddress `json:"trader" yaml:"trader"`         // Address of the trader
	OfferCoin sdk.Coin       `json:"offer_coin" yaml:"offer_coin"` // Coin being offered
	AskDenom  string         `json:"ask_denom" yaml:"ask_denom"`   // Denom of the coin to swap to
}

MsgSwap contains a swap request

func NewMsgSwap

func NewMsgSwap(traderAddress sdk.AccAddress, offerCoin sdk.Coin, askCoin string) MsgSwap

NewMsgSwap creates a MsgSwap instance

func (MsgSwap) GetSignBytes

func (msg MsgSwap) GetSignBytes() []byte

GetSignBytes Implements Msg

func (MsgSwap) GetSigners

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

GetSigners Implements Msg

func (MsgSwap) Route

func (msg MsgSwap) Route() string

Route Implements Msg

func (MsgSwap) String

func (msg MsgSwap) String() string

String implements fmt.Stringer interface

func (MsgSwap) Type

func (msg MsgSwap) Type() string

Type implements sdk.Msg

func (MsgSwap) ValidateBasic

func (msg MsgSwap) ValidateBasic() error

ValidateBasic Implements Msg

type MsgSwapSend added in v0.4.0

type MsgSwapSend struct {
	FromAddress sdk.AccAddress `json:"from_address" yaml:"from_address"` // Address of the offer coin payer
	ToAddress   sdk.AccAddress `json:"to_address" yaml:"to_address"`     // Address of the recipient
	OfferCoin   sdk.Coin       `json:"offer_coin" yaml:"offer_coin"`     // Coin being offered
	AskDenom    string         `json:"ask_denom" yaml:"ask_denom"`       // Denom of the coin to swap to
}

MsgSwapSend contains a swap request

func NewMsgSwapSend added in v0.4.0

func NewMsgSwapSend(fromAddress sdk.AccAddress, toAddress sdk.AccAddress, offerCoin sdk.Coin, askCoin string) MsgSwapSend

NewMsgSwapSend conducts market swap and send all the result coins to recipient

func (MsgSwapSend) GetSignBytes added in v0.4.0

func (msg MsgSwapSend) GetSignBytes() []byte

GetSignBytes Implements Msg

func (MsgSwapSend) GetSigners added in v0.4.0

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

GetSigners Implements Msg

func (MsgSwapSend) Route added in v0.4.0

func (msg MsgSwapSend) Route() string

Route Implements Msg

func (MsgSwapSend) String added in v0.4.0

func (msg MsgSwapSend) String() string

String implements fmt.Stringer interface

func (MsgSwapSend) Type added in v0.4.0

func (msg MsgSwapSend) Type() string

Type implements sdk.Msg

func (MsgSwapSend) ValidateBasic added in v0.4.0

func (msg MsgSwapSend) ValidateBasic() error

ValidateBasic Implements Msg

type OracleKeeper

type OracleKeeper interface {
	GetLunaExchangeRate(ctx sdk.Context, denom string) (price sdk.Dec, err error)
	GetTobinTax(ctx sdk.Context, denom string) (tobinTax sdk.Dec, err error)
}

OracleKeeper defines expected oracle keeper

type Params

type Params struct {
	BasePool           sdk.Dec `json:"base_pool" yaml:"base_pool"`
	PoolRecoveryPeriod int64   `json:"pool_recovery_period" yaml:"pool_recovery_period"`
	MinStabilitySpread sdk.Dec `json:"min_spread" yaml:"min_spread"`
}

Params market parameters

func DefaultParams

func DefaultParams() Params

DefaultParams creates default market module parameters

func (*Params) ParamSetPairs

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

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

func (Params) String

func (p Params) String() string

String implements fmt.Stringer interface

func (Params) ValidateBasic added in v0.4.0

func (p Params) ValidateBasic() error

ValidateBasic a set of params

type QuerySwapParams

type QuerySwapParams struct {
	OfferCoin sdk.Coin `json:"offer_coin"`
	AskDenom  string   `json:"ask_denom"`
}

QuerySwapParams for query - 'custom/market/swap'

func NewQuerySwapParams

func NewQuerySwapParams(offerCoin sdk.Coin, askDenom string) QuerySwapParams

NewQuerySwapParams returns param object for swap query

type SupplyKeeper

type SupplyKeeper interface {
	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, moduleName string) supplyexported.ModuleAccountI
	GetSupply(ctx sdk.Context) (supply supplyexported.SupplyI)
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error
	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

	BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error
	MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error
}

SupplyKeeper defines expected supply keeper

type TobinTax

type TobinTax struct {
	Denom   string  `json:"denom" yaml:"denom"`
	TaxRate sdk.Dec `json:"tax_rate" yaml:"tax_rate"`
}

TobinTax - struct to store tobin tax for the specific denom with high volatility

func (TobinTax) String

func (tt TobinTax) String() string

String implements fmt.Stringer interface

type TobinTaxList

type TobinTaxList []TobinTax

TobinTaxList is convience wrapper to handle TobinTax array

func (TobinTaxList) String

func (ttl TobinTaxList) String() string

String implements fmt.Stringer interface

Jump to

Keyboard shortcuts

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