All Projects → frefrik → pancakeswap-lottery

frefrik / pancakeswap-lottery

Licence: MIT License
🥞 A Python client for accessing PancakeSwap Lottery smart contract information through Web3.py

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pancakeswap-lottery

cyberevents
The protocol for EVENTs and TICKETs
Stars: ✭ 16 (-46.67%)
Mutual labels:  web3, smart-contract
ens.py
Ethereum Name Service, made easy in Python
Stars: ✭ 36 (+20%)
Mutual labels:  web3, web3py
botdexdamar
🤖 multichain trading bot with sniper, frontrun, backrun, sandwich
Stars: ✭ 124 (+313.33%)
Mutual labels:  web3, pancakeswap
uniswap-arbitrage-flash-swap
Uniswap flash swap arbitrage solidity contracts
Stars: ✭ 341 (+1036.67%)
Mutual labels:  web3, pancakeswap
cybaca
Small app for huge community growth
Stars: ✭ 16 (-46.67%)
Mutual labels:  web3, smart-contract
aragon.js
(Aragon 1) A monorepo of JavaScript libraries for interacting with Aragon
Stars: ✭ 84 (+180%)
Mutual labels:  web3
expo-solana-wallet
Cross-Platform Solana Wallet built with Expo and Solana/web3.js
Stars: ✭ 122 (+306.67%)
Mutual labels:  web3
babel-preset-react-native-web3
deprecated: babel preset for react native, web3 and babel 6
Stars: ✭ 22 (-26.67%)
Mutual labels:  web3
ethjs-extras
All your dApp / App essentials for working with Ethereum.
Stars: ✭ 17 (-43.33%)
Mutual labels:  web3
pancake-subgraph
📊 Pancake subgraph (blocks, profile, prediction, NFT's, ...)
Stars: ✭ 173 (+476.67%)
Mutual labels:  pancakeswap
nina
a self-publishing protocol for musicians - on solana
Stars: ✭ 27 (-10%)
Mutual labels:  web3
obd
OmniBOLT daemon, a golang implementation of OmniBOLT spec, the smart assets lightning network.
Stars: ✭ 34 (+13.33%)
Mutual labels:  smart-contract
web3-is-going-great
A timeline of some of the greatest hits in cryptocurrencies, NFTs, and other web3 projects since the beginning of 2021
Stars: ✭ 334 (+1013.33%)
Mutual labels:  web3
spectrum
💠 Full Gamut Ethereum Lightsuite
Stars: ✭ 56 (+86.67%)
Mutual labels:  web3
foot
foot是一个集足球数据采集器,简单分析的项目.AI足球球探为程序全自动处理,全程无人为参与干预足球分析足球预测程序.程序根据各大指数多维度数据,结合作者多年足球分析经验,精雕细琢,集天地之灵气,汲日月之精华,历时七七四十九天,经Bug九九八十一个,编码而成.有兴趣的朋友,可以关注一下公众号AI球探(微信号ai00268).
Stars: ✭ 96 (+220%)
Mutual labels:  lottery
go-ethutil
Ethereum utility functions for Go.
Stars: ✭ 17 (-43.33%)
Mutual labels:  web3
Wallet3
A secure mobile wallet for web3
Stars: ✭ 13 (-56.67%)
Mutual labels:  web3
Cake.Docker
Cake AddIn that extends Cake with Docker
Stars: ✭ 45 (+50%)
Mutual labels:  cake
borg
Client-server stack for Web3! Turn your Raspberry Pi to a BAS server in minutes and enjoy the freedom of decentralized Web with a superior user experience!
Stars: ✭ 25 (-16.67%)
Mutual labels:  web3
foundation
for the Great Civilization
Stars: ✭ 54 (+80%)
Mutual labels:  web3

PancakeSwap Lottery 🥞 - Web3 client

PyPI version PyPI downloads Licence Python version

A Python client for accessing PancakeSwap Lottery smart contract information through Web3.py.


Documentation: https://frefrik.github.io/pancakeswap-lottery

Examples: https://frefrik.github.io/pancakeswap-lottery/guide/examples

Source Code: https://github.com/frefrik/pancakeswap-lottery

PyPI: https://pypi.org/project/pancakeswap-lottery


Installation

Install from PyPI:

pip install pancakeswap-lottery

Usage

from pancakeswap_lottery import LotteryV2

lottery = LotteryV2()

# Current lottery round number
current_round = lottery.current_round()

# Current ticket id
ticketid = lottery.current_ticket()

# Status of lottery round
status = lottery.status()

# Lottery draw date and time of lottery round
draw_date = lottery.draw_date()

# Ticket price in CAKE
ticket_price = lottery.ticket_price()

# Total prize pool of lottery round in CAKE
prize_pool = lottery.prize_pool()

# Prize pool allocation in CAKE
allocation = lottery.prize_pool_allocation()

# Total number of tickets in lottery round
total_tickets = lottery.total_tickets(lotteryround=23)

# Winning numbers for lottery round
winning_numbers = lottery.winning_numbers(lotteryround=16)

# Get lottery winnings (CAKE) for a given address and round
address_winnings = lottery.address_winnings(address="0x621D6ee5FA9634d86396C13fAaD6A7827606A6d7", lotteryround=16)

# Get lottery winnings (CAKE) for a given ticket and round
ticket_winnings = lottery.ticket_winnings(lotteryround=10, ticketid=158408)

# Number of winners per prize bracket
winners = lottery.winners_per_bracket(lotteryround=16)

# Amount of CAKE won per ticket in each prize bracket
cake_per_bracket = lottery.cake_per_bracket(lotteryround=16)

# Percentage probability of winning the lottery
winning_probability = lottery.winning_probability()

# Data from historic lottery rounds can also be pulled
status = lottery.status(lotteryround=10)
draw_date = lottery.draw_date(lotteryround=10)
ticket_price = lottery.ticket_price(lotteryround=10)
prize_pool = lottery.prize_pool(lotteryround=10)
allocation = lottery.prize_pool_allocation(lotteryround=10)

Response previews

>>> lottery.current_round()
20

>>> lottery.current_ticket()
1124981

>>> lottery.status()
Open

>>> lottery.draw_date()
2021-07-12 20:00:00

>>> lottery.ticket_price()
0.32

>>> lottery.prize_pool()
63024

>>> lottery.prize_pool_allocation()
{'match_1': 630, 'match_2': 1891, 'match_3': 3781, 'match_4': 6302, 'match_5': 12605, 'match_6': 25210, 'burn': 12605}

>>> lottery.total_tickets(lotteryround=23)
14253

>>> lottery.ticket_winnings(lotteryround=15, ticketid=567093)
865.536634168

>>> lottery.address_winnings("0x621D6ee5FA9634d86396C13fAaD6A7827606A6d7", lotteryround=16)
{'tickets': 8, 'ticketids': [634970, 634971, 634972, 634973, 634974, 634975, 634976, 634977], 'winning_tickets': [634970, 634971]}

 >>> lottery.winning_numbers(lotteryround=16)
743350

>>> lottery.winners_per_bracket(lotteryround=16)
{'match_1': 19133, 'match_2': 1921, 'match_3': 188, 'match_4': 21, 'match_5': 1, 'match_6': 1}

>>> lottery.cake_per_bracket(lotteryround=16)
{'match_1': 0, 'match_2': 3, 'match_3': 62, 'match_4': 925, 'match_5': 38843, 'match_6': 77687}

>>> lottery.winning_probability()
{'match_1': 10.0, 'match_2': 1.0, 'match_3': 0.1, 'match_4': 0.01, 'match_5': 0.001, 'match_6': 0.0001}
Lottery V1

Usage (Lottery V1)

from pancakeswap_lottery import Lottery

lottery = Lottery()

# Current lottery round
issue_index = lottery.get_issue_index()

# Total pot (CAKE) of current lottery round
total_amount = lottery.get_total_amount()

# Prize pool allocation (percent)
allocation = lottery.get_allocation()

# Total addresses
total_addresses = lottery.get_total_addresses()

# Drawed 
drawed = lottery.get_drawed()

# Drawing phase
drawing_phase = lottery.get_drawing_phase()

# Last timestamp
timestamp = lottery.get_last_timestamp(epoch=False)

# Date and time of lottery round
lottery_date = lottery.get_lottery_date(432)

# Total rewards of lottery round
total_rewards = lottery.get_total_rewards(432)

# Winning numbers of lottery round
history_numbers = lottery.get_history_numbers(432)

# Numbers of tickets matched
history_amount = lottery.get_history_amount(432)

# Numers of tickets matched a specified number
matching_reward_amount = lottery.get_matching_reward_amount(432, 3)

# Lottery numbers for a given ticket
lottery_numbers = lottery.get_lottery_numbers(1328060)

# Rewards for a given ticket
reward_view = lottery.get_reward_view(1328060)

# Max number
max_number = lottery.get_max_number()

# CAKE contract address
cake_contract = lottery.get_cake()

# PLT-token contract address
lottery_contract = lottery.get_lotteryNFT()

# Total number of tickets bought by a given address
balance = lottery.get_balance_of("0xc13456A34305e9265E907F70f76B1BA6E2055c8B")

Response previews (Lottery V1)

>>> lottery.get_issue_index()
435

>>> lottery.get_total_amount()
34977.25

>>> lottery.get_allocation()
{'1': 50, '2': 20, '3': 10}

>>> lottery.get_total_addresses()
200

>>> lottery.get_drawed()
False

>>> lottery.get_drawing_phase()
False

>>> lottery.get_last_timestamp(epoch=False)
2021-03-27 11:38:49

>>> lottery.get_lottery_date(432)
2021-03-26 02:00:00+00:00

>>> lottery.get_total_rewards(432)
51384.125

>>> lottery.get_history_numbers(432)
[2, 13, 7, 3]

>>> lottery.get_history_amount(432)
{'4': 1, '3': 34, '2': 718}

>>> lottery.get_matching_reward_amount(432, 3)
34

>>> lottery.get_lottery_numbers(1328060)
[11, 5, 14, 6]

>>> lottery.get_reward_view(1328060)
0

>>> lottery.get_max_number()
14

>>> lottery.get_min_price()
1

>>> lottery.get_cake()
0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82

>>> lottery.get_lotteryNFT()
0x5e74094Cd416f55179DBd0E45b1a8ED030e396A1

>>> lottery.get_balance_of("0xc13456A34305e9265E907F70f76B1BA6E2055c8B")
2673

Donate

If you found this library useful and want to support my work feel free to donate a small amount 🙏🏻

  • 🥞 CAKE: 0xCFad66049e2C9Bc28647B2e2e3449B6B7C602d42
  • Ξ ETH: 0x7E916c46157f012Fb8dece4A042Dc603e8d627Df
  • ₿ BTC: bc1qgn2mdf5wsxft33s3ea8sh060y85mzntzs8cuu7

License

This project is licensed under the terms of the MIT license.

Disclaimer

This project is not affiliated with the PancakeSwap team.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].