keeper

package
v0.0.0-...-bf46863 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ContractPrefixKey = "x-wasm-contract"
View Source
const EpochKey = "epoch"
View Source
const MatchResultKey = "match-result"

Variables

This section is empty.

Functions

func GetKeyForLongBook

func GetKeyForLongBook(longBook types.LongBook) []byte

func GetKeyForPrice

func GetKeyForPrice(price sdk.Dec) []byte

func GetKeyForShortBook

func GetKeyForShortBook(shortBook types.ShortBook) []byte

func GetKeyForTs

func GetKeyForTs(ts uint64) []byte

Types

type Keeper

type Keeper struct {
	Cdc codec.BinaryCodec

	Paramstore    paramtypes.Subspace
	AccountKeeper authkeeper.AccountKeeper
	EpochKeeper   epochkeeper.Keeper
	BankKeeper    bankkeeper.Keeper
	WasmKeeper    wasm.Keeper
	MemState      *dexcache.MemState
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey sdk.StoreKey,
	ps paramtypes.Subspace,
	epochKeeper epochkeeper.Keeper,
	bankKeeper bankkeeper.Keeper,
	accountKeeper authkeeper.AccountKeeper,
) *Keeper

func (Keeper) AddRegisteredPair

func (k Keeper) AddRegisteredPair(ctx sdk.Context, contractAddr string, pair types.Pair) bool

func (Keeper) ChargeRentForGas

func (k Keeper) ChargeRentForGas(ctx sdk.Context, contractAddr string, gasUsed uint64, gasAllowance uint64) error

Reduce `RentBalance` of a contract if `userProvidedGas` cannot cover `gasUsed`

func (Keeper) ClearDependenciesForContract

func (k Keeper) ClearDependenciesForContract(ctx sdk.Context, removedContract types.ContractInfoV2)

func (Keeper) CreateModuleAccount

func (k Keeper) CreateModuleAccount(ctx sdk.Context)

func (Keeper) DecreaseOrderCount

func (k Keeper) DecreaseOrderCount(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, direction types.PositionDirection, price sdk.Dec, count uint64) error

func (Keeper) DeleteAllRegisteredPairsForContract

func (k Keeper) DeleteAllRegisteredPairsForContract(ctx sdk.Context, contractAddr string)

func (Keeper) DeleteContract

func (k Keeper) DeleteContract(ctx sdk.Context, contractAddr string)

func (Keeper) DeleteMatchResultState

func (k Keeper) DeleteMatchResultState(ctx sdk.Context, contractAddr string)

func (Keeper) DeleteNextOrderID

func (k Keeper) DeleteNextOrderID(ctx sdk.Context, contractAddr string)

func (Keeper) DeletePriceStateBefore

func (k Keeper) DeletePriceStateBefore(ctx sdk.Context, contractAddr string, timestamp uint64, pair types.Pair)

func (Keeper) DoUnregisterContract

func (k Keeper) DoUnregisterContract(ctx sdk.Context, contract types.ContractInfoV2)

Contract unregistration will remove all orderbook data stored for the contract

func (Keeper) DoUnregisterContractWithRefund

func (k Keeper) DoUnregisterContractWithRefund(ctx sdk.Context, contract types.ContractInfoV2) error

Unregistrate and refund the creator

func (Keeper) GetAllAssetMetadata

func (k Keeper) GetAllAssetMetadata(ctx sdk.Context) []types.AssetMetadata

func (Keeper) GetAllContractInfo

func (k Keeper) GetAllContractInfo(ctx sdk.Context) []types.ContractInfoV2

func (Keeper) GetAllLongBook

func (k Keeper) GetAllLongBook(ctx sdk.Context, contractAddr string) (list []types.LongBook)

GetAllLongBook returns all longBook

func (Keeper) GetAllLongBookForPair

func (k Keeper) GetAllLongBookForPair(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string) (list []types.OrderBookEntry)

func (Keeper) GetAllLongBookForPairPaginated

func (k Keeper) GetAllLongBookForPairPaginated(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, page *query.PageRequest) (list []types.LongBook, pageRes *query.PageResponse, err error)

func (Keeper) GetAllPrices

func (k Keeper) GetAllPrices(ctx sdk.Context, contractAddr string, pair types.Pair) (list []*types.Price)

func (Keeper) GetAllProcessableContractInfo

func (k Keeper) GetAllProcessableContractInfo(ctx sdk.Context) []types.ContractInfoV2

func (Keeper) GetAllRegisteredPairs

func (k Keeper) GetAllRegisteredPairs(ctx sdk.Context, contractAddr string) []types.Pair

func (Keeper) GetAllShortBook

func (k Keeper) GetAllShortBook(ctx sdk.Context, contractAddr string) (list []types.ShortBook)

GetAllShortBook returns all shortBook

func (Keeper) GetAllShortBookForPair

func (k Keeper) GetAllShortBookForPair(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string) (list []types.OrderBookEntry)

func (Keeper) GetAllShortBookForPairPaginated

func (k Keeper) GetAllShortBookForPairPaginated(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, page *query.PageRequest) (list []types.ShortBook, pageRes *query.PageResponse, err error)

func (Keeper) GetAssetMetadataByDenom

func (k Keeper) GetAssetMetadataByDenom(ctx sdk.Context, assetDenom string) (val types.AssetMetadata, found bool)

func (Keeper) GetContract

func (k Keeper) GetContract(ctx sdk.Context, contractAddr string) (types.ContractInfoV2, error)

func (Keeper) GetContractGasLimit

func (k Keeper) GetContractGasLimit(ctx sdk.Context, contractAddr sdk.AccAddress) (uint64, error)

func (Keeper) GetContractUnsuspendCost

func (k Keeper) GetContractUnsuspendCost(ctx sdk.Context) uint64

func (Keeper) GetContractWithoutGasCharge

func (k Keeper) GetContractWithoutGasCharge(ctx sdk.Context, contractAddr string) (types.ContractInfoV2, error)

func (Keeper) GetLongAllocationForOrderID

func (k Keeper) GetLongAllocationForOrderID(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, price sdk.Dec, orderID uint64) (*types.Allocation, bool)

func (Keeper) GetLongBookByPrice

func (k Keeper) GetLongBookByPrice(ctx sdk.Context, contractAddr string, price sdk.Dec, priceDenom string, assetDenom string) (val types.LongBook, found bool)

func (Keeper) GetLongOrderBookEntryByPrice

func (k Keeper) GetLongOrderBookEntryByPrice(ctx sdk.Context, contractAddr string, price sdk.Dec, priceDenom string, assetDenom string) (types.OrderBookEntry, bool)

func (Keeper) GetMatchResultState

func (k Keeper) GetMatchResultState(ctx sdk.Context, contractAddr string) (*types.MatchResult, bool)

func (Keeper) GetMaxOrderPerPrice

func (k Keeper) GetMaxOrderPerPrice(ctx sdk.Context) uint64

func (Keeper) GetMaxPairsPerContract

func (k Keeper) GetMaxPairsPerContract(ctx sdk.Context) uint64

func (Keeper) GetMemStoreKey

func (k Keeper) GetMemStoreKey() sdk.StoreKey

func (Keeper) GetMinProcessableRent

func (k Keeper) GetMinProcessableRent(ctx sdk.Context) uint64

func (Keeper) GetNextOrderID

func (k Keeper) GetNextOrderID(ctx sdk.Context, contractAddr string) uint64

func (Keeper) GetOrderBookEntriesPerLoad

func (k Keeper) GetOrderBookEntriesPerLoad(ctx sdk.Context) uint64

func (Keeper) GetOrderCountState

func (k Keeper) GetOrderCountState(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, direction types.PositionDirection, price sdk.Dec) uint64

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) types.Params

GetParams get all parameters as types.Params

func (Keeper) GetPriceKeysToDelete

func (k Keeper) GetPriceKeysToDelete(store sdk.KVStore, timestamp uint64) [][]byte

func (Keeper) GetPriceState

func (k Keeper) GetPriceState(ctx sdk.Context, contractAddr string, timestamp uint64, pair types.Pair) (types.Price, bool)

func (Keeper) GetPriceTickSizeForPair

func (k Keeper) GetPriceTickSizeForPair(ctx sdk.Context, contractAddr string, pair types.Pair) (sdk.Dec, bool)

func (Keeper) GetPricesForTwap

func (k Keeper) GetPricesForTwap(ctx sdk.Context, contractAddr string, pair types.Pair, lookback uint64) (list []*types.Price)

func (Keeper) GetQuantityTickSizeForPair

func (k Keeper) GetQuantityTickSizeForPair(ctx sdk.Context, contractAddr string, pair types.Pair) (sdk.Dec, bool)

func (Keeper) GetRegisteredPair

func (k Keeper) GetRegisteredPair(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string) (types.Pair, bool)

func (Keeper) GetRentsForContracts

func (k Keeper) GetRentsForContracts(ctx sdk.Context, contractAddrs []string) map[string]uint64

func (Keeper) GetSettlementGasAllowance

func (k Keeper) GetSettlementGasAllowance(ctx sdk.Context, numSettlements int) uint64

func (Keeper) GetShortAllocationForOrderID

func (k Keeper) GetShortAllocationForOrderID(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, price sdk.Dec, orderID uint64) (*types.Allocation, bool)

func (Keeper) GetShortBookByPrice

func (k Keeper) GetShortBookByPrice(ctx sdk.Context, contractAddr string, price sdk.Dec, priceDenom string, assetDenom string) (val types.ShortBook, found bool)

func (Keeper) GetShortOrderBookEntryByPrice

func (k Keeper) GetShortOrderBookEntryByPrice(ctx sdk.Context, contractAddr string, price sdk.Dec, priceDenom string, assetDenom string) (types.OrderBookEntry, bool)

func (Keeper) GetStoreKey

func (k Keeper) GetStoreKey() sdk.StoreKey

func (Keeper) GetTopNLongBooksForPair

func (k Keeper) GetTopNLongBooksForPair(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, n int) (list []types.OrderBookEntry)

func (Keeper) GetTopNLongBooksForPairStarting

func (k Keeper) GetTopNLongBooksForPairStarting(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, n int, startExclusive sdk.Dec) (list []types.OrderBookEntry)

Load the first (up to) N long book entries whose price are smaller than the specified limit in reverse sorted order. Parameters:

n: the largest number of entries to load
startExclusive: the price limit

func (Keeper) GetTopNShortBooksForPair

func (k Keeper) GetTopNShortBooksForPair(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, n int) (list []types.OrderBookEntry)

func (Keeper) GetTopNShortBooksForPairStarting

func (k Keeper) GetTopNShortBooksForPairStarting(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, n int, startExclusive sdk.Dec) (list []types.OrderBookEntry)

Load the first (up to) N short book entries whose price are larger than the specified limit in sorted order. Parameters:

n: the largest number of entries to load
startExclusive: the price limit

func (Keeper) HasRegisteredPair

func (k Keeper) HasRegisteredPair(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string) bool

func (Keeper) IncreaseOrderCount

func (k Keeper) IncreaseOrderCount(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, direction types.PositionDirection, price sdk.Dec, count uint64) error

func (Keeper) IsNewEpoch

func (k Keeper) IsNewEpoch(ctx sdk.Context) (bool, uint64)

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) RemoveAllLongBooksForContract

func (k Keeper) RemoveAllLongBooksForContract(ctx sdk.Context, contractAddr string)

func (Keeper) RemoveAllPricesForContract

func (k Keeper) RemoveAllPricesForContract(ctx sdk.Context, contractAddr string)

func (Keeper) RemoveAllShortBooksForContract

func (k Keeper) RemoveAllShortBooksForContract(ctx sdk.Context, contractAddr string)

func (Keeper) RemoveLongBookByPrice

func (k Keeper) RemoveLongBookByPrice(ctx sdk.Context, contractAddr string, price sdk.Dec, priceDenom string, assetDenom string)

func (Keeper) RemoveShortBookByPrice

func (k Keeper) RemoveShortBookByPrice(ctx sdk.Context, contractAddr string, price sdk.Dec, priceDenom string, assetDenom string)

func (Keeper) SetAssetMetadata

func (k Keeper) SetAssetMetadata(ctx sdk.Context, assetMetadata types.AssetMetadata)

func (Keeper) SetContract

func (k Keeper) SetContract(ctx sdk.Context, contract *types.ContractInfoV2) error

func (Keeper) SetEpoch

func (k Keeper) SetEpoch(ctx sdk.Context, epoch uint64)

func (Keeper) SetLongBook

func (k Keeper) SetLongBook(ctx sdk.Context, contractAddr string, longBook types.LongBook)

SetLongBook set a specific longBook in the store

func (Keeper) SetLongOrderBookEntry

func (k Keeper) SetLongOrderBookEntry(ctx sdk.Context, contractAddr string, longBook types.OrderBookEntry)

func (Keeper) SetMatchResult

func (k Keeper) SetMatchResult(ctx sdk.Context, contractAddr string, result *types.MatchResult)

func (Keeper) SetNextOrderID

func (k Keeper) SetNextOrderID(ctx sdk.Context, contractAddr string, nextID uint64)

func (Keeper) SetOrderCount

func (k Keeper) SetOrderCount(ctx sdk.Context, contractAddr string, priceDenom string, assetDenom string, direction types.PositionDirection, price sdk.Dec, count uint64) error

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams set the params

func (Keeper) SetPriceState

func (k Keeper) SetPriceState(ctx sdk.Context, price types.Price, contractAddr string)

func (Keeper) SetPriceTickSizeForPair

func (k Keeper) SetPriceTickSizeForPair(ctx sdk.Context, contractAddr string, pair types.Pair, ticksize sdk.Dec) error

contract_addr, pair -> tick size

func (Keeper) SetQuantityTickSizeForPair

func (k Keeper) SetQuantityTickSizeForPair(ctx sdk.Context, contractAddr string, pair types.Pair, ticksize sdk.Dec) error

contract_addr, pair -> tick size

func (Keeper) SetShortBook

func (k Keeper) SetShortBook(ctx sdk.Context, contractAddr string, shortBook types.ShortBook)

SetShortBook set a specific shortBook in the store

func (Keeper) SetShortOrderBookEntry

func (k Keeper) SetShortOrderBookEntry(ctx sdk.Context, contractAddr string, shortBook types.OrderBookEntry)

func (*Keeper) SetWasmKeeper

func (k *Keeper) SetWasmKeeper(wasmKeeper *wasm.Keeper)

func (Keeper) SuspendContract

func (k Keeper) SuspendContract(ctx sdk.Context, contractAddress string, reason string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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