Parimutuel on MATIC
Parimutuel is a system where bets for all possible outcomes of an event are put into a single pool, and the winning outcome bettors split the entire pool pro-rata sans fees. Most forms of prediction market can be implemented using the Parimutuel protocol.
Problem Statement
Scaling Ethereum Hackathon: Parimutuel on MATICIntroductionParimutuel is a system where all bets for different outcomes of an event put into a single pool, and the winning bettors split the pool pro-rata after deducting the fees paid to the "house" (operator).Common games include sports betting, politics, horse racing, and most forms of prediction markets can be implemented using Parimutuel.On-chain solutionI've created the on-chain smart contract to enable parimutuel game plays, with the following configurationshouse/operator: the wallet that launches the smart contractinitial pool is created, with a preset of 2 maximum outcomes (called "buckets", can be overwritten by the operator)a percentage fee (default at 10%)the ERC20 currency accepted as wagers is hardcoded, can be replaced by other standard ERC20 tokensUsers can interact with only one methodenterallows a user to specify which pool and which outcome (called bucket) and at what amount to enteruser needs to first approve the smart contract on the selected token in order to call theentermethodOperator functions includere-configuring some of the paramscreate a new poollock the poolset up to 4 metadata on each poolmost importantly, settle the pool with the winning outcome and trigger the payout and fee deductionWhy do we need a scaling solution?more transparency and fairness when executed on-chainwhile parimutuel can support high rollers, most gamers are playing it for fun with small bets, the high gas fee on Ethereum would prohibit the game from launching on-chainthe time it takes to finalize blocks would render it impossible for short timeframe games or last second entriesWhy did I choose MATIC?MATIC has a few crucial features that enable Parimutuel on-chain:MATIC is EVM- and Solidity-compatible, so I can use the same smart contract on Ethereum for implementationMATIC has a fast and reliable asset bridge (I selected the PoS bridge) to enable playing with Ethereum assetsMATIC's fee is low and block-time is fast
Solution
How was it implemented?the asset bridge I simply used the MATIC tutorial which provided an asset bridge using PoS: https://github.com/maticnetwork/pos-plasma-tutoriallaunched the Parimutuel Solidity smart contract on MATICI used a standard ERC20 token implementation fromthe APIS projectfor easyapprove()access, but should be able to use the transferred asset from the MATIC bridge, tooWhat was not implemented?I have done a partial widget-style UI but did not have time to finish within the hackathon time limit. The missing parts include a real data feed or oracle integration that brings in the outcome, and the approval interface for custom tokens. The wallet was connected and the methods of the Parimutuel smart contract can also be invoked but there is no meaningful presentation without some kind of real world dataWhat's next?the Parimutuel smart contract is truly versatile and configurable for a lot of different types of prediction markets. It is way simpler compared to other prediction market implementations such as Augur or Polymarket, using only one single smart contract (only 161 lines of codewith the standard contract and interfaces removed). The simplicity allows any operator to launch it with confidence without relying on an engineering teamI hope to implement some of the interesting Parimutuel games such asMoon-Rekt, sports betting in general, and integrate real data feed and configuration and UI for the next steps.Mumbai testnet contractsParimutuel:0xc4faB13CC051C334607d8DB61c58a017aDb13e30Dummy token:0x94082fe34E939EDd3FDE466Ea4a58cD5bFCF3048The source codes are in this repo. If you need test tokens or approval for your testnet address, please feel free toPM me on twitter, or feel free to relaunch with your own tweaks on Mumbai testnet! (Here's the instruction on how to launch the smart contracts using Remix: https://docs.matic.network/docs/develop/remix)
Hackathon
Scaling Ethereum
2024
Contributors
- calvinmd
18 contributions