diff --git a/.gitignore b/.gitignore index 5e06e6fe..e2c2389b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +.idea diff --git a/docs/develop/modules/injective/exchange/02_other_concepts.md b/docs/develop/modules/injective/exchange/02_other_concepts.md index e971f931..b4fbe8b9 100644 --- a/docs/develop/modules/injective/exchange/02_other_concepts.md +++ b/docs/develop/modules/injective/exchange/02_other_concepts.md @@ -67,3 +67,7 @@ Governance approves a **FeeDiscountProposal** which defines a fee discount **sch - If the fee discount proposal was passed less than 30 days ago, i.e. `BucketCount * BucketDuration` hasn't passed yet since the creation of the proposal, the fee volume requirement is ignored so we don't unfairly penalize market makers who onboard immediately. Internally the trading volumes are stored in buckets, typically 30 buckets each lasting 24 hours. When a bucket is older than 30 days, it gets removed. Additionally for performance reasons there is a cache for retrieving the fee discount tier for an account. This cache is updated every 24 hours. + +### Stake Delegations/Grants + +Staked INJ requirements for fee discount tiers can be met through grants from other addresses that have staked their INJ. The total staked INJ value used for fee discount calculations is `OwnStake + StakeGrantedFromGranter - TotalStakeGrantedToOthers`. Note that although several grants can be made to a single address, **only one grant can be activated** for use at a single time. However, a single address can have multiple grants made to other addresses at the same time. Note that only INJ staked with 25 validators is used to calculate `OwnStake` for stake grant purposes. To ensure all staked INJ can be utilized for grants, stake with 25 or fewer validators. Granted stake cannot be regranted. diff --git a/docs/develop/modules/injective/exchange/03_state.md b/docs/develop/modules/injective/exchange/03_state.md index 719cc7b2..3e615d37 100644 --- a/docs/develop/modules/injective/exchange/03_state.md +++ b/docs/develop/modules/injective/exchange/03_state.md @@ -592,3 +592,40 @@ enum ExecutionType { LimitMatchNewOrder = 4; } ``` + +## GrantAuthorization + +`GrantAuthorization` is used to track the grantee's address and amount of the granted stake that has been authorized by the granter for trading fee discounts. + +```protobuf +type GrantAuthorization struct { + Grantee string + Amount math.Int +} + +``` + +## ActiveGrant + +`ActiveGrant` is used to track the granter's address and amount of the granted stake (for trading fee discounts) in the grant that has been activated by the grantee. + +```protobuf +type ActiveGrant struct { + Granter string + Amount math.Int +} + +``` + +## EffectiveGrant + +`EffectiveGrant` is used to track the total amount of stake a granter has authorized in stake grants for trading fee discounts. + +```protobuf +type EffectiveGrant struct { + Granter string + NetGrantedStake math.Int + IsValid bool +} + +``` \ No newline at end of file diff --git a/docs/develop/modules/injective/exchange/04_state_transitions.md b/docs/develop/modules/injective/exchange/04_state_transitions.md index 99b858ee..d283ac88 100644 --- a/docs/develop/modules/injective/exchange/04_state_transitions.md +++ b/docs/develop/modules/injective/exchange/04_state_transitions.md @@ -34,10 +34,11 @@ This document describes the state transition operations pertaining to: - Derivative market param update proposal - Trading rewards launch proposal - Trading rewards update proposal -- Begin-blocker -- End-blocker +- Fee discount schedule proposal +- Stake grant authorizations +- Stake grant activation -## Deposit into exchange module account +## Deposit Into Exchange Module Account Deposit action is carried out by `MsgDeposit` which consists of `Sender`, `SubaccountId` and `Amount` fields. @@ -51,7 +52,7 @@ Deposit action is carried out by `MsgDeposit` which consists of `Sender`, `Subac - Increment deposit amount for the `subaccountID` by `msg.Amount` - Emit event for `EventSubaccountDeposit` with `msg.Sender`, `subaccountID` and `msg.Amount` -## Withdraw from exchange module account +## Withdraw From Exchange Module Account Withdraw action is carried out by `MsgWithdraw` which consists of `Sender`, `SubaccountId` and `Amount` fields. @@ -65,7 +66,7 @@ Withdraw action is carried out by `MsgWithdraw` which consists of `Sender`, `Sub - Send coins from `exchange` module to `msg.Sender` - Emit event for `EventSubaccountWithdraw` with `subaccountID`, `msg.Sender`, and `msg.Amount` -## Instant spot market launch +## Instant Spot Market Launch Instant spot market launch action is carried out by `MsgInstantSpotMarketLaunch` which consists of `Sender`, `Ticker`, `BaseDenom`, `QuoteDenom`, `MinPriceTickSize` and `MinQuantityTickSize` fields. @@ -77,7 +78,7 @@ Instant spot market launch action is carried out by `MsgInstantSpotMarketLaunch` - Send instant listing fee(params.SpotMarketInstantListingFee) from `msg.Sender` to `exchange` module account - Lastly send the instant listing fee to the community spend pool -## Instant perpetual market launch +## Instant Perpetual Market Launch Instant perpetual market launch action is carried out by `MsgInstantPerpetualMarketLaunch` which consists of `Sender`, `Ticker`, `QuoteDenom`, `OracleBase`, `OracleQuote`, `OracleScaleFactor`, `OracleType`, `MakerFeeRate`, `TakerFeeRate`, `InitialMarginRatio`, `MaintenanceMarginRatio`, `MinPriceTickSize` and `MinQuantityTickSize` fields. @@ -89,7 +90,7 @@ Instant perpetual market launch action is carried out by `MsgInstantPerpetualMar - Launch perpetual market with required params on `msg` object and revert if fail - Lastly send the instant listing fee to the community spend pool -## Instant expiry futures market launch +## Instant Expiry Futures Market Launch Instant expiry futures market launch action is carried out by `MsgInstantExpiryFuturesMarketLaunch` which consists of `Sender`, `Ticker`, `QuoteDenom`, `OracleBase`, `OracleQuote`, `OracleScaleFactor`, `OracleType`, `Expiry`, `MakerFeeRate`, `TakerFeeRate`, `InitialMarginRatio`, `MaintenanceMarginRatio`, `MinPriceTickSize` and `MinQuantityTickSize` fields. @@ -102,7 +103,7 @@ Instant expiry futures market launch action is carried out by `MsgInstantExpiryF - Trigger `EventExpiryFuturesMarketUpdate` event with market info - Lastly send the instant listing fee to the community spend pool -## Spot limit order creation +## Spot Limit Order Creation Spot limit order creation is carried out by `MsgCreateSpotLimitOrder` which consists of `Sender` and `Order`. @@ -119,7 +120,7 @@ Spot limit order creation is carried out by `MsgCreateSpotLimitOrder` which cons **Note:** The order in transient store is executed on endblocker or if not, put on long-live store. -## Batch creation of spot limit orders +## Batch Creation of Spot Limit Orders Batch creation of spot limit orders is carried out by `MsgBatchCreateSpotLimitOrders` which consists of `Sender` and `Orders`. @@ -127,7 +128,7 @@ Batch creation of spot limit orders is carried out by `MsgBatchCreateSpotLimitOr - Loop over the `msg.Orders` and create spot limit order as in `MsgCreateSpotLimitOrder` -## Spot market order creation +## Spot Market Order Creation Spot market order creation is carried out by `MsgCreateSpotMarketOrder` which consists of `Sender` and `Order`. @@ -143,7 +144,7 @@ Spot market order creation is carried out by `MsgCreateSpotMarketOrder` which co - Decrement deposit's AvailableBalance by the balance hold - Store the order in the transient spot market order store and transient market indicator store -## Cancel spot order +## Cancel Spot Order Spot order cancellation is carried out by `MsgCancelSpotOrder` which consists of `Sender` and `MarketId`, `SubaccountId` and `OrderHash`. @@ -157,7 +158,7 @@ Spot order cancellation is carried out by `MsgCancelSpotOrder` which consists of - Delete the order state from ordersStore and ordersIndexStore - Emit `EventCancelSpotOrder` event with marketID and order info -## Batch cancellation of spot orders +## Batch Cancellation of Spot Orders Batch cancellation of spot orders is carried out by `MsgBatchCancelSpotOrders` which consists of `Sender` and `Data`. @@ -165,7 +166,7 @@ Batch cancellation of spot orders is carried out by `MsgBatchCancelSpotOrders` w - Loop over the `msg.Data` and cancel spot order as in `MsgCancelSpotOrder` -## Derivative limit order creation +## Derivative Limit Order Creation Derivative limit order creation is carried out by `MsgCreateDerivativeLimitOrder` which consists of `Sender` and `Order`. @@ -188,7 +189,7 @@ Derivative limit order creation is carried out by `MsgCreateDerivativeLimitOrder - Store the order in the transient limit order store and transient market indicator store - Update orderbook metadata for subaccount -## Batch creation of derivative limit orders +## Batch Creation of Derivative Limit Orders Batch creation of derivative limit orders is carried out by `MsgBatchCreateDerivativeLimitOrders` which consists of `Sender` and `Orders`. @@ -196,7 +197,7 @@ Batch creation of derivative limit orders is carried out by `MsgBatchCreateDeriv - Loop over the `msg.Orders` and create derivative limit order as in `MsgCreateDerivativeLimitOrder` -## Derivative market order creation +## Derivative Market Order Creation Derivative market order creation is carried out by `MsgCreateDerivativeMarketOrder` which consists of `Sender` and `Order`. @@ -222,7 +223,7 @@ Derivative market order creation is carried out by `MsgCreateDerivativeMarketOrd - For an opposing position, if AggregateVanillaQuantity > position.quantity - AggregateReduceOnlyQuantity - order.FillableQuantity, the new reduce-only order might invalidate some existing reduce-only orders or itself be invalid, and do operations for that. - Store the order in the transient derivative market order store and transient market indicator store -## Cancel derivative order +## Cancel Derivative Order Derivative order cancellation is carried out by `MsgCancelDerivativeOrder` which consists of `Sender`, `MarketId`, `SubaccountId` and `OrderHash`. @@ -237,7 +238,7 @@ Derivative order cancellation is carried out by `MsgCancelDerivativeOrder` which - Update orderbook metadata for subaccount - Emit `EventCancelDerivativeOrder` event with marketID and order info -## Batch cancellation of derivative orders +## Batch Cancellation of Derivative Orders Batch cancellation of derivative orders is carried out by `MsgBatchCancelDerivativeOrders` which consists of `Sender` and `Data`. @@ -245,7 +246,7 @@ Batch cancellation of derivative orders is carried out by `MsgBatchCancelDerivat - Loop over the `msg.Data` and cancel spot order as in `MsgCancelDerivativeOrder` -## Batch order updates +## Batch Order Updates Batch updating orders is carried out by `MsgBatchUpdateOrders` which consists of `Sender` and `Orders`. @@ -257,7 +258,7 @@ Batch updating orders is carried out by `MsgBatchUpdateOrders` which consists of - Loop over the `msg.SpotOrdersToCreate` and create spot limit order as in `MsgCreateSpotOrder`. If the creation fails, continue to next order. Successful creations are reflected in the `MsgBatchUpdateOrdersResponse` as `SpotOrderHashes`. - Loop over the `msg.DerivativeOrdersToCreate` and create derivative limit order as in `MsgCreateDerivativeOrder`. If the creation fails, continue to next order. Successful creations are reflected in the `MsgBatchUpdateOrdersResponse` as `DerivativeOrderHashes`. -## Transfer between subaccounts +## Transfer Between Subaccounts Transfer between subaccounts is executed by `MsgSubaccountTransfer` which consists of `Sender`, `SourceSubaccountId`, `DestinationSubaccountId` and `Amount`. @@ -269,7 +270,7 @@ Transfer between subaccounts is executed by `MsgSubaccountTransfer` which consis **Note:** With subaccount transfer, no need to transfer actual coins from bank module but changing the records are enough. -## Transfer to external account +## Transfer to External Account Transfer to external account is executed by `MsgExternalTransfer` which consists of `Sender`, `SourceSubaccountId`, `DestinationSubaccountId` and `Amount`. @@ -284,7 +285,7 @@ Transfer to external account is executed by `MsgExternalTransfer` which consists 1. Event should be different for subaccount transfer and external transfer. 2. There's no difference in subaccount transfer and external transfer, still need to keep different messages? -## Liquidating a position +## Liquidating a Position Liquidating a position is executed by `MsgLiquidatePosition` which consists of `Sender`, `SubaccountId`, `MarketId` and `Order`. @@ -315,7 +316,7 @@ Liquidating a position is executed by `MsgLiquidatePosition` which consists of ` - If market is a perpetual market, upgrade VWAP data based on liquidation price and quantity - If there's remaining in liquidation order, return back remains by cancelling order -## Increasing position margin +## Increasing Position Margin Increasing position margin is executed by `MsgIncreasePositionMargin` which consists of `Sender`, `SourceSubaccountId`, `DestinationSubaccountId`, `MarketId` and `Amount`. @@ -329,7 +330,7 @@ Increasing position margin is executed by `MsgIncreasePositionMargin` which cons - Reduce deposit amount of `sourceSubaccountID` by `msg.Amount` - Increase position margin by `msg.Amount` and update position in the store -## Exchange enable proposal +## Exchange Enable Proposal The enable of market type is done by `ExchangeEnableProposal` which consists of `Title`, `Description` and `ExchangeType`. @@ -339,7 +340,7 @@ The enable of market type is done by `ExchangeEnableProposal` which consists of - If `p.ExchangeType` is spot market, enable spot exchange - If `p.ExchangeType` is derivative market, enable derivative market -## Spot market launch proposal +## Spot Market Launch Proposal Launch of spot market is handled by `SpotMarketLaunchProposal` which consists of `Title`, `Description`, `Ticker`, `BaseDenom`, `QuoteDenom`, `MinPriceTickSize` and `MinQuantityTickSize` fields. @@ -351,7 +352,7 @@ Launch of spot market is handled by `SpotMarketLaunchProposal` which consists of - Calculate RelayerFeeShareRate based on exchange module params. **Note:** for INJ currency, relayer share rate is set to 100% - Save spot market with calculated `ticker`, `baseDenom`, `quoteDenom`, `exchangeParams.DefaultSpotMakerFeeRate`, `exchangeParams.DefaultSpotTakerFeeRate`, `relayerFeeShareRate`, `minPriceTickSize`, `minQuantityTickSize`, `marketID`, and `MarketStatus_Active`. -## Perpetual market launch proposal +## Perpetual Market Launch Proposal Perpetual market launch is handled by `PerpetualMarketLaunchProposal` which consists of `Title`, `Description`, `Ticker`, `QuoteDenom`, `OracleBase`, `OracleQuote`, `OracleScaleFactor`, `OracleType`, `MakerFeeRate`, `TakerFeeRate`, `InitialMarginRatio`, `MaintenanceMarginRatio`, `MinPriceTickSize` and `MinQuantityTickSize` fields. @@ -366,7 +367,7 @@ Perpetual market launch is handled by `PerpetualMarketLaunchProposal` which cons - Calculate `defaultFundingInterval`, `nextFundingTimestamp`, `relayerFeeShareRate` from `exchange` module params - Execute `SetDerivativeMarketWithInfo` to set market info into the storage with `market`, `marketInfo` and `funding` objects -## Expiry futures market launch proposal +## Expiry Futures Market Launch Proposal Expiry futures market launch is handled by `ExpiryFuturesMarketLaunchProposal` which consists of `Title`, `Description`, `Ticker`, `QuoteDenom`, `OracleBase`, `OracleQuote`, `OracleScaleFactor`, `OracleType`, `Expiry`, `MakerFeeRate`, `TakerFeeRate`, `InitialMarginRatio`, `MaintenanceMarginRatio`, `MinPriceTickSize` and `MinQuantityTickSize` fields. @@ -382,7 +383,7 @@ Expiry futures market launch is handled by `ExpiryFuturesMarketLaunchProposal` w - Calculate RelayerFeeShareRate based on exchange module params. **Note:** for INJ currency, relayer share rate is set to 100% - Execute `SetDerivativeMarketWithInfo` to set market info into the storage with `market`, `marketInfo` objects **Note:** TwapStartTimestamp is set to `expiry - thirtyMinutesInSeconds`. -## Spot market param update proposal +## Spot Market Param Update Proposal The update of spot market param is handled by `SpotMarketParamUpdateProposal` which consists of `Title`, `Description`, `MarketId`, `MakerFeeRate`, `TakerFeeRate`, `RelayerFeeShareRate`, `MinPriceTickSize`, `MinQuantityTickSize` and `Status`. @@ -393,7 +394,7 @@ The update of spot market param is handled by `SpotMarketParamUpdateProposal` wh - Reset the params for `MakerFeeRate`, `TakerFeeRate`, `RelayerFeeShareRate`, `MinPriceTickSize`, `MinQuantityTickSize` and `Status` if not empty, if empty keep as it is. - Validate `MakerFeeRate` is bigger than `TakerFeeRate`. -## Derivative market param update proposal +## Derivative Market Param Update Proposal Derivative market param update is handled by `DerivativeMarketParamUpdateProposal` which consists of `Title`, `Description`, `MarketId`, `InitialMarginRatio`, `MaintenanceMarginRatio`, `MakerFeeRate`, `TakerFeeRate`, `RelayerFeeShareRate`, `MinPriceTickSize`, `MinQuantityTickSize` and `Status`. @@ -445,3 +446,24 @@ Derivative market param update is handled by `DerivativeMarketParamUpdateProposa - Set the first fee paid bucket timestamp as the current block time - Set New Fee Discount Schedule, delete it along with Market Qualifications - Set New Market Qualifications + +## Stake Grant Authorizations + +**Steps** + +- Check if an existing grant from the granter already exists for the grantee +- Calculate the new total amount of stake granted to the grantee by subtracting the existing grant amounts and adding the new grant amounts (essentially overwrites the existing grant amounts with the new grant amounts) +- Ensure valid grant authorizations by making sure total amount granted is less than or equal to total amount staked by granter +- Update grant amounts for grantee +- Set grant to active if the current active grant is from the same granter or if there is no current active grant +- Emit `EventGrantAuthorizations` with granter and grants + + +## Stake Grant Activation + +**Steps** + +- Check to make sure grant from granter to grantee exists +- Check to make sure granter is not granting more than their total staked amount +- If grant amount is 0, delete the grant, otherwise write new grant amount to store +- Emit `EventGrantActivation` with grantee, granter, and amount diff --git a/docs/develop/modules/injective/exchange/05_messages.md b/docs/develop/modules/injective/exchange/05_messages.md index 75ad01c5..537ae147 100644 --- a/docs/develop/modules/injective/exchange/05_messages.md +++ b/docs/develop/modules/injective/exchange/05_messages.md @@ -391,7 +391,6 @@ type MsgLiquidatePosition struct { `MsgIncreasePositionMargin` describes a message to increase margin of an account. ```go -// A Cosmos-SDK MsgIncreasePositionMargin type MsgIncreasePositionMargin struct { Sender string SourceSubaccountId string @@ -417,7 +416,6 @@ type MsgIncreasePositionMargin struct { `MsgBatchUpdateOrders` allows for the atomic cancellation and creation of spot and derivative limit orders, along with a new order cancellation mode. Upon execution, order cancellations (if any) occur first, followed by order creations (if any). ```go -// A Cosmos-SDK MsgBatchUpdateOrders // SubaccountId only used for the spot_market_ids_to_cancel_all and derivative_market_ids_to_cancel_all. type MsgBatchUpdateOrders struct { Sender string @@ -441,3 +439,39 @@ type MsgBatchUpdateOrders struct { - `DerivativeOrdersToCancel` field describes specific derivative orders the sender wants to cancel. - `SpotOrdersToCreate` field describes spot orders the sender wants to create. - `DerivativeOrdersToCreate` field describes derivative orders the sender wants to create. + + + +## Msg/AuthorizeStakeGrants + +`MsgAuthorizeStakeGrants` is a message used to grant another address with staked INJ balance for fee discount purposes. It can also be used to revoke/remove grants if the amount granted is set to 0. + +```go +type MsgAuthorizeStakeGrants struct { + Sender string + Grants []*GrantAuthorization +} +``` + +**Fields description** + +- `Sender` describes the creator of this msg. +- `Grants` describes a list of grantees' addresses and grant amounts + + + +## Msg/ActivateStakeGrant + +`MsgActivateStakeGrant` is a message used to select/activate a stake grant for fee discount purposes. + +```go +type MsgAuthorizeStakeGrants struct { + Sender string + Granter string +} +``` + +**Fields description** + +- `Sender` describes the creator of this msg. +- `Granter` describes the address of the granter. \ No newline at end of file diff --git a/docs/develop/modules/injective/exchange/09_events.md b/docs/develop/modules/injective/exchange/09_events.md index 09008054..97e70525 100644 --- a/docs/develop/modules/injective/exchange/09_events.md +++ b/docs/develop/modules/injective/exchange/09_events.md @@ -53,10 +53,20 @@ message EventDerivativeMarketPaused { string missing_funds_rate = 4; } +message EventMarketBeyondBankruptcy { + string market_id = 1; + string settle_price = 2; + string missing_market_funds = 3; +} + +message EventAllPositionsHaircut { + string market_id = 1; + string settle_price = 2; + string missing_funds_rate = 3; +} + message EventBinaryOptionsMarketUpdate { - BinaryOptionsMarket market = 1 [ - (gogoproto.nullable) = false - ]; + BinaryOptionsMarket market = 1 [ (gogoproto.nullable) = false ]; } message EventNewSpotOrders { @@ -73,43 +83,28 @@ message EventNewDerivativeOrders { message EventCancelSpotOrder { string market_id = 1; - SpotLimitOrder order = 2 [ - (gogoproto.nullable) = false - ]; + SpotLimitOrder order = 2 [ (gogoproto.nullable) = false ]; } message EventSpotMarketUpdate { - SpotMarket market = 1 [ - (gogoproto.nullable) = false - ]; + SpotMarket market = 1 [ (gogoproto.nullable) = false ]; } message EventPerpetualMarketUpdate { - DerivativeMarket market = 1 [ - (gogoproto.nullable) = false - ]; - PerpetualMarketInfo perpetual_market_info = 2[ - (gogoproto.nullable) = true - ]; - PerpetualMarketFunding funding = 3[ - (gogoproto.nullable) = true - ]; + DerivativeMarket market = 1 [ (gogoproto.nullable) = false ]; + PerpetualMarketInfo perpetual_market_info = 2 [ (gogoproto.nullable) = true ]; + PerpetualMarketFunding funding = 3 [ (gogoproto.nullable) = true ]; } message EventExpiryFuturesMarketUpdate { - DerivativeMarket market = 1 [ - (gogoproto.nullable) = false - ]; - ExpiryFuturesMarketInfo expiry_futures_market_info = 3[ - (gogoproto.nullable) = true - ]; + DerivativeMarket market = 1 [ (gogoproto.nullable) = false ]; + ExpiryFuturesMarketInfo expiry_futures_market_info = 3 + [ (gogoproto.nullable) = true ]; } message EventPerpetualMarketFundingUpdate { string market_id = 1; - PerpetualMarketFunding funding = 2[ - (gogoproto.nullable) = false - ]; + PerpetualMarketFunding funding = 2 [ (gogoproto.nullable) = false ]; bool is_hourly_funding = 3; string funding_rate = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", @@ -124,39 +119,40 @@ message EventPerpetualMarketFundingUpdate { message EventSubaccountDeposit { string src_address = 1; bytes subaccount_id = 2; - cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false ]; } message EventSubaccountWithdraw { bytes subaccount_id = 1; string dst_address = 2; - cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false ]; } message EventSubaccountBalanceTransfer { string src_subaccount_id = 1; string dst_subaccount_id = 2; - cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false ]; } -message EventBatchDepositUpdate { - repeated DepositUpdate deposit_updates = 1; +message EventBatchDepositUpdate { repeated DepositUpdate deposit_updates = 1; } + +message DerivativeMarketOrderCancel { + DerivativeMarketOrder market_order = 1 [ (gogoproto.nullable) = true ]; + string cancel_quantity = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; } message EventCancelDerivativeOrder { string market_id = 1; bool isLimitCancel = 2; - DerivativeLimitOrder limit_order = 3 [ - (gogoproto.nullable) = true - ]; - DerivativeMarketOrderCancel market_order_cancel = 4 [ - (gogoproto.nullable) = true - ]; + DerivativeLimitOrder limit_order = 3 [ (gogoproto.nullable) = true ]; + DerivativeMarketOrderCancel market_order_cancel = 4 + [ (gogoproto.nullable) = true ]; } -message EventFeeDiscountSchedule { - FeeDiscountSchedule schedule = 1; -} +message EventFeeDiscountSchedule { FeeDiscountSchedule schedule = 1; } message EventTradingRewardCampaignUpdate { TradingRewardCampaignInfo campaign_info = 1; @@ -166,4 +162,80 @@ message EventTradingRewardCampaignUpdate { message EventTradingRewardDistribution { repeated AccountRewards account_rewards = 1; } + +message EventNewConditionalDerivativeOrder { + string market_id = 1; + DerivativeOrder order = 2; + bytes hash = 3; + bool is_market = 4; +} + +message EventCancelConditionalDerivativeOrder { + string market_id = 1; + bool isLimitCancel = 2; + DerivativeLimitOrder limit_order = 3 [ (gogoproto.nullable) = true ]; + DerivativeMarketOrder market_order = 4 [ (gogoproto.nullable) = true ]; +} + +message EventConditionalDerivativeOrderTrigger { + bytes market_id = 1; + bool isLimitTrigger = 2; + bytes triggered_order_hash = 3; + bytes placed_order_hash = 4; + string triggered_order_cid = 5; +} + +message EventOrderFail { + bytes account = 1; + repeated bytes hashes = 2; + repeated uint32 flags = 3; + repeated string cids = 4; +} + +message EventAtomicMarketOrderFeeMultipliersUpdated { + repeated MarketFeeMultiplier market_fee_multipliers = 1; +} + +message EventOrderbookUpdate { + repeated OrderbookUpdate spot_updates = 1; + repeated OrderbookUpdate derivative_updates = 2; +} + +message OrderbookUpdate { + uint64 seq = 1; + Orderbook orderbook = 2; +} + +message Orderbook { + bytes market_id = 1; + repeated Level buy_levels = 2; + repeated Level sell_levels = 3; +} + +message EventGrantAuthorizations { + string granter = 1; + repeated GrantAuthorization grants = 2; +} + +message EventGrantActivation { + string grantee = 1; + string granter = 2; + string amount = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} + +message EventInvalidGrant { + string grantee = 1; + string granter = 2; +} + +message EventOrderCancelFail { + string market_id = 1; + string subaccount_id = 2; + string order_hash = 3; + string cid = 4; + string description = 5; +} ``` diff --git a/docs/develop/modules/injective/exchange/10_params.md b/docs/develop/modules/injective/exchange/10_params.md index 8dcdf5d1..6ae5d922 100644 --- a/docs/develop/modules/injective/exchange/10_params.md +++ b/docs/develop/modules/injective/exchange/10_params.md @@ -7,29 +7,30 @@ title: Parameters The exchange module contains the following parameters: -| Key | Type | Example | -| ------------------------------------------- | -------- | ------------------ | -| SpotMarketInstantListingFee | sdk.Coin | 100inj | -| DerivativeMarketInstantListingFee | sdk.Coin | 1000inj | -| DefaultSpotMakerFeeRate | math.LegacyDec | 0.1% | -| DefaultSpotTakerFeeRate | math.LegacyDec | 0.2% | -| DefaultDerivativeMakerFeeRate | math.LegacyDec | 0.1% | -| DefaultDerivativeTakerFeeRate | math.LegacyDec | 0.2% | -| DefaultInitialMarginRatio | math.LegacyDec | 5% | -| DefaultMaintenanceMarginRatio | math.LegacyDec | 2% | -| DefaultFundingInterval | int64 | 3600 | -| FundingMultiple | int64 | 3600 | -| RelayerFeeShareRate | math.LegacyDec | 40% | -| DefaultHourlyFundingRateCap | math.LegacyDec | 0.0625% | -| DefaultHourlyInterestRate | math.LegacyDec | 0.000416666% | -| MaxDerivativeOrderSideCount | int64 | 20 | -| InjRewardStakedRequirementThreshold | sdk.Coin | 25inj | -| TradingRewardsVestingDuration | int64 | 1209600 | -| LiquidatorRewardShareRate | math.LegacyDec | 0.05% | -| BinaryOptionsMarketInstantListingFee | sdk.Coin | 10inj | -| AtomicMarketOrderAccessLevel | string | SmartContractsOnly | -| SpotAtomicMarketOrderFeeMultiplier | math.LegacyDec | 2x | -| DerivativeAtomicMarketOrderFeeMultiplier | math.LegacyDec | 2x | -| BinaryOptionsAtomicMarketOrderFeeMultiplier | math.LegacyDec | 2x | -| MinimalProtocolFeeRate | math.LegacyDec | 0.00001% | -| IsInstantDerivativeMarketLaunchEnabled | bool | false | +| Key | Type | Example | +|---------------------------------------------|----------------|-------------------| +| SpotMarketInstantListingFee | sdk.Coin | 100inj | +| DerivativeMarketInstantListingFee | sdk.Coin | 1000inj | +| DefaultSpotMakerFeeRate | math.LegacyDec | 0.1% | +| DefaultSpotTakerFeeRate | math.LegacyDec | 0.2% | +| DefaultDerivativeMakerFeeRate | math.LegacyDec | 0.1% | +| DefaultDerivativeTakerFeeRate | math.LegacyDec | 0.2% | +| DefaultInitialMarginRatio | math.LegacyDec | 5% | +| DefaultMaintenanceMarginRatio | math.LegacyDec | 2% | +| DefaultFundingInterval | int64 | 3600 | +| FundingMultiple | int64 | 3600 | +| RelayerFeeShareRate | math.LegacyDec | 40% | +| DefaultHourlyFundingRateCap | math.LegacyDec | 0.0625% | +| DefaultHourlyInterestRate | math.LegacyDec | 0.000416666% | +| MaxDerivativeOrderSideCount | int64 | 20 | +| InjRewardStakedRequirementThreshold | sdk.Coin | 25inj | +| TradingRewardsVestingDuration | int64 | 1209600 | +| LiquidatorRewardShareRate | math.LegacyDec | 0.05% | +| BinaryOptionsMarketInstantListingFee | sdk.Coin | 10inj | +| AtomicMarketOrderAccessLevel | string | SmartContractsOnly | +| SpotAtomicMarketOrderFeeMultiplier | math.LegacyDec | 2x | +| DerivativeAtomicMarketOrderFeeMultiplier | math.LegacyDec | 2x | +| BinaryOptionsAtomicMarketOrderFeeMultiplier | math.LegacyDec | 2x | +| MinimalProtocolFeeRate | math.LegacyDec | 0.00001% | +| IsInstantDerivativeMarketLaunchEnabled | bool | false | +| PostOnlyModeHeightThreshold | int64 | 1000 |