1 unstable release
new 0.4.1-alpha.3 | Mar 26, 2025 |
---|
#5 in #gmx
48 downloads per month
62KB
1.5K
SLoC
GMX-Solana
Audits
Program | Last Audit Date | Version |
---|---|---|
gmsol-store | 2025-03-07 | 2a66761 |
gmsol-treasury | 2025-03-07 | 2a66761 |
gmsol-timelock | 2025-03-07 | 2a66761 |
Integration
Method 1: Using declare_program!
1. Initialize a new Rust project and add dependencies
Create a new Rust project and include anchor_lang
and bytemuck
as dependencies:
[dependencies]
anchor-lang = "0.30.1"
bytemuck = { version = "1.19.0", features = ["min_const_generics"] }
2. Download and Store IDLs in {PROJECT_ROOT}/idls/
You can retrieve the IDLs using the anchor
CLI or download them directly from the explorer (gmsol-store
Program and gmsol-treasury
Program).
Once downloaded, move them to the {PROJECT_ROOT}/idls/
directory.
Your project structure should now look like this:
{PROJECT_ROOT}/
├── .gitignore
├── Cargo.lock
├── Cargo.toml
├── idls
│ ├── gmsol_store.json
│ └── gmsol_treasury.json
└── src
└── lib.rs
3. Declaring Programs in lib.rs
Use declare_program!
to register the gmsol-store
and gmsol-treasury
programs:
use anchor_lang::declare_program;
declare_program!(gmsol_store);
declare_program!(gmsol_treasury);
4. Build and Open the Documentation
Run the following command to generate and view the documentation:
cargo doc --open
If the build is successful, it will automatically open the documentation in your default web browser.
5. Example Project
For a working implementation, check out the gmx-solana-programs.
Development
Prerequisites
Commands
To run all tests:
just
To install the gmsol
CLI:
cargo install-gmsol
Use the following command to verify the CLI is installed properly:
gmsol --version
Troubleshooting
1. Failed to start test-validator
on MacOS
Error Message:
Error: failed to start validator: Failed to create ledger at test-ledger: io error: Error checking to unpack genesis archive: Archive error: extra entry found: "._genesis.bin" Regular
Posssible Solution:
Check this comment.
Dependencies
~78MB
~1.5M SLoC