From 8380bf4f726cdfa0009cc40d6938ad5d65789d30 Mon Sep 17 00:00:00 2001 From: Milli Date: Sun, 5 Jun 2022 18:23:21 +0200 Subject: [PATCH] moved calculate ts for access in firebase --- {common => functions/shared}/calculate.ts | 14 +++++++++----- functions/src/resolve-market.ts | 2 +- web/components/bets-list.tsx | 2 +- web/components/resolution-panel.tsx | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) rename {common => functions/shared}/calculate.ts (94%) diff --git a/common/calculate.ts b/functions/shared/calculate.ts similarity index 94% rename from common/calculate.ts rename to functions/shared/calculate.ts index b7d79f2f..ef4cd330 100644 --- a/common/calculate.ts +++ b/functions/shared/calculate.ts @@ -1,12 +1,12 @@ import { maxBy } from 'lodash' -import { Bet } from './bet' +import { Bet } from '../../common/bet' import { calculateCpmmSale, getCpmmProbability, getCpmmOutcomeProbabilityAfterBet, getCpmmProbabilityAfterSale, calculateCpmmSharesAfterFee, -} from './calculate-cpmm' +} from '../../common/calculate-cpmm' import { calculateDpmPayout, calculateDpmPayoutAfterCorrectBet, @@ -16,9 +16,13 @@ import { getDpmProbability, getDpmOutcomeProbabilityAfterBet, getDpmProbabilityAfterSale, -} from './calculate-dpm' -import { calculateFixedPayout } from './calculate-fixed-payouts' -import { Contract, BinaryContract, FreeResponseContract } from './contract' +} from '../../common/calculate-dpm' +import { calculateFixedPayout } from '../../common/calculate-fixed-payouts' +import { + Contract, + BinaryContract, + FreeResponseContract, +} from '../../common/contract' export function getProbability(contract: BinaryContract) { return contract.mechanism === 'cpmm-1' diff --git a/functions/src/resolve-market.ts b/functions/src/resolve-market.ts index 9cf08476..1679b9a0 100644 --- a/functions/src/resolve-market.ts +++ b/functions/src/resolve-market.ts @@ -17,7 +17,7 @@ import { removeUndefinedProps } from '../../common/util/object' import { LiquidityProvision } from '../../common/liquidity-provision' import { getValues } from './utils' import { batchedWaitAll } from '../../common/util/promise' -import { getProbability } from 'common/calculate' +import { getProbability } from '../shared/calculate' export const resolveMarket = functions .runWith({ minInstances: 1 }) diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 506da013..6da3f1b0 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -44,7 +44,7 @@ import { getContractBetMetrics, resolvedPayout, getContractBetNullMetrics, -} from 'common/calculate' +} from 'functions/shared/calculate' import { useTimeSinceFirstRender } from 'web/hooks/use-time-since-first-render' import { trackLatency } from 'web/lib/firebase/tracking' import { NumericContract } from 'common/contract' diff --git a/web/components/resolution-panel.tsx b/web/components/resolution-panel.tsx index 8b453765..a457d616 100644 --- a/web/components/resolution-panel.tsx +++ b/web/components/resolution-panel.tsx @@ -9,7 +9,7 @@ import { ResolveConfirmationButton } from './confirmation-button' import { resolveMarket } from 'web/lib/firebase/fn-call' import { ProbabilitySelector } from './probability-selector' import { DPM_CREATOR_FEE } from 'common/fees' -import { getProbability } from 'common/calculate' +import { getProbability } from 'functions/shared/calculate' import { BinaryContract, resolution } from 'common/contract' import { formatMoney } from 'common/util/format'