lindy-labs / opus_contracts

Opus Source Code
https://opus.money
Other
0 stars 0 forks source link

script: simulate absorption #580

Closed tserg closed 4 months ago

tserg commented 4 months ago

The main purpose of this PR is to add a script that sets up a devnet instance with an absorbable trove for the purpose of testing the keeper for purger.absorb.

This led to a series of changes to set up the scripts directory in the best possible way for additional scripts to be added in the future:

  1. Added a simulation package to scripts. This package currently has a single script that opens a trove for 3 devnet accounts, have all three users provide to the Absorber, then crashes the prices to make the troves absorbable.
  2. To facilitate "simulation" scripts on devnet, we need the deployment addresses to be fixed. This is achieved by saving the start state after running the deploy_devnet script into a devnet_dump.json state file, which is then used for replaying the transactions next time. Hence, scarb run devnet in the top level Scarb.toml is now replaced by scarb run load_devnet (which uses the state file) and scarb run restart_devnet (which deletes the state file and starts a new devnet instance that will create a state file on exit).
  3. The scripts directory is also now its own package that contains constants and deployment addresses that are re-used in both deployment and simulation packages.