Skip to content

Latest commit

 

History

History
217 lines (151 loc) · 4.86 KB

File metadata and controls

217 lines (151 loc) · 4.86 KB
title sidebar_position description
FtsoV2Interface
1
Primary interface for interacting with FTSOv2.

import Remix from "@site/src/components/remix"; import CodeBlock from "@theme/CodeBlock"; import FTSOV2FeedById from "!!raw-loader!/examples/developer-hub-solidity/FTSOV2FeedById.sol"; import FTSOV2FeedByIdWei from "!!raw-loader!/examples/developer-hub-solidity/FTSOV2FeedByIdWei.sol"; import FTSOV2FeedsById from "!!raw-loader!/examples/developer-hub-solidity/FTSOV2FeedsById.sol"; import FTSOV2FeedsByIdWei from "!!raw-loader!/examples/developer-hub-solidity/FTSOV2FeedsByIdWei.sol"; import FTSOV2VerifyProof from "!!raw-loader!/examples/developer-hub-solidity/FTSOV2VerifyProof.sol";

Primary interface for interacting with FTSOv2. This is a long-term support (LTS) interface, designed to ensure continuity even as underlying contracts evolve or protocols migrate to new versions.

Sourced from FtsoV2Interface.sol on GitHub.

Functions

getFeedById

Returns stored data of a feed. A fee (calculated by the FeeCalculator contract) may need to be paid.

function getFeedById(
    bytes21 _feedId
) external payable returns (
    uint256 _value,
    int8 _decimals,
    uint64 _timestamp
);

Parameters

  • _feedId: The id of the feed.

Returns

  • _value: The value for the requested feed.
  • _decimals: The decimal places for the requested feed.
  • _timestamp: The timestamp of the last update.
Sample contract usage {FTSOV2FeedById}

Open sample in Remix

getFeedByIdInWei

Returns value in wei and timestamp of a feed. A fee (calculated by the FeeCalculator contract) may need to be paid.

function getFeedByIdInWei(
    bytes21 _feedId
) external payable returns (
    uint256 _value,
    uint64 _timestamp
);

Parameters

  • _feedId: The id of the feed.

Returns

  • _value: The value for the requested feed in wei (i.e. with 18 decimal places).
  • _timestamp: The timestamp of the last update.
Sample contract usage {FTSOV2FeedByIdWei}

Open sample in Remix

getFeedsById

Returns stored data of each feed. A fee (calculated by the FeeCalculator contract) may need to be paid.

function getFeedsById(
    bytes21[] _feedIds
) external payable returns (
    uint256[] _values,
    int8[] _decimals,
    uint64 _timestamp
);

Parameters

  • _feedIds: The list of feed ids.

Returns

  • _values: The list of values for the requested feeds.
  • _decimals: The list of decimal places for the requested feeds.
  • _timestamp: The timestamp of the last update.
Sample contract usage {FTSOV2FeedsById}

Open sample in Remix

getFeedsByIdInWei

Returns value of each feed and a timestamp. For some feeds, a fee (calculated by the FeeCalculator contract) may need to be paid.

function getFeedsByIdInWei(
    bytes21[] _feedIds
) external payable returns (
    uint256[] _values,
    uint64 _timestamp
);

Parameters

  • _feedIds: Ids of the feeds.

Returns

  • _values: The list of values for the requested feeds in wei (i.e. with 18 decimal places).
  • _timestamp: The timestamp of the last update.
Sample contract usage {FTSOV2FeedsByIdWei}

Open sample in Remix

verifyFeedData

Checks if the feed data is valid (i.e. is part of the confirmed Merkle tree).

function verifyFeedData(
    struct FtsoV2Interface.FeedDataWithProof _feedData
) external view returns (
    bool
);

Parameters

  • _feedData: Structure containing data about the feed (FeedData structure) and Merkle proof.

Returns

  • _0: true if the feed data is valid.
Sample contract usage {FTSOV2VerifyProof}

Open sample in Remix

Structures

FeedData

Feed data structure

struct FeedData {
  uint32 votingRoundId;
  bytes21 id;
  int32 value;
  uint16 turnoutBIPS;
  int8 decimals;
}

FeedDataWithProof

Feed data with proof structure

struct FeedDataWithProof {
    bytes32[] proof;
    struct FtsoV2Interface.FeedData body;
}