types

package
v0.16.4 Latest Latest
Warning

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

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

Documentation

Overview

Package types nolint

nolint

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = ModuleName

	CodeReservePoolNotExists         sdk.CodeType = 101
	CodeEqualDenom                   sdk.CodeType = 102
	CodeInvalidDeadline              sdk.CodeType = 103
	CodeNotPositive                  sdk.CodeType = 104
	CodeConstraintNotMet             sdk.CodeType = 105
	CodeIllegalDenom                 sdk.CodeType = 106
	CodeIllegalUniId                 sdk.CodeType = 107
	CodeReservePoolInsufficientFunds sdk.CodeType = 108
)
View Source
const (
	// ModuleName is the name of the module.
	ModuleName = "coinswap"

	// RouterKey is the message route for the coinswap module.
	RouterKey = ModuleName

	// StoreKey is the default store key for the coinswap module.
	StoreKey = ModuleName

	// QuerierRoute is the querier route for the coinswap module.
	QuerierRoute = StoreKey

	MsgTypeAddLiquidity    = "add_liquidity"
	MsgTypeRemoveLiquidity = "remove_liquidity"
	MsgTypeSwapOrder       = "swap_order"
)
View Source
const (
	FormatUniABSPrefix = sdk.FormatUniABSPrefix
	FormatUniId        = FormatUniABSPrefix + "%s"
)
View Source
const (
	// DefaultParamSpace for coinswap
	DefaultParamSpace = ModuleName
	MaxFeePrecision   = 10
)
View Source
const (
	// QueryLiquidity liquidity query endpoint supported by the coinswap querier
	QueryLiquidity = "liquidity"
)

Variables

View Source
var (
	TagAmount     = "amount"
	TagSender     = "sender"
	TagRecipient  = "recipient"
	TagIsBuyOrder = "is-buy-order"
	TagTokenPair  = "token-pair"
)
View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func CheckUniDenom

func CheckUniDenom(uniDenom string) sdk.Error

CheckUniDenom returns nil if the uni denom is valid

func CheckUniId

func CheckUniId(uniId string) sdk.Error

CheckUniId returns nil if the uni id is valid

func ErrConstraintNotMet

func ErrConstraintNotMet(msg string) sdk.Error

func ErrEqualDenom

func ErrEqualDenom(msg string) sdk.Error

func ErrIllegalDenom

func ErrIllegalDenom(msg string) sdk.Error

func ErrIllegalUniId

func ErrIllegalUniId(msg string) sdk.Error

func ErrInsufficientFunds

func ErrInsufficientFunds(msg string) sdk.Error

func ErrInvalidDeadline

func ErrInvalidDeadline(msg string) sdk.Error

func ErrNotPositive

func ErrNotPositive(msg string) sdk.Error

func ErrReservePoolNotExists

func ErrReservePoolNotExists(msg string) sdk.Error

func GetCoinMinDenomFromUniDenom

func GetCoinMinDenomFromUniDenom(uniDenom string) (string, sdk.Error)

GetCoinMinDenomFromUniDenom returns the token denom by uni denom

func GetUniCoinType

func GetUniCoinType(uniId string) (sdk.CoinType, sdk.Error)

GetUniCoinType returns the uni coin type

func GetUniDenom

func GetUniDenom(uniId string) (string, sdk.Error)

GetUniDenom returns uni denom if the uni id is valid

func GetUniId

func GetUniId(denom1, denom2 string) (string, sdk.Error)

GetUniId returns the unique uni id for the provided denominations. The uni id is in the format of 'u-coin-name' which the denomination is not iris-atto.

func ParamTypeTable

func ParamTypeTable() params.TypeTable

ParamTypeTable returns the TypeTable for coinswap module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the codec.

func ValidateParams

func ValidateParams(p Params) error

ValidateParams validates a set of params

Types

type AuthKeeper

type AuthKeeper interface {
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) auth.Account
}

type BankKeeper

type BankKeeper interface {
	SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error)

	AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error)

	SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error)
}

type Input

type Input struct {
	Address sdk.AccAddress `json:"address"`
	Coin    sdk.Coin       `json:"coin"`
}

MsgSwapOrder - struct for swapping a coin Input and Output can either be exact or calculated. An exact coin has the senders desired buy or sell amount. A calculated coin has the desired denomination and bounded amount the sender is willing to buy or sell in this order.

type MsgAddLiquidity

type MsgAddLiquidity struct {
	MaxToken     sdk.Coin       `json:"max_token"`      // coin to be deposited as liquidity with an upper bound for its amount
	ExactIrisAmt sdk.Int        `json:"exact_iris_amt"` // exact amount of native asset being add to the liquidity pool
	MinLiquidity sdk.Int        `json:"min_liquidity"`  // lower bound UNI sender is willing to accept for deposited coins
	Deadline     int64          `json:"deadline"`
	Sender       sdk.AccAddress `json:"sender"`
}

MsgAddLiquidity - struct for adding liquidity to a reserve pool

func NewMsgAddLiquidity

func NewMsgAddLiquidity(
	maxToken sdk.Coin, exactIrisAmt, minLiquidity sdk.Int,
	deadline int64, sender sdk.AccAddress,
) MsgAddLiquidity

NewMsgAddLiquidity creates a new MsgAddLiquidity object.

func (MsgAddLiquidity) GetSignBytes

func (msg MsgAddLiquidity) GetSignBytes() []byte

GetSignBytes Implements Msg.

func (MsgAddLiquidity) GetSigners

func (msg MsgAddLiquidity) GetSigners() []sdk.AccAddress

GetSigners Implements Msg.

func (MsgAddLiquidity) Route

func (msg MsgAddLiquidity) Route() string

Route Implements Msg.

func (MsgAddLiquidity) Type

func (msg MsgAddLiquidity) Type() string

Type Implements Msg.

func (MsgAddLiquidity) ValidateBasic

func (msg MsgAddLiquidity) ValidateBasic() sdk.Error

ValidateBasic Implements Msg.

type MsgRemoveLiquidity

type MsgRemoveLiquidity struct {
	MinToken          sdk.Int        `json:"min_token"`          // coin to be withdrawn with a lower bound for its amount
	WithdrawLiquidity sdk.Coin       `json:"withdraw_liquidity"` // amount of UNI to be burned to withdraw liquidity from a reserve pool
	MinIrisAmt        sdk.Int        `json:"min_iris_amt"`       // minimum amount of the native asset the sender is willing to accept
	Deadline          int64          `json:"deadline"`
	Sender            sdk.AccAddress `json:"sender"`
}

MsgRemoveLiquidity - struct for removing liquidity from a reserve pool

func NewMsgRemoveLiquidity

func NewMsgRemoveLiquidity(
	minToken sdk.Int, withdrawLiquidity sdk.Coin, minIrisAmt sdk.Int,
	deadline int64, sender sdk.AccAddress,
) MsgRemoveLiquidity

NewMsgRemoveLiquidity creates a new MsgRemoveLiquidity object

func (MsgRemoveLiquidity) GetSignBytes

func (msg MsgRemoveLiquidity) GetSignBytes() []byte

GetSignBytes Implements Msg.

func (MsgRemoveLiquidity) GetSigners

func (msg MsgRemoveLiquidity) GetSigners() []sdk.AccAddress

GetSigners Implements Msg.

func (MsgRemoveLiquidity) Route

func (msg MsgRemoveLiquidity) Route() string

Route Implements Msg.

func (MsgRemoveLiquidity) Type

func (msg MsgRemoveLiquidity) Type() string

Type Implements Msg.

func (MsgRemoveLiquidity) ValidateBasic

func (msg MsgRemoveLiquidity) ValidateBasic() sdk.Error

ValidateBasic Implements Msg.

type MsgSwapOrder

type MsgSwapOrder struct {
	Input      Input  `json:"input"`        // the amount the sender is trading
	Output     Output `json:"output"`       // the amount the sender is receiving
	Deadline   int64  `json:"deadline"`     // deadline for the transaction to still be considered valid
	IsBuyOrder bool   `json:"is_buy_order"` // boolean indicating whether the order should be treated as a buy or sell
}

func NewMsgSwapOrder

func NewMsgSwapOrder(
	input Input, output Output, deadline int64, isBuyOrder bool,
) MsgSwapOrder

NewMsgSwapOrder creates a new MsgSwapOrder object.

func (MsgSwapOrder) GetSignBytes

func (msg MsgSwapOrder) GetSignBytes() []byte

GetSignBytes Implements Msg.

func (MsgSwapOrder) GetSigners

func (msg MsgSwapOrder) GetSigners() []sdk.AccAddress

GetSigners Implements Msg.

func (MsgSwapOrder) Route

func (msg MsgSwapOrder) Route() string

Route Implements Msg.

func (MsgSwapOrder) Type

func (msg MsgSwapOrder) Type() string

Type Implements Msg.

func (MsgSwapOrder) ValidateBasic

func (msg MsgSwapOrder) ValidateBasic() sdk.Error

ValidateBasic Implements Msg.

type Output

type Output struct {
	Address sdk.AccAddress `json:"address"`
	Coin    sdk.Coin       `json:"coin"`
}

type Params

type Params struct {
	Fee sdk.Rat `json:"fee"`
}

Params defines the fee and native denomination for coinswap

func DefaultParams

func DefaultParams() Params

DefaultParams returns the default coinswap module parameters

func NewParams

func NewParams(fee sdk.Rat) Params

NewParams coinswap params constructor

func (*Params) GetParamSpace

func (p *Params) GetParamSpace() string

GetParamSpace Implements params.ParamStruct

func (*Params) KeyValuePairs

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

KeyValuePairs Implements params.KeyValuePairs

func (*Params) ReadOnly

func (p *Params) ReadOnly() bool

ReadOnly Implements params.ReadOnly

func (Params) String

func (p Params) String() string

String returns a human readable string representation of the parameters.

func (*Params) StringFromBytes

func (p *Params) StringFromBytes(cdc *codec.Codec, key string, bytes []byte) (string, error)

StringFromBytes Implements params.StringFromBytes

func (*Params) Validate

func (p *Params) Validate(key string, value string) (interface{}, sdk.Error)

Validate Implements params.Validate

type QueryLiquidityParams

type QueryLiquidityParams struct {
	Id string
}

QueryLiquidityParams is the query parameters for 'custom/swap/liquidity'

type QueryLiquidityResponse

type QueryLiquidityResponse struct {
	Iris      types.Coin `json:"iris"`
	Token     types.Coin `json:"token"`
	Liquidity types.Coin `json:"liquidity"`
	Fee       string     `json:"fee"`
}

QueryLiquidityResponse is the query response for 'custom/swap/liquidity'

Jump to

Keyboard shortcuts

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