manifold/common/bet.ts
2022-06-14 15:44:40 -05:00

51 lines
1.3 KiB
TypeScript

import { Fees } from './fees'
export type Bet = {
id: string
userId: string
contractId: string
createdTime: number
amount: number // bet size; negative if SELL bet
loanAmount?: number
outcome: string
shares: number // dynamic parimutuel pool weight or fixed ; negative if SELL bet
probBefore: number
probAfter: number
sale?: {
amount: number // amount user makes from sale
betId: string // id of bet being sold
// TODO: add sale time?
}
fees: Fees
isSold?: boolean // true if this BUY bet has been sold
isAnte?: boolean
isLiquidityProvision?: boolean
isRedemption?: boolean
// For limit orders.
limitProb?: number // [0, 1]. Bet to this probability.
isFilled?: boolean // Whether all of the bet amount has been filled.
isCancelled?: boolean // Whether to prevent any further fills.
// A record of each transaction that partially (or fully) fills the bet amount.
// I.e. A limit order could be filled by partially matching with several bets.
// Non-limit orders can also be filled by matching with multiple limit orders.
fills?: {
matchedBetId: string
amount: number
shares: number
}[]
}
export type NumericBet = Bet & {
value: number
allOutcomeShares: { [outcome: string]: number }
allBetAmounts: { [outcome: string]: number }
}
export const MAX_LOAN_PER_CONTRACT = 20