Commit Graph

438 Commits

Author SHA1 Message Date
James Grugett
05f1da430c Stats: Use action count of the user who is tenth percentile 2022-06-13 15:51:17 -05:00
Austin Chen
a7dca6a163 Add ACLU charity 2022-06-11 18:06:44 -07:00
Ian Philips
89784bf5eb
Notifications for liquidity proiders/provisions (#478)
* Notifications for liquidity proiders/provisions

* typo

* Rename

* Return default text

* Marke needs resolution notifications

* remove todo
2022-06-10 16:48:28 -06:00
Ian Philips
f1c3914807
Properly fill probs on DPMM bets (#480)
* Properly fill probs on DPMM bets

* Remove unused import
2022-06-10 15:15:52 -06:00
mantikoros
c59d93979c
Fix overflow (#472)
* fix pool overflow bug by enforcing minimum share quantity in pool

* CPMM_MIN_POOL_QTY = 0.01

* use newPool
2022-06-09 20:25:05 -05:00
mantikoros
52dd68303a dpm: don't use weightedShareTotal 2022-06-08 16:18:00 -05:00
TrueMilli
b231d0968f
dpm fix multi resolution (#461)
* fix dpm prob

* refactoring

* remove newline

* refactoring
2022-06-08 16:06:14 -05:00
mantikoros
0cd9943e0d
Liquidity withdrawal (#457)
* withdrawLiquidity cloud function

* update rules

* exclude antes from getCpmmLiquidityPoolWeights

* update correct lp shares

* liquidity panel

* don't create bet if less than 1 surplus share

* withdrawLiquidity return type

* static analysis fix

* hook dependency

* prettier

* renaming

* typo

* getCpmmLiquidityPoolWeights: always exclude antes

* delete unused function

* casting
2022-06-08 13:00:49 -05:00
Austin Chen
470e36a5a3 Add New Science 2022-06-08 10:08:02 -07:00
Ian Philips
936cabe353
Speed up notification loading by prepopulating relevant info (#453)
* Populate notification with relevant info

* eslint

* Remove duplicated code

* Unused ?

* Add new q notification, other small fixes
2022-06-08 08:43:24 -06:00
Marshall Polaris
244bbc51b2
Migrate sellBet cloud function to v2 sellbet (#438)
* Migrate sellBet to v2

* Kill sellBet warmup requests

* Point client at new v2 sellbet function

* Clean up `getSellBetInfo`

* Fix up functions index.ts
2022-06-07 14:08:56 -07:00
Marshall Polaris
60e830974e
Migrate sellShares cloud function to v2 sellshares (#440)
* Migrate `sellShares` to v2 `sellshares`

* Point client at new v2 sellshares function

* Clean up `getCpmmSellBetInfo`
2022-06-07 13:54:58 -07:00
Marshall Polaris
d9eb9798e5
Point client at new v2 versions of createmarket and placebet (#433)
* Kill 'warmup spam' for createContract and placeBet

* Point v2 function calls at v2 endpoints

* Add real prod placebet and createmarket endpoints
2022-06-06 12:46:06 -07:00
Ian Philips
1976bc755e Revert "Revert "Notification detail, grouping, and settings control [wip] (#403)""
This reverts commit 07f2d390e5.
2022-06-06 11:36:59 -06:00
Ian Philips
07f2d390e5 Revert "Notification detail, grouping, and settings control [wip] (#403)"
This reverts commit 37c7f909a3.
2022-06-06 10:54:25 -06:00
Ian Philips
37c7f909a3
Notification detail, grouping, and settings control [wip] (#403)
* Revert "Revert "Notifications ux fixes - wip (#383)""

This reverts commit 699b03eb42.

* Group & provide more control over notification display

* UI/UX improvements

* Remove unused text key

* Refactor

* Refactor

* Show answer resolution in notification

* Disable eslint on single linefor exhaustive deps

* Handle arbritrary notifications

* Refactor

* Remove unused vars

* Add follow user

* Various UX improvements, add follow notif

* Various small ui changes

* Show notification settings breakdown

* Improve notification status lines
2022-06-06 10:52:11 -06:00
Marshall Polaris
f8c44efeba
Small cleanup to some common code (#422)
* Remove unnecessary type helpers

* Turn on unused code lint
2022-06-04 13:30:54 -07:00
Forrest Wolf
b89753e1fe
Add yarn verify script (#378)
* Add yarn check script

* Rename

* Add verify script to subdirectories for convenience
2022-06-03 15:10:14 -07:00
TrueMilli
0f2a311b74
Refactoring (#401)
* refactoring

(cherry picked from commit 4de86d5b08)

* removed unused imports and variables

* added type for binary resolution

* Prettier

* const for binary resolutions

* using the type "resolution"

* Prettier

* Update functions/src/create-contract.ts

* launch config for debugging with vs code
* "Launch Chrome" does not work since login via google is not possible in debugger-chrome
* Breakpoints are unbound when attached to chrome
2022-06-02 17:30:34 -07:00
Jack
536ef180ce
Add charities: EA Funds and Founders Pledge funds (#382)
Co-authored-by: jackc271 <jackc2718@gmail.com>
2022-06-01 10:25:37 -07:00
Ian Philips
1c980ba678
Notifications (#354)
* Notifications generating on comment,answer,contract update

* Notifications MVP

* Submitted an answer => answered

* Listen for unseen notifications

* Fix userlink formatting, move page

* Fix links

* Remove redundant code

* Cleanup

* Cleanup

* Refactor name

* Comments

* Cleanup & update notif only after data retrieval

* Find initial new notifs on user change

* Enforce auth rules in db

* eslint update

* Code review changes

* Refactor reason
2022-06-01 07:11:25 -06:00
Marshall Polaris
35c373f6ce
MULTI contracts are not a thing (#381) 2022-05-31 20:40:08 -07:00
Marshall Polaris
7c4ec2a8e3
Refactor contract typing to be more concise and more correct (#355)
* Refactor contract types slightly

* Refactor contract types greatly

* Kill dead binary DPM contract creation code

* Use BinaryContract, DPMContract, etc. type aliases
2022-05-31 19:42:35 -07:00
mantikoros
9076b625e3 numeric bet ante provided by house 2022-05-28 13:43:57 -05:00
James Grugett
45f92379bc Portfolio: Fix calculation of whether you sold all your shares 2022-05-28 00:18:09 -05:00
Marshall Polaris
80d5607984 Revert fishy change regarding payouts 2022-05-27 14:24:49 -07:00
Marshall Polaris
86625798cd
Clean up some mess related to nullable collectedFees (#352)
* contract.collectedFees is no longer sometimes nonexistent

* Fix typing issues around payouts code
2022-05-27 14:02:02 -07:00
Marshall Polaris
5217270073
Serious business API validation & big cleanup of createContract, placeBet (#302)
* Add the great Zod as a dependency to help us

* Tweak eslint

* Rewrite a ton of stuff in createContract and placeBet

* Clean up error reporting in API

* Make sure the UI is enforcing validated limits on lengths

* Remove unnecessary Math.abs

* Better type on `BetInfo`

* Kill `manaLimitPerUser`

* Clean up hacky parameters on bet info functions

* Validate `closeTime` as a valid timestamp in the future
2022-05-26 14:37:51 -07:00
Marshall Polaris
b8b1c0d056
Add tsconfig, more linting to common package (#324)
* Add tsconfig.json for common

* Prefer `const` over `let` over `var`

* Kill dead code

* Fix some trivial Typescript issues

* Turn on Typescript linting in common except for no-explicit-any

* Correctly specify tsconfig dir name in functions eslintrc
2022-05-25 17:12:36 -07:00
mantikoros
5f385c2f9d Revert "use geometric mean probability to calculate fees for cfmm (a lot easier than solving the integral)"
This reverts commit a1c3a5e569.
2022-05-24 15:46:41 -05:00
Austin Chen
8cedf93901
Implement quick betting: directly from the market card (#291)
* Play with using 3 icons for 1-click usage

* Align bet icons with the percentages

* Hide liquidity injection star, for now

* Fix Free Response card layouts

* Use triangles instead of planes

* Set correct hover states the arrows

* Fix down triangle & padding

* Default large nums to 2 sigfigs

* Clean up hover areas

* Fix bet width, remove "chance/expected"

* Show "M$20" on hover, hide arrows when closed

* Improve click targets

* FR: "MULTI" => "MANY", single => "TOP"

* Install react-hot-toaster

* Implement quick betting on binary questions

* Handle different kinds of markets

* Extract out QuickBet into its own component

* Minor tweaks

* Visually separate out quick bet pane

* Hide quick bet for FR markets with no answers

* Fill in which bets the user has already placed

* Animate movements, fix binary direction

* Hover arrows are now always gray

* Pull out code into quick-bet.tsx

* Minor comments

* Fix import

ts-ignore is scary

* Fixes from James's feedback

* Hide text only on quickbet
2022-05-23 23:44:16 -07:00
Marshall Polaris
3987baa11b
Add Vercel routes for public write API (#280)
* Improve typing of client CORS helper

* Take node-fetch as a dependency

* Add explicit Firebase region into config

* Add new Vercel proxy API routes that talk to backend

* Call Vercel proxy routes from `api-call` module

* Tweak import to try to get Vercel happy

* Tidy up a tiny bit
2022-05-23 14:16:56 -07:00
Marshall Polaris
47f10301c8
Change lodash stuff so that it can be tree-shaken out of build (#233)
* Set common package.json sideEffects: false

* Configure SWC to modularize lodash imports

* Import specific lodash functions instead of _

* Add an eslint rule to avoid full lodash import
2022-05-22 01:36:05 -07:00
Marshall Polaris
0803a15902
Set up eslint for common, functions packages (#290)
* Move common dev dependencies to workspace top level

* Add .eslintrc.js for functions and common packages

* Add more linting to check workflow
2022-05-22 00:35:43 -07:00
Marshall Polaris
98c5329e03
Fix up API CORS header processing (#277)
* Fix ultra embarrassing bug not restricting CORS origins

* Put CORS origin regexps in common

* Static types so I don't muck it up again

* Fixup CORS regex to be more strict

* Fix sloppy imports to actually work
2022-05-20 19:34:26 -07:00
Austin Chen
03a13248a4 Limit large numbers to 3 sig figs 2022-05-20 15:25:32 -04:00
mantikoros
6f1a569797 back to M$ — the worst option except for all the others 2022-05-19 22:28:38 -04:00
mantikoros
e9fee04761 ante for free FR market now come from house 2022-05-19 22:06:50 -04:00
SirSaltyy
a0db1b806a
Add trevor project charity (#258) 2022-05-19 17:08:21 -07:00
James Grugett
76f27d1a93
Numeric range markets!! (#146)
* Numeric contract type

* Create market numeric type

* Add numeric graph (coded without testing)

* Outline of numeric bet panel

* Update bet panel logic

* create numeric contracts

* remove batching for antes for numeric markets

* Remove focus

* numeric market range [1, 100]

* Zoom graph

* Hide bet panels

* getNumericBets

* Add numeric resolution panel

* Use getNumericBets in bet panel calc

* Switch bucket count to 100

* Parallelize ante creation

* placeBet for numeric markets

* halve std of numeric bets

* Update resolveMarket with numeric type

* Set min and max for contract

* lower std for numeric bets

* calculateNumericDpmShares: use sorted order

* Use min and max to map the input

* Fix probability calc

* normpdf variance mislabeled

* range input

* merge

* change numeric graph color

* fix getNewContract params

* bet panel labels

* validation

* number input

* fix bucketing

* bucket input, numeric resolution panel

* outcome label

* merge

* numeric bet panel on mobile

* Make text underneath filled green answer bar selectable

* Default to 'all' feed category when loading page.

* fix numeric resolution panel

* fix numeric bet panel calculations

* display numeric resolution

* don't render NumericBetPanel for non numeric markets

* numeric bets: store shares, bet amounts across buckets in each bet object

* restore your bets for numeric markets

* numeric pnl calculations

* remove hasUserHitManaLimit

* contrain contract type

* handle undefined allOutcomeShares

* numeric ante bet amount

* use correct amount for numeric dpm payouts

* change numeric graph/outcome color

* numeric constants

* hack to show correct numeric payout in calculateDpmPayoutAfterCorrectBet

* remove comment

* fix ante display in bet list

* halve bucket count

* cast to NumericContract

* fix merge imports

* OUTCOME_TYPES

* typo

* lower bucket count to 200

* store raw numeric value with bet

* store raw numeric resolution value

* number input max length

* create page: min, max to undefined if not numeric market

* numeric resolution formatting

* expected value for numeric markets

* expected value for numeric markets

* rearrange lines for readability

* move normalpdf to util/math

* show bets tab

* check if outcomeMode is undefined

* remove extraneous auto-merge cruft

* hide comment status for numeric markets

* import

Co-authored-by: mantikoros <sgrugett@gmail.com>
2022-05-19 12:42:03 -05:00
Sinclair Chen
f7c1d98221 Add Sinclair to admins 2022-05-18 15:04:06 -04:00
Austin Chen
7b3c8ea046 Revert "back to M$ — playtime is over"
This reverts commit ed41d99484.
2022-05-18 12:09:24 -04:00
James Grugett
5adf430fad Revert "Fix up money moniker to be more elegant"
This reverts commit 4bba070423.
2022-05-17 23:54:51 -04:00
Marshall Polaris
4bba070423 Fix up money moniker to be more elegant 2022-05-17 20:04:39 -07:00
mantikoros
a1c3a5e569 use geometric mean probability to calculate fees for cfmm (a lot easier than solving the integral) 2022-05-17 17:05:00 -04:00
mantikoros
ed41d99484 back to M$ — playtime is over 2022-05-17 15:34:58 -04:00
James Grugett
d5cc6d5067 Revert "Better random (#213)"
This reverts commit c9f3644988.
2022-05-16 20:26:51 -04:00
Austin Chen
05c94374c9 Switch from 'M$' to 'ϻ'
Pros:
- Better emphasizes "mana"
- Visually pleasing
- Visually distinct (acts as an icon)
- Single character
Cons
- Harder to correctly type (but users can just do m1234 for shorthand)
2022-05-16 09:02:17 -04:00
James Grugett
695f243a93 Update categories: Add Culture, health => Covid, rearrange 2022-05-15 23:45:02 -04:00
Marshall Polaris
72b21925e5
Allow users to generate an API key in their profile (#182)
* Add /private-users/apiKey to DB

* Add field to edit API key on profile

* Move API key to bottom of profile page

Austin thinks this is better since most people don't care about it.
2022-05-15 20:41:07 -07:00
Jonas Wagner
c9f3644988
Better random (#213)
* randomString: generate a securely random string.

Also, support lengths > 12 in case that's ever needed.

This is used in at least one case (creating device tokens for users)
where it seems important that the output is unpredictable.

* Try harder to create unique usernames.

The previous version added 16 bits of entropy to the username, which
isn't all that much. Due to the birthday paradox, it would be enough to
create ~256 users with the same prefix to get a collision.

Trying that would probably fail later on, and not create security
issues... but it just seems better to be on the safe side here.
2022-05-15 13:13:07 -07:00
Jonas Wagner
92aa56ba20
Swap values with structured assignment rather than temporary (#210)
Saves two lines and a variable.

Also, a desperate attempt to save my Mana in https://manifold.markets/ManifoldMarkets/if-we-open-source-our-frontend-code
2022-05-14 22:06:35 -07:00
James Grugett
c2320a07be Free response markets initialize with 0 volume, instead of 100 2022-05-13 09:43:12 -04:00
James Grugett
31f57f8ff2 Condense category names to just the tag name 2022-05-12 11:18:44 -04:00
mantikoros
9a4e5763f5
Categories (#132)
* basic market categories

* use tags to store market category

* display category in market

* display full category

* category selector component on feed

* Move feed data fetching to new file

* Decrease batch size for updating feed to prevent out-of-memory error

* Compute and update category feeds!

* Show feeds based on category tabs

* Add react-query package!

* Use react query to cache contracts

* Remove 'other' category

* Add back personal / friends to feed categories

* Show scrollbar temporarily for categories

* Remove 5 categories, change geopolitics to world

* finance => economics

* Show categories on two lines on larger screens

Co-authored-by: James Grugett <jahooma@gmail.com>
2022-05-12 10:07:10 -05:00
Boa
02ed9bf7e1
Single threaded comments (#175)
* Remove unused hideOutcome in comments

* Remove unused hideOutcome in comments

* Add replyToComment fields to Comment

* Add 1 threaded replies to comments & answers

* Allow smooth scrolling within pages via #

* remove yarn-error log

* correct spelling

* Remove smooth-scroll-to-hashtag component

* Cleanup & show user position/bets in replies
2022-05-11 15:11:46 -06:00
mantikoros
b00814a8c4
Template emails (#185)
* unsubscribe from generic emails

* new welcome email

* fix from address

* thank you email

* one week bonus email
2022-05-11 10:51:58 -05:00
Sinclair Chen
a297f6492d
move manaToUSD to format.ts (#172) 2022-05-10 11:14:24 -07:00
James Grugett
bbfdc923fb Fix word scores, broken by an extra long word 2022-05-10 10:28:07 -04:00
mantikoros
264e5058ea
Separate out fees (#169)
* deduct market ante from profits

* display creator fees in stats

* show creator earnings in stats

* separate out creator, liquidity fees in payouts and deduct from profits

* include creator payout in resolution emails

* deduct liquidity from profits

* hide cost tooltip if daily free market
2022-05-10 08:49:14 -05:00
mantikoros
ef43e46153 include fees in tooltip 2022-05-09 17:33:24 -04:00
mantikoros
5135135e79
Separate out fees (#159)
* deduct market ante from profits

* display creator fees in stats

* show creator earnings in stats

* separate out creator, liquidity fees in payouts and deduct from profits
2022-05-09 16:04:40 -05:00
Boa
a5b0372a6e
Free response markets with investment cap (#157)
* Show error message for FR bet

* Allow M$ limit for markets

* Allow M$ limit for markets

* Apply M$ limit to FR answer bets

* Improve error message

* Improve error message

* Only check stats if mana limit set

* Consolidate logic

* Remove unused variable

* absolute import

* absolute imports
2022-05-09 14:09:07 -06:00
James Grugett
e8ab863557
🔍 Algolia search (#136)
* Add algolia and instantsearch packages

* Switch to hooks-web package

* Implement algolia search!

* Fix types

* Fix tags page

* Closed sort option

* Implement select for filtering on open, closed, resolved, all.

* Support search in dev environment

* Fix runtime error in landing page
2022-05-09 12:38:33 -05:00
Austin Chen
22a9901148 Feature Nonlinear as a charity 2022-05-07 08:15:40 -04:00
James Grugett
4de0fcd198 Revert "Represent DB avatar URLs as non-null (#128)"
This reverts commit bf8e09b6c1.
2022-05-06 14:29:15 -04:00
SirSaltyy
e41f646b42
Remove all spaces between M$ and the associated number (#134)
* Remove all spaces between M$ and the associated number

* Update index.tsx
2022-05-05 22:19:47 -04:00
Marshall Polaris
bf8e09b6c1
Represent DB avatar URLs as non-null (#128) 2022-05-04 11:07:22 -07:00
Boa
3a33efa8db
Threaded free response comments & general comments sections (#121)
* Allow comments to reference answers

* Add comment inputs for free response answers

* condense comment logic in one component

* Add General Comments section to FR answers

* Prompt signin even if no comment

* Remove unused & refactor

* Simplify general comments logic, toggle comment boxes

* Clarify rendering logic
2022-05-03 14:38:40 -06:00
Sinclair Chen
3434b3de3f
Move all charity images to imgur + Next (#120) 2022-05-03 07:00:33 -07:00
mantikoros
a516122f61 round shares to avoid negative shares error message 2022-05-02 13:59:09 -04:00
Austin Chen
1fa214ed48 Add Givewell MIF 2022-05-02 08:42:50 -04:00
James Grugett
06b7e49e98
[In progress] Server-side feed computation (#106)
* Store view counts & last viewed time

* Schedule updating user recommendations. Compute using tf-idf.

* Update contract's lastBetTime and lastCommentTime on new bets and comments.

* Remove contract's lastUpdatedTime

* Remove folds activity feed

* Implement getFeed cloud function

* Hook up client to use getFeed

* Script to cache viewCounts and lastViewTime

* Batched wait all userRecommendations

* Cache view script runs on all users

* Update user feed each hour and get feed from cache doc.

* Delete view cache script

* Update feed script

* Tweak feed algorithm

* Compute recommendation scores from updateUserFeed

* Disable lastViewedScore factor

* Update lastCommentTime script

* Comment out console.log

* Fix timeout issue by calling new cloud functions with part of the work.

* Listen for contract updates to feed.

* Handle new user: use default feed of top markets this week

* Track lastUpdatedTime

* Tweak logic of calling cloud functions in batches

* Tweak cloud function batching
2022-05-01 11:36:54 -05:00
Austin Chen
80d594bd5f Rename QURI back 2022-05-01 08:30:55 -04:00
Austin Chen
ade8eb7aae Add CSPI 2022-04-30 18:00:51 -04:00
Austin Chen
53a584f37d Add in LTFF, ARC, RC 2022-04-30 17:35:10 -04:00
Austin Chen
46bf09f182 Feature 1Day Sooner & QURI 2022-04-30 15:47:47 -04:00
Austin Chen
1c7232f31e Add 1Day Sooner & QURI as supported charities 2022-04-30 15:26:07 -04:00
mantikoros
f6d4409899 return liquidity pool after resolution according to true pool weight 2022-04-30 12:24:33 -04:00
Austin Chen
a6de0ec695 Add missing charity logos 2022-04-30 08:09:57 -04:00
Marshall Polaris
17b5345d82
Fix HTTP charity logo links (#113) 2022-04-30 07:44:11 -04:00
Sinclair Chen
73fc67955d
Send M$ to Charity & txns (#81)
* Add components for CPM landing and charity pages

* Remove misc.ts to fix build

* Set up cloud function for writing txns

* More plumbing for txns

* Fix up API call

* Use Date.now() to keep timestamps simple

* Some styles for charity list page

* Hard code charities data

* Pass charity data to charity page

* Update txn type

* Listen for charity txns

* Handle txn to non-user by burning it

* Read txns for charity card and charity page.

* Set images to object contain

* Clean up txn types

* Move pic to top of card. Other misc styling.

* Update charity short & long descriptions

* Add `token` and `category` to Txn

* Fix breakages

* Show Charity link in the sidebar

* Fix typing issues

* Fix not reading from the right type

* Switch out icon

* Also show Charity icon on mobile

* Update copy

Co-authored-by: Austin Chen <akrolsmir@gmail.com>
Co-authored-by: James Grugett <jahooma@gmail.com>
2022-04-29 19:35:56 -04:00
mantikoros
5cb6ee3bca daily free markets' liquidity provided by @ManifoldMarkets 2022-04-29 15:58:01 -04:00
mantikoros
5f86637ca5 raise ante to M$100 2022-04-29 15:53:13 -04:00
mantikoros
bfbcde4dfc remove fees for sold shares 2022-04-22 12:26:47 -05:00
mantikoros
a7c422e69e change ante to M$ 50 2022-04-21 12:59:12 -05:00
mantikoros
004969aa66
user-added liquidity provision panel (#90)
* user-added liquidity provision panel

* AddLiquidityPanel: handle loading, errors

* ContractInfoDialog: don't show add liquidity when market is closed

* ContractInfoDialog: hide add liquidity for FR
2022-04-21 12:58:12 -05:00
James Grugett
1af0740f10 Fix explore on dev 2022-04-21 12:43:57 -05:00
Boa
7b70b9b3bd
Free comments (#88)
* Allow free comments with optional bets

* Send emails for comments without bets

* Refactor to share logic

* No free comments on free response questions

* Minor fixes

* Condense line
2022-04-21 11:09:06 -06:00
James Grugett
7847a9e781 Track latency of feed and portfolio page. 2022-04-21 01:00:08 -05:00
James Grugett
01e43abd17 Add factors to weight new contracts higher, contracts with unseen comments, and contracts with prob closer to 50% 2022-04-20 16:37:01 -05:00
James Grugett
3c6369726e Add weekly activiation rate 2022-04-19 01:47:58 -05:00
James Grugett
280ae97070 Track clicks from feed 2022-04-19 00:16:08 -05:00
James Grugett
9c74f88b4a
Improve Free response UI (#78)
* Add legend to free response graph

* Hide answers panel unless resolving. Correctly order answers

* No gray background for add answer & resolve panel. Tweak spacing

* Max answer length 240 chars

* Show answer text in resolution for market page, card instead of number.

* Remove remaining answer #'s. Refactor outcome/resolution labels.

* Move answer panel back up

* Tweak spacing

* Update placement of bet button on mobile for FR answer feed item

* Fix reversed feed for binary markets

* Show multi resolve options

* Clean up unused parts of answer item

* Lighten resolve buttons

* Show answer text in market resolve email
2022-04-18 18:02:40 -05:00
mantikoros
7abc11c146 getInitialProbability: use totalShares to calculate prob for ported contracts 2022-04-18 17:15:25 -05:00
mantikoros
790aec9baf
Cfmm migration (#80)
* cfmm migration script

* save dpm shares, pool

* formatMoney: use floor instead of round

* migrate cfmm: use sale amount as shares for sold bets

* migration: make up fake share qty for sold shares

* migration: also convert resolved markets

* migration: don't migrate resolved markets after all

* migration: error checking
2022-04-18 17:02:53 -05:00
James Grugett
8a59ab3180 Tweak current investment calculation 2022-04-13 22:28:29 -05:00
James Grugett
2a3593c269 Fix profit calculation for dpm sales 2022-04-13 20:42:47 -05:00
James Grugett
bfb708d477 Fix profit calculation for cpmm sales. Change totalValue to investment value excluding sales 2022-04-13 17:25:32 -05:00
James Grugett
6ac361fdb9 Fix lodash import for cloud functions 2022-04-13 12:44:47 -05:00
James Grugett
ec49a73c74
Algo feed (#77)
* Implement algo feed

* Remove 'See more...' from feed items

* Fix problem with useUpdatedContracts.

* Tweak some params
2022-04-09 18:10:58 -05:00
mantikoros
2fe71731e4 create: fixed ante of $100 2022-04-09 13:51:22 -05:00
James Grugett
619644d6dd Run binary search until max precision 2022-04-05 16:00:26 -05:00
James Grugett
feb276ccfa Defensive break in binary search 2022-04-05 15:16:51 -05:00
James Grugett
f749eb1df8 Log views of contracts in feed 2022-04-04 22:28:38 -05:00
mantikoros
18bba89507 raise min ante to M$50 2022-04-04 10:47:29 -05:00
James Grugett
5dcd43f5b2 Refactor tricky bet calculations to one function 2022-04-03 14:48:53 -05:00
James Grugett
ce76a9754b Fix sell to pay back loans 2022-03-31 00:54:42 -05:00
James Grugett
80fe88a68a Constrain possible sell solutions by the size of the opposite sell pool. 2022-03-29 22:12:21 -05:00
James Grugett
3eb0bb1711 Throw error if sell conditions don't hold 2022-03-29 21:30:04 -05:00
James Grugett
ed5f69db7a
Sell shares panel (#69)
* Split BuyAmountInput out of AmountInput

* Buy and sell tabs. Compute some sell info

* In progress

* BuyPanel & SellPanel with banner above that shows current shares and toggle button

* Remove "Remaining balance"

* Bring back 'Place a trade'. Tweaks

* Sell shares cloud function.

* Sell all shares by default. Switch back to buy if sell all your shares.

* Cache your shares in local storage so sell banner doesn't flicker.

* Compute sale value of shares with binary search to keep k constant.

* Update bets table to show BUY or SELL

* Fixes from Stephen's review

* Don't allow selling more than max shares in cloud function

* Use modal for sell shares on desktop.

* Handle floating point precision in max shares you can sell.
2022-03-29 14:56:56 -05:00
Austin Chen
419a3106e8 Revert "Format large money amounts with 'k' and 'm'"
This reverts commit b7d39eaafd.
2022-03-25 15:54:15 -07:00
Austin Chen
b7d39eaafd Format large money amounts with 'k' and 'm' 2022-03-25 15:31:46 -07:00
James Grugett
7d8a87615a Embed market: dynamically adjust graph height 2022-03-24 12:03:17 -05:00
James Grugett
69e142e279 Make volume a non-optional field of contract 2022-03-23 00:09:47 -05:00
James Grugett
6b61d7209d Compute volume for contracts. Show volume instead of liquidity for cpmm. 2022-03-22 23:49:15 -05:00
Austin Chen
087e5f89fd Revert "formatPercent: always show at least one sig fig"
This reverts commit ae0cb4fc8c.
2022-03-22 16:53:23 -07:00
James Grugett
09da7fcb7c Add weekly active users chart. Put daily active first. 2022-03-21 17:42:12 -05:00
mantikoros
075804bb70 Revert "formatPercent: only show decimal to at most 2 places"
This reverts commit aebb4c5483.
2022-03-19 12:32:22 -05:00
mantikoros
aebb4c5483 formatPercent: only show decimal to at most 2 places 2022-03-19 12:30:30 -05:00
mantikoros
ae0cb4fc8c formatPercent: always show at least one sig fig 2022-03-19 11:23:01 -05:00
Austin Chen
d6a751d9a2 Show decimals on 98%+ 2022-03-18 20:02:04 -07:00
Austin Chen
7d5d945a20 Show 1 decimal point on probability tails 2022-03-18 19:12:50 -07:00
James Grugett
2937c0d891 Fix free response mkt payout to default to last probabilities if resolutions not specified 2022-03-18 14:59:06 -05:00
James Grugett
d13170f455 Revert "Revert "Fix free response MKT calculation to use probs from resolutions field, client-side.""
This reverts commit 11730e48a2.
2022-03-18 12:22:42 -05:00
Austin Chen
11730e48a2 Revert "Fix free response MKT calculation to use probs from resolutions field, client-side."
This reverts commit c12063799f.
2022-03-18 00:41:37 -07:00
James Grugett
c12063799f Fix free response MKT calculation to use probs from resolutions field, client-side. 2022-03-18 01:21:34 -05:00
mantikoros
93f790019c lower fees 2022-03-18 00:39:21 -05:00
mantikoros
a150be88e2 getDpmMktPayouts: log creator fee 2022-03-15 21:53:37 -05:00
mantikoros
c183e00d47
Cfmm (#64)
* cpmm initial commit: common logic, cloud functions

* remove unnecessary property

* contract type

* rename 'calculate.ts' => 'calculate-dpm.ts'

* rename dpm calculations

* use focus hook

* mechanism-agnostic calculations

* bet panel: use new calculations

* use new calculations

* delete markets cloud function

* use correct contract type in scripts / functions

* calculate fixed payouts; bets list calculations

* new bet: use calculateCpmmPurchase

* getOutcomeProbabilityAfterBet

* use deductFixedFees

* fix auto-refactor

* fix antes

* separate logic to payouts-dpm, payouts-fixed

* liquidity provision tracking

* remove comment

* liquidity label

* create liquidity provision even if no ante bet

* liquidity fee

* use all bets for getFixedCancelPayouts

* updateUserBalance: allow negative balances

* store initialProbability in contracts

* turn on liquidity fee; turn off creator fee

* Include time param in tweet url, so image preview is re-fetched

* share redemption

* cpmm ContractBetsTable display

* formatMoney: handle minus zero

* filter out redemption bets

* track fees on contract and bets; change fee schedule for cpmm markets; only pay out creator fees at resolution

* small fixes

* small fixes

* Redeem shares pays back loans first

* Fix initial point on graph

* calculateCpmmPurchase: deduct creator fee

* Filter out redemption bets from feed

* set env to dev for user-testing purposes

* creator fees messaging

* new cfmm: k = y^(1-p) * n^p

* addCpmmLiquidity

* correct price function

* enable fees

* handle overflow

* liquidity provision tracking

* raise fees

* Fix merge error

* fix dpm free response payout for single outcome

* Fix DPM payout calculation

* Remove hardcoding as dev

Co-authored-by: James Grugett <jahooma@gmail.com>
2022-03-15 17:27:51 -05:00
James Grugett
93287f8dc1
Answers in feed (#63)
* Compute answer group feed items

* Refactor feed code into 5 files under feed directory.

* Convert to typed ActivityItems

* Use feed "mode". Clean up cases.

* Implement feed answer groups!

* FR: Use nested comments/bets under answers for contract page. filter more items out of FR feed.

* Linkify answer text on activity feed

* Default feed excluded tags are case insensitive

* Show followed folds first

* Allow filtering your trades

* Store users's last sort in localstorage

* Use avatar of user that submitted answer and name instead of pencil icon. Spacing. Show up to 3 comments in asnwer group.

* Don't reveal market creator's bets

* Fix communites feed to be abbreviated

* Remove complicated answer group logic

Co-authored-by: Austin Chen <akrolsmir@gmail.com>
2022-03-14 15:29:32 -05:00
James Grugett
79bd299b68 Enforce max question length, description length, and tag length. 2022-03-09 11:08:57 -06:00
Austin Chen
da4ce99755
Merge Manifold for Teams infra into main codebase (#61)
* Add dev target for TheoremOne

* Restrict signups to theoremone.co emails

* Add new indices

* Forbid reads from unauthenticated users

* Client-side render pages that need auth

These pages are now client-side rendered:
- /home
- /leaderboards
- /market/...
- /fold/...

* Hide 404 for private Manifolds

* Brand instance for TheoremOne

* Hide "Add Funds" and "Personalize your feed"

* "M$" =>  "T$"

* Hide Discord & About Page too

* Update placeholders for teams

* Update firestore.indexes.json

* Switch /analytics to propz

* Migrate per-env code into common/

* More migrations to PROJECT_ID

* Conditionally use SSG depending on public vs private instance

* Fix props to be empty object

* Move more logic into access

* Spin out config files for each environment

* Generify most of the customizable brand stuff

* Move IS_PRIVATE_MANIFOLD to access.ts

* Rename access.ts to envs/constants.ts

* Add "dev:dev" alias

* Rever firestore rules to existing settings

* Fixes according to James's review
2022-03-08 18:43:30 -08:00
James Grugett
fe98a61e43 Fix leaderboard out of memory error with batchedWaitAll instead of Promise.all 2022-03-07 13:45:56 -08:00
James Grugett
ff92338873 Fix multi payout calculation! 2022-03-07 13:15:12 -08:00
James Grugett
9e9535ce56 Subtract loans from leaderboard calculations 2022-03-01 21:23:37 -08:00
James Grugett
985cdd2537
🏦 Per-market loans! (#57)
* Loan backend: Add loanAmount field to Bet, manage loans up to max loan amount per market -- buy, sell, and resolve.

* Loan frontend: show your loan amount in bet panel, answer bet panel

* Resolve emails include full payout not subtracting loan

* Exclude sold bets from current loan amount

* Handle bets table for loans. Sell dialog explains how you will repay your loan.

* Floor remaining balance

* Fix layout of create answer bet info

* Clean up Sell popup UI

* Fix bug where listen query was not updating data.

* Reword loan copy

* Adjust bet panel width

* Fix loan calc on front end

* Add comment for includeMetadataChanges.

Co-authored-by: Austin Chen <akrolsmir@gmail.com>
2022-03-01 21:31:48 -06:00
Austin Chen
8987a02975
Reapply Manifold for Teams config changes (#54)
* Reapply Manifold for Teams config changes

* Add Firebase config for TheoremOne

* Fix build

* Check in Firebase indexes

* Whitelist admins and new users by email

* Fix typo 🤦‍♂️
2022-02-26 23:29:33 -08:00
Austin Chen
492f777d0b Revert "Manifold for Teams: Support different Firestore dbs (#53)"
This reverts commit ebed7c15c0.
2022-02-26 22:19:16 -08:00
Austin Chen
ebed7c15c0
Manifold for Teams: Support different Firestore dbs (#53)
* Add Firebase config for TheoremOne

* Fix build

* Check in Firebase indexes

* Whitelist admins and new users by email
2022-02-26 22:08:50 -08:00
James Grugett
cb7c8ba7c2 Send email to market creator on new answer 2022-02-23 00:05:04 -06:00
James Grugett
7522b6af3c Send emails for new comments on markets you commented on or created. 2022-02-22 20:35:07 -06:00
James Grugett
fd846254a0 Implement resolving to multiple answers, weighted by probability 2022-02-20 01:26:33 -06:00
Austin Chen
a17342e55c
New, pretty user page (#48)
* Show bio, banner, and social links on user page

* Minor tweaks

* Allow edits to their user page

* Fix build; add a white ring around users

* From userpage, link to /profile (which is always editable now)

* Update userpage SEO

* Clean up Profile menu

* Fixes according to Stephen's code review
2022-02-17 17:16:58 -08:00
mantikoros
8e33c2b639 for sales, show change in implied probability 2022-02-17 18:24:10 -06:00
James Grugett
b2501d8145
Free response (#47)
* Answer datatype and MULTI outcome type for Contract

* Create free answer contract

* Automatically sort Tailwind classes with Prettier (#45)

* Add Prettier Tailwind plugin

* Autoformat Tailwind classes with Prettier

* Allow for non-binary contracts in contract page and related components

* logo with white inside, transparent bg

* Create answer

* Some UI for showing answers

* Answer bet panel

* Convert rest of calcuate file to generic multi contracts

* Working betting with ante'd NONE answer

* Numbered answers. Layout & calculation tweaks

* Can bet. More layout tweaks!

* Resolve answer UI

* Resolve multi market

* Resolved market UI

* Fix feed and cards for multi contracts

* Sell bets. Various fixes

* Tweaks for trades page

* Always dev mode

* Create answer bet has isAnte: true

* Fix  card showing 0% for multi contracts

* Fix grouped bets feed for multi outcomes

* None option converted to none of the above label at bottom of list. Button to resolve none.

* Tweaks to no answers yet, resolve button layout

* Show ante bets on new answers in the feed

* Update placeholder text for description

* Consolidate firestore rules for subcollections

* Remove Contract and Bet type params. Use string type for outcomes.

* Increase char limit to 10k for answers. Preserve line breaks.

* Don't show resolve options after answer chosen

* Fix type error in script

* Remove NONE resolution option

* Change outcomeType to include 'MULTI' and 'FREE_RESPONSE'

* Show bet probability change and payout when creating answer

* User info change: also change answers

* Append answers to contract field 'answers'

* sort trades by resolved

* Don't include trailing !:,.; in links

* Stop flooring inputs into formatMoney

* Revert "Stop flooring inputs into formatMoney"

This reverts commit 2f7ab18429.

* Consistently floor user.balance

* Expand create panel on focus

From Richard Hanania's feedback

* welcome email: include link to manifold

* Fix home page in dev on branches that are not free-response

* Close emails (#50)

* script init for stephen dev

* market close emails

* order of operations

* template email

* sendMarketCloseEmail: handle unsubscribe

* remove debugging

* marketCloseEmails: every hour

* sendMarketCloseEmails: check undefined

* marketCloseEmails: "every hour" => "every 1 hours"

* Set up a read API using Vercel serverless functions (#49)

* Set up read API using Vercel serverless functions

Featuring:
/api/v0/markets
/api/v0/market/[contractId]
/api/v0/slug/[contractSlug]

* Include tags in API

* Tweaks. Remove filter for only binary contract

* Fix bet probability change for NO bets

* Put back isProd calculation

Co-authored-by: Austin Chen <akrolsmir@gmail.com>
Co-authored-by: mantikoros <sgrugett@gmail.com>
Co-authored-by: mantikoros <95266179+mantikoros@users.noreply.github.com>
2022-02-17 17:00:19 -06:00
mantikoros
dcbdc66df5
Close emails (#50)
* script init for stephen dev

* market close emails

* order of operations

* template email

* sendMarketCloseEmail: handle unsubscribe

* remove debugging

* marketCloseEmails: every hour
2022-02-17 12:18:02 -06:00
mantikoros
800d9c6723 lower fees on sales 2022-02-13 20:24:11 -06:00
mantikoros
e2de257372
Simple dpm (#46)
* simpler payout mechanism; lower phantom ante to $1

* deductFees

* reduce phantom ante to 0.01

* PHANTOM_ANTE = 0.001

* payouts: pay back winner losses with fees

* simplify payouts
2022-02-12 19:19:17 -06:00
mantikoros
03f36cf954
User profile (#44)
* add id, userId to comment

* change user info cloud function and script; move cleanUsername to common

* change user info script

* fix rules

* add fund button: useLocation hook

* profile page

* merge

* profile stuff

* avatar uploading to storage bucket

* changeUserInfo: use transaction

* Styles for profile page

* Edit mode for profile, and more styles

Co-authored-by: James Grugett <jahooma@gmail.com>
2022-02-03 21:04:56 -06:00
mantikoros
63de359d22 lower creator fee to 4% 2022-02-03 20:49:04 -06:00
James Grugett
552e6e6c3a
Custom feed (#43)
* Show custom feed of contracts from folds your follow or have bet on.

* Add tw-elements UI library

* Add loading spinner while feed loads

* Switch from onSnapshot to our listenForValues, which doesn't set with partial cached values

* Change home tags to communities

* Remove tw-elements for now
2022-02-03 18:13:04 -06:00
mantikoros
4294481b5b change fee structure 2022-02-03 16:59:59 -06:00
James Grugett
ca29a43da9 Calculate global leaderboard from contract bets 2022-02-01 21:30:43 -06:00
James Grugett
0eac8d9c5c
Yarn workspaces (#42)
* Try yarn workspaces

* Add versions to sub package.json files
2022-02-01 15:25:51 -06:00
James Grugett
b95f258763 Add package.json to common directory, and lodash dependency 2022-02-01 12:59:51 -06:00
James Grugett
7c50b55331 Match lowercase tags for folds 2022-02-01 12:29:14 -06:00
James Grugett
79c5472c11 Match tags with hash 2022-02-01 11:02:30 -06:00
James Grugett
4e1174a4dc Option to disallow market creation from fold 2022-01-31 22:10:02 -06:00
James Grugett
6427e1bd06 Save tags unique and case-insensitive. Don't clear added tags on updating description. 2022-01-30 21:25:52 -06:00
mantikoros
f06ca8305c
Resolve prob (#41)
* rename MKT to PROB; show resolved probability; move format utilities to common

* ProbabilitySelector

* resolve to PROB

* prob and mkt labels
2022-01-30 15:51:30 -06:00
jahooma
9764a03189 Add create market to top of fold activity. Auto-adds the primary tag of the fold. 2022-01-27 12:45:35 -06:00
jahooma
ef8157025f Compute fold follower count from cloud function. 2022-01-26 14:27:16 -06:00
James Grugett
8b9d0e5dba
New fold page UI with tabs (#37)
* Tabbed fold page

* Implement market, leaderboard tab views for fold. And edit dialog

* Add about field to Fold
2022-01-25 14:47:25 -06:00
jahooma
705d5cada7 Add lowercaseTags field to contracts. ante / closeTime non-optional in new contract code 2022-01-24 16:33:10 -06:00
jahooma
aa1022546d Implement leaderboards for folds! 2022-01-22 17:59:50 -06:00
jahooma
4ba112df2e Parse tags optionally including '#' 2022-01-21 18:07:11 -06:00
James Grugett
60f68b178d
Folds (#34)
* Fold type, fold page, query for fold contracts

* Tsconfig: target esnext, nounused locals: false

* Store tags in field on contract. Script to update contract tags

* Show tags on fold page

* Load all fold comments server-side to serve better feed

* Fix the annoying firebase already initialized error!

* Add links to /edit and /leaderboards for fold

* Page with list of folds

* UI for creating a fold

* Create a fold

* Edit fold page
2022-01-21 17:21:46 -06:00
mantikoros
1b5e33ca54 no ante selling 2022-01-19 16:36:55 -06:00
Austin Chen
78c461b26c Show creator avatar in feed 2022-01-19 02:34:36 -05:00
mantikoros
4528615863
Private user (#32)
* PrivateUser

* createUser: create private user; detect multiple signups

* include user properties in private user

* script: create private users

* unsubscribing from market resolution emails

* track total deposits
2022-01-18 21:36:46 -06:00
mantikoros
908c8c03e6
Create user cloud function (#31)
* createUser cloud function; change User object

* initial commit

* listenForLogin: avoid race condition

* createUser: allow capital letters in username

* remove debugging

* leaderboard: empty url for undefined avatar image
2022-01-18 01:18:38 -06:00
jahooma
56c7e2597d Schedule cloud function to update user metrics: totalPnL, creatorVolume 2022-01-17 15:39:34 -06:00
Austin Chen
7d7286b1c1
Denormalize the avatar URL on contract creation (#29) 2022-01-16 01:03:59 -05:00
jahooma
f6079e68d0 Choose random hot contracts from top 16 every 5 minutes. 2022-01-15 00:44:33 -06:00
mantikoros
a0be5b6394 calculateMoneyRatio 2022-01-15 00:11:27 -06:00
mantikoros
3fa2926559 create page design; require minimum ante; lower phantom ante amount; createContract checks 2022-01-14 17:39:17 -06:00
mantikoros
3805adff58 calculateMoneyRatio: use share value amount 2022-01-14 11:35:32 -06:00
mantikoros
6d536c4e16 change fee structure (paid only on winnings); calculateMoneyRatio 2022-01-14 11:11:01 -06:00
mantikoros
3cffccdd3f calculateMoneyRatio 2022-01-13 20:52:03 -06:00
mantikoros
411a739004 ante bets created at same time as contract 2022-01-13 10:40:08 -06:00
mantikoros
bc454e89ba calculateMoneyRatio 2022-01-12 23:43:07 -06:00
jahooma
de043de589 Add visibility field to contracts. Hot contracts & activity feed show only visibility 'public'. 2022-01-12 19:53:50 -06:00
mantikoros
9d5490cf9a
Switch to new dpm mechanism (#26)
* initial commit

* antes

* rename path, compute to contractPath, contractMetrics

* merge

* Include antes as bets; more calculations

* fees on estimated winnings

* mkt payout calculation

* contract: remove startPool, add phantomShares

* Merge branch 'main' into new-dpm

* dpm migration script

* my service account
2022-01-12 13:01:04 -06:00
mantikoros
9a834526c0 formatting 2022-01-10 17:52:03 -06:00
mantikoros
a1aeabeab4 move market logic to common 2022-01-10 16:49:13 -06:00
mantikoros
129d66c10f improve slugs 2022-01-10 16:49:13 -06:00
mantikoros
b97a65cf2c refactor data structures, calculations to common directory 2022-01-10 15:07:57 -06:00