Goals

Stage 1: Build out MVP

User Stories

Pages

Data structures

export type User = {
  id: 'sd8v0saf90is' // Generated Firebase Auth id
  email: '[email protected]' // Email address
  name: 'Scott Alexander' // Full name
  username: 'ScottAlexander' // Used for public identification
  avatar: '<https://avatars3.githubusercontent.com/u/1234?s=460&v=4>' // Avatar URL
  balance: 10000 // Current balance in M$

  createdTime: 123456789 // Timestamp in millis since epoch
  lastUpdatedTime: 123456789

  ~~// Derived info (e.g. denormalized for caching)
  contracts: [] // List of contracts created by this user
  bets: [] // List of bets placed by this user~~
}

export type Contract = {
  id: 'COVID-123' // Chosen by creator; must be unique
  creatorId: 'sd8v0saf90is'
 
  question: 'Will at least 1% of U.S. COVID-19 cases be from the Omicron variant on January 1, 2022?'
  description: '....' // More info about what the contract is about
  outcomeType: 'binary' // | 'multi' | 'interval' | 'date'
  // outcomes: ['YES', 'NO']
  seedAmounts: { YES: number, NO: number } // seedBets: [number, number]
  pot: { YES: number, NO: number } 

  createdTime: 123456789
  lastUpdatedTime: 123456789 // If the question or description was changed
  closeTime?: 2345697 // When no more trading is allowed

	isResolved: boolean
  resolutionTime?: 10293849 // When the contract creator resolved the market; 0 if unresolved
  resolution?: 'YES' | 'NO' | 'CANCEL' // Chosen by creator; must be one of outcomes

  ~~// Derived info
  bets: []~~
}

// Firestore subcollection of a Contract
// Stephen: maybe a top-level collection? Need to query by user across all contracts
// James: I think you can query across sub-collections now (by userId), so it might be fine.
export type Bet = {
  id: string
  userId: 'sd8v0saf90is'
  contractId: 'COVID-123'

  size: 100 // Amount of USD bid
  outcome: 'YES' | 'NO' // Chosen outcome
  createdTime: 123456789

  // Derived info
  dpmWeight: 1238
}