balancer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2022 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

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 (
	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/swap 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 ValidateFutureGovernor

func ValidateFutureGovernor(governor string) error

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=poolParams,proto3" json:"poolParams,omitempty" yaml:"pool_params"`
	PoolAssets         []types.PoolAsset `protobuf:"bytes,3,rep,name=poolAssets,proto3" json:"poolAssets"`
	FuturePoolGovernor string            `` /* 145-byte string literal not displayed */
}

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

func (*MsgCreateBalancerPool) Descriptor

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

func (*MsgCreateBalancerPool) GetFuturePoolGovernor

func (m *MsgCreateBalancerPool) GetFuturePoolGovernor() string

func (*MsgCreateBalancerPool) GetPoolAssets

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

func (*MsgCreateBalancerPool) GetPoolParams

func (m *MsgCreateBalancerPool) GetPoolParams() *PoolParams

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) 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) 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) 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 {
}

func (*MsgCreateBalancerPoolResponse) Descriptor

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

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=poolParams,proto3" json:"poolParams" 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=totalShares,proto3" json:"totalShares" yaml:"total_shares"`
	// These are assumed to be sorted by denomiation.
	// They contain the pool asset and the information about the weight
	PoolAssets []types.PoolAsset `protobuf:"bytes,6,rep,name=poolAssets,proto3" json:"poolAssets" yaml:"pool_assets"`
	// sum of all non-normalized pool weights
	TotalWeight github_com_cosmos_cosmos_sdk_types.Int `` /* 135-byte string literal not displayed */
}

func NewBalancerPool

func NewBalancerPool(poolId uint64, balancerPoolParams PoolParams, assets []types.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 (pa *Pool) AddTotalShares(amt sdk.Int)

func (*Pool) Descriptor

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

func (Pool) GetAddress

func (pa 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 (pa Pool) GetAllPoolAssets() []types.PoolAsset

func (Pool) GetId

func (pa Pool) GetId() uint64

func (Pool) GetPoolAsset

func (pa Pool) GetPoolAsset(denom string) (types.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 (pa Pool) GetPoolAssets(denoms ...string) ([]types.PoolAsset, error)

func (Pool) GetPoolExitFee

func (pa Pool) GetPoolExitFee() sdk.Dec

func (Pool) GetPoolParams

func (pa Pool) GetPoolParams() PoolParams

func (Pool) GetPoolSwapFee

func (pa Pool) GetPoolSwapFee() sdk.Dec

func (Pool) GetTokenBalance

func (pa Pool) GetTokenBalance(denom string) (sdk.Int, error)

func (Pool) GetTokenWeight

func (pa Pool) GetTokenWeight(denom string) (sdk.Int, error)

func (Pool) GetTotalShares

func (pa Pool) GetTotalShares() sdk.Coin

func (Pool) GetTotalWeight

func (pa Pool) GetTotalWeight() sdk.Int

func (Pool) IsActive

func (pa Pool) IsActive(curBlockTime time.Time) bool

func (*Pool) Marshal

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

func (Pool) MarshalJSON

func (pa 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 (pa Pool) NumAssets() int

func (*Pool) PokeTokenWeights

func (pa *Pool) PokeTokenWeights(blockTime time.Time)

PokeTokenWeights checks to see if the pool's token weights need to be updated, and if so, does so.

func (*Pool) ProtoMessage

func (*Pool) ProtoMessage()

func (*Pool) Reset

func (m *Pool) Reset()

func (*Pool) Size

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

func (Pool) String

func (pa Pool) String() string

func (*Pool) SubTotalShares

func (pa *Pool) SubTotalShares(amt sdk.Int)

func (*Pool) Unmarshal

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

func (*Pool) UnmarshalJSON

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

UnmarshalJSON unmarshals raw JSON bytes into a Pool.

func (*Pool) UpdatePoolAssetBalance

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

func (*Pool) UpdatePoolAssetBalances

func (pa *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 PoolParams

type PoolParams struct {
	SwapFee                  github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swapFee" yaml:"swap_fee"`
	ExitFee                  github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=exitFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exitFee" yaml:"exit_fee"`
	SmoothWeightChangeParams *SmoothWeightChangeParams              `` /* 136-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 (*PoolParams) Descriptor

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

func (PoolParams) GetPoolExitFee

func (params PoolParams) GetPoolExitFee() sdk.Dec

func (PoolParams) GetPoolSwapFee

func (params PoolParams) GetPoolSwapFee() sdk.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 []types.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 []types.PoolAsset `protobuf:"bytes,3,rep,name=initialPoolWeights,proto3" json:"initialPoolWeights" yaml:"initial_pool_weights"`
	// 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 []types.PoolAsset `protobuf:"bytes,4,rep,name=targetPoolWeights,proto3" json:"targetPoolWeights" yaml:"target_pool_weights"`
}

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() []types.PoolAsset

func (*SmoothWeightChangeParams) GetStartTime

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

func (*SmoothWeightChangeParams) GetTargetPoolWeights

func (m *SmoothWeightChangeParams) GetTargetPoolWeights() []types.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