“I was asking around for cool projects and everyone has been talking about Timbermarket!” -Dagsen (Soon Technology)
“Oh shit you guys are the Timbermarket guys!” -Many, many people
“Can I pleaseeee have 1000 more leaves, I lost it to insider trading…” -Anonymous
In the first 12 hours, we got our core infra running and launched to 1,000 hackers Saturday 9am. In 36 hours, we got more than 250 users, 20+ markets, and over 6k trades, getting interviews with Soon Technology, the CEO of freeCodeCamp, and drawing attention from CMU hackers and Paradigm folks!
What it does
TimberMarket is a live prediction market built exclusively for TreeHacks. Traders get a starting balance of 1,000 “leaves” to trade contracts on existing markets or propose new markets. Our team travels between events to verify the ground truth and resolve each market for payouts.
We have a live-tv style view for monitoring the situation, which we stream out inside of Huang’s basement to hackers as they pass by.
Inspiration
Hackathons are wonderfully chaotic, and we built Timbermarket to extract the wisdom of the crowd and connect the hacker community. With predictions, we wanted to evaluate hackathon outcomes and judge fairness while building a social layer to engage project discussions, meme debates, friend making, and community building.
How we built it
At the core of TimberMarket is an Automated Market Maker (AMM) inspired by Maniswap, which is a variant of Uniswap v2. AMM is key to making markets work in lower-liquidity environments.
How Our Markets Work
Specifically, the core equation that an AMM preserves across all trades is a weighted geometric mean, \(k = y^pn^{(1-p)},\) where \(y, n\) are the number of yes/no token reserves, \(p\) is a fixed probability parameter set at market creation, and \(k\) is the invariant constant that must stay the same after each trade, and we update \(y, n\) as needed. The probability being displayed is equal to $$\frac{pn}{y(1-p)+pn},$$ which can be understood as the proportion of the no values to the yes ones.
Buying shares is pretty simple. If you bet on yes, it adds that amount to the no pool and calculates the new yes pool, and gives you the difference between the updated number of shares and the old number of shares. Selling is harder, where selling yes shares means you buy the same number of no shares, redeem both the yes and no shares at the same amount, and the payout is the difference between the redeemed leaves and the leaves you spent to buy the no shares. Note that buying the no shares is not analytically invertible (we are trying to find the price to buy a fixed number of shares, which is the inverse problem), so we use binary search to get an approximate solution within ~1e-8.
Ultimately, we went with this design because we didn’t need an order book & updating the database was simple.
TV View
Also, we also spent a LOT of time designing our TV view, as we knew that it was our unique way of showing ourselves to the rest of the hackers. It has a privileged connection to our database so that the live view can update in real time, showing off recent trades, featured markets, probabilities, number of traders, and comments. Without it, we wouldn’t have made something that felt exciting.
Challenges and Fun Stories
We got a lot more than we bargained for. All of it fun!
Beginning Development
We knew that an important part of this project would be getting it out to the hackers as soon as humanly possible. We started at around 10 PM sharp and locked ourselves in the basement until we got our website up after about 11 hours of planning, coding, and designing.
Design was an incredibly fun part of the night. We knew that if we had no traders, we wouldn’t have anything! So, we spent a bit of time designing posters during the first night with fun questions to post up on the walls and hand to hackers, which are attached as an image on the devpost!
Another constraint that we had to face was that of moderating users so we didn’t have suspicious trades. As a result, we spent a lot of time trying to figure out auth. At first, we wanted to use TreeHack's own QR codes, since they would’ve been unique, but other people who didn’t have one (sponsors, organizers, etc.) also wanted to trade together, so we ended up using phone numbers for verification instead.
Then, after we had finished our first version, we went to hand out the posters. Sadly, this was shut down by one of the organizers, so we instead used scraped data from Slack to email blast all of the participants. This grew our site to over a hundred users in only a few hours. Then we launched to hackers and more via Slack, X, and Fizz, drawing in attention from CMU cybersecurity mains who DDoSed us, media teams, the CEO of FreeCodeCamp, and people at Paradigm!
CMU Hackers…
After we posted our project on Twitter, it gained attention from people both inside and outside of treehacks, and we began to experience attacks on our system. All of Saturday was spent hardening our security against experienced CTF players who took it upon themselves to attempt to exploit our site by slamming our database and launching DDoS attacks.
Insider Trading!
During the course of the day, the treehacks organizers started joining in on the fun. At first, it was simple markets, with “Will there be at least 3 llamas at treehacks?” Then we got a little more creative, with “Will 6 TreeHacks Organizers form a human pyramid,” which they excitedly (insider) traded, and also “Will a treehacks organizer do more than 40 push-ups,” in which Shrish came into our room, bought a ton of YES shares, and ripped them out.
“Will You Find Love At TreeHacks?”
Organizers also found ways to spice up live events with our prediction markets. At the Valentines dating game show we made this market: “Will Michael find a date during the V-day event?” Quickly after the event started, we realized that Michael had donned a wig to become Michelle, which we promptly updated on the site. In the end, the pool of contestants was not appealing enough to Michelle, who rejected all of them, though Michelle did attempt to date one of the TreeHackers organizers at the end, so we resolved the market as N/A to reset the market and refund all users, which we implemented for purposes like this.
By the end of the second night, we found a TV to show our real-time trades in the Huang basement. We were excited to meet many of the other hackers who scanned our QR code to trade for fun between their intense building hours.
What we learned
There were two main things we learned. In no particular order, publicity and GTM really matters with a project like this, and when deploying at scale you will get hacked.
For publicity, it was extremely important that we get the link out to as many people as possible, but more importantly we needed each trader to feel like they were included. They would need a market that related to them, so we spent a lot of the time just brainstorming markets and adding them in as they came. We also worked on our TV view to reflect on this so you could see live trades happening!
For security, we learned that there are always more vulnerabilities than you think, and that if the site reaches a large enough scale, people will always try to find them. Tightening the security around a site takes deliberate planning and care. Vibecoding is an awesome tool, but if you don’t spend the time to understand your own protocol, then you’re at risk!!
What's next?
The backend is currently moderated by us. We would want to have a better mechanism for creating popular markets without needing at least one of us to be awake, and we’d also like to have a better way to check resolution criteria.
We also want to expand to everyone at Stanford. Timbermarket can help party or event organization as a great turnout indicator and encourage more students to discuss and participate in bonding activities like sports games. In particular, connecting the Timbermarket to Fizz posts, where people anonymously post events and questions, seems fun and scalable.
Built With
- figma
- nextjs
- react
- recharts
- supabase
- tailwindcss
- twilio
- typescript
- vercel

Log in or sign up for Devpost to join the conversation.