Giter Site home page Giter Site logo

steve-swap / pancake-lottery-scheduler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pancakeswap/pancake-lottery-scheduler

0.0 0.0 0.0 528 KB

๐ŸŽฐ Pancake Lottery scheduler

Home Page: https://pancakeswap.finance/lottery

License: GNU General Public License v3.0

TypeScript 99.01% Shell 0.99%

pancake-lottery-scheduler's Introduction

Pancake Lottery Scheduler

Description

The scheduler is composed of multiple scripts used to call startLottery, closeLottery, and drawFinalNumberAndMakeLotteryClaimable functions, trigger events; and monitor lottery results.

Configuration

  • Lottery Address of PancakeSwapLottery contract.
  • Ticket Ticket Price (denominated in USD) and Precision.
  • Discount Divisor to compute discount magnitude for bulk ticket purchase.
  • Rewards Reward breakdown per bracket (total must be equal to 10,000).
  • Treasury Fee (denominated as percentage) to 2 decimals (e.g. 100 => 1%).

Configuration can be overwritten by editing config.ts file.

Deployment

# Export operator private key to be used on Hardhat Network Config.
$ export OPERATOR_PRIVATE_KEY=OPERATOR_PRIVATE_KEY

$ yarn execute:[command]:[network]

Command(s)

  • start Start a new lottery; for a given network.
  • close Close a lottery, based on currentLotteryId; for a given network.
  • draw Draw winning numbers, based on currentLotteryId; for a given network.

Network(s)

Execution

# Close lottery.
0 0,12 * * * cd ~/pancake-lottery-scheduler && yarn execute:close:mainnet

# Draw lottery.
3 0,12 * * * cd ~/pancake-lottery-scheduler && yarn execute:draw:mainnet

# Start lottery.
5 0,12 * * * cd ~/pancake-lottery-scheduler && yarn execute:start:mainnet

Logging

Logs will be generated at logs/lottery-YYYY-MM-DD.log and will be archived (.gz) with a daily rotation.

Examples of success logs:

{"message":"[1970-01-01T06:05:00.000Z] network=testnet block=10000000 message='Started lottery' hash=0x... signer=0x...","level":"info"}
{"message":"[1970-01-01T18:00:00.000Z] network=testnet block=10010010 message='Closed lottery #123' hash=0x... signer=0x...","level":"info"}
{"message":"[1970-01-01T18:03:00.000Z] network=testnet block=10100100 message='Drawed lottery #123' hash=0x... signer=0x...","level":"info"}
{"message":"[1970-01-01T18:05:00.000Z] network=testnet block=11001000 message='Started lottery' hash=0x... signer=0x...","level":"info"}

Examples of error logs:

{"message":"[1970-01-01T00:00:00.000Z] network=testnet message='Unsupported network' signer=0x...","level":"error"}
{"message":"[1970-01-01T12:00:00.000Z] network=testnet message='Invalid JSON RPC response' signer=0x...","level":"error"}
{"message":"[1970-01-02T00:00:00.000Z] network=testnet message='Invalid keyHash on RandomGenerator contract' signer=0x...","level":"error"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.