@evvm/testnet-contracts 2.0.3 → 2.1.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/README.md +10 -2
- package/contracts/nameService/NameService.sol +13 -5
- package/contracts/p2pSwap/P2PSwap.sol +1361 -0
- package/contracts/p2pSwap/lib/SignatureUtils.sol +100 -0
- package/contracts/staking/Estimator.sol +1 -1
- package/interfaces/INameService.sol +5 -48
- package/interfaces/IP2PSwap.sol +135 -0
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
|
+
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
|
+
|
|
4
|
+
import {SignatureRecover} from "@evvm/testnet-contracts/library/SignatureRecover.sol";
|
|
5
|
+
import {AdvancedStrings} from "@evvm/testnet-contracts/library/AdvancedStrings.sol";
|
|
6
|
+
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
|
7
|
+
|
|
8
|
+
pragma solidity ^0.8.0;
|
|
9
|
+
|
|
10
|
+
library SignatureUtils {
|
|
11
|
+
/**
|
|
12
|
+
* @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
|
|
13
|
+
* verify messages, the next functions are used to verify the messages signed
|
|
14
|
+
* by the users
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function verifyMessageSignedForMakeOrder(
|
|
18
|
+
uint256 evvmID,
|
|
19
|
+
address signer,
|
|
20
|
+
uint256 _nonce,
|
|
21
|
+
address _tokenA,
|
|
22
|
+
address _tokenB,
|
|
23
|
+
uint256 _amountA,
|
|
24
|
+
uint256 _amountB,
|
|
25
|
+
bytes memory signature
|
|
26
|
+
) internal pure returns (bool) {
|
|
27
|
+
return
|
|
28
|
+
SignatureRecover.signatureVerification(
|
|
29
|
+
Strings.toString(evvmID),
|
|
30
|
+
"makeOrder",
|
|
31
|
+
string.concat(
|
|
32
|
+
Strings.toString(_nonce),
|
|
33
|
+
",",
|
|
34
|
+
AdvancedStrings.addressToString(_tokenA),
|
|
35
|
+
",",
|
|
36
|
+
AdvancedStrings.addressToString(_tokenB),
|
|
37
|
+
",",
|
|
38
|
+
Strings.toString(_amountA),
|
|
39
|
+
",",
|
|
40
|
+
Strings.toString(_amountB)
|
|
41
|
+
),
|
|
42
|
+
signature,
|
|
43
|
+
signer
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function verifyMessageSignedForCancelOrder(
|
|
48
|
+
uint256 evvmID,
|
|
49
|
+
address signer,
|
|
50
|
+
uint256 _nonce,
|
|
51
|
+
address _tokenA,
|
|
52
|
+
address _tokenB,
|
|
53
|
+
uint256 _orderId,
|
|
54
|
+
bytes memory signature
|
|
55
|
+
) internal pure returns (bool) {
|
|
56
|
+
return
|
|
57
|
+
SignatureRecover.signatureVerification(
|
|
58
|
+
Strings.toString(evvmID),
|
|
59
|
+
"cancelOrder",
|
|
60
|
+
string.concat(
|
|
61
|
+
Strings.toString(_nonce),
|
|
62
|
+
",",
|
|
63
|
+
AdvancedStrings.addressToString(_tokenA),
|
|
64
|
+
",",
|
|
65
|
+
AdvancedStrings.addressToString(_tokenB),
|
|
66
|
+
",",
|
|
67
|
+
Strings.toString(_orderId)
|
|
68
|
+
),
|
|
69
|
+
signature,
|
|
70
|
+
signer
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function verifyMessageSignedForDispatchOrder(
|
|
75
|
+
uint256 evvmID,
|
|
76
|
+
address signer,
|
|
77
|
+
uint256 _nonce,
|
|
78
|
+
address _tokenA,
|
|
79
|
+
address _tokenB,
|
|
80
|
+
uint256 _orderId,
|
|
81
|
+
bytes memory signature
|
|
82
|
+
) internal pure returns (bool) {
|
|
83
|
+
return
|
|
84
|
+
SignatureRecover.signatureVerification(
|
|
85
|
+
Strings.toString(evvmID),
|
|
86
|
+
"dispatchOrder",
|
|
87
|
+
string.concat(
|
|
88
|
+
Strings.toString(_nonce),
|
|
89
|
+
",",
|
|
90
|
+
AdvancedStrings.addressToString(_tokenA),
|
|
91
|
+
",",
|
|
92
|
+
AdvancedStrings.addressToString(_tokenB),
|
|
93
|
+
",",
|
|
94
|
+
Strings.toString(_orderId)
|
|
95
|
+
),
|
|
96
|
+
signature,
|
|
97
|
+
signer
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
pragma solidity ^0.8.
|
|
4
|
+
pragma solidity ^0.8.4;
|
|
5
5
|
|
|
6
|
-
interface
|
|
6
|
+
interface NameService {
|
|
7
7
|
struct OfferMetadata {
|
|
8
8
|
address offerer;
|
|
9
9
|
uint256 expireDate;
|
|
@@ -25,7 +25,6 @@ interface INameService {
|
|
|
25
25
|
error UsernameAlreadyRegistered();
|
|
26
26
|
|
|
27
27
|
function acceptChangeEvvmAddress() external;
|
|
28
|
-
|
|
29
28
|
function acceptOffer(
|
|
30
29
|
address user,
|
|
31
30
|
string memory username,
|
|
@@ -37,9 +36,7 @@ interface INameService {
|
|
|
37
36
|
bool priorityFlag_EVVM,
|
|
38
37
|
bytes memory signature_EVVM
|
|
39
38
|
) external;
|
|
40
|
-
|
|
41
39
|
function acceptProposeAdmin() external;
|
|
42
|
-
|
|
43
40
|
function addCustomMetadata(
|
|
44
41
|
address user,
|
|
45
42
|
string memory identity,
|
|
@@ -51,20 +48,14 @@ interface INameService {
|
|
|
51
48
|
bool priorityFlag_EVVM,
|
|
52
49
|
bytes memory signature_EVVM
|
|
53
50
|
) external;
|
|
54
|
-
|
|
55
51
|
function cancelChangeEvvmAddress() external;
|
|
56
|
-
|
|
57
52
|
function cancelProposeAdmin() external;
|
|
58
|
-
|
|
59
53
|
function cancelWithdrawPrincipalTokens() external;
|
|
60
|
-
|
|
61
54
|
function checkIfNameServiceNonceIsAvailable(
|
|
62
55
|
address _user,
|
|
63
56
|
uint256 _nonce
|
|
64
57
|
) external view returns (bool);
|
|
65
|
-
|
|
66
58
|
function claimWithdrawPrincipalTokens() external;
|
|
67
|
-
|
|
68
59
|
function flushCustomMetadata(
|
|
69
60
|
address user,
|
|
70
61
|
string memory identity,
|
|
@@ -75,7 +66,6 @@ interface INameService {
|
|
|
75
66
|
bool priorityFlag_EVVM,
|
|
76
67
|
bytes memory signature_EVVM
|
|
77
68
|
) external;
|
|
78
|
-
|
|
79
69
|
function flushUsername(
|
|
80
70
|
address user,
|
|
81
71
|
string memory username,
|
|
@@ -86,9 +76,7 @@ interface INameService {
|
|
|
86
76
|
bool priorityFlag_EVVM,
|
|
87
77
|
bytes memory signature_EVVM
|
|
88
78
|
) external;
|
|
89
|
-
|
|
90
79
|
function getAdmin() external view returns (address);
|
|
91
|
-
|
|
92
80
|
function getAdminFullDetails()
|
|
93
81
|
external
|
|
94
82
|
view
|
|
@@ -97,17 +85,13 @@ interface INameService {
|
|
|
97
85
|
address proposalAdmin,
|
|
98
86
|
uint256 timeToAcceptAdmin
|
|
99
87
|
);
|
|
100
|
-
|
|
101
88
|
function getAmountOfCustomMetadata(
|
|
102
89
|
string memory _username
|
|
103
90
|
) external view returns (uint256);
|
|
104
|
-
|
|
105
91
|
function getCustomMetadataMaxSlotsOfIdentity(
|
|
106
92
|
string memory _username
|
|
107
93
|
) external view returns (uint256);
|
|
108
|
-
|
|
109
94
|
function getEvvmAddress() external view returns (address);
|
|
110
|
-
|
|
111
95
|
function getEvvmAddressFullDetails()
|
|
112
96
|
external
|
|
113
97
|
view
|
|
@@ -116,51 +100,41 @@ interface INameService {
|
|
|
116
100
|
address proposalEvvmAddress,
|
|
117
101
|
uint256 timeToAcceptEvvmAddress
|
|
118
102
|
);
|
|
119
|
-
|
|
120
103
|
function getExpireDateOfIdentity(
|
|
121
104
|
string memory _identity
|
|
122
105
|
) external view returns (uint256);
|
|
123
|
-
|
|
124
106
|
function getFullCustomMetadataOfIdentity(
|
|
125
107
|
string memory _username
|
|
126
108
|
) external view returns (string[] memory);
|
|
127
|
-
|
|
128
109
|
function getIdentityBasicMetadata(
|
|
129
110
|
string memory _username
|
|
130
111
|
) external view returns (address, uint256);
|
|
131
|
-
|
|
132
112
|
function getLengthOfOffersUsername(
|
|
133
113
|
string memory _username
|
|
134
114
|
) external view returns (uint256 length);
|
|
135
|
-
|
|
136
115
|
function getOffersOfUsername(
|
|
137
116
|
string memory _username
|
|
138
117
|
) external view returns (OfferMetadata[] memory offers);
|
|
139
|
-
|
|
140
118
|
function getOwnerOfIdentity(
|
|
141
119
|
string memory _username
|
|
142
120
|
) external view returns (address);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
121
|
+
function getPriceOfRegistration(
|
|
122
|
+
string memory username
|
|
123
|
+
) external view returns (uint256);
|
|
146
124
|
function getPriceToAddCustomMetadata()
|
|
147
125
|
external
|
|
148
126
|
view
|
|
149
127
|
returns (uint256 price);
|
|
150
|
-
|
|
151
128
|
function getPriceToFlushCustomMetadata(
|
|
152
129
|
string memory _identity
|
|
153
130
|
) external view returns (uint256 price);
|
|
154
|
-
|
|
155
131
|
function getPriceToFlushUsername(
|
|
156
132
|
string memory _identity
|
|
157
133
|
) external view returns (uint256 price);
|
|
158
|
-
|
|
159
134
|
function getPriceToRemoveCustomMetadata()
|
|
160
135
|
external
|
|
161
136
|
view
|
|
162
137
|
returns (uint256 price);
|
|
163
|
-
|
|
164
138
|
function getProposedWithdrawAmountFullDetails()
|
|
165
139
|
external
|
|
166
140
|
view
|
|
@@ -168,26 +142,21 @@ interface INameService {
|
|
|
168
142
|
uint256 proposalAmountToWithdrawTokens,
|
|
169
143
|
uint256 timeToAcceptAmountToWithdrawTokens
|
|
170
144
|
);
|
|
171
|
-
|
|
172
145
|
function getSingleCustomMetadataOfIdentity(
|
|
173
146
|
string memory _username,
|
|
174
147
|
uint256 _key
|
|
175
148
|
) external view returns (string memory);
|
|
176
|
-
|
|
177
149
|
function getSingleOfferOfUsername(
|
|
178
150
|
string memory _username,
|
|
179
151
|
uint256 _offerID
|
|
180
152
|
) external view returns (OfferMetadata memory offer);
|
|
181
|
-
|
|
182
153
|
function hashUsername(
|
|
183
154
|
string memory _username,
|
|
184
155
|
uint256 _randomNumber
|
|
185
156
|
) external pure returns (bytes32);
|
|
186
|
-
|
|
187
157
|
function isUsernameAvailable(
|
|
188
158
|
string memory _username
|
|
189
159
|
) external view returns (bool);
|
|
190
|
-
|
|
191
160
|
function makeOffer(
|
|
192
161
|
address user,
|
|
193
162
|
string memory username,
|
|
@@ -200,7 +169,6 @@ interface INameService {
|
|
|
200
169
|
bool priorityFlag_EVVM,
|
|
201
170
|
bytes memory signature_EVVM
|
|
202
171
|
) external returns (uint256 offerID);
|
|
203
|
-
|
|
204
172
|
function preRegistrationUsername(
|
|
205
173
|
address user,
|
|
206
174
|
bytes32 hashPreRegisteredUsername,
|
|
@@ -211,13 +179,9 @@ interface INameService {
|
|
|
211
179
|
bool priorityFlag_EVVM,
|
|
212
180
|
bytes memory signature_EVVM
|
|
213
181
|
) external;
|
|
214
|
-
|
|
215
182
|
function proposeAdmin(address _adminToPropose) external;
|
|
216
|
-
|
|
217
183
|
function proposeChangeEvvmAddress(address _newEvvmAddress) external;
|
|
218
|
-
|
|
219
184
|
function proposeWithdrawPrincipalTokens(uint256 _amount) external;
|
|
220
|
-
|
|
221
185
|
function registrationUsername(
|
|
222
186
|
address user,
|
|
223
187
|
string memory username,
|
|
@@ -229,7 +193,6 @@ interface INameService {
|
|
|
229
193
|
bool priorityFlag_EVVM,
|
|
230
194
|
bytes memory signature_EVVM
|
|
231
195
|
) external;
|
|
232
|
-
|
|
233
196
|
function removeCustomMetadata(
|
|
234
197
|
address user,
|
|
235
198
|
string memory identity,
|
|
@@ -241,7 +204,6 @@ interface INameService {
|
|
|
241
204
|
bool priorityFlag_EVVM,
|
|
242
205
|
bytes memory signature_EVVM
|
|
243
206
|
) external;
|
|
244
|
-
|
|
245
207
|
function renewUsername(
|
|
246
208
|
address user,
|
|
247
209
|
string memory username,
|
|
@@ -252,23 +214,18 @@ interface INameService {
|
|
|
252
214
|
bool priorityFlag_EVVM,
|
|
253
215
|
bytes memory signature_EVVM
|
|
254
216
|
) external;
|
|
255
|
-
|
|
256
217
|
function seePriceToRenew(
|
|
257
218
|
string memory _identity
|
|
258
219
|
) external view returns (uint256 price);
|
|
259
|
-
|
|
260
220
|
function strictVerifyIfIdentityExist(
|
|
261
221
|
string memory _username
|
|
262
222
|
) external view returns (bool);
|
|
263
|
-
|
|
264
223
|
function verifyIfIdentityExists(
|
|
265
224
|
string memory _identity
|
|
266
225
|
) external view returns (bool);
|
|
267
|
-
|
|
268
226
|
function verifyStrictAndGetOwnerOfIdentity(
|
|
269
227
|
string memory _username
|
|
270
228
|
) external view returns (address answer);
|
|
271
|
-
|
|
272
229
|
function withdrawOffer(
|
|
273
230
|
address user,
|
|
274
231
|
string memory username,
|
|
@@ -0,0 +1,135 @@
|
|
|
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.4;
|
|
5
|
+
|
|
6
|
+
interface P2PSwap {
|
|
7
|
+
struct MarketInformation {
|
|
8
|
+
address tokenA;
|
|
9
|
+
address tokenB;
|
|
10
|
+
uint256 maxSlot;
|
|
11
|
+
uint256 ordersAvailable;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
struct MetadataCancelOrder {
|
|
15
|
+
uint256 nonce;
|
|
16
|
+
address tokenA;
|
|
17
|
+
address tokenB;
|
|
18
|
+
uint256 orderId;
|
|
19
|
+
bytes signature;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
struct MetadataDispatchOrder {
|
|
23
|
+
uint256 nonce;
|
|
24
|
+
address tokenA;
|
|
25
|
+
address tokenB;
|
|
26
|
+
uint256 orderId;
|
|
27
|
+
uint256 amountOfTokenBToFill;
|
|
28
|
+
bytes signature;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
struct MetadataMakeOrder {
|
|
32
|
+
uint256 nonce;
|
|
33
|
+
address tokenA;
|
|
34
|
+
address tokenB;
|
|
35
|
+
uint256 amountA;
|
|
36
|
+
uint256 amountB;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
struct Order {
|
|
40
|
+
address seller;
|
|
41
|
+
uint256 amountA;
|
|
42
|
+
uint256 amountB;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
struct OrderForGetter {
|
|
46
|
+
uint256 marketId;
|
|
47
|
+
uint256 orderId;
|
|
48
|
+
address seller;
|
|
49
|
+
uint256 amountA;
|
|
50
|
+
uint256 amountB;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
struct Percentage {
|
|
54
|
+
uint256 seller;
|
|
55
|
+
uint256 service;
|
|
56
|
+
uint256 mateStaker;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function acceptFillFixedPercentage() external;
|
|
60
|
+
function acceptFillPropotionalPercentage() external;
|
|
61
|
+
function acceptMaxLimitFillFixedFee() external;
|
|
62
|
+
function acceptOwner() external;
|
|
63
|
+
function acceptPercentageFee() external;
|
|
64
|
+
function acceptWithdrawal() external;
|
|
65
|
+
function addBalance(address _token, uint256 _amount) external;
|
|
66
|
+
function cancelOrder(
|
|
67
|
+
address user,
|
|
68
|
+
MetadataCancelOrder memory metadata,
|
|
69
|
+
uint256 _priorityFee_Evvm,
|
|
70
|
+
uint256 _nonce_Evvm,
|
|
71
|
+
bool _priority_Evvm,
|
|
72
|
+
bytes memory _signature_Evvm
|
|
73
|
+
) external;
|
|
74
|
+
function checkIfANonceP2PSwapIsUsed(address user, uint256 nonce) external view returns (bool);
|
|
75
|
+
function dispatchOrder_fillFixedFee(
|
|
76
|
+
address user,
|
|
77
|
+
MetadataDispatchOrder memory metadata,
|
|
78
|
+
uint256 _priorityFee_Evvm,
|
|
79
|
+
uint256 _nonce_Evvm,
|
|
80
|
+
bool _priority_Evvm,
|
|
81
|
+
bytes memory _signature_Evvm,
|
|
82
|
+
uint256 _amountOut
|
|
83
|
+
) external;
|
|
84
|
+
function dispatchOrder_fillPropotionalFee(
|
|
85
|
+
address user,
|
|
86
|
+
MetadataDispatchOrder memory metadata,
|
|
87
|
+
uint256 _priorityFee_Evvm,
|
|
88
|
+
uint256 _nonce_Evvm,
|
|
89
|
+
bool _priority_Evvm,
|
|
90
|
+
bytes memory _signature_Evvm
|
|
91
|
+
) external;
|
|
92
|
+
function findMarket(address tokenA, address tokenB) external view returns (uint256);
|
|
93
|
+
function getAllMarketOrders(uint256 market) external view returns (OrderForGetter[] memory orders);
|
|
94
|
+
function getAllMarketsMetadata() external view returns (MarketInformation[] memory);
|
|
95
|
+
function getBalanceOfContract(address token) external view returns (uint256);
|
|
96
|
+
function getMarketMetadata(uint256 market) external view returns (MarketInformation memory);
|
|
97
|
+
function getMaxLimitFillFixedFee() external view returns (uint256);
|
|
98
|
+
function getMaxLimitFillFixedFeeProposal() external view returns (uint256);
|
|
99
|
+
function getMyOrdersInSpecificMarket(address user, uint256 market)
|
|
100
|
+
external
|
|
101
|
+
view
|
|
102
|
+
returns (OrderForGetter[] memory orders);
|
|
103
|
+
function getOrder(uint256 market, uint256 orderId) external view returns (Order memory order);
|
|
104
|
+
function getOwner() external view returns (address);
|
|
105
|
+
function getOwnerProposal() external view returns (address);
|
|
106
|
+
function getOwnerTimeToAccept() external view returns (uint256);
|
|
107
|
+
function getPercentageFee() external view returns (uint256);
|
|
108
|
+
function getProposalPercentageFee() external view returns (uint256);
|
|
109
|
+
function getProposedWithdrawal() external view returns (address, uint256, address, uint256);
|
|
110
|
+
function getRewardPercentage() external view returns (Percentage memory);
|
|
111
|
+
function getRewardPercentageProposal() external view returns (Percentage memory);
|
|
112
|
+
function makeOrder(
|
|
113
|
+
address user,
|
|
114
|
+
MetadataMakeOrder memory metadata,
|
|
115
|
+
bytes memory signature,
|
|
116
|
+
uint256 _priorityFee_Evvm,
|
|
117
|
+
uint256 _nonce_Evvm,
|
|
118
|
+
bool _priority_Evvm,
|
|
119
|
+
bytes memory _signature_Evvm
|
|
120
|
+
) external returns (uint256 market, uint256 orderId);
|
|
121
|
+
function proposeFillFixedPercentage(uint256 _seller, uint256 _service, uint256 _mateStaker) external;
|
|
122
|
+
function proposeFillPropotionalPercentage(uint256 _seller, uint256 _service, uint256 _mateStaker) external;
|
|
123
|
+
function proposeMaxLimitFillFixedFee(uint256 _maxLimitFillFixedFee) external;
|
|
124
|
+
function proposeOwner(address _owner) external;
|
|
125
|
+
function proposePercentageFee(uint256 _percentageFee) external;
|
|
126
|
+
function proposeWithdrawal(address _tokenToWithdraw, uint256 _amountToWithdraw, address _to) external;
|
|
127
|
+
function rejectProposeFillFixedPercentage() external;
|
|
128
|
+
function rejectProposeFillPropotionalPercentage() external;
|
|
129
|
+
function rejectProposeMaxLimitFillFixedFee() external;
|
|
130
|
+
function rejectProposeOwner() external;
|
|
131
|
+
function rejectProposePercentageFee() external;
|
|
132
|
+
function rejectProposeWithdrawal() external;
|
|
133
|
+
function stake(uint256 amount) external;
|
|
134
|
+
function unstake(uint256 amount) external;
|
|
135
|
+
}
|
package/package.json
CHANGED