-
Notifications
You must be signed in to change notification settings - Fork 197
feat(pm-notifier): read order filled events from subgraph #4900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| const orderBookSubgraphEndpoint = | ||
| env.ORDER_BOOK_SUBGRAPH_ENDPOINT || | ||
| "https://api.goldsky.com/api/public/project_cl6mb8i9h0003e201j6li0diw/subgraphs/orderbook-subgraph/0.0.1/gn"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults to the public version (https://docs.polymarket.com/developers/subgraph/overview#hosted-version)
| // Try the fast subgraph version | ||
| return await getOrderFilledEventsFromSubgraph(params, clobTokenIds, startTimestamp); | ||
| } catch (error) { | ||
| // Fallback to the slow version if subgraph fails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we debug log this for better observability
| const blockDifference = currentBlockNumber - subgraphBlockNumber; | ||
|
|
||
| // If subgraph is behind by more than tolerance, use slow method | ||
| if (blockDifference >= params.subgraphSyncTolerance) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the subgraphSyncTolerance naming implies that == should still be tolerated, so we might want to use > comparison here. Also running this couple of times I always observed subgraph lagging 1 block behind in my tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
| // Check subgraph sync status first | ||
| const subgraphBlockNumber = await checkSubgraphSyncStatus(params.httpClient, params.orderBookSubgraphEndpoint); | ||
|
|
||
| if (subgraphBlockNumber !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when subgraphBlockNumber === null I don't think we should even try getOrderFilledEventsFromSubgraph below and instead fallback to getOrderFilledEventsSlow as subgraphSyncTolerance cannot be evaluated in this case.
|
|
||
| // If subgraph is behind by more than tolerance, use slow method | ||
| if (blockDifference >= params.subgraphSyncTolerance) { | ||
| return await getOrderFilledEventsSlow(params, clobTokenIds, startBlockNumber); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also might want to debug log the fallback
Changes proposed in this PR: