This project includes an alternative implementation of a smart contract of an autocompounder for distribution pools from the Staking Pools Autocompounder project. The smart contract supports autocompounding of distribution pools of Cometa platform. Since both projects implement the same functionality, refer to README.md of Staking Pools Autocompounder project for a detailed description.
The implementation takes advantage of Algorand's new functionality introduced with AVM8 - the box storage. Box storage is elegantly used to keep track of how much interest has each user earned between two autocompounding instances. Since the autocompounding can be done arbitrarily frequently, there is a need for an arbitrary amount of storage, which cannot be achieved using global or local storage (especially since autocompounding can be triggered by any user but the recorded data needs to be accessible by all other users as well). However, this can easily be achieved with box storage.
The difference in the implementation of this project and the Staking Pools Autocompounder project, is that this project uses the Beaker framework instead of pure PyTEAL. Comparing the smart contracts of the former and the latter shows that Beaker framework facilitates the development by simplifying contract's state management and code organization as well as providing methods for easier interactions. Nevertheless, comparing the smart contracts directly on the compiled TEAL code level (e.g. examples of the former vs. the latter) shows certain differences (ca. 20%). However, studying the TEAL code, it is possible to see that these come simply from different memory organizations. This was confirmed by verifying that both provide the same functionality.
The project includes a script for a sample interaction with autocompounding smart contracts through a simple command-line interface. The script implements the state machine shown in figure below.
An example scenario of interactions with the platform through the provided interaction script has been recorded and the video excerpts documented.
To test the platform with the provided script, the following is required:
- Python (>=3.10) with libraries in requirements.txt,
which can be installed using
pip install -r requirements.txt
- One or more mnemonics stored in plain text in .txt files (with spaces as delimiters) <= This is for simplicity of testing only!
- Connection to Algorand Testnet (e.g. via Sandbox or publicly available nodes by AlgoExplorer https://node.testnet.algoexplorerapi.io)
- Test ALGO and e.g. test USDC, which can both be received at https://dispenser.testnet.aws.algodev.network/
For testing, clone the repository and run the provided script.
The project was developed during Algorand Greenhouse Hack #3 and submitted to Learning Challenge: Box Storage with Beaker category.
The smart contracts were written using the Beaker framework, which uses PyTEAL. The contracts are ABI compliant. The command-line interface is written in Python and uses the py-algorand-sdk.
The software is not meant for production deployment - the smart contracts have not been audited and the provided test user interface does not follow the recommended security guidelines regarding handling of mnemonics.
Author: Uroš Hudomalj - https://github.com/uhudo