Commit Graph

99 Commits

Author SHA1 Message Date
James Grugett
72a56b46fd Switch portfolio default sort to recent trade 2022-04-14 00:16:08 -05:00
James Grugett
43b8c16fcc Compact-ify cards in portfolio page 2022-04-14 00:06:13 -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
e58ec54546 Clean up portfolio sorts 2022-04-13 18:56:28 -05:00
James Grugett
a09af526a0 Switch summary stat from payout at current % to profit 2022-04-13 17:57:46 -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
a9028b0a94 Remove invested metric for cfmm markets 2022-04-13 15:47:12 -05:00
James Grugett
ef0408dcdf Mobile navbar includes Portfolio instead of Communities. Each option is labeled! 2022-04-03 18:26:50 -05:00
James Grugett
5dcd43f5b2 Refactor tricky bet calculations to one function 2022-04-03 14:48:53 -05:00
James Grugett
1b9a38ff66 Tweak current value calculation 2022-04-03 11:18:31 -05:00
James Grugett
6b2f6f7185 Calculate invested differently. Sort trades by value and profit, including sales profit. Display profit when sorting by profit. 2022-04-03 01:08:57 -05:00
Austin Chen
94b7ebe5e8 Minor fixes: typo, React keys 2022-03-31 01:38:57 -07: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
James Grugett
0592909248 Subtract loan amount from investment 2022-03-21 01:29:53 -05:00
Austin Chen
03592f9c3e Add sort by close time 2022-03-20 19:30:04 -07:00
James Grugett
e0989bdfde Fix loan amount label to account for sales. 2022-03-17 12:04:48 -05:00
James Grugett
0390e851fc Show loan summary above bets table. Remove parenthetical loan amount per bet. 2022-03-16 18:08:33 -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
Austin Chen
e5d02dde06 Allow filtering your trades 2022-03-13 13:55:42 -07:00
Austin Chen
b4f8fcf38e Show profit/loss in sale panel 2022-03-03 02:10:20 -08:00
James Grugett
4d8af33c85 Invested value => Investment value 2022-03-02 15:48:38 -08:00
James Grugett
6285212a1e Update your trades to show total profit, invested value 2022-03-02 15:42:59 -08:00
James Grugett
1dd078562a Fix to actually show investment instead of current value. And subtract bet amount from current value. 2022-03-01 21:09:33 -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
James Grugett
5a39ca4c5e Don't show payout if chosen column for resolved markets 2022-02-28 16:44:25 -08:00
James Grugett
4bc2833e11 Add column to bets table with payout if chosen. Rearrange columns. Tweak sell dialog wording. 2022-02-28 16:38:09 -08:00
James Grugett
a680d80793 Free response: Show invested and payouts on market page, don't show payout if yes/no 2022-02-28 15:58:13 -08:00
James Grugett
b7f94e65a7 Change Settled to Resolved, Newest to Most recent in trades sort options. 2022-02-27 16:52:58 -08:00
Austin Chen
0a98ffe05c Remove sold bets from Your Trades 2022-02-25 16:57:28 -08:00
mantikoros
c24007012c bets list: show message if no active bets 2022-02-22 16:55:06 -06:00
James Grugett
858ce10b49 Re-order sell button and sale price to be first in bets table 2022-02-21 14:22:36 -06:00
James Grugett
6d3fb8f4ae Remove balance from your trades page (looks better on mobile, cleaner) 2022-02-21 12:55:26 -06:00
James Grugett
c32442ab41 Fix trades sort by newest 2022-02-21 12:42:51 -06:00
James Grugett
793742b499 Trades page: Wait for all bets / contract data to load with loading indicator 2022-02-20 22:26:22 -06: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
d3fdd4cd1f bets list: comment out expectation 2022-02-17 16:49:00 -06:00
mantikoros
3609255342 sort trades by value 2022-02-17 16:44:33 -06:00
Austin Chen
515676f885 Consistently floor user.balance 2022-02-16 19:19:11 -08:00
mantikoros
95242d94ac sort trades by resolved 2022-02-16 00:08:16 -06:00
Austin Chen
95fbfb7db0 Tweak padding 2022-02-14 15:39:59 -08:00
Austin Chen
86b4b1a907 Use badges in Your Trades 2022-02-14 15:29:29 -08:00
mantikoros
443acdbcf8 beautify trades page 2022-02-14 16:00:46 -06:00
mantikoros
a8abd4ecbb trades page: show pnl 2022-02-14 13:00:20 -06:00
Austin Chen
0e640bf53b Show the current % instead of "MKT" in Your Trades 2022-02-13 18:20:46 -08:00
Austin Chen
7338bdd47a
Automatically sort Tailwind classes with Prettier (#45)
* Add Prettier Tailwind plugin

* Autoformat Tailwind classes with Prettier
2022-02-11 10:40:22 -08:00
James Grugett
b0a1da62d2 Add sort options for /trades. Can sort by
profit or newest!
2022-02-08 23:28:20 -06:00
James Grugett
e66564cd1f Add current prob to trades items 2022-02-08 22:52:09 -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