Copy of OpenBook Whitepaper
  • Introduction
    • Welcome to OpenBook
  • Market Description
    • Market Participants
    • Market Size
  • Background
    • Introduction
    • Centralized Models
    • Decentralized Models
  • Description of the Problem
    • Existing Problems
  • Our Solution
    • Introduction
    • Problems and Solutions
    • Our New Model
    • Advantages for Bettors
    • Advantages for Bookies
  • Project Architecture
    • Introuduction
    • Protocol Structure
  • Betting Side
    • Introduction
    • Making a Bet
    • Types of Bets
  • Bookie Side
    • Introduction
    • Becoming a Bookie
    • Benefits of Being a Bookie
  • Backend Implementaion
    • Liquidity
    • Market
    • Bet Contract
  • Frontend Implementation
    • Introduction
    • Navigation Layouts
    • Betting Page
    • Account Page
    • Bookie Page
  • Business Model
    • Businese Model
  • Legal Consideration
    • Legal Considerations
  • Roadmap
    • Introduction
    • Three Phase Rollout
  • OpenBook DAO
    • OpenBook DAO
  • Allocation of funds
    • Allocation of funds
  • Team and Project History
    • Team and Project History
Powered by GitBook
On this page
  1. Backend Implementaion

Liquidity

PreviousBenefits of Being a BookieNextMarket

Last updated 3 years ago

Liquidity contract is inherited from ERC1155. ERC1155 standard has multiple tokens. Each address can have any amount of token for a given id. Item 0 in our contract represents the liquidity token.

In the frontend, UI calls addLiquidity contract after approving Liquidity contract to spend DAI on their behalf. The method moves DAI from the user’s wallet to the contract wallet, and if the transaction is successful, mints Item 0 of the same size as DAI transferred. This represents their stake in the liquidity pool. Furthermore, the date of the deposit is also logged.

When a user wants to remove liquidity, UI calls removeLiquidity function with the appropriate amount. UI does an initial check to see if the user has that amount of withdrawable balance. This function gets the balance of token0 and checks the locked liquidity to check if the user has that amount. If they do, the contract sends DAI to the address and burns the proportional amount of token 0.