Documentation ¶
Overview ¶
noalias
Index ¶
Constants ¶
const ( EventSwap = "swap" AttributeKeyOffer = "offer" AttributeKeyTrader = "trader" AttributeKeyRecipient = "recipient" AttributeKeySwapCoin = "swap_coin" AttributeKeySwapFee = "swap_fee" AttributeValueCategory = ModuleName )
Market module event types
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 )
const ( QuerySwap = "swap" QueryTerraPoolDelta = "terra_pool_delta" QueryParameters = "parameters" )
query endpoints supported by the oracle Querier
const DefaultParamspace = ModuleName
DefaultParamspace nolint
Variables ¶
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
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
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
var ModuleCdc = codec.New()
ModuleCdc defines internal Module Codec
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
ParamKeyTable returns the parameter key table.
func RegisterCodec ¶
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 ¶
NewMsgSwap creates a MsgSwap instance
func (MsgSwap) GetSigners ¶
func (msg MsgSwap) GetSigners() []sdk.AccAddress
GetSigners Implements Msg
func (MsgSwap) ValidateBasic ¶
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) ValidateBasic ¶ added in v0.4.0
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
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