Skip to main content

Oracle Price Feed

Limora uses decentralized oracle price feeds to determine accurate market prices for opening, closing, and liquidating positions. This page explains how the oracle system works.

Overview

Unlike order-book based exchanges where prices are determined by matching bids and asks, Limora uses oracle-based pricing. This approach offers several advantages:

No Slippage

Trades execute at the oracle price, regardless of position size.

Manipulation Resistant

Prices are aggregated from multiple sources, making manipulation difficult.

Consistent Execution

All trades in a block get the same price, ensuring fairness.

Transparent

Oracle prices are on-chain and independently verifiable.

Price Sources

Limora aggregates prices from multiple reputable sources:
  • Chainlink: Industry-leading decentralized oracle network
  • Pyth Network: High-frequency price feeds from major exchanges
  • Band Protocol: Cross-chain oracle solution
The protocol uses a median price from these sources to mitigate the impact of any single source being manipulated or experiencing issues.

Price Feed Architecture


Supported Price Feeds

AssetSymbolUpdate FrequencyDeviation Threshold
BitcoinBTC/USD1 second0.1%
EthereumETH/USD1 second0.1%
SolanaSOL/USD1 second0.25%
ArbitrumARB/USD10 seconds0.5%
OptimismOP/USD10 seconds0.5%
Price feeds are continuously updated. The table above shows typical parameters which may be adjusted based on market conditions.

Price Calculation

Entry Price

When opening a position, the entry price is determined by:
  1. Fetching the latest oracle price at transaction execution
  2. Applying any applicable spread (typically 0%)
  3. Recording the price in the position data

Mark Price

The mark price used for P&L calculation and liquidations:
Mark Price = Oracle Price
For most trading pairs, the mark price equals the oracle price directly. For some pairs, a time-weighted average price (TWAP) may be used to smooth volatility.

Settlement Price

When closing a position, the settlement price is:
  1. The oracle price at the time of the close transaction
  2. Used to calculate final P&L
  3. Determines fund distribution between trader and matcher

Staleness Protection

To protect against stale or outdated prices, the protocol implements staleness checks:
require(
    block.timestamp - priceTimestamp < MAX_PRICE_AGE,
    "Price feed is stale"
);
ParameterValueDescription
MAX_PRICE_AGE60 secondsMaximum age of price data
HEARTBEAT10 secondsExpected update frequency
If a price feed becomes stale:
  1. New positions cannot be opened for that pair
  2. Existing positions continue using the last valid price
  3. Alerts are triggered for protocol operators

Deviation Protection

The protocol monitors for unusual price deviations:
require(
    abs(newPrice - lastPrice) / lastPrice < MAX_DEVIATION,
    "Price deviation too large"
);
This prevents extreme price swings from triggering mass liquidations due to oracle errors.

Price Updates and Gas

Oracle price updates are performed by dedicated keeper networks that:
  • Monitor off-chain price sources
  • Submit on-chain updates when thresholds are met
  • Pay gas costs for update transactions
Users do not need to pay for oracle updates; these costs are covered by the protocol.

Liquidation Pricing

Liquidations use a specific pricing mechanism to ensure fairness:
  1. Trigger Check: Position checked against current oracle price
  2. Grace Period: Brief window before execution (configurable)
  3. Execution Price: Oracle price at liquidation transaction
This prevents front-running of liquidations and ensures traders have fair opportunity to add margin.

Oracle Governance

Oracle configuration is managed through protocol governance:
  • Adding new price feeds requires governance approval
  • Changing deviation thresholds requires governance approval
  • Emergency pauses can be triggered by the security council

Monitoring and Transparency

On-Chain Data

All oracle prices are recorded on-chain and can be verified:
// Query current price
function getPrice(address asset) external view returns (
    uint256 price,
    uint256 timestamp,
    uint8 decimals
);

// Query historical price
function getHistoricalPrice(address asset, uint256 timestamp)
    external view returns (uint256 price);

Price Dashboard

Monitor current and historical prices at:
  • On-chain: Contract read functions
  • API: /api/prices endpoint
  • UI: Price charts on the trading interface

Limitations

Known Limitations

  1. Update Latency: Oracle prices may lag spot prices by 1-10 seconds
  2. Weekend Gaps: Some assets may have reduced update frequency during low-volume periods
  3. Network Congestion: Base network congestion may delay price updates

Best Practices

  • Use stop-loss orders to limit downside risk
  • Avoid extremely high leverage during volatile periods
  • Monitor positions actively during major market events

Technical Integration

For developers integrating with Limora’s oracle system:
import { LimoraOracle } from '@limora/sdk'

const oracle = new LimoraOracle({
  provider: ethersProvider,
  network: 'base-mainnet',
})

// Get current price
const btcPrice = await oracle.getPrice('BTC')
console.log(`BTC Price: $${btcPrice.toFixed(2)}`)

// Subscribe to price updates
oracle.subscribe('ETH', (price, timestamp) => {
  console.log(`ETH: $${price} at ${timestamp}`)
})