> 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/id/kasus-penggunaan/defi-protocols.md).

# Protokol DeFi

Pola integrasi untuk DeFi EVM di Rome — lending dengan oracle Solana, menggabungkan Jupiter dan Kamino dari Solidity, serta pool likuiditas bersama.

Rome memungkinkan protokol DeFi EVM untuk berkomposisi secara atomik dengan ekosistem DeFi native Solana. Halaman ini membahas pola integrasi yang umum. Beberapa sudah aktif di Rome — Aave v3, Compound v3 (Aerarium), Uniswap V2/V3/V4, dan Rome DEX — lihat [Aplikasi di Rome](https://docs.rome.builders/id/aplikasi-di-rome/apps.md).

Kode di bawah ini bersifat ilustratif; nama antarmuka untuk program Solana pihak ketiga adalah contoh, bukan antarmuka SDK yang disertakan.

## Mengapa DeFi di Rome?

* **Akses likuiditas Solana** — Jupiter, Kamino, Drift, Meteora, Raydium, Orca
* **Komposabilitas atomik** — operasi DeFi multi-langkah dalam satu transaksi
* **Perangkat pengembangan Solidity** — ekosistem pengembangan dan audit yang familiar
* **State bersama** — pengguna EVM dan Solana berbagi kumpulan yang sama

## Pola 1: Protokol Peminjaman dengan Oracle Solana

Impor di bawah ini berasal dari [`rome-solidity`](https://github.com/rome-protocol/rome-solidity), yang diinstal dari GitHub, bukan dari npm: `npm install github:rome-protocol/rome-solidity`, atau `forge install rome-protocol/rome-solidity` dengan remapping `@rome-protocol/rome-solidity/=lib/rome-solidity/` (detail di [Deploy Solidity Contracts](https://docs.rome.builders/id/panduan-pengembang/deploy-solidity.md#using-the-rome-solidity-sdk)). Masukkan alamat feed dari [registry](https://docs.rome.builders/id/produk/oracle-gateway.md#consume-a-feed-in-three-steps) daripada meng-hardcode-nya.

```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();
        // Harga Pyth/Switchboard via Oracle Gateway
        // Antarmuka yang sama seperti Chainlink di Ethereum
        return (amount * uint256(price)) / 1e8;
    }
}
```

## Pola 2: Agregator DEX via CPI

```solidity
contract RomeSwap {
    function swap(
        bytes32 fromMint,
        bytes32 toMint,
        uint256 amount,
        uint256 minOut
    ) external {
        // CPI ke Jupiter/Raydium/Meteora
        // Semua likuiditas DEX Solana dapat diakses dari Solidity
        CpiProgram.invoke(JUPITER_PROGRAM, accounts, swapData);
    }
}
```

## Pola 3: Vault Imbal Hasil

```solidity
contract YieldVault {
    function deposit(uint256 amount) external {
        // Terima deposit USDC
        // CPI → Jupiter: tukar ke token optimal
        // CPI → Kamino: sediakan sebagai jaminan
        // CPI → Drift: buka lindung nilai delta-netral
        // Semua atomik — satu tx, semua-atau-tidak sama sekali
    }
}
```

## Pola 4: Arbitrase Lintas Protokol

Menggunakan `RemusTx` (beberapa transaksi EVM pada chain Rome yang berbeda, atomik dalam satu transaksi Solana):

1. Beli di DEX A pada satu chain Rome
2. Jual di DEX B pada chain Rome lainnya
3. Keduanya dieksekusi secara atomik; jika salah satu gagal, keduanya di-revert.

## Implementasi referensi

Fork aplikasi Rome yang berfungsi alih-alih memulai dari halaman kosong:

* [**rome-dex**](https://github.com/rome-protocol/rome-dex) — AMM jalur ganda; bawa ide baru dan terapkan untuk pengguna Solana dan EVM melalui satu pool.
* [**aerarium**](https://github.com/rome-protocol/aerarium) — UI peminjaman Compound v3 jalur ganda.
* [**cardo**](https://github.com/rome-protocol/cardo) — portal distribusi aplikasi berbasis CPI (swap / lend / perps / compose).
* [**rome-aave-v3-demo**](https://github.com/rome-protocol/rome-aave-v3-demo) — UI peminjaman Aave v3.
* [**compound-on-rome-comet**](https://github.com/rome-protocol/compound-on-rome-comet) — kontrak pasar uang Comet.
* [**rome-oracle-gateway**](https://github.com/rome-protocol/rome-oracle-gateway) — aplikasi cross-VM greenfield: membaca akun harga Solana (Pyth, Switchboard), mem-postingnya ke EVM, dan menyediakannya ke Solidity melalui Chainlink standar `AggregatorV3Interface`.

## Terkait

* [Gateway Oracle](https://docs.rome.builders/id/produk/oracle-gateway.md) — feed harga yang kompatibel dengan Chainlink
* [Rome SDK](https://docs.rome.builders/id/produk/rome-sdk.md) — antarmuka bertipe untuk protokol DeFi


---

# 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/id/kasus-penggunaan/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.
