Protocol
Oracles and pricing
Where prices come from, how the contract defends against a bad price, and what is coming for tokens on other chains.
NEAR pools: read on-chain
For a token on NEAR, the contract reads the price itself. refresh_price calls the DEX pool, and the callback computes the price from the pool's reserves and stores it as an observation. No off-chain party can supply or alter this price. Anyone can call refresh_price; the keeper does it every few seconds.
Defences against a bad price
| Defence | How it works |
|---|---|
| Smoothing | The mark follows an exponential moving average of pool reads, not a single read. |
| Price band | A read more than 20% away from the average is rejected, and the market drops to reduce-only. |
| Staircase | The engine price walks toward the target by at most 10 bps per block on majors and 30 bps on long-tail markets. It never jumps. |
| Depth check | A market only activates if its source pool is deep enough. |
| Two-step fills | An order can only fill on a price observed after it was requested. |
| Ordering | Observations must be strictly newer than the last one. |
When the price is old
| Price age | Effect |
|---|---|
under 10 s | Normal trading. |
10 s or more | Only orders that reduce a position fill. |
1 h or more | No fills and no liquidations until a fresh price arrives. |
The contract never invents a fallback price.
Price sources on testnet today
| Market | Source |
|---|---|
NEAR-PERP | Pushed by the Neap oracle account from public exchange prices. This is a transitional feed for the demo. |
TIDE-PERP | Read on-chain from Ref pool 2962 on ref-finance-101.testnet. |
| Markets you create | Read on-chain from the pool you name. |
Roadmap: tokens on other chains
NEAR cannot read a Solana pool directly. The next phase adds an oracle agent that runs inside a trusted execution environment (TEE), reads the Solana pool, and signs the price. The contract verifies the signature against keys registered on-chain before it accepts the price.
The same phase lets Solana users deposit, trade and withdraw from a Solana wallet through NEAR Intents. Funds arrive as USDC on NEAR. This is not live yet. The Solana page in the app previews the tokens.
