lower fees on sales

This commit is contained in:
mantikoros 2022-02-13 20:24:03 -06:00
parent 0e640bf53b
commit 800d9c6723
2 changed files with 7 additions and 4 deletions

View File

@ -104,7 +104,9 @@ export function calculateShareValue(contract: Contract, bet: Bet) {
}
export function calculateSaleAmount(contract: Contract, bet: Bet) {
return (1 - FEES) * calculateShareValue(contract, bet)
const { amount } = bet
const winnings = calculateShareValue(contract, bet)
return deductFees(amount, winnings)
}
export function calculatePayout(

View File

@ -1,5 +1,5 @@
import { Bet } from './bet'
import { calculateShareValue, getProbability } from './calculate'
import { calculateShareValue, deductFees, getProbability } from './calculate'
import { Contract } from './contract'
import { CREATOR_FEE, FEES } from './fees'
import { User } from './user'
@ -36,8 +36,9 @@ export const getSellBetInfo = (
const probBefore = getProbability(contract.totalShares)
const probAfter = getProbability(newTotalShares)
const creatorFee = CREATOR_FEE * adjShareValue
const saleAmount = (1 - FEES) * adjShareValue
const profit = adjShareValue - amount
const creatorFee = CREATOR_FEE * Math.max(0, profit)
const saleAmount = deductFees(amount, adjShareValue)
console.log(
'SELL M$',