The Envio multi-chain indexer is designed to index GMX V2 smart contracts, replicating the functionality of the GMX synthetics subgraphs.
Developed by Noveleader. You can give me a follow :)
Following are the supported chains by the indexer, the indexer is scalable in nature and can expand to multiple chains as GMX scale itself:
- Arbitrum One (chainId: 42161)
- Avalanche (chainId: 43114)
- Clone the repository:
git clone https://github.com/Noveleader/gmx-v2-subgraph-envio.git
- Go into specific directory:
cd gmx-v2-subgraph-envio
- Install dependencies:
pnpm i
- Run codegen to generate the required files:
pnpm run codegen
- Run the indexer:
pnpm dev
Now the indexing will start and it will also utilize the cache
built already which stores GMX pool value and market tokens supply. Since this data comes from making RPC requests, caching acts like a persistent storage for older block states.
In order to view the data and make queries, visit http://localhost:8080
. The local password is testing
.
This section outlines the various queries that can be made regarding the following entities:
- Order: Queries the essential details of an
order
in GMX contracts. - Position Increase: Represents a type of order, represents opening a
position
in the GMX market. - Position Decrease: resents a type of order, represents closing a
position
in the GMX market. - Position FeesInfo: Stores all information related to fees collected from
positions
andrebates
given to traders. - Claimable Collateral: Refers to the
collateral
that an account can still claim. - Swap Info: Represents a type of
order
made for token swaps in a specific market. - Swap Fees Info: Queries information related to fees for swaps within a market.
- Trade Action: Queries and stores data related to any
trade action
performed on the exchange. - Token Price: Stores the price of
tokens
. - User: Stores global details related to a user's swaps, positions, deposits, and withdrawals.
In every entity, we also store chain ID
in order to filter data based on multiple chains.
Order is a generic entity and includes all types of order including position and swap related requests.
The following query gets the order data for arbitrum one having chain ID 42161
:
query GetOrderArbitrumOne {
Order(limit: 10, where: {chainId: {_eq: 42161}}) {
acceptablePrice
account
frozenReason
frozenReasonBytes
initialCollateralDeltaAmount
initialCollateralTokenAddress
isLong
marketAddress
minOutputAmount
orderType
receiver
sizeDeltaUsd
swapPath
triggerPrice
}
}
Find all the other fields related to the Order Entity here
This entity stores any data relating to opening a position, position increase simply means a position is iniitiated and it stores all the details regarding the same. It is also a type of Order
.
The following query gets the Position Increase
data for chain Avalanche having chain ID 43114
:
query GetPositionIncreaseAvalanche {
PositionIncrease(limit: 10, where: {chainId: {_eq: 43114}}) {
account
basePnlUsd
borrowingFactor
collateralAmount
executionPrice
isLong
sizeDeltaUsd
sizeInUsd
}
}
Find all the other fields related to Position Increase
Entity here
This entity stores any data relating to closing a position, position decrease simply means a position is closed and it stores all the details regarding the same. It is also a type of Order
.
The following query gets the Position Decrease
data for chain Avalanche having chain ID 43114
:
query GetPositionDecreaseAvalanche {
PositionDecrease(limit: 10, where: {chainId: {_eq: 43114}}) {
account
borrowingFactor
collateralAmount
isLong
marketAddress
sizeInUsd
sizeDeltaUsd
priceImpactAmount
priceImpactUsd
shortTokenFundingAmountPerSize
}
}
Find all the other fields related to Position Decrease
Entity here
This entity helps in querying position fees
and rebates
related info.
The following query get the Position Fees Info
data for Arbitrum chain having chain ID 42161
:
query GetPositionFeesInfoArbitrumOne {
PositionFeesInfo(limit: 10, where: {chainId: {_eq: 42161}}) {
collateralTokenAddress
collateralTokenPriceMax
collateralTokenPriceMin
marketAddress
positionFeeAmount
totalRebateAmount
traderDiscountAmount
fundingFeeAmount
feeUsdForPool
trader
}
}
Find all the other fields related to Positon Fees Info
Entity here
This entity helps in querying all the collateral left to claim and maintain a boolean called claimed
to monitor if the collateral is claimed or not.
The following query get the Claimable Collateral
data for Arbitrum Chain having chain ID 42161
:
query GetClaimableCollateralArbitrumOne {
ClaimableCollateral(limit: 10, where: {chainId: {_eq: 42161}}) {
claimed
factor
factorByTime
marketAddress
tokenAddress
value
}
}
Find all the other fields related to Claimable Collateral
Entity here
This entity helps in querying any swap related info. It stores orderKey
, market
the trade is made in, etc.
The following query get the Swap Info
data for Avalanche chain having chain ID 43114
:
query GetSwapInfoAvalanche {
SwapInfo(limit: 10, where: {chainId: {_eq: 43114}}) {
amountIn
amountOut
marketAddress
priceImpactUsd
receiver
tokenInAddress
tokenInPrice
tokenOutAddress
tokenOutPrice
}
}
Find all the other fields related to Swap Info
Entity here
This entity stores info related to swap fees.
The following query get the Swap Fees Info
data for Avalanche chain having chain ID 43114
:
query GetSwapFeesInfoAvalanche {
SwapFeesInfo(limit: 10, where: {chainId: {_eq: 43114}}) {
feeUsdForPool
swapFeeType
tokenAddress
tokenPrice
feeReceiverAmount
}
}
Find all the other fields related to Swap Fees Info
Entity here
This entity stores all the data related to any trade executed through the contracts including positions
and swaps
.
The following query get the Trade Action
data for Arbitrum chain having the chain ID 42161
:
query GetTradeActionArbitrumOne {
TradeAction(limit: 10, where: {chainId: {_eq: 42161}}) {
account
executionPrice
isLong
marketAddress
orderType
sizeDeltaUsd
}
}
Find all the other fields related to Trade Action
Entity here
This entity stores the token price which is listed on the exchange.
The following query get the Tokens
price data for Arbitrum chain having the chain ID 42161
:
query GetTokenPriceArbitrumOne {
TokenPrice(limit: 10, where: {chainId: {_eq: 42161}}) {
id
maxPrice
minPrice
}
}
Find all the other fields related to Token Price
Entity here
This entity stores the user data including their swap
, position
, deposit
, and withdrawal
stats.
The following query get the User
data for Arbitrum chaing having the chain ID 42161
:
query GetUserDataArbitrumOne{
User(limit: 10, where: {chainId: {_eq: 42161}}) {
account
totalDepositCount
totalPositionCount
totalSwapCount
totalWithdrawalCount
}
}
Find all the other fields related to User
Entity here
This project is licensed under the MIT License.