Skip to content

Commit 08eaab7

Browse files
authored
Merge pull request #1 from smartnodes-lab/dao-payments
Implemented 3% DAO Reward Distribution
2 parents cb17627 + 565e450 commit 08eaab7

File tree

11 files changed

+344
-176
lines changed

11 files changed

+344
-176
lines changed

.DS_Store

-6 KB
Binary file not shown.

script/Deploy.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.22;
33

44
import {Script, console} from "forge-std/Script.sol";
55
import {SmartnodesCore} from "../src/SmartnodesCore.sol";
6-
import {SmartnodesToken} from "../src/SmartnodesToken.sol";
6+
import {SmartnodesERC20} from "../src/SmartnodesERC20.sol";
77
import {SmartnodesCoordinator} from "../src/SmartnodesCoordinator.sol";
88
import {SmartnodesDAO} from "../src/SmartnodesDAO.sol";
99

@@ -21,7 +21,7 @@ contract Deploy is Script {
2121

2222
vm.startBroadcast();
2323

24-
SmartnodesToken token = new SmartnodesToken(
24+
SmartnodesERC20 token = new SmartnodesERC20(
2525
DEPLOYMENT_MULTIPLIER,
2626
genesis
2727
);

src/SmartnodesCoordinator.sol

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity ^0.8.22;
33

44
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
55
import {ISmartnodesCore} from "./interfaces/ISmartnodesCore.sol";
6-
import {ISmartnodesToken} from "./interfaces/ISmartnodesToken.sol";
6+
import {ISmartnodesERC20} from "./interfaces/ISmartnodesERC20.sol";
77

88
/**
99
* @title SmartnodesCoordinator
@@ -31,7 +31,7 @@ contract SmartnodesCoordinator is ReentrancyGuard {
3131

3232
// ============= State Variables ==============
3333
ISmartnodesCore private immutable i_smartnodesCore;
34-
ISmartnodesToken private immutable i_smartnodesToken;
34+
ISmartnodesERC20 private immutable i_smartnodesToken;
3535
uint8 private immutable i_requiredApprovalsPercentage;
3636

3737
// Packed time-related variables
@@ -134,7 +134,7 @@ contract SmartnodesCoordinator is ReentrancyGuard {
134134
}
135135

136136
i_smartnodesCore = ISmartnodesCore(_smartnodesCore);
137-
i_smartnodesToken = ISmartnodesToken(_smartnodesToken);
137+
i_smartnodesToken = ISmartnodesERC20(_smartnodesToken);
138138
i_requiredApprovalsPercentage = _requiredApprovalsPercentage;
139139

140140
timeConfig = TimeConfig({
@@ -269,7 +269,6 @@ contract SmartnodesCoordinator is ReentrancyGuard {
269269

270270
// Verify proposal data integrity
271271
bytes32 computedHash = _computeProposalHash(
272-
proposalId,
273272
merkleRoot,
274273
validatorsToRemove,
275274
jobHashes,
@@ -557,7 +556,6 @@ contract SmartnodesCoordinator is ReentrancyGuard {
557556
}
558557

559558
function _computeProposalHash(
560-
uint8 proposalId,
561559
bytes32 merkleRoot,
562560
address[] calldata validatorsToRemove,
563561
bytes32[] calldata jobHashes,
@@ -567,7 +565,6 @@ contract SmartnodesCoordinator is ReentrancyGuard {
567565
return
568566
keccak256(
569567
abi.encode(
570-
proposalId,
571568
merkleRoot,
572569
validatorsToRemove,
573570
jobHashes,

src/SmartnodesCore.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pragma solidity ^0.8.22;
33

44
import {ISmartnodesCoordinator} from "./interfaces/ISmartnodesCoordinator.sol";
5-
import {ISmartnodesToken, PaymentAmounts} from "./interfaces/ISmartnodesToken.sol";
5+
import {ISmartnodesERC20, PaymentAmounts} from "./interfaces/ISmartnodesERC20.sol";
66

77
/**
88
* @title SmartnodesCore - Job Management System for Secure, Incentivised, Multi-Network P2P Resource Sharing
@@ -55,7 +55,7 @@ contract SmartnodesCore {
5555
/** Constants */
5656
uint24 private constant UNLOCK_PERIOD = 14 days;
5757

58-
ISmartnodesToken private immutable i_tokenContract;
58+
ISmartnodesERC20 private immutable i_tokenContract;
5959

6060
/** State Variables */
6161
ISmartnodesCoordinator private validatorContract;
@@ -83,7 +83,7 @@ contract SmartnodesCore {
8383
}
8484

8585
constructor(address _tokenContract) {
86-
i_tokenContract = ISmartnodesToken(_tokenContract);
86+
i_tokenContract = ISmartnodesERC20(_tokenContract);
8787
jobCounter = 0;
8888
}
8989

src/SmartnodesDAO.sol

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ contract SmartnodesDAO is ReentrancyGuard {
6767
bool queued;
6868
address[] targets;
6969
bytes[] calldatas;
70+
uint256[] values;
7071
string description;
7172
}
7273

@@ -137,6 +138,7 @@ contract SmartnodesDAO is ReentrancyGuard {
137138
function propose(
138139
address[] calldata targets,
139140
bytes[] calldata calldatas,
141+
uint256[] calldata values,
140142
string calldata description
141143
) external returns (uint256) {
142144
uint256 targetsLength = targets.length;
@@ -168,13 +170,9 @@ contract SmartnodesDAO is ReentrancyGuard {
168170
p.startTime = uint128(block.timestamp);
169171
p.endTime = uint128(block.timestamp + votingPeriod);
170172

171-
// Copy arrays
172-
p.targets = new address[](targetsLength);
173-
p.calldatas = new bytes[](targetsLength);
174-
for (uint256 i = 0; i < targetsLength; ++i) {
175-
p.targets[i] = targets[i];
176-
p.calldatas[i] = calldatas[i];
177-
}
173+
p.targets = targets;
174+
p.calldatas = calldatas;
175+
p.values = values;
178176
p.description = description;
179177

180178
emit ProposalCreated(
@@ -269,9 +267,10 @@ contract SmartnodesDAO is ReentrancyGuard {
269267
// Execute all calls
270268
uint256 targetsLength = p.targets.length;
271269
for (uint256 i = 0; i < targetsLength; ++i) {
272-
(bool success, bytes memory returnData) = p.targets[i].call(
273-
p.calldatas[i]
274-
);
270+
(bool success, bytes memory returnData) = p.targets[i].call{
271+
value: p.values[i]
272+
}(p.calldatas[i]);
273+
275274
if (!success) {
276275
// Handle revert reason
277276
if (returnData.length > 0) {

0 commit comments

Comments
 (0)