https://github.com/dimdim1177/tezos-pool-games
Full code and documentation of contracts for periodic reward draws on deposit from pools in farms Crunchy or Qupipuswap. Project developed on Debian 11, not tested in other OS.
The project is NOT COMPLETE, namely:
- scripts for off-chain calling of contract methods are not written
- all tests for CPoolGames not written
- not fully tested
- obviously there are sub-optimalities, because I saw Tezos and PascaLIGO a month ago for the first time
Execute script ./install/install_all.sh
for download and install: LIGO, tezos-client, python, pytezos and so on.
Or execute ./install/install_*.sh scripts for each tool manually.
Usage: compile.sh NAME|ALL Compile 'contracts/NAME.ligo' or 'contracts/*.ligo' for ALL. Compiled files saved to 'build/NAME.tz' and 'build/NAME.storage.tz' files.
Usage: tests.sh NAME|ALL Execute tests 'tests/NAME.ligo' or 'tests/*.ligo' for ALL. Logs saved to 'build/NAME.test.log' files.
Usage: deploy.sh NAME|ALL [force] Deploing 'build/NAME.tz' inited by 'build/NAME.storage.tz' (or 'build/*.tz' for ALL) by account saved as 'owner' in tezos-client.
Firstly, install submodules by git submodule update --init --recursive
.
Then execute script ./doc/doc.sh
for generate English and Russian documentations for contracts.
Script usage code of subprojects, attached as git submodule:
- https://github.com/dimdim1177/mlcomment Multi-Language comments
- https://github.com/dimdim1177/ligo2dox Convert PascaLIGO to C++ like code for auto-documenting by Doxygen The html-en and html-ru folders and their contents are generated automatically.
Presentation about the project in text files slides-en/*.slide (all other files in the folder are generated by scripts), the slides.sh
script generates a video presentation slides-en/video.mp4.
See contracts/CPoolGames.ligo and folder contracts/CPoolGames. Main features:
- Support 2 farms interfaces: Crunchy and QUIPU
- Three algorithms to determine the winner:
- Probability of win proportional time in current game
- Probability of win proportional sum of time * deposit in current game
- Equal probabilities for all users in pool
- Additional pool options:
- minimal deposit
- minimal seconds in game
- maximum deposit (only for algorithm by sum time * deposit)
- win percent, burn percent, fee percent
- burn token, fee address
- Flexible code configuration (see contracts/CPoolGames/config.ligo):
- pool owner/admins or pool as service
- can enable security transfer tokens (remove operator after transfer)
- can enable pool statictics in blockchain for promotion
- can enable pool views for other smart contracts
See contracts/CRandom.ligo and folder contracts/CRandom Main features:
- Any can request random number in future
- Request has caller address and ID of object
- Random number based on nearest Tezos block hash with time more time in request and XORed with hash of request, that is why one Tezos block generate different random numbers for different requests with the same time.
- C - Contract
- M - Module
- t_ - Type
- c_ - Constant
- cERR_ - Constant with error code for failwith
Folder with contracts code. Files by mask contracts/CONTRACT_NAME.ligo compiled as contracts. Folder contracts/CONTRACT_NAME used for contract specific includes and modules. File contracts/CONTRACT_NAME/config.ligo contains contract configuration defines. File contracts/CONTRACT_NAME/initial_storage.ligo contains initial storage description.
Common includes for all contracts.
Common modules for all contracts.
Includes and modules specific for contract contracts/CPoolGames.ligo.
Includes and modules specific for contract contracts/CRandom.ligo.
Documentation folder. File algo.xlsx - example in comparing table of changeing weights users and game in different alrorithms in different situations for simplify understanding weight code logic.
English documentation, please open doc/html-en/index.html
Russian documentation, please open doc/html-ru/index.html
https://github.com/dimdim1177/mlcomment Multi-Language comments
https://github.com/dimdim1177/ligo2dox Convert PascaLIGO to C++ like code for auto-documenting by Doxygen
English text for slides in *.slide and other auto-generated by slides.sh files
Russian text for slides in *.slide and other auto-generated by slides.sh files
Folder with *.json faucet files, downloaded from https://teztnets.xyz/, basename of file used as account name in tezos-client.
One of it must be named as owner.json, this account used for deploy contracts.
Script accounts/activate.sh
activate all accounts in testnet.
Folder for compiled files *.tz, logs *.log and so on.
Folder with scripts for install development tools: LIGO, tezos-client and so on.
Binaries from tezos: tezos-client and so on.
Unit tests in LIGO. See tests tests/CPoolGames.ligo
and tests/CRandom.ligo
.
Common tests code
Only CPoolGames test code for include.
Only CRandom test code for include.
Virtual envoriment for python