Comparing version 1.9.2 to 1.9.3
# Versions | ||
## 1.9.2 | ||
## 1.9.3 | ||
@@ -5,0 +5,0 @@ - `hopsFromChannels`, `routeFromChannels`, `routeFromHops`: Add support for |
@@ -31,3 +31,3 @@ { | ||
}, | ||
"version": "1.9.2" | ||
"version": "1.9.3" | ||
} |
@@ -7,2 +7,6 @@ const none = '0'; | ||
{ | ||
inbound: { | ||
[inbound_base_discount_mtokens]: <Source Base Fee Reduction String> | ||
[inbound_rate_discount]: <Source Per Million Rate Reduction Number> | ||
} | ||
mtokens: <Millitokens String> | ||
@@ -12,4 +16,2 @@ policy: { | ||
fee_rate: <Fee Rate Number> | ||
[inbound_base_discount_mtokens]: <Source Base Fee Reduction String> | ||
[inbound_rate_discount]: <Source Per Million Rate Reduction Number> | ||
} | ||
@@ -26,3 +28,3 @@ } | ||
*/ | ||
module.exports = ({mtokens, policy}) => { | ||
module.exports = ({inbound, mtokens, policy}) => { | ||
if (mtokens === undefined) { | ||
@@ -47,4 +49,4 @@ throw new Error('ExpectedMillitokensForPolicyFeeCalculation'); | ||
const forwardMtokens = BigInt(mtokens); | ||
const lowerBaseFee = BigInt(policy.inbound_base_discount_mtokens || none); | ||
const lowerFeeRate = BigInt(policy.inbound_rate_discount || none); | ||
const lowerBaseFee = BigInt(inbound.inbound_base_discount_mtokens || none); | ||
const lowerFeeRate = BigInt(inbound.inbound_rate_discount || none); | ||
@@ -51,0 +53,0 @@ const fee = baseFeeMtokens + forwardMtokens * feeRate / rateDivisor; |
@@ -115,3 +115,7 @@ const asTokens = require('./as_tokens'); | ||
if (!!i) { | ||
const forward = policyFee({policy: hops[i-1], mtokens: forwardMtokens}); | ||
const forward = policyFee({ | ||
inbound: hops[i], | ||
policy: hops[i-1], | ||
mtokens: forwardMtokens, | ||
}); | ||
@@ -118,0 +122,0 @@ feeMtokens = BigInt(forward.fee_mtokens); |
@@ -9,3 +9,3 @@ const strictSame = require('node:assert').strict.deepStrictEqual; | ||
{ | ||
args: {}, | ||
args: {inbound: {}}, | ||
description: 'Mtokens are required', | ||
@@ -15,3 +15,3 @@ error: 'ExpectedMillitokensForPolicyFeeCalculation', | ||
{ | ||
args: {mtokens: '1000000'}, | ||
args: {inbound: {}, mtokens: '1000000'}, | ||
description: 'A policy is required', | ||
@@ -21,3 +21,3 @@ error: 'ExpectedPolicyToCalculateFeeFor', | ||
{ | ||
args: {mtokens: '1000000', policy: {}}, | ||
args: {inbound: {}, mtokens: '1000000', policy: {}}, | ||
description: 'Base fee tokens are required', | ||
@@ -27,3 +27,3 @@ error: 'ExpectedBaseFeeMillitokensForPolicyFeeCalculation', | ||
{ | ||
args: {mtokens: '1000000', policy: {base_fee_mtokens: '1'}}, | ||
args: {inbound: {}, mtokens: '1000000', policy: {base_fee_mtokens: '1'}}, | ||
description: 'Fee rate is required', | ||
@@ -33,3 +33,7 @@ error: 'ExpectedFeeRateForPolicyFeeCalculation', | ||
{ | ||
args: {mtokens: '1000000', policy: {base_fee_mtokens: '1', fee_rate: 1}}, | ||
args: { | ||
inbound: {}, | ||
mtokens: '1000000', | ||
policy: {base_fee_mtokens: '1', fee_rate: 1}, | ||
}, | ||
description: 'Fee is calculated', | ||
@@ -40,9 +44,5 @@ expected: {fee_mtokens: '2'}, | ||
args: { | ||
inbound: {inbound_base_discount_mtokens: '1', inbound_rate_discount: 1}, | ||
mtokens: '1000000', | ||
policy: { | ||
base_fee_mtokens: '1', | ||
fee_rate: 1, | ||
inbound_base_discount_mtokens: '1', | ||
inbound_rate_discount: 1, | ||
}, | ||
policy: {base_fee_mtokens: '1', fee_rate: 1}, | ||
}, | ||
@@ -54,9 +54,5 @@ description: 'Fee rate with discount is calculated', | ||
args: { | ||
inbound: {inbound_base_discount_mtokens: '10', inbound_rate_discount: 1}, | ||
mtokens: '1000000', | ||
policy: { | ||
base_fee_mtokens: '1', | ||
fee_rate: 1, | ||
inbound_base_discount_mtokens: '10', | ||
inbound_rate_discount: 1, | ||
}, | ||
policy: {base_fee_mtokens: '1', fee_rate: 1}, | ||
}, | ||
@@ -63,0 +59,0 @@ description: 'Fee rate with big discount is calculated', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104491
3218