Documentation ¶
Index ¶
- Constants
- Variables
- func GetPoolKey(pair common.TokenPair) []byte
- func GetSnapshotCounterKey(pair common.TokenPair) []byte
- func GetSnapshotKey(pair common.TokenPair, counter uint64) []byte
- func ParamKeyTable() paramtypes.KeyTable
- func RegisterCodec(cdc *codec.LegacyAmino)
- func RegisterInterfaces(registry codectypes.InterfaceRegistry)
- type Direction
- type GenesisState
- func (*GenesisState) Descriptor() ([]byte, []int)
- func (m *GenesisState) GetParams() Params
- func (m *GenesisState) Marshal() (dAtA []byte, err error)
- func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)
- func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GenesisState) ProtoMessage()
- func (m *GenesisState) Reset()
- func (m *GenesisState) Size() (n int)
- func (m *GenesisState) String() string
- func (m *GenesisState) Unmarshal(dAtA []byte) error
- func (gs GenesisState) Validate() error
- func (m *GenesisState) XXX_DiscardUnknown()
- func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GenesisState) XXX_Merge(src proto.Message)
- func (m *GenesisState) XXX_Size() int
- func (m *GenesisState) XXX_Unmarshal(b []byte) error
- type Params
- func (*Params) Descriptor() ([]byte, []int)
- func (m *Params) Marshal() (dAtA []byte, err error)
- func (m *Params) MarshalTo(dAtA []byte) (int, error)
- func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs
- func (*Params) ProtoMessage()
- func (m *Params) Reset()
- func (m *Params) Size() (n int)
- func (p Params) String() string
- func (m *Params) Unmarshal(dAtA []byte) error
- func (p Params) Validate() error
- func (m *Params) XXX_DiscardUnknown()
- func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Params) XXX_Merge(src proto.Message)
- func (m *Params) XXX_Size() int
- func (m *Params) XXX_Unmarshal(b []byte) error
- type Pool
- func (p *Pool) DecreaseBaseAssetReserve(amount sdk.Dec)
- func (p *Pool) DecreaseQuoteAssetReserve(amount sdk.Dec)
- func (*Pool) Descriptor() ([]byte, []int)
- func (p *Pool) GetBaseAmountByQuoteAmount(dir Direction, quoteAmount sdk.Dec) (baseAmount sdk.Dec, err error)
- func (m *Pool) GetPair() string
- func (p *Pool) GetQuoteAmountByBaseAmount(dir Direction, baseAmount sdk.Dec) (quoteAmount sdk.Dec, err error)
- func (p *Pool) HasEnoughBaseReserve(baseAmount sdk.Dec) bool
- func (p *Pool) HasEnoughQuoteReserve(quoteAmount sdk.Dec) bool
- func (p *Pool) IncreaseBaseAssetReserve(amount sdk.Dec)
- func (p *Pool) IncreaseQuoteAssetReserve(amount sdk.Dec)
- func (m *Pool) Marshal() (dAtA []byte, err error)
- func (m *Pool) MarshalTo(dAtA []byte) (int, error)
- func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Pool) ProtoMessage()
- func (m *Pool) Reset()
- func (m *Pool) Size() (n int)
- func (m *Pool) String() string
- func (m *Pool) Unmarshal(dAtA []byte) error
- func (m *Pool) XXX_DiscardUnknown()
- func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Pool) XXX_Merge(src proto.Message)
- func (m *Pool) XXX_Size() int
- func (m *Pool) XXX_Unmarshal(b []byte) error
- type PricefeedKeeper
- type ReserveSnapshot
- func (*ReserveSnapshot) Descriptor() ([]byte, []int)
- func (m *ReserveSnapshot) GetBlockNumber() int64
- func (m *ReserveSnapshot) GetTimestampMs() int64
- func (m *ReserveSnapshot) Marshal() (dAtA []byte, err error)
- func (m *ReserveSnapshot) MarshalTo(dAtA []byte) (int, error)
- func (m *ReserveSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ReserveSnapshot) ProtoMessage()
- func (m *ReserveSnapshot) Reset()
- func (m *ReserveSnapshot) Size() (n int)
- func (m *ReserveSnapshot) String() string
- func (m *ReserveSnapshot) Unmarshal(dAtA []byte) error
- func (m *ReserveSnapshot) XXX_DiscardUnknown()
- func (m *ReserveSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ReserveSnapshot) XXX_Merge(src proto.Message)
- func (m *ReserveSnapshot) XXX_Size() int
- func (m *ReserveSnapshot) XXX_Unmarshal(b []byte) error
- type TwapCalcOption
Constants ¶
const ( EventSnapshotSaved = "reserve_snapshot_saved" AttributeBlockHeight = "block_height" AttributeQuoteReserve = "quote_reserve" AttributeBaseReserve = "base_reserve" EventSwapQuoteForBase = "swap_input" EventSwapBaseForQuote = "swap_output" AttributeQuoteAssetAmount = "quote_asset_amount" AttributeBaseAssetAmount = "base_asset_amount" )
const ( ModuleName = "vpool" StoreKey = "vpoolkey" RouterKey = ModuleName QuerierRoute = ModuleName )
Variables ¶
var ( Amino = codec.NewLegacyAmino() ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) )
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") ErrAssetOverUserLimit = sdkerrors.Register(ModuleName, 7, "amout of assets traded is over user-defined limit") )
var ( ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") )
var ( PoolKey = []byte{0x00} PoolReserveSnapshotCounter = []byte{0x01} PoolReserveSnapshots = []byte{0x02} )
PoolKey | 0x00 + PairString | The Pool struct PoolReserveSnapshotCounter | 0x01 + PairString | Integer PoolReserveSnapshots | 0x02 + PairString + Counter | Snapshot
var ( ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") )
var ( ErrInvalidLengthVpool = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowVpool = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupVpool = fmt.Errorf("proto: unexpected end of group") )
var Direction_name = map[int32]string{
0: "ADD_TO_POOL",
1: "REMOVE_FROM_POOL",
}
var Direction_value = map[string]int32{
"ADD_TO_POOL": 0,
"REMOVE_FROM_POOL": 1,
}
var TwapCalcOption_name = map[int32]string{
0: "SPOT",
1: "QUOTE_ASSET_SWAP",
2: "BASE_ASSET_SWAP",
}
var TwapCalcOption_value = map[string]int32{
"SPOT": 0,
"QUOTE_ASSET_SWAP": 1,
"BASE_ASSET_SWAP": 2,
}
Functions ¶
func GetPoolKey ¶
GetPoolKey returns pool key for KVStore
func GetSnapshotCounterKey ¶
GetSnapshotCounterKey returns the KVStore for the Snapshot Pool counters.
func GetSnapshotKey ¶
GetSnapshotKey returns the KVStore for the pool reserve snapshots.
func ParamKeyTable ¶ added in v0.2.9
func ParamKeyTable() paramtypes.KeyTable
ParamKeyTable the param key table for launch module
func RegisterCodec ¶ added in v0.2.9
func RegisterCodec(cdc *codec.LegacyAmino)
func RegisterInterfaces ¶ added in v0.2.9
func RegisterInterfaces(registry codectypes.InterfaceRegistry)
Types ¶
type GenesisState ¶ added in v0.2.9
type GenesisState struct {
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
}
GenesisState defines the vpool module's genesis state.
func DefaultGenesis ¶ added in v0.2.9
func DefaultGenesis() *GenesisState
DefaultGenesis returns the default Capability genesis state
func (*GenesisState) Descriptor ¶ added in v0.2.9
func (*GenesisState) Descriptor() ([]byte, []int)
func (*GenesisState) GetParams ¶ added in v0.2.9
func (m *GenesisState) GetParams() Params
func (*GenesisState) Marshal ¶ added in v0.2.9
func (m *GenesisState) Marshal() (dAtA []byte, err error)
func (*GenesisState) MarshalTo ¶ added in v0.2.9
func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)
func (*GenesisState) MarshalToSizedBuffer ¶ added in v0.2.9
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*GenesisState) ProtoMessage ¶ added in v0.2.9
func (*GenesisState) ProtoMessage()
func (*GenesisState) Reset ¶ added in v0.2.9
func (m *GenesisState) Reset()
func (*GenesisState) Size ¶ added in v0.2.9
func (m *GenesisState) Size() (n int)
func (*GenesisState) String ¶ added in v0.2.9
func (m *GenesisState) String() string
func (*GenesisState) Unmarshal ¶ added in v0.2.9
func (m *GenesisState) Unmarshal(dAtA []byte) error
func (GenesisState) Validate ¶ added in v0.2.9
func (gs GenesisState) Validate() error
Validate performs basic genesis state validation returning an error upon any failure.
func (*GenesisState) XXX_DiscardUnknown ¶ added in v0.2.9
func (m *GenesisState) XXX_DiscardUnknown()
func (*GenesisState) XXX_Marshal ¶ added in v0.2.9
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GenesisState) XXX_Merge ¶ added in v0.2.9
func (m *GenesisState) XXX_Merge(src proto.Message)
func (*GenesisState) XXX_Size ¶ added in v0.2.9
func (m *GenesisState) XXX_Size() int
func (*GenesisState) XXX_Unmarshal ¶ added in v0.2.9
func (m *GenesisState) XXX_Unmarshal(b []byte) error
type Params ¶ added in v0.2.9
type Params struct { }
Params defines the parameters for the module.
func DefaultParams ¶ added in v0.2.9
func DefaultParams() Params
DefaultParams returns a default set of parameters
func (*Params) Descriptor ¶ added in v0.2.9
func (*Params) MarshalToSizedBuffer ¶ added in v0.2.9
func (*Params) ParamSetPairs ¶ added in v0.2.9
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs
ParamSetPairs get the params.ParamSet
func (*Params) ProtoMessage ¶ added in v0.2.9
func (*Params) ProtoMessage()
func (*Params) XXX_DiscardUnknown ¶ added in v0.2.9
func (m *Params) XXX_DiscardUnknown()
func (*Params) XXX_Marshal ¶ added in v0.2.9
func (*Params) XXX_Unmarshal ¶ added in v0.2.9
type Pool ¶
type Pool struct { // always BASE:QUOTE, e.g. BTC:NUSD or ETH:NUSD Pair string `protobuf:"bytes,1,opt,name=pair,proto3" json:"pair,omitempty"` // base asset is the crypto asset, e.g. BTC or ETH BaseAssetReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 151-byte string literal not displayed */ // quote asset is usually stablecoin, in our case NUSD QuoteAssetReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 154-byte string literal not displayed */ // 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 */ }
A virtual pool used only for price discovery of perpetual futures contracts. No real liquidity exists in this pool.
func (*Pool) DecreaseBaseAssetReserve ¶
DecreaseBaseAssetReserve descreases the quote asset reserve by amount
func (*Pool) DecreaseQuoteAssetReserve ¶
DecreaseQuoteAssetReserve decreases the base reserve by amount
func (*Pool) Descriptor ¶
func (*Pool) GetBaseAmountByQuoteAmount ¶
func (p *Pool) GetBaseAmountByQuoteAmount( dir Direction, quoteAmount sdk.Dec, ) (baseAmount sdk.Dec, err error)
GetBaseAmountByQuoteAmount returns the amount of base asset you will get out by giving a specified amount of quote asset
args:
- dir: add to pool or remove from pool
- quoteAmount: the amount of quote asset to add to/remove from the pool
ret:
- baseAmountOut: the amount of base assets required to make this hypothetical swap always an absolute value
- err: error
func (*Pool) GetQuoteAmountByBaseAmount ¶
func (p *Pool) GetQuoteAmountByBaseAmount( dir Direction, baseAmount sdk.Dec, ) (quoteAmount sdk.Dec, err error)
GetQuoteAmountByBaseAmount 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:
- quoteAmountOut: the amount of quote assets required to make this hypothetical swap always an absolute value
- err: error
func (*Pool) HasEnoughBaseReserve ¶
HasEnoughBaseReserve returns true if there is enough base reserve based on baseReserve * tradeLimitRatio
func (*Pool) HasEnoughQuoteReserve ¶
HasEnoughQuoteReserve returns true if there is enough quote reserve based on quoteReserve * tradeLimitRatio
func (*Pool) IncreaseBaseAssetReserve ¶
IncreaseBaseAssetReserve increases the quote reserve by amount
func (*Pool) IncreaseQuoteAssetReserve ¶
func (*Pool) ProtoMessage ¶
func (*Pool) ProtoMessage()
func (*Pool) XXX_DiscardUnknown ¶
func (m *Pool) XXX_DiscardUnknown()
func (*Pool) XXX_Unmarshal ¶
type PricefeedKeeper ¶
type ReserveSnapshot ¶
type ReserveSnapshot struct { BaseAssetReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 151-byte string literal not displayed */ // quote asset is usually the margin asset, e.g. NUSD QuoteAssetReserve github_com_cosmos_cosmos_sdk_types.Dec `` /* 154-byte string literal not displayed */ // milliseconds since unix epoch TimestampMs int64 `protobuf:"varint,3,opt,name=timestamp_ms,json=timestampMs,proto3" json:"timestamp_ms,omitempty"` BlockNumber int64 `protobuf:"varint,4,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` }
a snapshot of the vpool's reserves at a given point in time
func (*ReserveSnapshot) Descriptor ¶
func (*ReserveSnapshot) Descriptor() ([]byte, []int)
func (*ReserveSnapshot) GetBlockNumber ¶
func (m *ReserveSnapshot) GetBlockNumber() int64
func (*ReserveSnapshot) GetTimestampMs ¶
func (m *ReserveSnapshot) GetTimestampMs() int64
func (*ReserveSnapshot) Marshal ¶
func (m *ReserveSnapshot) Marshal() (dAtA []byte, err 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) 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 TwapCalcOption ¶
type TwapCalcOption int32
Enumerates different options of calculating twap.
const ( // Spot price from quote asset reserve / base asset reserve TwapCalcOption_SPOT TwapCalcOption = 0 // Swapping with quote assets, output denominated in base assets TwapCalcOption_QUOTE_ASSET_SWAP TwapCalcOption = 1 // Swapping with base assets, output denominated in quote assets TwapCalcOption_BASE_ASSET_SWAP TwapCalcOption = 2 )
func (TwapCalcOption) EnumDescriptor ¶
func (TwapCalcOption) EnumDescriptor() ([]byte, []int)
func (TwapCalcOption) String ¶
func (x TwapCalcOption) String() string