numeric constants
This commit is contained in:
parent
2b69d7108a
commit
cd99d13deb
|
@ -40,7 +40,7 @@ export function getNumericBets(
|
|||
contract: NumericContract,
|
||||
bucket: string,
|
||||
betAmount: number,
|
||||
variance = 0.01
|
||||
variance: number
|
||||
) {
|
||||
const { bucketCount } = contract
|
||||
const bucketNumber = parseInt(bucket)
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
import { User } from './user'
|
||||
import { noFees } from './fees'
|
||||
import { addObjects } from './util/object'
|
||||
import { NUMERIC_FIXED_VAR } from './numeric-constants'
|
||||
|
||||
export const getNewBinaryCpmmBetInfo = (
|
||||
user: User,
|
||||
|
@ -167,7 +168,7 @@ export const getNumericBetsInfo = (
|
|||
) => {
|
||||
const { pool, totalShares, totalBets } = contract
|
||||
|
||||
const bets = getNumericBets(contract, outcome, amount)
|
||||
const bets = getNumericBets(contract, outcome, amount, NUMERIC_FIXED_VAR)
|
||||
const allBetAmounts = Object.fromEntries(bets)
|
||||
|
||||
const newPool = addObjects(pool, allBetAmounts)
|
||||
|
|
5
common/numeric-constants.ts
Normal file
5
common/numeric-constants.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export const NUMERIC_BUCKET_COUNT = 500
|
||||
export const NUMERIC_FIXED_VAR = 0.005
|
||||
|
||||
export const NUMERIC_GRAPH_COLOR = '#5fa5f9'
|
||||
export const NUMERIC_TEXT_COLOR = 'text-blue-500'
|
|
@ -29,6 +29,7 @@ import {
|
|||
MINIMUM_ANTE,
|
||||
} from 'common/antes'
|
||||
import { getNoneAnswer } from 'common/answer'
|
||||
import { NUMERIC_BUCKET_COUNT } from 'common/numeric-constants'
|
||||
|
||||
export const createContract = functions
|
||||
.runWith({ minInstances: 1 })
|
||||
|
@ -146,7 +147,7 @@ export const createContract = functions
|
|||
ante,
|
||||
closeTime,
|
||||
tags ?? [],
|
||||
100,
|
||||
NUMERIC_BUCKET_COUNT,
|
||||
min ?? 0,
|
||||
max ?? 100,
|
||||
manaLimitPerUser ?? 0
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { DatumValue } from '@nivo/core'
|
||||
import { ResponsiveLine } from '@nivo/line'
|
||||
import { NUMERIC_GRAPH_COLOR } from 'common/numeric-constants'
|
||||
import _ from 'lodash'
|
||||
import { memo } from 'react'
|
||||
import { getDpmOutcomeProbabilities } from '../../../common/calculate-dpm'
|
||||
|
@ -21,7 +22,7 @@ export const NumericGraph = memo(function NumericGraph(props: {
|
|||
const probs = _.range(bucketCount).map((i) => bucketProbs[`${i}`] * 100)
|
||||
const points = probs.map((prob, i) => ({ x: xs[i], y: prob }))
|
||||
const maxProb = Math.max(...probs)
|
||||
const data = [{ id: 'Probability', data: points, color: '#5fa5f9' }] // text-blue-500
|
||||
const data = [{ id: 'Probability', data: points, color: NUMERIC_GRAPH_COLOR }]
|
||||
|
||||
const yTickValues = [
|
||||
0,
|
||||
|
|
Loading…
Reference in New Issue
Block a user