# Delegated Accounts Source: https://docs.glam.systems/v1/access-control/delegated-accounts Delegated accounts (also known as delegates) start with no permissions and must be explicitly granted access. Permissions are granular, allowing vault owners to build precise guardrails by adding specific capabilities to each delegate. * Low-privileged delegates are ideal for performing routine tasks such as staking and farming. * High-privileged delegates can be used for more sensitive operations like trading and transfers. This approach enhances security by ensuring that delegates can only perform intended actions within the defined boundaries: * It reduces the risk of unauthorized operations and accidental mistakes. * Even if a delegate is compromised, the impact is limited to the permissions granted to them. ## Permissions Permissions are protocol-specific capabilities defined by each [integration program](/v1/platform/integrations). They represent the smallest units of access that can be granted to delegates, allowing for fine-grained control over what actions each delegate can perform. Permission bitflags are stored as `u64` integers, allowing for a maximum of 64 permissions per protocol. Follow the links in the table to view the permission definitions in program IDLs. | Protocol | Permission Name | Permission Bitflag | Description | | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------- | -------------------- | ------------------------------------------- | | [System](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/glam_protocol.json#L3103-L3112) | WSOL | `0b0000000000000001` | Wrap SOL to wSOL | | | Transfer | `0b0000000000000010` | Transfer vault SOL an allowlisted address | | [Jupiter Swap](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/glam_protocol.json#L3068-L3082) | SwapAny | `0b0000000000000001` | Swap any token to any other token | | | SwapLST | `0b0000000000000010` | Swap among SOL and LSTs | | | SwapAllowlisted | `0b0000000000000100` | Swap tokens that are explicitly allowlisted | | [SPL](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_spl.json#L1259-L1263) | Transfer | `0b0000000000000001` | Transfer vault token an allowlisted address | | [Kamino Lending](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_kamino.json#L2841-L2865) | Init | `0b0000000000000001` | Initialize Kamino lending account | | | Deposit | `0b0000000000000010` | Deposit tokens into Kamino lending | | | Withdraw | `0b0000000000000100` | Withdraw tokens from Kamino lending | | | Borrow | `0b0000000000001000` | Borrow tokens on Kamino lending | | | Repay | `0b0000000000010000` | Repay borrowed tokens | | [Kamino Vaults](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_kamino.json#L2871-L2880) | Deposit | `0b0000000000000001` | Deposit into Kamino vaults | | | Withdraw | `0b0000000000000010` | Withdraw from Kamino vaults | | [Kamino Farms](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_kamino.json#L2821-L2835) | Stake | `0b0000000000000001` | Stake tokens in Kamino farms | | | Unstake | `0b0000000000000010` | Unstake tokens from Kamino farms | | | HarvestReward | `0b0000000000000100` | Harvest farming rewards | | [CCTP](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_cctp.json#L1253-L1257) | Transfer | `0b0000000000000001` | Bridge asset to another chain | ### Pending Audit This table lists permissions defined by integration programs that are pending audit. | Protocol | Permission Name | Permission Bitflag | Description | | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------- | -------------------- | ---------------------------------- | | [Stake Program](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/glam_protocol.json#L3088-L3097) | Stake | `0b0000000000000001` | Stake SOL to a validator | | | Unstake | `0b0000000000000010` | Unstake from a validator | | [Stake Pool](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_stake_pool.json#L1577-L1596) | DepositSol | `0b0000000000000001` | Deposit SOL to a pool | | | DepositStake | `0b0000000000000010` | Deposit stake account to a pool | | | DepositSolAny | `0b0000000000000100` | Deposit SOL to any pool | | | DepositStakeAny | `0b0000000000001000` | Deposit stake account to any pool | | | WithdrawSol | `0b0000000000010000` | Withdraw SOL from a pool | | | WithdrawStake | `0b0000000000100000` | Withdraw stake account from a pool | | [Sanctum](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_stake_pool.json#L1557-L1576) | DepositSol | `0b0000000000000001` | Deposit SOL to a pool | | | DepositStake | `0b0000000000000010` | Deposit stake account to a pool | | | DepositSolAny | `0b0000000000000100` | Deposit SOL to any pool | | | DepositStakeAny | `0b0000000000001000` | Deposit stake account to any pool | | | WithdrawSol | `0b0000000000010000` | Withdraw SOL from a pool | | | WithdrawStake | `0b0000000000100000` | Withdraw stake account from a pool | | [Marinade](https://github.com/glamsystems/glam-sdk/blob/6d03d99af6650b3f211de84c8e5f152eebef78f3/idl/ext_marinade.json#L1577-L1586) | Stake | `0b0000000000000001` | Stake SOL to get mSOL | | | Unstake | `0b0000000000000010` | Unstake mSOL to get SOL | # Framework Source: https://docs.glam.systems/v1/access-control/framework The GLAM access control framework fully operates onchain. It plays a crucial role in protecting Vaults and Mints from unauthorized access and malicious activities. Program invocations are thoroughly examined at three different levels. The vault-level access control ensures that rules are applied uniformly to all signers, regardless of their roles or permissions. *Benefits: This strengthens security by providing an overarching control layer for critical vault operations.* The instruction-level access control is enforced on individual instructions, ensuring that only authorized instruction(s) can be executed by a delegate. *Benefits: It ensures that delegates can only perform specific actions permitted by the vault owner, enhancing operational flexibility without compromising security.* The parameter-level access control represents a highly granular mechanism that restricts and defines access based not only on instructions but also on specific parameters within those actions. *Benefits: This level of control ensures that even when a delegate is permitted to execute certain instructions, the scope of those instructions is limited to predefined parameters.* *** Learn how GLAM's onchain access control can help mitigate supply chain attacks targeting crypto projects in our blog post [here](https://www.glam.systems/blog/mitigating-supply-chain-attacks-with-onchain-access-control-and-timelocks). # Use Cases Source: https://docs.glam.systems/v1/access-control/use-cases GLAM access control framework provides a flexible and secure way to manage delegated accounts and their permissions. Some common use cases are listed below. # Address Lookup Tables Source: https://docs.glam.systems/v1/cli/alt Address Lookup Tables (ALTs) reduce transaction size by allowing addresses to be referenced by index rather than including full 32-byte public keys. This is especially useful for complex vault operations like pricing with many assets or DeFi positions. For assistance with address lookup tables, please contact us at [dev@glam.systems](mailto:dev@glam.systems). ## When to Use ALTs ALTs are recommended when: * The vault holds many assets that need pricing in a single transaction * DeFi integrations (e.g., Kamino) add many accounts to transactions * Transactions exceed the Solana transaction size limit (1232 bytes) Pricing transactions are the most common case where ALTs are needed, as they reference oracle accounts, token accounts, and market accounts for each asset in the vault. # Cross-Chain Transfer (CCTP) Source: https://docs.glam.systems/v1/cli/cctp Bridge USDC across chains using Circle's CCTP Commands for bridging USDC across chains using Circle's Cross-Chain Transfer Protocol (CCTP). The `CCTP` integration must be enabled before using these commands: ```bash theme={null} glam-cli integration enable CCTP ``` ## Bridge USDC Bridge USDC from Solana to an EVM chain. * `amount`: Amount of USDC to bridge * `domain`: Destination domain ID (see table below) * `destination_address`: Recipient address on the destination chain * `--destination-caller`, `-d`: Optional destination caller address * `--max-fee-bps`, `-m`: Maximum fee in basis points (default: 1) * `--base58`, `-b`: Address is in base58 format (default: EVM hex format) * `--fast`, `-f`: Use fast transfer mode (lower finality threshold) ```bash theme={null} glam-cli cctp bridge-usdc [options] [--yes] ``` **Example:** Bridge 100 USDC to Ethereum: ```bash theme={null} glam-cli cctp bridge-usdc 100 0 0x1234567890abcdef1234567890abcdef12345678 ``` **Example:** Fast bridge to Arbitrum: ```bash theme={null} glam-cli cctp bridge-usdc 100 3 0x1234567890abcdef1234567890abcdef12345678 --fast ``` ### Domain IDs | Domain ID | Chain | | --------- | --------- | | 0 | Ethereum | | 1 | Avalanche | | 2 | Optimism | | 3 | Arbitrum | | 6 | Base | | 7 | Polygon | ## Receive USDC Receive USDC bridged from an EVM chain to Solana. * `source_domain`: Source chain domain ID * `--txHash`, `-t`: Transaction hash from the source chain (hex string starting with 0x) * `--nonce`, `-n`: Nonce from the source transaction (hex string starting with 0x) ```bash theme={null} glam-cli cctp receive [--txHash ] [--nonce ] ``` ## List Bridge Events List CCTP events for incoming and outgoing bridge transfers. * `--since-slot`, `-s`: Fetch events since this slot * `--batch-size`, `-b`: Batch size for RPC requests * `--commitment`, `-c`: Commitment level (default: confirmed) ```bash theme={null} glam-cli cctp list [--since-slot ] [--batch-size ] [--commitment ] ``` *** ## Policy Management CCTP policies allow you to restrict which destination addresses can receive bridged USDC. ### View Policy View the current CCTP policy. ```bash theme={null} glam-cli cctp view-policy ``` ### Allowlist Destination Add a destination address to the CCTP allowlist. * `domain`: Destination domain ID * `destination_address`: Address on the destination chain * `--base58`: Address is in base58 format ```bash theme={null} glam-cli cctp allowlist-destination [--base58] [--yes] ``` **Example:** Allowlist an Ethereum address: ```bash theme={null} glam-cli cctp allowlist-destination 0 0x1234567890abcdef1234567890abcdef12345678 ``` ### Remove Destination Remove a destination address from the CCTP allowlist. ```bash theme={null} glam-cli cctp remove-destination [--base58] [--yes] ``` # Delegate Commands Source: https://docs.glam.systems/v1/cli/delegate Manage delegate permissions for your vault. Only the vault owner can grant or revoke delegate permissions. For more information on the access control framework, see [Access Control](/v1/access-control/framework). ## List Delegates List all delegates and their permissions for the active vault. ```bash theme={null} glam-cli delegate list ``` ## Grant Permissions Grant delegate permissions for a specific protocol. * `pubkey`: Public key of the delegate * `permissions...`: Space-separated list of permission names * `--protocol`: Protocol name (required). Examples: `KaminoLend`, `SplToken`, `JupiterSwap` ```bash theme={null} glam-cli delegate grant --protocol [--yes] ``` **Example:** Grant a delegate permission to deposit and withdraw on Kamino Lending: ```bash theme={null} glam-cli delegate grant Delegate111111111111111111111111 Deposit Withdraw --protocol KaminoLend ``` Run `glam-cli delegate grant -h` to see the full list of available permissions for each protocol. ## Revoke Permissions Revoke specific delegate permissions for a protocol. * `pubkey`: Public key of the delegate * `permissions...`: Space-separated list of permission names to revoke * `--protocol`: Protocol name (required) ```bash theme={null} glam-cli delegate revoke --protocol [--yes] ``` **Example:** Revoke deposit permission from a delegate: ```bash theme={null} glam-cli delegate revoke Delegate111111111111111111111111 Deposit --protocol KaminoLend ``` ## Revoke All Permissions Completely remove a delegate's access to the vault. ```bash theme={null} glam-cli delegate revoke-all [--yes] ``` # CLI Examples Source: https://docs.glam.systems/v1/cli/examples ## Install & Configure CLI The GLAM CLI is built using the GLAM SDK. The [source code is available on Github](https://github.com/glamsystems/glam-cli). For reference, here's a sample configuration: ```json theme={null} { "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: ```json theme={null} { "accountType": "vault", "name": "GLAM Vault Demo", "enabled": true, "assets": [ "So11111111111111111111111111111111111111112", "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" ] } ``` Create the vault: ```bash theme={null} glam-cli vault create vault.json ``` Output: ```text theme={null} txSig: 58QhaZWjVqdBr1Ap9eitp8p4LL2NyzT2c5fxhVtb7qgo2Y8DDhrY6yeAobcTqz1fW3AYcjknbtXqbSNkcg7ePkrW GLAM state created: 6K1wuNhcFX6yDJZaGYwQMnnf4rGuCNBTvngx5dQNNfcN Vault: 5zJKfPVQLEBiVqoXRtG9tYRXHS166d5JiZbyQtiopqgh ``` *** ## Enable Integrations Integrations are disabled by default. Enable them before use: ```bash theme={null} glam-cli integration enable KaminoLend JupiterSwap ``` Verify enabled integrations: ```bash theme={null} glam-cli integration list ``` Output: ```text theme={null} GLAM Vault Quickstart (6K1wuNhcFX6yDJZaGYwQMnnf4rGuCNBTvngx5dQNNfcN) has 2 integration programs enabled: [0] GLAMpk...111111, protocols (0b001): KaminoLend [1] GLAMpk...111111, protocols (0b010): JupiterSwap ``` *** ## Deposit SOL and tokens can be transferred to the vault directly. ### Get Vault Address ```bash theme={null} glam-cli env ``` 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! ```text theme={null} 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 ```bash theme={null} glam-cli vault token-balances ``` Output: ```text theme={null} Token Mint Amount Value (USD) SOL N/A 0.5 70.4668035 ``` *** ## Kamino Lending ### Initialize Kamino User ```bash theme={null} glam-cli kamino-lend init ``` ### Deposit to Main Market The pubkey of Kamino main market is `7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF`. Deposit 0.1 SOL: ```bash theme={null} glam-cli kamino-lend deposit 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF So11111111111111111111111111111111111111112 0.1 ``` To verify the deposit, visit the vault's Kamino account at: ```text theme={null} https://app.kamino.finance/?DEBUG_WALLET=[ YourVaultAddress ] ``` ### Borrow Borrow cbBTC using deposited SOL as collateral: ```bash theme={null} glam-cli kamino-lend borrow 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij 0.000001 ``` ### Withdraw ```bash theme={null} glam-cli kamino-lend withdraw 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF So11111111111111111111111111111111111111112 0.05 ``` ### Repay ```bash theme={null} glam-cli kamino-lend repay 7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij 0.000001 ``` *** ## Jupiter Swap Swap 0.01 SOL to USDC: ```bash theme={null} glam-cli jupiter swap SOL USDC 0.01 ``` *** ## Access Control & Delegation ### Grant Permissions ```bash theme={null} glam-cli delegate grant Deposit --protocol KaminoLend ``` ### List Delegates ```bash theme={null} glam-cli delegate list ``` ### Revoke Permissions ```bash theme={null} glam-cli delegate revoke Deposit --protocol KaminoLend ``` ### Revoke All Access ```bash theme={null} glam-cli delegate revoke-all ``` *** ## 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](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/](https://explorer.solana.com/) instead. # General Commands Source: https://docs.glam.systems/v1/cli/general ## Environment ### View Environment Setup Display the current CLI configuration including connected wallet, RPC endpoint, and active vault. ```bash theme={null} glam-cli env ``` *** ## Vault Management ### List Vaults List GLAM vaults accessible to the connected wallet. * `--owner-only`, `-o`: Only show vaults owned by the connected wallet * `--all`, `-a`: Show all GLAM vaults * `--type`, `-t`: Filter by type (`vault` or `tokenizedVault`) ```bash theme={null} glam-cli vault list [--owner-only] [--all] [--type ] ``` ### Set Active Vault Set the active GLAM vault for subsequent CLI operations. Saves the vault state to the config file. ```bash theme={null} glam-cli vault set ``` ### View Vault Details View a GLAM vault by its state pubkey. * `--compact`, `-c`: Output as compact JSON * `state`: If not provided, the current active vault is used ```bash theme={null} glam-cli vault view [--compact] [state] ``` ### Create a Vault Create a new GLAM vault from a JSON template file. * See the [templates directory](https://github.com/glamsystems/glam/tree/main/cli/templates) for available templates ```bash theme={null} glam-cli vault create ``` ### Close a Vault Close a GLAM vault. Only the owner can close a vault. Tokenized vaults cannot be closed if mint supply is greater than 0. * `state`: If not provided, the current active vault is used * `--yes`, `-y`: Skip confirmation prompt ```bash theme={null} glam-cli vault close [state] [--yes] ``` ### Update Owner Transfer vault ownership to a new owner. * `--name`, `-n`: Optionally set a new portfolio manager name * `--yes`, `-y`: Skip confirmation prompt ```bash theme={null} glam-cli vault update-owner [--name ] [--yes] ``` ### Enable/Disable Vault Enable a GLAM vault. ```bash theme={null} glam-cli vault enable [--yes] ``` Disable a GLAM vault. ```bash theme={null} glam-cli vault disable [--yes] ``` ### Extend State Account Extend the GLAM state account by additional bytes. Useful when the state account needs more space. ```bash theme={null} glam-cli vault extend [--yes] ``` *** ## Asset Management ### View Balances Get token balances for the vault. * `--all`, `-a`: Show all assets including token accounts with 0 balance ```bash theme={null} glam-cli vault token-balances [--all] ``` ### View Holdings Get all vault holdings including token balances and positions across integrated protocols. ```bash theme={null} glam-cli vault holdings ``` ### Close Token Accounts Close vault token accounts by specifying mint addresses, or use `--empty` to close all zero-balance token accounts. * `mints`: One or more mint addresses of token accounts to close ```bash theme={null} glam-cli vault close-token-accounts [--yes] glam-cli vault close-token-accounts --empty [--yes] ``` Token programs prevent closing token accounts with non-zero balances. ### List Asset Allowlist List the vault's asset allowlist and corresponding token accounts. ```bash theme={null} glam-cli vault list-assets ``` ### Add Asset to Allowlist Add an asset to the vault's allowlist. ```bash theme={null} glam-cli vault allowlist-asset [--yes] ``` ### Remove Asset from Allowlist Remove an asset from the vault's allowlist. ```bash theme={null} glam-cli vault remove-asset [--yes] ``` *** ## SOL Wrapping ### Wrap SOL Wrap SOL into wSOL. ```bash theme={null} glam-cli vault wrap [--yes] ``` ### Unwrap wSOL Unwrap all wSOL back to SOL. ```bash theme={null} glam-cli vault unwrap [--yes] ``` *** ## Vault Templates When creating a vault with `glam-cli vault create