# Protokol DeFi

Rome memungkinkan protokol DeFi EVM untuk berkomposisi dengan ekosistem DeFi native Solana secara atomik. Halaman ini membahas pola integrasi umum.

## Mengapa DeFi di Rome?

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

## Pola 1: Protokol Peminjaman dengan Oracle Solana

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

kontrak 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
kontrak 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 Yield

```solidity
kontrak YieldVault {
    function deposit(uint256 amount) external {
        // Menerima deposit USDC
        // CPI → Jupiter: tukar ke token optimal
        // CPI → Kamino: pasok 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` (transaksi lintas-rollup atomik):

1. Beli di DEX A dalam rollup 1
2. Jual di DEX B dalam rollup 2
3. Keduanya secara atomik — risiko eksekusi nol

## Terkait

* [DeFi Composer](/id/produk/defi-composer.md) — infrastruktur vault multi-protokol
* [Oracle Gateway](/id/produk/oracle-gateway.md) — feed harga kompatibel dengan Chainlink
* [Rome SDK](/id/produk/rome-sdk.md) — antarmuka bertipe untuk protokol DeFi


---

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