The GLAM CLI is built using the GLAM SDK. The source code is available on Github.
For reference, here’s a sample configuration:
{
"cluster": "mainnet-beta",
"json_rpc_url": "https://mainnet.helius-rpc.com/?api-key=[ redacted ]",
"tx_rpc_url": "https://staked.helius-rpc.com/?api-key=[ redacted ]",
"keypair_path": "/path/to/keypair.json",
"jupiter_api_key": "[ redacted ]",
"priority_fee": {
"level": "Min",
"helius_api_key": "[ redacted ]"
}
}
If you don’t have a dedicated RPC for landing transactions, it’s highly recommended to set priority fee level to High.
Create a Vault
Prepare a vault.json file with basic vault configurations:
{
"accountType": "vault",
"name": "GLAM Vault Demo",
"enabled": true,
"assets": [
"So11111111111111111111111111111111111111112",
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
]
}
Create the vault:
glam-cli vault create vault.json
Output:
txSig: 58QhaZWjVqdBr1Ap9eitp8p4LL2NyzT2c5fxhVtb7qgo2Y8DDhrY6yeAobcTqz1fW3AYcjknbtXqbSNkcg7ePkrW
GLAM state created: 6K1wuNhcFX6yDJZaGYwQMnnf4rGuCNBTvngx5dQNNfcN
Vault: 5zJKfPVQLEBiVqoXRtG9tYRXHS166d5JiZbyQtiopqgh
Enable Integrations
Integrations are disabled by default. Enable them before use:
glam-cli integration enable DriftProtocol KaminoLend JupiterSwap
Verify enabled integrations:
glam-cli integration list
Output:
GLAM Vault Quickstart (6K1wuNhcFX6yDJZaGYwQMnnf4rGuCNBTvngx5dQNNfcN) has 3 integration programs enabled:
[0] GLAMpk...111111, protocols (0b001): DriftProtocol
[1] GLAMpk...111111, protocols (0b010): KaminoLend
[2] GLAMpk...111111, protocols (0b100): JupiterSwap
Deposit
SOL and tokens can be transferred to the vault directly.
Get Vault Address
In the output, the pubkey after Active vault: is the vault address that can receive tokens.
Double check you have the right address before transferring. Sending tokens to the wrong address might lead to unrecoverable loss of your funds!
Wallet connected: gLJHKPrZLGBiBZ33hFgZh6YnsEhTVxuRT17UCqNp6ff
RPC endpoint: https://mainnet.helius-rpc.com/?api-key=[ redacted ]
Priority fee: { level: 'Min', helius_api_key: '...' }
GLAM state: 6K1wuNhcFX6yDJZaGYwQMnnf4rGuCNBTvngx5dQNNfcN
✅ Active vault: 5zJKfPVQLEBiVqoXRtG9tYRXHS166d5JiZbyQtiopqgh
Check Vault Holdings
Output:
Token Mint Amount Value (USD)
SOL N/A 0.5 70.4668035
Drift Protocol
Initialize User
glam-cli drift-protocol init-user
Deposit
Deposit 0.1 SOL to spot market index #1 (SOL spot market):
glam-cli drift-protocol deposit 1 0.1
You can find all Drift market indexes via the GLAM API.
Withdraw / Borrow
Drift doesn’t distinguish between withdrawing and borrowing. If you withdraw an asset you don’t hold but have sufficient collateral, it becomes a borrow.
Borrow 1 USDC using SOL as collateral:
glam-cli drift-protocol withdraw 0 1
Repay
Deposit USDC to repay the borrow:
glam-cli drift-protocol deposit 0 1
Enable Margin Trading
glam-cli drift-protocol margin true
Place Perp Order
# Long 0.1 SOL-PERP at price limit $120
glam-cli drift-protocol perp long 1 0.1 120
Place Spot Order
# Long 0.1 SOL at price limit $120
glam-cli drift-protocol spot long 1 0.1 120
View and Cancel Orders
# List open orders
glam-cli drift-protocol list-orders
# Cancel order ID #1
glam-cli drift-protocol cancel 1
Kamino Lending
Initialize Kamino User
glam-cli kamino-lend init
Deposit to Main Market
The pubkey of Kamino main market is 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF.
Deposit 0.1 SOL:
glam-cli kamino-lend deposit 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF So11111111111111111111111111111111111111112 0.1
To verify the deposit, visit the vault’s Kamino account at:
https://app.kamino.finance/?DEBUG_WALLET=[ YourVaultAddress ]
Borrow
Borrow cbBTC using deposited SOL as collateral:
glam-cli kamino-lend borrow 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij 0.000001
Withdraw
glam-cli kamino-lend withdraw 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF So11111111111111111111111111111111111111112 0.05
Repay
glam-cli kamino-lend repay 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij 0.000001
Jupiter Swap
Swap 0.01 SOL to USDC:
glam-cli jupiter swap SOL USDC 0.01
Access Control & Delegation
Grant Permissions
glam-cli delegate grant <delegate_pubkey> Deposit --protocol KaminoLend
List Delegates
Revoke Permissions
glam-cli delegate revoke <delegate_pubkey> Deposit --protocol KaminoLend
Revoke All Access
glam-cli delegate revoke-all <delegate_pubkey>
Debugging Tips
Simulation
If a transaction fails during simulation, copy the base64 encoded transaction data and simulate it on https://explorer.solana.com/tx/inspector for better error messages.
Inspecting Onchain Data
Due to active development, new IDLs are shipped frequently. If a transaction isn’t parsed on solscan.io, try https://explorer.solana.com/ instead.