@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.
- package/README.md +44 -24
- package/contracts/core/Core.sol +1392 -0
- package/contracts/core/lib/CoreStorage.sol +171 -0
- package/contracts/nameService/NameService.sol +613 -543
- package/contracts/nameService/lib/IdentityValidation.sol +15 -21
- package/contracts/p2pSwap/P2PSwap.sol +258 -145
- package/contracts/staking/Estimator.sol +25 -44
- package/contracts/staking/Staking.sol +284 -262
- package/contracts/treasury/Treasury.sol +40 -47
- package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +585 -198
- package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +425 -174
- package/contracts/treasuryTwoChains/lib/PayloadUtils.sol +2 -4
- package/interfaces/{IEvvm.sol → ICore.sol} +58 -25
- package/interfaces/IEstimator.sol +1 -1
- package/interfaces/INameService.sol +46 -49
- package/interfaces/IP2PSwap.sol +16 -17
- package/interfaces/IStaking.sol +21 -17
- package/interfaces/ITreasury.sol +2 -1
- package/interfaces/ITreasuryExternalChainStation.sol +15 -9
- package/interfaces/ITreasuryHostChainStation.sol +14 -11
- package/interfaces/IUserValidator.sol +6 -0
- package/library/Erc191TestBuilder.sol +336 -471
- package/library/EvvmService.sol +27 -71
- package/library/errors/CoreError.sol +116 -0
- package/library/errors/CrossChainTreasuryError.sol +36 -0
- package/library/errors/NameServiceError.sol +79 -0
- package/library/errors/StakingError.sol +79 -0
- package/{contracts/treasury/lib/ErrorsLib.sol → library/errors/TreasuryError.sol} +9 -17
- package/library/structs/CoreStructs.sol +146 -0
- package/library/structs/ExternalChainStationStructs.sol +92 -0
- package/library/structs/HostChainStationStructs.sol +77 -0
- package/library/structs/NameServiceStructs.sol +47 -0
- package/library/structs/P2PSwapStructs.sol +127 -0
- package/library/structs/StakingStructs.sol +67 -0
- package/library/utils/AdvancedStrings.sol +62 -44
- package/library/utils/CAUtils.sol +29 -0
- package/library/utils/governance/Admin.sol +66 -0
- package/library/utils/governance/ProposalStructs.sol +49 -0
- package/library/utils/service/CoreExecution.sol +158 -0
- package/library/utils/service/StakingServiceUtils.sol +20 -37
- package/library/utils/signature/CoreHashUtils.sol +73 -0
- package/library/utils/signature/NameServiceHashUtils.sol +156 -0
- package/library/utils/signature/P2PSwapHashUtils.sol +65 -0
- package/library/utils/signature/StakingHashUtils.sol +41 -0
- package/library/utils/signature/TreasuryCrossChainHashUtils.sol +40 -0
- package/package.json +1 -1
- package/contracts/evvm/Evvm.sol +0 -1300
- package/contracts/evvm/lib/ErrorsLib.sol +0 -131
- package/contracts/evvm/lib/EvvmStorage.sol +0 -217
- package/contracts/evvm/lib/EvvmStructs.sol +0 -208
- package/contracts/evvm/lib/SignatureUtils.sol +0 -162
- package/contracts/nameService/lib/ErrorsLib.sol +0 -155
- package/contracts/nameService/lib/NameServiceStructs.sol +0 -125
- package/contracts/nameService/lib/SignatureUtils.sol +0 -420
- package/contracts/p2pSwap/lib/P2PSwapStructs.sol +0 -59
- package/contracts/p2pSwap/lib/SignatureUtils.sol +0 -98
- package/contracts/staking/lib/ErrorsLib.sol +0 -98
- package/contracts/staking/lib/SignatureUtils.sol +0 -105
- package/contracts/staking/lib/StakingStructs.sol +0 -106
- package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +0 -48
- package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +0 -80
- package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +0 -87
- package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +0 -79
- package/library/utils/GovernanceUtils.sol +0 -81
- package/library/utils/nonces/AsyncNonce.sol +0 -74
- package/library/utils/nonces/SyncNonce.sol +0 -71
- package/library/utils/service/EvvmPayments.sol +0 -144
|
@@ -2,6 +2,12 @@
|
|
|
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 {Staking} from "@evvm/testnet-contracts/contracts/staking/Staking.sol";
|
|
7
|
+
import {
|
|
8
|
+
StakingStructs
|
|
9
|
+
} from "@evvm/testnet-contracts/library/structs/StakingStructs.sol";
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
MM""""""""`M dP oo dP
|
|
7
13
|
MM mmmmmmmM 88 88
|
|
@@ -11,39 +17,14 @@ MM MMMMMMMM 88 88 88 88 88 88 88. .88 88 88. .88 88
|
|
|
11
17
|
MM .M `88888P' dP dP dP dP dP `88888P8 dP `88888P' dP
|
|
12
18
|
MMMMMMMMMMMM
|
|
13
19
|
|
|
14
|
-
* @title Staking Estimator
|
|
20
|
+
* @title EVVM Staking Estimator
|
|
15
21
|
* @author Mate Labs
|
|
16
|
-
* @notice
|
|
17
|
-
* @dev
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* Key Responsibilities:
|
|
21
|
-
* - Track epoch metadata (pool, total staked, time periods)
|
|
22
|
-
* - Calculate time-weighted average stake for each user
|
|
23
|
-
* - Determine proportional reward distribution
|
|
24
|
-
*
|
|
25
|
-
* Reward Calculation Formula:
|
|
26
|
-
* The time-weighted average is calculated as:
|
|
27
|
-
* Sum of [(ti - ti-1) x Si-1] x 10^18 / (tFinal - tStart)
|
|
28
|
-
*
|
|
29
|
-
* Where:
|
|
30
|
-
* - ti: timestamp of current iteration
|
|
31
|
-
* - ti-1: timestamp of previous iteration
|
|
32
|
-
* - Si-1: stake amount at previous iteration
|
|
33
|
-
* - tFinal: epoch end timestamp
|
|
34
|
-
* - tStart: epoch start timestamp
|
|
35
|
-
*
|
|
36
|
-
* Access Control:
|
|
37
|
-
* - onlyStaking: Functions callable only by the Staking contract
|
|
38
|
-
* - onlyActivator: Functions callable only by the epoch activator
|
|
39
|
-
* - onlyAdmin: Administrative functions for governance
|
|
22
|
+
* @notice Calculates validator rewards using time-weighted averages.
|
|
23
|
+
* @dev Collaborates with Staking.sol to track epochs, total staked amounts, and distribution pools.
|
|
24
|
+
* Features time-delayed governance for administrative changes.
|
|
40
25
|
*/
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
import {
|
|
44
|
-
StakingStructs
|
|
45
|
-
} from "@evvm/testnet-contracts/contracts/staking/lib/StakingStructs.sol";
|
|
46
|
-
import {Evvm} from "@evvm/testnet-contracts/contracts/evvm/Evvm.sol";
|
|
27
|
+
|
|
47
28
|
|
|
48
29
|
contract Estimator {
|
|
49
30
|
/// @dev Struct for managing address change proposals with time delay
|
|
@@ -81,7 +62,7 @@ contract Estimator {
|
|
|
81
62
|
/// @dev Proposal system for activator address changes
|
|
82
63
|
AddressTypeProposal private activator;
|
|
83
64
|
/// @dev Proposal system for EVVM address changes
|
|
84
|
-
AddressTypeProposal private
|
|
65
|
+
AddressTypeProposal private coreAddress;
|
|
85
66
|
/// @dev Proposal system for Staking contract address changes
|
|
86
67
|
AddressTypeProposal private addressStaking;
|
|
87
68
|
/// @dev Proposal system for admin address changes
|
|
@@ -119,18 +100,18 @@ contract Estimator {
|
|
|
119
100
|
* @notice Initializes the Estimator contract
|
|
120
101
|
* @dev Sets up all required addresses for contract operation
|
|
121
102
|
* @param _activator Address authorized to start new epochs
|
|
122
|
-
* @param
|
|
103
|
+
* @param _coreAddress Address of the EVVM core contract
|
|
123
104
|
* @param _addressStaking Address of the Staking contract
|
|
124
105
|
* @param _admin Address with administrative privileges
|
|
125
106
|
*/
|
|
126
107
|
constructor(
|
|
127
108
|
address _activator,
|
|
128
|
-
address
|
|
109
|
+
address _coreAddress,
|
|
129
110
|
address _addressStaking,
|
|
130
111
|
address _admin
|
|
131
112
|
) {
|
|
132
113
|
activator.actual = _activator;
|
|
133
|
-
|
|
114
|
+
coreAddress.actual = _coreAddress;
|
|
134
115
|
addressStaking.actual = _addressStaking;
|
|
135
116
|
admin.actual = _admin;
|
|
136
117
|
}
|
|
@@ -273,23 +254,23 @@ contract Estimator {
|
|
|
273
254
|
/// @notice Proposes a new EVVM address with 1-day time delay
|
|
274
255
|
/// @param _proposal Address of the proposed new EVVM contract
|
|
275
256
|
function setEvvmAddressProposal(address _proposal) external onlyAdmin {
|
|
276
|
-
|
|
277
|
-
|
|
257
|
+
coreAddress.proposal = _proposal;
|
|
258
|
+
coreAddress.timeToAccept = block.timestamp + 1 days;
|
|
278
259
|
}
|
|
279
260
|
|
|
280
261
|
/// @notice Cancels the pending EVVM address proposal
|
|
281
262
|
function cancelEvvmAddressProposal() external onlyAdmin {
|
|
282
|
-
|
|
283
|
-
|
|
263
|
+
coreAddress.proposal = address(0);
|
|
264
|
+
coreAddress.timeToAccept = 0;
|
|
284
265
|
}
|
|
285
266
|
|
|
286
267
|
/// @notice Accepts the EVVM address proposal after time delay
|
|
287
268
|
function acceptEvvmAddressProposal() external onlyAdmin {
|
|
288
|
-
if (block.timestamp <
|
|
269
|
+
if (block.timestamp < coreAddress.timeToAccept) revert();
|
|
289
270
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
271
|
+
coreAddress.actual = coreAddress.proposal;
|
|
272
|
+
coreAddress.proposal = address(0);
|
|
273
|
+
coreAddress.timeToAccept = 0;
|
|
293
274
|
}
|
|
294
275
|
|
|
295
276
|
/// @notice Proposes a new Staking contract address with 1-day time delay
|
|
@@ -370,12 +351,12 @@ contract Estimator {
|
|
|
370
351
|
|
|
371
352
|
/// @notice Returns the EVVM address proposal information
|
|
372
353
|
/// @return Complete AddressTypeProposal struct for EVVM
|
|
373
|
-
function
|
|
354
|
+
function getCoreAddressMetadata()
|
|
374
355
|
external
|
|
375
356
|
view
|
|
376
357
|
returns (AddressTypeProposal memory)
|
|
377
358
|
{
|
|
378
|
-
return
|
|
359
|
+
return coreAddress;
|
|
379
360
|
}
|
|
380
361
|
|
|
381
362
|
/// @notice Returns the Staking contract address proposal information
|