Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to use ERC20 Neuro for Knowledge Mining Incentivization #286

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions abi/ParanetIncentivesPoolFactory.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
},
{
"inputs": [
{
"internalType": "bool",
"name": "isNativeReward",
"type": "bool"
},
{
"internalType": "address",
"name": "paranetKAStorageContract",
Expand Down
71 changes: 51 additions & 20 deletions abi/ParanetNeuroIncentivesPool.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"name": "hubAddress",
"type": "address"
},
{
"internalType": "address",
"name": "rewardTokenAddress",
"type": "address"
},
{
"internalType": "address",
"name": "paranetsRegistryAddress",
Expand Down Expand Up @@ -81,19 +86,19 @@
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "oldMultiplier",
"type": "uint256"
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "newMultiplier",
"name": "amount",
"type": "uint256"
}
],
"name": "NeuroEmissionMultiplierUpdateFinalized",
"name": "NativeNeuroRewardDeposit",
"type": "event"
},
{
Expand All @@ -110,34 +115,34 @@
"internalType": "uint256",
"name": "newMultiplier",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
}
],
"name": "NeuroEmissionMultiplierUpdateInitiated",
"name": "NeuroEmissionMultiplierUpdateFinalized",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
"indexed": false,
"internalType": "uint256",
"name": "oldMultiplier",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"name": "newMultiplier",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
}
],
"name": "NeuroRewardDeposit",
"name": "NeuroEmissionMultiplierUpdateInitiated",
"type": "event"
},
{
Expand Down Expand Up @@ -213,7 +218,7 @@
}
],
"internalType": "struct ParanetStructs.ParanetIncentivizationProposalVoterInput[]",
"name": "voters_",
"name": "newVoters",
"type": "tuple[]"
}
],
Expand Down Expand Up @@ -715,6 +720,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "isNativeNeuro",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -924,6 +942,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "token",
"outputs": [
{
"internalType": "contract IERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalMinersClaimedNeuro",
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/constants/ParanetIncentivesPoolConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.16;

uint24 constant TOKENS_DIGITS_DIFF = 10 ** 6;
uint24 constant NATIVE_NEURO_DECIMALS_DIFF = 10 ** 6;
uint64 constant EMISSION_MULTIPLIER_SCALING_FACTOR = 10 ** 18;
uint16 constant PERCENTAGE_SCALING_FACTOR = 10 ** 4;
uint16 constant MAX_CUMULATIVE_VOTERS_WEIGHT = 10 ** 4;
13 changes: 8 additions & 5 deletions contracts/v2/paranets/ParanetIncentivesPoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ contract ParanetIncentivesPoolFactory is Named, Versioned, ContractStatusV2, Ini
}

function deployNeuroIncentivesPool(
bool isNativeReward,
address paranetKAStorageContract,
uint256 paranetKATokenId,
uint256 tracToNeuroEmissionMultiplier,
Expand All @@ -54,26 +55,28 @@ contract ParanetIncentivesPoolFactory is Named, Versioned, ContractStatusV2, Ini
) external onlyKnowledgeAssetOwner(paranetKAStorageContract, paranetKATokenId) returns (address) {
HubV2 h = hub;
ParanetsRegistry pr = paranetsRegistry;
string memory incentivesPoolType = isNativeReward ? "Neuroweb" : "NeurowebERC20";
u-hubar marked this conversation as resolved.
Show resolved Hide resolved

if (
pr.hasIncentivesPoolByType(
keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)),
"Neuroweb"
incentivesPoolType
)
) {
revert ParanetErrors.ParanetIncentivesPoolAlreadyExists(
paranetKAStorageContract,
paranetKATokenId,
"Neuroweb",
incentivesPoolType,
pr.getIncentivesPoolAddress(
keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)),
"Neuroweb"
incentivesPoolType
)
);
}

ParanetNeuroIncentivesPool incentivesPool = new ParanetNeuroIncentivesPool(
address(h),
isNativeReward ? address(0) : h.getContractAddress(incentivesPoolType),
h.getContractAddress("ParanetsRegistry"),
h.getContractAddress("ParanetKnowledgeMinersRegistry"),
keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)),
Expand All @@ -84,14 +87,14 @@ contract ParanetIncentivesPoolFactory is Named, Versioned, ContractStatusV2, Ini

pr.setIncentivesPoolAddress(
keccak256(abi.encodePacked(paranetKAStorageContract, paranetKATokenId)),
"Neuroweb",
incentivesPoolType,
address(incentivesPool)
);

emit ParanetIncetivesPoolDeployed(
paranetKAStorageContract,
paranetKATokenId,
ParanetStructs.IncentivesPool({poolType: "Neuroweb", addr: address(incentivesPool)})
ParanetStructs.IncentivesPool({poolType: incentivesPoolType, addr: address(incentivesPool)})
);

return address(incentivesPool);
Expand Down
Loading
Loading