tpMarket - A Prediction Market on Tron

Project Name: tpMarket - A Prediction Market on Tron
Project Track: DeFi
Team Name: Multi
Team Member(s): 5, @klappetron, @karilplazik, @kipchoge, @jabba, @fifa_guy

DevPost URL: https://devpost.com/software/tpmarket-prediction-market-on-tron
Video Submission: https://youtu.be/QRVx0lL9wyg

Project Repo/Website:
Website - Mainnet: https://tpmarket.io
Website - Testnet: https://testnet.tpmarket.io
Github: https://github.com/klappe22/pMarket

Project Goal:
After seeing multiple accounts on twitter engaging in making bets against each others, most famously the Algod vs Do Kwon bet regarding Luna and UST https://www.theblock.co/post/137687/terraform-labs-do-kwon-bets-1-million-on-lunas-future-price, we saw that a prediction market for over/under bets is necessary and sought after in the crypto space. With oracles and smart contracts it’s possible to remove the escrow, and automate the whole process from the creation of a bet to the payout of a bet.

Project Info & Details:

why?
As explained in the section above, clearly this seems to be something that the market participants wants. There are endless of reason to why someone would want to use tpMarket, and some examples are:

  1. You are bullish BTC and is certain that it will be above $30k on January 1st 2023.
  2. You are bearish a stablecoin and think that it will depeg.
  3. You wanna go long an asset without buying it

how?
We will now use example 1 from above and show how a bet can go from creation to payout on tpMarket. First, you’ll need to choose some parameters:

  • Strike Price: $30 000 (the price BTC needs to hit for you to win)
  • Expiry: 2023-01-01 (the end date)
  • Position Size: 1000 TRX (what should the payout be?)
  • Over Odds: 5.00 which is the same as 20% (your side)
  • Under Odds: 1.25 which is the same as 80% (the opponent’s side)

Note: Over Odds + Under Odds = 100% always because we take 0 fees.

Now when this market is created, the Under side will automatically be for sale and in our case,
it will cost 800TRX. Why?

Under Price = Position Size / Under Odds = 1000 / 1.25 = 800 TRX

Someone buys it for 800 TRX which means that you’ll receive 800TRX, making the input for your bet:

Your stake = Position Size - List Price = 1000 - 800 TRX = 200 TRX

And your opponents stake is of course 800 TRX. This table explains what will happen on January 1st:

BTC Price Winner Payout
$BTC is above $30000 -> You 200 TRX * 5.00 = 1000TRX
$BTC is below $30000 -> Not You 800 TRX * 1.25 = 1000TRX

So to summarize, if you win you’ll get 1000TRX and your stake is only 200 TRX, which makes sense since 200 * 5.00 = 1000 and your odds was 5.00!

When 2023 is here and if BTC is above $30k then you just go to https://tpmarket.io/positions and click exercise, and you’ll receive the payout.

Check out https://youtu.be/QRVx0lL9wyg for a video where we go through the above scenario.

This is how easy it is to create a market on tpMarket, and keep in mind in most cases you are not the one creating markets, you just take markets that someone else created. In that case it’s even simpler, you just browse at https://tpmarket.io/trade and buy what you want:

Project Milestones:

  1. Keep working on the UI and the general UX of the website

  2. Optimize the contracts to consume less energy.

  3. Get support for more markets, and they don’t have to be for cryptocurrencies.

  4. Make it possible to have whatever token you want as collateral for a position

Deployed Contracts

PredictionMarket.sol:
https://tronscan.org/#/contract/TQe2mJiLd493atDVVoEZTmFYpS8Gx8TCgx/code
https://nile.tronscan.org/#/contract/TD9MPoqzWxx74ADC36kYsUrsnqwnWvwprX/code

Exchange.sol:
https://tronscan.org/#/contract/TJoP1GHbi5Lybe1FiMqWqU6CX6zMDDh4Nc/code
https://nile.tronscan.org/#/contract/TVEZKmK73exA2x7AryDs3D9TXacUvFiTkQ/code

Summary:

tpMarket is a prediction market where users can be both market makers and takers. Currently it supports 3 currencies on testnet (TRX, BTC and JST) and 9 on mainnet (TRX, BTC, JST, ETH, SUN, NFT, BTT, USDT, USDC). If you wanna try it out, keep in mind that the code is not audited so there are probably bugs, and that the contracts are not optimized yet. Also, be sure to watch the submission video at https://youtu.be/QRVx0lL9wyg!

10 Likes

I like this idea, but I think the app is missing an important feature: a deadline for the takers. Let me explain with an example. I bet that BTC will be over 30k on 1/1/23 and commit to it now. Any user could just wait to the last minute and take it only if he knows he’ll be winning (i.e. BTC below 30k). There should be an option for the maker, to specify a deadline for the takers, otherwise any bet would be lost or not taken.

2 Likes

Yeah, right now if you go to https://tpmarket.io/create you’ll see “Invalidate order if BTC goes over/under:” which will cancel the sell order if the price goes over/under the specified price but you’re exactly right, we should also add a line where you can specify for how long the order should be active. This is actually really easy to do (just add a timestamp check in the ask/bid matching function) and we’ll definitely do that if this ever goes to production. Thanks for your feedback!

EDIT: another solution to this that is much harder to implement but that I’ve been thinking about is to have like “perpetual odds” meaning that they change with time. So in the scenario you mentioned, when 1/1/23 is approaching the odds for the market should change automatically as a function of the time to expiry and the current price. So if we are at december 31st 2022 and BTC price is $20k, then if the under side is still listed the odds should have been automatically adjusted to 1.00

2 Likes

EDIT: Added 4 team members that helped me design the frontend and write/audit the smart contracts

5 Likes

This is a cool project!

4 Likes

Thank you! You can vote on us at the hackathon post :slight_smile:

2 Likes

I have not voted yet, but you have one of my 5 votes! Just keep building!

3 Likes

You got my vote brother

1 Like

I found it nice that you bring different perspectives to DeFi, nice project. Go on!

2 Likes

Thanks again, hopefully the rest of the community and judges think the same :slight_smile:

1 Like

This is a cool project. What is the chance of you further developing this into a complete futures market like dydx?

1 Like

that would be nice but don’t think it’s possible on tron because of the gas fees. would need an L2 or even L3

1 Like

Hi just noticed the following link wasn’t working:

https://tpmarket.io/

Are there any updates occurring to make the site better?