How DeFi Saver knows price changes before you do — a quick look at Maker’s new price oracles

If you’re a DeFi Saver user, you probably noticed a recent addition to our MakerDAO dashboard labelled Next price.

How DeFi Saver knows price changes before you do — a quick look at Maker’s new price oracles

If you’re a DeFi Saver user, you probably noticed a recent addition to our MakerDAO dashboard labelled Next price which displays the upcoming, future collateral price in Maker’s Multi-Collateral Dai protocol. But how can we know what the future price in the protocol will be, what sort of magic is involved and what will be the price of Ether in 2022? Stick with us through this post and we’ll answer at least 2 of those questions.

With the new MCD version of the Maker protocol came multiple enhancements (most of which we already talked about here) and one of those is the new price oracles system. The updated oracles bring numerous changes to the table. First of all, compared to the previous system, the new system uses a lot less gas to operate, which was a necessary improvement in order to support multiple price updates for different collaterals in MCD.

The second important change users need to be aware of is the 1 hour delay between price updates, set in place in order to protect the system from any malicious attempts to feed wrong prices into the protocol. The price smart contract stores the current collateral price and updates it only after an hour has passed since the previous update. The periods between updates usually end up being a bit over an hour, though, depending on how long it takes the bot to send the transaction calling for an update and the actual transaction to go through. But this is the Next price information you can now see in our dashboard, meaning that even before the price is entered into the system, you’ll know what it will be and can react to the change in time if needed.

Please note that the prices displayed are not market prices, as we unfortunately cannot predict those. These are just the prices in the MakerDAO MCD protocol. But we believe this is still useful, as you can now see the next price and, for example, repay your debt before liquidation happens. Or you can have your CDP protected against liquidation with our CDP Automation😉.

The techy details

If you’re a technical person who likes 3 letter variables that don’t make much sense, proceed reading this next part where we explain how the new system works in more detail.

A great part of the new Oracles system’s work is actually done off-chain. Before any price update reaches the Ethereum blockchain, trusted entities will submit price updates, not directly to the blockchain, but rather through Scuttlebut. Scuttle…what? You heard it right — Scuttlebut, a p2p decentralized gossip network which is in this case used to gossip about new prices of crypto.

Once the prices are gathered from the entities, they are sorted in an array and sent to the Median contract. The poke() method is then called and the prices are signed by a trusted party and an on-chain check is performed for whether the signature is correct. If correct, a median value is selected from the array and that becomes the new price in the Median contract.

Some of the first organizations that provide price updates for MCD.

However, as we mentioned before, there is a 1-hour delay between price updates and the new price from the Median contract does not enter the Maker protocol right away. The OSM (short for Oracle Security Module) is called by outside bots to fetch the price from the Median contract. The poke() function is then called, no less than an hour since the last time, and it fetches the most recent price in the Median contract, but it doesn’t propagate that value to the Maker protocol just yet.

The Oracle Security Module has 2 important variables - ‘cur’ and ‘nxt’ and when the poke() function is called the new price value is set in the ‘nxt’ variable, while the ‘cur’ is set to the previous ‘nxt’ value. Effectively, this means that the price which was current an hour earlier now gets fed into the system and the new next price is stored to be introduced after another hour passes.

The core Maker protocol fetches the price from the OSM, where the Spot contract is responsible for fetching the price. Once again, you poke() the Spot for it to fetch the price from the OSM. And do note that every collateral type that needs price updates has their own, separate Median and OSM contracts.


If you’re interested in seeing all of this in action, you can follow the MegaPoker contract, which in fact has nothing to do with the game of poker, but rather serves to poke() around. MegaPoker ensures that the OSM contract’s poke() method is called when needed and that the other protocol’s contracts are up to date with it.

You can also see that one of those contracts is the ETH OSM contract which handles the ETH price in the Maker protocol. And one step before it is the Median ETH contract, which is periodically updated with the array of prices from the trusted oracle sources, where a median value is calculated and that’s the value the OSM contract is fetching.

This is the magic behind DeFi Saver knowing what the next price in the Maker protocol will be. Hope you find the addition useful! We think it’s quite handy as it allows people to respond to incoming price changes in a timely fashion. If you don’t have CDP Automation already enabled, that is.

If you like these kinds of short dissections of bits and pieces of DeFi, make sure to click the follow button and feel free to connect via Twitter or join our Discord. See you soon for more updates!

Stay connected:
💬: Official Discord
📢: Official Twitter account