@evvm/testnet-contracts 1.0.0

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 (34) hide show
  1. package/LICENSE +166 -0
  2. package/README.md +216 -0
  3. package/package.json +51 -0
  4. package/src/contracts/evvm/Evvm.sol +1327 -0
  5. package/src/contracts/evvm/EvvmLegacy.sol +1553 -0
  6. package/src/contracts/evvm/lib/ErrorsLib.sol +17 -0
  7. package/src/contracts/evvm/lib/EvvmStorage.sol +60 -0
  8. package/src/contracts/evvm/lib/EvvmStructs.sol +64 -0
  9. package/src/contracts/evvm/lib/SignatureUtils.sol +124 -0
  10. package/src/contracts/nameService/NameService.sol +1751 -0
  11. package/src/contracts/nameService/lib/ErrorsLib.sol +27 -0
  12. package/src/contracts/nameService/lib/SignatureUtils.sol +239 -0
  13. package/src/contracts/staking/Estimator.sol +358 -0
  14. package/src/contracts/staking/Staking.sol +1148 -0
  15. package/src/contracts/staking/lib/ErrorsLib.sol +19 -0
  16. package/src/contracts/staking/lib/SignatureUtils.sol +68 -0
  17. package/src/contracts/treasury/Treasury.sol +104 -0
  18. package/src/contracts/treasury/lib/ErrorsLib.sol +11 -0
  19. package/src/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +551 -0
  20. package/src/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +512 -0
  21. package/src/contracts/treasuryTwoChains/lib/ErrorsLib.sol +15 -0
  22. package/src/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +41 -0
  23. package/src/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +52 -0
  24. package/src/contracts/treasuryTwoChains/lib/SignatureUtils.sol +47 -0
  25. package/src/interfaces/IEstimator.sol +102 -0
  26. package/src/interfaces/IEvvm.sol +195 -0
  27. package/src/interfaces/INameService.sol +283 -0
  28. package/src/interfaces/IStaking.sol +202 -0
  29. package/src/interfaces/ITreasury.sol +17 -0
  30. package/src/interfaces/ITreasuryExternalChainStation.sol +262 -0
  31. package/src/interfaces/ITreasuryHostChainStation.sol +251 -0
  32. package/src/lib/AdvancedStrings.sol +77 -0
  33. package/src/lib/Erc191TestBuilder.sol +402 -0
  34. package/src/lib/SignatureRecover.sol +56 -0
@@ -0,0 +1,202 @@
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
+ interface IStaking {
6
+ struct BoolTypeProposal {
7
+ bool flag;
8
+ uint256 timeToAccept;
9
+ }
10
+
11
+ struct HistoryMetadata {
12
+ bytes32 transactionType;
13
+ uint256 amount;
14
+ uint256 timestamp;
15
+ uint256 totalStaked;
16
+ }
17
+
18
+ error AddressIsNotAService();
19
+ error InvalidSignatureOnStaking();
20
+ error PresaleStakingDisabled();
21
+ error PublicStakingDisabled();
22
+ error SenderIsNotAdmin();
23
+ error SenderIsNotGoldenFisher();
24
+ error StakingNonceAlreadyUsed();
25
+ error UserAndServiceMismatch();
26
+ error UserIsNotPresaleStaker();
27
+ error UserMustWaitToFullUnstake();
28
+ error UserMustWaitToStakeAgain();
29
+ error UserPresaleStakerLimitExceeded();
30
+
31
+ function _setupEstimatorAndEvvm(address _estimator, address _evvm) external;
32
+
33
+ function acceptNewAdmin() external;
34
+
35
+ function acceptNewEstimator() external;
36
+
37
+ function acceptNewGoldenFisher() external;
38
+
39
+ function acceptSetSecondsToUnlockStaking() external;
40
+
41
+ function addPresaleStaker(address _staker) external;
42
+
43
+ function addPresaleStakers(address[] memory _stakers) external;
44
+
45
+ function cancelChangeAllowPresaleStaking() external;
46
+
47
+ function cancelChangeAllowPublicStaking() external;
48
+
49
+ function cancelSetSecondsToUnllockFullUnstaking() external;
50
+
51
+ function checkIfStakeNonceUsed(
52
+ address _account,
53
+ uint256 _nonce
54
+ ) external view returns (bool);
55
+
56
+ function confirmChangeAllowPresaleStaking() external;
57
+
58
+ function confirmChangeAllowPublicStaking() external;
59
+
60
+ function confirmSetSecondsToUnllockFullUnstaking() external;
61
+
62
+ function getAddressHistory(
63
+ address _account
64
+ ) external view returns (HistoryMetadata[] memory);
65
+
66
+ function getAddressHistoryByIndex(
67
+ address _account,
68
+ uint256 _index
69
+ ) external view returns (HistoryMetadata memory);
70
+
71
+ function getAllDataOfAllowPublicStaking()
72
+ external
73
+ view
74
+ returns (BoolTypeProposal memory);
75
+
76
+ function getAllowPresaleStaking()
77
+ external
78
+ view
79
+ returns (BoolTypeProposal memory);
80
+
81
+ function getEstimatorAddress() external view returns (address);
82
+
83
+ function getEstimatorProposal() external view returns (address);
84
+
85
+ function getEvvmAddress() external view returns (address);
86
+
87
+ function getGoldenFisher() external view returns (address);
88
+
89
+ function getGoldenFisherProposal() external view returns (address);
90
+
91
+ function getMateAddress() external pure returns (address);
92
+
93
+ function getOwner() external view returns (address);
94
+
95
+ function getPresaleStaker(
96
+ address _account
97
+ ) external view returns (bool, uint256);
98
+
99
+ function getPresaleStakerCount() external view returns (uint256);
100
+
101
+ function getSecondsToUnlockFullUnstaking() external view returns (uint256);
102
+
103
+ function getSecondsToUnlockStaking() external view returns (uint256);
104
+
105
+ function getSizeOfAddressHistory(
106
+ address _account
107
+ ) external view returns (uint256);
108
+
109
+ function getTimeToUserUnlockFullUnstakingTime(
110
+ address _account
111
+ ) external view returns (uint256);
112
+
113
+ function getTimeToUserUnlockStakingTime(
114
+ address _account
115
+ ) external view returns (uint256);
116
+
117
+ function getUserAmountStaked(
118
+ address _account
119
+ ) external view returns (uint256);
120
+
121
+ function gimmeYiel(
122
+ address user
123
+ )
124
+ external
125
+ returns (
126
+ bytes32 epochAnswer,
127
+ address tokenToBeRewarded,
128
+ uint256 amountTotalToBeRewarded,
129
+ uint256 idToOverwriteUserHistory,
130
+ uint256 timestampToBeOverwritten
131
+ );
132
+
133
+ function goldenStaking(
134
+ bool isStaking,
135
+ uint256 amountOfStaking,
136
+ bytes memory signature_EVVM
137
+ ) external;
138
+
139
+ function prepareChangeAllowPresaleStaking() external;
140
+
141
+ function prepareChangeAllowPublicStaking() external;
142
+
143
+ function prepareSetSecondsToUnllockFullUnstaking(
144
+ uint256 _secondsToUnllockFullUnstaking
145
+ ) external;
146
+
147
+ function presaleStaking(
148
+ address user,
149
+ bool isStaking,
150
+ uint256 nonce,
151
+ bytes memory signature,
152
+ uint256 priorityFee_EVVM,
153
+ uint256 nonce_EVVM,
154
+ bool priorityFlag_EVVM,
155
+ bytes memory signature_EVVM
156
+ ) external;
157
+
158
+ function priceOfStaking() external pure returns (uint256);
159
+
160
+ function proposeAdmin(address _newAdmin) external;
161
+
162
+ function proposeEstimator(address _estimator) external;
163
+
164
+ function proposeGoldenFisher(address _goldenFisher) external;
165
+
166
+ function proposeSetSecondsToUnlockStaking(
167
+ uint256 _secondsToUnlockStaking
168
+ ) external;
169
+
170
+ function publicServiceStaking(
171
+ address user,
172
+ address service,
173
+ bool isStaking,
174
+ uint256 amountOfStaking,
175
+ uint256 nonce,
176
+ bytes memory signature,
177
+ uint256 priorityFee_EVVM,
178
+ uint256 nonce_EVVM,
179
+ bool priorityFlag_EVVM,
180
+ bytes memory signature_EVVM
181
+ ) external;
182
+
183
+ function publicStaking(
184
+ address user,
185
+ bool isStaking,
186
+ uint256 amountOfStaking,
187
+ uint256 nonce,
188
+ bytes memory signature,
189
+ uint256 priorityFee_EVVM,
190
+ uint256 nonce_EVVM,
191
+ bool priorityFlag_EVVM,
192
+ bytes memory signature_EVVM
193
+ ) external;
194
+
195
+ function rejectProposalAdmin() external;
196
+
197
+ function rejectProposalEstimator() external;
198
+
199
+ function rejectProposalGoldenFisher() external;
200
+
201
+ function rejectProposalSetSecondsToUnlockStaking() external;
202
+ }
@@ -0,0 +1,17 @@
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
+ interface ITreasury {
7
+ error DepositAmountMustBeGreaterThanZero();
8
+ error InsufficientBalance();
9
+ error InvalidDepositAmount();
10
+ error PrincipalTokenIsNotWithdrawable();
11
+
12
+ function deposit(address token, uint256 amount) external payable;
13
+
14
+ function evvmAddress() external view returns (address);
15
+
16
+ function withdraw(address token, uint256 amount) external;
17
+ }
@@ -0,0 +1,262 @@
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
+ library ExternalChainStationStructs {
7
+ struct AddressTypeProposal {
8
+ address current;
9
+ address proposal;
10
+ uint256 timeToAccept;
11
+ }
12
+
13
+ struct AxelarConfig {
14
+ string hostChainStationChainName;
15
+ string hostChainStationAddress;
16
+ address gasServiceAddress;
17
+ address gatewayAddress;
18
+ }
19
+
20
+ struct CrosschainConfig {
21
+ uint32 hostChainStationDomainId;
22
+ address mailboxAddress;
23
+ uint32 hostChainStationEid;
24
+ address endpointAddress;
25
+ string hostChainStationChainName;
26
+ address gasServiceAddress;
27
+ address gatewayAddress;
28
+ }
29
+
30
+ struct HyperlaneConfig {
31
+ uint32 hostChainStationDomainId;
32
+ bytes32 hostChainStationAddress;
33
+ address mailboxAddress;
34
+ }
35
+
36
+ struct LayerZeroConfig {
37
+ uint32 hostChainStationEid;
38
+ bytes32 hostChainStationAddress;
39
+ address endpointAddress;
40
+ }
41
+ }
42
+
43
+ interface ITreasuryExternalChainStation {
44
+ struct EnforcedOptionParam {
45
+ uint32 eid;
46
+ uint16 msgType;
47
+ bytes options;
48
+ }
49
+
50
+ struct Origin {
51
+ uint32 srcEid;
52
+ bytes32 sender;
53
+ uint64 nonce;
54
+ }
55
+
56
+ error AddressEmptyCode(address target);
57
+ error AddressInsufficientBalance(address account);
58
+ error ChainIdNotAuthorized();
59
+ error FailedInnerCall();
60
+ error InsufficientBalance();
61
+ error InvalidAddress();
62
+ error InvalidDelegate();
63
+ error InvalidEndpointCall();
64
+ error InvalidOptionType(uint16 optionType);
65
+ error InvalidOptions(bytes options);
66
+ error InvalidSignature();
67
+ error LzTokenUnavailable();
68
+ error MailboxNotAuthorized();
69
+ error NoPeer(uint32 eid);
70
+ error NotApprovedByGateway();
71
+ error NotEnoughNative(uint256 msgValue);
72
+ error OnlyEndpoint(address addr);
73
+ error OnlyPeer(uint32 eid, bytes32 sender);
74
+ error OwnableInvalidOwner(address owner);
75
+ error OwnableUnauthorizedAccount(address account);
76
+ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
77
+ error SafeERC20FailedOperation(address token);
78
+ error SenderNotAuthorized();
79
+
80
+ event EnforcedOptionSet(EnforcedOptionParam[] _enforcedOptions);
81
+ event FisherBridgeSend(
82
+ address indexed from,
83
+ address indexed addressToReceive,
84
+ address indexed tokenAddress,
85
+ uint256 priorityFee,
86
+ uint256 amount,
87
+ uint256 nonce
88
+ );
89
+ event OwnershipTransferred(
90
+ address indexed previousOwner,
91
+ address indexed newOwner
92
+ );
93
+ event PeerSet(uint32 eid, bytes32 peer);
94
+
95
+ function acceptAdmin() external;
96
+
97
+ function acceptFisherExecutor() external;
98
+
99
+ function allowInitializePath(
100
+ Origin memory origin
101
+ ) external view returns (bool);
102
+
103
+ function combineOptions(
104
+ uint32 _eid,
105
+ uint16 _msgType,
106
+ bytes memory _extraOptions
107
+ ) external view returns (bytes memory);
108
+
109
+ function depositCoin(
110
+ address toAddress,
111
+ uint256 amount,
112
+ bytes1 protocolToExecute
113
+ ) external payable;
114
+
115
+ function depositERC20(
116
+ address toAddress,
117
+ address token,
118
+ uint256 amount,
119
+ bytes1 protocolToExecute
120
+ ) external payable;
121
+
122
+ function endpoint() external view returns (address);
123
+
124
+ function enforcedOptions(
125
+ uint32 eid,
126
+ uint16 msgType
127
+ ) external view returns (bytes memory enforcedOption);
128
+
129
+ function execute(
130
+ bytes32 commandId,
131
+ string memory sourceChain,
132
+ string memory sourceAddress,
133
+ bytes memory payload
134
+ ) external;
135
+
136
+ function fisherBridgeReceive(
137
+ address from,
138
+ address addressToReceive,
139
+ address tokenAddress,
140
+ uint256 priorityFee,
141
+ uint256 amount,
142
+ bytes memory signature
143
+ ) external;
144
+
145
+ function fisherBridgeSendCoin(
146
+ address from,
147
+ address addressToReceive,
148
+ uint256 priorityFee,
149
+ uint256 amount,
150
+ bytes memory signature
151
+ ) external payable;
152
+
153
+ function fisherBridgeSendERC20(
154
+ address from,
155
+ address addressToReceive,
156
+ address tokenAddress,
157
+ uint256 priorityFee,
158
+ uint256 amount,
159
+ bytes memory signature
160
+ ) external;
161
+
162
+ function gateway() external view returns (address);
163
+
164
+ function getAdmin()
165
+ external
166
+ view
167
+ returns (ExternalChainStationStructs.AddressTypeProposal memory);
168
+
169
+ function getAxelarConfig()
170
+ external
171
+ view
172
+ returns (ExternalChainStationStructs.AxelarConfig memory);
173
+
174
+ function getFisherExecutor()
175
+ external
176
+ view
177
+ returns (ExternalChainStationStructs.AddressTypeProposal memory);
178
+
179
+ function getHyperlaneConfig()
180
+ external
181
+ view
182
+ returns (ExternalChainStationStructs.HyperlaneConfig memory);
183
+
184
+ function getLayerZeroConfig()
185
+ external
186
+ view
187
+ returns (ExternalChainStationStructs.LayerZeroConfig memory);
188
+
189
+ function getNextFisherExecutionNonce(
190
+ address user
191
+ ) external view returns (uint256);
192
+
193
+ function getOptions() external view returns (bytes memory);
194
+
195
+ function getQuoteHyperlane(
196
+ address toAddress,
197
+ address token,
198
+ uint256 amount
199
+ ) external view returns (uint256);
200
+
201
+ function handle(
202
+ uint32 _origin,
203
+ bytes32 _sender,
204
+ bytes memory _data
205
+ ) external payable;
206
+
207
+ function isComposeMsgSender(
208
+ Origin memory,
209
+ bytes memory,
210
+ address _sender
211
+ ) external view returns (bool);
212
+
213
+ function lzReceive(
214
+ Origin memory _origin,
215
+ bytes32 _guid,
216
+ bytes memory _message,
217
+ address _executor,
218
+ bytes memory _extraData
219
+ ) external payable;
220
+
221
+ function nextNonce(uint32, bytes32) external view returns (uint64 nonce);
222
+
223
+ function oAppVersion()
224
+ external
225
+ pure
226
+ returns (uint64 senderVersion, uint64 receiverVersion);
227
+
228
+ function owner() external view returns (address);
229
+
230
+ function peers(uint32 eid) external view returns (bytes32 peer);
231
+
232
+ function proposeAdmin(address _newOwner) external;
233
+
234
+ function proposeFisherExecutor(address _newFisherExecutor) external;
235
+
236
+ function quoteLayerZero(
237
+ address toAddress,
238
+ address token,
239
+ uint256 amount
240
+ ) external view returns (uint256);
241
+
242
+ function rejectProposalAdmin() external;
243
+
244
+ function rejectProposalFisherExecutor() external;
245
+
246
+ function renounceOwnership() external;
247
+
248
+ function setDelegate(address _delegate) external;
249
+
250
+ function setEnforcedOptions(
251
+ EnforcedOptionParam[] memory _enforcedOptions
252
+ ) external;
253
+
254
+ function setHostChainAddress(
255
+ address hostChainStationAddress,
256
+ string memory hostChainStationAddressString
257
+ ) external;
258
+
259
+ function setPeer(uint32 _eid, bytes32 _peer) external;
260
+
261
+ function transferOwnership(address newOwner) external;
262
+ }