Crate gmsol_store

Source
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
§Instructions for Config Management
§Instructions for Feature Management

§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 the Store 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 a RoleStore 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.
§Instructions for Oracle accounts

§Market Management

See also the module level documentation for Market for details.

§Instructions for Market management
§Instructions for MarketConfigBuffer accounts
§Instructions for token accounts

§Exchange

The instructions for providing functionalities as an exchange are as follows:

§Instructions for Deposit
§Instructions for Withdrawal
§Instructions for Shift
§Instructions for Order and Position

§GLV (GMX Liquidity Vault) Pools

The instructions for providing functionalities for GLV are as follows:

§Instructions for Glv.
§Instructions for GlvDeposit
§Instructions for GlvWithdrawal
§Instructions for GlvShift

§User Accounts and Referrals

The instructions for user accounts and referrals are as follows:

§GT Model

See also the module level documentation for GT for details.

The instructions for GT Model are as follows:

Modules§

accounts
An Anchor generated module, providing a set of structs mirroring the structs deriving Accounts, where each field is a Pubkey. 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§

debug_msg

Enums§

CoreError

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§

CoreResult
Result type with CoreError as error type.