Overview
The GLAM delegate system enables vault owners to grant specific permissions to other addresses, allowing controlled access to vault operations without transferring ownership.Delegate System
Delegates are third-party addresses (wallets, programs, or multisigs) that can perform specific actions on behalf of a vault.Key Concepts
- Granular Permissions: Grant only the specific capabilities needed
- Protocol-Scoped: Permissions apply to specific DeFi protocols
- Revocable: Owner can revoke permissions at any time
- Multiple Delegates: Support for multiple delegates with different permission sets
Delegates never have access to the vault owner’s private key or ability to transfer ownership.
Permission Model
Permissions in GLAM are organized hierarchically:Integration Programs
Integration programs are GLAM adapters that interface with external DeFi protocols:- Protocol Program: Core GLAM integrations (SPL Token, Jupiter, etc.)
- Ext Drift Program: Drift Protocol integrations
- Ext Kamino Program: Kamino Protocol integrations
Protocols
Each integration program supports multiple protocols, identified by bitflags: Protocol Program (0x…):0b0000001- SplToken0b0000010- Transfer0b0000100- JupiterSwap0b0001000- Stake (Native staking)0b0010000- Marinade0b0100000- LST (Liquid staking tokens)
0b01- DriftProtocol
0b01- KaminoLend0b10- KaminoVaults0b100- KaminoFarms
Protocol bitflags are combined using bitwise OR to enable multiple protocols within a single integration program.
Permissions
Each protocol defines specific permissions that can be granted: SplToken Protocol:Burn- Burn tokens from vaultMint- Mint tokens to vaultTransfer- Transfer tokens between accounts
Swap- Execute token swaps
Initialize- Initialize Drift accountsDeposit- Deposit collateralWithdraw- Withdraw collateralPlaceOrder- Place spot/perp ordersCancelOrder- Cancel ordersModifyOrder- Modify existing orders
Deposit- Deposit to lending marketsWithdraw- Withdraw from lending marketsBorrow- Borrow assetsRepay- Repay loans
Delegate Access Control Lists (ACLs)
The vault state maintains a list of delegate ACLs, each containing:- Multiple delegates per vault
- Multiple integration programs per delegate
- Multiple protocols per integration program
- Fine-grained permissions per protocol
Managing Delegates
Listing Delegates
View all delegates and their permissions:Granting Permissions
Grant specific permissions to a delegate:- Resolves protocol name (case-insensitive, fuzzy matching)
- Resolves permission names for the protocol
- Parses into integration program, protocol bitflag, and permissions bitmask
- Submits on-chain transaction to update ACLs
Protocol Name Fuzzy Matching
Protocol Name Fuzzy Matching
The CLI supports fuzzy matching for protocol and permission names:From utils.ts:446-484, the resolver:
- Tries exact match first
- Falls back to case-insensitive match
- Suggests close matches using Levenshtein distance (≤3)
- Lists all valid protocol names on error
Revoking Permissions
Revoke specific permissions from a delegate:Revoking All Access
Completely remove a delegate’s access:- Removes the delegate from all integration ACLs
- Clears all protocol permissions
- Uses
emergencyAccessUpdatefor immediate effect - Cannot be undone (must re-grant permissions)
Permission Validation
When a delegate attempts to execute an operation, GLAM validates:- Delegate exists: Delegate pubkey is in vault’s ACL list
- Integration enabled: Integration program is enabled for vault (see Integrations)
- Protocol enabled: Protocol bitflag is set in integration ACL
- Permission granted: Specific permission bit is set in permissions bitmask
Use Cases
Trading Bot
Grant a trading bot limited swap permissions:- Transfer assets out of vault
- Change vault configuration
- Grant permissions to others
- Access other protocols
Multi-Manager Fund
Grant different managers different protocol access:Custodian Integration
Grant a custodian service transfer rights:Emergency Operator
Grant emergency permissions to close positions during crisis:Combine delegates with integration policies (max slippage, market allowlists) to create defense-in-depth security.
Best Practices
Principle of Least Privilege
Only grant the minimum permissions required:Regular Audits
Periodically review delegate access:Separation of Concerns
Use different delegates for different functions:- Trading delegate: Swap and order permissions only
- Yield delegate: Lending and staking permissions only
- Custody delegate: Transfer permissions only
- Emergency delegate: Withdrawal and cancel permissions only
Time-Limited Access
For temporary access, grant and revoke as needed:Technical Details
Bitmask Operations
Permissions use bitwise operations for efficiency:Integration Program Resolution
From delegate.ts:17-54, the system:- Receives protocol name and permission names
- Looks up integration program ID and protocol bitflag
- Converts permission names to bitmask
- Calls
grantDelegatePermissionsorrevokeDelegatePermissions - Updates on-chain ACL data
On-Chain Storage
Delegate ACLs are stored in the vault state account, growing dynamically as delegates are added. Usevault extend if the state account needs more space.
Each delegate entry consumes approximately 100-200 bytes depending on the number of integration programs and protocols configured.