Compare commits
3145 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c762869b83 | ||
|
aaa09f49c0 | ||
|
4d214c01b4 | ||
|
0a70652667 | ||
|
b4162a0896 | ||
|
2ecece02c3 | ||
|
4359ad0530 | ||
|
3f8988bf27 | ||
|
41a46aad9b | ||
|
4097082c75 | ||
|
58cd0e57bd | ||
|
3a63503161 | ||
|
abd06f272b | ||
|
ab1c3020da | ||
|
c044460a91 | ||
|
7a6725ee77 | ||
|
823d1ddd4c | ||
|
7d490e0de1 | ||
|
96d2255cb1 | ||
|
4a139c5cc2 | ||
|
47eb8abed0 | ||
|
903fcc83b3 | ||
|
0615bb2d4b | ||
|
3508c94634 | ||
|
29c0dfe3fe | ||
|
18a3b66164 | ||
|
9e4f41253f | ||
|
546b0231e7 | ||
|
8bb44593f3 | ||
|
2c2bc61788 | ||
|
34c9dbb3e7 | ||
|
d6525bae9f | ||
|
da32a756a8 | ||
|
fa476c78dd | ||
|
e7ba7e715f | ||
|
9bf82c6082 | ||
|
3e1876f0dc | ||
|
5ba4a9dce7 | ||
|
4e5b78f4ee | ||
|
bc6fab399e | ||
|
c2d112e516 | ||
|
3cbe8ad8bb | ||
|
6226291e02 | ||
|
fa4dba4da3 | ||
|
9eff69be75 | ||
|
789bec2a4f | ||
|
18042cd4d1 | ||
|
04a126707b | ||
|
7a412fdb0d | ||
|
e2dc4c6b8f | ||
|
204d302d87 | ||
|
ae39c1175b | ||
|
c44f223064 | ||
|
aa717a767d | ||
|
d9f57b7daa | ||
|
93ceaa52c4 | ||
|
de76557326 | ||
|
da1fcb646f | ||
|
1d618ba337 | ||
|
2cda3a4d4f | ||
|
e44fc8ae13 | ||
|
e6a90e18e4 | ||
|
cee8caa3e8 | ||
|
b49264ddfa | ||
|
12ed569ff6 | ||
|
00acc262a0 | ||
|
fd7d4eb5e2 | ||
|
8ae1166c49 | ||
|
84e2b63c49 | ||
|
f19ef83ac2 | ||
|
0c11f3b450 | ||
|
de9ffa2b52 | ||
|
decb3213f6 | ||
|
ff6278b147 | ||
|
3fc53112b9 | ||
|
59cdc9f776 | ||
|
f587e0256d | ||
|
1c209f68f6 | ||
|
b4e7d88ed8 | ||
|
b2cd6bbe03 | ||
|
a6d5d5ad15 | ||
|
beeca57d4e | ||
|
fb8bd1acfb | ||
|
4215821f35 | ||
|
a71c3d6a4a | ||
|
cdcce421a8 | ||
|
8beff6eb1f | ||
|
f714918b88 | ||
|
946d74489f | ||
|
220d0841bd | ||
|
9d44190b9a | ||
|
3cdd790ae9 | ||
|
6c1ac89cbe | ||
|
0d8a84ef06 | ||
|
d528566ffa | ||
|
b0f8369d9c | ||
|
721c18cf6c | ||
|
43b06ae6fa | ||
|
bfdb5ae595 | ||
|
274f7fa849 | ||
|
d507c4092e | ||
|
e970a908c6 | ||
|
4fd0e5caad | ||
|
70b2b14f80 | ||
|
0ec15ff2f8 | ||
|
8bb9885aee | ||
|
c46c384d1d | ||
|
4f5c93be96 | ||
|
f03e5d7af0 | ||
|
fb0a09664e | ||
|
17d0fb7da6 | ||
|
867cdf2496 | ||
|
f26ba1c4a2 | ||
|
cdc64c6475 | ||
|
5d561acdf8 | ||
|
84f79ffe7c | ||
|
f6fd703005 | ||
|
b8ef272784 | ||
|
a4699b79ed | ||
|
66071e16fa | ||
|
b3136ebcac | ||
|
a143a96919 | ||
|
dea65a4ba0 | ||
|
a310963952 | ||
|
8d06e4b4d2 | ||
|
dc51e2cf46 | ||
|
4831c25ce0 | ||
|
60f2552139 | ||
|
4b8d381da5 | ||
|
565177b76f | ||
|
8bd21c6693 | ||
|
310a41d63e | ||
|
e1636d0f13 | ||
|
d00ea65279 | ||
|
60bb5379cb | ||
|
f3dedfb27a | ||
|
efa2e44937 | ||
|
84bc490ed3 | ||
|
443397b7dc | ||
|
b57ff68654 | ||
|
f0b35993c9 | ||
|
8f56ccad22 | ||
|
9e289146af | ||
|
4285198f09 | ||
|
f533d9bfcb | ||
|
71b0c71729 | ||
|
25333317b0 | ||
|
42a7d04b4d | ||
|
b1d386ca5a | ||
|
0dc8753a92 | ||
|
454f2d1417 | ||
|
d846b9fb30 | ||
|
77e0631ea4 | ||
|
badd67c278 | ||
|
80622dc7ee | ||
|
9d12fa3af0 | ||
|
d9c8925ea0 | ||
|
adb809f973 | ||
|
a63405ca7c | ||
|
7ca0fb72fc | ||
|
ac37f94cf7 | ||
|
bc5af50b0c | ||
|
4162cca3ff | ||
|
91da39370f | ||
|
2f2c586d5d | ||
|
853e3e4896 | ||
|
edbd0feb37 | ||
|
59de979949 | ||
|
b8d65acc3f | ||
|
26f04fb04a | ||
|
e127f9646a | ||
|
25ef17498a | ||
|
68075db3da | ||
|
e1f24f24a9 | ||
|
cd8245fbee | ||
|
f1e400765a | ||
|
94624c5387 | ||
|
7ce09ae39d | ||
|
935bdd12a7 | ||
|
5d7721e041 | ||
|
a149777c0e | ||
|
81fb2456bd | ||
|
f8ec306ee9 | ||
|
a53fb49ec3 | ||
|
7863a4232d | ||
|
a3b841423f | ||
|
b8911cafe8 | ||
|
60aa294131 | ||
|
0818a94307 | ||
|
a3acd3fa3c | ||
|
1ef1af8234 | ||
|
189da4a0cf | ||
|
10f0bbc63d | ||
|
2d56525d65 | ||
|
f1f8082600 | ||
|
ec006f25c4 | ||
|
b40a114168 | ||
|
4bbadeb27c | ||
|
2596d54831 | ||
|
0df5497ffb | ||
|
27dabc193c | ||
|
6ec1b38a21 | ||
|
f35eb42d7b | ||
|
18f8ad433d | ||
|
37e8f2ff5a | ||
|
328aa1457d | ||
|
b9ba3e75fa | ||
|
70bfec2742 | ||
|
26281556f7 | ||
|
730abf584a | ||
|
34d09316e0 | ||
|
6f41ab8efd | ||
|
f1207e87ec | ||
|
4e22b8e332 | ||
|
07de8cc86a | ||
|
f07a022d63 | ||
|
d42ec42b0e | ||
|
6fa4e17a58 | ||
|
af3a3a3934 | ||
|
9e3477970d | ||
|
3390c34d0a | ||
|
419219c703 | ||
|
8aaca848b2 | ||
|
e4d7d0a232 | ||
|
e9050973e1 | ||
|
83d9a1f3e2 | ||
|
49e97ddac1 | ||
|
a9d5dd7fc8 | ||
|
ddb186dd98 | ||
|
d2273087cf | ||
|
6a0b577aeb | ||
|
ca6197c7bb | ||
|
ed6ea011c2 | ||
|
83d33792aa | ||
|
583c5b225e | ||
|
9f256aa7a8 | ||
|
7a271fce29 | ||
|
d8ef363f06 | ||
|
8043fa515a | ||
|
f551e6c469 | ||
|
3f0b665753 | ||
|
40b07329bd | ||
|
7b9aeea0bd | ||
|
935ff7b97a | ||
|
c115b5cca7 | ||
|
d6bb27f97c | ||
|
bbce3e873e | ||
|
26f5e506b7 | ||
|
5adaa7253f | ||
|
a55d85d4b6 | ||
|
f085df96e3 | ||
|
1d2af2900b | ||
|
a48cec63fc | ||
|
e6374c4994 | ||
|
6ac467764d | ||
|
79af4b2be0 | ||
|
094bcaea17 | ||
|
c6e5e04e65 | ||
|
ee4d3947b8 | ||
|
45b281fac5 | ||
|
31c6cb7739 | ||
|
23ca3ff56a | ||
|
c3ffac34a1 | ||
|
375a4e089f | ||
|
efd83eaad4 | ||
|
8d70dc4800 | ||
|
a1dcf8d168 | ||
|
84aaeece9f | ||
|
27d765a4a1 | ||
|
5214f27be3 | ||
|
d0d223f7ad | ||
|
0c9226de41 | ||
|
ce48016f80 | ||
|
1515d8cab2 | ||
|
28cad9caf8 | ||
|
9a950dc080 | ||
|
42cc07e4a6 | ||
|
a5490c903f | ||
|
71975f307c | ||
|
ae4136348d | ||
|
67de983aac | ||
|
59b128dbe7 | ||
|
074a1fdde2 | ||
|
7c34805eeb | ||
|
77a5f8b9dd | ||
|
5ae9049295 | ||
|
d5d1284306 | ||
|
adb8bc476f | ||
|
f92f098f82 | ||
|
370edec890 | ||
|
f5a3abf0bc | ||
|
27e6534d94 | ||
|
1caf75d3b5 | ||
|
051c2905e1 | ||
|
1f7b9174b3 | ||
|
06571a3657 | ||
|
3fb43c16c4 | ||
|
603201a00f | ||
|
b517817ee3 | ||
|
80693620f0 | ||
|
f1ae54355d | ||
|
503038d2a2 | ||
|
bf8dca25b2 | ||
|
a82f447965 | ||
|
1f8c72b4c9 | ||
|
40c51c3d59 | ||
|
86ceea831b | ||
|
efb9ef7602 | ||
|
8c1131ebab | ||
|
2c223160ed | ||
|
11bd658c68 | ||
|
39638a3888 | ||
|
234820ecd4 | ||
|
4d996c2476 | ||
|
9ecf10496c | ||
|
42b27fcedd | ||
|
7bf59bcdd0 | ||
|
043b18da0e | ||
|
64951e691e | ||
|
9a90cc3835 | ||
|
10e361bcac | ||
|
a7f6cb7cfa | ||
|
359a768e14 | ||
|
42aea03415 | ||
|
0fb263efa4 | ||
|
747977556b | ||
|
37e8cfbbed | ||
|
701d0a06cd | ||
|
0ffd6c129a | ||
|
758dbfe398 | ||
|
33dfce3e16 | ||
|
af66d94c84 | ||
|
290a34bc64 | ||
|
4c2f9011d0 | ||
|
57b592b5aa | ||
|
fd31b7eaca | ||
|
1d645e5ff8 | ||
|
0b0b84a6ad | ||
|
2baae33a77 | ||
|
fac87f8e0c | ||
|
670c6faea8 | ||
|
09e4864b32 | ||
|
a445d9b7fa | ||
|
cb613705e9 | ||
|
aeeb47bdbe | ||
|
0844e5620a | ||
|
2d6fe308b8 | ||
|
759685258a | ||
|
b53e4acea6 | ||
|
2f1221f094 | ||
|
2f3ae5192e | ||
|
b0b1d72ba6 | ||
|
dc0b6dc6a6 | ||
|
89e26d077e | ||
|
38b7c898f6 | ||
|
1fc2f15dae | ||
|
3d146dd57d | ||
|
a219680701 | ||
|
1e2df99054 | ||
|
37beb584ef | ||
|
9815e7301f | ||
|
ac97e62f2e | ||
|
17d1b8575c | ||
|
a25acbe1db | ||
|
b2f81c1149 | ||
|
9d81e3b6d1 | ||
|
ab883ea777 | ||
|
3677de58c3 | ||
|
31de3636fd | ||
|
a90b765670 | ||
|
55f854115c | ||
|
138f34fc66 | ||
|
c16e5189f7 | ||
|
1bc1debbe8 | ||
|
608ee7b865 | ||
|
95c47aba1a | ||
|
f892c92e26 | ||
|
7e91133229 | ||
|
523689b525 | ||
|
b83e5db563 | ||
|
13b3613460 | ||
|
715bae57e0 | ||
|
5b5a919ed7 | ||
|
2625ab1549 | ||
|
262183e0e6 | ||
|
b7df1a7043 | ||
|
8929b2e6ba | ||
|
9fc1e855ff | ||
|
1755fb15d4 | ||
|
1e6b72059e | ||
|
2d1fd07834 | ||
|
ec1a9fab77 | ||
|
2cc08ba9e7 | ||
|
35aa6c0429 | ||
|
cd7ddae133 | ||
|
46fab105d9 | ||
|
4cc985634a | ||
|
15cd8b1f94 | ||
|
8862425120 | ||
|
be010da9f5 | ||
|
7f7e7acd61 | ||
|
1f2c7271b7 | ||
|
83de206e9e | ||
|
d55cedb36c | ||
|
eb762d9b9e | ||
|
dba938032f | ||
|
7c8e977d60 | ||
|
e0e6838711 | ||
|
513cf7b290 | ||
|
89c3ea559c | ||
|
9238b20242 | ||
|
925a9e850f | ||
|
8f88af4e2a | ||
|
5b54e7d468 | ||
|
f52127237e | ||
|
95f2604479 | ||
|
a5b943965c | ||
|
c16adb9ec9 | ||
|
e0d9b4d335 | ||
|
9dc0d1696e | ||
|
a7abdbb1db | ||
|
13dad9a10c | ||
|
14c008234a | ||
|
b87e29d7c0 | ||
|
3ed29877ce | ||
|
80d4bffc95 | ||
|
b21daa1248 | ||
|
419c7ab636 | ||
|
e2047210b7 | ||
|
5e34b5a911 | ||
|
723d9dbece | ||
|
7ba19c274b | ||
|
a12ed78813 | ||
|
aa93ec060d | ||
|
fd90bc353b | ||
|
e17a59ae23 | ||
|
2fe9fe593d | ||
|
d612192109 | ||
|
13cffcdaf1 | ||
|
1b9811ce28 | ||
|
3ed3b6fb42 | ||
|
f7bf42d2e0 | ||
|
df316fc4da | ||
|
2ef025a151 | ||
|
90eaf83775 | ||
|
94ffac287e | ||
|
a10e4c115e | ||
|
cc3b44891b | ||
|
d9292f7a95 | ||
|
bf92c4fb06 | ||
|
68120ec2b2 | ||
|
be2c60d3f3 | ||
|
c1c3a360fd | ||
|
ae4d49d960 | ||
|
21c7130d3b | ||
|
d990bc2f07 | ||
|
e2a8df6c3a | ||
|
96dc060a0a | ||
|
d04304bdac | ||
|
2891a47d8c | ||
|
490734db00 | ||
|
77ddc456a2 | ||
|
1a5dcdedcc | ||
|
0ab82a7bd4 | ||
|
deb8397ee9 | ||
|
57190e7876 | ||
|
5a10132e2b | ||
|
ebcecd4fe9 | ||
|
61a9224a7d | ||
|
47c97c36db | ||
|
5483955590 | ||
|
91f89ccb3d | ||
|
08202c3ede | ||
|
70bc5b2c4a | ||
|
c6d034545a | ||
|
eaaa46294a | ||
|
2240db9baa | ||
|
a1c3d0a2dd | ||
|
7704de6904 | ||
|
721448f408 | ||
|
6ee8d90bdb | ||
|
6fe0a22a48 | ||
|
b9fffcfa30 | ||
|
0c0e7b5582 | ||
|
06db5515f6 | ||
|
a5e293c010 | ||
|
4412d0195c | ||
|
c15285aa64 | ||
|
9ff2b62740 | ||
|
e9ab234d61 | ||
|
7988fdde60 | ||
|
b875ac563d | ||
|
b4a59cfb21 | ||
|
d922900bda | ||
|
24766740c5 | ||
|
73fad2e34b | ||
|
a10605e74c | ||
|
c7f29af2ee | ||
|
ea1579975c | ||
|
6e2aa622ab | ||
|
54778ec1b1 | ||
|
8870f0d356 | ||
|
be4def49a2 | ||
|
589bf9651d | ||
|
60c79141aa | ||
|
faaf502114 | ||
|
30ce80d0c9 | ||
|
8145b128ad | ||
|
a2d9e8e3d2 | ||
|
106dc232b8 | ||
|
379e736e51 | ||
|
8920241c39 | ||
|
ac952f1164 | ||
|
6d7fbd69c7 | ||
|
a4399aaee9 | ||
|
6c3338f5d7 | ||
|
272ba921a0 | ||
|
fdd7dcc0ab | ||
|
5ab86c8362 | ||
|
c6a60a6678 | ||
|
62f20694bf | ||
|
c338dce3ce | ||
|
44deaf7b0a | ||
|
4dc3eada1f | ||
|
d0973de2b4 | ||
|
b4244ea75d | ||
|
a2b01e28c9 | ||
|
935c550733 | ||
|
c101337c38 | ||
|
f3ff6d99c8 | ||
|
de8e4df04c | ||
|
1a82ce193d | ||
|
fb27fac524 | ||
|
6f5d69ec9c | ||
|
55a68d4fec | ||
|
24cf42284f | ||
|
6aa45a2d12 | ||
|
5d65bb5bb1 | ||
|
bfe00595e7 | ||
|
b93af31d2f | ||
|
a9e5020904 | ||
|
58dcbaaf6e | ||
|
e37b805b49 | ||
|
8ebf829169 | ||
|
56b4889b94 | ||
|
17453e5618 | ||
|
ae6437442b | ||
|
373cfc5d10 | ||
|
540915eb65 | ||
|
f111d6e24f | ||
|
676bcc159d | ||
|
1da4373335 | ||
|
c9e782faa7 | ||
|
39119a3419 | ||
|
65166f2fcb | ||
|
eb021f30f5 | ||
|
4aea3b96d7 | ||
|
987274ad2d | ||
|
2166169608 | ||
|
d8e9e7812a | ||
|
3bddda37d2 | ||
|
42f66b11f4 | ||
|
436646cc47 | ||
|
a14e7d3947 | ||
|
47cc313aef | ||
|
44f9a1faa2 | ||
|
f71791bdd5 | ||
|
350ab35856 | ||
|
37cff04e39 | ||
|
e7ed893b78 | ||
|
8f30ef38d9 | ||
|
1fbadf8181 | ||
|
438c12da57 | ||
|
191ec9535c | ||
|
b74fd57912 | ||
|
a54f060ccb | ||
|
fdde57e334 | ||
|
fde90be5a2 | ||
|
d2471e2a02 | ||
|
f35799c129 | ||
|
6a21067440 | ||
|
340b21c53e | ||
|
fc5807ebbe | ||
|
e0806cf0e0 | ||
|
94c448ee8b | ||
|
3e9f046a29 | ||
|
9340d827d9 | ||
|
612066d96c | ||
|
015e86afcb | ||
|
7c710ba598 | ||
|
5b8fc12163 | ||
|
ab3ed3fbf1 | ||
|
22d5c74818 | ||
|
1321139e7f | ||
|
70ef9e1836 | ||
|
e4cfd92bb2 | ||
|
25ee793208 | ||
|
f7164ddd7d | ||
|
dd2b09830e | ||
|
52ecd79736 | ||
|
c316d49957 | ||
|
68f2277def | ||
|
a2d912bb5a | ||
|
c183315d52 | ||
|
6a5873f8d4 | ||
|
456aed467c | ||
|
256fd89fd2 | ||
|
833ec518b4 | ||
|
1321b95eb1 | ||
|
ca4a2bc7db | ||
|
430ad1acb0 | ||
|
1ce989f3d6 | ||
|
5a1cc4c19d | ||
|
e0634cea6d | ||
|
ebbb8905e2 | ||
|
140628692f | ||
|
e9fcf5a352 | ||
|
3362b2f953 | ||
|
61c672ce4c | ||
|
7628713c4b | ||
|
b903183fff | ||
|
1476f669d3 | ||
|
8c6a40bab7 | ||
|
69c2570ff9 | ||
|
b3e6dce31e | ||
|
be91d5d5e0 | ||
|
e9f136a653 | ||
|
4c10c8499b | ||
|
718218c717 | ||
|
772eeb5c93 | ||
|
ada9fac343 | ||
|
733d206517 | ||
|
4a5c6a42f6 | ||
|
e5428ce525 | ||
|
176acf959f | ||
|
8aaaf5e9e0 | ||
|
ccf02bdba8 | ||
|
9aa56dd193 | ||
|
3efd968058 | ||
|
68b0539fc1 | ||
|
7aaacf4d50 | ||
|
050bd14e46 | ||
|
7ba2eab65e | ||
|
edbae16c8e | ||
|
d6b0a1edc0 | ||
|
a2d61a1daa | ||
|
7144e57c93 | ||
|
1ebb505752 | ||
|
273b815e54 | ||
|
e7d8cfe7e0 | ||
|
be851b8382 | ||
|
58ef43a8ec | ||
|
f6feacfbc9 | ||
|
74335f2b01 | ||
|
df3d7b591d | ||
|
c9d323c83f | ||
|
34bad35cb8 | ||
|
c423326270 | ||
|
4398fa9bda | ||
|
2c922cbae6 | ||
|
55b895146b | ||
|
8b1776fe3b | ||
|
de8c27c970 | ||
|
483838c1b2 | ||
|
cb143117e5 | ||
|
22d2248951 | ||
|
2351403674 | ||
|
018eb8fbfc | ||
|
f49cb9b399 | ||
|
d66a81bc6b | ||
|
8e41b39936 | ||
|
0e5b1a7742 | ||
|
3d3caa7a42 | ||
|
a3da8a7c3c | ||
|
2a96ee98f4 | ||
|
5c6fe08bdb | ||
|
747d5d7c7c | ||
|
3a814a5b5d | ||
|
e35c0b3b52 | ||
|
0af1ff112b | ||
|
4456a771fd | ||
|
86422f90ea | ||
|
7d9908dbd0 | ||
|
ff81b859d1 | ||
|
3cb36a36ec | ||
|
4f19220778 | ||
|
5c6328ffc2 | ||
|
28f0c6b1f8 | ||
|
a6ed8c9228 | ||
|
c1287a4a25 | ||
|
f8d346a404 | ||
|
93033b5b24 | ||
|
18815caed4 | ||
|
9ee7173305 | ||
|
b39e0f304f | ||
|
e17234ecce | ||
|
33bcc1a65e | ||
|
e61591622e | ||
|
11ba65ec4a | ||
|
26f83ac4f6 | ||
|
cca870ced5 | ||
|
fdf123b875 | ||
|
a737ae9f46 | ||
|
43660387fa | ||
|
7729bdd2dc | ||
|
1ae0f0e273 | ||
|
18466afc78 | ||
|
4c801f76b4 | ||
|
6a69f44f07 | ||
|
aa5876fe0d | ||
|
e639cb654e | ||
|
1408908959 | ||
|
cd1d8ecd8a | ||
|
0dbb42aa69 | ||
|
2ebb83418c | ||
|
eac56b1f4f | ||
|
987ebccdfd | ||
|
cf74a195b2 | ||
|
677b20a7ba | ||
|
e3e80a5fd0 | ||
|
8aeb544f7e | ||
|
b9ae919fda | ||
|
f25460a647 | ||
|
28f3694e8f | ||
|
caa3fc06e6 | ||
|
1e645f911a | ||
|
adf2086141 | ||
|
d9bb7d1926 | ||
|
5547b30364 | ||
|
3932a3dbd4 | ||
|
bff4eff719 | ||
|
54c227cf6c | ||
|
edbebb7e67 | ||
|
004671f032 | ||
|
45a965476e | ||
|
bcee49878b | ||
|
35de4c485a | ||
|
4439447a6d | ||
|
e6c6f64077 | ||
|
0acdec787d | ||
|
ce52f21ce9 | ||
|
b3343c210a | ||
|
b4e0e9ebc0 | ||
|
28af2063c3 | ||
|
cce14cbe1f | ||
|
87060488f5 | ||
|
ad18987e65 | ||
|
a40bdc28be | ||
|
082125bd2f | ||
|
21870d7edb | ||
|
85be84071a | ||
|
a9627bb2b6 | ||
|
537962a7dc | ||
|
f7d027ccc9 | ||
|
8759064ccb | ||
|
c16e7c6cfd | ||
|
668f30dd55 | ||
|
45e54789b7 | ||
|
c59de1be2e | ||
|
a038ef91eb | ||
|
74af54f3c0 | ||
|
7c44abdcd7 | ||
|
5af92a7d81 | ||
|
2ee067c072 | ||
|
39d7f1055b | ||
|
a3b18e5bea | ||
|
59f3936dad | ||
|
450b140f5f | ||
|
f21711f3dc | ||
|
cd8bb72f94 | ||
|
837a4d8949 | ||
|
8952b100ad | ||
|
2d724bf2c8 | ||
|
374c25ffb3 | ||
|
96cf1a5f7f | ||
|
ae40999700 | ||
|
30d73d6362 | ||
|
97e0a78806 | ||
|
d812776357 | ||
|
9a49c0b8fe | ||
|
70eec63533 | ||
|
6ef2beed8f | ||
|
a15230e7ab | ||
|
a21466d877 | ||
|
89b30fc50d | ||
|
9060abde8e | ||
|
085b9aeb2a | ||
|
c0383bcf26 | ||
|
0938368e30 | ||
|
272658e5dc | ||
|
861fb7abbd | ||
|
2d88675f42 | ||
|
bfa88c3406 | ||
|
784c081663 | ||
|
8318621d51 | ||
|
e924061c54 | ||
|
25a0276bf7 | ||
|
c74d972caf | ||
|
57b74a5d09 | ||
|
9577955d2d | ||
|
cf508fd8b6 | ||
|
2f53cef36f | ||
|
af68fa6c42 | ||
|
231d3e65c4 | ||
|
00de66cd79 | ||
|
b6449ad296 | ||
|
d1e1937195 | ||
|
245627a347 | ||
|
a429a98a29 | ||
|
b1bb6fab5b | ||
|
21b9d0efab | ||
|
4c429cd519 | ||
|
0cb20d89ed | ||
|
8029ee49a4 | ||
|
4406e53121 | ||
|
dca7205a47 | ||
|
04e8bb248b | ||
|
51fe44f877 | ||
|
00ba3b0c48 | ||
|
7508d86c73 | ||
|
8d853815d6 | ||
|
1208694d2d | ||
|
96be4e8992 | ||
|
7310cf3d4a | ||
|
8922b370cc | ||
|
fecf976ab9 | ||
|
0823414360 | ||
|
c6eac97b64 | ||
|
6706fe7350 | ||
|
a7c8b8aec4 | ||
|
5dec6b4a22 | ||
|
a8d7e91a02 | ||
|
fec4e19c1d | ||
|
0568322c82 | ||
|
42548cea2a | ||
|
879d6fb2dd | ||
|
2a17bcb8b2 | ||
|
7c1e663b26 | ||
|
2c3cd34444 | ||
|
e0ebdc644d | ||
|
ee76f4188b | ||
|
58e671e640 | ||
|
bc1ec414de | ||
|
5514eeff2d | ||
|
7a9b159909 | ||
|
74b6df2e44 | ||
|
26aba26da5 | ||
|
7c8b33597a | ||
|
3660830ec1 | ||
|
83696cca21 | ||
|
d06b725f52 | ||
|
149204f6ca | ||
|
5a9d8e3f5d | ||
|
37d2be9384 | ||
|
5df594e46a | ||
|
91e5abe76a | ||
|
27b46f4306 | ||
|
d336383a93 | ||
|
a3569280a4 | ||
|
ccb6fd291e | ||
|
849402ed70 | ||
|
7dddff52b8 | ||
|
40f1c09002 | ||
|
ec90b041ee | ||
|
c202c5de68 | ||
|
aad5f6528b | ||
|
3e1e84ee5e | ||
|
f83b62cf50 | ||
|
d658a48b66 | ||
|
876abef040 | ||
|
74c9406191 | ||
|
a0402830c5 | ||
|
e1f19c52ab | ||
|
7debc4925e | ||
|
1e3a0ca3d9 | ||
|
c7452796f0 | ||
|
1369f3b967 | ||
|
1d948821ca | ||
|
0318f7a12b | ||
|
84432e5ac4 | ||
|
851cffd73e | ||
|
1d1b09c938 | ||
|
8f338a8d88 | ||
|
7ea6777d6b | ||
|
ecacce0796 | ||
|
71dfcc4dd9 | ||
|
6c64c9f1cd | ||
|
6facf3b7a7 | ||
|
62e72b2091 | ||
|
4dad954820 | ||
|
f0727a65fc | ||
|
c7be227865 | ||
|
cf58fc9fd4 | ||
|
996b4795ea | ||
|
7e00f29189 | ||
|
1ff453d64c | ||
|
e4c66e08f5 | ||
|
3fd07da1b0 | ||
|
eb070f0b07 | ||
|
c88621de19 | ||
|
2e96721a5c | ||
|
0a5fb4752a | ||
|
cae2154893 | ||
|
926929880a | ||
|
9c15d5b96c | ||
|
3d073da97e | ||
|
d63dd12056 | ||
|
133e7a9c3f | ||
|
98861ccc19 | ||
|
1e11491369 | ||
|
7c798a063c | ||
|
03e07037ea | ||
|
2acc1a8433 | ||
|
9dd23b4a08 | ||
|
e4f46c48f1 | ||
|
cb08a114ae | ||
|
e7f369e2b4 | ||
|
f31db2f9ed | ||
|
b21051ced5 | ||
|
ef77c7c9a3 | ||
|
36fa9078f5 | ||
|
a80d1f194c | ||
|
d7793841d1 | ||
|
4b513a894d | ||
|
eeed9eef10 | ||
|
305acbb18f | ||
|
5d8f5d41fc | ||
|
3e976eadac | ||
|
51ceb62871 | ||
|
a9ea335cd1 | ||
|
a040df2732 | ||
|
2e3c2d4dcb | ||
|
5ff847fba3 | ||
|
f641569bcc | ||
|
8e4dd407f6 | ||
|
b88f9a4fc1 | ||
|
86cf956894 | ||
|
e4d6bb35b5 | ||
|
902d9e140c | ||
|
9698895c22 | ||
|
a2da319e7c | ||
|
1dbef921b0 | ||
|
59aa76a474 | ||
|
99bff6b794 | ||
|
5735864fd1 | ||
|
8903b1ef95 | ||
|
3255806891 | ||
|
ba7d0f45db | ||
|
490115d890 | ||
|
803091db06 | ||
|
31db330319 | ||
|
b1ccee73fd | ||
|
74ce98913c | ||
|
26a2eb2391 | ||
|
6f2e2a3bbb | ||
|
539bfba70c | ||
|
e5777f02d8 | ||
|
1b029ce8dd | ||
|
4faab4fcdc | ||
|
0f49effade | ||
|
7773234138 | ||
|
91bb4dfab2 | ||
|
97b648a51e | ||
|
b785d4b047 | ||
|
90e1fdb586 | ||
|
dc89d5d4d0 | ||
|
b9f0da9d3b | ||
|
6e3b8fdd4d | ||
|
465e219bfc | ||
|
18f2550e4d | ||
|
93739e7990 | ||
|
51380febd4 | ||
|
cffd5dcd31 | ||
|
0caa5e24e8 | ||
|
25eca71846 | ||
|
535e50eeac | ||
|
bca34dad60 | ||
|
a8da5719fe | ||
|
7a38d67c5b | ||
|
7a22c7d76a | ||
|
8d1cebf4db | ||
|
b6e636cbc0 | ||
|
5bf135760e | ||
|
74a0479cbd | ||
|
52a89d0783 | ||
|
d553aae71e | ||
|
5365fa6175 | ||
|
d5ac560f0c | ||
|
de74b2987a | ||
|
d390b39e0a | ||
|
d6d1e8e86f | ||
|
1c323c5a7f | ||
|
3eb1b66e9a | ||
|
c72bf506c3 | ||
|
432ee387ec | ||
|
a5812a5a73 | ||
|
5dcaae7af6 | ||
|
480371cf9f | ||
|
f50b4775a1 | ||
|
78780a9219 | ||
|
7da4eb8fe9 | ||
|
bea94d58c5 | ||
|
1c73d21925 | ||
|
b476a7e3f8 | ||
|
baa27a3c85 | ||
|
20fd286756 | ||
|
552f9add70 | ||
|
3bea983662 | ||
|
6929076740 | ||
|
e1775681aa | ||
|
ec4d0f6b4a | ||
|
b9a667b126 | ||
|
571cf80e13 | ||
|
3313b55853 | ||
|
650aa68bcd | ||
|
7736f1e3c1 | ||
|
0cd61eb214 | ||
|
2530171721 | ||
|
009c85b61a | ||
|
7a0d64e72f | ||
|
40a22b31f3 | ||
|
8ea9a79760 | ||
|
e6db99e810 | ||
|
571d3e71b5 | ||
|
b7790a9678 | ||
|
88bf678ce3 | ||
|
8b7cd20b6f | ||
|
3158740ea3 | ||
|
258b2a318f | ||
|
aa3647e0f3 | ||
|
d18dd5b8fb | ||
|
645cfc65f4 | ||
|
97b38c156f | ||
|
c6dc852cd8 | ||
|
ef127ea335 | ||
|
43bbc9ec24 | ||
|
2439317408 | ||
|
f4ebb2b504 | ||
|
a9f846e8fc | ||
|
099764a931 | ||
|
09e8993cd4 | ||
|
dd6c5dc97a | ||
|
2fef413d88 | ||
|
474304d284 | ||
|
6791da0fc8 | ||
|
c850cfe97f | ||
|
51c843d765 | ||
|
03d98a7ad7 | ||
|
0cbc0010c1 | ||
|
fc8487dca0 | ||
|
b67a26ad61 | ||
|
39c312cf9f | ||
|
1196ec4375 | ||
|
634196d8f1 | ||
|
36bfbe8f42 | ||
|
a0f62ba172 | ||
|
ba5dabd613 | ||
|
00c9fa61c3 | ||
|
4f3202f90b | ||
|
98a0ed99c9 | ||
|
4d7df00a68 | ||
|
f51ad2224b | ||
|
0972de9025 | ||
|
f2764e9258 | ||
|
2537663a57 | ||
|
0cf9a90cfb | ||
|
4f6d478211 | ||
|
06ced7042d | ||
|
c37997bcb7 | ||
|
c2db558b85 | ||
|
097000c9da | ||
|
d216b298ba | ||
|
56e9b5fa2f | ||
|
c9c3a95d2a | ||
|
87561503c1 | ||
|
68a949de35 | ||
|
33edd3c0fb | ||
|
c3d09e5323 | ||
|
97fa5fa636 | ||
|
fb67010c0e | ||
|
5bf39a7a92 | ||
|
2c97be815b | ||
|
159723ed0c | ||
|
ce3d092497 | ||
|
99009f841b | ||
|
bf64f5b3a9 | ||
|
770a8d049c | ||
|
a00857cb45 | ||
|
59565416b6 | ||
|
8c2f3c56d3 | ||
|
814c4aa01d | ||
|
62728e52b7 | ||
|
63a5241b2e | ||
|
c58ed8bd2c | ||
|
c3eaf0351b | ||
|
59ca1f7640 | ||
|
d00fe7bcd2 | ||
|
186befd0ac | ||
|
ec7263da18 | ||
|
f2f77cb51e | ||
|
e5aef763cd | ||
|
aef14e49bb | ||
|
cd520e6cfe | ||
|
d56435b9cd | ||
|
4002c23bee | ||
|
997d68a574 | ||
|
34e8138e50 | ||
|
428d9a3692 | ||
|
2ff2d6c1fc | ||
|
5c49461449 | ||
|
c80f82a3f7 | ||
|
972f215f0c | ||
|
5d14d79e6e | ||
|
b57c84bbd9 | ||
|
4e1fae5b5f | ||
|
0b711be480 | ||
|
69c49679f1 | ||
|
0085ffcb0b | ||
|
0a9df3ac6b | ||
|
aeea66491a | ||
|
456d9398a1 | ||
|
dcc3c61f52 | ||
|
0f7f55ec0a | ||
|
e4239d0122 | ||
|
facb19a347 | ||
|
96a378ec4b | ||
|
79be0c555b | ||
|
3cb28cdecb | ||
|
3cbf5a6f7d | ||
|
20ab313c6c | ||
|
88535e5512 | ||
|
df858f916b | ||
|
d2b634c775 | ||
|
8ebccd05ec | ||
|
80fd38990f | ||
|
7ad8af848a | ||
|
e2eae01ad8 | ||
|
38d9e8190c | ||
|
af4c442105 | ||
|
9311652bed | ||
|
daba28423a | ||
|
dc95587cca | ||
|
4e8b94a28c | ||
|
b9f347b7f4 | ||
|
ad75ecdc87 | ||
|
daa86fa330 | ||
|
99326eb65a | ||
|
3f6ca6c8ed | ||
|
6e93f11a59 | ||
|
61ae481a03 | ||
|
8c537537a1 | ||
|
b5b77be188 | ||
|
d7b021b79f | ||
|
654790315c | ||
|
35df201e2e | ||
|
e591de8b29 | ||
|
4d953d58a1 | ||
|
dc26db2864 | ||
|
3d30a1adbc | ||
|
05c9d3513a | ||
|
52a2a3d842 | ||
|
521c479abf | ||
|
818c90a95e | ||
|
5f77a026aa | ||
|
63538ae925 | ||
|
0b9ca6b7ee | ||
|
c07daafb8d | ||
|
847d3d0f27 | ||
|
5715b0e44a | ||
|
1e3c5cb936 | ||
|
914fc476ce | ||
|
49541d3eec | ||
|
592125b5e7 | ||
|
e7f1d3924b | ||
|
5649161348 | ||
|
fd308151b3 | ||
|
85e55312ca | ||
|
98806a806f | ||
|
8fb3b42ea1 | ||
|
a910e5dc17 | ||
|
012b67e3c5 | ||
|
abd344b951 | ||
|
1f8aef2891 | ||
|
da977f62a9 | ||
|
5892ccee97 | ||
|
d43b9e1836 | ||
|
e0196f7107 | ||
|
b3b06896be | ||
|
48ac21ffad | ||
|
bf3ba8ac3f | ||
|
bba9f9a555 | ||
|
7e0634aee0 | ||
|
f05db0ef0f | ||
|
db3b0c2cf5 | ||
|
d9ddabcfd4 | ||
|
67139b99f9 | ||
|
5e89628593 | ||
|
f11c9a3341 | ||
|
ced404eb74 | ||
|
60ebadbbe5 | ||
|
f47b70dd3c | ||
|
de6d5b388a | ||
|
1c80bf1faf | ||
|
97e3de4e0f | ||
|
d90901b4e3 | ||
|
f3704633ee | ||
|
5988dd1e48 | ||
|
16f4fb9490 | ||
|
4d153755c1 | ||
|
1e66f4d140 | ||
|
33906adfe4 | ||
|
f52da72115 | ||
|
edae709f5f | ||
|
912ccad530 | ||
|
c93f9c5483 | ||
|
798253f887 | ||
|
2d3ca47b52 | ||
|
7e46188107 | ||
|
d83e103fab | ||
|
5bc905b358 | ||
|
b4c6b99e09 | ||
|
756115ba54 | ||
|
fab83cfc33 | ||
|
aa3101baa9 | ||
|
82419d0b92 | ||
|
a7d80d62cb | ||
|
a761f8c65e | ||
|
280308b625 | ||
|
b5d8acfef3 | ||
|
3c9108de0d | ||
|
c24b4e77a8 | ||
|
d45edb7887 | ||
|
e700697423 | ||
|
f8a74aa438 | ||
|
6563082746 | ||
|
5e8b9711dc | ||
|
96c0876053 | ||
|
164d9ef079 | ||
|
53d89fa4ac | ||
|
b83caf4dd9 | ||
|
cfeb50826c | ||
|
6901507461 | ||
|
0b06ded5e5 | ||
|
b4e8c5d602 | ||
|
ec84245dd4 | ||
|
0819c3918f | ||
|
ae2e7dfe30 | ||
|
87f6949d80 | ||
|
003301762c | ||
|
d6cf4332da | ||
|
be01a15230 | ||
|
079a2a3936 | ||
|
5812d8ed2e | ||
|
779b6dfc0c | ||
|
bdea739c55 | ||
|
693eb96d23 | ||
|
ada3f0787c | ||
|
d3da6de5dd | ||
|
aa6d0d1750 | ||
|
05b0ca5cdb | ||
|
b6a70641a0 | ||
|
1aaae93113 | ||
|
b1c4f018f9 | ||
|
013ff1d941 | ||
|
f32e995baa | ||
|
b506e96548 | ||
|
ad46a60c4f | ||
|
7e4f4b9a87 | ||
|
0c2bcceae2 | ||
|
af25a6c795 | ||
|
ec0e25e5ed | ||
|
3107c8fe30 | ||
|
24124ac86a | ||
|
06948bb98b | ||
|
64462d6ab4 | ||
|
e4f8c14fab | ||
|
d8f96876a0 | ||
|
d82c7d7f3e | ||
|
d982d0332c | ||
|
df91310d0f | ||
|
e389f4cc3b | ||
|
9840742927 | ||
|
312b244e2a | ||
|
a1d5d161dd | ||
|
6ad43b02c7 | ||
|
1f655acddb | ||
|
6c89e5f18f | ||
|
f4e4582913 | ||
|
6c8c068327 | ||
|
64f2dbbe71 | ||
|
f43df42449 | ||
|
71b20eb61a | ||
|
7f42796724 | ||
|
71880dfc98 | ||
|
408027dd6a | ||
|
2116b86aec | ||
|
56a579ff91 | ||
|
abde013ab6 | ||
|
5f074206de | ||
|
5899c1f3c0 | ||
|
135160dd92 | ||
|
a1d51e3778 | ||
|
f800570845 | ||
|
d319b654ce | ||
|
63d8e6739b | ||
|
d3d472f5d2 | ||
|
6fb9849007 | ||
|
163c990e9d | ||
|
c3a0326b1e | ||
|
e13f4d3d4d | ||
|
2c80133856 | ||
|
de53a13c84 | ||
|
624df76393 | ||
|
7cace82b83 | ||
|
87170894e2 | ||
|
83cb0a6130 | ||
|
bfb11339ca | ||
|
08fd27cb26 | ||
|
3b953a7c21 | ||
|
23b704ffe0 | ||
|
ca5ca9b2b8 | ||
|
7474c0a0fd | ||
|
4b4734531f | ||
|
cded3f50ff | ||
|
80b27fdf6e | ||
|
daca6ef482 | ||
|
91bec9c996 | ||
|
96e9f749d2 | ||
|
6603effd1b | ||
|
03858e4a8c | ||
|
8aa360c853 | ||
|
21c08aed30 | ||
|
2ad7266283 | ||
|
7a041fd753 | ||
|
f7151f131d | ||
|
8f5e51a304 | ||
|
aba818a9de | ||
|
260f4641dd | ||
|
edee910e2d | ||
|
6b5b9b42f5 | ||
|
c3b825cc44 | ||
|
a3f150b1d9 | ||
|
528dd2b28a | ||
|
5ddf496dae | ||
|
aa554ca9f6 | ||
|
ace39ef73d | ||
|
49dcd97d70 | ||
|
75a1d606cb | ||
|
302a635542 | ||
|
c35d0a8bc6 | ||
|
44afa92b58 | ||
|
e45d81513c | ||
|
0870397fea | ||
|
202132868f | ||
|
d65a60984d | ||
|
45b883477d | ||
|
b60892fada | ||
|
c8361f1748 | ||
|
b517f7cfa7 | ||
|
2b13085dff | ||
|
0013f76873 | ||
|
83e9408d69 | ||
|
bacd546e5d | ||
|
61094ea17d | ||
|
b2c89d36cf | ||
|
921ac4b2a9 | ||
|
b48e910f70 | ||
|
bab828412b | ||
|
1f0983a145 | ||
|
4aface583d | ||
|
2152e5286a | ||
|
58d6286361 | ||
|
6124ea01f6 | ||
|
6d3490cd68 | ||
|
af6552958f | ||
|
f9aab39039 | ||
|
fc9e261601 | ||
|
e9ad30cc74 | ||
|
2684c8bcca | ||
|
6c070464dd | ||
|
b5ef7490c3 | ||
|
6dcad6225b | ||
|
b6c8390a46 | ||
|
a1e03c3a25 | ||
|
93b9ace477 | ||
|
74760b1062 | ||
|
61cbb07bd5 | ||
|
12567074cc | ||
|
4b3370e374 | ||
|
0d282a962c | ||
|
a203f43142 | ||
|
c236eb15b1 | ||
|
2bae7dc200 | ||
|
55775d9d37 | ||
|
c256e9c0cc | ||
|
f6d2c56e43 | ||
|
a103a2ee2c | ||
|
d1ad0716c8 | ||
|
b501776e33 | ||
|
dcd2ccae1b | ||
|
8793288dc8 | ||
|
f2a7a145e4 | ||
|
61a21d34b2 | ||
|
47a27bf3fe | ||
|
781de79b97 | ||
|
e2a72dd0a2 | ||
|
f2a16afc90 | ||
|
65e4f24531 | ||
|
39c38a669e | ||
|
db537a97ba | ||
|
229d270d25 | ||
|
eb4906cb97 | ||
|
d012561c50 | ||
|
906cfc29c8 | ||
|
a247e6d0de | ||
|
f393246e4f | ||
|
281b712258 | ||
|
b5f0b58898 | ||
|
07bfdadd25 | ||
|
c1d77f48e3 | ||
|
1edc1993e1 | ||
|
bae55828a1 | ||
|
60f4e43cf3 | ||
|
a3975080a1 | ||
|
7feacbd961 | ||
|
7b6344d976 | ||
|
32cb19d01f | ||
|
1bc49dc0a2 | ||
|
349772a2f9 | ||
|
916618be31 | ||
|
6d8ad74b4d | ||
|
7d24a3e4a2 | ||
|
eed7990c3c | ||
|
2543bdcdfc | ||
|
38c26f8b5c | ||
|
feba0b58ee | ||
|
a6cbb6b759 | ||
|
1ca73ecd4d | ||
|
ec682788e0 | ||
|
0be38c4e09 | ||
|
50447cf8d3 | ||
|
d54a72c431 | ||
|
dd9d24e657 | ||
|
2610f32521 | ||
|
47579e8509 | ||
|
9c49f2e2d7 | ||
|
36851ae9f9 | ||
|
64c83c4ef0 | ||
|
590c63e911 | ||
|
17c9beca28 | ||
|
2f02e4d3e0 | ||
|
44d993a588 | ||
|
a9018d77c7 | ||
|
6e1aa4b0f4 | ||
|
be64bf71a7 | ||
|
d9279e42cc | ||
|
6a28643215 | ||
|
27a544205f | ||
|
8daf1b2ba8 | ||
|
a93e64c830 | ||
|
0c328bc398 | ||
|
deaa595f07 | ||
|
4eba3c8124 | ||
|
eb6b1b9f89 | ||
|
709ce5377a | ||
|
ee01328553 | ||
|
5ebd4498a0 | ||
|
095af10d4f | ||
|
f4b7b9efd0 | ||
|
67b3450924 | ||
|
9240cd3d1c | ||
|
98192ee580 | ||
|
664e55a40b | ||
|
45fb3803c1 | ||
|
e1b6619e9c | ||
|
7a49549389 | ||
|
f08d6bda93 | ||
|
a4e2cce4aa | ||
|
55c91dfcdd | ||
|
e868f0a15a | ||
|
9075a6f33a | ||
|
87b669e358 | ||
|
a92eda3af2 | ||
|
9a11f55762 | ||
|
83d8f18bd7 | ||
|
50eee33a6e | ||
|
f1eea66588 | ||
|
737d803903 | ||
|
18abad38b6 | ||
|
cc1431da60 | ||
|
490eabf977 | ||
|
e3f7f0efda | ||
|
b3f4c2f009 | ||
|
9e90f849a8 | ||
|
96a378f25f | ||
|
1f2bdf40d0 | ||
|
10c510fc6b | ||
|
68343701ca | ||
|
5c166b9dd5 | ||
|
38aad40569 | ||
|
dd9fdc381f | ||
|
24896e44b4 | ||
|
5fd42df1ed | ||
|
43b30e6d04 | ||
|
0882f1c0d6 | ||
|
b8d7c2ee17 | ||
|
24fac1fc0b | ||
|
ed9a2c0d35 | ||
|
90a75985dd | ||
|
61300e93a4 | ||
|
7b60cc63ce | ||
|
9b252b93ab | ||
|
dd6f5e5ef4 | ||
|
52d688885d | ||
|
86c256cbf7 | ||
|
a2a08b90ff | ||
|
1e68267e8e | ||
|
098f20ccad | ||
|
89d48d6c34 | ||
|
99fcfa6be7 | ||
|
9586e81e95 | ||
|
fd7384a099 | ||
|
67edc7b639 | ||
|
5e1ed17cdf | ||
|
f294189e20 | ||
|
162e73912e | ||
|
5c6a143614 | ||
|
78ceac0659 | ||
|
4700ceb14c | ||
|
6462d4a2ed | ||
|
eb9b14d6d5 | ||
|
83c5f9b323 | ||
|
f2df32e710 | ||
|
900fc75506 | ||
|
4de22acb3e | ||
|
80ae551ca9 | ||
|
fc06b03af8 | ||
|
d063e209dd | ||
|
480b3e7c54 | ||
|
43b1096313 | ||
|
67a05c2f1b | ||
|
581a42f288 | ||
|
e7e686d579 | ||
|
c1ca1471a1 | ||
|
fdde73710e | ||
|
d9f42caa6a | ||
|
ed0544212d | ||
|
93b293ca0e | ||
|
50c5f8b6eb | ||
|
b1b016f9e0 | ||
|
d6136a9937 | ||
|
53ddb1243b | ||
|
c3bc25a4b9 | ||
|
999c1cd8e3 | ||
|
e456b9a855 | ||
|
3eee4a4103 | ||
|
3ff8b26312 | ||
|
d6e808e1a3 | ||
|
cfbb78af48 | ||
|
a22b29ad6d | ||
|
7f8617832f | ||
|
b8748fd49a | ||
|
93b2900015 | ||
|
a23c744c3e | ||
|
2591655269 | ||
|
e969540c72 | ||
|
54b4f97a84 | ||
|
de20ee9fb9 | ||
|
2d1e76eae8 | ||
|
434b8b9dbe | ||
|
83a02c4b20 | ||
|
a6143c1abb | ||
|
029021b351 | ||
|
6cd8b04bd0 | ||
|
b71944607b | ||
|
cb25a7752d | ||
|
3a6d28e2c2 | ||
|
270a5fc139 | ||
|
5eca9def9d | ||
|
4d1c50a6cc | ||
|
7f2bbdcb87 | ||
|
f0fbdf1b42 | ||
|
a9e74e7111 | ||
|
9bff858696 | ||
|
b26648c1ce | ||
|
53b4a28944 | ||
|
c39e3aedfa | ||
|
af2b148b34 | ||
|
790fdad1e3 | ||
|
22f917e250 | ||
|
e712ad8289 | ||
|
d78bbcb3df | ||
|
579dcd81dc | ||
|
9839b7b5a4 | ||
|
8fdc44f7f3 | ||
|
960f8a1b3d | ||
|
7dea9cbfa8 | ||
|
90d7f55c6d | ||
|
18b8758191 | ||
|
218b18254c | ||
|
1a6afaf44f | ||
|
cc52bff05e | ||
|
2dce3e15a1 | ||
|
b9931e65da | ||
|
cb68530e2a | ||
|
d29115b05a | ||
|
5034a43c3c | ||
|
3165e42119 | ||
|
b0b8c6e98b | ||
|
7fc1ec6bd2 | ||
|
c5efd5b7d0 | ||
|
a5a0a1370a | ||
|
fc7f19e785 | ||
|
2fbbc66029 | ||
|
7bbc425690 | ||
|
19d12c949a | ||
|
3b4666ba3e | ||
|
8132fa595b | ||
|
2d79d7f8db | ||
|
8c3c30c707 | ||
|
63528aa0f3 | ||
|
7f9b0557c4 | ||
|
c18a0378e9 | ||
|
2f434c849d | ||
|
0b585d1c98 | ||
|
4107d5fedb | ||
|
1e904f567a | ||
|
54356b8d2f | ||
|
c1765ca0cb | ||
|
3b6ba76db6 | ||
|
0067bee94b | ||
|
2e5d852a77 | ||
|
11f6a57c54 | ||
|
fa86f5e89a | ||
|
5e768aa57c | ||
|
b7cbd2a431 | ||
|
4edad9f19b | ||
|
3123021d94 | ||
|
da81035e58 | ||
|
8357361038 | ||
|
f224fc2e28 | ||
|
969cdcaa16 | ||
|
b7dbcaaadf | ||
|
e7abe709b3 | ||
|
8d7bf6fb64 | ||
|
8ced159d9a | ||
|
ebc4bd6bcf | ||
|
b4e09e37b1 | ||
|
db3c65a974 | ||
|
d8a0cc281d | ||
|
603bec9e88 | ||
|
4f9e303daa | ||
|
f0d4e9940c | ||
|
17ac6c58b2 | ||
|
b5810481d0 | ||
|
8cc0cf160a | ||
|
970800bd31 | ||
|
00c2012ccf | ||
|
9757ed1d8b | ||
|
211905c27f | ||
|
75907f6c18 | ||
|
b569f67fc1 | ||
|
28c8cc6863 | ||
|
cdd8af241b | ||
|
4a1a907b37 | ||
|
6cc2d8af58 | ||
|
4eedf65b21 | ||
|
6dcbc92a66 | ||
|
ba39eb114c | ||
|
6f789c9363 | ||
|
fee36a378c | ||
|
16ac25bb77 | ||
|
4ea7b6692a | ||
|
237a6c4d2a | ||
|
6a35d3bf2d | ||
|
e5e13cc598 | ||
|
8276046f8e | ||
|
a785fe4f83 | ||
|
8b1d132e17 | ||
|
c58e75f49a | ||
|
4902321cd3 | ||
|
495cbef995 | ||
|
eb02207c56 | ||
|
a1ea864799 | ||
|
3b3717d307 | ||
|
67d0a6c0c2 | ||
|
7a09365f00 | ||
|
0df4ca8f1e | ||
|
402f80b420 | ||
|
5b02485f4b | ||
|
7e999881c5 | ||
|
a8b874a32f | ||
|
9a97da72d8 | ||
|
d4f2a81735 | ||
|
1b3b4eb6d8 | ||
|
5add7eea49 | ||
|
d572efad1a | ||
|
9004c694ca | ||
|
dca957708c | ||
|
1075fec53f | ||
|
08632a3a07 | ||
|
24176c864d | ||
|
833dd37469 | ||
|
bb934d8390 | ||
|
83ded17625 | ||
|
7679849c7d | ||
|
e567782a7d | ||
|
e0a40d4d24 | ||
|
732a474cc9 | ||
|
172f14c16f | ||
|
61a2bcb609 | ||
|
0820cc8f4d | ||
|
a8ae724159 | ||
|
f063d5cd24 | ||
|
2d3088bfc3 | ||
|
5d6bdff988 | ||
|
73b048a5dc | ||
|
60bb892601 | ||
|
6bb1a1f9ea | ||
|
b99f9dd193 | ||
|
8219929227 | ||
|
ecbfed049d | ||
|
67abb942a0 | ||
|
d2a1af7c15 | ||
|
6c6f03e622 | ||
|
c2945f11b7 | ||
|
a15d39110b | ||
|
f295e0a537 | ||
|
fb10e9cddc | ||
|
b1597c0f24 | ||
|
6a73dc042c | ||
|
0c1ca11304 | ||
|
781506129c | ||
|
c45da8c334 | ||
|
730b7272ce | ||
|
e4f1d7cae1 | ||
|
c3b15ac5dc | ||
|
cc4b9abd9f | ||
|
26921451a8 | ||
|
b405bd453a | ||
|
38c63fb3ee | ||
|
4f96b9ef63 | ||
|
cb70ab3675 | ||
|
a3663d03e8 | ||
|
cb64703905 | ||
|
b08cdd495f | ||
|
be777ba122 | ||
|
9945738811 | ||
|
da2c6ae037 | ||
|
0ecff1b581 | ||
|
92b368f11e | ||
|
be094ef8e5 | ||
|
e49f614acb | ||
|
716e00374c | ||
|
af3895de79 | ||
|
c4e3376313 | ||
|
dd4444caf9 | ||
|
d9f0428e41 | ||
|
64542f775a | ||
|
dcaddd6a1a | ||
|
05f1da430c | ||
|
e2d7e94e4c | ||
|
e6a1046039 | ||
|
a34a32d790 | ||
|
f3d4827115 | ||
|
68da02ec00 | ||
|
72f4a2f603 | ||
|
aaef9842d4 | ||
|
816fc5d64c | ||
|
0d2204bb02 | ||
|
246aa5c214 | ||
|
5beda1ded7 | ||
|
4ad04869a1 | ||
|
515928a69a | ||
|
3d39b705ae | ||
|
e34d34080d | ||
|
8fce8d5f23 | ||
|
6ac129a0b8 | ||
|
a7dca6a163 | ||
|
49bd954945 | ||
|
1ab17bbbf0 | ||
|
789c9aa32a | ||
|
457db07da4 | ||
|
f4a66263dd | ||
|
00d7e622df | ||
|
d8dc91d4b7 | ||
|
3a6960c71b | ||
|
6956f0d730 | ||
|
ee816d6552 | ||
|
789bbced5f | ||
|
89784bf5eb | ||
|
8bdc33f683 | ||
|
9cccc08021 | ||
|
f1c3914807 | ||
|
15882904eb | ||
|
ad1a40ba3e | ||
|
fba3905724 | ||
|
f2c6c8c483 | ||
|
a68e943d0b | ||
|
e28dfaaa80 | ||
|
86581a421a | ||
|
25c1e9c3a3 | ||
|
077bd946ff | ||
|
ead13b4e08 | ||
|
05c6575ebb | ||
|
c59d93979c | ||
|
6fac56d2c9 | ||
|
30eac1bd96 | ||
|
2564eb9c26 | ||
|
3858f8fbea | ||
|
699bddcb2a | ||
|
8634af702a | ||
|
64f04185d4 | ||
|
bdb3bbd960 | ||
|
65bc0f0f86 | ||
|
65a879d5ab | ||
|
3d18b12ede | ||
|
f52b756163 | ||
|
a2eece5f5c | ||
|
5a2ff18859 | ||
|
01adf50ae1 | ||
|
52dd68303a | ||
|
b231d0968f | ||
|
88bf22622d | ||
|
ad820913f7 | ||
|
c9a4fa8679 | ||
|
902bdc96b2 | ||
|
4e83aa1431 | ||
|
f809acd6fd | ||
|
d7e52c1969 | ||
|
21d6815de1 | ||
|
0cd9943e0d | ||
|
45eb5a3e63 | ||
|
470e36a5a3 | ||
|
a31766b020 | ||
|
bc752b853a | ||
|
323a62f041 | ||
|
61d7f0eca0 | ||
|
936cabe353 | ||
|
7e37fc776c | ||
|
ad6594f0bc | ||
|
ac763de16b | ||
|
00cbec2309 | ||
|
66cf69e425 | ||
|
879ab272e0 | ||
|
18044e7302 | ||
|
43be03617a | ||
|
82b189aa48 | ||
|
244bbc51b2 | ||
|
60e830974e | ||
|
0f0390cb6a | ||
|
2ac7caaf24 | ||
|
4aec46f880 | ||
|
85ad343d5d | ||
|
a7a482eecd | ||
|
849e7d03a8 | ||
|
d9eb9798e5 | ||
|
13826b5759 | ||
|
44b3579cc7 | ||
|
caa43856af | ||
|
587357c13f | ||
|
6aa639591b | ||
|
1976bc755e | ||
|
07f2d390e5 | ||
|
37c7f909a3 | ||
|
773465c6c5 | ||
|
43b0fe6749 | ||
|
9e66daa861 | ||
|
e712a054ae | ||
|
004dd7168e | ||
|
a39b1e502c | ||
|
96db414ca1 | ||
|
3d31641050 | ||
|
a42a0f086c | ||
|
cfd6af7c72 | ||
|
11974f68fc | ||
|
93bb1dd519 | ||
|
5152be57ba | ||
|
cd12628565 | ||
|
069b88d6fd | ||
|
33ddd86add | ||
|
e3eb43a14b | ||
|
f8c44efeba | ||
|
b89753e1fe | ||
|
7572e07489 | ||
|
00f142ec7e | ||
|
49859e6f00 | ||
|
c1bda8a775 | ||
|
749f7aad40 | ||
|
397d90c6b7 | ||
|
0f2a311b74 | ||
|
bbb9a2c1fa | ||
|
06c5c97a03 | ||
|
5a4bb65d80 | ||
|
5af2e1fef0 | ||
|
5b142baa98 | ||
|
4fbc7703ce | ||
|
e1b1f30c55 | ||
|
9b4974a3da | ||
|
31a0a378ef | ||
|
c40f2904f0 | ||
|
311b39ffe9 | ||
|
f14bb63393 | ||
|
c2f993ddf2 | ||
|
78a359407d | ||
|
699b03eb42 | ||
|
b5057f4028 | ||
|
536ef180ce | ||
|
29a09ad276 | ||
|
2c4aa6152e | ||
|
59830579a9 | ||
|
1c980ba678 | ||
|
35c373f6ce | ||
|
dec286583a | ||
|
9f1fe3ee17 | ||
|
7c4ec2a8e3 | ||
|
30adb5e1f8 | ||
|
9cb24c9f3c | ||
|
b236ebdbd9 | ||
|
a840143990 | ||
|
c8bf71d40d | ||
|
3d9d60e8fe | ||
|
d8af8accbb | ||
|
cee8e8b892 | ||
|
c640b4c830 | ||
|
6106eeee95 | ||
|
5bcff4171b | ||
|
a4330cfdf2 | ||
|
2fb1c4bb11 | ||
|
3bc4e7b336 | ||
|
5978f4b1cb | ||
|
23944bf47a | ||
|
90a8de09d7 | ||
|
4c81106612 | ||
|
29a05ffff2 | ||
|
c3a5205d8e | ||
|
9076b625e3 | ||
|
45f92379bc | ||
|
2ea7ddc1aa | ||
|
80d5607984 | ||
|
86625798cd | ||
|
279b139556 | ||
|
15d203977a | ||
|
e5ce17c2ad | ||
|
3e25faf74c | ||
|
1e0845f4b9 | ||
|
420ea9e90e | ||
|
5217270073 | ||
|
09e93779fb | ||
|
7b0be014eb | ||
|
6f23c16df7 | ||
|
38fa58406d | ||
|
eb68d059e2 | ||
|
b8b1c0d056 | ||
|
0c3fa9f065 | ||
|
1334840ee0 | ||
|
f0d44be2f4 | ||
|
f3be3b1f3c | ||
|
d117ff600a | ||
|
959ee5f8d1 | ||
|
d69f4f9a0a | ||
|
92df092ad3 | ||
|
c5763e6ec3 | ||
|
fb237d502d | ||
|
1942e1c47a | ||
|
eef5dda0f3 | ||
|
d5a362502a | ||
|
8715ff2740 | ||
|
f9336c00be | ||
|
2d8ad40e70 | ||
|
5f385c2f9d | ||
|
c3be126337 | ||
|
811a7cece7 | ||
|
49bfb67daa | ||
|
13bf5ac253 | ||
|
d19d60eb6a | ||
|
8cedf93901 | ||
|
a8e47d4fc7 | ||
|
fc320ca1e4 | ||
|
854daaebb7 | ||
|
244fd7c981 | ||
|
3987baa11b | ||
|
fb33f829cc | ||
|
2b13b1adb7 | ||
|
0f01753795 | ||
|
d0347ff5c2 | ||
|
355b2261a7 | ||
|
e94d204a87 | ||
|
fc6b36b690 | ||
|
21527275d1 | ||
|
1c73bba908 | ||
|
f85b10e517 | ||
|
2a5b68977b | ||
|
73d538c7cf | ||
|
d072216d2d | ||
|
47f10301c8 | ||
|
0803a15902 | ||
|
3061af3837 | ||
|
3db1de6b66 | ||
|
cd602755be | ||
|
f25b0d66f5 | ||
|
55fb59a54c | ||
|
7fdd8bd539 | ||
|
1c041d74f0 | ||
|
32284791e2 | ||
|
8321bc94c6 | ||
|
00e14ac8b2 | ||
|
9a25fd4b73 | ||
|
1be7685741 | ||
|
190f013a15 | ||
|
767ec81205 | ||
|
1008c8a9fc | ||
|
d118551405 | ||
|
c0cc9cdb7a | ||
|
1ddfd41a18 | ||
|
c5660ab762 | ||
|
688ebb797a | ||
|
98c5329e03 | ||
|
540476f65a | ||
|
03a13248a4 | ||
|
52ad4c42b0 | ||
|
4c93da3cc0 | ||
|
5d96fdafd6 | ||
|
6f1a569797 | ||
|
1616ffc817 | ||
|
e9fee04761 | ||
|
99c41b6112 | ||
|
4c7836abc7 | ||
|
a0db1b806a | ||
|
20f4b97d8b | ||
|
d4a49789d1 | ||
|
a275b3a9c2 | ||
|
4396456ed1 | ||
|
be3d4d7735 | ||
|
76f27d1a93 | ||
|
7d8ccb78a4 | ||
|
8013862f15 | ||
|
6935f8865d | ||
|
e6dabf97d9 | ||
|
6a30a41b10 | ||
|
e9ee7e2355 | ||
|
1f3f800a57 | ||
|
6d3aaf71d4 | ||
|
e2b03f31e9 | ||
|
f7c1d98221 | ||
|
daf6cadea9 | ||
|
7b3c8ea046 | ||
|
ca9e93fe47 | ||
|
f17675bbcf | ||
|
44c53ae96d | ||
|
89b05be5ec | ||
|
39870dd933 | ||
|
eb3ac802c0 | ||
|
974d5a8d89 | ||
|
142206b79a | ||
|
d51a20e2e0 | ||
|
acd59767e4 | ||
|
7b3c21cf98 | ||
|
d50cc39c27 | ||
|
42c981a54d | ||
|
84c86552d5 | ||
|
5adf430fad | ||
|
4bba070423 | ||
|
76ffe8eea1 | ||
|
be9df7bcd8 | ||
|
a1c3a5e569 | ||
|
85a182b7f2 | ||
|
ed41d99484 | ||
|
7da46050e5 | ||
|
1bf2073e61 | ||
|
f8601af45c | ||
|
d458d8a299 | ||
|
ef98c16c26 | ||
|
b98468c7ea | ||
|
1afda07525 | ||
|
8337cb251f | ||
|
5310da05e2 | ||
|
2858fd090c | ||
|
14ce820dcb | ||
|
f47d75c120 | ||
|
4860150334 | ||
|
a3c1cd2cc1 | ||
|
8982dcae10 | ||
|
cd7efb03ca | ||
|
aafd2a226f | ||
|
d5cc6d5067 | ||
|
6c6cbdc1a5 | ||
|
05c94374c9 | ||
|
6f1c20571b | ||
|
695f243a93 | ||
|
72b21925e5 | ||
|
19da0c6c82 | ||
|
727d85ddac | ||
|
ee91a94466 | ||
|
c9f3644988 | ||
|
c85b806bc1 | ||
|
75a1dfd0e4 | ||
|
ab8d541f8d | ||
|
92aa56ba20 | ||
|
07ded756d9 | ||
|
bc5cd5be45 | ||
|
33c0471c29 | ||
|
babca140f1 | ||
|
0e64e0f9f9 | ||
|
8be6b79732 | ||
|
8ce3a09471 | ||
|
e660acab56 | ||
|
67717bbde7 | ||
|
b195dcdfd2 | ||
|
5f59623be8 | ||
|
d62156b8c0 | ||
|
805a997ba0 | ||
|
bf07b45467 | ||
|
c99cf7579b | ||
|
c2320a07be | ||
|
a373f08b4f | ||
|
06cdf2a84a | ||
|
e0d266887c | ||
|
25d3fbcc5f | ||
|
c2f8aee89e | ||
|
aafc08f24c | ||
|
fed49d3040 | ||
|
31f57f8ff2 | ||
|
49f900b298 | ||
|
9a4e5763f5 | ||
|
403156ed1a | ||
|
696e6a7882 | ||
|
1063897c7c | ||
|
02ed9bf7e1 | ||
|
aa433e309c | ||
|
2fd9759bc1 | ||
|
b00814a8c4 | ||
|
1ca634be3b | ||
|
2b9e639281 | ||
|
b55e807c62 | ||
|
22c594eb79 | ||
|
948d878222 | ||
|
9b376fb11a | ||
|
4565430db5 | ||
|
c82a56af09 | ||
|
6c9df223d8 | ||
|
167cf20bfc | ||
|
a297f6492d | ||
|
b97301c6fa | ||
|
8313930c70 | ||
|
bbfdc923fb | ||
|
264e5058ea | ||
|
067fb34973 | ||
|
235c9f6b21 | ||
|
d34907681a | ||
|
ef43e46153 | ||
|
8a99f3772a | ||
|
9fc9fc0dd6 | ||
|
5135135e79 | ||
|
a5b0372a6e | ||
|
d55990d5d4 | ||
|
e8ab863557 | ||
|
3fc159f10b | ||
|
8fbbeffd38 | ||
|
5c1bc78408 | ||
|
acc9c84e2e | ||
|
dd2366458d | ||
|
b47e4364ad | ||
|
5efcf61289 | ||
|
2eed1c432a | ||
|
cea9422802 | ||
|
22a9901148 | ||
|
4de0fcd198 | ||
|
87b43e6bdb | ||
|
e41f646b42 | ||
|
bbf419953e | ||
|
2e214cab7a | ||
|
adefd3259c | ||
|
1caed44552 | ||
|
b42e77858f | ||
|
9480f9f34c | ||
|
bf8e09b6c1 | ||
|
899c6ab0e0 | ||
|
95b67c05e2 | ||
|
5c18820d96 | ||
|
a004d3a4bf | ||
|
278bcb9724 | ||
|
0d63e471be | ||
|
3a33efa8db | ||
|
100821e34c | ||
|
f2217d1d8b | ||
|
abf23a1462 | ||
|
a982b86cfe | ||
|
14544d064a | ||
|
2da5423f36 | ||
|
3434b3de3f | ||
|
8da36298e5 | ||
|
ab4dbc798c | ||
|
2f6a3c4e00 | ||
|
a516122f61 | ||
|
db695875c4 | ||
|
beece64ae5 | ||
|
43d3662db1 | ||
|
6232284e92 | ||
|
bec8cdb3e8 | ||
|
fdbcffcfbc | ||
|
0b5b0bb9d3 | ||
|
d6a9b89c43 | ||
|
0a63a0ae1f | ||
|
b63cc17630 | ||
|
1fa214ed48 | ||
|
06b7e49e98 | ||
|
80d594bd5f | ||
|
ade8eb7aae | ||
|
bbc8915f79 | ||
|
53a584f37d | ||
|
731e5d5b7c | ||
|
a3311bd5aa | ||
|
46bf09f182 | ||
|
1c7232f31e | ||
|
f5e5af0b7a | ||
|
f6d4409899 | ||
|
ccd0e42734 | ||
|
04c42e7835 | ||
|
a4c722550a | ||
|
d2218b5b8b | ||
|
cc300c84e1 | ||
|
5c03f1581a | ||
|
774ba6fba6 | ||
|
c51aa0b6b4 | ||
|
bd98e8810e | ||
|
a6de0ec695 | ||
|
17b5345d82 | ||
|
3bb4111445 | ||
|
78e8927de4 | ||
|
73fc67955d | ||
|
78997c1e45 | ||
|
5cb6ee3bca | ||
|
5f86637ca5 | ||
|
c2832039b8 | ||
|
f078ce4fa9 | ||
|
be7e4a5c03 | ||
|
c59e444d0a | ||
|
fa8ebe36bd | ||
|
7e9007aad1 | ||
|
ca8420d61b | ||
|
2ddd95e904 | ||
|
760681f958 | ||
|
9e275a18f1 | ||
|
4ec59be46f | ||
|
2e17f9f917 | ||
|
625308c19d | ||
|
da153ceea9 | ||
|
45aa6646fa | ||
|
d9ee03a96f | ||
|
8e514de28f | ||
|
d33913a111 | ||
|
5a5069a419 | ||
|
e926741177 | ||
|
53c79f41a3 | ||
|
c0d6e17060 | ||
|
1db1a739cf | ||
|
f9f226aceb | ||
|
d6c7230d6a | ||
|
9fbd521732 | ||
|
8ba2a55180 | ||
|
7722c723c4 | ||
|
9270d48e12 | ||
|
5df0b014c1 | ||
|
1e2f9fc099 | ||
|
44107ccbd3 | ||
|
4d48c98975 | ||
|
8ac95b363d | ||
|
06f9f53951 | ||
|
bfbcde4dfc | ||
|
4e4ffe8e20 | ||
|
3f471e7e8e | ||
|
8109f3d9a9 | ||
|
a525ad82ec | ||
|
a7c422e69e | ||
|
004969aa66 | ||
|
1af0740f10 | ||
|
7b70b9b3bd | ||
|
9ce82b1b6f | ||
|
7847a9e781 | ||
|
8c8a9be6a1 | ||
|
e1b5b595e7 | ||
|
01e43abd17 | ||
|
0390ec0f47 | ||
|
d6d72aa619 | ||
|
9ba7c04524 | ||
|
c592a3ab59 | ||
|
d8a24e1abd | ||
|
5dbe16ec8d | ||
|
987e36c357 | ||
|
3c1e16b815 | ||
|
3b413e52e5 | ||
|
30d92becd6 | ||
|
0f3b0f242d | ||
|
bf408d9bf0 | ||
|
abf9d30ad2 | ||
|
d19debfd19 | ||
|
24a9a79f16 | ||
|
190a39b2d6 | ||
|
7ccdc6d683 | ||
|
7c7d6815f8 | ||
|
e8e19e0e5d | ||
|
3c6369726e | ||
|
280ae97070 | ||
|
a6e6e2f52f | ||
|
88b8d39c7c | ||
|
9c74f88b4a | ||
|
7abc11c146 | ||
|
790aec9baf | ||
|
b637ab1536 | ||
|
102e22e111 | ||
|
87b54ff92e | ||
|
72a56b46fd | ||
|
43b8c16fcc | ||
|
8a59ab3180 | ||
|
2a3593c269 | ||
|
e58ec54546 | ||
|
ec63464461 | ||
|
a09af526a0 | ||
|
bfb708d477 | ||
|
a9028b0a94 | ||
|
624d99fc1d | ||
|
75b39cbf6f | ||
|
6ac361fdb9 | ||
|
4268e03293 | ||
|
ff1cb68077 | ||
|
e53cde5b34 | ||
|
9f2ac17ffb | ||
|
8c9da833bf | ||
|
4a9fc7bc9b | ||
|
642fedbbb4 | ||
|
ea07edcbd3 | ||
|
5bf36d1963 | ||
|
2d8e85ab5e | ||
|
ec49a73c74 | ||
|
7c11df6147 | ||
|
fe5fba184f | ||
|
6e38540d58 | ||
|
13300326fd | ||
|
b624ec045e | ||
|
2fe71731e4 | ||
|
ab41404d07 | ||
|
108f0afb95 | ||
|
238af975e3 | ||
|
7dfc3fb966 | ||
|
f773a59676 | ||
|
aff6acc8f4 | ||
|
14cef9ffc3 | ||
|
5e8decfa4e | ||
|
7e6545a669 | ||
|
20052b61ec | ||
|
67d71fa531 | ||
|
a2344492a2 | ||
|
dfa61be382 | ||
|
849248376b | ||
|
e3800612ea | ||
|
a524b952ee | ||
|
619644d6dd | ||
|
feb276ccfa | ||
|
f749eb1df8 | ||
|
f577437a8b | ||
|
8ccf834724 | ||
|
708773e9a6 | ||
|
18bba89507 | ||
|
9c11104110 | ||
|
d0aa9c710c | ||
|
1ec8fc5b45 | ||
|
6d25494713 | ||
|
20db898753 | ||
|
076f2979b4 | ||
|
3760cd576b | ||
|
7cd4b5d454 | ||
|
6ce53a4418 | ||
|
ef0408dcdf | ||
|
9420b10bd9 | ||
|
d7b702fe00 | ||
|
5dcd43f5b2 | ||
|
1b9a38ff66 | ||
|
6b2f6f7185 | ||
|
cb0f9d922f | ||
|
d18cc372f6 | ||
|
b454d3eca0 | ||
|
55c6481d5b | ||
|
7ad331bc3d | ||
|
b965926fc8 | ||
|
80728ff4f9 | ||
|
94b7ebe5e8 | ||
|
34e7a27125 | ||
|
ce76a9754b | ||
|
75e48204ef | ||
|
a90441d9d5 | ||
|
925e623a64 | ||
|
5c12da140d | ||
|
cfbbbc4367 | ||
|
80fe88a68a | ||
|
3eb0bb1711 | ||
|
ed5f69db7a | ||
|
a40d593d32 | ||
|
419a3106e8 | ||
|
b7d39eaafd | ||
|
6e387ef938 | ||
|
50eb9bd4bd | ||
|
bad58652b8 | ||
|
7d8a87615a | ||
|
b6281b0b56 | ||
|
467f7ded73 | ||
|
1a1dc97ec8 | ||
|
1374309de3 | ||
|
7696dd84b5 | ||
|
8569a0362b | ||
|
a967f7459d | ||
|
364c6ad8e5 | ||
|
69e142e279 | ||
|
510e4400d3 | ||
|
6b61d7209d | ||
|
9c19966ef9 | ||
|
087e5f89fd | ||
|
cbc01d8160 | ||
|
c40c7af0b0 | ||
|
6d5a4d6e3f | ||
|
1a44124a59 | ||
|
cc0beb4ca4 | ||
|
a37ab956db | ||
|
28e3adcdff | ||
|
09da7fcb7c | ||
|
a3067527ee | ||
|
a9cdeb46a2 | ||
|
033ff3e150 | ||
|
cf2b54ab8d | ||
|
2eeaeff92d | ||
|
4a617a4c07 | ||
|
0592909248 | ||
|
03592f9c3e | ||
|
37b8cc9687 | ||
|
7df69dda4d | ||
|
cc15eb2044 | ||
|
ee6f91a52f | ||
|
087a2a1f8f | ||
|
48f5c28d75 | ||
|
164f5fba06 | ||
|
7585a1a649 | ||
|
075804bb70 | ||
|
aebb4c5483 | ||
|
a3c72214b8 | ||
|
ae0cb4fc8c | ||
|
47f95678bd | ||
|
f00064732d | ||
|
d6a751d9a2 | ||
|
434c7b6b97 | ||
|
5f4908b072 | ||
|
7d5d945a20 | ||
|
224a8214b4 | ||
|
e638bf1b32 | ||
|
758385f044 | ||
|
2937c0d891 | ||
|
d13170f455 | ||
|
11730e48a2 | ||
|
c12063799f | ||
|
93f790019c | ||
|
4c8b7bbc3d | ||
|
e0989bdfde | ||
|
f14a87c9b3 | ||
|
927a5137a2 | ||
|
e39f6d4125 | ||
|
318da1bd6f | ||
|
addc883440 | ||
|
3b933923e2 | ||
|
50c4866958 | ||
|
3009c6cc01 | ||
|
e4c9508340 | ||
|
94f6f08784 | ||
|
01884bd3df | ||
|
9426cc2b94 | ||
|
d4af15714c | ||
|
727911816c | ||
|
0390e851fc | ||
|
4847939e8c | ||
|
3f0002f9e8 | ||
|
a150be88e2 | ||
|
ecc87c7989 | ||
|
958dc2b431 | ||
|
77b2c9893d | ||
|
c183e00d47 | ||
|
bd62d8fbcd | ||
|
1444d60e11 | ||
|
1bb5d3b8cd | ||
|
f17c4ac40f | ||
|
db7eee495c | ||
|
a82b3577d4 | ||
|
7ca0b3662f | ||
|
5524889d48 | ||
|
f2d26b631d | ||
|
93287f8dc1 | ||
|
d053fb6cb7 | ||
|
e5d02dde06 | ||
|
14e2071b1d | ||
|
8773bf7624 | ||
|
719ec5cc54 | ||
|
7bb663891f | ||
|
917e066a45 | ||
|
eaa1a26af4 | ||
|
404f3a6b0c | ||
|
fe49ae4d5a | ||
|
43ce91a537 | ||
|
e4064b89ff | ||
|
c24c9404a7 | ||
|
7aa074a31a | ||
|
f9b881a017 | ||
|
d12189ae08 | ||
|
79bd299b68 | ||
|
4b2fd0bdc7 | ||
|
da4ce99755 | ||
|
9fbed63eaf | ||
|
b0e4f6d27a | ||
|
fe98a61e43 | ||
|
ff92338873 | ||
|
a32bb57167 | ||
|
abd9be921f | ||
|
a8fd4c8014 | ||
|
d8681b043c | ||
|
4ee458d3f5 | ||
|
d7d8fb94c4 | ||
|
e49b64ee9f | ||
|
cb9fa0ceb2 | ||
|
ed9b20b5ad | ||
|
b4f8fcf38e | ||
|
ef77779cec | ||
|
d9fb2c0557 | ||
|
c0ace53df2 | ||
|
76c4cd6d68 | ||
|
c30962bf80 | ||
|
4d8af33c85 | ||
|
6285212a1e | ||
|
fa817c34a9 | ||
|
cd8b336635 | ||
|
405604adef | ||
|
6abf235505 | ||
|
2a03751d49 | ||
|
9e9535ce56 | ||
|
1dd078562a | ||
|
985cdd2537 | ||
|
a3973b3481 | ||
|
ce30b34480 | ||
|
6243f132aa | ||
|
5944cada77 | ||
|
41b5dd2e38 | ||
|
1fe63c75fe | ||
|
c372a0af9d | ||
|
415bd4990a | ||
|
71faee584c | ||
|
445e90f2b9 | ||
|
5a39ca4c5e | ||
|
4bc2833e11 | ||
|
a9b887a4f4 | ||
|
a680d80793 | ||
|
c6eb729e46 | ||
|
8884f1beb9 | ||
|
b7f94e65a7 | ||
|
0ccba20d5c | ||
|
8987a02975 | ||
|
492f777d0b | ||
|
ebed7c15c0 | ||
|
77b4ca4f22 | ||
|
2775bf44a2 | ||
|
6f9ee3b79e | ||
|
b1e0f3ee80 | ||
|
0a98ffe05c | ||
|
a3592f388b | ||
|
ab5ea0181d | ||
|
cd590031e7 | ||
|
8305ecd667 | ||
|
952b7be94a | ||
|
a2c1107e10 | ||
|
764ade0749 | ||
|
db541cb63b | ||
|
64223e5ff1 | ||
|
aec690a106 | ||
|
bf2f289e29 | ||
|
dcd3bc759a | ||
|
9b98c6f300 | ||
|
cb7c8ba7c2 | ||
|
702755c797 | ||
|
cc375256a1 | ||
|
d3ffc7d786 | ||
|
7bc43682b8 | ||
|
b7af65eec3 | ||
|
571a319c10 | ||
|
7522b6af3c | ||
|
a6657a28fd | ||
|
c24007012c | ||
|
39cc2026f1 | ||
|
85c3a1532a | ||
|
72d0797b3f | ||
|
185e68fa23 | ||
|
8fe9f23d91 | ||
|
858ce10b49 | ||
|
6d3fb8f4ae | ||
|
ed789aa4bb | ||
|
c32442ab41 | ||
|
207a12df55 | ||
|
62b1966b21 | ||
|
793742b499 | ||
|
561a7e2c75 | ||
|
7c18f4b96b | ||
|
20a3966820 | ||
|
f5ab60b2df | ||
|
8580698c15 | ||
|
fd846254a0 | ||
|
42f88766b3 | ||
|
096a9e773a | ||
|
60f72fa6ab | ||
|
2c572dd89a | ||
|
13727bb19f | ||
|
693652935d | ||
|
0641db1f2d | ||
|
26bbb75ccd | ||
|
2a5172cb48 | ||
|
963c578a73 | ||
|
3dd7b12e71 | ||
|
675f0a1599 | ||
|
a17342e55c | ||
|
20ec09b7c6 | ||
|
0a3b14883c | ||
|
8e33c2b639 | ||
|
c48913d91e | ||
|
8f40350a75 | ||
|
24e646640a | ||
|
96ea325136 | ||
|
3667e81c6f | ||
|
b2501d8145 | ||
|
d3fdd4cd1f | ||
|
3609255342 | ||
|
51aa8df010 | ||
|
6701bfca0d | ||
|
1036c2df0d | ||
|
dcbdc66df5 | ||
|
d6f15deff4 | ||
|
482a72f4e1 | ||
|
a12a8bcd6a | ||
|
515676f885 | ||
|
87a33933e4 | ||
|
2f7ab18429 | ||
|
a2e4893be8 | ||
|
95242d94ac | ||
|
4917d4084b | ||
|
95fbfb7db0 | ||
|
86b4b1a907 | ||
|
443acdbcf8 | ||
|
97bf1049b5 | ||
|
a8abd4ecbb | ||
|
cef9eebbdf | ||
|
800d9c6723 | ||
|
0e640bf53b | ||
|
e4f1fbde3f | ||
|
5c3370ded8 | ||
|
e2de257372 | ||
|
2d66be5208 | ||
|
7338bdd47a | ||
|
dc0c9cf1d4 | ||
|
d02611a37a | ||
|
4150479aa3 | ||
|
00fbe711e5 | ||
|
9b50d67313 | ||
|
bcc011c1fd | ||
|
b0a1da62d2 | ||
|
e66564cd1f | ||
|
6214b6e425 | ||
|
66624ff92c | ||
|
096ac8f512 | ||
|
2d7c895964 | ||
|
192b54f986 | ||
|
041bfe5ac0 | ||
|
19baf86963 | ||
|
1cf7b42597 | ||
|
546005139b | ||
|
2b5a0b1111 | ||
|
faa49b750e | ||
|
ab6cfd2564 | ||
|
4f0b94150c | ||
|
25e498ab3c | ||
|
63b7f64683 | ||
|
5aebd7eb41 | ||
|
516656f194 | ||
|
99a5612c8d | ||
|
359bfbf614 | ||
|
0223ecdac2 | ||
|
4c3119c9ec | ||
|
d2f5742231 | ||
|
dc2fada751 | ||
|
fae28fed7c | ||
|
1c8c2a4126 | ||
|
3baffd4a35 | ||
|
d0a56cd1af | ||
|
31fbd6b900 | ||
|
f7b981c55c | ||
|
d439a2e1c0 | ||
|
1ab7a4162c | ||
|
637a76cf34 | ||
|
247f5e9275 | ||
|
0959ec7679 | ||
|
a46c311a99 | ||
|
b4a68bf436 | ||
|
6914e5d706 | ||
|
03f36cf954 | ||
|
63de359d22 | ||
|
6a542e4530 | ||
|
ccbe98cdd6 | ||
|
ca89fd158d | ||
|
552e6e6c3a | ||
|
00f632ec47 | ||
|
c36ce3e521 | ||
|
e5f553fa1a | ||
|
d170e31f54 | ||
|
587e1e5d61 | ||
|
8e06e4351e | ||
|
55aa2db553 | ||
|
4294481b5b | ||
|
3cf4cb7a77 | ||
|
6c9f566d3d | ||
|
426d41ba44 | ||
|
193b9ae6bf | ||
|
6d6e127f7b | ||
|
65ff3ebdac | ||
|
e7433c2eec | ||
|
d0766fa7c3 | ||
|
a90e9b7083 | ||
|
fdbaa5270b | ||
|
00ac581736 | ||
|
32ce410092 | ||
|
95268844aa | ||
|
6ad40cf75d | ||
|
f80ef1cd34 | ||
|
75fd870d69 | ||
|
473534bc35 | ||
|
ca29a43da9 | ||
|
375ce69b7d | ||
|
2cb4321766 | ||
|
0eac8d9c5c | ||
|
0a091831de | ||
|
d6b855f0de | ||
|
b95f258763 | ||
|
7e15c2870b | ||
|
7c50b55331 | ||
|
96c1410f01 | ||
|
565ded1063 | ||
|
79c5472c11 | ||
|
4e1174a4dc | ||
|
5b5e6c78d6 | ||
|
3bbe6062e9 | ||
|
bc208df597 | ||
|
6525ffc6c3 | ||
|
08eac5b0ef | ||
|
2e1fdd7d7a | ||
|
64fc0c74ff | ||
|
6234b12f89 | ||
|
7549cf6a89 | ||
|
d49656cb77 | ||
|
ff4bb3330a | ||
|
00b7f3505f | ||
|
9d2b99f237 | ||
|
6427e1bd06 | ||
|
997f13d986 | ||
|
f06ca8305c | ||
|
855256816e | ||
|
83f4fd3555 | ||
|
ac9af1acd6 | ||
|
967ac1b08d | ||
|
9fa457dec8 | ||
|
482654d06b | ||
|
f04d66d5c8 | ||
|
836c87b371 | ||
|
f75dc0200d | ||
|
53a6748c6d | ||
|
764790c1e1 | ||
|
d5742900b0 | ||
|
acc95bbd9c | ||
|
1ab71f8521 | ||
|
99bb8fdeea | ||
|
23ea1d72b7 | ||
|
49bc3c5735 | ||
|
63ca394d6e | ||
|
bdb2cfd710 | ||
|
0cc108e1ac | ||
|
649c6f4642 | ||
|
bd6c215cd3 | ||
|
9b59ea9fbe | ||
|
f2c4d3e9c1 | ||
|
77eaf070e6 | ||
|
4ca1d33d65 | ||
|
6e2d16225e | ||
|
077eeec2c7 | ||
|
aebf572dc9 | ||
|
f451d94295 | ||
|
e697024f52 | ||
|
f58126e630 | ||
|
9acb07aa14 | ||
|
bb788d5201 | ||
|
6696ac2a15 | ||
|
d2e78eb5de | ||
|
9764a03189 | ||
|
64d46b7cdd | ||
|
61d2557c35 | ||
|
d83fe1a202 | ||
|
769763d006 | ||
|
da695c33f4 | ||
|
1eccdb7b4f | ||
|
549926a323 | ||
|
d9c67e8d49 | ||
|
33c8fe2bc0 | ||
|
2e7a8210bb | ||
|
c047365bb4 | ||
|
8e51f68430 | ||
|
348c8d565a | ||
|
b1abfcda8b | ||
|
ef8157025f | ||
|
e4377ee3a3 | ||
|
76841e53b1 | ||
|
c3f49c44a0 | ||
|
8e511e7cc9 | ||
|
2ea05f8913 | ||
|
8b0091f30d | ||
|
897eb0c27b | ||
|
29b946671b | ||
|
a52b2992af | ||
|
8b9d0e5dba | ||
|
e481b971d0 | ||
|
ed9285dbc1 | ||
|
705d5cada7 | ||
|
7534847e8d | ||
|
793a2c6d6c | ||
|
13590bf5d1 | ||
|
e7ef6134b5 | ||
|
98064119e1 | ||
|
d22a21caec | ||
|
0e3e4b8192 | ||
|
bc3e43802b | ||
|
f66bc6af4d | ||
|
c5a5869f21 | ||
|
b9a82b652e | ||
|
b059a44acc | ||
|
6cc2e6692e | ||
|
fd03eb841f | ||
|
7c124c1390 | ||
|
cff2611582 | ||
|
80776186aa | ||
|
e53dd78502 | ||
|
aa1022546d | ||
|
bc1decdbfc | ||
|
f0f7b85ed8 | ||
|
789df9a76d | ||
|
fe912921eb | ||
|
be82406c4d | ||
|
2e3f1b4c52 | ||
|
a5f953743f | ||
|
0617fedb17 | ||
|
4698d119b4 | ||
|
b95dfa0a33 | ||
|
affa9a5ab6 | ||
|
9733056ce7 | ||
|
7e44af318b | ||
|
d357f51883 | ||
|
b29e69a52c | ||
|
4ba112df2e | ||
|
60f68b178d | ||
|
5be6a75e4b | ||
|
9457ac9337 | ||
|
1b5e33ca54 | ||
|
4c0a994174 | ||
|
df9b498e18 | ||
|
4cca60b16e | ||
|
2320f0b962 | ||
|
5ce23c0bdb | ||
|
b3282c4302 | ||
|
f3404b893d | ||
|
b704f4fe78 | ||
|
5ac77674ed | ||
|
f9780a2f69 | ||
|
ed7902f77f | ||
|
78c461b26c | ||
|
b963cc2fe2 | ||
|
f75fbfb4c5 | ||
|
5082c8b3f2 | ||
|
4528615863 | ||
|
21949abbe1 | ||
|
ee64c4e923 | ||
|
d3031e0f10 | ||
|
aa164cd5f5 | ||
|
142feaffff | ||
|
e6dbcbc4fd | ||
|
908c8c03e6 | ||
|
e6d467764d | ||
|
6625983bb7 | ||
|
746a97c1df | ||
|
ead441ce9f | ||
|
b86720e943 | ||
|
4d975ff512 | ||
|
56c7e2597d | ||
|
673c432bb9 | ||
|
8331e7afc5 | ||
|
d32147b536 | ||
|
8d474ef031 | ||
|
6e92e3fba1 | ||
|
7d7286b1c1 | ||
|
279437ba08 | ||
|
07709cdccb | ||
|
c13b71b754 | ||
|
4618b37c82 | ||
|
615d5874b3 | ||
|
43c67b2820 | ||
|
1aa88a917b | ||
|
9209b3cb05 | ||
|
a16d35974f | ||
|
3f42991741 | ||
|
0069846335 | ||
|
f6079e68d0 | ||
|
a0be5b6394 | ||
|
e12e399679 | ||
|
9d44c40415 | ||
|
895eba4553 | ||
|
d25fb916ba | ||
|
3fa2926559 | ||
|
77e6ea5a6b | ||
|
10e6255a53 | ||
|
1af03bc53d | ||
|
78b27ee964 | ||
|
c70ec1dad3 | ||
|
3805adff58 | ||
|
520fd5d48e | ||
|
6d536c4e16 | ||
|
40c853e595 | ||
|
3e08349df6 | ||
|
aa77effcb6 | ||
|
41b24d415d | ||
|
3cffccdd3f | ||
|
3ae456f730 | ||
|
974d41434e | ||
|
ea342248de | ||
|
6ae9e6354c | ||
|
dcf07fe0a1 | ||
|
fc5fa000b9 | ||
|
1683a3842b | ||
|
07a7fc219b | ||
|
2db69e4d15 | ||
|
2b618be3ac | ||
|
1c74afd741 | ||
|
58fbc40276 | ||
|
dfcac2fb97 | ||
|
411a739004 | ||
|
431f8d41cf | ||
|
a8896375c7 | ||
|
bc454e89ba | ||
|
4f8d689ad8 | ||
|
de043de589 | ||
|
1fbde3646f | ||
|
33f4965fa4 | ||
|
cc5312f52e | ||
|
23e7c8aaf3 | ||
|
342cef8c1d | ||
|
9d5490cf9a | ||
|
d38f1300c3 | ||
|
7c1d70313b | ||
|
5c4235a247 | ||
|
2df96cc0b5 | ||
|
344ce69fee | ||
|
edb3809f1c | ||
|
d121e59189 | ||
|
8839ffc492 | ||
|
ca38640b89 | ||
|
5947be6647 | ||
|
2f88a5cdab | ||
|
19c0f83b85 | ||
|
ebb1bc7359 | ||
|
f10f7bbaea | ||
|
0fef0eeccb | ||
|
5b431226d4 | ||
|
dc7460f209 | ||
|
209089cc45 | ||
|
bfd0af1c80 | ||
|
7fbecbc102 | ||
|
6ef48af085 | ||
|
9a834526c0 | ||
|
df4ecb3fe2 | ||
|
a1aeabeab4 | ||
|
8266fb995c | ||
|
129d66c10f | ||
|
c5ab1ba2e0 | ||
|
b97a65cf2c | ||
|
dd6edc3b7a | ||
|
188ab66029 | ||
|
d47e2f5d93 | ||
|
a04c978408 | ||
|
829c8a4b75 | ||
|
01506fedeb | ||
|
a9b4570fff | ||
|
feca042e47 | ||
|
ed37d93868 | ||
|
179fa8c608 | ||
|
7528ac0604 | ||
|
e655462a2f | ||
|
cedd8df45c | ||
|
d1c6e5bc91 | ||
|
16ab0e0c37 | ||
|
6b4417d8b8 | ||
|
6d4554e9ef | ||
|
34b208f63d | ||
|
519dda6473 | ||
|
e4206d6277 | ||
|
1013192281 | ||
|
abb5d53431 | ||
|
6398f93ffe | ||
|
44fa4f263b | ||
|
af6387bbf3 | ||
|
fccf52eb34 | ||
|
03af90f17b | ||
|
4b2412c49c | ||
|
b1b371e708 | ||
|
1b69a34270 | ||
|
e3800de2ad | ||
|
a7c42ee8ec | ||
|
59034839a9 | ||
|
bdb46fc7c1 | ||
|
6d86a5eb49 | ||
|
4390ee4314 | ||
|
bcd86ddce9 | ||
|
928b34784c | ||
|
a333d8334e | ||
|
85b5ee5cbc | ||
|
b928d0e70c | ||
|
0c9984287c | ||
|
95472c5faf | ||
|
4659cab18c | ||
|
f218a74a0c | ||
|
477878a09f | ||
|
95b28bd536 | ||
|
3d780be70a | ||
|
22894cb44e | ||
|
75e9d419ee | ||
|
fbc61fe28f | ||
|
8594700fb4 | ||
|
0b8ad76b0f | ||
|
5eaf50612d | ||
|
3302cbddbd | ||
|
8f3a002840 | ||
|
2453fcf1ef | ||
|
e20537bf49 | ||
|
1bc323d575 | ||
|
4386422f02 | ||
|
7c875f80da | ||
|
57ee53e133 | ||
|
67007c5897 | ||
|
6d97b82aee | ||
|
596c6fe33d | ||
|
73f1116b8f | ||
|
db1543ea71 | ||
|
583dc10e6a | ||
|
07ce27f20b | ||
|
f0e045694a | ||
|
7d5b4359f8 | ||
|
4d0646a200 | ||
|
44f44272ff | ||
|
24e873b6de | ||
|
a331faa1a7 | ||
|
f7d4926d22 | ||
|
fb0e16d619 | ||
|
3ba96028f4 | ||
|
bad7a2b543 | ||
|
b375256e96 | ||
|
657b6b2763 | ||
|
cdf25ba659 | ||
|
907acec601 | ||
|
a9e8b4c1e7 | ||
|
8c644da10d | ||
|
b74a0c02c5 | ||
|
0950a281f2 | ||
|
5890b74225 | ||
|
afc6f28a49 | ||
|
4db7e03b92 | ||
|
50e3dc5cd0 | ||
|
7d5e02a69c | ||
|
0b9b2396f1 | ||
|
96d5ea0437 | ||
|
f1977f26ea | ||
|
6eda71286c | ||
|
41a011a9bb | ||
|
6a851fe86a | ||
|
f78920c912 | ||
|
527a8a8b09 | ||
|
a5e4411075 | ||
|
a9e1cbc0be | ||
|
b06d41e31a | ||
|
a902dfebca | ||
|
b2945c24b1 | ||
|
f48ae0170b | ||
|
856a2453a1 | ||
|
ff4550fe51 | ||
|
9d438dc356 | ||
|
3841e2a98f | ||
|
998b01cde7 | ||
|
05b8ce96b5 | ||
|
f79d69cd69 | ||
|
5cbbb55dba | ||
|
918229c6ef | ||
|
4b3b6436a0 | ||
|
702c0af33e | ||
|
28a2199ec7 | ||
|
bf211b91fe | ||
|
c03e68640e | ||
|
481b97d689 | ||
|
6270ec2c59 | ||
|
f0acc11b83 | ||
|
58521b6503 | ||
|
ccff8c9bec | ||
|
1d9adcbeaf | ||
|
80ffed9460 | ||
|
6efdf46bb3 | ||
|
0a4e05ad32 | ||
|
c563ecc88b | ||
|
a760940ae6 | ||
|
f1a96b5320 | ||
|
ab2011609f | ||
|
b87e751b2d | ||
|
2a4ad3734b | ||
|
77291956bc | ||
|
86e323bf25 | ||
|
5be7ce5f8f | ||
|
d8dfd103b9 | ||
|
639d17cada | ||
|
95e7b0970d | ||
|
191742c88f | ||
|
2ecc4730d7 | ||
|
f93d10f850 | ||
|
83a75def06 | ||
|
bc81091243 | ||
|
1851b20f42 | ||
|
802f376042 | ||
|
957eb3ac94 | ||
|
77e15e3aa8 | ||
|
f6c45a29c2 | ||
|
db122fb614 | ||
|
393a4962c9 | ||
|
86c2ff4605 | ||
|
55479ef4ab | ||
|
b3bacd6e1e | ||
|
689a2f6244 | ||
|
c0e22d89ca |
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"projects": {
|
||||
"default": "mantic-markets"
|
||||
"default": "mantic-markets",
|
||||
"prod": "mantic-markets",
|
||||
"dev": "dev-mantic-markets"
|
||||
}
|
||||
}
|
||||
|
|
27
.github/CONTRIBUTING.md
vendored
Normal file
27
.github/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Manifold CLA
|
||||
|
||||
**Manifold Markets Contributor License Agreement**
|
||||
|
||||
(Thanks to [Beeminder](http://bmndr.co/cla) and [Discourse.org](https://cla-assistant.io/discourse/discourse) whose CLAs we modeled this on!)
|
||||
|
||||
## Unofficial Summary
|
||||
|
||||
- Manifold can use your contributions
|
||||
- Manifold can sell things involving your contributions
|
||||
- You’re legally able to agree to the above
|
||||
- You’re the one who created these contributions
|
||||
- Manifold decides what gets included in Manifold
|
||||
- Manifold does not promise any support
|
||||
|
||||
## Official Agreement
|
||||
|
||||
The document below clarifies the terms under which You (the copyright owner or legal entity authorized by the copyright owner), may make "The Contributions" (software, bug fixes, configuration changes, documentation, or any other materials) to "The Work" (Manifold Markets). This license protects You, "The Company" (Manifold Markets, Inc.) and licensees; it does not change your rights to use your own contributions for any other purpose.
|
||||
|
||||
You and "The Company" (Manifold Markets, Inc.) agree:
|
||||
|
||||
- You grant to "The Company" (Manifold Markets, Inc.) a non-exclusive, irrevocable, worldwide, royalty-free, sublicenseable, relicenseable, transferable license under all of Your relevant intellectual property rights, to use, copy, prepare derivative works of, distribute and publicly perform and display "The Contributions" on any licensing terms, including without limitation: (a) open source licenses like the GNU General Public (v2.0) license; and (b) binary, proprietary, or commercial licenses. Except for the licenses granted herein, You reserve all right, title, and interest in and to "The Contributions".
|
||||
- You grant to "The Company" a non-exclusive, irrevocable (except as stated in this section), worldwide, royalty-free, sublicenseable, transferable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer "The Work", where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with "The Work" to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or "The Work" to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed.
|
||||
- You are able to grant us these rights. You represent that You are legally entitled to grant the above license(s). If Your employer has rights to intellectual property that You create, You represent that You have received permission to make "The Contributions" on behalf of that employer, or that Your employer has waived such rights for "The Contributions".
|
||||
- "The Contributions" are your original work. You represent that "The Contributions" are Your original works of authorship, and to Your knowledge, no other person claims, or has the right to claim, any right in any invention or patent related to "The Contributions". You also represent that You are not legally obligated, whether by entering into an agreement or otherwise, in any way that conflicts with the terms of this license. For example, if you have signed an agreement requiring you to assign the intellectual property rights in "The Contributions" to an employer or customer, that would conflict with the terms of this license.
|
||||
- We, as authoritative representatives of "The Company" determine the code that is in "The Work". You understand that the decision to include "The Contribution(s)" in any project or source repository is entirely that of "The Company", and this agreement does not guarantee that "The Contributions" will be included in any product.
|
||||
- No Implied Warranties. "The Company" acknowledges that, except as explicitly described in this Agreement, the Contribution is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
|
55
.github/workflows/check.yml
vendored
Normal file
55
.github/workflows/check.yml
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
name: Check PRs
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Static analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Restore cached node_modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: '**/node_modules'
|
||||
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
|
||||
- name: Install missing dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile
|
||||
- name: Run Prettier on web client
|
||||
working-directory: web
|
||||
run: npx prettier --check .
|
||||
- name: Run ESLint on common
|
||||
if: ${{ success() || failure() }}
|
||||
working-directory: common
|
||||
run: npx eslint . --max-warnings 0
|
||||
- name: Run ESLint on web client
|
||||
if: ${{ success() || failure() }}
|
||||
working-directory: web
|
||||
run: yarn lint --max-warnings 0
|
||||
- name: Run ESLint on cloud functions
|
||||
if: ${{ success() || failure() }}
|
||||
working-directory: functions
|
||||
run: npx eslint . --max-warnings 0
|
||||
- name: Run Typescript checker on web client
|
||||
if: ${{ success() || failure() }}
|
||||
working-directory: web
|
||||
run: tsc --pretty --project tsconfig.json --noEmit
|
||||
- name: Run Typescript checker on cloud functions
|
||||
if: ${{ success() || failure() }}
|
||||
working-directory: functions
|
||||
run: tsc -b -v --pretty
|
43
.github/workflows/format.yml
vendored
Normal file
43
.github/workflows/format.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
name: Reformat main
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
|
||||
# mqp - i generated a personal token to use for these writes -- it's unclear
|
||||
# why, but the default token didn't work, even when i gave it max permissions
|
||||
|
||||
jobs:
|
||||
prettify:
|
||||
name: Auto-prettify
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.FORMATTER_ACCESS_TOKEN }}
|
||||
- name: Restore cached node_modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: '**/node_modules'
|
||||
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
|
||||
- name: Install missing dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile
|
||||
- name: Run Prettier on web client
|
||||
working-directory: web
|
||||
run: yarn format
|
||||
- name: Commit any Prettier changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Auto-prettification
|
||||
branch: ${{ github.head_ref }}
|
43
.github/workflows/lint.yml
vendored
Normal file
43
.github/workflows/lint.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
name: Run linter (remove unused imports)
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
|
||||
# mqp - i generated a personal token to use for these writes -- it's unclear
|
||||
# why, but the default token didn't work, even when i gave it max permissions
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Auto-lint
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.FORMATTER_ACCESS_TOKEN }}
|
||||
- name: Restore cached node_modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: '**/node_modules'
|
||||
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
|
||||
- name: Install missing dependencies
|
||||
run: yarn install --prefer-offline --frozen-lockfile
|
||||
- name: Run lint script
|
||||
run: yarn lint
|
||||
- name: Commit any lint changes
|
||||
if: always()
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Auto-remove unused imports
|
||||
branch: ${{ github.head_ref }}
|
17
.github/workflows/merge-main-into-main2.yml
vendored
Normal file
17
.github/workflows/merge-main-into-main2.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: Merge main into main2 on every commit
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
jobs:
|
||||
merge-branch:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Merge main -> main2
|
||||
uses: devmasx/merge-branch@master
|
||||
with:
|
||||
type: now
|
||||
target_branch: main2
|
||||
github_token: ${{ github.token }}
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1 +1,7 @@
|
|||
.DS_Store
|
||||
.idea/
|
||||
.vercel
|
||||
node_modules
|
||||
yarn-error.log
|
||||
|
||||
firebase-debug.log
|
14
.vscode/extensions.json
vendored
Normal file
14
.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
||||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"toba.vsfire",
|
||||
"bradlc.vscode-tailwindcss"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": []
|
||||
}
|
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Chrome",
|
||||
"type": "chrome",
|
||||
"request": "attach",
|
||||
"port": 9222, // chrome needs to be started with the parameter "--remote-debugging-port=9222"
|
||||
"urlFilter": "http://localhost:3000/*",
|
||||
"webRoot": "${workspaceFolder}/web"
|
||||
}
|
||||
]
|
||||
}
|
13
.vscode/settings.json
vendored
Normal file
13
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"javascript.preferences.importModuleSpecifier": "shortest",
|
||||
"typescript.preferences.importModuleSpecifier": "shortest",
|
||||
"files.eol": "\n",
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
"**/package-lock.json": true,
|
||||
"**/yarn.lock": true
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnPaste": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 Manifold Markets, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
55
README.md
55
README.md
|
@ -1,2 +1,53 @@
|
|||
# mantic
|
||||
Mantic Markets
|
||||
# Manifold Markets
|
||||
|
||||
This [monorepo][] has basically everything involved in running and operating Manifold.
|
||||
|
||||
## Getting started
|
||||
|
||||
0. Make sure you have [Yarn 1.x][yarn]
|
||||
1. `$ cd web`
|
||||
2. `$ yarn`
|
||||
3. `$ yarn dev:dev`
|
||||
4. Your site will be available on http://localhost:3000
|
||||
|
||||
See [`web/README.md`][web-readme] for more details on hacking on the web client.
|
||||
|
||||
## General architecture
|
||||
|
||||
Manifold's public API and web app are hosted by [Vercel][vercel]. In general, the web app runs as much as possible on the client; we follow a [JAMStack][jamstack] architecture. All data is stored in Firebase's database, [Cloud Firestore][cloud-firestore]. This is directly accessed by the client for most data access operations.
|
||||
|
||||
Operations with complicated contracts (e.g. buying shares) are provided in a separate HTTP API using Firebase's [Cloud Functions][cloud-functions]. Those are deployed separately from the Vercel website; see [`functions/README.md`][functions-readme] for more details.
|
||||
|
||||
## Directory overview
|
||||
|
||||
- `web/`: UI and business logic for the client. Where most of the site lives. The public API endpoints are also in here.
|
||||
|
||||
- `functions/`: Firebase cloud functions, for secure work (e.g. balances, Stripe payments, emails). Also contains in
|
||||
`functions/src/scripts/` some Typescript scripts that do ad hoc CLI interaction with Firebase.
|
||||
|
||||
- `common/`: Typescript library code shared between `web/` & `functions/`. If you want to look at how the market math
|
||||
works, most of that's in here (it gets called from the `placeBet` and `sellBet` endpoints in `functions/`.) Also
|
||||
contains in `common/envs` configuration for the different environments (i.e. prod, dev, Manifold for Teams instances.)
|
||||
|
||||
- `og-image/`: The OpenGraph image generator; creates the preview images shown on Twitter/social media.
|
||||
|
||||
- `docs/`: Manifold's public documentation that lives at https://docs.manifold.markets.
|
||||
|
||||
## Contributing
|
||||
|
||||
Since we are just now open-sourcing things, we will see how things go. Feel free to open issues, submit PRs, and chat about the process on [Discord][discord]. We would prefer [small PRs][small-prs] that we can effectively evaluate and review -- maybe check in with us first if you are thinking to work on a big change.
|
||||
|
||||
By contributing to this codebase, you are agreeing to the terms of the [Manifold CLA](https://github.com/manifoldmarkets/manifold/blob/main/.github/CONTRIBUTING.md).
|
||||
|
||||
If you need additional access to any infrastructure in order to work on something (e.g. Vercel, Firebase) let us know about that on [Discord][discord] as well.
|
||||
|
||||
[vercel]: https://vercel.com/
|
||||
[jamstack]: https://jamstack.org/
|
||||
[monorepo]: https://semaphoreci.com/blog/what-is-monorepo
|
||||
[yarn]: https://classic.yarnpkg.com/lang/en/docs/install/
|
||||
[web-readme]: https://github.com/manifoldmarkets/manifold/blob/main/web/README.md
|
||||
[functions-readme]: https://github.com/manifoldmarkets/manifold/blob/main/functions/README.md
|
||||
[cloud-firestore]: https://firebase.google.com/docs/firestore
|
||||
[cloud-functions]: https://firebase.google.com/docs/functions
|
||||
[small-prs]: https://google.github.io/eng-practices/review/developer/small-cls.html
|
||||
[discord]: https://discord.gg/3Zuth9792G
|
||||
|
|
39
common/.eslintrc.js
Normal file
39
common/.eslintrc.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
module.exports = {
|
||||
plugins: ['lodash', 'unused-imports'],
|
||||
extends: ['eslint:recommended'],
|
||||
ignorePatterns: ['lib'],
|
||||
env: {
|
||||
browser: true,
|
||||
node: true,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
plugins: ['@typescript-eslint'],
|
||||
extends: ['plugin:@typescript-eslint/recommended'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: ['./tsconfig.json'],
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'unused-imports/no-unused-imports': 'warn',
|
||||
},
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
'no-extra-semi': 'off',
|
||||
'no-constant-condition': ['error', { checkLoops: false }],
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
'lodash/import-scope': [2, 'member'],
|
||||
},
|
||||
}
|
12
common/.gitignore
vendored
Normal file
12
common/.gitignore
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Compiled JavaScript files
|
||||
lib/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Node.js dependency directory
|
||||
node_modules/
|
||||
|
||||
package-lock.json
|
||||
ui-debug.log
|
||||
firebase-debug.log
|
1
common/.yarnrc
Normal file
1
common/.yarnrc
Normal file
|
@ -0,0 +1 @@
|
|||
save-prefix ""
|
30
common/add-liquidity.ts
Normal file
30
common/add-liquidity.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { getCpmmLiquidity } from './calculate-cpmm'
|
||||
import { CPMMContract } from './contract'
|
||||
import { LiquidityProvision } from './liquidity-provision'
|
||||
|
||||
export const getNewLiquidityProvision = (
|
||||
userId: string,
|
||||
amount: number,
|
||||
contract: CPMMContract,
|
||||
newLiquidityProvisionId: string
|
||||
) => {
|
||||
const { pool, p, totalLiquidity, subsidyPool } = contract
|
||||
|
||||
const liquidity = getCpmmLiquidity(pool, p)
|
||||
|
||||
const newLiquidityProvision: LiquidityProvision = {
|
||||
id: newLiquidityProvisionId,
|
||||
userId: userId,
|
||||
contractId: contract.id,
|
||||
amount,
|
||||
pool,
|
||||
p,
|
||||
liquidity,
|
||||
createdTime: Date.now(),
|
||||
}
|
||||
|
||||
const newTotalLiquidity = (totalLiquidity ?? 0) + amount
|
||||
const newSubsidyPool = (subsidyPool ?? 0) + amount
|
||||
|
||||
return { newLiquidityProvision, newTotalLiquidity, newSubsidyPool }
|
||||
}
|
33
common/answer.ts
Normal file
33
common/answer.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { User } from './user'
|
||||
|
||||
export type Answer = {
|
||||
id: string
|
||||
number: number
|
||||
contractId: string
|
||||
createdTime: number
|
||||
|
||||
userId: string
|
||||
username: string
|
||||
name: string
|
||||
avatarUrl?: string
|
||||
|
||||
text: string
|
||||
}
|
||||
|
||||
export const getNoneAnswer = (contractId: string, creator: User) => {
|
||||
const { username, name, avatarUrl } = creator
|
||||
|
||||
return {
|
||||
id: '0',
|
||||
number: 0,
|
||||
contractId,
|
||||
createdTime: Date.now(),
|
||||
userId: creator.id,
|
||||
username,
|
||||
name,
|
||||
avatarUrl,
|
||||
text: 'None',
|
||||
}
|
||||
}
|
||||
|
||||
export const MAX_ANSWER_LENGTH = 240
|
200
common/antes.ts
Normal file
200
common/antes.ts
Normal file
|
@ -0,0 +1,200 @@
|
|||
import { range } from 'lodash'
|
||||
import { Bet, NumericBet } from './bet'
|
||||
import { getDpmProbability, getValueFromBucket } from './calculate-dpm'
|
||||
import {
|
||||
CPMMBinaryContract,
|
||||
DPMBinaryContract,
|
||||
FreeResponseContract,
|
||||
MultipleChoiceContract,
|
||||
NumericContract,
|
||||
} from './contract'
|
||||
import { User } from './user'
|
||||
import { LiquidityProvision } from './liquidity-provision'
|
||||
import { noFees } from './fees'
|
||||
import { Answer } from './answer'
|
||||
|
||||
export const HOUSE_LIQUIDITY_PROVIDER_ID = 'IPTOzEqrpkWmEzh6hwvAyY9PqFb2' // @ManifoldMarkets' id
|
||||
export const DEV_HOUSE_LIQUIDITY_PROVIDER_ID = '94YYTk1AFWfbWMpfYcvnnwI1veP2' // @ManifoldMarkets' id
|
||||
export const UNIQUE_BETTOR_LIQUIDITY_AMOUNT = 20
|
||||
|
||||
type NormalizedBet<T extends Bet = Bet> = Omit<
|
||||
T,
|
||||
'userAvatarUrl' | 'userName' | 'userUsername'
|
||||
>
|
||||
|
||||
export function getCpmmInitialLiquidity(
|
||||
providerId: string,
|
||||
contract: CPMMBinaryContract,
|
||||
anteId: string,
|
||||
amount: number
|
||||
) {
|
||||
const { createdTime, p } = contract
|
||||
|
||||
const lp: LiquidityProvision = {
|
||||
id: anteId,
|
||||
userId: providerId,
|
||||
contractId: contract.id,
|
||||
createdTime,
|
||||
isAnte: true,
|
||||
|
||||
amount: amount,
|
||||
liquidity: amount,
|
||||
p: p,
|
||||
pool: { YES: 0, NO: 0 },
|
||||
}
|
||||
|
||||
return lp
|
||||
}
|
||||
|
||||
export function getAnteBets(
|
||||
creator: User,
|
||||
contract: DPMBinaryContract,
|
||||
yesAnteId: string,
|
||||
noAnteId: string
|
||||
) {
|
||||
const p = getDpmProbability(contract.totalShares)
|
||||
const ante = contract.totalBets.YES + contract.totalBets.NO
|
||||
|
||||
const { createdTime } = contract
|
||||
|
||||
const yesBet: NormalizedBet = {
|
||||
id: yesAnteId,
|
||||
userId: creator.id,
|
||||
contractId: contract.id,
|
||||
amount: p * ante,
|
||||
shares: Math.sqrt(p) * ante,
|
||||
outcome: 'YES',
|
||||
probBefore: p,
|
||||
probAfter: p,
|
||||
createdTime,
|
||||
isAnte: true,
|
||||
fees: noFees,
|
||||
}
|
||||
|
||||
const noBet: NormalizedBet = {
|
||||
id: noAnteId,
|
||||
userId: creator.id,
|
||||
contractId: contract.id,
|
||||
amount: (1 - p) * ante,
|
||||
shares: Math.sqrt(1 - p) * ante,
|
||||
outcome: 'NO',
|
||||
probBefore: p,
|
||||
probAfter: p,
|
||||
createdTime,
|
||||
isAnte: true,
|
||||
fees: noFees,
|
||||
}
|
||||
|
||||
return { yesBet, noBet }
|
||||
}
|
||||
|
||||
export function getFreeAnswerAnte(
|
||||
anteBettorId: string,
|
||||
contract: FreeResponseContract,
|
||||
anteBetId: string
|
||||
) {
|
||||
const { totalBets, totalShares } = contract
|
||||
const amount = totalBets['0']
|
||||
const shares = totalShares['0']
|
||||
|
||||
const { createdTime } = contract
|
||||
|
||||
const anteBet: NormalizedBet = {
|
||||
id: anteBetId,
|
||||
userId: anteBettorId,
|
||||
contractId: contract.id,
|
||||
amount,
|
||||
shares,
|
||||
outcome: '0',
|
||||
probBefore: 0,
|
||||
probAfter: 1,
|
||||
createdTime,
|
||||
isAnte: true,
|
||||
fees: noFees,
|
||||
}
|
||||
|
||||
return anteBet
|
||||
}
|
||||
|
||||
export function getMultipleChoiceAntes(
|
||||
creator: User,
|
||||
contract: MultipleChoiceContract,
|
||||
answers: string[],
|
||||
betDocIds: string[]
|
||||
) {
|
||||
const { totalBets, totalShares } = contract
|
||||
const amount = totalBets['0']
|
||||
const shares = totalShares['0']
|
||||
const p = 1 / answers.length
|
||||
|
||||
const { createdTime } = contract
|
||||
|
||||
const bets: NormalizedBet[] = answers.map((answer, i) => ({
|
||||
id: betDocIds[i],
|
||||
userId: creator.id,
|
||||
contractId: contract.id,
|
||||
amount,
|
||||
shares,
|
||||
outcome: i.toString(),
|
||||
probBefore: p,
|
||||
probAfter: p,
|
||||
createdTime,
|
||||
isAnte: true,
|
||||
fees: noFees,
|
||||
}))
|
||||
|
||||
const { username, name, avatarUrl } = creator
|
||||
|
||||
const answerObjects: Answer[] = answers.map((answer, i) => ({
|
||||
id: i.toString(),
|
||||
number: i,
|
||||
contractId: contract.id,
|
||||
createdTime,
|
||||
userId: creator.id,
|
||||
username,
|
||||
name,
|
||||
avatarUrl,
|
||||
text: answer,
|
||||
}))
|
||||
|
||||
return { bets, answerObjects }
|
||||
}
|
||||
|
||||
export function getNumericAnte(
|
||||
anteBettorId: string,
|
||||
contract: NumericContract,
|
||||
ante: number,
|
||||
newBetId: string
|
||||
) {
|
||||
const { bucketCount, createdTime } = contract
|
||||
|
||||
const betAnte = ante / bucketCount
|
||||
const betShares = Math.sqrt(ante ** 2 / bucketCount)
|
||||
|
||||
const allOutcomeShares = Object.fromEntries(
|
||||
range(0, bucketCount).map((_, i) => [i, betShares])
|
||||
)
|
||||
|
||||
const allBetAmounts = Object.fromEntries(
|
||||
range(0, bucketCount).map((_, i) => [i, betAnte])
|
||||
)
|
||||
|
||||
const anteBet: NormalizedBet<NumericBet> = {
|
||||
id: newBetId,
|
||||
userId: anteBettorId,
|
||||
contractId: contract.id,
|
||||
amount: ante,
|
||||
allBetAmounts,
|
||||
outcome: '0',
|
||||
value: getValueFromBucket('0', contract),
|
||||
shares: betShares,
|
||||
allOutcomeShares,
|
||||
probBefore: 0,
|
||||
probAfter: 1 / bucketCount,
|
||||
createdTime,
|
||||
isAnte: true,
|
||||
fees: noFees,
|
||||
}
|
||||
|
||||
return anteBet
|
||||
}
|
24
common/api.ts
Normal file
24
common/api.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { ENV_CONFIG } from './envs/constants'
|
||||
|
||||
export class APIError extends Error {
|
||||
code: number
|
||||
details?: unknown
|
||||
constructor(code: number, message: string, details?: unknown) {
|
||||
super(message)
|
||||
this.code = code
|
||||
this.name = 'APIError'
|
||||
this.details = details
|
||||
}
|
||||
}
|
||||
|
||||
export function getFunctionUrl(name: string) {
|
||||
if (process.env.NEXT_PUBLIC_FUNCTIONS_URL) {
|
||||
return `${process.env.NEXT_PUBLIC_FUNCTIONS_URL}/${name}`
|
||||
} else if (process.env.NEXT_PUBLIC_FIREBASE_EMULATE) {
|
||||
const { projectId, region } = ENV_CONFIG.firebaseConfig
|
||||
return `http://localhost:5001/${projectId}/${region}/${name}`
|
||||
} else {
|
||||
const { cloudRunId, cloudRunRegion } = ENV_CONFIG
|
||||
return `https://${name}-${cloudRunId}-${cloudRunRegion}.a.run.app`
|
||||
}
|
||||
}
|
123
common/badge.ts
Normal file
123
common/badge.ts
Normal file
|
@ -0,0 +1,123 @@
|
|||
import { User } from './user'
|
||||
|
||||
export type Badge = {
|
||||
type: BadgeTypes
|
||||
createdTime: number
|
||||
data: { [key: string]: any }
|
||||
name: 'Proven Correct' | 'Streaker' | 'Market Creator'
|
||||
}
|
||||
|
||||
export type BadgeTypes = 'PROVEN_CORRECT' | 'STREAKER' | 'MARKET_CREATOR'
|
||||
|
||||
export type ProvenCorrectBadgeData = {
|
||||
type: 'PROVEN_CORRECT'
|
||||
data: {
|
||||
contractSlug: string
|
||||
contractCreatorUsername: string
|
||||
contractTitle: string
|
||||
commentId: string
|
||||
betAmount: number
|
||||
}
|
||||
}
|
||||
|
||||
export type MarketCreatorBadgeData = {
|
||||
type: 'MARKET_CREATOR'
|
||||
data: {
|
||||
totalContractsCreated: number
|
||||
}
|
||||
}
|
||||
|
||||
export type StreakerBadgeData = {
|
||||
type: 'STREAKER'
|
||||
data: {
|
||||
totalBettingStreak: number
|
||||
}
|
||||
}
|
||||
|
||||
export type ProvenCorrectBadge = Badge & ProvenCorrectBadgeData
|
||||
export type StreakerBadge = Badge & StreakerBadgeData
|
||||
export type MarketCreatorBadge = Badge & MarketCreatorBadgeData
|
||||
|
||||
export const MINIMUM_UNIQUE_BETTORS_FOR_PROVEN_CORRECT_BADGE = 5
|
||||
export const provenCorrectRarityThresholds = [1, 1000, 10000]
|
||||
const calculateProvenCorrectBadgeRarity = (badge: ProvenCorrectBadge) => {
|
||||
const { betAmount } = badge.data
|
||||
const thresholdArray = provenCorrectRarityThresholds
|
||||
let i = thresholdArray.length - 1
|
||||
while (i >= 0) {
|
||||
if (betAmount >= thresholdArray[i]) {
|
||||
return i + 1
|
||||
}
|
||||
i--
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
export const streakerBadgeRarityThresholds = [1, 50, 250]
|
||||
const calculateStreakerBadgeRarity = (badge: StreakerBadge) => {
|
||||
const { totalBettingStreak } = badge.data
|
||||
const thresholdArray = streakerBadgeRarityThresholds
|
||||
let i = thresholdArray.length - 1
|
||||
while (i >= 0) {
|
||||
if (totalBettingStreak == thresholdArray[i]) {
|
||||
return i + 1
|
||||
}
|
||||
i--
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
export const marketCreatorBadgeRarityThresholds = [1, 75, 300]
|
||||
const calculateMarketCreatorBadgeRarity = (badge: MarketCreatorBadge) => {
|
||||
const { totalContractsCreated } = badge.data
|
||||
const thresholdArray = marketCreatorBadgeRarityThresholds
|
||||
let i = thresholdArray.length - 1
|
||||
while (i >= 0) {
|
||||
if (totalContractsCreated == thresholdArray[i]) {
|
||||
return i + 1
|
||||
}
|
||||
i--
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
export type rarities = 'bronze' | 'silver' | 'gold'
|
||||
|
||||
const rarityRanks: { [key: number]: rarities } = {
|
||||
1: 'bronze',
|
||||
2: 'silver',
|
||||
3: 'gold',
|
||||
}
|
||||
|
||||
export const calculateBadgeRarity = (badge: Badge) => {
|
||||
switch (badge.type) {
|
||||
case 'PROVEN_CORRECT':
|
||||
return rarityRanks[
|
||||
calculateProvenCorrectBadgeRarity(badge as ProvenCorrectBadge)
|
||||
]
|
||||
case 'MARKET_CREATOR':
|
||||
return rarityRanks[
|
||||
calculateMarketCreatorBadgeRarity(badge as MarketCreatorBadge)
|
||||
]
|
||||
case 'STREAKER':
|
||||
return rarityRanks[calculateStreakerBadgeRarity(badge as StreakerBadge)]
|
||||
default:
|
||||
return rarityRanks[0]
|
||||
}
|
||||
}
|
||||
|
||||
export const getBadgesByRarity = (user: User | null | undefined) => {
|
||||
const rarities: { [key in rarities]: number } = {
|
||||
bronze: 0,
|
||||
silver: 0,
|
||||
gold: 0,
|
||||
}
|
||||
if (!user) return rarities
|
||||
Object.values(user.achievements).map((value) => {
|
||||
value.badges.map((badge) => {
|
||||
rarities[calculateBadgeRarity(badge)] =
|
||||
(rarities[calculateBadgeRarity(badge)] ?? 0) + 1
|
||||
})
|
||||
})
|
||||
return rarities
|
||||
}
|
69
common/bet.ts
Normal file
69
common/bet.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
import { Fees } from './fees'
|
||||
|
||||
export type Bet = {
|
||||
id: string
|
||||
userId: string
|
||||
|
||||
// denormalized for bet lists
|
||||
userAvatarUrl?: string
|
||||
userUsername: string
|
||||
userName: string
|
||||
|
||||
contractId: string
|
||||
createdTime: number
|
||||
|
||||
amount: number // bet size; negative if SELL bet
|
||||
loanAmount?: number
|
||||
outcome: string
|
||||
shares: number // dynamic parimutuel pool weight or fixed ; negative if SELL bet
|
||||
|
||||
probBefore: number
|
||||
probAfter: number
|
||||
|
||||
fees: Fees
|
||||
|
||||
isAnte?: boolean
|
||||
isLiquidityProvision?: boolean
|
||||
isRedemption?: boolean
|
||||
challengeSlug?: string
|
||||
|
||||
// Props for bets in DPM contract below.
|
||||
// A bet is either a BUY or a SELL that sells all of a previous buy.
|
||||
isSold?: boolean // true if this BUY bet has been sold
|
||||
// This field marks a SELL bet.
|
||||
sale?: {
|
||||
amount: number // amount user makes from sale
|
||||
betId: string // id of BUY bet being sold
|
||||
}
|
||||
} & Partial<LimitProps>
|
||||
|
||||
export type NumericBet = Bet & {
|
||||
value: number
|
||||
allOutcomeShares: { [outcome: string]: number }
|
||||
allBetAmounts: { [outcome: string]: number }
|
||||
}
|
||||
|
||||
// Binary market limit order.
|
||||
export type LimitBet = Bet & LimitProps
|
||||
|
||||
type LimitProps = {
|
||||
orderAmount: number // Amount of limit order.
|
||||
limitProb: number // [0, 1]. Bet to this probability.
|
||||
isFilled: boolean // Whether all of the bet amount has been filled.
|
||||
isCancelled: boolean // Whether to prevent any further fills.
|
||||
// A record of each transaction that partially (or fully) fills the orderAmount.
|
||||
// I.e. A limit order could be filled by partially matching with several bets.
|
||||
// Non-limit orders can also be filled by matching with multiple limit orders.
|
||||
fills: fill[]
|
||||
}
|
||||
|
||||
export type fill = {
|
||||
// The id the bet matched against, or null if the bet was matched by the pool.
|
||||
matchedBetId: string | null
|
||||
amount: number
|
||||
shares: number
|
||||
timestamp: number
|
||||
// If the fill is a sale, it means the matching bet has shares of the same outcome.
|
||||
// I.e. -fill.shares === matchedBet.shares
|
||||
isSale?: boolean
|
||||
}
|
288
common/calculate-cpmm.ts
Normal file
288
common/calculate-cpmm.ts
Normal file
|
@ -0,0 +1,288 @@
|
|||
import { groupBy, mapValues, sumBy } from 'lodash'
|
||||
import { LimitBet } from './bet'
|
||||
|
||||
import { CREATOR_FEE, Fees, LIQUIDITY_FEE, PLATFORM_FEE } from './fees'
|
||||
import { LiquidityProvision } from './liquidity-provision'
|
||||
import { computeFills } from './new-bet'
|
||||
import { binarySearch } from './util/algos'
|
||||
|
||||
export type CpmmState = {
|
||||
pool: { [outcome: string]: number }
|
||||
p: number
|
||||
}
|
||||
|
||||
export function getCpmmProbability(
|
||||
pool: { [outcome: string]: number },
|
||||
p: number
|
||||
) {
|
||||
const { YES, NO } = pool
|
||||
return (p * NO) / ((1 - p) * YES + p * NO)
|
||||
}
|
||||
|
||||
export function getCpmmProbabilityAfterBetBeforeFees(
|
||||
state: CpmmState,
|
||||
outcome: string,
|
||||
bet: number
|
||||
) {
|
||||
const { pool, p } = state
|
||||
const shares = calculateCpmmShares(pool, p, bet, outcome)
|
||||
const { YES: y, NO: n } = pool
|
||||
|
||||
const [newY, newN] =
|
||||
outcome === 'YES'
|
||||
? [y - shares + bet, n + bet]
|
||||
: [y + bet, n - shares + bet]
|
||||
|
||||
return getCpmmProbability({ YES: newY, NO: newN }, p)
|
||||
}
|
||||
|
||||
export function getCpmmOutcomeProbabilityAfterBet(
|
||||
state: CpmmState,
|
||||
outcome: string,
|
||||
bet: number
|
||||
) {
|
||||
const { newPool } = calculateCpmmPurchase(state, bet, outcome)
|
||||
const p = getCpmmProbability(newPool, state.p)
|
||||
return outcome === 'NO' ? 1 - p : p
|
||||
}
|
||||
|
||||
// before liquidity fee
|
||||
function calculateCpmmShares(
|
||||
pool: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
p: number,
|
||||
bet: number,
|
||||
betChoice: string
|
||||
) {
|
||||
const { YES: y, NO: n } = pool
|
||||
const k = y ** p * n ** (1 - p)
|
||||
|
||||
return betChoice === 'YES'
|
||||
? // https://www.wolframalpha.com/input?i=%28y%2Bb-s%29%5E%28p%29*%28n%2Bb%29%5E%281-p%29+%3D+k%2C+solve+s
|
||||
y + bet - (k * (bet + n) ** (p - 1)) ** (1 / p)
|
||||
: n + bet - (k * (bet + y) ** -p) ** (1 / (1 - p))
|
||||
}
|
||||
|
||||
export function getCpmmFees(state: CpmmState, bet: number, outcome: string) {
|
||||
const prob = getCpmmProbabilityAfterBetBeforeFees(state, outcome, bet)
|
||||
const betP = outcome === 'YES' ? 1 - prob : prob
|
||||
|
||||
const liquidityFee = LIQUIDITY_FEE * betP * bet
|
||||
const platformFee = PLATFORM_FEE * betP * bet
|
||||
const creatorFee = CREATOR_FEE * betP * bet
|
||||
const fees: Fees = { liquidityFee, platformFee, creatorFee }
|
||||
|
||||
const totalFees = liquidityFee + platformFee + creatorFee
|
||||
const remainingBet = bet - totalFees
|
||||
|
||||
return { remainingBet, totalFees, fees }
|
||||
}
|
||||
|
||||
export function calculateCpmmSharesAfterFee(
|
||||
state: CpmmState,
|
||||
bet: number,
|
||||
outcome: string
|
||||
) {
|
||||
const { pool, p } = state
|
||||
const { remainingBet } = getCpmmFees(state, bet, outcome)
|
||||
|
||||
return calculateCpmmShares(pool, p, remainingBet, outcome)
|
||||
}
|
||||
|
||||
export function calculateCpmmPurchase(
|
||||
state: CpmmState,
|
||||
bet: number,
|
||||
outcome: string
|
||||
) {
|
||||
const { pool, p } = state
|
||||
const { remainingBet, fees } = getCpmmFees(state, bet, outcome)
|
||||
|
||||
const shares = calculateCpmmShares(pool, p, remainingBet, outcome)
|
||||
const { YES: y, NO: n } = pool
|
||||
|
||||
const { liquidityFee: fee } = fees
|
||||
|
||||
const [newY, newN] =
|
||||
outcome === 'YES'
|
||||
? [y - shares + remainingBet + fee, n + remainingBet + fee]
|
||||
: [y + remainingBet + fee, n - shares + remainingBet + fee]
|
||||
|
||||
const postBetPool = { YES: newY, NO: newN }
|
||||
|
||||
const { newPool, newP } = addCpmmLiquidity(postBetPool, p, fee)
|
||||
|
||||
return { shares, newPool, newP, fees }
|
||||
}
|
||||
|
||||
// Note: there might be a closed form solution for this.
|
||||
// If so, feel free to switch out this implementation.
|
||||
export function calculateCpmmAmountToProb(
|
||||
state: CpmmState,
|
||||
prob: number,
|
||||
outcome: 'YES' | 'NO'
|
||||
) {
|
||||
if (prob <= 0 || prob >= 1 || isNaN(prob)) return Infinity
|
||||
if (outcome === 'NO') prob = 1 - prob
|
||||
|
||||
// First, find an upper bound that leads to a more extreme probability than prob.
|
||||
let maxGuess = 10
|
||||
let newProb = 0
|
||||
do {
|
||||
maxGuess *= 10
|
||||
newProb = getCpmmOutcomeProbabilityAfterBet(state, outcome, maxGuess)
|
||||
} while (newProb < prob)
|
||||
|
||||
// Then, binary search for the amount that gets closest to prob.
|
||||
const amount = binarySearch(0, maxGuess, (amount) => {
|
||||
const newProb = getCpmmOutcomeProbabilityAfterBet(state, outcome, amount)
|
||||
return newProb - prob
|
||||
})
|
||||
|
||||
return amount
|
||||
}
|
||||
|
||||
function calculateAmountToBuyShares(
|
||||
state: CpmmState,
|
||||
shares: number,
|
||||
outcome: 'YES' | 'NO',
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) {
|
||||
// Search for amount between bounds (0, shares).
|
||||
// Min share price is M$0, and max is M$1 each.
|
||||
return binarySearch(0, shares, (amount) => {
|
||||
const { takers } = computeFills(
|
||||
outcome,
|
||||
amount,
|
||||
state,
|
||||
undefined,
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
)
|
||||
|
||||
const totalShares = sumBy(takers, (taker) => taker.shares)
|
||||
return totalShares - shares
|
||||
})
|
||||
}
|
||||
|
||||
export function calculateCpmmSale(
|
||||
state: CpmmState,
|
||||
shares: number,
|
||||
outcome: 'YES' | 'NO',
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) {
|
||||
if (Math.round(shares) < 0) {
|
||||
throw new Error('Cannot sell non-positive shares')
|
||||
}
|
||||
|
||||
const oppositeOutcome = outcome === 'YES' ? 'NO' : 'YES'
|
||||
const buyAmount = calculateAmountToBuyShares(
|
||||
state,
|
||||
shares,
|
||||
oppositeOutcome,
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
)
|
||||
|
||||
const { cpmmState, makers, takers, totalFees, ordersToCancel } = computeFills(
|
||||
oppositeOutcome,
|
||||
buyAmount,
|
||||
state,
|
||||
undefined,
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
)
|
||||
|
||||
// Transform buys of opposite outcome into sells.
|
||||
const saleTakers = takers.map((taker) => ({
|
||||
...taker,
|
||||
// You bought opposite shares, which combine with existing shares, removing them.
|
||||
shares: -taker.shares,
|
||||
// Opposite shares combine with shares you are selling for M$ of shares.
|
||||
// You paid taker.amount for the opposite shares.
|
||||
// Take the negative because this is money you gain.
|
||||
amount: -(taker.shares - taker.amount),
|
||||
isSale: true,
|
||||
}))
|
||||
|
||||
const saleValue = -sumBy(saleTakers, (taker) => taker.amount)
|
||||
|
||||
return {
|
||||
saleValue,
|
||||
cpmmState,
|
||||
fees: totalFees,
|
||||
makers,
|
||||
takers: saleTakers,
|
||||
ordersToCancel,
|
||||
}
|
||||
}
|
||||
|
||||
export function getCpmmProbabilityAfterSale(
|
||||
state: CpmmState,
|
||||
shares: number,
|
||||
outcome: 'YES' | 'NO',
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) {
|
||||
const { cpmmState } = calculateCpmmSale(
|
||||
state,
|
||||
shares,
|
||||
outcome,
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
)
|
||||
return getCpmmProbability(cpmmState.pool, cpmmState.p)
|
||||
}
|
||||
|
||||
export function getCpmmLiquidity(
|
||||
pool: { [outcome: string]: number },
|
||||
p: number
|
||||
) {
|
||||
const { YES, NO } = pool
|
||||
return YES ** p * NO ** (1 - p)
|
||||
}
|
||||
|
||||
export function addCpmmLiquidity(
|
||||
pool: { [outcome: string]: number },
|
||||
p: number,
|
||||
amount: number
|
||||
) {
|
||||
const prob = getCpmmProbability(pool, p)
|
||||
|
||||
//https://www.wolframalpha.com/input?i=p%28n%2Bb%29%2F%28%281-p%29%28y%2Bb%29%2Bp%28n%2Bb%29%29%3Dq%2C+solve+p
|
||||
const { YES: y, NO: n } = pool
|
||||
const numerator = prob * (amount + y)
|
||||
const denominator = amount - n * (prob - 1) + prob * y
|
||||
const newP = numerator / denominator
|
||||
|
||||
const newPool = { YES: y + amount, NO: n + amount }
|
||||
|
||||
const oldLiquidity = getCpmmLiquidity(pool, newP)
|
||||
const newLiquidity = getCpmmLiquidity(newPool, newP)
|
||||
const liquidity = newLiquidity - oldLiquidity
|
||||
|
||||
return { newPool, liquidity, newP }
|
||||
}
|
||||
|
||||
export function getCpmmLiquidityPoolWeights(liquidities: LiquidityProvision[]) {
|
||||
const userAmounts = groupBy(liquidities, (w) => w.userId)
|
||||
const totalAmount = sumBy(liquidities, (w) => w.amount)
|
||||
|
||||
return mapValues(
|
||||
userAmounts,
|
||||
(amounts) => sumBy(amounts, (w) => w.amount) / totalAmount
|
||||
)
|
||||
}
|
||||
|
||||
export function getUserLiquidityShares(
|
||||
userId: string,
|
||||
state: CpmmState,
|
||||
liquidities: LiquidityProvision[]
|
||||
) {
|
||||
const weights = getCpmmLiquidityPoolWeights(liquidities)
|
||||
const userWeight = weights[userId] ?? 0
|
||||
|
||||
return mapValues(state.pool, (shares) => userWeight * shares)
|
||||
}
|
420
common/calculate-dpm.ts
Normal file
420
common/calculate-dpm.ts
Normal file
|
@ -0,0 +1,420 @@
|
|||
import { cloneDeep, range, sum, sumBy, sortBy, mapValues } from 'lodash'
|
||||
import { Bet, NumericBet } from './bet'
|
||||
import { DPMContract, DPMBinaryContract, NumericContract } from './contract'
|
||||
import { DPM_FEES } from './fees'
|
||||
import { normpdf } from './util/math'
|
||||
import { addObjects } from './util/object'
|
||||
|
||||
export function getDpmProbability(totalShares: { [outcome: string]: number }) {
|
||||
// For binary contracts only.
|
||||
return getDpmOutcomeProbability(totalShares, 'YES')
|
||||
}
|
||||
|
||||
export function getDpmOutcomeProbability(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
outcome: string
|
||||
) {
|
||||
const squareSum = sumBy(Object.values(totalShares), (shares) => shares ** 2)
|
||||
const shares = totalShares[outcome] ?? 0
|
||||
return shares ** 2 / squareSum
|
||||
}
|
||||
|
||||
export function getDpmOutcomeProbabilities(totalShares: {
|
||||
[outcome: string]: number
|
||||
}) {
|
||||
const squareSum = sumBy(Object.values(totalShares), (shares) => shares ** 2)
|
||||
return mapValues(totalShares, (shares) => shares ** 2 / squareSum)
|
||||
}
|
||||
|
||||
export function getNumericBets(
|
||||
contract: NumericContract,
|
||||
bucket: string,
|
||||
betAmount: number,
|
||||
variance: number
|
||||
) {
|
||||
const { bucketCount } = contract
|
||||
const bucketNumber = parseInt(bucket)
|
||||
const buckets = range(0, bucketCount)
|
||||
|
||||
const mean = bucketNumber / bucketCount
|
||||
|
||||
const allDensities = buckets.map((i) =>
|
||||
normpdf(i / bucketCount, mean, variance)
|
||||
)
|
||||
const densitySum = sum(allDensities)
|
||||
|
||||
const rawBetAmounts = allDensities
|
||||
.map((d) => (d / densitySum) * betAmount)
|
||||
.map((x) => (x >= 1 / bucketCount ? x : 0))
|
||||
|
||||
const rawSum = sum(rawBetAmounts)
|
||||
const scaledBetAmounts = rawBetAmounts.map((x) => (x / rawSum) * betAmount)
|
||||
|
||||
const bets = scaledBetAmounts
|
||||
.map((x, i) => (x > 0 ? [i.toString(), x] : undefined))
|
||||
.filter((x) => x != undefined) as [string, number][]
|
||||
|
||||
return bets
|
||||
}
|
||||
|
||||
export const getMappedBucket = (value: number, contract: NumericContract) => {
|
||||
const { bucketCount, min, max } = contract
|
||||
|
||||
const index = Math.floor(((value - min) / (max - min)) * bucketCount)
|
||||
const bucket = Math.max(Math.min(index, bucketCount - 1), 0)
|
||||
|
||||
return `${bucket}`
|
||||
}
|
||||
|
||||
export const getValueFromBucket = (
|
||||
bucket: string,
|
||||
contract: NumericContract
|
||||
) => {
|
||||
const { bucketCount, min, max } = contract
|
||||
const index = parseInt(bucket)
|
||||
const value = min + (index / bucketCount) * (max - min)
|
||||
const rounded = Math.round(value * 1e4) / 1e4
|
||||
return rounded
|
||||
}
|
||||
|
||||
export const getExpectedValue = (contract: NumericContract) => {
|
||||
const { bucketCount, min, max, totalShares } = contract
|
||||
|
||||
const totalShareSum = sumBy(
|
||||
Object.values(totalShares),
|
||||
(shares) => shares ** 2
|
||||
)
|
||||
const probs = range(0, bucketCount).map(
|
||||
(i) => totalShares[i] ** 2 / totalShareSum
|
||||
)
|
||||
|
||||
const values = range(0, bucketCount).map(
|
||||
(i) =>
|
||||
// use mid point within bucket
|
||||
0.5 * (min + (i / bucketCount) * (max - min)) +
|
||||
0.5 * (min + ((i + 1) / bucketCount) * (max - min))
|
||||
)
|
||||
|
||||
const weightedValues = range(0, bucketCount).map((i) => probs[i] * values[i])
|
||||
|
||||
const expectation = sum(weightedValues)
|
||||
const rounded = Math.round(expectation * 1e2) / 1e2
|
||||
return rounded
|
||||
}
|
||||
|
||||
export function getDpmOutcomeProbabilityAfterBet(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
outcome: string,
|
||||
bet: number
|
||||
) {
|
||||
const shares = calculateDpmShares(totalShares, bet, outcome)
|
||||
|
||||
const prevShares = totalShares[outcome] ?? 0
|
||||
const newTotalShares = { ...totalShares, [outcome]: prevShares + shares }
|
||||
|
||||
return getDpmOutcomeProbability(newTotalShares, outcome)
|
||||
}
|
||||
|
||||
export function getDpmProbabilityAfterSale(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
outcome: string,
|
||||
shares: number
|
||||
) {
|
||||
const prevShares = totalShares[outcome] ?? 0
|
||||
const newTotalShares = { ...totalShares, [outcome]: prevShares - shares }
|
||||
|
||||
const predictionOutcome = outcome === 'NO' ? 'YES' : outcome
|
||||
return getDpmOutcomeProbability(newTotalShares, predictionOutcome)
|
||||
}
|
||||
|
||||
export function calculateDpmShares(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
bet: number,
|
||||
betChoice: string
|
||||
) {
|
||||
const squareSum = sumBy(Object.values(totalShares), (shares) => shares ** 2)
|
||||
const shares = totalShares[betChoice] ?? 0
|
||||
|
||||
const c = 2 * bet * Math.sqrt(squareSum)
|
||||
|
||||
return Math.sqrt(bet ** 2 + shares ** 2 + c) - shares
|
||||
}
|
||||
|
||||
export function calculateNumericDpmShares(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
bets: [string, number][]
|
||||
) {
|
||||
const shares: number[] = []
|
||||
|
||||
totalShares = cloneDeep(totalShares)
|
||||
|
||||
const order = sortBy(
|
||||
bets.map(([, amount], i) => [amount, i]),
|
||||
([amount]) => amount
|
||||
).map(([, i]) => i)
|
||||
|
||||
for (const i of order) {
|
||||
const [bucket, bet] = bets[i]
|
||||
shares[i] = calculateDpmShares(totalShares, bet, bucket)
|
||||
totalShares = addObjects(totalShares, { [bucket]: shares[i] })
|
||||
}
|
||||
|
||||
return { shares, totalShares }
|
||||
}
|
||||
|
||||
export function calculateDpmRawShareValue(
|
||||
totalShares: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
shares: number,
|
||||
betChoice: string
|
||||
) {
|
||||
const currentValue = Math.sqrt(
|
||||
sumBy(Object.values(totalShares), (shares) => shares ** 2)
|
||||
)
|
||||
|
||||
const postSaleValue = Math.sqrt(
|
||||
sumBy(Object.keys(totalShares), (outcome) =>
|
||||
outcome === betChoice
|
||||
? Math.max(0, totalShares[outcome] - shares) ** 2
|
||||
: totalShares[outcome] ** 2
|
||||
)
|
||||
)
|
||||
|
||||
return currentValue - postSaleValue
|
||||
}
|
||||
|
||||
export function calculateDpmMoneyRatio(
|
||||
contract: DPMContract,
|
||||
bet: Bet,
|
||||
shareValue: number
|
||||
) {
|
||||
const { totalShares, totalBets, pool } = contract
|
||||
const { outcome, amount } = bet
|
||||
|
||||
const p = getDpmOutcomeProbability(totalShares, outcome)
|
||||
|
||||
const actual = sum(Object.values(pool)) - shareValue
|
||||
|
||||
const betAmount = p * amount
|
||||
|
||||
const expected =
|
||||
sumBy(
|
||||
Object.keys(totalBets),
|
||||
(outcome) =>
|
||||
getDpmOutcomeProbability(totalShares, outcome) *
|
||||
(totalBets as { [outcome: string]: number })[outcome]
|
||||
) - betAmount
|
||||
|
||||
if (actual <= 0 || expected <= 0) return 0
|
||||
|
||||
return actual / expected
|
||||
}
|
||||
|
||||
export function calculateDpmShareValue(contract: DPMContract, bet: Bet) {
|
||||
const { pool, totalShares } = contract
|
||||
const { shares, outcome } = bet
|
||||
|
||||
const shareValue = calculateDpmRawShareValue(totalShares, shares, outcome)
|
||||
const f = calculateDpmMoneyRatio(contract, bet, shareValue)
|
||||
|
||||
const myPool = pool[outcome]
|
||||
const adjShareValue = Math.min(Math.min(1, f) * shareValue, myPool)
|
||||
return adjShareValue
|
||||
}
|
||||
|
||||
export function calculateDpmSaleAmount(contract: DPMContract, bet: Bet) {
|
||||
const { amount } = bet
|
||||
const winnings = calculateDpmShareValue(contract, bet)
|
||||
return deductDpmFees(amount, winnings)
|
||||
}
|
||||
|
||||
export function calculateDpmPayout(
|
||||
contract: DPMContract,
|
||||
bet: Bet,
|
||||
outcome: string
|
||||
) {
|
||||
if (outcome === 'CANCEL') return calculateDpmCancelPayout(contract, bet)
|
||||
if (outcome === 'MKT') return calculateMktDpmPayout(contract, bet)
|
||||
|
||||
return calculateStandardDpmPayout(contract, bet, outcome)
|
||||
}
|
||||
|
||||
export function calculateDpmCancelPayout(contract: DPMContract, bet: Bet) {
|
||||
const { totalBets, pool } = contract
|
||||
const betTotal = sum(Object.values(totalBets))
|
||||
const poolTotal = sum(Object.values(pool))
|
||||
|
||||
return (bet.amount / betTotal) * poolTotal
|
||||
}
|
||||
|
||||
export function calculateStandardDpmPayout(
|
||||
contract: DPMContract,
|
||||
bet: Bet,
|
||||
outcome: string
|
||||
) {
|
||||
const { outcome: betOutcome } = bet
|
||||
const isNumeric = contract.outcomeType === 'NUMERIC'
|
||||
if (!isNumeric && betOutcome !== outcome) return 0
|
||||
|
||||
const shares = isNumeric
|
||||
? ((bet as NumericBet).allOutcomeShares ?? {})[outcome]
|
||||
: bet.shares
|
||||
|
||||
if (!shares) return 0
|
||||
|
||||
const { totalShares, phantomShares, pool } = contract
|
||||
if (!totalShares[outcome]) return 0
|
||||
|
||||
const poolTotal = sum(Object.values(pool))
|
||||
|
||||
const total =
|
||||
totalShares[outcome] - (phantomShares ? phantomShares[outcome] : 0)
|
||||
|
||||
const winnings = (shares / total) * poolTotal
|
||||
|
||||
const amount = isNumeric
|
||||
? (bet as NumericBet).allBetAmounts[outcome]
|
||||
: bet.amount
|
||||
|
||||
const payout = amount + (1 - DPM_FEES) * Math.max(0, winnings - amount)
|
||||
return payout
|
||||
}
|
||||
|
||||
export function calculateDpmPayoutAfterCorrectBet(
|
||||
contract: DPMContract,
|
||||
bet: Bet
|
||||
) {
|
||||
const { totalShares, pool, totalBets, outcomeType } = contract
|
||||
const { shares, amount, outcome } = bet
|
||||
|
||||
const prevShares = totalShares[outcome] ?? 0
|
||||
const prevPool = pool[outcome] ?? 0
|
||||
const prevTotalBet = totalBets[outcome] ?? 0
|
||||
|
||||
const newContract = {
|
||||
...contract,
|
||||
totalShares: {
|
||||
...totalShares,
|
||||
[outcome]: prevShares + shares,
|
||||
},
|
||||
pool: {
|
||||
...pool,
|
||||
[outcome]: prevPool + amount,
|
||||
},
|
||||
totalBets: {
|
||||
...totalBets,
|
||||
[outcome]: prevTotalBet + amount,
|
||||
},
|
||||
outcomeType:
|
||||
outcomeType === 'NUMERIC'
|
||||
? 'FREE_RESPONSE' // hack to show payout at particular bet point estimate
|
||||
: outcomeType,
|
||||
}
|
||||
|
||||
return calculateStandardDpmPayout(newContract as any, bet, outcome)
|
||||
}
|
||||
|
||||
function calculateMktDpmPayout(contract: DPMContract, bet: Bet) {
|
||||
if (contract.outcomeType === 'BINARY')
|
||||
return calculateBinaryMktDpmPayout(contract, bet)
|
||||
|
||||
const { totalShares, pool, resolutions, outcomeType } = contract
|
||||
|
||||
let probs: { [outcome: string]: number }
|
||||
|
||||
if (resolutions) {
|
||||
const probTotal = sum(Object.values(resolutions))
|
||||
probs = mapValues(
|
||||
totalShares,
|
||||
(_, outcome) => (resolutions[outcome] ?? 0) / probTotal
|
||||
)
|
||||
} else {
|
||||
const squareSum = sum(
|
||||
Object.values(totalShares).map((shares) => shares ** 2)
|
||||
)
|
||||
probs = mapValues(totalShares, (shares) => shares ** 2 / squareSum)
|
||||
}
|
||||
|
||||
const { outcome, amount, shares } = bet
|
||||
|
||||
const poolFrac =
|
||||
outcomeType === 'NUMERIC'
|
||||
? sumBy(
|
||||
Object.keys((bet as NumericBet).allOutcomeShares ?? {}),
|
||||
(outcome) => {
|
||||
return (
|
||||
(probs[outcome] * (bet as NumericBet).allOutcomeShares[outcome]) /
|
||||
totalShares[outcome]
|
||||
)
|
||||
}
|
||||
)
|
||||
: (probs[outcome] * shares) / totalShares[outcome]
|
||||
|
||||
const totalPool = sum(Object.values(pool))
|
||||
const winnings = poolFrac * totalPool
|
||||
return deductDpmFees(amount, winnings)
|
||||
}
|
||||
|
||||
function calculateBinaryMktDpmPayout(contract: DPMBinaryContract, bet: Bet) {
|
||||
const { resolutionProbability, totalShares, phantomShares } = contract
|
||||
const p =
|
||||
resolutionProbability !== undefined
|
||||
? resolutionProbability
|
||||
: getDpmProbability(totalShares)
|
||||
|
||||
const pool = contract.pool.YES + contract.pool.NO
|
||||
|
||||
const weightedShareTotal =
|
||||
p * (totalShares.YES - (phantomShares?.YES ?? 0)) +
|
||||
(1 - p) * (totalShares.NO - (phantomShares?.NO ?? 0))
|
||||
|
||||
const { outcome, amount, shares } = bet
|
||||
|
||||
const betP = outcome === 'YES' ? p : 1 - p
|
||||
const winnings = ((betP * shares) / weightedShareTotal) * pool
|
||||
|
||||
return deductDpmFees(amount, winnings)
|
||||
}
|
||||
|
||||
export function resolvedDpmPayout(contract: DPMContract, bet: Bet) {
|
||||
if (contract.resolution)
|
||||
return calculateDpmPayout(contract, bet, contract.resolution)
|
||||
throw new Error('Contract was not resolved')
|
||||
}
|
||||
|
||||
export const deductDpmFees = (betAmount: number, winnings: number) => {
|
||||
return winnings > betAmount
|
||||
? betAmount + (1 - DPM_FEES) * (winnings - betAmount)
|
||||
: winnings
|
||||
}
|
||||
|
||||
export const calcDpmInitialPool = (
|
||||
initialProbInt: number,
|
||||
ante: number,
|
||||
phantomAnte: number
|
||||
) => {
|
||||
const p = initialProbInt / 100.0
|
||||
const totalAnte = phantomAnte + ante
|
||||
|
||||
const sharesYes = Math.sqrt(p * totalAnte ** 2)
|
||||
const sharesNo = Math.sqrt(totalAnte ** 2 - sharesYes ** 2)
|
||||
|
||||
const poolYes = p * ante
|
||||
const poolNo = (1 - p) * ante
|
||||
|
||||
const phantomYes = Math.sqrt(p) * phantomAnte
|
||||
const phantomNo = Math.sqrt(1 - p) * phantomAnte
|
||||
|
||||
return { sharesYes, sharesNo, poolYes, poolNo, phantomYes, phantomNo }
|
||||
}
|
38
common/calculate-fixed-payouts.ts
Normal file
38
common/calculate-fixed-payouts.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { Bet } from './bet'
|
||||
import { getProbability } from './calculate'
|
||||
import { CPMMContract } from './contract'
|
||||
|
||||
export function calculateFixedPayout(
|
||||
contract: CPMMContract,
|
||||
bet: Bet,
|
||||
outcome: string
|
||||
) {
|
||||
if (outcome === 'CANCEL') return calculateFixedCancelPayout(bet)
|
||||
if (outcome === 'MKT') return calculateFixedMktPayout(contract, bet)
|
||||
|
||||
return calculateStandardFixedPayout(bet, outcome)
|
||||
}
|
||||
|
||||
export function calculateFixedCancelPayout(bet: Bet) {
|
||||
return bet.amount
|
||||
}
|
||||
|
||||
export function calculateStandardFixedPayout(bet: Bet, outcome: string) {
|
||||
const { outcome: betOutcome, shares } = bet
|
||||
if (betOutcome !== outcome) return 0
|
||||
return shares
|
||||
}
|
||||
|
||||
function calculateFixedMktPayout(contract: CPMMContract, bet: Bet) {
|
||||
const { resolutionProbability } = contract
|
||||
const p =
|
||||
resolutionProbability !== undefined
|
||||
? resolutionProbability
|
||||
: getProbability(contract)
|
||||
|
||||
const { outcome, shares } = bet
|
||||
|
||||
const betP = outcome === 'YES' ? p : 1 - p
|
||||
|
||||
return betP * shares
|
||||
}
|
315
common/calculate-metrics.ts
Normal file
315
common/calculate-metrics.ts
Normal file
|
@ -0,0 +1,315 @@
|
|||
import { Dictionary, groupBy, last, partition, sum, sumBy, uniq } from 'lodash'
|
||||
import { calculatePayout, getContractBetMetrics } from './calculate'
|
||||
import { Bet, LimitBet } from './bet'
|
||||
import {
|
||||
Contract,
|
||||
CPMMBinaryContract,
|
||||
CPMMContract,
|
||||
DPMContract,
|
||||
} from './contract'
|
||||
import { PortfolioMetrics, User } from './user'
|
||||
import { DAY_MS } from './util/time'
|
||||
import { getBinaryCpmmBetInfo, getNewMultiBetInfo } from './new-bet'
|
||||
import { getCpmmProbability } from './calculate-cpmm'
|
||||
import { removeUndefinedProps } from './util/object'
|
||||
|
||||
const computeInvestmentValue = (
|
||||
bets: Bet[],
|
||||
contractsDict: { [k: string]: Contract }
|
||||
) => {
|
||||
return sumBy(bets, (bet) => {
|
||||
const contract = contractsDict[bet.contractId]
|
||||
if (!contract || contract.isResolved) return 0
|
||||
if (bet.sale || bet.isSold) return 0
|
||||
|
||||
const payout = calculatePayout(contract, bet, 'MKT')
|
||||
const value = payout - (bet.loanAmount ?? 0)
|
||||
if (isNaN(value)) return 0
|
||||
return value
|
||||
})
|
||||
}
|
||||
|
||||
export const computeInvestmentValueCustomProb = (
|
||||
bets: Bet[],
|
||||
contract: Contract,
|
||||
p: number
|
||||
) => {
|
||||
return sumBy(bets, (bet) => {
|
||||
if (!contract || contract.isResolved) return 0
|
||||
if (bet.sale || bet.isSold) return 0
|
||||
const { outcome, shares } = bet
|
||||
|
||||
const betP = outcome === 'YES' ? p : 1 - p
|
||||
|
||||
const value = betP * shares
|
||||
if (isNaN(value)) return 0
|
||||
return value
|
||||
})
|
||||
}
|
||||
|
||||
export const computeElasticity = (
|
||||
bets: Bet[],
|
||||
contract: Contract,
|
||||
betAmount = 50
|
||||
) => {
|
||||
const { mechanism, outcomeType } = contract
|
||||
return mechanism === 'cpmm-1' &&
|
||||
(outcomeType === 'BINARY' || outcomeType === 'PSEUDO_NUMERIC')
|
||||
? computeBinaryCpmmElasticity(bets, contract, betAmount)
|
||||
: computeDpmElasticity(contract, betAmount)
|
||||
}
|
||||
|
||||
export const computeBinaryCpmmElasticity = (
|
||||
bets: Bet[],
|
||||
contract: CPMMContract,
|
||||
betAmount: number
|
||||
) => {
|
||||
const limitBets = bets
|
||||
.filter(
|
||||
(b) =>
|
||||
!b.isFilled &&
|
||||
!b.isSold &&
|
||||
!b.isRedemption &&
|
||||
!b.sale &&
|
||||
!b.isCancelled &&
|
||||
b.limitProb !== undefined
|
||||
)
|
||||
.sort((a, b) => a.createdTime - b.createdTime) as LimitBet[]
|
||||
|
||||
const userIds = uniq(limitBets.map((b) => b.userId))
|
||||
// Assume all limit orders are good.
|
||||
const userBalances = Object.fromEntries(
|
||||
userIds.map((id) => [id, Number.MAX_SAFE_INTEGER])
|
||||
)
|
||||
|
||||
const { newPool: poolY, newP: pY } = getBinaryCpmmBetInfo(
|
||||
'YES',
|
||||
betAmount,
|
||||
contract,
|
||||
undefined,
|
||||
limitBets,
|
||||
userBalances
|
||||
)
|
||||
const resultYes = getCpmmProbability(poolY, pY)
|
||||
|
||||
const { newPool: poolN, newP: pN } = getBinaryCpmmBetInfo(
|
||||
'NO',
|
||||
betAmount,
|
||||
contract,
|
||||
undefined,
|
||||
limitBets,
|
||||
userBalances
|
||||
)
|
||||
const resultNo = getCpmmProbability(poolN, pN)
|
||||
|
||||
// handle AMM overflow
|
||||
const safeYes = Number.isFinite(resultYes) ? resultYes : 1
|
||||
const safeNo = Number.isFinite(resultNo) ? resultNo : 0
|
||||
|
||||
return safeYes - safeNo
|
||||
}
|
||||
|
||||
export const computeDpmElasticity = (
|
||||
contract: DPMContract,
|
||||
betAmount: number
|
||||
) => {
|
||||
return getNewMultiBetInfo('', 2 * betAmount, contract).newBet.probAfter
|
||||
}
|
||||
|
||||
const computeTotalPool = (userContracts: Contract[], startTime = 0) => {
|
||||
const periodFilteredContracts = userContracts.filter(
|
||||
(contract) => contract.createdTime >= startTime
|
||||
)
|
||||
return sum(
|
||||
periodFilteredContracts.map((contract) => sum(Object.values(contract.pool)))
|
||||
)
|
||||
}
|
||||
|
||||
export const computeVolume = (contractBets: Bet[], since: number) => {
|
||||
return sumBy(contractBets, (b) =>
|
||||
b.createdTime > since && !b.isRedemption ? Math.abs(b.amount) : 0
|
||||
)
|
||||
}
|
||||
|
||||
const calculateProbChangeSince = (descendingBets: Bet[], since: number) => {
|
||||
const newestBet = descendingBets[0]
|
||||
if (!newestBet) return 0
|
||||
|
||||
const betBeforeSince = descendingBets.find((b) => b.createdTime < since)
|
||||
|
||||
if (!betBeforeSince) {
|
||||
const oldestBet = last(descendingBets) ?? newestBet
|
||||
return newestBet.probAfter - oldestBet.probBefore
|
||||
}
|
||||
|
||||
return newestBet.probAfter - betBeforeSince.probAfter
|
||||
}
|
||||
|
||||
export const calculateProbChanges = (descendingBets: Bet[]) => {
|
||||
const now = Date.now()
|
||||
const yesterday = now - DAY_MS
|
||||
const weekAgo = now - 7 * DAY_MS
|
||||
const monthAgo = now - 30 * DAY_MS
|
||||
|
||||
return {
|
||||
day: calculateProbChangeSince(descendingBets, yesterday),
|
||||
week: calculateProbChangeSince(descendingBets, weekAgo),
|
||||
month: calculateProbChangeSince(descendingBets, monthAgo),
|
||||
}
|
||||
}
|
||||
|
||||
export const calculateCreatorVolume = (userContracts: Contract[]) => {
|
||||
const allTimeCreatorVolume = computeTotalPool(userContracts, 0)
|
||||
const monthlyCreatorVolume = computeTotalPool(
|
||||
userContracts,
|
||||
Date.now() - 30 * DAY_MS
|
||||
)
|
||||
const weeklyCreatorVolume = computeTotalPool(
|
||||
userContracts,
|
||||
Date.now() - 7 * DAY_MS
|
||||
)
|
||||
|
||||
const dailyCreatorVolume = computeTotalPool(
|
||||
userContracts,
|
||||
Date.now() - 1 * DAY_MS
|
||||
)
|
||||
|
||||
return {
|
||||
daily: dailyCreatorVolume,
|
||||
weekly: weeklyCreatorVolume,
|
||||
monthly: monthlyCreatorVolume,
|
||||
allTime: allTimeCreatorVolume,
|
||||
}
|
||||
}
|
||||
|
||||
export const calculateNewPortfolioMetrics = (
|
||||
user: User,
|
||||
contractsById: { [k: string]: Contract },
|
||||
currentBets: Bet[]
|
||||
) => {
|
||||
const investmentValue = computeInvestmentValue(currentBets, contractsById)
|
||||
const newPortfolio = {
|
||||
investmentValue: investmentValue,
|
||||
balance: user.balance,
|
||||
totalDeposits: user.totalDeposits,
|
||||
timestamp: Date.now(),
|
||||
userId: user.id,
|
||||
}
|
||||
return newPortfolio
|
||||
}
|
||||
|
||||
const calculateProfitForPeriod = (
|
||||
startingPortfolio: PortfolioMetrics | undefined,
|
||||
currentProfit: number
|
||||
) => {
|
||||
if (startingPortfolio === undefined) {
|
||||
return currentProfit
|
||||
}
|
||||
|
||||
const startingProfit = calculatePortfolioProfit(startingPortfolio)
|
||||
|
||||
return currentProfit - startingProfit
|
||||
}
|
||||
|
||||
export const calculatePortfolioProfit = (portfolio: PortfolioMetrics) => {
|
||||
return portfolio.investmentValue + portfolio.balance - portfolio.totalDeposits
|
||||
}
|
||||
|
||||
export const calculateNewProfit = (
|
||||
portfolioHistory: Record<
|
||||
'current' | 'day' | 'week' | 'month',
|
||||
PortfolioMetrics | undefined
|
||||
>,
|
||||
newPortfolio: PortfolioMetrics
|
||||
) => {
|
||||
const allTimeProfit = calculatePortfolioProfit(newPortfolio)
|
||||
|
||||
const newProfit = {
|
||||
daily: calculateProfitForPeriod(portfolioHistory.day, allTimeProfit),
|
||||
weekly: calculateProfitForPeriod(portfolioHistory.week, allTimeProfit),
|
||||
monthly: calculateProfitForPeriod(portfolioHistory.month, allTimeProfit),
|
||||
allTime: allTimeProfit,
|
||||
}
|
||||
|
||||
return newProfit
|
||||
}
|
||||
|
||||
export const calculateMetricsByContract = (
|
||||
bets: Bet[],
|
||||
contractsById: Dictionary<Contract>
|
||||
) => {
|
||||
const betsByContract = groupBy(bets, (bet) => bet.contractId)
|
||||
const unresolvedContracts = Object.keys(betsByContract)
|
||||
.map((cid) => contractsById[cid])
|
||||
.filter((c) => c && !c.isResolved)
|
||||
|
||||
return unresolvedContracts.map((c) => {
|
||||
const bets = betsByContract[c.id] ?? []
|
||||
const current = getContractBetMetrics(c, bets)
|
||||
|
||||
let periodMetrics
|
||||
if (c.mechanism === 'cpmm-1' && c.outcomeType === 'BINARY') {
|
||||
const periods = ['day', 'week', 'month'] as const
|
||||
periodMetrics = Object.fromEntries(
|
||||
periods.map((period) => [
|
||||
period,
|
||||
calculatePeriodProfit(c, bets, period),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
return removeUndefinedProps({
|
||||
contractId: c.id,
|
||||
...current,
|
||||
from: periodMetrics,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export type ContractMetrics = ReturnType<
|
||||
typeof calculateMetricsByContract
|
||||
>[number]
|
||||
|
||||
const calculatePeriodProfit = (
|
||||
contract: CPMMBinaryContract,
|
||||
bets: Bet[],
|
||||
period: 'day' | 'week' | 'month'
|
||||
) => {
|
||||
const days = period === 'day' ? 1 : period === 'week' ? 7 : 30
|
||||
const fromTime = Date.now() - days * DAY_MS
|
||||
const [previousBets, recentBets] = partition(
|
||||
bets,
|
||||
(b) => b.createdTime < fromTime
|
||||
)
|
||||
|
||||
const prevProb = contract.prob - contract.probChanges[period]
|
||||
const prob = contract.resolutionProbability
|
||||
? contract.resolutionProbability
|
||||
: contract.prob
|
||||
|
||||
const previousBetsValue = computeInvestmentValueCustomProb(
|
||||
previousBets,
|
||||
contract,
|
||||
prevProb
|
||||
)
|
||||
const currentBetsValue = computeInvestmentValueCustomProb(
|
||||
previousBets,
|
||||
contract,
|
||||
prob
|
||||
)
|
||||
|
||||
const { profit: recentProfit, invested: recentInvested } =
|
||||
getContractBetMetrics(contract, recentBets)
|
||||
|
||||
const profit = currentBetsValue - previousBetsValue + recentProfit
|
||||
const invested = previousBetsValue + recentInvested
|
||||
const profitPercent = invested === 0 ? 0 : 100 * (profit / invested)
|
||||
|
||||
return {
|
||||
profit,
|
||||
profitPercent,
|
||||
invested,
|
||||
prevValue: previousBetsValue,
|
||||
value: currentBetsValue,
|
||||
}
|
||||
}
|
302
common/calculate.ts
Normal file
302
common/calculate.ts
Normal file
|
@ -0,0 +1,302 @@
|
|||
import { maxBy, partition, sortBy, sum, sumBy } from 'lodash'
|
||||
import { Bet, LimitBet } from './bet'
|
||||
import {
|
||||
calculateCpmmSale,
|
||||
getCpmmProbability,
|
||||
getCpmmOutcomeProbabilityAfterBet,
|
||||
getCpmmProbabilityAfterSale,
|
||||
calculateCpmmSharesAfterFee,
|
||||
} from './calculate-cpmm'
|
||||
import {
|
||||
calculateDpmPayout,
|
||||
calculateDpmPayoutAfterCorrectBet,
|
||||
calculateDpmSaleAmount,
|
||||
calculateDpmShares,
|
||||
getDpmOutcomeProbability,
|
||||
getDpmProbability,
|
||||
getDpmOutcomeProbabilityAfterBet,
|
||||
getDpmProbabilityAfterSale,
|
||||
} from './calculate-dpm'
|
||||
import { calculateFixedPayout } from './calculate-fixed-payouts'
|
||||
import {
|
||||
Contract,
|
||||
BinaryContract,
|
||||
FreeResponseContract,
|
||||
PseudoNumericContract,
|
||||
MultipleChoiceContract,
|
||||
} from './contract'
|
||||
import { floatingEqual } from './util/math'
|
||||
|
||||
export function getProbability(
|
||||
contract: BinaryContract | PseudoNumericContract
|
||||
) {
|
||||
return contract.mechanism === 'cpmm-1'
|
||||
? getCpmmProbability(contract.pool, contract.p)
|
||||
: getDpmProbability(contract.totalShares)
|
||||
}
|
||||
|
||||
export function getInitialProbability(
|
||||
contract: BinaryContract | PseudoNumericContract
|
||||
) {
|
||||
if (contract.initialProbability) return contract.initialProbability
|
||||
|
||||
if (contract.mechanism === 'dpm-2' || (contract as any).totalShares)
|
||||
// use totalShares to calculate prob for ported contracts
|
||||
return getDpmProbability(
|
||||
(contract as any).phantomShares ?? (contract as any).totalShares
|
||||
)
|
||||
|
||||
return getCpmmProbability(contract.pool, contract.p)
|
||||
}
|
||||
|
||||
export function getOutcomeProbability(contract: Contract, outcome: string) {
|
||||
return contract.mechanism === 'cpmm-1'
|
||||
? getCpmmProbability(contract.pool, contract.p)
|
||||
: getDpmOutcomeProbability(contract.totalShares, outcome)
|
||||
}
|
||||
|
||||
export function getOutcomeProbabilityAfterBet(
|
||||
contract: Contract,
|
||||
outcome: string,
|
||||
bet: number
|
||||
) {
|
||||
return contract.mechanism === 'cpmm-1'
|
||||
? getCpmmOutcomeProbabilityAfterBet(contract, outcome, bet)
|
||||
: getDpmOutcomeProbabilityAfterBet(contract.totalShares, outcome, bet)
|
||||
}
|
||||
|
||||
export function calculateShares(
|
||||
contract: Contract,
|
||||
bet: number,
|
||||
betChoice: string
|
||||
) {
|
||||
return contract.mechanism === 'cpmm-1'
|
||||
? calculateCpmmSharesAfterFee(contract, bet, betChoice)
|
||||
: calculateDpmShares(contract.totalShares, bet, betChoice)
|
||||
}
|
||||
|
||||
export function calculateSaleAmount(
|
||||
contract: Contract,
|
||||
bet: Bet,
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) {
|
||||
return contract.mechanism === 'cpmm-1' &&
|
||||
(contract.outcomeType === 'BINARY' ||
|
||||
contract.outcomeType === 'PSEUDO_NUMERIC')
|
||||
? calculateCpmmSale(
|
||||
contract,
|
||||
Math.abs(bet.shares),
|
||||
bet.outcome as 'YES' | 'NO',
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
).saleValue
|
||||
: calculateDpmSaleAmount(contract, bet)
|
||||
}
|
||||
|
||||
export function calculatePayoutAfterCorrectBet(contract: Contract, bet: Bet) {
|
||||
return contract.mechanism === 'cpmm-1'
|
||||
? bet.shares
|
||||
: calculateDpmPayoutAfterCorrectBet(contract, bet)
|
||||
}
|
||||
|
||||
export function getProbabilityAfterSale(
|
||||
contract: Contract,
|
||||
outcome: string,
|
||||
shares: number,
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) {
|
||||
return contract.mechanism === 'cpmm-1'
|
||||
? getCpmmProbabilityAfterSale(
|
||||
contract,
|
||||
shares,
|
||||
outcome as 'YES' | 'NO',
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
)
|
||||
: getDpmProbabilityAfterSale(contract.totalShares, outcome, shares)
|
||||
}
|
||||
|
||||
export function calculatePayout(contract: Contract, bet: Bet, outcome: string) {
|
||||
return contract.mechanism === 'cpmm-1' &&
|
||||
(contract.outcomeType === 'BINARY' ||
|
||||
contract.outcomeType === 'PSEUDO_NUMERIC')
|
||||
? calculateFixedPayout(contract, bet, outcome)
|
||||
: calculateDpmPayout(contract, bet, outcome)
|
||||
}
|
||||
|
||||
export function resolvedPayout(contract: Contract, bet: Bet) {
|
||||
const outcome = contract.resolution
|
||||
if (!outcome) throw new Error('Contract not resolved')
|
||||
|
||||
return contract.mechanism === 'cpmm-1' &&
|
||||
(contract.outcomeType === 'BINARY' ||
|
||||
contract.outcomeType === 'PSEUDO_NUMERIC')
|
||||
? calculateFixedPayout(contract, bet, outcome)
|
||||
: calculateDpmPayout(contract, bet, outcome)
|
||||
}
|
||||
|
||||
function getCpmmInvested(yourBets: Bet[]) {
|
||||
const totalShares: { [outcome: string]: number } = {}
|
||||
const totalSpent: { [outcome: string]: number } = {}
|
||||
|
||||
const sortedBets = sortBy(yourBets, 'createdTime')
|
||||
for (const bet of sortedBets) {
|
||||
const { outcome, shares, amount } = bet
|
||||
if (floatingEqual(shares, 0)) continue
|
||||
|
||||
const spent = totalSpent[outcome] ?? 0
|
||||
const position = totalShares[outcome] ?? 0
|
||||
|
||||
if (amount > 0) {
|
||||
totalShares[outcome] = position + shares
|
||||
totalSpent[outcome] = spent + amount
|
||||
} else if (amount < 0) {
|
||||
const averagePrice = position === 0 ? 0 : spent / position
|
||||
totalShares[outcome] = position + shares
|
||||
totalSpent[outcome] = spent + averagePrice * shares
|
||||
}
|
||||
}
|
||||
|
||||
return sum([0, ...Object.values(totalSpent)])
|
||||
}
|
||||
|
||||
function getDpmInvested(yourBets: Bet[]) {
|
||||
const sortedBets = sortBy(yourBets, 'createdTime')
|
||||
|
||||
return sumBy(sortedBets, (bet) => {
|
||||
const { amount, sale } = bet
|
||||
|
||||
if (sale) {
|
||||
const originalBet = sortedBets.find((b) => b.id === sale.betId)
|
||||
if (originalBet) return -originalBet.amount
|
||||
return 0
|
||||
}
|
||||
|
||||
return amount
|
||||
})
|
||||
}
|
||||
|
||||
export type ContractBetMetrics = ReturnType<typeof getContractBetMetrics>
|
||||
|
||||
export function getContractBetMetrics(contract: Contract, yourBets: Bet[]) {
|
||||
const { resolution } = contract
|
||||
const isCpmm = contract.mechanism === 'cpmm-1'
|
||||
|
||||
let totalInvested = 0
|
||||
let payout = 0
|
||||
let loan = 0
|
||||
let saleValue = 0
|
||||
let redeemed = 0
|
||||
const totalShares: { [outcome: string]: number } = {}
|
||||
|
||||
for (const bet of yourBets) {
|
||||
const { isSold, sale, amount, loanAmount, isRedemption, shares, outcome } =
|
||||
bet
|
||||
totalShares[outcome] = (totalShares[outcome] ?? 0) + shares
|
||||
|
||||
if (isSold) {
|
||||
totalInvested += amount
|
||||
} else if (sale) {
|
||||
saleValue += sale.amount
|
||||
} else {
|
||||
if (isRedemption) {
|
||||
redeemed += -1 * amount
|
||||
} else if (amount > 0) {
|
||||
totalInvested += amount
|
||||
} else {
|
||||
saleValue -= amount
|
||||
}
|
||||
|
||||
loan += loanAmount ?? 0
|
||||
payout += resolution
|
||||
? calculatePayout(contract, bet, resolution)
|
||||
: calculatePayout(contract, bet, 'MKT')
|
||||
}
|
||||
}
|
||||
|
||||
const profit = payout + saleValue + redeemed - totalInvested
|
||||
const profitPercent = totalInvested === 0 ? 0 : (profit / totalInvested) * 100
|
||||
|
||||
const invested = isCpmm ? getCpmmInvested(yourBets) : getDpmInvested(yourBets)
|
||||
const hasShares = Object.values(totalShares).some(
|
||||
(shares) => !floatingEqual(shares, 0)
|
||||
)
|
||||
|
||||
return {
|
||||
invested,
|
||||
loan,
|
||||
payout,
|
||||
profit,
|
||||
profitPercent,
|
||||
totalShares,
|
||||
hasShares,
|
||||
}
|
||||
}
|
||||
|
||||
export function getContractBetNullMetrics() {
|
||||
return {
|
||||
invested: 0,
|
||||
loan: 0,
|
||||
payout: 0,
|
||||
profit: 0,
|
||||
profitPercent: 0,
|
||||
totalShares: {} as { [outcome: string]: number },
|
||||
hasShares: false,
|
||||
}
|
||||
}
|
||||
|
||||
export function getTopAnswer(
|
||||
contract: FreeResponseContract | MultipleChoiceContract
|
||||
) {
|
||||
const { answers } = contract
|
||||
const top = maxBy(
|
||||
answers?.map((answer) => ({
|
||||
answer,
|
||||
prob: getOutcomeProbability(contract, answer.id),
|
||||
})),
|
||||
({ prob }) => prob
|
||||
)
|
||||
return top?.answer
|
||||
}
|
||||
|
||||
export function getLargestPosition(contract: Contract, userBets: Bet[]) {
|
||||
let yesFloorShares = 0,
|
||||
yesShares = 0,
|
||||
noShares = 0,
|
||||
noFloorShares = 0
|
||||
|
||||
if (userBets.length === 0) {
|
||||
return null
|
||||
}
|
||||
if (contract.outcomeType === 'FREE_RESPONSE') {
|
||||
const answerCounts: { [outcome: string]: number } = {}
|
||||
for (const bet of userBets) {
|
||||
if (bet.outcome) {
|
||||
if (!answerCounts[bet.outcome]) {
|
||||
answerCounts[bet.outcome] = bet.amount
|
||||
} else {
|
||||
answerCounts[bet.outcome] += bet.amount
|
||||
}
|
||||
}
|
||||
}
|
||||
const majorityAnswer =
|
||||
maxBy(Object.keys(answerCounts), (outcome) => answerCounts[outcome]) ?? ''
|
||||
return {
|
||||
prob: undefined,
|
||||
shares: answerCounts[majorityAnswer] || 0,
|
||||
outcome: majorityAnswer,
|
||||
}
|
||||
}
|
||||
|
||||
const [yesBets, noBets] = partition(userBets, (bet) => bet.outcome === 'YES')
|
||||
yesShares = sumBy(yesBets, (bet) => bet.shares)
|
||||
noShares = sumBy(noBets, (bet) => bet.shares)
|
||||
yesFloorShares = Math.floor(yesShares)
|
||||
noFloorShares = Math.floor(noShares)
|
||||
|
||||
const shares = yesFloorShares || noFloorShares
|
||||
const outcome = yesFloorShares > noFloorShares ? 'YES' : 'NO'
|
||||
return { shares, outcome }
|
||||
}
|
43
common/categories.ts
Normal file
43
common/categories.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { difference } from 'lodash'
|
||||
|
||||
export const CATEGORIES_GROUP_SLUG_POSTFIX = '-default'
|
||||
|
||||
export const CATEGORIES = {
|
||||
politics: 'Politics',
|
||||
technology: 'Technology',
|
||||
science: 'Science',
|
||||
world: 'World',
|
||||
sports: 'Sports',
|
||||
economics: 'Economics',
|
||||
personal: 'Personal',
|
||||
culture: 'Culture',
|
||||
manifold: 'Manifold',
|
||||
covid: 'Covid',
|
||||
crypto: 'Crypto',
|
||||
gaming: 'Gaming',
|
||||
fun: 'Fun',
|
||||
}
|
||||
|
||||
export type category = keyof typeof CATEGORIES
|
||||
|
||||
export const TO_CATEGORY = Object.fromEntries(
|
||||
Object.entries(CATEGORIES).map(([k, v]) => [v, k])
|
||||
)
|
||||
|
||||
export const CATEGORY_LIST = Object.keys(CATEGORIES)
|
||||
|
||||
export const EXCLUDED_CATEGORIES: category[] = [
|
||||
'fun',
|
||||
'manifold',
|
||||
'personal',
|
||||
'covid',
|
||||
'gaming',
|
||||
'crypto',
|
||||
]
|
||||
|
||||
export const DEFAULT_CATEGORIES = difference(CATEGORY_LIST, EXCLUDED_CATEGORIES)
|
||||
|
||||
export const DEFAULT_CATEGORY_GROUPS = DEFAULT_CATEGORIES.map((c) => ({
|
||||
slug: c.toLowerCase() + CATEGORIES_GROUP_SLUG_POSTFIX,
|
||||
name: CATEGORIES[c as category],
|
||||
}))
|
65
common/challenge.ts
Normal file
65
common/challenge.ts
Normal file
|
@ -0,0 +1,65 @@
|
|||
import { IS_PRIVATE_MANIFOLD } from './envs/constants'
|
||||
|
||||
export type Challenge = {
|
||||
// The link to send: https://manifold.markets/challenges/username/market-slug/{slug}
|
||||
// Also functions as the unique id for the link.
|
||||
slug: string
|
||||
|
||||
// The user that created the challenge.
|
||||
creatorId: string
|
||||
creatorUsername: string
|
||||
creatorName: string
|
||||
creatorAvatarUrl?: string
|
||||
|
||||
// Displayed to people claiming the challenge
|
||||
message: string
|
||||
|
||||
// How much to put up
|
||||
creatorAmount: number
|
||||
|
||||
// YES or NO for now
|
||||
creatorOutcome: string
|
||||
|
||||
// Different than the creator
|
||||
acceptorOutcome: string
|
||||
acceptorAmount: number
|
||||
|
||||
// The probability the challenger thinks
|
||||
creatorOutcomeProb: number
|
||||
|
||||
contractId: string
|
||||
contractSlug: string
|
||||
contractQuestion: string
|
||||
contractCreatorUsername: string
|
||||
|
||||
createdTime: number
|
||||
// If null, the link is valid forever
|
||||
expiresTime: number | null
|
||||
|
||||
// How many times the challenge can be used
|
||||
maxUses: number
|
||||
|
||||
// Used for simpler caching
|
||||
acceptedByUserIds: string[]
|
||||
// Successful redemptions of the link
|
||||
acceptances: Acceptance[]
|
||||
|
||||
// TODO: will have to fill this on resolve contract
|
||||
isResolved: boolean
|
||||
resolutionOutcome?: string
|
||||
}
|
||||
|
||||
export type Acceptance = {
|
||||
// User that accepted the challenge
|
||||
userId: string
|
||||
userUsername: string
|
||||
userName: string
|
||||
userAvatarUrl: string
|
||||
|
||||
// The ID of the successful bet that tracks the money moved
|
||||
betId: string
|
||||
|
||||
createdTime: number
|
||||
}
|
||||
|
||||
export const CHALLENGES_ENABLED = !IS_PRIVATE_MANIFOLD
|
608
common/charity.ts
Normal file
608
common/charity.ts
Normal file
|
@ -0,0 +1,608 @@
|
|||
export interface Charity {
|
||||
id: string
|
||||
slug: string
|
||||
name: string
|
||||
website: string
|
||||
ein?: string
|
||||
photo?: string
|
||||
preview: string
|
||||
description: string
|
||||
tags?: CharityTag[]
|
||||
}
|
||||
|
||||
type CharityTag = 'Featured' // | 'Health' | 'Poverty' | 'X-Risk' | 'Animal Welfare' | 'Policy'
|
||||
|
||||
// Warning: 'name' is currently used as the slug and the txn toId for the charity.
|
||||
export const charities: Charity[] = [
|
||||
{
|
||||
name: '1Day Sooner',
|
||||
website: 'https://www.1daysooner.org/',
|
||||
preview:
|
||||
'Accelerating the development of each vaccine by even a couple of days via COVID-19 human challenge trials could save thousands of lives.',
|
||||
photo: 'https://i.imgur.com/bUDdzUE.png',
|
||||
description: `1Day Sooner is a non-profit that advocates on behalf of COVID-19 challenge trial volunteers.
|
||||
|
||||
After a vaccine candidate is created in a lab, it is developed through a combination of pre-clinical evaluation and three phases of clinical trials that test its safety and efficacy. In traditional Phase III trials, participants receive the vaccine candidate or a placebo/active comparator, and efficacy is judged by comparing the prevalence of infection in the vaccine group and the placebo/comparator group, to test the hypothesis that significantly fewer participants in the vaccine group get infected. In these traditional trials, after receiving the treatment, participants return to their homes and their normal daily lives so as to test the treatment under real world conditions. Since only a small proportion of these participants may encounter the disease, it may take a large number of participants and a good deal of time for these trials to reveal differences between the vaccine and placebo groups.
|
||||
|
||||
In a human challenge trial (HCT), willing participants would receive the vaccine candidate or placebo and, after some time for the vaccine to take effect, be deliberately exposed to live coronavirus. Since exposure to the virus is guaranteed in HCTs, it may be possible to judge a vaccine candidate’s efficacy more quickly and with far fewer participants than a standard Phase III trial. While HCT efficacy results do not traditionally provide sufficient basis for licensure on their own, they could allow us to (1) more quickly weed out disappointing vaccine candidates or (2) promote the development of promising candidates in conjunction with traditional Phase III studies.
|
||||
|
||||
In addition, by gathering detailed data on the process of infection and vaccine protection in a clinical setting, researchers could learn information that proves extremely useful for broader vaccine and therapeutic development efforts. Altogether, there are scenarios in which the speed of HCTs and the richness of the data they provide accelerate the development of an effective and broadly accessible COVID-19 vaccine, with thousands of lives spared (depending on the pandemic’s long-term trajectory).`,
|
||||
tags: ['Featured'] as CharityTag[],
|
||||
},
|
||||
{
|
||||
name: 'QURI',
|
||||
website: 'https://quantifieduncertainty.org/',
|
||||
preview:
|
||||
'The Quantified Uncertainty Research Institute advances forecasting and epistemics to improve the long-term future of humanity.',
|
||||
photo: 'https://i.imgur.com/ZsSXPjH.png',
|
||||
description: `QURI researches systematic practices to specify and estimate the most important parameters for the most important or scalable decisions. Research areas include forecasting, epistemics, evaluations, ontology, and estimation.
|
||||
|
||||
We emphasize technological solutions that can heavily scale in the next 5 to 30 years.
|
||||
|
||||
We believe that humanity’s success in the next few hundred years will lie intensely on its ability to coordinate and make good decisions. If important governmental and philanthropic bodies become significantly more effective, this will make society far more resilient to many kinds of challenges ahead.`,
|
||||
tags: ['Featured'] as CharityTag[],
|
||||
},
|
||||
{
|
||||
name: 'Long-Term Future Fund',
|
||||
website: 'https://funds.effectivealtruism.org/funds/far-future',
|
||||
photo: 'https://i.imgur.com/C2qka9g.png',
|
||||
preview:
|
||||
'The Long-Term Future Fund aims to improve the long-term trajectory of civilization by making grants that address global catastrophic risks.',
|
||||
description: `The Long-Term Future Fund aims to positively influence the long-term trajectory of civilization by making grants that address global catastrophic risks, especially potential risks from advanced artificial intelligence and pandemics. In addition, we seek to promote, implement, and advocate for longtermist ideas, and to otherwise increase the likelihood that future generations will flourish.
|
||||
|
||||
The Fund has a broad remit to make grants that promote, implement and advocate for longtermist ideas. Many of our grants aim to address potential risks from advanced artificial intelligence and to build infrastructure and advocate for longtermist projects. However, we welcome applications related to long-term institutional reform or other global catastrophic risks (e.g., pandemics or nuclear conflict).
|
||||
|
||||
We intend to support:
|
||||
- Projects that directly contribute to reducing existential risks through technical research, policy analysis, advocacy, and/or demonstration projects
|
||||
- Training for researchers or practitioners who work to mitigate existential risks, or help with relevant recruitment efforts, or infrastructure for people working on longtermist projects
|
||||
- Promoting long-term thinking`,
|
||||
tags: ['Featured'] as CharityTag[],
|
||||
},
|
||||
{
|
||||
name: 'New Science',
|
||||
website: 'https://newscience.org/',
|
||||
photo: 'https://i.imgur.com/C7PoR4q.png',
|
||||
preview:
|
||||
'Facilitating scientific breakthroughs by empowering the next generation of scientists and building the 21st century institutions of basic science.',
|
||||
description: `As its first major project, in the summer of 2022, New Science will run an in-person research fellowship in Boston for young life scientists, during which they will independently explore an ambitious high-risk scientific idea they couldn’t work on otherwise and start building the foundations for a bigger research project, while having much more freedom than they could expect in their normal research environment but also much more support from us. This is inspired by Cold Spring Harbor Laboratory, which started as a place where leading molecular biologists came for the summer to hang out and work on random projects together, and which eventually housed 8 Nobel Prize winners.
|
||||
|
||||
As its second major project, in the fall of 2022, New Science will run an in-person 12-month-long fellowship for young scientists starting to directly attack the biggest structural issues of the established institutions of science. We will double down on things that worked well during the summer fellowship, while extending the fellowship to one year, thus allowing researchers to make much more progress and will strive to provide them as much scientific leverage as possible.
|
||||
|
||||
In several years, New Science will start funding entire labs outside of academia and then will be creating an entire network of scientific organizations, while supporting the broader scientific ecosystem that will constitute the 21st century institutions of basic science.`,
|
||||
tags: ['Featured'] as CharityTag[],
|
||||
},
|
||||
{
|
||||
name: 'Global Health and Development Fund',
|
||||
website: 'https://funds.effectivealtruism.org/funds/global-development',
|
||||
photo: 'https://i.imgur.com/C2qka9g.png',
|
||||
preview:
|
||||
"The Global Health and Development Fund aims to improve people's lives, typically in the poorest regions of the world where the need for healthcare and economic empowerment is greatest.",
|
||||
description: `The Global Health and Development Fund recommends grants with the aim of improving people's lives, typically in the poorest regions of the world where the need for healthcare and economic empowerment is greatest. This will be achieved primarily by supporting projects that:
|
||||
|
||||
- Directly provide healthcare, or preventive measures that will improve health, well-being, or life expectancy
|
||||
- Directly provide services that raise incomes or otherwise improve economic conditions
|
||||
- Provide assistance to governments in the design and implementation of effective policies
|
||||
|
||||
In addition, the Global Health and Development Fund has a broad remit, and may fund other activities whose ultimate purpose is to serve people living in the poorest regions of the world, for example by raising additional funds (e.g. One for the World) or by exploring novel financing arrangements (e.g. Instiglio).
|
||||
|
||||
The Fund manager recommends grants to GiveWell top charities as a baseline, but will recommend higher-risk grants they believe to be more effective (in expectation) than GiveWell top charities. As such, the fund makes grants with a variety of different risk profiles.`,
|
||||
},
|
||||
{
|
||||
name: 'Animal Welfare Fund',
|
||||
website: 'https://funds.effectivealtruism.org/funds/animal-welfare',
|
||||
photo: 'https://i.imgur.com/C2qka9g.png',
|
||||
preview:
|
||||
'The Animal Welfare Fund aims to effectively improve the well-being of nonhuman animals.',
|
||||
description: `The Animal Welfare Fund aims to effectively improve the well-being of nonhuman animals, by making grants that focus on one or more of the following:
|
||||
|
||||
- Relatively neglected geographic regions or groups of animals
|
||||
- Promising research into animal advocacy or animal well-being
|
||||
- Activities that could make it easier to help animals in the future
|
||||
- Otherwise best-in-class opportunities
|
||||
|
||||
The Fund focuses on projects that primarily address farmed animals, as well as projects that could affect other large populations of nonhuman animals. Some examples of projects that the Fund could support:
|
||||
|
||||
- Supporting farmed animal advocacy in Asia
|
||||
- Researching ways to improve the welfare of farmed fish
|
||||
- Promoting alternative proteins in order to reduce demand for animal products
|
||||
- Advocating against the use of some cruel practice within the industrial agriculture system
|
||||
- Growing the field of welfare biology in order to improve our understanding of different ways to address wild animal suffering`,
|
||||
},
|
||||
{
|
||||
name: 'Effective Altruism Infrastructure Fund',
|
||||
website: 'https://funds.effectivealtruism.org/funds/ea-community',
|
||||
photo: 'https://i.imgur.com/C2qka9g.png',
|
||||
preview:
|
||||
'The Effective Altruism Infrastructure Fund aims to increase the impact of projects that use the principles of effective altruism.',
|
||||
description: `The Effective Altruism Infrastructure Fund (EA Infrastructure Fund) recommends grants that aim to improve the work of projects using principles of effective altruism, by increasing their access to talent, capital, and knowledge.
|
||||
|
||||
The EA Infrastructure Fund has historically attempted to make strategic grants to incubate and grow projects that attempt to use reason and evidence to do as much good as possible. These include meta-charities that fundraise for highly effective charities doing direct work on important problems, research organizations that improve our understanding of how to do good more effectively, and projects that promote principles of effective altruism in contexts like academia.`,
|
||||
},
|
||||
{
|
||||
name: 'Nonlinear',
|
||||
website: 'https://www.nonlinear.org/',
|
||||
photo: 'https://i.imgur.com/Muifc1l.png',
|
||||
preview:
|
||||
'Incubate longtermist nonprofits by connecting founders with ideas, funding, and mentorship.',
|
||||
description: `Problem: There are tens of thousands of people working full time to make AI powerful, but around one hundred working to make AI safe. This needs to change.
|
||||
|
||||
Longtermism is held back by two bottlenecks:
|
||||
1. Lots of funding, but few charities to deploy it.
|
||||
2. Lots of talent, but few charities creating jobs.
|
||||
|
||||
Solution: Longtermism needs more charities to deploy funding and create jobs. Our goal is to 10x the number of talented people working on longtermism by launching dozens of high impact charities.
|
||||
|
||||
This helps solve the bottlenecks because entrepreneurs “unlock” latent EA talent - if one person starts an organization that employs 100 people who weren’t previously working on AI safety, that doubles the number of people working on the problem.
|
||||
|
||||
Our process:
|
||||
1. Research the highest leverage ideas
|
||||
2. Find the right founders
|
||||
3. Connect them with mentors and funding
|
||||
|
||||
We will be announcing more details about our incubation program soon.
|
||||
|
||||
A few of the ideas we’ve incubated so far:
|
||||
- The Nonlinear Library: Listen to top EA content on your podcast player. We use text-to-speech software to create an automatically updating repository of audio content from the EA Forum, Alignment Forum, and LessWrong. You can find it on all major podcast players here.
|
||||
- EA Hiring Agency: Helping EA orgs scalably hire talent.
|
||||
- EA Houses: EA's Airbnb - Connecting EAs who have extra space with EAs who need space here.`,
|
||||
tags: ['Featured'] as CharityTag[],
|
||||
},
|
||||
{
|
||||
name: 'GiveWell Maximum Impact Fund',
|
||||
website: 'https://www.givewell.org/maximum-impact-fund',
|
||||
photo: 'https://i.imgur.com/xikuDMZ.png',
|
||||
preview:
|
||||
'We search for the charities that save or improve lives the most per dollar.',
|
||||
description: `
|
||||
GiveWell is a nonprofit dedicated to finding outstanding giving opportunities and publishing the full details of our analysis to help donors decide where to give.
|
||||
|
||||
We don't focus solely on financials, such as assessing administrative or fundraising costs. Instead, we conduct in-depth research to determine how much good a given program accomplishes (in terms of lives saved, lives improved, etc.) per dollar spent. Rather than rating as many charities as possible, we focus on the few charities that stand out most (by our criteria) in order to find and confidently recommend high-impact giving opportunities (our list of top charities).
|
||||
|
||||
Our top recommendation to GiveWell donors seeking to do the most good possible is to donate to the Maximum Impact Fund. Donations to the Maximum Impact Fund are granted each quarter. We use our latest research to grant the funds to the recommended charity (or charities) where we believe they’ll do the most good.
|
||||
|
||||
We grant funds from the Maximum Impact Fund to the recipient charity (or charities) at the end of each fiscal quarter. Our research team decides which charities have the highest priority funding needs at that time. This decision takes into consideration factors such as:
|
||||
|
||||
- Which funding gaps we expect to be filled and unfilled
|
||||
- Each charity’s plans for additional funding
|
||||
- The cost-effectiveness of each funding gap`,
|
||||
},
|
||||
{
|
||||
name: "Founder's Pledge Climate Change Fund",
|
||||
website: 'https://founderspledge.com/funds/climate-change-fund',
|
||||
photo: 'https://i.imgur.com/9turaJW.png',
|
||||
preview:
|
||||
'The Climate Change Fund aims to sustainably reach net-zero emissions globally, while still allowing growth to free millions from energy poverty.',
|
||||
description: `The Climate Change Fund aims to sustainably reach net-zero emissions globally.
|
||||
|
||||
Current levels of emissions are contributing to millions of deaths annually from air pollution and causing irrevocable damage to our planet. In addition, millions worldwide do not have access to modern energy technology, severely hampering development goals.
|
||||
|
||||
This Fund is committed to finding and funding sustainable solutions to the emissions crisis that still allow growth, freeing millions from the prison of energy poverty.
|
||||
|
||||
The Fund is a philanthropic co-funding vehicle that does not provide investment returns.`,
|
||||
},
|
||||
{
|
||||
name: "Founder's Pledge Patient Philanthropy Fund",
|
||||
website: 'https://founderspledge.com/funds/patient-philanthropy-fund',
|
||||
photo: 'https://i.imgur.com/LLR6CI6.png',
|
||||
preview:
|
||||
'The Patient Philanthropy Project aims to safeguard and benefit the long-term future of humanity',
|
||||
description: `The Patient Philanthropy Project focuses on how we can collectively grow our resources to support the long-term flourishing of humanity. It addresses a crucial gap: as a society, we spend much too little on safeguarding and benefiting future generations. In fact, we spend more money on ice cream each year than we do on preventing our own extinction. However, people in the future - who do not have a voice in their future survival or environment - matter. Lots of them may yet come into existence and we have the ability to positively affect their lives now, if only by making sure we avoid major catastrophes that could destroy our common future.
|
||||
|
||||
Housed within the Project is the Patient Philanthropy Fund, a philanthropic co-funding vehicle which invests to give and ensures capital is at the ready when extraordinary opportunities to safeguard and improve the long-term future arise.
|
||||
|
||||
The Fund’s patient approach means that we aim to identify the point in time when the highest-impact opportunities are available, which may be years, decades, or even centuries ahead.`,
|
||||
},
|
||||
{
|
||||
name: 'ARC',
|
||||
website: 'https://alignment.org/',
|
||||
photo: 'https://i.imgur.com/Hwg8OMP.png',
|
||||
preview: 'Align future machine learning systems with human interests.',
|
||||
description: `ARC is a non-profit research organization whose mission is to align future machine learning systems with human interests. Its current work focuses on developing an alignment strategy that could be adopted in industry today while scaling gracefully to future ML systems. Right now Paul Christiano and Mark Xu are researchers and Kyle Scott handles operations.
|
||||
|
||||
What is “alignment”? ML systems can exhibit goal-directed behavior, but it is difficult to understand or control what they are “trying” to do. Powerful models could cause harm if they were trying to manipulate and deceive humans. The goal of intent alignment is to instead train these models to be helpful and honest.
|
||||
|
||||
Motivation: We believe that modern ML techniques would lead to severe misalignment if scaled up to large enough computers and datasets. Practitioners may be able to adapt before these failures have catastrophic consequences, but we could reduce the risk by adopting scalable methods further in advance.
|
||||
|
||||
What we’re working on: The best way to understand our research priorities and methodology is probably to read our report on Eliciting Latent Knowledge. At a high level, we’re trying to figure out how to train ML systems to answer questions by straightforwardly “translating” their beliefs into natural language rather than by reasoning about what a human wants to hear.
|
||||
|
||||
Methodology: We’re unsatisfied with an algorithm if we can see any plausible story about how it eventually breaks down, which means that we can rule out most algorithms on paper without ever implementing them. The cost of this approach is that it may completely miss strategies that exploit important structure in realistic ML models; the benefit is that you can consider lots of ideas quickly. (More)
|
||||
|
||||
Future plans: We expect to focus on similar theoretical problems in alignment until we either become more pessimistic about tractability or ARC grows enough to branch out into other areas. Over the long term we are likely to work on a combination of theoretical and empirical alignment research, collaborations with industry labs, alignment forecasting, and ML deployment policy.`,
|
||||
},
|
||||
{
|
||||
name: 'Give Directly',
|
||||
website: 'https://www.givedirectly.org/',
|
||||
ein: '27-1661997',
|
||||
photo: 'https://i.imgur.com/lrdxSyd.jpg',
|
||||
preview: 'Send money directly to people living in poverty.',
|
||||
description:
|
||||
'GiveDirectly is a nonprofit that lets donors like you send money directly to the world’s poorest households. We believe people living in poverty deserve the dignity to choose for themselves how best to improve their lives — cash enables that choice. Since 2009, we’ve delivered $500M+ in cash directly into the hands of over 1 million families living in poverty. We currently have operations in Kenya, Rwanda, Liberia, Malawi, Morocco, Mozambique, DRC, Uganda, and the United States.',
|
||||
},
|
||||
{
|
||||
name: 'Hellen Keller International',
|
||||
website: 'https://www.hki.org/',
|
||||
ein: '13-5562162',
|
||||
photo: 'https://i.imgur.com/Dl97Abk.jpg',
|
||||
preview:
|
||||
'We envision a world where no one is deprived of the opportunity to live a healthy life – and reach their true potential.',
|
||||
description:
|
||||
'Right now, 36 million people worldwide — most of them in developing countries — are blind.\n 90 percent of them didn’t have to lose their sight. Helen Keller International is dedicated to combating the causes and consequences of vision loss and making clear vision a reality for those most vulnerable to disease and who lack access to quality eye care.\n Last year alone, we helped provide many tens of millions of people with treatment to prevent diseases of poverty including blinding trachoma and river blindness.\n Surgeons trained by our staff also performed tens of thousands of cataract surgeries in the developing world. And in the United States, we screened the vision of nearly 66,000 students living in some of our country’s poorest neighborhoods and provided free eyeglasses to just over 16,000 of them. ',
|
||||
},
|
||||
{
|
||||
name: 'Against Malaria Foundation',
|
||||
website: 'https://www.againstmalaria.com/',
|
||||
ein: '20-3069841',
|
||||
photo: 'https://i.imgur.com/F3JoZi9.png',
|
||||
preview: 'We help protect people from malaria.',
|
||||
description:
|
||||
'AMF (againstmalaria.com) provides funding for long-lasting insecticide-treated net (LLIN) distributions (for protection against malaria) in developing countries. There is strong evidence that distributing LLINs reduces child mortality and malaria cases. AMF conducts post-distribution surveys of completed distributions to determine whether LLINs have reached their intended destinations and how long they remain in good condition.',
|
||||
},
|
||||
{
|
||||
name: 'Rethink Charity',
|
||||
website: 'https://rethink.charity/',
|
||||
photo: 'https://i.imgur.com/Go7N7As.png',
|
||||
preview:
|
||||
'Providing vital support to high-impact charities and charitable projects.',
|
||||
description: `At Rethink Charity, we’re excited about improving the world by providing vital support to high-impact charities and charitable projects. We equip them with tools to boost their impact, through our projects that empower their donors with tax-efficient giving options and strategically coordinated matching opportunities.
|
||||
What we do:
|
||||
|
||||
- Rethink Charity Forward is a cause-neutral donation routing fund for high-impact charities around the world. Canadians have used RC Forward to donate $10 million to high-impact charities since the project was launched in late 2017.
|
||||
|
||||
- EA Giving Tuesday supports both donors and highly effective nonprofits participating in Facebook’s annual Giving Tuesday match. In addition to setting up systems and processes, the team provides analysis-based recommendations, detailed instructions, and responsive support. The team’s goal is to make it as easy as possible for donors to direct matching dollars to highly effective nonprofits.`,
|
||||
},
|
||||
{
|
||||
name: 'Malaria Consortium',
|
||||
website: 'https://www.malariaconsortium.org/',
|
||||
ein: '98-0627052',
|
||||
photo: 'https://i.imgur.com/LGwy9d8.png ',
|
||||
preview:
|
||||
'We specialise in the prevention, control and treatment of malaria and other communicable diseases.',
|
||||
description:
|
||||
'We are dedicated to ensuring our work is supported by strong evidence and remains grounded in the lessons we learn through implementation. We explore beyond current practice, to try out innovative ways – through research, implementation and policy development – to achieve effective and sustainable disease management and control.',
|
||||
},
|
||||
{
|
||||
name: 'The Center for the Study of Partisanship and Ideology',
|
||||
website: 'https://cspicenter.org/',
|
||||
photo: 'https://i.imgur.com/O88tkOW.png',
|
||||
preview:
|
||||
'Support and fund research on how ideology and government policy contribute to scientific, technological, and social progress.',
|
||||
description: `Over the last few decades, scientific and technological progress have stagnated. Scientists conduct more research than ever before, but groundbreaking innovation is scarce. At the same time, identity politics and political polarization have reached new extremes, and social trends such as family stability and crime are worse than in previous decades and in some cases moving in the wrong direction. What explains these trends, and how can we reverse them?
|
||||
|
||||
Much of the blame lies with the institutions we rely on for administration, innovation, and leadership. Instead of forward-looking governments, we have short-sighted politicians and bloated bureaucracies. Instead of real experts with proven track records, we have so-called ‘experts’ who appeal to the authority of their credentials. Instead of political leaders willing to face facts and make tough tradeoffs, we have politicians who appeal to ignorance and defer responsibility.
|
||||
|
||||
To fix our institutions, we need to rethink them from the ground up. That is why CSPI supports and funds research into the administrative systems, organizational structures, and political ideologies of modern governance. Only by understanding what makes these systems so often dysfunctional can we change them for the better.
|
||||
|
||||
CSPI believes that governments should be accountable to the populace as a whole, not special interest groups. We think experts should have greater say in public policy, but that there should be different standards for what qualifies as “expertise.” We want to end scientific and technological stagnation and usher in a new era of growth and innovation.
|
||||
|
||||
We are interested in funding and supporting research that can speak to these issues in the social sciences through grants and fellowships. CSPI particularly seek outs work that is unlikely to receive support elsewhere. See our home page for more about the kinds of research we are particularly interested in funding.`,
|
||||
},
|
||||
{
|
||||
name: 'Faunalytics',
|
||||
website: 'https://faunalytics.org/',
|
||||
ein: '01-0686889',
|
||||
photo: 'https://i.imgur.com/3JXhuXl.jpg',
|
||||
preview:
|
||||
'Faunalytics conducts research and shares knowledge to help advocates help animals effectively.',
|
||||
description:
|
||||
"Faunalytics' mission is to empower animal advocates with access to research, analysis, strategies, and messages that maximize their effectiveness to reduce animal suffering.\n Animals need you, and you need data. We conduct essential research, maintain an online research library, and directly support advocates and organizations in their work to save lives. The range of data we offer helps our movement understand how people think about and respond to advocacy, providing advocates with the best strategies to inspire change for animals. ",
|
||||
},
|
||||
{
|
||||
name: 'The Humane League',
|
||||
website: 'https://thehumaneleague.org/',
|
||||
ein: '04-3817491',
|
||||
photo: 'https://i.imgur.com/za9Rwon.jpg',
|
||||
preview:
|
||||
'We exist to end the abuse of animals raised for food by influencing the policies of the world’s biggest companies, demanding legislation, and empowering others to take action and leave animals off their plates',
|
||||
description:
|
||||
'The Humane League (THL) currently operates in the U.S., Mexico, the U.K., and Japan, where they work to improve animal welfare standards through grassroots campaigns, movement building, veg*n advocacy, research, and advocacy training, as well as through corporate, media, and community outreach. They work to build the animal advocacy movement internationally through the Open Wing Alliance (OWA), a coalition founded by THL whose mission is to end the use of battery cages globally.',
|
||||
},
|
||||
{
|
||||
name: 'Wild Animal Initiative',
|
||||
website: 'https://www.wildanimalinitiative.org/',
|
||||
ein: '82-2281466',
|
||||
tags: ['Featured'] as CharityTag[],
|
||||
photo: 'https://i.imgur.com/bOVUnDm.png',
|
||||
preview:
|
||||
'Our mission is to understand and improve the lives of wild animals.',
|
||||
description: `Although the natural world is a source of great beauty and happiness, vast numbers of animals routinely face serious challenges such as disease, hunger, or natural disasters. There is no “one-size-fits-all” solution to these threats. However, even as we recognize that improving the welfare of free-ranging wild animals is difficult, we believe that humans have a responsibility to help whenever we can.
|
||||
|
||||
Our staff explores how humans can beneficially coexist with animals through the lens of wild animal welfare.
|
||||
|
||||
We respect wild animals as individuals with their own needs and preferences, rather than seeing them as mere parts of ecosystems. But this approach demands a richer understanding of wild animals’ lives.
|
||||
|
||||
We want to take a proactive approach to managing the welfare benefits, threats, and uncertainties that are inherent to complex natural and urban environments. Yet, to take action safely, we must conduct research to understand the impacts of our actions. The transdisciplinary perspective of wild animal welfare draws upon ethics, ecology, and animal welfare science to gather the knowledge we need, facilitating evidence-based improvements to wild animals’ quality of life.
|
||||
|
||||
Without sufficient public interest or research activity, solutions to the problems wild animals face will go undiscovered.
|
||||
|
||||
Wild Animal Initiative currently focuses on helping scientists, grantors, and decision-makers investigate important and understudied questions about wild animal welfare. Our work catalyzes research and applied projects that will open the door to a clearer picture of wild animals’ needs and how to enhance their well-being. Ultimately, we envision a world in which people actively choose to help wild animals — and have the knowledge they need to do so responsibly.`,
|
||||
},
|
||||
{
|
||||
name: 'FYXX Foundation',
|
||||
website: 'https://www.fyxxfoundation.org/',
|
||||
photo: 'https://i.imgur.com/ROmWO7m.png',
|
||||
preview:
|
||||
'FYXX Foundation: wildlife population management, without killing.',
|
||||
description: `The future of our planet depends on the innovations of today, and the health of our wildlife are the first indication of our successful stewardship, which we believe can be improved by safe population management utilizing fertility control instead of poison and culling.`,
|
||||
},
|
||||
{
|
||||
name: 'New Incentives',
|
||||
website: 'https://www.newincentives.org/',
|
||||
ein: '45-2368993',
|
||||
photo: 'https://i.imgur.com/bYl4tk3.png',
|
||||
preview: 'Cash incentives to boost vaccination rates and save lives.',
|
||||
description:
|
||||
'New Incentives (newincentives.org) runs a conditional cash transfer (CCT) program in North West Nigeria which seeks to increase uptake of routine immunizations through cash transfers, raising public awareness of the benefits of vaccination and reducing the frequency of vaccine stockouts.',
|
||||
},
|
||||
{
|
||||
name: 'SCI foundation',
|
||||
website: 'https://schistosomiasiscontrolinitiative.org/',
|
||||
ein: '',
|
||||
photo: 'https://i.imgur.com/sWD8zM5.png',
|
||||
preview:
|
||||
'SCI works with governments in sub-Saharan Africa to create or scale up programs that treat schistosomiasis and soil-transmitted helminthiasis ("deworming").',
|
||||
description:
|
||||
'We’re a non-profit initiative supporting governments in sub-Saharan African countries. We support them to develop sustainable, cost-effective programmes against parasitic worm infections such as schistosomiasis and intestinal worms. Since our foundation in 2002, we’ve contributed to the delivery of over 200 million treatments against these diseases. The programmes are highly effective; parasitic worm infections can be reduced by up to 60% after just one round of treatment.',
|
||||
},
|
||||
{
|
||||
name: 'Wikimedia Foundation',
|
||||
website: 'https://wikimediafoundation.org/',
|
||||
ein: '20-0049703',
|
||||
photo: 'https://i.imgur.com/klEzUbR.png',
|
||||
preview: 'We help everyone share in the sum of all knowledge.',
|
||||
description:
|
||||
'We are the people who keep knowledge free. There is an amazing community of people around the world that makes great projects like Wikipedia. We help them do that work. We take care of the technical infrastructure, the legal challenges, and the growing pains.',
|
||||
},
|
||||
{
|
||||
name: 'Rainforest Trust',
|
||||
website: 'https://www.rainforesttrust.org/',
|
||||
ein: '13-3500609',
|
||||
photo: 'https://i.imgur.com/6MzS530.png',
|
||||
preview:
|
||||
'Rainforest Trust saves endangered wildlife and protects our planet by creating rainforest reserves through partnerships, community engagement and donor support.',
|
||||
description:
|
||||
'Our unique, cost-effective conservation model for protecting endangered species has been implemented successfully for over 30 years. Thanks to the generosity of our donors, the expertise of our partners and the participation of local communities across the tropics, our reserves are exemplary models of international conservation.',
|
||||
},
|
||||
{
|
||||
name: 'The Nature Conservancy',
|
||||
website: 'https://www.nature.org/en-us/',
|
||||
ein: '53-0242652',
|
||||
photo: 'https://i.imgur.com/vjxkoGo.jpg',
|
||||
preview: 'A Future Where People and Nature Thrive',
|
||||
description:
|
||||
'The Nature Conservancy is a global environmental nonprofit working to create a world where people and nature can thrive. Founded in the U.S. through grassroots action in 1951, The Nature Conservancy has grown to become one of the most effective and wide-reaching environmental organizations in the world. Thanks to more than a million members and the dedicated efforts of our diverse staff and over 400 scientists, we impact conservation in 76 countries and territories: 37 by direct conservation impact and 39 through partners.',
|
||||
},
|
||||
{
|
||||
name: 'Doctors Without Borders',
|
||||
website: 'https://www.doctorswithoutborders.org/',
|
||||
ein: '13-3433452',
|
||||
photo: 'https://i.imgur.com/xqhH9FE.png',
|
||||
preview:
|
||||
'We provide independent, impartial medical humanitarian assistance to the people who need it most.',
|
||||
description:
|
||||
'Doctors Without Borders/Médecins Sans Frontières (MSF) cares for people affected by conflict, disease outbreaks, natural and human-made disasters, and exclusion from health care in more than 70 countries.',
|
||||
},
|
||||
{
|
||||
name: 'World Wildlife Fund',
|
||||
website: 'https://www.worldwildlife.org/',
|
||||
ein: '52-1693387',
|
||||
photo: 'https://i.imgur.com/hDADuqW.png',
|
||||
preview:
|
||||
'WWF works to sustain the natural world for the benefit of people and wildlife, collaborating with partners from local to global levels in nearly 100 countries.',
|
||||
description:
|
||||
'As the world’s leading conservation organization, WWF works in nearly 100 countries to tackle the most pressing issues at the intersection of nature, people, and climate. We collaborate with local communities to conserve the natural resources we all depend on and build a future in which people and nature thrive. Together with partners at all levels, we transform markets and policies toward sustainability, tackle the threats driving the climate crisis, and protect and restore wildlife and their habitats.',
|
||||
},
|
||||
{
|
||||
name: 'UNICEF USA',
|
||||
website: 'https://www.unicefusa.org/',
|
||||
photo: 'https://i.imgur.com/9cxuvZi.png',
|
||||
ein: '13-1760110',
|
||||
preview:
|
||||
"UNICEF USA helps save and protect the world's most vulnerable children.",
|
||||
description:
|
||||
'Over eight decades, the United Nations Children’s Fund (UNICEF) has built an unprecedented global support system for the world’s children. UNICEF relentlessly works day in and day out to deliver the essentials that give every child an equitable chance in life: health care and immunizations, safe water and sanitation, nutrition, education, emergency relief and more. UNICEF USA advances the global mission of UNICEF by rallying the American public to support the world’s most vulnerable children. Together, we have helped save more children’s lives than any other humanitarian organization.',
|
||||
},
|
||||
{
|
||||
name: 'Vitamin Angels',
|
||||
website: 'https://www.vitaminangels.org/',
|
||||
ein: '77-0485881',
|
||||
photo: 'https://i.imgur.com/Mf35IOu.jpg',
|
||||
preview:
|
||||
'By improving access to vital nutrition, everyone gets an equal chance to grow, thrive, and prosper.',
|
||||
description:
|
||||
'Our team of program experts collaborates with thousands of local organizations and national governments around the world, focusing efforts on reaching communities who are underserved. Vitamin Angels’ program partners are a local presence in these communities. As trusted organizations already hard at work, they connect millions of pregnant women and young children with our evidence-based nutrition interventions in addition to the health services they already provide.',
|
||||
},
|
||||
{
|
||||
name: 'Free Software Foundation',
|
||||
website: 'https://www.fsf.org/',
|
||||
ein: '04-2888848',
|
||||
photo: 'https://i.imgur.com/z87sFDE.png',
|
||||
preview:
|
||||
'The Free Software Foundation (FSF) is a nonprofit with a worldwide mission to promote computer user freedom.',
|
||||
description:
|
||||
'As our society grows more dependent on computers, the software we run is of critical importance to securing the future of a free society. Free software is about having control over the technology we use in our homes, schools and businesses, where computers work for our individual and communal benefit, not for proprietary software companies or governments who might seek to restrict and monitor us. The Free Software Foundation exclusively uses free software to perform its work.The Free Software Foundation is working to secure freedom for computerusers by promoting the development and use of free (as in freedom) software and documentation—particularly the GNU operating system—and by campaigning against threats to computer user freedom like Digital Restrictions Management (DRM) and software patents.',
|
||||
},
|
||||
{
|
||||
name: 'Direct Relief',
|
||||
website: 'https://www.directrelief.org/',
|
||||
ein: '95-1831116',
|
||||
photo: 'https://i.imgur.com/QS7kHAU.png',
|
||||
preview:
|
||||
'Direct Relief is a humanitarian aid organization, active in all 50 states and more than 80 countries, with a mission to improve the health and lives of people affected by poverty or emergencies – without regard to politics, religion, or ability to pay.',
|
||||
description:
|
||||
'Nongovernmental, nonsectarian, and not-for-profit, Direct Relief relies entirely on private contributions to advance its mission and perform a wide range of functions.\n Included among them are identifying key local providers of health services; working to identify the unmet needs of people in the low-resource areas; mobilizing essential medicines, supplies, and equipment that are requested and appropriate for the circumstances; and managing the many details inherent in storing, transporting, and distributing such resources to organizations in the most efficient manner possible.',
|
||||
},
|
||||
{
|
||||
name: 'World Resources Institute',
|
||||
website: 'https://www.wri.org/',
|
||||
ein: '52-1257057',
|
||||
photo: 'https://i.imgur.com/Bi6MgYI.png',
|
||||
preview:
|
||||
'WRI is a global nonprofit organization that works with leaders in government, business and civil society to research, design, and carry out practical solutions that simultaneously improve people’s lives and ensure nature can thrive.',
|
||||
description:
|
||||
"Since its founding in 1982, WRI has been guided by its mission and core values which are integrated into all that we do. Our mission: To move human society to live in ways that protect Earth’s environment and its capacity to provide for the needs and aspirations of current and future generations. WRI relies on the generosity of our donors to drive outcomes that help the world to be a fairer, healthier and more sustainable place for people and the planet. We publish our financials annually to highlight our continued fiscal accountability. That's why WRI consistently receives top ratings from charity evaluators for our strong financial stewardship and commitment to transparency and accountability.",
|
||||
},
|
||||
{
|
||||
name: 'ProPublica',
|
||||
website: 'https://www.propublica.org/',
|
||||
ein: '14-2007220',
|
||||
photo: 'https://i.imgur.com/R5Vt3Pb.png',
|
||||
preview:
|
||||
'The mission: to expose abuses of power and betrayals of the public trust by government, business, and other institutions, using the moral force of investigative journalism to spur reform through the sustained spotlighting of wrongdoing.',
|
||||
description:
|
||||
'ProPublica is an independent, nonprofit newsroom that produces investigative journalism with moral force. We dig deep into important issues, shining a light on abuses of power and betrayals of public trust — and we stick with those issues as long as it takes to hold power to account. With a team of more than 100 dedicated journalists, ProPublica covers a range of topics including government and politics, business, criminal justice, the environment, education, health care, immigration, and technology. We focus on stories with the potential to spur real-world impact. Among other positive changes, our reporting has contributed to the passage of new laws; reversals of harmful policies and practices; and accountability for leaders at local, state and national levels.',
|
||||
},
|
||||
{
|
||||
name: 'Dana-Farber Cancer Institute',
|
||||
website: 'https://www.dana-farber.org/',
|
||||
ein: '04-2263040',
|
||||
photo: 'https://i.imgur.com/SQNn97p.png',
|
||||
preview:
|
||||
"For over 70 years, we've led the world by making life-changing breakthroughs in cancer research and patient care, providing the most advanced treatments available.",
|
||||
description:
|
||||
"Since its founding in 1947, Dana-Farber Cancer Institute in Boston, Massachusetts has been committed to providing adults and children with cancer with the best treatment available today while developing tomorrow's cures through cutting-edge research. Today, the Institute employs more than 5,000 staff, faculty, and clinicians supporting more than 640,000 annual outpatient visits, more than 1,000 hospital discharges per year, and has over 1,100 open clinical trials. Dana-Farber is internationally renowned for its equal commitment to cutting edge research and provision of excellent patient care. The deep expertise in these two areas uniquely positions Dana-Farber to develop, test, and gain FDA approval for new cancer therapies in its laboratories and clinical settings. Dana-Farber researchers have contributed to the development of 35 of 75 cancer drugs recently approved by the FDA for use in cancer patients.",
|
||||
},
|
||||
{
|
||||
name: 'Save The Children',
|
||||
website: 'https://www.savethechildren.org/',
|
||||
ein: '06-0726487',
|
||||
photo: 'https://i.imgur.com/GngYPBI.png',
|
||||
preview:
|
||||
'Through the decades, Save the Children has continued to work to save children’s lives, and that’s still what we do today.',
|
||||
description:
|
||||
"Our pioneering programs address children's unique needs, giving them a healthy start in life, the opportunity to learn and protection from harm. In the United States and around the world, our work creates lasting change for children, their families and communities – ultimately, transforming the future we all share.\nThis work is only made possible by the ongoing generosity of our donors, whose valuable support is used in the most cost-effective ways. It's important to note that all our work intersects – helping a boy or girl go to school also protects them from dangers such as child trafficking and early marriage. Keeping children healthy from disease or malnutrition means their parents are more likely to avoid costly treatment and be better able to provide for their family.\nWe don’t go into communities, carry out a project and then move on. We consult with children, their families, community leaders and local councils to understand all the issues or barriers, and then we develop programs that address these. We build trust so that our programs are successful and bring about real change.",
|
||||
},
|
||||
{
|
||||
name: 'World Central Kitchen Incorporated',
|
||||
website: 'https://wck.org/',
|
||||
ein: '27-3521132',
|
||||
photo: 'https://i.imgur.com/te93MaY.png',
|
||||
preview:
|
||||
'WCK is first to the frontlines, providing meals in response to humanitarian, climate, and community crises. We build resilient food systems with locally led solutions.',
|
||||
description:
|
||||
"WCK responds to natural disasters, man-made crises, and humanitarian emergencies around the world. We're a team of food first responders, mobilizing with the urgency of now to get meals to the people who need them most. Deploying our model of quick action, leveraging local resources, and adapting in real time, we know that a nourishing meal in a time of crisis is so much more than a plate of food—it's hope, it's dignity, and it's a sign that someone cares.",
|
||||
},
|
||||
{
|
||||
name: 'The Johns Hopkins Center for Health Security',
|
||||
website: 'https://www.centerforhealthsecurity.org/',
|
||||
ein: '',
|
||||
photo: 'https://i.imgur.com/gKZE2Xs.png',
|
||||
preview:
|
||||
'Our mission: to protect people’s health from epidemics and disasters and ensure that communities are resilient to major challenges.',
|
||||
description:
|
||||
'The Center for Health Security undertakes a series of projects, collaborations, and initiatives to push forward progress on global health security, emerging infectious diseases and epidemics, medical and public health preparedness and response, deliberate biological threats, and opportunities and risks in the life sciences. We:\n- Conduct research and analysis on major domestic and international health security issues.\n- Engage with researchers, the policymaking community, and the private sector to make progress in the field.\n- Convene expert working groups, congressional seminars, scientific meetings, conferences, and tabletop exercises to stimulate new thinking and provoke action.\n- Educate a rising generation of scholars, practitioners, and policymakers.',
|
||||
},
|
||||
{
|
||||
name: 'ALLFED',
|
||||
website: 'https://allfed.info/',
|
||||
photo: 'https://i.imgur.com/p235vwF.jpg',
|
||||
ein: '27-6601178',
|
||||
preview: 'Feeding everyone no matter what.',
|
||||
description:
|
||||
'The mission of the Alliance to Feed the Earth in Disasters is to help create resilience to global food shocks. We seek to identify various resilient food solutions and to help governments implement these solutions, to increase the chances that people have enough to eat in the event of a global catastrophe. We focus on events that could deplete food supplies or access to 5% of the global population or more.Our ultimate goal is to feed everyone, no matter what. An important aspect of this goal is that we need to establish equitable solutions so that all people can access the nutrition they need, regardless of wealth or location.ALLFED is inspired by effective altruism, using reason and evidence to identify how to do the most good. Our solutions are backed by science and research, and we also identify the most cost-effective solutions, to be able to provide more nutrition in catastrophes.',
|
||||
},
|
||||
{
|
||||
name: 'The Trevor Project',
|
||||
website: 'https://www.thetrevorproject.org/',
|
||||
photo: 'https://i.imgur.com/QN4mVNn.jpeg',
|
||||
preview:
|
||||
'The Trevor Project is the world’s largest suicide prevention and crisis intervention organization for LGBTQ (lesbian, gay, bisexual, transgender, queer, and questioning) young people.',
|
||||
description: `Two decades ago, we responded to a health crisis. Now we’re building a safer, more-inclusive world. LGBTQ young people are four times more likely to attempt suicide, and suicide remains the second leading cause of death among all young people in the U.S.
|
||||
|
||||
Our Mission
|
||||
To end suicide among lesbian, gay, bisexual, transgender, queer & questioning young people.
|
||||
|
||||
Our Vision
|
||||
A world where all LGBTQ young people see a bright future for themselves.
|
||||
|
||||
Our Goal
|
||||
To serve 1.8 million crisis contacts annually, by the end of our 25th year, while continuing to innovate on our core services.`,
|
||||
},
|
||||
{
|
||||
name: 'ACLU',
|
||||
website: 'https://www.aclu.org/',
|
||||
photo: 'https://i.imgur.com/nbSYuDC.png',
|
||||
preview:
|
||||
'The ACLU works in the courts, legislatures, and communities to defend and preserve the individual rights and liberties guaranteed to all people in this country by the Constitution and laws of the United States.',
|
||||
description: `
|
||||
THREE THINGS TO KNOW ABOUT THE ACLU
|
||||
• We protect American values. In many ways, the ACLU is the nation's most conservative organization. Our job is to conserve America's original civic values - the Constitution and the Bill of Rights - and defend the rights of every man, woman and child in this country.
|
||||
• We're not anti-anything. The only things we fight are attempts to take away or limit your civil liberties, like your right to practice any religion you want (or none at all); or to decide in private whether or not to have a child; or to speak out - for or against - anything at all; or to be treated with equality and fairness, no matter who you are.
|
||||
• We're there for you. Rich or poor, straight or gay, black or white or brown, urban or rural, pious or atheist, American-born or foreign-born, able-bodied or living with a disability. Every person in this country should have the same basic rights. And since our founding in 1920, we've been working hard to make sure no one takes them away.
|
||||
|
||||
The American Civil Liberties Union is our nation's guardian of liberty, working daily in courts, legislatures and communities to defend and preserve the individual rights and liberties that the Constitution and laws of the United States guarantee everyone in this country.
|
||||
|
||||
"So long as we have enough people in this country willing to fight for their rights, we'll be called a democracy," ACLU Founder Roger Baldwin said.
|
||||
|
||||
The U.S. Constitution and the Bill of Rights trumpet our aspirations for the kind of society that we want to be. But for much of our history, our nation failed to fulfill the promise of liberty for whole groups of people.`,
|
||||
},
|
||||
{
|
||||
name: 'The Center for Election Science',
|
||||
website: 'https://electionscience.org/',
|
||||
photo: 'https://i.imgur.com/WvdHHZa.png',
|
||||
preview:
|
||||
'The Center for Election Science is a nonpartisan nonprofit dedicated to empowering voters with voting methods that strengthen democracy. We believe you deserve a vote that empowers you to impact the world you live in.',
|
||||
description: `Founded in 2011, The Center for Election Science is a national, nonpartisan nonprofit focused on voting reform.
|
||||
|
||||
Our Mission — To empower people with voting methods that strengthen democracy.
|
||||
|
||||
Our Vision — A world where democracies thrive because voters’ voices are heard.
|
||||
|
||||
With an emphasis on approval voting, we bring better elections to people across the country through both advocacy and research.
|
||||
|
||||
The movement for a better way to vote is rapidly gaining momentum as voters grow tired of election results that don’t represent the will of the people. In 2018, we worked with locals in Fargo, ND to help them become the first city in the U.S. to adopt approval voting. And in 2020, we helped grassroots activists empower the 300k people of St. Louis, MO with stronger democracy through approval voting.`,
|
||||
},
|
||||
{
|
||||
name: 'Founders Pledge Global Health and Development Fund',
|
||||
website: 'https://founderspledge.com/funds/global-health-and-development',
|
||||
photo: 'https://i.imgur.com/EXbxH7T.png',
|
||||
preview:
|
||||
'Tackling the vast global inequalities in health, wealth and opportunity',
|
||||
description: `Nearly half the world lives on less than $2.50 a day, yet giving by the world’s richest often overlooks the world’s poorest and most vulnerable. Despite the average American household being richer than 90% of the rest of the world, only 6% of US charitable giving goes to charities which work internationally.
|
||||
|
||||
This Fund is focused on helping those who need it most, wherever that help can make the biggest difference. By building a mixed portfolio of direct and indirect interventions, such as policy work, we aim to:
|
||||
|
||||
Improve the lives of the world's most vulnerable people.
|
||||
Reduce the number of easily preventable deaths worldwide.
|
||||
Work towards sustainable, systemic change.`,
|
||||
},
|
||||
{
|
||||
name: 'YIMBY Law',
|
||||
website: 'https://www.yimbylaw.org/',
|
||||
photo: 'https://i.imgur.com/zlzp21Z.png',
|
||||
preview:
|
||||
'YIMBY Law works to make housing in California more accessible and affordable, by enforcing state housing laws.',
|
||||
description: `
|
||||
YIMBY Law works to make housing in California more accessible and affordable. Our method is to enforce state housing laws, and some examples are outlined below. We send letters to cities considering zoning or general plan compliant housing developments informing them of their duties under state law, and sue them when they do not comply.
|
||||
|
||||
If you would like to support our work, you can do so by getting involved or by donating.`,
|
||||
},
|
||||
{
|
||||
name: 'CaRLA',
|
||||
website: 'https://carlaef.org/',
|
||||
photo: 'https://i.imgur.com/IsNVTOY.png',
|
||||
preview:
|
||||
'The California Renters Legal Advocacy and Education Fund’s core mission is to make lasting impacts to improve the affordability and accessibility of housing to current and future Californians, especially low- and moderate-income people and communities of color.',
|
||||
description: `
|
||||
The California Renters Legal Advocacy and Education Fund’s core mission is to make lasting impacts to improve the affordability and accessibility of housing to current and future Californians, especially low- and moderate-income people and communities of color.
|
||||
|
||||
CaRLA uses legal advocacy and education to ensure all cities comply with their own zoning and state housing laws and do their part to help solve the state’s housing shortage.
|
||||
|
||||
In addition to housing impact litigation, we provide free legal aid, education and workshops, counseling and advocacy to advocates, homeowners, small developers, and city and state government officials.`,
|
||||
},
|
||||
{
|
||||
name: 'Mriya',
|
||||
website: 'https://mriya-ua.org/',
|
||||
photo:
|
||||
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2Fdefault%2Fci2h3hStFM.47?alt=media&token=0d2cdc3d-e4d8-4f5e-8f23-4a586b6ff637',
|
||||
preview: 'Donate supplies to soldiers in Ukraine',
|
||||
description:
|
||||
'Donate supplies to soldiers in Ukraine, including tourniquets and plate carriers.',
|
||||
},
|
||||
].map((charity) => {
|
||||
const slug = charity.name.toLowerCase().replace(/\s/g, '-')
|
||||
return {
|
||||
...charity,
|
||||
id: slug,
|
||||
slug,
|
||||
}
|
||||
})
|
56
common/comment.ts
Normal file
56
common/comment.ts
Normal file
|
@ -0,0 +1,56 @@
|
|||
import type { JSONContent } from '@tiptap/core'
|
||||
|
||||
export type AnyCommentType = OnContract | OnGroup | OnPost
|
||||
|
||||
// Currently, comments are created after the bet, not atomically with the bet.
|
||||
// They're uniquely identified by the pair contractId/betId.
|
||||
export type Comment<T extends AnyCommentType = AnyCommentType> = {
|
||||
id: string
|
||||
replyToCommentId?: string
|
||||
userId: string
|
||||
|
||||
/** @deprecated - content now stored as JSON in content*/
|
||||
text?: string
|
||||
content: JSONContent
|
||||
createdTime: number
|
||||
|
||||
// Denormalized, for rendering comments
|
||||
userName: string
|
||||
userUsername: string
|
||||
userAvatarUrl?: string
|
||||
bountiesAwarded?: number
|
||||
} & T
|
||||
|
||||
export type OnContract = {
|
||||
commentType: 'contract'
|
||||
contractId: string
|
||||
answerOutcome?: string
|
||||
betId?: string
|
||||
|
||||
// denormalized from contract
|
||||
contractSlug: string
|
||||
contractQuestion: string
|
||||
|
||||
// denormalized from bet
|
||||
betAmount?: number
|
||||
betOutcome?: string
|
||||
|
||||
// denormalized based on betting history
|
||||
commenterPositionProb?: number // binary only
|
||||
commenterPositionShares?: number
|
||||
commenterPositionOutcome?: string
|
||||
}
|
||||
|
||||
export type OnGroup = {
|
||||
commentType: 'group'
|
||||
groupId: string
|
||||
}
|
||||
|
||||
export type OnPost = {
|
||||
commentType: 'post'
|
||||
postId: string
|
||||
}
|
||||
|
||||
export type ContractComment = Comment<OnContract>
|
||||
export type GroupComment = Comment<OnGroup>
|
||||
export type PostComment = Comment<OnPost>
|
168
common/contract-details.ts
Normal file
168
common/contract-details.ts
Normal file
|
@ -0,0 +1,168 @@
|
|||
import { Challenge } from './challenge'
|
||||
import { BinaryContract, Contract } from './contract'
|
||||
import { getFormattedMappedValue } from './pseudo-numeric'
|
||||
import { getProbability } from './calculate'
|
||||
import { richTextToString } from './util/parse'
|
||||
import { getCpmmProbability } from './calculate-cpmm'
|
||||
import { getDpmProbability } from './calculate-dpm'
|
||||
import { formatMoney, formatPercent } from './util/format'
|
||||
|
||||
export function contractMetrics(contract: Contract) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const dayjs = require('dayjs')
|
||||
const { createdTime, resolutionTime, isResolved } = contract
|
||||
|
||||
const createdDate = dayjs(createdTime).format('MMM D')
|
||||
|
||||
const resolvedDate = isResolved
|
||||
? dayjs(resolutionTime).format('MMM D')
|
||||
: undefined
|
||||
|
||||
const volumeLabel = `${formatMoney(contract.volume)} bet`
|
||||
|
||||
return { volumeLabel, createdDate, resolvedDate }
|
||||
}
|
||||
|
||||
// String version of the above, to send to the OpenGraph image generator
|
||||
export function contractTextDetails(contract: Contract) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const dayjs = require('dayjs')
|
||||
const { closeTime, groupLinks } = contract
|
||||
const { createdDate, resolvedDate, volumeLabel } = contractMetrics(contract)
|
||||
|
||||
const groupHashtags = groupLinks?.map((g) => `#${g.name.replace(/ /g, '')}`)
|
||||
|
||||
return (
|
||||
`${resolvedDate ? `${createdDate} - ${resolvedDate}` : createdDate}` +
|
||||
(closeTime
|
||||
? ` • ${closeTime > Date.now() ? 'Closes' : 'Closed'} ${dayjs(
|
||||
closeTime
|
||||
).format('MMM D, h:mma')}`
|
||||
: '') +
|
||||
` • ${volumeLabel}` +
|
||||
(groupHashtags ? ` • ${groupHashtags.join(' ')}` : '')
|
||||
)
|
||||
}
|
||||
|
||||
export function getBinaryProb(contract: BinaryContract) {
|
||||
const { pool, resolutionProbability, mechanism } = contract
|
||||
|
||||
return (
|
||||
resolutionProbability ??
|
||||
(mechanism === 'cpmm-1'
|
||||
? getCpmmProbability(pool, contract.p)
|
||||
: getDpmProbability(contract.totalShares))
|
||||
)
|
||||
}
|
||||
|
||||
export const getOpenGraphProps = (contract: Contract) => {
|
||||
const {
|
||||
resolution,
|
||||
question,
|
||||
creatorName,
|
||||
creatorUsername,
|
||||
outcomeType,
|
||||
creatorAvatarUrl,
|
||||
description: desc,
|
||||
} = contract
|
||||
const probPercent =
|
||||
outcomeType === 'BINARY'
|
||||
? formatPercent(getBinaryProb(contract))
|
||||
: undefined
|
||||
|
||||
const numericValue =
|
||||
outcomeType === 'PSEUDO_NUMERIC'
|
||||
? getFormattedMappedValue(contract)(getProbability(contract))
|
||||
: undefined
|
||||
|
||||
const stringDesc = typeof desc === 'string' ? desc : richTextToString(desc)
|
||||
|
||||
const description = resolution
|
||||
? `Resolved ${resolution}. ${stringDesc}`
|
||||
: probPercent
|
||||
? `${probPercent} chance. ${stringDesc}`
|
||||
: stringDesc
|
||||
|
||||
return {
|
||||
question,
|
||||
probability: probPercent,
|
||||
metadata: contractTextDetails(contract),
|
||||
creatorName,
|
||||
creatorUsername,
|
||||
creatorAvatarUrl,
|
||||
description,
|
||||
numericValue,
|
||||
resolution,
|
||||
}
|
||||
}
|
||||
|
||||
export type OgCardProps = {
|
||||
question: string
|
||||
probability?: string
|
||||
metadata: string
|
||||
creatorName: string
|
||||
creatorUsername: string
|
||||
creatorAvatarUrl?: string
|
||||
numericValue?: string
|
||||
resolution?: string
|
||||
}
|
||||
|
||||
export function buildCardUrl(props: OgCardProps, challenge?: Challenge) {
|
||||
const {
|
||||
creatorAmount,
|
||||
acceptances,
|
||||
acceptorAmount,
|
||||
creatorOutcome,
|
||||
acceptorOutcome,
|
||||
} = challenge || {}
|
||||
const {
|
||||
probability,
|
||||
numericValue,
|
||||
resolution,
|
||||
creatorAvatarUrl,
|
||||
question,
|
||||
metadata,
|
||||
creatorUsername,
|
||||
creatorName,
|
||||
} = props
|
||||
const { userName, userAvatarUrl } = acceptances?.[0] ?? {}
|
||||
|
||||
const probabilityParam =
|
||||
probability === undefined
|
||||
? ''
|
||||
: `&probability=${encodeURIComponent(probability ?? '')}`
|
||||
|
||||
const numericValueParam =
|
||||
numericValue === undefined
|
||||
? ''
|
||||
: `&numericValue=${encodeURIComponent(numericValue ?? '')}`
|
||||
|
||||
const creatorAvatarUrlParam =
|
||||
creatorAvatarUrl === undefined
|
||||
? ''
|
||||
: `&creatorAvatarUrl=${encodeURIComponent(creatorAvatarUrl ?? '')}`
|
||||
|
||||
const challengeUrlParams = challenge
|
||||
? `&creatorAmount=${creatorAmount}&creatorOutcome=${creatorOutcome}` +
|
||||
`&challengerAmount=${acceptorAmount}&challengerOutcome=${acceptorOutcome}` +
|
||||
`&acceptedName=${userName ?? ''}&acceptedAvatarUrl=${userAvatarUrl ?? ''}`
|
||||
: ''
|
||||
|
||||
const resolutionUrlParam = resolution
|
||||
? `&resolution=${encodeURIComponent(resolution)}`
|
||||
: ''
|
||||
|
||||
// URL encode each of the props, then add them as query params
|
||||
return (
|
||||
`https://manifold-og-image.vercel.app/m.png` +
|
||||
`?question=${encodeURIComponent(question)}` +
|
||||
probabilityParam +
|
||||
numericValueParam +
|
||||
`&metadata=${encodeURIComponent(metadata)}` +
|
||||
`&creatorName=${encodeURIComponent(creatorName)}` +
|
||||
creatorAvatarUrlParam +
|
||||
`&creatorUsername=${encodeURIComponent(creatorUsername)}` +
|
||||
challengeUrlParams +
|
||||
resolutionUrlParam
|
||||
)
|
||||
}
|
165
common/contract.ts
Normal file
165
common/contract.ts
Normal file
|
@ -0,0 +1,165 @@
|
|||
import { Answer } from './answer'
|
||||
import { Fees } from './fees'
|
||||
import { JSONContent } from '@tiptap/core'
|
||||
import { GroupLink } from 'common/group'
|
||||
|
||||
export type AnyMechanism = DPM | CPMM
|
||||
export type AnyOutcomeType =
|
||||
| Binary
|
||||
| MultipleChoice
|
||||
| PseudoNumeric
|
||||
| FreeResponse
|
||||
| Numeric
|
||||
|
||||
export type AnyContractType =
|
||||
| (CPMM & Binary)
|
||||
| (CPMM & PseudoNumeric)
|
||||
| (DPM & Binary)
|
||||
| (DPM & FreeResponse)
|
||||
| (DPM & Numeric)
|
||||
| (DPM & MultipleChoice)
|
||||
|
||||
export type Contract<T extends AnyContractType = AnyContractType> = {
|
||||
id: string
|
||||
slug: string // auto-generated; must be unique
|
||||
|
||||
creatorId: string
|
||||
creatorName: string
|
||||
creatorUsername: string
|
||||
creatorAvatarUrl?: string
|
||||
|
||||
question: string
|
||||
description: string | JSONContent // More info about what the contract is about
|
||||
tags: string[]
|
||||
lowercaseTags: string[]
|
||||
visibility: visibility
|
||||
|
||||
createdTime: number // Milliseconds since epoch
|
||||
lastUpdatedTime?: number // Updated on new bet or comment
|
||||
lastBetTime?: number
|
||||
lastCommentTime?: number
|
||||
closeTime?: number // When no more trading is allowed
|
||||
|
||||
isResolved: boolean
|
||||
resolutionTime?: number // When the contract creator resolved the market
|
||||
resolution?: string
|
||||
resolutionProbability?: number
|
||||
|
||||
closeEmailsSent?: number
|
||||
|
||||
volume: number
|
||||
volume24Hours: number
|
||||
volume7Days: number
|
||||
elasticity: number
|
||||
|
||||
collectedFees: Fees
|
||||
|
||||
groupSlugs?: string[]
|
||||
groupLinks?: GroupLink[]
|
||||
uniqueBettorIds?: string[]
|
||||
uniqueBettorCount?: number
|
||||
popularityScore?: number
|
||||
dailyScore?: number
|
||||
followerCount?: number
|
||||
featuredOnHomeRank?: number
|
||||
likedByUserIds?: string[]
|
||||
likedByUserCount?: number
|
||||
flaggedByUsernames?: string[]
|
||||
openCommentBounties?: number
|
||||
unlistedById?: string
|
||||
} & T
|
||||
|
||||
export type BinaryContract = Contract & Binary
|
||||
export type PseudoNumericContract = Contract & PseudoNumeric
|
||||
export type NumericContract = Contract & Numeric
|
||||
export type FreeResponseContract = Contract & FreeResponse
|
||||
export type MultipleChoiceContract = Contract & MultipleChoice
|
||||
export type DPMContract = Contract & DPM
|
||||
export type CPMMContract = Contract & CPMM
|
||||
export type DPMBinaryContract = BinaryContract & DPM
|
||||
export type CPMMBinaryContract = BinaryContract & CPMM
|
||||
|
||||
export type DPM = {
|
||||
mechanism: 'dpm-2'
|
||||
|
||||
pool: { [outcome: string]: number }
|
||||
phantomShares?: { [outcome: string]: number }
|
||||
totalShares: { [outcome: string]: number }
|
||||
totalBets: { [outcome: string]: number }
|
||||
}
|
||||
|
||||
export type CPMM = {
|
||||
mechanism: 'cpmm-1'
|
||||
pool: { [outcome: string]: number }
|
||||
p: number // probability constant in y^p * n^(1-p) = k
|
||||
totalLiquidity: number // for historical reasons, this the total subsidy amount added in M$
|
||||
subsidyPool: number // current value of subsidy pool in M$
|
||||
prob: number
|
||||
probChanges: {
|
||||
day: number
|
||||
week: number
|
||||
month: number
|
||||
}
|
||||
}
|
||||
|
||||
export type Binary = {
|
||||
outcomeType: 'BINARY'
|
||||
initialProbability: number
|
||||
resolutionProbability?: number // Used for BINARY markets resolved to MKT
|
||||
resolution?: resolution
|
||||
}
|
||||
|
||||
export type PseudoNumeric = {
|
||||
outcomeType: 'PSEUDO_NUMERIC'
|
||||
min: number
|
||||
max: number
|
||||
isLogScale: boolean
|
||||
resolutionValue?: number
|
||||
|
||||
// same as binary market; map everything to probability
|
||||
initialProbability: number
|
||||
resolutionProbability?: number
|
||||
}
|
||||
|
||||
export type FreeResponse = {
|
||||
outcomeType: 'FREE_RESPONSE'
|
||||
answers: Answer[] // Used for outcomeType 'FREE_RESPONSE'.
|
||||
resolution?: string | 'MKT' | 'CANCEL'
|
||||
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
||||
}
|
||||
|
||||
export type MultipleChoice = {
|
||||
outcomeType: 'MULTIPLE_CHOICE'
|
||||
answers: Answer[]
|
||||
resolution?: string | 'MKT' | 'CANCEL'
|
||||
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
||||
}
|
||||
|
||||
export type Numeric = {
|
||||
outcomeType: 'NUMERIC'
|
||||
bucketCount: number
|
||||
min: number
|
||||
max: number
|
||||
resolutions?: { [outcome: string]: number } // Used for MKT resolution.
|
||||
resolutionValue?: number
|
||||
}
|
||||
|
||||
export type outcomeType = AnyOutcomeType['outcomeType']
|
||||
export type resolution = 'YES' | 'NO' | 'MKT' | 'CANCEL'
|
||||
export const RESOLUTIONS = ['YES', 'NO', 'MKT', 'CANCEL'] as const
|
||||
export const OUTCOME_TYPES = [
|
||||
'BINARY',
|
||||
'MULTIPLE_CHOICE',
|
||||
'FREE_RESPONSE',
|
||||
'PSEUDO_NUMERIC',
|
||||
'NUMERIC',
|
||||
] as const
|
||||
|
||||
export const MAX_QUESTION_LENGTH = 240
|
||||
export const MAX_DESCRIPTION_LENGTH = 16000
|
||||
export const MAX_TAG_LENGTH = 60
|
||||
|
||||
export const CPMM_MIN_POOL_QTY = 0.01
|
||||
|
||||
export type visibility = 'public' | 'unlisted'
|
||||
export const VISIBILITIES = ['public', 'unlisted'] as const
|
20
common/economy.ts
Normal file
20
common/economy.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { ENV_CONFIG } from './envs/constants'
|
||||
|
||||
const econ = ENV_CONFIG.economy
|
||||
|
||||
export const FIXED_ANTE = econ?.FIXED_ANTE ?? 100
|
||||
|
||||
export const STARTING_BALANCE = econ?.STARTING_BALANCE ?? 1000
|
||||
// for sus users, i.e. multiple sign ups for same person
|
||||
export const SUS_STARTING_BALANCE = econ?.SUS_STARTING_BALANCE ?? 10
|
||||
export const REFERRAL_AMOUNT = econ?.REFERRAL_AMOUNT ?? 250
|
||||
|
||||
export const UNIQUE_BETTOR_BONUS_AMOUNT = econ?.UNIQUE_BETTOR_BONUS_AMOUNT ?? 10
|
||||
export const BETTING_STREAK_BONUS_AMOUNT =
|
||||
econ?.BETTING_STREAK_BONUS_AMOUNT ?? 5
|
||||
export const BETTING_STREAK_BONUS_MAX = econ?.BETTING_STREAK_BONUS_MAX ?? 25
|
||||
export const BETTING_STREAK_RESET_HOUR = econ?.BETTING_STREAK_RESET_HOUR ?? 7
|
||||
export const FREE_MARKETS_PER_USER_MAX = econ?.FREE_MARKETS_PER_USER_MAX ?? 5
|
||||
export const COMMENT_BOUNTY_AMOUNT = econ?.COMMENT_BOUNTY_AMOUNT ?? 250
|
||||
|
||||
export const UNIQUE_BETTOR_LIQUIDITY = 20
|
58
common/envs/constants.ts
Normal file
58
common/envs/constants.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import { escapeRegExp } from 'lodash'
|
||||
import { DEV_CONFIG } from './dev'
|
||||
import { EnvConfig, PROD_CONFIG } from './prod'
|
||||
import { THEOREMONE_CONFIG } from './theoremone'
|
||||
|
||||
export const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD'
|
||||
|
||||
const CONFIGS: { [env: string]: EnvConfig } = {
|
||||
PROD: PROD_CONFIG,
|
||||
DEV: DEV_CONFIG,
|
||||
THEOREMONE: THEOREMONE_CONFIG,
|
||||
}
|
||||
|
||||
export const ENV_CONFIG = CONFIGS[ENV]
|
||||
|
||||
export function isWhitelisted(email?: string) {
|
||||
if (!ENV_CONFIG.whitelistEmail) {
|
||||
return true
|
||||
}
|
||||
return email && (email.endsWith(ENV_CONFIG.whitelistEmail) || isAdmin(email))
|
||||
}
|
||||
|
||||
// TODO: Before open sourcing, we should turn these into env vars
|
||||
export function isAdmin(email?: string) {
|
||||
if (!email) {
|
||||
return false
|
||||
}
|
||||
return ENV_CONFIG.adminEmails.includes(email)
|
||||
}
|
||||
|
||||
export function isManifoldId(userId: string) {
|
||||
return userId === 'IPTOzEqrpkWmEzh6hwvAyY9PqFb2'
|
||||
}
|
||||
|
||||
export const DOMAIN = ENV_CONFIG.domain
|
||||
export const FIREBASE_CONFIG = ENV_CONFIG.firebaseConfig
|
||||
export const PROJECT_ID = ENV_CONFIG.firebaseConfig.projectId
|
||||
export const IS_PRIVATE_MANIFOLD = ENV_CONFIG.visibility === 'PRIVATE'
|
||||
|
||||
export const AUTH_COOKIE_NAME = `FBUSER_${PROJECT_ID.toUpperCase().replace(
|
||||
/-/g,
|
||||
'_'
|
||||
)}`
|
||||
|
||||
// Manifold's domain or any subdomains thereof
|
||||
export const CORS_ORIGIN_MANIFOLD = new RegExp(
|
||||
'^https?://(?:[a-zA-Z0-9\\-]+\\.)*' + escapeRegExp(ENV_CONFIG.domain) + '$'
|
||||
)
|
||||
// Vercel deployments, used for testing.
|
||||
export const CORS_ORIGIN_VERCEL = new RegExp(
|
||||
'^https?://[a-zA-Z0-9\\-]+' + escapeRegExp('mantic.vercel.app') + '$'
|
||||
)
|
||||
// Any localhost server on any port
|
||||
export const CORS_ORIGIN_LOCALHOST = /^http:\/\/localhost:\d+$/
|
||||
|
||||
export function firestoreConsolePath(contractId: string) {
|
||||
return `https://console.firebase.google.com/project/${PROJECT_ID}/firestore/data/~2Fcontracts~2F${contractId}`
|
||||
}
|
21
common/envs/dev.ts
Normal file
21
common/envs/dev.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { EnvConfig, PROD_CONFIG } from './prod'
|
||||
|
||||
export const DEV_CONFIG: EnvConfig = {
|
||||
...PROD_CONFIG,
|
||||
domain: 'dev.manifold.markets',
|
||||
firebaseConfig: {
|
||||
apiKey: 'AIzaSyBoq3rzUa8Ekyo3ZaTnlycQYPRCA26VpOw',
|
||||
authDomain: 'dev-mantic-markets.firebaseapp.com',
|
||||
projectId: 'dev-mantic-markets',
|
||||
region: 'us-central1',
|
||||
storageBucket: 'dev-mantic-markets.appspot.com',
|
||||
messagingSenderId: '134303100058',
|
||||
appId: '1:134303100058:web:27f9ea8b83347251f80323',
|
||||
measurementId: 'G-YJC9E37P37',
|
||||
},
|
||||
cloudRunId: 'w3txbmd3ba',
|
||||
cloudRunRegion: 'uc',
|
||||
amplitudeApiKey: 'fd8cbfd964b9a205b8678a39faae71b3',
|
||||
twitchBotEndpoint: 'https://dev-twitch-bot.manifold.markets',
|
||||
sprigEnvironmentId: 'Tu7kRZPm7daP',
|
||||
}
|
101
common/envs/prod.ts
Normal file
101
common/envs/prod.ts
Normal file
|
@ -0,0 +1,101 @@
|
|||
export type EnvConfig = {
|
||||
domain: string
|
||||
firebaseConfig: FirebaseConfig
|
||||
amplitudeApiKey?: string
|
||||
twitchBotEndpoint?: string
|
||||
sprigEnvironmentId?: string
|
||||
|
||||
// IDs for v2 cloud functions -- find these by deploying a cloud function and
|
||||
// examining the URL, https://[name]-[cloudRunId]-[cloudRunRegion].a.run.app
|
||||
cloudRunId: string
|
||||
cloudRunRegion: string
|
||||
|
||||
// Access controls
|
||||
adminEmails: string[]
|
||||
whitelistEmail?: string // e.g. '@theoremone.co'. If not provided, all emails are whitelisted
|
||||
visibility: 'PRIVATE' | 'PUBLIC'
|
||||
|
||||
// Branding
|
||||
moneyMoniker: string // e.g. 'M$'
|
||||
bettor?: string // e.g. 'bettor' or 'predictor'
|
||||
presentBet?: string // e.g. 'bet' or 'predict'
|
||||
pastBet?: string // e.g. 'bet' or 'prediction'
|
||||
faviconPath?: string // Should be a file in /public
|
||||
navbarLogoPath?: string
|
||||
newQuestionPlaceholders: string[]
|
||||
|
||||
economy?: Economy
|
||||
}
|
||||
|
||||
export type Economy = {
|
||||
FIXED_ANTE?: number
|
||||
|
||||
STARTING_BALANCE?: number
|
||||
SUS_STARTING_BALANCE?: number
|
||||
|
||||
REFERRAL_AMOUNT?: number
|
||||
|
||||
UNIQUE_BETTOR_BONUS_AMOUNT?: number
|
||||
|
||||
BETTING_STREAK_BONUS_AMOUNT?: number
|
||||
BETTING_STREAK_BONUS_MAX?: number
|
||||
BETTING_STREAK_RESET_HOUR?: number
|
||||
FREE_MARKETS_PER_USER_MAX?: number
|
||||
COMMENT_BOUNTY_AMOUNT?: number
|
||||
}
|
||||
|
||||
type FirebaseConfig = {
|
||||
apiKey: string
|
||||
authDomain: string
|
||||
projectId: string
|
||||
region?: string
|
||||
storageBucket: string
|
||||
messagingSenderId: string
|
||||
appId: string
|
||||
measurementId: string
|
||||
}
|
||||
|
||||
export const PROD_CONFIG: EnvConfig = {
|
||||
domain: 'manifold.markets',
|
||||
amplitudeApiKey: '2d6509fd4185ebb8be29709842752a15',
|
||||
sprigEnvironmentId: 'sQcrq9TDqkib',
|
||||
|
||||
firebaseConfig: {
|
||||
apiKey: 'AIzaSyDp3J57vLeAZCzxLD-vcPaGIkAmBoGOSYw',
|
||||
authDomain: 'mantic-markets.firebaseapp.com',
|
||||
projectId: 'mantic-markets',
|
||||
region: 'us-central1',
|
||||
storageBucket: 'mantic-markets.appspot.com',
|
||||
messagingSenderId: '128925704902',
|
||||
appId: '1:128925704902:web:f61f86944d8ffa2a642dc7',
|
||||
measurementId: 'G-SSFK1Q138D',
|
||||
},
|
||||
twitchBotEndpoint: 'https://twitch-bot.manifold.markets',
|
||||
cloudRunId: 'nggbo3neva',
|
||||
cloudRunRegion: 'uc',
|
||||
adminEmails: [
|
||||
'akrolsmir@gmail.com', // Austin
|
||||
'jahooma@gmail.com', // James
|
||||
'taowell@gmail.com', // Stephen
|
||||
'abc.sinclair@gmail.com', // Sinclair
|
||||
'manticmarkets@gmail.com', // Manifold
|
||||
'iansphilips@gmail.com', // Ian
|
||||
'd4vidchee@gmail.com', // D4vid
|
||||
'federicoruizcassarino@gmail.com', // Fede
|
||||
'ingawei@gmail.com', //Inga
|
||||
],
|
||||
visibility: 'PUBLIC',
|
||||
|
||||
moneyMoniker: 'M$',
|
||||
bettor: 'trader',
|
||||
pastBet: 'trade',
|
||||
presentBet: 'trade',
|
||||
navbarLogoPath: '',
|
||||
faviconPath: '/favicon.ico',
|
||||
newQuestionPlaceholders: [
|
||||
'Will anyone I know get engaged this year?',
|
||||
'Will humans set foot on Mars by the end of 2030?',
|
||||
'Will any cryptocurrency eclipse Bitcoin by market cap this year?',
|
||||
'Will the Democrats win the 2024 presidential election?',
|
||||
],
|
||||
}
|
29
common/envs/theoremone.ts
Normal file
29
common/envs/theoremone.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { EnvConfig, PROD_CONFIG } from './prod'
|
||||
|
||||
export const THEOREMONE_CONFIG: EnvConfig = {
|
||||
domain: 'theoremone.manifold.markets',
|
||||
firebaseConfig: {
|
||||
apiKey: 'AIzaSyBSXL6Ys7InNHnCKSy-_E_luhh4Fkj4Z6M',
|
||||
authDomain: 'theoremone-manifold.firebaseapp.com',
|
||||
projectId: 'theoremone-manifold',
|
||||
region: 'us-central1',
|
||||
storageBucket: 'theoremone-manifold.appspot.com',
|
||||
messagingSenderId: '698012149198',
|
||||
appId: '1:698012149198:web:b342af75662831aa84b79f',
|
||||
measurementId: 'G-Y3EZ1WNT6E',
|
||||
},
|
||||
cloudRunId: 'nggbo3neva', // TODO: fill in real ID for T1
|
||||
cloudRunRegion: 'uc',
|
||||
adminEmails: [...PROD_CONFIG.adminEmails, 'david.glidden@theoremone.co'],
|
||||
whitelistEmail: '@theoremone.co',
|
||||
moneyMoniker: 'T$',
|
||||
visibility: 'PRIVATE',
|
||||
faviconPath: '/theoremone/logo.ico',
|
||||
navbarLogoPath: '/theoremone/TheoremOne-Logo.svg',
|
||||
newQuestionPlaceholders: [
|
||||
'Will we have at least 5 new team members by the end of this quarter?',
|
||||
'Will we meet or exceed our goals this sprint?',
|
||||
'Will we sign on 3 or more new clients this month?',
|
||||
'Will Paul shave his beard by the end of the month?',
|
||||
],
|
||||
}
|
9
common/feed.ts
Normal file
9
common/feed.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { Bet } from './bet'
|
||||
import { Comment } from './comment'
|
||||
import { Contract } from './contract'
|
||||
|
||||
export type feed = {
|
||||
contract: Contract
|
||||
recentBets: Bet[]
|
||||
recentComments: Comment[]
|
||||
}[]
|
21
common/fees.ts
Normal file
21
common/fees.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
export const FLAT_TRADE_FEE = 0.1 // M$0.1
|
||||
|
||||
export const PLATFORM_FEE = 0
|
||||
export const CREATOR_FEE = 0
|
||||
export const LIQUIDITY_FEE = 0
|
||||
|
||||
export const DPM_PLATFORM_FEE = 0.0
|
||||
export const DPM_CREATOR_FEE = 0.0
|
||||
export const DPM_FEES = DPM_PLATFORM_FEE + DPM_CREATOR_FEE
|
||||
|
||||
export type Fees = {
|
||||
creatorFee: number
|
||||
platformFee: number
|
||||
liquidityFee: number
|
||||
}
|
||||
|
||||
export const noFees: Fees = {
|
||||
creatorFee: 0,
|
||||
platformFee: 0,
|
||||
liquidityFee: 0,
|
||||
}
|
9
common/follow.ts
Normal file
9
common/follow.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export type Follow = {
|
||||
userId: string
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
export type ContractFollow = {
|
||||
id: string // user id
|
||||
createdTime: number
|
||||
}
|
3
common/globalConfig.ts
Normal file
3
common/globalConfig.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export type GlobalConfig = {
|
||||
pinnedItems: { itemId: string; type: 'post' | 'contract' }[]
|
||||
}
|
42
common/group.ts
Normal file
42
common/group.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
export type Group = {
|
||||
id: string
|
||||
slug: string
|
||||
name: string
|
||||
about: string
|
||||
creatorId: string // User id
|
||||
createdTime: number
|
||||
mostRecentActivityTime: number
|
||||
anyoneCanJoin: boolean
|
||||
totalContracts: number
|
||||
totalMembers: number
|
||||
aboutPostId?: string
|
||||
postIds: string[]
|
||||
chatDisabled?: boolean
|
||||
mostRecentContractAddedTime?: number
|
||||
cachedLeaderboard?: {
|
||||
topTraders: {
|
||||
userId: string
|
||||
score: number
|
||||
}[]
|
||||
topCreators: {
|
||||
userId: string
|
||||
score: number
|
||||
}[]
|
||||
}
|
||||
pinnedItems: { itemId: string; type: 'post' | 'contract' }[]
|
||||
}
|
||||
|
||||
export const MAX_GROUP_NAME_LENGTH = 75
|
||||
export const MAX_ABOUT_LENGTH = 140
|
||||
export const MAX_ID_LENGTH = 60
|
||||
export const NEW_USER_GROUP_SLUGS = ['updates', 'bugs', 'welcome']
|
||||
export const GROUP_CHAT_SLUG = 'chat'
|
||||
|
||||
export type GroupLink = {
|
||||
slug: string
|
||||
name: string
|
||||
groupId: string
|
||||
createdTime: number
|
||||
userId?: string
|
||||
}
|
||||
export type GroupContractDoc = { contractId: string; createdTime: number }
|
9
common/like.ts
Normal file
9
common/like.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export type Like = {
|
||||
id: string // will be id of the object liked, i.e. contract.id
|
||||
userId: string
|
||||
type: 'contract' | 'post'
|
||||
createdTime: number
|
||||
tipTxnId?: string // only holds most recent tip txn id
|
||||
}
|
||||
export const LIKE_TIP_AMOUNT = 10
|
||||
export const TIP_UNDO_DURATION = 2000
|
13
common/liquidity-provision.ts
Normal file
13
common/liquidity-provision.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
export type LiquidityProvision = {
|
||||
id: string
|
||||
userId: string
|
||||
contractId: string
|
||||
createdTime: number
|
||||
isAnte?: boolean
|
||||
|
||||
amount: number // M$ quantity
|
||||
|
||||
pool: { [outcome: string]: number } // pool shares before provision
|
||||
liquidity: number // change in constant k after provision
|
||||
p: number // p constant after provision
|
||||
}
|
138
common/loans.ts
Normal file
138
common/loans.ts
Normal file
|
@ -0,0 +1,138 @@
|
|||
import { Dictionary, groupBy, sumBy, minBy } from 'lodash'
|
||||
import { Bet } from './bet'
|
||||
import { getContractBetMetrics } from './calculate'
|
||||
import {
|
||||
Contract,
|
||||
CPMMContract,
|
||||
FreeResponseContract,
|
||||
MultipleChoiceContract,
|
||||
} from './contract'
|
||||
import { PortfolioMetrics, User } from './user'
|
||||
import { filterDefined } from './util/array'
|
||||
|
||||
const LOAN_DAILY_RATE = 0.02
|
||||
|
||||
const calculateNewLoan = (investedValue: number, loanTotal: number) => {
|
||||
const netValue = investedValue - loanTotal
|
||||
return netValue * LOAN_DAILY_RATE
|
||||
}
|
||||
|
||||
export const getLoanUpdates = (
|
||||
users: User[],
|
||||
contractsById: { [contractId: string]: Contract },
|
||||
portfolioByUser: { [userId: string]: PortfolioMetrics | undefined },
|
||||
betsByUser: { [userId: string]: Bet[] }
|
||||
) => {
|
||||
const eligibleUsers = filterDefined(
|
||||
users.map((user) =>
|
||||
isUserEligibleForLoan(portfolioByUser[user.id]) ? user : undefined
|
||||
)
|
||||
)
|
||||
|
||||
const betUpdates = eligibleUsers
|
||||
.map((user) => {
|
||||
const updates = calculateLoanBetUpdates(
|
||||
betsByUser[user.id] ?? [],
|
||||
contractsById
|
||||
).betUpdates
|
||||
return updates.map((update) => ({ ...update, user }))
|
||||
})
|
||||
.flat()
|
||||
|
||||
const updatesByUser = groupBy(betUpdates, (update) => update.userId)
|
||||
const userPayouts = Object.values(updatesByUser).map((updates) => {
|
||||
return {
|
||||
user: updates[0].user,
|
||||
payout: sumBy(updates, (update) => update.newLoan),
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
betUpdates,
|
||||
userPayouts,
|
||||
}
|
||||
}
|
||||
|
||||
const isUserEligibleForLoan = (portfolio: PortfolioMetrics | undefined) => {
|
||||
if (!portfolio) return true
|
||||
|
||||
const { balance, investmentValue } = portfolio
|
||||
return balance + investmentValue > 0
|
||||
}
|
||||
|
||||
const calculateLoanBetUpdates = (
|
||||
bets: Bet[],
|
||||
contractsById: Dictionary<Contract>
|
||||
) => {
|
||||
const betsByContract = groupBy(bets, (bet) => bet.contractId)
|
||||
const contracts = filterDefined(
|
||||
Object.keys(betsByContract).map((contractId) => contractsById[contractId])
|
||||
).filter((c) => !c.isResolved)
|
||||
|
||||
const betUpdates = filterDefined(
|
||||
contracts
|
||||
.map((c) => {
|
||||
if (c.mechanism === 'cpmm-1') {
|
||||
return getBinaryContractLoanUpdate(c, betsByContract[c.id])
|
||||
} else if (
|
||||
c.outcomeType === 'FREE_RESPONSE' ||
|
||||
c.outcomeType === 'MULTIPLE_CHOICE'
|
||||
)
|
||||
return getFreeResponseContractLoanUpdate(c, betsByContract[c.id])
|
||||
else {
|
||||
// Unsupported contract / mechanism for loans.
|
||||
return []
|
||||
}
|
||||
})
|
||||
.flat()
|
||||
)
|
||||
|
||||
const totalNewLoan = sumBy(betUpdates, (loanUpdate) => loanUpdate.loanTotal)
|
||||
|
||||
return {
|
||||
totalNewLoan,
|
||||
betUpdates,
|
||||
}
|
||||
}
|
||||
|
||||
const getBinaryContractLoanUpdate = (contract: CPMMContract, bets: Bet[]) => {
|
||||
const { invested } = getContractBetMetrics(contract, bets)
|
||||
const loanAmount = sumBy(bets, (bet) => bet.loanAmount ?? 0)
|
||||
const oldestBet = minBy(bets, (bet) => bet.createdTime)
|
||||
|
||||
const newLoan = calculateNewLoan(invested, loanAmount)
|
||||
if (!isFinite(newLoan) || newLoan <= 0 || !oldestBet) return undefined
|
||||
|
||||
const loanTotal = (oldestBet.loanAmount ?? 0) + newLoan
|
||||
|
||||
return {
|
||||
userId: oldestBet.userId,
|
||||
contractId: contract.id,
|
||||
betId: oldestBet.id,
|
||||
newLoan,
|
||||
loanTotal,
|
||||
}
|
||||
}
|
||||
|
||||
const getFreeResponseContractLoanUpdate = (
|
||||
contract: FreeResponseContract | MultipleChoiceContract,
|
||||
bets: Bet[]
|
||||
) => {
|
||||
const openBets = bets.filter((bet) => !bet.isSold && !bet.sale)
|
||||
|
||||
return openBets.map((bet) => {
|
||||
const loanAmount = bet.loanAmount ?? 0
|
||||
const newLoan = calculateNewLoan(bet.amount, loanAmount)
|
||||
const loanTotal = loanAmount + newLoan
|
||||
|
||||
if (!isFinite(newLoan) || newLoan <= 0) return undefined
|
||||
|
||||
return {
|
||||
userId: bet.userId,
|
||||
contractId: contract.id,
|
||||
betId: bet.id,
|
||||
newLoan,
|
||||
loanTotal,
|
||||
}
|
||||
})
|
||||
}
|
35
common/manalink.ts
Normal file
35
common/manalink.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
export type Manalink = {
|
||||
// The link to send: https://manifold.markets/send/{slug}
|
||||
// Also functions as the unique id for the link.
|
||||
slug: string
|
||||
|
||||
// Note: we assume both fromId and toId are of SourceType 'USER'
|
||||
fromId: string
|
||||
|
||||
// Displayed to people claiming the link
|
||||
message: string
|
||||
|
||||
// How much to send with the link
|
||||
amount: number
|
||||
token: 'M$' // TODO: could send eg YES shares too??
|
||||
|
||||
createdTime: number
|
||||
// If null, the link is valid forever
|
||||
expiresTime: number | null
|
||||
// If null, the link can be used infinitely
|
||||
maxUses: number | null
|
||||
|
||||
// Used for simpler caching
|
||||
claimedUserIds: string[]
|
||||
// Successful redemptions of the link
|
||||
claims: Claim[]
|
||||
}
|
||||
|
||||
export type Claim = {
|
||||
toId: string
|
||||
|
||||
// The ID of the successful txn that tracks the money moved
|
||||
txnId: string
|
||||
|
||||
claimedTime: number
|
||||
}
|
420
common/new-bet.ts
Normal file
420
common/new-bet.ts
Normal file
|
@ -0,0 +1,420 @@
|
|||
import { sortBy, sum, sumBy } from 'lodash'
|
||||
|
||||
import { Bet, fill, LimitBet, NumericBet } from './bet'
|
||||
import {
|
||||
calculateDpmShares,
|
||||
getDpmProbability,
|
||||
getDpmOutcomeProbability,
|
||||
getNumericBets,
|
||||
calculateNumericDpmShares,
|
||||
} from './calculate-dpm'
|
||||
import {
|
||||
calculateCpmmAmountToProb,
|
||||
calculateCpmmPurchase,
|
||||
CpmmState,
|
||||
getCpmmProbability,
|
||||
} from './calculate-cpmm'
|
||||
import {
|
||||
CPMMBinaryContract,
|
||||
DPMBinaryContract,
|
||||
DPMContract,
|
||||
NumericContract,
|
||||
PseudoNumericContract,
|
||||
} from './contract'
|
||||
import { noFees } from './fees'
|
||||
import { addObjects, removeUndefinedProps } from './util/object'
|
||||
import { NUMERIC_FIXED_VAR } from './numeric-constants'
|
||||
import {
|
||||
floatingEqual,
|
||||
floatingGreaterEqual,
|
||||
floatingLesserEqual,
|
||||
} from './util/math'
|
||||
|
||||
export type CandidateBet<T extends Bet = Bet> = Omit<
|
||||
T,
|
||||
'id' | 'userId' | 'userAvatarUrl' | 'userName' | 'userUsername'
|
||||
>
|
||||
export type BetInfo = {
|
||||
newBet: CandidateBet
|
||||
newPool?: { [outcome: string]: number }
|
||||
newTotalShares?: { [outcome: string]: number }
|
||||
newTotalBets?: { [outcome: string]: number }
|
||||
newTotalLiquidity?: number
|
||||
newP?: number
|
||||
}
|
||||
|
||||
const computeFill = (
|
||||
amount: number,
|
||||
outcome: 'YES' | 'NO',
|
||||
limitProb: number | undefined,
|
||||
cpmmState: CpmmState,
|
||||
matchedBet: LimitBet | undefined
|
||||
) => {
|
||||
const prob = getCpmmProbability(cpmmState.pool, cpmmState.p)
|
||||
|
||||
if (
|
||||
limitProb !== undefined &&
|
||||
(outcome === 'YES'
|
||||
? floatingGreaterEqual(prob, limitProb) &&
|
||||
(matchedBet?.limitProb ?? 1) > limitProb
|
||||
: floatingLesserEqual(prob, limitProb) &&
|
||||
(matchedBet?.limitProb ?? 0) < limitProb)
|
||||
) {
|
||||
// No fill.
|
||||
return undefined
|
||||
}
|
||||
|
||||
const timestamp = Date.now()
|
||||
|
||||
if (
|
||||
!matchedBet ||
|
||||
(outcome === 'YES'
|
||||
? !floatingGreaterEqual(prob, matchedBet.limitProb)
|
||||
: !floatingLesserEqual(prob, matchedBet.limitProb))
|
||||
) {
|
||||
// Fill from pool.
|
||||
const limit = !matchedBet
|
||||
? limitProb
|
||||
: outcome === 'YES'
|
||||
? Math.min(matchedBet.limitProb, limitProb ?? 1)
|
||||
: Math.max(matchedBet.limitProb, limitProb ?? 0)
|
||||
|
||||
const buyAmount =
|
||||
limit === undefined
|
||||
? amount
|
||||
: Math.min(amount, calculateCpmmAmountToProb(cpmmState, limit, outcome))
|
||||
|
||||
const { shares, newPool, newP, fees } = calculateCpmmPurchase(
|
||||
cpmmState,
|
||||
buyAmount,
|
||||
outcome
|
||||
)
|
||||
const newState = { pool: newPool, p: newP }
|
||||
|
||||
return {
|
||||
maker: {
|
||||
matchedBetId: null,
|
||||
shares,
|
||||
amount: buyAmount,
|
||||
state: newState,
|
||||
fees,
|
||||
timestamp,
|
||||
},
|
||||
taker: {
|
||||
matchedBetId: null,
|
||||
shares,
|
||||
amount: buyAmount,
|
||||
timestamp,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Fill from matchedBet.
|
||||
const matchRemaining = matchedBet.orderAmount - matchedBet.amount
|
||||
const shares = Math.min(
|
||||
amount /
|
||||
(outcome === 'YES' ? matchedBet.limitProb : 1 - matchedBet.limitProb),
|
||||
matchRemaining /
|
||||
(outcome === 'YES' ? 1 - matchedBet.limitProb : matchedBet.limitProb)
|
||||
)
|
||||
|
||||
const maker = {
|
||||
bet: matchedBet,
|
||||
matchedBetId: 'taker',
|
||||
amount:
|
||||
shares *
|
||||
(outcome === 'YES' ? 1 - matchedBet.limitProb : matchedBet.limitProb),
|
||||
shares,
|
||||
timestamp,
|
||||
}
|
||||
const taker = {
|
||||
matchedBetId: matchedBet.id,
|
||||
amount:
|
||||
shares *
|
||||
(outcome === 'YES' ? matchedBet.limitProb : 1 - matchedBet.limitProb),
|
||||
shares,
|
||||
timestamp,
|
||||
}
|
||||
return { maker, taker }
|
||||
}
|
||||
|
||||
export const computeFills = (
|
||||
outcome: 'YES' | 'NO',
|
||||
betAmount: number,
|
||||
state: CpmmState,
|
||||
limitProb: number | undefined,
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) => {
|
||||
if (isNaN(betAmount)) {
|
||||
throw new Error('Invalid bet amount: ${betAmount}')
|
||||
}
|
||||
if (isNaN(limitProb ?? 0)) {
|
||||
throw new Error('Invalid limitProb: ${limitProb}')
|
||||
}
|
||||
|
||||
const sortedBets = sortBy(
|
||||
unfilledBets.filter((bet) => bet.outcome !== outcome),
|
||||
(bet) => (outcome === 'YES' ? bet.limitProb : -bet.limitProb),
|
||||
(bet) => bet.createdTime
|
||||
)
|
||||
|
||||
const takers: fill[] = []
|
||||
const makers: {
|
||||
bet: LimitBet
|
||||
amount: number
|
||||
shares: number
|
||||
timestamp: number
|
||||
}[] = []
|
||||
const ordersToCancel: LimitBet[] = []
|
||||
|
||||
let amount = betAmount
|
||||
let cpmmState = { pool: state.pool, p: state.p }
|
||||
let totalFees = noFees
|
||||
const currentBalanceByUserId = { ...balanceByUserId }
|
||||
|
||||
let i = 0
|
||||
while (true) {
|
||||
const matchedBet: LimitBet | undefined = sortedBets[i]
|
||||
const fill = computeFill(amount, outcome, limitProb, cpmmState, matchedBet)
|
||||
if (!fill) break
|
||||
|
||||
const { taker, maker } = fill
|
||||
|
||||
if (maker.matchedBetId === null) {
|
||||
// Matched against pool.
|
||||
cpmmState = maker.state
|
||||
totalFees = addObjects(totalFees, maker.fees)
|
||||
takers.push(taker)
|
||||
} else {
|
||||
// Matched against bet.
|
||||
i++
|
||||
const { userId } = maker.bet
|
||||
const makerBalance = currentBalanceByUserId[userId]
|
||||
|
||||
if (floatingGreaterEqual(makerBalance, maker.amount)) {
|
||||
currentBalanceByUserId[userId] = makerBalance - maker.amount
|
||||
} else {
|
||||
// Insufficient balance. Cancel maker bet.
|
||||
ordersToCancel.push(maker.bet)
|
||||
continue
|
||||
}
|
||||
|
||||
takers.push(taker)
|
||||
makers.push(maker)
|
||||
}
|
||||
|
||||
amount -= taker.amount
|
||||
|
||||
if (floatingEqual(amount, 0)) break
|
||||
}
|
||||
|
||||
return { takers, makers, totalFees, cpmmState, ordersToCancel }
|
||||
}
|
||||
|
||||
export const getBinaryCpmmBetInfo = (
|
||||
outcome: 'YES' | 'NO',
|
||||
betAmount: number,
|
||||
contract: CPMMBinaryContract | PseudoNumericContract,
|
||||
limitProb: number | undefined,
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) => {
|
||||
const { pool, p } = contract
|
||||
const { takers, makers, cpmmState, totalFees, ordersToCancel } = computeFills(
|
||||
outcome,
|
||||
betAmount,
|
||||
{ pool, p },
|
||||
limitProb,
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
)
|
||||
const probBefore = getCpmmProbability(contract.pool, contract.p)
|
||||
const probAfter = getCpmmProbability(cpmmState.pool, cpmmState.p)
|
||||
|
||||
const takerAmount = sumBy(takers, 'amount')
|
||||
const takerShares = sumBy(takers, 'shares')
|
||||
const isFilled = floatingEqual(betAmount, takerAmount)
|
||||
|
||||
const newBet: CandidateBet = removeUndefinedProps({
|
||||
orderAmount: betAmount,
|
||||
amount: takerAmount,
|
||||
shares: takerShares,
|
||||
limitProb,
|
||||
isFilled,
|
||||
isCancelled: false,
|
||||
fills: takers,
|
||||
contractId: contract.id,
|
||||
outcome,
|
||||
probBefore,
|
||||
probAfter,
|
||||
loanAmount: 0,
|
||||
createdTime: Date.now(),
|
||||
fees: totalFees,
|
||||
})
|
||||
|
||||
const { liquidityFee } = totalFees
|
||||
const newTotalLiquidity = (contract.totalLiquidity ?? 0) + liquidityFee
|
||||
|
||||
return {
|
||||
newBet,
|
||||
newPool: cpmmState.pool,
|
||||
newP: cpmmState.p,
|
||||
newTotalLiquidity,
|
||||
makers,
|
||||
ordersToCancel,
|
||||
}
|
||||
}
|
||||
|
||||
export const getBinaryBetStats = (
|
||||
outcome: 'YES' | 'NO',
|
||||
betAmount: number,
|
||||
contract: CPMMBinaryContract | PseudoNumericContract,
|
||||
limitProb: number,
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number }
|
||||
) => {
|
||||
const { newBet } = getBinaryCpmmBetInfo(
|
||||
outcome,
|
||||
betAmount ?? 0,
|
||||
contract,
|
||||
limitProb,
|
||||
unfilledBets,
|
||||
balanceByUserId
|
||||
)
|
||||
const remainingMatched =
|
||||
((newBet.orderAmount ?? 0) - newBet.amount) /
|
||||
(outcome === 'YES' ? limitProb : 1 - limitProb)
|
||||
const currentPayout = newBet.shares + remainingMatched
|
||||
|
||||
const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
|
||||
|
||||
const totalFees = sum(Object.values(newBet.fees))
|
||||
|
||||
return { currentPayout, currentReturn, totalFees, newBet }
|
||||
}
|
||||
|
||||
export const getNewBinaryDpmBetInfo = (
|
||||
outcome: 'YES' | 'NO',
|
||||
amount: number,
|
||||
contract: DPMBinaryContract
|
||||
) => {
|
||||
const { YES: yesPool, NO: noPool } = contract.pool
|
||||
|
||||
const newPool =
|
||||
outcome === 'YES'
|
||||
? { YES: yesPool + amount, NO: noPool }
|
||||
: { YES: yesPool, NO: noPool + amount }
|
||||
|
||||
const shares = calculateDpmShares(contract.totalShares, amount, outcome)
|
||||
|
||||
const { YES: yesShares, NO: noShares } = contract.totalShares
|
||||
|
||||
const newTotalShares =
|
||||
outcome === 'YES'
|
||||
? { YES: yesShares + shares, NO: noShares }
|
||||
: { YES: yesShares, NO: noShares + shares }
|
||||
|
||||
const { YES: yesBets, NO: noBets } = contract.totalBets
|
||||
|
||||
const newTotalBets =
|
||||
outcome === 'YES'
|
||||
? { YES: yesBets + amount, NO: noBets }
|
||||
: { YES: yesBets, NO: noBets + amount }
|
||||
|
||||
const probBefore = getDpmProbability(contract.totalShares)
|
||||
const probAfter = getDpmProbability(newTotalShares)
|
||||
|
||||
const newBet: CandidateBet = {
|
||||
contractId: contract.id,
|
||||
amount,
|
||||
loanAmount: 0,
|
||||
shares,
|
||||
outcome,
|
||||
probBefore,
|
||||
probAfter,
|
||||
createdTime: Date.now(),
|
||||
fees: noFees,
|
||||
}
|
||||
|
||||
return { newBet, newPool, newTotalShares, newTotalBets }
|
||||
}
|
||||
|
||||
export const getNewMultiBetInfo = (
|
||||
outcome: string,
|
||||
amount: number,
|
||||
contract: DPMContract
|
||||
) => {
|
||||
const { pool, totalShares, totalBets } = contract
|
||||
|
||||
const prevOutcomePool = pool[outcome] ?? 0
|
||||
const newPool = { ...pool, [outcome]: prevOutcomePool + amount }
|
||||
|
||||
const shares = calculateDpmShares(contract.totalShares, amount, outcome)
|
||||
|
||||
const prevShares = totalShares[outcome] ?? 0
|
||||
const newTotalShares = { ...totalShares, [outcome]: prevShares + shares }
|
||||
|
||||
const prevTotalBets = totalBets[outcome] ?? 0
|
||||
const newTotalBets = { ...totalBets, [outcome]: prevTotalBets + amount }
|
||||
|
||||
const probBefore = getDpmOutcomeProbability(totalShares, outcome)
|
||||
const probAfter = getDpmOutcomeProbability(newTotalShares, outcome)
|
||||
|
||||
const newBet: CandidateBet = {
|
||||
contractId: contract.id,
|
||||
amount,
|
||||
loanAmount: 0,
|
||||
shares,
|
||||
outcome,
|
||||
probBefore,
|
||||
probAfter,
|
||||
createdTime: Date.now(),
|
||||
fees: noFees,
|
||||
}
|
||||
|
||||
return { newBet, newPool, newTotalShares, newTotalBets }
|
||||
}
|
||||
|
||||
export const getNumericBetsInfo = (
|
||||
value: number,
|
||||
outcome: string,
|
||||
amount: number,
|
||||
contract: NumericContract
|
||||
) => {
|
||||
const { pool, totalShares, totalBets } = contract
|
||||
|
||||
const bets = getNumericBets(contract, outcome, amount, NUMERIC_FIXED_VAR)
|
||||
|
||||
const allBetAmounts = Object.fromEntries(bets)
|
||||
const newTotalBets = addObjects(totalBets, allBetAmounts)
|
||||
const newPool = addObjects(pool, allBetAmounts)
|
||||
|
||||
const { shares, totalShares: newTotalShares } = calculateNumericDpmShares(
|
||||
contract.totalShares,
|
||||
bets
|
||||
)
|
||||
|
||||
const allOutcomeShares = Object.fromEntries(
|
||||
bets.map(([outcome], i) => [outcome, shares[i]])
|
||||
)
|
||||
|
||||
const probBefore = getDpmOutcomeProbability(totalShares, outcome)
|
||||
const probAfter = getDpmOutcomeProbability(newTotalShares, outcome)
|
||||
|
||||
const newBet: CandidateBet<NumericBet> = {
|
||||
contractId: contract.id,
|
||||
value,
|
||||
amount,
|
||||
allBetAmounts,
|
||||
shares: shares.find((s, i) => bets[i][0] === outcome) ?? 0,
|
||||
allOutcomeShares,
|
||||
outcome,
|
||||
probBefore,
|
||||
probAfter,
|
||||
createdTime: Date.now(),
|
||||
fees: noFees,
|
||||
}
|
||||
|
||||
return { newBet, newPool, newTotalShares, newTotalBets }
|
||||
}
|
206
common/new-contract.ts
Normal file
206
common/new-contract.ts
Normal file
|
@ -0,0 +1,206 @@
|
|||
import { range } from 'lodash'
|
||||
import {
|
||||
Binary,
|
||||
Contract,
|
||||
CPMM,
|
||||
DPM,
|
||||
FreeResponse,
|
||||
MultipleChoice,
|
||||
Numeric,
|
||||
outcomeType,
|
||||
PseudoNumeric,
|
||||
visibility,
|
||||
} from './contract'
|
||||
import { User } from './user'
|
||||
import { removeUndefinedProps } from './util/object'
|
||||
import { JSONContent } from '@tiptap/core'
|
||||
|
||||
export function getNewContract(
|
||||
id: string,
|
||||
slug: string,
|
||||
creator: User,
|
||||
question: string,
|
||||
outcomeType: outcomeType,
|
||||
description: JSONContent,
|
||||
initialProb: number,
|
||||
ante: number,
|
||||
closeTime: number,
|
||||
extraTags: string[],
|
||||
|
||||
// used for numeric markets
|
||||
bucketCount: number,
|
||||
min: number,
|
||||
max: number,
|
||||
isLogScale: boolean,
|
||||
|
||||
// for multiple choice
|
||||
answers: string[],
|
||||
visibility: visibility
|
||||
) {
|
||||
const propsByOutcomeType =
|
||||
outcomeType === 'BINARY'
|
||||
? getBinaryCpmmProps(initialProb, ante) // getBinaryDpmProps(initialProb, ante)
|
||||
: outcomeType === 'PSEUDO_NUMERIC'
|
||||
? getPseudoNumericCpmmProps(initialProb, ante, min, max, isLogScale)
|
||||
: outcomeType === 'NUMERIC'
|
||||
? getNumericProps(ante, bucketCount, min, max)
|
||||
: outcomeType === 'MULTIPLE_CHOICE'
|
||||
? getMultipleChoiceProps(ante, answers)
|
||||
: getFreeAnswerProps(ante)
|
||||
|
||||
const contract: Contract = removeUndefinedProps({
|
||||
id,
|
||||
slug,
|
||||
...propsByOutcomeType,
|
||||
|
||||
creatorId: creator.id,
|
||||
creatorName: creator.name,
|
||||
creatorUsername: creator.username,
|
||||
creatorAvatarUrl: creator.avatarUrl,
|
||||
|
||||
question: question.trim(),
|
||||
description,
|
||||
tags: [],
|
||||
lowercaseTags: [],
|
||||
visibility,
|
||||
unlistedById: visibility === 'unlisted' ? creator.id : undefined,
|
||||
isResolved: false,
|
||||
createdTime: Date.now(),
|
||||
closeTime,
|
||||
|
||||
volume: 0,
|
||||
volume24Hours: 0,
|
||||
volume7Days: 0,
|
||||
elasticity: propsByOutcomeType.mechanism === 'cpmm-1' ? 0.38 : 0.75,
|
||||
|
||||
collectedFees: {
|
||||
creatorFee: 0,
|
||||
liquidityFee: 0,
|
||||
platformFee: 0,
|
||||
},
|
||||
})
|
||||
|
||||
return contract as Contract
|
||||
}
|
||||
|
||||
/*
|
||||
import { PHANTOM_ANTE } from './antes'
|
||||
import { calcDpmInitialPool } from './calculate-dpm'
|
||||
const getBinaryDpmProps = (initialProb: number, ante: number) => {
|
||||
const { sharesYes, sharesNo, poolYes, poolNo, phantomYes, phantomNo } =
|
||||
calcDpmInitialPool(initialProb, ante, PHANTOM_ANTE)
|
||||
|
||||
const system: DPM & Binary = {
|
||||
mechanism: 'dpm-2',
|
||||
outcomeType: 'BINARY',
|
||||
initialProbability: initialProb / 100,
|
||||
phantomShares: { YES: phantomYes, NO: phantomNo },
|
||||
pool: { YES: poolYes, NO: poolNo },
|
||||
totalShares: { YES: sharesYes, NO: sharesNo },
|
||||
totalBets: { YES: poolYes, NO: poolNo },
|
||||
}
|
||||
|
||||
return system
|
||||
}
|
||||
*/
|
||||
|
||||
const getBinaryCpmmProps = (initialProb: number, ante: number) => {
|
||||
const pool = { YES: ante, NO: ante }
|
||||
const p = initialProb / 100
|
||||
|
||||
const system: CPMM & Binary = {
|
||||
mechanism: 'cpmm-1',
|
||||
outcomeType: 'BINARY',
|
||||
totalLiquidity: ante,
|
||||
subsidyPool: 0,
|
||||
initialProbability: p,
|
||||
p,
|
||||
pool: pool,
|
||||
prob: initialProb,
|
||||
probChanges: { day: 0, week: 0, month: 0 },
|
||||
}
|
||||
|
||||
return system
|
||||
}
|
||||
|
||||
const getPseudoNumericCpmmProps = (
|
||||
initialProb: number,
|
||||
ante: number,
|
||||
min: number,
|
||||
max: number,
|
||||
isLogScale: boolean
|
||||
) => {
|
||||
const system: CPMM & PseudoNumeric = {
|
||||
...getBinaryCpmmProps(initialProb, ante),
|
||||
outcomeType: 'PSEUDO_NUMERIC',
|
||||
min,
|
||||
max,
|
||||
isLogScale,
|
||||
}
|
||||
|
||||
return system
|
||||
}
|
||||
|
||||
const getFreeAnswerProps = (ante: number) => {
|
||||
const system: DPM & FreeResponse = {
|
||||
mechanism: 'dpm-2',
|
||||
outcomeType: 'FREE_RESPONSE',
|
||||
pool: { '0': ante },
|
||||
totalShares: { '0': ante },
|
||||
totalBets: { '0': ante },
|
||||
answers: [],
|
||||
}
|
||||
|
||||
return system
|
||||
}
|
||||
|
||||
const getMultipleChoiceProps = (ante: number, answers: string[]) => {
|
||||
const numAnswers = answers.length
|
||||
const betAnte = ante / numAnswers
|
||||
const betShares = Math.sqrt(ante ** 2 / numAnswers)
|
||||
|
||||
const defaultValues = (x: any) =>
|
||||
Object.fromEntries(range(0, numAnswers).map((k) => [k, x]))
|
||||
|
||||
const system: DPM & MultipleChoice = {
|
||||
mechanism: 'dpm-2',
|
||||
outcomeType: 'MULTIPLE_CHOICE',
|
||||
pool: defaultValues(betAnte),
|
||||
totalShares: defaultValues(betShares),
|
||||
totalBets: defaultValues(betAnte),
|
||||
answers: [],
|
||||
}
|
||||
|
||||
return system
|
||||
}
|
||||
|
||||
const getNumericProps = (
|
||||
ante: number,
|
||||
bucketCount: number,
|
||||
min: number,
|
||||
max: number
|
||||
) => {
|
||||
const buckets = range(0, bucketCount).map((i) => i.toString())
|
||||
|
||||
const betAnte = ante / bucketCount
|
||||
const pool = Object.fromEntries(buckets.map((answer) => [answer, betAnte]))
|
||||
const totalBets = pool
|
||||
|
||||
const betShares = Math.sqrt(ante ** 2 / bucketCount)
|
||||
const totalShares = Object.fromEntries(
|
||||
buckets.map((answer) => [answer, betShares])
|
||||
)
|
||||
|
||||
const system: DPM & Numeric = {
|
||||
mechanism: 'dpm-2',
|
||||
outcomeType: 'NUMERIC',
|
||||
pool,
|
||||
totalBets,
|
||||
totalShares,
|
||||
bucketCount,
|
||||
min,
|
||||
max,
|
||||
}
|
||||
|
||||
return system
|
||||
}
|
270
common/notification.ts
Normal file
270
common/notification.ts
Normal file
|
@ -0,0 +1,270 @@
|
|||
import { notification_preference } from './user-notification-preferences'
|
||||
|
||||
export type Notification = {
|
||||
id: string
|
||||
userId: string
|
||||
reasonText?: string
|
||||
reason?: notification_reason_types | notification_preference
|
||||
createdTime: number
|
||||
viewTime?: number
|
||||
isSeen: boolean
|
||||
|
||||
sourceId?: string
|
||||
sourceType?: notification_source_types
|
||||
sourceUpdateType?: notification_source_update_types
|
||||
sourceContractId?: string
|
||||
sourceUserName?: string
|
||||
sourceUserUsername?: string
|
||||
sourceUserAvatarUrl?: string
|
||||
sourceText?: string
|
||||
data?: { [key: string]: any }
|
||||
|
||||
sourceContractTitle?: string
|
||||
sourceContractCreatorUsername?: string
|
||||
sourceContractSlug?: string
|
||||
|
||||
sourceSlug?: string
|
||||
sourceTitle?: string
|
||||
|
||||
isSeenOnHref?: string
|
||||
}
|
||||
|
||||
export type notification_source_types =
|
||||
| 'contract'
|
||||
| 'comment'
|
||||
| 'bet'
|
||||
| 'answer'
|
||||
| 'liquidity'
|
||||
| 'follow'
|
||||
| 'tip'
|
||||
| 'admin_message'
|
||||
| 'group'
|
||||
| 'user'
|
||||
| 'bonus'
|
||||
| 'challenge'
|
||||
| 'betting_streak_bonus'
|
||||
| 'loan'
|
||||
| 'like'
|
||||
| 'tip_and_like'
|
||||
| 'badge'
|
||||
|
||||
export type notification_source_update_types =
|
||||
| 'created'
|
||||
| 'updated'
|
||||
| 'resolved'
|
||||
| 'deleted'
|
||||
| 'closed'
|
||||
|
||||
/* Optional - if possible use a notification_preference */
|
||||
export type notification_reason_types =
|
||||
| 'tagged_user'
|
||||
| 'on_new_follow'
|
||||
| 'contract_from_followed_user'
|
||||
| 'you_referred_user'
|
||||
| 'user_joined_to_bet_on_your_market'
|
||||
| 'unique_bettors_on_your_contract'
|
||||
| 'tip_received'
|
||||
| 'bet_fill'
|
||||
| 'user_joined_from_your_group_invite'
|
||||
| 'challenge_accepted'
|
||||
| 'betting_streak_incremented'
|
||||
| 'loan_income'
|
||||
| 'liked_and_tipped_your_contract'
|
||||
| 'comment_on_your_contract'
|
||||
| 'answer_on_your_contract'
|
||||
| 'comment_on_contract_you_follow'
|
||||
| 'answer_on_contract_you_follow'
|
||||
| 'update_on_contract_you_follow'
|
||||
| 'resolution_on_contract_you_follow'
|
||||
| 'comment_on_contract_with_users_shares_in'
|
||||
| 'answer_on_contract_with_users_shares_in'
|
||||
| 'update_on_contract_with_users_shares_in'
|
||||
| 'resolution_on_contract_with_users_shares_in'
|
||||
| 'comment_on_contract_with_users_answer'
|
||||
| 'update_on_contract_with_users_answer'
|
||||
| 'resolution_on_contract_with_users_answer'
|
||||
| 'answer_on_contract_with_users_answer'
|
||||
| 'comment_on_contract_with_users_comment'
|
||||
| 'answer_on_contract_with_users_comment'
|
||||
| 'update_on_contract_with_users_comment'
|
||||
| 'resolution_on_contract_with_users_comment'
|
||||
| 'reply_to_users_answer'
|
||||
| 'reply_to_users_comment'
|
||||
| 'your_contract_closed'
|
||||
| 'subsidized_your_market'
|
||||
|
||||
type notification_descriptions = {
|
||||
[key in notification_preference]: {
|
||||
simple: string
|
||||
detailed: string
|
||||
necessary?: boolean
|
||||
}
|
||||
}
|
||||
export const NOTIFICATION_DESCRIPTIONS: notification_descriptions = {
|
||||
all_answers_on_my_markets: {
|
||||
simple: 'Answers on your markets',
|
||||
detailed: 'Answers on your own markets',
|
||||
},
|
||||
all_comments_on_my_markets: {
|
||||
simple: 'Comments on your markets',
|
||||
detailed: 'Comments on your own markets',
|
||||
},
|
||||
answers_by_followed_users_on_watched_markets: {
|
||||
simple: 'Only answers by users you follow',
|
||||
detailed: "Only answers by users you follow on markets you're watching",
|
||||
},
|
||||
answers_by_market_creator_on_watched_markets: {
|
||||
simple: 'Only answers by market creator',
|
||||
detailed: "Only answers by market creator on markets you're watching",
|
||||
},
|
||||
betting_streaks: {
|
||||
simple: `For prediction streaks`,
|
||||
detailed: `Bonuses for predictions made over consecutive days (Prediction streaks)})`,
|
||||
},
|
||||
comments_by_followed_users_on_watched_markets: {
|
||||
simple: 'Only comments by users you follow',
|
||||
detailed:
|
||||
'Only comments by users that you follow on markets that you watch',
|
||||
},
|
||||
contract_from_followed_user: {
|
||||
simple: 'New markets from users you follow',
|
||||
detailed: 'New markets from users you follow',
|
||||
},
|
||||
limit_order_fills: {
|
||||
simple: 'Limit order fills',
|
||||
detailed: 'When your limit order is filled by another user',
|
||||
},
|
||||
loan_income: {
|
||||
simple: 'Automatic loans from your predictions in unresolved markets',
|
||||
detailed:
|
||||
'Automatic loans from your predictions that are locked in unresolved markets',
|
||||
},
|
||||
market_updates_on_watched_markets: {
|
||||
simple: 'All creator updates',
|
||||
detailed: 'All market updates made by the creator',
|
||||
},
|
||||
market_updates_on_watched_markets_with_shares_in: {
|
||||
simple: "Only creator updates on markets that you're invested in",
|
||||
detailed:
|
||||
"Only updates made by the creator on markets that you're invested in",
|
||||
},
|
||||
on_new_follow: {
|
||||
simple: 'A user followed you',
|
||||
detailed: 'A user followed you',
|
||||
},
|
||||
onboarding_flow: {
|
||||
simple: 'Emails to help you get started using Manifold',
|
||||
detailed: 'Emails to help you learn how to use Manifold',
|
||||
},
|
||||
probability_updates_on_watched_markets: {
|
||||
simple: 'Large changes in probability on markets that you watch',
|
||||
detailed: 'Large changes in probability on markets that you watch',
|
||||
},
|
||||
profit_loss_updates: {
|
||||
simple: 'Weekly portfolio updates',
|
||||
detailed: 'Weekly portfolio updates',
|
||||
},
|
||||
referral_bonuses: {
|
||||
simple: 'For referring new users',
|
||||
detailed: 'Bonuses you receive from referring a new user',
|
||||
},
|
||||
resolutions_on_watched_markets: {
|
||||
simple: 'All market resolutions',
|
||||
detailed: "All resolutions on markets that you're watching",
|
||||
},
|
||||
resolutions_on_watched_markets_with_shares_in: {
|
||||
simple: "Only market resolutions that you're invested in",
|
||||
detailed:
|
||||
"Only resolutions of markets you're watching and that you're invested in",
|
||||
},
|
||||
subsidized_your_market: {
|
||||
simple: 'Your market was subsidized',
|
||||
detailed: 'When someone subsidizes your market',
|
||||
},
|
||||
tagged_user: {
|
||||
simple: 'A user tagged you',
|
||||
detailed: 'When another use tags you',
|
||||
},
|
||||
thank_you_for_purchases: {
|
||||
simple: 'Thank you notes for your purchases',
|
||||
detailed: 'Thank you notes for your purchases',
|
||||
},
|
||||
tipped_comments_on_watched_markets: {
|
||||
simple: 'Only highly tipped comments on markets that you watch',
|
||||
detailed: 'Only highly tipped comments on markets that you watch',
|
||||
},
|
||||
tips_on_your_comments: {
|
||||
simple: 'Tips on your comments',
|
||||
detailed: 'Tips on your comments',
|
||||
},
|
||||
tips_on_your_markets: {
|
||||
simple: 'Tips/Likes on your markets',
|
||||
detailed: 'Tips/Likes on your markets',
|
||||
},
|
||||
trending_markets: {
|
||||
simple: 'Weekly interesting markets',
|
||||
detailed: 'Weekly interesting markets',
|
||||
},
|
||||
unique_bettors_on_your_contract: {
|
||||
simple: 'For unique predictors on your markets',
|
||||
detailed: 'Bonuses for unique predictors on your markets',
|
||||
},
|
||||
your_contract_closed: {
|
||||
simple: 'Your market has closed and you need to resolve it (necessary)',
|
||||
detailed: 'Your market has closed and you need to resolve it (necessary)',
|
||||
necessary: true,
|
||||
},
|
||||
all_comments_on_watched_markets: {
|
||||
simple: 'All new comments',
|
||||
detailed: 'All new comments on markets you follow',
|
||||
},
|
||||
all_comments_on_contracts_with_shares_in_on_watched_markets: {
|
||||
simple: `Only on markets you're invested in`,
|
||||
detailed: `Comments on markets that you're watching and you're invested in`,
|
||||
},
|
||||
all_replies_to_my_comments_on_watched_markets: {
|
||||
simple: 'Only replies to your comments',
|
||||
detailed: "Only replies to your comments on markets you're watching",
|
||||
},
|
||||
all_replies_to_my_answers_on_watched_markets: {
|
||||
simple: 'Only replies to your answers',
|
||||
detailed: "Only replies to your answers on markets you're watching",
|
||||
},
|
||||
all_answers_on_watched_markets: {
|
||||
simple: 'All new answers',
|
||||
detailed: "All new answers on markets you're watching",
|
||||
},
|
||||
all_answers_on_contracts_with_shares_in_on_watched_markets: {
|
||||
simple: `Only on markets you're invested in`,
|
||||
detailed: `Answers on markets that you're watching and that you're invested in`,
|
||||
},
|
||||
badges_awarded: {
|
||||
simple: 'New badges awarded',
|
||||
detailed: 'New badges you have earned',
|
||||
},
|
||||
opt_out_all: {
|
||||
simple: 'Opt out of all notifications (excludes when your markets close)',
|
||||
detailed:
|
||||
'Opt out of all notifications excluding your own market closure notifications',
|
||||
},
|
||||
}
|
||||
|
||||
export type BettingStreakData = {
|
||||
streak: number
|
||||
bonusAmount: number
|
||||
}
|
||||
|
||||
export type BetFillData = {
|
||||
betOutcome: string
|
||||
creatorOutcome: string
|
||||
probability: number
|
||||
fillAmount: number
|
||||
limitOrderTotal?: number
|
||||
limitOrderRemaining?: number
|
||||
}
|
||||
|
||||
export type ContractResolutionData = {
|
||||
outcome: string
|
||||
userPayout: number
|
||||
userInvestment: number
|
||||
}
|
5
common/numeric-constants.ts
Normal file
5
common/numeric-constants.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export const NUMERIC_BUCKET_COUNT = 200
|
||||
export const NUMERIC_FIXED_VAR = 0.005
|
||||
|
||||
export const NUMERIC_GRAPH_COLOR = '#5fa5f9'
|
||||
export const NUMERIC_TEXT_COLOR = 'text-blue-500'
|
23
common/package.json
Normal file
23
common/package.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "common",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"verify": "(cd .. && yarn verify)",
|
||||
"verify:dir": "npx eslint . --max-warnings 0"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"dependencies": {
|
||||
"@tiptap/core": "2.0.0-beta.199",
|
||||
"@tiptap/extension-image": "2.0.0-beta.199",
|
||||
"@tiptap/extension-link": "2.0.0-beta.199",
|
||||
"@tiptap/extension-mention": "2.0.0-beta.199",
|
||||
"@tiptap/html": "2.0.0-beta.199",
|
||||
"@tiptap/starter-kit": "2.0.0-beta.199",
|
||||
"@tiptap/suggestion": "2.0.0-beta.199",
|
||||
"lodash": "4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "4.14.178"
|
||||
}
|
||||
}
|
191
common/payouts-dpm.ts
Normal file
191
common/payouts-dpm.ts
Normal file
|
@ -0,0 +1,191 @@
|
|||
import { sum, groupBy, sumBy, mapValues } from 'lodash'
|
||||
|
||||
import { Bet, NumericBet } from './bet'
|
||||
import { deductDpmFees, getDpmProbability } from './calculate-dpm'
|
||||
import {
|
||||
DPMContract,
|
||||
FreeResponseContract,
|
||||
MultipleChoiceContract,
|
||||
} from './contract'
|
||||
import { DPM_CREATOR_FEE, DPM_FEES, DPM_PLATFORM_FEE } from './fees'
|
||||
import { addObjects } from './util/object'
|
||||
|
||||
export const getDpmCancelPayouts = (contract: DPMContract, bets: Bet[]) => {
|
||||
const { pool } = contract
|
||||
const poolTotal = sum(Object.values(pool))
|
||||
|
||||
const betSum = sumBy(bets, (b) => b.amount)
|
||||
|
||||
const payouts = bets.map((bet) => ({
|
||||
userId: bet.userId,
|
||||
payout: (bet.amount / betSum) * poolTotal,
|
||||
}))
|
||||
|
||||
return {
|
||||
payouts,
|
||||
creatorPayout: 0,
|
||||
liquidityPayouts: [],
|
||||
collectedFees: contract.collectedFees,
|
||||
}
|
||||
}
|
||||
|
||||
export const getDpmStandardPayouts = (
|
||||
outcome: string,
|
||||
contract: DPMContract,
|
||||
bets: Bet[]
|
||||
) => {
|
||||
const winningBets = bets.filter((bet) => bet.outcome === outcome)
|
||||
|
||||
const poolTotal = sum(Object.values(contract.pool))
|
||||
const totalShares = sumBy(winningBets, (b) => b.shares)
|
||||
|
||||
const payouts = winningBets.map(({ userId, amount, shares }) => {
|
||||
const winnings = (shares / totalShares) * poolTotal
|
||||
const profit = winnings - amount
|
||||
|
||||
// profit can be negative if using phantom shares
|
||||
const payout = amount + (1 - DPM_FEES) * Math.max(0, profit)
|
||||
return { userId, profit, payout }
|
||||
})
|
||||
|
||||
const profits = sumBy(payouts, (po) => Math.max(0, po.profit))
|
||||
const creatorFee = DPM_CREATOR_FEE * profits
|
||||
const platformFee = DPM_PLATFORM_FEE * profits
|
||||
const collectedFees = addObjects(contract.collectedFees, {
|
||||
creatorFee,
|
||||
platformFee,
|
||||
liquidityFee: 0,
|
||||
})
|
||||
|
||||
return {
|
||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||
creatorPayout: creatorFee,
|
||||
liquidityPayouts: [],
|
||||
collectedFees,
|
||||
}
|
||||
}
|
||||
|
||||
export const getNumericDpmPayouts = (
|
||||
outcome: string,
|
||||
contract: DPMContract,
|
||||
bets: NumericBet[]
|
||||
) => {
|
||||
const totalShares = sumBy(bets, (bet) => bet.allOutcomeShares[outcome] ?? 0)
|
||||
const winningBets = bets.filter((bet) => !!bet.allOutcomeShares[outcome])
|
||||
|
||||
const poolTotal = sum(Object.values(contract.pool))
|
||||
|
||||
const payouts = winningBets.map(
|
||||
({ userId, allBetAmounts, allOutcomeShares }) => {
|
||||
const shares = allOutcomeShares[outcome] ?? 0
|
||||
const winnings = (shares / totalShares) * poolTotal
|
||||
|
||||
const amount = allBetAmounts[outcome] ?? 0
|
||||
const profit = winnings - amount
|
||||
|
||||
// profit can be negative if using phantom shares
|
||||
const payout = amount + (1 - DPM_FEES) * Math.max(0, profit)
|
||||
return { userId, profit, payout }
|
||||
}
|
||||
)
|
||||
|
||||
const profits = sumBy(payouts, (po) => Math.max(0, po.profit))
|
||||
const creatorFee = DPM_CREATOR_FEE * profits
|
||||
const platformFee = DPM_PLATFORM_FEE * profits
|
||||
const collectedFees = addObjects(contract.collectedFees, {
|
||||
creatorFee,
|
||||
platformFee,
|
||||
liquidityFee: 0,
|
||||
})
|
||||
|
||||
return {
|
||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||
creatorPayout: creatorFee,
|
||||
liquidityPayouts: [],
|
||||
collectedFees,
|
||||
}
|
||||
}
|
||||
|
||||
export const getDpmMktPayouts = (
|
||||
contract: DPMContract,
|
||||
bets: Bet[],
|
||||
resolutionProbability?: number
|
||||
) => {
|
||||
const p =
|
||||
resolutionProbability === undefined
|
||||
? getDpmProbability(contract.totalShares)
|
||||
: resolutionProbability
|
||||
|
||||
const weightedShareTotal = sumBy(bets, (b) =>
|
||||
b.outcome === 'YES' ? p * b.shares : (1 - p) * b.shares
|
||||
)
|
||||
|
||||
const pool = contract.pool.YES + contract.pool.NO
|
||||
|
||||
const payouts = bets.map(({ userId, outcome, amount, shares }) => {
|
||||
const betP = outcome === 'YES' ? p : 1 - p
|
||||
const winnings = ((betP * shares) / weightedShareTotal) * pool
|
||||
const profit = winnings - amount
|
||||
const payout = deductDpmFees(amount, winnings)
|
||||
return { userId, profit, payout }
|
||||
})
|
||||
|
||||
const profits = sumBy(payouts, (po) => Math.max(0, po.profit))
|
||||
|
||||
const creatorFee = DPM_CREATOR_FEE * profits
|
||||
const platformFee = DPM_PLATFORM_FEE * profits
|
||||
const collectedFees = addObjects(contract.collectedFees, {
|
||||
creatorFee,
|
||||
platformFee,
|
||||
liquidityFee: 0,
|
||||
})
|
||||
|
||||
return {
|
||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||
creatorPayout: creatorFee,
|
||||
liquidityPayouts: [],
|
||||
collectedFees,
|
||||
}
|
||||
}
|
||||
|
||||
export const getPayoutsMultiOutcome = (
|
||||
resolutions: { [outcome: string]: number },
|
||||
contract: FreeResponseContract | MultipleChoiceContract,
|
||||
bets: Bet[]
|
||||
) => {
|
||||
const poolTotal = sum(Object.values(contract.pool))
|
||||
const winningBets = bets.filter((bet) => resolutions[bet.outcome])
|
||||
|
||||
const betsByOutcome = groupBy(winningBets, (bet) => bet.outcome)
|
||||
const sharesByOutcome = mapValues(betsByOutcome, (bets) =>
|
||||
sumBy(bets, (bet) => bet.shares)
|
||||
)
|
||||
|
||||
const probTotal = sum(Object.values(resolutions))
|
||||
|
||||
const payouts = winningBets.map(({ userId, outcome, amount, shares }) => {
|
||||
const prob = resolutions[outcome] / probTotal
|
||||
const winnings = (shares / sharesByOutcome[outcome]) * prob * poolTotal
|
||||
const profit = winnings - amount
|
||||
|
||||
const payout = amount + (1 - DPM_FEES) * profit
|
||||
return { userId, profit, payout }
|
||||
})
|
||||
|
||||
const profits = sumBy(payouts, (po) => po.profit)
|
||||
|
||||
const creatorFee = DPM_CREATOR_FEE * profits
|
||||
const platformFee = DPM_PLATFORM_FEE * profits
|
||||
const collectedFees = addObjects(contract.collectedFees, {
|
||||
creatorFee,
|
||||
platformFee,
|
||||
liquidityFee: 0,
|
||||
})
|
||||
|
||||
return {
|
||||
payouts: payouts.map(({ userId, payout }) => ({ userId, payout })),
|
||||
creatorPayout: creatorFee,
|
||||
liquidityPayouts: [],
|
||||
collectedFees,
|
||||
}
|
||||
}
|
108
common/payouts-fixed.ts
Normal file
108
common/payouts-fixed.ts
Normal file
|
@ -0,0 +1,108 @@
|
|||
import { Bet } from './bet'
|
||||
import { getProbability } from './calculate'
|
||||
import { getCpmmLiquidityPoolWeights } from './calculate-cpmm'
|
||||
import { CPMMContract } from './contract'
|
||||
import { noFees } from './fees'
|
||||
import { LiquidityProvision } from './liquidity-provision'
|
||||
|
||||
export const getFixedCancelPayouts = (
|
||||
bets: Bet[],
|
||||
liquidities: LiquidityProvision[]
|
||||
) => {
|
||||
const liquidityPayouts = liquidities.map((lp) => ({
|
||||
userId: lp.userId,
|
||||
payout: lp.amount,
|
||||
}))
|
||||
|
||||
const payouts = bets
|
||||
.filter((b) => !b.isAnte && !b.isLiquidityProvision)
|
||||
.map((bet) => ({
|
||||
userId: bet.userId,
|
||||
payout: bet.amount,
|
||||
}))
|
||||
|
||||
const creatorPayout = 0
|
||||
|
||||
return { payouts, creatorPayout, liquidityPayouts, collectedFees: noFees }
|
||||
}
|
||||
|
||||
export const getStandardFixedPayouts = (
|
||||
outcome: string,
|
||||
contract: CPMMContract,
|
||||
bets: Bet[],
|
||||
liquidities: LiquidityProvision[]
|
||||
) => {
|
||||
const winningBets = bets.filter((bet) => bet.outcome === outcome)
|
||||
|
||||
const payouts = winningBets.map(({ userId, shares }) => ({
|
||||
userId,
|
||||
payout: shares,
|
||||
}))
|
||||
|
||||
const { collectedFees } = contract
|
||||
const creatorPayout = collectedFees.creatorFee
|
||||
const liquidityPayouts = getLiquidityPoolPayouts(
|
||||
contract,
|
||||
outcome,
|
||||
liquidities
|
||||
)
|
||||
|
||||
return { payouts, creatorPayout, liquidityPayouts, collectedFees }
|
||||
}
|
||||
|
||||
export const getLiquidityPoolPayouts = (
|
||||
contract: CPMMContract,
|
||||
outcome: string,
|
||||
liquidities: LiquidityProvision[]
|
||||
) => {
|
||||
const { pool, subsidyPool } = contract
|
||||
const finalPool = pool[outcome] + (subsidyPool ?? 0)
|
||||
if (finalPool < 1e-3) return []
|
||||
|
||||
const weights = getCpmmLiquidityPoolWeights(liquidities)
|
||||
|
||||
return Object.entries(weights).map(([providerId, weight]) => ({
|
||||
userId: providerId,
|
||||
payout: weight * finalPool,
|
||||
}))
|
||||
}
|
||||
|
||||
export const getMktFixedPayouts = (
|
||||
contract: CPMMContract,
|
||||
bets: Bet[],
|
||||
liquidities: LiquidityProvision[],
|
||||
resolutionProbability?: number
|
||||
) => {
|
||||
const p =
|
||||
resolutionProbability === undefined
|
||||
? getProbability(contract)
|
||||
: resolutionProbability
|
||||
|
||||
const payouts = bets.map(({ userId, outcome, shares }) => {
|
||||
const betP = outcome === 'YES' ? p : 1 - p
|
||||
return { userId, payout: betP * shares }
|
||||
})
|
||||
|
||||
const { collectedFees } = contract
|
||||
const creatorPayout = collectedFees.creatorFee
|
||||
const liquidityPayouts = getLiquidityPoolProbPayouts(contract, p, liquidities)
|
||||
|
||||
return { payouts, creatorPayout, liquidityPayouts, collectedFees }
|
||||
}
|
||||
|
||||
export const getLiquidityPoolProbPayouts = (
|
||||
contract: CPMMContract,
|
||||
p: number,
|
||||
liquidities: LiquidityProvision[]
|
||||
) => {
|
||||
const { pool, subsidyPool } = contract
|
||||
const finalPool = p * pool.YES + (1 - p) * pool.NO + (subsidyPool ?? 0)
|
||||
if (finalPool < 1e-3) return []
|
||||
|
||||
const weights = getCpmmLiquidityPoolWeights(liquidities)
|
||||
|
||||
return Object.entries(weights).map(([providerId, weight]) => ({
|
||||
userId: providerId,
|
||||
payout: weight * finalPool,
|
||||
}))
|
||||
}
|
143
common/payouts.ts
Normal file
143
common/payouts.ts
Normal file
|
@ -0,0 +1,143 @@
|
|||
import { sumBy, groupBy, mapValues } from 'lodash'
|
||||
|
||||
import { Bet, NumericBet } from './bet'
|
||||
import {
|
||||
Contract,
|
||||
CPMMBinaryContract,
|
||||
DPMContract,
|
||||
PseudoNumericContract,
|
||||
} from './contract'
|
||||
import { Fees } from './fees'
|
||||
import { LiquidityProvision } from './liquidity-provision'
|
||||
import {
|
||||
getDpmCancelPayouts,
|
||||
getDpmMktPayouts,
|
||||
getDpmStandardPayouts,
|
||||
getNumericDpmPayouts,
|
||||
getPayoutsMultiOutcome,
|
||||
} from './payouts-dpm'
|
||||
import {
|
||||
getFixedCancelPayouts,
|
||||
getMktFixedPayouts,
|
||||
getStandardFixedPayouts,
|
||||
} from './payouts-fixed'
|
||||
|
||||
export type Payout = {
|
||||
userId: string
|
||||
payout: number
|
||||
}
|
||||
|
||||
export const getLoanPayouts = (bets: Bet[]): Payout[] => {
|
||||
const betsWithLoans = bets.filter((bet) => bet.loanAmount)
|
||||
const betsByUser = groupBy(betsWithLoans, (bet) => bet.userId)
|
||||
const loansByUser = mapValues(betsByUser, (bets) =>
|
||||
sumBy(bets, (bet) => -(bet.loanAmount ?? 0))
|
||||
)
|
||||
return Object.entries(loansByUser).map(([userId, payout]) => ({
|
||||
userId,
|
||||
payout,
|
||||
}))
|
||||
}
|
||||
|
||||
export const groupPayoutsByUser = (payouts: Payout[]) => {
|
||||
const groups = groupBy(payouts, (payout) => payout.userId)
|
||||
return mapValues(groups, (group) => sumBy(group, (g) => g.payout))
|
||||
}
|
||||
|
||||
export type PayoutInfo = {
|
||||
payouts: Payout[]
|
||||
creatorPayout: number
|
||||
liquidityPayouts: Payout[]
|
||||
collectedFees: Fees
|
||||
}
|
||||
|
||||
export const getPayouts = (
|
||||
outcome: string | undefined,
|
||||
contract: Contract,
|
||||
bets: Bet[],
|
||||
liquidities: LiquidityProvision[],
|
||||
resolutions?: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
resolutionProbability?: number
|
||||
): PayoutInfo => {
|
||||
if (
|
||||
contract.mechanism === 'cpmm-1' &&
|
||||
(contract.outcomeType === 'BINARY' ||
|
||||
contract.outcomeType === 'PSEUDO_NUMERIC')
|
||||
) {
|
||||
return getFixedPayouts(
|
||||
outcome,
|
||||
contract,
|
||||
bets,
|
||||
liquidities,
|
||||
resolutionProbability
|
||||
)
|
||||
}
|
||||
return getDpmPayouts(
|
||||
outcome,
|
||||
contract,
|
||||
bets,
|
||||
resolutions,
|
||||
resolutionProbability
|
||||
)
|
||||
}
|
||||
|
||||
export const getFixedPayouts = (
|
||||
outcome: string | undefined,
|
||||
contract: CPMMBinaryContract | PseudoNumericContract,
|
||||
bets: Bet[],
|
||||
liquidities: LiquidityProvision[],
|
||||
resolutionProbability?: number
|
||||
) => {
|
||||
switch (outcome) {
|
||||
case 'YES':
|
||||
case 'NO':
|
||||
return getStandardFixedPayouts(outcome, contract, bets, liquidities)
|
||||
case 'MKT':
|
||||
return getMktFixedPayouts(
|
||||
contract,
|
||||
bets,
|
||||
liquidities,
|
||||
resolutionProbability
|
||||
)
|
||||
default:
|
||||
case 'CANCEL':
|
||||
return getFixedCancelPayouts(bets, liquidities)
|
||||
}
|
||||
}
|
||||
|
||||
export const getDpmPayouts = (
|
||||
outcome: string | undefined,
|
||||
contract: DPMContract,
|
||||
bets: Bet[],
|
||||
resolutions?: {
|
||||
[outcome: string]: number
|
||||
},
|
||||
resolutionProbability?: number
|
||||
): PayoutInfo => {
|
||||
const openBets = bets.filter((b) => !b.isSold && !b.sale)
|
||||
const { outcomeType } = contract
|
||||
|
||||
switch (outcome) {
|
||||
case 'YES':
|
||||
case 'NO':
|
||||
return getDpmStandardPayouts(outcome, contract, openBets)
|
||||
|
||||
case 'MKT':
|
||||
return outcomeType === 'FREE_RESPONSE' ||
|
||||
outcomeType === 'MULTIPLE_CHOICE' // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
? getPayoutsMultiOutcome(resolutions!, contract, openBets)
|
||||
: getDpmMktPayouts(contract, openBets, resolutionProbability)
|
||||
case 'CANCEL':
|
||||
case undefined:
|
||||
return getDpmCancelPayouts(contract, openBets)
|
||||
|
||||
default:
|
||||
if (outcomeType === 'NUMERIC')
|
||||
return getNumericDpmPayouts(outcome, contract, openBets as NumericBet[])
|
||||
|
||||
// Outcome is a free response answer id.
|
||||
return getDpmStandardPayouts(outcome, contract, openBets)
|
||||
}
|
||||
}
|
29
common/post.ts
Normal file
29
common/post.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { JSONContent } from '@tiptap/core'
|
||||
|
||||
export type Post = {
|
||||
id: string
|
||||
title: string
|
||||
subtitle: string
|
||||
content: JSONContent
|
||||
creatorId: string // User id
|
||||
createdTime: number
|
||||
slug: string
|
||||
|
||||
// denormalized user fields
|
||||
creatorName: string
|
||||
creatorUsername: string
|
||||
creatorAvatarUrl?: string
|
||||
|
||||
likedByUserIds?: string[]
|
||||
likedByUserCount?: number
|
||||
}
|
||||
|
||||
export type DateDoc = Post & {
|
||||
bounty: number
|
||||
birthday: number
|
||||
type: 'date-doc'
|
||||
contractSlug: string
|
||||
}
|
||||
|
||||
export const MAX_POST_TITLE_LENGTH = 480
|
||||
export const MAX_POST_SUBTITLE_LENGTH = 480
|
48
common/pseudo-numeric.ts
Normal file
48
common/pseudo-numeric.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { BinaryContract, PseudoNumericContract } from './contract'
|
||||
import { formatLargeNumber, formatPercent } from './util/format'
|
||||
|
||||
export function formatNumericProbability(
|
||||
p: number,
|
||||
contract: PseudoNumericContract
|
||||
) {
|
||||
const value = getMappedValue(contract)(p)
|
||||
return formatLargeNumber(value)
|
||||
}
|
||||
|
||||
export const getMappedValue =
|
||||
(contract: PseudoNumericContract | BinaryContract) => (p: number) => {
|
||||
if (contract.outcomeType === 'BINARY') return p
|
||||
|
||||
const { min, max, isLogScale } = contract
|
||||
|
||||
if (isLogScale) {
|
||||
const logValue = p * Math.log10(max - min + 1)
|
||||
return 10 ** logValue + min - 1
|
||||
}
|
||||
|
||||
return p * (max - min) + min
|
||||
}
|
||||
|
||||
export const getFormattedMappedValue =
|
||||
(contract: PseudoNumericContract | BinaryContract) => (p: number) => {
|
||||
if (contract.outcomeType === 'BINARY') return formatPercent(p)
|
||||
|
||||
const value = getMappedValue(contract)(p)
|
||||
return formatLargeNumber(value)
|
||||
}
|
||||
|
||||
export const getPseudoProbability = (
|
||||
value: number,
|
||||
min: number,
|
||||
max: number,
|
||||
isLogScale = false
|
||||
) => {
|
||||
if (value < min) return 0
|
||||
if (value > max) return 1
|
||||
|
||||
if (isLogScale) {
|
||||
return Math.log10(value - min + 1) / Math.log10(max - min + 1)
|
||||
}
|
||||
|
||||
return (value - min) / (max - min)
|
||||
}
|
27
common/quadratic-funding.ts
Normal file
27
common/quadratic-funding.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { groupBy, mapValues, sum, sumBy } from 'lodash'
|
||||
import { Txn } from './txn'
|
||||
|
||||
// Returns a map of charity ids to the amount of M$ matched
|
||||
export function quadraticMatches(
|
||||
allCharityTxns: Txn[],
|
||||
matchingPool: number
|
||||
): Record<string, number> {
|
||||
// For each charity, group the donations by each individual donor
|
||||
const donationsByCharity = groupBy(allCharityTxns, 'toId')
|
||||
const donationsByDonors = mapValues(donationsByCharity, (txns) =>
|
||||
groupBy(txns, 'fromId')
|
||||
)
|
||||
|
||||
// Weight for each charity = [sum of sqrt(individual donor)] ^ 2
|
||||
const weights = mapValues(donationsByDonors, (byDonor) => {
|
||||
const sumByDonor = Object.values(byDonor).map((txns) =>
|
||||
sumBy(txns, 'amount')
|
||||
)
|
||||
const sumOfRoots = sumBy(sumByDonor, Math.sqrt)
|
||||
return sumOfRoots ** 2
|
||||
})
|
||||
|
||||
// Then distribute the matching pool based on the individual weights
|
||||
const totalWeight = sum(Object.values(weights))
|
||||
return mapValues(weights, (weight) => matchingPool * (weight / totalWeight))
|
||||
}
|
58
common/redeem.ts
Normal file
58
common/redeem.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import { partition, sumBy } from 'lodash'
|
||||
|
||||
import { Bet } from './bet'
|
||||
import { getProbability } from './calculate'
|
||||
import { CPMMContract } from './contract'
|
||||
import { noFees } from './fees'
|
||||
import { CandidateBet } from './new-bet'
|
||||
|
||||
type RedeemableBet = Pick<Bet, 'outcome' | 'shares' | 'loanAmount'>
|
||||
|
||||
export const getRedeemableAmount = (bets: RedeemableBet[]) => {
|
||||
const [yesBets, noBets] = partition(bets, (b) => b.outcome === 'YES')
|
||||
const yesShares = sumBy(yesBets, (b) => b.shares)
|
||||
const noShares = sumBy(noBets, (b) => b.shares)
|
||||
const shares = Math.max(Math.min(yesShares, noShares), 0)
|
||||
const soldFrac =
|
||||
shares > 0
|
||||
? Math.min(yesShares, noShares) / Math.max(yesShares, noShares)
|
||||
: 0
|
||||
const loanAmount = sumBy(bets, (bet) => bet.loanAmount ?? 0)
|
||||
const loanPayment = loanAmount * soldFrac
|
||||
const netAmount = shares - loanPayment
|
||||
return { shares, loanPayment, netAmount }
|
||||
}
|
||||
|
||||
export const getRedemptionBets = (
|
||||
shares: number,
|
||||
loanPayment: number,
|
||||
contract: CPMMContract
|
||||
) => {
|
||||
const p = getProbability(contract)
|
||||
const createdTime = Date.now()
|
||||
const yesBet: CandidateBet = {
|
||||
contractId: contract.id,
|
||||
amount: p * -shares,
|
||||
shares: -shares,
|
||||
loanAmount: loanPayment ? -loanPayment / 2 : 0,
|
||||
outcome: 'YES',
|
||||
probBefore: p,
|
||||
probAfter: p,
|
||||
createdTime,
|
||||
isRedemption: true,
|
||||
fees: noFees,
|
||||
}
|
||||
const noBet: CandidateBet = {
|
||||
contractId: contract.id,
|
||||
amount: (1 - p) * -shares,
|
||||
shares: -shares,
|
||||
loanAmount: loanPayment ? -loanPayment / 2 : 0,
|
||||
outcome: 'NO',
|
||||
probBefore: p,
|
||||
probAfter: p,
|
||||
createdTime,
|
||||
isRedemption: true,
|
||||
fees: noFees,
|
||||
}
|
||||
return [yesBet, noBet]
|
||||
}
|
93
common/scoring.ts
Normal file
93
common/scoring.ts
Normal file
|
@ -0,0 +1,93 @@
|
|||
import { groupBy, sumBy, mapValues, keyBy, sortBy } from 'lodash'
|
||||
|
||||
import { Bet } from './bet'
|
||||
import { getContractBetMetrics, resolvedPayout } from './calculate'
|
||||
import { Contract } from './contract'
|
||||
import { ContractComment } from './comment'
|
||||
|
||||
export function scoreCreators(contracts: Contract[]) {
|
||||
const creatorScore = mapValues(
|
||||
groupBy(contracts, ({ creatorId }) => creatorId),
|
||||
(contracts) =>
|
||||
sumBy(
|
||||
contracts.map((contract) => {
|
||||
return contract.volume
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
return creatorScore
|
||||
}
|
||||
|
||||
export function scoreTraders(contracts: Contract[], bets: Bet[][]) {
|
||||
const userScoresByContract = contracts.map((contract, index) =>
|
||||
scoreUsersByContract(contract, bets[index])
|
||||
)
|
||||
const userScores: { [userId: string]: number } = {}
|
||||
for (const scores of userScoresByContract) {
|
||||
addUserScores(scores, userScores)
|
||||
}
|
||||
return userScores
|
||||
}
|
||||
|
||||
export function scoreUsersByContract(contract: Contract, bets: Bet[]) {
|
||||
const betsByUser = groupBy(bets, (bet) => bet.userId)
|
||||
return mapValues(
|
||||
betsByUser,
|
||||
(bets) => getContractBetMetrics(contract, bets).profit
|
||||
)
|
||||
}
|
||||
|
||||
export function addUserScores(
|
||||
src: { [userId: string]: number },
|
||||
dest: { [userId: string]: number }
|
||||
) {
|
||||
for (const [userId, score] of Object.entries(src)) {
|
||||
if (dest[userId] === undefined) dest[userId] = 0
|
||||
dest[userId] += score
|
||||
}
|
||||
}
|
||||
|
||||
export function scoreCommentorsAndBettors(
|
||||
contract: Contract,
|
||||
bets: Bet[],
|
||||
comments: ContractComment[]
|
||||
) {
|
||||
const commentsById = keyBy(comments, 'id')
|
||||
const betsById = keyBy(bets, 'id')
|
||||
|
||||
// If 'id2' is the sale of 'id1', both are logged with (id2 - id1) of profit
|
||||
// Otherwise, we record the profit at resolution time
|
||||
const profitById: Record<string, number> = {}
|
||||
for (const bet of bets) {
|
||||
if (bet.sale) {
|
||||
const originalBet = betsById[bet.sale.betId]
|
||||
const profit = bet.sale.amount - originalBet.amount
|
||||
profitById[bet.id] = profit
|
||||
profitById[originalBet.id] = profit
|
||||
} else {
|
||||
profitById[bet.id] = resolvedPayout(contract, bet) - bet.amount
|
||||
}
|
||||
}
|
||||
|
||||
// Now find the betId with the highest profit
|
||||
const topBetId = sortBy(bets, (b) => -profitById[b.id])[0]?.id
|
||||
const topBettor = betsById[topBetId]?.userName
|
||||
|
||||
// And also the commentId of the comment with the highest profit
|
||||
const topCommentId = sortBy(
|
||||
comments,
|
||||
(c) => c.betId && -profitById[c.betId]
|
||||
)[0]?.id
|
||||
const topCommentBetId = commentsById[topCommentId]?.betId
|
||||
|
||||
return {
|
||||
topCommentId,
|
||||
topBetId,
|
||||
topBettor,
|
||||
profitById,
|
||||
commentsById,
|
||||
betsById,
|
||||
topCommentBetId,
|
||||
}
|
||||
}
|
141
common/sell-bet.ts
Normal file
141
common/sell-bet.ts
Normal file
|
@ -0,0 +1,141 @@
|
|||
import { Bet, LimitBet } from './bet'
|
||||
import {
|
||||
calculateDpmShareValue,
|
||||
deductDpmFees,
|
||||
getDpmOutcomeProbability,
|
||||
} from './calculate-dpm'
|
||||
import { calculateCpmmSale, getCpmmProbability } from './calculate-cpmm'
|
||||
import { CPMMContract, DPMContract } from './contract'
|
||||
import { DPM_CREATOR_FEE, DPM_PLATFORM_FEE, Fees } from './fees'
|
||||
import { sumBy } from 'lodash'
|
||||
|
||||
export type CandidateBet<T extends Bet> = Omit<
|
||||
T,
|
||||
'id' | 'userId' | 'userAvatarUrl' | 'userName' | 'userUsername'
|
||||
>
|
||||
|
||||
export const getSellBetInfo = (bet: Bet, contract: DPMContract) => {
|
||||
const { pool, totalShares, totalBets } = contract
|
||||
const { id: betId, amount, shares, outcome, loanAmount } = bet
|
||||
|
||||
const adjShareValue = calculateDpmShareValue(contract, bet)
|
||||
|
||||
const newPool = { ...pool, [outcome]: pool[outcome] - adjShareValue }
|
||||
|
||||
const newTotalShares = {
|
||||
...totalShares,
|
||||
[outcome]: totalShares[outcome] - shares,
|
||||
}
|
||||
|
||||
const newTotalBets = { ...totalBets, [outcome]: totalBets[outcome] - amount }
|
||||
|
||||
const probBefore = getDpmOutcomeProbability(totalShares, outcome)
|
||||
const probAfter = getDpmOutcomeProbability(newTotalShares, outcome)
|
||||
|
||||
const profit = adjShareValue - amount
|
||||
|
||||
const creatorFee = DPM_CREATOR_FEE * Math.max(0, profit)
|
||||
const platformFee = DPM_PLATFORM_FEE * Math.max(0, profit)
|
||||
const fees: Fees = {
|
||||
creatorFee,
|
||||
platformFee,
|
||||
liquidityFee: 0,
|
||||
}
|
||||
|
||||
const saleAmount = deductDpmFees(amount, adjShareValue)
|
||||
|
||||
console.log(
|
||||
'SELL M$',
|
||||
amount,
|
||||
outcome,
|
||||
'for M$',
|
||||
saleAmount,
|
||||
'creator fee: M$',
|
||||
creatorFee
|
||||
)
|
||||
|
||||
const newBet: CandidateBet<Bet> = {
|
||||
contractId: contract.id,
|
||||
amount: -adjShareValue,
|
||||
shares: -shares,
|
||||
outcome,
|
||||
probBefore,
|
||||
probAfter,
|
||||
createdTime: Date.now(),
|
||||
sale: {
|
||||
amount: saleAmount,
|
||||
betId,
|
||||
},
|
||||
fees,
|
||||
loanAmount: -(loanAmount ?? 0),
|
||||
}
|
||||
|
||||
return {
|
||||
newBet,
|
||||
newPool,
|
||||
newTotalShares,
|
||||
newTotalBets,
|
||||
fees,
|
||||
}
|
||||
}
|
||||
|
||||
export const getCpmmSellBetInfo = (
|
||||
shares: number,
|
||||
outcome: 'YES' | 'NO',
|
||||
contract: CPMMContract,
|
||||
unfilledBets: LimitBet[],
|
||||
balanceByUserId: { [userId: string]: number },
|
||||
loanPaid: number
|
||||
) => {
|
||||
const { pool, p } = contract
|
||||
|
||||
const { saleValue, cpmmState, fees, makers, takers, ordersToCancel } = calculateCpmmSale(
|
||||
contract,
|
||||
shares,
|
||||
outcome,
|
||||
unfilledBets,
|
||||
balanceByUserId,
|
||||
)
|
||||
|
||||
const probBefore = getCpmmProbability(pool, p)
|
||||
const probAfter = getCpmmProbability(cpmmState.pool, cpmmState.p)
|
||||
|
||||
const takerAmount = sumBy(takers, 'amount')
|
||||
const takerShares = sumBy(takers, 'shares')
|
||||
|
||||
console.log(
|
||||
'SELL M$',
|
||||
shares,
|
||||
outcome,
|
||||
'for M$',
|
||||
saleValue,
|
||||
'creator fee: M$',
|
||||
fees.creatorFee
|
||||
)
|
||||
|
||||
const newBet: CandidateBet<Bet> = {
|
||||
contractId: contract.id,
|
||||
amount: takerAmount,
|
||||
shares: takerShares,
|
||||
outcome,
|
||||
probBefore,
|
||||
probAfter,
|
||||
createdTime: Date.now(),
|
||||
loanAmount: -loanPaid,
|
||||
fees,
|
||||
fills: takers,
|
||||
isFilled: true,
|
||||
isCancelled: false,
|
||||
orderAmount: takerAmount,
|
||||
}
|
||||
|
||||
return {
|
||||
newBet,
|
||||
newPool: cpmmState.pool,
|
||||
newP: cpmmState.p,
|
||||
fees,
|
||||
makers,
|
||||
takers,
|
||||
ordersToCancel
|
||||
}
|
||||
}
|
25
common/stats.ts
Normal file
25
common/stats.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
export type Stats = {
|
||||
startDate: number
|
||||
dailyActiveUsers: number[]
|
||||
dailyActiveUsersWeeklyAvg: number[]
|
||||
weeklyActiveUsers: number[]
|
||||
monthlyActiveUsers: number[]
|
||||
d1: number[]
|
||||
d1WeeklyAvg: number[]
|
||||
nd1: number[]
|
||||
nd1WeeklyAvg: number[]
|
||||
nw1: number[]
|
||||
dailyBetCounts: number[]
|
||||
dailyContractCounts: number[]
|
||||
dailyCommentCounts: number[]
|
||||
dailySignups: number[]
|
||||
weekOnWeekRetention: number[]
|
||||
monthlyRetention: number[]
|
||||
dailyActivationRate: number[]
|
||||
dailyActivationRateWeeklyAvg: number[]
|
||||
manaBet: {
|
||||
daily: number[]
|
||||
weekly: number[]
|
||||
monthly: number[]
|
||||
}
|
||||
}
|
18
common/tracking.ts
Normal file
18
common/tracking.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
export type View = {
|
||||
contractId: string
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
export type UserEvent = ClickEvent
|
||||
|
||||
export type ClickEvent = {
|
||||
type: 'click'
|
||||
contractId: string
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
export type LatencyEvent = {
|
||||
type: 'feed' | 'portfolio'
|
||||
latency: number
|
||||
timestamp: number
|
||||
}
|
14
common/tsconfig.json
Normal file
14
common/tsconfig.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../",
|
||||
"composite": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"noImplicitReturns": true,
|
||||
"outDir": "lib",
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"target": "es2017"
|
||||
},
|
||||
"include": ["**/*.ts"]
|
||||
}
|
140
common/txn.ts
Normal file
140
common/txn.ts
Normal file
|
@ -0,0 +1,140 @@
|
|||
// A txn (pronounced "texan") respresents a payment between two ids on Manifold
|
||||
// Shortened from "transaction" to distinguish from Firebase transactions (and save chars)
|
||||
type AnyTxnType =
|
||||
| Donation
|
||||
| Tip
|
||||
| Manalink
|
||||
| Referral
|
||||
| UniqueBettorBonus
|
||||
| BettingStreakBonus
|
||||
| CancelUniqueBettorBonus
|
||||
| CommentBountyRefund
|
||||
type SourceType = 'USER' | 'CONTRACT' | 'CHARITY' | 'BANK'
|
||||
|
||||
export type Txn<T extends AnyTxnType = AnyTxnType> = {
|
||||
id: string
|
||||
createdTime: number
|
||||
|
||||
fromId: string
|
||||
fromType: SourceType
|
||||
|
||||
toId: string
|
||||
toType: SourceType
|
||||
|
||||
amount: number
|
||||
token: 'M$' // | 'USD' | MarketOutcome
|
||||
|
||||
category:
|
||||
| 'CHARITY'
|
||||
| 'MANALINK'
|
||||
| 'TIP'
|
||||
| 'REFERRAL'
|
||||
| 'UNIQUE_BETTOR_BONUS'
|
||||
| 'BETTING_STREAK_BONUS'
|
||||
| 'CANCEL_UNIQUE_BETTOR_BONUS'
|
||||
| 'COMMENT_BOUNTY'
|
||||
| 'REFUND_COMMENT_BOUNTY'
|
||||
|
||||
// Any extra data
|
||||
data?: { [key: string]: any }
|
||||
|
||||
// Human-readable description
|
||||
description?: string
|
||||
} & T
|
||||
|
||||
type Donation = {
|
||||
fromType: 'USER'
|
||||
toType: 'CHARITY'
|
||||
category: 'CHARITY'
|
||||
}
|
||||
|
||||
type Tip = {
|
||||
fromType: 'USER'
|
||||
toType: 'USER'
|
||||
category: 'TIP'
|
||||
data: {
|
||||
commentId: string
|
||||
contractId?: string
|
||||
groupId?: string
|
||||
}
|
||||
}
|
||||
|
||||
type Manalink = {
|
||||
fromType: 'USER'
|
||||
toType: 'USER'
|
||||
category: 'MANALINK'
|
||||
}
|
||||
|
||||
type Referral = {
|
||||
fromType: 'BANK'
|
||||
toType: 'USER'
|
||||
category: 'REFERRAL'
|
||||
}
|
||||
|
||||
type UniqueBettorBonus = {
|
||||
fromType: 'BANK'
|
||||
toType: 'USER'
|
||||
category: 'UNIQUE_BETTOR_BONUS'
|
||||
data: {
|
||||
contractId: string
|
||||
uniqueNewBettorId?: string
|
||||
// Old unique bettor bonus txns stored all unique bettor ids
|
||||
uniqueBettorIds?: string[]
|
||||
}
|
||||
}
|
||||
|
||||
type BettingStreakBonus = {
|
||||
fromType: 'BANK'
|
||||
toType: 'USER'
|
||||
category: 'BETTING_STREAK_BONUS'
|
||||
data: {
|
||||
currentBettingStreak?: number
|
||||
}
|
||||
}
|
||||
|
||||
type CancelUniqueBettorBonus = {
|
||||
fromType: 'USER'
|
||||
toType: 'BANK'
|
||||
category: 'CANCEL_UNIQUE_BETTOR_BONUS'
|
||||
data: {
|
||||
contractId: string
|
||||
}
|
||||
}
|
||||
|
||||
type CommentBountyDeposit = {
|
||||
fromType: 'USER'
|
||||
toType: 'BANK'
|
||||
category: 'COMMENT_BOUNTY'
|
||||
data: {
|
||||
contractId: string
|
||||
}
|
||||
}
|
||||
|
||||
type CommentBountyWithdrawal = {
|
||||
fromType: 'BANK'
|
||||
toType: 'USER'
|
||||
category: 'COMMENT_BOUNTY'
|
||||
data: {
|
||||
contractId: string
|
||||
commentId: string
|
||||
}
|
||||
}
|
||||
|
||||
type CommentBountyRefund = {
|
||||
fromType: 'BANK'
|
||||
toType: 'USER'
|
||||
category: 'REFUND_COMMENT_BOUNTY'
|
||||
data: {
|
||||
contractId: string
|
||||
}
|
||||
}
|
||||
|
||||
export type DonationTxn = Txn & Donation
|
||||
export type TipTxn = Txn & Tip
|
||||
export type ManalinkTxn = Txn & Manalink
|
||||
export type ReferralTxn = Txn & Referral
|
||||
export type BettingStreakBonusTxn = Txn & BettingStreakBonus
|
||||
export type UniqueBettorBonusTxn = Txn & UniqueBettorBonus
|
||||
export type CancelUniqueBettorBonusTxn = Txn & CancelUniqueBettorBonus
|
||||
export type CommentBountyDepositTxn = Txn & CommentBountyDeposit
|
||||
export type CommentBountyWithdrawalTxn = Txn & CommentBountyWithdrawal
|
222
common/user-notification-preferences.ts
Normal file
222
common/user-notification-preferences.ts
Normal file
|
@ -0,0 +1,222 @@
|
|||
import { filterDefined } from './util/array'
|
||||
import { notification_reason_types } from './notification'
|
||||
import { getFunctionUrl } from './api'
|
||||
import { DOMAIN } from './envs/constants'
|
||||
import { PrivateUser } from './user'
|
||||
|
||||
export type notification_destination_types = 'email' | 'browser'
|
||||
export type notification_preference = keyof notification_preferences
|
||||
export type notification_preferences = {
|
||||
// Watched Markets
|
||||
all_comments_on_watched_markets: notification_destination_types[]
|
||||
all_answers_on_watched_markets: notification_destination_types[]
|
||||
|
||||
// Comments
|
||||
tipped_comments_on_watched_markets: notification_destination_types[]
|
||||
comments_by_followed_users_on_watched_markets: notification_destination_types[]
|
||||
all_replies_to_my_comments_on_watched_markets: notification_destination_types[]
|
||||
all_replies_to_my_answers_on_watched_markets: notification_destination_types[]
|
||||
all_comments_on_contracts_with_shares_in_on_watched_markets: notification_destination_types[]
|
||||
|
||||
// Answers
|
||||
answers_by_followed_users_on_watched_markets: notification_destination_types[]
|
||||
answers_by_market_creator_on_watched_markets: notification_destination_types[]
|
||||
all_answers_on_contracts_with_shares_in_on_watched_markets: notification_destination_types[]
|
||||
|
||||
// On users' markets
|
||||
your_contract_closed: notification_destination_types[]
|
||||
all_comments_on_my_markets: notification_destination_types[]
|
||||
all_answers_on_my_markets: notification_destination_types[]
|
||||
subsidized_your_market: notification_destination_types[]
|
||||
|
||||
// Market updates
|
||||
resolutions_on_watched_markets: notification_destination_types[]
|
||||
resolutions_on_watched_markets_with_shares_in: notification_destination_types[]
|
||||
market_updates_on_watched_markets: notification_destination_types[]
|
||||
market_updates_on_watched_markets_with_shares_in: notification_destination_types[]
|
||||
probability_updates_on_watched_markets: notification_destination_types[]
|
||||
|
||||
// Balance Changes
|
||||
loan_income: notification_destination_types[]
|
||||
betting_streaks: notification_destination_types[]
|
||||
referral_bonuses: notification_destination_types[]
|
||||
unique_bettors_on_your_contract: notification_destination_types[]
|
||||
tips_on_your_comments: notification_destination_types[]
|
||||
tips_on_your_markets: notification_destination_types[]
|
||||
limit_order_fills: notification_destination_types[]
|
||||
|
||||
// General
|
||||
tagged_user: notification_destination_types[]
|
||||
on_new_follow: notification_destination_types[]
|
||||
contract_from_followed_user: notification_destination_types[]
|
||||
trending_markets: notification_destination_types[]
|
||||
profit_loss_updates: notification_destination_types[]
|
||||
onboarding_flow: notification_destination_types[]
|
||||
thank_you_for_purchases: notification_destination_types[]
|
||||
badges_awarded: notification_destination_types[]
|
||||
opt_out_all: notification_destination_types[]
|
||||
// When adding a new notification preference, use add-new-notification-preference.ts to existing users
|
||||
}
|
||||
|
||||
export const getDefaultNotificationPreferences = (
|
||||
userId: string,
|
||||
privateUser?: PrivateUser,
|
||||
noEmails?: boolean
|
||||
) => {
|
||||
const constructPref = (browserIf: boolean, emailIf: boolean) => {
|
||||
const browser = browserIf ? 'browser' : undefined
|
||||
const email = noEmails ? undefined : emailIf ? 'email' : undefined
|
||||
return filterDefined([browser, email]) as notification_destination_types[]
|
||||
}
|
||||
const defaults: notification_preferences = {
|
||||
// Watched Markets
|
||||
all_comments_on_watched_markets: constructPref(true, false),
|
||||
all_answers_on_watched_markets: constructPref(true, false),
|
||||
|
||||
// Comments
|
||||
tips_on_your_comments: constructPref(true, true),
|
||||
comments_by_followed_users_on_watched_markets: constructPref(true, true),
|
||||
all_replies_to_my_comments_on_watched_markets: constructPref(true, true),
|
||||
all_replies_to_my_answers_on_watched_markets: constructPref(true, true),
|
||||
all_comments_on_contracts_with_shares_in_on_watched_markets: constructPref(
|
||||
true,
|
||||
false
|
||||
),
|
||||
|
||||
// Answers
|
||||
answers_by_followed_users_on_watched_markets: constructPref(true, true),
|
||||
answers_by_market_creator_on_watched_markets: constructPref(true, true),
|
||||
all_answers_on_contracts_with_shares_in_on_watched_markets: constructPref(
|
||||
true,
|
||||
true
|
||||
),
|
||||
|
||||
// On users' markets
|
||||
your_contract_closed: constructPref(true, true), // High priority
|
||||
all_comments_on_my_markets: constructPref(true, true),
|
||||
all_answers_on_my_markets: constructPref(true, true),
|
||||
subsidized_your_market: constructPref(true, true),
|
||||
|
||||
// Market updates
|
||||
resolutions_on_watched_markets: constructPref(true, false),
|
||||
market_updates_on_watched_markets: constructPref(true, false),
|
||||
market_updates_on_watched_markets_with_shares_in: constructPref(
|
||||
true,
|
||||
false
|
||||
),
|
||||
resolutions_on_watched_markets_with_shares_in: constructPref(true, true),
|
||||
|
||||
//Balance Changes
|
||||
loan_income: constructPref(true, false),
|
||||
betting_streaks: constructPref(true, false),
|
||||
referral_bonuses: constructPref(true, true),
|
||||
unique_bettors_on_your_contract: constructPref(true, true),
|
||||
tipped_comments_on_watched_markets: constructPref(true, true),
|
||||
tips_on_your_markets: constructPref(true, true),
|
||||
limit_order_fills: constructPref(true, false),
|
||||
|
||||
// General
|
||||
tagged_user: constructPref(true, true),
|
||||
on_new_follow: constructPref(true, true),
|
||||
contract_from_followed_user: constructPref(true, true),
|
||||
trending_markets: constructPref(false, true),
|
||||
profit_loss_updates: constructPref(false, true),
|
||||
probability_updates_on_watched_markets: constructPref(true, false),
|
||||
thank_you_for_purchases: constructPref(false, false),
|
||||
onboarding_flow: constructPref(false, false),
|
||||
|
||||
opt_out_all: [],
|
||||
badges_awarded: constructPref(true, false),
|
||||
}
|
||||
return defaults
|
||||
}
|
||||
|
||||
// Adding a new key:value here is optional, you can just use a key of notification_subscription_types
|
||||
// You might want to add a key:value here if there will be multiple notification reasons that map to the same
|
||||
// subscription type, i.e. 'comment_on_contract_you_follow' and 'comment_on_contract_with_users_answer' both map to
|
||||
// 'all_comments_on_watched_markets' subscription type
|
||||
// TODO: perhaps better would be to map notification_subscription_types to arrays of notification_reason_types
|
||||
const notificationReasonToSubscriptionType: Partial<
|
||||
Record<notification_reason_types, notification_preference>
|
||||
> = {
|
||||
you_referred_user: 'referral_bonuses',
|
||||
user_joined_to_bet_on_your_market: 'referral_bonuses',
|
||||
tip_received: 'tips_on_your_comments',
|
||||
bet_fill: 'limit_order_fills',
|
||||
user_joined_from_your_group_invite: 'referral_bonuses',
|
||||
challenge_accepted: 'limit_order_fills',
|
||||
betting_streak_incremented: 'betting_streaks',
|
||||
liked_and_tipped_your_contract: 'tips_on_your_markets',
|
||||
comment_on_your_contract: 'all_comments_on_my_markets',
|
||||
answer_on_your_contract: 'all_answers_on_my_markets',
|
||||
comment_on_contract_you_follow: 'all_comments_on_watched_markets',
|
||||
answer_on_contract_you_follow: 'all_answers_on_watched_markets',
|
||||
update_on_contract_you_follow: 'market_updates_on_watched_markets',
|
||||
resolution_on_contract_you_follow: 'resolutions_on_watched_markets',
|
||||
comment_on_contract_with_users_shares_in:
|
||||
'all_comments_on_contracts_with_shares_in_on_watched_markets',
|
||||
answer_on_contract_with_users_shares_in:
|
||||
'all_answers_on_contracts_with_shares_in_on_watched_markets',
|
||||
update_on_contract_with_users_shares_in:
|
||||
'market_updates_on_watched_markets_with_shares_in',
|
||||
resolution_on_contract_with_users_shares_in:
|
||||
'resolutions_on_watched_markets_with_shares_in',
|
||||
comment_on_contract_with_users_answer: 'all_comments_on_watched_markets',
|
||||
update_on_contract_with_users_answer: 'market_updates_on_watched_markets',
|
||||
resolution_on_contract_with_users_answer: 'resolutions_on_watched_markets',
|
||||
answer_on_contract_with_users_answer: 'all_answers_on_watched_markets',
|
||||
comment_on_contract_with_users_comment: 'all_comments_on_watched_markets',
|
||||
answer_on_contract_with_users_comment: 'all_answers_on_watched_markets',
|
||||
update_on_contract_with_users_comment: 'market_updates_on_watched_markets',
|
||||
resolution_on_contract_with_users_comment: 'resolutions_on_watched_markets',
|
||||
reply_to_users_answer: 'all_replies_to_my_answers_on_watched_markets',
|
||||
reply_to_users_comment: 'all_replies_to_my_comments_on_watched_markets',
|
||||
}
|
||||
|
||||
export const getNotificationDestinationsForUser = (
|
||||
privateUser: PrivateUser,
|
||||
// TODO: accept reasons array from most to least important and work backwards
|
||||
reason: notification_reason_types | notification_preference
|
||||
) => {
|
||||
const notificationSettings = privateUser.notificationPreferences
|
||||
const unsubscribeEndpoint = getFunctionUrl('unsubscribe')
|
||||
try {
|
||||
let destinations
|
||||
let subscriptionType: notification_preference | undefined
|
||||
if (Object.keys(notificationSettings).includes(reason)) {
|
||||
subscriptionType = reason as notification_preference
|
||||
destinations = notificationSettings[subscriptionType]
|
||||
} else {
|
||||
const key = reason as notification_reason_types
|
||||
subscriptionType = notificationReasonToSubscriptionType[key]
|
||||
destinations = subscriptionType
|
||||
? notificationSettings[subscriptionType]
|
||||
: []
|
||||
}
|
||||
const optOutOfAllSettings = notificationSettings['opt_out_all']
|
||||
// Your market closure notifications are high priority, opt-out doesn't affect their delivery
|
||||
const optedOutOfEmail =
|
||||
optOutOfAllSettings.includes('email') &&
|
||||
subscriptionType !== 'your_contract_closed'
|
||||
const optedOutOfBrowser =
|
||||
optOutOfAllSettings.includes('browser') &&
|
||||
subscriptionType !== 'your_contract_closed'
|
||||
return {
|
||||
sendToEmail: destinations.includes('email') && !optedOutOfEmail,
|
||||
sendToBrowser: destinations.includes('browser') && !optedOutOfBrowser,
|
||||
unsubscribeUrl: `${unsubscribeEndpoint}?id=${privateUser.id}&type=${subscriptionType}`,
|
||||
urlToManageThisNotification: `${DOMAIN}/notifications?tab=settings§ion=${subscriptionType}`,
|
||||
}
|
||||
} catch (e) {
|
||||
// Fail safely
|
||||
console.log(
|
||||
`couldn't get notification destinations for type ${reason} for user ${privateUser.id}`
|
||||
)
|
||||
return {
|
||||
sendToEmail: false,
|
||||
sendToBrowser: false,
|
||||
unsubscribeUrl: '',
|
||||
urlToManageThisNotification: '',
|
||||
}
|
||||
}
|
||||
}
|
107
common/user.ts
Normal file
107
common/user.ts
Normal file
|
@ -0,0 +1,107 @@
|
|||
import { notification_preferences } from './user-notification-preferences'
|
||||
import { ENV_CONFIG } from './envs/constants'
|
||||
import { MarketCreatorBadge, ProvenCorrectBadge, StreakerBadge } from './badge'
|
||||
|
||||
export type User = {
|
||||
id: string
|
||||
createdTime: number
|
||||
|
||||
name: string
|
||||
username: string
|
||||
avatarUrl?: string
|
||||
|
||||
// For their user page
|
||||
bio?: string
|
||||
website?: string
|
||||
twitterHandle?: string
|
||||
discordHandle?: string
|
||||
|
||||
balance: number
|
||||
totalDeposits: number
|
||||
|
||||
profitCached: {
|
||||
daily: number
|
||||
weekly: number
|
||||
monthly: number
|
||||
allTime: number
|
||||
}
|
||||
|
||||
creatorVolumeCached: {
|
||||
daily: number
|
||||
weekly: number
|
||||
monthly: number
|
||||
allTime: number
|
||||
}
|
||||
|
||||
fractionResolvedCorrectly: number
|
||||
|
||||
nextLoanCached: number
|
||||
followerCountCached: number
|
||||
|
||||
followedCategories?: string[]
|
||||
homeSections?: string[]
|
||||
|
||||
referredByUserId?: string
|
||||
referredByContractId?: string
|
||||
referredByGroupId?: string
|
||||
lastPingTime?: number
|
||||
shouldShowWelcome?: boolean
|
||||
lastBetTime?: number
|
||||
currentBettingStreak?: number
|
||||
hasSeenContractFollowModal?: boolean
|
||||
freeMarketsCreated?: number
|
||||
isBannedFromPosting?: boolean
|
||||
|
||||
achievements: {
|
||||
provenCorrect?: {
|
||||
badges: ProvenCorrectBadge[]
|
||||
}
|
||||
marketCreator?: {
|
||||
badges: MarketCreatorBadge[]
|
||||
}
|
||||
streaker?: {
|
||||
badges: StreakerBadge[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type PrivateUser = {
|
||||
id: string // same as User.id
|
||||
username: string // denormalized from User
|
||||
|
||||
email?: string
|
||||
weeklyTrendingEmailSent?: boolean
|
||||
weeklyPortfolioUpdateEmailSent?: boolean
|
||||
manaBonusEmailSent?: boolean
|
||||
initialDeviceToken?: string
|
||||
initialIpAddress?: string
|
||||
apiKey?: string
|
||||
notificationPreferences: notification_preferences
|
||||
twitchInfo?: {
|
||||
twitchName: string
|
||||
controlToken: string
|
||||
botEnabled?: boolean
|
||||
needsRelinking?: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export type PortfolioMetrics = {
|
||||
investmentValue: number
|
||||
balance: number
|
||||
totalDeposits: number
|
||||
timestamp: number
|
||||
userId: string
|
||||
}
|
||||
|
||||
export const MANIFOLD_USER_USERNAME = 'ManifoldMarkets'
|
||||
export const MANIFOLD_USER_NAME = 'ManifoldMarkets'
|
||||
export const MANIFOLD_AVATAR_URL = 'https://manifold.markets/logo-bg-white.png'
|
||||
|
||||
// TODO: remove. Hardcoding the strings would be better.
|
||||
// Different views require different language.
|
||||
export const BETTOR = ENV_CONFIG.bettor ?? 'trader'
|
||||
export const BETTORS = ENV_CONFIG.bettor + 's' ?? 'traders'
|
||||
export const PRESENT_BET = ENV_CONFIG.presentBet ?? 'trade'
|
||||
export const PRESENT_BETS = ENV_CONFIG.presentBet + 's' ?? 'trades'
|
||||
export const PAST_BET = ENV_CONFIG.pastBet ?? 'trade'
|
||||
export const PAST_BETS = ENV_CONFIG.pastBet + 's' ?? 'trades'
|
22
common/util/algos.ts
Normal file
22
common/util/algos.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
export function binarySearch(
|
||||
min: number,
|
||||
max: number,
|
||||
comparator: (x: number) => number
|
||||
) {
|
||||
let mid = 0
|
||||
while (true) {
|
||||
mid = min + (max - min) / 2
|
||||
|
||||
// Break once we've reached max precision.
|
||||
if (mid === min || mid === max) break
|
||||
|
||||
const comparison = comparator(mid)
|
||||
if (comparison === 0) break
|
||||
else if (comparison > 0) {
|
||||
max = mid
|
||||
} else {
|
||||
min = mid
|
||||
}
|
||||
}
|
||||
return mid
|
||||
}
|
40
common/util/array.ts
Normal file
40
common/util/array.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { isEqual } from 'lodash'
|
||||
|
||||
export function filterDefined<T>(array: (T | null | undefined)[]) {
|
||||
return array.filter((item) => item !== null && item !== undefined) as T[]
|
||||
}
|
||||
|
||||
export function buildArray<T>(
|
||||
...params: (T | T[] | false | undefined | null)[]
|
||||
) {
|
||||
const array: T[] = []
|
||||
|
||||
for (const el of params) {
|
||||
if (Array.isArray(el)) {
|
||||
array.push(...el)
|
||||
} else if (el) {
|
||||
array.push(el)
|
||||
}
|
||||
}
|
||||
|
||||
return array
|
||||
}
|
||||
|
||||
export function groupConsecutive<T, U>(xs: T[], key: (x: T) => U) {
|
||||
if (!xs.length) {
|
||||
return []
|
||||
}
|
||||
const result = []
|
||||
let curr = { key: key(xs[0]), items: [xs[0]] }
|
||||
for (const x of xs.slice(1)) {
|
||||
const k = key(x)
|
||||
if (!isEqual(key, curr.key)) {
|
||||
result.push(curr)
|
||||
curr = { key: k, items: [x] }
|
||||
} else {
|
||||
curr.items.push(x)
|
||||
}
|
||||
}
|
||||
result.push(curr)
|
||||
return result
|
||||
}
|
12
common/util/clean-username.ts
Normal file
12
common/util/clean-username.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
export const cleanUsername = (name: string, maxLength = 25) => {
|
||||
return name
|
||||
.replace(/\s+/g, '')
|
||||
.normalize('NFD') // split an accented letter in the base letter and the acent
|
||||
.replace(/[\u0300-\u036f]/g, '') // remove all previously split accents
|
||||
.replace(/[^A-Za-z0-9_]/g, '') // remove all chars not letters, numbers and underscores
|
||||
.substring(0, maxLength)
|
||||
}
|
||||
|
||||
export const cleanDisplayName = (displayName: string, maxLength = 30) => {
|
||||
return displayName.replace(/\s+/g, ' ').substring(0, maxLength).trim()
|
||||
}
|
24
common/util/color.ts
Normal file
24
common/util/color.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
export const interpolateColor = (color1: string, color2: string, p: number) => {
|
||||
const rgb1 = parseInt(color1.replace('#', ''), 16)
|
||||
const rgb2 = parseInt(color2.replace('#', ''), 16)
|
||||
|
||||
const [r1, g1, b1] = toArray(rgb1)
|
||||
const [r2, g2, b2] = toArray(rgb2)
|
||||
|
||||
const q = 1 - p
|
||||
const rr = Math.round(r1 * q + r2 * p)
|
||||
const rg = Math.round(g1 * q + g2 * p)
|
||||
const rb = Math.round(b1 * q + b2 * p)
|
||||
|
||||
const hexString = Number((rr << 16) + (rg << 8) + rb).toString(16)
|
||||
const hex = `#${'0'.repeat(6 - hexString.length)}${hexString}`
|
||||
return hex
|
||||
}
|
||||
|
||||
function toArray(rgb: number) {
|
||||
const r = rgb >> 16
|
||||
const g = (rgb >> 8) % 256
|
||||
const b = rgb % 256
|
||||
|
||||
return [r, g, b]
|
||||
}
|
86
common/util/format.ts
Normal file
86
common/util/format.ts
Normal file
|
@ -0,0 +1,86 @@
|
|||
import { ENV_CONFIG } from '../envs/constants'
|
||||
|
||||
const formatter = new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
maximumFractionDigits: 0,
|
||||
minimumFractionDigits: 0,
|
||||
})
|
||||
|
||||
export function formatMoney(amount: number) {
|
||||
const newAmount =
|
||||
// handle -0 case
|
||||
Math.round(amount) === 0
|
||||
? 0
|
||||
: // Handle 499.9999999999999 case
|
||||
(amount > 0 ? Math.floor : Math.ceil)(
|
||||
amount + 0.00000000001 * Math.sign(amount)
|
||||
)
|
||||
return ENV_CONFIG.moneyMoniker + formatter.format(newAmount).replace('$', '')
|
||||
}
|
||||
|
||||
export function formatMoneyWithDecimals(amount: number) {
|
||||
return ENV_CONFIG.moneyMoniker + amount.toFixed(2)
|
||||
}
|
||||
|
||||
export function formatWithCommas(amount: number) {
|
||||
return formatter.format(Math.floor(amount)).replace('$', '')
|
||||
}
|
||||
|
||||
export function manaToUSD(mana: number) {
|
||||
return (mana / 100).toLocaleString('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
})
|
||||
}
|
||||
|
||||
export function formatPercent(zeroToOne: number) {
|
||||
// Show 1 decimal place if <2% or >98%, giving more resolution on the tails
|
||||
const decimalPlaces = zeroToOne < 0.02 || zeroToOne > 0.98 ? 1 : 0
|
||||
return (zeroToOne * 100).toFixed(decimalPlaces) + '%'
|
||||
}
|
||||
|
||||
const showPrecision = (x: number, sigfigs: number) =>
|
||||
// convert back to number for weird formatting reason
|
||||
`${Number(x.toPrecision(sigfigs))}`
|
||||
|
||||
// Eg 1234567.89 => 1.23M; 5678 => 5.68K
|
||||
export function formatLargeNumber(num: number, sigfigs = 2): string {
|
||||
const absNum = Math.abs(num)
|
||||
if (absNum < 1) return showPrecision(num, sigfigs)
|
||||
|
||||
if (absNum < 100) return showPrecision(num, 2)
|
||||
if (absNum < 1000) return showPrecision(num, 3)
|
||||
if (absNum < 10000) return showPrecision(num, 4)
|
||||
|
||||
const suffix = ['', 'K', 'M', 'B', 'T', 'Q']
|
||||
const i = Math.floor(Math.log10(absNum) / 3)
|
||||
|
||||
const numStr = showPrecision(num / Math.pow(10, 3 * i), sigfigs)
|
||||
return `${numStr}${suffix[i] ?? ''}`
|
||||
}
|
||||
|
||||
export function shortFormatNumber(num: number): string {
|
||||
if (num < 1000) return showPrecision(num, 3)
|
||||
|
||||
const suffix = ['', 'K', 'M', 'B', 'T', 'Q']
|
||||
const i = Math.floor(Math.log10(num) / 3)
|
||||
|
||||
const numStr = showPrecision(num / Math.pow(10, 3 * i), 2)
|
||||
return `${numStr}${suffix[i] ?? ''}`
|
||||
}
|
||||
|
||||
export function toCamelCase(words: string) {
|
||||
const camelCase = words
|
||||
.split(' ')
|
||||
.map((word) => word.trim())
|
||||
.filter((word) => word)
|
||||
.map((word, index) =>
|
||||
index === 0 ? word : word[0].toLocaleUpperCase() + word.substring(1)
|
||||
)
|
||||
.join('')
|
||||
|
||||
// Remove non-alpha-numeric-underscore chars.
|
||||
const regex = /(?:^|\s)(?:[a-z0-9_]+)/gi
|
||||
return (camelCase.match(regex) || [])[0] ?? ''
|
||||
}
|
50
common/util/math.ts
Normal file
50
common/util/math.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { sortBy, sum } from 'lodash'
|
||||
|
||||
export const logInterpolation = (min: number, max: number, value: number) => {
|
||||
if (value <= min) return 0
|
||||
if (value >= max) return 1
|
||||
|
||||
return Math.log(value - min + 1) / Math.log(max - min + 1)
|
||||
}
|
||||
|
||||
export function normpdf(x: number, mean = 0, variance = 1) {
|
||||
if (variance === 0) {
|
||||
return x === mean ? Infinity : 0
|
||||
}
|
||||
|
||||
return (
|
||||
Math.exp((-0.5 * Math.pow(x - mean, 2)) / variance) /
|
||||
Math.sqrt(TAU * variance)
|
||||
)
|
||||
}
|
||||
|
||||
export const TAU = Math.PI * 2
|
||||
|
||||
export function median(xs: number[]) {
|
||||
if (xs.length === 0) return NaN
|
||||
|
||||
const sorted = sortBy(xs, (x) => x)
|
||||
const mid = Math.floor(sorted.length / 2)
|
||||
if (sorted.length % 2 === 0) {
|
||||
return (sorted[mid - 1] + sorted[mid]) / 2
|
||||
}
|
||||
return sorted[mid]
|
||||
}
|
||||
|
||||
export function average(xs: number[]) {
|
||||
return sum(xs) / xs.length
|
||||
}
|
||||
|
||||
const EPSILON = 0.00000001
|
||||
|
||||
export function floatingEqual(a: number, b: number, epsilon = EPSILON) {
|
||||
return Math.abs(a - b) < epsilon
|
||||
}
|
||||
|
||||
export function floatingGreaterEqual(a: number, b: number, epsilon = EPSILON) {
|
||||
return a + epsilon >= b
|
||||
}
|
||||
|
||||
export function floatingLesserEqual(a: number, b: number, epsilon = EPSILON) {
|
||||
return a - epsilon <= b
|
||||
}
|
39
common/util/object.ts
Normal file
39
common/util/object.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { union } from 'lodash'
|
||||
|
||||
export const removeUndefinedProps = <T extends object>(obj: T): T => {
|
||||
const newObj: any = {}
|
||||
|
||||
for (const key of Object.keys(obj)) {
|
||||
if ((obj as any)[key] !== undefined) newObj[key] = (obj as any)[key]
|
||||
}
|
||||
|
||||
return newObj
|
||||
}
|
||||
|
||||
export const addObjects = <T extends { [key: string]: number }>(
|
||||
obj1: T,
|
||||
obj2: T
|
||||
) => {
|
||||
const keys = union(Object.keys(obj1), Object.keys(obj2))
|
||||
const newObj = {} as any
|
||||
|
||||
for (const key of keys) {
|
||||
newObj[key] = (obj1[key] ?? 0) + (obj2[key] ?? 0)
|
||||
}
|
||||
|
||||
return newObj as T
|
||||
}
|
||||
|
||||
export const subtractObjects = <T extends { [key: string]: number }>(
|
||||
obj1: T,
|
||||
obj2: T
|
||||
) => {
|
||||
const keys = union(Object.keys(obj1), Object.keys(obj2))
|
||||
const newObj = {} as any
|
||||
|
||||
for (const key of keys) {
|
||||
newObj[key] = (obj1[key] ?? 0) - (obj2[key] ?? 0)
|
||||
}
|
||||
|
||||
return newObj as T
|
||||
}
|
115
common/util/parse.ts
Normal file
115
common/util/parse.ts
Normal file
|
@ -0,0 +1,115 @@
|
|||
import { generateText, JSONContent, Node } from '@tiptap/core'
|
||||
import { generateJSON } from '@tiptap/html'
|
||||
// Tiptap starter extensions
|
||||
import { Blockquote } from '@tiptap/extension-blockquote'
|
||||
import { Bold } from '@tiptap/extension-bold'
|
||||
import { BulletList } from '@tiptap/extension-bullet-list'
|
||||
import { Code } from '@tiptap/extension-code'
|
||||
import { CodeBlock } from '@tiptap/extension-code-block'
|
||||
import { Document } from '@tiptap/extension-document'
|
||||
import { HardBreak } from '@tiptap/extension-hard-break'
|
||||
import { Heading } from '@tiptap/extension-heading'
|
||||
import { History } from '@tiptap/extension-history'
|
||||
import { HorizontalRule } from '@tiptap/extension-horizontal-rule'
|
||||
import { Italic } from '@tiptap/extension-italic'
|
||||
import { ListItem } from '@tiptap/extension-list-item'
|
||||
import { OrderedList } from '@tiptap/extension-ordered-list'
|
||||
import { Paragraph } from '@tiptap/extension-paragraph'
|
||||
import { Strike } from '@tiptap/extension-strike'
|
||||
import { Text } from '@tiptap/extension-text'
|
||||
// other tiptap extensions
|
||||
import { Image } from '@tiptap/extension-image'
|
||||
import { Link } from '@tiptap/extension-link'
|
||||
import { Mention } from '@tiptap/extension-mention'
|
||||
import Iframe from './tiptap-iframe'
|
||||
import TiptapTweet from './tiptap-tweet-type'
|
||||
import { find } from 'linkifyjs'
|
||||
import { uniq } from 'lodash'
|
||||
import { TiptapSpoiler } from './tiptap-spoiler'
|
||||
|
||||
/** get first url in text. like "notion.so " -> "http://notion.so"; "notion" -> null */
|
||||
export function getUrl(text: string) {
|
||||
const results = find(text, 'url')
|
||||
return results.length ? results[0].href : null
|
||||
}
|
||||
|
||||
// TODO: fuzzy matching
|
||||
export const wordIn = (word: string, corpus: string) =>
|
||||
corpus.toLocaleLowerCase().includes(word.toLocaleLowerCase())
|
||||
|
||||
const checkAgainstQuery = (query: string, corpus: string) =>
|
||||
query.split(' ').every((word) => wordIn(word, corpus))
|
||||
|
||||
export const searchInAny = (query: string, ...fields: string[]) =>
|
||||
fields.some((field) => checkAgainstQuery(query, field))
|
||||
|
||||
/** @return user ids of all \@mentions */
|
||||
export function parseMentions(data: JSONContent): string[] {
|
||||
const mentions = data.content?.flatMap(parseMentions) ?? [] //dfs
|
||||
if (data.type === 'mention' && data.attrs) {
|
||||
mentions.push(data.attrs.id as string)
|
||||
}
|
||||
return uniq(mentions)
|
||||
}
|
||||
|
||||
// TODO: this is a hack to get around the fact that tiptap doesn't have a
|
||||
// way to add a node view without bundling in tsx
|
||||
function skippableComponent(name: string): Node<any, any> {
|
||||
return Node.create({
|
||||
name,
|
||||
|
||||
group: 'block',
|
||||
|
||||
content: 'inline*',
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{
|
||||
tag: 'grid-cards-component',
|
||||
},
|
||||
]
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const stringParseExts = [
|
||||
// StarterKit extensions
|
||||
Blockquote,
|
||||
Bold,
|
||||
BulletList,
|
||||
Code,
|
||||
CodeBlock,
|
||||
Document,
|
||||
HardBreak,
|
||||
Heading,
|
||||
History,
|
||||
HorizontalRule,
|
||||
Italic,
|
||||
ListItem,
|
||||
OrderedList,
|
||||
Paragraph,
|
||||
Strike,
|
||||
Text,
|
||||
// other extensions
|
||||
Link,
|
||||
Image.extend({ renderText: () => '[image]' }),
|
||||
Mention, // user @mention
|
||||
Mention.extend({ name: 'contract-mention' }), // market %mention
|
||||
Iframe.extend({
|
||||
renderText: ({ node }) =>
|
||||
'[embed]' + node.attrs.src ? `(${node.attrs.src})` : '',
|
||||
}),
|
||||
skippableComponent('gridCardsComponent'),
|
||||
skippableComponent('staticReactEmbedComponent'),
|
||||
TiptapTweet.extend({ renderText: () => '[tweet]' }),
|
||||
TiptapSpoiler.extend({ renderHTML: () => ['span', '[spoiler]', 0] }),
|
||||
]
|
||||
|
||||
export function richTextToString(text?: JSONContent) {
|
||||
if (!text) return ''
|
||||
return generateText(text, stringParseExts)
|
||||
}
|
||||
|
||||
export function htmlToRichText(html: string) {
|
||||
return generateJSON(html, stringParseExts)
|
||||
}
|
18
common/util/promise.ts
Normal file
18
common/util/promise.ts
Normal 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
|
||||
}
|
55
common/util/random.ts
Normal file
55
common/util/random.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
export const randomString = (length = 12) =>
|
||||
Math.random()
|
||||
.toString(16)
|
||||
.substring(2, length + 2)
|
||||
|
||||
export function genHash(str: string) {
|
||||
// xmur3
|
||||
let h: number
|
||||
for (let i = 0, h = 1779033703 ^ str.length; i < str.length; i++) {
|
||||
h = Math.imul(h ^ str.charCodeAt(i), 3432918353)
|
||||
h = (h << 13) | (h >>> 19)
|
||||
}
|
||||
return function () {
|
||||
h = Math.imul(h ^ (h >>> 16), 2246822507)
|
||||
h = Math.imul(h ^ (h >>> 13), 3266489909)
|
||||
return (h ^= h >>> 16) >>> 0
|
||||
}
|
||||
}
|
||||
|
||||
export function createRNG(seed: string) {
|
||||
// https://stackoverflow.com/a/47593316/1592933
|
||||
|
||||
const gen = genHash(seed)
|
||||
let [a, b, c, d] = [gen(), gen(), gen(), gen()]
|
||||
|
||||
// sfc32
|
||||
return function () {
|
||||
a >>>= 0
|
||||
b >>>= 0
|
||||
c >>>= 0
|
||||
d >>>= 0
|
||||
let t = (a + b) | 0
|
||||
a = b ^ (b >>> 9)
|
||||
b = (c + (c << 3)) | 0
|
||||
c = (c << 21) | (c >>> 11)
|
||||
d = (d + 1) | 0
|
||||
t = (t + d) | 0
|
||||
c = (c + t) | 0
|
||||
return (t >>> 0) / 4294967296
|
||||
}
|
||||
}
|
||||
|
||||
export const shuffle = (array: unknown[], rand: () => number) => {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const swapIndex = Math.floor(rand() * (array.length - i))
|
||||
;[array[i], array[swapIndex]] = [array[swapIndex], array[i]]
|
||||
}
|
||||
}
|
||||
|
||||
export function chooseRandomSubset<T>(items: T[], count: number) {
|
||||
const fiveMinutes = 5 * 60 * 1000
|
||||
const seed = Math.round(Date.now() / fiveMinutes).toString()
|
||||
shuffle(items, createRNG(seed))
|
||||
return items.slice(0, count)
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
export const slugify = (text: any, separator = '-'): string => {
|
||||
export const slugify = (
|
||||
text: string,
|
||||
separator = '-',
|
||||
maxLength = 35
|
||||
): string => {
|
||||
return text
|
||||
.toString()
|
||||
.normalize('NFD') // split an accented letter in the base letter and the acent
|
||||
|
@ -7,4 +11,6 @@ export const slugify = (text: any, separator = '-'): string => {
|
|||
.trim()
|
||||
.replace(/[^a-z0-9 ]/g, '') // remove all chars not letters, numbers and spaces (to be replaced)
|
||||
.replace(/\s+/g, separator)
|
||||
.substring(0, maxLength)
|
||||
.replace(new RegExp(separator + '+$', 'g'), '') // remove terminal separators
|
||||
}
|
6
common/util/time.ts
Normal file
6
common/util/time.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export const MINUTE_MS = 60 * 1000
|
||||
export const HOUR_MS = 60 * MINUTE_MS
|
||||
export const DAY_MS = 24 * HOUR_MS
|
||||
|
||||
export const sleep = (ms: number) =>
|
||||
new Promise((resolve) => setTimeout(resolve, ms))
|
100
common/util/tiptap-iframe.ts
Normal file
100
common/util/tiptap-iframe.ts
Normal file
|
@ -0,0 +1,100 @@
|
|||
// Adopted from https://github.com/ueberdosis/tiptap/blob/main/demos/src/Experiments/Embeds/Vue/iframe.ts
|
||||
|
||||
import { Node } from '@tiptap/core'
|
||||
|
||||
export interface IframeOptions {
|
||||
allowFullscreen: boolean
|
||||
HTMLAttributes: {
|
||||
[key: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands<ReturnType> {
|
||||
iframe: {
|
||||
setIframe: (options: { src: string }) => ReturnType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// These classes style the outer wrapper and the inner iframe;
|
||||
// Adopted from css in https://github.com/ueberdosis/tiptap/blob/main/demos/src/Experiments/Embeds/Vue/index.vue
|
||||
const wrapperClasses = 'relative h-auto w-full overflow-hidden'
|
||||
const iframeClasses = 'absolute top-0 left-0 h-full w-full'
|
||||
|
||||
export default Node.create<IframeOptions>({
|
||||
name: 'iframe',
|
||||
|
||||
group: 'block',
|
||||
|
||||
atom: true,
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
allowFullscreen: true,
|
||||
HTMLAttributes: {
|
||||
class: 'iframe-wrapper' + ' ' + wrapperClasses,
|
||||
// Tailwind JIT doesn't seem to pick up `pb-[20rem]`, so we hack this in:
|
||||
style: 'padding-bottom: 20rem; ',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
src: {
|
||||
default: null,
|
||||
},
|
||||
frameborder: {
|
||||
default: 0,
|
||||
},
|
||||
height: {
|
||||
default: 0,
|
||||
},
|
||||
allowfullscreen: {
|
||||
default: this.options.allowFullscreen,
|
||||
parseHTML: () => this.options.allowFullscreen,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [{ tag: 'iframe' }]
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
this.options.HTMLAttributes.style =
|
||||
this.options.HTMLAttributes.style +
|
||||
' height: ' +
|
||||
HTMLAttributes.height +
|
||||
';'
|
||||
return [
|
||||
'div',
|
||||
this.options.HTMLAttributes,
|
||||
[
|
||||
'iframe',
|
||||
{
|
||||
...HTMLAttributes,
|
||||
class: HTMLAttributes.class + ' ' + iframeClasses,
|
||||
},
|
||||
],
|
||||
]
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
setIframe:
|
||||
(options: { src: string }) =>
|
||||
({ tr, dispatch }) => {
|
||||
const { selection } = tr
|
||||
const node = this.type.create(options)
|
||||
|
||||
if (dispatch) {
|
||||
tr.replaceRangeWith(selection.from, selection.to, node)
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
116
common/util/tiptap-spoiler.ts
Normal file
116
common/util/tiptap-spoiler.ts
Normal file
|
@ -0,0 +1,116 @@
|
|||
// adapted from @n8body/tiptap-spoiler
|
||||
|
||||
import {
|
||||
Mark,
|
||||
markInputRule,
|
||||
markPasteRule,
|
||||
mergeAttributes,
|
||||
} from '@tiptap/core'
|
||||
import type { ElementType } from 'react'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands<ReturnType> {
|
||||
spoilerEditor: {
|
||||
setSpoiler: () => ReturnType
|
||||
toggleSpoiler: () => ReturnType
|
||||
unsetSpoiler: () => ReturnType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type SpoilerOptions = {
|
||||
HTMLAttributes: Record<string, any>
|
||||
spoilerOpenClass: string
|
||||
spoilerCloseClass?: string
|
||||
inputRegex: RegExp
|
||||
pasteRegex: RegExp
|
||||
as: ElementType
|
||||
}
|
||||
|
||||
const spoilerInputRegex = /(?:^|\s)((?:\|\|)((?:[^||]+))(?:\|\|))$/
|
||||
const spoilerPasteRegex = /(?:^|\s)((?:\|\|)((?:[^||]+))(?:\|\|))/g
|
||||
|
||||
export const TiptapSpoiler = Mark.create<SpoilerOptions>({
|
||||
name: 'spoiler',
|
||||
|
||||
inline: true,
|
||||
group: 'inline',
|
||||
inclusive: false,
|
||||
exitable: true,
|
||||
content: 'inline*',
|
||||
|
||||
priority: 1001, // higher priority than other formatting so they go inside
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
HTMLAttributes: { 'aria-label': 'spoiler' },
|
||||
spoilerOpenClass: '',
|
||||
spoilerCloseClass: undefined,
|
||||
inputRegex: spoilerInputRegex,
|
||||
pasteRegex: spoilerPasteRegex,
|
||||
as: 'span',
|
||||
editing: false,
|
||||
}
|
||||
},
|
||||
|
||||
addCommands() {
|
||||
return {
|
||||
setSpoiler:
|
||||
() =>
|
||||
({ commands }) =>
|
||||
commands.setMark(this.name),
|
||||
toggleSpoiler:
|
||||
() =>
|
||||
({ commands }) =>
|
||||
commands.toggleMark(this.name),
|
||||
unsetSpoiler:
|
||||
() =>
|
||||
({ commands }) =>
|
||||
commands.unsetMark(this.name),
|
||||
}
|
||||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
markInputRule({
|
||||
find: this.options.inputRegex,
|
||||
type: this.type,
|
||||
}),
|
||||
]
|
||||
},
|
||||
|
||||
addPasteRules() {
|
||||
return [
|
||||
markPasteRule({
|
||||
find: this.options.pasteRegex,
|
||||
type: this.type,
|
||||
}),
|
||||
]
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{
|
||||
tag: 'span',
|
||||
getAttrs: (node) =>
|
||||
(node as HTMLElement).ariaLabel?.toLowerCase() === 'spoiler' && null,
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
const elem = document.createElement(this.options.as as string)
|
||||
|
||||
Object.entries(
|
||||
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
||||
class: this.options.spoilerCloseClass ?? this.options.spoilerOpenClass,
|
||||
})
|
||||
).forEach(([attr, val]) => elem.setAttribute(attr, val))
|
||||
|
||||
elem.addEventListener('click', () => {
|
||||
elem.setAttribute('class', this.options.spoilerOpenClass)
|
||||
})
|
||||
|
||||
return elem
|
||||
},
|
||||
})
|
37
common/util/tiptap-tweet-type.ts
Normal file
37
common/util/tiptap-tweet-type.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
|
||||
export interface TweetOptions {
|
||||
tweetId: string
|
||||
}
|
||||
|
||||
// This is a version of the Tiptap Node config without addNodeView,
|
||||
// since that would require bundling in tsx
|
||||
export const TiptapTweetNode = {
|
||||
name: 'tiptapTweet',
|
||||
group: 'block',
|
||||
atom: true,
|
||||
|
||||
addAttributes() {
|
||||
return {
|
||||
tweetId: {
|
||||
default: null,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
parseHTML() {
|
||||
return [
|
||||
{
|
||||
tag: 'tiptap-tweet',
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
renderHTML(props: { HTMLAttributes: Record<string, any> }) {
|
||||
return ['tiptap-tweet', mergeAttributes(props.HTMLAttributes)]
|
||||
},
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
export default Node.create<TweetOptions>(TiptapTweetNode)
|
13
common/yarn.lock
Normal file
13
common/yarn.lock
Normal file
|
@ -0,0 +1,13 @@
|
|||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/lodash@4.14.178":
|
||||
version "4.14.178"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8"
|
||||
integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==
|
||||
|
||||
lodash@4.17.21:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
43
dev.sh
Executable file
43
dev.sh
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/bash
|
||||
|
||||
ENV=${1:-dev}
|
||||
case $ENV in
|
||||
dev)
|
||||
FIREBASE_PROJECT=dev
|
||||
NEXT_ENV=DEV ;;
|
||||
prod)
|
||||
FIREBASE_PROJECT=prod
|
||||
NEXT_ENV=PROD ;;
|
||||
localdb)
|
||||
FIREBASE_PROJECT=dev
|
||||
NEXT_ENV=DEV
|
||||
EMULATOR=true ;;
|
||||
*)
|
||||
echo "Invalid environment; must be dev, prod, or localdb."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
firebase use $FIREBASE_PROJECT
|
||||
|
||||
if [ ! -z $EMULATOR ]
|
||||
then
|
||||
npx concurrently \
|
||||
-n FIRESTORE,FUNCTIONS,NEXT,TS \
|
||||
-c green,white,magenta,cyan \
|
||||
"yarn --cwd=functions localDbScript" \
|
||||
"cross-env FIRESTORE_EMULATOR_HOST=localhost:8080 yarn --cwd=functions dev" \
|
||||
"cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8088 \
|
||||
NEXT_PUBLIC_FIREBASE_EMULATE=TRUE \
|
||||
NEXT_PUBLIC_FIREBASE_ENV=${NEXT_ENV} \
|
||||
yarn --cwd=web serve" \
|
||||
"cross-env yarn --cwd=web ts-watch"
|
||||
else
|
||||
npx concurrently \
|
||||
-n FUNCTIONS,NEXT,TS \
|
||||
-c white,magenta,cyan \
|
||||
"yarn --cwd=functions dev" \
|
||||
"cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8088 \
|
||||
NEXT_PUBLIC_FIREBASE_ENV=${NEXT_ENV} \
|
||||
yarn --cwd=web serve" \
|
||||
"cross-env yarn --cwd=web ts-watch"
|
||||
fi
|
2
docs/.gitattributes
vendored
Normal file
2
docs/.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
20
docs/.gitignore
vendored
Normal file
20
docs/.gitignore
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Dependencies
|
||||
/node_modules
|
||||
|
||||
# Production
|
||||
/build
|
||||
|
||||
# Generated files
|
||||
.docusaurus
|
||||
.cache-loader
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
2
docs/.prettierignore
Normal file
2
docs/.prettierignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
.docusaurus/
|
||||
build/
|
11
docs/README.md
Normal file
11
docs/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# docs
|
||||
|
||||
Manifold Markets Docs
|
||||
|
||||
## Getting started
|
||||
|
||||
0. Make sure you have [Yarn 1.x][yarn]
|
||||
1. `$ cd docs`
|
||||
2. `$ yarn`
|
||||
3. `$ yarn start`
|
||||
4. The docs site will be available on http://localhost:3000
|
3
docs/babel.config.js
Normal file
3
docs/babel.config.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
|
||||
}
|
61
docs/docs/$how-to.md
Normal file
61
docs/docs/$how-to.md
Normal file
|
@ -0,0 +1,61 @@
|
|||
# How to Manifold
|
||||
|
||||
Manifold Markets is a novel site where users can bet against each other to predict the outcomes of all types of questions. Engage in intense discussion, or joke with friends, whilst putting play-money where your mouth is.
|
||||
|
||||
## Mana
|
||||
|
||||
Mana (M$) is our virtual play currency that cannot be converted to real money.
|
||||
|
||||
- **Its Value**
|
||||
|
||||
You can redeem your Mana and we will [donate to a charity](https://manifold.markets/charity) on your behalf. Redeeming and purchasing Mana occurs at a rate of M$100 to $1. You will be able to redeem it for merch and other cool items soon too!
|
||||
|
||||
- **It sets us apart**
|
||||
|
||||
Using play-money sets us apart from other similar sites as we don’t want our users to solely focus on monetary gains. Instead we prioritize providing value in the form of an enjoyable experience and facilitating a more informed world through the power of prediction markets.
|
||||
|
||||
## How probabilities work
|
||||
|
||||
The probability of a market represents what the collective bets of users predict the chances of an outcome occurring is. How this is calculated depends on the type of market - see below!
|
||||
|
||||
## Types of markets
|
||||
|
||||
There are currently 3 types of markets: Yes/No (binary), Free response, and Numerical.
|
||||
|
||||
- **Yes/No (Binary)**
|
||||
|
||||
The creator asks a question where traders can bet yes or no.
|
||||
|
||||
Check out [Maniswap](https://www.notion.so/Maniswap-ce406e1e897d417cbd491071ea8a0c39) for more info on its automated market maker.
|
||||
|
||||
- **Free Response**
|
||||
|
||||
The creator asks an open ended question. Both the creator and users can propose answers which can be bet on. Don’t be intimidated to add new answers! The payout system and initial liquidity rewards users who bet on new answers early. The algorithm used to determine the probability and payout is complicated but if you want to learn more check out [DPM](https://www.notion.so/DPM-b9b48a09ea1f45b88d991231171730c5).
|
||||
|
||||
- **Numerical**
|
||||
|
||||
Retracted whilst we make improvements. You still may see some old ones floating around though. Questions which can be answered by a number within a given range. Betting on a value will cause you to buy shares from ‘buckets’ surrounding the number you choose.
|
||||
|
||||
## Compete and build your portfolio
|
||||
|
||||
Generate profits to prove your expertise and shine above your friends.
|
||||
|
||||
To the moon 🚀
|
||||
|
||||
- **Find inaccurate probabilities**
|
||||
|
||||
Use your superior knowledge on topics to identify markets which have inaccurate probabilities. This gives you favorable odds, so bet accordingly to shift the probability to what you think it should be.
|
||||
|
||||
- **React to news**
|
||||
|
||||
Markets are dynamic and ongoing events can drastically affect what the probability should look like. Be the keenest to react and there is a lot of Mana to be made.
|
||||
|
||||
- **Buy low, sell high**
|
||||
|
||||
Similar to a stock market, probabilities can be overvalued and undervalued. If you bet (buy shares) at one end of the spectrum and subsequently other users buy even more shares of that same type, the value of your own shares will increase. Sometimes it will be most profitable to wait for the market to resolve but often it can be wise to sell your shares and take the immediate profits. This can also be a great way to free up Mana if you are lacking funds.
|
||||
|
||||
- **Create innovative answers**
|
||||
|
||||
Certain free response markets provide room for creativity! The answers themselves can often affect the outcome based on how compelling they are.
|
||||
|
||||
More questions? Check out **[this community-driven FAQ](https://docs.manifold.markets/faq)**!
|
71
docs/docs/about.md
Normal file
71
docs/docs/about.md
Normal file
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
id: about
|
||||
slug: /
|
||||
---
|
||||
|
||||
# About Manifold Markets
|
||||
|
||||
Manifold Markets lets anyone create a prediction market on any topic. Win virtual play money betting on what you know, from **[chess tournaments](https://manifold.markets/SG/will-magnus-carlsen-lose-any-regula)** to **[lunar collisions](https://manifold.markets/Duncan/will-the-wayward-falcon-9-booster-h)** to **[newsletter subscriber rates](https://manifold.markets/Nu%C3%B1oSempere/how-many-additional-subscribers-wil)** - or learn about the future by creating your own market!
|
||||
|
||||
### **What are prediction markets?**
|
||||
|
||||
**Prediction markets are a place where you can bet on the outcome of future events.**
|
||||
|
||||
Consider a question like: "Will Democrats win the 2024 US presidential election?"
|
||||
|
||||
If I think the Democrats are very likely to win, and you disagree, I might offer $70 to your $30 (with the winner taking home $100 total). This set of bets imply a 70% probability of the Democrats winning.
|
||||
|
||||
Now, you or I could be mistaken and overshooting the true probability one way or another. If so, there's an incentive for someone else to bet and correct it! Over time, the implied probability will converge to the **[market's best estimate](https://en.wikipedia.org/wiki/Efficient-market_hypothesis)**. Since these probabilities are public, anyone can use them to make better decisions!
|
||||
|
||||
### **Can prediction markets work without real money?**
|
||||
|
||||
Yes! There is substantial evidence that play-money prediction markets provide real predictive power. Examples include **[sports betting](http://www.electronicmarkets.org/fileadmin/user_upload/doc/Issues/Volume_16/Issue_01/V16I1_Statistical_Tests_of_Real-Money_versus_Play-Money_Prediction_Markets.pdf)** and internal prediction markets at firms like **[Google](https://www.networkworld.com/article/2284098/google-bets-on-value-of-prediction-markets.html)**.
|
||||
|
||||
Our overall design also ensures that good forecasting will come out on top in the long term. In the competitive environment of the marketplace, bettors that are correct more often will gain influence, leading to better-calibrated forecasts over time.
|
||||
|
||||
Since our launch, we've seen hundreds of users trade each day, on over a thousand different markets! You can track the popularity of our platform at **[https://manifold.markets/stats](https://manifold.markets/stats)**.
|
||||
|
||||
### **Why is this important?**
|
||||
|
||||
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.
|
||||
|
||||
Prediction markets can predict **[which research papers will replicate](https://www.pnas.org/content/112/50/15343)**; 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.
|
||||
|
||||
### **How are markets resolved?**
|
||||
|
||||
The creator of the prediction market decides the outcome and earns a commission based on the trade volume.
|
||||
|
||||
This simple resolution mechanism has surprising benefits in allowing a diversity of views to flourish. Competition between market creators will lead to traders flocking to the creators with good judgment on market resolution.
|
||||
|
||||
What's more, when the creator is free to use their judgment, many new kinds of prediction markets can be created that are less objective or even personal. (E.g. "Will I enjoy participating in the Metaverse in 2023?")
|
||||
|
||||
<!-- ### **Can I create private markets?**
|
||||
|
||||
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.
|
||||
|
||||
If this sounds like something you’d want, **[join the waitlist here](https://docs.google.com/forms/d/e/1FAIpQLSfM_rxRHemCjKE6KPiYXGyP2nBSInZNKn_wc7yS1-rvlLAVnA/viewform?usp=sf_link)**! -->
|
||||
|
||||
### **Who are we?**
|
||||
|
||||
Manifold Markets is currently a team of three:
|
||||
|
||||
- James Grugett
|
||||
- Stephen Grugett
|
||||
- Austin Chen
|
||||
|
||||
We've previously launched consumer-facing startups (**[Throne](https://throne.live/)**, **[One Word](https://oneword.games/platform)**), and worked at top tech and trading firms (Google, Susquehanna).
|
||||
|
||||
## **Talk to us!**
|
||||
|
||||
Questions? Comments? Want to create a market? Talk to us!
|
||||
|
||||
- Email: **[info@manifold.markets](mailto:info@manifold.markets)**
|
||||
- Office hours:
|
||||
- **[Calendly — Austin](https://calendly.com/austinchen/manifold)**
|
||||
- **[Calendly — James](https://calendly.com/jamesgrugett/manifold)**
|
||||
- Chat: **[Manifold Markets Discord server](https://discord.gg/eHQBNBqXuh)**
|
||||
|
||||
## **Further Reading**
|
||||
|
||||
- **[Above the fold](https://manifoldmarkets.substack.com/)**, our newsletter
|
||||
- **[Scott Alexander on play-money prediction markets](https://astralcodexten.substack.com/p/play-money-and-reputation-systems)**
|
789
docs/docs/api.md
Normal file
789
docs/docs/api.md
Normal file
|
@ -0,0 +1,789 @@
|
|||
# API
|
||||
|
||||
:::caution
|
||||
|
||||
Our API is still in alpha — things may change or break at any time!
|
||||
|
||||
If you have questions, come chat with us on [Discord](https://discord.com/invite/eHQBNBqXuh). We’d love to hear about what you build!
|
||||
|
||||
:::
|
||||
|
||||
## General notes
|
||||
|
||||
Some APIs are not associated with any particular user. Other APIs require authentication.
|
||||
|
||||
APIs that require authentication accept an `Authorization` header in one of two formats:
|
||||
|
||||
- `Authorization: Key {key}`. A Manifold API key associated with a user
|
||||
account. Each account may have zero or one API keys. To generate an API key
|
||||
for your account, visit your user profile, click "edit", and click the
|
||||
"refresh" button next to the API key field at the bottom. You can click it
|
||||
again any time to invalidate your existing key and generate a new one.
|
||||
|
||||
- `Authorization: Bearer {jwt}`. A signed JWT from Firebase asserting your
|
||||
identity. This is what our web client uses. It will probably be annoying for
|
||||
you to generate and we will not document it further here.
|
||||
|
||||
API requests that accept parameters should either have the parameters in the
|
||||
query string if they are GET requests, or have a body with a JSON object with
|
||||
one property per parameter if they are POST requests.
|
||||
|
||||
API responses should always either have a body with a JSON result object (if
|
||||
the response was a 200) or with a JSON object representing an error (if the
|
||||
response was a 4xx or 5xx.)
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `GET /v0/user/[username]`
|
||||
|
||||
Gets a user by their username. Remember that usernames may change.
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
### `GET /v0/user/by-id/[id]`
|
||||
|
||||
Gets a user by their unique ID. Many other API endpoints return this as the `userId`.
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
### GET /v0/me
|
||||
|
||||
Returns the authenticated user.
|
||||
|
||||
### `GET /v0/groups`
|
||||
|
||||
Gets all groups, in no particular order.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `availableToUserId`: Optional. if specified, only groups that the user can
|
||||
join and groups they've already joined will be returned.
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
### `GET /v0/group/[slug]`
|
||||
|
||||
Gets a group by its slug.
|
||||
|
||||
Requires no authorization.
|
||||
Note: group is singular in the URL.
|
||||
|
||||
### `GET /v0/group/by-id/[id]`
|
||||
|
||||
Gets a group by its unique ID.
|
||||
|
||||
Requires no authorization.
|
||||
Note: group is singular in the URL.
|
||||
|
||||
### `GET /v0/group/by-id/[id]/markets`
|
||||
|
||||
Gets a group's markets by its unique ID.
|
||||
|
||||
Requires no authorization.
|
||||
Note: group is singular in the URL.
|
||||
|
||||
### `GET /v0/markets`
|
||||
|
||||
Lists all markets, ordered by creation date descending.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `limit`: Optional. How many markets to return. The maximum and the default is 1000.
|
||||
- `before`: Optional. The ID of the market before which the list will start. For
|
||||
example, if you ask for the most recent 10 markets, and then perform a second
|
||||
query for 10 more markets with `before=[the id of the 10th market]`, you will
|
||||
get markets 11 through 20.
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
- Example request
|
||||
```
|
||||
https://manifold.markets/api/v0/markets?limit=1
|
||||
```
|
||||
- Example response
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id":"EvIhzcJXwhL0HavaszD7",
|
||||
"creatorUsername":"Austin",
|
||||
"creatorName":"Austin",
|
||||
"createdTime":1653850472294,
|
||||
"creatorAvatarUrl":"https://lh3.googleusercontent.com/a-/AOh14GiZyl1lBehuBMGyJYJhZd-N-mstaUtgE4xdI22lLw=s96-c",
|
||||
"closeTime":1653893940000,
|
||||
"question":"Will I write a new blog post today?",
|
||||
"tags":[
|
||||
"personal",
|
||||
"commitments"
|
||||
],
|
||||
"url":"https://manifold.markets/Austin/will-i-write-a-new-blog-post-today",
|
||||
"pool":146.73022894879944,
|
||||
"probability":0.8958175225896258,
|
||||
"p":0.08281474972181882,
|
||||
"totalLiquidity":102.65696071594805,
|
||||
"outcomeType":"BINARY",
|
||||
"mechanism":"cpmm-1",
|
||||
"volume":241,
|
||||
"volume7Days":0,
|
||||
"volume24Hours":0,
|
||||
"isResolved":true,
|
||||
"resolution":"YES",
|
||||
"resolutionTime":1653924077078
|
||||
},
|
||||
...
|
||||
```
|
||||
- Response type: Array of `LiteMarket`
|
||||
|
||||
```tsx
|
||||
// Information about a market, but without bets or comments
|
||||
type LiteMarket = {
|
||||
// Unique identifer for this market
|
||||
id: string
|
||||
|
||||
// Attributes about the creator
|
||||
creatorUsername: string
|
||||
creatorName: string
|
||||
createdTime: number // milliseconds since epoch
|
||||
creatorAvatarUrl?: string
|
||||
|
||||
// Market attributes. All times are in milliseconds since epoch
|
||||
closeTime?: number // Min of creator's chosen date, and resolutionTime
|
||||
question: string
|
||||
|
||||
// A list of tags on each market. Any user can add tags to any market.
|
||||
// This list also includes the predefined categories shown as filters on the home page.
|
||||
tags: string[]
|
||||
|
||||
// Note: This url always points to https://manifold.markets, regardless of what instance the api is running on.
|
||||
// This url includes the creator's username, but this doesn't need to be correct when constructing valid URLs.
|
||||
// i.e. https://manifold.markets/Austin/test-market is the same as https://manifold.markets/foo/test-market
|
||||
url: string
|
||||
|
||||
outcomeType: string // BINARY, FREE_RESPONSE, MULTIPLE_CHOICE, NUMERIC, or PSEUDO_NUMERIC
|
||||
mechanism: string // dpm-2 or cpmm-1
|
||||
|
||||
probability: number
|
||||
pool: { outcome: number } // For CPMM markets, the number of shares in the liquidity pool. For DPM markets, the amount of mana invested in each answer.
|
||||
p?: number // CPMM markets only, probability constant in y^p * n^(1-p) = k
|
||||
totalLiquidity?: number // CPMM markets only, the amount of mana deposited into the liquidity pool
|
||||
min?: number // PSEUDO_NUMERIC markets only, the minimum resolvable value
|
||||
max?: number // PSEUDO_NUMERIC markets only, the maximum resolvable value
|
||||
isLogScale?: bool // PSEUDO_NUMERIC markets only, if true `number = (max - min + 1)^probability + minstart - 1`, otherwise `number = min + (max - min) * probability`
|
||||
|
||||
volume: number
|
||||
volume7Days: number
|
||||
volume24Hours: number
|
||||
|
||||
isResolved: boolean
|
||||
resolutionTime?: number
|
||||
resolution?: string
|
||||
resolutionProbability?: number // Used for BINARY markets resolved to MKT
|
||||
|
||||
lastUpdatedTime?: number
|
||||
}
|
||||
```
|
||||
|
||||
### `GET /v0/market/[marketId]`
|
||||
|
||||
Gets information about a single market by ID. Includes comments, bets, and answers.
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
- Example request
|
||||
|
||||
```
|
||||
https://manifold.markets/api/v0/market/3zspH9sSzMlbFQLn9GKR
|
||||
```
|
||||
|
||||
- <details><summary>Example response</summary><p>
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "lEoqtnDgJzft6apSKzYK",
|
||||
"creatorUsername": "Angela",
|
||||
"creatorName": "Angela",
|
||||
"createdTime": 1655258914863,
|
||||
"creatorAvatarUrl": "https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FAngela%2F50463444807_edfd4598d6_o.jpeg?alt=media&token=ef44e13b-2e6c-4498-b9c4-8e38bdaf1476",
|
||||
"closeTime": 1655265001448,
|
||||
"question": "What is good?",
|
||||
"description": "Resolves proportionally to the answer(s) which I find most compelling. (Obviously I’ll refrain from giving my own answers)\n\n(Please have at it with philosophy, ethics, etc etc)\n\n\nContract resolved automatically.",
|
||||
"tags": [],
|
||||
"url": "https://manifold.markets/Angela/what-is-good",
|
||||
"pool": null,
|
||||
"outcomeType": "FREE_RESPONSE",
|
||||
"mechanism": "dpm-2",
|
||||
"volume": 112,
|
||||
"volume7Days": 212,
|
||||
"volume24Hours": 0,
|
||||
"isResolved": true,
|
||||
"resolution": "MKT",
|
||||
"resolutionTime": 1655265001448,
|
||||
"answers": [
|
||||
{
|
||||
"createdTime": 1655258941573,
|
||||
"avatarUrl": "https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FAngela%2F50463444807_edfd4598d6_o.jpeg?alt=media&token=ef44e13b-2e6c-4498-b9c4-8e38bdaf1476",
|
||||
"id": "1",
|
||||
"username": "Angela",
|
||||
"number": 1,
|
||||
"name": "Angela",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"text": "ANTE",
|
||||
"userId": "qe2QqIlOkeWsbljfeF3MsxpSJ9i2",
|
||||
"probability": 0.66749733001068
|
||||
},
|
||||
{
|
||||
"name": "Isaac King",
|
||||
"username": "IsaacKing",
|
||||
"text": "This answer",
|
||||
"userId": "y1hb6k7txdZPV5mgyxPFApZ7nQl2",
|
||||
"id": "2",
|
||||
"number": 2,
|
||||
"avatarUrl": "https://lh3.googleusercontent.com/a-/AOh14GhNVriOvxK2VUAmE-jvYZwC-XIymatzVirT0Bqb2g=s96-c",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"createdTime": 1655261198074,
|
||||
"probability": 0.008922214311142757
|
||||
},
|
||||
{
|
||||
"createdTime": 1655263226587,
|
||||
"userId": "jbgplxty4kUKIa1MmgZk22byJq03",
|
||||
"id": "3",
|
||||
"avatarUrl": "https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FMartin%2Fgiphy.gif?alt=media&token=422ef610-553f-47e3-bf6f-c0c5cc16c70a",
|
||||
"text": "Toyota Camry",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"name": "Undox",
|
||||
"username": "Undox",
|
||||
"number": 3,
|
||||
"probability": 0.008966714133143469
|
||||
},
|
||||
{
|
||||
"number": 4,
|
||||
"name": "James Grugett",
|
||||
"userId": "5LZ4LgYuySdL1huCWe7bti02ghx2",
|
||||
"text": "Utility (Defined by your personal utility function.)",
|
||||
"createdTime": 1655264793224,
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"username": "JamesGrugett",
|
||||
"id": "4",
|
||||
"avatarUrl": "https://lh3.googleusercontent.com/a-/AOh14GjC83uMe-fEfzd6QvxiK6ZqZdlMytuHxevgMYIkpAI=s96-c",
|
||||
"probability": 0.09211463154147384
|
||||
}
|
||||
],
|
||||
"comments": [
|
||||
{
|
||||
"id": "ZdHIyfQazHyl8nI0ENS7",
|
||||
"userId": "qe2QqIlOkeWsbljfeF3MsxpSJ9i2",
|
||||
"createdTime": 1655265807433,
|
||||
"text": "ok what\ni did not resolve this intentionally",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"userName": "Angela",
|
||||
"userAvatarUrl": "https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FAngela%2F50463444807_edfd4598d6_o.jpeg?alt=media&token=ef44e13b-2e6c-4498-b9c4-8e38bdaf1476",
|
||||
"userUsername": "Angela"
|
||||
},
|
||||
{
|
||||
"userName": "James Grugett",
|
||||
"userUsername": "JamesGrugett",
|
||||
"id": "F7fvHGhTiFal8uTsUc9P",
|
||||
"userAvatarUrl": "https://lh3.googleusercontent.com/a-/AOh14GjC83uMe-fEfzd6QvxiK6ZqZdlMytuHxevgMYIkpAI=s96-c",
|
||||
"replyToCommentId": "ZdHIyfQazHyl8nI0ENS7",
|
||||
"text": "@Angela Sorry! There was an error that automatically resolved several markets that were created in the last few hours.",
|
||||
"createdTime": 1655266286514,
|
||||
"userId": "5LZ4LgYuySdL1huCWe7bti02ghx2",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK"
|
||||
},
|
||||
{
|
||||
"userId": "qe2QqIlOkeWsbljfeF3MsxpSJ9i2",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"id": "PIHhXy5hLHSgW8uoUD0Q",
|
||||
"userName": "Angela",
|
||||
"text": "lmk if anyone lost manna from this situation and i'll try to fix it",
|
||||
"userUsername": "Angela",
|
||||
"createdTime": 1655277581308,
|
||||
"userAvatarUrl": "https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FAngela%2F50463444807_edfd4598d6_o.jpeg?alt=media&token=ef44e13b-2e6c-4498-b9c4-8e38bdaf1476"
|
||||
},
|
||||
{
|
||||
"userAvatarUrl": "https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FAngela%2F50463444807_edfd4598d6_o.jpeg?alt=media&token=ef44e13b-2e6c-4498-b9c4-8e38bdaf1476",
|
||||
"userName": "Angela",
|
||||
"text": "from my end it looks like no one did",
|
||||
"replyToCommentId": "PIHhXy5hLHSgW8uoUD0Q",
|
||||
"createdTime": 1655287149528,
|
||||
"userUsername": "Angela",
|
||||
"id": "5slnWEQWwm6dHjDi6oiH",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"userId": "qe2QqIlOkeWsbljfeF3MsxpSJ9i2"
|
||||
}
|
||||
],
|
||||
"bets": [
|
||||
{
|
||||
"outcome": "0",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"fees": {
|
||||
"liquidityFee": 0,
|
||||
"creatorFee": 0,
|
||||
"platformFee": 0
|
||||
},
|
||||
"isAnte": true,
|
||||
"shares": 100,
|
||||
"probAfter": 1,
|
||||
"amount": 100,
|
||||
"userId": "IPTOzEqrpkWmEzh6hwvAyY9PqFb2",
|
||||
"createdTime": 1655258914863,
|
||||
"probBefore": 0,
|
||||
"id": "2jNZqnwoEQL7WDTTAWDP"
|
||||
},
|
||||
{
|
||||
"shares": 173.20508075688772,
|
||||
"fees": {
|
||||
"platformFee": 0,
|
||||
"liquidityFee": 0,
|
||||
"creatorFee": 0
|
||||
},
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"probBefore": 0,
|
||||
"createdTime": 1655258941573,
|
||||
"loanAmount": 0,
|
||||
"userId": "qe2QqIlOkeWsbljfeF3MsxpSJ9i2",
|
||||
"amount": 100,
|
||||
"outcome": "1",
|
||||
"probAfter": 0.75,
|
||||
"id": "xuc3JoiNkE8lXPh15mUb"
|
||||
},
|
||||
{
|
||||
"userId": "y1hb6k7txdZPV5mgyxPFApZ7nQl2",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"loanAmount": 0,
|
||||
"probAfter": 0.009925496893641248,
|
||||
"id": "8TBlzPtOdO0q5BgSyRbi",
|
||||
"createdTime": 1655261198074,
|
||||
"shares": 20.024984394500787,
|
||||
"amount": 1,
|
||||
"outcome": "2",
|
||||
"probBefore": 0,
|
||||
"fees": {
|
||||
"liquidityFee": 0,
|
||||
"creatorFee": 0,
|
||||
"platformFee": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"probAfter": 0.00987648269777473,
|
||||
"outcome": "3",
|
||||
"id": "9vdwes6s9QxbYZUBhHs4",
|
||||
"createdTime": 1655263226587,
|
||||
"shares": 20.074859899884732,
|
||||
"amount": 1,
|
||||
"loanAmount": 0,
|
||||
"fees": {
|
||||
"liquidityFee": 0,
|
||||
"platformFee": 0,
|
||||
"creatorFee": 0
|
||||
},
|
||||
"userId": "jbgplxty4kUKIa1MmgZk22byJq03",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"probBefore": 0
|
||||
},
|
||||
{
|
||||
"createdTime": 1655264793224,
|
||||
"fees": {
|
||||
"creatorFee": 0,
|
||||
"liquidityFee": 0,
|
||||
"platformFee": 0
|
||||
},
|
||||
"probAfter": 0.09211463154147384,
|
||||
"amount": 10,
|
||||
"id": "BehiSGgk1wAkIWz1a8L4",
|
||||
"userId": "5LZ4LgYuySdL1huCWe7bti02ghx2",
|
||||
"contractId": "lEoqtnDgJzft6apSKzYK",
|
||||
"loanAmount": 0,
|
||||
"probBefore": 0,
|
||||
"outcome": "4",
|
||||
"shares": 64.34283176858165
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
- Response type: A `FullMarket`
|
||||
|
||||
```tsx
|
||||
// A complete market, along with bets, comments, and answers (for free response markets)
|
||||
type FullMarket = LiteMarket & {
|
||||
bets: Bet[]
|
||||
comments: Comment[]
|
||||
answers?: Answer[] // dpm-2 markets only
|
||||
description: JSONContent // Rich text content. See https://tiptap.dev/guide/output#option-1-json
|
||||
textDescription: string // string description without formatting, images, or embeds
|
||||
}
|
||||
|
||||
type Bet = {
|
||||
id: string
|
||||
contractId: string
|
||||
|
||||
amount: number // bet size; negative if SELL bet
|
||||
outcome: string
|
||||
shares: number // dynamic parimutuel pool weight; negative if SELL bet
|
||||
|
||||
probBefore: number
|
||||
probAfter: number
|
||||
|
||||
sale?: {
|
||||
amount: number // amount user makes from sale
|
||||
betId: string // id of bet being sold
|
||||
}
|
||||
|
||||
isSold?: boolean // true if this BUY bet has been sold
|
||||
isAnte?: boolean
|
||||
|
||||
createdTime: number
|
||||
}
|
||||
```
|
||||
|
||||
### `GET /v0/slug/[marketSlug]`
|
||||
|
||||
Gets information about a single market by slug (the portion of the URL path after the username).
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
- Example request
|
||||
```
|
||||
https://manifold.markets/api/v0/slug/will-carrick-flynn-win-the-general
|
||||
```
|
||||
- Response type: A `FullMarket` ; same as above.
|
||||
|
||||
### `GET /v0/users`
|
||||
|
||||
Lists all users.
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
- Example request
|
||||
```
|
||||
https://manifold.markets/api/v0/users
|
||||
```
|
||||
- Example response
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id":"igi2zGXsfxYPgB0DJTXVJVmwCOr2",
|
||||
"createdTime":1639011767273,
|
||||
"name":"Austin",
|
||||
"username":"Austin",
|
||||
"url":"https://manifold.markets/Austin",
|
||||
"avatarUrl":"https://lh3.googleusercontent.com/a-/AOh14GiZyl1lBehuBMGyJYJhZd-N-mstaUtgE4xdI22lLw=s96-c",
|
||||
"bio":"I build Manifold! Always happy to chat; reach out on Discord or find a time on https://calendly.com/austinchen/manifold!",
|
||||
"bannerUrl":"https://images.unsplash.com/photo-1501523460185-2aa5d2a0f981?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1531&q=80",
|
||||
"website":"https://blog.austn.io",
|
||||
"twitterHandle":"akrolsmir",
|
||||
"discordHandle":"akrolsmir#4125",
|
||||
"balance":9122.607163564959,
|
||||
"totalDeposits":10339.004780544328,
|
||||
"totalPnLCached":9376.601262721899,
|
||||
"creatorVolumeCached":76078.46984199001
|
||||
}
|
||||
```
|
||||
- Response type: Array of `LiteUser`
|
||||
|
||||
```tsx
|
||||
// Basic information about a user
|
||||
type LiteUser = {
|
||||
id: string // user's unique id
|
||||
createdTime: number
|
||||
|
||||
name: string // display name, may contain spaces
|
||||
username: string // username, used in urls
|
||||
url: string // link to user's profile
|
||||
avatarUrl?: string
|
||||
|
||||
bio?: string
|
||||
bannerUrl?: string
|
||||
website?: string
|
||||
twitterHandle?: string
|
||||
discordHandle?: string
|
||||
|
||||
// Note: the following are here for convenience only and may be removed in the future.
|
||||
balance: number
|
||||
totalDeposits: number
|
||||
totalPnLCached: number
|
||||
creatorVolumeCached: number
|
||||
}
|
||||
```
|
||||
|
||||
### `POST /v0/bet`
|
||||
|
||||
Places a new bet on behalf of the authorized user.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `amount`: Required. The amount to bet, in M$, before fees.
|
||||
- `contractId`: Required. The ID of the contract (market) to bet on.
|
||||
- `outcome`: Required. The outcome to bet on. For binary markets, this is `YES`
|
||||
or `NO`. For free response markets, this is the ID of the free response
|
||||
answer. For numeric markets, this is a string representing the target bucket,
|
||||
and an additional `value` parameter is required which is a number representing
|
||||
the target value. (Bet on numeric markets at your own peril.)
|
||||
- `limitProb`: Optional. A number between `0.001` and `0.999` inclusive representing
|
||||
the limit probability for your bet (i.e. 0.1% to 99.9% — multiply by 100 for the
|
||||
probability percentage).
|
||||
The bet will execute immediately in the direction of `outcome`, but not beyond this
|
||||
specified limit. If not all the bet is filled, the bet will remain as an open offer
|
||||
that can later be matched against an opposite direction bet.
|
||||
- For example, if the current market probability is `50%`:
|
||||
- A `M$10` bet on `YES` with `limitProb=0.4` would not be filled until the market
|
||||
probability moves down to `40%` and someone bets `M$15` of `NO` to match your
|
||||
bet odds.
|
||||
- A `M$100` bet on `YES` with `limitProb=0.6` would fill partially or completely
|
||||
depending on current unfilled limit bets and the AMM's liquidity. Any remaining
|
||||
portion of the bet not filled would remain to be matched against in the future.
|
||||
- An unfilled limit order bet can be cancelled using the cancel API.
|
||||
|
||||
Example request:
|
||||
|
||||
```
|
||||
$ curl https://manifold.markets/api/v0/bet -X POST -H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Key {...}' \
|
||||
--data-raw '{"amount":1, \
|
||||
"outcome":"YES", \
|
||||
"contractId":"{...}"}'
|
||||
```
|
||||
|
||||
### `POST /v0/bet/cancel/[id]`
|
||||
|
||||
Cancel the limit order of a bet with the specified id. If the bet was unfilled, it will be cancelled so that no other bets will match with it. This is action irreversable.
|
||||
|
||||
### `POST /v0/market`
|
||||
|
||||
Creates a new market on behalf of the authorized user.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `outcomeType`: Required. One of `BINARY`, `FREE_RESPONSE`, `MULTIPLE_CHOICE`, or `PSEUDO_NUMERIC`.
|
||||
- `question`: Required. The headline question for the market.
|
||||
- `description`: Required. A long description describing the rules for the market.
|
||||
- Note: string descriptions do **not** turn into links, mentions, formatted text. Instead, rich text descriptions must be in [TipTap json](https://tiptap.dev/guide/output#option-1-json).
|
||||
- `closeTime`: Required. The time at which the market will close, represented as milliseconds since the epoch.
|
||||
- `tags`: Optional. An array of string tags for the market.
|
||||
|
||||
For binary markets, you must also provide:
|
||||
|
||||
- `initialProb`: An initial probability for the market, between 1 and 99.
|
||||
|
||||
For numeric markets, you must also provide:
|
||||
|
||||
- `min`: The minimum value that the market may resolve to.
|
||||
- `max`: The maximum value that the market may resolve to.
|
||||
- `isLogScale`: If true, your numeric market will increase exponentially from min to max.
|
||||
- `initialValue`: An initial value for the market, between min and max, exclusive.
|
||||
|
||||
For multiple choice markets, you must also provide:
|
||||
|
||||
- `answers`: An array of strings, each of which will be a valid answer for the market.
|
||||
|
||||
Example request:
|
||||
|
||||
```
|
||||
$ curl https://manifold.markets/api/v0/market -X POST -H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Key {...}'
|
||||
--data-raw '{"outcomeType":"BINARY", \
|
||||
"question":"Is there life on Mars?", \
|
||||
"description":"I'm not going to type some long ass example description.", \
|
||||
"closeTime":1700000000000, \
|
||||
"initialProb":25}'
|
||||
```
|
||||
|
||||
### `POST /v0/market/[marketId]/add-liquidity`
|
||||
|
||||
Adds a specified amount of liquidity into the market.
|
||||
|
||||
- `amount`: Required. The amount of liquidity to add, in M$.
|
||||
|
||||
### `POST /v0/market/[marketId]/close`
|
||||
|
||||
Closes a market on behalf of the authorized user.
|
||||
|
||||
- `closeTime`: Optional. Milliseconds since the epoch to close the market at. If not provided, the market will be closed immediately. Cannot provide close time in past.
|
||||
|
||||
### `POST /v0/market/[marketId]/resolve`
|
||||
|
||||
Resolves a market on behalf of the authorized user.
|
||||
|
||||
Parameters:
|
||||
|
||||
For binary markets:
|
||||
|
||||
- `outcome`: Required. One of `YES`, `NO`, `MKT`, or `CANCEL`.
|
||||
- `probabilityInt`: Optional. The probability to use for `MKT` resolution.
|
||||
|
||||
For free response or multiple choice markets:
|
||||
|
||||
- `outcome`: Required. One of `MKT`, `CANCEL`, or a `number` indicating the answer index.
|
||||
- `resolutions`: An array of `{ answer, pct }` objects to use as the weights for resolving in favor of multiple free response options. Can only be set with `MKT` outcome. Note that the total weights must add to 100.
|
||||
|
||||
For numeric markets:
|
||||
|
||||
- `outcome`: Required. One of `CANCEL`, or a `number` indicating the selected numeric bucket ID.
|
||||
- `value`: The value that the market may resolves to.
|
||||
- `probabilityInt`: Required if `value` is present. Should be equal to
|
||||
- If log scale: `log10(value - min + 1) / log10(max - min + 1)`
|
||||
- Otherwise: `(value - min) / (max - min)`
|
||||
|
||||
Example request:
|
||||
|
||||
```
|
||||
# Resolve a binary market
|
||||
$ curl https://manifold.markets/api/v0/market/{marketId}/resolve -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Key {...}' \
|
||||
--data-raw '{"outcome": "YES"}'
|
||||
|
||||
# Resolve a binary market with a specified probability
|
||||
$ curl https://manifold.markets/api/v0/market/{marketId}/resolve -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Key {...}' \
|
||||
--data-raw '{"outcome": "MKT", \
|
||||
"probabilityInt": 75}'
|
||||
|
||||
# Resolve a free response market with a single answer chosen
|
||||
$ curl https://manifold.markets/api/v0/market/{marketId}/resolve -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Key {...}' \
|
||||
--data-raw '{"outcome": 2}'
|
||||
|
||||
# Resolve a free response market with multiple answers chosen
|
||||
$ curl https://manifold.markets/api/v0/market/{marketId}/resolve -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Key {...}' \
|
||||
--data-raw '{"outcome": "MKT", \
|
||||
"resolutions": [ \
|
||||
{"answer": 0, "pct": 50}, \
|
||||
{"answer": 2, "pct": 50} \
|
||||
]}'
|
||||
```
|
||||
|
||||
### `POST /v0/market/[marketId]/sell`
|
||||
|
||||
Sells some quantity of shares in a binary market on behalf of the authorized user.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `outcome`: Optional. One of `YES`, or `NO`. If you leave it off, and you only
|
||||
own one kind of shares, you will sell that kind of shares.
|
||||
- `shares`: Optional. The amount of shares to sell of the outcome given
|
||||
above. If not provided, all the shares you own will be sold.
|
||||
|
||||
Example request:
|
||||
|
||||
```
|
||||
$ curl https://manifold.markets/api/v0/market/{marketId}/sell -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Key {...}' \
|
||||
--data-raw '{"outcome": "YES", "shares": 10}'
|
||||
```
|
||||
|
||||
### `POST /v0/comment`
|
||||
|
||||
Creates a comment in the specified market. Only supports top-level comments for now.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `contractId`: Required. The ID of the market to comment on.
|
||||
- `content`: The comment to post, formatted as [TipTap json](https://tiptap.dev/guide/output#option-1-json), OR
|
||||
- `html`: The comment to post, formatted as an HTML string, OR
|
||||
- `markdown`: The comment to post, formatted as a markdown string.
|
||||
|
||||
### `GET /v0/bets`
|
||||
|
||||
Gets a list of bets, ordered by creation date descending.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `username`: Optional. If set, the response will include only bets created by this user.
|
||||
- `market`: Optional. The slug of a market. If set, the response will only include bets on this market.
|
||||
- `limit`: Optional. How many bets to return. The maximum and the default is 1000.
|
||||
- `before`: Optional. The ID of the bet before which the list will start. For
|
||||
example, if you ask for the most recent 10 bets, and then perform a second
|
||||
query for 10 more bets with `before=[the id of the 10th bet]`, you will
|
||||
get bets 11 through 20.
|
||||
|
||||
Requires no authorization.
|
||||
|
||||
- Example request
|
||||
```
|
||||
https://manifold.markets/api/v0/bets?username=ManifoldMarkets&market=will-i-be-able-to-place-a-limit-ord
|
||||
```
|
||||
- Response type: A `Bet[]`.
|
||||
|
||||
- <details><summary>Example response</summary><p>
|
||||
|
||||
```json
|
||||
[
|
||||
// Limit bet, partially filled.
|
||||
{
|
||||
"isFilled": false,
|
||||
"amount": 15.596681605353808,
|
||||
"userId": "IPTOzEqrpkWmEzh6hwvAyY9PqFb2",
|
||||
"contractId": "Tz5dA01GkK5QKiQfZeDL",
|
||||
"probBefore": 0.5730753474948571,
|
||||
"isCancelled": false,
|
||||
"outcome": "YES",
|
||||
"fees": { "creatorFee": 0, "liquidityFee": 0, "platformFee": 0 },
|
||||
"shares": 31.193363210707616,
|
||||
"limitProb": 0.5,
|
||||
"id": "yXB8lVbs86TKkhWA1FVi",
|
||||
"loanAmount": 0,
|
||||
"orderAmount": 100,
|
||||
"probAfter": 0.5730753474948571,
|
||||
"createdTime": 1659482775970,
|
||||
"fills": [
|
||||
{
|
||||
"timestamp": 1659483249648,
|
||||
"matchedBetId": "MfrMd5HTiGASDXzqibr7",
|
||||
"amount": 15.596681605353808,
|
||||
"shares": 31.193363210707616
|
||||
}
|
||||
]
|
||||
},
|
||||
// Normal bet (no limitProb specified).
|
||||
{
|
||||
"shares": 17.350459904608414,
|
||||
"probBefore": 0.5304358279113885,
|
||||
"isFilled": true,
|
||||
"probAfter": 0.5730753474948571,
|
||||
"userId": "IPTOzEqrpkWmEzh6hwvAyY9PqFb2",
|
||||
"amount": 10,
|
||||
"contractId": "Tz5dA01GkK5QKiQfZeDL",
|
||||
"id": "1LPJHNz5oAX4K6YtJlP1",
|
||||
"fees": {
|
||||
"platformFee": 0,
|
||||
"liquidityFee": 0,
|
||||
"creatorFee": 0.4251333951457593
|
||||
},
|
||||
"isCancelled": false,
|
||||
"loanAmount": 0,
|
||||
"orderAmount": 10,
|
||||
"fills": [
|
||||
{
|
||||
"amount": 10,
|
||||
"matchedBetId": null,
|
||||
"shares": 17.350459904608414,
|
||||
"timestamp": 1659482757271
|
||||
}
|
||||
],
|
||||
"createdTime": 1659482757271,
|
||||
"outcome": "YES"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
## Changelog
|
||||
|
||||
- 2022-09-24: Expand market POST docs to include new market types (`PSEUDO_NUMERIC`, `MULTIPLE_CHOICE`)
|
||||
- 2022-07-15: Add user by username and user by ID APIs
|
||||
- 2022-06-08: Add paging to markets endpoint
|
||||
- 2022-06-05: Add new authorized write endpoints
|
||||
- 2022-02-28: Add `resolutionTime` to markets, change `closeTime` definition
|
||||
- 2022-02-19: Removed user IDs from bets
|
||||
- 2022-02-17: Released our v0 API, with `/markets`, `/market/[marketId]`, and `/slug/[slugId]`
|
47
docs/docs/awesome-manifold.md
Normal file
47
docs/docs/awesome-manifold.md
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Awesome Manifold 😎
|
||||
|
||||
A list of community-created projects built on, or related to, Manifold Markets.
|
||||
|
||||
## Data
|
||||
|
||||
- [Manifold Market Stats](https://wasabipesto.com/jupyter/manifold/)
|
||||
|
||||
## Sites using Manifold
|
||||
|
||||
- [WagerWith.me](https://www.wagerwith.me/) — Bet with your friends, with full Manifold integration to bet with M$.
|
||||
- [Alignment Markets](https://alignmentmarkets.com/) - Bet on the progress of benchmarks in ML safety!
|
||||
|
||||
## API / Dev
|
||||
|
||||
- [PyManifold](https://github.com/bcongdon/PyManifold) - Python client for the Manifold API
|
||||
- [PyManifold fork](https://github.com/gappleto97/PyManifold/) - Fork maintained by [@LivInTheLookingGlass](https://manifold.markets/LivInTheLookingGlass)
|
||||
- [manifold-markets-python](https://github.com/vluzko/manifold-markets-python) - Python tools for working with Manifold Markets (including various accuracy metrics)
|
||||
- [ManifoldMarketManager](https://github.com/gappleto97/ManifoldMarketManager) - Python script and library to automatically manage markets
|
||||
- [manifeed](https://github.com/joy-void-joy/manifeed) - Tool that creates an RSS feed for new Manifold markets
|
||||
- [manifold-sdk](https://github.com/keriwarr/manifold-sdk) - TypeScript/JavaScript client for the Manifold API
|
||||
|
||||
## Bots
|
||||
|
||||
- [@manifold@botsin.space](https://botsin.space/@manifold) - Posts new Manifold markets to Mastodon
|
||||
- [James' Bot](https://github.com/manifoldmarkets/market-maker) — Simple trading bot that makes markets
|
||||
- [mana](https://github.com/AnnikaCodes/mana) - A Discord bot for Manifold by [@arae](https://manifold.markets/arae)
|
||||
|
||||
## Writeups
|
||||
|
||||
- [Information Markets, Decision Markets, Attention Markets, Action Markets](https://astralcodexten.substack.com/p/information-markets-decision-markets) by Scott Alexander
|
||||
- [Mismatched Monetary Motivation in Manifold Markets](https://kevin.zielnicki.com/2022/02/17/manifold/) by Kevin Zielnicki
|
||||
- [Introducing the Salem/CSPI Forecasting Tournament](https://www.cspicenter.com/p/introducing-the-salemcspi-forecasting) by Richard Hanania
|
||||
- [What I learned about running a betting market game night contest](https://shakeddown.wordpress.com/2022/08/04/what-i-learned-about-running-a-betting-market-game-night-contest/) by shakeddown
|
||||
- [Free-riding on prediction markets](https://pedunculate.substack.com/p/free-riding-on-prediction-markets) by John Roxton
|
||||
|
||||
## Art
|
||||
|
||||
- Folded origami and doodles by [@hamnox](https://manifold.markets/hamnox) ![](https://i.imgur.com/nVGY4pL.png)
|
||||
- Laser-cut Foldy by [@wasabipesto](https://manifold.markets/wasabipesto) ![](https://i.imgur.com/g9S6v3P.jpg)
|
||||
|
||||
## Alumni
|
||||
|
||||
_These projects are no longer active, but were really really cool!_
|
||||
|
||||
- [Research.Bet](https://research.bet/) - Prediction market for scientific papers, using Manifold
|
||||
- [CivicDashboard](https://civicdash.org/dashboard) - Uses Manifold to for tracked solutions for the SF city government
|
145
docs/docs/bounties.md
Normal file
145
docs/docs/bounties.md
Normal file
|
@ -0,0 +1,145 @@
|
|||
# Bounties
|
||||
|
||||
## What are Manifold bounties?
|
||||
|
||||
From time to time, a member of our community goes above and beyond in helping Manifold make prediction markets accessible & ubiquitous. We’d like to recognize such contributions publicly, and include a token of our appreciation in the form of M$!
|
||||
|
||||
Examples of community work that may be eligible for a bounty:
|
||||
|
||||
- Blog posts, markets, or comments which lead us to significantly change our views
|
||||
- A track record of creating markets that help people make better decisions
|
||||
- Promoting Manifold & forecasting to a wider audience
|
||||
- Identifying serious exploits with our financial infrastructure
|
||||
|
||||
Our community is the beating heart of Manifold; your individual contributions are what make this platform valuable at all. Thanks to everyone listed here (as well as countless unnamed others) for your help & support!
|
||||
|
||||
## Awarded bounties
|
||||
|
||||
💥 *Awarded on 2022-10-07*
|
||||
|
||||
**[Pepe](https://manifold.markets/Pepe): M$10,000**
|
||||
**[Jack](https://manifold.markets/jack): M$2,000**
|
||||
**[Martin](https://manifold.markets/MartinRandall): M$2,000**
|
||||
**[Yev](https://manifold.markets/Yev): M$2,000**
|
||||
**[Michael](https://manifold.markets/MichaelWheatley): M$2,000**
|
||||
|
||||
- For discovering an infinite mana exploit using limit orders, and informing the Manifold team of it privately.
|
||||
|
||||
**[Matt](https://manifold.markets/MattP): M$5,000**
|
||||
**[Adrian](https://manifold.markets/ahalekelly): M$5,000**
|
||||
**[Yev](https://manifold.markets/Yev): M$5,000**
|
||||
|
||||
- For discovering an AMM liquidity exploit and informing the Manifold team of it privately.
|
||||
|
||||
🎈 *Awarded on 2022-06-14*
|
||||
|
||||
**[Wasabipesto](https://manifold.markets/wasabipesto): M$20,000**
|
||||
|
||||
- For creating an awesome stats page which features and analyses various data sets! This can be found on the second tab of our [analytics page](https://manifold.markets/stats).
|
||||
|
||||
**[Jack](https://manifold.markets/jack): M$10,000**
|
||||
|
||||
- For adding a bunch of charities to [Manifold for Good](https://manifold.markets/charity), working out market math with Austin, and excellent comment activity.
|
||||
|
||||
**[Forrest](https://manifold.markets/Forrest): M$10,000**
|
||||
|
||||
- For a variety of [open source code contributions](https://github.com/manifoldmarkets/manifold/commits?author=ForrestWeiswolf), making our code base easier to use and maintain.
|
||||
|
||||
**[IsaacKing](https://manifold.markets/IsaacKing): M$10,000**
|
||||
|
||||
- For responsible disclosure of an exploit involving liquidity withdrawal, which has [now been fixed](https://github.com/manifoldmarkets/manifold/pull/472)! Removing one infinite money glitch at a time.
|
||||
|
||||
**[Sjlver](https://manifold.markets/Sjlver): M$5,000**
|
||||
|
||||
- For responsible disclosure of a potential exploit. We would say what it is, but it isn’t quite fixed yet! 🤫
|
||||
|
||||
_🌿 Announced on 2022-05-02_
|
||||
|
||||
**[Marshall Polaris](https://manifold.markets/mqp): M$200K**
|
||||
|
||||
- For spearheading the effort to [open-source Manifold](https://github.com/manifoldmarkets/manifold), by documenting our processes, triaging bugs, and improving the new contributor experience.
|
||||
- Marshall contributed over 2 weeks of part-time volunteer work; as such, we are awarding an amount that reflects the extraordinary amount of effort he’s put in.
|
||||
|
||||
**[Vincent Luczkow](https://manifold.markets/VincentLuczkow): M$10,000**
|
||||
|
||||
- For building and releasing https://github.com/vluzko/manifold-markets-python, a super cool Python visualization of the calibration accuracy of all Manifold markets. Turns out we’re doing okay!
|
||||
|
||||
**[Akhil Wable](https://manifold.markets/AkhilWable): M$10,000**
|
||||
|
||||
- For writing up [Akhil’s Product Suggestions](https://www.notion.so/Akhil-s-Product-Suggestions-672e1cba393d4242852ff95ae79528df), an extensive, thoughtful list of improvements we could make to our platform.
|
||||
|
||||
**[Alex K. Chen](https://manifold.markets/AlexKChen): M$6,000**
|
||||
|
||||
- For the creation of a metric ton of innovative, long term questions. At the time of award, Alex was singlehandedly responsible for 20% of all markets posted in April.
|
||||
|
||||
**[ZorbaTHut](https://manifold.markets/ZorbaTHut): M$5,000**
|
||||
|
||||
- For [testing out futarchy](https://manifold.markets/tag/themotte_leaving) on an important problem for the community of The Motte.
|
||||
|
||||
**[Tetraspace](https://manifold.markets/Tetraspace): M$3,500**
|
||||
|
||||
- For the creation of [a focused set of questions on UK politics](https://twitter.com/TetraspaceWest/status/1516824123149848579), with relevant real-world predictions.
|
||||
- For the idea and execution of using FR bounded buckets for mapping out a scalar range ([example market](https://manifold.markets/Tetraspace/if-ron-desantis-is-elected-presiden), [discussion here](https://manifold.markets/StephenMalina/how-many-daily-active-users-will-ma)).
|
||||
|
||||
**[tcheasdfjkl](https://manifold.markets/tcheasdfjkl): M$2,500**
|
||||
|
||||
- For calling out numerous areas of improvement, e.g. around our profit numbers being wonky, and problems with the DPM ⇒ CFMM market conversions.
|
||||
|
||||
**[Jack](https://manifold.markets/JackC): M$500**
|
||||
|
||||
- For recommending we list the Long-Term Future Fund as a supported charity.
|
||||
|
||||
**[N.C. Young](https://manifold.markets/NcyRocks): M$500**
|
||||
|
||||
- For recommending we list the Givewell Maximum Impact Fund as a supported charity.
|
||||
|
||||
\**🥧 *Awarded 2022-03-14\*
|
||||
|
||||
**[Kevin Zielnicki](https://manifold.markets/kjz): M$10,000**
|
||||
|
||||
- For identifying issues with our Dynamic Parimutuel Market Maker in an [excellent blog post](https://kevin.zielnicki.com/2022/02/17/manifold/) (and [associated market](https://manifold.markets/kjz/will-manifolds-developers-agree-wit)), leading us to change to a different mechanism.
|
||||
|
||||
**[Pepe](https://manifold.markets/Pepe): M$10,000**
|
||||
|
||||
- For developing the function used in our Constant Function Market Maker, making it easier for us to provision liquidity compared to a CPMM.
|
||||
|
||||
**[Gurkenglas](https://manifold.markets/Gurkenglas): M$5,000**
|
||||
|
||||
- For concrete suggestions around improving our market maker algorithms, and creating useful graphs to make our different market makers more legible.
|
||||
|
||||
**[Scott Alexander](https://manifold.markets/ScottAlexander): M$5,000**
|
||||
|
||||
- For [developing and publicizing the idea of providing interest-free loans on each market](https://astralcodexten.substack.com/p/play-money-and-reputation-systems), helping make long-term markets more accurate.
|
||||
|
||||
**[David Glidden](https://manifold.markets/dglid): M$5,000**
|
||||
|
||||
- For taking on the mantle of [@MetaculusBot](https://manifold.markets/MetaculusBot), which allows traders access to a wider spread of topics, and permits head-to-head comparisons between our prediction markets and other forecasting platforms.
|
||||
|
||||
**[Isaac King](https://manifold.markets/IsaacKing): M$5,000**
|
||||
|
||||
- For [compiling an FAQ](https://outsidetheasylum.blog/manifold-markets-faq/) that answers a variety of questions that new users commonly face, and also inspiring us to move to [this open-source docs platform](https://docs.manifold.markets/).
|
||||
|
||||
**[Blazer](https://manifold.markets/BlazingDarkness/was-it-an-unpleasant-surprise-when): M$2,500**
|
||||
|
||||
- For [calling out our mistake](https://manifold.markets/BlazingDarkness/was-it-an-unpleasant-surprise-when) in retroactively publicizing the market creator’s trades, leading us to revert this feature entirely.
|
||||
|
||||
⛑️ _Awarded 2022-01-09_
|
||||
|
||||
**[Duncan](https://manifold.markets/Duncan): USD $50**
|
||||
|
||||
- For identifying and confidentially reporting an exploit where entering negative numbers into the trade box would allow the trade to go through.
|
||||
- _Note: this was denominated in USD, as it predated the creation of our bounty program._
|
||||
|
||||
## Final note
|
||||
|
||||
If a particular contribution isn't listed here, that doesn't mean we didn't really appreciate it. There’s so much great work by our community; we aren't always able to catch them all!
|
||||
|
||||
If you feel that someone's exceptional contribution has fallen through the cracks (including your own!), please consider creating a market for “Will <X\> be recognized for a Manifold bounty?” and posting it on our Discord. Thanks!
|
||||
|
||||
## See also
|
||||
|
||||
- [Will Manifold implement retroactive public goods funding by June 1?](https://manifold.markets/Austin/will-manifold-implement-retroactive)
|
||||
- [Bounties as described on LessWrong](https://www.lesswrong.com/tag/bounties-active)
|
||||
- Mistakes pages we admire: [Scott Alexander](https://astralcodexten.substack.com/p/mistakes), [Nintil](https://nintil.com/mistakes), [80K Hours](https://80000hours.org/about/credibility/evaluations/mistakes/)
|
||||
- [Donald Knuth’s reward checks](https://en.wikipedia.org/wiki/Knuth_reward_check)
|
||||
![https://imgs.xkcd.com/comics/applied_math.png](https://imgs.xkcd.com/comics/applied_math.png)
|
126
docs/docs/faq.md
Normal file
126
docs/docs/faq.md
Normal file
|
@ -0,0 +1,126 @@
|
|||
# Community FAQ
|
||||
|
||||
## General
|
||||
|
||||
### Do I have to pay real money in order to participate?
|
||||
|
||||
Nope! Each account starts with a free 1000 mana (or M$1000 for short). If you invest it wisely, you can increase your total without ever needing to put any real money into the site.
|
||||
|
||||
### Can M$ be sold for real money?
|
||||
|
||||
No. Gambling laws put many restrictions on real-money prediction markets, so Manifold uses play money instead.
|
||||
|
||||
You can instead redeem your Mana and we will [donate to a charity](http://manifold.markets/charity) on your behalf. Redeeming and purchasing Mana occurs at a rate of M$100 to $1.
|
||||
|
||||
### How do the free response markets work?
|
||||
|
||||
Any user can enter a response and bet on it, or they can bet on other people's responses. The response probabilities are weighted proportionally to how many people have bet on them. The market creator's ante goes into a "none of the above" pseudo-option that can't be bet on and can't be chosen as a correct answer when the market is resolved. (This means that free response markets tend to lose their creator almost their entire ante. It also means that if there are only a finite number of options that could win, traders can make guaranteed money by investing in them all equally.) See [here](https://manifoldmarkets.substack.com/p/above-the-fold-milestones-and-new) for more information.
|
||||
|
||||
### How accurate are the market probabilities?
|
||||
|
||||
In general, prediction markets are very accurate. They do have some known issues, most of which can be found on the [Wikipedia page.](https://en.wikipedia.org/wiki/Prediction_market#Accuracy). There are also a few factors that are specific to Manifold Markets:
|
||||
|
||||
- Manifold uses play money for their markets, so there's less of an incentive for people to invest safely. People often goof around with silly markets and investments that they don't expect to win M$ from.
|
||||
- Anyone can create a market on Manifold, and there's nothing preventing the creator of a market from trying to manipulate it to make a profit.
|
||||
- Manifold Markets is a new project and has a large number of individual markets, which means that many of their markets don't have many participants, sometimes less than 5 people.
|
||||
- Manifold's betting system isn't perfect and has some sources of error, discussed in detail [here](https://kevin.zielnicki.com/2022/02/17/manifold/).
|
||||
|
||||
As a general heuristic, check the total pool for the market in question. The more M$ there is in the market, the more likely it is to be accurate.
|
||||
|
||||
### Can I participate without having a Google account?
|
||||
|
||||
No. See [here](https://manifold.markets/hamnox/will-manifold-markets-add-nongoogle) for the probability that this changes.
|
||||
|
||||
## Placing and winning bets
|
||||
|
||||
### The payout probabilities I'm shown sometimes aren't right. For example if a market is at 15% and I bet M$1 on "no", it tells me that I'll make a 42% profit if I win, but the listed payout is just M$1. What's going on?
|
||||
|
||||
Payout amounts are visually rounded to the nearest M$1, and only integer amounts can be put into markets. Behind the scenes however, your balance does track fractional amounts, so you're making a M$0.42 profit on that bet. Once you win another M$0.08, that fractional M$0.5 will display as an extra M$1 in your account. (There's no way to view your exact balance, you can only see the rounded value.)
|
||||
|
||||
### What are the rules about insider trading? (Using private information about a market to make a profit.)
|
||||
|
||||
It's not only allowed, but encouraged. The whole point of a prediction market is to uncover and amplify this sort of hidden information. For example, if there's a market like "will [company] make [decision]?" and you work for that company and know what decision they're going to make, you can use that information to win M$ and make the market more accurate at the same time. (Subject to your company's policies on disclosing internal information of course.) However, if the reason you have private information is because you're colluding with the market creator, this will likely earn both of you a bad reputation and people will be less interested in participating in your markets in the future.
|
||||
|
||||
### Can I see who is buying/selling in a market?
|
||||
|
||||
All trades before June 1, 2022 are anonymous by default. Trades after that date can be viewed in the Bets tab of any market, and also on that user's profile.
|
||||
|
||||
## Creating and resolving markets
|
||||
|
||||
### Is there any benefit to creating markets?
|
||||
|
||||
You get your question answered! Plus, you earn a commission on trades in your markets.
|
||||
|
||||
### What can I create a market about?
|
||||
|
||||
Anything you want to! People ask about politics, science, gaming, and even [their personal lives](https://www.smbc-comics.com/?id=2418). Take a look at the [current list of markets](https://manifold.markets/markets) to see what sorts of things people ask about.
|
||||
|
||||
### What's the difference between a market being "closed" and being "resolved"?
|
||||
|
||||
A market being "closed" means that people can no longer place or sell bets, "locking in" the current probability. Markets close when the close date of the market is met. A market being "resolved" means that the market creator has indicated a given resolution to the market's question, such as "yes", "no", "N/A", or a certain probability. This is the point at which people are cashed out of the market. Resolving a market automatically closes it, but a market can close days, weeks, or even years before it gets resolved.
|
||||
|
||||
### What does "PROB" mean?
|
||||
|
||||
Resolving a market as "PROB" means that it's resolved at a certain probability, chosen by the market creator. PROB 100% is the same as "yes", and PROB 0% is the same as "no". For example, if a market is resolved at PROB 75%, anyone who bought "yes" at less than 75% will (usually) make a profit, and anyone who bought "yes" at greater than 75% will (usually) take a loss. Vice versa for "no". This is also shown as "MKT" in the interface and API.
|
||||
|
||||
### What happens if a market creator resolves a market incorrectly, or doesn't resolve it at all?
|
||||
|
||||
Nothing. The idea is for Manifold Markets to function with similar freedom and versatility to a Twitter poll, but with more accurate results due to the dynamics of prediction markets. Individual market resolution is not enforced by the site, so if you don't trust a certain user to judge their markets fairly, you probably shouldn't participate in their markets.
|
||||
|
||||
That being said, manifold staff may manually send reminder emails to the creators of large markets if they have not been resolved in some time. There are also some projects in the works to enable automated market resolution after some time has passed.
|
||||
|
||||
### How do I tell if a certain market creator is trustworthy?
|
||||
|
||||
Look at their market resolution history on their profile page. If their past markets have all been resolved correctly, their future ones probably will be too. You can also look at the comments on those markets to see if any traders noticed anything suspicious. You can also ask about that person in the [Manifold Markets Discord](https://discord.gg/eHQBNBqXuh). And if their profile links to their website or social media pages, you can take that into account too.
|
||||
|
||||
### Are there any content filters? What happens if someone creates an inappropriate, offensive, or [dangerous](https://en.wikipedia.org/wiki/Assassination_market) market?
|
||||
|
||||
Right now, there are no restrictions on what markets can be created. If this becomes a problem, they may change their policies.
|
||||
|
||||
### Can a market creator change the close date of their market?
|
||||
|
||||
Yes. As long as the market hasn't been resolved yet, the creator can freely change its close date. They can even reopen a market that has already closed.
|
||||
|
||||
### Is there a way to see my closed markets that I need to resolve?
|
||||
|
||||
You'll get an automated email when they close. You can also go to your profile page and select "closed" in the dropdown menu. (This will display only markets that you haven't resolved yet.)
|
||||
|
||||
### When do market creators get their commission fees?
|
||||
|
||||
When the creator resolves their market, they get the commission from all the trades that were executed in the market.
|
||||
|
||||
### How do I see markets that are currently open?
|
||||
|
||||
You can see the top markets in various categories [here](https://manifold.markets/markets).
|
||||
|
||||
### Can I bet in a market I created?
|
||||
|
||||
Yes. However if you're doing things that the community would perceive as "shady", such as putting all your money on the correct resolution immediately before closing the market, people may be more reluctant to participate in your markets in the future. Betting "normally" in your own market is fine though.
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
### How do I report bugs or ask for new features?
|
||||
|
||||
Contact them via [email](mailto:info@manifold.markets), post in their [Discord](https://discord.gg/eHQBNBqXuh), or create a market about that bug/feature in order to draw more attention to it and get community input.
|
||||
|
||||
If you don't mind putting in a little work, fork the code and open a [pull request](https://github.com/manifoldmarkets/manifold/pulls) on GitHub.
|
||||
|
||||
### How can I get notified of new developments?
|
||||
|
||||
Being a very recent project, Manifold is adding new features and tweaking existing ones quite frequently. You can keep up with changes by subscribing to their [Substack](https://manifoldmarkets.substack.com/), or joining their [Discord server](https://discord.gg/eHQBNBqXuh).
|
||||
|
||||
### Is there an app?
|
||||
|
||||
No, but the website is designed responsively and looks great on mobile.
|
||||
|
||||
### Does Manifold have an API for programmers?
|
||||
|
||||
Yep. Documentation is [here](https://docs.manifold.markets/api).
|
||||
|
||||
### If I have a question that isn't answered here, where can I ask it?
|
||||
|
||||
You can contact Manifold Markets via [email](mailto:info@manifold.markets) or post in their [Discord](https://discord.gg/eHQBNBqXuh). Once you have an answer, please consider updating this FAQ via "Edit this page" on Github!
|
||||
|
||||
## Credits
|
||||
|
||||
This FAQ was originally compiled by [Isaac King](https://outsidetheasylum.blog/manifold-markets-faq/).
|
109
docs/docs/market-details.md
Normal file
109
docs/docs/market-details.md
Normal file
|
@ -0,0 +1,109 @@
|
|||
# Guide to Market Types
|
||||
|
||||
# Market Mechanisms
|
||||
|
||||
Historically, Manifold used a special type of automated market maker based on a dynamic pari-mutuel (DPM) betting
|
||||
system. Free response and numeric markets still use this system. Binary markets created prior to March 15, 2022 used
|
||||
this system, but all of those markets have since closed.
|
||||
|
||||
Binary markets created after March 15 use a constant-function market maker which holds constant the weighted geometric
|
||||
mean, with weights equal to the probabilities chosen by the market creator at creation. This design was inspired by
|
||||
Uniswap's CPMM and a suggestion from Manifold user Pepe. The benefit of this approach is that the payout for any bet
|
||||
is fixed at purchase time - 100 shares of YES will always return M$100 if YES is chosen.
|
||||
|
||||
Free response markets (and the depreciated numeric markets) still use the DPM system, as they have discrete "buckets"
|
||||
for the pool to be sorted into.
|
||||
|
||||
## Market Creation
|
||||
|
||||
- Users can create a market on any question they want.
|
||||
- When a user creates a market, they must choose a close date, after which trading will halt.
|
||||
- They must also pay a M$100 market creation fee, which is used as liquidity to subsidize trading on the market.
|
||||
- The market creator will earn a commission on all bets placed in the market.
|
||||
- The market creator is responsible for resolving each market in a timely manner. All fees earned as a commission will be paid out after resolution.
|
||||
- Creators can also resolve N/A to cancel all transactions and reverse all transactions made on the market - this includes profits from selling shares.
|
||||
|
||||
# Binary Markets
|
||||
|
||||
## Binary Markets: Overview
|
||||
|
||||
- Binary markets are structured around a question with a binary outcome, such as:
|
||||
- [Will Bitcoin be worth more than $60,000 on Jan 1, 2022 at 12 am ET?](https://manifold.markets/SG/will-bitcoin-be-worth-more-than-600)
|
||||
- [Will Manifold Markets have over $1M in revenue by Jan 1st, 2023?](https://manifold.markets/ManifoldMarkets/will-mantic-markets-have-over-1m)
|
||||
- [Will we discover life on Mars before 2024?](https://manifold.markets/LarsDoucet/will-we-discover-life-on-mars-befor)
|
||||
- Some binary markets are used as quasi-numeric markets, such as:
|
||||
- [How many additional subscribers will my newsletter have by the end of February?](https://manifold.markets/Nu%C3%B1oSempere/how-many-additional-subscribers-wil)
|
||||
- [How many new signups will Manifold have at the end of launch day?](https://manifold.markets/ManifoldMarkets/how-many-new-signups-will-manifold)
|
||||
- [What day will US Covid deaths peak in February?](https://manifold.markets/JamesGrugett/what-day-will-us-covid-deaths-peak)
|
||||
- These markets are made possible by the MKT option described below.
|
||||
|
||||
## Binary Markets: Betting & Payouts
|
||||
|
||||
- Traders can place a bet on either YES or NO and receive shares in the outcome in return.
|
||||
- Betting on YES will increase the market’s implied probability; betting on NO will decrease the probability.
|
||||
- Manifold's automated market automatically adjusts the market probability after each trade and determines how many shares a user will get for their bet.
|
||||
- You can sell back your shares for cash. If you sell YES shares, the market probability will go down. If you sell NO shares, the probability will go up.
|
||||
- 1 YES share = M$1 if the event happens. 1 NO share = M$1 if the event does not happen.
|
||||
- Notice that 1 YES share + 1 NO share = M$1. If you ever get multiple YES and NO shares, they will cancel out and you will be left with cash.
|
||||
- When the market is resolved, you will be paid out according to your shares. If you own 100 YES shares, if the event resolves YES, you will earn M$100. (If the event resolves NO, you will earn M$0).
|
||||
- The creator of each market is responsible for resolving each market. They can resolve to YES, NO, MKT, or N/A.
|
||||
- Resolving to MKT allows the creator to choose a percentage. The payout for any YES share is multiplied by this percentage, and vice versa for NO.
|
||||
- For example, if a market resolves to MKT at 30%, if you have 100 shares of YES you will receive `M$100 * 30% = M$30`.
|
||||
- In the same situation as above, if you have 100 shares of NO you will receive `M$100 * (100% - 30%) = M$70`.
|
||||
- Note that even in this instance, 1 YES share plus 1 NO share still equals M$1.
|
||||
|
||||
## Binary Markets: Liquidity
|
||||
|
||||
- The liquidity in a market is the amount of capital available for traders to trade against. The more liquidity, the greater incentive there is for traders to bet, and the more accurate the market should be.
|
||||
- When a market is created, the creation fee (also called the ante or subsidy) is used to fill the liquiity pool. This happens whether the creation fee is paid by the user or by Manifold for the daily free market.
|
||||
- Behind the scenes, when a bet is placed the CPMM mechanism does [a bunch of math](http://bit.ly/maniswap). The end result is that for each M$1 bet, 1 YES share and 1 NO share is created. Some amount of shares are then given to the user who made the bet, and the rest are stored in the liquidity pool.
|
||||
Due to this mechansim, the number of YES shares in the whole market always equals the number of NO shares.
|
||||
- You can manually add liquidity to any market to increase the incentives for traders to participate. You can think of added liquidity as a subsidy for getting your question answered. You can do this by opening up the market info popup window located in the (...) section of the header on the market page.
|
||||
- Adding liquidity provides you with a number of YES and NO shares, which can be withdrawn from the same interface. These shares resolve to M$ like normal when the market resolves, which will return you some amount of your investment.
|
||||
- If the market moves significantly in either direction, your liquidity will become significantly less valuable. You are currently very unlikely to make money by investing liquidity in a market, it is a way to subsidize a market and encourage more people to bet, to achieve a more accurate answer.
|
||||
- Adding liquidity to a market also makes it require more capital to move the market, so if you want to subsidize a market, first make sure the market price is roughly where you think it should be.
|
||||
|
||||
# Free-Response Markets
|
||||
|
||||
## Free-Response Markets: Overview
|
||||
|
||||
- Free-response markets are structured around a question with a multiple outcomes, such as:
|
||||
- [Which team will win the NBA Finals 2022?](https://manifold.markets/howtodowtle/which-team-will-win-the-nba-finals)
|
||||
- [Who will win "Top Streaming Songs Artist" at the 2022 Billboard Music Awards?](https://manifold.markets/Predictor/who-will-win-top-streaming-songs-ar)
|
||||
- [What life improvement intervention suggested would I found most useful?](https://manifold.markets/vlad/what-life-improvement-intervention)
|
||||
- Some free-response markets are used as quasi-numeric markets, such as:
|
||||
- [What day will Russia invade Ukraine?](https://manifold.markets/Duncan/what-day-will-russia-invade-ukraine)
|
||||
- [What will inflation be in March?](https://manifold.markets/ManifoldMarkets/what-will-inflation-be-in-march)
|
||||
- [How many Manifold team members in the Bahamas will test positive for COVID?](https://manifold.markets/Sinclair/how-many-manifold-team-members-in-t)
|
||||
|
||||
## Free-Response Markets: Betting & Payouts
|
||||
|
||||
- Markets are structured around a list of answers, any of which can be bet on.
|
||||
- When a Free Response market is created, the market creation fee goes into a hidden answer called the Ante and gets paid to the winner(s), to subsidize the market and create an incentive to bet. This happens whether the creation fee is paid by the user or by Manifold for the daily free market.
|
||||
- This hidden answer is why a market's probabilities will not add up to 100%.
|
||||
- If you want to further subsidize a market, it's customary to create an ANTE answer and put money in that.
|
||||
- Anyone can add answers to a market as long as they stake some amount of M$ on it. Traders can place a bet on any answer and receive shares in the outcome in return.
|
||||
- When a user places a bet, their M$ goes into the market's pool and they receive a certain amount of shares of the selected answer.
|
||||
- When the market is resolved, you will be paid out according to your shares. If the creator resolves to answer #1, the entire pool is divided up amongst the users who bet on answer #1 proportional to their shares.
|
||||
- The creator of each market is responsible for resolving each market. They can resolve to any single answer, or even multiple answers.
|
||||
- Resolving to multiple answers allows the creator to choose a percentage for each selected answer (or distribute equally). The payout for any answer is taken from the amount of the total pool allocated to that answer.
|
||||
- For example, let's take a free-response market with many answers. The pool for this market is $500, and you own 100 out of 500 total shares of answer #1.
|
||||
- If the creator resolves to answer #1 only, you will receive `M$500 * (100 / 500) = M$100`.
|
||||
- If the creator resolves 50% to answer #1 and 50% to answer #2, you will receive `(M$500 * 50%) * (100 / 500) = M$50`.
|
||||
- Note that your payout is dependent on the total number of shares, and thus may decrease if more people buy shares in that answer.
|
||||
|
||||
# Fees
|
||||
|
||||
- Manifold charges fees on each trade. They are automatically calculated and baked into the number of shares you receive when you place a bet.
|
||||
- Our CPMM fee schedule is currently: `10% * (1 - post-bet probability) * bet amount`
|
||||
- Note that all current binary markets use this fee schedule.
|
||||
- The post-bet probability is what the market probability would be after your bet if there were no fees.
|
||||
- Example:
|
||||
- If you bet M$100 on NO and the resulting probability without fees would be 10%, then you pay `M$100 * 10% * 10% = M$1.0`.
|
||||
- If you bet M$100 on YES and the resulting probability without fees would be 50%, then you pay `M$100 * 10% * 50% = M$5.0`.
|
||||
- 100% of this fee is used to provide a commission to the market creator, which is paid out after the market is resolved.
|
||||
- Our DPM fee schedule is currently: `5% * (1 - post-bet probability) * bet amount`
|
||||
- Note that all free-response markets use this fee schedule. The calculation for this is the same as above.
|
||||
- 4% is used to provide a commission to the market creator, which is paid out after the market is resolved. 1% is "burnt" to prevent inflation.
|
||||
- No fees are levied on sales. If you have existing shares in a binary market and buy shares on the opposite side, that is equivalent to selling your shares and you do not pay fees.
|
||||
|
132
docs/docusaurus.config.js
Normal file
132
docs/docusaurus.config.js
Normal file
|
@ -0,0 +1,132 @@
|
|||
// @ts-check
|
||||
// Note: type annotations allow type checking and IDEs autocompletion
|
||||
|
||||
const lightCodeTheme = require('prism-react-renderer/themes/github')
|
||||
const darkCodeTheme = require('prism-react-renderer/themes/dracula')
|
||||
const math = require('remark-math')
|
||||
const katex = require('rehype-katex')
|
||||
|
||||
/** @type {import('@docusaurus/types').Config} */
|
||||
const config = {
|
||||
title: 'Manifold Docs',
|
||||
tagline: 'Learn more about the BESTEST prediction market platform~',
|
||||
url: 'https://docs.manifold.markets',
|
||||
baseUrl: '/',
|
||||
onBrokenLinks: 'throw',
|
||||
onBrokenMarkdownLinks: 'warn',
|
||||
favicon: 'https://manifold.markets/favicon.ico',
|
||||
organizationName: 'manifoldmarkets', // Usually your GitHub org/user name.
|
||||
projectName: 'docs', // Usually your repo name.
|
||||
|
||||
presets: [
|
||||
[
|
||||
'classic',
|
||||
/** @type {import('@docusaurus/preset-classic').Options} */
|
||||
({
|
||||
docs: {
|
||||
routeBasePath: '/',
|
||||
sidebarPath: require.resolve('./sidebars.js'),
|
||||
editUrl: 'https://github.com/manifoldmarkets/manifold/tree/main/docs',
|
||||
remarkPlugins: [math],
|
||||
rehypePlugins: [katex],
|
||||
},
|
||||
theme: {
|
||||
customCss: require.resolve('./src/css/custom.css'),
|
||||
},
|
||||
}),
|
||||
],
|
||||
],
|
||||
|
||||
stylesheets: [
|
||||
{
|
||||
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css',
|
||||
type: 'text/css',
|
||||
integrity:
|
||||
'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
|
||||
crossorigin: 'anonymous',
|
||||
},
|
||||
],
|
||||
|
||||
scripts: [
|
||||
{
|
||||
src: 'https://cdn.jsdelivr.net/npm/link-summoner@1.0.2/dist/browser.min.js',
|
||||
async: 'true',
|
||||
},
|
||||
],
|
||||
|
||||
themeConfig:
|
||||
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
||||
({
|
||||
navbar: {
|
||||
title: 'Manifold Docs',
|
||||
logo: {
|
||||
alt: 'Manifold Markets Logo',
|
||||
src: 'https://manifold.markets/logo.svg',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
type: 'doc',
|
||||
docId: 'about',
|
||||
position: 'left',
|
||||
label: 'Docs',
|
||||
},
|
||||
{
|
||||
href: 'https://github.com/manifoldmarkets/manifold/tree/main/docs/docs',
|
||||
label: 'GitHub',
|
||||
position: 'right',
|
||||
},
|
||||
],
|
||||
},
|
||||
footer: {
|
||||
style: 'dark',
|
||||
links: [
|
||||
{
|
||||
title: 'Manifold',
|
||||
items: [
|
||||
{
|
||||
label: 'Manifold Markets',
|
||||
to: 'https://manifold.markets',
|
||||
},
|
||||
{
|
||||
label: 'Docs',
|
||||
to: '/',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'Community',
|
||||
items: [
|
||||
{
|
||||
label: 'Discord',
|
||||
href: 'https://discord.gg/eHQBNBqXuh',
|
||||
},
|
||||
{
|
||||
label: 'Twitter',
|
||||
href: 'https://twitter.com/manifoldmarkets',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'More',
|
||||
items: [
|
||||
{
|
||||
label: 'Blog',
|
||||
to: 'https://manifoldmarkets.substack.com',
|
||||
},
|
||||
{
|
||||
label: 'GitHub',
|
||||
href: 'https://github.com/manifoldmarkets/manifold/',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
copyright: `Copyright © ${new Date().getFullYear()} Manifold Markets, Inc. Built with Docusaurus.`,
|
||||
},
|
||||
prism: {
|
||||
theme: lightCodeTheme,
|
||||
darkTheme: darkCodeTheme,
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
||||
module.exports = config
|
48
docs/package.json
Normal file
48
docs/package.json
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "docs",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"docusaurus": "docusaurus",
|
||||
"dev": "yarn start",
|
||||
"start": "docusaurus start",
|
||||
"build": "docusaurus build",
|
||||
"swizzle": "docusaurus swizzle",
|
||||
"deploy": "docusaurus deploy",
|
||||
"clear": "docusaurus clear",
|
||||
"serve": "docusaurus serve",
|
||||
"write-translations": "docusaurus write-translations",
|
||||
"write-heading-ids": "docusaurus write-heading-ids",
|
||||
"typecheck": "tsc",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "2.0.0-beta.17",
|
||||
"@docusaurus/preset-classic": "2.0.0-beta.17",
|
||||
"@mdx-js/react": "^1.6.22",
|
||||
"clsx": "^1.1.1",
|
||||
"hast-util-is-element": "1.1.0",
|
||||
"prism-react-renderer": "^1.2.1",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"rehype-katex": "5",
|
||||
"remark-math": "3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "2.0.0-beta.17",
|
||||
"@tsconfig/docusaurus": "^1.0.4",
|
||||
"@types/react": "^17.0.2"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.5%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
31
docs/sidebars.js
Normal file
31
docs/sidebars.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Creating a sidebar enables you to:
|
||||
- create an ordered group of docs
|
||||
- render a sidebar for each doc of that group
|
||||
- provide next/previous navigation
|
||||
|
||||
The sidebars can be generated from the filesystem, or explicitly defined here.
|
||||
|
||||
Create as many sidebars as you want.
|
||||
*/
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
||||
const sidebars = {
|
||||
// By default, Docusaurus generates a sidebar from the docs folder structure
|
||||
tutorialSidebar: [{ type: 'autogenerated', dirName: '.' }],
|
||||
|
||||
// But you can create a sidebar manually
|
||||
/*
|
||||
tutorialSidebar: [
|
||||
{
|
||||
type: 'category',
|
||||
label: 'Tutorial',
|
||||
items: ['hello'],
|
||||
},
|
||||
],
|
||||
*/
|
||||
}
|
||||
|
||||
module.exports = sidebars
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user