types

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

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"
)
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 (
	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 GetPoolTokenName added in v0.12.1

func GetPoolTokenName(token1, token2 string) string

func GetSwapTokenPairName added in v0.12.1

func GetSwapTokenPairName(token1, token2 string) string

func GetTokenPairKey

func GetTokenPairKey(key string) []byte

nolint

func InitPoolToken

func InitPoolToken(poolTokenName string) token.Token

InitPoolToken default pool token

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for swap module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

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

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.DecCoin
	TokenToBuy string
}

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) String

func (s SwapTokenPair) String() string

String implement fmt.Stringer

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

Jump to

Keyboard shortcuts

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