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
| Situation | latestRoundData returns |
|---|---|
| Market open, official feed has posted since the last reopen | The official round, unchanged |
| Market closed, Prevu estimate from this closure, at most 3 hours old | Prevu's lower band (or fair value, on the fair feed); the round id has the top bit set |
| Market closed, no fresh estimate | Reverts: 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 ahead | Reverts: 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.
Prevu oracle0x3d0D3348f77D1572F5b09b5f601a03E56B659D41
Demo vault, official feed0x355CEaC2807af299ad9bd1C0cadC0c8279B13B92
Demo vault, Prevu feed0xA0c521f5Eb97F98d3d57F008B74bC65Dc4c5EF11
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