keeper

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: AGPL-3.0 Imports: 18 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,
	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,
) []types.Asset

func (Keeper) GetAsset

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

func (Keeper) GetDenomById

func (k Keeper) GetDenomById(
	ctx sdk.Context,
	id uint32,
) (
	denom string,
	err error,
)

GetDenomById returns the `denom` of the asset with a given `id`. Returns an error if the `id` does not exist.

func (Keeper) GetIdByDenom

func (k Keeper) GetIdByDenom(
	ctx sdk.Context,
	denom string,
) (
	id uint32,
	err error,
)

GetIdByDenom returns the `id` of the asset with a given `denom`. Returns an error if the `denom` does not exist.

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) GetNumAssets

func (k Keeper) GetNumAssets(
	ctx sdk.Context,
) uint32

func (Keeper) InitializeForGenesis

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

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)

func (Keeper) ModifyLongInterest

func (k Keeper) ModifyLongInterest(
	ctx sdk.Context,
	id uint32,
	isIncrease bool,
	delta uint64,
) (types.Asset, error)

Jump to

Keyboard shortcuts

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