action

package
v0.21.0-rc.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMargin

func AddMargin(
	account sdk.AccAddress,
	pair asset.Pair,
	margin sdkmath.Int,
) action.Action

AddMargin adds margin to the position

func ChangeLiquidationFeeRatio

func ChangeLiquidationFeeRatio(liquidationFeeRatio sdk.Dec) action.Action

func ClosePosition

func ClosePosition(account sdk.AccAddress, pair asset.Pair) action.Action

ClosePosition closes a position for the given account and pair.

func CreateCustomMarket

func CreateCustomMarket(pair asset.Pair, marketModifiers ...marketModifier) action.Action

CreateCustomMarket creates a market with custom parameters

func CreateMarket

func CreateMarket(pair asset.Pair, market types.Market, amm types.AMM) action.Action

func EditPriceMultiplier

func EditPriceMultiplier(pair asset.Pair, multiplier sdk.Dec) action.Action

func EditSwapInvariant

func EditSwapInvariant(pair asset.Pair, multiplier sdk.Dec) action.Action

func InsertPosition

func InsertPosition(modifiers ...positionModifier) action.Action

func InsertReserveSnapshot

func InsertReserveSnapshot(pair asset.Pair, time time.Time, modifiers ...reserveSnapshotModifier) action.Action

func MsgServerAddMargin

func MsgServerAddMargin(
	traderAddress sdk.AccAddress,
	pair asset.Pair,
	amount sdkmath.Int,
) action.Action

func MsgServerClosePosition

func MsgServerClosePosition(
	traderAddress sdk.AccAddress,
	pair asset.Pair,
) action.Action

func MsgServerDonateToPerpEf

func MsgServerDonateToPerpEf(
	traderAddress sdk.AccAddress,
	amount sdkmath.Int,
) action.Action

func MsgServerMultiLiquidate

func MsgServerMultiLiquidate(liquidator sdk.AccAddress, shouldAllFail bool, pairTraderTuples ...PairTraderTuple) action.Action

func MsgServerOpenPosition

func MsgServerOpenPosition(
	traderAddress sdk.AccAddress,
	pair asset.Pair,
	dir types.Direction,
	quoteAssetAmt sdkmath.Int,
	leverage sdk.Dec,
	baseAssetAmtLimit sdkmath.Int,
) action.Action

func MsgServerRemoveMargin

func MsgServerRemoveMargin(
	traderAddress sdk.AccAddress,
	pair asset.Pair,
	amount sdkmath.Int,
) action.Action

func MultiLiquidate

func MultiLiquidate(liquidator sdk.AccAddress, shouldAllFail bool, pairTraderTuples ...PairTraderTuple) action.Action

func OpenPosition

func OpenPosition(
	trader sdk.AccAddress,
	pair asset.Pair,
	dir types.Direction,
	margin sdkmath.Int,
	leverage sdk.Dec,
	baseAssetLimit sdk.Dec,
	responseCheckers ...OpenPositionResponseChecker,
) action.Action

OpenPosition opens a position with the given parameters.

responseCheckers are optional functions that can be used to check expected response.

func OpenPositionFails

func OpenPositionFails(
	trader sdk.AccAddress,
	pair asset.Pair,
	dir types.Direction,
	margin sdkmath.Int,
	leverage sdk.Dec,
	baseAssetLimit sdk.Dec,
	expectedErr error,
) action.Action

func QueryPosition

func QueryPosition(pair asset.Pair, traderAddress sdk.AccAddress, responseCheckers ...QueryPositionChecker) action.Action

func QueryPositionNotFound

func QueryPositionNotFound(pair asset.Pair, traderAddress sdk.AccAddress) action.Action

func QueryPositions

func QueryPositions(traderAddress sdk.AccAddress, responseCheckers ...[]QueryPositionChecker) action.Action

func RemoveMargin

func RemoveMargin(
	account sdk.AccAddress,
	pair asset.Pair,
	margin sdkmath.Int,
) action.Action

func RemoveMarginFail

func RemoveMarginFail(
	account sdk.AccAddress,
	pair asset.Pair,
	margin sdkmath.Int,
	err error,
) action.Action

func SetMarketEnabled

func SetMarketEnabled(pair asset.Pair, enable bool) action.Action

Enable market

func WithLastUpdatedBlockNumber

func WithLastUpdatedBlockNumber(lastUpdatedBlockNumber int64) positionModifier

func WithLatestCumulativePremiumFraction

func WithLatestCumulativePremiumFraction(latestCumulativePremiumFraction sdk.Dec) positionModifier

func WithMargin

func WithMargin(margin sdk.Dec) positionModifier

func WithOpenNotional

func WithOpenNotional(openNotional sdk.Dec) positionModifier

func WithPair

func WithPair(pair asset.Pair) positionModifier

func WithPrepaidBadDebt

func WithPrepaidBadDebt(amount sdkmath.Int) marketModifier

func WithPriceMultiplier

func WithPriceMultiplier(multiplier sdk.Dec) reserveSnapshotModifier

func WithPricePeg

func WithPricePeg(multiplier sdk.Dec) marketModifier

func WithSize

func WithSize(size sdk.Dec) positionModifier

func WithSqrtDepth

func WithSqrtDepth(amount sdk.Dec) marketModifier

func WithTotalLong

func WithTotalLong(amount sdk.Dec) marketModifier

func WithTotalShort

func WithTotalShort(amount sdk.Dec) marketModifier

func WithTrader

func WithTrader(addr sdk.AccAddress) positionModifier

func WithdrawFromVault

func WithdrawFromVault(pair asset.Pair, account sdk.AccAddress, amount sdkmath.Int) action.Action

Types

type OpenPositionResponseChecker

type OpenPositionResponseChecker func(resp *types.PositionResp) error

Open Position Response Checkers

func OpenPositionResp_BadDebtShouldBeEqual

func OpenPositionResp_BadDebtShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_BadDebtShouldBeEqual checks that the bad debt included in the response is equal to the expected value.

func OpenPositionResp_ExchangeNotionalValueShouldBeEqual

func OpenPositionResp_ExchangeNotionalValueShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_ExchangeNotionalValueShouldBeEqual checks that the exchanged notional value included in the response is equal to the expected value.

func OpenPositionResp_ExchangedPositionSizeShouldBeEqual

func OpenPositionResp_ExchangedPositionSizeShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_ExchangedPositionSizeShouldBeEqual checks that the exchanged position size included in the response is equal to the expected value.

func OpenPositionResp_FundingPaymentShouldBeEqual

func OpenPositionResp_FundingPaymentShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_FundingPaymentShouldBeEqual checks that the funding payment included in the response is equal to the expected value.

func OpenPositionResp_MarginToVaultShouldBeEqual

func OpenPositionResp_MarginToVaultShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_MarginToVaultShouldBeEqual checks that the margin to vault included in the response is equal to the expected value.

func OpenPositionResp_PositionNotionalShouldBeEqual

func OpenPositionResp_PositionNotionalShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_PositionNotionalShouldBeEqual checks that the position notional included in the response is equal to the expected value.

func OpenPositionResp_PositionShouldBeEqual

func OpenPositionResp_PositionShouldBeEqual(expected types.Position) OpenPositionResponseChecker

OpenPositionResp_PositionShouldBeEqual checks that the position included in the response is equal to the expected position response.

func OpenPositionResp_RealizedPnlShouldBeEqual

func OpenPositionResp_RealizedPnlShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_RealizedPnlShouldBeEqual checks that the realized pnl included in the response is equal to the expected value.

func OpenPositionResp_UnrealizedPnlAfterShouldBeEqual

func OpenPositionResp_UnrealizedPnlAfterShouldBeEqual(expected sdk.Dec) OpenPositionResponseChecker

OpenPositionResp_UnrealizedPnlAfterShouldBeEqual checks that the unrealized pnl after included in the response is equal to the expected value.

type PairTraderTuple

type PairTraderTuple struct {
	Pair       asset.Pair
	Trader     sdk.AccAddress
	Successful bool
}

type QueryPositionChecker

type QueryPositionChecker func(resp types.QueryPositionResponse) error

func QueryPosition_MarginRatioEquals

func QueryPosition_MarginRatioEquals(expected sdk.Dec) QueryPositionChecker

func QueryPosition_PositionEquals

func QueryPosition_PositionEquals(expected types.Position) QueryPositionChecker

func QueryPosition_PositionNotionalEquals

func QueryPosition_PositionNotionalEquals(expected sdk.Dec) QueryPositionChecker

func QueryPosition_UnrealizedPnlEquals

func QueryPosition_UnrealizedPnlEquals(expected sdk.Dec) QueryPositionChecker

Jump to

Keyboard shortcuts

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