market

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2019 License: Apache-2.0 Imports: 21 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

	// 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

Variables

This section is empty.

Functions

func ErrExceedsDailySwapLimit added in v0.1.1

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

ErrExceedsDailySwapLimit called when the coin swap exceeds the daily swap limit

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 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(ok oracle.Keeper, mk mint.Keeper, paramspace params.Subspace) Keeper

NewKeeper creates a new Keeper for the market module

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

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

SetParams set budget params from the global param store

func (Keeper) SwapCoins

func (k Keeper) SwapCoins(ctx sdk.Context, offerCoin sdk.Coin, askDenom string) (sdk.Coin, sdk.Error)

SwapCoins 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.

func (Keeper) SwapDecCoins added in v0.0.5

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

SwapDecCoins returns the amount of asked DecCoins should be returned for a given offerCoin at the effective exchange rate registered with the oracle. Similar to SwapCoins, but operates over sdk.DecCoins for convinience and accuracy.

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

type Params struct {
	DailySwapLimit sdk.Dec `json:"daily_swap_limit"` // daily % inflation cap on a currency from swaps
}

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(dailySwapLimit sdk.Dec) Params

NewParams creates a new param instance

func (Params) String added in v0.1.1

func (params Params) String() string

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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