Merge branch 'main' into cpmm

This commit is contained in:
mantikoros 2022-03-08 11:45:30 -06:00
commit d1b510c720
4 changed files with 95 additions and 50 deletions

18
common/util/promise.ts Normal file
View File

@ -0,0 +1,18 @@
export const batchedWaitAll = async <T>(
createPromises: (() => Promise<T>)[],
batchSize = 10
) => {
const numBatches = Math.ceil(createPromises.length / batchSize)
const result: T[] = []
for (let batchIndex = 0; batchIndex < numBatches; batchIndex++) {
const from = batchIndex * batchSize
const to = from + batchSize
const promises = createPromises.slice(from, to).map((f) => f())
const batch = await Promise.all(promises)
result.push(...batch)
}
return result
}

View File

@ -5,6 +5,7 @@ import * as _ from 'lodash'
import { getValues } from './utils' import { getValues } from './utils'
import { Contract } from '../../common/contract' import { Contract } from '../../common/contract'
import { Bet } from '../../common/bet' import { Bet } from '../../common/bet'
import { batchedWaitAll } from '../../common/util/promise'
const firestore = admin.firestore() const firestore = admin.firestore()
@ -17,8 +18,8 @@ export const updateContractMetrics = functions.pubsub
firestore.collection('contracts') firestore.collection('contracts')
) )
await Promise.all( await batchedWaitAll(
contracts.map(async (contract) => { contracts.map((contract) => async () => {
const volume24Hours = await computeVolumeFrom(contract, oneDay) const volume24Hours = await computeVolumeFrom(contract, oneDay)
const volume7Days = await computeVolumeFrom(contract, oneDay * 7) const volume7Days = await computeVolumeFrom(contract, oneDay * 7)

View File

@ -7,6 +7,7 @@ import { Contract } from '../../common/contract'
import { Bet } from '../../common/bet' import { Bet } from '../../common/bet'
import { User } from '../../common/user' import { User } from '../../common/user'
import { calculateDpmPayout } from '../../common/calculate-dpm' import { calculateDpmPayout } from '../../common/calculate-dpm'
import { batchedWaitAll } from '../../common/util/promise'
const firestore = admin.firestore() const firestore = admin.firestore()
@ -22,8 +23,8 @@ export const updateUserMetrics = functions.pubsub
contracts.map((contract) => [contract.id, contract]) contracts.map((contract) => [contract.id, contract])
) )
await Promise.all( await batchedWaitAll(
users.map(async (user) => { users.map((user) => async () => {
const [investmentValue, creatorVolume] = await Promise.all([ const [investmentValue, creatorVolume] = await Promise.all([
computeInvestmentValue(user, contractsDict), computeInvestmentValue(user, contractsDict),
computeTotalPool(user, contractsDict), computeTotalPool(user, contractsDict),

View File

@ -118,6 +118,13 @@ function Contents() {
</p> </p>
</li> </li>
</ol> </ol>
<p>
More questions? Check out{' '}
<a href="https://outsidetheasylum.blog/manifold-markets-faq/">
this community-driven FAQ
</a>
!
</p>
<h3 id="can-prediction-markets-work-without-real-money-"> <h3 id="can-prediction-markets-work-without-real-money-">
Can prediction markets work without real money? Can prediction markets work without real money?
</h3> </h3>
@ -148,6 +155,40 @@ function Contents() {
</a> </a>
. .
</p> </p>
<h3 id="why-is-this-important-">Why is this important?</h3>
<p>
Prediction markets aggregate and reveal crucial information that would
not otherwise be known. They are a bottom-up mechanism that can
influence everything from politics, economics, and business, to
scientific research and education.
</p>
<p>
Prediction markets can predict{' '}
<a href="https://www.pnas.org/content/112/50/15343">
which research papers will replicate
</a>
; which drug is the most effective; which policy would generate the most
tax revenue; which charity will be underfunded; or which startup idea is
the most promising. By surfacing and quantifying our collective
knowledge, we as a society become wiser.
</p>
<h3 id="how-does-betting-work">How does betting work?</h3>
<ul>
<li>Markets are structured around a question with a binary outcome.</li>
<li>
Traders can place a bet on either YES or NO. The trader receives some
shares of the betting pool. The number of shares depends on the
current probability.
</li>
<li>
When the market is resolved, the traders who bet on the correct
outcome are paid out of the final pool in proportion to the number of
shares they own.
</li>
</ul>
<h3 id="how-are-markets-resolved-">How are markets resolved?</h3> <h3 id="how-are-markets-resolved-">How are markets resolved?</h3>
<p> <p>
The creator of the prediction market decides the outcome and earns{' '} The creator of the prediction market decides the outcome and earns{' '}
@ -166,29 +207,9 @@ function Contents() {
or even personal. (E.g. &quot;Will I enjoy participating in the or even personal. (E.g. &quot;Will I enjoy participating in the
Metaverse in 2023?&quot;) Metaverse in 2023?&quot;)
</p> </p>
<h3 id="why-is-this-important-">Why is this important?</h3> {/* <h3 id="how-is-this-different-from-metaculus-or-hypermind-">
<p>
Prediction markets aggregate and reveal crucial information that would
not otherwise be known. They are a bottom-up mechanism that can
influence everything from politics, economics, and business, to
scientific research and education.
</p>
<p>
Prediction markets can predict{' '}
<a href="https://www.pnas.org/content/112/50/15343">
which research papers will replicate
</a>
; which drug is the most effective; which policy would generate the most
tax revenue; which charity will be underfunded; or, which startup idea
is the most promising.
</p>
<p>
By surfacing and quantifying our collective knowledge, we as a society
become wiser.
</p>
<h3 id="how-is-this-different-from-metaculus-or-hypermind-">
How is this different from Metaculus or Hypermind? How is this different from Metaculus or Hypermind?
</h3> </h3> */}
{/* <p> {/* <p>
We believe that in order to get the best results, you have to have skin We believe that in order to get the best results, you have to have skin
in the game. We require that people use real money to buy the currency in the game. We require that people use real money to buy the currency
@ -199,28 +220,13 @@ function Contents() {
carefully and can&#39;t rig the outcome by creating multiple accounts. carefully and can&#39;t rig the outcome by creating multiple accounts.
The result is more accurate predictions. The result is more accurate predictions.
</p> */} </p> */}
<p> {/* <p>
Manifold Markets is focused on accessibility and allowing anyone to Manifold Markets is focused on accessibility and allowing anyone to
quickly create and judge a prediction market. When we all have the power quickly create and judge a prediction market. When we all have the power
to create and share prediction markets in seconds and apply our own to create and share prediction markets in seconds and apply our own
judgment on the outcome, it leads to a qualitative shift in the number, judgment on the outcome, it leads to a qualitative shift in the number,
variety, and usefulness of prediction markets. variety, and usefulness of prediction markets.
</p> </p> */}
<h3 id="how-does-betting-work">How does betting work?</h3>
<ul>
<li>Markets are structured around a question with a binary outcome.</li>
<li>
Traders can place a bet on either YES or NO. The trader receives some
shares of the betting pool. The number of shares depends on the
current probability.
</li>
<li>
When the market is resolved, the traders who bet on the correct
outcome are paid out of the final pool in proportion to the number of
shares they own.
</li>
</ul>
<h3 id="type-of-market-maker">What kind of betting system do you use?</h3> <h3 id="type-of-market-maker">What kind of betting system do you use?</h3>
<p> <p>
@ -249,6 +255,20 @@ function Contents() {
to find out more! to find out more!
</p> </p>
<h3 id="private-markets">Can I create private markets?</h3>
<p>
Soon! We're running a pilot version of Manifold for Teams - private
Manifold instances where you can discuss internal topics and predict on
outcomes for your organization.
</p>
<p>
If this sounds like something youd want,{' '}
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfM_rxRHemCjKE6KPiYXGyP2nBSInZNKn_wc7yS1-rvlLAVnA/viewform?usp=sf_link">
join the waitlist here
</a>
!
</p>
<h3 id="who-are-we-">Who are we?</h3> <h3 id="who-are-we-">Who are we?</h3>
<p>Manifold Markets is currently a team of three:</p> <p>Manifold Markets is currently a team of three:</p>
<ul> <ul>
@ -296,19 +316,24 @@ function Contents() {
<h2 id="further-reading">Further Reading</h2> <h2 id="further-reading">Further Reading</h2>
<ul> <ul>
<li>
<a href="https://outsidetheasylum.blog/manifold-markets-faq/">
An in-depth, unofficial FAQ by Isaac King
</a>
</li>
<li> <li>
<a href="https://manifoldmarkets.notion.site/Technical-Guide-to-Manifold-Markets-b9b48a09ea1f45b88d991231171730c5"> <a href="https://manifoldmarkets.notion.site/Technical-Guide-to-Manifold-Markets-b9b48a09ea1f45b88d991231171730c5">
Technical Guide to Manifold Markets How Manifold's market maker works
</a>
</li>
<li>
<a href="https://astralcodexten.substack.com/p/play-money-and-reputation-systems">
Scott Alexander on play-money prediction markets
</a> </a>
</li> </li>
<li> <li>
<a href="https://sideways-view.com/2019/10/27/prediction-markets-for-internet-points/"> <a href="https://sideways-view.com/2019/10/27/prediction-markets-for-internet-points/">
Paul Christiano: Prediction markets for internet points Paul Christiano on prediction markets for internet points
</a>
</li>
<li>
<a href="https://thezvi.wordpress.com/2021/12/02/covid-prediction-markets-at-polymarket/">
Zvi Mowshowitz on resolving prediction markets
</a> </a>
</li> </li>
</ul> </ul>