Skip to content

Commit

Permalink
another round of deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
bout3fiddy committed Oct 23, 2023
1 parent d564a9f commit 5926e9b
Show file tree
Hide file tree
Showing 5 changed files with 331 additions and 11 deletions.
156 changes: 156 additions & 0 deletions contracts/ProxyAdmin.vy
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# pragma version 0.3.10
# pragma evm-version paris
"""
@title ProxyAdmin
@notice Thin proxy allowing shared ownership of contracts
@author Ben Hauser
@license MIT
"""


event TransactionExecuted:
admin: indexed(address)
target: indexed(address)
calldata: Bytes[100000]
value: uint256

event RequestAdminChange:
current_admin: address
future_admin: address

event RevokeAdminChange:
current_admin: address
future_admin: address
calling_admin: address

event ApproveAdminChange:
current_admin: address
future_admin: address
calling_admin: address

event AcceptAdminChange:
previous_admin: address
current_admin: address


admins: public(address[2])

pending_current_admin: uint256
pending_new_admin: address
change_approved: bool


@external
def __init__(_authorized: address[2]):
"""
@notice Contract constructor
@param _authorized Admin accounts for this contract
"""
self.admins = _authorized


@payable
@external
def execute(_target: address, _calldata: Bytes[100000]):
"""
@notice Execute a contract call
@dev Ether sent when calling this function is forwarded onward
@param _target Address of the contract to call
@param _calldata Calldata to use in the call
"""
assert msg.sender in self.admins # dev: only admin

raw_call(_target, _calldata, value=msg.value)
log TransactionExecuted(msg.sender, _target, _calldata, msg.value)


@view
@external
def get_admin_change_status() -> (address, address, bool):
"""
@notice Get information about a pending admin change
@return Admin address to be replaced,
admin address to be added,
has change been approved?
"""
idx: uint256 = self.pending_current_admin
if idx == 0:
return ZERO_ADDRESS, ZERO_ADDRESS, False
else:
return self.admins[idx - 1], self.pending_new_admin, self.change_approved


@external
def request_admin_change(_new_admin: address):
"""
@notice Initiate changing an admin address
@param _new_admin New admin address (replaces msg.sender)
"""
assert self.pending_current_admin == 0 # dev: already an active request

admin_list: address[2] = self.admins
assert _new_admin not in admin_list # dev: new admin is already admin

for i in range(2):
if admin_list[i] == msg.sender:
self.pending_current_admin = i + 1
self.pending_new_admin = _new_admin
log RequestAdminChange(msg.sender, _new_admin)
return

raise # dev: only admin


@external
def approve_admin_change():
"""
@notice Approve changing an admin address
@dev Only callable by the 2nd admin address (the one that will not change)
"""
idx: uint256 = self.pending_current_admin

assert idx > 0 # dev: no active request
assert msg.sender == self.admins[idx % 2] # dev: caller is not 2nd admin

self.change_approved = True
log ApproveAdminChange(self.admins[idx - 1], self.pending_new_admin, msg.sender)


@external
def revoke_admin_change():
"""
@notice Revoke changing an admin address
@dev May be called by either admin at any time to reset the process,
even if approval has previous been given
"""
assert msg.sender in self.admins # dev: only admin

idx: uint256 = self.pending_current_admin
pending_admin: address = ZERO_ADDRESS
if idx > 0:
pending_admin = self.admins[idx - 1]

log RevokeAdminChange(pending_admin, self.pending_new_admin, msg.sender)

self.pending_current_admin = 0
self.pending_new_admin = ZERO_ADDRESS
self.change_approved = False



@external
def accept_admin_change():
"""
@notice Accept a changed admin address
@dev Only callable by the new admin address, after approval has been given
"""
assert self.change_approved == True # dev: change not approved
assert msg.sender == self.pending_new_admin # dev: only new admin

idx: uint256 = self.pending_current_admin - 1
log AcceptAdminChange(self.admins[idx], msg.sender)
self.admins[idx] = msg.sender

self.pending_current_admin = 0
self.pending_new_admin = ZERO_ADDRESS
self.change_approved = False
92 changes: 85 additions & 7 deletions scripts/deploy_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,76 @@
"meta_amm": "0x5eee3091f747e60a045a2e715a4c71e600e31f6e",
"factory": "0xd2002373543Ce3527023C75e7518C274A51ce712",
},
"avax:mainnet": {
"math": "0xf3A431008396df8A8b2DF492C913706BDB0874ef",
"views": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6",
"plain_amm": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f",
"meta_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617",
"factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
},
"ftm:mainnet": {
"math": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6",
"views": "0x5eeE3091f747E60a045a2E715a4c71e600e31F6E",
"plain_amm": "0xd2002373543Ce3527023C75e7518C274A51ce712",
"meta_amm": "0x686bdb3D24Bc6F3ED89ed3d3B659765c54aC78B4",
"factory": "0xe61Fb97Ef6eBFBa12B36Ffd7be785c1F5A2DE66b",
},
"kava:mainnet": {
"math": "",
"views": "",
"plain_amm": "",
"meta_amm": "",
"factory": "",
},
"celo:mainnet": {
"math": "0xf3A431008396df8A8b2DF492C913706BDB0874ef",
"views": "0x8b3EFBEfa6eD222077455d6f0DCdA3bF4f3F57A6",
"plain_amm": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f",
"meta_amm": "0x87FE17697D0f14A222e8bEf386a0860eCffDD617",
"factory": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
},
"aurora:mainnet": {
"math": "",
"views": "",
"plain_amm": "",
"meta_amm": "",
"factory": "",
},
"bsc:mainnet": {
"math": "0x506F594ceb4E33F5161139bAe3Ee911014df9f7f",
"views": "0x1764ee18e8B3ccA4787249Ceb249356192594585",
"plain_amm": "0x604388Bb1159AFd21eB5191cE22b4DeCdEE2Ae22",
"meta_amm": "0x06452f9c013fc37169B57Eab8F50A7A48c9198A3",
"factory": "0xd7E72f3615aa65b92A4DBdC211E296a35512988B",
},
"linea:mainnet": {
"math": "",
"views": "",
"plain_amm": "",
"meta_amm": "",
"factory": "",
},
"scroll:mainnet": {
"math": "",
"views": "",
"plain_amm": "",
"meta_amm": "",
"factory": "",
},
"zksync:mainnet": {
"math": "",
"views": "",
"plain_amm": "",
"meta_amm": "",
"factory": "",
},
"pzkevm:mainnet": {
"math": "",
"views": "",
"plain_amm": "",
"meta_amm": "",
"factory": "",
},
}


Expand Down Expand Up @@ -212,12 +282,12 @@ def main():
# )

# # base
deploy_infra(
"base:mainnet",
os.environ["RPC_BASE"],
"FIDDYDEPLOYER",
fork=False,
)
# deploy_infra(
# "base:mainnet",
# os.environ["RPC_BASE"],
# "FIDDYDEPLOYER",
# fork=False,
# )

# # avax
# deploy_infra(
Expand All @@ -229,7 +299,7 @@ def main():

# # fantom
# deploy_infra(
# "fantom:mainnet",
# "ftm:mainnet",
# os.environ["RPC_FANTOM"],
# "FIDDYDEPLOYER",
# fork=False,
Expand Down Expand Up @@ -259,6 +329,14 @@ def main():
# fork=False,
# )

# # bsc
deploy_infra(
"bsc:mainnet",
os.environ["RPC_BSC"],
"FIDDYDEPLOYER",
fork=False,
)

# # eth
# deploy_infra(
# "ethereum:mainnet",
Expand Down
46 changes: 46 additions & 0 deletions scripts/deploy_proxy_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import sys

import boa
import deployment_utils as deploy_utils
from boa.network import NetworkEnv
from deploy_infra import set_evm_version
from eth_abi import encode
from eth_account import Account
from rich.console import Console as RichConsole

logger = RichConsole(file=sys.stdout)


def deploy_proxy_admin(network, url, account, fork=False):

logger.log(f"Deploying ProxyAdmin for {network} ...")

if fork:
boa.env.fork(url)
logger.log("Forkmode ...")
else:
logger.log("Prodmode ...")
boa.set_env(NetworkEnv(url))
boa.env.add_account(Account.from_key(os.environ[account]))

# deploy thin proxy if no owners exist:
proxy_admin_contract_obj = set_evm_version("./contracts/ProxyAdmin.vy", network)
args = [deploy_utils.FIDDYDEPLOYER, deploy_utils.BABE]
encoded_args = encode(["address", "address"], args).hex()
logger.log(f"Constructor: {encoded_args}")
proxy_admin = proxy_admin_contract_obj.deploy(args)
logger.log(f"Deployed ProxyAdmin at {proxy_admin.address} on {network}.")


def main():
deploy_proxy_admin(
"aurora:mainnet",
os.environ["RPC_AURORA"],
"FIDDYDEPLOYER",
fork=False,
)


if __name__ == "__main__":
main()
41 changes: 41 additions & 0 deletions scripts/deployment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def deploy_blueprint(contract, account):
ADDRESS_PROVIDER = "0x0000000022d53366457f9d5e68ec105046fc4383"
FIDDYRESEARCH = "0xE6DA683076b7eD6ce7eC972f21Eb8F91e9137a17"
FIDDYDEPLOYER = "0x2d12D0907A388811e3AA855A550F959501d303EE"
BABE = "0xbabe61887f1de2713c6f97e567623453d3C79f67"


# -------------- CURVE DATA --------------
Expand Down Expand Up @@ -104,6 +105,46 @@ class CurveNetworkSettings:
dao_ownership_contract="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy
fee_receiver_address="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy
),
"avax:mainnet": CurveNetworkSettings(
dao_ownership_contract="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy
fee_receiver_address="0x06534b0BF7Ff378F162d4F348390BDA53b15fA35",
),
"ftm:mainnet": CurveNetworkSettings(
dao_ownership_contract="0xB055EbbAcc8Eefc166c169e9Ce2886D0406aB49b", # proxy
fee_receiver_address="0x2B039565B2b7a1A9192D4847fbd33B25b836B950",
),
"kava:mainnet": CurveNetworkSettings(
dao_ownership_contract="0x1f0e8445Ebe0D0F60A96A7cd5BB095533cb15B58",
fee_receiver_address="0x1f0e8445Ebe0D0F60A96A7cd5BB095533cb15B58",
),
"celo:mainnet": CurveNetworkSettings(
dao_ownership_contract="0x56bc95Ded2BEF162131905dfd600F2b9F1B380a4",
fee_receiver_address="0x56bc95Ded2BEF162131905dfd600F2b9F1B380a4",
),
"aurora:mainnet": CurveNetworkSettings(
dao_ownership_contract="",
fee_receiver_address="",
),
"bsc:mainnet": CurveNetworkSettings(
dao_ownership_contract="0x98B4029CaBEf7Fd525A36B0BF8555EC1d42ec0B6",
fee_receiver_address="0x98B4029CaBEf7Fd525A36B0BF8555EC1d42ec0B6",
),
"linea:mainnet": CurveNetworkSettings(
dao_ownership_contract="",
fee_receiver_address="",
),
"scroll:mainnet": CurveNetworkSettings(
dao_ownership_contract="",
fee_receiver_address="",
),
"zksync:mainnet": CurveNetworkSettings(
dao_ownership_contract="",
fee_receiver_address="",
),
"pzkevm:mainnet": CurveNetworkSettings(
dao_ownership_contract="",
fee_receiver_address="",
),
}


Expand Down
Loading

0 comments on commit 5926e9b

Please sign in to comment.