@evvm/testnet-contracts 2.0.4 → 2.1.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.
@@ -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
+ }
@@ -11,7 +11,7 @@ MM MMMMMMMM 88 88 88 88 88 88 88. .88 88 88. .88 88
11
11
  MM .M `88888P' dP dP dP dP dP `88888P8 dP `88888P' dP
12
12
  MMMMMMMMMMMM
13
13
 
14
- * @title Staking Mate contract for Roll A Mate Protocol
14
+ * @title Staking Estimator Contract
15
15
  * @author Mate labs
16
16
  */
17
17
 
@@ -1,4 +1,6 @@
1
- // SPDX-License-Identifier: UNLICENSED
1
+ // SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
2
+ // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
+
2
4
  pragma solidity ^0.8.4;
3
5
 
4
6
  interface NameService {
@@ -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 maxFillFixedFee
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
+ }
@@ -375,6 +375,88 @@ library Erc191TestBuilder {
375
375
  );
376
376
  }
377
377
 
378
+ //-----------------------------------------------------------------------------------
379
+ // P2PSwap functions
380
+ //-----------------------------------------------------------------------------------
381
+
382
+ function buildMessageSignedForMakeOrder(
383
+ uint256 evvmID,
384
+ uint256 _nonce,
385
+ address _tokenA,
386
+ address _tokenB,
387
+ uint256 _amountA,
388
+ uint256 _amountB
389
+ ) internal pure returns (bytes32 messageHash) {
390
+ return
391
+ buildHashForSign(
392
+ string.concat(
393
+ Strings.toString(evvmID),
394
+ ",",
395
+ "makeOrder",
396
+ ",",
397
+ Strings.toString(_nonce),
398
+ ",",
399
+ AdvancedStrings.addressToString(_tokenA),
400
+ ",",
401
+ AdvancedStrings.addressToString(_tokenB),
402
+ ",",
403
+ Strings.toString(_amountA),
404
+ ",",
405
+ Strings.toString(_amountB)
406
+ )
407
+ );
408
+ }
409
+
410
+ function buildMessageSignedForCancelOrder(
411
+ uint256 evvmID,
412
+ uint256 _nonce,
413
+ address _tokenA,
414
+ address _tokenB,
415
+ uint256 _orderId
416
+ ) internal pure returns (bytes32 messageHash) {
417
+ return
418
+ buildHashForSign(
419
+ string.concat(
420
+ Strings.toString(evvmID),
421
+ ",",
422
+ "cancelOrder",
423
+ ",",
424
+ Strings.toString(_nonce),
425
+ ",",
426
+ AdvancedStrings.addressToString(_tokenA),
427
+ ",",
428
+ AdvancedStrings.addressToString(_tokenB),
429
+ ",",
430
+ Strings.toString(_orderId)
431
+ )
432
+ );
433
+ }
434
+
435
+ function buildMessageSignedForDispatchOrder(
436
+ uint256 evvmID,
437
+ uint256 _nonce,
438
+ address _tokenA,
439
+ address _tokenB,
440
+ uint256 _orderId
441
+ ) internal pure returns (bytes32 messageHash) {
442
+ return
443
+ buildHashForSign(
444
+ string.concat(
445
+ Strings.toString(evvmID),
446
+ ",",
447
+ "dispatchOrder",
448
+ ",",
449
+ Strings.toString(_nonce),
450
+ ",",
451
+ AdvancedStrings.addressToString(_tokenA),
452
+ ",",
453
+ AdvancedStrings.addressToString(_tokenB),
454
+ ",",
455
+ Strings.toString(_orderId)
456
+ )
457
+ );
458
+ }
459
+
378
460
  //-----------------------------------------------------------------------------------
379
461
  // General functions
380
462
  //-----------------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evvm/testnet-contracts",
3
- "version": "2.0.4",
3
+ "version": "2.1.1",
4
4
  "description": "EVVM Testnet Contracts - Smart contracts and tools for scalable, modular, and cross-chain EVM virtualization",
5
5
  "files": [
6
6
  "contracts/**/*.sol",