This repository contains contracts used to resolve Polymarket prediction markets via UMA's optimistic oracle.
The Adapter is an oracle to Conditional Tokens Framework(CTF) conditions, which Polymarket prediction markets are based on.
It fetches resolution data from UMA's Optmistic Oracle and resolves the condition based on said resolution data.
When a new market is deployed, it is initialized
, meaning:
- The market's parameters(ancillary data, request timestamp, reward token, reward, etc) are stored onchain
- The market is
prepared
on the CTF contract - A resolution data request is sent out to the Optimistic Oracle
UMA Proposers will then respond to the request and fetch resolution data offchain. If the resolution data is not disputed, the data will be available to the Adapter after a defined liveness period(currently about 2 hours).
The first time a request is disputed, the market is automatically reset
, meaning, a new Optimistic Oracle request is sent out. This ensures that obviously incorrect disputes do not slow down resolution of the market.
If the request is disputed again, this indicates a more fundamental disagreement among proposers and the Optimistic Oracle falls back to UMA's DVM to come to agreement. The DVM will return data after a 48 - 72 hour period.
After resolution data is available, anyone can call resolve
which resolves the market using the resolution data.
These contracts have been audited by OpenZeppelin and the report is available here.
See Deployments
Clone the repo: git clone https://github.com/Polymarket/uma-ctf-adapter.git --recurse-submodules
Install Foundry.
Foundry has daily updates, run foundryup
to update forge
and cast
.
To install/update forge dependencies: forge update
To build contracts: forge build
To run all tests: forge test
Set -vvv
to see a stack trace for a failed test.