From 0c2ab5e9d7c3adfafd84cdd9a80930617f0fd8d1 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Tue, 14 Jun 2022 15:44:40 -0500 Subject: [PATCH] Update bet schema --- common/bet.ts | 14 +++++++++++++- functions/src/place-bet.ts | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/common/bet.ts b/common/bet.ts index 993a2fac..81dbe6e5 100644 --- a/common/bet.ts +++ b/common/bet.ts @@ -4,6 +4,7 @@ export type Bet = { id: string userId: string contractId: string + createdTime: number amount: number // bet size; negative if SELL bet loanAmount?: number @@ -26,7 +27,18 @@ export type Bet = { isLiquidityProvision?: boolean isRedemption?: boolean - createdTime: number + // 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 & { diff --git a/functions/src/place-bet.ts b/functions/src/place-bet.ts index 2effc90c..e2bb6d19 100644 --- a/functions/src/place-bet.ts +++ b/functions/src/place-bet.ts @@ -21,6 +21,7 @@ const bodySchema = z.object({ const binarySchema = z.object({ outcome: z.enum(['YES', 'NO']), + limitProb: z.number().gte(0).lte(1).optional(), }) const freeResponseSchema = z.object({