Documentation
¶
Index ¶
- Constants
- func ErrExceedsDailySwapLimit(codespace sdk.CodespaceType) sdk.Error
- func ErrInsufficientSwapCoins(codespace sdk.CodespaceType, rval sdk.Int) sdk.Error
- func ErrNoEffectivePrice(codespace sdk.CodespaceType, denom string) sdk.Error
- func ErrRecursiveSwap(codespace sdk.CodespaceType, denom string) sdk.Error
- func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)
- func NewHandler(k Keeper) sdk.Handler
- func NewQuerier(keeper Keeper) sdk.Querier
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type GenesisState
- type Keeper
- func (k Keeper) ComputeLunaDelta(ctx sdk.Context, change sdk.Int) sdk.Dec
- func (k Keeper) GetParams(ctx sdk.Context) Params
- func (k Keeper) GetSwapCoin(ctx sdk.Context, offerCoin sdk.Coin, askDenom string, isInternal bool) (retCoin sdk.Coin, spread sdk.Dec, err sdk.Error)
- func (k Keeper) GetSwapDecCoin(ctx sdk.Context, offerCoin sdk.DecCoin, askDenom string) (sdk.DecCoin, sdk.Error)
- func (k Keeper) SetParams(ctx sdk.Context, params Params)
- type Log
- type MintKeeper
- type MsgSwap
- type OracleKeeper
- type Params
- type QuerySwapParams
Constants ¶
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 )
const ( DefaultCodespace sdk.CodespaceType = "market" CodeInsufficientSwap sdk.CodeType = 1 CodeNoEffectivePrice sdk.CodeType = 2 CodeRecursiveSwap sdk.CodeType = 3 CodeExceedsSwapLimit sdk.CodeType = 4 )
market error codes
const ( // LogKeySwapCoin is the amount of swapped coin LogKeySwapCoin = string("swap_coin") // LogKeySwapFee is the fee for swap operation LogKeySwapFee = string("swap_fee") )
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 ¶
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 ¶
NewHandler creates a new handler for all market type messages.
func NewQuerier ¶ added in v0.2.0
NewQuerier is the module level router for state queries
func RegisterCodec ¶ added in v0.0.5
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
ComputeLunaDelta returns the issuance rate change of Luna for the day post-swap
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.
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
NewMsgSwap creates a MsgSwap instance
func (MsgSwap) GetSignBytes ¶ added in v0.0.7
GetSignBytes Implements Msg
func (MsgSwap) GetSigners ¶ added in v0.0.7
func (msg MsgSwap) GetSigners() []sdk.AccAddress
GetSigners Implements Msg
func (MsgSwap) ValidateBasic ¶ added in v0.0.7
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
type QuerySwapParams ¶ added in v0.2.0
QuerySwapParams for query 'custom/market/swap'
func NewQuerySwapParams ¶ added in v0.2.0
func NewQuerySwapParams(offerCoin sdk.Coin) QuerySwapParams