types

package
v0.20.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package types is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	ProposalTypeCreatePool         = "CreatePool"
	ProposalTypeEditPoolConfig     = "EditPoolConfig"
	ProposalTypeEditSwapInvariants = "EditSwapInvariants"
)
View Source
const (
	ModuleName   = "market"
	StoreKey     = "marketkey"
	RouterKey    = ModuleName
	QuerierRoute = ModuleName
)

Variables

View Source
var (
	ErrPairNotSupported     = sdkerrors.Register(ModuleName, 1, "pair not supported")
	ErrOverTradingLimit     = sdkerrors.Register(ModuleName, 2, "over trading limit")
	ErrQuoteReserveAtZero   = sdkerrors.Register(ModuleName, 3, "quote reserve after at zero")
	ErrBaseReserveAtZero    = sdkerrors.Register(ModuleName, 4, "base reserve after at zero")
	ErrNoLastSnapshotSaved  = sdkerrors.Register(ModuleName, 5, "There was no last snapshot, could be that you did not do snapshot on pool creation")
	ErrOverFluctuationLimit = sdkerrors.Register(ModuleName, 6, "price is over fluctuation limit")
	ErrAssetFailsUserLimit  = sdkerrors.Register(ModuleName, 7, "amount of assets traded does not meet user-defined limit")
	ErrNoValidPrice         = sdkerrors.Register(ModuleName, 8, "no valid prices available")
	ErrNoValidTWAP          = sdkerrors.Register(ModuleName, 9, "TWAP price not found")
	// Could replace ErrBaseReserveAtZero and ErrQUoteReserveAtZero if wrapped
	ErrNonPositiveReserves = sdkerrors.Register(ModuleName, 10,
		"base and quote reserves must always be positive")
	ErrLiquidityDepth = sdkerrors.Register(ModuleName, 11,
		"liquidity depth must be positive and equal to the square of the reserves")
	ErrNonPositivePegMultiplier           = sdkerrors.Register(ModuleName, 12, "peg multiplier must be > 0")
	ErrNonPositiveSwapInvariantMutliplier = sdkerrors.Register(ModuleName, 13, "swap multiplier must be > 0")
	ErrNilSwapInvariantMutliplier         = sdkerrors.Register(ModuleName, 14, "swap multiplier must be not nil")
	ErrLiquidityDepthOverflow             = sdkerrors.Register(ModuleName, 15, "liquidty depth overflow")
)
View Source
var (
	ErrInvalidLengthEvent        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowEvent          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthGov        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGov          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthQuery        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowQuery          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthState        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowState          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group")
)
View Source
var Direction_name = map[int32]string{
	0: "DIRECTION_UNSPECIFIED",
	1: "LONG",
	2: "SHORT",
}
View Source
var Direction_value = map[string]int32{
	"DIRECTION_UNSPECIFIED": 0,
	"LONG":                  1,
	"SHORT":                 2,
}
View Source
var TwapCalcOption_name = map[int32]string{
	0: "TWAP_CALC_OPTION_UNSPECIFIED",
	1: "SPOT",
	2: "QUOTE_ASSET_SWAP",
	3: "BASE_ASSET_SWAP",
}
View Source
var TwapCalcOption_value = map[string]int32{
	"TWAP_CALC_OPTION_UNSPECIFIED": 0,
	"SPOT":                         1,
	"QUOTE_ASSET_SWAP":             2,
	"BASE_ASSET_SWAP":              3,
}

Functions

func RegisterCodec

func RegisterCodec(cdc *codec.LegacyAmino)

func RegisterInterfaces

func RegisterInterfaces(registry codectypes.InterfaceRegistry)

func RegisterQueryHandler

func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterQueryHandler registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterQueryHandlerClient

func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error

RegisterQueryHandlerClient registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "QueryClient" to call the correct interceptors.

func RegisterQueryHandlerFromEndpoint

func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterQueryHandlerServer

func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error

RegisterQueryHandlerServer registers the http handlers for service Query to "mux". UnaryRPC :call QueryServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.

func RegisterQueryServer

func RegisterQueryServer(s grpc1.Server, srv QueryServer)

Types

type ArgsNewMarket

type ArgsNewMarket struct {
	Pair          asset.Pair
	BaseReserves  sdk.Dec
	QuoteReserves sdk.Dec
	Config        *MarketConfig
	TotalLong     sdk.Dec
	TotalShort    sdk.Dec
	PegMultiplier sdk.Dec
}

type CreatePoolProposal

type CreatePoolProposal struct {
	Title       string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// pair represents the pair of the market.
	Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,3,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	// quote_reserve is the amount of quote asset the pool will be
	// initialized with.
	QuoteReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 137-byte string literal not displayed */
	// base_reserve is the amount of base asset the pool will be
	// initialized with.
	BaseReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 134-byte string literal not displayed */
	Config      MarketConfig                           `protobuf:"bytes,7,opt,name=config,proto3" json:"config"`
	// peg multiplier is the peg factor for the pool.
	PegMultiplier github_com_cosmos_cosmos_sdk_types.Dec `` /* 140-byte string literal not displayed */
}

func (*CreatePoolProposal) Descriptor

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

func (*CreatePoolProposal) GetConfig

func (m *CreatePoolProposal) GetConfig() MarketConfig

func (*CreatePoolProposal) GetDescription

func (m *CreatePoolProposal) GetDescription() string

func (*CreatePoolProposal) GetTitle

func (m *CreatePoolProposal) GetTitle() string

func (*CreatePoolProposal) Marshal

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

func (*CreatePoolProposal) MarshalTo

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

func (*CreatePoolProposal) MarshalToSizedBuffer

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

func (*CreatePoolProposal) ProposalRoute

func (proposal *CreatePoolProposal) ProposalRoute() string

func (*CreatePoolProposal) ProposalType

func (proposal *CreatePoolProposal) ProposalType() string

func (*CreatePoolProposal) ProtoMessage

func (*CreatePoolProposal) ProtoMessage()

func (*CreatePoolProposal) Reset

func (m *CreatePoolProposal) Reset()

func (*CreatePoolProposal) Size

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

func (*CreatePoolProposal) String

func (m *CreatePoolProposal) String() string

func (*CreatePoolProposal) Unmarshal

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

func (*CreatePoolProposal) ValidateBasic

func (proposal *CreatePoolProposal) ValidateBasic() error

func (*CreatePoolProposal) XXX_DiscardUnknown

func (m *CreatePoolProposal) XXX_DiscardUnknown()

func (*CreatePoolProposal) XXX_Marshal

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

func (*CreatePoolProposal) XXX_Merge

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

func (*CreatePoolProposal) XXX_Size

func (m *CreatePoolProposal) XXX_Size() int

func (*CreatePoolProposal) XXX_Unmarshal

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

type CurrentTWAP

type CurrentTWAP struct {
	PairID      string                                 `protobuf:"bytes,1,opt,name=pair_id,json=pairId,proto3" json:"pair_id,omitempty"`
	Numerator   github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=numerator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"numerator"`
	Denominator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=denominator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"denominator"`
	Price       github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"`
}

CurrentTWAP states defines the numerator and denominator for the TWAP calculation

func (*CurrentTWAP) Descriptor

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

func (*CurrentTWAP) GetPairID

func (m *CurrentTWAP) GetPairID() string

func (*CurrentTWAP) Marshal

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

func (*CurrentTWAP) MarshalTo

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

func (*CurrentTWAP) MarshalToSizedBuffer

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

func (*CurrentTWAP) ProtoMessage

func (*CurrentTWAP) ProtoMessage()

func (*CurrentTWAP) Reset

func (m *CurrentTWAP) Reset()

func (*CurrentTWAP) Size

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

func (*CurrentTWAP) String

func (m *CurrentTWAP) String() string

func (*CurrentTWAP) Unmarshal

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

func (*CurrentTWAP) XXX_DiscardUnknown

func (m *CurrentTWAP) XXX_DiscardUnknown()

func (*CurrentTWAP) XXX_Marshal

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

func (*CurrentTWAP) XXX_Merge

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

func (*CurrentTWAP) XXX_Size

func (m *CurrentTWAP) XXX_Size() int

func (*CurrentTWAP) XXX_Unmarshal

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

type Direction

type Direction int32
const (
	Direction_DIRECTION_UNSPECIFIED Direction = 0
	Direction_LONG                  Direction = 1
	Direction_SHORT                 Direction = 2
)

func (Direction) EnumDescriptor

func (Direction) EnumDescriptor() ([]byte, []int)

func (Direction) String

func (x Direction) String() string

func (Direction) ToMultiplier

func (dir Direction) ToMultiplier() int64

type EditPoolConfigProposal

type EditPoolConfigProposal struct {
	Title       string                                            `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	Description string                                            `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	Pair        github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,3,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	Config      MarketConfig                                      `protobuf:"bytes,4,opt,name=config,proto3" json:"config"`
}

func (*EditPoolConfigProposal) Descriptor

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

func (*EditPoolConfigProposal) GetConfig

func (m *EditPoolConfigProposal) GetConfig() MarketConfig

func (*EditPoolConfigProposal) GetDescription

func (m *EditPoolConfigProposal) GetDescription() string

func (*EditPoolConfigProposal) GetTitle

func (m *EditPoolConfigProposal) GetTitle() string

func (*EditPoolConfigProposal) Marshal

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

func (*EditPoolConfigProposal) MarshalTo

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

func (*EditPoolConfigProposal) MarshalToSizedBuffer

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

func (*EditPoolConfigProposal) ProposalRoute

func (proposal *EditPoolConfigProposal) ProposalRoute() string

func (*EditPoolConfigProposal) ProposalType

func (proposal *EditPoolConfigProposal) ProposalType() string

func (*EditPoolConfigProposal) ProtoMessage

func (*EditPoolConfigProposal) ProtoMessage()

func (*EditPoolConfigProposal) Reset

func (m *EditPoolConfigProposal) Reset()

func (*EditPoolConfigProposal) Size

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

func (*EditPoolConfigProposal) String

func (m *EditPoolConfigProposal) String() string

func (*EditPoolConfigProposal) Unmarshal

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

func (*EditPoolConfigProposal) ValidateBasic

func (proposal *EditPoolConfigProposal) ValidateBasic() error

func (*EditPoolConfigProposal) XXX_DiscardUnknown

func (m *EditPoolConfigProposal) XXX_DiscardUnknown()

func (*EditPoolConfigProposal) XXX_Marshal

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

func (*EditPoolConfigProposal) XXX_Merge

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

func (*EditPoolConfigProposal) XXX_Size

func (m *EditPoolConfigProposal) XXX_Size() int

func (*EditPoolConfigProposal) XXX_Unmarshal

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

type EditSwapInvariantsProposal

type EditSwapInvariantsProposal struct {
	Title       string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// Map from pair ID to a multiple on the swap invariant. For example, a
	// proposal containing "swap_invariant_maps": [{ "uatom:unusd": "5" }, {
	// "uosmo:unusd": "0.9" }] would mutliply the swap invariant of the ATOM and
	// OSMO trading pairs by 5 and 0.9 respectively. The price at which k changes
	// is the instantaneous mark price at the time of the proposal's execution.
	SwapInvariantMaps []EditSwapInvariantsProposal_SwapInvariantMultiple `protobuf:"bytes,5,rep,name=swap_invariant_maps,json=swapInvariantMaps,proto3" json:"swap_invariant_maps"`
}

EditSwapInvariantsProposal is a governance proposal to change the swap invariant of the virtual pool for one or more trading pairs.

func (*EditSwapInvariantsProposal) Descriptor

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

func (*EditSwapInvariantsProposal) GetDescription

func (m *EditSwapInvariantsProposal) GetDescription() string

func (*EditSwapInvariantsProposal) GetSwapInvariantMaps

func (*EditSwapInvariantsProposal) GetTitle

func (m *EditSwapInvariantsProposal) GetTitle() string

func (*EditSwapInvariantsProposal) Marshal

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

func (*EditSwapInvariantsProposal) MarshalTo

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

func (*EditSwapInvariantsProposal) MarshalToSizedBuffer

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

func (*EditSwapInvariantsProposal) ProposalRoute

func (proposal *EditSwapInvariantsProposal) ProposalRoute() string

func (*EditSwapInvariantsProposal) ProposalType

func (proposal *EditSwapInvariantsProposal) ProposalType() string

func (*EditSwapInvariantsProposal) ProtoMessage

func (*EditSwapInvariantsProposal) ProtoMessage()

func (*EditSwapInvariantsProposal) Reset

func (m *EditSwapInvariantsProposal) Reset()

func (*EditSwapInvariantsProposal) Size

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

func (*EditSwapInvariantsProposal) String

func (m *EditSwapInvariantsProposal) String() string

func (*EditSwapInvariantsProposal) Unmarshal

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

func (*EditSwapInvariantsProposal) ValidateBasic

func (proposal *EditSwapInvariantsProposal) ValidateBasic() error

func (*EditSwapInvariantsProposal) XXX_DiscardUnknown

func (m *EditSwapInvariantsProposal) XXX_DiscardUnknown()

func (*EditSwapInvariantsProposal) XXX_Marshal

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

func (*EditSwapInvariantsProposal) XXX_Merge

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

func (*EditSwapInvariantsProposal) XXX_Size

func (m *EditSwapInvariantsProposal) XXX_Size() int

func (*EditSwapInvariantsProposal) XXX_Unmarshal

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

type EditSwapInvariantsProposal_SwapInvariantMultiple

type EditSwapInvariantsProposal_SwapInvariantMultiple struct {
	// Pair is a string identifier for an asset pair.
	Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,3,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	// Multiplier is a number representing the desired percentage change to the
	// swap invariant of the AMM pool underlying 'pair'
	Multiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=multiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"multiplier"`
}

A map between a trading pair and a desired multiplier for its swap invariant.

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) Descriptor

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) Marshal

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

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) MarshalTo

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) MarshalToSizedBuffer

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

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) ProtoMessage

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) Reset

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) Size

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) String

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) Unmarshal

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) Validate

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) XXX_DiscardUnknown

func (m *EditSwapInvariantsProposal_SwapInvariantMultiple) XXX_DiscardUnknown()

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) XXX_Marshal

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

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) XXX_Merge

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) XXX_Size

func (*EditSwapInvariantsProposal_SwapInvariantMultiple) XXX_Unmarshal

type GenesisState

type GenesisState struct {
	Markets []Market `protobuf:"bytes,1,rep,name=markets,proto3" json:"markets"`
}

GenesisState defines the perp.amm module's genesis state.

func DefaultGenesis

func DefaultGenesis() *GenesisState

DefaultGenesis returns the default Capability genesis state

func GetGenesisStateFromAppState

func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState

func (*GenesisState) Descriptor

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

func (*GenesisState) GetMarkets

func (m *GenesisState) GetMarkets() []Market

func (*GenesisState) Marshal

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

func (*GenesisState) MarshalTo

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

func (*GenesisState) MarshalToSizedBuffer

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

func (*GenesisState) ProtoMessage

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset

func (m *GenesisState) Reset()

func (*GenesisState) Size

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

func (*GenesisState) String

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal

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

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic genesis state validation returning an error upon any failure.

func (*GenesisState) XXX_DiscardUnknown

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal

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

func (*GenesisState) XXX_Merge

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

func (*GenesisState) XXX_Size

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal

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

type MarkPriceChangedEvent

type MarkPriceChangedEvent struct {
	Pair           github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	Price          github_com_cosmos_cosmos_sdk_types.Dec            `protobuf:"bytes,2,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"price"`
	BlockTimestamp time.Time                                         `protobuf:"bytes,3,opt,name=block_timestamp,json=blockTimestamp,proto3,stdtime" json:"block_timestamp"`
}

func (*MarkPriceChangedEvent) Descriptor

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

func (*MarkPriceChangedEvent) GetBlockTimestamp

func (m *MarkPriceChangedEvent) GetBlockTimestamp() time.Time

func (*MarkPriceChangedEvent) Marshal

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

func (*MarkPriceChangedEvent) MarshalTo

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

func (*MarkPriceChangedEvent) MarshalToSizedBuffer

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

func (*MarkPriceChangedEvent) ProtoMessage

func (*MarkPriceChangedEvent) ProtoMessage()

func (*MarkPriceChangedEvent) Reset

func (m *MarkPriceChangedEvent) Reset()

func (*MarkPriceChangedEvent) Size

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

func (*MarkPriceChangedEvent) String

func (m *MarkPriceChangedEvent) String() string

func (*MarkPriceChangedEvent) Unmarshal

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

func (*MarkPriceChangedEvent) XXX_DiscardUnknown

func (m *MarkPriceChangedEvent) XXX_DiscardUnknown()

func (*MarkPriceChangedEvent) XXX_Marshal

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

func (*MarkPriceChangedEvent) XXX_Merge

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

func (*MarkPriceChangedEvent) XXX_Size

func (m *MarkPriceChangedEvent) XXX_Size() int

func (*MarkPriceChangedEvent) XXX_Unmarshal

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

type Market

type Market struct {
	// always BASE:QUOTE, e.g. BTC:NUSD or ETH:NUSD
	Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	// base asset is the crypto asset, e.g. BTC or ETH
	BaseReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 134-byte string literal not displayed */
	// quote asset is usually stablecoin, in our case NUSD
	QuoteReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 137-byte string literal not displayed */
	Config       MarketConfig                           `protobuf:"bytes,4,opt,name=config,proto3" json:"config"`
	// The square root of the liquidity depth. Liquidity depth is the product of
	// the reserves.
	SqrtDepth github_com_cosmos_cosmos_sdk_types.Dec `` /* 128-byte string literal not displayed */
	// Total long refers to the sum of long open notional in base.
	TotalLong github_com_cosmos_cosmos_sdk_types.Dec `` /* 128-byte string literal not displayed */
	// Total short refers to the sum of short open notional in base.
	TotalShort github_com_cosmos_cosmos_sdk_types.Dec `` /* 131-byte string literal not displayed */
	// TD docs. For now, leave this as 1 until the feature PR.
	PegMultiplier github_com_cosmos_cosmos_sdk_types.Dec `` /* 140-byte string literal not displayed */
}

A virtual pool used only for price discovery of perpetual futures contracts. No real liquidity exists in this pool.

func NewMarket

func NewMarket(args ArgsNewMarket) Market

func (*Market) AddToBaseReserveAndTotalLongShort

func (market *Market) AddToBaseReserveAndTotalLongShort(amount sdk.Dec)

AddToBaseReserveAndTotalLongShort adds 'amount' to the base asset reserves The 'amount' is not assumed to be positive.

func (*Market) AddToQuoteReserve

func (market *Market) AddToQuoteReserve(amount sdk.Dec)

AddToQuoteReserve adds 'amount' to the quote asset reserves The 'amount' is not assumed to be positive.

func (*Market) ComputeSqrtDepth

func (market *Market) ComputeSqrtDepth() (sqrtDepth sdk.Dec, err error)

func (*Market) Descriptor

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

func (*Market) FromQuoteAssetToReserve

func (market *Market) FromQuoteAssetToReserve(quoteAsset sdk.Dec) sdk.Dec

FromQuoteAssetToReserve returns the amount of quote reserve equivalent to the amount of quote asset given

func (*Market) FromQuoteReserveToAsset

func (market *Market) FromQuoteReserveToAsset(quoteReserve sdk.Dec) sdk.Dec

FromQuoteReserveToAsset returns the amount of quote asset equivalent to the amount of quote reserve given

func (*Market) GetBaseAmountByQuoteAmount

func (market *Market) GetBaseAmountByQuoteAmount(
	quoteDelta sdk.Dec,
) (baseOutAbs sdk.Dec, err error)

GetBaseAmountByQuoteAmount returns the amount of base asset you will get out by giving a specified amount of quote asset

args:

  • quoteDelta: the amount of quote asset to add to/remove from the pool. Adding to the quote reserves is synonymous with positive 'quoteDelta'.

ret:

  • baseOutAbs: the amount of base assets required to make this hypothetical swap always an absolute value
  • err: error

func (*Market) GetBias

func (market *Market) GetBias() (bias sdk.Dec)

GetBias returns the bias of the market in the base asset. It's the net amount of base assets for longs minus the net amount of base assets for shorts.

func (*Market) GetConfig

func (m *Market) GetConfig() MarketConfig

func (Market) GetMarkPrice

func (market Market) GetMarkPrice() sdk.Dec

GetMarkPrice returns the price of the asset.

func (*Market) GetQuoteReserveByBase

func (market *Market) GetQuoteReserveByBase(
	baseDelta sdk.Dec,
) (quoteOutAbs sdk.Dec, err error)

GetQuoteReserveByBase returns the amount of quote asset you will get out by giving a specified amount of base asset

args:

  • dir: add to pool or remove from pool
  • baseAmount: the amount of base asset to add to/remove from the pool

ret:

  • quoteOutAbs: the amount of quote assets required to make this hypothetical swap always an absolute value
  • err: error

func (*Market) GetRepegCost

func (market *Market) GetRepegCost(pegCandidate sdk.Dec) (cost sdk.Dec, err error)

GetRepegCost provides the cost of re-pegging the pool to a new candidate peg multiplier.

func (*Market) GetSwapInvariantUpdateCost

func (market *Market) GetSwapInvariantUpdateCost(swapInvariantMultiplier sdk.Dec) (cost sdk.Dec, err error)

GetSwapInvariantUpdateCost returns the cost of updating the invariant of the pool

func (*Market) HasEnoughBaseReserve

func (market *Market) HasEnoughBaseReserve(baseAmount sdk.Dec) bool

HasEnoughBaseReserve returns true if there is enough base reserve based on baseReserve * tradeLimitRatio

func (*Market) HasEnoughQuoteReserve

func (market *Market) HasEnoughQuoteReserve(quoteAmount sdk.Dec) bool

HasEnoughQuoteReserve returns true if there is enough quote reserve based on quoteReserve * tradeLimitRatio

func (*Market) HasEnoughReservesForTrade

func (market *Market) HasEnoughReservesForTrade(
	quoteAmtAbs sdk.Dec, baseAmtAbs sdk.Dec,
) (err error)

func (*Market) InitLiqDepth

func (market *Market) InitLiqDepth() (Market, error)

func (Market) IsOverFluctuationLimitInRelationWithSnapshot

func (market Market) IsOverFluctuationLimitInRelationWithSnapshot(snapshot ReserveSnapshot) bool

IsOverFluctuationLimitInRelationWithSnapshot compares the updated pool's spot price with the current spot price.

If the fluctuation limit ratio is zero, then the fluctuation limit check is skipped.

args:

  • pool: the updated market
  • snapshot: the snapshot to compare against

ret:

  • bool: true if the fluctuation limit is violated. false otherwise

func (Market) IsOverSpreadLimit

func (market Market) IsOverSpreadLimit(indexPrice sdk.Dec) bool

IsOverSpreadLimit compares the current mark price of the market to the underlying's index price. It panics if you provide it with a pair that doesn't exist in the state.

args:

  • indexPrice: the index price we want to compare.

ret:

  • bool: whether or not the price has deviated from the oracle price beyond a spread ratio

func (*Market) Marshal

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

func (*Market) MarshalTo

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

func (*Market) MarshalToSizedBuffer

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

func (*Market) ProtoMessage

func (*Market) ProtoMessage()

func (*Market) Reset

func (m *Market) Reset()

func (*Market) Size

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

func (*Market) String

func (pool *Market) String() string

String returns the string representation of the pool. Note that this differs from the default output of the proto-generated 'String' method.

func (Market) ToSnapshot

func (market Market) ToSnapshot(ctx sdk.Context) ReserveSnapshot

func (*Market) Unmarshal

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

func (Market) UpdateSwapInvariant

func (market Market) UpdateSwapInvariant(swapInvariantMultiplier sdk.Dec) (newMarket Market, err error)

UpdateSwapInvariant creates a new market object with an updated swap invariant

func (*Market) Validate

func (market *Market) Validate() error

func (*Market) ValidateLiquidityDepth

func (market *Market) ValidateLiquidityDepth() error

ValidateLiquidityDepth checks that reserves are positive.

func (*Market) ValidateReserves

func (market *Market) ValidateReserves() error

ValidateReserves checks that reserves are positive.

func (*Market) XXX_DiscardUnknown

func (m *Market) XXX_DiscardUnknown()

func (*Market) XXX_Marshal

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

func (*Market) XXX_Merge

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

func (*Market) XXX_Size

func (m *Market) XXX_Size() int

func (*Market) XXX_Unmarshal

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

type MarketConfig

type MarketConfig struct {
	// ratio applied to reserves in order not to over trade
	TradeLimitRatio github_com_cosmos_cosmos_sdk_types.Dec `` /* 148-byte string literal not displayed */
	// percentage that a single open or close position can alter the reserve
	// amounts
	FluctuationLimitRatio github_com_cosmos_cosmos_sdk_types.Dec `` /* 166-byte string literal not displayed */
	// max_oracle_spread_ratio
	MaxOracleSpreadRatio github_com_cosmos_cosmos_sdk_types.Dec `` /* 165-byte string literal not displayed */
	// maintenance_margin_ratio
	MaintenanceMarginRatio github_com_cosmos_cosmos_sdk_types.Dec `` /* 169-byte string literal not displayed */
	// max_leverage
	MaxLeverage github_com_cosmos_cosmos_sdk_types.Dec `` /* 134-byte string literal not displayed */
}

func DefaultMarketConfig

func DefaultMarketConfig() *MarketConfig

func (*MarketConfig) Descriptor

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

func (*MarketConfig) Marshal

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

func (*MarketConfig) MarshalTo

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

func (*MarketConfig) MarshalToSizedBuffer

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

func (*MarketConfig) ProtoMessage

func (*MarketConfig) ProtoMessage()

func (*MarketConfig) Reset

func (m *MarketConfig) Reset()

func (*MarketConfig) SetConfig

func (poolCfg *MarketConfig) SetConfig(cfg MarketConfig) *MarketConfig

func (*MarketConfig) Size

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

func (*MarketConfig) String

func (m *MarketConfig) String() string

func (*MarketConfig) Unmarshal

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

func (*MarketConfig) Validate

func (cfg *MarketConfig) Validate() error

func (*MarketConfig) WithFluctuationLimitRatio

func (poolCfg *MarketConfig) WithFluctuationLimitRatio(value sdk.Dec) *MarketConfig

func (*MarketConfig) WithMaintenanceMarginRatio

func (poolCfg *MarketConfig) WithMaintenanceMarginRatio(value sdk.Dec) *MarketConfig

func (*MarketConfig) WithMaxLeverage

func (poolCfg *MarketConfig) WithMaxLeverage(value sdk.Dec) *MarketConfig

func (*MarketConfig) WithMaxOracleSpreadRatio

func (poolCfg *MarketConfig) WithMaxOracleSpreadRatio(value sdk.Dec) *MarketConfig

func (*MarketConfig) WithTradeLimitRatio

func (poolCfg *MarketConfig) WithTradeLimitRatio(value sdk.Dec) *MarketConfig

func (*MarketConfig) XXX_DiscardUnknown

func (m *MarketConfig) XXX_DiscardUnknown()

func (*MarketConfig) XXX_Marshal

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

func (*MarketConfig) XXX_Merge

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

func (*MarketConfig) XXX_Size

func (m *MarketConfig) XXX_Size() int

func (*MarketConfig) XXX_Unmarshal

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

type OracleKeeper

type OracleKeeper interface {
	GetExchangeRate(ctx sdk.Context, pair asset.Pair) (sdk.Dec, error)
	SetPrice(ctx sdk.Context, pair asset.Pair, price sdk.Dec)
}

type PoolPrices

type PoolPrices struct {
	// Pair identifier for the two assets. Always in format 'base:quote'
	Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,9,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	// MarkPrice is the instantaneous price of the perp.
	// Equivalent to quoteReserve / baseReserve.
	MarkPrice github_com_cosmos_cosmos_sdk_types.Dec `` /* 129-byte string literal not displayed */
	// IndexPrice is the price of the "underlying" for the perp
	IndexPrice string `protobuf:"bytes,11,opt,name=index_price,json=indexPrice,proto3" json:"index_price,omitempty"`
	// TwapMark is the time-weighted average (mark) price.
	TwapMark string `protobuf:"bytes,12,opt,name=twap_mark,json=twapMark,proto3" json:"twap_mark,omitempty"`
	// SwapInvariant is the product of the reserves, commonly referred to as "k".
	SwapInvariant github_com_cosmos_cosmos_sdk_types.Int `` /* 163-byte string literal not displayed */
	// The block number corresponding to each price
	BlockNumber int64 `protobuf:"varint,14,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"`
}

PoolPrices is a simple structure that displays a snapshot of the mark and index prices for an asset. Empty strings for the indexPrice or twapMark fields indicate that the price is currently unavailable.

func (*PoolPrices) Descriptor

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

func (*PoolPrices) GetBlockNumber

func (m *PoolPrices) GetBlockNumber() int64

func (*PoolPrices) GetIndexPrice

func (m *PoolPrices) GetIndexPrice() string

func (*PoolPrices) GetTwapMark

func (m *PoolPrices) GetTwapMark() string

func (*PoolPrices) Marshal

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

func (*PoolPrices) MarshalTo

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

func (*PoolPrices) MarshalToSizedBuffer

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

func (*PoolPrices) ProtoMessage

func (*PoolPrices) ProtoMessage()

func (*PoolPrices) Reset

func (m *PoolPrices) Reset()

func (*PoolPrices) Size

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

func (*PoolPrices) String

func (m *PoolPrices) String() string

func (*PoolPrices) Unmarshal

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

func (*PoolPrices) XXX_DiscardUnknown

func (m *PoolPrices) XXX_DiscardUnknown()

func (*PoolPrices) XXX_Marshal

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

func (*PoolPrices) XXX_Merge

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

func (*PoolPrices) XXX_Size

func (m *PoolPrices) XXX_Size() int

func (*PoolPrices) XXX_Unmarshal

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

type QueryAllPoolsRequest

type QueryAllPoolsRequest struct {
}

func (*QueryAllPoolsRequest) Descriptor

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

func (*QueryAllPoolsRequest) Marshal

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

func (*QueryAllPoolsRequest) MarshalTo

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

func (*QueryAllPoolsRequest) MarshalToSizedBuffer

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

func (*QueryAllPoolsRequest) ProtoMessage

func (*QueryAllPoolsRequest) ProtoMessage()

func (*QueryAllPoolsRequest) Reset

func (m *QueryAllPoolsRequest) Reset()

func (*QueryAllPoolsRequest) Size

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

func (*QueryAllPoolsRequest) String

func (m *QueryAllPoolsRequest) String() string

func (*QueryAllPoolsRequest) Unmarshal

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

func (*QueryAllPoolsRequest) XXX_DiscardUnknown

func (m *QueryAllPoolsRequest) XXX_DiscardUnknown()

func (*QueryAllPoolsRequest) XXX_Marshal

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

func (*QueryAllPoolsRequest) XXX_Merge

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

func (*QueryAllPoolsRequest) XXX_Size

func (m *QueryAllPoolsRequest) XXX_Size() int

func (*QueryAllPoolsRequest) XXX_Unmarshal

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

type QueryAllPoolsResponse

type QueryAllPoolsResponse struct {
	Markets []Market     `protobuf:"bytes,1,rep,name=markets,proto3" json:"markets"`
	Prices  []PoolPrices `protobuf:"bytes,2,rep,name=prices,proto3" json:"prices"`
}

func (*QueryAllPoolsResponse) Descriptor

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

func (*QueryAllPoolsResponse) GetMarkets

func (m *QueryAllPoolsResponse) GetMarkets() []Market

func (*QueryAllPoolsResponse) GetPrices

func (m *QueryAllPoolsResponse) GetPrices() []PoolPrices

func (*QueryAllPoolsResponse) Marshal

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

func (*QueryAllPoolsResponse) MarshalTo

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

func (*QueryAllPoolsResponse) MarshalToSizedBuffer

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

func (*QueryAllPoolsResponse) ProtoMessage

func (*QueryAllPoolsResponse) ProtoMessage()

func (*QueryAllPoolsResponse) Reset

func (m *QueryAllPoolsResponse) Reset()

func (*QueryAllPoolsResponse) Size

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

func (*QueryAllPoolsResponse) String

func (m *QueryAllPoolsResponse) String() string

func (*QueryAllPoolsResponse) Unmarshal

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

func (*QueryAllPoolsResponse) XXX_DiscardUnknown

func (m *QueryAllPoolsResponse) XXX_DiscardUnknown()

func (*QueryAllPoolsResponse) XXX_Marshal

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

func (*QueryAllPoolsResponse) XXX_Merge

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

func (*QueryAllPoolsResponse) XXX_Size

func (m *QueryAllPoolsResponse) XXX_Size() int

func (*QueryAllPoolsResponse) XXX_Unmarshal

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

type QueryBaseAssetPriceRequest

type QueryBaseAssetPriceRequest struct {
	Pair      github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	Direction Direction                                         `protobuf:"varint,2,opt,name=direction,proto3,enum=nibiru.perp.v1.amm.Direction" json:"direction,omitempty"`
	// base asset is the crypto asset, e.g. BTC or ETH
	BaseAssetAmount github_com_cosmos_cosmos_sdk_types.Dec `` /* 148-byte string literal not displayed */
}

func (*QueryBaseAssetPriceRequest) Descriptor

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

func (*QueryBaseAssetPriceRequest) GetDirection

func (m *QueryBaseAssetPriceRequest) GetDirection() Direction

func (*QueryBaseAssetPriceRequest) Marshal

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

func (*QueryBaseAssetPriceRequest) MarshalTo

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

func (*QueryBaseAssetPriceRequest) MarshalToSizedBuffer

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

func (*QueryBaseAssetPriceRequest) ProtoMessage

func (*QueryBaseAssetPriceRequest) ProtoMessage()

func (*QueryBaseAssetPriceRequest) Reset

func (m *QueryBaseAssetPriceRequest) Reset()

func (*QueryBaseAssetPriceRequest) Size

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

func (*QueryBaseAssetPriceRequest) String

func (m *QueryBaseAssetPriceRequest) String() string

func (*QueryBaseAssetPriceRequest) Unmarshal

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

func (*QueryBaseAssetPriceRequest) XXX_DiscardUnknown

func (m *QueryBaseAssetPriceRequest) XXX_DiscardUnknown()

func (*QueryBaseAssetPriceRequest) XXX_Marshal

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

func (*QueryBaseAssetPriceRequest) XXX_Merge

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

func (*QueryBaseAssetPriceRequest) XXX_Size

func (m *QueryBaseAssetPriceRequest) XXX_Size() int

func (*QueryBaseAssetPriceRequest) XXX_Unmarshal

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

type QueryBaseAssetPriceResponse

type QueryBaseAssetPriceResponse struct {
	PriceInQuoteDenom github_com_cosmos_cosmos_sdk_types.Dec `` /* 156-byte string literal not displayed */
}

func (*QueryBaseAssetPriceResponse) Descriptor

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

func (*QueryBaseAssetPriceResponse) Marshal

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

func (*QueryBaseAssetPriceResponse) MarshalTo

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

func (*QueryBaseAssetPriceResponse) MarshalToSizedBuffer

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

func (*QueryBaseAssetPriceResponse) ProtoMessage

func (*QueryBaseAssetPriceResponse) ProtoMessage()

func (*QueryBaseAssetPriceResponse) Reset

func (m *QueryBaseAssetPriceResponse) Reset()

func (*QueryBaseAssetPriceResponse) Size

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

func (*QueryBaseAssetPriceResponse) String

func (m *QueryBaseAssetPriceResponse) String() string

func (*QueryBaseAssetPriceResponse) Unmarshal

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

func (*QueryBaseAssetPriceResponse) XXX_DiscardUnknown

func (m *QueryBaseAssetPriceResponse) XXX_DiscardUnknown()

func (*QueryBaseAssetPriceResponse) XXX_Marshal

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

func (*QueryBaseAssetPriceResponse) XXX_Merge

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

func (*QueryBaseAssetPriceResponse) XXX_Size

func (m *QueryBaseAssetPriceResponse) XXX_Size() int

func (*QueryBaseAssetPriceResponse) XXX_Unmarshal

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

type QueryClient

type QueryClient interface {
	// Queries the reserve assets in a given pool, identified by a token pair.
	ReserveAssets(ctx context.Context, in *QueryReserveAssetsRequest, opts ...grpc.CallOption) (*QueryReserveAssetsResponse, error)
	// Queries all virtual pools.
	AllPools(ctx context.Context, in *QueryAllPoolsRequest, opts ...grpc.CallOption) (*QueryAllPoolsResponse, error)
	// Queries prices
	BaseAssetPrice(ctx context.Context, in *QueryBaseAssetPriceRequest, opts ...grpc.CallOption) (*QueryBaseAssetPriceResponse, error)
}

QueryClient is the client API for Query service.

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

func NewQueryClient

func NewQueryClient(cc grpc1.ClientConn) QueryClient

type QueryReserveAssetsRequest

type QueryReserveAssetsRequest struct {
	// always BASE:QUOTE, e.g. BTC:NUSD or ETH:NUSD
	Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
}

func (*QueryReserveAssetsRequest) Descriptor

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

func (*QueryReserveAssetsRequest) Marshal

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

func (*QueryReserveAssetsRequest) MarshalTo

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

func (*QueryReserveAssetsRequest) MarshalToSizedBuffer

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

func (*QueryReserveAssetsRequest) ProtoMessage

func (*QueryReserveAssetsRequest) ProtoMessage()

func (*QueryReserveAssetsRequest) Reset

func (m *QueryReserveAssetsRequest) Reset()

func (*QueryReserveAssetsRequest) Size

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

func (*QueryReserveAssetsRequest) String

func (m *QueryReserveAssetsRequest) String() string

func (*QueryReserveAssetsRequest) Unmarshal

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

func (*QueryReserveAssetsRequest) XXX_DiscardUnknown

func (m *QueryReserveAssetsRequest) XXX_DiscardUnknown()

func (*QueryReserveAssetsRequest) XXX_Marshal

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

func (*QueryReserveAssetsRequest) XXX_Merge

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

func (*QueryReserveAssetsRequest) XXX_Size

func (m *QueryReserveAssetsRequest) XXX_Size() int

func (*QueryReserveAssetsRequest) XXX_Unmarshal

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

type QueryReserveAssetsResponse

type QueryReserveAssetsResponse struct {
	// base asset is the crypto asset, e.g. BTC or ETH
	BaseReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 134-byte string literal not displayed */
	// quote asset is usually stablecoin, in our case NUSD
	QuoteReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 137-byte string literal not displayed */
}

func (*QueryReserveAssetsResponse) Descriptor

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

func (*QueryReserveAssetsResponse) Marshal

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

func (*QueryReserveAssetsResponse) MarshalTo

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

func (*QueryReserveAssetsResponse) MarshalToSizedBuffer

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

func (*QueryReserveAssetsResponse) ProtoMessage

func (*QueryReserveAssetsResponse) ProtoMessage()

func (*QueryReserveAssetsResponse) Reset

func (m *QueryReserveAssetsResponse) Reset()

func (*QueryReserveAssetsResponse) Size

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

func (*QueryReserveAssetsResponse) String

func (m *QueryReserveAssetsResponse) String() string

func (*QueryReserveAssetsResponse) Unmarshal

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

func (*QueryReserveAssetsResponse) XXX_DiscardUnknown

func (m *QueryReserveAssetsResponse) XXX_DiscardUnknown()

func (*QueryReserveAssetsResponse) XXX_Marshal

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

func (*QueryReserveAssetsResponse) XXX_Merge

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

func (*QueryReserveAssetsResponse) XXX_Size

func (m *QueryReserveAssetsResponse) XXX_Size() int

func (*QueryReserveAssetsResponse) XXX_Unmarshal

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

type QueryServer

type QueryServer interface {
	// Queries the reserve assets in a given pool, identified by a token pair.
	ReserveAssets(context.Context, *QueryReserveAssetsRequest) (*QueryReserveAssetsResponse, error)
	// Queries all virtual pools.
	AllPools(context.Context, *QueryAllPoolsRequest) (*QueryAllPoolsResponse, error)
	// Queries prices
	BaseAssetPrice(context.Context, *QueryBaseAssetPriceRequest) (*QueryBaseAssetPriceResponse, error)
}

QueryServer is the server API for Query service.

type ReserveSnapshot

type ReserveSnapshot struct {
	Pair        github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,5,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	BaseReserve github_com_cosmos_cosmos_sdk_types.Dec            `` /* 134-byte string literal not displayed */
	// quote asset is usually the margin asset, e.g. NUSD
	QuoteReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 137-byte string literal not displayed */
	// milliseconds since unix epoch
	TimestampMs int64 `protobuf:"varint,4,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"`
	// peg multiplier is needed to compute mark price in the snapshot
	PegMultiplier github_com_cosmos_cosmos_sdk_types.Dec `` /* 140-byte string literal not displayed */
}

a snapshot of the perp.amm's reserves at a given point in time

func NewReserveSnapshot

func NewReserveSnapshot(
	pair asset.Pair,
	baseReserve, quoteReserve sdk.Dec,
	pegMultiplier sdk.Dec,
	blockTime time.Time,
) ReserveSnapshot

func (*ReserveSnapshot) Descriptor

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

func (ReserveSnapshot) GetLowerMarkPriceFluctuationLimit

func (s ReserveSnapshot) GetLowerMarkPriceFluctuationLimit(fluctuationLimitRatio sdk.Dec) sdk.Dec

GetLowerMarkPriceFluctuationLimit returns the minimum limit price based on the fluctuationLimitRatio

func (*ReserveSnapshot) GetTimestampMs

func (m *ReserveSnapshot) GetTimestampMs() int64

func (ReserveSnapshot) GetUpperMarkPriceFluctuationLimit

func (s ReserveSnapshot) GetUpperMarkPriceFluctuationLimit(fluctuationLimitRatio sdk.Dec) sdk.Dec

GetUpperMarkPriceFluctuationLimit returns the maximum limit price based on the fluctuationLimitRatio

func (*ReserveSnapshot) Marshal

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

func (*ReserveSnapshot) MarshalTo

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

func (*ReserveSnapshot) MarshalToSizedBuffer

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

func (*ReserveSnapshot) ProtoMessage

func (*ReserveSnapshot) ProtoMessage()

func (*ReserveSnapshot) Reset

func (m *ReserveSnapshot) Reset()

func (*ReserveSnapshot) Size

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

func (*ReserveSnapshot) String

func (m *ReserveSnapshot) String() string

func (*ReserveSnapshot) Unmarshal

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

func (ReserveSnapshot) Validate

func (s ReserveSnapshot) Validate() error

func (*ReserveSnapshot) XXX_DiscardUnknown

func (m *ReserveSnapshot) XXX_DiscardUnknown()

func (*ReserveSnapshot) XXX_Marshal

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

func (*ReserveSnapshot) XXX_Merge

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

func (*ReserveSnapshot) XXX_Size

func (m *ReserveSnapshot) XXX_Size() int

func (*ReserveSnapshot) XXX_Unmarshal

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

type ReserveSnapshotSavedEvent

type ReserveSnapshotSavedEvent struct {
	Pair         github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	QuoteReserve github_com_cosmos_cosmos_sdk_types.Dec            `` /* 137-byte string literal not displayed */
	BaseReserve  github_com_cosmos_cosmos_sdk_types.Dec            `` /* 134-byte string literal not displayed */
	// MarkPrice at the end of the block.
	// (instantaneous) markPrice := quoteReserve / baseReserve
	MarkPrice      github_com_cosmos_cosmos_sdk_types.Dec `` /* 128-byte string literal not displayed */
	BlockHeight    int64                                  `protobuf:"varint,5,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"`
	BlockTimestamp time.Time                              `protobuf:"bytes,6,opt,name=block_timestamp,json=blockTimestamp,proto3,stdtime" json:"block_timestamp"`
}

func (*ReserveSnapshotSavedEvent) Descriptor

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

func (*ReserveSnapshotSavedEvent) GetBlockHeight

func (m *ReserveSnapshotSavedEvent) GetBlockHeight() int64

func (*ReserveSnapshotSavedEvent) GetBlockTimestamp

func (m *ReserveSnapshotSavedEvent) GetBlockTimestamp() time.Time

func (*ReserveSnapshotSavedEvent) Marshal

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

func (*ReserveSnapshotSavedEvent) MarshalTo

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

func (*ReserveSnapshotSavedEvent) MarshalToSizedBuffer

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

func (*ReserveSnapshotSavedEvent) ProtoMessage

func (*ReserveSnapshotSavedEvent) ProtoMessage()

func (*ReserveSnapshotSavedEvent) Reset

func (m *ReserveSnapshotSavedEvent) Reset()

func (*ReserveSnapshotSavedEvent) Size

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

func (*ReserveSnapshotSavedEvent) String

func (m *ReserveSnapshotSavedEvent) String() string

func (*ReserveSnapshotSavedEvent) Unmarshal

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

func (*ReserveSnapshotSavedEvent) XXX_DiscardUnknown

func (m *ReserveSnapshotSavedEvent) XXX_DiscardUnknown()

func (*ReserveSnapshotSavedEvent) XXX_Marshal

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

func (*ReserveSnapshotSavedEvent) XXX_Merge

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

func (*ReserveSnapshotSavedEvent) XXX_Size

func (m *ReserveSnapshotSavedEvent) XXX_Size() int

func (*ReserveSnapshotSavedEvent) XXX_Unmarshal

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

type SwapEvent

type SwapEvent struct {
	Pair github_com_NibiruChain_nibiru_x_common_asset.Pair `protobuf:"bytes,1,opt,name=pair,proto3,customtype=github.com/NibiruChain/nibiru/x/common/asset.Pair" json:"pair"`
	// delta in the quote reserves of the perp.amm
	QuoteAmount github_com_cosmos_cosmos_sdk_types.Dec `` /* 134-byte string literal not displayed */
	// delta in the base reserves of the perp.amm
	BaseAmount github_com_cosmos_cosmos_sdk_types.Dec `` /* 131-byte string literal not displayed */
}

A swap on the perp.amm represented by 'pair'. Amounts are negative or positive base on the perspective of the pool, i.e. a negative quote means the trader has gained quote and the perp.amm lost quote.

func (*SwapEvent) Descriptor

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

func (*SwapEvent) Marshal

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

func (*SwapEvent) MarshalTo

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

func (*SwapEvent) MarshalToSizedBuffer

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

func (*SwapEvent) ProtoMessage

func (*SwapEvent) ProtoMessage()

func (*SwapEvent) Reset

func (m *SwapEvent) Reset()

func (*SwapEvent) Size

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

func (*SwapEvent) String

func (m *SwapEvent) String() string

func (*SwapEvent) Unmarshal

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

func (*SwapEvent) XXX_DiscardUnknown

func (m *SwapEvent) XXX_DiscardUnknown()

func (*SwapEvent) XXX_Marshal

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

func (*SwapEvent) XXX_Merge

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

func (*SwapEvent) XXX_Size

func (m *SwapEvent) XXX_Size() int

func (*SwapEvent) XXX_Unmarshal

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

type TwapCalcOption

type TwapCalcOption int32

Enumerates different options of calculating twap.

const (
	TwapCalcOption_TWAP_CALC_OPTION_UNSPECIFIED TwapCalcOption = 0
	// Spot price from quote asset reserve / base asset reserve
	TwapCalcOption_SPOT TwapCalcOption = 1
	// Swapping with quote assets, output denominated in base assets
	TwapCalcOption_QUOTE_ASSET_SWAP TwapCalcOption = 2
	// Swapping with base assets, output denominated in quote assets
	TwapCalcOption_BASE_ASSET_SWAP TwapCalcOption = 3
)

func (TwapCalcOption) EnumDescriptor

func (TwapCalcOption) EnumDescriptor() ([]byte, []int)

func (TwapCalcOption) String

func (x TwapCalcOption) String() string

type UnimplementedQueryServer

type UnimplementedQueryServer struct {
}

UnimplementedQueryServer can be embedded to have forward compatible implementations.

func (*UnimplementedQueryServer) AllPools

func (*UnimplementedQueryServer) BaseAssetPrice

func (*UnimplementedQueryServer) ReserveAssets

Jump to

Keyboard shortcuts

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