@evvm/testnet-contracts 2.1.0 → 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.
|
@@ -559,7 +559,7 @@ contract P2PSwap is StakingServiceHooks {
|
|
|
559
559
|
* @param _nonce_Evvm Nonce for EVVM payment transaction
|
|
560
560
|
* @param _priority_Evvm Whether to use priority (async) processing
|
|
561
561
|
* @param _signature_Evvm Signature for EVVM payment authorization
|
|
562
|
-
* @param
|
|
562
|
+
* @param maxFillFixedFee Maximum output amount for fee calculation (testing parameter)
|
|
563
563
|
*/
|
|
564
564
|
function dispatchOrder_fillFixedFee(
|
|
565
565
|
address user,
|
|
@@ -568,7 +568,7 @@ contract P2PSwap is StakingServiceHooks {
|
|
|
568
568
|
uint256 _nonce_Evvm,
|
|
569
569
|
bool _priority_Evvm,
|
|
570
570
|
bytes memory _signature_Evvm,
|
|
571
|
-
uint256
|
|
571
|
+
uint256 maxFillFixedFee
|
|
572
572
|
) external {
|
|
573
573
|
if (
|
|
574
574
|
!SignatureUtils.verifyMessageSignedForDispatchOrder(
|
|
@@ -598,9 +598,8 @@ contract P2PSwap is StakingServiceHooks {
|
|
|
598
598
|
}
|
|
599
599
|
|
|
600
600
|
(uint256 fee, uint256 fee10) = calculateFillFixedFee(
|
|
601
|
-
metadata.tokenB,
|
|
602
601
|
ordersInsideMarket[market][metadata.orderId].amountB,
|
|
603
|
-
|
|
602
|
+
maxFillFixedFee
|
|
604
603
|
);
|
|
605
604
|
|
|
606
605
|
if (
|
|
@@ -704,19 +703,17 @@ contract P2PSwap is StakingServiceHooks {
|
|
|
704
703
|
/**
|
|
705
704
|
* @notice Calculates fixed trading fee with maximum limit constraints
|
|
706
705
|
* @dev Compares proportional fee with maximum output, applies 10% reduction if needed
|
|
707
|
-
* @param token Token address for fee calculation (currently unused)
|
|
708
706
|
* @param amount Order amount for proportional fee calculation
|
|
709
|
-
* @param
|
|
707
|
+
* @param maxFillFixedFee Maximum output amount for fee limiting
|
|
710
708
|
* @return fee The final calculated fee amount
|
|
711
709
|
* @return fee10 10% of the fee amount for specific calculations
|
|
712
710
|
*/
|
|
713
711
|
function calculateFillFixedFee(
|
|
714
|
-
address token,
|
|
715
712
|
uint256 amount,
|
|
716
|
-
uint256
|
|
713
|
+
uint256 maxFillFixedFee
|
|
717
714
|
) internal view returns (uint256 fee, uint256 fee10) {
|
|
718
|
-
if (calculateFillPropotionalFee(amount) >
|
|
719
|
-
fee =
|
|
715
|
+
if (calculateFillPropotionalFee(amount) > maxFillFixedFee) {
|
|
716
|
+
fee = maxFillFixedFee;
|
|
720
717
|
fee10 = (fee * 1000) / 10_000;
|
|
721
718
|
} else {
|
|
722
719
|
fee = calculateFillPropotionalFee(amount);
|
package/interfaces/IP2PSwap.sol
CHANGED
|
@@ -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