Skip to content

Commit

Permalink
refactor: change polymarket provider to use markets endpoint (#666)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Johnson <[email protected]>
  • Loading branch information
technicallyty and aljo242 committed Aug 13, 2024
1 parent d886707 commit 5e4b45c
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 325 deletions.
16 changes: 5 additions & 11 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ adadfc
adb
adec
adf
adk
aec
aed
afa
Expand Down Expand Up @@ -182,7 +181,6 @@ codecmock
codecov
codectypes
codeowners
codespell
coinbaseapi
coinbasebtcusd
coinbaseethusd
Expand Down Expand Up @@ -232,7 +230,6 @@ datacenters
datadog
datasources
davecgh
davidterpay
dbddb
dbf
dbm
Expand All @@ -256,6 +253,7 @@ depinject
desertbit
Devation
dfa
dfb
dfd
dfe
dgraph
Expand All @@ -281,6 +279,7 @@ dyno
EAB
eaf
ece
ecfc
eci
eda
eeba
Expand Down Expand Up @@ -314,7 +313,6 @@ ETHUSDTAMMID
EUR
eux
evm
exportloopref
extendee
fabf
Factom
Expand All @@ -339,6 +337,7 @@ FHK
findstring
Finex
flatbuffers
fpmm
fromjson
fsnotify
fznuf
Expand Down Expand Up @@ -539,7 +538,6 @@ mmmocks
mms
mmservicetypes
mmtypes
moby
mocd
mockmetrics
mockstrategies
Expand Down Expand Up @@ -578,7 +576,6 @@ neuton
nfalling
nhooyr
Nilf
nivasan
nocapongodskiptoonicewititshiiiiiiiii
nolint
nolintlint
Expand Down Expand Up @@ -618,9 +615,6 @@ orderedcode
otel
otelgrpc
otelhttp
otlp
otlptrace
otlptracehttp
outpkg
outstruct
pamock
Expand Down Expand Up @@ -755,6 +749,7 @@ SMOLE
solana
solanago
solusd
sortkeys
sortme
sourcegraph
soz
Expand Down Expand Up @@ -885,8 +880,8 @@ Warehime
wastedassign
wbs
websockets
wethusdc
wesl
wethusdc
WFys
Whyy
wincred
Expand Down Expand Up @@ -959,4 +954,3 @@ zerolog
ZFvy
zondax
zstd
sortkeys
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ linters:
- dogsled
# Check for two durations multiplied together.
- durationcheck
- exportloopref
- goconst
- gocritic
- gofumpt
Expand All @@ -28,8 +27,6 @@ linters:
- misspell
- nakedret
- errorlint
# Checks for pointers to enclosing loop variables.
- exportloopref
- nolintlint
# Finds shadowing of Go's predeclared identifiers.
# I hear a lot of complaints from junior developers.
Expand Down
42 changes: 4 additions & 38 deletions cmd/constants/marketmaps/markets.go
Original file line number Diff line number Diff line change
Expand Up @@ -9724,48 +9724,14 @@ var (
"Base":"WILL_BERNIE_SANDERS_WIN_THE_2024_US_PRESIDENTIAL_ELECTION?YES",
"Quote":"USD"
},
"decimals":3,
"decimals":4,
"min_provider_count":1,
"enabled":true
},
"provider_configs":[
{
"name":"polymarket_api",
"off_chain_ticker":"95128817762909535143571435260705470642391662537976312011260538371392879420759"
}
]
},
"WILL_ROBERT_F_KENNEDY_JR_WIN_THE_2024_US_PRESIDENTIAL_ELECTION?NO/USD":{
"ticker":{
"currency_pair":{
"Base":"WILL_ROBERT_F_KENNEDY_JR_WIN_THE_2024_US_PRESIDENTIAL_ELECTION?NO",
"Quote":"USD"
},
"decimals":3,
"min_provider_count":1,
"enabled":true
},
"provider_configs":[
{
"name":"polymarket_api",
"off_chain_ticker":"56404905393055211239795086916790918063008904529043139446524120756836481670648"
}
]
},
"USA_WINS_THE_MOST_GOLD_MEDALS_IN_2024_PARIS_OLYMPICS?YES/USD":{
"ticker":{
"currency_pair":{
"Base":"USA_WINS_THE_MOST_GOLD_MEDALS_IN_2024_PARIS_OLYMPICS?YES",
"Quote":"USD"
},
"decimals":3,
"min_provider_count":1,
"enabled":true
},
"provider_configs":[
{
"name":"polymarket_api",
"off_chain_ticker":"21948917496837354367910826573765617012647201536430148892502780921686496760749"
"off_chain_ticker":"0x08f5fe8d0d29c08a96f0bc3dfb52f50e0caf470d94d133d95d38fa6c847e0925/95128817762909535143571435260705470642391662537976312011260538371392879420759"
}
]
},
Expand All @@ -9775,14 +9741,14 @@ var (
"Base":"WILL_INSIDE_OUT_2_GROSS_MOST_IN_2024?YES",
"Quote":"USD"
},
"decimals":3,
"decimals":4,
"min_provider_count":1,
"enabled":true
},
"provider_configs":[
{
"name":"polymarket_api",
"off_chain_ticker":"50107902083284751016545440401692219408556171231461347396738260657226842527986"
"off_chain_ticker":"0x1ab07117f9f698f28490f57754d6fe5309374230c95867a7eba572892a11d710/50107902083284751016545440401692219408556171231461347396738260657226842527986"
}
]
}
Expand Down
22 changes: 9 additions & 13 deletions providers/apis/polymarket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ Polymarket is a web3 based prediction market. This provider uses the Polymarket

Polymarket uses [conditional outcome tokens](https://docs.gnosis.io/conditionaltokens/), a token that represents an outcome of a specific event. All tokens in Polymarket are denominated in terms of USD.

Tickers take the form of the `<market_slug>?<outcome>/USD`:
We suggest tickers take the form of the `<market_slug>?<outcome>/USD`. However, tickers are ignored by the polymarket provider, and they can be whatever arbitrary data that suits your use case. The ONLY required text is your ticker must end in `/USD`.

Example: `WILL_BERNIE_SANDERS_WIN_THE_2024_US_PRESIDENTIAL_ELECTION?YES/USD`
Example2: `BernieBecomesPresident/USD`

The offchain ticker is expected to be _just_ the token_id.
The offchain ticker **must** be <market_id>/<token_id>

example: `95128817762909535143571435260705470642391662537976312011260538371392879420759`
example: `0x08f5fe8d0d29c08a96f0bc3dfb52f50e0caf470d94d133d95d38fa6c847e0925/95128817762909535143571435260705470642391662537976312011260538371392879420759`

The Provider can handle both the midpoint and the price endpoints. However, passing in multiple endpoints to the same provider will not yield additional data, as only the first endpoint is considered for the provider.
The Provider queries the `/markets` endpoint, and looks for the token_id in the response. The provider will throw an error if the token_id in the offchain ticker is not present in the response data.

Example:

Midpoint:
`https://clob.polymarket.com/markets/0xc6485bb7ea46d7bb89beb9c91e7572ecfc72a6273789496f78bc5e989e4d1638`

`https://clob.polymarket.com/midpoint?token_id=95128817762909535143571435260705470642391662537976312011260538371392879420759`

Price:

`https://clob.polymarket.com/price?token_id=95128817762909535143571435260705470642391662537976312011260538371392879420759&side=BUY`

## Market Config

Expand All @@ -48,7 +44,7 @@ Below is an example of a market config for a single Polymarket token.
"provider_configs": [
{
"name": "polymarket_api",
"off_chain_ticker": "95128817762909535143571435260705470642391662537976312011260538371392879420759"
"off_chain_ticker": "0x08f5fe8d0d29c08a96f0bc3dfb52f50e0caf470d94d133d95d38fa6c847e0925/95128817762909535143571435260705470642391662537976312011260538371392879420759"
}
]
}
Expand All @@ -73,10 +69,10 @@ Below is an example of an oracle config with a Polymarket provider.
"interval": 500000000,
"reconnectTimeout": 2000000000,
"maxQueries": 1,
"atomic": true,
"atomic": false,
"endpoints": [
{
"url": "https://clob.polymarket.com/midpoint?token_id=%s",
"url": "https://clob.polymarket.com/markets/%s",
"authentication": {
"apiKey": "",
"apiKeyHeader": ""
Expand Down
Loading

0 comments on commit 5e4b45c

Please sign in to comment.