> For the complete documentation index, see [llms.txt](https://docs.keystonefi.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keystonefi.xyz/build-on-it/quick-start/protocols.md).

# Protocol Integrations

The vault works with other Solana protocols by calling them directly from its own program, a pattern called CPI. Every one of those calls is signed by the vault itself, so no private key is involved.

{% hint style="warning" %}
v1 hedges on **Phoenix Perps** (Ellipsis Labs) via on-chain CPI, USDC margin through **Ember**. The Phoenix/Ember CPI surface below is finalized with the integration.
{% endhint %}

For Phoenix, Keystone uses the **Rise SDK** (`github.com/Ellipsis-Labs/rise-public`) and reads Phoenix's account layouts from it. The other integrations build their instructions and account lists by hand.

***

## Venues

| Role                    | Program / Asset                                            | Address                                        |
| ----------------------- | ---------------------------------------------------------- | ---------------------------------------------- |
| Perp venue (mainnet)    | Phoenix Perps (Ellipsis Labs)                              | `EtrnLzgbS7nMMy5fbD42kXiUzGg8XQzJ972Xtk1cjWih` |
| Margin (USDC → Phoenix) | Ember                                                      | `EMBERpYNE6ehWmXymZZS2skiFmCa9V5dp14e1iduM5qy` |
| Spot leg                | jitoSOL (LST, held for staking — **not** posted as margin) | `J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn` |
| Lending / parked        | Kamino USDC reserve                                        | `D6q6wuQSrifJKZYpR1M8R4YawnLDtDsMmWM1NbBmgJ59` |
| Quote / settlement      | USDC                                                       | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |

***

## Dependencies

| Protocol                          | Purpose                                                                   | Where used                                                                       |
| --------------------------------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| **Phoenix Perps** (Ellipsis Labs) | SOL-PERP short; USDC margin (posted via Ember); real two-sided funding    | `open_position`, `close_position`, `settle`, `emergency_close`, `enable_phoenix` |
| **Ember**                         | Routes USDC → Phoenix perp margin                                         | `open_position`, `close_position` (margin post/withdraw)                         |
| **Kamino KLend**                  | USDC lending for buffer + parked capital                                  | `enable_lending`, `lend_idle_usdc`, `unlend_usdc`                                |
| **Jupiter V6**                    | All token swaps (USDC ↔ jitoSOL); off-chain quote, on-chain execution     | Every open/close path that crosses tokens                                        |
| **Pyth (pull oracles)**           | SOL/USD + jitoSOL/USD for NAV math, drawdown guard, depeg check           | `settle`, `open_*`, `close_*`, `set_oracles`                                     |
| **Jito (jitoSOL)**                | Liquid staking; held **unlevered as the spot leg** (not posted as margin) | Implicit — staking yield is embedded in the jitoSOL/SOL exchange rate            |

***

## Verified mainnet addresses

| Item                                  | Address                                        |
| ------------------------------------- | ---------------------------------------------- |
| Phoenix Perps Program                 | `EtrnLzgbS7nMMy5fbD42kXiUzGg8XQzJ972Xtk1cjWih` |
| Ember Program (USDC → Phoenix margin) | `EMBERpYNE6ehWmXymZZS2skiFmCa9V5dp14e1iduM5qy` |
| Phoenix SOL-PERP market               | resolved via `PerpAssetMap` (Rise SDK)         |
| Kamino KLend Program                  | `KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD`  |
| Kamino Main Market                    | `7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF` |
| Kamino USDC Reserve                   | `D6q6wuQSrifJKZYpR1M8R4YawnLDtDsMmWM1NbBmgJ59` |
| Kamino USDT Reserve                   | `H3t6qZ1JkguCNTi9uzVKqQ7dvt2cum4XiXWom6Gn5e5S` |
| Jupiter V6 Program                    | `JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4`  |
| jitoSOL mint                          | `J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn` |
| USDC mint                             | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |

***

## CPI surface (Rust)

| Module                          | Helpers                                                                                                                                                                                                                                                                                        |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `utils::phoenix_cpi` *(target)* | Onboard trader (Rise builder path), post/withdraw USDC margin via Ember, `place_perp_order`, `cancel_orders`, settle funding, `read_phoenix_funding_rate` — built on the `phoenix-rise` account views (`TraderHeader`, `TraderPositions`, `PerpAssetMap`, `GlobalConfig`, `PermissionAccount`) |
| `utils::kamino`                 | `deposit_reserve_liquidity`, `redeem_reserve_collateral`, `refresh_reserve`                                                                                                                                                                                                                    |
| `utils::jupiter_swap`           | `route_swap`, `require_min_received`                                                                                                                                                                                                                                                           |
| `utils::oracle`                 | Pyth pull-oracle staleness + confidence wrappers, jitoSOL/SOL depeg check                                                                                                                                                                                                                      |

* Every helper passes the vault's signer seeds (`[b"vault", &[bump]]`), which is how the vault authorizes the call.
* Phoenix account layouts come from the `phoenix-rise` crate, read in place without copying. Kamino's return data is checked with minimal Borsh decoding.
* Kamino's byte offsets are hard-coded against a layout verified on-chain. Phoenix uses the Rise definitions instead of hand-written offsets.

***

## Off-chain account assembly

Strategy instructions expect 3–5 groups of accounts in `remaining_accounts`, plus a count for each group. The keeper assembles those off-chain:

* **Phoenix** — the Rise SDK (`github.com/Ellipsis-Labs/rise-public`) provides the correct account ordering for trader onboarding, margin in and out through Ember, `place_perp_order`, and funding settlement.
* **Kamino** — the same idea. The `refresh_obligation` and collateral instructions follow a fixed pattern documented in the Kamino IDL.
* **Jupiter** — Jupiter's `/swap-instructions` endpoint returns both the swap data (passed as `jupiter_swap_data`) and the account list that goes with it (passed as the matching account group).

See [Keeper bot](/run-it/keeper-bot.md) for the off-chain orchestration pattern.

***

## Related

* [Whitepaper](/how-it-works/whitepaper.md) — single-page overview of the system
* [Instructions reference](/build-on-it/quick-start/instructions.md) — per-instruction account-context groups
* [Quick start](/build-on-it/quick-start.md)
