@evvm/testnet-contracts 2.3.0 → 3.0.1

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 (67) hide show
  1. package/README.md +44 -24
  2. package/contracts/core/Core.sol +1392 -0
  3. package/contracts/core/lib/CoreStorage.sol +171 -0
  4. package/contracts/nameService/NameService.sol +613 -543
  5. package/contracts/nameService/lib/IdentityValidation.sol +15 -21
  6. package/contracts/p2pSwap/P2PSwap.sol +258 -145
  7. package/contracts/staking/Estimator.sol +25 -44
  8. package/contracts/staking/Staking.sol +284 -262
  9. package/contracts/treasury/Treasury.sol +40 -47
  10. package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +585 -198
  11. package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +425 -174
  12. package/contracts/treasuryTwoChains/lib/PayloadUtils.sol +2 -4
  13. package/interfaces/{IEvvm.sol → ICore.sol} +58 -25
  14. package/interfaces/IEstimator.sol +1 -1
  15. package/interfaces/INameService.sol +46 -49
  16. package/interfaces/IP2PSwap.sol +16 -17
  17. package/interfaces/IStaking.sol +21 -17
  18. package/interfaces/ITreasury.sol +2 -1
  19. package/interfaces/ITreasuryExternalChainStation.sol +15 -9
  20. package/interfaces/ITreasuryHostChainStation.sol +14 -11
  21. package/interfaces/IUserValidator.sol +6 -0
  22. package/library/Erc191TestBuilder.sol +336 -471
  23. package/library/EvvmService.sol +27 -71
  24. package/library/errors/CoreError.sol +116 -0
  25. package/library/errors/CrossChainTreasuryError.sol +36 -0
  26. package/library/errors/NameServiceError.sol +79 -0
  27. package/library/errors/StakingError.sol +79 -0
  28. package/{contracts/treasury/lib/ErrorsLib.sol → library/errors/TreasuryError.sol} +9 -17
  29. package/library/structs/CoreStructs.sol +146 -0
  30. package/library/structs/ExternalChainStationStructs.sol +92 -0
  31. package/library/structs/HostChainStationStructs.sol +77 -0
  32. package/library/structs/NameServiceStructs.sol +47 -0
  33. package/library/structs/P2PSwapStructs.sol +127 -0
  34. package/library/structs/StakingStructs.sol +67 -0
  35. package/library/utils/AdvancedStrings.sol +62 -44
  36. package/library/utils/CAUtils.sol +29 -0
  37. package/library/utils/governance/Admin.sol +66 -0
  38. package/library/utils/governance/ProposalStructs.sol +49 -0
  39. package/library/utils/service/CoreExecution.sol +158 -0
  40. package/library/utils/service/StakingServiceUtils.sol +20 -37
  41. package/library/utils/signature/CoreHashUtils.sol +73 -0
  42. package/library/utils/signature/NameServiceHashUtils.sol +156 -0
  43. package/library/utils/signature/P2PSwapHashUtils.sol +65 -0
  44. package/library/utils/signature/StakingHashUtils.sol +41 -0
  45. package/library/utils/signature/TreasuryCrossChainHashUtils.sol +40 -0
  46. package/package.json +1 -1
  47. package/contracts/evvm/Evvm.sol +0 -1300
  48. package/contracts/evvm/lib/ErrorsLib.sol +0 -131
  49. package/contracts/evvm/lib/EvvmStorage.sol +0 -217
  50. package/contracts/evvm/lib/EvvmStructs.sol +0 -208
  51. package/contracts/evvm/lib/SignatureUtils.sol +0 -162
  52. package/contracts/nameService/lib/ErrorsLib.sol +0 -155
  53. package/contracts/nameService/lib/NameServiceStructs.sol +0 -125
  54. package/contracts/nameService/lib/SignatureUtils.sol +0 -420
  55. package/contracts/p2pSwap/lib/P2PSwapStructs.sol +0 -59
  56. package/contracts/p2pSwap/lib/SignatureUtils.sol +0 -98
  57. package/contracts/staking/lib/ErrorsLib.sol +0 -98
  58. package/contracts/staking/lib/SignatureUtils.sol +0 -105
  59. package/contracts/staking/lib/StakingStructs.sol +0 -106
  60. package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +0 -48
  61. package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +0 -80
  62. package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +0 -87
  63. package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +0 -79
  64. package/library/utils/GovernanceUtils.sol +0 -81
  65. package/library/utils/nonces/AsyncNonce.sol +0 -74
  66. package/library/utils/nonces/SyncNonce.sol +0 -71
  67. package/library/utils/service/EvvmPayments.sol +0 -144
@@ -2,6 +2,26 @@
2
2
  // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
3
 
4
4
  pragma solidity ^0.8.0;
5
+
6
+ import {
7
+ StakingError as Error
8
+ } from "@evvm/testnet-contracts/library/errors/StakingError.sol";
9
+ import {
10
+ StakingHashUtils as Hash
11
+ } from "@evvm/testnet-contracts/library/utils/signature/StakingHashUtils.sol";
12
+ import {
13
+ StakingStructs as Structs
14
+ } from "@evvm/testnet-contracts/library/structs/StakingStructs.sol";
15
+
16
+ import {Core} from "@evvm/testnet-contracts/contracts/core/Core.sol";
17
+ import {
18
+ Estimator
19
+ } from "@evvm/testnet-contracts/contracts/staking/Estimator.sol";
20
+
21
+ import {
22
+ ProposalStructs
23
+ } from "@evvm/testnet-contracts/library/utils/governance/ProposalStructs.sol";
24
+
5
25
  /**
6
26
 
7
27
 
@@ -23,36 +43,14 @@ pragma solidity ^0.8.0;
23
43
  ██║ ██╔══╝ ╚════██║ ██║ ██║╚██╗██║██╔══╝ ██║
24
44
  ██║ ███████╗███████║ ██║ ██║ ╚████║███████╗ ██║
25
45
  ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝
26
- * @title Staking Mate contract
46
+ * @title EVVM Staking
27
47
  * @author Mate labs
28
- * @notice This contract manages the staking mechanism for the EVVM ecosystem
29
- * @dev Handles presale staking, public staking, and service staking with time locks and signature verification
30
- *
31
- * The contract supports three types of staking:
32
- * 1. Golden Staking: Exclusive to the goldenFisher address
33
- * 2. Presale Staking: Limited to 800 presale users with 2 staking token limit
34
- * 3. Public Staking: Open to all users when enabled
35
- * 4. Service Staking: Allows smart contracts to stake on behalf of users
36
- *
37
- * Key features:
38
- * - Time-locked unstaking mechanisms
39
- * - Signature-based authorization
40
- * - Integration with EVVM core contract for payments and rewards
41
- * - Estimator integration for yield calculations
48
+ * @notice Validator staking mechanism for the EVVM ecosystem.
49
+ * @dev Manages staking, unstaking, and yield distribution via the Estimator contract.
50
+ * Supports presale and public staking phases with time-locked security and nonce-based replay protection.
42
51
  */
43
52
 
44
- import {Evvm} from "@evvm/testnet-contracts/contracts/evvm/Evvm.sol";
45
- import {IEstimator} from "@evvm/testnet-contracts/interfaces/IEstimator.sol";
46
- import {
47
- AsyncNonce
48
- } from "@evvm/testnet-contracts/library/utils/nonces/AsyncNonce.sol";
49
- import {
50
- StakingStructs
51
- } from "@evvm/testnet-contracts/contracts/staking/lib/StakingStructs.sol";
52
- import {ErrorsLib} from "./lib/ErrorsLib.sol";
53
- import {SignatureUtils} from "./lib/SignatureUtils.sol";
54
-
55
- contract Staking is AsyncNonce, StakingStructs {
53
+ contract Staking {
56
54
  uint256 constant TIME_TO_ACCEPT_PROPOSAL = 1 days;
57
55
 
58
56
  /// @dev Address of the EVVM core contract
@@ -66,37 +64,37 @@ contract Staking is AsyncNonce, StakingStructs {
66
64
  uint256 private constant PRICE_OF_STAKING = 5083 * (10 ** 18);
67
65
 
68
66
  /// @dev Admin address management with proposal system
69
- AddressTypeProposal private admin;
67
+ ProposalStructs.AddressTypeProposal private admin;
70
68
  /// @dev Golden Fisher address management with proposal system
71
- AddressTypeProposal private goldenFisher;
69
+ ProposalStructs.AddressTypeProposal private goldenFisher;
72
70
  /// @dev Estimator contract address management with proposal system
73
- AddressTypeProposal private estimatorAddress;
71
+ ProposalStructs.AddressTypeProposal private estimatorAddress;
74
72
  /// @dev Time delay for regular staking after unstaking
75
- UintTypeProposal private secondsToUnlockStaking;
73
+ ProposalStructs.UintTypeProposal private secondsToUnlockStaking;
76
74
  /// @dev Time delay for full unstaking (21 days default)
77
- UintTypeProposal private secondsToUnllockFullUnstaking;
75
+ ProposalStructs.UintTypeProposal private secondsToUnllockFullUnstaking;
78
76
  /// @dev Flag to enable/disable presale staking
79
- BoolTypeProposal private allowPresaleStaking;
77
+ ProposalStructs.BoolTypeProposal private allowPresaleStaking;
80
78
  /// @dev Flag to enable/disable public staking
81
- BoolTypeProposal private allowPublicStaking;
79
+ ProposalStructs.BoolTypeProposal private allowPublicStaking;
82
80
  /// @dev Variable to store service staking metadata
83
- ServiceStakingMetadata private serviceStakingData;
81
+ Structs.ServiceStakingMetadata private serviceStakingData;
84
82
 
85
83
  /// @dev One-time setup breaker for estimator and EVVM addresses
86
84
  bytes1 private breakerSetupEstimatorAndEvvm;
87
85
 
88
86
  /// @dev Mapping to store presale staker metadata
89
- mapping(address => presaleStakerMetadata) private userPresaleStaker;
87
+ mapping(address => Structs.PresaleStakerMetadata) private userPresaleStaker;
90
88
 
91
89
  /// @dev Mapping to store complete staking history for each user
92
- mapping(address => HistoryMetadata[]) private userHistory;
90
+ mapping(address => Structs.HistoryMetadata[]) private userHistory;
93
91
 
94
- Evvm private evvm;
95
- IEstimator private estimator;
92
+ Core private core;
93
+ Estimator private estimator;
96
94
 
97
95
  /// @dev Modifier to verify access to admin functions
98
96
  modifier onlyOwner() {
99
- if (msg.sender != admin.actual) revert ErrorsLib.SenderIsNotAdmin();
97
+ if (msg.sender != admin.current) revert Error.SenderIsNotAdmin();
100
98
 
101
99
  _;
102
100
  }
@@ -111,250 +109,268 @@ contract Staking is AsyncNonce, StakingStructs {
111
109
  size := extcodesize(callerAddress)
112
110
  }
113
111
 
114
- if (size == 0) revert ErrorsLib.AddressIsNotAService();
112
+ if (size == 0) revert Error.AddressIsNotAService();
115
113
 
116
114
  _;
117
115
  }
118
116
 
119
117
  /**
120
- * @notice Contract constructor
121
- * @dev Initializes the staking contract with admin and golden fisher addresses
122
- * @param initialAdmin Address that will have admin privileges
123
- * @param initialGoldenFisher Address that will have golden fisher privileges
118
+ * @notice Initializes the staking contract.
119
+ * @param initialAdmin System administrator.
120
+ * @param initialGoldenFisher Authorized Golden Fisher address.
124
121
  */
125
122
  constructor(address initialAdmin, address initialGoldenFisher) {
126
- admin.actual = initialAdmin;
127
-
128
- goldenFisher.actual = initialGoldenFisher;
129
-
130
- /**
131
- * @dev Because presale staking is disabled by default
132
- * if you want to enable it, you need to do it via
133
- * this admin functions
134
- *
135
- * prepareChangeAllowPresaleStaking()
136
- * prepareChangeAllowPublicStaking()
137
- *
138
- * wait TIME_TO_ACCEPT_PROPOSAL
139
- *
140
- * confirmChangeAllowPresaleStaking()
141
- * confirmChangeAllowPublicStaking()
142
- */
123
+ admin.current = initialAdmin;
124
+
125
+ goldenFisher.current = initialGoldenFisher;
143
126
 
144
127
  allowPublicStaking.flag = true;
145
128
  allowPresaleStaking.flag = false;
146
129
 
147
- secondsToUnlockStaking.actual = 0;
130
+ secondsToUnlockStaking.current = 0;
148
131
 
149
- secondsToUnllockFullUnstaking.actual = 5 days;
132
+ secondsToUnllockFullUnstaking.current = 5 days;
150
133
 
151
134
  breakerSetupEstimatorAndEvvm = 0x01;
152
135
  }
153
136
 
154
137
  /**
155
- * @notice One-time setup function for estimator and EVVM addresses
156
- * @dev Can only be called once during contract initialization
157
- * @param _estimator Address of the Estimator contract
158
- * @param _evvm Address of the EVVM core contract
138
+ * @notice Configures system contract integrations once.
139
+ * @param _estimator Estimator contract address (yield calculations).
140
+ * @param _core EVVM Core contract address (payments).
159
141
  */
160
- function _setupEstimatorAndEvvm(
142
+ function initializeSystemContracts(
161
143
  address _estimator,
162
- address _evvm
144
+ address _core
163
145
  ) external {
164
146
  if (breakerSetupEstimatorAndEvvm == 0x00) revert();
165
147
 
166
- estimatorAddress.actual = _estimator;
167
- EVVM_ADDRESS = _evvm;
148
+ estimatorAddress.current = _estimator;
149
+ EVVM_ADDRESS = _core;
150
+
151
+ core = Core(_core);
152
+ estimator = Estimator(_estimator);
168
153
  breakerSetupEstimatorAndEvvm = 0x00;
169
- evvm = Evvm(_evvm);
170
- estimator = IEstimator(_estimator);
171
154
  }
172
155
 
173
156
  /**
174
- * @notice Allows the golden fisher to stake/unstake with synchronized EVVM nonces
175
- * @dev Only the golden fisher address can call this function
176
- * @param isStaking True for staking, false for unstaking
177
- * @param amountOfStaking Amount of staking tokens to stake/unstake
178
- * @param signature_EVVM Signature for the EVVM contract transaction
157
+ * @notice Unlimited staking/unstaking for the Golden Fisher.
158
+ * @dev Uses sync nonces for coordination with Core operations.
159
+ * @param isStaking True to stake, false to unstake.
160
+ * @param amountOfStaking Number of staking tokens.
161
+ * @param signaturePay Authorization signature for Core payment.
179
162
  */
180
163
  function goldenStaking(
181
164
  bool isStaking,
182
165
  uint256 amountOfStaking,
183
- bytes memory signature_EVVM
166
+ bytes memory signaturePay
184
167
  ) external {
185
- if (msg.sender != goldenFisher.actual)
186
- revert ErrorsLib.SenderIsNotGoldenFisher();
168
+ if (msg.sender != goldenFisher.current)
169
+ revert Error.SenderIsNotGoldenFisher();
187
170
 
188
171
  stakingBaseProcess(
189
- AccountMetadata({Address: goldenFisher.actual, IsAService: false}),
172
+ Structs.AccountMetadata({
173
+ Address: goldenFisher.current,
174
+ IsAService: false
175
+ }),
190
176
  isStaking,
191
177
  amountOfStaking,
192
178
  0,
193
- evvm.getNextCurrentSyncNonce(msg.sender),
179
+ core.getNextCurrentSyncNonce(msg.sender),
194
180
  false,
195
- signature_EVVM
181
+ signaturePay
196
182
  );
197
183
  }
198
184
 
199
185
  /**
200
- * @notice Allows presale users to stake/unstake with a limit of 2 staking tokens
201
- * @dev Only registered presale users can call this function when presale staking is enabled
202
- * @param user Address of the user performing the staking operation
203
- * @param isStaking True for staking, false for unstaking
204
- * @param nonce Unique nonce for this staking operation
205
- * @param signature Signature proving authorization for this staking operation
206
- * @param priorityFee_EVVM Priority fee for the EVVM transaction
207
- * @param nonce_EVVM Nonce for the EVVM contract transaction
208
- * @param priorityFlag_EVVM True for async EVVM transaction, false for sync
209
- * @param signature_EVVM Signature for the EVVM contract transaction
186
+ * @notice White-listed presale staking (max 2 tokens per user).
187
+ * @param user Participant address.
188
+ * @param isStaking True to stake, false to unstake.
189
+ * @param nonce Async nonce for signature verification.
190
+ * @param signature Participant's authorization signature.
191
+ * @param priorityFeePay Optional priority fee.
192
+ * @param noncePay Nonce for the Core payment.
193
+ * @param signaturePay Signature for the Core payment.
210
194
  */
211
195
  function presaleStaking(
212
196
  address user,
213
197
  bool isStaking,
198
+ address originExecutor,
214
199
  uint256 nonce,
215
200
  bytes memory signature,
216
- uint256 priorityFee_EVVM,
217
- uint256 nonce_EVVM,
218
- bool priorityFlag_EVVM,
219
- bytes memory signature_EVVM
201
+ uint256 priorityFeePay,
202
+ uint256 noncePay,
203
+ bytes memory signaturePay
220
204
  ) external {
221
205
  if (!allowPresaleStaking.flag || allowPublicStaking.flag)
222
- revert ErrorsLib.PresaleStakingDisabled();
206
+ revert Error.PresaleStakingDisabled();
223
207
 
224
- if (
225
- !SignatureUtils.verifyMessageSignedForPresaleStake(
226
- evvm.getEvvmID(),
227
- user,
228
- isStaking,
229
- 1,
230
- nonce,
231
- signature
232
- )
233
- ) revert ErrorsLib.InvalidSignatureOnStaking();
208
+ core.validateAndConsumeNonce(
209
+ user,
210
+ Hash.hashDataForPresaleStake(isStaking, 1),
211
+ originExecutor,
212
+ nonce,
213
+ true,
214
+ signature
215
+ );
234
216
 
235
217
  if (!userPresaleStaker[user].isAllow)
236
- revert ErrorsLib.UserIsNotPresaleStaker();
237
-
238
- verifyAsyncNonce(user, nonce);
218
+ revert Error.UserIsNotPresaleStaker();
239
219
 
240
220
  uint256 current = userPresaleStaker[user].stakingAmount;
241
221
 
242
222
  if (isStaking ? current >= 2 : current == 0)
243
- revert ErrorsLib.UserPresaleStakerLimitExceeded();
223
+ revert Error.UserPresaleStakerLimitExceeded();
244
224
 
245
225
  userPresaleStaker[user].stakingAmount = isStaking
246
226
  ? current + 1
247
227
  : current - 1;
248
228
 
249
229
  stakingBaseProcess(
250
- AccountMetadata({Address: user, IsAService: false}),
230
+ Structs.AccountMetadata({Address: user, IsAService: false}),
251
231
  isStaking,
252
232
  1,
253
- priorityFee_EVVM,
254
- nonce_EVVM,
255
- priorityFlag_EVVM,
256
- signature_EVVM
233
+ priorityFeePay,
234
+ noncePay,
235
+ true,
236
+ signaturePay
257
237
  );
258
-
259
- markAsyncNonceAsUsed(user, nonce);
260
238
  }
261
239
 
262
240
  /**
263
- * @notice Allows any user to stake/unstake when public staking is enabled
264
- * @dev Requires signature verification and handles nonce management
265
- * @param user Address of the user performing the staking operation
266
- * @param isStaking True for staking, false for unstaking
267
- * @param amountOfStaking Amount of staking tokens to stake/unstake
268
- * @param nonce Unique nonce for this staking operation
269
- * @param signature Signature proving authorization for this staking operation
270
- * @param priorityFee_EVVM Priority fee for the EVVM transaction
271
- * @param nonce_EVVM Nonce for the EVVM contract transaction
272
- * @param priorityFlag_EVVM True for async EVVM transaction, false for sync
273
- * @param signature_EVVM Signature for the EVVM contract transaction
241
+ * @notice Public staking open to any user when enabled.
242
+ * @param user Participant address.
243
+ * @param isStaking True to stake, false to unstake.
244
+ * @param amountOfStaking Number of tokens.
245
+ * @param nonce Async nonce for signature verification.
246
+ * @param signature Participant's authorization signature.
247
+ * @param priorityFeePay Optional priority fee.
248
+ * @param noncePay Nonce for the Core payment.
249
+ * @param signaturePay Signature for the Core payment.
274
250
  */
275
251
  function publicStaking(
276
252
  address user,
277
253
  bool isStaking,
278
254
  uint256 amountOfStaking,
255
+ address originExecutor,
279
256
  uint256 nonce,
280
257
  bytes memory signature,
281
- uint256 priorityFee_EVVM,
282
- uint256 nonce_EVVM,
283
- bool priorityFlag_EVVM,
284
- bytes memory signature_EVVM
258
+ uint256 priorityFeePay,
259
+ uint256 noncePay,
260
+ bytes memory signaturePay
285
261
  ) external {
286
- if (!allowPublicStaking.flag) revert ErrorsLib.PublicStakingDisabled();
262
+ if (!allowPublicStaking.flag) revert Error.PublicStakingDisabled();
287
263
 
288
- if (
289
- !SignatureUtils.verifyMessageSignedForPublicStake(
290
- evvm.getEvvmID(),
291
- user,
292
- isStaking,
293
- amountOfStaking,
294
- nonce,
295
- signature
296
- )
297
- ) revert ErrorsLib.InvalidSignatureOnStaking();
298
-
299
- verifyAsyncNonce(user, nonce);
264
+ core.validateAndConsumeNonce(
265
+ user,
266
+ Hash.hashDataForPublicStake(isStaking, amountOfStaking),
267
+ originExecutor,
268
+ nonce,
269
+ true,
270
+ signature
271
+ );
300
272
 
301
273
  stakingBaseProcess(
302
- AccountMetadata({Address: user, IsAService: false}),
274
+ Structs.AccountMetadata({Address: user, IsAService: false}),
303
275
  isStaking,
304
276
  amountOfStaking,
305
- priorityFee_EVVM,
306
- nonce_EVVM,
307
- priorityFlag_EVVM,
308
- signature_EVVM
277
+ priorityFeePay,
278
+ noncePay,
279
+ true,
280
+ signaturePay
309
281
  );
310
-
311
- markAsyncNonceAsUsed(user, nonce);
312
282
  }
313
283
 
314
284
  /**
315
- * @notice Prepares a service/contract account for staking by recording pre-staking state
316
- * @dev First step in the service staking process. Must be followed by payment via caPay and confirmServiceStaking in the same transaction
317
- * @param amountOfStaking Amount of staking tokens the service intends to stake
285
+ * @notice Step 1: Prepare service (contract) staking
286
+ * @dev Records pre-staking state for atomic validation
318
287
  *
319
- * Service Staking Process:
320
- * 1. Call prepareServiceStaking(amount) - Records balances and metadata
321
- * 2. Use EVVM.caPay() to transfer the required Principal Tokens to this contract
322
- * 3. Call confirmServiceStaking() - Validates payment and completes staking
288
+ * Service Staking Process (ATOMIC - Same TX):
289
+ * 1. prepareServiceStaking: Record balances
290
+ * 2. Evvm.caPay: Transfer Principal Tokens
291
+ * 3. confirmServiceStaking: Validate and complete
323
292
  *
324
- * @dev All three steps MUST occur in the same transaction or the staking will fail
325
- * @dev CRITICAL WARNING: If the process is not completed properly (especially if caPay is called
326
- * but confirmServiceStaking is not), the Principal Tokens will remain locked in the staking
327
- * contract with no way to recover them. The service will lose the tokens permanently.
328
- * @dev Only callable by contract accounts (services), not EOAs
293
+ * CRITICAL WARNING:
294
+ * - All 3 steps MUST occur in single transaction
295
+ * - If incomplete, tokens permanently locked
296
+ * - No recovery mechanism for failed process
297
+ * - Service loses tokens if not atomic
298
+ *
299
+ * Metadata Recorded:
300
+ * - service: msg.sender (contract address)
301
+ * - timestamp: block.timestamp (atomicity check)
302
+ * - amountOfStaking: Requested staking tokens
303
+ * - amountServiceBeforeStaking: Service PT balance
304
+ * - amountStakingBeforeStaking: Staking PT balance
305
+ *
306
+ * Core.sol Payment (Step 2):
307
+ * - Service must call Evvm.caPay after this
308
+ * - Transfer: PRICE_OF_STAKING * amountOfStaking
309
+ * - Recipient: address(this) (Staking contract)
310
+ * - Token: Principal Token from Core.sol
311
+ *
312
+ * Access Control:
313
+ * - onlyCA modifier: Only contracts allowed
314
+ * - Checks code size via assembly
315
+ * - EOAs rejected (size == 0)
316
+ *
317
+ * @param amountOfStaking Number of staking tokens to acquire
329
318
  */
330
319
  function prepareServiceStaking(uint256 amountOfStaking) external onlyCA {
331
- serviceStakingData = ServiceStakingMetadata({
320
+ serviceStakingData = Structs.ServiceStakingMetadata({
332
321
  service: msg.sender,
333
322
  timestamp: block.timestamp,
334
323
  amountOfStaking: amountOfStaking,
335
- amountServiceBeforeStaking: evvm.getBalance(
324
+ amountServiceBeforeStaking: core.getBalance(
336
325
  msg.sender,
337
- evvm.getPrincipalTokenAddress()
326
+ core.getPrincipalTokenAddress()
338
327
  ),
339
- amountStakingBeforeStaking: evvm.getBalance(
328
+ amountStakingBeforeStaking: core.getBalance(
340
329
  address(this),
341
- evvm.getPrincipalTokenAddress()
330
+ core.getPrincipalTokenAddress()
342
331
  )
343
332
  });
344
333
  }
345
334
 
346
335
  /**
347
- * @notice Confirms and completes the service staking operation after payment verification
348
- * @dev Final step in service staking. Validates that payment was made correctly and completes the staking process
336
+ * @notice Step 3: Confirm service staking after payment
337
+ * @dev Validates payment and completes atomic staking
338
+ *
339
+ * Validation Checks:
340
+ * 1. Timestamp: Must equal prepareServiceStaking tx
341
+ * - Ensures atomicity (same transaction)
342
+ * - serviceStakingData.timestamp == block.timestamp
343
+ *
344
+ * 2. Caller: Must match prepareServiceStaking caller
345
+ * - serviceStakingData.service == msg.sender
346
+ * - Prevents staking hijacking
347
+ *
348
+ * 3. Payment Amount: Validates exact transfer
349
+ * - Service balance decreased by exact amount
350
+ * - Staking balance increased by exact amount
351
+ * - totalStakingRequired = PRICE_OF_STAKING *
352
+ * amountOfStaking
353
+ *
354
+ * Core.sol Integration:
355
+ * - Validates caPay occurred between steps 1 and 3
356
+ * - Checks balance deltas via Evvm.getBalance
357
+ * - Token: core.getPrincipalTokenAddress()
358
+ * - Must be exact amount (no overpayment/underpayment)
349
359
  *
350
- * Validation checks:
351
- * - Service balance decreased by the exact staking cost
352
- * - Staking contract balance increased by the exact staking cost
353
- * - Operation occurs in the same transaction as prepareServiceStaking
354
- * - Caller matches the service that initiated the preparation
360
+ * Completion:
361
+ * - Calls stakingBaseProcess on success
362
+ * - Records history with transaction type 0x01
363
+ * - Updates userHistory with staking event
364
+ * - Service becomes staker (isAddressStaker = true)
355
365
  *
356
- * @dev Only callable by the same contract that called prepareServiceStaking
357
- * @dev Must be called in the same transaction as prepareServiceStaking
366
+ * Error Cases:
367
+ * - ServiceDoesNotStakeInSameTx: timestamp mismatch
368
+ * - AddressMismatch: caller mismatch
369
+ * - ServiceDoesNotFulfillCorrectStakingAmount:
370
+ * payment incorrect
371
+ *
372
+ * Access Control:
373
+ * - onlyCA modifier: Only contracts allowed
358
374
  */
359
375
  function confirmServiceStaking() external onlyCA {
360
376
  uint256 totalStakingRequired = PRICE_OF_STAKING *
@@ -363,23 +379,23 @@ contract Staking is AsyncNonce, StakingStructs {
363
379
  if (
364
380
  serviceStakingData.amountServiceBeforeStaking -
365
381
  totalStakingRequired !=
366
- evvm.getBalance(msg.sender, evvm.getPrincipalTokenAddress()) &&
382
+ core.getBalance(msg.sender, core.getPrincipalTokenAddress()) &&
367
383
  serviceStakingData.amountStakingBeforeStaking +
368
384
  totalStakingRequired !=
369
- evvm.getBalance(address(this), evvm.getPrincipalTokenAddress())
385
+ core.getBalance(address(this), core.getPrincipalTokenAddress())
370
386
  )
371
- revert ErrorsLib.ServiceDoesNotFulfillCorrectStakingAmount(
387
+ revert Error.ServiceDoesNotFulfillCorrectStakingAmount(
372
388
  totalStakingRequired
373
389
  );
374
390
 
375
391
  if (serviceStakingData.timestamp != block.timestamp)
376
- revert ErrorsLib.ServiceDoesNotStakeInSameTx();
392
+ revert Error.ServiceDoesNotStakeInSameTx();
377
393
 
378
394
  if (serviceStakingData.service != msg.sender)
379
- revert ErrorsLib.AddressMismatch();
395
+ revert Error.AddressMismatch();
380
396
 
381
397
  stakingBaseProcess(
382
- AccountMetadata({Address: msg.sender, IsAService: true}),
398
+ Structs.AccountMetadata({Address: msg.sender, IsAService: true}),
383
399
  true,
384
400
  serviceStakingData.amountOfStaking,
385
401
  0,
@@ -400,7 +416,7 @@ contract Staking is AsyncNonce, StakingStructs {
400
416
  */
401
417
  function serviceUnstaking(uint256 amountOfStaking) external onlyCA {
402
418
  stakingBaseProcess(
403
- AccountMetadata({Address: msg.sender, IsAService: true}),
419
+ Structs.AccountMetadata({Address: msg.sender, IsAService: true}),
404
420
  false,
405
421
  amountOfStaking,
406
422
  0,
@@ -418,19 +434,18 @@ contract Staking is AsyncNonce, StakingStructs {
418
434
  * - IsAService: Boolean indicating if the account is a smart contract (service) account
419
435
  * @param isStaking True for staking (requires payment), false for unstaking (provides refund)
420
436
  * @param amountOfStaking Amount of staking tokens to stake/unstake
421
- * @param priorityFee_EVVM Priority fee for EVVM transaction
422
- * @param nonce_EVVM Nonce for EVVM contract transaction
423
- * @param priorityFlag_EVVM True for async EVVM transaction, false for sync
424
- * @param signature_EVVM Signature for EVVM contract transaction
437
+ * @param priorityFeePay Priority fee for EVVM transaction
438
+ * @param noncePay Nonce for EVVM contract transaction
439
+ * @param signaturePay Signature for EVVM contract transaction
425
440
  */
426
441
  function stakingBaseProcess(
427
- AccountMetadata memory account,
442
+ Structs.AccountMetadata memory account,
428
443
  bool isStaking,
429
444
  uint256 amountOfStaking,
430
- uint256 priorityFee_EVVM,
431
- uint256 nonce_EVVM,
432
- bool priorityFlag_EVVM,
433
- bytes memory signature_EVVM
445
+ uint256 priorityFeePay,
446
+ uint256 noncePay,
447
+ bool isAsyncExecEvvm,
448
+ bytes memory signaturePay
434
449
  ) internal {
435
450
  uint256 auxSMsteBalance;
436
451
 
@@ -438,19 +453,19 @@ contract Staking is AsyncNonce, StakingStructs {
438
453
  if (
439
454
  getTimeToUserUnlockStakingTime(account.Address) >
440
455
  block.timestamp
441
- ) revert ErrorsLib.AddressMustWaitToStakeAgain();
456
+ ) revert Error.AddressMustWaitToStakeAgain();
442
457
 
443
458
  if (!account.IsAService)
444
459
  makePay(
445
460
  account.Address,
446
461
  (PRICE_OF_STAKING * amountOfStaking),
447
- priorityFee_EVVM,
448
- priorityFlag_EVVM,
449
- nonce_EVVM,
450
- signature_EVVM
462
+ priorityFeePay,
463
+ isAsyncExecEvvm,
464
+ noncePay,
465
+ signaturePay
451
466
  );
452
467
 
453
- evvm.pointStaker(account.Address, 0x01);
468
+ core.pointStaker(account.Address, 0x01);
454
469
 
455
470
  auxSMsteBalance = userHistory[account.Address].length == 0
456
471
  ? amountOfStaking
@@ -462,19 +477,19 @@ contract Staking is AsyncNonce, StakingStructs {
462
477
  if (
463
478
  getTimeToUserUnlockFullUnstakingTime(account.Address) >
464
479
  block.timestamp
465
- ) revert ErrorsLib.AddressMustWaitToFullUnstake();
480
+ ) revert Error.AddressMustWaitToFullUnstake();
466
481
 
467
- evvm.pointStaker(account.Address, 0x00);
482
+ core.pointStaker(account.Address, 0x00);
468
483
  }
469
484
 
470
- if (priorityFee_EVVM != 0 && !account.IsAService)
485
+ if (priorityFeePay != 0 && !account.IsAService)
471
486
  makePay(
472
487
  account.Address,
473
488
  0,
474
- priorityFee_EVVM,
475
- priorityFlag_EVVM,
476
- nonce_EVVM,
477
- signature_EVVM
489
+ priorityFeePay,
490
+ isAsyncExecEvvm,
491
+ noncePay,
492
+ signaturePay
478
493
  );
479
494
 
480
495
  auxSMsteBalance =
@@ -484,14 +499,14 @@ contract Staking is AsyncNonce, StakingStructs {
484
499
  amountOfStaking;
485
500
 
486
501
  makeCaPay(
487
- evvm.getPrincipalTokenAddress(),
502
+ core.getPrincipalTokenAddress(),
488
503
  account.Address,
489
504
  (PRICE_OF_STAKING * amountOfStaking)
490
505
  );
491
506
  }
492
507
 
493
508
  userHistory[account.Address].push(
494
- HistoryMetadata({
509
+ Structs.HistoryMetadata({
495
510
  transactionType: isStaking
496
511
  ? bytes32(uint256(1))
497
512
  : bytes32(uint256(2)),
@@ -501,11 +516,11 @@ contract Staking is AsyncNonce, StakingStructs {
501
516
  })
502
517
  );
503
518
 
504
- if (evvm.isAddressStaker(msg.sender) && !account.IsAService) {
519
+ if (core.isAddressStaker(msg.sender) && !account.IsAService) {
505
520
  makeCaPay(
506
- evvm.getPrincipalTokenAddress(),
521
+ core.getPrincipalTokenAddress(),
507
522
  msg.sender,
508
- (evvm.getRewardAmount() * 2) + priorityFee_EVVM
523
+ (core.getRewardAmount() * 2) + priorityFeePay
509
524
  );
510
525
  }
511
526
  }
@@ -551,11 +566,11 @@ contract Staking is AsyncNonce, StakingStructs {
551
566
  userHistory[user][idToOverwriteUserHistory]
552
567
  .timestamp = timestampToBeOverwritten;
553
568
 
554
- if (evvm.isAddressStaker(msg.sender)) {
569
+ if (core.isAddressStaker(msg.sender)) {
555
570
  makeCaPay(
556
- evvm.getPrincipalTokenAddress(),
571
+ core.getPrincipalTokenAddress(),
557
572
  msg.sender,
558
- (evvm.getRewardAmount() * 1)
573
+ (core.getRewardAmount() * 1)
559
574
  );
560
575
  }
561
576
  }
@@ -572,7 +587,7 @@ contract Staking is AsyncNonce, StakingStructs {
572
587
  * @param user Address of the user making the payment
573
588
  * @param amount Amount to be paid in Principal Tokens
574
589
  * @param priorityFee Additional priority fee for the transaction
575
- * @param priorityFlag True for async payment, false for sync payment
590
+ * @param isAsyncExec True for async payment, false for sync payment
576
591
  * @param nonce Nonce for the EVVM transaction
577
592
  * @param signature Signature authorizing the payment
578
593
  */
@@ -580,20 +595,20 @@ contract Staking is AsyncNonce, StakingStructs {
580
595
  address user,
581
596
  uint256 amount,
582
597
  uint256 priorityFee,
583
- bool priorityFlag,
598
+ bool isAsyncExec,
584
599
  uint256 nonce,
585
600
  bytes memory signature
586
601
  ) internal {
587
- evvm.pay(
602
+ core.pay(
588
603
  user,
589
604
  address(this),
590
605
  "",
591
- evvm.getPrincipalTokenAddress(),
606
+ core.getPrincipalTokenAddress(),
592
607
  amount,
593
608
  priorityFee,
594
- nonce,
595
- priorityFlag,
596
609
  address(this),
610
+ nonce,
611
+ isAsyncExec,
597
612
  signature
598
613
  );
599
614
  }
@@ -610,7 +625,7 @@ contract Staking is AsyncNonce, StakingStructs {
610
625
  address user,
611
626
  uint256 amount
612
627
  ) internal {
613
- evvm.caPay(user, tokenAddress, amount);
628
+ core.caPay(user, tokenAddress, amount);
614
629
  }
615
630
 
616
631
  //▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
@@ -624,7 +639,7 @@ contract Staking is AsyncNonce, StakingStructs {
624
639
  */
625
640
  function addPresaleStaker(address _staker) external onlyOwner {
626
641
  if (presaleStakerCount > LIMIT_PRESALE_STAKER)
627
- revert ErrorsLib.LimitPresaleStakersExceeded();
642
+ revert Error.LimitPresaleStakersExceeded();
628
643
 
629
644
  userPresaleStaker[_staker].isAllow = true;
630
645
  presaleStakerCount++;
@@ -638,7 +653,7 @@ contract Staking is AsyncNonce, StakingStructs {
638
653
  function addPresaleStakers(address[] calldata _stakers) external onlyOwner {
639
654
  for (uint256 i = 0; i < _stakers.length; i++) {
640
655
  if (presaleStakerCount > LIMIT_PRESALE_STAKER)
641
- revert ErrorsLib.LimitPresaleStakersExceeded();
656
+ revert Error.LimitPresaleStakersExceeded();
642
657
 
643
658
  userPresaleStaker[_stakers[i]].isAllow = true;
644
659
  presaleStakerCount++;
@@ -670,12 +685,12 @@ contract Staking is AsyncNonce, StakingStructs {
670
685
  */
671
686
  function acceptNewAdmin() external {
672
687
  if (msg.sender != admin.proposal)
673
- revert ErrorsLib.SenderIsNotProposedAdmin();
688
+ revert Error.SenderIsNotProposedAdmin();
674
689
 
675
690
  if (admin.timeToAccept > block.timestamp)
676
- revert ErrorsLib.TimeToAcceptProposalNotReached();
691
+ revert Error.TimeToAcceptProposalNotReached();
677
692
 
678
- admin.actual = admin.proposal;
693
+ admin.current = admin.proposal;
679
694
  admin.proposal = address(0);
680
695
  admin.timeToAccept = 0;
681
696
  }
@@ -705,9 +720,9 @@ contract Staking is AsyncNonce, StakingStructs {
705
720
  */
706
721
  function acceptNewGoldenFisher() external onlyOwner {
707
722
  if (goldenFisher.timeToAccept > block.timestamp)
708
- revert ErrorsLib.TimeToAcceptProposalNotReached();
723
+ revert Error.TimeToAcceptProposalNotReached();
709
724
 
710
- goldenFisher.actual = goldenFisher.proposal;
725
+ goldenFisher.current = goldenFisher.proposal;
711
726
  goldenFisher.proposal = address(0);
712
727
  goldenFisher.timeToAccept = 0;
713
728
  }
@@ -741,9 +756,9 @@ contract Staking is AsyncNonce, StakingStructs {
741
756
  */
742
757
  function acceptSetSecondsToUnlockStaking() external onlyOwner {
743
758
  if (secondsToUnlockStaking.timeToAccept > block.timestamp)
744
- revert ErrorsLib.TimeToAcceptProposalNotReached();
759
+ revert Error.TimeToAcceptProposalNotReached();
745
760
 
746
- secondsToUnlockStaking.actual = secondsToUnlockStaking.proposal;
761
+ secondsToUnlockStaking.current = secondsToUnlockStaking.proposal;
747
762
  secondsToUnlockStaking.proposal = 0;
748
763
  secondsToUnlockStaking.timeToAccept = 0;
749
764
  }
@@ -777,9 +792,9 @@ contract Staking is AsyncNonce, StakingStructs {
777
792
  */
778
793
  function confirmSetSecondsToUnllockFullUnstaking() external onlyOwner {
779
794
  if (secondsToUnllockFullUnstaking.timeToAccept > block.timestamp)
780
- revert ErrorsLib.TimeToAcceptProposalNotReached();
795
+ revert Error.TimeToAcceptProposalNotReached();
781
796
 
782
- secondsToUnllockFullUnstaking.actual = secondsToUnllockFullUnstaking
797
+ secondsToUnllockFullUnstaking.current = secondsToUnllockFullUnstaking
783
798
  .proposal;
784
799
  secondsToUnllockFullUnstaking.proposal = 0;
785
800
  secondsToUnllockFullUnstaking.timeToAccept = 0;
@@ -809,9 +824,9 @@ contract Staking is AsyncNonce, StakingStructs {
809
824
  */
810
825
  function confirmChangeAllowPublicStaking() external onlyOwner {
811
826
  if (allowPublicStaking.timeToAccept > block.timestamp)
812
- revert ErrorsLib.TimeToAcceptProposalNotReached();
827
+ revert Error.TimeToAcceptProposalNotReached();
813
828
 
814
- allowPublicStaking = BoolTypeProposal({
829
+ allowPublicStaking = ProposalStructs.BoolTypeProposal({
815
830
  flag: !allowPublicStaking.flag,
816
831
  timeToAccept: 0
817
832
  });
@@ -841,7 +856,7 @@ contract Staking is AsyncNonce, StakingStructs {
841
856
  */
842
857
  function confirmChangeAllowPresaleStaking() external onlyOwner {
843
858
  if (allowPresaleStaking.timeToAccept > block.timestamp)
844
- revert ErrorsLib.TimeToAcceptProposalNotReached();
859
+ revert Error.TimeToAcceptProposalNotReached();
845
860
 
846
861
  allowPresaleStaking.flag = !allowPresaleStaking.flag;
847
862
  allowPresaleStaking.timeToAccept = 0;
@@ -874,12 +889,12 @@ contract Staking is AsyncNonce, StakingStructs {
874
889
  */
875
890
  function acceptNewEstimator() external onlyOwner {
876
891
  if (estimatorAddress.timeToAccept > block.timestamp)
877
- revert ErrorsLib.TimeToAcceptProposalNotReached();
892
+ revert Error.TimeToAcceptProposalNotReached();
878
893
 
879
- estimatorAddress.actual = estimatorAddress.proposal;
894
+ estimatorAddress.current = estimatorAddress.proposal;
880
895
  estimatorAddress.proposal = address(0);
881
896
  estimatorAddress.timeToAccept = 0;
882
- estimator = IEstimator(estimatorAddress.actual);
897
+ estimator = Estimator(estimatorAddress.current);
883
898
  }
884
899
 
885
900
  //▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
@@ -890,11 +905,11 @@ contract Staking is AsyncNonce, StakingStructs {
890
905
  * @notice Returns the complete staking history for an address
891
906
  * @dev Returns an array of all staking transactions and rewards for the user
892
907
  * @param _account Address to query the history for
893
- * @return Array of HistoryMetadata containing all transactions
908
+ * @return Array of Structs.HistoryMetadata containing all transactions
894
909
  */
895
910
  function getAddressHistory(
896
911
  address _account
897
- ) public view returns (HistoryMetadata[] memory) {
912
+ ) public view returns (Structs.HistoryMetadata[] memory) {
898
913
  return userHistory[_account];
899
914
  }
900
915
 
@@ -915,12 +930,12 @@ contract Staking is AsyncNonce, StakingStructs {
915
930
  * @dev Allows accessing individual transactions by index
916
931
  * @param _account Address to query the history for
917
932
  * @param _index Index of the transaction to retrieve (0-based)
918
- * @return HistoryMetadata of the transaction at the specified index
933
+ * @return Structs.HistoryMetadata of the transaction at the specified index
919
934
  */
920
935
  function getAddressHistoryByIndex(
921
936
  address _account,
922
937
  uint256 _index
923
- ) public view returns (HistoryMetadata memory) {
938
+ ) public view returns (Structs.HistoryMetadata memory) {
924
939
  return userHistory[_account][_index];
925
940
  }
926
941
 
@@ -946,13 +961,13 @@ contract Staking is AsyncNonce, StakingStructs {
946
961
  if (userHistory[_account][i - 1].totalStaked == 0) {
947
962
  return
948
963
  userHistory[_account][i - 1].timestamp +
949
- secondsToUnllockFullUnstaking.actual;
964
+ secondsToUnllockFullUnstaking.current;
950
965
  }
951
966
  }
952
967
 
953
968
  return
954
969
  userHistory[_account][0].timestamp +
955
- secondsToUnllockFullUnstaking.actual;
970
+ secondsToUnllockFullUnstaking.current;
956
971
  }
957
972
 
958
973
  /**
@@ -972,7 +987,7 @@ contract Staking is AsyncNonce, StakingStructs {
972
987
  if (userHistory[_account][lengthOfHistory - 1].totalStaked == 0) {
973
988
  return
974
989
  userHistory[_account][lengthOfHistory - 1].timestamp +
975
- secondsToUnlockStaking.actual;
990
+ secondsToUnlockStaking.current;
976
991
  } else {
977
992
  return 0;
978
993
  }
@@ -984,7 +999,7 @@ contract Staking is AsyncNonce, StakingStructs {
984
999
  * @return Number of seconds required to wait for full unstaking
985
1000
  */
986
1001
  function getSecondsToUnlockFullUnstaking() external view returns (uint256) {
987
- return secondsToUnllockFullUnstaking.actual;
1002
+ return secondsToUnllockFullUnstaking.current;
988
1003
  }
989
1004
 
990
1005
  /**
@@ -993,7 +1008,7 @@ contract Staking is AsyncNonce, StakingStructs {
993
1008
  * @return Number of seconds required to wait between unstaking and staking
994
1009
  */
995
1010
  function getSecondsToUnlockStaking() external view returns (uint256) {
996
- return secondsToUnlockStaking.actual;
1011
+ return secondsToUnlockStaking.current;
997
1012
  }
998
1013
 
999
1014
  /**
@@ -1020,7 +1035,7 @@ contract Staking is AsyncNonce, StakingStructs {
1020
1035
  * @return Address of the current golden fisher
1021
1036
  */
1022
1037
  function getGoldenFisher() external view returns (address) {
1023
- return goldenFisher.actual;
1038
+ return goldenFisher.current;
1024
1039
  }
1025
1040
 
1026
1041
  /**
@@ -1054,7 +1069,7 @@ contract Staking is AsyncNonce, StakingStructs {
1054
1069
  * @return Address of the current estimator contract
1055
1070
  */
1056
1071
  function getEstimatorAddress() external view returns (address) {
1057
- return estimatorAddress.actual;
1072
+ return estimatorAddress.current;
1058
1073
  }
1059
1074
 
1060
1075
  /**
@@ -1078,12 +1093,12 @@ contract Staking is AsyncNonce, StakingStructs {
1078
1093
  /**
1079
1094
  * @notice Returns the complete public staking configuration and status
1080
1095
  * @dev Includes current flag state and any pending changes with timestamps
1081
- * @return BoolTypeProposal struct containing flag and timeToAccept
1096
+ * @return ProposalStructs.BoolTypeProposal struct containing flag and timeToAccept
1082
1097
  */
1083
1098
  function getAllowPublicStaking()
1084
1099
  external
1085
1100
  view
1086
- returns (BoolTypeProposal memory)
1101
+ returns (ProposalStructs.BoolTypeProposal memory)
1087
1102
  {
1088
1103
  return allowPublicStaking;
1089
1104
  }
@@ -1091,12 +1106,12 @@ contract Staking is AsyncNonce, StakingStructs {
1091
1106
  /**
1092
1107
  * @notice Returns the complete presale staking configuration and status
1093
1108
  * @dev Includes current flag state and any pending changes with timestamps
1094
- * @return BoolTypeProposal struct containing flag and timeToAccept
1109
+ * @return ProposalStructs.BoolTypeProposal struct containing flag and timeToAccept
1095
1110
  */
1096
1111
  function getAllowPresaleStaking()
1097
1112
  external
1098
1113
  view
1099
- returns (BoolTypeProposal memory)
1114
+ returns (ProposalStructs.BoolTypeProposal memory)
1100
1115
  {
1101
1116
  return allowPresaleStaking;
1102
1117
  }
@@ -1107,7 +1122,7 @@ contract Staking is AsyncNonce, StakingStructs {
1107
1122
  * @return Unique EvvmID string
1108
1123
  */
1109
1124
  function getEvvmID() external view returns (uint256) {
1110
- return evvm.getEvvmID();
1125
+ return core.getEvvmID();
1111
1126
  }
1112
1127
 
1113
1128
  /**
@@ -1115,17 +1130,24 @@ contract Staking is AsyncNonce, StakingStructs {
1115
1130
  * @dev The EVVM contract handles payments and staker registration
1116
1131
  * @return Address of the EVVM core contract
1117
1132
  */
1118
- function getEvvmAddress() external view returns (address) {
1133
+ function getCoreAddress() external view returns (address) {
1119
1134
  return EVVM_ADDRESS;
1120
1135
  }
1121
1136
 
1137
+ function getIfUsedAsyncNonce(
1138
+ address user,
1139
+ uint256 nonce
1140
+ ) external view returns (bool) {
1141
+ return core.getIfUsedAsyncNonce(user, nonce);
1142
+ }
1143
+
1122
1144
  /**
1123
1145
  * @notice Returns the address representing the Principal Token
1124
1146
  * @dev This is a constant address used to represent the principal token
1125
1147
  * @return Address representing the Principal Token (0x...0001)
1126
1148
  */
1127
1149
  function getMateAddress() external view returns (address) {
1128
- return evvm.getPrincipalTokenAddress();
1150
+ return core.getPrincipalTokenAddress();
1129
1151
  }
1130
1152
 
1131
1153
  /**
@@ -1134,6 +1156,6 @@ contract Staking is AsyncNonce, StakingStructs {
1134
1156
  * @return Address of the current contract admin
1135
1157
  */
1136
1158
  function getOwner() external view returns (address) {
1137
- return admin.actual;
1159
+ return admin.current;
1138
1160
  }
1139
1161
  }