> 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/use-cases/defi-protocols.md).

# DeFi Protocols

Integration patterns for EVM DeFi on Rome — lending with Solana oracles, composing Jupiter and Kamino from Solidity, and shared-liquidity pools.

Rome enables EVM DeFi protocols to compose with Solana's native DeFi ecosystem atomically. This page covers common integration patterns. Several are already live on Rome — Aave v3, Compound v3 (Aerarium), Uniswap V2/V3/V4, and Rome DEX — see [Apps on Rome](/apps-on-rome/apps.md).

The code below is illustrative; interface names for third-party Solana programs are examples, not shipped SDK interfaces.

## Why DeFi on Rome?

* **Access Solana liquidity** — Jupiter, Kamino, Drift, Meteora, Raydium, Orca
* **Atomic composability** — multi-step DeFi operations in a single transaction
* **Solidity tooling** — familiar development and audit ecosystem
* **Shared state** — EVM and Solana users share the same pools

## Pattern 1: Lending Protocol with Solana Oracles

The import below comes from [`rome-solidity`](https://github.com/rome-protocol/rome-solidity), which is installed from GitHub, not from npm: `npm install github:rome-protocol/rome-solidity`, or `forge install rome-protocol/rome-solidity` with the remapping `@rome-protocol/rome-solidity/=lib/rome-solidity/` (details in [Deploy Solidity Contracts](/developer-guides/deploy-solidity.md#using-the-rome-solidity-sdk)). Pass the feed address in from the [registry](/products/oracle-gateway.md#consume-a-feed-in-three-steps) rather than hardcoding it.

```solidity
import {IAggregatorV3Interface} from "@rome-protocol/rome-solidity/contracts/oracle/IAggregatorV3Interface.sol";

contract RomeLending {
    IAggregatorV3Interface public priceFeed;

    constructor(address _priceFeed) {
        priceFeed = IAggregatorV3Interface(_priceFeed);
    }

    function getCollateralValue(uint256 amount) public view returns (uint256) {
        (, int256 price,,,) = priceFeed.latestRoundData();
        // Pyth/Switchboard price via Oracle Gateway
        // Same interface as Chainlink on Ethereum
        return (amount * uint256(price)) / 1e8;
    }
}
```

## Pattern 2: DEX Aggregator via CPI

```solidity
contract RomeSwap {
    function swap(
        bytes32 fromMint,
        bytes32 toMint,
        uint256 amount,
        uint256 minOut
    ) external {
        // CPI to Jupiter/Raydium/Meteora
        // All Solana DEX liquidity accessible from Solidity
        CpiProgram.invoke(JUPITER_PROGRAM, accounts, swapData);
    }
}
```

## Pattern 3: Yield Vault

```solidity
contract YieldVault {
    function deposit(uint256 amount) external {
        // Accept USDC deposit
        // CPI → Jupiter: swap to optimal tokens
        // CPI → Kamino: supply as collateral
        // CPI → Drift: open delta-neutral hedge
        // All atomic — one tx, all-or-nothing
    }
}
```

## Pattern 4: Cross-Protocol Arbitrage

Using `RemusTx` (atomic cross-rollup transactions):

1. Buy on DEX A in rollup 1
2. Sell on DEX B in rollup 2
3. Both atomically — zero execution risk

## Reference implementations

Fork a working Rome app instead of starting from a blank page:

* [**rome-dex**](https://github.com/rome-protocol/rome-dex) — dual-lane AMM; bring a new idea and deploy it for both Solana and EVM users over one pool.
* [**aerarium**](https://github.com/rome-protocol/aerarium) — dual-lane Compound v3 lending UI.
* [**cardo**](https://github.com/rome-protocol/cardo) — CPI app-distribution portal (swap / lend / perps / compose).
* [**rome-aave-v3-demo**](https://github.com/rome-protocol/rome-aave-v3-demo) — Aave v3 lending UI.
* [**compound-on-rome-comet**](https://github.com/rome-protocol/compound-on-rome-comet) — the Comet money-market contracts.
* [**rome-oracle-gateway**](https://github.com/rome-protocol/rome-oracle-gateway) — a greenfield cross-VM app: reads Solana price accounts (Pyth, Switchboard), posts them on EVM, and serves them to Solidity through the standard Chainlink `AggregatorV3Interface`.

## Related

* [Oracle Gateway](/products/oracle-gateway.md) — Chainlink-compatible price feeds
* [Rome SDK](/products/rome-sdk.md) — typed interfaces for DeFi protocols


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rome.builders/use-cases/defi-protocols.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
