Skip to content
Developers

Integrate Prevu in one address

Each stock has a Prevu feed that implements Chainlink's AggregatorV3Interface. While the market is open it passes the official price through. While it is closed it returns Prevu's safe value, the lower edge of its band. When it can't give a safe answer it reverts, so your app pauses instead of lending against a stale price.

D.01 Quick start

Read it like any Chainlink feed

import {AggregatorV3Interface} from "chainlink/AggregatorV3Interface.sol";

contract MyLender {
    AggregatorV3Interface public immutable mstrPrice;   // Prevu MSTR lower-band feed

    constructor(AggregatorV3Interface feed) { mstrPrice = feed; }

    function collateralPrice() public view returns (uint256) {
        // Reverts with NoFreshEstimate, ScheduleExpired or OfficialNotResumed when no safe price exists.
        (, int256 answer,, uint256 updatedAt,) = mstrPrice.latestRoundData();
        require(answer > 0 && block.timestamp - updatedAt <= 26 hours, "stale");
        return uint256(answer); // 8 decimals, like the official feed
    }
}

The same read from TypeScript with viem:

import { createPublicClient, http, parseAbi } from "viem";
import { baseSepolia } from "viem/chains";

const client = createPublicClient({ chain: baseSepolia, transport: http() });
const [, answer, , updatedAt] = await client.readContract({
  address: "0xa87daA247F6E21D5F182DD0f3e969b82Ad686Ef5", // MSTR, lower band
  abi: parseAbi(["function latestRoundData() view returns (uint80, int256, uint256, uint256, uint80)"]),
  functionName: "latestRoundData",
});
console.log(Number(answer) / 1e8, new Date(Number(updatedAt) * 1000));
D.02 Behaviour

What the feed returns, and when it refuses

SituationlatestRoundData returns
Market open, official feed has posted since the last reopenThe official round, unchanged
Market closed, Prevu estimate from this closure, at most 3 hours oldPrevu's lower band (or fair value, on the fair feed); the round id has the top bit set
Market closed, no fresh estimateReverts: NoFreshEstimate
Market open, official feed hasn't posted since the reopen (5 minute grace)Reverts: OfficialNotResumed
The on-chain calendar reaches less than 7 days aheadReverts: ScheduleExpired
Who decides “closed”The oracle holds the NYSE calendar of closures on-chain, so a publisher outage can't make a closed market look open, or the reverse.
Lower or fairUse the lower-band feed to value collateral: it is below the reopen about 95% of the time. The fair-value feed suits display and accounting.
LiquidationsThe safe value is low on purpose, so a vault that liquidates on it will close some loans the reopen would have left healthy. Use it to cap new borrowing; for liquidations, consider a wider margin on weekends, or the fair-value feed together with a check that the two feeds aren't far apart.
Decimals8, the same as the official stock feeds. Values are total-return, like the official feeds.
Full estimateFor the fair value, both band edges, the regime and the official feed's staleness in one call, read the oracle's latest function with the token address.
HistoryEvery Prevu round stays readable through getRoundData and the oracle's estimate function, so a liquidation can be audited later.
D.03 Addresses

Base Sepolia (chain 84532)

Testnet deployment. The tokens are test stand-ins; the official feeds replay Base mainnet's Chainlink rounds with their original values and times.

StockPrevu lower bandPrevu fair valueOfficial (replay)Test token
AAPLApple0x11156fb18DcA564d9961E4bf14e4ca920eB73DE20xeF479e2C7028bDf7e6aa3409e1Fa28e1d32E717f0x31B0A2e7911b54984AfaCEee1340451668D7AC100x14B3E475DCE52A56724f11C4492C2E5b07680464
AMZNAmazon0x6f0CAC4F91766d52452E0034Cf550189fCD621eD0x6080Ebe5Ad751aD6c1e675CC23Aa406E2029eA540xb96ebbA090C21fB9292ef2D7A7ED147343BF2EE60x209B29826614A2f2d4A75f29F16B4C420803713A
GOOGLAlphabet0x36C3c1153c53Cf6fa1391244c9F3e039D0b192600xd608296d7459bd20322f2fD6274Ff81C8dd7D0230x5D13d1423FBdd7f8Ebd241B8F3b57129e2e01ae60x387DED1bD3D91646f8Cc49Fbe9f8D4e78eeEB00f
METAMeta Platforms0xE9403943E921D321e0E40bF06928024a7933f4fc0x2eF005D3CCB6eEc18EC6C7d79cb4E6f8B9228a340x700A50Ca5fF8aF9a3e64A4fA7D6F57a512Ce33A20x484850aDeB986385b6510d9dB27d6C063893C2FE
MSFTMicrosoft0xe3E51038724a454F0D7d9F6a4C8A51b66594969B0xA6dE626D9d6b80bbd637fB232C883e97FAaC5FCF0x15393a7Eb1Dac8c3739d7a84A94F312A081860Ee0xaA9E9CA6680C3D17a36682bf56efB734B730e2e6
MSTRStrategy0xa87daA247F6E21D5F182DD0f3e969b82Ad686Ef50x481a964caCf31Ba0D55D144A847153f2DCB8A4060x9f400ab50C38Cb96a17cFBf1f17e6d98707af5480xD5DF01736c65fEac7de84B7E015f6cD14926360a
NVDANVIDIA0x5DBF66ec1823d9230C7C25eBf9952B5c04e2D6410x659f3B308be3f686aB2625E3820f1650626BB4120x93E9a577DCD4C2AD28FC65337507BDAB9B32045e0xe7cD7631706e23Ed06e01BB2968731C594A63c2a
SNDKSandisk0xbBf2010D0986902b93c83adA2F952e802dDd1af40x3a918658E83f907bAcEADeB8244b56b8c6c3748c0x38a20ED920aCC90bb85dE6E45eEa68800BB4D07D0xfa493958a45100aD9a7B4d10CfbC3ccFDd9512BD
SPCXSpaceX0x124d1d32E950f556aA8e9F61C52fa628Db2BFFBd0x751A5E38C3B649E4D3AFc338c96E908358AdF6C00xb9F44b1D0b92f5343AAaac8f3e47d6ac82c35C300x1598efFB2D9a04a3E23F4B09F1c9C6A6B6BAFcA6
TSLATesla0x8ea45Bf8B0C9A69B3e30353dEEC8B7C568eeFeBd0x75dF90495025B2E8C7127D7314118AaC187306fA0xbC54E43AB78E4b9D489342359a411a6585773Bb10x74e30043d909C125B614331bEB6807d8eF06D8cc
D.04 The repository

Contracts, estimator, publisher, this site

contractsSolidity and Foundry: the oracle, the feed adapter, the demo vault, with unit and fuzz tests at full line coverage.
estimatorTypeScript: data capture, the model, the backtest, the lender analysis and the publisher.
siteThis Next.js site. It reads the chain from your browser; no backend.
pnpm install
pnpm contracts:setup && pnpm contracts:test   # Solidity tests
pnpm test                                     # estimator tests
pnpm --filter @prevu/site dev                 # this site on localhost:3000