-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from theref/upgrade-tapir-45
Upgrade Tapir contracts to be inline with mainnet
- Loading branch information
Showing
10 changed files
with
1,368 additions
and
185 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
deployment: | ||
name: bqeth-tapir | ||
chain_id: 80002 | ||
|
||
artifacts: | ||
dir: ./deployment/artifacts/ | ||
filename: bqeth-tapir.json | ||
|
||
constants: | ||
# See deployment/artifacts/tapir.json | ||
COORDINATOR_PROXY: "0xE690b6bCC0616Dc5294fF84ff4e00335cA52C388" | ||
TAPIR_RITUAL_TOKEN: "0xf91afFE7cf1d9c367Cb56eDd70C0941a4E8570d9" | ||
TESTNET_DEPLOYER: "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600" | ||
GLOBAL_ALLOW_LIST: "0xcc537b292d142dABe2424277596d8FFCC3e6A12D" | ||
|
||
MAX_NODES: 5 | ||
|
||
# - Fee parameters: | ||
INITIAL_BASE_FEE_RATE: 4050925925925 # $0.35 per day, in DAI units per second (in Python: 35*10**16 // 86400) | ||
ENCRYPTOR_FEE_RATE: 63419583967 # $2 per year, in DAI units per second (in Python: 2 * 10**18 // 86400 // 365) | ||
BASE_FEE_RATE_INCREASE: 500 # 5%/year ~ 2.47%/semester, expressed in basis points (0.01%) | ||
|
||
PERIOD: 172800 # 2 days | ||
YELLOW_PERIOD: 86400 # 1 day | ||
RED_PERIOD: 86400 # 1 day | ||
|
||
contracts: | ||
- BqETHSubscription: | ||
proxy: | ||
constructor: | ||
initialOwner: $TESTNET_DEPLOYER | ||
_data: $encode:initialize,$TESTNET_DEPLOYER | ||
constructor: | ||
_coordinator: $COORDINATOR_PROXY | ||
_accessController: $GLOBAL_ALLOW_LIST | ||
_feeToken: $TAPIR_RITUAL_TOKEN | ||
_adopterSetter: $TESTNET_DEPLOYER | ||
_initialBaseFeeRate: $INITIAL_BASE_FEE_RATE | ||
_baseFeeRateIncrease: $BASE_FEE_RATE_INCREASE | ||
_encryptorFeeRate: $ENCRYPTOR_FEE_RATE | ||
_maxNodes: $MAX_NODES | ||
_subscriptionPeriodDuration: $PERIOD | ||
_yellowPeriodDuration: $YELLOW_PERIOD | ||
_redPeriodDuration: $RED_PERIOD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
deployment: | ||
name: tapir-free-fee-model | ||
chain_id: 80002 | ||
|
||
artifacts: | ||
dir: ./deployment/artifacts/ | ||
filename: tapir-free-fee-model.json | ||
|
||
contracts: | ||
- FreeFeeModel |
15 changes: 15 additions & 0 deletions
15
deployment/constructor_params/tapir/upgrade-coordinator.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
deployment: | ||
name: tapir-upgrade-coordinator | ||
chain_id: 80002 | ||
|
||
artifacts: | ||
dir: ./deployment/artifacts/ | ||
filename: tapir-upgrade-coordinator.json | ||
|
||
constants: | ||
TACO_CHILD_APPLICATION: "0x489287Ed5BdF7a35fEE411FBdCc47331093D0769" | ||
|
||
contracts: | ||
- Coordinator: | ||
constructor: | ||
_application: $TACO_CHILD_APPLICATION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/python3 | ||
|
||
from ape import project, networks | ||
|
||
from deployment.constants import ARTIFACTS_DIR | ||
from deployment.params import Transactor | ||
from deployment.registry import contracts_from_registry | ||
|
||
TAPIR_REGISTRY_FILEPATH = ARTIFACTS_DIR / "tapir.json" | ||
|
||
def main(): | ||
""" | ||
Coordinator approves the fee model for BqETHSubscription | ||
ape run tapir coordinator_approve_fee_model --network polygon:amoy:infura | ||
""" | ||
|
||
transactor = Transactor() | ||
deployments = contracts_from_registry( | ||
filepath=TAPIR_REGISTRY_FILEPATH, chain_id=networks.active_provider.chain_id | ||
) | ||
coordinator = deployments[project.Coordinator.contract_type.name] | ||
bqeth_subscription = deployments[project.BqETHSubscription.contract_type.name] | ||
|
||
# Grant TREASURY_ROLE | ||
TREASURY_ROLE = coordinator.TREASURY_ROLE() | ||
transactor.transact( | ||
coordinator.grantRole, | ||
TREASURY_ROLE, | ||
transactor.get_account().address | ||
) | ||
transactor.transact(coordinator.approveFeeModel, bqeth_subscription.address) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/python3 | ||
|
||
from ape import project, networks | ||
|
||
from deployment.constants import ARTIFACTS_DIR | ||
from deployment.params import Transactor | ||
from deployment.registry import contracts_from_registry | ||
|
||
TAPIR_REGISTRY_FILEPATH = ARTIFACTS_DIR / "tapir.json" | ||
|
||
def main(): | ||
""" | ||
Coordinator approves the fee model for Free Fee Model | ||
ape run tapir coordinator_approve_free_fee_model --network polygon:amoy:infura | ||
""" | ||
|
||
transactor = Transactor() | ||
deployments = contracts_from_registry( | ||
filepath=TAPIR_REGISTRY_FILEPATH, chain_id=networks.active_provider.chain_id | ||
) | ||
coordinator = deployments[project.Coordinator.contract_type.name] | ||
free_fee_model = deployments[project.FreeFeeModel.contract_type.name] | ||
|
||
transactor.transact(coordinator.approveFeeModel, free_fee_model.address) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/python3 | ||
|
||
from ape import project | ||
|
||
from deployment.constants import ( | ||
CONSTRUCTOR_PARAMS_DIR, ARTIFACTS_DIR, | ||
) | ||
from deployment.params import Deployer | ||
from deployment.registry import merge_registries | ||
|
||
VERIFY = False | ||
CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "tapir" / "bqeth.yml" | ||
TAPIR_REGISTRY = ARTIFACTS_DIR / "tapir.json" | ||
|
||
|
||
def main(): | ||
deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH, verify=VERIFY) | ||
bqeth_subscription = deployer.deploy(project.BqETHSubscription) | ||
deployments = [bqeth_subscription] | ||
deployer.finalize(deployments=deployments) | ||
merge_registries( | ||
registry_1_filepath=TAPIR_REGISTRY, | ||
registry_2_filepath=deployer.registry_filepath, | ||
output_filepath=TAPIR_REGISTRY, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/python3 | ||
|
||
from ape import project, networks | ||
|
||
from deployment.constants import ( | ||
ARTIFACTS_DIR, | ||
CONSTRUCTOR_PARAMS_DIR, | ||
) | ||
from deployment.params import Deployer | ||
from deployment.registry import contracts_from_registry, merge_registries | ||
|
||
VERIFY = False | ||
CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "tapir" / "free-fee-model.yml" | ||
TAPIR_REGISTRY_FILEPATH = ARTIFACTS_DIR / "tapir.json" | ||
|
||
|
||
def main(): | ||
deployments = contracts_from_registry( | ||
filepath=TAPIR_REGISTRY_FILEPATH, chain_id=networks.active_provider.chain_id | ||
) | ||
deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH, verify=VERIFY) | ||
|
||
free_fee_model = deployer.deploy(project.FreeFeeModel) | ||
deployments = [free_fee_model] | ||
|
||
deployer.finalize(deployments=deployments) | ||
merge_registries( | ||
registry_1_filepath=TAPIR_REGISTRY_FILEPATH, | ||
registry_2_filepath=deployer.registry_filepath, | ||
output_filepath=TAPIR_REGISTRY_FILEPATH, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python3 | ||
|
||
from ape import project | ||
|
||
from deployment.constants import ARTIFACTS_DIR, CONSTRUCTOR_PARAMS_DIR | ||
from deployment.params import Deployer | ||
from deployment.registry import contracts_from_registry, merge_registries | ||
|
||
VERIFY = False | ||
CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "tapir" / "upgrade-coordinator.yml" | ||
TAPIR_REGISTRY_FILEPATH = ARTIFACTS_DIR / "tapir.json" | ||
|
||
|
||
def main(): | ||
""" | ||
This script upgrades Coordinator on Tapir/Amoy. | ||
""" | ||
|
||
deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH, verify=VERIFY) | ||
instances = contracts_from_registry(filepath=ARTIFACTS_DIR / "tapir.json", chain_id=80002) | ||
|
||
coordinator = deployer.upgrade( | ||
project.Coordinator, instances[project.Coordinator.contract_type.name].address | ||
) | ||
|
||
deployments = [ | ||
coordinator, | ||
] | ||
|
||
deployer.finalize(deployments=deployments) | ||
merge_registries( | ||
registry_1_filepath=TAPIR_REGISTRY_FILEPATH, | ||
registry_2_filepath=deployer.registry_filepath, | ||
output_filepath=TAPIR_REGISTRY_FILEPATH, | ||
) |