/bbeUSD-gnosis-extractor

Use this to extract liquid dollars out of bbeusd

Primary LanguageSolidity

bb-e-usd liquid dollar extraction POC

See Here for instructions how to run this PoC using etherscan. Below are instructions for how to execute on a multisig and/or fork.

Concept

This script runs in a fork of mainnet and simulates emergency withdrawing all everything back to non-bpt tokens in the addresses internal vault balances. Then it withdraws all DAI, USDC, and USDT from the balance. It can be run on any address to print a report, and the resulting JSON should work with any gnosis-safe multisig that has bbeUSD in it. It has not been tested with other tokens.

IMPORTANT

This is A Proof of Concept and Development Work. You should only use this if you are thinking a lot. Take the time to simulate in tenderly and understand the resulting outputs if you are going to execute a payload generated by this script. No one takes any responsibilty at all for your actions when using this code.

Please contact Tritium or the Balancer Maxis if you have questions or would like help understanding the tenderly sim.

Test Extractions made using this PoC

TempleDAO Multisig: https://etherscan.io/tx/0xe21cd49a8738fcb1e874e44b926d1042142bb76197873c120bda6f16e0db2fe4

Balancer Feel Collector: https://etherscan.io/tx/0xd88e493c76989c6bb58d244a5a0d8a26b96fdc1925c9d8e1074e016e53626f39

How do i do it

Getting set up

API keys

You will need an Infura api key that you can get at Infura. Accounts are free. Once logged in you can easily create a key.

You'll also need an etherscan api key. You can find that by loging into etherscan, and then creating an api key here

export these keys to the following environment variables

export ETHERSCAN_TOKEN=...
export WEB3_INFURA_PROJECT_ID=...

HINT: Add these to your .profile so they are always there and you don't have to think about this again if you had to do all this.

Dev Environment

Recommend using Python 3.9. You can install it on a mac with homebrew brew install python@3.9

You will also need ganahce-cli installed. npm install ganache-cli

If you don't have npm, try brew install npm

Install dependancies. You can setup a venv if you want

python3.9 -m venv venv
source venv/bin/activate
pip3.9 install requirements.txt

Running the simulated extraction and building a multisig payload

Edit the script in scripts/extractInFork.py and change the address of multisig to your address. It doesn't have to be a multisig to run the simulation, but you can only load the resulting payload into a gnosis safe.

Check all the other addresses and make sure they make sense/you understand.

Review the script breifly and make sure that no other addresses are used and you understand to at least this level.

Run the script from the scripts directory

cd scripts
brownie run --network mainnet-fork scripts/extractInFork.py

It should print a bunch of stuff, and at the end a report that looks something lke this:

=*** Final report.
BPTS burnt: 375523.8269979963
USDC in: 61995.513759
USDT in: 4.080702
DAI in: 64590.65470597399

A file will be created called EulerBreakoutOutput.json. If the address provided as multisig was a multisig, you can load this into transaction builder and simulate the results on tenderly. Once loaded into the safe, the transaction is reasonably easy to read.