manifold/functions/src
Jonas Wagner 2a5b68977b
Require a minimum amount of 1 Mana per bet. (#273)
This is a hacky patch for a problem that runs more deeply: the use of
floating-point for Mana calculations, along with the associated rounding
errors.

Consider the following example:

```typescript
const balance = 1000
const bet = 5.6e-14
const newBalance = balance - bet
if (newBalance == balance) {
  alert(`I placed a bet of ${bet} without changing my balance.`)
}
```

This will actually print a message, because floating-point numbers can
only represent so many digits, and thus we get 1000.0 rather than
999.99999999999994.

This is a purely theoretical attack at this point; nobody could create
enough pico-bets to actually affect their balance using this technique.
However, I believe is worth ensuring a minimum bet amount, and might
prevent other problems such as the UI showing messages like "User Foo
bought M0 of YES", which could confuse users.

For a more definite solution, we would probably need to change some
computation to integers, where addition is always commutative and
value-preserving. This is similar to what most financial software does
(e.g., Bitcoin uses 1 Satoshi = 0.00000001 BTC as their unit).
2022-05-22 16:34:18 -05:00
..
email-templates Typo fix; fixes #216 (#218) 2022-05-13 18:22:10 -04:00
scripts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
add-liquidity.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00
api.ts Fix up API CORS header processing (#277) 2022-05-20 19:34:26 -07:00
backup-db.ts Send M$ to Charity & txns (#81) 2022-04-29 19:35:56 -04:00
call-cloud-function.ts keep awake cloud functions 2021-12-17 20:13:20 -06:00
change-user-info.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00
create-answer.ts Numeric range markets!! (#146) 2022-05-19 12:42:03 -05:00
create-contract.ts Public API improvements (#266) 2022-05-20 14:58:14 -07:00
create-fold.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
create-user.ts Revert "Better random (#213)" 2022-05-16 20:26:51 -04:00
emails.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
fetch.ts keep awake cloud functions 2021-12-17 20:13:20 -06:00
get-feed-data.ts Categories (#132) 2022-05-12 10:07:10 -05:00
index.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00
keep-awake.ts turn keep awake on 2021-12-24 16:14:02 -05:00
market-close-emails.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00
on-create-bet.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
on-create-comment.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
on-fold-delete.ts Fold delete 2022-01-26 14:56:15 -06:00
on-fold-follow.ts Compute fold follower count from cloud function. 2022-01-26 14:27:16 -06:00
on-view.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00
place-bet.ts Require a minimum amount of 1 Mana per bet. (#273) 2022-05-22 16:34:18 -05:00
redeem-shares.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
resolve-market.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
sell-bet.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00
sell-shares.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
send-email.ts Send emails for new comments on markets you commented on or created. 2022-02-22 20:35:07 -06:00
stripe.ts Update mantic.markets -> manifold.markets (#212) 2022-05-13 07:07:51 -04:00
transact.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00
unsubscribe.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
update-contract-metrics.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
update-feed.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
update-recommendations.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
update-user-metrics.ts Change lodash stuff so that it can be tree-shaken out of build (#233) 2022-05-22 01:36:05 -07:00
utils.ts Revert "Make absolute imports work with functions project (#168)" 2022-05-15 13:39:42 -04:00