Scripts built for the Lyra protocol:
/src/rewardsscripts for off-chain allocation of $LYRA in various reward programs/src/poolsscripts for calculation of AMM statistics/src/cachescripts to cache events and blocks locally (used to store pre-regenesis data)
We use MongoDB for local and remote data storage in our scripts.
docker pull mongo
docker run --name testContainer --restart=always -d -p 27017:27017 mongo mongod --auth
sudo docker exec -i -t testContainer bash
mongo
use admin
db.createUser({user:"foouser",pwd:"foopwd",roles:[{role:"root",db:"admin"}]})
exit
exit
Install git-lfs, for mac: brew install git-lfs.
Then use mongorestore to import the pre-regenesis event cache to MongoDB.
git lfs install
git pull
ulimit -S -n 2048
mongorestore --uri="mongodb://localhost:27017" --username=foouser --password=foopwd --authenticationDatabase=admin --drop
yarn
Copy the contents of .env.example to .env.local in the root directory.
(Optional) You can use your own infura node (instead of the public Optimism node) by adding an infura key to INFURA_KEY in .env.local and setting USE_INFURA=true. You can get an infura key at https://infura.io/.
Run the following script:
yarn cache-events-and-blocks --env local
Before running scripts that depend on live data, you should update the event cache:
yarn cache-events-and-blocks --env local
These scripts calculate rewards for various ignition reward programs. You can read more about the programs here: https://docs.lyra.finance/tokenomics/ignition
<program> = lyra-lp, retro-trading, trading, dai-susd-lp, snx-staking
To export data for programs to .csv files in the /out directory, run the following script:
yarn export-rewards <program> --env local
To sync data for programs to MongoDB, run the following script:
yarn sync-rewards <program> --env local
To recreate post-regenesis data for snx-staking, run the following script:
yarn sync-snx-staking-data
To recreate post-regenesis data for dai-susd-lp, run the following script:
yarn sync-dai-susd-lp-data
This script calculates realtime pool stats such as TVl and trading volume.
yarn sync-pool-stats --env local
To refresh the MongoDB cache:
mongodump --uri="mongodb://localhost:27017" --username=foouser --password=foopwd --db=lyra --authenticationDatabase=admin