A Betting Engine for multi-outcome pre-match betting

The PrematchCore is a Betting Engine contract implements all the necessary logic for conducting pre-match betting with multiple outcomes. Data providers can create Conditions for games that have not yet started on the LP contract to which the PrematchCore contract belongs, providing information about the winning outcomes after the result is known.

Before the Game starts, anyone can place a bet on one of the two outcomes of the Condition through LP contract and receive an ERC-721 AzuroBet token, representing the right to own the bet. The betting odds are calculated based on the current ratio of funds for the outcomes of Condition, taking into account its margin rate. The data provider also can virtually change the ratio at its discretion at any time, which affects the resulting odds. If the bet is successful, the bettor can request a refund of their winnings from the LP, otherwise, they receive nothing.

PrematchCore takes a reinforcement for bets from the Pool to which it belongs. When a bet is placed, PrematchCore locks/unlocks a portion of the liquidity from the LP so that after each bet, only the amount equal to the maximum possible loss of the Pool for the given Condition is locked.

If the event associated with the Condition is canceled, the data provider can cancel the Condition. In this case, all bets are returned to the bettors, and the Pool does not earn or lose any funds.