types

package
v0.15.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	AttributeValueCategory     = ModuleName
	EventTypeSwapDeposit       = "swap_deposit"
	EventTypeSwapWithdraw      = "swap_withdraw"
	EventTypeSwapTrade         = "swap_trade"
	AttributeKeyPoolID         = "pool_id"
	AttributeKeyDepositor      = "depositor"
	AttributeKeyShares         = "shares"
	AttributeKeyOwner          = "owner"
	AttributeKeyRequester      = "requester"
	AttributeKeySwapInput      = "input"
	AttributeKeySwapOutput     = "output"
	AttributeKeyFeePaid        = "fee"
	AttributeKeyExactDirection = "exact"
)

Event types for swap module

View Source
const (
	// ModuleName name that will be used throughout the module
	ModuleName = "swap"

	// ModuleAccountName name of module account used to hold liquidity
	ModuleAccountName = "swap"

	// StoreKey Top level store key where all module items will be stored
	StoreKey = ModuleName

	// RouterKey Top level router key
	RouterKey = ModuleName

	// QuerierRoute Top level query string
	QuerierRoute = ModuleName

	// DefaultParamspace default name for parameter store
	DefaultParamspace = ModuleName
)
View Source
const (
	QueryGetParams   = "params"
	QueryGetDeposits = "deposits"
	QueryGetPool     = "pool"
	QueryGetPools    = "pools"
)

Querier routes for the swap module

View Source
const PoolIDSep = ":"

Variables

View Source
var (
	ErrNotAllowed            = sdkerrors.Register(ModuleName, 2, "not allowed")
	ErrInvalidDeadline       = sdkerrors.Register(ModuleName, 3, "invalid deadline")
	ErrDeadlineExceeded      = sdkerrors.Register(ModuleName, 4, "deadline exceeded")
	ErrSlippageExceeded      = sdkerrors.Register(ModuleName, 5, "slippage exceeded")
	ErrInvalidPool           = sdkerrors.Register(ModuleName, 6, "invalid pool")
	ErrInvalidSlippage       = sdkerrors.Register(ModuleName, 7, "invalid slippage")
	ErrInsufficientLiquidity = sdkerrors.Register(ModuleName, 8, "insufficient liquidity")
	ErrInvalidShares         = sdkerrors.Register(ModuleName, 9, "invalid shares")
	ErrDepositNotFound       = sdkerrors.Register(ModuleName, 10, "deposit not found")
	ErrInvalidCoin           = sdkerrors.Register(ModuleName, 11, "invalid coin")
	ErrNotImplemented        = sdkerrors.Register(ModuleName, 12, "not implemented")
)

swap module errors

View Source
var (
	// DefaultPoolRecords is used to set default records in default genesis state
	DefaultPoolRecords = PoolRecords{}
	// DefaultShareRecords is used to set default records in default genesis state
	DefaultShareRecords = ShareRecords{}
)
View Source
var (
	PoolKeyPrefix             = []byte{0x01}
	DepositorPoolSharesPrefix = []byte{0x02}
)

key prefixes for store

View Source
var (
	KeyAllowedPools     = []byte("AllowedPools")
	KeySwapFee          = []byte("SwapFee")
	DefaultAllowedPools = AllowedPools{}
	DefaultSwapFee      = sdk.ZeroDec()
	MaxSwapFee          = sdk.OneDec()
)

Parameter keys and default values

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func DepositorPoolSharesKey

func DepositorPoolSharesKey(depositor sdk.AccAddress, poolID string) []byte

DepositorPoolSharesKey returns a key from a depositor and poolID

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable Key declaration for parameters

func PoolID

func PoolID(denomA string, denomB string) string

PoolID returns an alphabetically sorted pool name from two denoms. The name is commutative for any all pairs A,B: f(A,B) == f(B,A).

func PoolIDFromCoins

func PoolIDFromCoins(coins sdk.Coins) string

PoolIDFromCoins returns a poolID from a coins object

func PoolKey

func PoolKey(poolID string) []byte

PoolKey returns a key generated from a poolID

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the necessary types for swap module

Types

type AccountKeeper

type AccountKeeper interface {
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) authexported.Account
	SetAccount(ctx sdk.Context, acc authexported.Account)
}

AccountKeeper defines the expected keeper interface for interacting with account (noalias)

type AllowedPool

type AllowedPool struct {
	TokenA string `json:"token_a" yaml:"token_a"`
	TokenB string `json:"token_b" yaml:"token_b"`
}

AllowedPool defines a tradable pool

func NewAllowedPool

func NewAllowedPool(tokenA, tokenB string) AllowedPool

NewAllowedPool returns a new AllowedPool object

func (AllowedPool) Name

func (p AllowedPool) Name() string

Name returns the name for the allowed pool

func (AllowedPool) String

func (p AllowedPool) String() string

String pretty prints the allowedPool

func (AllowedPool) Validate

func (p AllowedPool) Validate() error

Validate validates allowedPool attributes and returns an error if invalid

type AllowedPools

type AllowedPools []AllowedPool

AllowedPools is a slice of AllowedPool

func NewAllowedPools

func NewAllowedPools(allowedPools ...AllowedPool) AllowedPools

NewAllowedPools returns AllowedPools from the provided values

func (AllowedPools) Validate

func (p AllowedPools) Validate() error

Validate validates each allowedPool and returns an error if there are any duplicates

type BasePool

type BasePool struct {
	// contains filtered or unexported fields
}

BasePool implements a unitless constant-product liquidity pool.

The pool is symmetric. For all A,B,s, any operation F on a pool (A,B,s) and pool (B,A,s) will result in equal state values of A', B', s': F(A,B,s) => (A',B',s'), F(B,A,s) => (B',A',s')

In addition, the pool is protected from overflow in intermediate calculations, and will only overflow when A, B, or s become larger than the max sdk.Int.

Pool operations with non-positive values are invalid, and all functions on a pool will panic when given zero or negative values.

func NewBasePool

func NewBasePool(reservesA, reservesB sdk.Int) (*BasePool, error)

NewBasePool returns a pointer to a base pool with reserves and total shares initialized

func NewBasePoolWithExistingShares

func NewBasePoolWithExistingShares(reservesA, reservesB, totalShares sdk.Int) (*BasePool, error)

NewBasePoolWithExistingShares returns a pointer to a base pool with existing shares

func (*BasePool) AddLiquidity

func (p *BasePool) AddLiquidity(desiredA sdk.Int, desiredB sdk.Int) (sdk.Int, sdk.Int, sdk.Int)

AddLiquidity adds liquidity to the pool returns the actual reservesA, reservesB deposits in addition to the number of shares created. The deposits are always less than or equal to the provided and desired values.

func (*BasePool) IsEmpty

func (p *BasePool) IsEmpty() bool

IsEmpty returns true if all reserves are zero and returns false if reserveA or reserveB is not empty

func (*BasePool) RemoveLiquidity

func (p *BasePool) RemoveLiquidity(shares sdk.Int) (sdk.Int, sdk.Int)

RemoveLiquidity removes liquidity from the pool and panics if the shares provided are greater than the total shares of the pool or the shares are not positive. In addition, also panics if reserves go negative, which should not happen. If panic occurs, it is a bug.

func (*BasePool) ReservesA

func (p *BasePool) ReservesA() sdk.Int

ReservesA returns the A reserves of the pool

func (*BasePool) ReservesB

func (p *BasePool) ReservesB() sdk.Int

ReservesB returns the B reserves of the pool

func (*BasePool) ShareValue

func (p *BasePool) ShareValue(shares sdk.Int) (sdk.Int, sdk.Int)

ShareValue returns the value of the provided shares and panics if the shares are greater than the total shares of the pool or if the shares are not positive.

func (*BasePool) SwapAForExactB

func (p *BasePool) SwapAForExactB(b sdk.Int, fee sdk.Dec) (sdk.Int, sdk.Int)

SwapAForExactB trades a for an exact b. Returns the positive amount a that is added to the pool, and the portion of a that is used to pay the fee.

func (*BasePool) SwapBForExactA

func (p *BasePool) SwapBForExactA(a sdk.Int, fee sdk.Dec) (sdk.Int, sdk.Int)

SwapBForExactA trades b for an exact a. Returns the positive amount b that is added to the pool, and the portion of b that is used to pay the fee.

func (*BasePool) SwapExactAForB

func (p *BasePool) SwapExactAForB(a sdk.Int, fee sdk.Dec) (sdk.Int, sdk.Int)

SwapExactAForB trades an exact value of a for b. Returns the positive amount b that is removed from the pool and the portion of a that is used for paying the fee.

func (*BasePool) SwapExactBForA

func (p *BasePool) SwapExactBForA(b sdk.Int, fee sdk.Dec) (sdk.Int, sdk.Int)

SwapExactBForA trades an exact value of b for a. Returns the positive amount a that is removed from the pool and the portion of b that is used for paying the fee.

func (*BasePool) TotalShares

func (p *BasePool) TotalShares() sdk.Int

TotalShares returns the total number of shares in the pool

type DenominatedPool

type DenominatedPool struct {
	// contains filtered or unexported fields
}

DenominatedPool implements a denominated constant-product liquidity pool

func NewDenominatedPool

func NewDenominatedPool(reserves sdk.Coins) (*DenominatedPool, error)

NewDenominatedPool creates a new denominated pool from reserve coins

func NewDenominatedPoolWithExistingShares

func NewDenominatedPoolWithExistingShares(reserves sdk.Coins, totalShares sdk.Int) (*DenominatedPool, error)

NewDenominatedPoolWithExistingShares creates a new denominated pool from reserve coins

func (*DenominatedPool) AddLiquidity

func (p *DenominatedPool) AddLiquidity(deposit sdk.Coins) (sdk.Coins, sdk.Int)

AddLiquidity adds liquidity to the reserves and returns the added amount and shares created

func (*DenominatedPool) IsEmpty

func (p *DenominatedPool) IsEmpty() bool

IsEmpty returns true if the pool is empty

func (*DenominatedPool) RemoveLiquidity

func (p *DenominatedPool) RemoveLiquidity(shares sdk.Int) sdk.Coins

RemoveLiquidity removes liquidity from the pool

func (*DenominatedPool) Reserves

func (p *DenominatedPool) Reserves() sdk.Coins

Reserves returns the reserves held in the pool

func (*DenominatedPool) ShareValue

func (p *DenominatedPool) ShareValue(shares sdk.Int) sdk.Coins

ShareValue returns the value of the provided shares

func (*DenominatedPool) SwapWithExactInput

func (p *DenominatedPool) SwapWithExactInput(swapInput sdk.Coin, fee sdk.Dec) (sdk.Coin, sdk.Coin)

SwapWithExactInput trades an exact input coin for the other. Returns the positive other coin amount that is removed from the pool and the portion of the input coin that is used for the fee. It panics if the input denom does not match the pool reserves.

func (*DenominatedPool) SwapWithExactOutput

func (p *DenominatedPool) SwapWithExactOutput(swapOutput sdk.Coin, fee sdk.Dec) (sdk.Coin, sdk.Coin)

SwapWithExactOutput trades a coin for an exact output coin b. Returns the positive input coin that is added to the pool, and the portion of that input that is used to pay the fee. Panics if the output denom does not match the pool reserves.

func (*DenominatedPool) TotalShares

func (p *DenominatedPool) TotalShares() sdk.Int

TotalShares returns the total shares for the pool

type DepositsQueryResult

type DepositsQueryResult struct {
	Depositor   sdk.AccAddress `json:"depositor" yaml:"depositor"`
	PoolID      string         `json:"pool_id" yaml:"pool_id"`
	SharesOwned sdk.Int        `json:"shares_owned" yaml:"shares_owned"`
	SharesValue sdk.Coins      `json:"shares_value" yaml:"shares_value"`
}

DepositsQueryResult contains the result of a deposits query

func NewDepositsQueryResult

func NewDepositsQueryResult(shareRecord ShareRecord, sharesValue sdk.Coins) DepositsQueryResult

NewDepositsQueryResult creates a new DepositsQueryResult

type DepositsQueryResults

type DepositsQueryResults []DepositsQueryResult

DepositsQueryResults is a slice of DepositsQueryResult

type GenesisState

type GenesisState struct {
	Params       Params `json:"params" yaml:"params"`
	PoolRecords  `json:"pool_records" yaml:"pool_records"`
	ShareRecords `json:"share_records" yaml:"share_records"`
}

GenesisState is the state that must be provided at genesis.

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns a default genesis state

func NewGenesisState

func NewGenesisState(params Params, poolRecords PoolRecords, shareRecords ShareRecords) GenesisState

NewGenesisState creates a new genesis state.

func (GenesisState) Equal

func (gs GenesisState) Equal(gs2 GenesisState) bool

Equal checks whether two gov GenesisState structs are equivalent

func (GenesisState) IsEmpty

func (gs GenesisState) IsEmpty() bool

IsEmpty returns true if a GenesisState is empty

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate validates the module's genesis state

type MsgDeposit

type MsgDeposit struct {
	Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
	TokenA    sdk.Coin       `json:"token_a" yaml:"token_a"`
	TokenB    sdk.Coin       `json:"token_b" yaml:"token_b"`
	Slippage  sdk.Dec        `json:"slippage" yaml:"slippage"`
	Deadline  int64          `json:"deadline" yaml:"deadline"`
}

MsgDeposit deposits liquidity into a pool

func NewMsgDeposit

func NewMsgDeposit(depositor sdk.AccAddress, tokenA sdk.Coin, tokenB sdk.Coin, slippage sdk.Dec, deadline int64) MsgDeposit

NewMsgDeposit returns a new MsgDeposit

func (MsgDeposit) DeadlineExceeded

func (msg MsgDeposit) DeadlineExceeded(blockTime time.Time) bool

DeadlineExceeded returns if the msg has exceeded it's deadline

func (MsgDeposit) GetDeadline

func (msg MsgDeposit) GetDeadline() time.Time

GetDeadline returns the time at which the msg is considered invalid

func (MsgDeposit) GetSignBytes

func (msg MsgDeposit) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgDeposit) GetSigners

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

GetSigners returns the addresses of signers that must sign.

func (MsgDeposit) Route

func (msg MsgDeposit) Route() string

Route return the message type used for routing the message.

func (MsgDeposit) Type

func (msg MsgDeposit) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgDeposit) ValidateBasic

func (msg MsgDeposit) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgSwapExactForTokens

type MsgSwapExactForTokens struct {
	Requester   sdk.AccAddress `json:"requester" yaml:"requester"`
	ExactTokenA sdk.Coin       `json:"exact_token_a" yaml:"exact_token_a"`
	TokenB      sdk.Coin       `json:"token_b" yaml:"token_b"`
	Slippage    sdk.Dec        `json:"slippage" yaml:"slippage"`
	Deadline    int64          `json:"deadline" yaml:"deadline"`
}

MsgSwapExactForTokens trades an exact coinA for coinB

func NewMsgSwapExactForTokens

func NewMsgSwapExactForTokens(requester sdk.AccAddress, exactTokenA sdk.Coin, tokenB sdk.Coin, slippage sdk.Dec, deadline int64) MsgSwapExactForTokens

NewMsgSwapExactForTokens returns a new MsgSwapExactForTokens

func (MsgSwapExactForTokens) DeadlineExceeded

func (msg MsgSwapExactForTokens) DeadlineExceeded(blockTime time.Time) bool

DeadlineExceeded returns if the msg has exceeded it's deadline

func (MsgSwapExactForTokens) GetDeadline

func (msg MsgSwapExactForTokens) GetDeadline() time.Time

GetDeadline returns the time at which the msg is considered invalid

func (MsgSwapExactForTokens) GetSignBytes

func (msg MsgSwapExactForTokens) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgSwapExactForTokens) GetSigners

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

GetSigners returns the addresses of signers that must sign.

func (MsgSwapExactForTokens) Route

func (msg MsgSwapExactForTokens) Route() string

Route return the message type used for routing the message.

func (MsgSwapExactForTokens) Type

func (msg MsgSwapExactForTokens) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgSwapExactForTokens) ValidateBasic

func (msg MsgSwapExactForTokens) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgSwapForExactTokens

type MsgSwapForExactTokens struct {
	Requester   sdk.AccAddress `json:"requester" yaml:"requester"`
	TokenA      sdk.Coin       `json:"token_a" yaml:"token_a"`
	ExactTokenB sdk.Coin       `json:"exact_token_b" yaml:"exact_token_b"`
	Slippage    sdk.Dec        `json:"slippage" yaml:"slippage"`
	Deadline    int64          `json:"deadline" yaml:"deadline"`
}

MsgSwapForExactTokens trades coinA for an exact coinB

func NewMsgSwapForExactTokens

func NewMsgSwapForExactTokens(requester sdk.AccAddress, tokenA sdk.Coin, exactTokenB sdk.Coin, slippage sdk.Dec, deadline int64) MsgSwapForExactTokens

NewMsgSwapForExactTokens returns a new MsgSwapForExactTokens

func (MsgSwapForExactTokens) DeadlineExceeded

func (msg MsgSwapForExactTokens) DeadlineExceeded(blockTime time.Time) bool

DeadlineExceeded returns if the msg has exceeded it's deadline

func (MsgSwapForExactTokens) GetDeadline

func (msg MsgSwapForExactTokens) GetDeadline() time.Time

GetDeadline returns the time at which the msg is considered invalid

func (MsgSwapForExactTokens) GetSignBytes

func (msg MsgSwapForExactTokens) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgSwapForExactTokens) GetSigners

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

GetSigners returns the addresses of signers that must sign.

func (MsgSwapForExactTokens) Route

func (msg MsgSwapForExactTokens) Route() string

Route return the message type used for routing the message.

func (MsgSwapForExactTokens) Type

func (msg MsgSwapForExactTokens) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgSwapForExactTokens) ValidateBasic

func (msg MsgSwapForExactTokens) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgWithDeadline

type MsgWithDeadline interface {
	GetDeadline() time.Time
	DeadlineExceeded(blockTime time.Time) bool
}

MsgWithDeadline allows messages to define a deadline of when they are considered invalid

type MsgWithdraw

type MsgWithdraw struct {
	From      sdk.AccAddress `json:"from" yaml:"from"`
	Shares    sdk.Int        `json:"shares" yaml:"shares"`
	MinTokenA sdk.Coin       `json:"min_token_a" yaml:"min_token_a"`
	MinTokenB sdk.Coin       `json:"min_token_b" yaml:"min_token_b"`
	Deadline  int64          `json:"deadline" yaml:"deadline"`
}

MsgWithdraw deposits liquidity into a pool

func NewMsgWithdraw

func NewMsgWithdraw(from sdk.AccAddress, shares sdk.Int, minTokenA, minTokenB sdk.Coin, deadline int64) MsgWithdraw

NewMsgWithdraw returns a new MsgWithdraw

func (MsgWithdraw) DeadlineExceeded

func (msg MsgWithdraw) DeadlineExceeded(blockTime time.Time) bool

DeadlineExceeded returns if the msg has exceeded it's deadline

func (MsgWithdraw) GetDeadline

func (msg MsgWithdraw) GetDeadline() time.Time

GetDeadline returns the time at which the msg is considered invalid

func (MsgWithdraw) GetSignBytes

func (msg MsgWithdraw) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgWithdraw) GetSigners

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

GetSigners returns the addresses of signers that must sign.

func (MsgWithdraw) Route

func (msg MsgWithdraw) Route() string

Route return the message type used for routing the message.

func (MsgWithdraw) Type

func (msg MsgWithdraw) Type() string

Type returns a human-readable string for the message, intended for utilization within tags.

func (MsgWithdraw) ValidateBasic

func (msg MsgWithdraw) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type Params

type Params struct {
	AllowedPools AllowedPools `json:"allowed_pools" yaml:"allowed_pools"`
	SwapFee      sdk.Dec      `json:"swap_fee" yaml:"swap_fee"`
}

Params are governance parameters for the swap module

func DefaultParams

func DefaultParams() Params

DefaultParams returns default params for swap module

func NewParams

func NewParams(pairs AllowedPools, swapFee sdk.Dec) Params

NewParams returns a new params object

func (*Params) ParamSetPairs

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

ParamSetPairs implements the ParamSet interface and returns all the key/value pairs

func (Params) String

func (p Params) String() string

String implements fmt.Stringer

func (Params) Validate

func (p Params) Validate() error

Validate checks that the parameters have valid values.

type PoolRecord

type PoolRecord struct {
	// primary key
	PoolID      string   `json:"pool_id" yaml:"pool_id"`
	ReservesA   sdk.Coin `json:"reserves_a" yaml:"reserves_a"`
	ReservesB   sdk.Coin `json:"reserves_b" yaml:"reserves_b"`
	TotalShares sdk.Int  `json:"total_shares" yaml:"total_shares"`
}

PoolRecord represents the state of a liquidity pool and is used to store the state of a denominated pool

func NewPoolRecord

func NewPoolRecord(reserves sdk.Coins, totalShares sdk.Int) PoolRecord

NewPoolRecord takes reserve coins and total shares, returning a new pool record with a id

func NewPoolRecordFromPool

func NewPoolRecordFromPool(pool *DenominatedPool) PoolRecord

NewPoolRecordFromPool takes a pointer to a denominated pool and returns a pool record for storage in state.

func (PoolRecord) Reserves

func (p PoolRecord) Reserves() sdk.Coins

Reserves returns the total reserves for a pool

func (PoolRecord) Validate

func (p PoolRecord) Validate() error

Validate performs basic validation checks of the record data

type PoolRecords

type PoolRecords []PoolRecord

PoolRecords is a slice of PoolRecord

func (PoolRecords) Validate

func (prs PoolRecords) Validate() error

Validate performs basic validation checks on all records in the slice

type PoolStatsQueryResult

type PoolStatsQueryResult struct {
	Name        string    `json:"name" yaml:"name"`
	Coins       sdk.Coins `json:"coins" yaml:"coins"`
	TotalShares sdk.Int   `json:"total_shares" yaml:"total_shares"`
}

PoolStatsQueryResult contains the result of a pool query

func NewPoolStatsQueryResult

func NewPoolStatsQueryResult(name string, coins sdk.Coins, totalShares sdk.Int) PoolStatsQueryResult

NewPoolStatsQueryResult creates a new PoolStatsQueryResult

type PoolStatsQueryResults

type PoolStatsQueryResults []PoolStatsQueryResult

PoolStatsQueryResults is a slice of PoolStatsQueryResult

type QueryDepositsParams

type QueryDepositsParams struct {
	Page  int            `json:"page" yaml:"page"`
	Limit int            `json:"limit" yaml:"limit"`
	Owner sdk.AccAddress `json:"owner" yaml:"owner"`
	Pool  string         `json:"pool" yaml:"pool"`
}

QueryDepositsParams is the params for a filtered deposits query

func NewQueryDepositsParams

func NewQueryDepositsParams(page, limit int, owner sdk.AccAddress, pool string) QueryDepositsParams

NewQueryDepositsParams creates a new QueryDepositsParams

type QueryPoolParams

type QueryPoolParams struct {
	Pool string `json:"pool" yaml:"pool"`
}

QueryPoolParams is the params for a pool query

func NewQueryPoolParams

func NewQueryPoolParams(pool string) QueryPoolParams

NewQueryPoolParams creates a new QueryPoolParams

type ShareRecord

type ShareRecord struct {
	// primary key
	Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
	// secondary / sort key
	PoolID      string  `json:"pool_id" yaml:"pool_id"`
	SharesOwned sdk.Int `json:"shares_owned" yaml:"shares_owned"`
}

ShareRecord stores the shares owned for a depositor and pool

func NewShareRecord

func NewShareRecord(depositor sdk.AccAddress, poolID string, sharesOwned sdk.Int) ShareRecord

NewShareRecord takes a depositor, poolID, and shares and returns a new share record for storage in state.

func (ShareRecord) Validate

func (sr ShareRecord) Validate() error

Validate performs basic validation checks of the record data

type ShareRecords

type ShareRecords []ShareRecord

ShareRecords is a slice of ShareRecord

func (ShareRecords) Validate

func (srs ShareRecords) Validate() error

Validate performs basic validation checks on all records in the slice

type SupplyKeeper

type SupplyKeeper interface {
	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, name string) exported.ModuleAccountI
	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
}

SupplyKeeper defines the expected supply keeper (noalias)

type SwapHooks

type SwapHooks interface {
	AfterPoolDepositCreated(ctx sdk.Context, poolID string, depositor sdk.AccAddress, sharedOwned sdk.Int)
	BeforePoolDepositModified(ctx sdk.Context, poolID string, depositor sdk.AccAddress, sharedOwned sdk.Int)
}

SwapHooks are event hooks called when a user's deposit to a swap pool changes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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