@evvm/testnet-contracts 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +46 -521
  3. package/contracts/evvm/Evvm.sol +28 -31
  4. package/contracts/evvm/lib/ErrorsLib.sol +2 -1
  5. package/contracts/evvm/lib/EvvmStructs.sol +27 -1
  6. package/contracts/evvm/lib/SignatureUtils.sol +2 -5
  7. package/contracts/nameService/NameService.sol +118 -363
  8. package/contracts/nameService/lib/ErrorsLib.sol +1 -7
  9. package/contracts/nameService/lib/IdentityValidation.sol +182 -0
  10. package/contracts/nameService/lib/NameServiceStructs.sol +69 -0
  11. package/contracts/nameService/lib/SignatureUtils.sol +11 -4
  12. package/contracts/p2pSwap/P2PSwap.sol +41 -154
  13. package/contracts/p2pSwap/lib/P2PSwapStructs.sol +59 -0
  14. package/contracts/p2pSwap/lib/SignatureUtils.sol +1 -2
  15. package/contracts/staking/Estimator.sol +7 -6
  16. package/contracts/staking/Staking.sol +46 -146
  17. package/contracts/staking/lib/SignatureUtils.sol +1 -2
  18. package/contracts/staking/lib/StakingStructs.sol +94 -0
  19. package/contracts/treasury/Treasury.sol +18 -20
  20. package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +88 -35
  21. package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +81 -47
  22. package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +2 -0
  23. package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +3 -14
  24. package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +3 -7
  25. package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +5 -7
  26. package/interfaces/IEstimator.sol +7 -50
  27. package/interfaces/IEvvm.sol +16 -90
  28. package/interfaces/INameService.sol +37 -88
  29. package/interfaces/IP2PSwap.sol +19 -15
  30. package/interfaces/IStaking.sol +20 -50
  31. package/interfaces/ITreasury.sol +1 -4
  32. package/interfaces/ITreasuryExternalChainStation.sol +11 -15
  33. package/interfaces/ITreasuryHostChainStation.sol +7 -10
  34. package/library/Erc191TestBuilder.sol +0 -1
  35. package/library/EvvmService.sol +14 -78
  36. package/library/primitives/IERC20.sol +79 -0
  37. package/library/utils/GovernanceUtils.sol +81 -0
  38. package/library/utils/{service/AsyncNonceService.sol → nonces/AsyncNonce.sol} +9 -11
  39. package/library/utils/nonces/SyncNonce.sol +27 -0
  40. package/library/utils/service/EvvmPayments.sol +77 -0
  41. package/library/utils/service/StakingServiceUtils.sol +15 -20
  42. package/package.json +11 -13
  43. package/library/utils/service/MakeServicePaymentOnEvvm.sol +0 -49
  44. package/library/utils/service/SyncNonceService.sol +0 -18
@@ -0,0 +1,59 @@
1
+ // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
+ // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+
7
+ abstract contract P2PSwapStructs {
8
+ struct MarketInformation {
9
+ address tokenA;
10
+ address tokenB;
11
+ uint256 maxSlot;
12
+ uint256 ordersAvailable;
13
+ }
14
+
15
+ struct Order {
16
+ address seller;
17
+ uint256 amountA;
18
+ uint256 amountB;
19
+ }
20
+
21
+ struct OrderForGetter {
22
+ uint256 marketId;
23
+ uint256 orderId;
24
+ address seller;
25
+ uint256 amountA;
26
+ uint256 amountB;
27
+ }
28
+
29
+ struct Percentage {
30
+ uint256 seller;
31
+ uint256 service;
32
+ uint256 mateStaker;
33
+ }
34
+
35
+ struct MetadataMakeOrder {
36
+ uint256 nonce;
37
+ address tokenA;
38
+ address tokenB;
39
+ uint256 amountA;
40
+ uint256 amountB;
41
+ }
42
+
43
+ struct MetadataCancelOrder {
44
+ uint256 nonce;
45
+ address tokenA;
46
+ address tokenB;
47
+ uint256 orderId;
48
+ bytes signature;
49
+ }
50
+
51
+ struct MetadataDispatchOrder {
52
+ uint256 nonce;
53
+ address tokenA;
54
+ address tokenB;
55
+ uint256 orderId;
56
+ uint256 amountOfTokenBToFill;
57
+ bytes signature;
58
+ }
59
+ }
@@ -1,11 +1,10 @@
1
1
  // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
2
  // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
+ pragma solidity ^0.8.0;
3
4
 
4
5
  import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
5
6
  import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
6
7
 
7
- pragma solidity ^0.8.0;
8
-
9
8
  library SignatureUtils {
10
9
  /**
11
10
  * @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
@@ -16,6 +16,7 @@ MMMMMMMMMMMM
16
16
  */
17
17
 
18
18
  import {Staking} from "@evvm/testnet-contracts/contracts/staking/Staking.sol";
19
+ import {StakingStructs} from "@evvm/testnet-contracts/contracts/staking/lib/StakingStructs.sol";
19
20
  import {Evvm} from "@evvm/testnet-contracts/contracts/evvm/Evvm.sol";
20
21
 
21
22
  contract Estimator {
@@ -111,7 +112,7 @@ contract Estimator {
111
112
  uint256 sumSmT;
112
113
 
113
114
  uint256 tLast = epoch.tStart;
114
- Staking.HistoryMetadata memory h;
115
+ StakingStructs.HistoryMetadata memory h;
115
116
  uint256 size = Staking(addressStaking.actual).getSizeOfAddressHistory(
116
117
  _user
117
118
  );
@@ -180,7 +181,7 @@ contract Estimator {
180
181
  address _proposal
181
182
  ) external onlyActivator {
182
183
  activator.proposal = _proposal;
183
- activator.timeToAccept = block.timestamp + 1 minutes;
184
+ activator.timeToAccept = block.timestamp + 1 days;
184
185
  }
185
186
 
186
187
  function cancelActivatorProposal() external onlyActivator {
@@ -200,7 +201,7 @@ contract Estimator {
200
201
  address _proposal
201
202
  ) external onlyAdmin {
202
203
  evvmAddress.proposal = _proposal;
203
- evvmAddress.timeToAccept = block.timestamp + 1 minutes;
204
+ evvmAddress.timeToAccept = block.timestamp + 1 days;
204
205
  }
205
206
 
206
207
  function cancelEvvmAddressProposal() external onlyAdmin {
@@ -220,7 +221,7 @@ contract Estimator {
220
221
  address _proposal
221
222
  ) external onlyAdmin {
222
223
  addressStaking.proposal = _proposal;
223
- addressStaking.timeToAccept = block.timestamp + 1 minutes;
224
+ addressStaking.timeToAccept = block.timestamp + 1 days;
224
225
  }
225
226
 
226
227
  function cancelAddressStakingProposal() external onlyAdmin {
@@ -240,7 +241,7 @@ contract Estimator {
240
241
  address _proposal
241
242
  ) external onlyAdmin {
242
243
  admin.proposal = _proposal;
243
- admin.timeToAccept = block.timestamp + 1 minutes;
244
+ admin.timeToAccept = block.timestamp + 1 days;
244
245
  }
245
246
 
246
247
  function cancelAdminProposal() external onlyAdmin {
@@ -315,7 +316,7 @@ contract Estimator {
315
316
  uint256 sumSmT;
316
317
 
317
318
  uint256 tLast = epoch.tStart;
318
- Staking.HistoryMetadata memory h;
319
+ StakingStructs.HistoryMetadata memory h;
319
320
  uint256 size = Staking(addressStaking.actual).getSizeOfAddressHistory(
320
321
  _user
321
322
  );
@@ -41,101 +41,14 @@ pragma solidity ^0.8.0;
41
41
  * - Estimator integration for yield calculations
42
42
  */
43
43
 
44
- import {Evvm} from "@evvm/testnet-contracts/contracts/evvm/Evvm.sol";
45
- import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
46
- import {NameService} from "@evvm/testnet-contracts/contracts/nameService/NameService.sol";
47
- import {Estimator} from "@evvm/testnet-contracts/contracts/staking/Estimator.sol";
48
- import {ErrorsLib} from "@evvm/testnet-contracts/contracts/staking/lib/ErrorsLib.sol";
49
- import {SignatureUtils} from "@evvm/testnet-contracts/contracts/staking/lib/SignatureUtils.sol";
50
-
51
- contract Staking {
52
- /**
53
- * @dev Metadata for presale stakers
54
- * @param isAllow Whether the address is allowed to participate in presale staking
55
- * @param stakingAmount Current number of staking tokens staked (max 2 for presale)
56
- */
57
- struct presaleStakerMetadata {
58
- bool isAllow;
59
- uint256 stakingAmount;
60
- }
61
-
62
- /**
63
- * @dev Struct to store the history of the user
64
- * @param transactionType Type of transaction:
65
- * - 0x01 for staking
66
- * - 0x02 for unstaking
67
- * - Other values for yield/reward transactions
68
- * @param amount Amount of staking staked/unstaked or reward received
69
- * @param timestamp Timestamp when the transaction occurred
70
- * @param totalStaked Total amount of staking currently staked after this transaction
71
- */
72
- struct HistoryMetadata {
73
- bytes32 transactionType;
74
- uint256 amount;
75
- uint256 timestamp;
76
- uint256 totalStaked;
77
- }
78
-
79
- /**
80
- * @dev Struct for managing address change proposals with time delay
81
- * @param actual Current active address
82
- * @param proposal Proposed new address
83
- * @param timeToAccept Timestamp when the proposal can be accepted
84
- */
85
- struct AddressTypeProposal {
86
- address actual;
87
- address proposal;
88
- uint256 timeToAccept;
89
- }
90
-
91
- /**
92
- * @dev Struct for managing uint256 change proposals with time delay
93
- * @param actual Current active value
94
- * @param proposal Proposed new value
95
- * @param timeToAccept Timestamp when the proposal can be accepted
96
- */
97
- struct UintTypeProposal {
98
- uint256 actual;
99
- uint256 proposal;
100
- uint256 timeToAccept;
101
- }
102
-
103
- /**
104
- * @dev Struct for managing boolean flag changes with time delay
105
- * @param flag Current boolean state
106
- * @param timeToAccept Timestamp when the flag change can be executed
107
- */
108
- struct BoolTypeProposal {
109
- bool flag;
110
- uint256 timeToAccept;
111
- }
112
-
113
- /**
114
- * @dev Struct to store service staking metadata during the staking process
115
- * @param service Address of the service or contract account
116
- * @param timestamp Timestamp when the prepareServiceStaking was called
117
- * @param amountOfStaking Amount of staking tokens to be staked
118
- * @param amountServiceBeforeStaking Service's Principal Token balance before staking
119
- * @param amountStakingBeforeStaking Staking contract's Principal Token balance before staking
120
- */
121
- struct ServiceStakingMetadata {
122
- address service;
123
- uint256 timestamp;
124
- uint256 amountOfStaking;
125
- uint256 amountServiceBeforeStaking;
126
- uint256 amountStakingBeforeStaking;
127
- }
128
-
129
- /**
130
- * @dev Struct to encapsulate account metadata for staking operations
131
- * @param Address Address of the account
132
- * @param IsAService Boolean indicating if the account is a smart contract (service) account
133
- */
134
- struct AccountMetadata {
135
- address Address;
136
- bool IsAService;
137
- }
138
-
44
+ import {IEvvm} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
45
+ import {IEstimator} from "@evvm/testnet-contracts/interfaces/IEstimator.sol";
46
+ import {AsyncNonce} from "@evvm/testnet-contracts/library/utils/nonces/AsyncNonce.sol";
47
+ import {StakingStructs} from "@evvm/testnet-contracts/contracts/staking/lib/StakingStructs.sol";
48
+ import {ErrorsLib} from "./lib/ErrorsLib.sol";
49
+ import {SignatureUtils} from "./lib/SignatureUtils.sol";
50
+
51
+ contract Staking is AsyncNonce, StakingStructs {
139
52
  uint256 constant TIME_TO_ACCEPT_PROPOSAL = 1 days;
140
53
 
141
54
  /// @dev Address of the EVVM core contract
@@ -157,7 +70,7 @@ contract Staking {
157
70
  /// @dev Golden Fisher address management with proposal system
158
71
  AddressTypeProposal private goldenFisher;
159
72
  /// @dev Estimator contract address management with proposal system
160
- AddressTypeProposal private estimator;
73
+ AddressTypeProposal private estimatorAddress;
161
74
  /// @dev Time delay for regular staking after unstaking
162
75
  UintTypeProposal private secondsToUnlockStaking;
163
76
  /// @dev Time delay for full unstaking (21 days default)
@@ -172,15 +85,15 @@ contract Staking {
172
85
  /// @dev One-time setup breaker for estimator and EVVM addresses
173
86
  bytes1 private breakerSetupEstimatorAndEvvm;
174
87
 
175
- /// @dev Mapping to track used nonces for staking operations per user
176
- mapping(address => mapping(uint256 => bool)) private stakingNonce;
177
-
178
88
  /// @dev Mapping to store presale staker metadata
179
89
  mapping(address => presaleStakerMetadata) private userPresaleStaker;
180
90
 
181
91
  /// @dev Mapping to store complete staking history for each user
182
92
  mapping(address => HistoryMetadata[]) private userHistory;
183
93
 
94
+ IEvvm private evvm;
95
+ IEstimator private estimator;
96
+
184
97
  /// @dev Modifier to verify access to admin functions
185
98
  modifier onlyOwner() {
186
99
  if (msg.sender != admin.actual) revert ErrorsLib.SenderIsNotAdmin();
@@ -236,9 +149,11 @@ contract Staking {
236
149
  ) external {
237
150
  if (breakerSetupEstimatorAndEvvm == 0x00) revert();
238
151
 
239
- estimator.actual = _estimator;
152
+ estimatorAddress.actual = _estimator;
240
153
  EVVM_ADDRESS = _evvm;
241
154
  breakerSetupEstimatorAndEvvm = 0x00;
155
+ evvm = IEvvm(_evvm);
156
+ estimator = IEstimator(_estimator);
242
157
  }
243
158
 
244
159
  /**
@@ -261,7 +176,7 @@ contract Staking {
261
176
  isStaking,
262
177
  amountOfStaking,
263
178
  0,
264
- Evvm(EVVM_ADDRESS).getNextCurrentSyncNonce(msg.sender),
179
+ evvm.getNextCurrentSyncNonce(msg.sender),
265
180
  false,
266
181
  signature_EVVM
267
182
  );
@@ -291,7 +206,7 @@ contract Staking {
291
206
  ) external {
292
207
  if (
293
208
  !SignatureUtils.verifyMessageSignedForStake(
294
- Evvm(EVVM_ADDRESS).getEvvmID(),
209
+ evvm.getEvvmID(),
295
210
  user,
296
211
  false,
297
212
  isStaking,
@@ -301,8 +216,7 @@ contract Staking {
301
216
  )
302
217
  ) revert ErrorsLib.InvalidSignatureOnStaking();
303
218
 
304
- if (checkIfStakeNonceUsed(user, nonce))
305
- revert ErrorsLib.StakingNonceAlreadyUsed();
219
+ verifyAsyncNonce(user, nonce);
306
220
 
307
221
  presaleClaims(isStaking, user);
308
222
 
@@ -319,7 +233,7 @@ contract Staking {
319
233
  signature_EVVM
320
234
  );
321
235
 
322
- stakingNonce[user][nonce] = true;
236
+ markAsyncNonceAsUsed(user, nonce);
323
237
  }
324
238
 
325
239
  /**
@@ -384,7 +298,7 @@ contract Staking {
384
298
 
385
299
  if (
386
300
  !SignatureUtils.verifyMessageSignedForStake(
387
- Evvm(EVVM_ADDRESS).getEvvmID(),
301
+ evvm.getEvvmID(),
388
302
  user,
389
303
  true,
390
304
  isStaking,
@@ -394,8 +308,7 @@ contract Staking {
394
308
  )
395
309
  ) revert ErrorsLib.InvalidSignatureOnStaking();
396
310
 
397
- if (checkIfStakeNonceUsed(user, nonce))
398
- revert ErrorsLib.StakingNonceAlreadyUsed();
311
+ verifyAsyncNonce(user, nonce);
399
312
 
400
313
  stakingBaseProcess(
401
314
  AccountMetadata({Address: user, IsAService: false}),
@@ -407,7 +320,7 @@ contract Staking {
407
320
  signature_EVVM
408
321
  );
409
322
 
410
- stakingNonce[user][nonce] = true;
323
+ markAsyncNonceAsUsed(user, nonce);
411
324
  }
412
325
 
413
326
  /**
@@ -431,11 +344,11 @@ contract Staking {
431
344
  service: msg.sender,
432
345
  timestamp: block.timestamp,
433
346
  amountOfStaking: amountOfStaking,
434
- amountServiceBeforeStaking: Evvm(EVVM_ADDRESS).getBalance(
347
+ amountServiceBeforeStaking: evvm.getBalance(
435
348
  msg.sender,
436
349
  PRINCIPAL_TOKEN_ADDRESS
437
350
  ),
438
- amountStakingBeforeStaking: Evvm(EVVM_ADDRESS).getBalance(
351
+ amountStakingBeforeStaking: evvm.getBalance(
439
352
  address(this),
440
353
  PRINCIPAL_TOKEN_ADDRESS
441
354
  )
@@ -459,12 +372,12 @@ contract Staking {
459
372
  uint256 totalStakingRequired = PRICE_OF_STAKING *
460
373
  serviceStakingData.amountOfStaking;
461
374
 
462
- uint256 actualServiceBalance = Evvm(EVVM_ADDRESS).getBalance(
375
+ uint256 actualServiceBalance = evvm.getBalance(
463
376
  msg.sender,
464
377
  PRINCIPAL_TOKEN_ADDRESS
465
378
  );
466
379
 
467
- uint256 actualStakingBalance = Evvm(EVVM_ADDRESS).getBalance(
380
+ uint256 actualStakingBalance = evvm.getBalance(
468
381
  address(this),
469
382
  PRINCIPAL_TOKEN_ADDRESS
470
383
  );
@@ -559,7 +472,7 @@ contract Staking {
559
472
  signature_EVVM
560
473
  );
561
474
 
562
- Evvm(EVVM_ADDRESS).pointStaker(account.Address, 0x01);
475
+ evvm.pointStaker(account.Address, 0x01);
563
476
 
564
477
  auxSMsteBalance = userHistory[account.Address].length == 0
565
478
  ? amountOfStaking
@@ -573,7 +486,7 @@ contract Staking {
573
486
  block.timestamp
574
487
  ) revert ErrorsLib.AddressMustWaitToFullUnstake();
575
488
 
576
- Evvm(EVVM_ADDRESS).pointStaker(account.Address, 0x00);
489
+ evvm.pointStaker(account.Address, 0x00);
577
490
  }
578
491
 
579
492
  if (priorityFee_EVVM != 0 && !account.IsAService)
@@ -611,13 +524,13 @@ contract Staking {
611
524
  );
612
525
 
613
526
  if (
614
- Evvm(EVVM_ADDRESS).isAddressStaker(msg.sender) &&
527
+ evvm.isAddressStaker(msg.sender) &&
615
528
  !account.IsAService
616
529
  ) {
617
530
  makeCaPay(
618
531
  PRINCIPAL_TOKEN_ADDRESS,
619
532
  msg.sender,
620
- (Evvm(EVVM_ADDRESS).getRewardAmount() * 2) + priorityFee_EVVM
533
+ (evvm.getRewardAmount() * 2) + priorityFee_EVVM
621
534
  );
622
535
  }
623
536
  }
@@ -651,7 +564,7 @@ contract Staking {
651
564
  amountTotalToBeRewarded,
652
565
  idToOverwriteUserHistory,
653
566
  timestampToBeOverwritten
654
- ) = Estimator(estimator.actual).makeEstimation(user);
567
+ ) = estimator.makeEstimation(user);
655
568
 
656
569
  if (amountTotalToBeRewarded > 0) {
657
570
  makeCaPay(tokenToBeRewarded, user, amountTotalToBeRewarded);
@@ -663,11 +576,11 @@ contract Staking {
663
576
  userHistory[user][idToOverwriteUserHistory]
664
577
  .timestamp = timestampToBeOverwritten;
665
578
 
666
- if (Evvm(EVVM_ADDRESS).isAddressStaker(msg.sender)) {
579
+ if (evvm.isAddressStaker(msg.sender)) {
667
580
  makeCaPay(
668
581
  PRINCIPAL_TOKEN_ADDRESS,
669
582
  msg.sender,
670
- (Evvm(EVVM_ADDRESS).getRewardAmount() * 1)
583
+ (evvm.getRewardAmount() * 1)
671
584
  );
672
585
  }
673
586
  }
@@ -696,7 +609,7 @@ contract Staking {
696
609
  uint256 nonce,
697
610
  bytes memory signature
698
611
  ) internal {
699
- Evvm(EVVM_ADDRESS).pay(
612
+ evvm.pay(
700
613
  user,
701
614
  address(this),
702
615
  "",
@@ -722,7 +635,7 @@ contract Staking {
722
635
  address user,
723
636
  uint256 amount
724
637
  ) internal {
725
- Evvm(EVVM_ADDRESS).caPay(user, tokenAddress, amount);
638
+ evvm.caPay(user, tokenAddress, amount);
726
639
  }
727
640
 
728
641
  //▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
@@ -966,8 +879,8 @@ contract Staking {
966
879
  * @param _estimator Address of the proposed new estimator contract
967
880
  */
968
881
  function proposeEstimator(address _estimator) external onlyOwner {
969
- estimator.proposal = _estimator;
970
- estimator.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
882
+ estimatorAddress.proposal = _estimator;
883
+ estimatorAddress.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
971
884
  }
972
885
 
973
886
  /**
@@ -975,8 +888,8 @@ contract Staking {
975
888
  * @dev Only current admin can reject the pending estimator contract proposal
976
889
  */
977
890
  function rejectProposalEstimator() external onlyOwner {
978
- estimator.proposal = address(0);
979
- estimator.timeToAccept = 0;
891
+ estimatorAddress.proposal = address(0);
892
+ estimatorAddress.timeToAccept = 0;
980
893
  }
981
894
 
982
895
  /**
@@ -984,12 +897,13 @@ contract Staking {
984
897
  * @dev Can only be called by the current admin after the 1-day time delay
985
898
  */
986
899
  function acceptNewEstimator() external onlyOwner {
987
- if (estimator.timeToAccept > block.timestamp) {
900
+ if (estimatorAddress.timeToAccept > block.timestamp) {
988
901
  revert();
989
902
  }
990
- estimator.actual = estimator.proposal;
991
- estimator.proposal = address(0);
992
- estimator.timeToAccept = 0;
903
+ estimatorAddress.actual = estimatorAddress.proposal;
904
+ estimatorAddress.proposal = address(0);
905
+ estimatorAddress.timeToAccept = 0;
906
+ estimator = IEstimator(estimatorAddress.actual);
993
907
  }
994
908
 
995
909
  //▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
@@ -1124,20 +1038,6 @@ contract Staking {
1124
1038
  return userHistory[_account][lengthOfHistory - 1].totalStaked;
1125
1039
  }
1126
1040
 
1127
- /**
1128
- * @notice Checks if a specific nonce has been used for staking by a user
1129
- * @dev Prevents replay attacks by tracking used nonces
1130
- * @param _account Address to check the nonce for
1131
- * @param _nonce Nonce value to check
1132
- * @return True if the nonce has been used, false otherwise
1133
- */
1134
- function checkIfStakeNonceUsed(
1135
- address _account,
1136
- uint256 _nonce
1137
- ) public view returns (bool) {
1138
- return stakingNonce[_account][_nonce];
1139
- }
1140
-
1141
1041
  /**
1142
1042
  * @notice Returns the current golden fisher address
1143
1043
  * @dev The golden fisher has special staking privileges
@@ -1178,7 +1078,7 @@ contract Staking {
1178
1078
  * @return Address of the current estimator contract
1179
1079
  */
1180
1080
  function getEstimatorAddress() external view returns (address) {
1181
- return estimator.actual;
1081
+ return estimatorAddress.actual;
1182
1082
  }
1183
1083
 
1184
1084
  /**
@@ -1187,7 +1087,7 @@ contract Staking {
1187
1087
  * @return Address of the proposed estimator contract (zero address if none)
1188
1088
  */
1189
1089
  function getEstimatorProposal() external view returns (address) {
1190
- return estimator.proposal;
1090
+ return estimatorAddress.proposal;
1191
1091
  }
1192
1092
 
1193
1093
  /**
@@ -1,11 +1,10 @@
1
1
  // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
2
  // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
+ pragma solidity ^0.8.0;
3
4
 
4
5
  import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
5
6
  import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
6
7
 
7
- pragma solidity ^0.8.0;
8
-
9
8
  library SignatureUtils {
10
9
  /**
11
10
  * @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
@@ -0,0 +1,94 @@
1
+ // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
+ // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ abstract contract StakingStructs {
7
+ /**
8
+ * @dev Metadata for presale stakers
9
+ * @param isAllow Whether the address is allowed to participate in presale staking
10
+ * @param stakingAmount Current number of staking tokens staked (max 2 for presale)
11
+ */
12
+ struct presaleStakerMetadata {
13
+ bool isAllow;
14
+ uint256 stakingAmount;
15
+ }
16
+
17
+ /**
18
+ * @dev Struct to store the history of the user
19
+ * @param transactionType Type of transaction:
20
+ * - 0x01 for staking
21
+ * - 0x02 for unstaking
22
+ * - Other values for yield/reward transactions
23
+ * @param amount Amount of staking staked/unstaked or reward received
24
+ * @param timestamp Timestamp when the transaction occurred
25
+ * @param totalStaked Total amount of staking currently staked after this transaction
26
+ */
27
+ struct HistoryMetadata {
28
+ bytes32 transactionType;
29
+ uint256 amount;
30
+ uint256 timestamp;
31
+ uint256 totalStaked;
32
+ }
33
+
34
+ /**
35
+ * @dev Struct for managing address change proposals with time delay
36
+ * @param actual Current active address
37
+ * @param proposal Proposed new address
38
+ * @param timeToAccept Timestamp when the proposal can be accepted
39
+ */
40
+ struct AddressTypeProposal {
41
+ address actual;
42
+ address proposal;
43
+ uint256 timeToAccept;
44
+ }
45
+
46
+ /**
47
+ * @dev Struct for managing uint256 change proposals with time delay
48
+ * @param actual Current active value
49
+ * @param proposal Proposed new value
50
+ * @param timeToAccept Timestamp when the proposal can be accepted
51
+ */
52
+ struct UintTypeProposal {
53
+ uint256 actual;
54
+ uint256 proposal;
55
+ uint256 timeToAccept;
56
+ }
57
+
58
+ /**
59
+ * @dev Struct for managing boolean flag changes with time delay
60
+ * @param flag Current boolean state
61
+ * @param timeToAccept Timestamp when the flag change can be executed
62
+ */
63
+ struct BoolTypeProposal {
64
+ bool flag;
65
+ uint256 timeToAccept;
66
+ }
67
+
68
+ /**
69
+ * @dev Struct to store service staking metadata during the staking process
70
+ * @param service Address of the service or contract account
71
+ * @param timestamp Timestamp when the prepareServiceStaking was called
72
+ * @param amountOfStaking Amount of staking tokens to be staked
73
+ * @param amountServiceBeforeStaking Service's Principal Token balance before staking
74
+ * @param amountStakingBeforeStaking Staking contract's Principal Token balance before staking
75
+ */
76
+ struct ServiceStakingMetadata {
77
+ address service;
78
+ uint256 timestamp;
79
+ uint256 amountOfStaking;
80
+ uint256 amountServiceBeforeStaking;
81
+ uint256 amountStakingBeforeStaking;
82
+ }
83
+
84
+ /**
85
+ * @dev Struct to encapsulate account metadata for staking operations
86
+ * @param Address Address of the account
87
+ * @param IsAService Boolean indicating if the account is a smart contract (service) account
88
+ */
89
+ struct AccountMetadata {
90
+ address Address;
91
+ bool IsAService;
92
+ }
93
+
94
+ }