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

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

The question should be specific, self-contained, and written in natural language.
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.
