RedstonePullAdapter

A contract implementing PullAdapter that integrates with redstone pull model oracle.

In previous versions, AspisLiquidityCalculatorV2 implemented this pull model oracle. Now, we have separated the redstone-specific logic into this dedicated adapter.

For detailed implementation information, refer to the redstone documentation:

https://docs.redstone.finance/docs/dapps/redstone-pull/

Configuring Token Price Feeds:

Each token must be configured with a DataFeed object:

 struct DataFeed {
            bytes32 redstoneFeedId;
            uint8 quoteDecimals;
     }

The quoteDecimals represents the token’s decimal places, and redstoneFeedId is the hash of the corresponding Redstone feed for this token.

To configure a DataFeed for a token we use updatePriceFeeds function (limited to Guardian)

    function updatePriceFeeds(
    address[] calldata _tokens,
    DataFeed[] calldata _dataFeeds) external onlyGuardian {}

The function iterates through all tokens and their tokenToDataFeed mappings. It performs basic verification to ensure that redstoneFeedId is not zero bytes and quoteDecimals is greater than 0.

The function emits an event to notify off-chain services of the changes:

event DataFeedUpdated(address _token, bytes32 _feedId);

You can also use removePriceFeeds to delete a token’s assigned DataFeed:

function removePriceFeeds(address[] calldata _tokens) external onlyGuardian {}

Fetching the price of a token in USD:

The getPrice function retrieves a token’s price using its redstoneFeedId and redstone payload. The payload verifies the price’s integrity: