bolt07 1.9.0 → 1.9.2
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/CHANGELOG.md +1 -1
- package/package.json +1 -1
- package/routing/policy_fee.js +6 -3
- package/test/routing/test_policy_fee.js +4 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/routing/policy_fee.js
CHANGED
|
@@ -44,13 +44,16 @@ module.exports = ({mtokens, policy}) => {
|
|
|
44
44
|
const lowerBaseFee = BigInt(policy.inbound_base_discount_mtokens || none);
|
|
45
45
|
const lowerFeeRate = BigInt(policy.inbound_rate_discount || none);
|
|
46
46
|
|
|
47
|
-
const discount = lowerBaseFee + forwardMtokens * lowerFeeRate / rateDivisor;
|
|
48
47
|
const fee = baseFeeMtokens + forwardMtokens * feeRate / rateDivisor;
|
|
49
48
|
|
|
49
|
+
const total = fee + forwardMtokens;
|
|
50
|
+
|
|
51
|
+
const discount = lowerBaseFee + total * lowerFeeRate / rateDivisor;
|
|
52
|
+
|
|
50
53
|
// Exit early when the discount drowns out the fee
|
|
51
|
-
if (
|
|
54
|
+
if (discount > fee) {
|
|
52
55
|
return {fee_mtokens: none};
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
return {fee_mtokens: (fee
|
|
58
|
+
return {fee_mtokens: (fee - discount).toString()};
|
|
56
59
|
};
|
|
@@ -36,8 +36,8 @@ const tests = [
|
|
|
36
36
|
policy: {
|
|
37
37
|
base_fee_mtokens: '1',
|
|
38
38
|
fee_rate: 1,
|
|
39
|
-
inbound_base_discount_mtokens: '
|
|
40
|
-
inbound_rate_discount:
|
|
39
|
+
inbound_base_discount_mtokens: '1',
|
|
40
|
+
inbound_rate_discount: 1,
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
description: 'Fee rate with discount is calculated',
|
|
@@ -49,8 +49,8 @@ const tests = [
|
|
|
49
49
|
policy: {
|
|
50
50
|
base_fee_mtokens: '1',
|
|
51
51
|
fee_rate: 1,
|
|
52
|
-
inbound_base_discount_mtokens: '
|
|
53
|
-
inbound_rate_discount:
|
|
52
|
+
inbound_base_discount_mtokens: '10',
|
|
53
|
+
inbound_rate_discount: 1,
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
56
|
description: 'Fee rate with big discount is calculated',
|