@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
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
import {
|
|
7
|
+
CoreStructs as Structs
|
|
8
|
+
} from "@evvm/testnet-contracts/library/structs/CoreStructs.sol";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ProposalStructs
|
|
12
|
+
} from "@evvm/testnet-contracts/library/utils/governance/ProposalStructs.sol";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @title CoreStorage
|
|
16
|
+
* @author Mate labs
|
|
17
|
+
* @notice Centralized storage layout for the EVVM Core contract.
|
|
18
|
+
* @dev Designed for use with proxy patterns. This contract must remain append-only
|
|
19
|
+
* to maintain storage slots across upgrades.
|
|
20
|
+
*/
|
|
21
|
+
abstract contract CoreStorage {
|
|
22
|
+
//░▒▓█ Constants ██████████████████████████████████████████████████████████████████▓▒░
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @notice Sentinel address representing native ETH (or the chain's native token).
|
|
26
|
+
*/
|
|
27
|
+
address constant ETH_ADDRESS = address(0);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @notice Flag indicating an address is a registered staker.
|
|
31
|
+
* @dev Value 0x01 is used in stakerList to signify active status.
|
|
32
|
+
*/
|
|
33
|
+
bytes1 constant FLAG_IS_STAKER = 0x01;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @notice Minimum time delay (1 day) to accept a proposed admin change.
|
|
37
|
+
*/
|
|
38
|
+
uint256 constant TIME_TO_ACCEPT_PROPOSAL = 1 days;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @notice Minimum time delay (30 days) to accept a proposed implementation upgrade.
|
|
42
|
+
*/
|
|
43
|
+
uint256 constant TIME_TO_ACCEPT_IMPLEMENTATION = 30 days;
|
|
44
|
+
|
|
45
|
+
//░▒▓█ External Contract Addresses █████████████████████████████████████████████████▓▒░
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @notice Address of the EVVM NameService for identity and username resolution.
|
|
49
|
+
*/
|
|
50
|
+
address nameServiceAddress;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @notice Address of the Staking contract.
|
|
54
|
+
* @dev Authorized to update staker status and manage reward distributions.
|
|
55
|
+
*/
|
|
56
|
+
address stakingContractAddress;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @notice Address of the Treasury contract.
|
|
60
|
+
* @dev Authorized for privileged balance operations (add/remove tokens).
|
|
61
|
+
*/
|
|
62
|
+
address treasuryAddress;
|
|
63
|
+
|
|
64
|
+
//░▒▓█ Token Whitelist Proposal State ██████████████████████████████████████████████▓▒░
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @notice Pending token address to be whitelisted.
|
|
68
|
+
*/
|
|
69
|
+
address whitelistTokenToBeAdded_address;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @notice Uniswap V3 (or similar) pool address used to verify liquidity for the pending token.
|
|
73
|
+
*/
|
|
74
|
+
address whitelistTokenToBeAdded_pool;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @notice Timestamp when the pending token whitelist proposal can be accepted.
|
|
78
|
+
*/
|
|
79
|
+
uint256 whitelistTokenToBeAdded_dateToSet;
|
|
80
|
+
|
|
81
|
+
//░▒▓█ Proxy Implementation State ██████████████████████████████████████████████████▓▒░
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @notice Current active implementation address.
|
|
85
|
+
* @dev Used by the fallback function for delegatecall.
|
|
86
|
+
*/
|
|
87
|
+
address currentImplementation;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @notice Proposed future implementation address.
|
|
91
|
+
*/
|
|
92
|
+
address proposalImplementation;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @notice Timestamp after which the proposed implementation can be finalized.
|
|
96
|
+
*/
|
|
97
|
+
uint256 timeToAcceptImplementation;
|
|
98
|
+
|
|
99
|
+
//░▒▓█ EVVM Configuration State ████████████████████████████████████████████████████▓▒░
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @notice Timestamp limiting when the EVVM ID can be modified (initial window).
|
|
103
|
+
*/
|
|
104
|
+
uint256 windowTimeToChangeEvvmID;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @notice Metadata configuration for this EVVM instance (ID, token info, rewards).
|
|
108
|
+
* @dev Crucial for EIP-191 signature verification to prevent replay attacks.
|
|
109
|
+
*/
|
|
110
|
+
Structs.EvvmMetadata evvmMetadata;
|
|
111
|
+
|
|
112
|
+
//░▒▓█ Admin Governance State ██████████████████████████████████████████████████████▓▒░
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @notice Management of the admin role with time-delayed transitions.
|
|
116
|
+
*/
|
|
117
|
+
ProposalStructs.AddressTypeProposal admin;
|
|
118
|
+
|
|
119
|
+
//░▒▓█ Initialization State ████████████████████████████████████████████████████████▓▒░
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @notice Internal guard to ensure system contracts are initialized only once.
|
|
123
|
+
*/
|
|
124
|
+
bytes1 breakerSetupNameServiceAddress;
|
|
125
|
+
|
|
126
|
+
//░▒▓█ Staker Registry █████████████████████████████████████████████████████████████▓▒░
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @notice Tracks addresses registered as active stakers.
|
|
130
|
+
*/
|
|
131
|
+
mapping(address => bytes1) stakerList;
|
|
132
|
+
|
|
133
|
+
//░▒▓█ Balance Management ██████████████████████████████████████████████████████████▓▒░
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @notice Internal ledger of user balances across different tokens.
|
|
137
|
+
* @dev Format: user => token => balance. address(0) = ETH.
|
|
138
|
+
*/
|
|
139
|
+
mapping(address user => mapping(address token => uint256 quantity)) balances;
|
|
140
|
+
|
|
141
|
+
//░▒▓█ Fisher Bridge State ██████████████████████████████████████████████████████████▓▒░
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @notice Nonce tracking for ordered Fisher Bridge cross-chain deposits.
|
|
145
|
+
*/
|
|
146
|
+
mapping(address user => uint256 nonce) nextFisherDepositNonce;
|
|
147
|
+
|
|
148
|
+
//░▒▓█ Nonce State ██████████████████████████████████████████████████████████▓▒░
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @notice (Unused but kept for storage alignment) Proposed address for user validation.
|
|
152
|
+
*/
|
|
153
|
+
ProposalStructs.AddressTypeProposal userValidatorAddress;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @notice tracks if a specific async nonce has already been consumed.
|
|
157
|
+
* @dev Async nonces allow parallel execution as they can be used in any order.
|
|
158
|
+
*/
|
|
159
|
+
mapping(address user => mapping(uint256 nonce => bool isUsed)) asyncNonce;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @notice Reserves an async nonce for a specific service address.
|
|
163
|
+
* @dev Prevents different services from attempting to use the same user nonce simultaneously.
|
|
164
|
+
*/
|
|
165
|
+
mapping(address user => mapping(uint256 nonce => address serviceReserved)) asyncNonceReservedPointers;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @notice tracks the next expected nonce for sequential (synchronous) transactions.
|
|
169
|
+
*/
|
|
170
|
+
mapping(address user => uint256 nonce) nextSyncNonce;
|
|
171
|
+
}
|