@atomicfinance/bitcoin-wallet-provider 4.2.7 → 4.2.8
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 +4 -5
- package/CHANGELOG.md +12 -0
- package/package.json +6 -6
- package/.turbo/turbo-lint$colon$fix.log +0 -4
- package/.turbo/turbo-lint.log +0 -5
- package/.turbo/turbo-test.log +0 -0
- package/.yalc/@node-dlc/core/.nyc_output/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
- package/.yalc/@node-dlc/core/.nyc_output/processinfo/index.json +0 -1
- package/.yalc/@node-dlc/core/README.md +0 -11
- package/.yalc/@node-dlc/core/__tests__/core.spec.ts +0 -7
- package/.yalc/@node-dlc/core/__tests__/dlc/CETCalculator.spec.ts +0 -1029
- package/.yalc/@node-dlc/core/__tests__/dlc/CoinSelect.spec.ts +0 -179
- package/.yalc/@node-dlc/core/__tests__/dlc/PolynomialPayoutCurve.spec.ts +0 -345
- package/.yalc/@node-dlc/core/__tests__/dlc/TxBuilder.spec.ts +0 -424
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/Builder.spec.ts +0 -492
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CoveredCall.spec.ts +0 -112
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/CsoInfo.spec.ts +0 -1124
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongCall.spec.ts +0 -55
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongPut.spec.ts +0 -55
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/OptionInfo.spec.ts +0 -226
- package/.yalc/@node-dlc/core/__tests__/dlc/finance/ShortPut.spec.ts +0 -62
- package/.yalc/@node-dlc/core/__tests__/tsconfig.json +0 -8
- package/.yalc/@node-dlc/core/__tests__/utils/precision.spec.ts +0 -40
- package/.yalc/@node-dlc/core/coverage/lcov-report/base.css +0 -224
- package/.yalc/@node-dlc/core/coverage/lcov-report/block-navigation.js +0 -79
- package/.yalc/@node-dlc/core/coverage/lcov-report/favicon.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/index.html +0 -171
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/AsyncProcessingQueue.ts.html +0 -269
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Base32.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BigIntUtils.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BitField.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ChannelId.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedList.ts.html +0 -413
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedListNode.ts.html +0 -122
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Queue.ts.html +0 -188
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelId.ts.html +0 -86
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelIdUtils.ts.html +0 -107
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CETCalculator.ts.html +0 -1430
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CoinSelect.ts.html +0 -431
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/HyperbolaPayoutCurve.ts.html +0 -644
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/PolynomialPayoutCurve.ts.html +0 -878
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxBuilder.ts.html +0 -1088
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxFinalizer.ts.html +0 -731
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/Builder.ts.html +0 -2270
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CoveredCall.ts.html +0 -410
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CsoInfo.ts.html +0 -1574
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LinearPayout.ts.html +0 -362
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongCall.ts.html +0 -302
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongPut.ts.html +0 -302
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/OptionInfo.ts.html +0 -626
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/ShortPut.ts.html +0 -305
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/index.html +0 -216
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/index.html +0 -186
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.html +0 -261
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.ts.html +0 -278
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelId.ts.html +0 -242
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelKeys.ts.html +0 -407
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentNumber.ts.html +0 -362
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecret.ts.html +0 -203
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecretStore.ts.html +0 -332
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/Htlc.ts.html +0 -236
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/HtlcDirection.ts.html +0 -131
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ScriptFactory.ts.html +0 -530
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/TxFactory.ts.html +0 -1094
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/index.html +0 -231
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/BigIntUtils.ts.html +0 -272
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/Precision.ts.html +0 -149
- package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/index.html +0 -126
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.css +0 -1
- package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.js +0 -2
- package/.yalc/@node-dlc/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/.yalc/@node-dlc/core/coverage/lcov-report/sorter.js +0 -170
- package/.yalc/@node-dlc/core/coverage/lcov.info +0 -2426
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.d.ts +0 -22
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js +0 -55
- package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/Base32.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/Base32.js +0 -7
- package/.yalc/@node-dlc/core/dist/Base32.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/BigIntUtils.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js +0 -8
- package/.yalc/@node-dlc/core/dist/BigIntUtils.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/BitField.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/BitField.js +0 -7
- package/.yalc/@node-dlc/core/dist/BitField.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/ChannelId.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/ChannelId.js +0 -7
- package/.yalc/@node-dlc/core/dist/ChannelId.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/LinkedList.d.ts +0 -30
- package/.yalc/@node-dlc/core/dist/LinkedList.js +0 -104
- package/.yalc/@node-dlc/core/dist/LinkedList.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/LinkedListNode.d.ts +0 -9
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js +0 -15
- package/.yalc/@node-dlc/core/dist/LinkedListNode.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/Queue.d.ts +0 -22
- package/.yalc/@node-dlc/core/dist/Queue.js +0 -38
- package/.yalc/@node-dlc/core/dist/Queue.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelId.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js +0 -7
- package/.yalc/@node-dlc/core/dist/ShortChannelId.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.d.ts +0 -1
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js +0 -12
- package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.d.ts +0 -50
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js +0 -332
- package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.d.ts +0 -23
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js +0 -77
- package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.d.ts +0 -20
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js +0 -117
- package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.d.ts +0 -5
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js +0 -3
- package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.d.ts +0 -52
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js +0 -173
- package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.d.ts +0 -55
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js +0 -217
- package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.d.ts +0 -40
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js +0 -146
- package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.d.ts +0 -193
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js +0 -422
- package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js +0 -67
- package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.d.ts +0 -114
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js +0 -290
- package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.d.ts +0 -6
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js +0 -79
- package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js +0 -47
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js +0 -47
- package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.d.ts +0 -20
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js +0 -101
- package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.d.ts +0 -12
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js +0 -46
- package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/index.d.ts +0 -39
- package/.yalc/@node-dlc/core/dist/index.js +0 -78
- package/.yalc/@node-dlc/core/dist/index.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.d.ts +0 -31
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js +0 -52
- package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.d.ts +0 -55
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js +0 -105
- package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.d.ts +0 -55
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js +0 -76
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.d.ts +0 -26
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js +0 -44
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.d.ts +0 -41
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js +0 -79
- package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.d.ts +0 -46
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js +0 -46
- package/.yalc/@node-dlc/core/dist/lightning/Htlc.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.d.ts +0 -16
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js +0 -21
- package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.d.ts +0 -76
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js +0 -102
- package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.d.ts +0 -83
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js +0 -222
- package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.d.ts +0 -9
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js +0 -59
- package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js.map +0 -1
- package/.yalc/@node-dlc/core/dist/utils/Precision.d.ts +0 -13
- package/.yalc/@node-dlc/core/dist/utils/Precision.js +0 -28
- package/.yalc/@node-dlc/core/dist/utils/Precision.js.map +0 -1
- package/.yalc/@node-dlc/core/lib/AsyncProcessingQueue.ts +0 -63
- package/.yalc/@node-dlc/core/lib/Base32.ts +0 -2
- package/.yalc/@node-dlc/core/lib/BigIntUtils.ts +0 -2
- package/.yalc/@node-dlc/core/lib/BitField.ts +0 -2
- package/.yalc/@node-dlc/core/lib/ChannelId.ts +0 -2
- package/.yalc/@node-dlc/core/lib/LinkedList.ts +0 -111
- package/.yalc/@node-dlc/core/lib/LinkedListNode.ts +0 -14
- package/.yalc/@node-dlc/core/lib/Queue.ts +0 -36
- package/.yalc/@node-dlc/core/lib/ShortChannelId.ts +0 -2
- package/.yalc/@node-dlc/core/lib/ShortChannelIdUtils.ts +0 -9
- package/.yalc/@node-dlc/core/lib/dlc/CETCalculator.ts +0 -450
- package/.yalc/@node-dlc/core/lib/dlc/CoinSelect.ts +0 -117
- package/.yalc/@node-dlc/core/lib/dlc/HyperbolaPayoutCurve.ts +0 -188
- package/.yalc/@node-dlc/core/lib/dlc/PayoutCurve.ts +0 -6
- package/.yalc/@node-dlc/core/lib/dlc/PolynomialPayoutCurve.ts +0 -266
- package/.yalc/@node-dlc/core/lib/dlc/TxBuilder.ts +0 -336
- package/.yalc/@node-dlc/core/lib/dlc/TxFinalizer.ts +0 -217
- package/.yalc/@node-dlc/core/lib/dlc/finance/Builder.ts +0 -730
- package/.yalc/@node-dlc/core/lib/dlc/finance/CoveredCall.ts +0 -110
- package/.yalc/@node-dlc/core/lib/dlc/finance/CsoInfo.ts +0 -498
- package/.yalc/@node-dlc/core/lib/dlc/finance/LinearPayout.ts +0 -94
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongCall.ts +0 -74
- package/.yalc/@node-dlc/core/lib/dlc/finance/LongPut.ts +0 -74
- package/.yalc/@node-dlc/core/lib/dlc/finance/OptionInfo.ts +0 -182
- package/.yalc/@node-dlc/core/lib/dlc/finance/ShortPut.ts +0 -75
- package/.yalc/@node-dlc/core/lib/index.ts +0 -66
- package/.yalc/@node-dlc/core/lib/lightning/ChannelId.ts +0 -54
- package/.yalc/@node-dlc/core/lib/lightning/ChannelKeys.ts +0 -109
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentNumber.ts +0 -94
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecret.ts +0 -41
- package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecretStore.ts +0 -84
- package/.yalc/@node-dlc/core/lib/lightning/Htlc.ts +0 -52
- package/.yalc/@node-dlc/core/lib/lightning/HtlcDirection.ts +0 -17
- package/.yalc/@node-dlc/core/lib/lightning/ScriptFactory.ts +0 -150
- package/.yalc/@node-dlc/core/lib/lightning/TxFactory.ts +0 -338
- package/.yalc/@node-dlc/core/lib/utils/BigIntUtils.ts +0 -64
- package/.yalc/@node-dlc/core/lib/utils/Precision.ts +0 -23
- package/.yalc/@node-dlc/core/package.json +0 -38
- package/.yalc/@node-dlc/core/tsconfig.json +0 -8
- package/.yalc/@node-dlc/core/yalc.sig +0 -1
- package/yalc.lock +0 -10
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateCsoPayoutFunction = exports.getCsoInfoFromOffer = exports.getCsoInfoFromContractInfo = exports.getCsoInfoParamsFromContractInfoV1 = exports.getCsoInfoParamsFromContractInfoV0 = void 0;
|
|
7
|
-
const bitcoin_1 = require("@node-dlc/bitcoin");
|
|
8
|
-
const messaging_1 = require("@node-dlc/messaging");
|
|
9
|
-
const assert_1 = __importDefault(require("assert"));
|
|
10
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
11
|
-
const Builder_1 = require("./Builder");
|
|
12
|
-
const ONE_BTC_CONTRACT = bitcoin_1.Value.fromBitcoin(1);
|
|
13
|
-
/**
|
|
14
|
-
* getCsoInfoParamsFromContractInfo V0
|
|
15
|
-
*
|
|
16
|
-
* Old getCsoInfoParamsFromContractInfo implementation
|
|
17
|
-
*
|
|
18
|
-
* @param {Value} contractSize - The size of the contract in terms of value.
|
|
19
|
-
* @param {Value} collateral - The collateral value put up for the contract.
|
|
20
|
-
* @param {DlcParty} shiftForFees - Specifies which party ('offeror' or 'acceptor') will bear the fees, affecting the outcome values.
|
|
21
|
-
* @param {Value} fees - The fees associated with the contract.
|
|
22
|
-
* @param {string} unit - The unit of measurement for the contract outcomes (e.g., 'BTC').
|
|
23
|
-
* @param {Value} startOutcomeValue - The starting outcome value for the contract.
|
|
24
|
-
* @param {Value} endOutcomeValue - The ending outcome value for the contract.
|
|
25
|
-
* @returns {CsoInfoParams} An object containing the calculated CSO parameters:
|
|
26
|
-
* - normalizedMaxGain: Maximum gain relative to a 1 BTC contract.
|
|
27
|
-
* - normalizedMaxLoss: Maximum loss relative to a 1 BTC contract.
|
|
28
|
-
* - maxGainForContractSize: Maximum gain for the actual contract size.
|
|
29
|
-
* - maxLossForContractSize: Maximum loss for the actual contract size.
|
|
30
|
-
* - offerCollateral: The offer collateral value after adjustments.
|
|
31
|
-
*
|
|
32
|
-
* Note: This function calculates the adjusted fees incorrectly, using collateral instead of contract size. Use v1 where possible.
|
|
33
|
-
*/
|
|
34
|
-
const getCsoInfoParamsFromContractInfoV0 = (contractSize, collateral, shiftForFees, fees, unit, startOutcomeValue, endOutcomeValue) => {
|
|
35
|
-
const leverageMultiplier = parseFloat(new decimal_js_1.default(contractSize.bitcoin).dividedBy(collateral.bitcoin).toFixed(1));
|
|
36
|
-
const defaultContractSize = bitcoin_1.Value.fromBitcoin(1);
|
|
37
|
-
const shiftValue = collateral.sats > 0
|
|
38
|
-
? bitcoin_1.Value.fromSats((0, Builder_1.roundToNearestMultiplier)((fees.sats * defaultContractSize.sats) / collateral.sats, // WARNING: this should be contract size not collateral
|
|
39
|
-
Builder_1.UNIT_MULTIPLIER[unit.toLowerCase()]))
|
|
40
|
-
: bitcoin_1.Value.zero();
|
|
41
|
-
if (shiftForFees === 'offeror') {
|
|
42
|
-
startOutcomeValue.sub(shiftValue);
|
|
43
|
-
endOutcomeValue.sub(shiftValue);
|
|
44
|
-
}
|
|
45
|
-
else if (shiftForFees === 'acceptor') {
|
|
46
|
-
startOutcomeValue.add(shiftValue);
|
|
47
|
-
endOutcomeValue.add(shiftValue);
|
|
48
|
-
}
|
|
49
|
-
const normalizedMaxGain = endOutcomeValue.clone();
|
|
50
|
-
normalizedMaxGain.sub(ONE_BTC_CONTRACT);
|
|
51
|
-
const normalizedMaxLoss = ONE_BTC_CONTRACT.clone();
|
|
52
|
-
normalizedMaxLoss.sub(startOutcomeValue);
|
|
53
|
-
const maxGainForContractSize = bitcoin_1.Value.fromBitcoin(new decimal_js_1.default(normalizedMaxGain.bitcoin)
|
|
54
|
-
.times(leverageMultiplier)
|
|
55
|
-
.toDecimalPlaces(5)
|
|
56
|
-
.toNumber());
|
|
57
|
-
const maxLossForContractSize = bitcoin_1.Value.fromBitcoin(new decimal_js_1.default(normalizedMaxLoss.bitcoin)
|
|
58
|
-
.times(contractSize.bitcoin)
|
|
59
|
-
.toDecimalPlaces(8 - Math.log10(Number(Builder_1.UNIT_MULTIPLIER[unit.toLowerCase()])))
|
|
60
|
-
.toNumber());
|
|
61
|
-
const offerCollateral = collateral.clone();
|
|
62
|
-
offerCollateral.sub(bitcoin_1.Value.fromSats((maxGainForContractSize.sats * collateral.sats) / BigInt(1e8)));
|
|
63
|
-
return {
|
|
64
|
-
normalizedMaxGain,
|
|
65
|
-
normalizedMaxLoss,
|
|
66
|
-
maxGainForContractSize,
|
|
67
|
-
maxLossForContractSize,
|
|
68
|
-
offerCollateral,
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
exports.getCsoInfoParamsFromContractInfoV0 = getCsoInfoParamsFromContractInfoV0;
|
|
72
|
-
/**
|
|
73
|
-
* getCsoInfoParamsFromContractInfo V1
|
|
74
|
-
*
|
|
75
|
-
* Fixed getCsoInfoParamsFromContractInfo implementation
|
|
76
|
-
*
|
|
77
|
-
* @param {Value} contractSize - The size of the contract in terms of value.
|
|
78
|
-
* @param {Value} collateral - The collateral value put up for the contract.
|
|
79
|
-
* @param {DlcParty} shiftForFees - Specifies which party ('offeror' or 'acceptor') will bear the fees, affecting the outcome values.
|
|
80
|
-
* @param {Value} fees - The fees associated with the contract.
|
|
81
|
-
* @param {string} unit - The unit of measurement for the contract outcomes (e.g., 'BTC').
|
|
82
|
-
* @param {Value} startOutcomeValue - The starting outcome value for the contract.
|
|
83
|
-
* @param {Value} endOutcomeValue - The ending outcome value for the contract.
|
|
84
|
-
* @returns {CsoInfoParams} An object containing the calculated CSO parameters:
|
|
85
|
-
* - normalizedMaxGain: Maximum gain relative to a 1 BTC contract.
|
|
86
|
-
* - normalizedMaxLoss: Maximum loss relative to a 1 BTC contract.
|
|
87
|
-
* - maxGainForContractSize: Maximum gain for the actual contract size.
|
|
88
|
-
* - maxLossForContractSize: Maximum loss for the actual contract size.
|
|
89
|
-
* - offerCollateral: The offer collateral value after adjustments.
|
|
90
|
-
*
|
|
91
|
-
* This version improves upon the previous by correctly adjusting fees based on the contract size, leading to more accurate
|
|
92
|
-
* calculations of CSO parameters.
|
|
93
|
-
*/
|
|
94
|
-
const getCsoInfoParamsFromContractInfoV1 = (contractSize, collateral, shiftForFees, fees, unit, startOutcomeValue, endOutcomeValue) => {
|
|
95
|
-
const feesAdjusted = bitcoin_1.Value.fromSats((0, Builder_1.roundToNearestMultiplier)((fees.sats * BigInt(1e8)) / contractSize.sats, // NOTE: this is done correctly using contractSize
|
|
96
|
-
BigInt(Builder_1.UNIT_MULTIPLIER[unit.toLowerCase()])));
|
|
97
|
-
if (shiftForFees === 'offeror') {
|
|
98
|
-
startOutcomeValue.sub(feesAdjusted);
|
|
99
|
-
endOutcomeValue.sub(feesAdjusted);
|
|
100
|
-
}
|
|
101
|
-
else if (shiftForFees === 'acceptor') {
|
|
102
|
-
startOutcomeValue.add(feesAdjusted);
|
|
103
|
-
endOutcomeValue.add(feesAdjusted);
|
|
104
|
-
}
|
|
105
|
-
const normalizedMaxGain = endOutcomeValue.clone();
|
|
106
|
-
normalizedMaxGain.sub(ONE_BTC_CONTRACT);
|
|
107
|
-
const normalizedMaxLoss = ONE_BTC_CONTRACT.clone();
|
|
108
|
-
normalizedMaxLoss.sub(startOutcomeValue);
|
|
109
|
-
const maxGainForContractSize = bitcoin_1.Value.fromSats((0, Builder_1.roundUpToNearestMultiplier)((normalizedMaxGain.sats * contractSize.sats) / BigInt(1e8), BigInt(Builder_1.UNIT_MULTIPLIER[unit.toLowerCase()])));
|
|
110
|
-
const maxLossForContractSize = bitcoin_1.Value.fromSats((0, Builder_1.roundUpToNearestMultiplier)((normalizedMaxLoss.sats * contractSize.sats) / BigInt(1e8), BigInt(Builder_1.UNIT_MULTIPLIER[unit.toLowerCase()])));
|
|
111
|
-
const offerCollateral = collateral.clone();
|
|
112
|
-
offerCollateral.sub(maxGainForContractSize);
|
|
113
|
-
return {
|
|
114
|
-
normalizedMaxGain,
|
|
115
|
-
normalizedMaxLoss,
|
|
116
|
-
maxGainForContractSize,
|
|
117
|
-
maxLossForContractSize,
|
|
118
|
-
offerCollateral,
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
exports.getCsoInfoParamsFromContractInfoV1 = getCsoInfoParamsFromContractInfoV1;
|
|
122
|
-
/**
|
|
123
|
-
* Decode CsoInfo from a ContractInfo object. Essentially the opposite of buildCustomStrategyOrderOffer
|
|
124
|
-
*
|
|
125
|
-
* @param {_contractInfo} ContractInfo - Contract Info object, containing oracle and descriptor info
|
|
126
|
-
* @param {DlcParty} shiftForFees - Specifies which party ('offeror', 'acceptor', or 'neither') will pay for network fees
|
|
127
|
-
* @param {Value} fees - Network fees associated with the contract. Defaults to 0 sats.
|
|
128
|
-
* @param {_contractSize} Value - Optional. If not provided, it defaults to the total collateral.
|
|
129
|
-
* @param {csoVersion} 'v0' | 'v1' - Specifies the version of the CSO parameter calculation to use. Defaults to 'v1'.
|
|
130
|
-
* @returns {CsoInfo} An object containing the calculated CSO information:
|
|
131
|
-
* - normalizedMaxGain: Maximum gain relative to a 1 BTC contract.
|
|
132
|
-
* - normalizedMaxLoss: Maximum loss relative to a 1 BTC contract.
|
|
133
|
-
* - maxGainForContractSize: Maximum gain for the actual contract size.
|
|
134
|
-
* - maxLossForContractSize: Maximum loss for the actual contract size.
|
|
135
|
-
* - minPayout: Minimum payout as determined by the contract's payout function.
|
|
136
|
-
* - maxPayout: Maximum payout as determined by the contract's payout function.
|
|
137
|
-
* - contractSize: The size of the contract in terms of value.
|
|
138
|
-
* - offerCollateral: The offer collateral value after adjustments.
|
|
139
|
-
* - totalCollateral: The total collateral put up for the contract.
|
|
140
|
-
* - expiry: The expiry date of the contract based on the oracle's event maturity epoch.
|
|
141
|
-
*
|
|
142
|
-
* Note: This function performs several validations to ensure that the contract information and its components are of the
|
|
143
|
-
* expected types and formats.
|
|
144
|
-
* It throws errors if unsupported types or formats are encountered.
|
|
145
|
-
*/
|
|
146
|
-
const getCsoInfoFromContractInfo = (_contractInfo, shiftForFees = 'neither', fees = bitcoin_1.Value.fromSats(0), _contractSize, csoVersion = 'v1') => {
|
|
147
|
-
if (_contractInfo.contractInfoType !== messaging_1.ContractInfoType.Single)
|
|
148
|
-
throw Error('Only ContractInfoV0 currently supported');
|
|
149
|
-
const contractInfo = _contractInfo;
|
|
150
|
-
if (contractInfo.contractDescriptor.contractDescriptorType !==
|
|
151
|
-
messaging_1.ContractDescriptorType.NumericOutcome)
|
|
152
|
-
throw Error('Only Numeric Descriptor currently supported');
|
|
153
|
-
const oracleInfo = contractInfo.oracleInfo;
|
|
154
|
-
// Handle both SingleOracleInfo and MultiOracleInfo
|
|
155
|
-
let eventMaturityEpoch;
|
|
156
|
-
let eventDescriptor;
|
|
157
|
-
switch (oracleInfo.type) {
|
|
158
|
-
case messaging_1.MessageType.SingleOracleInfo: {
|
|
159
|
-
const singleOracleInfo = oracleInfo;
|
|
160
|
-
eventMaturityEpoch =
|
|
161
|
-
singleOracleInfo.announcement.oracleEvent.eventMaturityEpoch;
|
|
162
|
-
eventDescriptor = singleOracleInfo.announcement.oracleEvent
|
|
163
|
-
.eventDescriptor;
|
|
164
|
-
if (singleOracleInfo.announcement.oracleEvent.eventDescriptor.type !==
|
|
165
|
-
messaging_1.MessageType.DigitDecompositionEventDescriptor)
|
|
166
|
-
throw Error('Only DigitDecompositionEventDescriptor currently supported');
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
case messaging_1.MessageType.MultiOracleInfo: {
|
|
170
|
-
const multiOracleInfo = oracleInfo;
|
|
171
|
-
eventMaturityEpoch =
|
|
172
|
-
multiOracleInfo.announcements[0].oracleEvent.eventMaturityEpoch;
|
|
173
|
-
eventDescriptor = multiOracleInfo.announcements[0].oracleEvent
|
|
174
|
-
.eventDescriptor;
|
|
175
|
-
if (multiOracleInfo.announcements[0].oracleEvent.eventDescriptor.type !==
|
|
176
|
-
messaging_1.MessageType.DigitDecompositionEventDescriptor)
|
|
177
|
-
throw Error('Only DigitDecompositionEventDescriptor currently supported');
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
default:
|
|
181
|
-
throw Error('Unknown oracle info type');
|
|
182
|
-
}
|
|
183
|
-
const contractDescriptor = contractInfo.contractDescriptor;
|
|
184
|
-
if (contractDescriptor.payoutFunction.type !== messaging_1.MessageType.PayoutFunction)
|
|
185
|
-
throw Error('Only PayoutFunction currently supported');
|
|
186
|
-
const payoutFunction = contractDescriptor.payoutFunction;
|
|
187
|
-
(0, exports.validateCsoPayoutFunction)(payoutFunction);
|
|
188
|
-
const initialPiece = payoutFunction.payoutFunctionPieces[0];
|
|
189
|
-
const midPiece = payoutFunction.payoutFunctionPieces[1];
|
|
190
|
-
const minPayout = initialPiece.endPoint.outcomePayout;
|
|
191
|
-
const maxPayout = midPiece.endPoint.outcomePayout;
|
|
192
|
-
const startOutcome = initialPiece.endPoint.eventOutcome;
|
|
193
|
-
const endOutcome = midPiece.endPoint.eventOutcome;
|
|
194
|
-
const unit = eventDescriptor.unit;
|
|
195
|
-
const collateral = bitcoin_1.Value.fromSats(contractInfo.totalCollateral);
|
|
196
|
-
const contractSize = _contractSize && _contractSize.sats > 0 ? _contractSize : collateral;
|
|
197
|
-
const startOutcomeValue = bitcoin_1.Value.fromSats(startOutcome * Builder_1.UNIT_MULTIPLIER[unit.toLowerCase()]);
|
|
198
|
-
const endOutcomeValue = bitcoin_1.Value.fromSats(endOutcome * Builder_1.UNIT_MULTIPLIER[unit.toLowerCase()]);
|
|
199
|
-
const getCsoInfoParamsFromContractInfo = csoVersion === 'v0'
|
|
200
|
-
? exports.getCsoInfoParamsFromContractInfoV0
|
|
201
|
-
: exports.getCsoInfoParamsFromContractInfoV1;
|
|
202
|
-
const { normalizedMaxGain, normalizedMaxLoss, maxGainForContractSize, maxLossForContractSize, offerCollateral, } = getCsoInfoParamsFromContractInfo(contractSize, collateral, shiftForFees, fees, unit, startOutcomeValue, endOutcomeValue);
|
|
203
|
-
const expiry = new Date(eventMaturityEpoch * 1000);
|
|
204
|
-
return {
|
|
205
|
-
normalizedMaxGain,
|
|
206
|
-
normalizedMaxLoss,
|
|
207
|
-
maxGainForContractSize,
|
|
208
|
-
maxLossForContractSize,
|
|
209
|
-
minPayout,
|
|
210
|
-
maxPayout,
|
|
211
|
-
contractSize,
|
|
212
|
-
offerCollateral,
|
|
213
|
-
totalCollateral: collateral,
|
|
214
|
-
expiry,
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
exports.getCsoInfoFromContractInfo = getCsoInfoFromContractInfo;
|
|
218
|
-
/**
|
|
219
|
-
* Get CsoInfo from OrderOffer or DlcOffer and validate
|
|
220
|
-
*
|
|
221
|
-
* @param {HasContractInfo & HasType} offer
|
|
222
|
-
* @returns {CsoInfo}
|
|
223
|
-
*/
|
|
224
|
-
const getCsoInfoFromOffer = (offer, csoVersion = 'v1') => {
|
|
225
|
-
if (offer.type !== messaging_1.MessageType.DlcOffer &&
|
|
226
|
-
offer.type !== messaging_1.MessageType.OrderOffer)
|
|
227
|
-
throw Error('Only DlcOffer and OrderOffer currently supported');
|
|
228
|
-
let shiftForFees = 'neither';
|
|
229
|
-
const fees = bitcoin_1.Value.zero();
|
|
230
|
-
const contractSize = bitcoin_1.Value.zero();
|
|
231
|
-
if (offer.positionInfo) {
|
|
232
|
-
shiftForFees = offer.positionInfo.shiftForFees;
|
|
233
|
-
fees.add(bitcoin_1.Value.fromSats(offer.positionInfo.fees));
|
|
234
|
-
contractSize.add(bitcoin_1.Value.fromSats(offer.positionInfo.contractSize));
|
|
235
|
-
}
|
|
236
|
-
const positionInfo = (0, exports.getCsoInfoFromContractInfo)(offer.contractInfo, shiftForFees, fees, contractSize, csoVersion);
|
|
237
|
-
if (positionInfo.offerCollateral.sats !== offer.offerCollateral)
|
|
238
|
-
throw Error('Offer was not generated with CSO ContractInfo');
|
|
239
|
-
return positionInfo;
|
|
240
|
-
};
|
|
241
|
-
exports.getCsoInfoFromOffer = getCsoInfoFromOffer;
|
|
242
|
-
/**
|
|
243
|
-
* Validate Payout Function for proper CSO format
|
|
244
|
-
*
|
|
245
|
-
* It should have 3 PayoutCurvePieces which consist of a flat line (maxLoss),
|
|
246
|
-
* ascending line (maxLoss to maxGain) and finally another flat line (maxGain)
|
|
247
|
-
*
|
|
248
|
-
* All PayoutCurvePieces should be type PolynomialPayoutCurvePieces
|
|
249
|
-
*
|
|
250
|
-
* @param {PayoutFunction} payoutFunction
|
|
251
|
-
*/
|
|
252
|
-
const validateCsoPayoutFunction = (payoutFunction) => {
|
|
253
|
-
(0, assert_1.default)(payoutFunction.payoutFunctionPieces.length === 3, 'CSO Payout Function must have 3 PayoutFunctionPieces');
|
|
254
|
-
for (const [i, piece] of payoutFunction.payoutFunctionPieces.entries()) {
|
|
255
|
-
(0, assert_1.default)(piece.payoutCurvePiece.payoutCurvePieceType ===
|
|
256
|
-
messaging_1.PayoutCurvePieceType.Polynomial ||
|
|
257
|
-
piece.payoutCurvePiece.type === messaging_1.MessageType.PolynomialPayoutCurvePiece, 'CSO Payout Function PayoutCurvePieces must be PolynomialCurvePieces');
|
|
258
|
-
const payoutCurvePiece = piece.payoutCurvePiece;
|
|
259
|
-
const points = payoutCurvePiece.points;
|
|
260
|
-
// eventOutcome should always be ascending
|
|
261
|
-
(0, assert_1.default)(points[0].eventOutcome < points[1].eventOutcome, 'CSO Payout Function PayoutCurvePiece point payout should be an ascending line');
|
|
262
|
-
// endpoints should always be ascending
|
|
263
|
-
let previousPiece, previousPoints;
|
|
264
|
-
if (i > 0) {
|
|
265
|
-
previousPiece = payoutFunction.payoutFunctionPieces[i - 1];
|
|
266
|
-
previousPoints = previousPiece.payoutCurvePiece.points;
|
|
267
|
-
(0, assert_1.default)(previousPiece.endPoint.eventOutcome < piece.endPoint.eventOutcome, 'CSO Payout Function point endpoints should be an ascending line');
|
|
268
|
-
(0, assert_1.default)(previousPoints[1].outcomePayout === points[0].outcomePayout, 'CSO Payout Function point outcome payout should be continuous without gaps');
|
|
269
|
-
}
|
|
270
|
-
switch (i) {
|
|
271
|
-
case 0:
|
|
272
|
-
// First piece - should start from initial endpoint
|
|
273
|
-
// maxLoss should be a flat line
|
|
274
|
-
(0, assert_1.default)(points[0].outcomePayout === points[1].outcomePayout, 'CSO Payout Function maxLoss PayoutCurvePiece point should be a flat line');
|
|
275
|
-
break;
|
|
276
|
-
case 1:
|
|
277
|
-
// maxLoss to maxGain should be an ascending line
|
|
278
|
-
(0, assert_1.default)(previousPiece.endPoint.outcomePayout < piece.endPoint.outcomePayout);
|
|
279
|
-
(0, assert_1.default)(points[0].outcomePayout < points[1].outcomePayout, 'CSO Payout Function maxLoss to maxGain PayoutCurvePiece point should be an ascending line');
|
|
280
|
-
break;
|
|
281
|
-
case 2:
|
|
282
|
-
// maxGain should be a flat line
|
|
283
|
-
(0, assert_1.default)(previousPiece.endPoint.outcomePayout === piece.endPoint.outcomePayout);
|
|
284
|
-
(0, assert_1.default)(points[0].outcomePayout === points[1].outcomePayout, 'CSO Payout Function maxGain PayoutCurvePiece point should be a flat line');
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
exports.validateCsoPayoutFunction = validateCsoPayoutFunction;
|
|
290
|
-
//# sourceMappingURL=CsoInfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CsoInfo.js","sourceRoot":"","sources":["../../../lib/dlc/finance/CsoInfo.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA0C;AAC1C,mDAc6B;AAC7B,oDAA4B;AAC5B,4DAAiC;AAEjC,uCAKmB;AAwBnB,MAAM,gBAAgB,GAAG,eAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAM9C;;;;;;;;;;;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3E,CAAC;gBACF,MAAM;SACT;KACF;AACH,CAAC,CAAC;AAtEW,QAAA,yBAAyB,6BAsEpC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PayoutFunction } from '@node-dlc/messaging';
|
|
2
|
-
export declare const LinearPayout: {
|
|
3
|
-
buildPayoutFunction: (minPayout: bigint, maxPayout: bigint, startOutcome: bigint, endOutcome: bigint, oracleBase: number, oracleDigits: number) => {
|
|
4
|
-
payoutFunction: PayoutFunction;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LinearPayout = void 0;
|
|
7
|
-
const messaging_1 = require("@node-dlc/messaging");
|
|
8
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
-
const PolynomialPayoutCurve_1 = require("../PolynomialPayoutCurve");
|
|
10
|
-
const buildPayoutFunction = (minPayout, maxPayout, startOutcome, endOutcome, oracleBase, oracleDigits) => {
|
|
11
|
-
// Max outcome limited by the oracle
|
|
12
|
-
const maxOutcome = BigInt(new bignumber_js_1.default(oracleBase).pow(oracleDigits).minus(1).toString(10));
|
|
13
|
-
// max loss line
|
|
14
|
-
const payoutCurveMaxLoss = new PolynomialPayoutCurve_1.PolynomialPayoutCurve([
|
|
15
|
-
{ outcome: new bignumber_js_1.default(0), payout: new bignumber_js_1.default(Number(minPayout)) },
|
|
16
|
-
{
|
|
17
|
-
outcome: new bignumber_js_1.default(Number(startOutcome)),
|
|
18
|
-
payout: new bignumber_js_1.default(Number(minPayout)),
|
|
19
|
-
},
|
|
20
|
-
]);
|
|
21
|
-
// payout line
|
|
22
|
-
const payoutCurve = new PolynomialPayoutCurve_1.PolynomialPayoutCurve([
|
|
23
|
-
{
|
|
24
|
-
outcome: new bignumber_js_1.default(Number(startOutcome)),
|
|
25
|
-
payout: new bignumber_js_1.default(Number(minPayout)),
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
outcome: new bignumber_js_1.default(Number(endOutcome)),
|
|
29
|
-
payout: new bignumber_js_1.default(Number(maxPayout)),
|
|
30
|
-
},
|
|
31
|
-
]);
|
|
32
|
-
// max gain line
|
|
33
|
-
const payoutCurveMaxGain = new PolynomialPayoutCurve_1.PolynomialPayoutCurve([
|
|
34
|
-
{ outcome: new bignumber_js_1.default(Number(endOutcome)), payout: new bignumber_js_1.default(Number(maxPayout)) },
|
|
35
|
-
{
|
|
36
|
-
outcome: new bignumber_js_1.default(Number(maxOutcome)),
|
|
37
|
-
payout: new bignumber_js_1.default(Number(maxPayout)),
|
|
38
|
-
},
|
|
39
|
-
]);
|
|
40
|
-
const payoutFunction = new messaging_1.PayoutFunction();
|
|
41
|
-
// Defensive fix: ensure payoutFunctionPieces is initialized as an array
|
|
42
|
-
if (!payoutFunction.payoutFunctionPieces) {
|
|
43
|
-
payoutFunction.payoutFunctionPieces = [];
|
|
44
|
-
}
|
|
45
|
-
payoutFunction.payoutFunctionPieces.push({
|
|
46
|
-
endPoint: {
|
|
47
|
-
eventOutcome: startOutcome,
|
|
48
|
-
outcomePayout: minPayout,
|
|
49
|
-
extraPrecision: 0,
|
|
50
|
-
},
|
|
51
|
-
payoutCurvePiece: payoutCurveMaxLoss.toPayoutCurvePiece(),
|
|
52
|
-
});
|
|
53
|
-
payoutFunction.payoutFunctionPieces.push({
|
|
54
|
-
endPoint: {
|
|
55
|
-
eventOutcome: endOutcome,
|
|
56
|
-
outcomePayout: maxPayout,
|
|
57
|
-
extraPrecision: 0,
|
|
58
|
-
},
|
|
59
|
-
payoutCurvePiece: payoutCurve.toPayoutCurvePiece(),
|
|
60
|
-
});
|
|
61
|
-
payoutFunction.payoutFunctionPieces.push({
|
|
62
|
-
endPoint: {
|
|
63
|
-
eventOutcome: maxOutcome,
|
|
64
|
-
outcomePayout: maxPayout,
|
|
65
|
-
extraPrecision: 0,
|
|
66
|
-
},
|
|
67
|
-
payoutCurvePiece: payoutCurveMaxGain.toPayoutCurvePiece(),
|
|
68
|
-
});
|
|
69
|
-
payoutFunction.lastEndpoint = {
|
|
70
|
-
eventOutcome: maxOutcome,
|
|
71
|
-
outcomePayout: maxPayout,
|
|
72
|
-
extraPrecision: 0,
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
payoutFunction,
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
exports.LinearPayout = { buildPayoutFunction };
|
|
79
|
-
//# sourceMappingURL=LinearPayout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LinearPayout.js","sourceRoot":"","sources":["../../../lib/dlc/finance/LinearPayout.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAqD;AACrD,gEAA8B;AAE9B,oEAAiE;AAEjE,MAAM,mBAAmB,GAAG,CAC1B,SAAiB,EACjB,SAAiB,EACjB,YAAoB,EACpB,UAAkB,EAClB,UAAkB,EAClB,YAAoB,EACgB,EAAE;IACtC,oCAAoC;IACpC,MAAM,UAAU,GAAG,MAAM,CACvB,IAAI,sBAAE,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAC3D,CAAC;IAEF,gBAAgB;IAChB,MAAM,kBAAkB,GAAG,IAAI,6CAAqB,CAAC;QACnD,EAAE,OAAO,EAAE,IAAI,sBAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,sBAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;QACzD;YACE,OAAO,EAAE,IAAI,sBAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACrC,MAAM,EAAE,IAAI,sBAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SA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AS;YACxB,cAAc,EAAE,CAAC;SAClB;QACD,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,EAAE;KACnD,CAAC,CAAC;IAEH,cAAc,CAAC,oBAAoB,CAAC,IAAI,CAAC;QACvC,QAAQ,EAAE;YACR,YAAY,EAAE,UAAU;YACxB,aAAa,EAAE,SAAS;YACxB,cAAc,EAAE,CAAC;SAClB;QACD,gBAAgB,EAAE,kBAAkB,CAAC,kBAAkB,EAAE;KAC1D,CAAC,CAAC;IAEH,cAAc,CAAC,YAAY,GAAG;QAC5B,YAAY,EAAE,UAAU;QACxB,aAAa,EAAE,SAAS;QACxB,cAAc,EAAE,CAAC;KAClB,CAAC;IAEF,OAAO;QACL,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,YAAY,GAAG,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PayoutFunctionV0 } from '@node-dlc/messaging';
|
|
2
|
-
import { HyperbolaPayoutCurve } from '../HyperbolaPayoutCurve';
|
|
3
|
-
export declare const LongCall: {
|
|
4
|
-
buildCurve: (strikePrice: bigint, contractSize: bigint, oracleBase: number, oracleDigits: number) => {
|
|
5
|
-
maxOutcome: bigint;
|
|
6
|
-
totalCollateral: bigint;
|
|
7
|
-
payoutCurve: HyperbolaPayoutCurve;
|
|
8
|
-
};
|
|
9
|
-
buildPayoutFunction: (strikePrice: bigint, contractSize: bigint, totalCollateral: bigint, oracleBase: number, oracleDigits: number) => {
|
|
10
|
-
payoutFunction: PayoutFunctionV0;
|
|
11
|
-
totalCollateral: bigint;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LongCall = void 0;
|
|
7
|
-
const messaging_1 = require("@node-dlc/messaging");
|
|
8
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
-
const HyperbolaPayoutCurve_1 = require("../HyperbolaPayoutCurve");
|
|
10
|
-
const buildCurve = (strikePrice, contractSize, oracleBase, oracleDigits) => {
|
|
11
|
-
const a = new bignumber_js_1.default(-1);
|
|
12
|
-
const b = new bignumber_js_1.default(0);
|
|
13
|
-
const c = new bignumber_js_1.default(0);
|
|
14
|
-
const d = new bignumber_js_1.default((strikePrice * contractSize).toString());
|
|
15
|
-
const f_1 = new bignumber_js_1.default(0);
|
|
16
|
-
const f_2 = new bignumber_js_1.default(Number(contractSize));
|
|
17
|
-
const payoutCurve = new HyperbolaPayoutCurve_1.HyperbolaPayoutCurve(a, b, c, d, f_1, f_2);
|
|
18
|
-
const maxOutcome = BigInt(new bignumber_js_1.default(oracleBase).pow(oracleDigits).minus(1).toString(10));
|
|
19
|
-
return {
|
|
20
|
-
maxOutcome,
|
|
21
|
-
totalCollateral: contractSize,
|
|
22
|
-
payoutCurve,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const buildPayoutFunction = (strikePrice, contractSize, totalCollateral, oracleBase, oracleDigits) => {
|
|
26
|
-
const { maxOutcome, payoutCurve } = buildCurve(strikePrice, contractSize, oracleBase, oracleDigits);
|
|
27
|
-
const payoutFunction = new messaging_1.PayoutFunctionV0();
|
|
28
|
-
payoutFunction.payoutFunctionPieces.push({
|
|
29
|
-
endPoint: {
|
|
30
|
-
eventOutcome: maxOutcome,
|
|
31
|
-
outcomePayout: totalCollateral,
|
|
32
|
-
extraPrecision: 0,
|
|
33
|
-
},
|
|
34
|
-
payoutCurvePiece: payoutCurve.toPayoutCurvePiece(),
|
|
35
|
-
});
|
|
36
|
-
payoutFunction.lastEndpoint = {
|
|
37
|
-
eventOutcome: maxOutcome,
|
|
38
|
-
outcomePayout: totalCollateral,
|
|
39
|
-
extraPrecision: 0,
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
payoutFunction,
|
|
43
|
-
totalCollateral,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
exports.LongCall = { buildCurve, buildPayoutFunction };
|
|
47
|
-
//# sourceMappingURL=LongCall.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LongCall.js","sourceRoot":"","sources":["../../../lib/dlc/finance/LongCall.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAuD;AACvD,gEAA8B;AAE9B,kEAA+D;AAE/D,MAAM,UAAU,GAAG,CACjB,WAAmB,EACnB,YAAoB,EACpB,UAAkB,EAClB,YAAoB,EAKpB,EAAE;IACF,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE1D,MAAM,GAAG,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,GAAG,GAAG,IAAI,sBAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzC,MAAM,WAAW,GAAG,IAAI,2CAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAG,MAAM,CACvB,IAAI,sBAAE,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAC3D,CAAC;IAEF,OAAO;QACL,UAAU;QACV,eAAe,EAAE,YAAY;QAC7B,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAC1B,WAAmB,EACnB,YAAoB,EACpB,eAAuB,EACvB,UAAkB,EAClB,YAAoB,EAC2C,EAAE;IACjE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,UAAU,CAC5C,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,CACb,CAAC;IAEF,MAAM,cAAc,GAAG,IAAI,4BAAgB,EAAE,CAAC;IAE9C,cAAc,CAAC,oBAAoB,CAAC,IAAI,CAAC;QACvC,QAAQ,EAAE;YACR,YAAY,EAAE,UAAU;YACxB,aAAa,EAAE,eAAe;YAC9B,cAAc,EAAE,CAAC;SAClB;QACD,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,EAAE;KACnD,CAAC,CAAC;IAEH,cAAc,CAAC,YAAY,GAAG;QAC5B,YAAY,EAAE,UAAU;QACxB,aAAa,EAAE,eAAe;QAC9B,cAAc,EAAE,CAAC;KAClB,CAAC;IAEF,OAAO;QACL,cAAc;QACd,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,QAAQ,GAAG,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PayoutFunctionV0 } from '@node-dlc/messaging';
|
|
2
|
-
import { HyperbolaPayoutCurve } from '../HyperbolaPayoutCurve';
|
|
3
|
-
export declare const LongPut: {
|
|
4
|
-
buildCurve: (strikePrice: bigint, contractSize: bigint, oracleBase: number, oracleDigits: number) => {
|
|
5
|
-
maxOutcome: bigint;
|
|
6
|
-
totalCollateral: bigint;
|
|
7
|
-
payoutCurve: HyperbolaPayoutCurve;
|
|
8
|
-
};
|
|
9
|
-
buildPayoutFunction: (strikePrice: bigint, contractSize: bigint, totalCollateral: bigint, oracleBase: number, oracleDigits: number) => {
|
|
10
|
-
payoutFunction: PayoutFunctionV0;
|
|
11
|
-
totalCollateral: bigint;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LongPut = void 0;
|
|
7
|
-
const messaging_1 = require("@node-dlc/messaging");
|
|
8
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
-
const HyperbolaPayoutCurve_1 = require("../HyperbolaPayoutCurve");
|
|
10
|
-
const buildCurve = (strikePrice, contractSize, oracleBase, oracleDigits) => {
|
|
11
|
-
const a = new bignumber_js_1.default(1);
|
|
12
|
-
const b = new bignumber_js_1.default(0);
|
|
13
|
-
const c = new bignumber_js_1.default(0);
|
|
14
|
-
const d = new bignumber_js_1.default((strikePrice * contractSize).toString());
|
|
15
|
-
const f_1 = new bignumber_js_1.default(0);
|
|
16
|
-
const f_2 = new bignumber_js_1.default(-Number(contractSize));
|
|
17
|
-
const payoutCurve = new HyperbolaPayoutCurve_1.HyperbolaPayoutCurve(a, b, c, d, f_1, f_2);
|
|
18
|
-
const maxOutcome = BigInt(new bignumber_js_1.default(oracleBase).pow(oracleDigits).minus(1).toString(10));
|
|
19
|
-
return {
|
|
20
|
-
maxOutcome,
|
|
21
|
-
totalCollateral: contractSize,
|
|
22
|
-
payoutCurve,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const buildPayoutFunction = (strikePrice, contractSize, totalCollateral, oracleBase, oracleDigits) => {
|
|
26
|
-
const { maxOutcome, payoutCurve } = buildCurve(strikePrice, contractSize, oracleBase, oracleDigits);
|
|
27
|
-
const payoutFunction = new messaging_1.PayoutFunctionV0();
|
|
28
|
-
payoutFunction.payoutFunctionPieces.push({
|
|
29
|
-
endPoint: {
|
|
30
|
-
eventOutcome: maxOutcome,
|
|
31
|
-
outcomePayout: BigInt(0),
|
|
32
|
-
extraPrecision: 0,
|
|
33
|
-
},
|
|
34
|
-
payoutCurvePiece: payoutCurve.toPayoutCurvePiece(),
|
|
35
|
-
});
|
|
36
|
-
payoutFunction.lastEndpoint = {
|
|
37
|
-
eventOutcome: maxOutcome,
|
|
38
|
-
outcomePayout: BigInt(0),
|
|
39
|
-
extraPrecision: 0,
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
payoutFunction,
|
|
43
|
-
totalCollateral,
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
exports.LongPut = { buildCurve, buildPayoutFunction };
|
|
47
|
-
//# sourceMappingURL=LongPut.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LongPut.js","sourceRoot":"","sources":["../../../lib/dlc/finance/LongPut.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAuD;AACvD,gEAA8B;AAE9B,kEAA+D;AAE/D,MAAM,UAAU,GAAG,CACjB,WAAmB,EACnB,YAAoB,EACpB,UAAkB,EAClB,YAAoB,EAKpB,EAAE;IACF,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,IAAI,sBAAE,CAAC,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE1D,MAAM,GAAG,GAAG,IAAI,sBAAE,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,GAAG,GAAG,IAAI,sBAAE,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAE1C,MAAM,WAAW,GAAG,IAAI,2CAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAG,MAAM,CACvB,IAAI,sBAAE,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAC3D,CAAC;IAEF,OAAO;QACL,UAAU;QACV,eAAe,EAAE,YAAY;QAC7B,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAC1B,WAAmB,EACnB,YAAoB,EACpB,eAAuB,EACvB,UAAkB,EAClB,YAAoB,EAC2C,EAAE;IACjE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,UAAU,CAC5C,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,CACb,CAAC;IAEF,MAAM,cAAc,GAAG,IAAI,4BAAgB,EAAE,CAAC;IAE9C,cAAc,CAAC,oBAAoB,CAAC,IAAI,CAAC;QACvC,QAAQ,EAAE;YACR,YAAY,EAAE,UAAU;YACxB,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;YACxB,cAAc,EAAE,CAAC;SAClB;QACD,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,EAAE;KACnD,CAAC,CAAC;IAEH,cAAc,CAAC,YAAY,GAAG;QAC5B,YAAY,EAAE,UAAU;QACxB,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;QACxB,cAAc,EAAE,CAAC;KAClB,CAAC;IAEF,OAAO;QACL,cAAc;QACd,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ContractInfo, MessageType } from '@node-dlc/messaging';
|
|
2
|
-
export interface OptionInfo {
|
|
3
|
-
contractSize: bigint;
|
|
4
|
-
strikePrice: bigint;
|
|
5
|
-
premium?: bigint;
|
|
6
|
-
type?: OptionType;
|
|
7
|
-
expiry: Date;
|
|
8
|
-
}
|
|
9
|
-
export type HasOfferCollateral = {
|
|
10
|
-
offerCollateral: bigint;
|
|
11
|
-
};
|
|
12
|
-
export type HasContractInfo = {
|
|
13
|
-
contractInfo: ContractInfo;
|
|
14
|
-
};
|
|
15
|
-
export type HasType = {
|
|
16
|
-
type: MessageType;
|
|
17
|
-
};
|
|
18
|
-
export type OptionType = 'put' | 'call';
|
|
19
|
-
export declare function getOptionInfoFromContractInfo(_contractInfo: ContractInfo): OptionInfo;
|
|
20
|
-
export declare function getOptionInfoFromOffer(offer: HasOfferCollateral & HasContractInfo & HasType): OptionInfo;
|