use deductFixedFees
This commit is contained in:
parent
a7e7fc0c90
commit
660597f10b
|
@ -1,6 +1,8 @@
|
|||
import * as _ from 'lodash'
|
||||
import { Bet } from './bet'
|
||||
import { deductFixedFees } from './calculate-fixed-payouts'
|
||||
import { Binary, CPMM, FullContract } from './contract'
|
||||
import { CREATOR_FEE } from './fees'
|
||||
|
||||
export function getCpmmProbability(pool: { [outcome: string]: number }) {
|
||||
// For binary contracts only.
|
||||
|
@ -85,7 +87,11 @@ export function calculateCpmmSale(
|
|||
|
||||
const newPool = { YES: newY, NO: newN }
|
||||
|
||||
return { saleValue, newPool }
|
||||
const profit = saleValue - bet.amount
|
||||
const creatorFee = CREATOR_FEE * Math.max(0, profit)
|
||||
const saleAmount = deductFixedFees(bet.amount, saleValue)
|
||||
|
||||
return { saleValue, newPool, creatorFee, saleAmount }
|
||||
}
|
||||
|
||||
export function getCpmmProbabilityAfterSale(
|
||||
|
|
|
@ -21,7 +21,7 @@ export function calculateFixedCancelPayout(bet: Bet) {
|
|||
export function calculateStandardFixedPayout(bet: Bet, outcome: string) {
|
||||
const { amount, outcome: betOutcome, shares } = bet
|
||||
if (betOutcome !== outcome) return 0
|
||||
return deductFixedFees(amount, shares - amount)
|
||||
return deductFixedFees(amount, shares)
|
||||
}
|
||||
|
||||
function calculateFixedMktPayout(
|
||||
|
@ -43,7 +43,8 @@ function calculateFixedMktPayout(
|
|||
}
|
||||
|
||||
export const deductFixedFees = (betAmount: number, winnings: number) => {
|
||||
return winnings > betAmount
|
||||
? betAmount + (1 - FEES) * (winnings - betAmount)
|
||||
: winnings
|
||||
return winnings
|
||||
// return winnings > betAmount
|
||||
// ? betAmount + (1 - FEES) * (winnings - betAmount)
|
||||
// : winnings
|
||||
}
|
||||
|
|
|
@ -4,11 +4,7 @@ import {
|
|||
calculateDpmShareValue,
|
||||
deductDpmFees,
|
||||
} from './calculate-dpm'
|
||||
import {
|
||||
calculateCpmmSale,
|
||||
calculateCpmmShareValue,
|
||||
getCpmmProbability,
|
||||
} from './calculate-cpmm'
|
||||
import { calculateCpmmSale, getCpmmProbability } from './calculate-cpmm'
|
||||
import { Binary, DPM, CPMM, FullContract } from './contract'
|
||||
import { CREATOR_FEE } from './fees'
|
||||
import { User } from './user'
|
||||
|
@ -87,15 +83,14 @@ export const getCpmmSellBetInfo = (
|
|||
const { pool } = contract
|
||||
const { id: betId, amount, shares, outcome } = bet
|
||||
|
||||
const { saleValue, newPool } = calculateCpmmSale(contract, bet)
|
||||
const { saleValue, newPool, creatorFee, saleAmount } = calculateCpmmSale(
|
||||
contract,
|
||||
bet
|
||||
)
|
||||
|
||||
const probBefore = getCpmmProbability(pool)
|
||||
const probAfter = getCpmmProbability(newPool)
|
||||
|
||||
const profit = saleValue - amount
|
||||
const creatorFee = CREATOR_FEE * Math.max(0, profit)
|
||||
const saleAmount = deductDpmFees(amount, profit)
|
||||
|
||||
console.log(
|
||||
'SELL M$',
|
||||
amount,
|
||||
|
|
Loading…
Reference in New Issue
Block a user