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
Automated market resolution #404
Automated market resolution #404
Conversation
Should this be done in the repo or should everyone using VS Code do that himself globally on his machine(s)?
# Conflicts: # web/components/choices-toggle-group.tsx # web/pages/create.tsx
# Conflicts: # common/contract.ts # functions/src/create-contract.ts # web/pages/create.tsx
This reverts commit 22f59ad.
…solution # Conflicts: # web/components/contract/contract-info-dialog.tsx
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.
Found a few more things to fix, but otherwise approved!
I'll rerun the script to update autoResolutionTime
for all contracts, and merge this PR in — hopefully later today if you make the small fixes suggested.
Thanks!
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 PR was reverted because of a few bugs I found.
@@ -113,6 +116,7 @@ export const createmarket = newEndpoint(['POST'], async (req, auth) => { | |||
ante, | |||
closeTime.getTime(), | |||
tags ?? [], | |||
autoResolutionTime, |
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.
This is not in the right order, autoResolutionTime
should be the last parameter. (To make this more robust, we could switch to taking all the parameters as an object instead of a param list. Not sure if that should be part of this change.)
firestore | ||
.collection('contracts') | ||
.where('isResolved', '==', false) | ||
.where('closeTime', '>', Date.now()) |
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.
closeTime should be '<' Date.now() if the market is closed!
.collection('contracts') | ||
.where('isResolved', '==', false) | ||
.where('closeTime', '>', Date.now()) | ||
.where('autoResolutionTime', '<', Date.now()) |
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.
Firebase does not allow two queries with not equal operators. Advice is to move the closeTime query into a filter operation after loading the contracts.
) | ||
|
||
export const autoResolveMarkets = functions.pubsub | ||
.schedule('every 1 minutes') |
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.
Needs .runWith({ secrets: ['MAILGUN_KEY'] })
since it sends emails.
This feature will brings automatic resolutions to abandoned markets.
Automatic resolution means that unresolved markets get resolved as 'MKT' (paying out investors according to the current odds) at a specified date. By default that date is 1 week after the market closes but it can be modified by the market creator.
Features
Already done on prod
ToDo prod db
Possible features for later PRs
Untested