Skip to content

Commit e284f49

Browse files
committed
docs(ftso): improve wording
1 parent 279b86d commit e284f49

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

docs/ftso/guides/adapters.mdx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,46 @@ import bandExample from "!!raw-loader!/examples/developer-hub-javascript/bandExa
2727
import ChronicleExample from "!!raw-loader!/examples/developer-hub-solidity/ChronicleExample.sol";
2828
import chronicleExample from "!!raw-loader!/examples/developer-hub-javascript/chronicleExample.ts";
2929

30-
FTSO Adapters, provided by the `@flarenetwork/ftso-adapters` library, allow decentralized applications (dApps) built for other popular oracle interfaces to integrate with Flare's FTSO with minimal code changes. The library provides adapters for Pyth, Chainlink, API3, Band Protocol, and Chronicle. These adapters act as a compatibility layer, translating the FTSO's data structure into the format expected by each respective oracle's interface.
30+
FTSO Adapters, provided by the `@flarenetwork/ftso-adapters` library, allow decentralized applications (dApps) built for other popular oracle interfaces to integrate with Flare's FTSO with minimal code changes.
31+
The library provides adapters for Pyth, Chainlink, API3, Band Protocol, and Chronicle.
32+
These adapters act as a compatibility layer, translating the FTSO's data structure into the format expected by each respective oracle's interface.
3133

32-
This enables a seamless migration path for projects looking to leverage the speed, decentralization, and cost-effectiveness of Flare's native oracle. This guide focuses on the specific code modifications required to migrate your existing dApp.
34+
This enables a seamless migration path for projects looking to leverage the speed, decentralization, and cost-effectiveness of Flare's native oracle.
35+
This guide focuses on the specific code modifications required to migrate your existing dApp.
3336

3437
All code examples can be found in our [hardhat-starter-kit](https://github.com/flare-network/hardhat-starter-kit/tree/main/contracts/adapters).
3538

3639
## Migrating Your dApp: Key Code Changes
3740

38-
Migrating from an external oracle to Flare's FTSO adapter involves a paradigm shift: instead of your contract calling an external oracle for data, your contract becomes its own oracle by integrating an adapter library. This process involves two key areas of change: on-chain contract modifications and a new off-chain keeper process.
41+
Migrating to a Flare FTSO adapter requires a different approach to handling oracle data. Instead of your contract calling an external oracle, it will now manage price data internally by using an adapter library.
42+
This process involves two main changes: modifying your smart contract and setting up a new off-chain keeper process.
3943

4044
### 1. On-Chain: Integrate the Adapter Library
4145

42-
The core of the migration happens within your smart contract. You will modify it to store, update, and serve the FTSO price data itself.
46+
The main changes happen within your smart contract. You will modify it to store, update, and serve the FTSO price data itself.
4347

44-
- **State Variables**: Instead of storing an address to an external oracle proxy, you add state variables to your contract to manage the FTSO feed and cache the price data.
48+
- **State Variables**: Instead of storing an address to an external oracle, you add state variables to your contract to manage the FTSO feed and cache the price data.
4549
- **Before**: `AggregatorV3Interface internal dataFeed;`
4650
- **After**: `bytes21 public immutable ftsoFeedId; FtsoChainlinkAdapterLibrary.Round private _latestPriceData;`
4751

48-
- **Constructor**: Your constructor no longer needs a proxy address. Instead, it takes FTSO-specific configuration, such as the `ftsoFeedId` and any adapter-specific parameters (like `chainlinkDecimals`).
52+
- **Constructor**: Your constructor no longer needs an oracle's address. Instead, it takes FTSO-specific information, such as the `ftsoFeedId` and any other parameters the adapter needs (like `chainlinkDecimals`).
4953
- **Before**: `constructor(address _dataFeedAddress) { dataFeed = AggregatorV3Interface(_dataFeedAddress); }`
5054
- **After**: `constructor(bytes21 _ftsoFeedId, uint8 _chainlinkDecimals) { ftsoFeedId = _ftsoFeedId; chainlinkDecimals = _chainlinkDecimals; }`
5155

52-
- **Implement `refresh()`**: You must add a public `refresh()` function. This function's only job is to call the adapter library's `refresh` logic, passing in your contract's state variables to be updated with the latest FTSO price.
56+
- **Implement `refresh()`**: You must add a public `refresh()` function. This function's only job is to call the adapter library's `refresh` logic, which updates your contract's state variables with the latest FTSO price.
5357

54-
- **Implement the Oracle Interface**: You then implement the standard `view` function for the oracle you are migrating from (e.g., `latestRoundData()` for Chainlink, `getPriceNoOlderThan()` for Pyth). This function calls the corresponding logic from the adapter library, reading directly from your contract's cached state.
58+
- **Implement the Oracle Interface**: You then add the standard `view` function for the oracle you are migrating from (e.g., `latestRoundData()` for Chainlink).
59+
This function calls the corresponding logic from the adapter library, reading directly from your contract's cached state.
5560

56-
- **No Change to Core Logic**: Crucially, your dApp's internal business logic, which consumes the price data, remains unchanged. It continues to call the same standard oracle functions as before (e.g., `latestRoundData()`), but now it's calling a function implemented directly on your own contract.
61+
- **No Change to Core Logic**: Your dApp's internal logic that uses the price data remains unchanged.
62+
It continues to call the same standard oracle functions as before (e.g., `latestRoundData()`), but now it's calling a function implemented directly within your own contract.
5763

5864
### 2. Off-Chain: Set Up a Keeper Bot
5965

60-
Since your contract now controls its own price updates, you need an external process to trigger them.
66+
Since your contract now manages its own price updates, you need an external process to trigger them.
6167

6268
- **Create a Keeper Script**: This is a simple script that connects to the network and periodically calls the public `refresh()` function on your deployed contract.
63-
- **Run the Keeper**: This script ensures the cached price in your contract remains fresh and doesn't become stale. It replaces the need to rely on the oracle provider's keeper network, giving you direct control over the frequency—and therefore the cost—of your price updates.
69+
- **Run the Keeper**: This script ensures the price cached in your contract stays fresh. It replaces the need to rely on the oracle provider's keepers, giving you direct control over how often your prices are updated and how much you spend on gas.
6470

6571
<Tabs block>
6672
<TabItem value="chainlink" label="Chainlink">

0 commit comments

Comments
 (0)