https://github.com/azaurus1/plation
https://github.com/azaurus1/plation
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/azaurus1/plation
- Owner: azaurus1
- License: mit
- Created: 2022-05-09T00:29:38.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-18T06:00:34.000Z (almost 3 years ago)
- Last Synced: 2025-01-31T12:17:09.070Z (4 months ago)
- Language: JavaScript
- Size: 14.6 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# plation
An on-chain prediction market for inflation using Truflations inflation oracle. A winner for the truflation sponsor prize for the Chainlink Hackathon Spring 2022.
live version available at: http://plation.io
# Design
System design overview:
## Setup
1. Deploy Inflation oracle contract
2. Deploy InflationUpkeep keeper with Inflation oracle address from 1.
3. Deploy PredictionHandler contract
4. Deploy a prediction with the PredictionHandler function
5. Deploy the PredictionUpkeep contract
6. Use the setKeeper function on the PredictionHandler to set the Keeper to the address of the PredictionUpkeep contract from 5.
7. Set up both keepers at keepers.chain.link
8. Once both keepers have run once, start the keeper.py script with the PredictionHandlerAddr and InflationOracleAddr addresses set to the addresses from steps 3 and 1 respectively
9. Now run npm start in the client folder
10. You should now have the system set up!Gas limits for the keepers:
Prediction Keeper: 1,250,000
Inflation Keeper: 130,000
# Prediction payout model
1. Users bet on a prediction contract for a certain amount for whether inflation will rise in the next cycle, or will drop. The wagers are pooled together.
2. Once the prediction timeframe is over, a keeper contract will request the handler contract to close the prediction and begin payouts based on the inflation index from the oracle.
3. Depending on the result, winning betters will receive their initial wagers + their share of the losing wager pool. (The share is derived from the initial wagers share of the pool e.g. if inflation rises, and a person bet 1 eth in the over pool and they constituted 50% of the over pool, they would recieve 50% of the under pool)# An example
**Person 1 thinks inflation will rise****Person 2 thinks inflation will drop**
**Person 3 thinks inflation will rise**
========================================
**Person 1 bets 2 ETH (Pot: 2 ETH)**
**Person 2 bets 5 ETH (Pot: 7 ETH)**
**Person 3 bets 8 ETH (Pot: 15 ETH)**
========================================
**OVER WAGERS = 10 ETH
Of Over Wagers:
• Person 1 makes up 20%
• Person 3 makes up 80%****UNDER WAGERS = 7 ETH
Of Under Wagers:
• Person 2 makes up 100%****If inflation rises:
Person 1 gets 2 ETH + 20% of losers wagers (1.4 ETH)
Person 3 gets 7 ETH + 80% of losers wagers (5.6 ETH)**
**If inflation drops:
Person 2 gets 7 ETH + 100% of losers wagers (10 ETH)**
# Python Keeper architecture
Python keeper that keeps track of timings of predictions, listens for the prediction closed event being emitted on the handler contract and orders the prediction handler to payout the winnings.
# Chainlink Keepers

Two chainlink keepers, both with 24 hour intervals, one for closing the last prediction and one for requesting latest inflation oracle information. Should be started out of sync so that inflation oracle is always updated ahead of the new prediction.