@atomicfinance/bitcoin-wallet-provider 4.2.8 → 4.3.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.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint$colon$fix.log +4 -0
- package/.turbo/turbo-lint.log +5 -0
- package/.turbo/turbo-test.log +0 -0
- package/.yalc/@node-dlc/core/.nyc_output/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +1 -0
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +1 -0
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/index.json +1 -0
- package/.yalc/@node-dlc/core/README.md +11 -0
- package/.yalc/@node-dlc/core/__tests__/core.spec.ts +7 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/CETCalculator.spec.ts +1029 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/CoinSelect.spec.ts +179 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/PolynomialPayoutCurve.spec.ts +345 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/TxBuilder.spec.ts +424 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/Builder.spec.ts +492 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CoveredCall.spec.ts +112 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CsoInfo.spec.ts +1124 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongCall.spec.ts +55 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongPut.spec.ts +55 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/OptionInfo.spec.ts +226 -0
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/ShortPut.spec.ts +62 -0
- package/.yalc/@node-dlc/core/__tests__/tsconfig.json +8 -0
- package/.yalc/@node-dlc/core/__tests__/utils/precision.spec.ts +40 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/base.css +224 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/block-navigation.js +79 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/favicon.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/index.html +171 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/AsyncProcessingQueue.ts.html +269 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Base32.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BigIntUtils.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BitField.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ChannelId.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedList.ts.html +413 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedListNode.ts.html +122 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Queue.ts.html +188 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelId.ts.html +86 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelIdUtils.ts.html +107 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CETCalculator.ts.html +1430 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CoinSelect.ts.html +431 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/HyperbolaPayoutCurve.ts.html +644 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/PolynomialPayoutCurve.ts.html +878 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxBuilder.ts.html +1088 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxFinalizer.ts.html +731 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/Builder.ts.html +2270 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CoveredCall.ts.html +410 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CsoInfo.ts.html +1574 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LinearPayout.ts.html +362 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongCall.ts.html +302 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongPut.ts.html +302 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/OptionInfo.ts.html +626 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/ShortPut.ts.html +305 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/index.html +216 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/index.html +186 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.html +261 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.ts.html +278 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelId.ts.html +242 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelKeys.ts.html +407 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentNumber.ts.html +362 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecret.ts.html +203 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecretStore.ts.html +332 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/Htlc.ts.html +236 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/HtlcDirection.ts.html +131 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ScriptFactory.ts.html +530 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/TxFactory.ts.html +1094 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/index.html +231 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/BigIntUtils.ts.html +272 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/Precision.ts.html +149 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/index.html +126 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.css +1 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.js +2 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/sorter.js +170 -0
- package/.yalc/@node-dlc/core/coverage/lcov.info +2426 -0
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.d.ts +22 -0
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js +55 -0
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/Base32.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/Base32.js +7 -0
- package/.yalc/@node-dlc/core/dist/Base32.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/BigIntUtils.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js +8 -0
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/BitField.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/BitField.js +7 -0
- package/.yalc/@node-dlc/core/dist/BitField.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/ChannelId.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/ChannelId.js +7 -0
- package/.yalc/@node-dlc/core/dist/ChannelId.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/LinkedList.d.ts +30 -0
- package/.yalc/@node-dlc/core/dist/LinkedList.js +104 -0
- package/.yalc/@node-dlc/core/dist/LinkedList.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/LinkedListNode.d.ts +9 -0
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js +15 -0
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/Queue.d.ts +22 -0
- package/.yalc/@node-dlc/core/dist/Queue.js +38 -0
- package/.yalc/@node-dlc/core/dist/Queue.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelId.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js +7 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.d.ts +1 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js +12 -0
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.d.ts +50 -0
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js +332 -0
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.d.ts +23 -0
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js +77 -0
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.d.ts +20 -0
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js +117 -0
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.d.ts +5 -0
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js +3 -0
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.d.ts +52 -0
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js +173 -0
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.d.ts +55 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js +217 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.d.ts +40 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js +146 -0
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.d.ts +193 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js +422 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js +67 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.d.ts +114 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js +290 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.d.ts +6 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js +79 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js +47 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js +47 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.d.ts +20 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js +101 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.d.ts +12 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js +46 -0
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/index.d.ts +39 -0
- package/.yalc/@node-dlc/core/dist/index.js +78 -0
- package/.yalc/@node-dlc/core/dist/index.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.d.ts +31 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js +52 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.d.ts +55 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js +105 -0
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.d.ts +55 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js +76 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.d.ts +26 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js +44 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.d.ts +41 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js +79 -0
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.d.ts +46 -0
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js +46 -0
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.d.ts +16 -0
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js +21 -0
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.d.ts +76 -0
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js +102 -0
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.d.ts +83 -0
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js +222 -0
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.d.ts +9 -0
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js +59 -0
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js.map +1 -0
- package/.yalc/@node-dlc/core/dist/utils/Precision.d.ts +13 -0
- package/.yalc/@node-dlc/core/dist/utils/Precision.js +28 -0
- package/.yalc/@node-dlc/core/dist/utils/Precision.js.map +1 -0
- package/.yalc/@node-dlc/core/lib/AsyncProcessingQueue.ts +63 -0
- package/.yalc/@node-dlc/core/lib/Base32.ts +2 -0
- package/.yalc/@node-dlc/core/lib/BigIntUtils.ts +2 -0
- package/.yalc/@node-dlc/core/lib/BitField.ts +2 -0
- package/.yalc/@node-dlc/core/lib/ChannelId.ts +2 -0
- package/.yalc/@node-dlc/core/lib/LinkedList.ts +111 -0
- package/.yalc/@node-dlc/core/lib/LinkedListNode.ts +14 -0
- package/.yalc/@node-dlc/core/lib/Queue.ts +36 -0
- package/.yalc/@node-dlc/core/lib/ShortChannelId.ts +2 -0
- package/.yalc/@node-dlc/core/lib/ShortChannelIdUtils.ts +9 -0
- package/.yalc/@node-dlc/core/lib/dlc/CETCalculator.ts +450 -0
- package/.yalc/@node-dlc/core/lib/dlc/CoinSelect.ts +117 -0
- package/.yalc/@node-dlc/core/lib/dlc/HyperbolaPayoutCurve.ts +188 -0
- package/.yalc/@node-dlc/core/lib/dlc/PayoutCurve.ts +6 -0
- package/.yalc/@node-dlc/core/lib/dlc/PolynomialPayoutCurve.ts +266 -0
- package/.yalc/@node-dlc/core/lib/dlc/TxBuilder.ts +336 -0
- package/.yalc/@node-dlc/core/lib/dlc/TxFinalizer.ts +217 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/Builder.ts +730 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/CoveredCall.ts +110 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/CsoInfo.ts +498 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/LinearPayout.ts +94 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongCall.ts +74 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongPut.ts +74 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/OptionInfo.ts +182 -0
- package/.yalc/@node-dlc/core/lib/dlc/finance/ShortPut.ts +75 -0
- package/.yalc/@node-dlc/core/lib/index.ts +66 -0
- package/.yalc/@node-dlc/core/lib/lightning/ChannelId.ts +54 -0
- package/.yalc/@node-dlc/core/lib/lightning/ChannelKeys.ts +109 -0
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentNumber.ts +94 -0
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecret.ts +41 -0
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecretStore.ts +84 -0
- package/.yalc/@node-dlc/core/lib/lightning/Htlc.ts +52 -0
- package/.yalc/@node-dlc/core/lib/lightning/HtlcDirection.ts +17 -0
- package/.yalc/@node-dlc/core/lib/lightning/ScriptFactory.ts +150 -0
- package/.yalc/@node-dlc/core/lib/lightning/TxFactory.ts +338 -0
- package/.yalc/@node-dlc/core/lib/utils/BigIntUtils.ts +64 -0
- package/.yalc/@node-dlc/core/lib/utils/Precision.ts +23 -0
- package/.yalc/@node-dlc/core/package.json +38 -0
- package/.yalc/@node-dlc/core/tsconfig.json +8 -0
- package/.yalc/@node-dlc/core/yalc.sig +1 -0
- package/CHANGELOG.md +23 -0
- package/package.json +7 -7
- package/yalc.lock +10 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Value } from '@node-dlc/bitcoin';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
|
|
4
|
+
import { dualFees, dualFundingCoinSelect, UTXO } from '../../lib';
|
|
5
|
+
|
|
6
|
+
const getUtxos = (totalCollateral: bigint, numUtxos = 1) => {
|
|
7
|
+
const utxos: UTXO[] = [];
|
|
8
|
+
|
|
9
|
+
for (let i = 0; i < numUtxos; i++) {
|
|
10
|
+
utxos.push({
|
|
11
|
+
address: 'bcrt1qjzut0906d9sk4hml4k6sz6cssljktf4c7yl80f',
|
|
12
|
+
txid: 'c7bf12ac16aba1cf6c7769117294853453f7da3006363dfe4e8979847e32f7e1',
|
|
13
|
+
value: Math.ceil(Number(totalCollateral) / numUtxos),
|
|
14
|
+
vout: Math.floor(Math.random() * 11), // random integer between 0 and 10
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return utxos;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
describe('CoinSelect', () => {
|
|
22
|
+
describe('dualFundingCoinSelect', () => {
|
|
23
|
+
it('should select coins correctly for 5 UTXOs and feeRate 450', () => {
|
|
24
|
+
const feeRate = BigInt(450);
|
|
25
|
+
const numUtxos = 5;
|
|
26
|
+
const totalCollateral = Value.fromBitcoin(0.01);
|
|
27
|
+
const offerCollateral = Value.fromBitcoin(0.0075);
|
|
28
|
+
|
|
29
|
+
const utxos = getUtxos(totalCollateral.sats, numUtxos);
|
|
30
|
+
|
|
31
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
32
|
+
utxos,
|
|
33
|
+
[offerCollateral.sats],
|
|
34
|
+
feeRate,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
expect(fee).to.equal(BigInt(217350));
|
|
38
|
+
expect(inputs.length).to.equal(5);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should fail to select coins if fee is greater than sum of utxos', () => {
|
|
42
|
+
const feeRate = BigInt(450);
|
|
43
|
+
const numUtxos = 5;
|
|
44
|
+
const totalCollateral = Value.fromBitcoin(0.01);
|
|
45
|
+
const offerCollateral = Value.fromBitcoin(0.096);
|
|
46
|
+
|
|
47
|
+
const utxos = getUtxos(totalCollateral.sats, numUtxos);
|
|
48
|
+
|
|
49
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
50
|
+
utxos,
|
|
51
|
+
[offerCollateral.sats],
|
|
52
|
+
feeRate,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(fee).to.equal(BigInt(94950));
|
|
56
|
+
expect(inputs.length).to.equal(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should fail to select coins if detrimental input', () => {
|
|
60
|
+
const feeRate = BigInt(450);
|
|
61
|
+
const numUtxos = 1;
|
|
62
|
+
const totalCollateral = Value.fromSats(30000);
|
|
63
|
+
const offerCollateral = Value.fromSats(20000);
|
|
64
|
+
|
|
65
|
+
const utxos = getUtxos(totalCollateral.sats, numUtxos);
|
|
66
|
+
|
|
67
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
68
|
+
utxos,
|
|
69
|
+
[offerCollateral.sats],
|
|
70
|
+
feeRate,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(fee).to.equal(BigInt(94950));
|
|
74
|
+
expect(inputs.length).to.equal(0);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should prioritize utxo selection', () => {
|
|
78
|
+
const feeRate = BigInt(450);
|
|
79
|
+
const numUtxos = 5;
|
|
80
|
+
const totalCollateral = Value.fromBitcoin(0.01);
|
|
81
|
+
const offerCollateral = Value.fromBitcoin(0.0075);
|
|
82
|
+
|
|
83
|
+
const utxos = getUtxos(totalCollateral.sats, numUtxos);
|
|
84
|
+
|
|
85
|
+
utxos.push({
|
|
86
|
+
address: 'bcrt1qjzut0906d9sk4hml4k6sz6cssljktf4c7yl80f',
|
|
87
|
+
txid:
|
|
88
|
+
'c7bf12ac16aba1cf6c7769117294853453f7da3006363dfe4e8979847e32f7e1',
|
|
89
|
+
value: 10000,
|
|
90
|
+
vout: Math.floor(Math.random() * 11), // random integer between 0 and 10
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
94
|
+
utxos,
|
|
95
|
+
[offerCollateral.sats],
|
|
96
|
+
feeRate,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(fee).to.equal(BigInt(217350));
|
|
100
|
+
expect(inputs.length).to.equal(5);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('Additional CoinSelect Tests', () => {
|
|
105
|
+
const feeRate = BigInt(450);
|
|
106
|
+
const totalCollateral = Value.fromBitcoin(0.01);
|
|
107
|
+
const offerCollateral = Value.fromBitcoin(0.0075);
|
|
108
|
+
|
|
109
|
+
it('should fail to select coins when all UTXOs are detrimental due to high fee rate', () => {
|
|
110
|
+
const highFeeRate = BigInt(10000); // An exaggerated fee rate to make the point
|
|
111
|
+
const utxos = getUtxos(totalCollateral.sats, 5);
|
|
112
|
+
|
|
113
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
114
|
+
utxos,
|
|
115
|
+
[offerCollateral.sats],
|
|
116
|
+
highFeeRate,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(inputs.length).to.equal(0);
|
|
120
|
+
expect(fee).to.equal(BigInt(2110000));
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should select all UTXOs when they are just enough to cover collateral and fees', () => {
|
|
124
|
+
const utxos = getUtxos(totalCollateral.sats, 5);
|
|
125
|
+
|
|
126
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
127
|
+
utxos,
|
|
128
|
+
[offerCollateral.sats],
|
|
129
|
+
feeRate,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
expect(inputs.length).to.equal(5);
|
|
133
|
+
expect(fee).to.equal(BigInt(217350));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('should select UTXOs optimally from a mixed set', () => {
|
|
137
|
+
const mixedUtxos = [
|
|
138
|
+
...getUtxos(Value.fromBitcoin(0.005).sats, 2), // smaller UTXOs
|
|
139
|
+
...getUtxos(Value.fromBitcoin(0.02).sats, 3), // larger UTXOs
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
143
|
+
mixedUtxos,
|
|
144
|
+
[offerCollateral.sats],
|
|
145
|
+
feeRate,
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// Expecting it to select fewer, larger UTXOs over many small ones
|
|
149
|
+
expect(inputs.length).to.be.lessThan(5);
|
|
150
|
+
expect(fee).to.equal(BigInt(125550));
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should handle an empty array of UTXOs correctly', () => {
|
|
154
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
155
|
+
[],
|
|
156
|
+
[offerCollateral.sats],
|
|
157
|
+
feeRate,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
expect(inputs.length).to.equal(0);
|
|
161
|
+
expect(fee).to.equal(dualFees(feeRate, 1, 1)); // The fee for an attempt with no inputs
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('should select fewer UTXOs with a very low fee rate', () => {
|
|
165
|
+
const lowFeeRate = BigInt(1); // An extremely low fee rate
|
|
166
|
+
const utxos = getUtxos(totalCollateral.sats, 10); // More UTXOs than needed
|
|
167
|
+
|
|
168
|
+
const { fee, inputs } = dualFundingCoinSelect(
|
|
169
|
+
utxos,
|
|
170
|
+
[offerCollateral.sats],
|
|
171
|
+
lowFeeRate,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
// Expecting it to select fewer UTXOs due to the low cost of adding an input
|
|
175
|
+
expect(inputs.length).to.be.lessThan(10);
|
|
176
|
+
expect(fee).to.equal(BigInt(687));
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MessageType,
|
|
3
|
+
PayoutFunction,
|
|
4
|
+
PolynomialPayoutCurvePiece,
|
|
5
|
+
RoundingIntervals,
|
|
6
|
+
} from '@node-dlc/messaging';
|
|
7
|
+
import BigNumber from 'bignumber.js';
|
|
8
|
+
import { expect } from 'chai';
|
|
9
|
+
|
|
10
|
+
import { HyperbolaPayoutCurve } from '../../lib';
|
|
11
|
+
import { LinearPayout } from '../../lib/dlc/finance/LinearPayout';
|
|
12
|
+
import { PolynomialPayoutCurve } from '../../lib/dlc/PolynomialPayoutCurve';
|
|
13
|
+
import { fromPrecision } from '../../lib/utils/Precision';
|
|
14
|
+
|
|
15
|
+
describe('PolynomialPayoutCurve', () => {
|
|
16
|
+
const points = [
|
|
17
|
+
{
|
|
18
|
+
outcome: new BigNumber(1),
|
|
19
|
+
payout: new BigNumber(1),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
outcome: new BigNumber(2),
|
|
23
|
+
payout: new BigNumber(3),
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
describe('#constructor', () => {
|
|
28
|
+
it('should create a PolynomialPayoutCurve', () => {
|
|
29
|
+
const curve = new PolynomialPayoutCurve(points);
|
|
30
|
+
expect(curve).to.be.instanceOf(PolynomialPayoutCurve);
|
|
31
|
+
});
|
|
32
|
+
it('should fail if not 2 points', () => {
|
|
33
|
+
// 1 point
|
|
34
|
+
expect(
|
|
35
|
+
() =>
|
|
36
|
+
new PolynomialPayoutCurve([
|
|
37
|
+
{
|
|
38
|
+
outcome: new BigNumber(1),
|
|
39
|
+
payout: new BigNumber(1),
|
|
40
|
+
},
|
|
41
|
+
]),
|
|
42
|
+
).to.throw('Must have two points');
|
|
43
|
+
|
|
44
|
+
// 3 points
|
|
45
|
+
expect(
|
|
46
|
+
() =>
|
|
47
|
+
new PolynomialPayoutCurve([
|
|
48
|
+
{
|
|
49
|
+
outcome: new BigNumber(1),
|
|
50
|
+
payout: new BigNumber(1),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
outcome: new BigNumber(2),
|
|
54
|
+
payout: new BigNumber(2),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
outcome: new BigNumber(3),
|
|
58
|
+
payout: new BigNumber(3),
|
|
59
|
+
},
|
|
60
|
+
]),
|
|
61
|
+
).to.throw;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('#getPayout', () => {
|
|
66
|
+
it('should get the payout for an outcome', () => {
|
|
67
|
+
const curve = new PolynomialPayoutCurve(points);
|
|
68
|
+
const payout = curve.getPayout(BigInt(1));
|
|
69
|
+
expect(payout).to.deep.equal(new BigNumber(1));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should get the payout for an outcome', () => {
|
|
73
|
+
const curve = new PolynomialPayoutCurve(points);
|
|
74
|
+
const payout = curve.getPayout(BigInt(2));
|
|
75
|
+
expect(payout).to.deep.equal(new BigNumber(3));
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('#getOutcomeForPayout', () => {
|
|
80
|
+
it('should get the outcome for a payout', () => {
|
|
81
|
+
const curve = new PolynomialPayoutCurve(points);
|
|
82
|
+
const outcome = curve.getOutcomeForPayout(new BigNumber(1));
|
|
83
|
+
expect(outcome).to.deep.equal(BigInt(1));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should get the outcome for a payout', () => {
|
|
87
|
+
const curve = new PolynomialPayoutCurve(points);
|
|
88
|
+
const outcome = curve.getOutcomeForPayout(new BigNumber(3));
|
|
89
|
+
expect(outcome).to.deep.equal(BigInt(2));
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('#toPayoutCurvePiece', () => {
|
|
94
|
+
it('should serialize to a PolynomialPayoutCurvePiece', () => {
|
|
95
|
+
const curve = new PolynomialPayoutCurve(points);
|
|
96
|
+
const piece = curve.toPayoutCurvePiece();
|
|
97
|
+
expect(piece).to.deep.equal({
|
|
98
|
+
type: MessageType.PolynomialPayoutCurvePiece,
|
|
99
|
+
payoutCurvePieceType: 0, // PayoutCurvePieceType.Polynomial
|
|
100
|
+
points: [
|
|
101
|
+
{
|
|
102
|
+
eventOutcome: BigInt(1),
|
|
103
|
+
outcomePayout: BigInt(1),
|
|
104
|
+
extraPrecision: 0,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
eventOutcome: BigInt(2),
|
|
108
|
+
outcomePayout: BigInt(3),
|
|
109
|
+
extraPrecision: 0,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('#fromPayoutCurvePiece', () => {
|
|
117
|
+
const points = [
|
|
118
|
+
{
|
|
119
|
+
eventOutcome: BigInt(1),
|
|
120
|
+
outcomePayout: BigInt(1),
|
|
121
|
+
extraPrecision: 0,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
eventOutcome: BigInt(2),
|
|
125
|
+
outcomePayout: BigInt(3),
|
|
126
|
+
extraPrecision: 0,
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
it('should deserialize from a PolynomialPayoutCurvePiece', () => {
|
|
131
|
+
const piece = new PolynomialPayoutCurvePiece();
|
|
132
|
+
piece.points = points;
|
|
133
|
+
const curve = PolynomialPayoutCurve.fromPayoutCurvePiece(piece);
|
|
134
|
+
expect(curve).to.be.instanceOf(PolynomialPayoutCurve);
|
|
135
|
+
expect(curve['points']).to.deep.eq(
|
|
136
|
+
points.map((p) => ({
|
|
137
|
+
outcome: new BigNumber(p.eventOutcome.toString()),
|
|
138
|
+
payout: new BigNumber(p.outcomePayout.toString()).plus(
|
|
139
|
+
fromPrecision(p.extraPrecision),
|
|
140
|
+
),
|
|
141
|
+
})),
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('#equals', () => {
|
|
147
|
+
it('should return true if the curves are equal', () => {
|
|
148
|
+
const curve1 = new PolynomialPayoutCurve(points);
|
|
149
|
+
const curve2 = new PolynomialPayoutCurve(points);
|
|
150
|
+
expect(curve1.equals(curve2)).to.be.true;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should return false if the curves are not equal', () => {
|
|
154
|
+
const curve1 = new PolynomialPayoutCurve(points);
|
|
155
|
+
const curve2 = new PolynomialPayoutCurve([
|
|
156
|
+
{
|
|
157
|
+
outcome: new BigNumber(1),
|
|
158
|
+
payout: new BigNumber(1),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
outcome: new BigNumber(3),
|
|
162
|
+
payout: new BigNumber(3),
|
|
163
|
+
},
|
|
164
|
+
]);
|
|
165
|
+
expect(curve1.equals(curve2)).to.be.false;
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('#computePayouts', () => {
|
|
170
|
+
it('should compute the correct payouts for simple interval', () => {
|
|
171
|
+
const numDigits = 18;
|
|
172
|
+
const oracleBase = 2;
|
|
173
|
+
const minPayout = 40n;
|
|
174
|
+
const maxPayout = 60n;
|
|
175
|
+
const startOutcome = 40n;
|
|
176
|
+
const endOutcome = 60n;
|
|
177
|
+
|
|
178
|
+
const { payoutFunction } = LinearPayout.buildPayoutFunction(
|
|
179
|
+
minPayout,
|
|
180
|
+
maxPayout,
|
|
181
|
+
startOutcome,
|
|
182
|
+
endOutcome,
|
|
183
|
+
oracleBase,
|
|
184
|
+
numDigits,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const intervals = [{ beginInterval: 0n, roundingMod: 1n }];
|
|
188
|
+
const roundingIntervals = new RoundingIntervals();
|
|
189
|
+
roundingIntervals.intervals = intervals;
|
|
190
|
+
|
|
191
|
+
const payouts = PolynomialPayoutCurve.computePayouts(
|
|
192
|
+
payoutFunction,
|
|
193
|
+
maxPayout,
|
|
194
|
+
roundingIntervals,
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const n = payouts.length - 1;
|
|
198
|
+
|
|
199
|
+
const maxOutcome = BigInt(
|
|
200
|
+
new BigNumber(oracleBase).pow(numDigits).minus(1).toString(10),
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
expect(n).to.eq(20);
|
|
204
|
+
|
|
205
|
+
// max loss CETS
|
|
206
|
+
expect(payouts[0].indexFrom).to.eq(0n);
|
|
207
|
+
expect(payouts[0].indexTo).to.eq(startOutcome);
|
|
208
|
+
expect(payouts[0].payout).to.eq(minPayout);
|
|
209
|
+
|
|
210
|
+
// payout curve CETS
|
|
211
|
+
for (let i = 1; i < n - 1; ++i) {
|
|
212
|
+
expect(payouts[i].indexFrom).to.eq(startOutcome + BigInt(i));
|
|
213
|
+
expect(payouts[i].indexTo).to.eq(startOutcome + BigInt(i));
|
|
214
|
+
expect(payouts[i].payout).to.eq(minPayout + BigInt(i));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// max gain CETS
|
|
218
|
+
expect(payouts[n].indexFrom).to.eq(endOutcome);
|
|
219
|
+
expect(payouts[n].indexTo).to.eq(maxOutcome);
|
|
220
|
+
expect(payouts[n].payout).to.eq(maxPayout);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('should compute the correct payouts for advanced interval', () => {
|
|
224
|
+
const numDigits = 18;
|
|
225
|
+
const oracleBase = 2;
|
|
226
|
+
const minPayout = 40n;
|
|
227
|
+
const maxPayout = 60n;
|
|
228
|
+
const startOutcome = 40n;
|
|
229
|
+
const endOutcome = 60n;
|
|
230
|
+
|
|
231
|
+
const { payoutFunction } = LinearPayout.buildPayoutFunction(
|
|
232
|
+
minPayout,
|
|
233
|
+
maxPayout,
|
|
234
|
+
startOutcome,
|
|
235
|
+
endOutcome,
|
|
236
|
+
oracleBase,
|
|
237
|
+
numDigits,
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
const intervals = [{ beginInterval: 0n, roundingMod: 2n }];
|
|
241
|
+
const roundingIntervals = new RoundingIntervals();
|
|
242
|
+
roundingIntervals.intervals = intervals;
|
|
243
|
+
|
|
244
|
+
const payouts = PolynomialPayoutCurve.computePayouts(
|
|
245
|
+
payoutFunction,
|
|
246
|
+
maxPayout,
|
|
247
|
+
roundingIntervals,
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const n = payouts.length - 1;
|
|
251
|
+
|
|
252
|
+
const maxOutcome = BigInt(
|
|
253
|
+
new BigNumber(oracleBase).pow(numDigits).minus(1).toString(10),
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
expect(n).to.eq(10);
|
|
257
|
+
|
|
258
|
+
// max loss CETS
|
|
259
|
+
expect(payouts[0].indexFrom).to.eq(0n);
|
|
260
|
+
expect(payouts[0].indexTo).to.eq(startOutcome);
|
|
261
|
+
expect(payouts[0].payout).to.eq(minPayout);
|
|
262
|
+
|
|
263
|
+
// payout curve CETS
|
|
264
|
+
for (let i = 1; i < n; ++i) {
|
|
265
|
+
expect(payouts[i].indexFrom).to.eq(
|
|
266
|
+
startOutcome + 2n * BigInt(i - 1) + 1n,
|
|
267
|
+
);
|
|
268
|
+
expect(payouts[i].indexTo).to.eq(startOutcome + 2n * BigInt(i));
|
|
269
|
+
expect(payouts[i].payout).to.eq(minPayout + 2n * BigInt(i));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// max gain CETS
|
|
273
|
+
expect(payouts[n].indexFrom).to.eq(endOutcome - 1n);
|
|
274
|
+
expect(payouts[n].indexTo).to.eq(maxOutcome);
|
|
275
|
+
expect(payouts[n].payout).to.eq(maxPayout);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('should fail if < 1 payout function pieces', () => {
|
|
279
|
+
const maxPayout = 60n;
|
|
280
|
+
|
|
281
|
+
const payoutFunction = new PayoutFunction();
|
|
282
|
+
payoutFunction.payoutFunctionPieces = [];
|
|
283
|
+
payoutFunction.lastEndpoint = {
|
|
284
|
+
eventOutcome: BigInt(0),
|
|
285
|
+
outcomePayout: BigInt(0),
|
|
286
|
+
extraPrecision: 0,
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const intervals = [{ beginInterval: 0n, roundingMod: 1n }];
|
|
290
|
+
const roundingIntervals = new RoundingIntervals();
|
|
291
|
+
roundingIntervals.intervals = intervals;
|
|
292
|
+
|
|
293
|
+
expect(() => {
|
|
294
|
+
PolynomialPayoutCurve.computePayouts(
|
|
295
|
+
payoutFunction,
|
|
296
|
+
maxPayout,
|
|
297
|
+
roundingIntervals,
|
|
298
|
+
);
|
|
299
|
+
}).to.throw('Must have at least one piece');
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('should fail if there is a non-polynomial payout curve piece', () => {
|
|
303
|
+
const maxPayout = 60n;
|
|
304
|
+
|
|
305
|
+
const hyperbola = new HyperbolaPayoutCurve(
|
|
306
|
+
new BigNumber(1),
|
|
307
|
+
new BigNumber(0),
|
|
308
|
+
new BigNumber(0),
|
|
309
|
+
new BigNumber(500000),
|
|
310
|
+
new BigNumber(0),
|
|
311
|
+
new BigNumber(0),
|
|
312
|
+
true,
|
|
313
|
+
).toPayoutCurvePiece();
|
|
314
|
+
|
|
315
|
+
const payoutFunction = new PayoutFunction();
|
|
316
|
+
payoutFunction.payoutFunctionPieces = [
|
|
317
|
+
{
|
|
318
|
+
endPoint: {
|
|
319
|
+
eventOutcome: 2n,
|
|
320
|
+
outcomePayout: 2n,
|
|
321
|
+
extraPrecision: 0,
|
|
322
|
+
},
|
|
323
|
+
payoutCurvePiece: hyperbola,
|
|
324
|
+
},
|
|
325
|
+
];
|
|
326
|
+
payoutFunction.lastEndpoint = {
|
|
327
|
+
eventOutcome: 0n,
|
|
328
|
+
outcomePayout: 0n,
|
|
329
|
+
extraPrecision: 0,
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const intervals = [{ beginInterval: 0n, roundingMod: 1n }];
|
|
333
|
+
const roundingIntervals = new RoundingIntervals();
|
|
334
|
+
roundingIntervals.intervals = intervals;
|
|
335
|
+
|
|
336
|
+
expect(() => {
|
|
337
|
+
PolynomialPayoutCurve.computePayouts(
|
|
338
|
+
payoutFunction,
|
|
339
|
+
maxPayout,
|
|
340
|
+
roundingIntervals,
|
|
341
|
+
);
|
|
342
|
+
}).to.throw('Payout curve piece must be a polynomial');
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
});
|