Revert fishy change regarding payouts
This commit is contained in:
parent
86625798cd
commit
80d5607984
|
@ -46,7 +46,6 @@ export type Contract = FullContract<
|
||||||
export type BinaryContract = FullContract<DPM | CPMM, Binary>
|
export type BinaryContract = FullContract<DPM | CPMM, Binary>
|
||||||
export type FreeResponseContract = FullContract<DPM | CPMM, FreeResponse>
|
export type FreeResponseContract = FullContract<DPM | CPMM, FreeResponse>
|
||||||
export type NumericContract = FullContract<DPM, Numeric>
|
export type NumericContract = FullContract<DPM, Numeric>
|
||||||
export type AnyOutcome = Binary | Multi | FreeResponse | Numeric
|
|
||||||
|
|
||||||
export type DPM = {
|
export type DPM = {
|
||||||
mechanism: 'dpm-2'
|
mechanism: 'dpm-2'
|
||||||
|
|
|
@ -2,12 +2,12 @@ import { sum, groupBy, sumBy, mapValues } from 'lodash'
|
||||||
|
|
||||||
import { Bet, NumericBet } from './bet'
|
import { Bet, NumericBet } from './bet'
|
||||||
import { deductDpmFees, getDpmProbability } from './calculate-dpm'
|
import { deductDpmFees, getDpmProbability } from './calculate-dpm'
|
||||||
import { DPM, FreeResponse, FullContract, Multi, AnyOutcome } from './contract'
|
import { DPM, FreeResponse, FullContract, Multi } from './contract'
|
||||||
import { DPM_CREATOR_FEE, DPM_FEES, DPM_PLATFORM_FEE } from './fees'
|
import { DPM_CREATOR_FEE, DPM_FEES, DPM_PLATFORM_FEE } from './fees'
|
||||||
import { addObjects } from './util/object'
|
import { addObjects } from './util/object'
|
||||||
|
|
||||||
export const getDpmCancelPayouts = (
|
export const getDpmCancelPayouts = (
|
||||||
contract: FullContract<DPM, AnyOutcome>,
|
contract: FullContract<DPM, any>,
|
||||||
bets: Bet[]
|
bets: Bet[]
|
||||||
) => {
|
) => {
|
||||||
const { pool } = contract
|
const { pool } = contract
|
||||||
|
@ -31,7 +31,7 @@ export const getDpmCancelPayouts = (
|
||||||
|
|
||||||
export const getDpmStandardPayouts = (
|
export const getDpmStandardPayouts = (
|
||||||
outcome: string,
|
outcome: string,
|
||||||
contract: FullContract<DPM, AnyOutcome>,
|
contract: FullContract<DPM, any>,
|
||||||
bets: Bet[]
|
bets: Bet[]
|
||||||
) => {
|
) => {
|
||||||
const winningBets = bets.filter((bet) => bet.outcome === outcome)
|
const winningBets = bets.filter((bet) => bet.outcome === outcome)
|
||||||
|
@ -78,7 +78,7 @@ export const getDpmStandardPayouts = (
|
||||||
|
|
||||||
export const getNumericDpmPayouts = (
|
export const getNumericDpmPayouts = (
|
||||||
outcome: string,
|
outcome: string,
|
||||||
contract: FullContract<DPM, AnyOutcome>,
|
contract: FullContract<DPM, any>,
|
||||||
bets: NumericBet[]
|
bets: NumericBet[]
|
||||||
) => {
|
) => {
|
||||||
const totalShares = sumBy(bets, (bet) => bet.allOutcomeShares[outcome] ?? 0)
|
const totalShares = sumBy(bets, (bet) => bet.allOutcomeShares[outcome] ?? 0)
|
||||||
|
@ -129,7 +129,7 @@ export const getNumericDpmPayouts = (
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDpmMktPayouts = (
|
export const getDpmMktPayouts = (
|
||||||
contract: FullContract<DPM, AnyOutcome>,
|
contract: FullContract<DPM, any>,
|
||||||
bets: Bet[],
|
bets: Bet[],
|
||||||
resolutionProbability?: number
|
resolutionProbability?: number
|
||||||
) => {
|
) => {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
FreeResponse,
|
FreeResponse,
|
||||||
FullContract,
|
FullContract,
|
||||||
Multi,
|
Multi,
|
||||||
AnyOutcome,
|
|
||||||
} from './contract'
|
} from './contract'
|
||||||
import { Fees } from './fees'
|
import { Fees } from './fees'
|
||||||
import { LiquidityProvision } from './liquidity-provision'
|
import { LiquidityProvision } from './liquidity-provision'
|
||||||
|
@ -73,7 +72,8 @@ export const getPayouts = (
|
||||||
liquidities,
|
liquidities,
|
||||||
resolutionProbability
|
resolutionProbability
|
||||||
)
|
)
|
||||||
} else if (contract.mechanism === 'dpm-2') {
|
}
|
||||||
|
|
||||||
return getDpmPayouts(
|
return getDpmPayouts(
|
||||||
outcome,
|
outcome,
|
||||||
resolutions,
|
resolutions,
|
||||||
|
@ -81,9 +81,6 @@ export const getPayouts = (
|
||||||
bets,
|
bets,
|
||||||
resolutionProbability
|
resolutionProbability
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
throw new Error('Unknown contract mechanism.')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getFixedPayouts = (
|
export const getFixedPayouts = (
|
||||||
|
@ -115,7 +112,7 @@ export const getDpmPayouts = (
|
||||||
resolutions: {
|
resolutions: {
|
||||||
[outcome: string]: number
|
[outcome: string]: number
|
||||||
},
|
},
|
||||||
contract: FullContract<DPM, AnyOutcome>,
|
contract: Contract,
|
||||||
bets: Bet[],
|
bets: Bet[],
|
||||||
resolutionProbability?: number
|
resolutionProbability?: number
|
||||||
): PayoutInfo => {
|
): PayoutInfo => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user