market

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

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 oracle module
	QuerierRoute = ModuleName

	// DefaultParamspace is for the paramspace notation
	DefaultParamspace = ModuleName
)
View Source
const (
	DefaultCodespace sdk.CodespaceType = "market"

	CodeInsufficientSwap sdk.CodeType = 1
	CodeNoEffectivePrice sdk.CodeType = 2
	CodeRecursiveSwap    sdk.CodeType = 3
	CodeExceedsSwapLimit sdk.CodeType = 4
)

market error codes

View Source
const (
	// LogKeySwapCoin is the amount of swapped coin
	LogKeySwapCoin = string("swap_coin")
	// LogKeySwapFee is the fee for swap operation
	LogKeySwapFee = string("swap_fee")
)
View Source
const (
	QuerySwap   = "swap"
	QueryParams = "params"
)

query endpoints supported by the oracle Querier

Variables

This section is empty.

Functions

func ErrExceedsDailySwapLimit added in v0.1.1

func ErrExceedsDailySwapLimit(codespace sdk.CodespaceType) sdk.Error

ErrExceedsDailySwapLimit called when the coin swap exceeds the daily swap limit for Luna

func ErrInsufficientSwapCoins

func ErrInsufficientSwapCoins(codespace sdk.CodespaceType, rval sdk.Int) sdk.Error

ErrInsufficientSwapCoins called when not enough coins are being requested for a swap

func ErrNoEffectivePrice added in v0.0.5

func ErrNoEffectivePrice(codespace sdk.CodespaceType, denom string) sdk.Error

ErrNoEffectivePrice called when a price for the asset is not registered with the oracle

func ErrRecursiveSwap

func ErrRecursiveSwap(codespace sdk.CodespaceType, denom string) sdk.Error

ErrRecursiveSwap called when Ask and Offer coin denominatioins are equal

func InitGenesis added in v0.1.1

func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)

new oracle genesis

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler creates a new handler for all market type messages.

func NewQuerier added in v0.2.0

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func RegisterCodec added in v0.0.5

func RegisterCodec(cdc *codec.Codec)

RegisterCodec concretes types on codec codec

func ValidateGenesis added in v0.1.1

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 added in v0.1.1

type GenesisState struct {
	Params Params `json:"params"` // market params
}

GenesisState - all distribution state that must be provided at genesis

func DefaultGenesisState added in v0.1.1

func DefaultGenesisState() GenesisState

get raw genesis raw message for testing

func ExportGenesis added in v0.1.1

func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState

ExportGenesis returns a GenesisState for a given context and keeper. The GenesisState will contain the pool, and validator/delegator distribution info's

func NewGenesisState added in v0.1.1

func NewGenesisState(params Params) GenesisState

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper holds data structures for the market module

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, ok OracleKeeper, mk MintKeeper, paramspace params.Subspace) Keeper

NewKeeper creates a new Keeper for the market module

func (Keeper) ComputeLunaDelta added in v0.2.0

func (k Keeper) ComputeLunaDelta(ctx sdk.Context, change sdk.Int) sdk.Dec

ComputeLunaDelta returns the issuance rate change of Luna for the day post-swap

func (Keeper) GetParams added in v0.1.1

func (k Keeper) GetParams(ctx sdk.Context) Params

GetParams get budget params from the global param store

func (Keeper) GetSwapCoin added in v0.2.0

func (k Keeper) GetSwapCoin(ctx sdk.Context, offerCoin sdk.Coin, askDenom string, isInternal bool) (retCoin sdk.Coin, spread sdk.Dec, err sdk.Error)

GetSwapCoin returns the amount of asked coins should be returned for a given offerCoin at the effective exchange rate registered with the oracle. Returns an Error if the swap is recursive, or the coins to be traded are unknown by the oracle, or the amount to trade is too small. Ignores caps and spreads if isInternal = true.

func (Keeper) GetSwapDecCoin added in v0.2.0

func (k Keeper) GetSwapDecCoin(ctx sdk.Context, offerCoin sdk.DecCoin, askDenom string) (sdk.DecCoin, sdk.Error)

GetSwapDecCoin returns the amount of asked DecCoins should be returned for a given offerCoin at the effective exchange rate registered with the oracle. Different from swapcoins, SwapDecCoins does not charge a spread as its use is system internal. Similar to SwapCoins, but operates over sdk.DecCoins for convenience and accuracy.

func (Keeper) SetParams added in v0.1.1

func (k Keeper) SetParams(ctx sdk.Context, params Params)

SetParams set budget params from the global param store

type Log added in v0.2.0

type Log map[string]string

Log is map type object to organize msg result

func NewLog added in v0.2.0

func NewLog() Log

func (Log) String added in v0.2.0

func (log Log) String() string

type MintKeeper added in v0.2.0

type MintKeeper interface {
	Mint(ctx sdk.Context, recipient sdk.AccAddress, coin sdk.Coin) (err sdk.Error)
	Burn(ctx sdk.Context, payer sdk.AccAddress, coin sdk.Coin) (err sdk.Error)
	GetIssuance(ctx sdk.Context, denom string, day sdk.Int) (issuance sdk.Int)
}

expected mint keeper

type MsgSwap added in v0.0.7

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

MsgSwap contains a swap request

func NewMsgSwap added in v0.0.7

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

NewMsgSwap creates a MsgSwap instance

func (MsgSwap) GetSignBytes added in v0.0.7

func (msg MsgSwap) GetSignBytes() []byte

GetSignBytes Implements Msg

func (MsgSwap) GetSigners added in v0.0.7

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

GetSigners Implements Msg

func (MsgSwap) Route added in v0.0.7

func (msg MsgSwap) Route() string

Route Implements Msg

func (MsgSwap) String added in v0.0.7

func (msg MsgSwap) String() string

String Implements Msg

func (MsgSwap) Type added in v0.0.7

func (msg MsgSwap) Type() string

Type implements sdk.Msg

func (MsgSwap) ValidateBasic added in v0.0.7

func (msg MsgSwap) ValidateBasic() sdk.Error

ValidateBasic Implements Msg

type OracleKeeper added in v0.2.0

type OracleKeeper interface {
	AddSwapFeePool(ctx sdk.Context, fees sdk.Coins)
	GetLunaSwapRate(ctx sdk.Context, denom string) (price sdk.Dec, err sdk.Error)
}

expected oracle keeper

type Params added in v0.1.1

type Params struct {
	DailyLunaDeltaCap sdk.Dec `json:"daily_luna_delta_limit"` // daily % inflation or deflation cap on Luna
	MinSwapSpread     sdk.Dec `json:"min_swap_spread"`        // minimum spread for swaps involving Luna
	MaxSwapSpread     sdk.Dec `json:"max_swap_spread"`        // maximum spread for swaps involving Luna
}

Params market parameters

func DefaultParams added in v0.1.1

func DefaultParams() Params

DefaultParams creates default market module parameters

func NewParams added in v0.1.1

func NewParams(dailyLunaDeltaCap, minSwapSpread, maxSwapSpread sdk.Dec) Params

NewParams creates a new param instance

func (Params) String added in v0.1.1

func (params Params) String() string

type QuerySwapParams added in v0.2.0

type QuerySwapParams struct {
	OfferCoin sdk.Coin
}

QuerySwapParams for query 'custom/market/swap'

func NewQuerySwapParams added in v0.2.0

func NewQuerySwapParams(offerCoin sdk.Coin) QuerySwapParams

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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