From f0d06525a8e98fe6667b5764c8644052cd6e869f Mon Sep 17 00:00:00 2001 From: sajanrajdev Date: Wed, 11 Oct 2023 18:35:08 +0200 Subject: [PATCH 1/2] feat: swap ibbtc signers --- scripts/issue/1424/change_ibbtc_signers.py | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 scripts/issue/1424/change_ibbtc_signers.py diff --git a/scripts/issue/1424/change_ibbtc_signers.py b/scripts/issue/1424/change_ibbtc_signers.py new file mode 100644 index 00000000..f205df40 --- /dev/null +++ b/scripts/issue/1424/change_ibbtc_signers.py @@ -0,0 +1,55 @@ +from brownie import interface +from great_ape_safe import GreatApeSafe +from helpers.addresses import r +from rich.console import Console + +C = Console() + +SENTINEL_OWNERS = "0x0000000000000000000000000000000000000001" + +def main(): + safe = GreatApeSafe(r.badger_wallets.ibbtc_multisig) + ibbtc_multisig = interface.IGnosisSafe_v1_3_0(safe.address, owner=safe.account) + trops_multisig = interface.IGnosisSafe_v1_3_0(r.badger_wallets.treasury_ops_multisig) + + trops_owners = trops_multisig.getOwners() + ibbtc_owners = ibbtc_multisig.getOwners() + + unique_to_ibbtc = list(set(ibbtc_owners).difference(set(trops_owners))) + unique_to_trops = list(set(trops_owners).difference(set(ibbtc_owners))) + + # Swap out any unique addresses to ibBTC + for i in range(len(unique_to_ibbtc)): + C.print(f"Swapping {unique_to_ibbtc[i]} for {unique_to_trops[i]}...") + + ibbtc_multisig.swapOwner( + get_previous_owner(ibbtc_multisig, unique_to_ibbtc[i]), + unique_to_ibbtc[i], + unique_to_trops[i], + ) + + # Add any missing owners + ibbtc_owners = ibbtc_multisig.getOwners() + for owner in trops_owners: + if owner not in ibbtc_owners: + ibbtc_multisig.addOwnerWithThreshold(owner, 3) + + # Confirm all owners + for owner in ibbtc_multisig.getOwners(): + assert owner in trops_owners + assert len(ibbtc_multisig.getOwners()) == len(trops_owners) + + C.print(f"\nNew Owners at ibbtc_multisig Multisig:") + C.print(f"[green]{ibbtc_multisig.getOwners()}[/green]\n") + + safe.post_safe_tx() + + +def get_previous_owner(safe, owner): + owners = safe.getOwners() + for i in range(len(owners)): + if owners[i] == owner: + if i == 0: + return SENTINEL_OWNERS + else: + return owners[i - 1] \ No newline at end of file From ca1e080dde96bc73b1f529962e82c893501d2079 Mon Sep 17 00:00:00 2001 From: sajanrajdev Date: Wed, 11 Oct 2023 18:38:35 +0200 Subject: [PATCH 2/2] fix: lint --- scripts/issue/1424/change_ibbtc_signers.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/issue/1424/change_ibbtc_signers.py b/scripts/issue/1424/change_ibbtc_signers.py index f205df40..daa16bd2 100644 --- a/scripts/issue/1424/change_ibbtc_signers.py +++ b/scripts/issue/1424/change_ibbtc_signers.py @@ -7,10 +7,13 @@ SENTINEL_OWNERS = "0x0000000000000000000000000000000000000001" + def main(): safe = GreatApeSafe(r.badger_wallets.ibbtc_multisig) ibbtc_multisig = interface.IGnosisSafe_v1_3_0(safe.address, owner=safe.account) - trops_multisig = interface.IGnosisSafe_v1_3_0(r.badger_wallets.treasury_ops_multisig) + trops_multisig = interface.IGnosisSafe_v1_3_0( + r.badger_wallets.treasury_ops_multisig + ) trops_owners = trops_multisig.getOwners() ibbtc_owners = ibbtc_multisig.getOwners() @@ -40,8 +43,8 @@ def main(): assert len(ibbtc_multisig.getOwners()) == len(trops_owners) C.print(f"\nNew Owners at ibbtc_multisig Multisig:") - C.print(f"[green]{ibbtc_multisig.getOwners()}[/green]\n") - + C.print(f"[green]{ibbtc_multisig.getOwners()}[/green]\n") + safe.post_safe_tx() @@ -52,4 +55,4 @@ def get_previous_owner(safe, owner): if i == 0: return SENTINEL_OWNERS else: - return owners[i - 1] \ No newline at end of file + return owners[i - 1]