> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glam.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# 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).

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 ]"
  }
}
```

<Info>
  If you don't have a dedicated RPC for landing transactions, it's highly recommended to set priority fee level to High.
</Info>

***

## 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:

```
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:

```
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.

<Warning>
  Double check you have the right address before transferring. Sending tokens to the wrong address might lead to unrecoverable loss of your funds!
</Warning>

```
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:

```
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:

```
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 <delegate_pubkey> Deposit --protocol KaminoLend
```

### List Delegates

```bash theme={null}
glam-cli delegate list
```

### Revoke Permissions

```bash theme={null}
glam-cli delegate revoke <delegate_pubkey> Deposit --protocol KaminoLend
```

### Revoke All Access

```bash theme={null}
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](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.
