Contains a proxy contract which takes LDO and stETH tokens from the treasury, converts them to ETH (LDO -> stETH -> ETH), and then purchases insurance by Unslashed to cover eth2 validators slashing.
- python3 from version 3.7 to 3.9
- brownie - version 1.13.1
- ganache-cli - version 6.12.1
To get started, first create and initialize a Python virtual environment. Next, clone the repo and install the dependencies. Run the tests:
git clone https://github.com/lidofinance/insurance-purchaser.git
cd insurance-purchaser
export WEB3_INFURA_PROJECT_ID=infura-token
brownie test
To validate that a proposed vote for transferring tokens (LDO, stETH) to the InsurancePurchaser is correct, you need to do the following steps:
-
Open Lido
voting app
in etherscan, fetch the vote with the correspondingid
, and extract thescript
field content. -
Check the configuration of the proposed purchase in
scripts/generate_purchase_exec_script.py
(ldo_amount
,steth_amount
,insurance_amount
,min_insurance_tokens
,reference
). -
Run
scripts/generate_purchase_exec_script.py
and check that the exec script it generates matches the one extracted from the vote.export WEB3_INFURA_PROJECT_ID=infura-token brownie run generate_purchase_exec_script --network mainnet
To deploy the purchaser contract:
-
Edit the configuration settings within
scripts/deploy.py
. Check aragon agent mainnet address. -
Test it locally.
brownie run deploy --network development
-
Set DEPLOYER env variable to the deployer account name first (from ~/.brownie/accounts).
export DEPLOYER=ldo_holder
-
Deploy to the mainnet and transfer ownership to the agent address.
brownie run deploy --network mainnet
To propose a new purchase:
-
Edit the configuration settings within
propose_insurance_purchase.py
. -
Test it locally.
brownie run propose_insurance_purchase --network development
-
Set DEPLOYER env variable to the deployer account name first (from
~/.brownie/accounts
). Important: DEPLOYER acc should have some LDO governance token to be able to submit new vote.export DEPLOYER=ldo_holder
-
Submit the vote.
brownie run propose_insurance_purchase --network mainnet
When the script completes it will print the
vote_id
.
-
Set WEB3_INFURA_PROJECT_ID and open brownie console.
export WEB3_INFURA_PROJECT_ID=infura-token brownie networks modify development timeout=120 brownie console --network development
-
Deploy insurance purchaser by running deploy script from the console.
>>> run("deploy.py") >>> purchaser = InsurancePurchaser.at("0x602C71e4DAC47a042Ee7f46E0aee17F94A3bA0B6")
-
Edit the configuration settings within
propose_insurance_purchase.py
. Put the actual address forInsurancePurchaser
. -
Get some LDO tokens to be able to submit a vote.
>>> run("get_coins.py") >>> ldo_token = interface.ERC20("0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32") >>> ldo_token.balanceOf(accounts[0])
-
Propose a vote and check the script.
>>> run("propose_insurance_purchase.py") >>> voting = interface.Voting("0x2e59A20f205bB85a89C53f1936454680651E618e") >>> voting.getVote(44)
-
Perform voting.
>>> run("perform_voting.py")