Documentation ¶
Index ¶
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- type Keeper
- func (k Keeper) AllAssets(c context.Context, req *types.QueryAllAssetsRequest) (*types.QueryAllAssetsResponse, error)
- func (k Keeper) Asset(c context.Context, req *types.QueryAssetRequest) (*types.QueryAssetResponse, error)
- func (k Keeper) ConvertAssetToCoin(ctx sdk.Context, assetId uint32, quantums *big.Int) (convertedQuantums *big.Int, coin sdk.Coin, err error)
- func (k Keeper) CreateAsset(ctx sdk.Context, assetId uint32, symbol string, denom string, ...) (types.Asset, error)
- func (k Keeper) GetAllAssets(ctx sdk.Context) (list []types.Asset)
- func (k Keeper) GetAsset(ctx sdk.Context, id uint32) (val types.Asset, exists bool)
- func (k Keeper) GetIndexerEventManager() indexer_manager.IndexerEventManager
- func (k Keeper) GetMarginRequirements(ctx sdk.Context, id uint32, bigQuantums *big.Int) (bigInitialMarginQuoteQuantums *big.Int, ...)
- func (k Keeper) GetNetCollateral(ctx sdk.Context, id uint32, bigQuantums *big.Int) (bigNetCollateralQuoteQuantums *big.Int, err error)
- func (k Keeper) InitializeForGenesis(ctx sdk.Context)
- func (k Keeper) IsPositionUpdatable(ctx sdk.Context, id uint32) (updatable bool, err error)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) ModifyAsset(ctx sdk.Context, id uint32, hasMarket bool, marketId uint32) (types.Asset, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMsgServerImpl ¶
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 ¶
func (k Keeper) AllAssets( c context.Context, req *types.QueryAllAssetsRequest, ) (*types.QueryAllAssetsResponse, error)
TODO(CLOB-863) Add tests for these endpoints.
func (Keeper) Asset ¶
func (k Keeper) Asset(c context.Context, req *types.QueryAssetRequest) (*types.QueryAssetResponse, error)
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 (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 (Keeper) IsPositionUpdatable ¶
IsPositionUpdatable returns whether position of an asset is updatable.