> 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/ru/scenarii-ispolzovaniya/defi-protocols.md).

# Протоколы DeFi

Rome позволяет EVM DeFi-протоколам атомарно композировать операции с нативной DeFi-экосистемой Solana. Эта страница описывает распространённые шаблоны интеграции. Несколько из них уже работают в Rome — Aave v3, Compound v3 (Aerarium), Uniswap V2/V3/V4 и Rome DEX — см. [Приложения на Rome](/ru/prilozheniya-na-rome/apps.md).

Код ниже носит иллюстративный характер; имена интерфейсов для сторонних программ Solana — это примеры, а не поставляемые интерфейсы SDK.

## Почему DeFi на Rome?

* **Доступ к ликвидности Solana** — Jupiter, Kamino, Drift, Meteora, Raydium, Orca
* **Атомарная компонуемость** — многошаговые DeFi-операции в одной транзакции
* **Инструменты Solidity** — привычная экосистема разработки и аудита
* **Общее состояние** — пользователи EVM и Solana разделяют одни и те же пулы

## Шаблон 1: Протокол кредитования с оракулами Solana

```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 через Oracle Gateway
        // Тот же интерфейс, что и у Chainlink в Ethereum
        return (amount * uint256(price)) / 1e8;
    }
}
```

## Шаблон 2: DEX-агрегатор через CPI

```solidity
contract RomeSwap {
    function swap(
        bytes32 fromMint,
        bytes32 toMint,
        uint256 amount,
        uint256 minOut
    ) external {
        // CPI к Jupiter/Raydium/Meteora
        // Вся ликвидность Solana DEX доступна из Solidity
        CpiProgram.invoke(JUPITER_PROGRAM, accounts, swapData);
    }
}
```

## Шаблон 3: Хранилище доходности

```solidity
contract YieldVault {
    function deposit(uint256 amount) external {
        // Принять депозит USDC
        // CPI → Jupiter: обменять на оптимальные токены
        // CPI → Kamino: предоставить как обеспечение
        // CPI → Drift: открыть дельта-нейтральный хедж
        // Всё атомарно — одна транзакция, всё или ничего
    }
}
```

## Шаблон 4: Межпротокольный арбитраж

Используя `RemusTx` (атомарные кросс-rollup транзакции):

1. Покупка на DEX A в rollup 1
2. Продажа на DEX B в rollup 2
3. Обе атомарно — нулевой риск исполнения

## Референсные реализации

Сделайте форк рабочего приложения Rome вместо того, чтобы начинать с чистого листа:

* [**rome-dex**](https://github.com/rome-protocol/rome-dex) — двухполосный AMM; принесите новую идею и разверните её для пользователей Solana и EVM через один пул.
* [**aerarium**](https://github.com/rome-protocol/aerarium) — двухполосный интерфейс кредитования Compound v3.
* [**cardo**](https://github.com/rome-protocol/cardo) — портал распределения приложений CPI (swap / lend / perps / compose).
* [**rome-aave-v3-demo**](https://github.com/rome-protocol/rome-aave-v3-demo) — интерфейс кредитования Aave v3.
* [**compound-on-rome-comet**](https://github.com/rome-protocol/compound-on-rome-comet) — контракты денежного рынка Comet.
* [**rome-oracle-gateway**](https://github.com/rome-protocol/rome-oracle-gateway) — новое кросс-VM приложение: читает ценовые аккаунты Solana (Pyth, Switchboard), публикует их в EVM и предоставляет их Solidity через стандартный Chainlink `AggregatorV3Interface`.

## Связанные материалы

* [Шлюз оракула](/ru/produkty/oracle-gateway.md) — ценовые потоки, совместимые с Chainlink
* [Rome SDK](/ru/produkty/rome-sdk.md) — типизированные интерфейсы для 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 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/ru/scenarii-ispolzovaniya/defi-protocols.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.
