Custom Oracle Development
Chainlink and Pyth cover 95% of price data needs. But cases exist where ready solution doesn't fit: specific illiquid asset without coverage, non-standard data type, minimal third-party trust requirement, or specific aggregation need. Then custom oracle developed.
When Custom Oracle Needed
- Illiquid or niche asset: Chainlink won't add feed for $1M TVL token
- Off-chain data: sports results, weather, insurance indexes — specific
- Private data: corporate metrics, TradFi data with licensing restrictions
- Special aggregation: median from specific sources, VWAP for custom period
- On-chain data with verification: data from other chain via ZK proofs
Custom Oracle Architecture
Components
External Data Sources
↓ (HTTP/WebSocket)
Oracle Node Network
├── Node 1 (fetches, signs, submits)
├── Node 2 (fetches, signs, submits)
└── Node N (fetches, signs, submits)
↓ (signed reports)
On-chain Aggregator Contract
├── Collect reports
├── Verify signatures
├── Aggregate (median/TWAP)
└── Publish result
On-chain Aggregator
contract CustomOracle {
struct Report {
uint256 value;
uint256 timestamp;
bytes signature;
}
mapping(address => bool) public trustedNodes;
uint256 public requiredReports;
function submitReport(uint256 value, uint256 timestamp, bytes calldata sig) external {
require(trustedNodes[msg.sender], "Not trusted node");
// Verify signature
bytes32 messageHash = keccak256(abi.encodePacked(value, timestamp));
address signer = recoverSigner(messageHash, sig);
require(signer == msg.sender, "Invalid signature");
_pendingReports[roundId][msg.sender] = Report(value, timestamp, sig);
if (_pendingReportCount[roundId] >= requiredReports) {
_finalizeRound(roundId);
}
}
}
Oracle Node
Off-chain node periodically:
- Fetches data from sources
- Aggregates (median, weighted average)
- Signs ECDSA
- Submits transaction to aggregator
Verifiable Oracle with ZK Proofs
For high trustlessness — ZK-based oracle. Node provides ZK proof that data correctly obtained and aggregated.
On practice experimental and computationally expensive — but developing direction.
Oracle Manipulation Protection
Flash loan + manipulation: attacker takes flash loan, moves price on DEX, exploits protocol at manipulated price.
Protections:
- TWAP instead of spot: Time-Weighted Average Price harder to manipulate
- Multiple sources: median from several exchanges
- Circuit breakers: reject when deviation > X%
- Volume-weighted: ignore sources with anomalously low volume
Development of custom oracle: 4-12 weeks depending on sources, networks and trustlessness requirements.







