types

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCodespace = ModuleName

	CodeNonExistSwapTokenPair                   uint32 = 65000
	CodeNonExistPoolToken                       uint32 = 65001
	CodeMintCoinsFailed                         uint32 = 65002
	CodeSendCoinsFromAccountToModule            uint32 = 65003
	CodeBaseAmountNameBiggerThanQuoteAmountName uint32 = 65004
	CodeValidateSwapAmountName                  uint32 = 65005
	CodeBaseNameEqualQuoteName                  uint32 = 65006
	CodeValidateDenom                           uint32 = 65007
	CodeNotAllowedOriginSymbol                  uint32 = 65008
	CodeInsufficientPoolToken                   uint32 = 65009
	CodeTokenNotExist                           uint32 = 65010
	CodeInvalidCoins                            uint32 = 65011
	CodeInvalidTokenPair                        uint32 = 65012
	CodeAddressIsRequire                        uint32 = 65013
	CodeIsZeroValue                             uint32 = 65014
	CodeBlockTimeBigThanDeadline                uint32 = 65015
	CodeLessThan                                uint32 = 65016
	CodeMintPoolTokenFailed                     uint32 = 65017
	CodeSendCoinsFromPoolToAccountFailed        uint32 = 65018
	CodeBurnPoolTokenFailed                     uint32 = 65019
	CodeSendCoinsToPoolFailed                   uint32 = 65020
	CodeSwapUnknownMsgType                      uint32 = 65021
	CodeSwapUnknownQueryTypes                   uint32 = 65022
	CodeSellAmountOrBuyTokenIsEmpty             uint32 = 65023
	CodeSellAmountEqualBuyToken                 uint32 = 65024
	CodeQueryParamsAddressIsEmpty               uint32 = 65025
	CodeQueryParamsQuoteTokenAmountIsEmpty      uint32 = 65026
	CodeQueryParamsBaseTokenIsEmpty             uint32 = 65027
	CodeMinLiquidityIsNegative                  uint32 = 65028
	CodeMaxBaseAmountOrQuoteAmountIsNegative    uint32 = 65029
	CodeMaxBaseAmount                           uint32 = 65030
	CodeQuoteAmount                             uint32 = 65031
	CodeMinBaseAmount                           uint32 = 65032
	CodeMinQuoteAmount                          uint32 = 65033
	CodeSoldTokenAmountIsNegative               uint32 = 65034
	CodeToken0NameEqualToken1Name               uint32 = 65035
	CodeSoldTokenAmount                         uint32 = 65036
	CodeMinBoughtTokenAmount                    uint32 = 65037
	CodeConvertSellTokenAmount                  uint32 = 65038
	CodeConvertQuoteTokenAmount                 uint32 = 65039
	CodeSendCoinsFailed                         uint32 = 65040
	CodeMsgDeadlineLessThanBlockTime            uint32 = 65041
	CodeBaseTokensAmountBiggerThanMax           uint32 = 65042
	CodeIsSwapTokenPairExist                    uint32 = 65043
	CodeIsPoolTokenPairExist                    uint32 = 65044
	CodeInternalError                           uint32 = 65045
)
View Source
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"
	QuerySwapTokens             = "swapTokens"
	QuerySwapQuoteInfo          = "swapQuoteInfo"
	QuerySwapLiquidityHistories = "swapLiquidityHistories"
	QuerySwapAddLiquidityQuote  = "swapAddLiquidityQuote"
)
View Source
const (
	TypeMsgAddLiquidity = "add_liquidity"
	TypeMsgTokenSwap    = "token_swap"
)

PoolSwap message types and routes

View Source
const (
	DefaultParamspace = ModuleName

	GenerateTokenType = 2
)

Default parameter namespace

View Source
const (
	// swap business type
	SwapBusinessTypeCreate = "create"
	SwapBusinessTypeAdd    = "add"
	SwapBusinessTypeSwap   = "swap"
)
View Source
const (
	AttributeValueCategory = ModuleName
)

ammswap module event types

View Source
const PoolTokenPrefix = "ammswap_"

PoolTokenPrefix defines pool token prefix name

View Source
const TestBasePooledToken = "aab"

nolint

View Source
const TestBasePooledToken2 = "ccb"
View Source
const TestBasePooledToken3 = "ddb"
View Source
const TestQuotePooledToken = common.NativeToken
View Source
const TestSwapTokenPairName = TestBasePooledToken + "_" + TestQuotePooledToken

Variables

View Source
var (
	KeyFeeRate = []byte("FeeRate")
)

Parameter store keys

View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the module codec

View Source
var (
	// TokenPairPrefixKey to be used for KVStore
	TokenPairPrefixKey = []byte{0x01}
)

Functions

func ErrAddressIsRequire added in v0.16.0

func ErrAddressIsRequire(msg string) sdk.EnvelopedErr

func ErrBaseAmountNameBiggerThanQuoteAmountName added in v0.16.0

func ErrBaseAmountNameBiggerThanQuoteAmountName() sdk.EnvelopedErr

func ErrBaseNameEqualQuoteName added in v0.16.0

func ErrBaseNameEqualQuoteName() sdk.EnvelopedErr

func ErrBaseTokensAmountBiggerThanMax added in v0.16.0

func ErrBaseTokensAmountBiggerThanMax() sdk.EnvelopedErr

func ErrBlockTimeBigThanDeadline added in v0.16.0

func ErrBlockTimeBigThanDeadline() sdk.EnvelopedErr

func ErrBurnPoolTokenFailed added in v0.16.0

func ErrBurnPoolTokenFailed(err error) sdk.EnvelopedErr

func ErrCodeMinCoinsFailed added in v0.16.0

func ErrCodeMinCoinsFailed(err error) sdk.EnvelopedErr

func ErrConvertQuoteTokenAmount added in v0.16.0

func ErrConvertQuoteTokenAmount(quoteTokenAmount string, err error) sdk.EnvelopedErr

func ErrConvertSellTokenAmount added in v0.16.0

func ErrConvertSellTokenAmount(sellTokenAmount string, err error) sdk.EnvelopedErr

func ErrInsufficientPoolToken added in v0.16.0

func ErrInsufficientPoolToken() sdk.EnvelopedErr

func ErrInvalidCoins added in v0.16.0

func ErrInvalidCoins() sdk.EnvelopedErr

func ErrInvalidTokenPair added in v0.16.0

func ErrInvalidTokenPair(swapTokenPair string) sdk.EnvelopedErr

func ErrIsZeroValue added in v0.16.0

func ErrIsZeroValue(msg string) sdk.EnvelopedErr

func ErrLessThan added in v0.16.0

func ErrLessThan(param1 string, param2 string) sdk.EnvelopedErr

func ErrMaxBaseAmount added in v0.16.0

func ErrMaxBaseAmount() sdk.EnvelopedErr

func ErrMaxBaseAmountOrQuoteAmountIsNegative added in v0.16.0

func ErrMaxBaseAmountOrQuoteAmountIsNegative() sdk.EnvelopedErr

func ErrMinBaseAmount added in v0.16.0

func ErrMinBaseAmount() sdk.EnvelopedErr

func ErrMinBoughtTokenAmount added in v0.16.0

func ErrMinBoughtTokenAmount() sdk.EnvelopedErr

func ErrMinLiquidityIsNegative added in v0.16.0

func ErrMinLiquidityIsNegative() sdk.EnvelopedErr

func ErrMinQuoteAmount added in v0.16.0

func ErrMinQuoteAmount() sdk.EnvelopedErr

func ErrMintPoolTokenFailed added in v0.16.0

func ErrMintPoolTokenFailed(err error) sdk.EnvelopedErr

func ErrMsgDeadlineLessThanBlockTime added in v0.16.0

func ErrMsgDeadlineLessThanBlockTime() sdk.EnvelopedErr

func ErrNonExistPoolToken added in v0.16.0

func ErrNonExistPoolToken(token string) sdk.EnvelopedErr

func ErrNonExistSwapTokenPair added in v0.16.0

func ErrNonExistSwapTokenPair(tokenPairName string) sdk.EnvelopedErr

func ErrNotAllowedOriginSymbol added in v0.16.0

func ErrNotAllowedOriginSymbol() sdk.EnvelopedErr

func ErrPoolTokenPairExist added in v0.16.0

func ErrPoolTokenPairExist() sdk.EnvelopedErr

func ErrQueryParamsAddressIsEmpty added in v0.16.0

func ErrQueryParamsAddressIsEmpty() sdk.EnvelopedErr

func ErrQueryParamsBaseTokenIsEmpty added in v0.16.0

func ErrQueryParamsBaseTokenIsEmpty() sdk.EnvelopedErr

func ErrQueryParamsQuoteTokenAmountIsEmpty added in v0.16.0

func ErrQueryParamsQuoteTokenAmountIsEmpty() sdk.EnvelopedErr

func ErrQuoteAmount added in v0.16.0

func ErrQuoteAmount() sdk.EnvelopedErr

func ErrSellAmountEqualBuyToken added in v0.16.0

func ErrSellAmountEqualBuyToken() sdk.EnvelopedErr

func ErrSellAmountOrBuyTokenIsEmpty added in v0.16.0

func ErrSellAmountOrBuyTokenIsEmpty() sdk.EnvelopedErr

func ErrSendCoinsFailed added in v0.16.0

func ErrSendCoinsFailed(err error) sdk.EnvelopedErr

func ErrSendCoinsFromAccountToModule added in v0.16.0

func ErrSendCoinsFromAccountToModule(err error) sdk.EnvelopedErr

func ErrSendCoinsFromPoolToAccountFailed added in v0.16.0

func ErrSendCoinsFromPoolToAccountFailed(msg string) sdk.EnvelopedErr

func ErrSendCoinsToPoolFailed added in v0.16.0

func ErrSendCoinsToPoolFailed(msg string) sdk.EnvelopedErr

func ErrSoldTokenAmount added in v0.16.0

func ErrSoldTokenAmount() sdk.EnvelopedErr

func ErrSoldTokenAmountIsNegative added in v0.16.0

func ErrSoldTokenAmountIsNegative() sdk.EnvelopedErr

func ErrSwapTokenPairExist added in v0.16.0

func ErrSwapTokenPairExist() sdk.EnvelopedErr

func ErrSwapUnknownMsgType added in v0.16.0

func ErrSwapUnknownMsgType() sdk.EnvelopedErr

func ErrSwapUnknownQueryType added in v0.16.0

func ErrSwapUnknownQueryType() sdk.EnvelopedErr

func ErrToken0NameEqualToken1Name added in v0.16.0

func ErrToken0NameEqualToken1Name() sdk.EnvelopedErr

func ErrTokenNotExist added in v0.16.0

func ErrTokenNotExist() sdk.EnvelopedErr

func ErrValidateDenom added in v0.16.0

func ErrValidateDenom(tokenName string) sdk.EnvelopedErr

func ErrValidateSwapAmountName added in v0.16.0

func ErrValidateSwapAmountName() sdk.EnvelopedErr

func GetBaseQuoteTokenName added in v0.13.0

func GetBaseQuoteTokenName(token0, token1 string) (string, string)

func GetPoolTokenName added in v0.12.1

func GetPoolTokenName(token1, token2 string) string

func GetSwapTokenPairName added in v0.12.1

func GetSwapTokenPairName(token0, token1 string) string

func GetTokenPairKey

func GetTokenPairKey(key string) []byte

nolint

func InitPoolToken

func InitPoolToken(poolTokenName string) token.Token

InitPoolToken default pool token

func IsPoolToken added in v0.13.0

func IsPoolToken(symbol string) bool

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for swap module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

func SplitPoolToken added in v0.13.0

func SplitPoolToken(symbol string) (token0, token1 string)

func ValidateBaseAndQuoteAmount added in v0.12.1

func ValidateBaseAndQuoteAmount(baseAmountName, quoteAmountName string) error

func ValidateSwapAmountName added in v0.12.1

func ValidateSwapAmountName(amountName string) error

Types

type BackendKeeper added in v0.16.0

type BackendKeeper interface {
	OnSwapToken(ctx sdk.Context, address sdk.AccAddress, swapTokenPair SwapTokenPair, sellAmount sdk.SysCoin, buyAmount sdk.SysCoin)
	OnSwapCreateExchange(ctx sdk.Context, swapTokenPair SwapTokenPair)
}

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.SysCoin    `json:"max_base_amount"` // Maximum number of tokens deposited. Deposits max amount if total pool token supply is 0.
	QuoteAmount   sdk.SysCoin    `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.SysCoin, 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 {
	Token0Name string         `json:"token0_name"`
	Token1Name string         `json:"token1_name"`
	Sender     sdk.AccAddress `json:"sender"` // Sender
}

MsgCreateExchange creates a new exchange with token

func NewMsgCreateExchange

func NewMsgCreateExchange(token0Name string, token1Name 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.SysCoin    `json:"min_base_amount"`  // Minimum base amount.
	MinQuoteAmount sdk.SysCoin    `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.SysCoin, 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.SysCoin    `json:"sold_token_amount"`       // Amount of Tokens sold.
	MinBoughtTokenAmount sdk.SysCoin    `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.SysCoin, 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

type Params struct {
	FeeRate sdk.Dec `json:"fee_rate"`
}

Params - used for initializing default parameter for swap at genesis

func DefaultParams

func DefaultParams() Params

DefaultParams defines the parameters for this module

func NewParams

func NewParams(feeRate sdk.Dec) Params

NewParams creates a new Params object

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

ParamSetPairs implements params.ParamSet

func (Params) String

func (p Params) String() string

String implements the stringer interface for Params

type QueryBuyAmountParams

type QueryBuyAmountParams struct {
	SoldToken  sdk.SysCoin
	TokenToBuy string
}

type QuerySwapAddInfoParams added in v0.13.0

type QuerySwapAddInfoParams struct {
	QuoteTokenAmount string `json:"quote_token_amount"`
	BaseToken        string `json:"base_token"`
}

nolint

func NewQuerySwapAddInfoParams added in v0.13.0

func NewQuerySwapAddInfoParams(quoteTokenAmount string, baseToken string) QuerySwapAddInfoParams

NewQuerySwapAddInfoParams creates a new instance of QuerySwapAddInfoParams

type QuerySwapBuyInfoParams added in v0.13.0

type QuerySwapBuyInfoParams struct {
	SellTokenAmount string `json:"sell_token_amount"`
	BuyToken        string `json:"buy_token"`
}

nolint

func NewQuerySwapBuyInfoParams added in v0.13.0

func NewQuerySwapBuyInfoParams(sellTokenAmount string, buyToken string) QuerySwapBuyInfoParams

NewQuerySwapBuyInfoParams creates a new instance of QuerySwapBuyInfoParams

type QuerySwapLiquidityInfoParams added in v0.13.0

type QuerySwapLiquidityInfoParams struct {
	Address       string `json:"address"`
	TokenPairName string `json:"token_pair_name"`
}

nolint

func NewQuerySwapLiquidityInfoParams added in v0.13.0

func NewQuerySwapLiquidityInfoParams(address string, tokenPairName string) QuerySwapLiquidityInfoParams

NewQuerySwapBuyInfoParams creates a new instance of QuerySwapLiquidityInfoParams

type QuerySwapTokensParams added in v0.13.0

type QuerySwapTokensParams struct {
	BusinessType  string `json:"business_type"`
	Address       string `json:"address"`
	BaseTokenName string `json:"base_token_name"`
}

nolint

func NewQuerySwapTokensParams added in v0.13.0

func NewQuerySwapTokensParams(businessType string, address string, baseTokenName string) QuerySwapTokensParams

NewQuerySwapTokensParams creates a new instance of QueryDexFeesParams

type SupplyKeeper

type SupplyKeeper interface {
	GetSupplyByDenom(ctx sdk.Context, denom string) sdk.Dec
	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 SwapAddInfo added in v0.13.0

type SwapAddInfo struct {
	BaseTokenAmount sdk.Dec `json:"base_token_amount"`
	PoolShare       sdk.Dec `json:"pool_share"`
}

type SwapBuyInfo added in v0.13.0

type SwapBuyInfo struct {
	BuyAmount   sdk.Dec `json:"buy_amount"`
	Price       sdk.Dec `json:"price"`
	PriceImpact sdk.Dec `json:"price_impact"`
	Fee         string  `json:"fee"`
	Route       string  `json:"route"`
}

type SwapLiquidityInfo added in v0.13.0

type SwapLiquidityInfo struct {
	BasePooledCoin  sdk.SysCoin `json:"base_pooled_coin"`
	QuotePooledCoin sdk.SysCoin `json:"quote_pooled_coin"`
	PoolTokenCoin   sdk.SysCoin `json:"pool_token_coin"`
	PoolTokenRatio  sdk.Dec     `json:"pool_token_ratio"`
}

type SwapToken added in v0.13.0

type SwapToken struct {
	Symbol    string  `json:"symbol"`
	Available sdk.Dec `json:"available"`
}

func NewSwapToken added in v0.13.0

func NewSwapToken(symbol string, available sdk.Dec) SwapToken

type SwapTokenPair

type SwapTokenPair struct {
	QuotePooledCoin sdk.SysCoin `json:"quote_pooled_coin"` // The volume of quote token in the token pair exchange pool
	BasePooledCoin  sdk.SysCoin `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 NewSwapPair added in v0.13.0

func NewSwapPair(token0, token1 string) SwapTokenPair

func NewSwapTokenPair

func NewSwapTokenPair(quotePooledCoin sdk.SysCoin, basePooledCoin sdk.SysCoin, poolTokenName string) *SwapTokenPair

NewSwapTokenPair is a constructor function for SwapTokenPair

func (SwapTokenPair) String

func (s SwapTokenPair) String() string

String implement fmt.Stringer

func (SwapTokenPair) TokenPairName

func (s SwapTokenPair) TokenPairName() string

TokenPairName defines token pair

type SwapTokens added in v0.13.0

type SwapTokens []SwapToken

func (SwapTokens) Len added in v0.13.0

func (swapTokens SwapTokens) Len() int

func (SwapTokens) Less added in v0.13.0

func (swapTokens SwapTokens) Less(i, j int) bool

func (SwapTokens) Swap added in v0.13.0

func (swapTokens SwapTokens) Swap(i, j int)

type SwapTokensResponse added in v0.13.0

type SwapTokensResponse struct {
	NativeToken string     `json:"native_token"`
	Tokens      SwapTokens `json:"tokens"`
}

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.SysCoins
	TokenExist(ctx sdk.Context, symbol string) bool
	GetTokensInfo(ctx sdk.Context) (tokens []token.Token)
}

TokenKeeper defines the expected token interface

Jump to

Keyboard shortcuts

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