diff --git a/lib/autonolas-registries b/lib/autonolas-registries index 5495a42..beebdc1 160000 --- a/lib/autonolas-registries +++ b/lib/autonolas-registries @@ -1 +1 @@ -Subproject commit 5495a42e95bad087567cef7baaf2baeba66dc1b9 +Subproject commit beebdc1c56eb19c8461d81ffca047a536ba6629e diff --git a/lib/forge-std b/lib/forge-std index 52715a2..c28115d 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 52715a217dc51d0de15877878ab8213f6cbbbab5 +Subproject commit c28115db8d90ebffb41953cf83aac63130f4bd40 diff --git a/scripts/deployment/deploy_00_basic_service_staking_activity_checker.js b/scripts/deployment/deploy_00_basic_service_staking_activity_checker.js new file mode 100644 index 0000000..054d68c --- /dev/null +++ b/scripts/deployment/deploy_00_basic_service_staking_activity_checker.js @@ -0,0 +1,87 @@ +/*global process*/ + +const { ethers } = require("hardhat"); +const { LedgerSigner } = require("@anders-t/ethers-ledger"); + +async function main() { + const fs = require("fs"); + const globalsFile = "globals.json"; + const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); + let parsedData = JSON.parse(dataFromJSON); + const useLedger = parsedData.useLedger; + const derivationPath = parsedData.derivationPath; + const providerName = parsedData.providerName; + const gasPriceInGwei = parsedData.gasPriceInGwei; + const livenessRatio = parsedData.livenessRatio; + + let networkURL = parsedData.networkURL; + if (providerName === "mainnet") { + if (!process.env.ALCHEMY_API_KEY_MAINNET) { + console.log("set ALCHEMY_API_KEY_MAINNET env variable"); + } + networkURL += process.env.ALCHEMY_API_KEY_MAINNET; + } else if (providerName === "sepolia") { + if (!process.env.ALCHEMY_API_KEY_SEPOLIA) { + console.log("set ALCHEMY_API_KEY_SEPOLIA env variable"); + return; + } + networkURL += process.env.ALCHEMY_API_KEY_SEPOLIA; + } else if (providerName === "polygon") { + if (!process.env.ALCHEMY_API_KEY_MATIC) { + console.log("set ALCHEMY_API_KEY_MATIC env variable"); + } + networkURL += process.env.ALCHEMY_API_KEY_MATIC; + } else if (providerName === "polygonAmoy") { + if (!process.env.ALCHEMY_API_KEY_AMOY) { + console.log("set ALCHEMY_API_KEY_AMOY env variable"); + return; + } + networkURL += process.env.ALCHEMY_API_KEY_AMOY; + } + + const provider = new ethers.providers.JsonRpcProvider(networkURL); + const signers = await ethers.getSigners(); + + let EOA; + if (useLedger) { + EOA = new LedgerSigner(provider, derivationPath); + } else { + EOA = signers[0]; + } + // EOA address + const deployer = await EOA.getAddress(); + console.log("EOA is:", deployer); + + // Transaction signing and execution + console.log("18. EOA to deploy StakingActivityChecker"); + const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); + const StakingActivityChecker = await ethers.getContractFactory("StakingActivityChecker"); + console.log("You are signing the following transaction: StakingActivityChecker.connect(EOA).deploy()"); + const stakingActivityChecker = await StakingActivityChecker.connect(EOA).deploy(livenessRatio, + { gasPrice }); + const result = await stakingActivityChecker.deployed(); + + // Transaction details + console.log("Contract deployment: StakingActivityChecker"); + console.log("Contract address:", stakingActivityChecker.address); + console.log("Transaction:", result.deployTransaction.hash); + // Wait half a minute for the transaction completion + await new Promise(r => setTimeout(r, 30000)); + + // Writing updated parameters back to the JSON file + parsedData.stakingActivityCheckerAddress = stakingActivityChecker.address; + fs.writeFileSync(globalsFile, JSON.stringify(parsedData)); + + // Contract verification + if (parsedData.contractVerification) { + const execSync = require("child_process").execSync; + execSync("npx hardhat verify --constructor-args scripts/deployment/l2/verify_18_service_staking_activity_checker.js --network " + providerName + " " + stakingActivityChecker.address, { encoding: "utf-8" }); + } +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployment/deploy_02_staking_token_instance.js b/scripts/deployment/deploy_02_staking_token_instance.js index 96b4ff1..0e00d8c 100644 --- a/scripts/deployment/deploy_02_staking_token_instance.js +++ b/scripts/deployment/deploy_02_staking_token_instance.js @@ -12,6 +12,7 @@ async function main() { const derivationPath = parsedData.derivationPath; const providerName = parsedData.providerName; const stakingParams = parsedData.stakingParams; + const gasPriceInGwei = parsedData.gasPriceInGwei; const serviceRegistryTokenUtilityAddress = parsedData.serviceRegistryTokenUtilityAddress; const olasAddress = parsedData.olasAddress; const stakingTokenAddress = parsedData.stakingTokenAddress; @@ -52,11 +53,14 @@ async function main() { // Transaction signing and execution console.log("21. EOA to deploy StakingTokenInstance via the StakingFactory"); console.log("You are signing the following transaction: StakingFactory.connect(EOA).createStakingInstance()"); + const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); const initPayload = stakingToken.interface.encodeFunctionData("initialize", [stakingParams, serviceRegistryTokenUtilityAddress, olasAddress]); - const stakingTokenInstanceAddress = await stakingFactory.callStatic.createStakingInstance(stakingTokenAddress, - initPayload); - const result = await stakingFactory.createStakingInstance(stakingTokenAddress, initPayload); + const result = await stakingFactory.createStakingInstance(stakingTokenAddress, initPayload, { gasPrice }); + let res = await result.wait(); + // Get staking contract instance address from the event + const stakingTokenInstanceAddress = "0x" + res.logs[0].topics[2].slice(26); + // Transaction details console.log("Contract deployment: StakingProxy"); diff --git a/scripts/deployment/deploy_03_staking_native_token_instance.js b/scripts/deployment/deploy_03_staking_native_token_instance.js index 9fcc05b..e575452 100644 --- a/scripts/deployment/deploy_03_staking_native_token_instance.js +++ b/scripts/deployment/deploy_03_staking_native_token_instance.js @@ -11,6 +11,7 @@ async function main() { const useLedger = parsedData.useLedger; const derivationPath = parsedData.derivationPath; const providerName = parsedData.providerName; + const gasPriceInGwei = parsedData.gasPriceInGwei; const stakingParams = parsedData.stakingParams; const stakingNativeTokenAddress = parsedData.stakingNativeTokenAddress; const stakingFactoryAddress = parsedData.stakingFactoryAddress; @@ -50,10 +51,12 @@ async function main() { // Transaction signing and execution console.log("22. EOA to deploy StakingNativeTokenInstance via the StakingFactory"); console.log("You are signing the following transaction: StakingFactory.connect(EOA).createStakingInstance()"); + const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei"); const initPayload = stakingNativeToken.interface.encodeFunctionData("initialize", [stakingParams]); - const stakingNativeTokenInstanceAddress = await stakingFactory.callStatic.createStakingInstance( - stakingNativeTokenAddress, initPayload); - const result = await stakingFactory.createStakingInstance(stakingNativeTokenAddress, initPayload); + const result = await stakingFactory.createStakingInstance(stakingNativeTokenAddress, initPayload, { gasPrice }); + let res = await result.wait(); + // Get staking contract instance address from the event + const stakingNativeTokenInstanceAddress = "0x" + res.logs[0].topics[2].slice(26); // Transaction details console.log("Contract deployment: StakingProxy"); diff --git a/scripts/deployment/globals_arbitrum_one.json b/scripts/deployment/globals_arbitrum_one.json new file mode 100644 index 0000000..947263c --- /dev/null +++ b/scripts/deployment/globals_arbitrum_one.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"arbitrumOne","networkURL":"https://arb1.arbitrum.io/rpc","gasPriceInGwei":"2","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0xE3607b00E75f6405248323A9417ff6b39B244b50","serviceRegistryTokenUtilityAddress":"0x3d77596beb0f130a4415df3D2D8232B3d3D31e44","olasAddress":"0x064F8B858C2A603e1b106a2039f5446D32dc81c1","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","stakingTokenAddress":"0x04b0007b2aFb398015B76e5f22993a1fddF83644","stakingNativeTokenAddress":"","stakingFactoryAddress":"0xEB5638eefE289691EcE01943f768EDBF96258a80","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"","stakingParams":{"metadataHash":"","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["14"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0xE3607b00E75f6405248323A9417ff6b39B244b50","activityChecker":""}} \ No newline at end of file diff --git a/scripts/deployment/globals_arbitrum_sepolia.json b/scripts/deployment/globals_arbitrum_sepolia.json new file mode 100644 index 0000000..293e0d9 --- /dev/null +++ b/scripts/deployment/globals_arbitrum_sepolia.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"arbitrumSepolia","networkURL":"https://sepolia-rollup.arbitrum.io/rpc","gasPriceInGwei":"1","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0x31D3202d8744B16A120117A053459DDFAE93c855","serviceRegistryTokenUtilityAddress":"0xeB49bE5DF00F74bd240DE4535DDe6Bc89CEfb994","olasAddress":"0x2AeD71638128A3811F5e5971a397fFe6A8587caa","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","stakingTokenAddress":"0xea930a028793FeBE9F6A2CFb62c95620dB91da71","stakingNativeTokenAddress":"0xA9D794548486D15BfbCe2b8b5F5518b739fa8A4b","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"","stakingFactoryAddress":"0xd64Cf67500b7d15A41E02DDeb40F3A73CB533eB5","stakingParams":{"metadataHash":"0x0000000000000000000000000000000000000000000000000000000000000001","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["12"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x31D3202d8744B16A120117A053459DDFAE93c855","activityChecker":""},"stakingTokenInstanceAddress":"","stakingNativeTokenInstanceAddress":""} \ No newline at end of file diff --git a/scripts/deployment/globals_base_mainnet.json b/scripts/deployment/globals_base_mainnet.json new file mode 100644 index 0000000..66660cb --- /dev/null +++ b/scripts/deployment/globals_base_mainnet.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"base","networkURL":"https://mainnet.base.org","gasPriceInGwei":"2","gnosisSafeAddress":"0x69f4D1788e39c87893C980c06EdF4b7f686e2938","gnosisSafeProxyFactoryAddress":"0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC","olasAddress":"0x54330d28ca3357F294334BDC454a032e7f353416","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistryAddress":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","serviceRegistryTokenUtilityAddress":"0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5","stakingTokenAddress":"0xEB5638eefE289691EcE01943f768EDBF96258a80","stakingNativeTokenAddress":"","stakingFactoryAddress":"0x1cEe30D08943EB58EFF84DD1AB44a6ee6FEff63a","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"","stakingParams":{"metadataHash":"","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["14"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","activityChecker":""}} \ No newline at end of file diff --git a/scripts/deployment/globals_base_sepolia.json b/scripts/deployment/globals_base_sepolia.json new file mode 100644 index 0000000..579ceb5 --- /dev/null +++ b/scripts/deployment/globals_base_sepolia.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"baseSepolia","networkURL":"https://sepolia.base.org","gasPriceInGwei":"2","gnosisSafeAddress":"0x69f4D1788e39c87893C980c06EdF4b7f686e2938","gnosisSafeProxyFactoryAddress":"0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC","olasAddress":"","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistryAddress":"0x31D3202d8744B16A120117A053459DDFAE93c855","serviceRegistryTokenUtilityAddress":"0xeB49bE5DF00F74bd240DE4535DDe6Bc89CEfb994","mechActivityCheckerAddress":""} \ No newline at end of file diff --git a/scripts/deployment/globals_celo_alfajores.json b/scripts/deployment/globals_celo_alfajores.json new file mode 100644 index 0000000..cb20b92 --- /dev/null +++ b/scripts/deployment/globals_celo_alfajores.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"celoAlfajores","networkURL":"https://alfajores-forno.celo-testnet.org","gasPriceInGwei":"10","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","olasAddress":"","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistryAddress":"0x31D3202d8744B16A120117A053459DDFAE93c855","serviceRegistryTokenUtilityAddress":"0xeB49bE5DF00F74bd240DE4535DDe6Bc89CEfb994","stakingParams":{"maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","livenessRatio":"700000000000000","numAgentInstances":"1","agentIds":["12"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000"},"stakingTokenAddress":"0x4cEB52802ef86edF8796632546d89e55c87a0901","stakingFactoryAddress":"0xaC26774616bbeD41b0CB69EA2ae7de366F430b23"} \ No newline at end of file diff --git a/scripts/deployment/globals_celo_mainnet.json b/scripts/deployment/globals_celo_mainnet.json new file mode 100644 index 0000000..6d7f45e --- /dev/null +++ b/scripts/deployment/globals_celo_mainnet.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"celo","networkURL":"https://forno.celo.org","gasPriceInGwei":"10","gnosisSafeAddress":"0x69f4D1788e39c87893C980c06EdF4b7f686e2938","gnosisSafeProxyFactoryAddress":"0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC","olasAddress":"0xaCFfAe8e57Ec6E394Eb1b41939A8CF7892DbDc51","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistryAddress":"0xE3607b00E75f6405248323A9417ff6b39B244b50","serviceRegistryTokenUtilityAddress":"0x3d77596beb0f130a4415df3D2D8232B3d3D31e44","stakingTokenAddress":"0xe1E1B286EbE95b39F785d8069f2248ae9C41b7a9","stakingNativeTokenAddress":"","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"","stakingFactoryAddress":"0x1c2cD884127b080F940b7546c1e9aaf525b1FA55","stakingParams":{"metadataHash":"0x0000000000000000000000000000000000000000000000000000000000000001","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["12"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0xE3607b00E75f6405248323A9417ff6b39B244b50","activityChecker":""},"stakingTokenInstanceAddress":"0x83839b36d41bdb44abfb6a52ef5549de9bbbb046"} \ No newline at end of file diff --git a/scripts/deployment/globals_ethereum_mainnet.json b/scripts/deployment/globals_ethereum_mainnet.json new file mode 100644 index 0000000..be6cecc --- /dev/null +++ b/scripts/deployment/globals_ethereum_mainnet.json @@ -0,0 +1,37 @@ +{ + "contractVerification": true, + "useLedger": true, + "derivationPath": "m/44'/60'/2'/0/0", + "providerName": "mainnet", + "networkURL": "https://eth-mainnet.g.alchemy.com/v2/", + "gasPriceInGwei": "15", + "serviceRegistryAddress": "0x48b6af7B12C71f09e2fC8aF4855De4Ff54e775cA", + "serviceRegistryTokenUtilityAddress": "0x3Fb926116D454b95c669B6Bf2E7c3bad8d19affA", + "olasAddress": "0x0001A500A6B18995B03f44bb040A5fFc28E45CB0", + "multisigProxyHash130": "0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000", + "stakingNativeTokenAddress":"", + "stakingTokenAddress":"0x0Dc23eEf3bC64CF3cbd8f9329B57AE4C4f28d5d2", + "agentMechAddress":"", + "livenessRatio":"700000000000000", + "mechActivityCheckerAddress":"", + "stakingActivityCheckerAddress":"", + "stakingFactoryAddress":"0xEBdde456EA288b49f7D5975E7659bA1Ccf607efc", + "stakingParams": + { + "metadataHash":"", + "maxNumServices":"100", + "rewardsPerSecond":"1000000000000000", + "minStakingDeposit":"50000000000000000000", + "minNumStakingPeriods":"3", + "maxNumInactivityPeriods":"3", + "livenessPeriod":"86400", + "timeForEmissions":"2592000", + "numAgentInstances":"1", + "agentIds":["12"], + "threshold":"0", + "configHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000", + "serviceRegistry":"0x48b6af7B12C71f09e2fC8aF4855De4Ff54e775cA", + "activityChecker":""}, + "stakingTokenInstanceAddress":"" +} diff --git a/scripts/deployment/globals_ethereum_sepolia.json b/scripts/deployment/globals_ethereum_sepolia.json new file mode 100644 index 0000000..2f337e2 --- /dev/null +++ b/scripts/deployment/globals_ethereum_sepolia.json @@ -0,0 +1,37 @@ +{ + "contractVerification": true, + "useLedger": false, + "derivationPath": "m/44'/60'/2'/0/0", + "providerName": "mainnet", + "networkURL": "https://eth-sepolia.g.alchemy.com/v2/", + "gasPriceInGwei": "30", + "serviceRegistryAddress": "", + "serviceRegistryTokenUtilityAddress": "", + "olasAddress": "0x0001A500A6B18995B03f44bb040A5fFc28E45CB0", + "multisigProxyHash130": "0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000", + "stakingNativeTokenAddress":"", + "stakingTokenAddress":"", + "agentMechAddress":"", + "livenessRatio":"700000000000000", + "mechActivityCheckerAddress":"", + "stakingActivityCheckerAddress":"", + "stakingFactoryAddress":"", + "stakingParams": + { + "metadataHash":"", + "maxNumServices":"100", + "rewardsPerSecond":"1000000000000000", + "minStakingDeposit":"50000000000000000000", + "minNumStakingPeriods":"3", + "maxNumInactivityPeriods":"3", + "livenessPeriod":"86400", + "timeForEmissions":"2592000", + "numAgentInstances":"1", + "agentIds":["12"], + "threshold":"0", + "configHash":"0x0000000000000000000000000000000000000000000000000000000000000000", + "proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000", + "serviceRegistry":"", + "activityChecker":""}, + "stakingTokenInstanceAddress":"" +} diff --git a/scripts/deployment/globals_gnosis_chiado.json b/scripts/deployment/globals_gnosis_chiado.json index cf4c4bc..59aa64f 100644 --- a/scripts/deployment/globals_gnosis_chiado.json +++ b/scripts/deployment/globals_gnosis_chiado.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"chiado","networkURL":"https://rpc.chiadochain.net","gasPriceInGwei":"5","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0x31D3202d8744B16A120117A053459DDFAE93c855","serviceRegistryTokenUtilityAddress":"0xc2c7E40674f1C7Bb99eFe5680Efd79842502bED4","olasAddress":"0xE40AE73aa0Ed3Ec35fdAF56e01FCd0D1Ff1d9AB6","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","stakingNativeTokenAddress":"0xAed729d4f4b895d8ca84ba022675bB0C44d2cD52","stakingTokenAddress":"0xf438a9a11902ffecfc2dA2f2224193C6AaBc6346","agentMechAddress":"0x0A3cFc6BEe9658Eda040e6BB366FE963DdCe82C9","livenessRatio":"700000000000000","mechActivityCheckerAddress":"0x7781202B9b09B92F512A0E343F24d349d09bc3A6","stakingVerifierAddress":"0x00000000000000000000000000000000000000000","stakingFactoryAddress":"0xbF6Dd5e87535b8766f4848DE1c13f8d4EDfA86C5","stakingParams":{"metadataHash":"0x0000000000000000000000000000000000000000000000000000000000000001","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"86400","numAgentInstances":"1","agentIds":["12"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x31D3202d8744B16A120117A053459DDFAE93c855","activityChecker":"0x7781202B9b09B92F512A0E343F24d349d09bc3A6"},"stakingTokenInstanceAddress":"0x3cbf58bcC16d9195c35E01aFE1A57caf257e113a","stakingNativeTokenInstanceAddress":"0x6F67efF5cb5C35a40CdE2eD570f0885fe7De7D6b"} \ No newline at end of file +{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"chiado","networkURL":"https://rpc.chiadochain.net","gasPriceInGwei":"5","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0x31D3202d8744B16A120117A053459DDFAE93c855","serviceRegistryTokenUtilityAddress":"0xc2c7E40674f1C7Bb99eFe5680Efd79842502bED4","olasAddress":"0xE40AE73aa0Ed3Ec35fdAF56e01FCd0D1Ff1d9AB6","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","stakingNativeTokenAddress":"","stakingTokenAddress":"0x00c3B912FF54B2a7E37D495a496f025D51fb8058","agentMechAddress":"0x0A3cFc6BEe9658Eda040e6BB366FE963DdCe82C9","livenessRatio":"700000000000000","mechActivityCheckerAddress":"0x7781202B9b09B92F512A0E343F24d349d09bc3A6","stakingFactoryAddress":"0xbF6Dd5e87535b8766f4848DE1c13f8d4EDfA86C5","stakingParams":{"metadataHash":"0x0000000000000000000000000000000000000000000000000000000000000001","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"2","livenessPeriod":"86400","timeForEmissions":"86400","numAgentInstances":"1","agentIds":["25"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x31D3202d8744B16A120117A053459DDFAE93c855","activityChecker":"0x7781202B9b09B92F512A0E343F24d349d09bc3A6"},"stakingTokenInstanceAddress":"","stakingNativeTokenInstanceAddress":""} \ No newline at end of file diff --git a/scripts/deployment/globals_gnosis_mainnet.json b/scripts/deployment/globals_gnosis_mainnet.json index 79054ef..6c90be1 100644 --- a/scripts/deployment/globals_gnosis_mainnet.json +++ b/scripts/deployment/globals_gnosis_mainnet.json @@ -1 +1 @@ -{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL":"https://rpc.gnosischain.com","gasPriceInGwei":"15","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","serviceRegistryTokenUtilityAddress":"0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8","olasAddress":"0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","stakingNativeTokenAddress":"","stakingTokenAddress":"0x9Ec97Be9FF55ff11606ce7c589956f7Bf3D0b241","agentMechAddress":"0x77af31De935740567Cf4fF1986D04B2c964A786a","livenessRatio":"46296296296296","mechActivityCheckerAddress":"0x155547857680A6D51bebC5603397488988DEb1c8","stakingVerifierAddress":"0x00000000000000000000000000000000000000000","stakingFactoryAddress":"0xC720f1Ada2a882a4B375dCCd0aAc3F3B3e58bc84","stakingParams":{"metadataHash":"0x888914090dd6dd2bc98e113d7558854e6be7ad06d1af180cac83aac61479059e","maxNumServices":"200","rewardsPerSecond":"549768518519","minStakingDeposit":"10000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"2","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["14"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","activityChecker":"0x155547857680A6D51bebC5603397488988DEb1c8"},"stakingTokenInstanceAddress":"0xEE9F19b5DF06c7E8Bfc7B28745dcf944C504198A"} \ No newline at end of file +{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"gnosis","networkURL":"https://rpc.gnosischain.com","gasPriceInGwei":"15","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","serviceRegistryTokenUtilityAddress":"0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8","olasAddress":"0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","stakingNativeTokenAddress":"","stakingTokenAddress":"0xEa00be6690a871827fAfD705440D20dd75e67AB1","agentMechAddress":"0x77af31De935740567Cf4fF1986D04B2c964A786a","livenessRatio":"46296296296296","mechActivityCheckerAddress":"0x155547857680A6D51bebC5603397488988DEb1c8","stakingFactoryAddress":"0xb0228CA253A88Bc8eb4ca70BCAC8f87b381f4700","stakingParams":{"metadataHash":"0x888914090dd6dd2bc98e113d7558854e6be7ad06d1af180cac83aac61479059e","maxNumServices":"100","rewardsPerSecond":"1649305555557","minStakingDeposit":"20000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"2","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["25"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x9338b5153AE39BB89f50468E608eD9d764B755fD","activityChecker":"0x155547857680A6D51bebC5603397488988DEb1c8"},"stakingTokenInstanceAddress":""} \ No newline at end of file diff --git a/scripts/deployment/globals_optimistic_mainnet.json b/scripts/deployment/globals_optimistic_mainnet.json new file mode 100644 index 0000000..cd59f08 --- /dev/null +++ b/scripts/deployment/globals_optimistic_mainnet.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"optimistic","networkURL":"https://mainnet.optimism.io","gasPriceInGwei":"2","gnosisSafeAddress":"0x69f4D1788e39c87893C980c06EdF4b7f686e2938","gnosisSafeProxyFactoryAddress":"0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC","olasAddress":"0xFC2E6e6BCbd49ccf3A5f029c79984372DcBFE527","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistryAddress":"0x3d77596beb0f130a4415df3D2D8232B3d3D31e44","serviceRegistryTokenUtilityAddress":"0xBb7e1D6Cb6F243D6bdE81CE92a9f2aFF7Fbe7eac","stakingTokenAddress":"0x63C2c53c09dE534Dd3bc0b7771bf976070936bAC","stakingNativeTokenAddress":"","stakingFactoryAddress":"0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"","stakingParams":{"metadataHash":"","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["14"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x3d77596beb0f130a4415df3D2D8232B3d3D31e44","activityChecker":""}} \ No newline at end of file diff --git a/scripts/deployment/globals_optimistic_sepolia.json b/scripts/deployment/globals_optimistic_sepolia.json new file mode 100644 index 0000000..729bf8d --- /dev/null +++ b/scripts/deployment/globals_optimistic_sepolia.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"optimisticSepolia","networkURL":"https://sepolia.optimism.io","gasPriceInGwei":"2","gnosisSafeAddress":"0x69f4D1788e39c87893C980c06EdF4b7f686e2938","gnosisSafeProxyFactoryAddress":"0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC","olasAddress":"0x01B8b6384298D4848E3BE63D4C9D17830EeE488A","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistryAddress":"0x31D3202d8744B16A120117A053459DDFAE93c855","serviceRegistryTokenUtilityAddress":"0xeB49bE5DF00F74bd240DE4535DDe6Bc89CEfb994","stakingTokenAddress":"0x57f3703D281Fd7b3896969086Cf14Aa6Ace99d92","stakingNativeTokenAddress":"0x87ecEccEDA41A6dF29FFC780c028510b3198DC74","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"0xf91962bEEF99cc53adD71Aa035CBEFF9Ec062728","stakingFactoryAddress":"0x3ac32cE492d2bDaf11C8f43Edc16FCa9b4b65675","stakingParams":{"metadataHash":"0x0000000000000000000000000000000000000000000000000000000000000001","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["12"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x31D3202d8744B16A120117A053459DDFAE93c855","activityChecker":""},"stakingTokenInstanceAddress":"0xCae661c929EC23e695e904d871C8D623f83bAC38","stakingNativeTokenInstanceAddress":"0xaa2d979ff7890aef3c436cefd9a486bee88363b0"} \ No newline at end of file diff --git a/scripts/deployment/globals_polygon_amoy.json b/scripts/deployment/globals_polygon_amoy.json new file mode 100644 index 0000000..09cc345 --- /dev/null +++ b/scripts/deployment/globals_polygon_amoy.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":false,"derivationPath":"m/44'/60'/2'/0/0","providerName":"polygonAmoy","networkURL":"https://polygon-amoy.g.alchemy.com/v2/","gasPriceInGwei":"40","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0x31D3202d8744B16A120117A053459DDFAE93c855","serviceRegistryTokenUtilityAddress":"0xeB49bE5DF00F74bd240DE4535DDe6Bc89CEfb994","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","olasAddress":"0xeCD870085AA3bab4aE12F675811122da4173C6a9","stakingTokenAddress":"0x945550dECe7E40ae70C6ebf5699637927eAF13E9","stakingNativeTokenAddress":"0x34235f9D447f9F54167e2Ac7A0F4283cB3fAD669","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"0x94676070018ff7D09BC32DAc6bb01Ae67282b8E8","stakingFactoryAddress":"0xc2c7E40674f1C7Bb99eFe5680Efd79842502bED4","stakingParams":{"metadataHash":"0x0000000000000000000000000000000000000000000000000000000000000001","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["12"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0x31D3202d8744B16A120117A053459DDFAE93c855","activityChecker":""},"stakingTokenInstanceAddress":"0xa28327f6b308f1a04e565025400311f48275c0fc","stakingNativeTokenInstanceAddress":"0xd76bc6aa871643a0aa87f5985f1e7ffda7b19eea"} \ No newline at end of file diff --git a/scripts/deployment/globals_polygon_mainnet.json b/scripts/deployment/globals_polygon_mainnet.json new file mode 100644 index 0000000..d219b13 --- /dev/null +++ b/scripts/deployment/globals_polygon_mainnet.json @@ -0,0 +1 @@ +{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"polygon","networkURL":"https://polygon-mainnet.g.alchemy.com/v2/","gasPriceInGwei":"100","gnosisSafeAddress":"0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552","gnosisSafeProxyFactoryAddress":"0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2","serviceRegistryAddress":"0xE3607b00E75f6405248323A9417ff6b39B244b50","multisigProxyHash130":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","olasAddress":"0xFEF5d947472e72Efbb2E388c730B7428406F2F95","serviceRegistryTokenUtilityAddress":"0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8","stakingTokenAddress":"0x4aba1Cf7a39a51D75cBa789f5f21cf4882162519","stakingNativeTokenAddress":"","stakingFactoryAddress":"0x46C0D07F55d4F9B5Eed2Fc9680B5953e5fd7b461","agentMechAddress":"","livenessRatio":"700000000000000","mechActivityCheckerAddress":"","stakingActivityCheckerAddress":"","stakingParams":{"metadataHash":"","maxNumServices":"100","rewardsPerSecond":"1000000000000000","minStakingDeposit":"50000000000000000000","minNumStakingPeriods":"3","maxNumInactivityPeriods":"3","livenessPeriod":"86400","timeForEmissions":"2592000","numAgentInstances":"1","agentIds":["14"],"threshold":"0","configHash":"0x0000000000000000000000000000000000000000000000000000000000000000","proxyHash":"0xb89c1b3bdf2cf8827818646bce9a8f6e372885f8c55e5c07acbd307cb133b000","serviceRegistry":"0xE3607b00E75f6405248323A9417ff6b39B244b50","activityChecker":""}} \ No newline at end of file diff --git a/scripts/deployment/verify_00_basic_service_staking_activity_checker.js b/scripts/deployment/verify_00_basic_service_staking_activity_checker.js new file mode 100644 index 0000000..3cb52a0 --- /dev/null +++ b/scripts/deployment/verify_00_basic_service_staking_activity_checker.js @@ -0,0 +1,9 @@ +const fs = require("fs"); +const globalsFile = "globals.json"; +const dataFromJSON = fs.readFileSync(globalsFile, "utf8"); +const parsedData = JSON.parse(dataFromJSON); +const livenessRatio = parsedData.livenessRatio; + +module.exports = [ + livenessRatio +]; \ No newline at end of file diff --git a/test/StakingMechUsage.js b/test/StakingMechUsage.js index a902991..f3a8a57 100644 --- a/test/StakingMechUsage.js +++ b/test/StakingMechUsage.js @@ -120,18 +120,20 @@ describe("StakingMechUsage", function () { stakingImplementation = await StakingNativeToken.deploy(); let initPayload = stakingImplementation.interface.encodeFunctionData("initialize", [serviceParams]); - const stakingAddress = await stakingFactory.callStatic.createStakingInstance( - stakingImplementation.address, initPayload); - await stakingFactory.createStakingInstance(stakingImplementation.address, initPayload); + let tx = await stakingFactory.createStakingInstance(stakingImplementation.address, initPayload); + let res = await tx.wait(); + // Get staking contract instance address from the event + const stakingAddress = "0x" + res.logs[0].topics[2].slice(26); stakingNativeToken = await ethers.getContractAt("StakingNativeToken", stakingAddress); const StakingToken = await ethers.getContractFactory("StakingToken"); stakingTokenImplementation = await StakingToken.deploy(); initPayload = stakingTokenImplementation.interface.encodeFunctionData("initialize", [serviceParams, serviceRegistryTokenUtility.address, token.address]); - const stakingTokenAddress = await stakingFactory.callStatic.createStakingInstance( - stakingTokenImplementation.address, initPayload); - await stakingFactory.createStakingInstance(stakingTokenImplementation.address, initPayload); + tx = await stakingFactory.createStakingInstance(stakingTokenImplementation.address, initPayload); + res = await tx.wait(); + // Get staking contract instance address from the event + const stakingTokenAddress = "0x" + res.logs[0].topics[2].slice(26); stakingToken = await ethers.getContractAt("StakingToken", stakingTokenAddress); // Set the deployer to be the unit manager by default diff --git a/test/StakingMechUsages.t.sol b/test/StakingMechUsages.t.sol index 646e159..c12b799 100644 --- a/test/StakingMechUsages.t.sol +++ b/test/StakingMechUsages.t.sol @@ -53,8 +53,8 @@ contract BaseSetup is Test { uint256 internal largeApproval = 1_000_000_000 ether; uint256 internal oneYear = 365 * 24 * 3600; uint32 internal threshold = 1; - uint96 internal regBond = 1000; - uint256 internal regDeposit = 1000; + uint96 internal regBond = 10 ether; + uint256 internal regDeposit = 10 ether; uint256 internal numDays = 10; bytes32 internal unitHash = 0x9999999999999999999999999999999999999999999999999999999999999999; @@ -64,9 +64,11 @@ contract BaseSetup is Test { // Maximum number of staking services uint256 internal maxNumServices = 10; // Rewards per second - uint256 internal rewardsPerSecond = 0.0001 ether; + uint256 internal rewardsPerSecond = 549768518519; // Minimum service staking deposit value required for staking uint256 internal minStakingDeposit = regDeposit; + // APY limit + uint256 internal apyLimit = 2 ether; // Min number of staking periods before the service can be unstaked uint256 internal minNumStakingPeriods = 3; // Max number of accumulated inactivity periods after which the service is evicted @@ -123,7 +125,8 @@ contract BaseSetup is Test { agentMech = new MockAgentMech(); // Deploy service staking verifier - stakingVerifier = new StakingVerifier(address(token), rewardsPerSecond, timeForEmissions, maxNumServices); + stakingVerifier = new StakingVerifier(address(token), address(serviceRegistry), + address(serviceRegistryTokenUtility), minStakingDeposit, timeForEmissions, maxNumServices, apyLimit); // Deploy service staking factory stakingFactory = new StakingFactory(address(0));