From 90c3b6dc2a9fe00f765176a007322c6a28dafca0 Mon Sep 17 00:00:00 2001 From: Dmitry Redkin Date: Tue, 25 Jun 2024 16:25:57 +0300 Subject: [PATCH] unlock in multiplier --- contracts/core/TokenAllocator.sol | 10 +++++----- .../ERC721/multipliers/AbstractERC721Multiplier.sol | 2 ++ contracts/interfaces/core/ITokenAllocator.sol | 2 +- contracts/mock/gov/GovPoolMock.sol | 2 ++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/contracts/core/TokenAllocator.sol b/contracts/core/TokenAllocator.sol index 455c7ee3..89917bfe 100644 --- a/contracts/core/TokenAllocator.sol +++ b/contracts/core/TokenAllocator.sol @@ -97,7 +97,7 @@ contract TokenAllocator is ITokenAllocator, AbstractDependant, MultiOwnable, UUP address token = allocation.token; _allocations[allocator][token].remove(id); - uint256 balance = allocation.amountToAllocate; + uint256 balance = allocation.balance; if (balance > 0) { IERC20(token).safeTransfer(allocator, balance); } @@ -117,8 +117,8 @@ contract TokenAllocator is ITokenAllocator, AbstractDependant, MultiOwnable, UUP address user = msg.sender; require(allocationInfo.claimed.add(user), "TA: already claimed"); - require(allocationInfo.amountToAllocate >= amount, "TA: insufficient funds"); - allocationInfo.amountToAllocate -= amount; + require(allocationInfo.balance >= amount, "TA: insufficient funds"); + allocationInfo.balance -= amount; bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(user, amount)))); bytes32 merkleRoot = allocationInfo.merkleRoot; @@ -176,7 +176,7 @@ contract TokenAllocator is ITokenAllocator, AbstractDependant, MultiOwnable, UUP allocation.isClosed, allocation.allocator, allocation.token, - allocation.amountToAllocate, + allocation.balance, allocation.merkleRoot, allocation.descriptionURL ); @@ -205,7 +205,7 @@ contract TokenAllocator is ITokenAllocator, AbstractDependant, MultiOwnable, UUP AllocationData storage allocationInfo = _allocationInfos[id]; allocationInfo.token = token; - allocationInfo.amountToAllocate = amount; + allocationInfo.balance = amount; allocationInfo.allocator = allocator; allocationInfo.merkleRoot = merkleRoot; allocationInfo.descriptionURL = descriptionURL; diff --git a/contracts/gov/ERC721/multipliers/AbstractERC721Multiplier.sol b/contracts/gov/ERC721/multipliers/AbstractERC721Multiplier.sol index 7a18c86d..0623aecd 100644 --- a/contracts/gov/ERC721/multipliers/AbstractERC721Multiplier.sol +++ b/contracts/gov/ERC721/multipliers/AbstractERC721Multiplier.sol @@ -61,6 +61,8 @@ abstract contract AbstractERC721Multiplier is _onlyTokenOwner(tokenId); + IGovPool(owner()).unlock(msg.sender); + require( IGovPool(owner()).getUserActiveProposalsCount(msg.sender) == 0, "ERC721Multiplier: Cannot unlock with active proposals" diff --git a/contracts/interfaces/core/ITokenAllocator.sol b/contracts/interfaces/core/ITokenAllocator.sol index e13538f8..b13a146f 100644 --- a/contracts/interfaces/core/ITokenAllocator.sol +++ b/contracts/interfaces/core/ITokenAllocator.sol @@ -10,7 +10,7 @@ interface ITokenAllocator { bool isClosed; address allocator; address token; - uint256 amountToAllocate; + uint256 balance; bytes32 merkleRoot; string descriptionURL; EnumerableSet.AddressSet claimed; diff --git a/contracts/mock/gov/GovPoolMock.sol b/contracts/mock/gov/GovPoolMock.sol index c9c80185..c5a10eb9 100644 --- a/contracts/mock/gov/GovPoolMock.sol +++ b/contracts/mock/gov/GovPoolMock.sol @@ -17,6 +17,8 @@ contract GovPoolMock { _votePowerContract = votePowerContract; } + function unlock(address user) external {} + function getHelperContracts() external view