@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
@@ -1,1300 +0,0 @@
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
- ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
8
- ░▒▓█▓▒░ ░▒▓█▓▒▒▓█▓▒░ ░▒▓█▓▒▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
9
- ░▒▓██████▓▒░ ░▒▓█▓▒▒▓█▓▒░ ░▒▓█▓▒▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
10
- ░▒▓█▓▒░ ░▒▓█▓▓█▓▒░ ░▒▓█▓▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
11
- ░▒▓█▓▒░ ░▒▓█▓▓█▓▒░ ░▒▓█▓▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
12
- ░▒▓████████▓▒░ ░▒▓██▓▒░ ░▒▓██▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░
13
-
14
- ████████╗███████╗███████╗████████╗███╗ ██╗███████╗████████╗
15
- ╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝████╗ ██║██╔════╝╚══██╔══╝
16
- ██║ █████╗ ███████╗ ██║ ██╔██╗ ██║█████╗ ██║
17
- ██║ ██╔══╝ ╚════██║ ██║ ██║╚██╗██║██╔══╝ ██║
18
- ██║ ███████╗███████║ ██║ ██║ ╚████║███████╗ ██║
19
- ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝
20
-
21
- * @title EVVM (Ethereum Virtual Machine Virtualization) Core Contract
22
- * @author Mate labs
23
- * @notice Core payment processing and token management system for the EVVM ecosystem
24
- * @dev This contract serves as the central hub for:
25
- * - Multi-token payment processing with signature verification
26
- * - Staker reward distribution and incentive mechanisms
27
- * - Cross-chain bridge functionality (Fisher Bridge)
28
- * - Balance management across the EVVM ecosystem
29
- * - Integration with NameService for identity-based payments
30
- * - Treasury integration for privileged balance operations
31
- *
32
- * Key Features:
33
- * - Synchronous and asynchronous payment processing with nonce management
34
- * - Staker privilege system with enhanced rewards and transaction processing benefits
35
- * - Multi-recipient payment batching (payMultiple, dispersePay)
36
- * - Administrative payment distribution (caPay, disperseCaPay)
37
- * - Proxy pattern support with delegatecall fallback for upgradeability
38
- * - Cross-chain asset bridging capabilities through Fisher Bridge
39
- * - Deflationary tokenomics with era-based reward halving mechanism
40
- * - Treasury-controlled balance management for minting and burning operations
41
- *
42
- * Payment Types:
43
- * - `payNoStaker_*`: Standard payments for non-stakers with basic functionality
44
- * - `payStaker_*`: Enhanced payments for Principal Token stakers with priority fee rewards
45
- * - `payMultiple`: Batch payments to multiple recipients with individual success tracking
46
- * - `dispersePay`: Single-source multi-recipient distribution with signature verification
47
- * - `caPay`: Administrative token distribution for smart contracts
48
- * - Treasury functions: Direct balance manipulation for authorized operations
49
- *
50
- * Economic Model:
51
- * - Principal Token as principal token with reward distribution system
52
- * - Era-based reward halving when supply thresholds are reached
53
- * - Staker incentives through transaction processing rewards
54
- * - Random bonus rewards for triggering era transitions
55
- *
56
- * Security Features:
57
- * - Signature-based transaction authorization with EIP-191 compliance
58
- * - Dual nonce system: synchronous (sequential) and asynchronous (custom)
59
- * - Executor validation for delegated transaction processing
60
- * - Balance verification before transfers to prevent overdrafts
61
- * - Time-delayed governance for critical upgrades (30-day implementation, 1-day admin)
62
- * - Access control through admin and treasury authorization
63
- *
64
- * Integration Points:
65
- * - NameService: Identity resolution for username-based payments
66
- * - Staking Contract: Staker status management and reward distribution
67
- * - Treasury Contract: Privileged balance operations and token management
68
- * - Implementation Contract: Proxy pattern for contract upgradeability
69
- *
70
- * @custom:version 1.0.0
71
- * @custom:testnet This contract is deployed on testnet for development and testing
72
- * @custom:security Time-delayed governance, signature verification, access control
73
- * @custom:upgrade-pattern Transparent proxy with admin-controlled implementation
74
- */
75
-
76
- import {
77
- NameService
78
- } from "@evvm/testnet-contracts/contracts/nameService/NameService.sol";
79
- import {
80
- EvvmStorage
81
- } from "@evvm/testnet-contracts/contracts/evvm/lib/EvvmStorage.sol";
82
- import {
83
- ErrorsLib
84
- } from "@evvm/testnet-contracts/contracts/evvm/lib/ErrorsLib.sol";
85
- import {
86
- SignatureUtils
87
- } from "@evvm/testnet-contracts/contracts/evvm/lib/SignatureUtils.sol";
88
- import {
89
- AdvancedStrings
90
- } from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
91
-
92
- contract Evvm is EvvmStorage {
93
- /**
94
- * @notice Access control modifier restricting function calls to the current admin
95
- * @dev Validates that msg.sender matches the current admin address before function execution
96
- *
97
- * Access Control:
98
- * - Only the current admin can call functions with this modifier
99
- * - Uses the admin.current address from the storage structure
100
- * - Reverts with no specific error message for unauthorized calls
101
- *
102
- * Usage:
103
- * - Applied to critical administrative functions
104
- * - Protects system configuration changes
105
- * - Prevents unauthorized upgrades and parameter modifications
106
- *
107
- * Security:
108
- * - Simple but effective access control mechanism
109
- * - Used for proxy upgrades, admin transfers, and system configuration
110
- * - Part of the time-delayed governance system for critical operations
111
- */
112
- modifier onlyAdmin() {
113
- if (msg.sender != admin.current) revert ErrorsLib.SenderIsNotAdmin();
114
-
115
- _;
116
- }
117
-
118
- /**
119
- * @notice Initializes the EVVM contract with essential configuration and token distributions
120
- * @dev Sets up the core system parameters, admin roles, and initial Principal Token allocations
121
- *
122
- * Critical Initial Setup:
123
- * - Configures admin address with full administrative privileges
124
- * - Sets staking contract address for reward distribution and status management
125
- * - Stores EVVM metadata including principal token address and reward parameters
126
- * - Distributes initial Principal Tokens to staking contract (2x reward amount)
127
- * - Registers staking contract as privileged staker with full benefits
128
- * - Activates breaker flag for one-time NameService and Treasury setup
129
- *
130
- * Token Distribution:
131
- * - Staking contract receives 2x current reward amount in Principal Tokens
132
- * - Enables immediate reward distribution capabilities
133
- * - Provides operational liquidity for staking rewards
134
- *
135
- * Security Initialization:
136
- * - Sets admin.current for immediate administrative access
137
- * - Prepares system for NameService and Treasury integration
138
- * - Establishes staking privileges for the staking contract
139
- *
140
- * Post-Deployment Requirements:
141
- * - Must call `_setupNameServiceAndTreasuryAddress()` to complete integration
142
- * - NameService and Treasury addresses must be configured before full operation
143
- * - Implementation contract should be set for proxy functionality
144
- *
145
- * @param _initialOwner Address that will have administrative privileges over the contract
146
- * @param _stakingContractAddress Address of the staking contract for reward distribution and staker management
147
- * @param _evvmMetadata Metadata structure containing principal token address, reward amounts, and system parameters
148
- *
149
- * @custom:deployment Must be followed by NameService and Treasury setup
150
- * @custom:security Admin address has full control over system configuration
151
- */
152
- constructor(
153
- address _initialOwner,
154
- address _stakingContractAddress,
155
- EvvmMetadata memory _evvmMetadata
156
- ) {
157
- if (
158
- _initialOwner == address(0) || _stakingContractAddress == address(0)
159
- ) revert ErrorsLib.AddressCantBeZero();
160
-
161
- evvmMetadata = _evvmMetadata;
162
-
163
- stakingContractAddress = _stakingContractAddress;
164
-
165
- admin.current = _initialOwner;
166
-
167
- balances[_stakingContractAddress][evvmMetadata.principalTokenAddress] =
168
- getRewardAmount() *
169
- 2;
170
-
171
- stakerList[_stakingContractAddress] = FLAG_IS_STAKER;
172
-
173
- breakerSetupNameServiceAddress = FLAG_IS_STAKER;
174
- }
175
-
176
- /**
177
- * @notice One-time setup function to configure NameService and Treasury contract addresses
178
- * @dev Can only be called once due to breaker flag mechanism for security
179
- *
180
- * Critical Setup Process:
181
- * - Validates the breaker flag is active (prevents multiple calls)
182
- * - Sets the NameService contract address for identity resolution in payments
183
- * - Configures the Treasury contract address for privileged balance operations
184
- * - Provides initial Principal Token balance (10,000 tokens) to NameService for operations
185
- * - Registers NameService as a privileged staker for enhanced functionality and rewards
186
- *
187
- * Security Features:
188
- * - Single-use function protected by breaker flag
189
- * - Prevents unauthorized reconfiguration of critical system addresses
190
- * - Must be called during initial system deployment phase
191
- *
192
- * Initial Token Distribution:
193
- * - NameService receives 10,000 Principal Tokens for operational expenses
194
- * - NameService gains staker privileges for transaction processing
195
- * - Enables identity-based payment resolution throughout the ecosystem
196
- *
197
- * @param _nameServiceAddress Address of the deployed NameService contract for identity resolution
198
- * @param _treasuryAddress Address of the Treasury contract for balance management operations
199
- *
200
- * @custom:security Single-use function - can only be called once
201
- * @custom:access-control No explicit access control - relies on deployment sequence
202
- * @custom:integration Critical for NameService and Treasury functionality
203
- */
204
- function _setupNameServiceAndTreasuryAddress(
205
- address _nameServiceAddress,
206
- address _treasuryAddress
207
- ) external {
208
- if (breakerSetupNameServiceAddress == 0x00)
209
- revert ErrorsLib.BreakerExploded();
210
-
211
- if (_nameServiceAddress == address(0) || _treasuryAddress == address(0))
212
- revert ErrorsLib.AddressCantBeZero();
213
-
214
- nameServiceAddress = _nameServiceAddress;
215
- balances[nameServiceAddress][evvmMetadata.principalTokenAddress] =
216
- 10000 *
217
- 10 ** 18;
218
- stakerList[nameServiceAddress] = FLAG_IS_STAKER;
219
-
220
- treasuryAddress = _treasuryAddress;
221
- }
222
-
223
- /**
224
- * @notice Updates the EVVM ID with a new value, restricted to admin and time-limited
225
- * @dev Allows the admin to change the EVVM ID within a 1-day window after deployment
226
- */
227
- function setEvvmID(uint256 newEvvmID) external onlyAdmin {
228
- if (evvmMetadata.EvvmID != 0) {
229
- if (block.timestamp > windowTimeToChangeEvvmID)
230
- revert ErrorsLib.WindowExpired();
231
- }
232
-
233
- evvmMetadata.EvvmID = newEvvmID;
234
-
235
- windowTimeToChangeEvvmID = block.timestamp + 24 hours;
236
- }
237
-
238
- /**
239
- * @notice Fallback function implementing proxy pattern with delegatecall to implementation
240
- * @dev Routes all unrecognized function calls to the current implementation contract
241
- *
242
- * Proxy Mechanism:
243
- * - Forwards all calls not handled by this contract to the implementation
244
- * - Uses delegatecall to preserve storage context and msg.sender
245
- * - Allows for contract upgrades without changing the main contract address
246
- * - Maintains all state variables in the proxy contract storage
247
- *
248
- * Implementation Process:
249
- * 1. Validates that an implementation contract is set
250
- * 2. Copies all calldata to memory for forwarding
251
- * 3. Executes delegatecall to implementation with full gas allowance
252
- * 4. Copies the return data back from the implementation
253
- * 5. Returns the result or reverts based on implementation response
254
- *
255
- * Security Features:
256
- * - Reverts if no implementation is set (prevents undefined behavior)
257
- * - Preserves all gas for the implementation call
258
- * - Maintains exact return data and revert behavior from implementation
259
- * - Uses storage slot reading for gas efficiency
260
- *
261
- * Upgrade Compatibility:
262
- * - Enables seamless contract upgrades through implementation changes
263
- * - Preserves all existing state and user balances
264
- * - Allows new functionality addition without user migration
265
- * - Supports time-delayed upgrade governance for security
266
- *
267
- * @custom:security Requires valid implementation address
268
- * @custom:proxy Transparent proxy pattern implementation
269
- * @custom:upgrade-safe Preserves storage layout between upgrades
270
- */
271
- fallback() external {
272
- if (currentImplementation == address(0))
273
- revert ErrorsLib.ImplementationIsNotActive();
274
-
275
- assembly {
276
- /**
277
- * Copy the data of the call
278
- * copy s bytes of calldata from position
279
- * f to mem in position t
280
- * calldatacopy(t, f, s)
281
- */
282
- calldatacopy(0, 0, calldatasize())
283
-
284
- /**
285
- * 2. We make a delegatecall to the implementation
286
- * and we copy the result
287
- */
288
- let result := delegatecall(
289
- gas(), // Send all the available gas
290
- sload(currentImplementation.slot), // Address of the implementation
291
- 0, // Start of the memory where the data is
292
- calldatasize(), // Size of the data
293
- 0, // Where we will store the response
294
- 0 // Initial size of the response
295
- )
296
-
297
- /// Copy the response
298
- returndatacopy(0, 0, returndatasize())
299
-
300
- /// Handle the result
301
- switch result
302
- case 0 {
303
- revert(0, returndatasize()) // If it failed, revert
304
- }
305
- default {
306
- return(0, returndatasize()) // If it worked, return
307
- }
308
- }
309
- }
310
-
311
- /**
312
- * @notice Faucet function to add balance to a user's account for testing purposes
313
- * @dev This function is intended for testnet use only to provide tokens for testing
314
- * @param user The address of the user to receive the balance
315
- * @param token The address of the token contract to add balance for
316
- * @param quantity The amount of tokens to add to the user's balance
317
- */
318
- function addBalance(
319
- address user,
320
- address token,
321
- uint256 quantity
322
- ) external {
323
- balances[user][token] += quantity;
324
- }
325
-
326
- /**
327
- * @notice Faucet function to set point staker status for testing purposes
328
- * @dev This function is intended for testnet use only to configure staker points for testing
329
- * @param user The address of the user to set as point staker
330
- * @param answer The bytes1 value representing the staker status or answer
331
- */
332
- function setPointStaker(address user, bytes1 answer) external {
333
- stakerList[user] = answer;
334
- }
335
-
336
- //░▒▓█ Payment Functions ████████████████████████████████████████████████████████▓▒░
337
-
338
- /**
339
- * @notice Processes single payments
340
- *
341
- * Payment Flow:
342
- * - Validates signature authorization for the payment
343
- * (if synchronous nonce, uses nextSyncUsedNonce inside
344
- * the signature verification to verify the correct nonce)
345
- * - Checks executor permission if specified
346
- * - Validates synchronous nonce matches expected value
347
- * - Resolves recipient address (identity or direct address)
348
- * - If the fisher (msg.sender) is a staker:
349
- * - Transfers priority fee to the fisher
350
- * - Rewards the fisher with Principal tokens
351
- * - Updates balances and increments nonce
352
- *
353
- * @param from Address of the payment sender
354
- * @param to_address Direct recipient address (used if to_identity is empty)
355
- * @param to_identity Username/identity of recipient (resolved via NameService)
356
- * @param token Address of the token contract to transfer
357
- * @param amount Amount of tokens to transfer
358
- * @param priorityFee Additional fee for transaction priority (not used in non-staker payments)
359
- * @param nonce Transaction nonce
360
- * @param priorityFlag Execution type flag (false = sync nonce, true = async nonce)
361
- * @param executor Address authorized to execute this transaction (zero address = sender only)
362
- * @param signature Cryptographic signature authorizing this payment
363
- */
364
- function pay(
365
- address from,
366
- address to_address,
367
- string memory to_identity,
368
- address token,
369
- uint256 amount,
370
- uint256 priorityFee,
371
- uint256 nonce,
372
- bool priorityFlag,
373
- address executor,
374
- bytes memory signature
375
- ) external {
376
- if (
377
- !SignatureUtils.verifyMessageSignedForPay(
378
- evvmMetadata.EvvmID,
379
- from,
380
- to_address,
381
- to_identity,
382
- token,
383
- amount,
384
- priorityFee,
385
- nonce,
386
- priorityFlag,
387
- executor,
388
- signature
389
- )
390
- ) revert ErrorsLib.InvalidSignature();
391
-
392
- if ((executor != address(0)) && (msg.sender != executor))
393
- revert ErrorsLib.SenderIsNotTheExecutor();
394
-
395
- if (priorityFlag) {
396
- if (asyncUsedNonce[from][nonce])
397
- revert ErrorsLib.AsyncNonceAlreadyUsed();
398
- } else {
399
- if (nextSyncUsedNonce[from] != nonce)
400
- revert ErrorsLib.SyncNonceMismatch();
401
- }
402
-
403
- address to = !AdvancedStrings.equal(to_identity, "")
404
- ? NameService(nameServiceAddress).verifyStrictAndGetOwnerOfIdentity(
405
- to_identity
406
- )
407
- : to_address;
408
-
409
- _updateBalance(from, to, token, amount);
410
-
411
- if (isAddressStaker(msg.sender)) {
412
- if (priorityFee > 0) {
413
- _updateBalance(from, msg.sender, token, priorityFee);
414
- }
415
- _giveReward(msg.sender, 1);
416
- }
417
-
418
- if (priorityFlag) asyncUsedNonce[from][nonce] = true;
419
- else nextSyncUsedNonce[from]++;
420
- }
421
-
422
- /**
423
- * @notice Processes multiple payments in a single transaction batch
424
- * @dev Executes an array of payment operations with individual success/failure tracking
425
- *
426
- * Batch Processing Features:
427
- * - Processes each payment independently (partial success allowed)
428
- * - Returns detailed results for each transaction
429
- * - Supports both staker and non-staker payment types
430
- * - Handles both sync and async nonce types per payment
431
- * - Provides comprehensive transaction statistics
432
- *
433
- * Payment Validation:
434
- * - Each payment signature is verified independently
435
- * - Nonce management handled per payment type (sync/async)
436
- * - Identity resolution performed for each recipient
437
- * - Balance updates executed atomically per payment
438
- *
439
- * Return Values:
440
- * - successfulTransactions: Count of completed payments
441
- * - results: Boolean array indicating success/failure for each payment
442
- *
443
- * @param payData Array of PayData structures containing payment details
444
- * @return successfulTransactions Number of payments that completed successfully
445
- * @return results Boolean array with success status for each payment
446
- */
447
- function payMultiple(
448
- PayData[] memory payData
449
- ) external returns (uint256 successfulTransactions, bool[] memory results) {
450
-
451
- bool isSenderStaker = isAddressStaker(msg.sender);
452
- address to_aux;
453
- PayData memory payment;
454
- results = new bool[](payData.length);
455
-
456
- for (uint256 iteration = 0; iteration < payData.length; iteration++) {
457
- payment = payData[iteration];
458
- if (
459
- !SignatureUtils.verifyMessageSignedForPay(
460
- evvmMetadata.EvvmID,
461
- payment.from,
462
- payment.to_address,
463
- payment.to_identity,
464
- payment.token,
465
- payment.amount,
466
- payment.priorityFee,
467
- payment.nonce,
468
- payment.priorityFlag,
469
- payment.executor,
470
- payment.signature
471
- )
472
- ) revert ErrorsLib.InvalidSignature();
473
-
474
- if (
475
- payment.executor != address(0) && msg.sender != payment.executor
476
- ) {
477
- results[iteration] = false;
478
- continue;
479
- }
480
-
481
- if (payment.priorityFlag) {
482
- /// @dev priorityFlag == true (async)
483
-
484
- if (asyncUsedNonce[payment.from][payment.nonce]) {
485
- results[iteration] = false;
486
- continue;
487
- }
488
- } else {
489
- /// @dev priorityFlag == false (sync)
490
-
491
- if (nextSyncUsedNonce[payment.from] != payment.nonce) {
492
- results[iteration] = false;
493
- continue;
494
- }
495
- }
496
-
497
- if (
498
- (isSenderStaker ? payment.priorityFee : 0) + payment.amount >
499
- balances[payment.from][payment.token]
500
- ) {
501
- results[iteration] = false;
502
- continue;
503
- }
504
-
505
- to_aux = !AdvancedStrings.equal(payment.to_identity, "")
506
- ? NameService(nameServiceAddress)
507
- .verifyStrictAndGetOwnerOfIdentity(payment.to_identity)
508
- : payment.to_address;
509
-
510
- /// @dev Because of the previous check, _updateBalance can´t fail
511
-
512
- _updateBalance(payment.from, to_aux, payment.token, payment.amount);
513
-
514
- if (payment.priorityFee > 0 && isSenderStaker)
515
- _updateBalance(
516
- payment.from,
517
- msg.sender,
518
- payment.token,
519
- payment.priorityFee
520
- );
521
-
522
- if (payment.priorityFlag)
523
- asyncUsedNonce[payment.from][payment.nonce] = true;
524
- else nextSyncUsedNonce[payment.from]++;
525
-
526
- successfulTransactions++;
527
- results[iteration] = true;
528
- }
529
-
530
- if (isSenderStaker) _giveReward(msg.sender, successfulTransactions);
531
- }
532
-
533
- /**
534
- * @notice Distributes tokens from a single sender to multiple recipients
535
- * @dev Efficient single-source multi-recipient payment distribution with signature verification
536
- *
537
- * Distribution Features:
538
- * - Single signature authorizes distribution to multiple recipients
539
- * - Supports both direct addresses and identity-based recipients
540
- * - Proportional amount distribution based on recipient configurations
541
- * - Integrated priority fee and staker reward system
542
- * - Supports both sync and async nonce management
543
- *
544
- * Verification Process:
545
- * - Validates single signature for entire distribution
546
- * - Checks total amount and priority fee against sender balance
547
- * - Ensures executor permissions and nonce validity
548
- * - Processes each recipient distribution atomically
549
- *
550
- * Staker Benefits:
551
- * - Executor receives priority fee (if staker)
552
- * - Principal Token reward based on number of successful distributions
553
- *
554
- * @param from Address of the payment sender
555
- * @param toData Array of recipient data with addresses/identities and amounts
556
- * @param token Address of the token contract to distribute
557
- * @param amount Total amount to distribute (must match sum of individual amounts)
558
- * @param priorityFee Fee amount for the transaction executor
559
- * @param nonce Transaction nonce for replay protection
560
- * @param priorityFlag True for async nonce, false for sync nonce
561
- * @param executor Address authorized to execute this distribution
562
- * @param signature Cryptographic signature authorizing this distribution
563
- */
564
- function dispersePay(
565
- address from,
566
- DispersePayMetadata[] memory toData,
567
- address token,
568
- uint256 amount,
569
- uint256 priorityFee,
570
- uint256 nonce,
571
- bool priorityFlag,
572
- address executor,
573
- bytes memory signature
574
- ) external {
575
- if (
576
- !SignatureUtils.verifyMessageSignedForDispersePay(
577
- evvmMetadata.EvvmID,
578
- from,
579
- sha256(abi.encode(toData)),
580
- token,
581
- amount,
582
- priorityFee,
583
- nonce,
584
- priorityFlag,
585
- executor,
586
- signature
587
- )
588
- ) revert ErrorsLib.InvalidSignature();
589
-
590
- if ((executor != address(0)) && (msg.sender != executor))
591
- revert ErrorsLib.SenderIsNotTheExecutor();
592
-
593
- if (priorityFlag) {
594
- if (asyncUsedNonce[from][nonce])
595
- revert ErrorsLib.AsyncNonceAlreadyUsed();
596
- } else {
597
- if (nextSyncUsedNonce[from] != nonce)
598
- revert ErrorsLib.SyncNonceMismatch();
599
- }
600
-
601
- bool isSenderStaker = isAddressStaker(msg.sender);
602
-
603
- if (balances[from][token] < amount + (isSenderStaker ? priorityFee : 0))
604
- revert ErrorsLib.InsufficientBalance();
605
-
606
- uint256 acomulatedAmount = 0;
607
- balances[from][token] -= (amount + (isSenderStaker ? priorityFee : 0));
608
- address to_aux;
609
- for (uint256 i = 0; i < toData.length; i++) {
610
- acomulatedAmount += toData[i].amount;
611
-
612
- if (!AdvancedStrings.equal(toData[i].to_identity, "")) {
613
- if (
614
- NameService(nameServiceAddress).strictVerifyIfIdentityExist(
615
- toData[i].to_identity
616
- )
617
- ) {
618
- to_aux = NameService(nameServiceAddress).getOwnerOfIdentity(
619
- toData[i].to_identity
620
- );
621
- }
622
- } else {
623
- to_aux = toData[i].to_address;
624
- }
625
-
626
- balances[to_aux][token] += toData[i].amount;
627
- }
628
-
629
- if (acomulatedAmount != amount) revert ErrorsLib.InvalidAmount();
630
-
631
- if (isSenderStaker) {
632
- _giveReward(msg.sender, 1);
633
- balances[msg.sender][token] += priorityFee;
634
- }
635
-
636
- if (priorityFlag) asyncUsedNonce[from][nonce] = true;
637
- else nextSyncUsedNonce[from]++;
638
- }
639
-
640
- /**
641
- * @notice Contract-to-address payment function for authorized smart contracts
642
- * @dev Allows registered contracts to distribute tokens without signature verification
643
- *
644
- * Authorization Model:
645
- * - Only smart contracts (non-EOA addresses) can call this function
646
- * - Calling contract must have sufficient token balance
647
- * - No signature verification required (contract-level authorization)
648
- * - Used primarily for automated distributions and rewards
649
- *
650
- * Use Cases:
651
- * - Staking contract reward distributions
652
- * - NameService fee distributions
653
- * - Automated system payouts
654
- * - Cross-contract token transfers
655
- *
656
- * Security Features:
657
- * - Validates caller is a contract (has bytecode)
658
- * - Checks sufficient balance before transfer
659
- * - Direct balance manipulation for efficiency
660
- *
661
- * @param to Address of the token recipient
662
- * @param token Address of the token contract to transfer
663
- * @param amount Amount of tokens to transfer from calling contract
664
- */
665
- function caPay(address to, address token, uint256 amount) external {
666
- uint256 size;
667
- address from = msg.sender;
668
-
669
- assembly {
670
- /// @dev check the size of the opcode of the address
671
- size := extcodesize(from)
672
- }
673
-
674
- if (size == 0) revert ErrorsLib.NotAnCA();
675
-
676
- _updateBalance(from, to, token, amount);
677
-
678
- if (isAddressStaker(msg.sender)) _giveReward(msg.sender, 1);
679
- }
680
-
681
- /**
682
- * @notice Contract-to-multiple-addresses payment distribution function
683
- * @dev Allows authorized contracts to distribute tokens to multiple recipients efficiently
684
- *
685
- * Batch Distribution Features:
686
- * - Single call distributes to multiple recipients
687
- * - Supports both direct addresses and identity resolution
688
- * - Validates total amount matches sum of individual distributions
689
- * - Optimized for contract-based automated distributions
690
- *
691
- * Authorization Model:
692
- * - Only smart contracts can call this function
693
- * - No signature verification required (contract authorization)
694
- * - Calling contract must have sufficient balance for total distribution
695
- *
696
- * Use Cases:
697
- * - Bulk reward distributions from staking contracts
698
- * - Multi-recipient fee distributions
699
- * - Batch payroll or dividend distributions
700
- * - Cross-contract multi-party settlements
701
- *
702
- * @param toData Array of recipient data containing addresses/identities and amounts
703
- * @param token Address of the token contract to distribute
704
- * @param amount Total amount to distribute (must equal sum of individual amounts)
705
- */
706
- function disperseCaPay(
707
- DisperseCaPayMetadata[] memory toData,
708
- address token,
709
- uint256 amount
710
- ) external {
711
- uint256 size;
712
- address from = msg.sender;
713
-
714
- assembly {
715
- /// @dev check the size of the opcode of the address
716
- size := extcodesize(from)
717
- }
718
-
719
- if (size == 0) revert ErrorsLib.NotAnCA();
720
-
721
- if (balances[msg.sender][token] < amount)
722
- revert ErrorsLib.InsufficientBalance();
723
-
724
- uint256 acomulatedAmount = 0;
725
-
726
- balances[msg.sender][token] -= amount;
727
-
728
- for (uint256 i = 0; i < toData.length; i++) {
729
- acomulatedAmount += toData[i].amount;
730
- balances[toData[i].toAddress][token] += toData[i].amount;
731
- }
732
-
733
- if (acomulatedAmount != amount) revert ErrorsLib.InvalidAmount();
734
-
735
- if (isAddressStaker(msg.sender)) _giveReward(msg.sender, 1);
736
- }
737
-
738
- //░▒▓█Treasury exclusive functions██████████████████████████████████████████▓▒░
739
-
740
- /**
741
- * @notice Adds tokens to a user's balance in the EVVM system
742
- * @dev Restricted function that can only be called by the authorized treasury contract
743
- *
744
- * Treasury Operations:
745
- * - Allows treasury to mint or credit tokens to user accounts
746
- * - Used for reward distributions, airdrops, or token bridging
747
- * - Direct balance manipulation bypasses normal transfer restrictions
748
- * - No signature verification required (treasury authorization)
749
- *
750
- * Access Control:
751
- * - Only the registered treasury contract can call this function
752
- * - Reverts with SenderIsNotTreasury error for unauthorized callers
753
- * - Provides centralized token distribution mechanism
754
- *
755
- * Use Cases:
756
- * - Cross-chain bridge token minting
757
- * - Administrative reward distributions
758
- * - System-level token allocations
759
- * - Emergency balance corrections
760
- *
761
- * @param user Address of the user to receive tokens
762
- * @param token Address of the token contract to add balance for
763
- * @param amount Amount of tokens to add to the user's balance
764
- *
765
- * @custom:access-control Only treasury contract
766
- * @custom:security No overflow protection needed due to controlled access
767
- */
768
- function addAmountToUser(
769
- address user,
770
- address token,
771
- uint256 amount
772
- ) external {
773
- if (msg.sender != treasuryAddress)
774
- revert ErrorsLib.SenderIsNotTreasury();
775
-
776
- balances[user][token] += amount;
777
- }
778
-
779
- /**
780
- * @notice Removes tokens from a user's balance in the EVVM system
781
- * @dev Restricted function that can only be called by the authorized treasury contract
782
- *
783
- * Treasury Operations:
784
- * - Allows treasury to burn or debit tokens from user accounts
785
- * - Used for cross-chain bridging, penalties, or system corrections
786
- * - Direct balance manipulation bypasses normal transfer protections
787
- * - Can potentially create negative balances if not carefully managed
788
- *
789
- * Access Control:
790
- * - Only the registered treasury contract can call this function
791
- * - Reverts with SenderIsNotTreasury error for unauthorized callers
792
- * - Provides centralized token withdrawal mechanism
793
- *
794
- * Use Cases:
795
- * - Cross-chain bridge token burning
796
- * - Administrative penalty applications
797
- * - System-level token reclamations
798
- * - Emergency balance corrections
799
- *
800
- * Security Considerations:
801
- * - No underflow protection: treasury must ensure sufficient balance
802
- * - Can result in unexpected negative balances if misused
803
- * - Treasury contract should implement additional validation
804
- *
805
- * @param user Address of the user to remove tokens from
806
- * @param token Address of the token contract to remove balance for
807
- * @param amount Amount of tokens to remove from the user's balance
808
- *
809
- * @custom:access-control Only treasury contract
810
- * @custom:security No underflow protection - treasury responsibility
811
- */
812
- function removeAmountFromUser(
813
- address user,
814
- address token,
815
- uint256 amount
816
- ) external {
817
- if (msg.sender != treasuryAddress)
818
- revert ErrorsLib.SenderIsNotTreasury();
819
-
820
- balances[user][token] -= amount;
821
- }
822
-
823
- //█ Internal Functions ███████████████████████████████████████████████████████████████████
824
-
825
- //█ Balance Management Functions █████████████████████████████████████████████
826
-
827
- /**
828
- * @notice Internal function to safely transfer tokens between addresses
829
- * @dev Performs balance validation and atomic transfer with overflow protection
830
- *
831
- * Transfer Process:
832
- * - Validates sender has sufficient balance
833
- * - Performs atomic balance updates using unchecked arithmetic
834
- * - Returns success/failure status for error handling
835
- *
836
- * Security Features:
837
- * - Balance validation prevents overdrafts
838
- * - Unchecked arithmetic for gas optimization (overflow impossible)
839
- * - Returns boolean for caller error handling
840
- *
841
- * @param from Address to transfer tokens from
842
- * @param to Address to transfer tokens to
843
- * @param token Address of the token contract
844
- * @param value Amount of tokens to transfer
845
- */
846
- function _updateBalance(
847
- address from,
848
- address to,
849
- address token,
850
- uint256 value
851
- ) internal {
852
- uint256 fromBalance = balances[from][token];
853
- if (fromBalance < value) revert ErrorsLib.InsufficientBalance();
854
-
855
- unchecked {
856
- balances[from][token] = fromBalance - value;
857
- balances[to][token] += value;
858
- }
859
- }
860
-
861
- /**
862
- * @notice Internal function to distribute Principal Token rewards to stakers
863
- * @dev Provides incentive distribution for transaction processing and staking participation
864
- *
865
- * Reward System:
866
- * - Calculates reward based on system reward rate and transaction count
867
- * - Directly increases principal token balance for gas efficiency
868
- * - Returns success status for error handling in calling functions
869
- *
870
- * Reward Calculation:
871
- * - Base reward per transaction: evvmMetadata.reward
872
- * - Total reward: base_reward × transaction_amount
873
- * - Added directly to user's Principal Token balance
874
- *
875
- * @param user Address of the staker to receive principal tokenrewards
876
- * @param amount Number of transactions or reward multiplier
877
- * @return success True if reward distribution completed successfully
878
- */
879
- function _giveReward(address user, uint256 amount) internal returns (bool) {
880
- uint256 principalReward = evvmMetadata.reward * amount;
881
- uint256 userBalance = balances[user][
882
- evvmMetadata.principalTokenAddress
883
- ];
884
-
885
- balances[user][evvmMetadata.principalTokenAddress] =
886
- userBalance +
887
- principalReward;
888
-
889
- return (userBalance + principalReward ==
890
- balances[user][evvmMetadata.principalTokenAddress]);
891
- }
892
-
893
- //█ Administrative Functions ██████████████████████████████████████████████████████████████
894
-
895
- //█ Proxy Management Functions █████████████████████████████████████████████
896
-
897
- /**
898
- * @notice Proposes a new implementation contract for the proxy with time delay
899
- * @dev Part of the time-delayed governance system for critical upgrades
900
- *
901
- * Upgrade Security:
902
- * - 30-day time delay for implementation changes
903
- * - Only admin can propose upgrades
904
- * - Allows time for community review and validation
905
- * - Can be rejected before acceptance deadline
906
- *
907
- * @param _newImpl Address of the new implementation contract
908
- */
909
- function proposeImplementation(address _newImpl) external onlyAdmin {
910
- if (_newImpl == address(0)) revert ErrorsLib.IncorrectAddressInput();
911
- proposalImplementation = _newImpl;
912
- timeToAcceptImplementation =
913
- block.timestamp +
914
- TIME_TO_ACCEPT_IMPLEMENTATION;
915
- }
916
-
917
- /**
918
- * @notice Cancels a pending implementation upgrade proposal
919
- * @dev Allows admin to reject proposed upgrades before the time delay expires
920
- */
921
- function rejectUpgrade() external onlyAdmin {
922
- proposalImplementation = address(0);
923
- timeToAcceptImplementation = 0;
924
- }
925
-
926
- /**
927
- * @notice Accepts a pending implementation upgrade after the time delay
928
- * @dev Executes the proxy upgrade to the new implementation contract
929
- */
930
- function acceptImplementation() external onlyAdmin {
931
- if (block.timestamp < timeToAcceptImplementation)
932
- revert ErrorsLib.TimeLockNotExpired();
933
-
934
- currentImplementation = proposalImplementation;
935
- proposalImplementation = address(0);
936
- timeToAcceptImplementation = 0;
937
- }
938
-
939
- //█ Admin Management Functions ███████████████████████████████████████████████
940
-
941
- /**
942
- * @notice Proposes a new admin address with 1-day time delay
943
- * @dev Part of the time-delayed governance system for admin changes
944
- * @param _newOwner Address of the proposed new admin
945
- */
946
- function proposeAdmin(address _newOwner) external onlyAdmin {
947
- if (_newOwner == address(0) || _newOwner == admin.current)
948
- revert ErrorsLib.IncorrectAddressInput();
949
-
950
- admin = AddressTypeProposal({
951
- current: admin.current,
952
- proposal: _newOwner,
953
- timeToAccept: block.timestamp + TIME_TO_ACCEPT_PROPOSAL
954
- });
955
- }
956
-
957
- /**
958
- * @notice Cancels a pending admin change proposal
959
- * @dev Allows current admin to reject proposed admin changes
960
- */
961
- function rejectProposalAdmin() external onlyAdmin {
962
- admin = AddressTypeProposal({
963
- current: admin.current,
964
- proposal: address(0),
965
- timeToAccept: 0
966
- });
967
- }
968
-
969
- /**
970
- * @notice Accepts a pending admin proposal and becomes the new admin
971
- * @dev Can only be called by the proposed admin after the time delay
972
- */
973
- function acceptAdmin() external {
974
- if (block.timestamp < admin.timeToAccept)
975
- revert ErrorsLib.TimeLockNotExpired();
976
-
977
- if (msg.sender != admin.proposal)
978
- revert ErrorsLib.SenderIsNotTheProposedAdmin();
979
-
980
- admin = AddressTypeProposal({
981
- current: admin.proposal,
982
- proposal: address(0),
983
- timeToAccept: 0
984
- });
985
- }
986
-
987
- //█ Reward System Functions ███████████████████████████████████████████████████████████████
988
-
989
- /**
990
- * @notice Triggers a reward recalculation and era transition in the token economy
991
- * @dev Implements deflationary tokenomics with halving mechanism and random rewards
992
- *
993
- * Era Transition Mechanism:
994
- * - Activates when total supply exceeds current era token threshold
995
- * - Moves half of remaining tokens to next era threshold
996
- * - Halves the base reward amount for future transactions
997
- * - Provides random Principal Token bonus to caller (1-5083x reward)
998
- *
999
- * Economic Impact:
1000
- * - Gradually reduces inflation through reward halving
1001
- * - Creates scarcity as era thresholds become harder to reach
1002
- * - Incentivizes early participation with higher rewards
1003
- * - Provides lottery-style bonus for triggering era transitions
1004
- *
1005
- * Requirements:
1006
- * - Total supply must exceed current era token threshold
1007
- * - Can be called by anyone when conditions are met
1008
- */
1009
- function recalculateReward() public {
1010
- if (evvmMetadata.totalSupply > evvmMetadata.eraTokens) {
1011
- evvmMetadata.eraTokens += ((evvmMetadata.totalSupply -
1012
- evvmMetadata.eraTokens) / 2);
1013
- balances[msg.sender][evvmMetadata.principalTokenAddress] +=
1014
- evvmMetadata.reward *
1015
- getRandom(1, 5083);
1016
- evvmMetadata.reward = evvmMetadata.reward / 2;
1017
- } else {
1018
- revert();
1019
- }
1020
- }
1021
-
1022
- /**
1023
- * @notice Generates a pseudo-random number within a specified range
1024
- * @dev Uses block timestamp and prevrandao for randomness (suitable for non-critical randomness)
1025
- *
1026
- * Randomness Source:
1027
- * - Combines block.timestamp and block.prevrandao
1028
- * - Suitable for reward bonuses and non-security-critical randomness
1029
- * - Not suitable for high-stakes randomness requiring true unpredictability
1030
- *
1031
- * @param min Minimum value (inclusive)
1032
- * @param max Maximum value (inclusive)
1033
- * @return Random number between min and max (inclusive)
1034
- */
1035
- function getRandom(
1036
- uint256 min,
1037
- uint256 max
1038
- ) internal view returns (uint256) {
1039
- return
1040
- min +
1041
- (uint256(
1042
- keccak256(abi.encodePacked(block.timestamp, block.prevrandao))
1043
- ) % (max - min + 1));
1044
- }
1045
-
1046
- //█ Staking Integration Functions █████████████████████████████████████████████████████████
1047
-
1048
- /**
1049
- * @notice Updates staker status for a user address
1050
- * @dev Can only be called by the authorized staking contract
1051
- *
1052
- * Staker Status Management:
1053
- * - Controls who can earn staking rewards and process transactions
1054
- * - Integrates with external staking contract for validation
1055
- * - Updates affect payment processing privileges and reward eligibility
1056
- *
1057
- * Access Control:
1058
- * - Only the registered staking contract can call this function
1059
- * - Ensures staker status changes are properly authorized
1060
- *
1061
- * @param user Address to update staker status for
1062
- * @param answer Bytes1 flag indicating staker status/type
1063
- */
1064
- function pointStaker(address user, bytes1 answer) public {
1065
- if (msg.sender != stakingContractAddress) revert();
1066
-
1067
- stakerList[user] = answer;
1068
- }
1069
-
1070
- //█ View Functions ████████████████████████████████████████████████████████████████████████
1071
-
1072
- /**
1073
- * @notice Returns the complete EVVM metadata configuration
1074
- * @dev Provides access to system-wide configuration and economic parameters
1075
- *
1076
- * Metadata Contents:
1077
- * - Principal token address (Principal Token)
1078
- * - Current reward amount per transaction
1079
- * - Total supply tracking
1080
- * - Era tokens threshold for reward transitions
1081
- * - System configuration parameters
1082
- *
1083
- * @return Complete EvvmMetadata struct with all system parameters
1084
- */
1085
- function getEvvmMetadata() external view returns (EvvmMetadata memory) {
1086
- return evvmMetadata;
1087
- }
1088
-
1089
- /**
1090
- * @notice Gets the address representing the Principal Token in balance mappings
1091
- * @dev Returns the virtual address used to track Principal Token balances in the balances mapping
1092
- * This is not an ERC20 contract address but a sentinel value for the EVVM-native token
1093
- * @return Address used as the key for Principal Token balances
1094
- */
1095
- function getPrincipalTokenAddress() external view returns (address) {
1096
- return evvmMetadata.principalTokenAddress;
1097
- }
1098
-
1099
- /**
1100
- * @notice Gets the address representing native chain currency (ETH/MATIC) in balance mappings
1101
- * @dev Returns address(0) which is the standard sentinel for native blockchain tokens
1102
- * Use this address as the token parameter when dealing with ETH or chain-native assets
1103
- * @return address(0) representing the native chain currency
1104
- */
1105
- function getChainHostCoinAddress() external pure returns (address) {
1106
- return address(0);
1107
- }
1108
-
1109
- /**
1110
- * @notice Gets the unique identifier string for this EVVM instance
1111
- * @dev Returns the EvvmID used for distinguishing different EVVM deployments
1112
- * @return Unique EvvmID string
1113
- */
1114
- function getEvvmID() external view returns (uint256) {
1115
- return evvmMetadata.EvvmID;
1116
- }
1117
-
1118
- /**
1119
- * @notice Gets the acceptance deadline for pending token whitelist proposals
1120
- * @dev Returns timestamp when prepared tokens can be added to whitelist
1121
- * @return Timestamp when pending token can be whitelisted (0 if no pending proposal)
1122
- */
1123
- function getWhitelistTokenToBeAddedDateToSet()
1124
- external
1125
- view
1126
- returns (uint256)
1127
- {
1128
- return whitelistTokenToBeAdded_dateToSet;
1129
- }
1130
-
1131
- /**
1132
- * @notice Gets the current NameService contract address
1133
- * @dev Returns the address used for identity resolution in payments
1134
- * @return Address of the integrated NameService contract
1135
- */
1136
- function getNameServiceAddress() external view returns (address) {
1137
- return nameServiceAddress;
1138
- }
1139
-
1140
- /**
1141
- * @notice Gets the authorized staking contract address
1142
- * @dev Returns the address that can modify staker status and receive rewards
1143
- * @return Address of the integrated staking contract
1144
- */
1145
- function getStakingContractAddress() external view returns (address) {
1146
- return stakingContractAddress;
1147
- }
1148
-
1149
- /**
1150
- * @notice Gets the next synchronous nonce for a user
1151
- * @dev Returns the expected nonce for the next sync payment transaction
1152
- * @param user Address to check sync nonce for
1153
- * @return Next synchronous nonce value
1154
- */
1155
- function getNextCurrentSyncNonce(
1156
- address user
1157
- ) external view returns (uint256) {
1158
- return nextSyncUsedNonce[user];
1159
- }
1160
-
1161
- /**
1162
- * @notice Checks if a specific async nonce has been used by a user
1163
- * @dev Verifies nonce status to prevent replay attacks in async payments
1164
- * @param user Address to check nonce usage for
1165
- * @param nonce Specific nonce value to verify
1166
- * @return True if the nonce has been used, false if still available
1167
- */
1168
- function getIfUsedAsyncNonce(
1169
- address user,
1170
- uint256 nonce
1171
- ) external view returns (bool) {
1172
- return asyncUsedNonce[user][nonce];
1173
- }
1174
-
1175
- /**
1176
- * @notice Gets the next Fisher Bridge deposit nonce for a user
1177
- * @dev Returns the expected nonce for the next cross-chain deposit
1178
- * @param user Address to check deposit nonce for
1179
- * @return Next Fisher Bridge deposit nonce
1180
- */
1181
- function getNextFisherDepositNonce(
1182
- address user
1183
- ) external view returns (uint256) {
1184
- return nextFisherDepositNonce[user];
1185
- }
1186
-
1187
- /**
1188
- * @notice Gets the balance of a specific token for a user
1189
- * @dev Returns the current balance stored in the EVVM system
1190
- * @param user Address to check balance for
1191
- * @param token Token contract address to check
1192
- * @return Current token balance for the user
1193
- */
1194
- function getBalance(
1195
- address user,
1196
- address token
1197
- ) external view returns (uint) {
1198
- return balances[user][token];
1199
- }
1200
-
1201
- /**
1202
- * @notice Checks if an address is registered as a staker
1203
- * @dev Verifies staker status for transaction processing privileges and rewards
1204
- * @param user Address to check staker status for
1205
- * @return True if the address is a registered staker
1206
- */
1207
- function isAddressStaker(address user) public view returns (bool) {
1208
- return stakerList[user] == FLAG_IS_STAKER;
1209
- }
1210
-
1211
- /**
1212
- * @notice Gets the current era token threshold for reward transitions
1213
- * @dev Returns the token supply threshold that triggers the next reward halving
1214
- * @return Current era tokens threshold
1215
- */
1216
- function getEraPrincipalToken() public view returns (uint256) {
1217
- return evvmMetadata.eraTokens;
1218
- }
1219
-
1220
- /**
1221
- * @notice Gets the current Principal Token reward amount per transaction
1222
- * @dev Returns the base reward distributed to stakers for transaction processing
1223
- * @return Current reward amount in Principal Tokens
1224
- */
1225
- function getRewardAmount() public view returns (uint256) {
1226
- return evvmMetadata.reward;
1227
- }
1228
-
1229
- /**
1230
- * @notice Gets the total supply of the Principal Token
1231
- * @dev Returns the current total supply used for era transition calculations
1232
- * @return Total supply of Principal Tokens
1233
- */
1234
- function getPrincipalTokenTotalSupply() public view returns (uint256) {
1235
- return evvmMetadata.totalSupply;
1236
- }
1237
-
1238
- /**
1239
- * @notice Gets the current active implementation contract address
1240
- * @dev Returns the implementation used by the proxy for delegatecalls
1241
- * @return Address of the current implementation contract
1242
- */
1243
- function getCurrentImplementation() public view returns (address) {
1244
- return currentImplementation;
1245
- }
1246
-
1247
- /**
1248
- * @notice Gets the proposed implementation contract address
1249
- * @dev Returns the implementation pending approval for proxy upgrade
1250
- * @return Address of the proposed implementation contract (zero if none)
1251
- */
1252
- function getProposalImplementation() public view returns (address) {
1253
- return proposalImplementation;
1254
- }
1255
-
1256
- /**
1257
- * @notice Gets the acceptance deadline for the pending implementation upgrade
1258
- * @dev Returns timestamp when the proposed implementation can be accepted
1259
- * @return Timestamp when implementation upgrade can be executed (0 if no pending proposal)
1260
- */
1261
- function getTimeToAcceptImplementation() public view returns (uint256) {
1262
- return timeToAcceptImplementation;
1263
- }
1264
-
1265
- /**
1266
- * @notice Gets the current admin address
1267
- * @dev Returns the address with administrative privileges over the contract
1268
- * @return Address of the current admin
1269
- */
1270
- function getCurrentAdmin() public view returns (address) {
1271
- return admin.current;
1272
- }
1273
-
1274
- /**
1275
- * @notice Gets the proposed admin address
1276
- * @dev Returns the address pending approval for admin privileges
1277
- * @return Address of the proposed admin (zero if no pending proposal)
1278
- */
1279
- function getProposalAdmin() public view returns (address) {
1280
- return admin.proposal;
1281
- }
1282
-
1283
- /**
1284
- * @notice Gets the acceptance deadline for the pending admin change
1285
- * @dev Returns timestamp when the proposed admin can accept the role
1286
- * @return Timestamp when admin change can be executed (0 if no pending proposal)
1287
- */
1288
- function getTimeToAcceptAdmin() public view returns (uint256) {
1289
- return admin.timeToAccept;
1290
- }
1291
-
1292
- /**
1293
- * @notice Gets the address of the token pending whitelist approval
1294
- * @dev Returns the token address that can be whitelisted after time delay
1295
- * @return Address of the token prepared for whitelisting (zero if none)
1296
- */
1297
- function getWhitelistTokenToBeAdded() public view returns (address) {
1298
- return whitelistTokenToBeAdded_address;
1299
- }
1300
- }