Squidlor
Loading docs

Taking longer than usual. Check your connection, or reload the page.

Read prices on-chain

Production-ready patterns for consuming Squidlor feeds from Solidity, including what updatedAt means on an aggregator.

Squidlor aggregators implement Chainlink's AggregatorV3Interface, so a migration is one address change. Getting it right takes a little more care, and this page is about the parts that are easy to get wrong.

The interface

Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IAggregatorV3 {
    function decimals() external view returns (uint8);
    function description() external view returns (string memory);
    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
    function getRoundData(uint80 roundId)
        external
        view
        returns (uint80, int256, uint256, uint256, uint80);
}

/// Squidlor's richer read: price plus the health data behind it.
interface ISquidlorAggregator is IAggregatorV3 {
    function peek()
        external
        view
        returns (
            int256 answerValue,
            uint256 freshestUpdatedAt,
            uint256 healthyCount
        );
    function sourceCount() external view returns (uint256);
    function poke() external returns (uint80 roundId, int256 answer);
}

updatedAt on an aggregator

On a Squidlor aggregator, latestRoundData().updatedAt is the publish time of the freshest healthy source, not the time of your read. A standard Chainlink staleness check works as written:

Solidity
(, int256 answer, , uint256 updatedAt, ) = aggregator.latestRoundData();
require(block.timestamp - updatedAt <= maxAge, "stale price");

Two more guarantees hold on every read:

  • It reverts instead of serving a stale price. When fewer than minHealthySources sources are fresh, latestRoundData() reverts with InsufficientHealthySources, exactly like peek().
  • It always follows the newest data. A round committed with poke() is returned only while it is still the freshest publish. After the next publish, latestRoundData() returns the live aggregate as provisional round latestRoundId() + 1, the id the next poke() would commit it under.

Warning

Aggregators deployed before 2026-09-24 behave differently: until a round is committed they stamp updatedAt with block.timestamp, so a staleness check against it always passes. Every current address on networks & addresses has the new behaviour. If you hardcoded an older address, move to the current one, or read peek().

peek() gives you the source count too

peek() returns the same publish time plus the number of healthy sources, so you can demand more than one when a feed has them:

Solidity
(int256 answer, uint256 freshestUpdatedAt, uint256 healthyCount) = aggregator.peek();

require(answer > 0, "invalid price");
require(block.timestamp - freshestUpdatedAt <= maxAge, "stale price");
require(healthyCount >= minSources, "insufficient sources");
Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface ISquidlorAggregator {
    function decimals() external view returns (uint8);
    function peek()
        external
        view
        returns (int256 answerValue, uint256 freshestUpdatedAt, uint256 healthyCount);
}

/// @notice Reads a Squidlor feed with explicit freshness and source-agreement bounds.
contract SquidlorPriceReader {
    ISquidlorAggregator public immutable aggregator;

    /// Maximum acceptable data age. Set per asset class, since crypto and equities
    /// have very different natural cadences.
    uint256 public immutable maxAge;

    /// Minimum sources that must agree. The aggregator's own floor is 1, which
    /// is chosen for availability; a protocol with real money at risk should
    /// insist on more where the feed has more.
    uint256 public immutable minHealthySources;

    error InvalidPrice(int256 answer);
    error StalePrice(uint256 updatedAt, uint256 age);
    error InsufficientSources(uint256 healthyCount, uint256 required);

    constructor(address aggregator_, uint256 maxAge_, uint256 minHealthySources_) {
        aggregator = ISquidlorAggregator(aggregator_);
        maxAge = maxAge_;
        minHealthySources = minHealthySources_;
    }

    /// @return price 8-decimal price
    /// @return updatedAt freshest source timestamp behind that price
    function readPrice() public view returns (uint256 price, uint256 updatedAt) {
        (int256 answer, uint256 freshestUpdatedAt, uint256 healthyCount) =
            aggregator.peek();

        if (answer <= 0) revert InvalidPrice(answer);
        if (healthyCount < minHealthySources) {
            revert InsufficientSources(healthyCount, minHealthySources);
        }

        // Guard against a source timestamped slightly ahead of this block;
        // the adapter tolerates up to a minute of clock drift, and unsigned
        // subtraction would underflow into an enormous "age".
        uint256 age = block.timestamp > freshestUpdatedAt
            ? block.timestamp - freshestUpdatedAt
            : 0;
        if (age > maxAge) revert StalePrice(freshestUpdatedAt, age);

        return (uint256(answer), freshestUpdatedAt);
    }

    /// @notice Converts a token amount into its USD value, 18-decimal fixed point.
    function valueOf(uint256 amount, uint8 tokenDecimals)
        external
        view
        returns (uint256)
    {
        (uint256 price, ) = readPrice();
        uint8 priceDecimals = aggregator.decimals(); // 8 for every Squidlor feed

        // Normalize to 18 decimals in one expression to avoid intermediate
        // truncation on small amounts.
        return (amount * price * 1e18) / (10 ** tokenDecimals) / (10 ** priceDecimals);
    }
}

Choosing maxAge

There is no universal answer; it depends on the feed's cadence and on what a stale price would cost you.

Feed typeSuggested maxAgeWhy
Crypto60 minutesOn Arc the relay pushes on a 2% move or a 55-minute heartbeat, and the Squidlor leg's on-chain window is 3,600 s, so the aggregator itself refuses anything older. A bound under 57 minutes will trip on normal operation. Other chains run other cadences: see the chain's page under Networks.
Tokenized equity48–72 hoursNo updates overnight or at weekends, and on Arc there is no second leg to carry the price across the gap.
Anything liquidating positionsAs tight as the cadence allowsA stale price here costs users money.

Warning

A too-tight maxAge is its own failure mode: your protocol halts during ordinary operation. A too-loose one lets you act on a price that no longer reflects reality. Pick from the feed's actual cadence (see price feeds & assets), not from a number that feels safe.

Choosing minHealthySources

Read sourceCount() for the feed and set your floor relative to it:

FeedSourcesReasonable floor
Arc: BTC/USD, ETH/USD, SOL/USDSquidlor only, pushed every 55 minutes or on a 2% move1, and read updatedAt; move to 2 once a second source is added
Arc: NVDA, TSLA, AAPL, GOOGLSquidlor only, pushed during the US session1, and read updatedAt; peek() reverts outside the session

Important

Demanding healthyCount >= 2 on a feed with one healthy source makes it permanently unreadable, and on Arc every feed has one source today. Check sourceCount() and peek() before choosing your floor, and revisit it when a second source is wired. The price feeds page carries the table.

If you already read a Chainlink feed, the mechanical change is the address. Two things are worth doing at the same time:

Solidity
// Before
AggregatorV3Interface feed = AggregatorV3Interface(CHAINLINK_BTC_USD);
(, int256 answer, , uint256 updatedAt, ) = feed.latestRoundData();

// After: same interface, plus the health data Chainlink cannot give you
ISquidlorAggregator feed = ISquidlorAggregator(SQUIDLOR_BTC_USD);
(int256 answer, uint256 updatedAt, uint256 healthyCount) = feed.peek();

Both are 8 decimals, so no scaling changes. The upgrade is moving from latestRoundData to peek, which gets you a real timestamp and a source count.

Committing rounds

If your protocol needs a stable round ID to settle against, so you can prove which price you acted on, call poke() first:

Solidity
(uint80 roundId, int256 answer) = aggregator.poke();
// roundId is now replayable via getRoundData(roundId)

poke() is permissionless and writes state, so it costs gas. Only settlement and indexing paths generally need it.

Reading the Squidlor feed alone

To read Squidlor's own price without the cross-oracle layer, point at the pair's SquidPriceFeed. There, latestRoundData().updatedAt is the on-chain publish time of the last push. Unlike the aggregator, the proxy does not revert when the price is stale, so the updatedAt check is yours to make.

You are also giving up Layer 3 protection entirely. Do this only when you specifically want the single source.