> For the complete documentation index, see [llms.txt](https://docs.rome.builders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rome.builders/products/defi-composer.md).

# DeFi Composer

DeFi Composer enables Yearn-style multi-protocol vaults written in Solidity that compose across multiple Solana DeFi protocols atomically via CPI.

## Overview

A single Solidity function can orchestrate operations across Jupiter, Kamino, Drift, Meteora, and other Solana protocols — all atomically. If any step fails, the entire transaction reverts.

```solidity
function executeStrategy(uint256 amount) external {
    // 1. Swap 50% USDC to SOL via Jupiter
    IJupiter(JUPITER).swap(USDC, SOL, amount / 2, minSolOut);

    // 2. Deposit SOL as collateral on Kamino
    IKamino(KAMINO).deposit(SOL, solAmount);

    // 3. Borrow USDC against SOL collateral
    IKamino(KAMINO).borrow(USDC, borrowAmount);

    // 4. Open SOL-PERP short on Drift (delta hedge)
    IDrift(DRIFT).placeOrder(SOL_PERP, SHORT, size, leverage);

    // All atomic. One Solidity function. Four CPI hops.
}
```

## Why Solidity for DeFi Composition?

* **Familiar tooling** — Solidity devs don't need to learn Rust/Anchor
* **Mature ecosystem** — leverage OpenZeppelin, existing audit tooling, Hardhat/Foundry workflows
* **Composability** — Solidity's `try/catch`, modifiers, and inheritance work naturally
* **Atomic execution** — Solana's transaction model guarantees all-or-nothing

## Reference Strategies (Planned)

| Strategy            | Protocols              | Description                                      |
| ------------------- | ---------------------- | ------------------------------------------------ |
| SOL Yield Optimizer | Kamino, Drift          | Supply SOL, borrow stables, delta-hedge on perps |
| Stablecoin Yield    | Kamino, Orca           | LP stablecoins across pools, auto-rebalance      |
| Delta-Neutral       | Jupiter, Kamino, Drift | Swap + supply + hedge for yield without exposure |
| LST Arbitrage       | Jupiter, Marinade      | Exploit LST price differentials                  |

## Status

**Designed** — depends on Rome SDK Phase 2 (IJupiter, IDrift, IKamino interfaces). Core CPI infrastructure is live; protocol-specific typed interfaces are in progress.

## What's Next

* [Rome SDK](/products/rome-sdk.md) — typed Solidity interfaces for Solana programs
* [Call Solana from EVM](/developer-guides/call-solana-from-evm.md) — CPI guide
* [Constraints](/core-concepts/constraints.md) — CPI depth limits and compute budget


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rome.builders/products/defi-composer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
