diff --git a/contracts/contracts/testnet/OpenAccessAuthorizer.sol b/contracts/contracts/testnet/OpenAccessAuthorizer.sol index b94b71e0..717133f7 100644 --- a/contracts/contracts/testnet/OpenAccessAuthorizer.sol +++ b/contracts/contracts/testnet/OpenAccessAuthorizer.sol @@ -2,13 +2,7 @@ pragma solidity ^0.8.0; -interface IEncryptionAuthorizer { - function isAuthorized( - uint32 ritualId, - bytes memory evidence, - bytes memory ciphertextHeader - ) external view returns (bool); -} +import "../coordination/IEncryptionAuthorizer.sol"; contract OpenAccessAuthorizer is IEncryptionAuthorizer { function isAuthorized( diff --git a/deployment/artifacts/lynx.json b/deployment/artifacts/lynx.json index f7ac2f77..d03a8e7f 100644 --- a/deployment/artifacts/lynx.json +++ b/deployment/artifacts/lynx.json @@ -2294,8 +2294,8 @@ } }, "80002": { - "BetaProgramInitiator": { - "address": "0xf47dde316D994a050b8b4e5986e0790309979697", + "BqETHSubscription": { + "address": "0x3E851204c29742b713d5C243093E98691591e654", "abi": [ { "type": "constructor", @@ -2304,12 +2304,68 @@ { "name": "_coordinator", "type": "address", - "internalType": "contract Coordinator" + "components": null, + "internal_type": "contract Coordinator" }, { - "name": "_executor", + "name": "_accessController", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "contract GlobalAllowList" + }, + { + "name": "_feeToken", + "type": "address", + "components": null, + "internal_type": "contract IERC20" + }, + { + "name": "_adopter", + "type": "address", + "components": null, + "internal_type": "address" + }, + { + "name": "_initialBaseFeeRate", + "type": "uint256", + "components": null, + "internal_type": "uint256" + }, + { + "name": "_baseFeeRateIncrease", + "type": "uint256", + "components": null, + "internal_type": "uint256" + }, + { + "name": "_encryptorFeeRate", + "type": "uint256", + "components": null, + "internal_type": "uint256" + }, + { + "name": "_maxNodes", + "type": "uint256", + "components": null, + "internal_type": "uint256" + }, + { + "name": "_subscriptionPeriodDuration", + "type": "uint32", + "components": null, + "internal_type": "uint32" + }, + { + "name": "_yellowPeriodDuration", + "type": "uint32", + "components": null, + "internal_type": "uint32" + }, + { + "name": "_redPeriodDuration", + "type": "uint32", + "components": null, + "internal_type": "uint32" } ] }, @@ -2320,7 +2376,8 @@ { "name": "target", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "address" } ] }, @@ -2331,7 +2388,8 @@ { "name": "account", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "address" } ] }, @@ -2340,6 +2398,40 @@ "name": "FailedInnerCall", "inputs": [] }, + { + "type": "error", + "name": "InvalidInitialization", + "inputs": [] + }, + { + "type": "error", + "name": "NotInitializing", + "inputs": [] + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "components": null, + "internal_type": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "components": null, + "internal_type": "address" + } + ] + }, { "type": "error", "name": "SafeERC20FailedOperation", @@ -2347,24 +2439,41 @@ { "name": "token", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "address" } ] }, { "type": "event", - "name": "FailedRequestRefunded", + "name": "EncryptorSlotsPaid", "inputs": [ { - "name": "requestIndex", - "type": "uint256", - "internalType": "uint256", + "name": "sponsor", + "type": "address", + "components": null, + "internal_type": "address", "indexed": true }, { - "name": "refundAmount", + "name": "amount", "type": "uint256", - "internalType": "uint256", + "components": null, + "internal_type": "uint256", + "indexed": false + }, + { + "name": "encryptorSlots", + "type": "uint128", + "components": null, + "internal_type": "uint128", + "indexed": false + }, + { + "name": "endOfCurrentPeriod", + "type": "uint32", + "components": null, + "internal_type": "uint32", "indexed": false } ], @@ -2372,37 +2481,34 @@ }, { "type": "event", - "name": "RequestCanceled", + "name": "Initialized", "inputs": [ { - "name": "sender", - "type": "address", - "internalType": "address", - "indexed": true - }, - { - "name": "requestIndex", - "type": "uint256", - "internalType": "uint256", - "indexed": true + "name": "version", + "type": "uint64", + "components": null, + "internal_type": "uint64", + "indexed": false } ], "anonymous": false }, { "type": "event", - "name": "RequestExecuted", + "name": "OwnershipTransferred", "inputs": [ { - "name": "requestIndex", - "type": "uint256", - "internalType": "uint256", + "name": "previousOwner", + "type": "address", + "components": null, + "internal_type": "address", "indexed": true }, { - "name": "ritualId", - "type": "uint256", - "internalType": "uint256", + "name": "newOwner", + "type": "address", + "components": null, + "internal_type": "address", "indexed": true } ], @@ -2410,48 +2516,55 @@ }, { "type": "event", - "name": "RequestRegistered", + "name": "SubscriptionPaid", "inputs": [ { - "name": "sender", + "name": "subscriber", "type": "address", - "internalType": "address", + "components": null, + "internal_type": "address", "indexed": true }, { - "name": "requestIndex", + "name": "amount", "type": "uint256", - "internalType": "uint256", - "indexed": true - }, - { - "name": "providers", - "type": "address[]", - "internalType": "address[]", + "components": null, + "internal_type": "uint256", "indexed": false }, { - "name": "authority", - "type": "address", - "internalType": "address", + "name": "encryptorSlots", + "type": "uint128", + "components": null, + "internal_type": "uint128", "indexed": false }, { - "name": "duration", + "name": "endOfSubscription", "type": "uint32", - "internalType": "uint32", + "components": null, + "internal_type": "uint32", "indexed": false - }, + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "WithdrawalToTreasury", + "inputs": [ { - "name": "accessController", + "name": "treasury", "type": "address", - "internalType": "contract IEncryptionAuthorizer", - "indexed": false + "components": null, + "internal_type": "address", + "indexed": true }, { - "name": "payment", + "name": "amount", "type": "uint256", - "internalType": "uint256", + "components": null, + "internal_type": "uint256", "indexed": false } ], @@ -2459,208 +2572,585 @@ }, { "type": "function", - "name": "NO_RITUAL", + "name": "INACTIVE_RITUAL_ID", "stateMutability": "view", "inputs": [], "outputs": [ { "name": "", "type": "uint32", - "internalType": "uint32" + "components": null, + "internal_type": "uint32" } ] }, { "type": "function", - "name": "cancelInitiationRequest", - "stateMutability": "nonpayable", - "inputs": [ + "name": "INCREASE_BASE", + "stateMutability": "view", + "inputs": [], + "outputs": [ { - "name": "requestIndex", + "name": "", "type": "uint256", - "internalType": "uint256" + "components": null, + "internal_type": "uint256" } - ], - "outputs": [] + ] }, { "type": "function", - "name": "coordinator", + "name": "accessController", "stateMutability": "view", "inputs": [], "outputs": [ { "name": "", "type": "address", - "internalType": "contract Coordinator" + "components": null, + "internal_type": "contract GlobalAllowList" } ] }, { "type": "function", - "name": "currency", + "name": "activeRitualId", "stateMutability": "view", "inputs": [], "outputs": [ { "name": "", - "type": "address", - "internalType": "contract IERC20" + "type": "uint32", + "components": null, + "internal_type": "uint32" } ] }, { "type": "function", - "name": "executeInitiationRequest", - "stateMutability": "nonpayable", - "inputs": [ + "name": "adopter", + "stateMutability": "view", + "inputs": [], + "outputs": [ { - "name": "requestIndex", - "type": "uint256", - "internalType": "uint256" + "name": "", + "type": "address", + "components": null, + "internal_type": "address" } - ], - "outputs": [] + ] }, { "type": "function", - "name": "executor", + "name": "baseFeeRateIncrease", "stateMutability": "view", "inputs": [], "outputs": [ { "name": "", - "type": "address", - "internalType": "address" + "type": "uint256", + "components": null, + "internal_type": "uint256" } ] }, { "type": "function", - "name": "getProviders", + "name": "baseFees", "stateMutability": "view", "inputs": [ { - "name": "requestIndex", + "name": "periodNumber", "type": "uint256", - "internalType": "uint256" + "components": null, + "internal_type": "uint256" } ], "outputs": [ { "name": "", - "type": "address[]", - "internalType": "address[]" + "type": "uint256", + "components": null, + "internal_type": "uint256" } ] }, { "type": "function", - "name": "getRequestsLength", + "name": "baseFees", "stateMutability": "view", "inputs": [], "outputs": [ { "name": "", "type": "uint256", - "internalType": "uint256" + "components": null, + "internal_type": "uint256" } ] }, { "type": "function", - "name": "refundFailedRequest", - "stateMutability": "nonpayable", + "name": "beforeIsAuthorized", + "stateMutability": "view", "inputs": [ { - "name": "requestIndex", - "type": "uint256", - "internalType": "uint256" + "name": "ritualId", + "type": "uint32", + "components": null, + "internal_type": "uint32" } ], "outputs": [] }, { "type": "function", - "name": "registerInitiationRequest", + "name": "beforeSetAuthorization", "stateMutability": "nonpayable", "inputs": [ { - "name": "providers", + "name": "ritualId", + "type": "uint32", + "components": null, + "internal_type": "uint32" + }, + { + "name": "addresses", "type": "address[]", - "internalType": "address[]" + "components": null, + "internal_type": "address[]" }, { - "name": "authority", + "name": "value", + "type": "bool", + "components": null, + "internal_type": "bool" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "billingInfo", + "stateMutability": "view", + "inputs": [ + { + "name": "periodNumber", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ], + "outputs": [ + { + "name": "paid", + "type": "bool", + "components": null, + "internal_type": "bool" + }, + { + "name": "encryptorSlots", + "type": "uint128", + "components": null, + "internal_type": "uint128" + } + ] + }, + { + "type": "function", + "name": "coordinator", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "contract Coordinator" + } + ] + }, + { + "type": "function", + "name": "encryptorFeeRate", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ] + }, + { + "type": "function", + "name": "encryptorFees", + "stateMutability": "view", + "inputs": [ + { + "name": "encryptorSlots", + "type": "uint128", + "components": null, + "internal_type": "uint128" }, { "name": "duration", "type": "uint32", - "internalType": "uint32" - }, + "components": null, + "internal_type": "uint32" + } + ], + "outputs": [ { - "name": "accessController", + "name": "", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ] + }, + { + "type": "function", + "name": "feeToken", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", "type": "address", - "internalType": "contract IEncryptionAuthorizer" + "components": null, + "internal_type": "contract IERC20" } - ], + ] + }, + { + "type": "function", + "name": "getCurrentPeriodNumber", + "stateMutability": "view", + "inputs": [], "outputs": [ { - "name": "requestIndex", + "name": "", "type": "uint256", - "internalType": "uint256" + "components": null, + "internal_type": "uint256" + } + ] + }, + { + "type": "function", + "name": "getEndOfSubscription", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "endOfSubscription", + "type": "uint32", + "components": null, + "internal_type": "uint32" } ] }, { "type": "function", - "name": "requests", + "name": "getPaidEncryptorSlots", "stateMutability": "view", "inputs": [ + { + "name": "periodNumber", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ], + "outputs": [ { "name": "", "type": "uint256", - "internalType": "uint256" + "components": null, + "internal_type": "uint256" + } + ] + }, + { + "type": "function", + "name": "initialBaseFeeRate", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ] + }, + { + "type": "function", + "name": "initialize", + "stateMutability": "nonpayable", + "inputs": [ + { + "name": "_treasury", + "type": "address", + "components": null, + "internal_type": "address" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "isPeriodPaid", + "stateMutability": "view", + "inputs": [ + { + "name": "periodNumber", + "type": "uint256", + "components": null, + "internal_type": "uint256" } ], "outputs": [ { - "name": "authority", + "name": "", + "type": "bool", + "components": null, + "internal_type": "bool" + } + ] + }, + { + "type": "function", + "name": "maxNodes", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ] + }, + { + "type": "function", + "name": "owner", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "address" + } + ] + }, + { + "type": "function", + "name": "payForEncryptorSlots", + "stateMutability": "nonpayable", + "inputs": [ + { + "name": "additionalEncryptorSlots", + "type": "uint128", + "components": null, + "internal_type": "uint128" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "payForSubscription", + "stateMutability": "nonpayable", + "inputs": [ + { + "name": "encryptorSlots", + "type": "uint128", + "components": null, + "internal_type": "uint128" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "processRitualExtending", + "stateMutability": "view", + "inputs": [ + { + "name": "", + "type": "address", + "components": null, + "internal_type": "address" }, { - "name": "duration", + "name": "ritualId", "type": "uint32", - "internalType": "uint32" + "components": null, + "internal_type": "uint32" }, { - "name": "accessController", - "type": "address", - "internalType": "contract IEncryptionAuthorizer" + "name": "", + "type": "uint256", + "components": null, + "internal_type": "uint256" }, { - "name": "sender", + "name": "", + "type": "uint32", + "components": null, + "internal_type": "uint32" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "processRitualPayment", + "stateMutability": "nonpayable", + "inputs": [ + { + "name": "initiator", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "address" }, { "name": "ritualId", "type": "uint32", - "internalType": "uint32" + "components": null, + "internal_type": "uint32" }, { - "name": "payment", + "name": "numberOfProviders", "type": "uint256", - "internalType": "uint256" + "components": null, + "internal_type": "uint256" + }, + { + "name": "duration", + "type": "uint32", + "components": null, + "internal_type": "uint32" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "redPeriodDuration", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "components": null, + "internal_type": "uint32" + } + ] + }, + { + "type": "function", + "name": "renounceOwnership", + "stateMutability": "nonpayable", + "inputs": [], + "outputs": [] + }, + { + "type": "function", + "name": "startOfSubscription", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "components": null, + "internal_type": "uint32" + } + ] + }, + { + "type": "function", + "name": "subscriptionPeriodDuration", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "components": null, + "internal_type": "uint32" + } + ] + }, + { + "type": "function", + "name": "transferOwnership", + "stateMutability": "nonpayable", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "components": null, + "internal_type": "address" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "usedEncryptorSlots", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ] + }, + { + "type": "function", + "name": "withdrawToTreasury", + "stateMutability": "nonpayable", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ], + "outputs": [] + }, + { + "type": "function", + "name": "yellowPeriodDuration", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "components": null, + "internal_type": "uint32" } ] } ], - "tx_hash": "0xbc06258dbf24b6da9d45619a3048e6894a2779a198d4b7e6cdc48470e8e93ee6", - "block_number": 5199800, + "tx_hash": "0x709f8cb91d3489fed89b0006a162e226a12095e12c5b737d1ec639109cac4a26", + "block_number": 9101924, "deployer": "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600" }, "Coordinator": { @@ -4444,7 +4934,7 @@ "deployer": "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600" }, "GlobalAllowList": { - "address": "0xfDBA7100B015586270B62bA116920b78F4ff6930", + "address": "0xd5a66BF5f63dccAFEC74AEe1ba755CD7e06F683a", "abi": [ { "type": "constructor", @@ -4453,7 +4943,8 @@ { "name": "_coordinator", "type": "address", - "internalType": "contract Coordinator" + "components": null, + "internal_type": "contract Coordinator" } ] }, @@ -4469,7 +4960,8 @@ { "name": "length", "type": "uint256", - "internalType": "uint256" + "components": null, + "internal_type": "uint256" } ] }, @@ -4480,7 +4972,8 @@ { "name": "s", "type": "bytes32", - "internalType": "bytes32" + "components": null, + "internal_type": "bytes32" } ] }, @@ -4491,24 +4984,62 @@ { "name": "ritualId", "type": "uint32", - "internalType": "uint32", + "components": null, + "internal_type": "uint32", "indexed": true }, { "name": "_address", "type": "address", - "internalType": "address", + "components": null, + "internal_type": "address", "indexed": true }, { "name": "isAuthorized", "type": "bool", - "internalType": "bool", + "components": null, + "internal_type": "bool", "indexed": false } ], "anonymous": false }, + { + "type": "function", + "name": "MAX_AUTH_ACTIONS", + "stateMutability": "view", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "uint32", + "components": null, + "internal_type": "uint32" + } + ] + }, + { + "type": "function", + "name": "authActions", + "stateMutability": "view", + "inputs": [ + { + "name": "", + "type": "uint32", + "components": null, + "internal_type": "uint32" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "components": null, + "internal_type": "uint256" + } + ] + }, { "type": "function", "name": "authorize", @@ -4517,12 +5048,14 @@ { "name": "ritualId", "type": "uint32", - "internalType": "uint32" + "components": null, + "internal_type": "uint32" }, { "name": "addresses", "type": "address[]", - "internalType": "address[]" + "components": null, + "internal_type": "address[]" } ], "outputs": [] @@ -4536,7 +5069,8 @@ { "name": "", "type": "address", - "internalType": "contract Coordinator" + "components": null, + "internal_type": "contract Coordinator" } ] }, @@ -4548,12 +5082,14 @@ { "name": "ritualId", "type": "uint32", - "internalType": "uint32" + "components": null, + "internal_type": "uint32" }, { "name": "addresses", "type": "address[]", - "internalType": "address[]" + "components": null, + "internal_type": "address[]" } ], "outputs": [] @@ -4566,19 +5102,22 @@ { "name": "ritualId", "type": "uint32", - "internalType": "uint32" + "components": null, + "internal_type": "uint32" }, { "name": "encryptor", "type": "address", - "internalType": "address" + "components": null, + "internal_type": "address" } ], "outputs": [ { "name": "", "type": "bool", - "internalType": "bool" + "components": null, + "internal_type": "bool" } ] }, @@ -4590,30 +5129,34 @@ { "name": "ritualId", "type": "uint32", - "internalType": "uint32" + "components": null, + "internal_type": "uint32" }, { "name": "evidence", "type": "bytes", - "internalType": "bytes" + "components": null, + "internal_type": "bytes" }, { "name": "ciphertextHeader", "type": "bytes", - "internalType": "bytes" + "components": null, + "internal_type": "bytes" } ], "outputs": [ { "name": "", "type": "bool", - "internalType": "bool" + "components": null, + "internal_type": "bool" } ] } ], - "tx_hash": "0xe1f8d7d3afac631312665faab5e45a4a8bbbfa7180f22014b5ad2dc0497edf72", - "block_number": 5198678, + "tx_hash": "0x7753ec5286e2521a8430a9686052d7e065b3b561167123e6975f0ae1a2d312d0", + "block_number": 9101909, "deployer": "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600" }, "LynxRitualToken": { diff --git a/deployment/constructor_params/lynx/beta_program_initiator.yml b/deployment/constructor_params/lynx/beta_program_initiator.yml deleted file mode 100644 index 808102f9..00000000 --- a/deployment/constructor_params/lynx/beta_program_initiator.yml +++ /dev/null @@ -1,20 +0,0 @@ -deployment: - name: beta-program-initiator - chain_id: 80002 - -artifacts: - dir: ./deployment/artifacts/ - filename: beta_program_initiator_lynx.json - -constants: - # See deployment/artifacts/lynx.json - COORDINATOR_PROXY: "0xE9e94499bB0f67b9DBD75506ec1735486DE57770" - - # lynx deployer account - EXECUTOR: "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600" - -contracts: - - BetaProgramInitiator: - constructor: - _coordinator: $COORDINATOR_PROXY - _executor: $EXECUTOR diff --git a/deployment/constructor_params/lynx/bqeth.yml b/deployment/constructor_params/lynx/bqeth.yml new file mode 100644 index 00000000..6755d370 --- /dev/null +++ b/deployment/constructor_params/lynx/bqeth.yml @@ -0,0 +1,51 @@ +deployment: + name: bqeth-lynx + chain_id: 80002 + +artifacts: + dir: ./deployment/artifacts/ + filename: bqeth-lynx.json + +constants: + # See deployment/artifacts/lynx.json + COORDINATOR_PROXY: "0xE9e94499bB0f67b9DBD75506ec1735486DE57770" + + # LynxRitualToken, see deployment/artifacts/lynx.json + LYNX_RITUAL_TOKEN: "0x064Be2a9740e565729BC0d47bC616c5bb8Cc87B9" + + # lynx deployer account + LYNX_DEPLOYER: "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600" + + MAX_NODES: 4 + + # Let's use proposed values for mainnet. See https://github.com/nucypher/tdec/issues/169 + 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%, expressed as parts on 10,000 + + # TODO: Are these good period durations for testing in Lynx? + PERIOD: 172800 # 2 days + YELLOW_PERIOD: 86400 # 1 day + RED_PERIOD: 86400 # 1 day + +contracts: + - GlobalAllowList: + constructor: + _coordinator: $COORDINATOR_PROXY + - BqETHSubscription: + proxy: + constructor: + initialOwner: $LYNX_DEPLOYER # Upgrades owner + _data: $encode:initialize,$LYNX_DEPLOYER + constructor: + _coordinator: $COORDINATOR_PROXY + _accessController: $GlobalAllowList + _feeToken: $LYNX_RITUAL_TOKEN + _adopter: $LYNX_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 \ No newline at end of file diff --git a/deployment/constructor_params/lynx/upgrade-coordinator.yml b/deployment/constructor_params/lynx/upgrade-coordinator.yml index 2ecf71d4..3b20a770 100644 --- a/deployment/constructor_params/lynx/upgrade-coordinator.yml +++ b/deployment/constructor_params/lynx/upgrade-coordinator.yml @@ -8,11 +8,8 @@ artifacts: constants: TACO_CHILD_APPLICATION: "0x42F30AEc1A36995eEFaf9536Eb62BD751F982D32" - LYNX_RITUAL_TOKEN: "0x064Be2a9740e565729BC0d47bC616c5bb8Cc87B9" contracts: - Coordinator: constructor: _application: $TACO_CHILD_APPLICATION - _currency: $LYNX_RITUAL_TOKEN - _feeRatePerSecond: 1 diff --git a/deployment/constructor_params/mainnet/beta_program_initiator.yml b/deployment/constructor_params/mainnet/beta_program_initiator.yml deleted file mode 100644 index 502666ef..00000000 --- a/deployment/constructor_params/mainnet/beta_program_initiator.yml +++ /dev/null @@ -1,20 +0,0 @@ -deployment: - name: beta-program-initiator - chain_id: 137 - -artifacts: - dir: ./deployment/artifacts/ - filename: beta_program_initiator.json - -constants: - # See deployment/artifacts/mainnet.json - COORDINATOR_PROXY: "0xE74259e3dafe30bAA8700238e324b47aC98FE755" - # See https://github.com/nucypher/tdec/issues/137#issuecomment-1881525878 - # and https://app.safe.global/home?safe=matic:0x861aa915C785dEe04684444560fC7A2AB43a1543 - EXECUTOR_MULTISIG: "0x861aa915C785dEe04684444560fC7A2AB43a1543" - -contracts: - - BetaProgramInitiator: - constructor: - _coordinator: $COORDINATOR_PROXY - _executor: $EXECUTOR_MULTISIG diff --git a/deployment/constructor_params/mainnet/bqeth.yml b/deployment/constructor_params/mainnet/bqeth.yml new file mode 100644 index 00000000..cc319096 --- /dev/null +++ b/deployment/constructor_params/mainnet/bqeth.yml @@ -0,0 +1,57 @@ +deployment: + name: bqeth-mainnet + chain_id: 137 + +artifacts: + dir: ./deployment/artifacts/ + filename: bqeth-mainnet.json + +constants: + # See deployment/artifacts/mainnet.json + COORDINATOR_PROXY: "0xE74259e3dafe30bAA8700238e324b47aC98FE755" + + BQETH_ADOPTER: "TBD" + + # DAI Token on Polygon PoS - References: + # - https://polygonscan.com/token/0x8f3cf7ad23cd3cadbd9735aff958023239c6a063 + # - https://github.com/search?q=0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063&type=code + DAI_ON_POLYGON: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063" + + # Threshold Network - References: + # - https://docs.threshold.network/resources/contract-addresses/mainnet/threshold-dao + # - https://github.com/keep-network/tbtc-v2/issues/594 + TREASURY_GUILD_ON_POLYGON: "0xc3Bf49eBA094AF346830dF4dbB42a07dE378EeB6" + THRESHOLD_COUNCIL_ON_POLYGON: "0x9F6e831c8F8939DC0C830C6e492e7cEf4f9C2F5f" + + # Subscription Parameters + # See https://github.com/nucypher/tdec/issues/169 + + # - 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_PER_PERIOD: 247 # 5%/year ~ 2.47%/semester, expressed in basis points (0.01%) + # - Duration parameters --> 1 period = 6 months + SIX_MONTHS_IN_SECONDS: 15552000 # 180 days (~6 months) + THREE_MONTHS_IN_SECONDS: 7776000 # 90 day (~3 months) + +contracts: + - GlobalAllowList: + constructor: + _coordinator: $COORDINATOR_PROXY + - BqETHSubscription: + proxy: + constructor: + initialOwner: $THRESHOLD_COUNCIL_ON_POLYGON # Upgrades owner + _data: $encode:initialize,$TREASURY_GUILD_ON_POLYGON + constructor: + _coordinator: $COORDINATOR_PROXY + _accessController: $GlobalAllowList + _feeToken: $DAI_ON_POLYGON + _adopter: $BQETH_ADOPTER + _initialBaseFeeRate: $INITIAL_BASE_FEE_RATE + _baseFeeRateIncrease: $BASE_FEE_RATE_INCREASE_PER_PERIOD + _encryptorFeeRate: $ENCRYPTOR_FEE_RATE + _maxNodes: $MAX_NODES + _subscriptionPeriodDuration: $SIX_MONTHS_IN_SECONDS + _yellowPeriodDuration: $THREE_MONTHS_IN_SECONDS + _redPeriodDuration: $THREE_MONTHS_IN_SECONDS diff --git a/deployment/constructor_params/mainnet/redeploy-coordinator.yml b/deployment/constructor_params/mainnet/redeploy-coordinator.yml index fb18bd1a..0b9d7988 100644 --- a/deployment/constructor_params/mainnet/redeploy-coordinator.yml +++ b/deployment/constructor_params/mainnet/redeploy-coordinator.yml @@ -10,17 +10,7 @@ constants: # See deployment/artifacts/mainnet.json TACO_CHILD_APPLICATION: "0xFa07aaB78062Fac4C36995bF28F6D677667973F5" - # DAI Token on Polygon PoS - References: - # - https://polygonscan.com/token/0x8f3cf7ad23cd3cadbd9735aff958023239c6a063 - # - https://github.com/search?q=0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063&type=code - DAI_ON_POLYGON: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063" - - # TACO specific constants: - PRIVATE_BETA_FEE_RATE: 4050925925925 # $0.35 per day, expressed in DAI units per seconds (in Python: 35*10**16 // 86400) - contracts: - Coordinator: constructor: _application: $TACO_CHILD_APPLICATION - _currency: $DAI_ON_POLYGON - _feeRatePerSecond: $PRIVATE_BETA_FEE_RATE diff --git a/deployment/params.py b/deployment/params.py index 97e3d613..abcc99fd 100644 --- a/deployment/params.py +++ b/deployment/params.py @@ -6,7 +6,7 @@ from ape import chain, networks from ape.api import AccountAPI, ReceiptAPI -from ape.cli import get_user_selected_account +from ape.cli.choices import select_account from ape.contracts.base import ContractContainer, ContractInstance, ContractTransactionHandler from ape.utils import EMPTY_BYTES32, ZERO_ADDRESS from eth_typing import ChecksumAddress @@ -482,7 +482,7 @@ class Transactor: def __init__(self, account: typing.Optional[AccountAPI] = None): if account is None: - self._account = get_user_selected_account() + self._account = select_account() else: self._account = account @@ -538,7 +538,7 @@ def __init__( constants = config.get("constants", {}) _Constants = namedtuple("_Constants", list(constants)) self.constants = _Constants(**constants) - + super().__init__(account) self._set_account(self._account) self.verify = verify @@ -588,7 +588,7 @@ def _deploy_contract( kwargs = self._get_kwargs() deployer_account = self.get_account() - return deployer_account.deploy(*deployment_params, + return deployer_account.deploy(*deployment_params, # FIXME: Manual gas fees - #199 # max_priority_fee="3 gwei", # max_fee="120 gwei", @@ -616,7 +616,7 @@ def _deploy_proxy( return contract_type_container.at(proxy_contract.address) def upgrade(self, container: ContractContainer, proxy_address, data=b'') -> ContractInstance: - + admin_slot = chain.provider.get_storage_at( address=proxy_address, slot=EIP1967_ADMIN_SLOT @@ -627,7 +627,7 @@ def upgrade(self, container: ContractContainer, proxy_address, data=b'') -> Cont f"Admin slot for contract at {proxy_address} is empty. " "Are you sure this is an EIP1967-compatible proxy?" ) - + admin_address = to_checksum_address(admin_slot[-20:]) proxy_admin = OZ_DEPENDENCY.ProxyAdmin.at(admin_address) # TODO: Check that owner of proxy admin is deployer @@ -636,7 +636,7 @@ def upgrade(self, container: ContractContainer, proxy_address, data=b'') -> Cont # TODO: initialize taco app implementation too self.transact(proxy_admin.upgradeAndCall, proxy_address, implementation.address, data) - + wrapped_instance = container.at(proxy_address) return wrapped_instance diff --git a/scripts/lynx/coordinator_approve_fee_model.py b/scripts/lynx/coordinator_approve_fee_model.py new file mode 100644 index 00000000..7203ef76 --- /dev/null +++ b/scripts/lynx/coordinator_approve_fee_model.py @@ -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 + +LYNX_REGISTRY_FILEPATH = ARTIFACTS_DIR / "lynx.json" + +def main(): + """ + Coordinator approves the fee model for BqETHSubscription + + ape run lynx coordinator_approve_fee_model --network polygon:amoy:infura + """ + + transactor = Transactor() + deployments = contracts_from_registry( + filepath=LYNX_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) diff --git a/scripts/lynx/deploy_beta_program.py b/scripts/lynx/deploy_bqeth.py similarity index 75% rename from scripts/lynx/deploy_beta_program.py rename to scripts/lynx/deploy_bqeth.py index d7ffe75e..51ab62f2 100644 --- a/scripts/lynx/deploy_beta_program.py +++ b/scripts/lynx/deploy_bqeth.py @@ -9,14 +9,19 @@ from deployment.registry import merge_registries VERIFY = False -CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "lynx" / "beta_program_initiator.yml" +CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "lynx" / "bqeth.yml" LYNX_REGISTRY = ARTIFACTS_DIR / "lynx.json" def main(): deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH, verify=VERIFY) - beta_program_initiator = deployer.deploy(project.BetaProgramInitiator) - deployments = [beta_program_initiator] + + global_allow_list = deployer.deploy(project.GlobalAllowList) + + bqeth_subscription = deployer.deploy(project.BqETHSubscription) + + deployments = [global_allow_list, bqeth_subscription] + deployer.finalize(deployments=deployments) merge_registries( registry_1_filepath=LYNX_REGISTRY, diff --git a/scripts/mainnet/deploy_beta_program.py b/scripts/mainnet/deploy_bqeth.py similarity index 77% rename from scripts/mainnet/deploy_beta_program.py rename to scripts/mainnet/deploy_bqeth.py index 27a009ac..4a9a464d 100644 --- a/scripts/mainnet/deploy_beta_program.py +++ b/scripts/mainnet/deploy_bqeth.py @@ -15,8 +15,13 @@ def main(): deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH, verify=VERIFY) - beta_program_initiator = deployer.deploy(project.BetaProgramInitiator) - deployments = [beta_program_initiator] + + global_allow_list = deployer.deploy(project.GlobalAllowList) + + bqeth_subscription = deployer.deploy(project.BqETHSubscription) + + deployments = [global_allow_list, bqeth_subscription] + deployer.finalize(deployments=deployments) merge_registries( registry_1_filepath=MAINNET_REGISTRY, diff --git a/scripts/tapir/deploy_beta_program.py b/scripts/tapir/deploy_beta_program.py deleted file mode 100644 index d6c55a10..00000000 --- a/scripts/tapir/deploy_beta_program.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/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" / "beta_program_initiator.yml" -TAPIR_REGISTRY = ARTIFACTS_DIR / "tapir.json" - - -def main(): - deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH, verify=VERIFY) - beta_program_initiator = deployer.deploy(project.BetaProgramInitiator) - deployments = [beta_program_initiator] - deployer.finalize(deployments=deployments) - merge_registries( - registry_1_filepath=TAPIR_REGISTRY, - registry_2_filepath=deployer.registry_filepath, - output_filepath=TAPIR_REGISTRY, - )