@evvm/testnet-contracts 2.0.4 → 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.
|
@@ -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
|
+
}
|
|
@@ -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