Documentation ¶
Index ¶
- Constants
- Variables
- func GetPoolTokenName(token1, token2 string) string
- func GetSwapTokenPairName(token1, token2 string) string
- func GetTokenPairKey(key string) []byte
- func InitPoolToken(poolTokenName string) token.Token
- func ParamKeyTable() params.KeyTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateBaseAndQuoteAmount(baseAmountName, quoteAmountName string) error
- func ValidateSwapAmountName(amountName string) error
- type BankKeeper
- type MsgAddLiquidity
- type MsgCreateExchange
- func (msg MsgCreateExchange) GetSignBytes() []byte
- func (msg MsgCreateExchange) GetSigners() []sdk.AccAddress
- func (msg MsgCreateExchange) GetSwapTokenPairName() string
- func (msg MsgCreateExchange) Route() string
- func (msg MsgCreateExchange) Type() string
- func (msg MsgCreateExchange) ValidateBasic() sdk.Error
- type MsgRemoveLiquidity
- func (msg MsgRemoveLiquidity) GetSignBytes() []byte
- func (msg MsgRemoveLiquidity) GetSigners() []sdk.AccAddress
- func (msg MsgRemoveLiquidity) GetSwapTokenPairName() string
- func (msg MsgRemoveLiquidity) Route() string
- func (msg MsgRemoveLiquidity) Type() string
- func (msg MsgRemoveLiquidity) ValidateBasic() sdk.Error
- type MsgTokenToToken
- type ParamSubspace
- type Params
- type QueryBuyAmountParams
- type SupplyKeeper
- type SwapTokenPair
- type TokenKeeper
Constants ¶
const ( // ModuleName is the name of the module ModuleName = "ammswap" // StoreKey to be used when creating the KVStore StoreKey = ModuleName // RouterKey to be used for routing msgs RouterKey = ModuleName // QuerierRoute to be used for querier msgs QuerierRoute = ModuleName // QuerySwapTokenPair query endpoints supported by the swap Querier QuerySwapTokenPair = "swapTokenPair" QuerySwapTokenPairs = "swapTokenPairs" QueryRedeemableAssets = "queryRedeemableAssets" QueryParams = "params" QueryBuyAmount = "buy" )
const ( TypeMsgAddLiquidity = "add_liquidity" TypeMsgTokenSwap = "token_swap" )
PoolSwap message types and routes
const ( DefaultParamspace = ModuleName GenerateTokenType = 2 )
Default parameter namespace
const (
AttributeValueCategory = ModuleName
)
ammswap module event types
const PoolTokenPrefix = "ammswap_"
PoolTokenPrefix defines pool token prefix name
const TestBasePooledToken = "aab"
nolint
const TestBasePooledToken2 = "ccb"
const TestBasePooledToken3 = "ddb"
const TestQuotePooledToken = common.NativeToken
const TestSwapTokenPairName = TestBasePooledToken + "_" + TestQuotePooledToken
Variables ¶
var (
KeyFeeRate = []byte("FeeRate")
)
Parameter store keys
var ModuleCdc *codec.Codec
ModuleCdc defines the module codec
var ( // TokenPairPrefixKey to be used for KVStore TokenPairPrefixKey = []byte{0x01} )
Functions ¶
func GetPoolTokenName ¶ added in v0.12.1
func GetSwapTokenPairName ¶ added in v0.12.1
func InitPoolToken ¶
InitPoolToken default pool token
func RegisterCodec ¶
RegisterCodec registers concrete types on codec
func ValidateBaseAndQuoteAmount ¶ added in v0.12.1
func ValidateSwapAmountName ¶ added in v0.12.1
Types ¶
type BankKeeper ¶
type BankKeeper interface { SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, error) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error }
BankKeeper defines the expected bank interface
type MsgAddLiquidity ¶
type MsgAddLiquidity struct { MinLiquidity sdk.Dec `json:"min_liquidity"` // Minimum number of sender will mint if total pool token supply is greater than 0. MaxBaseAmount sdk.DecCoin `json:"max_base_amount"` // Maximum number of tokens deposited. Deposits max amount if total pool token supply is 0. QuoteAmount sdk.DecCoin `json:"quote_amount"` // Quote token amount Deadline int64 `json:"deadline"` // Time after which this transaction can no longer be executed. Sender sdk.AccAddress `json:"sender"` // Sender }
MsgAddLiquidity Deposit quote_amount and base_amount at current ratio to mint pool tokens.
func NewMsgAddLiquidity ¶
func NewMsgAddLiquidity(minLiquidity sdk.Dec, maxBaseAmount, quoteAmount sdk.DecCoin, deadline int64, sender sdk.AccAddress) MsgAddLiquidity
NewMsgAddLiquidity is a constructor function for MsgAddLiquidity
func (MsgAddLiquidity) GetSignBytes ¶
func (msg MsgAddLiquidity) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgAddLiquidity) GetSigners ¶
func (msg MsgAddLiquidity) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgAddLiquidity) GetSwapTokenPairName ¶ added in v0.12.1
func (msg MsgAddLiquidity) GetSwapTokenPairName() string
GetSwapTokenPair defines token pair
func (MsgAddLiquidity) Route ¶
func (msg MsgAddLiquidity) Route() string
Route should return the name of the module
func (MsgAddLiquidity) Type ¶
func (msg MsgAddLiquidity) Type() string
Type should return the action
func (MsgAddLiquidity) ValidateBasic ¶
func (msg MsgAddLiquidity) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgCreateExchange ¶
type MsgCreateExchange struct { BaseAmountName string `json:"base_amount_name"` // Token QuoteAmountName string `json:"quote_amount_name"` Sender sdk.AccAddress `json:"sender"` // Sender }
MsgCreateExchange creates a new exchange with token
func NewMsgCreateExchange ¶
func NewMsgCreateExchange(baseAmountName string, quoteAmountName string, sender sdk.AccAddress) MsgCreateExchange
NewMsgCreateExchange create a new exchange with token
func (MsgCreateExchange) GetSignBytes ¶
func (msg MsgCreateExchange) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgCreateExchange) GetSigners ¶
func (msg MsgCreateExchange) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgCreateExchange) GetSwapTokenPairName ¶ added in v0.12.1
func (msg MsgCreateExchange) GetSwapTokenPairName() string
GetSwapTokenPair defines token pair
func (MsgCreateExchange) Route ¶
func (msg MsgCreateExchange) Route() string
Route should return the name of the module
func (MsgCreateExchange) Type ¶
func (msg MsgCreateExchange) Type() string
Type should return the action
func (MsgCreateExchange) ValidateBasic ¶
func (msg MsgCreateExchange) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgRemoveLiquidity ¶
type MsgRemoveLiquidity struct { Liquidity sdk.Dec `json:"liquidity"` // Amount of pool token burned. MinBaseAmount sdk.DecCoin `json:"min_base_amount"` // Minimum base amount. MinQuoteAmount sdk.DecCoin `json:"min_quote_amount"` // Minimum quote amount. Deadline int64 `json:"deadline"` // Time after which this transaction can no longer be executed. Sender sdk.AccAddress `json:"sender"` // Sender }
MsgRemoveLiquidity burns pool tokens to withdraw okt and Tokens at current ratio.
func NewMsgRemoveLiquidity ¶
func NewMsgRemoveLiquidity(liquidity sdk.Dec, minBaseAmount, minQuoteAmount sdk.DecCoin, deadline int64, sender sdk.AccAddress) MsgRemoveLiquidity
NewMsgRemoveLiquidity is a constructor function for MsgAddLiquidity
func (MsgRemoveLiquidity) GetSignBytes ¶
func (msg MsgRemoveLiquidity) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgRemoveLiquidity) GetSigners ¶
func (msg MsgRemoveLiquidity) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgRemoveLiquidity) GetSwapTokenPairName ¶ added in v0.12.1
func (msg MsgRemoveLiquidity) GetSwapTokenPairName() string
GetSwapTokenPair defines token pair
func (MsgRemoveLiquidity) Route ¶
func (msg MsgRemoveLiquidity) Route() string
Route should return the name of the module
func (MsgRemoveLiquidity) Type ¶
func (msg MsgRemoveLiquidity) Type() string
Type should return the action
func (MsgRemoveLiquidity) ValidateBasic ¶
func (msg MsgRemoveLiquidity) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgTokenToToken ¶
type MsgTokenToToken struct { SoldTokenAmount sdk.DecCoin `json:"sold_token_amount"` // Amount of Tokens sold. MinBoughtTokenAmount sdk.DecCoin `json:"min_bought_token_amount"` // Minimum token purchased. Deadline int64 `json:"deadline"` // Time after which this transaction can no longer be executed. Recipient sdk.AccAddress `json:"recipient"` // Recipient address,transfer Tokens to recipient.default recipient is sender. Sender sdk.AccAddress `json:"sender"` // Sender }
MsgTokenToToken define the message for swap between token and DefaultBondDenom
func NewMsgTokenToToken ¶
func NewMsgTokenToToken( soldTokenAmount, minBoughtTokenAmount sdk.DecCoin, deadline int64, recipient, sender sdk.AccAddress, ) MsgTokenToToken
NewMsgTokenToToken is a constructor function for MsgTokenOKTSwap
func (MsgTokenToToken) GetSignBytes ¶
func (msg MsgTokenToToken) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgTokenToToken) GetSigners ¶
func (msg MsgTokenToToken) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgTokenToToken) GetSwapTokenPairName ¶ added in v0.12.1
func (msg MsgTokenToToken) GetSwapTokenPairName() string
GetSwapTokenPair defines token pair
func (MsgTokenToToken) Route ¶
func (msg MsgTokenToToken) Route() string
Route should return the name of the module
func (MsgTokenToToken) Type ¶
func (msg MsgTokenToToken) Type() string
Type should return the action
func (MsgTokenToToken) ValidateBasic ¶
func (msg MsgTokenToToken) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type ParamSubspace ¶
type ParamSubspace interface { WithKeyTable(table params.KeyTable) params.Subspace Get(ctx sdk.Context, key []byte, ptr interface{}) GetParamSet(ctx sdk.Context, ps params.ParamSet) SetParamSet(ctx sdk.Context, ps params.ParamSet) }
ParamSubspace defines the expected Subspace interface
type Params ¶
Params - used for initializing default parameter for swap at genesis
func DefaultParams ¶
func DefaultParams() Params
DefaultParams defines the parameters for this module
func (*Params) ParamSetPairs ¶
func (p *Params) ParamSetPairs() params.ParamSetPairs
ParamSetPairs implements params.ParamSet
type QueryBuyAmountParams ¶
type SupplyKeeper ¶
type SupplyKeeper interface { GetSupply(ctx sdk.Context) (supply supplyexported.SupplyI) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) sdk.Error SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) sdk.Error MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) sdk.Error BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) sdk.Error }
SupplyKeeper defines the expected supply interface
type SwapTokenPair ¶
type SwapTokenPair struct { QuotePooledCoin sdk.DecCoin `json:"quote_pooled_coin"` // The volume of quote token in the token pair exchange pool BasePooledCoin sdk.DecCoin `json:"base_pooled_coin"` // The volume of base token in the token pair exchange pool PoolTokenName string `json:"pool_token_name"` // The name of pool token }
SwapTokenPair defines token pair exchange
func GetTestSwapTokenPair ¶
func GetTestSwapTokenPair() SwapTokenPair
GetTestSwapTokenPair just for test
func NewSwapTokenPair ¶
func NewSwapTokenPair(quotePooledCoin sdk.DecCoin, basePooledCoin sdk.DecCoin, poolTokenName string) *SwapTokenPair
NewSwapTokenPair is a constructor function for SwapTokenPair
func (SwapTokenPair) TokenPairName ¶
func (s SwapTokenPair) TokenPairName() string
TokenPairName defines token pair
type TokenKeeper ¶
type TokenKeeper interface { GetTokenInfo(ctx sdk.Context, symbol string) token.Token NewToken(ctx sdk.Context, token token.Token) UpdateToken(ctx sdk.Context, token token.Token) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.DecCoins TokenExist(ctx sdk.Context, symbol string) bool }
TokenKeeper defines the expected token interface