Chainlink CRE — VWAP RFQ Spot
A settlement-grade 12h VWAP oracle for delayed RFQ spot trading, built on Chainlink CRE.
flowchart TB
Maker(["Maker"]) -- "Sign order via<br>EIP-712<br>off-chain" --> OB["Backend: Orderbook<br>"]
OB -- Maker cancels --> Cancel["Maker calls<br>cancelOrderHash<br>Order marked as used, cannot be<br>filled"]
OB -- Taker accepts order --> Taker(["Taker"])
Taker -- Fill order, signature,<br>takerAmountIn --> Contract["VWAPRFQSpot Contract<br>Verify signature<br>Lock maker + taker funds<br>Emit Filled event"]
Contract --> Cron["Backend: <br>hourly cron job<br>Scan for expired orders"]
Cron -- POST /settle --> Settler["CRE Settler"]
Settler --> Binance["Binance"] & OKX["OKX"] & Bybit["Bybit"] & Coinbase["Coinbase"] & Bitget["Bitget"]
Binance --> Report["VWAP Price calculation:<br>Filter outliers → Median<br>Build rawReport<br>MockKeystoneForwarder.report"]
OKX --> Report
Bybit --> Report
Coinbase --> Report
Bitget --> Report
Report --> OnChain["Forwarder:<br>Call VWAPOracle.onReport<br>to stores price"]
OnChain -- <br> --> Settle@{ label: "Anyone calls<br>VWAPRFQSpot.settle" }
Settle -- No one settles<br>Grace period<br>expired --> Refund("Maker / Taker<br>reclaim original deposits")
Settle --> n1@{ label: "Calculate settlement price with base point." }
n1 -- Success --> Payout("Maker / Taker<br>receive funds")
Settle@{ shape: diamond}
n1@{ shape: rect}
Loading
.
├── vwap-eth-quote-flow/ # CRE Workflow (Go) — VWAP computation + on-chain write
│ ├── workflow.go # Main workflow logic
│ ├── workflow_test.go # Unit tests
│ ├── config.staging.json # Staging config (oracle address, circuit breaker params)
│ └── workflow.yaml # CRE CLI target settings
├── contracts/evm/ # Solidity contracts
│ ├── src/
│ │ ├── VWAPRFQSpot.sol # Main exchange: fill / settle / refund
│ │ ├── ChainlinkVWAPAdapter.sol # Production oracle (CRE Forwarder + IReceiver)
│ │ ├── ManualVWAPOracle.sol # Staging oracle (onReport + setPrice backdoor)
│ │ └── IVWAPOracle.sol # Oracle interface
│ └── deploy.sh # Deploy script (ORACLE_MODE=manual|chainlink)
├── cmd/
│ ├── trigger/ # Signs and sends HTTP POST to CRE DON endpoint
│ └── server/ # Settler HTTP server (POST /settle, GET /health)
├── scripts/ # simulate.sh, simulate-and-forward.sh, demo-vtn.sh
└── project.yaml # CRE CLI project settings (RPC, chain targets)
Contract
Description
VWAPRFQSpot.sol
Main RFQ exchange — fill / settle / refund
ChainlinkVWAPAdapter.sol
Production oracle — receives signed reports from CRE Forwarder via IReceiver
ManualVWAPOracle.sol
Staging oracle — accepts reports via onReport and owner setPrice backdoor
IVWAPOracle.sol
Interface shared by both oracle implementations
MockForwarder vs Production CRE
Staging (current)
Production
Oracle
ManualVWAPOracle
ChainlinkVWAPAdapter
Forwarder
MockKeystoneForwarder (Chainlink-provided)
CRE Forwarder
Signature verification
None
F+1 DON signatures
Report source
simulate-and-forward.sh
Live CRE DON
Deployed Contracts (Sepolia)
Required variables:
DEPLOYER_PRIVATE_KEY=0x... # Signs on-chain transactions
MANUAL_ORACLE_ADDRESS=0x... # ManualVWAPOracle deployed address
RPC_URL=... # Sepolia or Tenderly VTN RPC
# CRE workflow unit tests
cd vwap-eth-quote-flow && go test -v
# Solidity contract tests
cd contracts/evm && forge test
Simulate CRE Workflow (no account needed)
# Simulate past 12h window (defaults to now)
./scripts/simulate.sh
# Simulate specific end time
./scripts/simulate.sh " 2025-02-15 15:00"
Simulate + Write On-chain
# Simulate and route report through MockKeystoneForwarder → onReport()
./scripts/simulate-and-forward.sh
# With Tenderly VTN
RPC_URL=$TENDERLY_ADMIN_RPC ./scripts/simulate-and-forward.sh
cd contracts/evm
# Staging (ManualVWAPOracle + VWAPRFQSpot)
ORACLE_MODE=manual ./deploy.sh
# Production (ChainlinkVWAPAdapter + VWAPRFQSpot)
ORACLE_MODE=chainlink ./deploy.sh
cast call $MANUAL_ORACLE_ADDRESS \
" getPrice(uint256,uint256)(uint256)" \
$START_TIME $END_TIME \
--rpc-url $RPC_URL
Script
Description
scripts/simulate.sh
Run CRE simulate, print VWAP result — no on-chain write
scripts/simulate-and-forward.sh
Simulate + submit rawReport via MockKeystoneForwarder
scripts/demo-vtn.sh
Create demo orders on Tenderly VTN in four settlement states