balancer

package
v20.0.0-...-da339d1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package balancer implements weighted constant product AMMs, satisfying the AMM pool interface from x/gamm/types. Please refer to the specification under /spec for further information, and the Balancer projects documentation for more details on the mathematical equations.

Index

Constants

View Source
const (
	TypeMsgCreateBalancerPool = "create_balancer_pool"
)

Variables

View Source
var (
	ErrInvalidLengthBalancerPool        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowBalancerPool          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupBalancerPool = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	// Pool creators can specify a weight in [1, MaxUserSpecifiedWeight)
	// for every token in the balancer pool.
	//
	// The weight used in the balancer equation is then creator-specified-weight * GuaranteedWeightPrecision.
	// This is done so that LBP's / smooth weight changes can actually happen smoothly,
	// without complex precision loss / edge effects.
	MaxUserSpecifiedWeight osmomath.Int = osmomath.NewIntFromUint64(1 << 20)
	// Scaling factor for every weight. The pool weight is:
	// weight_in_MsgCreateBalancerPool * GuaranteedWeightPrecision
	//
	// This is done so that smooth weight changes have enough precision to actually be smooth.
	GuaranteedWeightPrecision int64 = 1 << 30

	PoolTypeName string = "Balancer"
)
View Source
var (
	ErrInvalidLengthTx        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTx          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (

	// ModuleCdc references the global x/bank module codec. Note, the codec should
	// ONLY be used in certain instances of tests and for JSON encoding as Amino is
	// still used for that purpose.
	//
	// The actual codec used for serialization should be provided to x/staking and
	// defined at the application level.
	ModuleCdc = codec.NewAminoCodec(amino)
)

Functions

func RegisterInterfaces

func RegisterInterfaces(registry codectypes.InterfaceRegistry)

func RegisterLegacyAminoCodec

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the necessary x/gamm interfaces and concrete types on the provided LegacyAmino codec. These types are used for Amino JSON serialization.

func RegisterMsgServer

func RegisterMsgServer(s grpc1.Server, srv MsgServer)

func ValidateUserSpecifiedWeight

func ValidateUserSpecifiedWeight(weight osmomath.Int) error

ValidateUserSpecifiedWeight ensures that a weight that is provided from user-input anywhere for creating a pool obeys the expected guarantees. Namely, that the weight is in the range [1, MaxUserSpecifiedWeight)

Types

type MsgClient

type MsgClient interface {
	CreateBalancerPool(ctx context.Context, in *MsgCreateBalancerPool, opts ...grpc.CallOption) (*MsgCreateBalancerPoolResponse, error)
}

MsgClient is the client API for Msg service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewMsgClient

func NewMsgClient(cc grpc1.ClientConn) MsgClient

type MsgCreateBalancerPool

type MsgCreateBalancerPool struct {
	Sender             string      `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
	PoolParams         *PoolParams `protobuf:"bytes,2,opt,name=pool_params,json=poolParams,proto3" json:"pool_params,omitempty" yaml:"pool_params"`
	PoolAssets         []PoolAsset `protobuf:"bytes,3,rep,name=pool_assets,json=poolAssets,proto3" json:"pool_assets"`
	FuturePoolGovernor string      `` /* 145-byte string literal not displayed */
}

===================== MsgCreatePool

func NewMsgCreateBalancerPool

func NewMsgCreateBalancerPool(
	sender sdk.AccAddress,
	poolParams PoolParams,
	poolAssets []PoolAsset,
	futurePoolGovernor string,
) MsgCreateBalancerPool

func (MsgCreateBalancerPool) CreatePool

func (msg MsgCreateBalancerPool) CreatePool(ctx sdk.Context, poolID uint64) (poolmanagertypes.PoolI, error)

func (*MsgCreateBalancerPool) Descriptor

func (*MsgCreateBalancerPool) Descriptor() ([]byte, []int)

func (*MsgCreateBalancerPool) GetFuturePoolGovernor

func (m *MsgCreateBalancerPool) GetFuturePoolGovernor() string

func (*MsgCreateBalancerPool) GetPoolAssets

func (m *MsgCreateBalancerPool) GetPoolAssets() []PoolAsset

func (*MsgCreateBalancerPool) GetPoolParams

func (m *MsgCreateBalancerPool) GetPoolParams() *PoolParams

func (MsgCreateBalancerPool) GetPoolType

func (*MsgCreateBalancerPool) GetSender

func (m *MsgCreateBalancerPool) GetSender() string

func (MsgCreateBalancerPool) GetSignBytes

func (msg MsgCreateBalancerPool) GetSignBytes() []byte

func (MsgCreateBalancerPool) GetSigners

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

func (MsgCreateBalancerPool) InitialLiquidity

func (msg MsgCreateBalancerPool) InitialLiquidity() sdk.Coins

func (*MsgCreateBalancerPool) Marshal

func (m *MsgCreateBalancerPool) Marshal() (dAtA []byte, err error)

func (*MsgCreateBalancerPool) MarshalTo

func (m *MsgCreateBalancerPool) MarshalTo(dAtA []byte) (int, error)

func (*MsgCreateBalancerPool) MarshalToSizedBuffer

func (m *MsgCreateBalancerPool) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (MsgCreateBalancerPool) PoolCreator

func (msg MsgCreateBalancerPool) PoolCreator() sdk.AccAddress

func (*MsgCreateBalancerPool) ProtoMessage

func (*MsgCreateBalancerPool) ProtoMessage()

func (*MsgCreateBalancerPool) Reset

func (m *MsgCreateBalancerPool) Reset()

func (MsgCreateBalancerPool) Route

func (msg MsgCreateBalancerPool) Route() string

func (*MsgCreateBalancerPool) Size

func (m *MsgCreateBalancerPool) Size() (n int)

func (*MsgCreateBalancerPool) String

func (m *MsgCreateBalancerPool) String() string

func (MsgCreateBalancerPool) Type

func (msg MsgCreateBalancerPool) Type() string

func (*MsgCreateBalancerPool) Unmarshal

func (m *MsgCreateBalancerPool) Unmarshal(dAtA []byte) error

func (MsgCreateBalancerPool) Validate

func (msg MsgCreateBalancerPool) Validate(ctx sdk.Context) error

func (MsgCreateBalancerPool) ValidateBasic

func (msg MsgCreateBalancerPool) ValidateBasic() error

func (*MsgCreateBalancerPool) XXX_DiscardUnknown

func (m *MsgCreateBalancerPool) XXX_DiscardUnknown()

func (*MsgCreateBalancerPool) XXX_Marshal

func (m *MsgCreateBalancerPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgCreateBalancerPool) XXX_Merge

func (m *MsgCreateBalancerPool) XXX_Merge(src proto.Message)

func (*MsgCreateBalancerPool) XXX_Size

func (m *MsgCreateBalancerPool) XXX_Size() int

func (*MsgCreateBalancerPool) XXX_Unmarshal

func (m *MsgCreateBalancerPool) XXX_Unmarshal(b []byte) error

type MsgCreateBalancerPoolResponse

type MsgCreateBalancerPoolResponse struct {
	PoolID uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"`
}

Returns the poolID

func (*MsgCreateBalancerPoolResponse) Descriptor

func (*MsgCreateBalancerPoolResponse) Descriptor() ([]byte, []int)

func (*MsgCreateBalancerPoolResponse) GetPoolID

func (m *MsgCreateBalancerPoolResponse) GetPoolID() uint64

func (*MsgCreateBalancerPoolResponse) Marshal

func (m *MsgCreateBalancerPoolResponse) Marshal() (dAtA []byte, err error)

func (*MsgCreateBalancerPoolResponse) MarshalTo

func (m *MsgCreateBalancerPoolResponse) MarshalTo(dAtA []byte) (int, error)

func (*MsgCreateBalancerPoolResponse) MarshalToSizedBuffer

func (m *MsgCreateBalancerPoolResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgCreateBalancerPoolResponse) ProtoMessage

func (*MsgCreateBalancerPoolResponse) ProtoMessage()

func (*MsgCreateBalancerPoolResponse) Reset

func (m *MsgCreateBalancerPoolResponse) Reset()

func (*MsgCreateBalancerPoolResponse) Size

func (m *MsgCreateBalancerPoolResponse) Size() (n int)

func (*MsgCreateBalancerPoolResponse) String

func (*MsgCreateBalancerPoolResponse) Unmarshal

func (m *MsgCreateBalancerPoolResponse) Unmarshal(dAtA []byte) error

func (*MsgCreateBalancerPoolResponse) XXX_DiscardUnknown

func (m *MsgCreateBalancerPoolResponse) XXX_DiscardUnknown()

func (*MsgCreateBalancerPoolResponse) XXX_Marshal

func (m *MsgCreateBalancerPoolResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgCreateBalancerPoolResponse) XXX_Merge

func (m *MsgCreateBalancerPoolResponse) XXX_Merge(src proto.Message)

func (*MsgCreateBalancerPoolResponse) XXX_Size

func (m *MsgCreateBalancerPoolResponse) XXX_Size() int

func (*MsgCreateBalancerPoolResponse) XXX_Unmarshal

func (m *MsgCreateBalancerPoolResponse) XXX_Unmarshal(b []byte) error

type MsgServer

type MsgServer interface {
	CreateBalancerPool(context.Context, *MsgCreateBalancerPool) (*MsgCreateBalancerPoolResponse, error)
}

MsgServer is the server API for Msg service.

type Pool

type Pool struct {
	Address    string     `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"`
	Id         uint64     `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"`
	PoolParams PoolParams `protobuf:"bytes,3,opt,name=pool_params,json=poolParams,proto3" json:"pool_params" yaml:"balancer_pool_params"`
	// This string specifies who will govern the pool in the future.
	// Valid forms of this are:
	// {token name},{duration}
	// {duration}
	// where {token name} if specified is the token which determines the
	// governor, and if not specified is the LP token for this pool.duration is
	// a time specified as 0w,1w,2w, etc. which specifies how long the token
	// would need to be locked up to count in governance. 0w means no lockup.
	// TODO: Further improve these docs
	FuturePoolGovernor string `` /* 145-byte string literal not displayed */
	// sum of all LP tokens sent out
	TotalShares types1.Coin `protobuf:"bytes,5,opt,name=total_shares,json=totalShares,proto3" json:"total_shares" yaml:"total_shares"`
	// These are assumed to be sorted by denomiation.
	// They contain the pool asset and the information about the weight
	PoolAssets []PoolAsset `protobuf:"bytes,6,rep,name=pool_assets,json=poolAssets,proto3" json:"pool_assets" yaml:"pool_assets"`
	// sum of all non-normalized pool weights
	TotalWeight cosmossdk_io_math.Int `` /* 137-byte string literal not displayed */
}

func NewBalancerPool

func NewBalancerPool(poolId uint64, balancerPoolParams PoolParams, assets []PoolAsset, futureGovernor string, blockTime time.Time) (Pool, error)

NewPool returns a weighted CPMM pool with the provided parameters, and initial assets. Invariants that are assumed to be satisfied and not checked: (This is handled in ValidateBasic) * 2 <= len(assets) <= 8 * FutureGovernor is valid * poolID doesn't already exist

func (*Pool) AddTotalShares

func (p *Pool) AddTotalShares(amt osmomath.Int)

func (*Pool) AsSerializablePool

func (p *Pool) AsSerializablePool() poolmanagertypes.PoolI

func (*Pool) CalcExitPoolCoinsFromShares

func (p *Pool) CalcExitPoolCoinsFromShares(ctx sdk.Context, exitingShares osmomath.Int, exitFee osmomath.Dec) (exitedCoins sdk.Coins, err error)

func (Pool) CalcInAmtGivenOut

func (p Pool) CalcInAmtGivenOut(
	ctx sdk.Context, tokensOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (
	tokenIn sdk.Coin, err error,
)

CalcInAmtGivenOut calculates token to be provided, fee added, given the swapped out amount, using solveConstantFunctionInvariant.

func (*Pool) CalcJoinPoolNoSwapShares

func (p *Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, tokensJoined sdk.Coins, err error)

CalcJoinPoolNoSwapShares calculates the number of shares created to execute an all-asset pool join with the provided amount of `tokensIn`. The input tokens must contain the same tokens as in the pool.

Returns the number of shares created, the amount of coins actually joined into the pool, (in case of not being able to fully join), and the remaining tokens in `tokensIn` after joining. If an all-asset join is not possible, returns an error.

Since CalcJoinPoolNoSwapShares is non-mutative, the steps for updating pool shares / liquidity are more complex / don't just alter the state. We should simplify this logic further in the future using multi-join equations.

func (*Pool) CalcJoinPoolShares

func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, tokensJoined sdk.Coins, err error)

CalcJoinPoolShares calculates the number of shares created to join pool with the provided amount of `tokenIn`. The input tokens must either be: - a single token - contain exactly the same tokens as the pool contains

It returns the number of shares created, the amount of coins actually joined into the pool (in case of not being able to fully join), or an error.

func (Pool) CalcOutAmtGivenIn

func (p Pool) CalcOutAmtGivenIn(
	ctx sdk.Context,
	tokensIn sdk.Coins,
	tokenOutDenom string,
	spreadFactor osmomath.Dec,
) (sdk.Coin, error)

CalcOutAmtGivenIn calculates tokens to be swapped out given the provided amount and fee deducted, using solveConstantFunctionInvariant.

func (*Pool) CalcTokenInShareAmountOut

func (p *Pool) CalcTokenInShareAmountOut(
	ctx sdk.Context,
	tokenInDenom string,
	shareOutAmount osmomath.Int,
	spreadFactor osmomath.Dec,
) (tokenInAmount osmomath.Int, err error)

func (*Pool) Descriptor

func (*Pool) Descriptor() ([]byte, []int)

func (*Pool) ExitPool

func (p *Pool) ExitPool(ctx sdk.Context, exitingShares osmomath.Int, exitFee osmomath.Dec) (exitingCoins sdk.Coins, err error)

func (*Pool) ExitSwapExactAmountOut

func (p *Pool) ExitSwapExactAmountOut(
	ctx sdk.Context,
	tokenOut sdk.Coin,
	shareInMaxAmount osmomath.Int,
) (shareInAmount osmomath.Int, err error)

func (Pool) GetAddress

func (p Pool) GetAddress() sdk.AccAddress

GetAddress returns the address of a pool. If the pool address is not bech32 valid, it returns an empty address.

func (Pool) GetAllPoolAssets

func (p Pool) GetAllPoolAssets() []PoolAsset

func (Pool) GetExitFee

func (p Pool) GetExitFee(_ sdk.Context) osmomath.Dec

func (Pool) GetId

func (p Pool) GetId() uint64

func (Pool) GetPoolAsset

func (p Pool) GetPoolAsset(denom string) (PoolAsset, error)

GetPoolAssets returns the denom's PoolAsset, If the PoolAsset doesn't exist, will return error. As above, it will search the denom's PoolAsset by using binary search. So, it is important to make sure that the PoolAssets are sorted.

func (Pool) GetPoolAssets

func (p Pool) GetPoolAssets(denoms ...string) ([]PoolAsset, error)

func (Pool) GetPoolParams

func (p Pool) GetPoolParams() PoolParams

func (Pool) GetSpreadFactor

func (p Pool) GetSpreadFactor(_ sdk.Context) osmomath.Dec

func (Pool) GetTokenBalance

func (p Pool) GetTokenBalance(denom string) (osmomath.Int, error)

func (Pool) GetTokenWeight

func (p Pool) GetTokenWeight(denom string) (osmomath.Int, error)

func (Pool) GetTotalPoolLiquidity

func (p Pool) GetTotalPoolLiquidity(_ sdk.Context) sdk.Coins

func (Pool) GetTotalShares

func (p Pool) GetTotalShares() osmomath.Int

func (Pool) GetTotalWeight

func (p Pool) GetTotalWeight() osmomath.Int

func (Pool) GetType

func (p Pool) GetType() poolmanagertypes.PoolType

func (*Pool) IncreaseLiquidity

func (p *Pool) IncreaseLiquidity(sharesOut osmomath.Int, coinsIn sdk.Coins)

func (Pool) IsActive

func (p Pool) IsActive(ctx sdk.Context) bool

func (*Pool) JoinPool

func (p *Pool) JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error)

JoinPool calculates the number of shares needed given tokensIn with spreadFactor applied. It updates the liquidity if the pool is joined successfully. If not, returns error. and updates pool accordingly.

func (*Pool) JoinPoolNoSwap

func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error)

JoinPoolNoSwap calculates the number of shares needed for an all-asset join given tokensIn with spreadFactor applied. It updates the liquidity if the pool is joined successfully. If not, returns error.

func (*Pool) JoinPoolTokenInMaxShareAmountOut

func (p *Pool) JoinPoolTokenInMaxShareAmountOut(
	ctx sdk.Context,
	tokenInDenom string,
	shareOutAmount osmomath.Int,
) (tokenInAmount osmomath.Int, err error)

func (*Pool) Marshal

func (m *Pool) Marshal() (dAtA []byte, err error)

func (Pool) MarshalJSON

func (p Pool) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of a Pool.

func (*Pool) MarshalTo

func (m *Pool) MarshalTo(dAtA []byte) (int, error)

func (*Pool) MarshalToSizedBuffer

func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (Pool) NumAssets

func (p Pool) NumAssets() int

func (*Pool) PokePool

func (p *Pool) PokePool(blockTime time.Time)

PokePool checks to see if the pool's token weights need to be updated, and if so, does so. Currently doesn't do anything outside out LBPs.

func (*Pool) ProtoMessage

func (*Pool) ProtoMessage()

func (*Pool) Reset

func (m *Pool) Reset()

func (*Pool) SetInitialPoolAssets

func (p *Pool) SetInitialPoolAssets(PoolAssets []PoolAsset) error

SetInitialPoolAssets sets the PoolAssets in the pool. It is only designed to be called at the pool's creation. If the same denom's PoolAsset exists, will return error.

The list of PoolAssets must be sorted. This is done to enable fast searching for a PoolAsset by denomination. TODO: Unify story for validation of []PoolAsset, some is here, some is in CreatePool.ValidateBasic()

func (*Pool) Size

func (m *Pool) Size() (n int)

func (Pool) SpotPrice

func (p Pool) SpotPrice(ctx sdk.Context, quoteAsset, baseAsset string) (spotPrice osmomath.BigDec, err error)

SpotPrice returns the spot price of the pool This is the weight-adjusted balance of the tokens in the pool. To reduce the propagated effect of incorrect trailing digits, we take the ratio of weights and divide this by ratio of supplies this is equivalent to spot_price = (Quote Supply / Quote Weight) / (Base Supply / Base Weight)

As an example, assume equal weights. ufury supply of 2 and uatom supply of 4.

Case 1: base = ufury, quote = uatom -> for one ufury, get 2 uatom = 4 / 2 = 2 In other words, it costs 2 uatom to get one ufury.

Case 2: base = uatom, quote = ufury -> for one uatom, get 0.5 ufury = 2 / 4 = 0.5 In other words, it costs 0.5 ufury to get one uatom.

panics if the pool in state is incorrect, and has any weight that is 0.

func (Pool) String

func (p Pool) String() string

func (*Pool) SubTotalShares

func (p *Pool) SubTotalShares(amt osmomath.Int)

func (*Pool) SwapInAmtGivenOut

func (p *Pool) SwapInAmtGivenOut(
	ctx sdk.Context, tokensOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (
	tokenIn sdk.Coin, err error,
)

SwapInAmtGivenOut is a mutative method for CalcOutAmtGivenIn, which includes the actual swap.

func (*Pool) SwapOutAmtGivenIn

func (p *Pool) SwapOutAmtGivenIn(
	ctx sdk.Context,
	tokensIn sdk.Coins,
	tokenOutDenom string,
	spreadFactor osmomath.Dec,
) (
	tokenOut sdk.Coin, err error,
)

SwapOutAmtGivenIn is a mutative method for CalcOutAmtGivenIn, which includes the actual swap.

func (*Pool) Unmarshal

func (m *Pool) Unmarshal(dAtA []byte) error

func (*Pool) UnmarshalJSON

func (p *Pool) UnmarshalJSON(bz []byte) error

UnmarshalJSON unmarshals raw JSON bytes into a Pool.

func (*Pool) UpdatePoolAssetBalance

func (p *Pool) UpdatePoolAssetBalance(coin sdk.Coin) error

func (*Pool) UpdatePoolAssetBalances

func (p *Pool) UpdatePoolAssetBalances(coins sdk.Coins) error

func (*Pool) XXX_DiscardUnknown

func (m *Pool) XXX_DiscardUnknown()

func (*Pool) XXX_Marshal

func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Pool) XXX_Merge

func (m *Pool) XXX_Merge(src proto.Message)

func (*Pool) XXX_Size

func (m *Pool) XXX_Size() int

func (*Pool) XXX_Unmarshal

func (m *Pool) XXX_Unmarshal(b []byte) error

type PoolAsset

type PoolAsset struct {
	// Coins we are talking about,
	// the denomination must be unique amongst all PoolAssets for this pool.
	Token types1.Coin `protobuf:"bytes,1,opt,name=token,proto3" json:"token" yaml:"token"`
	// Weight that is not normalized. This weight must be less than 2^50
	Weight cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=cosmossdk.io/math.Int" json:"weight" yaml:"weight"`
}

Pool asset is an internal struct that combines the amount of the token in the pool, and its balancer weight. This is an awkward packaging of data, and should be revisited in a future state migration.

func (*PoolAsset) Descriptor

func (*PoolAsset) Descriptor() ([]byte, []int)

func (*PoolAsset) GetToken

func (m *PoolAsset) GetToken() types1.Coin

func (*PoolAsset) Marshal

func (m *PoolAsset) Marshal() (dAtA []byte, err error)

func (*PoolAsset) MarshalTo

func (m *PoolAsset) MarshalTo(dAtA []byte) (int, error)

func (*PoolAsset) MarshalToSizedBuffer

func (m *PoolAsset) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (PoolAsset) MarshalYAML

func (pa PoolAsset) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of a PoolAsset. This is assumed to not be called on a stand-alone instance, so it removes the first marshalled line.

func (*PoolAsset) ProtoMessage

func (*PoolAsset) ProtoMessage()

func (*PoolAsset) Reset

func (m *PoolAsset) Reset()

func (*PoolAsset) Size

func (m *PoolAsset) Size() (n int)

func (*PoolAsset) String

func (m *PoolAsset) String() string

func (*PoolAsset) Unmarshal

func (m *PoolAsset) Unmarshal(dAtA []byte) error

func (*PoolAsset) XXX_DiscardUnknown

func (m *PoolAsset) XXX_DiscardUnknown()

func (*PoolAsset) XXX_Marshal

func (m *PoolAsset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PoolAsset) XXX_Merge

func (m *PoolAsset) XXX_Merge(src proto.Message)

func (*PoolAsset) XXX_Size

func (m *PoolAsset) XXX_Size() int

func (*PoolAsset) XXX_Unmarshal

func (m *PoolAsset) XXX_Unmarshal(b []byte) error

type PoolParams

type PoolParams struct {
	SwapFee cosmossdk_io_math.LegacyDec `` /* 127-byte string literal not displayed */
	// N.B.: exit fee is disabled during pool creation in x/poolmanager. While old
	// pools can maintain a non-zero fee. No new pool can be created with non-zero
	// fee anymore
	ExitFee                  cosmossdk_io_math.LegacyDec `` /* 127-byte string literal not displayed */
	SmoothWeightChangeParams *SmoothWeightChangeParams   `` /* 172-byte string literal not displayed */
}

PoolParams defined the parameters that will be managed by the pool governance in the future. This params are not managed by the chain governance. Instead they will be managed by the token holders of the pool. The pool's token holders are specified in future_pool_governor.

func NewPoolParams

func NewPoolParams(spreadFactor, exitFee osmomath.Dec, params *SmoothWeightChangeParams) PoolParams

func (*PoolParams) Descriptor

func (*PoolParams) Descriptor() ([]byte, []int)

func (PoolParams) GetPoolExitFee

func (params PoolParams) GetPoolExitFee() osmomath.Dec

func (PoolParams) GetPoolSpreadFactor

func (params PoolParams) GetPoolSpreadFactor() osmomath.Dec

func (*PoolParams) GetSmoothWeightChangeParams

func (m *PoolParams) GetSmoothWeightChangeParams() *SmoothWeightChangeParams

func (*PoolParams) Marshal

func (m *PoolParams) Marshal() (dAtA []byte, err error)

func (*PoolParams) MarshalTo

func (m *PoolParams) MarshalTo(dAtA []byte) (int, error)

func (*PoolParams) MarshalToSizedBuffer

func (m *PoolParams) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PoolParams) ProtoMessage

func (*PoolParams) ProtoMessage()

func (*PoolParams) Reset

func (m *PoolParams) Reset()

func (*PoolParams) Size

func (m *PoolParams) Size() (n int)

func (*PoolParams) String

func (m *PoolParams) String() string

func (*PoolParams) Unmarshal

func (m *PoolParams) Unmarshal(dAtA []byte) error

func (PoolParams) Validate

func (params PoolParams) Validate(poolWeights []PoolAsset) error

func (*PoolParams) XXX_DiscardUnknown

func (m *PoolParams) XXX_DiscardUnknown()

func (*PoolParams) XXX_Marshal

func (m *PoolParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PoolParams) XXX_Merge

func (m *PoolParams) XXX_Merge(src proto.Message)

func (*PoolParams) XXX_Size

func (m *PoolParams) XXX_Size() int

func (*PoolParams) XXX_Unmarshal

func (m *PoolParams) XXX_Unmarshal(b []byte) error

type SmoothWeightChangeParams

type SmoothWeightChangeParams struct {
	// The start time for beginning the weight change.
	// If a parameter change / pool instantiation leaves this blank,
	// it should be generated by the state_machine as the current time.
	StartTime time.Time `protobuf:"bytes,1,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"`
	// Duration for the weights to change over
	Duration time.Duration `protobuf:"bytes,2,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"`
	// The initial pool weights. These are copied from the pool's settings
	// at the time of weight change instantiation.
	// The amount PoolAsset.token.amount field is ignored if present,
	// future type refactorings should just have a type with the denom & weight
	// here.
	InitialPoolWeights []PoolAsset `` /* 135-byte string literal not displayed */
	// The target pool weights. The pool weights will change linearly with respect
	// to time between start_time, and start_time + duration. The amount
	// PoolAsset.token.amount field is ignored if present, future type
	// refactorings should just have a type with the denom & weight here.
	TargetPoolWeights []PoolAsset `` /* 131-byte string literal not displayed */
}

Parameters for changing the weights in a balancer pool smoothly from a start weight and end weight over a period of time. Currently, the only smooth change supported is linear changing between the two weights, but more types may be added in the future. When these parameters are set, the weight w(t) for pool time `t` is the following:

t <= start_time: w(t) = initial_pool_weights
start_time < t <= start_time + duration:
  w(t) = initial_pool_weights + (t - start_time) *
    (target_pool_weights - initial_pool_weights) / (duration)
t > start_time + duration: w(t) = target_pool_weights

func (*SmoothWeightChangeParams) Descriptor

func (*SmoothWeightChangeParams) Descriptor() ([]byte, []int)

func (*SmoothWeightChangeParams) GetDuration

func (m *SmoothWeightChangeParams) GetDuration() time.Duration

func (*SmoothWeightChangeParams) GetInitialPoolWeights

func (m *SmoothWeightChangeParams) GetInitialPoolWeights() []PoolAsset

func (*SmoothWeightChangeParams) GetStartTime

func (m *SmoothWeightChangeParams) GetStartTime() time.Time

func (*SmoothWeightChangeParams) GetTargetPoolWeights

func (m *SmoothWeightChangeParams) GetTargetPoolWeights() []PoolAsset

func (*SmoothWeightChangeParams) Marshal

func (m *SmoothWeightChangeParams) Marshal() (dAtA []byte, err error)

func (*SmoothWeightChangeParams) MarshalTo

func (m *SmoothWeightChangeParams) MarshalTo(dAtA []byte) (int, error)

func (*SmoothWeightChangeParams) MarshalToSizedBuffer

func (m *SmoothWeightChangeParams) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SmoothWeightChangeParams) ProtoMessage

func (*SmoothWeightChangeParams) ProtoMessage()

func (*SmoothWeightChangeParams) Reset

func (m *SmoothWeightChangeParams) Reset()

func (*SmoothWeightChangeParams) Size

func (m *SmoothWeightChangeParams) Size() (n int)

func (*SmoothWeightChangeParams) String

func (m *SmoothWeightChangeParams) String() string

func (*SmoothWeightChangeParams) Unmarshal

func (m *SmoothWeightChangeParams) Unmarshal(dAtA []byte) error

func (*SmoothWeightChangeParams) XXX_DiscardUnknown

func (m *SmoothWeightChangeParams) XXX_DiscardUnknown()

func (*SmoothWeightChangeParams) XXX_Marshal

func (m *SmoothWeightChangeParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SmoothWeightChangeParams) XXX_Merge

func (m *SmoothWeightChangeParams) XXX_Merge(src proto.Message)

func (*SmoothWeightChangeParams) XXX_Size

func (m *SmoothWeightChangeParams) XXX_Size() int

func (*SmoothWeightChangeParams) XXX_Unmarshal

func (m *SmoothWeightChangeParams) XXX_Unmarshal(b []byte) error

type UnimplementedMsgServer

type UnimplementedMsgServer struct {
}

UnimplementedMsgServer can be embedded to have forward compatible implementations.

func (*UnimplementedMsgServer) CreateBalancerPool

Jump to

Keyboard shortcuts

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