What it does
Divebar (docs) is a no-frills P2P betting game where players place bets within a specific time frame in order to pin the moving average of all collective bets under their own. You win if at the end of the game your initial bet is greater than or equal to the average (the bar). Nearing the end of the game, movements in the average will be less and less volatile as people will attempt to bet right above the average to guarantee a win. Thus, players who enter later in the game have an advantage over player who entered before them. While theses players have a higher chance of winning, they are entitled to a much smaller portion of the pot as compared to those who bet before them, so much so that the last player to bet in any given game will only receive their initial bet back if they win. Losers of the game receive nothing.
The only rules are as follows:
- You may only bet once per game. You cannot withdraw or add to your bet once it is placed. The minimum bet is 0.001 ETH / ONE / Native token.
- When the game ends, if your initial bet is at or above the final average of all other bets, you are a winner of that game.
- Winners receive a payout containing (their initial bet) + (a weighted portion of a pot containing the sum of all losing bets). For full details including the formula used: https://docs.thedivebar.xyz/rewards/how-winnings-are-calculated. Thus, players who bet earlier are significantly rewarded by the game. This system is put in place to handicap players who choose to bet later, as the average is already well established and it is much easier for them to win.
- There are no minimum players per game, nor are there maximum bet limits.
Technical specs:
Divebar contract addresses:
Harmony Testnet: 0xD618724A779efF8e173a8500Ff796B37c33C7433 Ethereum Kovan Testnet: 0xD8Cffd2eF7fA46f8b24f93E123dF6c430E2Ead59 Fantom Testnet: 0x5CD7F0a504047859e15d4fb97F8086B5A634984b Mainnet soon :) Solidity ^0.8.0
Frontend: React + Typescript single page application deployed using Netlify. Source code here
Oracle: To handle the starting of new games after a specified amount of time, we use a custom node script to automatically listen for events and periodically call functions. We also use Chainlink Keepers for this same functionality on Ethereum testnet and mainnet.
Team members: Eric Zhong (@_ericzhong) ezhong.eth
What we learned
This was my first time diving into solidity besides intro projects / courses, so it was a lot of trial & error as I worked through bugs, common pitfalls, etc. I learned so much about programming in solidity since it's very different compared to what I'm used to (typescript, python, etc.), and of course got a lot of practice using libraries like ethers.js and web3.js. Next steps:
What's next for The Divebar
Adding a calculator / what if display on the frontend for players to learn about the game mechanics before they bet Going to do some comprehensive testing on the testnets first with friends / people wanting to help Launching on Harmony Mainnet ASAP, as well as Ethereum mainnet, then I'm planning on targeting a side chain like Fantom or Avalanche.
Built With
- fantom
- harmony
- keepers
- netlify
- react
- solidity
- typescript
Log in or sign up for Devpost to join the conversation.