Skip to content

Commit

Permalink
Merge pull request #308 from theref/upgrade-tapir-45
Browse files Browse the repository at this point in the history
Upgrade Tapir contracts to be inline with mainnet
  • Loading branch information
derekpierre authored Aug 27, 2024
2 parents 9f58db9 + e93302d commit 38a2420
Show file tree
Hide file tree
Showing 10 changed files with 1,368 additions and 185 deletions.
1,333 changes: 1,150 additions & 183 deletions deployment/artifacts/tapir.json

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions deployment/constructor_params/tapir/bqeth.yml
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
10 changes: 10 additions & 0 deletions deployment/constructor_params/tapir/free-fee-model.yml
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 deployment/constructor_params/tapir/upgrade-coordinator.yml
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
3 changes: 1 addition & 2 deletions scripts/mainnet/deploy_free_fee_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
from ape import project

from deployment.constants import (
CONSTRUCTOR_PARAMS_DIR, ARTIFACTS_DIR,
CONSTRUCTOR_PARAMS_DIR,
)
from deployment.params import Deployer

VERIFY = False
CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "mainnet" / "free-fee-model.yml"
LYNX_REGISTRY = ARTIFACTS_DIR / "free-fee-model.json"


def main():
Expand Down
32 changes: 32 additions & 0 deletions scripts/tapir/coordinator_approve_bqeth_fee_model.py
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)
25 changes: 25 additions & 0 deletions scripts/tapir/coordinator_approve_free_fee_model.py
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)
25 changes: 25 additions & 0 deletions scripts/tapir/deploy_bqeth.py
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,
)
31 changes: 31 additions & 0 deletions scripts/tapir/deploy_free_fee_model.py
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,
)
35 changes: 35 additions & 0 deletions scripts/tapir/upgrade_coordinator.py
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,
)

0 comments on commit 38a2420

Please sign in to comment.