Rogue Docs
  • Rogue Protocol
    • Introduction
  • Rogue Trader
    • Rogue Trader pages
      • Home page
      • Connect wallet page
      • Rogue Index page
      • RogueBot page
      • ROGUE bankroll page
      • High Rollers NFTs page
      • My account page
      • Deposit page
      • Withdraw page
    • Self-custodial & trustless
    • No KYC or geo-blocking
  • Rogue Index
    • Overview
    • Zero house edge betting
    • Binary options reimagined
    • How to play
    • Price update mechanism
    • Bet lifecycle
    • Provably-fair price updates
    • Leaderboard
    • Smart contracts
    • Place bets programmatically
  • RogueBots
    • High volatility token trading
    • RogueBot mechanics
    • RogueBot token pricing
    • RogueBot token page
    • RogueBot trading tools
    • RogueBots list
    • RogueBot 7 day lifespan
    • RogueBot smart contracts
    • Trade tokens programatically
  • ROGUE Bankroll
    • Adding liquidity to bankroll
    • Removing liquidity from bankroll
    • Pool token price calculation
    • Bankroll mechanics
    • Bankroll smart contract
    • Why does the house win?
  • ROGUE Token
    • Native gas token
    • Zero-fee betting token
    • Supply & distribution
    • Public token sale
    • ROGUE information
    • ROGUE bridge
    • Buy ROGUE
    • Earn ROGUE
  • Rogue Chain
    • Arbitrum Orbit AnyTrust
    • Instant time-to-finality
    • Ultra-low gas fees
    • Chain information
    • Block explorer
  • Rogue NFTs
    • Revenue sharing NFTs
    • NFT pricing & availability
    • Get ETH on Arbitrum
    • RHRC smart contracts
    • RHRC information
Powered by GitBook
On this page
  • Bet Submission
  • How Incoming Bets Are Processed By The Rogue Index Smart Contract
  • How Bets Are Settled

Was this helpful?

Export as PDF
  1. Rogue Index

Bet lifecycle

PreviousPrice update mechanismNextProvably-fair price updates

Last updated 18 days ago

Was this helpful?

Rogue Index has revolutionized the traditional binary options model by replacing bet expiry timestamps with verifiable serial numbers that are paired with price updates. This is a fundamental improvement on the binary options model.

This is made possible by our use of a third party service called random.org to generate the random numbers that are used as Rogue Index price updates.

When Rogue requests a price update from random.org, they reply with not only a random number but also a sequential serial number verifying that we didn't keep re-rolling the dice until we got a number that we like.

This creates the opportunity to use these serial numbers as the bet expiry deadlines instead of timestamps because each serial number has a verifiable price associated with it, making it impossible for us to manipulate results to affect the outcome of any bets. Here's the complete lifecycle of a bet from placement to settlement:

Bet Submission

To submit a bet the player must set the following four variables:

  1. Bet size - the amount of ROGUE being wagered

  2. Bet direction - whether the index will be higher or lower when the bet settles

  3. Bet duration - the number of serial number updates before the bet is settled

  4. Bet currency - can only be ROGUE but is still a required argument

The player calls the placeBet function in the Rogue Index smart contract with a ROGUE value of the desired bet size and passing the bet direction, bet duration and bet currency as arguments in the function call.

When using the game UI of the Rogue Trader platform to submit bets this function call is handled under the hood after the player has entered these variables into the correct input fields and pressed the UP or DOWN button to submit the bet.

If desired, the player can bypass using the Rogue Trader platform and instead submit bets by connecting his wallet to roguescan and calling the directly on the Rogue Index smart contract, passing in the required variables as function calls.

Or the player can use open source software like ethers.js to connect directly to Rogue Chain via our public RPC endpoint and then directly calling the

placeBet(uint256 _direction, uint256 _wagerCurrency, uint256 deadline)

function of the Rogue Index smart contract with a ROGUE value of the bet amount and the other 3 variables passed as arguments.

The method used by the player for submitting a bet makes no difference to the Rogue Index smart contract and the function call is handled exactly the same by the smart contract regardless of how the bet was submitted.

How Incoming Bets Are Processed By The Rogue Index Smart Contract

When the Rogue Index smart contract receives an incoming placeBet function call, it forwards the bet stake to the ROGUE Bankroll and creates an unsettled bet struct with the bet's info and then stores that struct in a mapping that holds all unsettled bets indexed by their expiry serial number.

The unsettled bet struct contains the following information:

struct OpenPositions {
        uint256 betId;
        address owner;
        uint256 direction; // 1 is up, 2 is down, need numbers because can't compare strings
        uint256 wagerAmount; // in Wei
        uint256 wagerCurrency; // must be 6 for ROGUE
        uint256 entryPrice;
        uint256 entrySerialNumber;
        uint256 exitSerialNumber; // currentSerialNumber + number of updates until bet expiry
        uint256 status; // 0 is open, 1 is won, 2 is lost
    }

How Bets Are Settled

The Rogue Trader platform updates the Rogue Index smart contract every second with the latest price update and serial number provided by random.org. It does this by calling the function

updatePrice(uint256 newPrice, uint256 _serialNumber)

and passing the new price and serial number as arguments in the function call. Within that function call the function

settleOpenPositions(newPrice, _serialNumber)

is called which finds all the unsettled bet structs that expire at this serialNumber and settles them at newPrice.

If the bet is a winner, the Rogue Index smart contract calls the function

winningBetROGUE(uint256 serialNumber, address winner, uint256 betID, uint256 payout)

in the ROGUE Bankroll smart contract which updates the contract's balance and liabilities and sends the winning payout to the player's wallet.

If the bet is a loser the Rogue Index smart contract calls the function

updateHouseBalanceBetLost(address _player, uint256 wagerAmount)

in the ROGUE Bankroll telling it to keep the player's stake and to update it's balance and liabilities accordingly.

If the settlement price of the bet is exactly the same as the entry price the bet breaks even and so the Rogue Index smart contract calls the function

breakEvenBetROGUE(uint256 serialNumber, address winner, uint256 betID, uint256 payout)

in the ROGUE Bankroll smart contract telling it to return the player's stake only and to update it's balance and liabilities accordingly.

The Rogue Index smart contract then emits the event

BetSettled(uint256 betId, address owner, uint256 direction,
                uint256 wagerAmount, uint256 payout, bool winner, uint256 wagerCurrency, uint256 entryPrice, 
                uint256 settledPrice, uint256 entrySerialNumber, uint256 exitSerialNumber)

and then moves on to the next unsettled bet that expires at the new serial number and repeats the above process until all bets have been settled.

The game UI on the Rogue Trader platform listens for BetSettled events and uses the information in them to update the Active Bets and Settled Bets tabs accordingly.

Finally, after all bets have been settled the Rogue Index smart contract emits the event

PriceUpdated(uint256 price, uint256 serialNumber, bool allOpenPositionsSettled)

which Rogue Trader uses to update the game UI accordingly and then it sends another request for a new price update to random.org. Upon receiving the reply from random.org it once again calls the function

updatePrice(uint256 newPrice, uint256 _serialNumber)

in the Rogue Index smart contract with the new price and serial number and that sets off a new round of bet settlements as described above.

placeBet function