> 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-протоколы

Паттерны интеграции EVM DeFi в Rome — кредитование с оракулами Solana, композиция Jupiter и Kamino из Solidity и пулы общей ликвидности.

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

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

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

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

## Шаблон 1: кредитный протокол с оракулами Solana

Импорт ниже берётся из [`rome-solidity`](https://github.com/rome-protocol/rome-solidity), который устанавливается из GitHub, а не из npm: `npm install github:rome-protocol/rome-solidity`, или `forge install rome-protocol/rome-solidity` с переназначением `@rome-protocol/rome-solidity/=lib/rome-solidity/` (подробности в [Развертывание Solidity-контрактов](/ru/rukovodstva-dlya-razrabotchikov/deploy-solidity.md#using-the-rome-solidity-sdk)). Передавайте адрес фида из [реестре](/ru/produkty/oracle-gateway.md#consume-a-feed-in-three-steps) вместо того чтобы жёстко задавать его.

```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` (атомарные кросс-роллапные транзакции):

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

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

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

* [**rome-dex**](https://github.com/rome-protocol/rome-dex) — AMM с двумя каналами; предложите новую идею и разверните её для пользователей Solana и EVM через один пул.
* [**aerarium**](https://github.com/rome-protocol/aerarium) — UI кредитования 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) — UI кредитования 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) — приложение cross-VM на новой базе: читает ценовые аккаунты Solana (Pyth, Switchboard), публикует их в EVM и предоставляет их Solidity через стандартный Chainlink `AggregatorV3Interface`.

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

* [Oracle Gateway](/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 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/ru/scenarii-ispolzovaniya/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.
