@evvm/testnet-contracts 2.1.3 → 2.2.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.
- package/contracts/evvm/Evvm.sol +13 -9
- package/contracts/evvm/lib/EvvmStorage.sol +2 -0
- package/contracts/evvm/lib/SignatureUtils.sol +13 -13
- package/contracts/nameService/NameService.sol +11 -8
- package/contracts/nameService/lib/ErrorsLib.sol +1 -1
- package/contracts/nameService/lib/SignatureUtils.sol +38 -39
- package/contracts/p2pSwap/P2PSwap.sol +20 -388
- package/contracts/p2pSwap/lib/SignatureUtils.sol +15 -16
- package/contracts/staking/Staking.sol +28 -17
- package/contracts/staking/lib/ErrorsLib.sol +0 -1
- package/contracts/staking/lib/SignatureUtils.sol +6 -34
- package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +7 -7
- package/interfaces/IStaking.sol +1 -1
- package/library/Erc191TestBuilder.sol +57 -57
- package/library/EvvmService.sol +104 -0
- package/library/primitives/Math.sol +415 -0
- package/library/primitives/SignatureRecover.sol +42 -0
- package/library/utils/AdvancedStrings.sol +89 -0
- package/library/utils/SignatureUtil.sol +29 -0
- package/library/utils/service/AsyncNonceService.sol +34 -0
- package/library/utils/service/MakeServicePaymentOnEvvm.sol +49 -0
- package/library/utils/service/StakingServiceUtils.sol +37 -0
- package/library/utils/service/SyncNonceService.sol +18 -0
- package/package.json +1 -1
- package/contracts/evvm/EvvmLegacy.sol +0 -1553
- package/library/AdvancedStrings.sol +0 -77
- package/library/SignatureRecover.sol +0 -140
- package/library/StakingServiceHooks.sol +0 -116
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
2
|
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {AdvancedStrings} from "@evvm/testnet-contracts/library/AdvancedStrings.sol";
|
|
6
|
-
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
|
4
|
+
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
5
|
+
import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
7
6
|
|
|
8
7
|
pragma solidity ^0.8.0;
|
|
9
8
|
|
|
@@ -25,19 +24,19 @@ library SignatureUtils {
|
|
|
25
24
|
bytes memory signature
|
|
26
25
|
) internal pure returns (bool) {
|
|
27
26
|
return
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
SignatureUtil.verifySignature(
|
|
28
|
+
evvmID,
|
|
30
29
|
"makeOrder",
|
|
31
30
|
string.concat(
|
|
32
|
-
|
|
31
|
+
AdvancedStrings.uintToString(_nonce),
|
|
33
32
|
",",
|
|
34
33
|
AdvancedStrings.addressToString(_tokenA),
|
|
35
34
|
",",
|
|
36
35
|
AdvancedStrings.addressToString(_tokenB),
|
|
37
36
|
",",
|
|
38
|
-
|
|
37
|
+
AdvancedStrings.uintToString(_amountA),
|
|
39
38
|
",",
|
|
40
|
-
|
|
39
|
+
AdvancedStrings.uintToString(_amountB)
|
|
41
40
|
),
|
|
42
41
|
signature,
|
|
43
42
|
signer
|
|
@@ -54,17 +53,17 @@ library SignatureUtils {
|
|
|
54
53
|
bytes memory signature
|
|
55
54
|
) internal pure returns (bool) {
|
|
56
55
|
return
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
SignatureUtil.verifySignature(
|
|
57
|
+
evvmID,
|
|
59
58
|
"cancelOrder",
|
|
60
59
|
string.concat(
|
|
61
|
-
|
|
60
|
+
AdvancedStrings.uintToString(_nonce),
|
|
62
61
|
",",
|
|
63
62
|
AdvancedStrings.addressToString(_tokenA),
|
|
64
63
|
",",
|
|
65
64
|
AdvancedStrings.addressToString(_tokenB),
|
|
66
65
|
",",
|
|
67
|
-
|
|
66
|
+
AdvancedStrings.uintToString(_orderId)
|
|
68
67
|
),
|
|
69
68
|
signature,
|
|
70
69
|
signer
|
|
@@ -81,17 +80,17 @@ library SignatureUtils {
|
|
|
81
80
|
bytes memory signature
|
|
82
81
|
) internal pure returns (bool) {
|
|
83
82
|
return
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
SignatureUtil.verifySignature(
|
|
84
|
+
evvmID,
|
|
86
85
|
"dispatchOrder",
|
|
87
86
|
string.concat(
|
|
88
|
-
|
|
87
|
+
AdvancedStrings.uintToString(_nonce),
|
|
89
88
|
",",
|
|
90
89
|
AdvancedStrings.addressToString(_tokenA),
|
|
91
90
|
",",
|
|
92
91
|
AdvancedStrings.addressToString(_tokenB),
|
|
93
92
|
",",
|
|
94
|
-
|
|
93
|
+
AdvancedStrings.uintToString(_orderId)
|
|
95
94
|
),
|
|
96
95
|
signature,
|
|
97
96
|
signer
|
|
@@ -42,6 +42,7 @@ pragma solidity ^0.8.0;
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
import {Evvm} from "@evvm/testnet-contracts/contracts/evvm/Evvm.sol";
|
|
45
|
+
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
45
46
|
import {NameService} from "@evvm/testnet-contracts/contracts/nameService/NameService.sol";
|
|
46
47
|
import {Estimator} from "@evvm/testnet-contracts/contracts/staking/Estimator.sol";
|
|
47
48
|
import {ErrorsLib} from "@evvm/testnet-contracts/contracts/staking/lib/ErrorsLib.sol";
|
|
@@ -135,6 +136,8 @@ contract Staking {
|
|
|
135
136
|
bool IsAService;
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
uint256 constant TIME_TO_ACCEPT_PROPOSAL = 1 days;
|
|
140
|
+
|
|
138
141
|
/// @dev Address of the EVVM core contract
|
|
139
142
|
address private EVVM_ADDRESS;
|
|
140
143
|
|
|
@@ -211,12 +214,12 @@ contract Staking {
|
|
|
211
214
|
|
|
212
215
|
goldenFisher.actual = initialGoldenFisher;
|
|
213
216
|
|
|
214
|
-
allowPublicStaking.flag =
|
|
215
|
-
allowPresaleStaking.flag =
|
|
217
|
+
allowPublicStaking.flag = false;
|
|
218
|
+
allowPresaleStaking.flag = true;
|
|
216
219
|
|
|
217
220
|
secondsToUnlockStaking.actual = 0;
|
|
218
221
|
|
|
219
|
-
secondsToUnllockFullUnstaking.actual =
|
|
222
|
+
secondsToUnllockFullUnstaking.actual = 5 days;
|
|
220
223
|
|
|
221
224
|
breakerSetupEstimatorAndEvvm = 0x01;
|
|
222
225
|
}
|
|
@@ -411,12 +414,12 @@ contract Staking {
|
|
|
411
414
|
* @notice Prepares a service/contract account for staking by recording pre-staking state
|
|
412
415
|
* @dev First step in the service staking process. Must be followed by payment via caPay and confirmServiceStaking in the same transaction
|
|
413
416
|
* @param amountOfStaking Amount of staking tokens the service intends to stake
|
|
414
|
-
*
|
|
417
|
+
*
|
|
415
418
|
* Service Staking Process:
|
|
416
419
|
* 1. Call prepareServiceStaking(amount) - Records balances and metadata
|
|
417
|
-
* 2. Use EVVM.caPay() to transfer the required Principal Tokens to this contract
|
|
420
|
+
* 2. Use EVVM.caPay() to transfer the required Principal Tokens to this contract
|
|
418
421
|
* 3. Call confirmServiceStaking() - Validates payment and completes staking
|
|
419
|
-
*
|
|
422
|
+
*
|
|
420
423
|
* @dev All three steps MUST occur in the same transaction or the staking will fail
|
|
421
424
|
* @dev CRITICAL WARNING: If the process is not completed properly (especially if caPay is called
|
|
422
425
|
* but confirmServiceStaking is not), the Principal Tokens will remain locked in the staking
|
|
@@ -442,13 +445,13 @@ contract Staking {
|
|
|
442
445
|
/**
|
|
443
446
|
* @notice Confirms and completes the service staking operation after payment verification
|
|
444
447
|
* @dev Final step in service staking. Validates that payment was made correctly and completes the staking process
|
|
445
|
-
*
|
|
448
|
+
*
|
|
446
449
|
* Validation checks:
|
|
447
450
|
* - Service balance decreased by the exact staking cost
|
|
448
|
-
* - Staking contract balance increased by the exact staking cost
|
|
451
|
+
* - Staking contract balance increased by the exact staking cost
|
|
449
452
|
* - Operation occurs in the same transaction as prepareServiceStaking
|
|
450
453
|
* - Caller matches the service that initiated the preparation
|
|
451
|
-
*
|
|
454
|
+
*
|
|
452
455
|
* @dev Only callable by the same contract that called prepareServiceStaking
|
|
453
456
|
* @dev Must be called in the same transaction as prepareServiceStaking
|
|
454
457
|
*/
|
|
@@ -499,7 +502,7 @@ contract Staking {
|
|
|
499
502
|
* @notice Allows a service/contract account to unstake their staking tokens
|
|
500
503
|
* @dev Simplified unstaking process for services - no signature or payment required, just direct unstaking
|
|
501
504
|
* @param amountOfStaking Amount of staking tokens to unstake
|
|
502
|
-
*
|
|
505
|
+
*
|
|
503
506
|
* @dev The service will receive Principal Tokens equal to: amountOfStaking * PRICE_OF_STAKING
|
|
504
507
|
* @dev Subject to the same time locks as regular unstaking (21 days for full unstake)
|
|
505
508
|
* @dev Only callable by contract accounts (services), not EOAs
|
|
@@ -761,7 +764,7 @@ contract Staking {
|
|
|
761
764
|
*/
|
|
762
765
|
function proposeAdmin(address _newAdmin) external onlyOwner {
|
|
763
766
|
admin.proposal = _newAdmin;
|
|
764
|
-
admin.timeToAccept = block.timestamp +
|
|
767
|
+
admin.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
|
|
765
768
|
}
|
|
766
769
|
|
|
767
770
|
/**
|
|
@@ -795,7 +798,7 @@ contract Staking {
|
|
|
795
798
|
*/
|
|
796
799
|
function proposeGoldenFisher(address _goldenFisher) external onlyOwner {
|
|
797
800
|
goldenFisher.proposal = _goldenFisher;
|
|
798
|
-
goldenFisher.timeToAccept = block.timestamp +
|
|
801
|
+
goldenFisher.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
|
|
799
802
|
}
|
|
800
803
|
|
|
801
804
|
/**
|
|
@@ -829,7 +832,9 @@ contract Staking {
|
|
|
829
832
|
uint256 _secondsToUnlockStaking
|
|
830
833
|
) external onlyOwner {
|
|
831
834
|
secondsToUnlockStaking.proposal = _secondsToUnlockStaking;
|
|
832
|
-
secondsToUnlockStaking.timeToAccept =
|
|
835
|
+
secondsToUnlockStaking.timeToAccept =
|
|
836
|
+
block.timestamp +
|
|
837
|
+
TIME_TO_ACCEPT_PROPOSAL;
|
|
833
838
|
}
|
|
834
839
|
|
|
835
840
|
/**
|
|
@@ -863,7 +868,9 @@ contract Staking {
|
|
|
863
868
|
uint256 _secondsToUnllockFullUnstaking
|
|
864
869
|
) external onlyOwner {
|
|
865
870
|
secondsToUnllockFullUnstaking.proposal = _secondsToUnllockFullUnstaking;
|
|
866
|
-
secondsToUnllockFullUnstaking.timeToAccept =
|
|
871
|
+
secondsToUnllockFullUnstaking.timeToAccept =
|
|
872
|
+
block.timestamp +
|
|
873
|
+
TIME_TO_ACCEPT_PROPOSAL;
|
|
867
874
|
}
|
|
868
875
|
|
|
869
876
|
/**
|
|
@@ -894,7 +901,9 @@ contract Staking {
|
|
|
894
901
|
* @dev Initiates the time-delayed process to enable/disable public staking
|
|
895
902
|
*/
|
|
896
903
|
function prepareChangeAllowPublicStaking() external onlyOwner {
|
|
897
|
-
allowPublicStaking.timeToAccept =
|
|
904
|
+
allowPublicStaking.timeToAccept =
|
|
905
|
+
block.timestamp +
|
|
906
|
+
TIME_TO_ACCEPT_PROPOSAL;
|
|
898
907
|
}
|
|
899
908
|
|
|
900
909
|
/**
|
|
@@ -924,7 +933,9 @@ contract Staking {
|
|
|
924
933
|
* @dev Initiates the time-delayed process to enable/disable presale staking
|
|
925
934
|
*/
|
|
926
935
|
function prepareChangeAllowPresaleStaking() external onlyOwner {
|
|
927
|
-
allowPresaleStaking.timeToAccept =
|
|
936
|
+
allowPresaleStaking.timeToAccept =
|
|
937
|
+
block.timestamp +
|
|
938
|
+
TIME_TO_ACCEPT_PROPOSAL;
|
|
928
939
|
}
|
|
929
940
|
|
|
930
941
|
/**
|
|
@@ -956,7 +967,7 @@ contract Staking {
|
|
|
956
967
|
*/
|
|
957
968
|
function proposeEstimator(address _estimator) external onlyOwner {
|
|
958
969
|
estimator.proposal = _estimator;
|
|
959
|
-
estimator.timeToAccept = block.timestamp +
|
|
970
|
+
estimator.timeToAccept = block.timestamp + TIME_TO_ACCEPT_PROPOSAL;
|
|
960
971
|
}
|
|
961
972
|
|
|
962
973
|
/**
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
2
|
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {AdvancedStrings} from "@evvm/testnet-contracts/library/AdvancedStrings.sol";
|
|
6
|
-
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
|
4
|
+
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
5
|
+
import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
7
6
|
|
|
8
7
|
pragma solidity ^0.8.0;
|
|
9
8
|
|
|
@@ -24,42 +23,15 @@ library SignatureUtils {
|
|
|
24
23
|
bytes memory signature
|
|
25
24
|
) internal pure returns (bool) {
|
|
26
25
|
return
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
SignatureUtil.verifySignature(
|
|
27
|
+
evvmID,
|
|
29
28
|
isExternalStaking ? "publicStaking" : "presaleStaking",
|
|
30
29
|
string.concat(
|
|
31
30
|
_isStaking ? "true" : "false",
|
|
32
31
|
",",
|
|
33
|
-
|
|
32
|
+
AdvancedStrings.uintToString(_amountOfStaking),
|
|
34
33
|
",",
|
|
35
|
-
|
|
36
|
-
),
|
|
37
|
-
signature,
|
|
38
|
-
user
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function verifyMessageSignedForPublicServiceStake(
|
|
43
|
-
uint256 evvmID,
|
|
44
|
-
address user,
|
|
45
|
-
address serviceAddress,
|
|
46
|
-
bool _isStaking,
|
|
47
|
-
uint256 _amountOfStaking,
|
|
48
|
-
uint256 _nonce,
|
|
49
|
-
bytes memory signature
|
|
50
|
-
) internal pure returns (bool) {
|
|
51
|
-
return
|
|
52
|
-
SignatureRecover.signatureVerification(
|
|
53
|
-
Strings.toString(evvmID),
|
|
54
|
-
"publicServiceStaking",
|
|
55
|
-
string.concat(
|
|
56
|
-
AdvancedStrings.addressToString(serviceAddress),
|
|
57
|
-
",",
|
|
58
|
-
_isStaking ? "true" : "false",
|
|
59
|
-
",",
|
|
60
|
-
Strings.toString(_amountOfStaking),
|
|
61
|
-
",",
|
|
62
|
-
Strings.toString(_nonce)
|
|
34
|
+
AdvancedStrings.uintToString(_nonce)
|
|
63
35
|
),
|
|
64
36
|
signature,
|
|
65
37
|
user
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
2
|
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {AdvancedStrings} from "@evvm/testnet-contracts/library/AdvancedStrings.sol";
|
|
4
|
+
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
5
|
+
import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
6
6
|
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
|
7
7
|
|
|
8
8
|
pragma solidity ^0.8.0;
|
|
@@ -60,19 +60,19 @@ library SignatureUtils {
|
|
|
60
60
|
bytes memory signature
|
|
61
61
|
) internal pure returns (bool) {
|
|
62
62
|
return
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
SignatureUtil.verifySignature(
|
|
64
|
+
evvmID,
|
|
65
65
|
"fisherBridge",
|
|
66
66
|
string.concat(
|
|
67
67
|
AdvancedStrings.addressToString(addressToReceive),
|
|
68
68
|
",",
|
|
69
|
-
|
|
69
|
+
AdvancedStrings.uintToString(nonce),
|
|
70
70
|
",",
|
|
71
71
|
AdvancedStrings.addressToString(tokenAddress),
|
|
72
72
|
",",
|
|
73
|
-
|
|
73
|
+
AdvancedStrings.uintToString(priorityFee),
|
|
74
74
|
",",
|
|
75
|
-
|
|
75
|
+
AdvancedStrings.uintToString(amount)
|
|
76
76
|
),
|
|
77
77
|
signature,
|
|
78
78
|
signer
|