model

package
v0.1.0-merlin.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeMsgCreateConcentratedPool = "create_concentrated_pool"
)

constants.

Variables

View Source
var (
	ErrInvalidLengthPool        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPool          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupPool = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthPosition        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPosition          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupPosition = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthTickInfo        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTickInfo          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTickInfo = 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 = codec.NewAminoCodec(amino)
)

TODO: re-enable this when CL state-breakage PR is merged. return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))

Functions

func RegisterCodec

func RegisterCodec(cdc *codec.LegacyAmino)

func RegisterInterfaces

func RegisterInterfaces(registry cdctypes.InterfaceRegistry)

func RegisterMsgCreatorServer

func RegisterMsgCreatorServer(s grpc1.Server, srv MsgCreatorServer)

Types

type MsgCreateConcentratedPool

type MsgCreateConcentratedPool struct {
	Sender                    string                                 `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"`
	Denom0                    string                                 `protobuf:"bytes,2,opt,name=denom0,proto3" json:"denom0,omitempty" yaml:"denom0"`
	Denom1                    string                                 `protobuf:"bytes,3,opt,name=denom1,proto3" json:"denom1,omitempty" yaml:"denom1"`
	TickSpacing               uint64                                 `protobuf:"varint,4,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"`
	PrecisionFactorAtPriceOne github_com_cosmos_cosmos_sdk_types.Int `` /* 219-byte string literal not displayed */
	SwapFee                   github_com_cosmos_cosmos_sdk_types.Dec `` /* 138-byte string literal not displayed */
}

===================== MsgCreateConcentratedPool

func NewMsgCreateConcentratedPool

func NewMsgCreateConcentratedPool(
	sender sdk.AccAddress,
	denom0 string,
	denom1 string,
	tickSpacing uint64,
	precisionFactorAtPriceOne sdk.Int,
	swapFee sdk.Dec,
) MsgCreateConcentratedPool

func (MsgCreateConcentratedPool) CreatePool

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

func (*MsgCreateConcentratedPool) Descriptor

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

func (*MsgCreateConcentratedPool) GetDenom0

func (m *MsgCreateConcentratedPool) GetDenom0() string

func (*MsgCreateConcentratedPool) GetDenom1

func (m *MsgCreateConcentratedPool) GetDenom1() string

func (MsgCreateConcentratedPool) GetPoolType

func (*MsgCreateConcentratedPool) GetSender

func (m *MsgCreateConcentratedPool) GetSender() string

func (MsgCreateConcentratedPool) GetSignBytes

func (msg MsgCreateConcentratedPool) GetSignBytes() []byte

func (MsgCreateConcentratedPool) GetSigners

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

func (*MsgCreateConcentratedPool) GetTickSpacing

func (m *MsgCreateConcentratedPool) GetTickSpacing() uint64

func (MsgCreateConcentratedPool) InitialLiquidity

func (msg MsgCreateConcentratedPool) InitialLiquidity() sdk.Coins

func (*MsgCreateConcentratedPool) Marshal

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

func (*MsgCreateConcentratedPool) MarshalTo

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

func (*MsgCreateConcentratedPool) MarshalToSizedBuffer

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

func (MsgCreateConcentratedPool) PoolCreator

func (msg MsgCreateConcentratedPool) PoolCreator() sdk.AccAddress

func (*MsgCreateConcentratedPool) ProtoMessage

func (*MsgCreateConcentratedPool) ProtoMessage()

func (*MsgCreateConcentratedPool) Reset

func (m *MsgCreateConcentratedPool) Reset()

func (MsgCreateConcentratedPool) Route

func (msg MsgCreateConcentratedPool) Route() string

func (*MsgCreateConcentratedPool) Size

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

func (*MsgCreateConcentratedPool) String

func (m *MsgCreateConcentratedPool) String() string

func (MsgCreateConcentratedPool) Type

func (msg MsgCreateConcentratedPool) Type() string

func (*MsgCreateConcentratedPool) Unmarshal

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

func (MsgCreateConcentratedPool) Validate

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

func (MsgCreateConcentratedPool) ValidateBasic

func (msg MsgCreateConcentratedPool) ValidateBasic() error

func (*MsgCreateConcentratedPool) XXX_DiscardUnknown

func (m *MsgCreateConcentratedPool) XXX_DiscardUnknown()

func (*MsgCreateConcentratedPool) XXX_Marshal

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

func (*MsgCreateConcentratedPool) XXX_Merge

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

func (*MsgCreateConcentratedPool) XXX_Size

func (m *MsgCreateConcentratedPool) XXX_Size() int

func (*MsgCreateConcentratedPool) XXX_Unmarshal

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

type MsgCreateConcentratedPoolResponse

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

Returns a unique poolID to identify the pool with.

func (*MsgCreateConcentratedPoolResponse) Descriptor

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

func (*MsgCreateConcentratedPoolResponse) GetPoolID

func (*MsgCreateConcentratedPoolResponse) Marshal

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

func (*MsgCreateConcentratedPoolResponse) MarshalTo

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

func (*MsgCreateConcentratedPoolResponse) MarshalToSizedBuffer

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

func (*MsgCreateConcentratedPoolResponse) ProtoMessage

func (*MsgCreateConcentratedPoolResponse) ProtoMessage()

func (*MsgCreateConcentratedPoolResponse) Reset

func (*MsgCreateConcentratedPoolResponse) Size

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

func (*MsgCreateConcentratedPoolResponse) String

func (*MsgCreateConcentratedPoolResponse) Unmarshal

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

func (*MsgCreateConcentratedPoolResponse) XXX_DiscardUnknown

func (m *MsgCreateConcentratedPoolResponse) XXX_DiscardUnknown()

func (*MsgCreateConcentratedPoolResponse) XXX_Marshal

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

func (*MsgCreateConcentratedPoolResponse) XXX_Merge

func (*MsgCreateConcentratedPoolResponse) XXX_Size

func (m *MsgCreateConcentratedPoolResponse) XXX_Size() int

func (*MsgCreateConcentratedPoolResponse) XXX_Unmarshal

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

type MsgCreatorClient

type MsgCreatorClient interface {
	CreateConcentratedPool(ctx context.Context, in *MsgCreateConcentratedPool, opts ...grpc.CallOption) (*MsgCreateConcentratedPoolResponse, error)
}

MsgCreatorClient is the client API for MsgCreator service.

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

func NewMsgCreatorClient

func NewMsgCreatorClient(cc grpc1.ClientConn) MsgCreatorClient

type MsgCreatorServer

type MsgCreatorServer interface {
	CreateConcentratedPool(context.Context, *MsgCreateConcentratedPool) (*MsgCreateConcentratedPoolResponse, error)
}

MsgCreatorServer is the server API for MsgCreator 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"`
	// Amount of total liquidity
	Liquidity        github_com_cosmos_cosmos_sdk_types.Dec `` /* 128-byte string literal not displayed */
	Token0           string                                 `protobuf:"bytes,4,opt,name=token0,proto3" json:"token0,omitempty"`
	Token1           string                                 `protobuf:"bytes,5,opt,name=token1,proto3" json:"token1,omitempty"`
	CurrentSqrtPrice github_com_cosmos_cosmos_sdk_types.Dec `` /* 169-byte string literal not displayed */
	CurrentTick      github_com_cosmos_cosmos_sdk_types.Int `` /* 154-byte string literal not displayed */
	// tick_spacing must be one of the authorized_tick_spacing values set in the
	// concentrated-liquidity parameters
	TickSpacing               uint64                                 `protobuf:"varint,8,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"`
	PrecisionFactorAtPriceOne github_com_cosmos_cosmos_sdk_types.Int `` /* 219-byte string literal not displayed */
	// swap_fee is the ratio that is charged on the amount of token in.
	SwapFee github_com_cosmos_cosmos_sdk_types.Dec `` /* 139-byte string literal not displayed */
}

func NewConcentratedLiquidityPool

func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpacing uint64, exponentAtPriceOne sdk.Int, swapFee sdk.Dec) (Pool, error)

NewConcentratedLiquidityPool creates a new ConcentratedLiquidity pool with the specified parameters. The two provided denoms are ordered so that denom0 is lexicographically smaller than denom1.

func (*Pool) ApplySwap

func (p *Pool) ApplySwap(newLiquidity sdk.Dec, newCurrentTick sdk.Int, newCurrentSqrtPrice sdk.Dec) error

ApplySwap state of pool after swap. It specifically overwrites the pool's liquidity, curr tick and the curr sqrt price

func (Pool) CalcActualAmounts

func (p Pool) CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, sqrtRatioLowerTick, sqrtRatioUpperTick sdk.Dec, liquidityDelta sdk.Dec) (actualAmountDenom0 sdk.Dec, actualAmountDenom1 sdk.Dec)

calcActualAmounts calculates and returns actual amounts based on where the current tick is located relative to position's lower and upper ticks. There are 3 possible cases: -The position is active ( lowerTick <= p.CurrentTick < upperTick).

  • The provided liquidity is distributed in both tokens.
  • Actual amounts might differ from desired because we recalculate them from liquidity delta and sqrt price. the calculations lead to amounts being off. // TODO: confirm logic is correct

- Current tick is below the position ( p.CurrentTick < lowerTick).

  • The provided liquidity is distributed in token0 only.

- Current tick is above the position ( p.CurrentTick >= p.upperTick ).

  • The provided liquidity is distributed in token1 only.

TODO: add tests.

func (*Pool) Descriptor

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

func (Pool) GetAddress

func (p Pool) GetAddress() sdk.AccAddress

GetAddress returns the address of the concentrated liquidity pool

func (Pool) GetCurrentSqrtPrice

func (p Pool) GetCurrentSqrtPrice() sdk.Dec

GetCurrentSqrtPrice returns the current sqrt price of the pool

func (Pool) GetCurrentTick

func (p Pool) GetCurrentTick() sdk.Int

GetCurrentTick returns the current tick of the pool

func (Pool) GetExitFee

func (p Pool) GetExitFee(ctx sdk.Context) sdk.Dec

GetExitFee returns the exit fee of the pool

func (Pool) GetId

func (p Pool) GetId() uint64

GetId returns the id of the concentrated liquidity pool

func (Pool) GetLiquidity

func (p Pool) GetLiquidity() sdk.Dec

GetLiquidity returns the liquidity of the pool

func (Pool) GetPrecisionFactorAtPriceOne

func (p Pool) GetPrecisionFactorAtPriceOne() sdk.Int

GetPrecisionFactorAtPriceOne returns the precision factor at price one of the pool

func (Pool) GetSwapFee

func (p Pool) GetSwapFee(ctx sdk.Context) sdk.Dec

GetSwapFee returns the swap fee of the pool

func (Pool) GetTickSpacing

func (p Pool) GetTickSpacing() uint64

GetTickSpacing returns the current tick spacing parameter of the pool

func (Pool) GetToken0

func (p Pool) GetToken0() string

GetToken0 returns the token0 of the pool

func (Pool) GetToken1

func (p Pool) GetToken1() string

GetToken1 returns the token1 of the pool

func (Pool) GetTotalPoolLiquidity

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

TODO: finish this function

func (Pool) GetTotalShares

func (p Pool) GetTotalShares() sdk.Int

GetTotalShares returns the total shares of the pool

func (Pool) GetType

func (p Pool) GetType() poolmanagertypes.PoolType

func (Pool) IsActive

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

IsActive returns true if the pool is active

func (*Pool) Marshal

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

func (*Pool) MarshalTo

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

func (*Pool) MarshalToSizedBuffer

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

func (*Pool) ProtoMessage

func (*Pool) ProtoMessage()

func (*Pool) Reset

func (m *Pool) Reset()

func (*Pool) SetCurrentSqrtPrice

func (p *Pool) SetCurrentSqrtPrice(newSqrtPrice sdk.Dec)

SetCurrentSqrtPrice updates the current sqrt price of the pool when the first position is created.

func (*Pool) SetCurrentTick

func (p *Pool) SetCurrentTick(newTick sdk.Int)

SetCurrentTick updates the current tick of the pool when the first position is created.

func (*Pool) Size

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

func (Pool) SpotPrice

func (p Pool) SpotPrice(ctx sdk.Context, baseAssetDenom string, quoteAssetDenom string) (sdk.Dec, error)

SpotPrice returns the spot price of the pool. If base asset is the Token0 of the pool, we use the current sqrt price of the pool. If not, we calculate the inverse of the current sqrt price of the pool.

func (Pool) String

func (p Pool) String() string

String returns the json marshalled string of the pool

func (*Pool) Unmarshal

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

func (*Pool) UpdateLiquidity

func (p *Pool) UpdateLiquidity(newLiquidity sdk.Dec)

UpdateLiquidity updates the liquidity of the pool. Note that this method is mutative.

func (*Pool) UpdateLiquidityIfActivePosition

func (p *Pool) UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) bool

updateLiquidityIfActivePosition updates the pool's liquidity if the position is active. Returns true if updated, false otherwise. TODO: add tests.

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 Position

type Position struct {
	Liquidity   github_com_cosmos_cosmos_sdk_types.Dec `` /* 128-byte string literal not displayed */
	FrozenUntil time.Time                              `protobuf:"bytes,2,opt,name=frozen_until,json=frozenUntil,proto3,stdtime" json:"frozen_until" yaml:"frozen_until"`
}

func (*Position) Descriptor

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

func (*Position) GetFrozenUntil

func (m *Position) GetFrozenUntil() time.Time

func (*Position) Marshal

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

func (*Position) MarshalTo

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

func (*Position) MarshalToSizedBuffer

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

func (*Position) ProtoMessage

func (*Position) ProtoMessage()

func (*Position) Reset

func (m *Position) Reset()

func (*Position) Size

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

func (*Position) String

func (m *Position) String() string

func (*Position) Unmarshal

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

func (*Position) XXX_DiscardUnknown

func (m *Position) XXX_DiscardUnknown()

func (*Position) XXX_Marshal

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

func (*Position) XXX_Merge

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

func (*Position) XXX_Size

func (m *Position) XXX_Size() int

func (*Position) XXX_Unmarshal

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

type TickInfo

type TickInfo struct {
	LiquidityGross   github_com_cosmos_cosmos_sdk_types.Dec      `` /* 166-byte string literal not displayed */
	LiquidityNet     github_com_cosmos_cosmos_sdk_types.Dec      `` /* 158-byte string literal not displayed */
	FeeGrowthOutside github_com_cosmos_cosmos_sdk_types.DecCoins `` /* 158-byte string literal not displayed */
}

func (*TickInfo) Descriptor

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

func (*TickInfo) GetFeeGrowthOutside

func (m *TickInfo) GetFeeGrowthOutside() github_com_cosmos_cosmos_sdk_types.DecCoins

func (*TickInfo) Marshal

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

func (*TickInfo) MarshalTo

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

func (*TickInfo) MarshalToSizedBuffer

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

func (*TickInfo) ProtoMessage

func (*TickInfo) ProtoMessage()

func (*TickInfo) Reset

func (m *TickInfo) Reset()

func (*TickInfo) Size

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

func (*TickInfo) String

func (m *TickInfo) String() string

func (*TickInfo) Unmarshal

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

func (*TickInfo) XXX_DiscardUnknown

func (m *TickInfo) XXX_DiscardUnknown()

func (*TickInfo) XXX_Marshal

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

func (*TickInfo) XXX_Merge

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

func (*TickInfo) XXX_Size

func (m *TickInfo) XXX_Size() int

func (*TickInfo) XXX_Unmarshal

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

type UnimplementedMsgCreatorServer

type UnimplementedMsgCreatorServer struct {
}

UnimplementedMsgCreatorServer can be embedded to have forward compatible implementations.

func (*UnimplementedMsgCreatorServer) CreateConcentratedPool

Jump to

Keyboard shortcuts

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