798253f887
* Challenge bets * Store avatar url * Fix before and after probs * Check balance before creation * Calculate winning shares * pretty * Change winning value * Set shares to equal each other * Fix share challenge link * pretty * remove lib refs * Probability of bet is set to market * Remove peer pill * Cleanup * Button on contract page * don't show challenge if not binary or if resolved * challenge button (WIP) * fix accept challenge: don't change pool/probability * Opengraph preview [WIP] * elim lib * Edit og card props * Change challenge text * New card gen attempt * Get challenge on server * challenge button styling * Use env domain * Remove other window ref * Use challenge creator as avatar * Remove user name * Remove s from property, replace prob with outcome * challenge form * share text * Add in challenge parts to template and url * Challenge url params optional * Add challenge params to parse request * Parse please * Don't remove prob * Challenge card styling * Challenge card styling * Challenge card styling * Challenge card styling * Challenge card styling * Challenge card styling * Challenge card styling * Challenge card styling * Add to readme about how to dev og-image * Add emojis * button: gradient background, 2xl size * beautify accept bet screen * update question button * Add separate challenge template * Accepted challenge sharing card, fix accept bet call * accept challenge button * challenge winner page * create challenge screen * Your outcome/cost=> acceptorOutcome/cost * New create challenge panel * Fix main merge * Add challenge slug to bet and filter by it * Center title * Add helper text * Add FAQ section * Lint * Columnize the user areas in preview link too * Absolutely position * Spacing * Orientation * Restyle challenges list, cache contract name * Make copying easy on mobile * Link spacing * Fix spacing * qr codes! * put your challenges first * eslint * Changes to contract buttons and create challenge modal * Change titles around for current bet * Add back in contract title after winning * Cleanup * Add challenge enabled flag * Spacing of switch button * Put sharing qr code in modal Co-authored-by: mantikoros <sgrugett@gmail.com>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 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
|
|
challengeSlug?: string
|
|
} & Partial<LimitProps>
|
|
|
|
export type NumericBet = Bet & {
|
|
value: number
|
|
allOutcomeShares: { [outcome: string]: number }
|
|
allBetAmounts: { [outcome: string]: number }
|
|
}
|
|
|
|
// Binary market limit order.
|
|
export type LimitBet = Bet & LimitProps
|
|
|
|
type LimitProps = {
|
|
orderAmount: number // Amount of limit order.
|
|
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 orderAmount.
|
|
// 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: fill[]
|
|
}
|
|
|
|
export type fill = {
|
|
// The id the bet matched against, or null if the bet was matched by the pool.
|
|
matchedBetId: string | null
|
|
amount: number
|
|
shares: number
|
|
timestamp: number
|
|
// If the fill is a sale, it means the matching bet has shares of the same outcome.
|
|
// I.e. -fill.shares === matchedBet.shares
|
|
isSale?: boolean
|
|
}
|
|
|
|
export const MAX_LOAN_PER_CONTRACT = 20
|