Expand description
§The GMX-Solana Store Program
The Store Program defines several fundamental accounts that form the core of its functionality:
Store
: A central account that serves as a global configuration store and permission manager. It acts as the authority (“owner”) for other program accounts and manages role-based access control. The global GT state is also stored in this account.TokenMap
: A mapping of token configurations and price feed configurations that defines supported tokens and their associated price oracle feeds.Market
: A market account that stores market-specific configurations and maintains the global market state.Position
: Tracks a user’s active position in a market.- Basic Market Action accounts: Accounts that track user actions and positions in markets
Deposit
: Tracks a user’s pending deposit request into a market.Withdrawal
: Tracks a user’s pending withdrawal request from a market.Shift
: Tracks a user’s pending request to shift from one kind of market token to another.Order
: Tracks a user’s pending order request in a market, including swap orders and increase/decrease position orders.
- GLV (GMX Liquidity Vault) Action accounts: Accounts that track user interactions with GLV tokens.
GlvDeposit
: Tracks a user’s pending deposit of tokens into a GLV pool to mint GLV tokens.GlvWithdrawal
: Tracks a user’s pending withdrawal of tokens from a GLV pool to burn GLV tokens and withdraw the underlying tokens.GlvShift
: Tracks a keeper’s pending request to rebalance tokens between different market pools within the GLV pool.
- User accounts (see
UserHeader
for details): Tracks user information including the GT and esGT balances of the user, referral code, and referral relationships.
The instructions for the store program are categorized into the following sections:
§Store
A Store
Account serves as both an authority and a global configuration
storage.
A store and its associated accounts form a deployment. Each deployment operates independently,
allowing multiple instances of the protocol to coexist on-chain (only available when the
multi-store
feature is enabled).
§Instructions for Store Accounts
initialize
: Create a newStore
account.transfer_store_authority
: Transfer the authority of the given store to a new authority.transfer_receiver
: Set the claimable fee receiver address.set_token_map
: Set the token map account to use.
§Instructions for Config Management
insert_amount
: Insert an amount to the global config.insert_factor
: Insert a factor to the global config.insert_address
: Insert an address to the global config.insert_order_fee_discount_for_referred_user
: Insert order fee discount for referred user factor to the global config.
§Instructions for Feature Management
toggle_feature
: Enable or disable the given feature.
§Role-based Permission Management
The role-based permission system for each GMSOL deployment is managed through its
Store
Account. The permission structure consists of:
-
Administrator Role: A single administrator address stored in the
authority
field of theStore
Account. This address has exclusive rights to modify the permission table and use other administrative instructions. -
Custom Roles: A flexible role system stored in the
role
field as aRoleStore
structure. This allows for granular permission management through custom roles and role assignments. Each role can be assigned to multiple addresses.
§Instructions for Permission Management
check_admin
: Check whether the signer is the admin of the given store.check_role
: Check whether the signer has the given role in the given store.has_admin
: Return whether the given address is the admin of the given store.has_role
: Return whether the given address has the given role in the given store.enable_role
: Insert or enable a role for the given store.disable_role
: Disable an existing role for the given store.grant_role
: Grant a role to the given user in the given store.revoke_role
: Revoke a role from the given user in the given store.
§Token Config and Oracle Management
§Instructions for managing TokenConfig
and token maps.
initialize_token_map
: Initialize a new token map account. This is a permissionless instruction.push_to_token_map
: Push a new token config for an existing token to the given token map.push_to_token_map_synthetic
: Push a new token config for a “synthetic” token to the given token map.toggle_token_config
: Enable or disable a token config of the given token map.set_expected_provider
: Set the expected provider for the given token.set_feed_config
: Set the feed config of the given provider for the given token.is_token_config_enabled
: Check if the config for the given token is enabled.token_expected_provider
: Get the expected provider set for the given token.token_feed
: Get the feed address of the given provider set for the given token.token_timestamp_adjustment
: Get the timestamp adjustment of the given provider for the give token.token_name
: Get the name of the given token.token_decimals
: Get the token decimals of the given token.token_precision
: Get the price precision of the given token.
§Instructions for Oracle
accounts
initialize_oracle
: Initialize a newOracle
account.clear_all_prices
: Clear the prices of the given oracle account.set_prices_from_price_feed
: Validate and set prices parsed from the provided price feed accounts.initialize_price_feed
: Initialize a custom price feed.update_price_feed_with_chainlink
: Update a custom Chainlink price feed with Chainlink Data Streams report.
§Market Management
See also the module level documentation for Market for details.
§Instructions for Market
management
initialize_market
: Initialize aMarket
account.toggle_market
: Enable or disable the given market.market_transfer_in
: Transfer tokens into the market and record the amount in its balance.update_market_config
: Update an item in the market config.update_market_config_with_buffer
: Update the market config with the givenMarketConfigBuffer
account.get_market_status
: Calculate the market status with the given prices.get_market_token_price
: Calculate the market token price the given prices.toggle_gt_minting
: Enable or disable GT minting for the given market.
§Instructions for MarketConfigBuffer
accounts
initialize_market_config_buffer
: Initialize a market config buffer account.set_market_config_buffer_authority
: Replace the authority of the market config buffer account with the new one.close_market_config_buffer
: Close the given market config buffer account.push_to_market_config_buffer
: Push config items to the given market config buffer account.
§Instructions for token accounts
initialize_market_vault
: Initialize the market vault for the given token.use_claimable_account
: Prepare a claimable account to receive tokens during the order execution.close_empty_claimable_account
: Close a empty claimble account.prepare_associated_token_account
: Prepare an ATA.
§Exchange
The instructions for providing functionalities as an exchange are as follows:
§Instructions for Deposit
create_deposit
: Create a deposit by the owner.execute_deposit
: Execute a deposit by keepers.close_deposit
: Close a deposit, either by the owner or by keepers.
§Instructions for Withdrawal
create_withdrawal
: Create a withdrawal by the owner.execute_withdrawal
: Execute a withdrawal by keepers.close_withdrawal
: Close a withdrawal, either by the owner or by keepers.
§Instructions for Shift
create_shift
: Create a shift by the owner.execute_shift
: Execute a shift by keepers.close_shift
: Close a shift, either by the owner or by keepers.
§Instructions for Order
and Position
prepare_position
: Prepare the position account for orders.prepare_trade_event_buffer
: Prepare trade event buffer.create_order
: Create an order by the owner.update_order
: Update an order by the owner.execute_increase_or_swap_order
: Execute an order by keepers.execute_decrease_order
: Execute a decrease order by keepers.close_order
: Close an order, either by the owner or by keepers.cancel_order_if_no_position
: Cancel an order if the position does not exist.liquidate
: Perform a liquidation by keepers.auto_deleverage
: Perform an ADL by keepers.update_adl_state
: Update the ADL state of the market.
§GLV (GMX Liquidity Vault) Pools
The instructions for providing functionalities for GLV are as follows:
§Instructions for Glv
.
initialize_glv
: Initialize a GLV.update_glv_market_config
: Update GLV market config.toggle_glv_market_flag
: Toggle flags of GLV market.update_glv_config
: Update GLV global config.insert_glv_market
: Insert a new market to the GLV.remove_glv_market
: Remove a market from the GLV.
§Instructions for GlvDeposit
create_glv_deposit
: Create a GLV deposit by the owner.execute_glv_deposit
: Execute a GLV deposit by keepers.close_glv_deposit
: Close a GLV deposit, either by the owner or by keepers.
§Instructions for GlvWithdrawal
create_glv_withdrawal
: Create a GLV withdrawal by the owner.execute_glv_withdrawal
: Execute a GLV withdrawal by keepers.close_glv_withdrawal
: Close a GLV withdrawal, either by the owner or by keepers.
§Instructions for GlvShift
create_glv_shift
: Create a GLV shift by keepers.execute_glv_shift
: Execute a GLV shift by keepers.close_glv_shift
: Close a shift by keepers.
§User Accounts and Referrals
The instructions for user accounts and referrals are as follows:
prepare_user
: Prepare a user account.initialize_referral_code
: Initialize and set a referral code.set_referrer
: Set the referrer.transfer_referral_code
: Transfer the referral code to others.cancel_referral_code_transfer
: Cancel the referral code transfer.accept_referral_code
: Complete the referral code transfer.
§GT Model
See also the module level documentation for GT for details.
The instructions for GT Model are as follows:
initialize_gt
: Initialize the GT state.gt_set_order_fee_discount_factors
: Set order fee discount factors.gt_set_referral_reward_factors
: Set referral reward factors.gt_set_exchange_time_window
: Set GT exchange time window.prepare_gt_exchange_vault
: Prepare current GT exchange vault.confirm_gt_exchange_vault
: Confirm GT exchange vault.request_gt_exchange
: Request a GT exchange.close_gt_exchange
: Close a confirmed GT exchange.
Modules§
- accounts
- An Anchor generated module, providing a set of structs
mirroring the structs deriving
Accounts
, where each field is aPubkey
. This is useful for specifying accounts for a client. - constants
- Constants.
- cpi
- events
- Events.
- gmsol_
store - Instructions definitions of the GMSOL Store Program.
- instruction
- An Anchor generated module containing the program’s set of
instructions, where each method handler in the
#[program]
mod is associated with a struct defining the input arguments to the method. These should be used directly, when one wants to serialize Anchor instruction data, for example, when speciying instructions on a client. - instructions
- Instructions.
- ops
- Operations.
- program
- Module representing the program.
- states
- States.
- utils
- Utils.
Macros§
Enums§
Constants§
- ID_
CONST - Const version of
ID
Statics§
- ID
- The static program ID
Functions§
- check_
id - Confirms that a given pubkey is equivalent to the program ID
- entry
- The Anchor codegen exposes a programming model where a user defines
a set of methods inside of a
#[program]
module in a way similar to writing RPC request handlers. The macro then generates a bunch of code wrapping these user defined methods into something that can be executed on Solana. - id
- Returns the program ID
- id_
const - Const version of
ID
Type Aliases§
- Core
Result - Result type with
CoreError
as error type.