reenable fees on share sales; rename getCpmmFees()
This commit is contained in:
parent
b1b016f9e0
commit
50c5f8b6eb
|
@ -1,7 +1,7 @@
|
||||||
import { sum, groupBy, mapValues, sumBy, partition } from 'lodash'
|
import { sum, groupBy, mapValues, sumBy, partition } from 'lodash'
|
||||||
|
|
||||||
import { CPMMContract } from './contract'
|
import { CPMMContract } from './contract'
|
||||||
import { CREATOR_FEE, Fees, LIQUIDITY_FEE, noFees, PLATFORM_FEE } from './fees'
|
import { CREATOR_FEE, Fees, LIQUIDITY_FEE, PLATFORM_FEE } from './fees'
|
||||||
import { LiquidityProvision } from './liquidity-provision'
|
import { LiquidityProvision } from './liquidity-provision'
|
||||||
import { addObjects } from './util/object'
|
import { addObjects } from './util/object'
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ function calculateCpmmShares(
|
||||||
: n + bet - (k * (bet + y) ** -p) ** (1 / (1 - p))
|
: n + bet - (k * (bet + y) ** -p) ** (1 / (1 - p))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCpmmLiquidityFee(
|
export function getCpmmFees(
|
||||||
contract: CPMMContract,
|
contract: CPMMContract,
|
||||||
bet: number,
|
bet: number,
|
||||||
outcome: string
|
outcome: string
|
||||||
|
@ -83,7 +83,7 @@ export function calculateCpmmSharesAfterFee(
|
||||||
outcome: string
|
outcome: string
|
||||||
) {
|
) {
|
||||||
const { pool, p } = contract
|
const { pool, p } = contract
|
||||||
const { remainingBet } = getCpmmLiquidityFee(contract, bet, outcome)
|
const { remainingBet } = getCpmmFees(contract, bet, outcome)
|
||||||
|
|
||||||
return calculateCpmmShares(pool, p, remainingBet, outcome)
|
return calculateCpmmShares(pool, p, remainingBet, outcome)
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,7 @@ export function calculateCpmmPurchase(
|
||||||
outcome: string
|
outcome: string
|
||||||
) {
|
) {
|
||||||
const { pool, p } = contract
|
const { pool, p } = contract
|
||||||
const { remainingBet, fees } = getCpmmLiquidityFee(contract, bet, outcome)
|
const { remainingBet, fees } = getCpmmFees(contract, bet, outcome)
|
||||||
// const remainingBet = bet
|
|
||||||
// const fees = noFees
|
|
||||||
|
|
||||||
const shares = calculateCpmmShares(pool, p, remainingBet, outcome)
|
const shares = calculateCpmmShares(pool, p, remainingBet, outcome)
|
||||||
const { YES: y, NO: n } = pool
|
const { YES: y, NO: n } = pool
|
||||||
|
@ -176,19 +174,17 @@ export function calculateCpmmSale(
|
||||||
throw new Error('Cannot sell non-positive shares')
|
throw new Error('Cannot sell non-positive shares')
|
||||||
}
|
}
|
||||||
|
|
||||||
const saleValue = calculateCpmmShareValue(
|
const rawSaleValue = calculateCpmmShareValue(
|
||||||
contract,
|
contract,
|
||||||
shares,
|
shares,
|
||||||
outcome as 'YES' | 'NO'
|
outcome as 'YES' | 'NO'
|
||||||
)
|
)
|
||||||
|
|
||||||
const fees = noFees
|
const { fees, remainingBet: saleValue } = getCpmmFees(
|
||||||
|
contract,
|
||||||
// const { fees, remainingBet: saleValue } = getCpmmLiquidityFee(
|
rawSaleValue,
|
||||||
// contract,
|
outcome === 'YES' ? 'NO' : 'YES'
|
||||||
// rawSaleValue,
|
)
|
||||||
// outcome === 'YES' ? 'NO' : 'YES'
|
|
||||||
// )
|
|
||||||
|
|
||||||
const { pool } = contract
|
const { pool } = contract
|
||||||
const { YES: y, NO: n } = pool
|
const { YES: y, NO: n } = pool
|
||||||
|
|
|
@ -37,7 +37,7 @@ import { useUserContractBets } from 'web/hooks/use-user-bets'
|
||||||
import {
|
import {
|
||||||
calculateCpmmSale,
|
calculateCpmmSale,
|
||||||
getCpmmProbability,
|
getCpmmProbability,
|
||||||
getCpmmLiquidityFee,
|
getCpmmFees,
|
||||||
} from 'common/calculate-cpmm'
|
} from 'common/calculate-cpmm'
|
||||||
import { getFormattedMappedValue } from 'common/pseudo-numeric'
|
import { getFormattedMappedValue } from 'common/pseudo-numeric'
|
||||||
import { SellRow } from './sell-row'
|
import { SellRow } from './sell-row'
|
||||||
|
@ -302,7 +302,7 @@ function BuyPanel(props: {
|
||||||
|
|
||||||
const cpmmFees =
|
const cpmmFees =
|
||||||
contract.mechanism === 'cpmm-1' &&
|
contract.mechanism === 'cpmm-1' &&
|
||||||
getCpmmLiquidityFee(contract, betAmount ?? 0, betChoice ?? 'YES').totalFees
|
getCpmmFees(contract, betAmount ?? 0, betChoice ?? 'YES').totalFees
|
||||||
|
|
||||||
const dpmTooltip =
|
const dpmTooltip =
|
||||||
contract.mechanism === 'dpm-2'
|
contract.mechanism === 'dpm-2'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user