From 36088fb6c160df34f1d9e8a15d187052e47ca2e8 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Fri, 14 Jun 2024 12:52:02 +0200 Subject: [PATCH] Added additional getters to NeuroIncentivesPool, added ParanetIncentivesPoolFactory with separated deploy function --- abi/ParanetIncentivesPoolFactory.json | 200 +++++++++ abi/ParanetNeuroIncentivesPool.json | 237 +++++++++- contracts/v2/paranets/Paranet.sol | 3 +- .../paranets/ParanetIncentivesPoolFactory.sol | 110 +++++ .../paranets/ParanetNeuroIncentivesPool.sol | 216 +++++++--- .../v2/structs/paranets/ParanetStructs.sol | 5 + package-lock.json | 403 ++++++++---------- package.json | 2 +- 8 files changed, 877 insertions(+), 299 deletions(-) create mode 100644 abi/ParanetIncentivesPoolFactory.json create mode 100644 contracts/v2/paranets/ParanetIncentivesPoolFactory.sol diff --git a/abi/ParanetIncentivesPoolFactory.json b/abi/ParanetIncentivesPoolFactory.json new file mode 100644 index 00000000..c276757b --- /dev/null +++ b/abi/ParanetIncentivesPoolFactory.json @@ -0,0 +1,200 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "hubAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "knowledgeAssetStorageAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "string", + "name": "poolType", + "type": "string" + }, + { + "internalType": "address", + "name": "poolAddress", + "type": "address" + } + ], + "name": "ParanetIncentivesPoolAlreadyExists", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "paranetKAStorageContract", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "paranetKATokenId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "string", + "name": "poolType", + "type": "string" + }, + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "indexed": false, + "internalType": "struct ParanetStructs.IncentivesPool", + "name": "incentivesPool", + "type": "tuple" + } + ], + "name": "ParanetIncetivesPoolDeployed", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "paranetKAStorageContract", + "type": "address" + }, + { + "internalType": "uint256", + "name": "paranetKATokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "tracToNeuroEmissionMultiplier", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "paranetOperatorRewardPercentage", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "paranetIncentivizationProposalVotersRewardPercentage", + "type": "uint16" + } + ], + "name": "deployNeuroIncentivesPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "hub", + "outputs": [ + { + "internalType": "contract HubV2", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "paranetsRegistry", + "outputs": [ + { + "internalType": "contract ParanetsRegistry", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_status", + "type": "bool" + } + ], + "name": "setStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "status", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + } +] diff --git a/abi/ParanetNeuroIncentivesPool.json b/abi/ParanetNeuroIncentivesPool.json index 224e665e..288bf3eb 100644 --- a/abi/ParanetNeuroIncentivesPool.json +++ b/abi/ParanetNeuroIncentivesPool.json @@ -244,21 +244,38 @@ "type": "function" }, { - "inputs": [], - "name": "claimedMinersNeuro", - "outputs": [ + "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], + "name": "claimedMinerRewards", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "claimedNeuro", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [], - "name": "claimedOperatorNeuro", + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "claimedMinerRewardsIndexes", "outputs": [ { "internalType": "uint256", @@ -270,8 +287,38 @@ "type": "function" }, { - "inputs": [], - "name": "claimedVotersNeuro", + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "claimedOperatorRewards", + "outputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "claimedNeuro", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "claimedOperatorRewardsIndexes", "outputs": [ { "internalType": "uint256", @@ -302,6 +349,69 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "getAllRewardedMiners", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "claimedNeuro", + "type": "uint256" + } + ], + "internalType": "struct ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllRewardedOperators", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "claimedNeuro", + "type": "uint256" + } + ], + "internalType": "struct ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getClaimableAllKnowledgeMinersRewardAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "getClaimableAllProposalVotersRewardAmount", @@ -343,7 +453,7 @@ }, { "inputs": [], - "name": "getClaimableSingleProposalVoterRewardAmount", + "name": "getClaimableProposalVoterRewardAmount", "outputs": [ { "internalType": "uint256", @@ -416,6 +526,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "getTotalAllKnowledgeMinersIncentiveEstimation", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "getTotalAllProposalVotersIncentiveEstimation", @@ -457,7 +580,7 @@ }, { "inputs": [], - "name": "getTotalSingleProposalVoterIncentiveEstimation", + "name": "getTotalProposalVoterIncentiveEstimation", "outputs": [ { "internalType": "uint256", @@ -630,6 +753,25 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "minerAddress", + "type": "address" + } + ], + "name": "minerClaimedNeuro", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "name", @@ -685,6 +827,25 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "operatorAddress", + "type": "address" + } + ], + "name": "operatorClaimedNeuro", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "paranetIncentivizationProposalVotersRewardPercentage", @@ -763,6 +924,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "totalMinersClaimedNeuro", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "totalNeuroReceived", @@ -776,6 +950,32 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "totalOperatorsClaimedNeuro", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalVotersClaimedNeuro", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { @@ -815,6 +1015,25 @@ "stateMutability": "pure", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "voterAddress", + "type": "address" + } + ], + "name": "voterClaimedNeuro", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { diff --git a/contracts/v2/paranets/Paranet.sol b/contracts/v2/paranets/Paranet.sol index 17159920..984178eb 100644 --- a/contracts/v2/paranets/Paranet.sol +++ b/contracts/v2/paranets/Paranet.sol @@ -19,7 +19,6 @@ import {Versioned} from "../../v1/interface/Versioned.sol"; import {ContentAssetStructs} from "../../v1/structs/assets/ContentAssetStructs.sol"; import {ParanetStructs} from "../structs/paranets/ParanetStructs.sol"; import {ParanetErrors} from "../errors/paranets/ParanetErrors.sol"; -import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import {HASH_FUNCTION_ID} from "../../v1/constants/assets/ContentAssetConstants.sol"; @@ -69,7 +68,7 @@ contract Paranet is Named, Versioned, ContractStatusV2, Initializable { ); string private constant _NAME = "Paranet"; - string private constant _VERSION = "2.1.2"; + string private constant _VERSION = "2.1.3"; ParanetsRegistry public paranetsRegistry; ParanetServicesRegistry public paranetServicesRegistry; diff --git a/contracts/v2/paranets/ParanetIncentivesPoolFactory.sol b/contracts/v2/paranets/ParanetIncentivesPoolFactory.sol new file mode 100644 index 00000000..89be712a --- /dev/null +++ b/contracts/v2/paranets/ParanetIncentivesPoolFactory.sol @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.16; + +import {HubV2} from "../Hub.sol"; +import {ParanetsRegistry} from "../storage/paranets/ParanetsRegistry.sol"; +import {ParanetNeuroIncentivesPool} from "./ParanetNeuroIncentivesPool.sol"; +import {ContractStatusV2} from "../abstract/ContractStatus.sol"; +import {Initializable} from "../../v1/interface/Initializable.sol"; +import {Named} from "../../v1/interface/Named.sol"; +import {Versioned} from "../../v1/interface/Versioned.sol"; +import {ParanetStructs} from "../structs/paranets/ParanetStructs.sol"; +import {ParanetErrors} from "../errors/paranets/ParanetErrors.sol"; +import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; + +contract ParanetIncentivesPoolFactory is Named, Versioned, ContractStatusV2, Initializable { + event ParanetIncetivesPoolDeployed( + address indexed paranetKAStorageContract, + uint256 indexed paranetKATokenId, + ParanetStructs.IncentivesPool incentivesPool + ); + + string private constant _NAME = "ParanetIncentivesPoolFactory"; + string private constant _VERSION = "2.0.0"; + + ParanetsRegistry public paranetsRegistry; + + // solhint-disable-next-line no-empty-blocks + constructor(address hubAddress) ContractStatusV2(hubAddress) {} + + modifier onlyKnowledgeAssetOwner(address knowledgeAssetStorageContract, uint256 knowledgeAssetTokenId) { + _checkKnowledgeAssetOwner(knowledgeAssetStorageContract, knowledgeAssetTokenId); + _; + } + + function initialize() public onlyHubOwner { + paranetsRegistry = ParanetsRegistry(hub.getContractAddress("ParanetsRegistry")); + } + + function name() external pure virtual override returns (string memory) { + return _NAME; + } + + function version() external pure virtual override returns (string memory) { + return _VERSION; + } + + function deployNeuroIncentivesPool( + address paranetKAStorageContract, + uint256 paranetKATokenId, + uint256 tracToNeuroEmissionMultiplier, + uint16 paranetOperatorRewardPercentage, + uint16 paranetIncentivizationProposalVotersRewardPercentage + ) external onlyKnowledgeAssetOwner(paranetKAStorageContract, paranetKATokenId) returns (address) { + HubV2 h = hub; + ParanetsRegistry pr = paranetsRegistry; + + if ( + pr.hasIncentivesPoolByType( + keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)), + "Neuroweb" + ) + ) { + revert ParanetErrors.ParanetIncentivesPoolAlreadyExists( + paranetKAStorageContract, + paranetKATokenId, + "Neuroweb", + pr.getIncentivesPoolAddress( + keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)), + "Neuroweb" + ) + ); + } + + ParanetNeuroIncentivesPool incentivesPool = new ParanetNeuroIncentivesPool( + address(h), + h.getContractAddress("ParanetsRegistry"), + h.getContractAddress("ParanetKnowledgeMinersRegistry"), + keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)), + tracToNeuroEmissionMultiplier, + paranetOperatorRewardPercentage, + paranetIncentivizationProposalVotersRewardPercentage + ); + + pr.setIncentivesPoolAddress( + keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)), + "Neuroweb", + address(incentivesPool) + ); + + emit ParanetIncetivesPoolDeployed( + paranetKAStorageContract, + paranetKATokenId, + ParanetStructs.IncentivesPool({poolType: "Neuroweb", addr: address(incentivesPool)}) + ); + + return address(incentivesPool); + } + + function _checkKnowledgeAssetOwner( + address knowledgeAssetStorageContract, + uint256 knowledgeAssetTokenId + ) internal view virtual { + require(hub.isAssetStorage(knowledgeAssetStorageContract), "Given address isn't KA Storage"); + require( + IERC721(knowledgeAssetStorageContract).ownerOf(knowledgeAssetTokenId) == msg.sender, + "Caller isn't the owner of the KA" + ); + } +} diff --git a/contracts/v2/paranets/ParanetNeuroIncentivesPool.sol b/contracts/v2/paranets/ParanetNeuroIncentivesPool.sol index 6dfa4b9c..60310b9d 100644 --- a/contracts/v2/paranets/ParanetNeuroIncentivesPool.sol +++ b/contracts/v2/paranets/ParanetNeuroIncentivesPool.sol @@ -27,7 +27,7 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { event ParanetIncentivizationProposalVoterRewardClaimed(address indexed voter, uint256 amount); string private constant _NAME = "ParanetNeuroIncentivesPool"; - string private constant _VERSION = "2.1.1"; + string private constant _VERSION = "2.1.2"; HubV2 public hub; ParanetsRegistry public paranetsRegistry; @@ -57,9 +57,15 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { // Address which can set Voters list and update Total NEURO Emission multiplier address public votersRegistrar; - uint256 public claimedMinersNeuro; - uint256 public claimedOperatorNeuro; - uint256 public claimedVotersNeuro; + uint256 public totalMinersClaimedNeuro; + uint256 public totalOperatorsClaimedNeuro; + uint256 public totalVotersClaimedNeuro; + + ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile[] public claimedMinerRewards; + mapping(address => uint256) public claimedMinerRewardsIndexes; + + ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile[] public claimedOperatorRewards; + mapping(address => uint256) public claimedOperatorRewardsIndexes; ParanetStructs.ParanetIncentivizationProposalVoter[] public voters; mapping(address => uint256) public votersIndexes; @@ -144,7 +150,7 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { } function totalNeuroReceived() external view returns (uint256) { - return address(this).balance + claimedMinersNeuro + claimedOperatorNeuro + claimedVotersNeuro; + return address(this).balance + totalMinersClaimedNeuro + totalOperatorsClaimedNeuro + totalVotersClaimedNeuro; } function getNeuroBalance() external view returns (uint256) { @@ -159,6 +165,34 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { votersRegistrar = newRegistrar; } + function minerClaimedNeuro(address minerAddress) external view returns (uint256) { + return claimedMinerRewards[claimedMinerRewardsIndexes[minerAddress]].claimedNeuro; + } + + function getAllRewardedMiners() + external + view + returns (ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile[] memory) + { + return claimedMinerRewards; + } + + function operatorClaimedNeuro(address operatorAddress) external view returns (uint256) { + return claimedOperatorRewards[claimedOperatorRewardsIndexes[operatorAddress]].claimedNeuro; + } + + function getAllRewardedOperators() + external + view + returns (ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile[] memory) + { + return claimedOperatorRewards; + } + + function voterClaimedNeuro(address voterAddress) external view returns (uint256) { + return voters[votersIndexes[voterAddress]].claimedNeuro; + } + function addVoters( ParanetStructs.ParanetIncentivizationProposalVoterInput[] calldata voters_ ) external onlyVotersRegistrar { @@ -308,6 +342,16 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { paranetIncentivizationProposalVotersRewardPercentage)) / PERCENTAGE_SCALING_FACTOR; } + function getTotalAllKnowledgeMinersIncentiveEstimation() public view returns (uint256) { + return + _getIncentiveEstimation( + PERCENTAGE_SCALING_FACTOR - + paranetOperatorRewardPercentage - + paranetIncentivizationProposalVotersRewardPercentage, + totalMinersClaimedNeuro + ); + } + function getClaimableKnowledgeMinerRewardAmount() public view returns (uint256) { uint256 neuroReward = getTotalKnowledgeMinerIncentiveEstimation(); @@ -316,17 +360,34 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { // Following the example from the above, if we have 100 NEURO as a total reward, Miners should never get // more than 80 NEURO. minersRewardLimit = 80 NEURO uint256 minersRewardLimit = ((address(this).balance + - claimedMinersNeuro + - claimedOperatorNeuro + - claimedVotersNeuro) * + totalMinersClaimedNeuro + + totalOperatorsClaimedNeuro + + totalVotersClaimedNeuro) * (PERCENTAGE_SCALING_FACTOR - paranetOperatorRewardPercentage - paranetIncentivizationProposalVotersRewardPercentage)) / PERCENTAGE_SCALING_FACTOR; return - claimedMinersNeuro + neuroReward <= minersRewardLimit + totalMinersClaimedNeuro + neuroReward <= minersRewardLimit ? neuroReward - : minersRewardLimit - claimedMinersNeuro; + : minersRewardLimit - totalMinersClaimedNeuro; + } + + function getClaimableAllKnowledgeMinersRewardAmount() public view returns (uint256) { + uint256 neuroReward = getTotalAllKnowledgeMinersIncentiveEstimation(); + + uint256 minersRewardLimit = ((address(this).balance + + totalMinersClaimedNeuro + + totalOperatorsClaimedNeuro + + totalVotersClaimedNeuro) * + (PERCENTAGE_SCALING_FACTOR - + paranetOperatorRewardPercentage - + paranetIncentivizationProposalVotersRewardPercentage)) / PERCENTAGE_SCALING_FACTOR; + + return + totalMinersClaimedNeuro + neuroReward <= minersRewardLimit + ? neuroReward + : minersRewardLimit - totalMinersClaimedNeuro; } function claimKnowledgeMinerReward() external onlyParanetKnowledgeMiner { @@ -364,7 +425,18 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { ); pkmr.addCumulativeAwardedNeuro(msg.sender, parentParanetId, claimableNeuroReward); - claimedMinersNeuro += claimableNeuroReward; + if (claimedMinerRewards[claimedMinerRewardsIndexes[msg.sender]].addr != msg.sender) { + claimedMinerRewardsIndexes[msg.sender] = claimedMinerRewards.length; + claimedMinerRewards.push( + ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile({ + addr: msg.sender, + claimedNeuro: claimableNeuroReward + }) + ); + } else { + claimedMinerRewards[claimedMinerRewardsIndexes[msg.sender]].claimedNeuro += claimableNeuroReward; + } + totalMinersClaimedNeuro += claimableNeuroReward; payable(msg.sender).transfer(claimableNeuroReward); @@ -372,34 +444,21 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { } function getTotalParanetOperatorIncentiveEstimation() public view returns (uint256) { - uint256 effectiveNeuroEmissionMultiplier = getEffectiveNeuroEmissionMultiplier(block.timestamp); - uint96 cumulativeKnowledgeValueOperatorPart = (paranetsRegistry.getCumulativeKnowledgeValue(parentParanetId) * - paranetOperatorRewardPercentage) / PERCENTAGE_SCALING_FACTOR; - uint96 rewardedTracSpentOperatorPart = uint96( - (claimedOperatorNeuro * EMISSION_MULTIPLIER_SCALING_FACTOR) / effectiveNeuroEmissionMultiplier - ); - - if (cumulativeKnowledgeValueOperatorPart - rewardedTracSpentOperatorPart < TOKENS_DIGITS_DIFF) { - return 0; - } - - return - ((cumulativeKnowledgeValueOperatorPart * effectiveNeuroEmissionMultiplier) / - EMISSION_MULTIPLIER_SCALING_FACTOR) - claimedOperatorNeuro; + return _getIncentiveEstimation(paranetOperatorRewardPercentage, totalOperatorsClaimedNeuro); } function getClaimableParanetOperatorRewardAmount() public view returns (uint256) { uint256 neuroReward = getTotalParanetOperatorIncentiveEstimation(); uint256 operatorRewardLimit = ((address(this).balance + - claimedMinersNeuro + - claimedOperatorNeuro + - claimedVotersNeuro) * paranetOperatorRewardPercentage) / PERCENTAGE_SCALING_FACTOR; + totalMinersClaimedNeuro + + totalOperatorsClaimedNeuro + + totalVotersClaimedNeuro) * paranetOperatorRewardPercentage) / PERCENTAGE_SCALING_FACTOR; return - claimedOperatorNeuro + neuroReward <= operatorRewardLimit + totalOperatorsClaimedNeuro + neuroReward <= operatorRewardLimit ? neuroReward - : operatorRewardLimit - claimedOperatorNeuro; + : operatorRewardLimit - totalOperatorsClaimedNeuro; } function claimParanetOperatorReward() external onlyParanetOperator { @@ -409,31 +468,25 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { revert ParanetErrors.NoRewardAvailable(parentParanetId, msg.sender); } - claimedOperatorNeuro += claimableNeuroReward; + if (claimedOperatorRewards[claimedOperatorRewardsIndexes[msg.sender]].addr != msg.sender) { + claimedOperatorRewardsIndexes[msg.sender] = claimedOperatorRewards.length; + claimedOperatorRewards.push( + ParanetStructs.ParanetIncentivesPoolClaimedRewardsProfile({ + addr: msg.sender, + claimedNeuro: claimableNeuroReward + }) + ); + } else { + claimedOperatorRewards[claimedOperatorRewardsIndexes[msg.sender]].claimedNeuro += claimableNeuroReward; + } + totalOperatorsClaimedNeuro += claimableNeuroReward; payable(msg.sender).transfer(claimableNeuroReward); emit ParanetOperatorRewardClaimed(msg.sender, claimableNeuroReward); } - function getTotalAllProposalVotersIncentiveEstimation() public view returns (uint256) { - uint256 effectiveNeuroEmissionMultiplier = getEffectiveNeuroEmissionMultiplier(block.timestamp); - uint96 cumulativeKnowledgeValueVotersPart = (paranetsRegistry.getCumulativeKnowledgeValue(parentParanetId) * - paranetIncentivizationProposalVotersRewardPercentage) / PERCENTAGE_SCALING_FACTOR; - uint96 rewardedTracSpentVotersPart = uint96( - (claimedVotersNeuro * EMISSION_MULTIPLIER_SCALING_FACTOR) / effectiveNeuroEmissionMultiplier - ); - - if (cumulativeKnowledgeValueVotersPart - rewardedTracSpentVotersPart < TOKENS_DIGITS_DIFF) { - return 0; - } - - return - ((cumulativeKnowledgeValueVotersPart * effectiveNeuroEmissionMultiplier) / - EMISSION_MULTIPLIER_SCALING_FACTOR) - claimedVotersNeuro; - } - - function getTotalSingleProposalVoterIncentiveEstimation() public view returns (uint256) { + function getTotalProposalVoterIncentiveEstimation() public view returns (uint256) { uint256 effectiveNeuroEmissionMultiplier = getEffectiveNeuroEmissionMultiplier(block.timestamp); uint96 cumulativeKnowledgeValueSingleVoterPart = (((paranetsRegistry.getCumulativeKnowledgeValue( parentParanetId @@ -453,33 +506,38 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { EMISSION_MULTIPLIER_SCALING_FACTOR) - voters[votersIndexes[msg.sender]].claimedNeuro; } - function getClaimableAllProposalVotersRewardAmount() public view returns (uint256) { - uint256 neuroReward = getTotalAllProposalVotersIncentiveEstimation(); + function getTotalAllProposalVotersIncentiveEstimation() public view returns (uint256) { + return _getIncentiveEstimation(paranetIncentivizationProposalVotersRewardPercentage, totalVotersClaimedNeuro); + } - uint256 votersRewardLimit = ((address(this).balance + - claimedMinersNeuro + - claimedOperatorNeuro + - claimedVotersNeuro) * paranetIncentivizationProposalVotersRewardPercentage) / PERCENTAGE_SCALING_FACTOR; + function getClaimableProposalVoterRewardAmount() public view returns (uint256) { + uint256 neuroReward = getTotalProposalVoterIncentiveEstimation(); + + uint256 voterRewardLimit = ((((address(this).balance + + totalMinersClaimedNeuro + + totalOperatorsClaimedNeuro + + totalVotersClaimedNeuro) * paranetIncentivizationProposalVotersRewardPercentage) / + PERCENTAGE_SCALING_FACTOR) * voters[votersIndexes[msg.sender]].weight) / MAX_CUMULATIVE_VOTERS_WEIGHT; return - claimedVotersNeuro + neuroReward <= votersRewardLimit + voters[votersIndexes[msg.sender]].claimedNeuro + neuroReward <= voterRewardLimit ? neuroReward - : votersRewardLimit - claimedVotersNeuro; + : voterRewardLimit - voters[votersIndexes[msg.sender]].claimedNeuro; } - function getClaimableSingleProposalVoterRewardAmount() public view returns (uint256) { - uint256 neuroReward = getTotalSingleProposalVoterIncentiveEstimation(); + function getClaimableAllProposalVotersRewardAmount() public view returns (uint256) { + uint256 neuroReward = getTotalAllProposalVotersIncentiveEstimation(); - uint256 voterRewardLimit = ((((address(this).balance + - claimedMinersNeuro + - claimedOperatorNeuro + - claimedVotersNeuro) * paranetIncentivizationProposalVotersRewardPercentage) / PERCENTAGE_SCALING_FACTOR) * - voters[votersIndexes[msg.sender]].weight) / MAX_CUMULATIVE_VOTERS_WEIGHT; + uint256 votersRewardLimit = ((address(this).balance + + totalMinersClaimedNeuro + + totalOperatorsClaimedNeuro + + totalVotersClaimedNeuro) * paranetIncentivizationProposalVotersRewardPercentage) / + PERCENTAGE_SCALING_FACTOR; return - voters[votersIndexes[msg.sender]].claimedNeuro + neuroReward <= voterRewardLimit + totalVotersClaimedNeuro + neuroReward <= votersRewardLimit ? neuroReward - : voterRewardLimit - voters[votersIndexes[msg.sender]].claimedNeuro; + : votersRewardLimit - totalVotersClaimedNeuro; } function claimIncentivizationProposalVoterReward() external onlyParanetIncentivizationProposalVoter { @@ -491,20 +549,40 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { ); } - uint256 claimableNeuroReward = getClaimableSingleProposalVoterRewardAmount(); + uint256 claimableNeuroReward = getClaimableProposalVoterRewardAmount(); if (claimableNeuroReward == 0) { revert ParanetErrors.NoRewardAvailable(parentParanetId, msg.sender); } voters[votersIndexes[msg.sender]].claimedNeuro += claimableNeuroReward; - claimedVotersNeuro += claimableNeuroReward; + totalVotersClaimedNeuro += claimableNeuroReward; payable(msg.sender).transfer(claimableNeuroReward); emit ParanetIncentivizationProposalVoterRewardClaimed(msg.sender, claimableNeuroReward); } + function _getIncentiveEstimation( + uint16 rewardPercentage, + uint256 totalClaimedNeuro + ) internal view returns (uint256) { + uint256 effectiveNeuroEmissionMultiplier = getEffectiveNeuroEmissionMultiplier(block.timestamp); + uint96 cumulativeKnowledgeValuePart = (paranetsRegistry.getCumulativeKnowledgeValue(parentParanetId) * + rewardPercentage) / PERCENTAGE_SCALING_FACTOR; + uint96 rewardedTracSpentPart = uint96( + (totalClaimedNeuro * EMISSION_MULTIPLIER_SCALING_FACTOR) / effectiveNeuroEmissionMultiplier + ); + + if (cumulativeKnowledgeValuePart - rewardedTracSpentPart < TOKENS_DIGITS_DIFF) { + return 0; + } + + return + ((cumulativeKnowledgeValuePart * effectiveNeuroEmissionMultiplier) / EMISSION_MULTIPLIER_SCALING_FACTOR) - + totalClaimedNeuro; + } + function _checkHubOwner() internal view virtual { require(msg.sender == hub.owner(), "Fn can only be used by hub owner"); } @@ -514,7 +592,7 @@ contract ParanetNeuroIncentivesPool is Named, Versioned { } function _checkParanetOperator() internal view virtual { - require(isParanetOperator(msg.sender), "Caller isn't the owner of the Paranet Knowledge Asset"); + require(isParanetOperator(msg.sender), "Fn can only be used by operator"); } function _checkParanetIncentivizationProposalVoter() internal view virtual { diff --git a/contracts/v2/structs/paranets/ParanetStructs.sol b/contracts/v2/structs/paranets/ParanetStructs.sol index a587d471..a2419ec3 100644 --- a/contracts/v2/structs/paranets/ParanetStructs.sol +++ b/contracts/v2/structs/paranets/ParanetStructs.sol @@ -97,6 +97,11 @@ library ParanetStructs { bool finalized; } + struct ParanetIncentivesPoolClaimedRewardsProfile { + address addr; + uint256 claimedNeuro; + } + struct ParanetIncentivizationProposalVoterInput { address addr; uint96 weight; diff --git a/package-lock.json b/package-lock.json index 792017c5..a73cd185 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dkg-evm-module", - "version": "4.3.0", + "version": "4.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "dkg-evm-module", - "version": "4.3.0", + "version": "4.3.1", "license": "Apache-2.0", "dependencies": { "@openzeppelin/contracts": "^4.9.3", @@ -1717,9 +1717,9 @@ } }, "node_modules/@openzeppelin/contracts": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.3.tgz", - "integrity": "sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==" + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.6.tgz", + "integrity": "sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA==" }, "node_modules/@openzeppelin/test-helpers": { "version": "0.5.16", @@ -2852,17 +2852,18 @@ } }, "node_modules/@truffle/contract": { - "version": "4.6.29", - "resolved": "https://registry.npmjs.org/@truffle/contract/-/contract-4.6.29.tgz", - "integrity": "sha512-gbgmC2YdcSD4QGvx3GWGIVhyQxEPkChcC2a3D5d9aj2XfV3f6+FQw5PuL1wreA3I222ggZQqzbvMvhpp8gWs4Q==", + "version": "4.6.31", + "resolved": "https://registry.npmjs.org/@truffle/contract/-/contract-4.6.31.tgz", + "integrity": "sha512-s+oHDpXASnZosiCdzu+X1Tx5mUJUs1L1CYXIcgRmzMghzqJkaUFmR6NpNo7nJYliYbO+O9/aW8oCKqQ7rCHfmQ==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", "dev": true, "dependencies": { "@ensdomains/ensjs": "^2.1.0", - "@truffle/blockchain-utils": "^0.1.8", - "@truffle/contract-schema": "^3.4.15", - "@truffle/debug-utils": "^6.0.56", - "@truffle/error": "^0.2.1", - "@truffle/interface-adapter": "^0.5.36", + "@truffle/blockchain-utils": "^0.1.9", + "@truffle/contract-schema": "^3.4.16", + "@truffle/debug-utils": "^6.0.57", + "@truffle/error": "^0.2.2", + "@truffle/interface-adapter": "^0.5.37", "bignumber.js": "^7.2.1", "debug": "^4.3.1", "ethers": "^4.0.32", @@ -2871,6 +2872,9 @@ "web3-core-promievent": "1.10.0", "web3-eth-abi": "1.10.0", "web3-utils": "1.10.0" + }, + "engines": { + "node": "^16.20 || ^18.16 || >=20" } }, "node_modules/@truffle/contract-schema": { @@ -4626,21 +4630,6 @@ "npm": "1.2.8000 || >= 1.4.16" } }, - "node_modules/body-parser/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -4678,11 +4667,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -5712,9 +5701,9 @@ } }, "node_modules/cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true, "engines": { "node": ">= 0.6" @@ -6582,14 +6571,15 @@ } }, "node_modules/es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", "dev": true, "hasInstallScript": true, "dependencies": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", "next-tick": "^1.1.0" }, "engines": { @@ -7211,6 +7201,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "dev": true, + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esniff/node_modules/type": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", + "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==", + "dev": true + }, "node_modules/espree": { "version": "9.4.0", "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", @@ -7592,6 +7603,16 @@ "npm": ">=3" } }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dev": true, + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -7691,17 +7712,17 @@ } }, "node_modules/express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -7732,60 +7753,6 @@ "node": ">= 0.10.0" } }, - "node_modules/express/node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dev": true, - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/express/node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/express/node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", - "dev": true, - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/ext": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", @@ -7952,9 +7919,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -8043,9 +8010,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", @@ -8747,23 +8714,34 @@ } }, "node_modules/hardhat-deploy": { - "version": "0.11.25", - "resolved": "https://registry.npmjs.org/hardhat-deploy/-/hardhat-deploy-0.11.25.tgz", - "integrity": "sha512-ppSgrVE9A13YgTmf2PQGoyIs9o/jgJOMORrUP/rblU5K8mQ2YHWlPvkzZmP4h+SBW+tNmlnvSrf5K5DmMmExhw==", + "version": "0.11.45", + "resolved": "https://registry.npmjs.org/hardhat-deploy/-/hardhat-deploy-0.11.45.tgz", + "integrity": "sha512-aC8UNaq3JcORnEUIwV945iJuvBwi65tjHVDU3v6mOcqik7WAzHVCJ7cwmkkipsHrWysrB5YvGF1q9S1vIph83w==", "dependencies": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/contracts": "^5.7.0", + "@ethersproject/providers": "^5.7.2", + "@ethersproject/solidity": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wallet": "^5.7.0", "@types/qs": "^6.9.7", "axios": "^0.21.1", "chalk": "^4.1.2", "chokidar": "^3.5.2", "debug": "^4.3.2", "enquirer": "^2.3.6", - "ethers": "^5.5.3", + "ethers": "^5.7.0", "form-data": "^4.0.0", "fs-extra": "^10.0.0", "match-all": "^1.2.6", "murmur-128": "^0.2.1", "qs": "^6.9.4", - "zksync-web3": "^0.8.1" + "zksync-web3": "^0.14.3" } }, "node_modules/hardhat-deploy-ethers": { @@ -12374,9 +12352,9 @@ ] }, "node_modules/qs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", - "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "dependencies": { "side-channel": "^1.0.4" }, @@ -15496,9 +15474,9 @@ } }, "node_modules/undici": { - "version": "5.27.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.27.0.tgz", - "integrity": "sha512-l3ydWhlhOJzMVOYkymLykcRRXqbUaQriERtR70B9LzNkZ4bX52Fc8wbTDneMiwo8T+AemZXvXaTx+9o5ROxrXg==", + "version": "5.28.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", + "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", "dependencies": { "@fastify/busboy": "^2.0.0" }, @@ -16416,11 +16394,12 @@ } }, "node_modules/zksync-web3": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/zksync-web3/-/zksync-web3-0.8.1.tgz", - "integrity": "sha512-1A4aHPQ3MyuGjpv5X/8pVEN+MdZqMjfVmiweQSRjOlklXYu65wT9BGEOtCmMs5d3gIvLp4ssfTeuR5OCKOD2kw==", + "version": "0.14.4", + "resolved": "https://registry.npmjs.org/zksync-web3/-/zksync-web3-0.14.4.tgz", + "integrity": "sha512-kYehMD/S6Uhe1g434UnaMN+sBr9nQm23Ywn0EUP5BfQCsbjcr3ORuS68PosZw8xUTu3pac7G6YMSnNHk+fwzvg==", + "deprecated": "This package has been deprecated in favor of zksync-ethers@5.0.0", "peerDependencies": { - "ethers": "~5.7.0" + "ethers": "^5.7.0" } } }, @@ -17506,9 +17485,9 @@ } }, "@openzeppelin/contracts": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.3.tgz", - "integrity": "sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==" + "version": "4.9.6", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.6.tgz", + "integrity": "sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA==" }, "@openzeppelin/test-helpers": { "version": "0.5.16", @@ -18427,17 +18406,17 @@ } }, "@truffle/contract": { - "version": "4.6.29", - "resolved": "https://registry.npmjs.org/@truffle/contract/-/contract-4.6.29.tgz", - "integrity": "sha512-gbgmC2YdcSD4QGvx3GWGIVhyQxEPkChcC2a3D5d9aj2XfV3f6+FQw5PuL1wreA3I222ggZQqzbvMvhpp8gWs4Q==", + "version": "4.6.31", + "resolved": "https://registry.npmjs.org/@truffle/contract/-/contract-4.6.31.tgz", + "integrity": "sha512-s+oHDpXASnZosiCdzu+X1Tx5mUJUs1L1CYXIcgRmzMghzqJkaUFmR6NpNo7nJYliYbO+O9/aW8oCKqQ7rCHfmQ==", "dev": true, "requires": { "@ensdomains/ensjs": "^2.1.0", - "@truffle/blockchain-utils": "^0.1.8", - "@truffle/contract-schema": "^3.4.15", - "@truffle/debug-utils": "^6.0.56", - "@truffle/error": "^0.2.1", - "@truffle/interface-adapter": "^0.5.36", + "@truffle/blockchain-utils": "^0.1.9", + "@truffle/contract-schema": "^3.4.16", + "@truffle/debug-utils": "^6.0.57", + "@truffle/error": "^0.2.2", + "@truffle/interface-adapter": "^0.5.37", "bignumber.js": "^7.2.1", "debug": "^4.3.1", "ethers": "^4.0.32", @@ -19760,17 +19739,6 @@ "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" - }, - "dependencies": { - "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "requires": { - "side-channel": "^1.0.4" - } - } } }, "boolbase": { @@ -19804,11 +19772,11 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" } }, "brorand": { @@ -20601,9 +20569,9 @@ "dev": true }, "cookie": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", - "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "dev": true }, "cookie-signature": { @@ -21275,13 +21243,14 @@ } }, "es5-ext": { - "version": "0.10.62", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", - "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", "dev": true, "requires": { "es6-iterator": "^2.0.3", "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", "next-tick": "^1.1.0" } }, @@ -21738,6 +21707,26 @@ "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true }, + "esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "dev": true, + "requires": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "dependencies": { + "type": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", + "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==", + "dev": true + } + } + }, "espree": { "version": "9.4.0", "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", @@ -22071,6 +22060,16 @@ "strip-hex-prefix": "1.0.0" } }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "dev": true, + "requires": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, "event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -22142,17 +22141,17 @@ } }, "express": { - "version": "4.18.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", - "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dev": true, "requires": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.1", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -22178,49 +22177,6 @@ "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" - }, - "dependencies": { - "body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", - "dev": true, - "requires": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.11.0", - "raw-body": "2.5.1", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - } - }, - "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", - "dev": true, - "requires": { - "side-channel": "^1.0.4" - } - }, - "raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", - "dev": true, - "requires": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - } - } } }, "ext": { @@ -22355,9 +22311,9 @@ } }, "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "requires": { "to-regex-range": "^5.0.1" } @@ -22425,9 +22381,9 @@ } }, "follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==" }, "for-each": { "version": "0.3.3", @@ -23168,23 +23124,34 @@ } }, "hardhat-deploy": { - "version": "0.11.25", - "resolved": "https://registry.npmjs.org/hardhat-deploy/-/hardhat-deploy-0.11.25.tgz", - "integrity": "sha512-ppSgrVE9A13YgTmf2PQGoyIs9o/jgJOMORrUP/rblU5K8mQ2YHWlPvkzZmP4h+SBW+tNmlnvSrf5K5DmMmExhw==", + "version": "0.11.45", + "resolved": "https://registry.npmjs.org/hardhat-deploy/-/hardhat-deploy-0.11.45.tgz", + "integrity": "sha512-aC8UNaq3JcORnEUIwV945iJuvBwi65tjHVDU3v6mOcqik7WAzHVCJ7cwmkkipsHrWysrB5YvGF1q9S1vIph83w==", "requires": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/contracts": "^5.7.0", + "@ethersproject/providers": "^5.7.2", + "@ethersproject/solidity": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wallet": "^5.7.0", "@types/qs": "^6.9.7", "axios": "^0.21.1", "chalk": "^4.1.2", "chokidar": "^3.5.2", "debug": "^4.3.2", "enquirer": "^2.3.6", - "ethers": "^5.5.3", + "ethers": "^5.7.0", "form-data": "^4.0.0", "fs-extra": "^10.0.0", "match-all": "^1.2.6", "murmur-128": "^0.2.1", "qs": "^6.9.4", - "zksync-web3": "^0.8.1" + "zksync-web3": "^0.14.3" }, "dependencies": { "chalk": { @@ -25659,9 +25626,9 @@ "dev": true }, "qs": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", - "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "requires": { "side-channel": "^1.0.4" } @@ -28075,9 +28042,9 @@ } }, "undici": { - "version": "5.27.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.27.0.tgz", - "integrity": "sha512-l3ydWhlhOJzMVOYkymLykcRRXqbUaQriERtR70B9LzNkZ4bX52Fc8wbTDneMiwo8T+AemZXvXaTx+9o5ROxrXg==", + "version": "5.28.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", + "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", "requires": { "@fastify/busboy": "^2.0.0" } @@ -28826,9 +28793,9 @@ "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==" }, "zksync-web3": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/zksync-web3/-/zksync-web3-0.8.1.tgz", - "integrity": "sha512-1A4aHPQ3MyuGjpv5X/8pVEN+MdZqMjfVmiweQSRjOlklXYu65wT9BGEOtCmMs5d3gIvLp4ssfTeuR5OCKOD2kw==", + "version": "0.14.4", + "resolved": "https://registry.npmjs.org/zksync-web3/-/zksync-web3-0.14.4.tgz", + "integrity": "sha512-kYehMD/S6Uhe1g434UnaMN+sBr9nQm23Ywn0EUP5BfQCsbjcr3ORuS68PosZw8xUTu3pac7G6YMSnNHk+fwzvg==", "requires": {} } } diff --git a/package.json b/package.json index 00777daa..edc49a57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dkg-evm-module", - "version": "4.3.0", + "version": "4.3.1", "description": "Smart contracts for OriginTrail V6", "main": "index.ts", "files": [