keeper

package
v0.0.0-...-baf6593 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

Types

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey storetypes.StoreKey,
	pricesKeeper types.PricesKeeper,
	indexerEventManager indexer_manager.IndexerEventManager,
) *Keeper

func (Keeper) AllAssets

TODO(CLOB-863) Add tests for these endpoints.

func (Keeper) Asset

func (Keeper) ConvertAssetToCoin

func (k Keeper) ConvertAssetToCoin(
	ctx sdk.Context,
	assetId uint32,
	quantums *big.Int,
) (
	convertedQuantums *big.Int,
	coin sdk.Coin,
	err error,
)

ConvertAssetToCoin converts the given `assetId` and `quantums` used in `x/asset`, to an `sdk.Coin` in correspoding `denom` and `amount` used in `x/bank`. Also outputs `convertedQuantums` which has the equal value as converted `sdk.Coin`. The conversion is done with the formula:

denom_amount = quantums * 10^(atomic_resolution - denom_exponent)

If the resulting `denom_amount` is not an integer, it is rounded down, and `convertedQuantums` of the equal value is returned. The upstream transfer function should adjust asset balance with `convertedQuantums` to ensure that that no fund is ever lost in the conversion due to rounding error.

Example: Assume `denom_exponent` = -7, `atomic_resolution` = -8, ConvertAssetToCoin(`101 quantums`) should output: - `convertedQuantums` = 100 quantums - converted coin amount = 10 coin

func (Keeper) CreateAsset

func (k Keeper) CreateAsset(
	ctx sdk.Context,
	assetId uint32,
	symbol string,
	denom string,
	denomExponent int32,
	hasMarket bool,
	marketId uint32,
	atomicResolution int32,
) (types.Asset, error)

func (Keeper) GetAllAssets

func (k Keeper) GetAllAssets(
	ctx sdk.Context,
) (list []types.Asset)

func (Keeper) GetAsset

func (k Keeper) GetAsset(
	ctx sdk.Context,
	id uint32,
) (val types.Asset, exists bool)

func (Keeper) GetIndexerEventManager

func (k Keeper) GetIndexerEventManager() indexer_manager.IndexerEventManager

func (Keeper) GetMarginRequirements

func (k Keeper) GetMarginRequirements(
	ctx sdk.Context,
	id uint32,
	bigQuantums *big.Int,
) (
	bigInitialMarginQuoteQuantums *big.Int,
	bigMaintenanceMarginQuoteQuantums *big.Int,
	err error,
)

GetMarginRequirements returns the initial and maintenance margin- requirements for a given position size for a given assetId.

func (Keeper) GetNetCollateral

func (k Keeper) GetNetCollateral(
	ctx sdk.Context,
	id uint32,
	bigQuantums *big.Int,
) (
	bigNetCollateralQuoteQuantums *big.Int,
	err error,
)

GetNetCollateral returns the net collateral that a given position (quantums) for a given assetId contributes to an account.

func (Keeper) InitializeForGenesis

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

func (Keeper) IsPositionUpdatable

func (k Keeper) IsPositionUpdatable(
	ctx sdk.Context,
	id uint32,
) (
	updatable bool,
	err error,
)

IsPositionUpdatable returns whether position of an asset is updatable.

func (Keeper) Logger

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

func (Keeper) ModifyAsset

func (k Keeper) ModifyAsset(
	ctx sdk.Context,
	id uint32,
	hasMarket bool,
	marketId uint32,
) (types.Asset, error)

Jump to

Keyboard shortcuts

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