Skip to main content

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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
startuint256Start index for pagination
enduint256End index for pagination

Returns: Array of Glv.Props.

Glv.Props

FieldTypeDescription
glvTokenaddressAddress of the GLV token
longTokenaddressAddress of the long token
shortTokenaddressAddress 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
startuint256Start index for pagination
enduint256End 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
marketAddressesaddress[]Addresses of the markets inside the GLV
indexTokenPricesPrice.Props[]Prices for the index tokens of each GLV market. The order must match marketAddresses.
longTokenPricePrice.PropsPrice of the long token
shortTokenPricePrice.PropsPrice of the short token
glvaddressAddress of the GLV vault
maximizeboolWhen 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
marketAddressesaddress[]Addresses of the markets inside the GLV
indexTokenPricesPrice.Props[]Prices for the index tokens of each GLV market. The order must match marketAddresses.
longTokenPricePrice.PropsPrice of the long token
shortTokenPricePrice.PropsPrice of the short token
glvaddressAddress of the GLV vault
maximizeboolWhen 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
glvaddressGLV token address

Returns: Glv.Props for the requested GLV.

GlvReader.getGlvInfo

function getGlvInfo(DataStore dataStore, address glv)
public view returns (GlvInfo memory)

Parameters:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
glvaddressGLV 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
saltbytes32Deterministic 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
keybytes32GLV 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
startuint256Start index for pagination
enduint256End 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
accountaddressAccount to retrieve GLV deposits for
startuint256Start index for pagination
enduint256End 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
keybytes32GLV 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
startuint256Start index for pagination
enduint256End 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
accountaddressAccount to retrieve GLV withdrawals for
startuint256Start index for pagination
enduint256End 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
keybytes32GLV 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:

ParameterTypeDescription
dataStoreaddressAddress of the DataStore contract
startuint256Start index for pagination
enduint256End index for pagination

Returns: Array of GlvShift.Props values.