GlvReader
The GlvReader contract provides read-only functions for querying GMX Liquidity Vault (GLV) data from on-chain storage.
For GM market reader functions, see Reader.
This page focuses on the most commonly used GLV read helpers. For the full public surface, see GlvReader.sol.
Examples below assume you already have contract instances such as glvReader and dataStore, plus any required price structs.
Getting a list of GLVs
Use getGlvs to retrieve all registered GLV vaults.
GlvReader.getGlvs
function getGlvs(DataStore dataStore, uint256 start, uint256 end)
external view returns (Glv.Props[] memory)
Example (TypeScript / ethers):
const glvs = await glvReader.getGlvs(dataStore.address, 0, 20);
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
start | uint256 | Start index for pagination |
end | uint256 | End index for pagination |
Returns: Array of Glv.Props.
Glv.Props
| Field | Type | Description |
|---|---|---|
glvToken | address | Address of the GLV token |
longToken | address | Address of the long token |
shortToken | address | Address of the short token |
Getting GLV info with market list
Use getGlvInfoList to retrieve GLV vaults together with the markets each vault is exposed to.
GlvReader.getGlvInfoList
function getGlvInfoList(DataStore dataStore, uint256 start, uint256 end)
external view returns (GlvInfo[] memory)
Example (TypeScript / ethers):
const glvInfoList = await glvReader.getGlvInfoList(dataStore.address, 0, 20);
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
start | uint256 | Start index for pagination |
end | uint256 | End index for pagination |
Returns: Array of GlvInfo elements, each containing a Glv.Props and a list of market addresses.
Getting GLV value
Use getGlvValue to retrieve the total GLV vault value before converting it into a token price.
GlvReader.getGlvValue
function getGlvValue(
DataStore dataStore,
address[] memory marketAddresses,
Price.Props[] memory indexTokenPrices,
Price.Props memory longTokenPrice,
Price.Props memory shortTokenPrice,
address glv,
bool maximize
) external view returns (uint256)
Example (TypeScript / ethers):
const glvValue = await glvReader.getGlvValue(
dataStore.address,
marketAddresses,
indexTokenPrices,
longTokenPrice,
shortTokenPrice,
glvAddress,
true
);
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
marketAddresses | address[] | Addresses of the markets inside the GLV |
indexTokenPrices | Price.Props[] | Prices for the index tokens of each GLV market. The order must match marketAddresses. |
longTokenPrice | Price.Props | Price of the long token |
shortTokenPrice | Price.Props | Price of the short token |
glv | address | Address of the GLV vault |
maximize | bool | When true, uses maximum token prices. When false, uses minimum prices. |
Returns: Total GLV vault value in 30-decimal USD precision.
Getting GLV token price
Use getGlvTokenPrice to retrieve the GLV token price, total vault value, and total supply.
GlvReader.getGlvTokenPrice
function getGlvTokenPrice(
DataStore dataStore,
address[] memory marketAddresses,
Price.Props[] memory indexTokenPrices,
Price.Props memory longTokenPrice,
Price.Props memory shortTokenPrice,
address glv,
bool maximize
) external view returns (uint256, uint256, uint256)
Example (TypeScript / ethers):
const [glvPrice, glvValue, totalSupply] = await glvReader.getGlvTokenPrice(
dataStore.address,
marketAddresses,
indexTokenPrices,
longTokenPrice,
shortTokenPrice,
glvAddress,
true
);
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
marketAddresses | address[] | Addresses of the markets inside the GLV |
indexTokenPrices | Price.Props[] | Prices for the index tokens of each GLV market. The order must match marketAddresses. |
longTokenPrice | Price.Props | Price of the long token |
shortTokenPrice | Price.Props | Price of the short token |
glv | address | Address of the GLV vault |
maximize | bool | When true, uses maximum token prices. When false, uses minimum prices. |
Returns: A tuple of (uint256 price, uint256 glvValue, uint256 totalSupply).
Direct GLV lookups
Use these methods when you already have a GLV address or deployment salt and want the raw stored object.
GlvReader.getGlv
function getGlv(DataStore dataStore, address glv)
external view returns (Glv.Props memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
glv | address | GLV token address |
Returns: Glv.Props for the requested GLV.
GlvReader.getGlvInfo
function getGlvInfo(DataStore dataStore, address glv)
public view returns (GlvInfo memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
glv | address | GLV token address |
Returns: GlvInfo, containing the GLV props plus its supported market list.
GlvReader.getGlvBySalt
function getGlvBySalt(DataStore dataStore, bytes32 salt)
external view returns (Glv.Props memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
salt | bytes32 | Deterministic GLV deployment salt |
Returns: Glv.Props for the requested GLV.
GLV deposit requests
Use these methods to inspect GLV deposit requests by key, globally, or for one account.
GlvReader.getGlvDeposit
function getGlvDeposit(DataStore dataStore, bytes32 key)
external view returns (GlvDeposit.Props memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
key | bytes32 | GLV deposit request key |
Returns: Raw GlvDeposit.Props for the request.
GlvReader.getGlvDeposits
function getGlvDeposits(
DataStore dataStore,
uint256 start,
uint256 end
) external view returns (GlvDeposit.Props[] memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
start | uint256 | Start index for pagination |
end | uint256 | End index for pagination |
Returns: Array of GlvDeposit.Props values.
GlvReader.getAccountGlvDeposits
function getAccountGlvDeposits(
DataStore dataStore,
address account,
uint256 start,
uint256 end
) external view returns (GlvDeposit.Props[] memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
account | address | Account to retrieve GLV deposits for |
start | uint256 | Start index for pagination |
end | uint256 | End index for pagination |
Returns: Array of GlvDeposit.Props values for the account.
GLV withdrawal requests
Use these methods to inspect GLV withdrawal requests by key, globally, or for one account.
GlvReader.getGlvWithdrawal
function getGlvWithdrawal(DataStore dataStore, bytes32 key)
external view returns (GlvWithdrawal.Props memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
key | bytes32 | GLV withdrawal request key |
Returns: Raw GlvWithdrawal.Props for the request.
GlvReader.getGlvWithdrawals
function getGlvWithdrawals(
DataStore dataStore,
uint256 start,
uint256 end
) external view returns (GlvWithdrawal.Props[] memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
start | uint256 | Start index for pagination |
end | uint256 | End index for pagination |
Returns: Array of GlvWithdrawal.Props values.
GlvReader.getAccountGlvWithdrawals
function getAccountGlvWithdrawals(
DataStore dataStore,
address account,
uint256 start,
uint256 end
) external view returns (GlvWithdrawal.Props[] memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
account | address | Account to retrieve GLV withdrawals for |
start | uint256 | Start index for pagination |
end | uint256 | End index for pagination |
Returns: Array of GlvWithdrawal.Props values for the account.
GLV shift requests
Use these methods to inspect GLV shift requests by key or through paginated lists.
GlvReader.getGlvShift
function getGlvShift(DataStore dataStore, bytes32 key)
external view returns (GlvShift.Props memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
key | bytes32 | GLV shift request key |
Returns: Raw GlvShift.Props for the request.
GlvReader.getGlvShifts
function getGlvShifts(
DataStore dataStore,
uint256 start,
uint256 end
) external view returns (GlvShift.Props[] memory)
Parameters:
| Parameter | Type | Description |
|---|---|---|
dataStore | address | Address of the DataStore contract |
start | uint256 | Start index for pagination |
end | uint256 | End index for pagination |
Returns: Array of GlvShift.Props values.