USER DEFINED ORACLES - PROGRAMMABLE ORACLES

USER DEFINED ORACLES - PROGRAMMABLE ORACLES

Oracles play a vital role in crypto, acting as bridges connecting blockchain networks to external, real world data, since blockchains are isolated systems that cannot directly access information from the internet or other foreign sources.

Smart contracts lack the ability to fetch external information on their own and oracles solve this problem by acting as a middle man delivering data feeds (e.g. crypto prices, stock market / RWA updates, weather updates, election results etc.) making them a pivotal component for many crypto apps.

Without oracles, smart contracts would be limited to operating solely with data already stored on the blockchain, severely restricting their potential.

 

HOW ORACLES WORK

The process of an oracle delivering data to a smart contract typically follows these steps:

· Request: A smart contract requests specific data (e.g., the current price of ETH/USD).

· Data Fetching: The oracle retrieves the requested information from external sources, such as APIs, websites, or other data providers.

· Verification: In decentralized systems, the data is cross-checked across multiple sources to ensure accuracy.

· Delivery: The oracle sends the data back to the smart contract, which then uses it to execute its logic (e.g., when transferring funds or updating a state).

 

DATA DELIVERY MECHANISM – ORACLE TYPES

1. Push Oracles: actively send "push “data to the blockchain or smart contract without being asked. Always great for situations where data needs to be updated constantly, like real-time cryptocurrency price feeds (e.g. continuous update of cryptocurrency price feed on exchanges). The upside is that the data stays fresh, but the downside is that it uses up a lot of resources since it is sending updates constantly.

2. Pull Oracles: wait for smart contracts to request data. The contract "pulls" the data when it’s needed, which makes this oracle type more resource-efficient since data isn’t sent unless when requested for, for instance, a smart contract might ask for the weather data at a specific moment. The downside is that there might be a small delay in getting the data, so it’s usually better for cases where instant updates aren’t crucial e.g. (most RWA markets). 

3. Programmable Oracles: are more advanced and can run custom code or process data before delivering it. They can be programmed to trigger actions or provide specific outputs based on certain conditions, which makes them the perfect oracle type for complex smart contracts that needs more than just raw data like automated decisions or tailored responses.

SEDA’s Head of Marketing explains oracle types according to their delivery mechanism in a 97sec video here

PROGRAMMABLE ORACLES, HOW DIFFERENT ARE THEY FROM LEGACY / TRADITIONAL ORACLES?

Programmable oracles act as a middle layer between blockchain and external data sources, letting smart contracts make use of them or trigger actions based on instructions embedded in the oracle.

Unlike legacy oracles which offer limited customizability, programmable oracles are highly customizable, enabling developers to define specific computations and conditions for how data is delivered and used.

Legacy oracles, mostly one-way and with a rigid design (i.e. deliver data to smart contracts without supporting complex feedback or outputs) are less suited for modern blockchain applications like DeFi, NFTS, interops etc. while programmable oracles are best suited for handling complex and advanced use cases like DeFi computations, cross-chain data sharing, or automations running on varying conditions / requirements.

While Legacy oracles uses a one-size-fits-all approach which often rely on centralized providers creating single points vulnerability to manipulation and downtime making them unable to trigger actions and respond dynamically to smart contracts. Programmable oracles on the other hand leverages on decentralized oracle networks and uses off-chain computation taking care of centralization risks and reducing on-chain costs, making them more efficient.

Matt explains use cases we can unlock with limitless data accessibility using an Aloe Vera in a pot.

MITOSIS + PROGRAMMABLE ORACLES - POWERING DYNAMIC LIQUIDITY IN DEFI

Mitosis’s programmable liquidity model relies on real-time data to make informed decisions about where, when, and how liquidity moves across chains. For example, to auto-rebalance collateral across chains or allocate liquidity to high-yield opportunities, Mitosis requires accurate and timely data on market conditions, asset prices, or protocol states.

Programmable oracles provide this capability by fetching and processing external data (e.g., cross-chain TVL, yield rates) and delivering it to Mitosis’s smart contracts. For instance, an oracle could compute the optimal chain for liquidity deployment based on yield data and feed this to Mitosis’s liquidity vaults.

Consider a Mitosis-powered lending protocol that auto-rebalances collateral across Ethereum and Morse based on yield opportunities:
A programmable oracle fetches yield data from both assets, aggregates it, and applies custom logic to determine the optimal chain for collateral deployment (e.g., Ethereum for stable yields, Morse for high-risk/high-reward opportunities).


The oracle delivers this processed data to Mitosis’s smart contracts, which mint Vanilla Assets (e.g., vETH) and allocate them to the chosen chain’s liquidity pool.
Users receive miAssets for governance and yield, with the entire process automated and trustless thanks to the oracle’s secure data delivery and Mitosis’s programmable infrastructure.

Setting Up A Programmable Oracle : Practical Example

A user building a decentralized insurance smart contract that pays out if a flight is delayed could define an oracle as follows:

  • Data Source: Fetch flight status from two APIs (e.g., FlightAware and a proprietary airline API).
  • Logic: Compare the delay times, discard outliers, and calculate the average delay. Only report if the delay exceeds 2 hours.
  • Delivery: Submit the result to the smart contract on Ethereum, triggering a payout if conditions are met.

    Using a programmable oracle function, the user might write:
const flightRequest1 = Functions.makeHttpRequest({ url: "https://flightaware.com/api/flight" });
const flightRequest2 = Functions.makeHttpRequest({ url: "https://airline.com/api/flight" });

const [response1, response2] = await Promise.all([flightRequest1, flightRequest2]);
const delay1 = response1.data.delayMinutes;
const delay2 = response2.data.delayMinutes;

const averageDelay = (delay1 + delay2) / 2;
const isDelayed = averageDelay > 120 ? 1 : 0; // 1 if delayed > 2 hours, else 0
return Functions.encodeUint256(isDelayed);

LEGACY & PROGRAMMABLE ORACLES: KEY DIFFERENCES

 

ASPECT

LEGACY ORACLE

PROGRAMMABLE ORACLE

Data source

Single API / limited sources

Multiple sources (e.g. exchanges)

Logic

None; delivers raw data

Custom (e.g. median, outlier removal)

Reliability

Vulnerable to source errors

Robust via aggregation and consensus

Decentralization

Often centralized

Typically decentralized (e.g. SEDA protocol)

Use case fit

Simple, low stakes apps

Complex DeFi protocols

Example Output

$2000 (raw, unverified)

$2002.5 (median, unverified)

 

CONCLUSION

User-defined oracles empower users to tailor programmable oracles to their specific needs, offering flexibility in data sourcing and processing logic.

Programmable oracles represent an important step when bridging the gap between blockchain ecosystems and real-world data, enabling smart contracts to execute with flexibility and reliability. These oracles facilitate complex off-chain computations, multi-source data aggregation, and conditional data delivery.

Programmability ensures that smart contracts can respond dynamically to external events, from DeFi price feeds to IoT-driven insurance payouts, while maintaining the security and decentralization ethos of blockchain systems.

However, challenges such as oracle centralization risks, data integrity, and gas cost optimization remain critical areas for ongoing innovation. As the ecosystem evolves, integrating cryptographic proofs (e.g., zero-knowledge proofs) and decentralized oracle networks (DONs) will further enhance trust and scalability, solidifying programmable oracles as a cornerstone of Web3 infrastructure.

About Mitosis
X
Discord
Mitosis App
Mitosis Docs