@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.
Files changed (226) hide show
  1. package/.turbo/turbo-build.log +4 -5
  2. package/CHANGELOG.md +12 -0
  3. package/package.json +6 -6
  4. package/.turbo/turbo-lint$colon$fix.log +0 -4
  5. package/.turbo/turbo-lint.log +0 -5
  6. package/.turbo/turbo-test.log +0 -0
  7. package/.yalc/@node-dlc/core/.nyc_output/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
  8. package/.yalc/@node-dlc/core/.nyc_output/processinfo/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
  9. package/.yalc/@node-dlc/core/.nyc_output/processinfo/index.json +0 -1
  10. package/.yalc/@node-dlc/core/README.md +0 -11
  11. package/.yalc/@node-dlc/core/__tests__/core.spec.ts +0 -7
  12. package/.yalc/@node-dlc/core/__tests__/dlc/CETCalculator.spec.ts +0 -1029
  13. package/.yalc/@node-dlc/core/__tests__/dlc/CoinSelect.spec.ts +0 -179
  14. package/.yalc/@node-dlc/core/__tests__/dlc/PolynomialPayoutCurve.spec.ts +0 -345
  15. package/.yalc/@node-dlc/core/__tests__/dlc/TxBuilder.spec.ts +0 -424
  16. package/.yalc/@node-dlc/core/__tests__/dlc/finance/Builder.spec.ts +0 -492
  17. package/.yalc/@node-dlc/core/__tests__/dlc/finance/CoveredCall.spec.ts +0 -112
  18. package/.yalc/@node-dlc/core/__tests__/dlc/finance/CsoInfo.spec.ts +0 -1124
  19. package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongCall.spec.ts +0 -55
  20. package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongPut.spec.ts +0 -55
  21. package/.yalc/@node-dlc/core/__tests__/dlc/finance/OptionInfo.spec.ts +0 -226
  22. package/.yalc/@node-dlc/core/__tests__/dlc/finance/ShortPut.spec.ts +0 -62
  23. package/.yalc/@node-dlc/core/__tests__/tsconfig.json +0 -8
  24. package/.yalc/@node-dlc/core/__tests__/utils/precision.spec.ts +0 -40
  25. package/.yalc/@node-dlc/core/coverage/lcov-report/base.css +0 -224
  26. package/.yalc/@node-dlc/core/coverage/lcov-report/block-navigation.js +0 -79
  27. package/.yalc/@node-dlc/core/coverage/lcov-report/favicon.png +0 -0
  28. package/.yalc/@node-dlc/core/coverage/lcov-report/index.html +0 -171
  29. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/AsyncProcessingQueue.ts.html +0 -269
  30. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Base32.ts.html +0 -86
  31. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BigIntUtils.ts.html +0 -86
  32. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BitField.ts.html +0 -86
  33. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ChannelId.ts.html +0 -86
  34. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedList.ts.html +0 -413
  35. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedListNode.ts.html +0 -122
  36. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Queue.ts.html +0 -188
  37. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelId.ts.html +0 -86
  38. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelIdUtils.ts.html +0 -107
  39. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CETCalculator.ts.html +0 -1430
  40. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CoinSelect.ts.html +0 -431
  41. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/HyperbolaPayoutCurve.ts.html +0 -644
  42. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/PolynomialPayoutCurve.ts.html +0 -878
  43. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxBuilder.ts.html +0 -1088
  44. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxFinalizer.ts.html +0 -731
  45. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/Builder.ts.html +0 -2270
  46. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CoveredCall.ts.html +0 -410
  47. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CsoInfo.ts.html +0 -1574
  48. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LinearPayout.ts.html +0 -362
  49. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongCall.ts.html +0 -302
  50. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongPut.ts.html +0 -302
  51. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/OptionInfo.ts.html +0 -626
  52. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/ShortPut.ts.html +0 -305
  53. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/index.html +0 -216
  54. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/index.html +0 -186
  55. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.html +0 -261
  56. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.ts.html +0 -278
  57. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelId.ts.html +0 -242
  58. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelKeys.ts.html +0 -407
  59. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentNumber.ts.html +0 -362
  60. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecret.ts.html +0 -203
  61. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecretStore.ts.html +0 -332
  62. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/Htlc.ts.html +0 -236
  63. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/HtlcDirection.ts.html +0 -131
  64. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ScriptFactory.ts.html +0 -530
  65. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/TxFactory.ts.html +0 -1094
  66. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/index.html +0 -231
  67. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/BigIntUtils.ts.html +0 -272
  68. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/Precision.ts.html +0 -149
  69. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/index.html +0 -126
  70. package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.css +0 -1
  71. package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.js +0 -2
  72. package/.yalc/@node-dlc/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  73. package/.yalc/@node-dlc/core/coverage/lcov-report/sorter.js +0 -170
  74. package/.yalc/@node-dlc/core/coverage/lcov.info +0 -2426
  75. package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.d.ts +0 -22
  76. package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js +0 -55
  77. package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js.map +0 -1
  78. package/.yalc/@node-dlc/core/dist/Base32.d.ts +0 -1
  79. package/.yalc/@node-dlc/core/dist/Base32.js +0 -7
  80. package/.yalc/@node-dlc/core/dist/Base32.js.map +0 -1
  81. package/.yalc/@node-dlc/core/dist/BigIntUtils.d.ts +0 -1
  82. package/.yalc/@node-dlc/core/dist/BigIntUtils.js +0 -8
  83. package/.yalc/@node-dlc/core/dist/BigIntUtils.js.map +0 -1
  84. package/.yalc/@node-dlc/core/dist/BitField.d.ts +0 -1
  85. package/.yalc/@node-dlc/core/dist/BitField.js +0 -7
  86. package/.yalc/@node-dlc/core/dist/BitField.js.map +0 -1
  87. package/.yalc/@node-dlc/core/dist/ChannelId.d.ts +0 -1
  88. package/.yalc/@node-dlc/core/dist/ChannelId.js +0 -7
  89. package/.yalc/@node-dlc/core/dist/ChannelId.js.map +0 -1
  90. package/.yalc/@node-dlc/core/dist/LinkedList.d.ts +0 -30
  91. package/.yalc/@node-dlc/core/dist/LinkedList.js +0 -104
  92. package/.yalc/@node-dlc/core/dist/LinkedList.js.map +0 -1
  93. package/.yalc/@node-dlc/core/dist/LinkedListNode.d.ts +0 -9
  94. package/.yalc/@node-dlc/core/dist/LinkedListNode.js +0 -15
  95. package/.yalc/@node-dlc/core/dist/LinkedListNode.js.map +0 -1
  96. package/.yalc/@node-dlc/core/dist/Queue.d.ts +0 -22
  97. package/.yalc/@node-dlc/core/dist/Queue.js +0 -38
  98. package/.yalc/@node-dlc/core/dist/Queue.js.map +0 -1
  99. package/.yalc/@node-dlc/core/dist/ShortChannelId.d.ts +0 -1
  100. package/.yalc/@node-dlc/core/dist/ShortChannelId.js +0 -7
  101. package/.yalc/@node-dlc/core/dist/ShortChannelId.js.map +0 -1
  102. package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.d.ts +0 -1
  103. package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js +0 -12
  104. package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js.map +0 -1
  105. package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.d.ts +0 -50
  106. package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js +0 -332
  107. package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js.map +0 -1
  108. package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.d.ts +0 -23
  109. package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js +0 -77
  110. package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js.map +0 -1
  111. package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.d.ts +0 -20
  112. package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js +0 -117
  113. package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js.map +0 -1
  114. package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.d.ts +0 -5
  115. package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js +0 -3
  116. package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js.map +0 -1
  117. package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.d.ts +0 -52
  118. package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js +0 -173
  119. package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js.map +0 -1
  120. package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.d.ts +0 -55
  121. package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js +0 -217
  122. package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js.map +0 -1
  123. package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.d.ts +0 -40
  124. package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js +0 -146
  125. package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js.map +0 -1
  126. package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.d.ts +0 -193
  127. package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js +0 -422
  128. package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js.map +0 -1
  129. package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.d.ts +0 -13
  130. package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js +0 -67
  131. package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js.map +0 -1
  132. package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.d.ts +0 -114
  133. package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js +0 -290
  134. package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js.map +0 -1
  135. package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.d.ts +0 -6
  136. package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js +0 -79
  137. package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js.map +0 -1
  138. package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.d.ts +0 -13
  139. package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js +0 -47
  140. package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js.map +0 -1
  141. package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.d.ts +0 -13
  142. package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js +0 -47
  143. package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js.map +0 -1
  144. package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.d.ts +0 -20
  145. package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js +0 -101
  146. package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js.map +0 -1
  147. package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.d.ts +0 -12
  148. package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js +0 -46
  149. package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js.map +0 -1
  150. package/.yalc/@node-dlc/core/dist/index.d.ts +0 -39
  151. package/.yalc/@node-dlc/core/dist/index.js +0 -78
  152. package/.yalc/@node-dlc/core/dist/index.js.map +0 -1
  153. package/.yalc/@node-dlc/core/dist/lightning/ChannelId.d.ts +0 -31
  154. package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js +0 -52
  155. package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js.map +0 -1
  156. package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.d.ts +0 -55
  157. package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js +0 -105
  158. package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js.map +0 -1
  159. package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.d.ts +0 -55
  160. package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js +0 -76
  161. package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js.map +0 -1
  162. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.d.ts +0 -26
  163. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js +0 -44
  164. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js.map +0 -1
  165. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.d.ts +0 -41
  166. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js +0 -79
  167. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js.map +0 -1
  168. package/.yalc/@node-dlc/core/dist/lightning/Htlc.d.ts +0 -46
  169. package/.yalc/@node-dlc/core/dist/lightning/Htlc.js +0 -46
  170. package/.yalc/@node-dlc/core/dist/lightning/Htlc.js.map +0 -1
  171. package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.d.ts +0 -16
  172. package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js +0 -21
  173. package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js.map +0 -1
  174. package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.d.ts +0 -76
  175. package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js +0 -102
  176. package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js.map +0 -1
  177. package/.yalc/@node-dlc/core/dist/lightning/TxFactory.d.ts +0 -83
  178. package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js +0 -222
  179. package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js.map +0 -1
  180. package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.d.ts +0 -9
  181. package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js +0 -59
  182. package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js.map +0 -1
  183. package/.yalc/@node-dlc/core/dist/utils/Precision.d.ts +0 -13
  184. package/.yalc/@node-dlc/core/dist/utils/Precision.js +0 -28
  185. package/.yalc/@node-dlc/core/dist/utils/Precision.js.map +0 -1
  186. package/.yalc/@node-dlc/core/lib/AsyncProcessingQueue.ts +0 -63
  187. package/.yalc/@node-dlc/core/lib/Base32.ts +0 -2
  188. package/.yalc/@node-dlc/core/lib/BigIntUtils.ts +0 -2
  189. package/.yalc/@node-dlc/core/lib/BitField.ts +0 -2
  190. package/.yalc/@node-dlc/core/lib/ChannelId.ts +0 -2
  191. package/.yalc/@node-dlc/core/lib/LinkedList.ts +0 -111
  192. package/.yalc/@node-dlc/core/lib/LinkedListNode.ts +0 -14
  193. package/.yalc/@node-dlc/core/lib/Queue.ts +0 -36
  194. package/.yalc/@node-dlc/core/lib/ShortChannelId.ts +0 -2
  195. package/.yalc/@node-dlc/core/lib/ShortChannelIdUtils.ts +0 -9
  196. package/.yalc/@node-dlc/core/lib/dlc/CETCalculator.ts +0 -450
  197. package/.yalc/@node-dlc/core/lib/dlc/CoinSelect.ts +0 -117
  198. package/.yalc/@node-dlc/core/lib/dlc/HyperbolaPayoutCurve.ts +0 -188
  199. package/.yalc/@node-dlc/core/lib/dlc/PayoutCurve.ts +0 -6
  200. package/.yalc/@node-dlc/core/lib/dlc/PolynomialPayoutCurve.ts +0 -266
  201. package/.yalc/@node-dlc/core/lib/dlc/TxBuilder.ts +0 -336
  202. package/.yalc/@node-dlc/core/lib/dlc/TxFinalizer.ts +0 -217
  203. package/.yalc/@node-dlc/core/lib/dlc/finance/Builder.ts +0 -730
  204. package/.yalc/@node-dlc/core/lib/dlc/finance/CoveredCall.ts +0 -110
  205. package/.yalc/@node-dlc/core/lib/dlc/finance/CsoInfo.ts +0 -498
  206. package/.yalc/@node-dlc/core/lib/dlc/finance/LinearPayout.ts +0 -94
  207. package/.yalc/@node-dlc/core/lib/dlc/finance/LongCall.ts +0 -74
  208. package/.yalc/@node-dlc/core/lib/dlc/finance/LongPut.ts +0 -74
  209. package/.yalc/@node-dlc/core/lib/dlc/finance/OptionInfo.ts +0 -182
  210. package/.yalc/@node-dlc/core/lib/dlc/finance/ShortPut.ts +0 -75
  211. package/.yalc/@node-dlc/core/lib/index.ts +0 -66
  212. package/.yalc/@node-dlc/core/lib/lightning/ChannelId.ts +0 -54
  213. package/.yalc/@node-dlc/core/lib/lightning/ChannelKeys.ts +0 -109
  214. package/.yalc/@node-dlc/core/lib/lightning/CommitmentNumber.ts +0 -94
  215. package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecret.ts +0 -41
  216. package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecretStore.ts +0 -84
  217. package/.yalc/@node-dlc/core/lib/lightning/Htlc.ts +0 -52
  218. package/.yalc/@node-dlc/core/lib/lightning/HtlcDirection.ts +0 -17
  219. package/.yalc/@node-dlc/core/lib/lightning/ScriptFactory.ts +0 -150
  220. package/.yalc/@node-dlc/core/lib/lightning/TxFactory.ts +0 -338
  221. package/.yalc/@node-dlc/core/lib/utils/BigIntUtils.ts +0 -64
  222. package/.yalc/@node-dlc/core/lib/utils/Precision.ts +0 -23
  223. package/.yalc/@node-dlc/core/package.json +0 -38
  224. package/.yalc/@node-dlc/core/tsconfig.json +0 -8
  225. package/.yalc/@node-dlc/core/yalc.sig +0 -1
  226. package/yalc.lock +0 -10
@@ -1,730 +0,0 @@
1
- import { Value } from '@node-dlc/bitcoin';
2
- import {
3
- DigitDecompositionEventDescriptorV0,
4
- MessageType,
5
- NumericalDescriptor,
6
- OracleAnnouncement,
7
- OrderOffer,
8
- OrderPositionInfo,
9
- PayoutFunction,
10
- RoundingIntervals,
11
- SingleContractInfo,
12
- SingleOracleInfo,
13
- } from '@node-dlc/messaging';
14
- import {
15
- BitcoinNetwork,
16
- BitcoinNetworks,
17
- chainHashFromNetwork,
18
- } from 'bitcoin-networks';
19
- import Decimal from 'decimal.js';
20
-
21
- import { dustThreshold } from '../CoinSelect';
22
- import { getFinalizerByCount } from '../TxFinalizer';
23
- import { CoveredCall } from './CoveredCall';
24
- import { LinearPayout } from './LinearPayout';
25
- import { LongCall } from './LongCall';
26
- import { LongPut } from './LongPut';
27
- import { ShortPut } from './ShortPut';
28
-
29
- export const UNIT_MULTIPLIER = {
30
- bits: BigInt(1e2),
31
- sats: BigInt(1),
32
- };
33
-
34
- /**
35
- * Round a number to the nearest multiple of a given multiplier.
36
- *
37
- * @param num - The number to be rounded.
38
- * @param multiplier - The multiplier to round to.
39
- * @returns The number rounded to the nearest multiple of the multiplier.
40
- *
41
- * @example
42
- * ```typescript
43
- * // Example: rounding to nearest 100
44
- * const number = BigInt(354);
45
- * const multiplier = BigInt(100);
46
- * const roundedNumber = roundToNearestMultiplier(number, multiplier);
47
- * console.log(roundedNumber); // Output: 300
48
- * ```
49
- */
50
- export const roundToNearestMultiplier = (
51
- num: bigint,
52
- multiplier: bigint,
53
- ): bigint => (num / multiplier) * multiplier;
54
-
55
- /**
56
- * Round a number up to the nearest multiple of a given multiplier.
57
- *
58
- * @param num - The number to be rounded.
59
- * @param multiplier - The multiplier to round to.
60
- * @returns The number rounded up to the nearest multiple of the multiplier.
61
- *
62
- * @example
63
- * ```typescript
64
- * // Example: rounding up to nearest 100
65
- * const number = BigInt(354);
66
- * const multiplier = BigInt(100);
67
- * const roundedNumber = roundToNearestMultiplier(number, multiplier);
68
- * console.log(roundedNumber); // Output: 400
69
- * ```
70
- */
71
- export const roundUpToNearestMultiplier = (
72
- num: bigint,
73
- multiplier: bigint,
74
- ): bigint => ((num + multiplier - BigInt(1)) / multiplier) * multiplier;
75
-
76
- export const roundDownToNearestMultiplier = (
77
- num: bigint,
78
- multiplier: bigint,
79
- ): bigint => num - (num % multiplier);
80
-
81
- export type DlcParty = 'offeror' | 'acceptor' | 'neither';
82
-
83
- /**
84
- * Compute rounding intervals for a linear or hyperbola payout curve
85
- *
86
- * @param {number | bigint | Value} rounding rounding interval in sats
87
- * @param {number | bigint | Value} contractSize contract size in sats
88
- * @returns rounding mod for contract size
89
- */
90
- export const computeRoundingModulus = (
91
- rounding: number | bigint | Value,
92
- contractSize: number | bigint | Value,
93
- ): bigint => {
94
- const roundingInSats =
95
- rounding instanceof Value
96
- ? rounding.sats
97
- : typeof rounding === 'number'
98
- ? BigInt(Math.round(rounding * 1e8)) // Convert bitcoin amount to satoshis
99
- : rounding;
100
-
101
- const contractSizeInSats =
102
- contractSize instanceof Value
103
- ? contractSize.sats
104
- : typeof contractSize === 'number'
105
- ? BigInt(Math.round(contractSize * 1e8)) // Convert bitcoin amount to satoshis
106
- : contractSize;
107
-
108
- return (roundingInSats * contractSizeInSats) / BigInt(1e8);
109
- };
110
-
111
- /**
112
- * Get digit decomposition event descriptor from oracle announcement
113
- *
114
- * @param {OracleAnnouncement} announcement oracle announcement
115
- * @returns {DigitDecompositionEventDescriptorV0} event descriptor
116
- */
117
- export const getDigitDecompositionEventDescriptor = (
118
- announcement: OracleAnnouncement,
119
- ): DigitDecompositionEventDescriptorV0 => {
120
- if (
121
- announcement.oracleEvent.eventDescriptor.type !==
122
- MessageType.DigitDecompositionEventDescriptorV0
123
- )
124
- throw Error('Only DigitDecompositionEventDescriptorV0 currently supported');
125
-
126
- const eventDescriptor = announcement.oracleEvent
127
- .eventDescriptor as DigitDecompositionEventDescriptorV0;
128
-
129
- return eventDescriptor;
130
- };
131
-
132
- /**
133
- * Build an orderoffer for ContractDescriptorV1
134
- *
135
- * @param {OracleAnnouncement} announcement oracle announcement
136
- * @param {bigint} totalCollateral total collateral in satoshis
137
- * @param {bigint} offerCollateral offer collateral in satoshis
138
- * @param {PayoutFunction} payoutFunction
139
- * @param {RoundingIntervals} roundingIntervals
140
- * @param {bigint} feePerByte sats/vbyte
141
- * @param {NetworkName} network
142
- * @returns {OrderOffer} Returns order offer
143
- */
144
- export const buildOrderOffer = (
145
- announcement: OracleAnnouncement,
146
- totalCollateral: bigint,
147
- offerCollateral: bigint,
148
- payoutFunction: PayoutFunction,
149
- roundingIntervals: RoundingIntervals,
150
- feePerByte: bigint,
151
- network: string,
152
- ): OrderOffer => {
153
- const eventDescriptor = getDigitDecompositionEventDescriptor(announcement);
154
-
155
- const contractDescriptor = new NumericalDescriptor();
156
- contractDescriptor.numDigits = eventDescriptor.nbDigits;
157
- contractDescriptor.payoutFunction = payoutFunction;
158
- contractDescriptor.roundingIntervals = roundingIntervals;
159
-
160
- const oracleInfo = new SingleOracleInfo();
161
- oracleInfo.announcement = announcement;
162
-
163
- const contractInfo = new SingleContractInfo();
164
- contractInfo.totalCollateral = totalCollateral;
165
- contractInfo.contractDescriptor = contractDescriptor;
166
- contractInfo.oracleInfo = oracleInfo;
167
-
168
- const orderOffer = new OrderOffer();
169
-
170
- // Set required fields for OrderOffer
171
- orderOffer.contractFlags = Buffer.from('00', 'hex'); // Default contract flags
172
- // Generate a random 32-byte temporary contract ID
173
- orderOffer.temporaryContractId = Buffer.from(
174
- Array.from({ length: 32 }, () => Math.floor(Math.random() * 256)),
175
- );
176
- orderOffer.chainHash = chainHashFromNetwork(BitcoinNetworks[network]);
177
- orderOffer.contractInfo = contractInfo;
178
- orderOffer.offerCollateral = offerCollateral; // Use correct property name
179
- orderOffer.feeRatePerVb = feePerByte;
180
- orderOffer.cetLocktime = Math.floor(new Date().getTime() / 1000); // set to current time
181
- orderOffer.refundLocktime =
182
- announcement.oracleEvent.eventMaturityEpoch + 2419200; // 4 weeks after maturity
183
-
184
- return orderOffer;
185
- };
186
-
187
- /**
188
- * Builds an order offer for a covered call or short put
189
- *
190
- * @param {OracleAnnouncement} announcement oracle announcement
191
- * @param {number} contractSize contract size in satoshis
192
- * @param {number} strikePrice strike price of contract
193
- * @param {number} premium premium of contract in satoshis
194
- * @param {number | bigint} feePerByte sats/vbyte
195
- * @param {number} rounding rounding interval
196
- * @param {string} network bitcoin network type
197
- * @param {string} type call or put
198
- * @param {number} _totalCollateral total collateral in satoshis (applicable only for short put)
199
- * @returns {OrderOffer} Returns order offer
200
- */
201
- export const buildOptionOrderOffer = (
202
- announcement: OracleAnnouncement,
203
- contractSize: Value,
204
- strikePrice: number,
205
- premium: Value,
206
- feePerByte: number | bigint,
207
- rounding: number,
208
- network: string,
209
- type: 'call' | 'put',
210
- direction: 'long' | 'short',
211
- _totalCollateral?: Value,
212
- ): OrderOffer => {
213
- const eventDescriptor = getDigitDecompositionEventDescriptor(announcement);
214
-
215
- let totalCollateral: bigint;
216
- let payoutFunctionInfo: {
217
- payoutFunction: PayoutFunction;
218
- totalCollateral?: bigint;
219
- };
220
-
221
- const roundingIntervals = new RoundingIntervals();
222
- const roundingMod = computeRoundingModulus(rounding, contractSize);
223
-
224
- if (direction === 'short') {
225
- if (type === 'call') {
226
- payoutFunctionInfo = CoveredCall.buildPayoutFunction(
227
- BigInt(strikePrice),
228
- contractSize.sats,
229
- eventDescriptor.base,
230
- eventDescriptor.nbDigits,
231
- );
232
-
233
- totalCollateral = payoutFunctionInfo.totalCollateral;
234
- roundingIntervals.intervals = [
235
- {
236
- beginInterval: BigInt(0),
237
- roundingMod: BigInt(1),
238
- },
239
- {
240
- beginInterval: BigInt(strikePrice),
241
- roundingMod,
242
- },
243
- ];
244
- } else {
245
- payoutFunctionInfo = ShortPut.buildPayoutFunction(
246
- BigInt(strikePrice),
247
- contractSize.sats,
248
- _totalCollateral.sats,
249
- eventDescriptor.base,
250
- eventDescriptor.nbDigits,
251
- );
252
- totalCollateral = _totalCollateral.sats;
253
- roundingIntervals.intervals = [
254
- {
255
- beginInterval: BigInt(0),
256
- roundingMod,
257
- },
258
- {
259
- beginInterval: BigInt(strikePrice),
260
- roundingMod: BigInt(1),
261
- },
262
- ];
263
- }
264
- } else {
265
- totalCollateral = _totalCollateral.sats;
266
-
267
- if (type === 'call') {
268
- payoutFunctionInfo = LongCall.buildPayoutFunction(
269
- BigInt(strikePrice),
270
- contractSize.sats,
271
- totalCollateral,
272
- eventDescriptor.base,
273
- eventDescriptor.nbDigits,
274
- );
275
-
276
- roundingIntervals.intervals = [
277
- {
278
- beginInterval: BigInt(0),
279
- roundingMod: BigInt(1),
280
- },
281
- {
282
- beginInterval: BigInt(strikePrice),
283
- roundingMod,
284
- },
285
- ];
286
- } else {
287
- payoutFunctionInfo = LongPut.buildPayoutFunction(
288
- BigInt(strikePrice),
289
- contractSize.sats,
290
- totalCollateral,
291
- eventDescriptor.base,
292
- eventDescriptor.nbDigits,
293
- );
294
-
295
- roundingIntervals.intervals = [
296
- {
297
- beginInterval: BigInt(0),
298
- roundingMod,
299
- },
300
- {
301
- beginInterval: BigInt(strikePrice),
302
- roundingMod: BigInt(1),
303
- },
304
- ];
305
- }
306
- }
307
-
308
- const payoutFunction = payoutFunctionInfo.payoutFunction;
309
-
310
- const offerCollateral =
311
- direction === 'short' ? totalCollateral - premium.sats : premium.sats;
312
-
313
- return buildOrderOffer(
314
- announcement,
315
- totalCollateral,
316
- offerCollateral,
317
- payoutFunction,
318
- roundingIntervals,
319
- BigInt(feePerByte),
320
- network,
321
- );
322
- };
323
-
324
- /**
325
- * Builds an order offer for a covered call
326
- *
327
- * @param {OracleAnnouncement} announcement oracle announcement
328
- * @param {number} contractSize contract size in satoshis
329
- * @param {number} strikePrice strike price of contract
330
- * @param {number} premium premium of contract in satoshis
331
- * @param {number} feePerByte sats/vbyte
332
- * @param {number} rounding rounding interval
333
- * @param {string} network bitcoin network type
334
- * @returns {OrderOffer} Returns order offer
335
- */
336
- export const buildCoveredCallOrderOffer = (
337
- announcement: OracleAnnouncement,
338
- contractSize: Value,
339
- strikePrice: number,
340
- premium: Value,
341
- feePerByte: number,
342
- rounding: number,
343
- network: string,
344
- ): OrderOffer => {
345
- return buildOptionOrderOffer(
346
- announcement,
347
- contractSize,
348
- strikePrice,
349
- premium,
350
- feePerByte,
351
- rounding,
352
- network,
353
- 'call',
354
- 'short',
355
- );
356
- };
357
-
358
- /**
359
- * Builds an order offer for a short put
360
- *
361
- * @param {OracleAnnouncement} announcement oracle announcement
362
- * @param {number} contractSize contract size in satoshis
363
- * @param {number} strikePrice strike price of contract
364
- * @param {number} totalCollateral total collateral in satoshis
365
- * @param {number} premium premium of contract in satoshis
366
- * @param {number} feePerByte sats/vbyte
367
- * @param {number} rounding rounding interval
368
- * @param {string} network bitcoin network type
369
- * @returns {OrderOffer} Returns order offer
370
- */
371
- export const buildShortPutOrderOffer = (
372
- announcement: OracleAnnouncement,
373
- contractSize: Value,
374
- strikePrice: number,
375
- totalCollateral: Value,
376
- premium: Value,
377
- feePerByte: number,
378
- rounding: number,
379
- network: string,
380
- ): OrderOffer => {
381
- return buildOptionOrderOffer(
382
- announcement,
383
- contractSize,
384
- strikePrice,
385
- premium,
386
- feePerByte,
387
- rounding,
388
- network,
389
- 'put',
390
- 'short',
391
- totalCollateral,
392
- );
393
- };
394
-
395
- /**
396
- * Builds an order offer for a long call
397
- *
398
- * @param {OracleAnnouncement} announcement oracle announcement
399
- * @param {number} contractSize contract size in satoshis
400
- * @param {number} strikePrice strike price of contract
401
- * @param {number} maxGain maximum amount that can be gained (totalCollateral)
402
- * @param {number} premium premium of contract in satoshis
403
- * @param {number} feePerByte sats/vbyte
404
- * @param {number} rounding rounding interval
405
- * @param {string} network bitcoin network type
406
- * @returns {OrderOffer} Returns order offer
407
- */
408
- export const buildLongCallOrderOffer = (
409
- announcement: OracleAnnouncement,
410
- contractSize: Value,
411
- strikePrice: number,
412
- maxGain: Value,
413
- premium: Value,
414
- feePerByte: number,
415
- rounding: number,
416
- network: string,
417
- ): OrderOffer => {
418
- return buildOptionOrderOffer(
419
- announcement,
420
- contractSize,
421
- strikePrice,
422
- premium,
423
- feePerByte,
424
- rounding,
425
- network,
426
- 'call',
427
- 'long',
428
- maxGain,
429
- );
430
- };
431
-
432
- /**
433
- * Builds an order offer for a long put
434
- *
435
- * @param {OracleAnnouncement} announcement oracle announcement
436
- * @param {number} contractSize contract size in satoshis
437
- * @param {number} strikePrice strike price of contract
438
- * @param {number} maxGain maximum amount that can be gained (totalCollateral)
439
- * @param {number} premium premium of contract in satoshis
440
- * @param {number} feePerByte sats/vbyte
441
- * @param {number} rounding rounding interval
442
- * @param {string} network bitcoin network type
443
- * @returns {OrderOffer} Returns order offer
444
- */
445
- export const buildLongPutOrderOffer = (
446
- announcement: OracleAnnouncement,
447
- contractSize: Value,
448
- strikePrice: number,
449
- maxGain: Value,
450
- premium: Value,
451
- feePerByte: number,
452
- rounding: number,
453
- network: string,
454
- ): OrderOffer => {
455
- return buildOptionOrderOffer(
456
- announcement,
457
- contractSize,
458
- strikePrice,
459
- premium,
460
- feePerByte,
461
- rounding,
462
- network,
463
- 'put',
464
- 'long',
465
- maxGain,
466
- );
467
- };
468
-
469
- /**
470
- * Builds an order offer for a linear curve
471
- *
472
- * @param {OracleAnnouncement} announcement oracle announcement
473
- * @param {Value} offerCollateral offer collateral amount
474
- * @param {Value} minPayout minimum payout
475
- * @param {Value} maxPayout maximum payout (also total collateral)
476
- * @param {bigint} startOutcome oracle outcome (in bits or sats)
477
- * @param {bigint} endOutcome oracle outcome (in bits or sats)
478
- * @param {bigint} feePerByte sats/vbyte
479
- * @param {Value} rounding rounding mod for RoundingInterval
480
- * @param {BitcoinNetwork} network bitcoin, bitcoin_testnet or bitcoin_regtest
481
- * @param {DlcParty} [shiftForFees] shift for offerer, acceptor or neither (who should pay fees)
482
- * @param {Value} [fees] fees to shift
483
- * @returns {OrderOffer}
484
- */
485
- export const buildLinearOrderOffer = (
486
- announcement: OracleAnnouncement,
487
- offerCollateral: Value,
488
- minPayout: Value,
489
- maxPayout: Value,
490
- startOutcome: bigint,
491
- endOutcome: bigint,
492
- feePerByte: bigint,
493
- roundingIntervals: RoundingIntervals,
494
- network: BitcoinNetwork,
495
- shiftForFees: DlcParty = 'neither',
496
- fees: Value = Value.fromSats(0),
497
- ): OrderOffer => {
498
- if (maxPayout.lt(minPayout))
499
- throw Error('maxPayout must be greater than minPayout');
500
- if (endOutcome < startOutcome)
501
- throw Error('endOutcome must be greater than startOutcome');
502
-
503
- const eventDescriptor = getDigitDecompositionEventDescriptor(announcement);
504
-
505
- const totalCollateral = maxPayout.sats;
506
-
507
- const { payoutFunction } = LinearPayout.buildPayoutFunction(
508
- minPayout.sats,
509
- maxPayout.sats,
510
- startOutcome,
511
- endOutcome,
512
- eventDescriptor.base,
513
- eventDescriptor.nbDigits,
514
- );
515
-
516
- const orderOffer = buildOrderOffer(
517
- announcement,
518
- totalCollateral,
519
- offerCollateral.sats,
520
- payoutFunction,
521
- roundingIntervals,
522
- feePerByte,
523
- network.name,
524
- );
525
-
526
- const positionInfo = new OrderPositionInfo();
527
- positionInfo.shiftForFees = shiftForFees;
528
- positionInfo.fees = shiftForFees === 'neither' ? BigInt(0) : fees.sats;
529
- orderOffer.positionInfo = positionInfo;
530
-
531
- return orderOffer;
532
- };
533
-
534
- /**
535
- * Builds a custom strategy order offer
536
- *
537
- * Calculates offer fees
538
- * calculates the minimum max gain
539
- * maxLoss and maxGain are normalized to 1 BTC contracts
540
- *
541
- * shiftForFees 'offeror' means 'offeror' pays network fees
542
- * shiftForFees 'acceptor' means 'acceptor' pays network fees
543
- *
544
- * numContracts refers to the number of DLCs in the funding transaction
545
- * if it's not a batch dlc funding transaction, then this is not relevant
546
- *
547
- * @param {OracleAnnouncement} announcement oracle announcement
548
- * @param {Value} contractSize contract size
549
- * @param {Value} normalizedMaxLoss maximum amount that can be lost based on 1 BTC contract
550
- * @param {Value} normalizedMaxGain maximum amount that can be gained based on 1 BTC contract
551
- * @param {bigint} feePerByte sats/vbyte
552
- * @param {Value} roundingIntervals rounding mod for RoundingInterval
553
- * @param {BitcoinNetwork} network bitcoin, bitcoin_testnet or bitcoin_regtest
554
- * @param {DlcParty} [shiftForFees] shift for offerer, acceptor or neither
555
- * @param {Value} [fees_] fees to shift
556
- * @param {Value} [collateral] collateral to use
557
- * @param {number} [numOfferInputs] number of inputs to use
558
- * @param {number} [numContracts] number of DLCs in the funding transaction
559
- *
560
- * @returns {OrderOffer}
561
- */
562
- export const buildCustomStrategyOrderOffer = (
563
- announcement: OracleAnnouncement,
564
- contractSize: Value,
565
- normalizedMaxLoss: Value,
566
- normalizedMaxGain: Value,
567
- feePerByte: bigint,
568
- roundingIntervals: RoundingIntervals,
569
- network: BitcoinNetwork,
570
- shiftForFees: DlcParty = 'neither',
571
- fees_: Value = Value.fromSats(0), // NOTE: fees should be divided before doing batch transaction
572
- collateral: Value = Value.fromSats(0),
573
- numOfferInputs = 1,
574
- numContracts = 1,
575
- skipValidation = false,
576
- ): OrderOffer => {
577
- if (contractSize.eq(Value.zero())) {
578
- throw Error('contractSize must be greater than 0');
579
- }
580
-
581
- if (collateral.eq(Value.zero())) {
582
- collateral = contractSize.clone();
583
- }
584
-
585
- const eventDescriptor = getDigitDecompositionEventDescriptor(announcement);
586
-
587
- const unit = eventDescriptor.unit;
588
-
589
- const fees = Value.fromSats(
590
- Number(new Decimal(Number(fees_.sats)).dividedBy(numContracts).toFixed(0)),
591
- );
592
-
593
- const finalizer = getFinalizerByCount(
594
- feePerByte,
595
- numOfferInputs,
596
- 1,
597
- numContracts,
598
- );
599
- const offerFees = Value.fromSats(finalizer.offerFees);
600
-
601
- // Use offerFees + dustThreshold for min max gain, to ensure in the case of
602
- // 0 PnL the acceptor payout is not dust
603
- const minMaxGainForContractSize_ = offerFees.addn(
604
- Value.fromSats(dustThreshold(BigInt(feePerByte))),
605
- );
606
- const minMaxGainForContractSize = Value.fromSats(
607
- roundUpToNearestMultiplier(
608
- minMaxGainForContractSize_.sats,
609
- BigInt(UNIT_MULTIPLIER[unit.toLowerCase()]),
610
- ),
611
- );
612
-
613
- const maxLossForContractSize = Value.fromSats(
614
- roundUpToNearestMultiplier(
615
- (normalizedMaxLoss.sats * contractSize.sats) / BigInt(1e8),
616
- BigInt(UNIT_MULTIPLIER[unit.toLowerCase()]),
617
- ),
618
- );
619
- const tempMaxGainForContractSize = Value.fromSats(
620
- roundUpToNearestMultiplier(
621
- (normalizedMaxGain.sats * contractSize.sats) / BigInt(1e8),
622
- BigInt(UNIT_MULTIPLIER[unit.toLowerCase()]),
623
- ),
624
- );
625
-
626
- const maxGainForContractSize = Value.zero();
627
-
628
- if (tempMaxGainForContractSize.lt(minMaxGainForContractSize)) {
629
- maxGainForContractSize.add(minMaxGainForContractSize);
630
- } else {
631
- maxGainForContractSize.add(tempMaxGainForContractSize);
632
- }
633
-
634
- const maxGainAdjusted = Value.fromSats(
635
- roundToNearestMultiplier(
636
- (maxGainForContractSize.sats * BigInt(1e8)) / contractSize.sats,
637
- BigInt(UNIT_MULTIPLIER[unit.toLowerCase()]),
638
- ),
639
- );
640
-
641
- const feesAdjusted = Value.fromSats(
642
- roundToNearestMultiplier(
643
- (fees.sats * BigInt(1e8)) / contractSize.sats,
644
- BigInt(UNIT_MULTIPLIER[unit.toLowerCase()]),
645
- ),
646
- );
647
-
648
- const minPayout = collateral.clone();
649
- if (minPayout.lt(maxLossForContractSize.addn(maxGainForContractSize))) {
650
- throw new Error(
651
- 'Subtraction would result in a negative value for minPayout.',
652
- );
653
- }
654
- minPayout.sub(maxLossForContractSize);
655
- minPayout.sub(maxGainForContractSize);
656
- const maxPayout = collateral.clone();
657
-
658
- const startOutcomeValue = Value.fromBitcoin(1);
659
- startOutcomeValue.sub(normalizedMaxLoss);
660
- const endOutcomeValue = Value.fromBitcoin(1);
661
- endOutcomeValue.add(maxGainAdjusted);
662
-
663
- if (shiftForFees === 'offeror') {
664
- startOutcomeValue.add(feesAdjusted);
665
- endOutcomeValue.add(feesAdjusted);
666
- } else if (shiftForFees === 'acceptor') {
667
- startOutcomeValue.sub(feesAdjusted);
668
- endOutcomeValue.sub(feesAdjusted);
669
- }
670
-
671
- const startOutcome =
672
- startOutcomeValue.sats / BigInt(UNIT_MULTIPLIER[unit.toLowerCase()]);
673
- const endOutcome =
674
- endOutcomeValue.sats / BigInt(UNIT_MULTIPLIER[unit.toLowerCase()]);
675
-
676
- const offerCollateral = collateral.clone();
677
- if (offerCollateral.lt(maxGainForContractSize)) {
678
- throw new Error(
679
- 'Subtraction would result in a negative value for offerCollateral.',
680
- );
681
- }
682
- offerCollateral.sub(maxGainForContractSize);
683
-
684
- const orderOffer = buildLinearOrderOffer(
685
- announcement,
686
- offerCollateral,
687
- minPayout,
688
- maxPayout,
689
- startOutcome,
690
- endOutcome,
691
- feePerByte,
692
- roundingIntervals,
693
- network,
694
- shiftForFees,
695
- fees,
696
- );
697
-
698
- (orderOffer.positionInfo as OrderPositionInfo).contractSize =
699
- contractSize.sats;
700
-
701
- (orderOffer.positionInfo as OrderPositionInfo).instrumentName = ((orderOffer.contractInfo as SingleContractInfo)
702
- .oracleInfo as SingleOracleInfo).announcement.oracleEvent.eventId;
703
-
704
- if (!skipValidation) orderOffer.validate();
705
-
706
- return orderOffer;
707
- };
708
-
709
- interface IInterval {
710
- beginInterval: bigint;
711
- rounding: number | bigint | Value;
712
- }
713
-
714
- export const buildRoundingIntervalsFromIntervals = (
715
- contractSize: Value,
716
- intervals: IInterval[],
717
- ): RoundingIntervals => {
718
- const roundingIntervals = new RoundingIntervals();
719
-
720
- roundingIntervals.intervals = intervals.map((interval) => {
721
- const roundingMod = computeRoundingModulus(interval.rounding, contractSize);
722
-
723
- return {
724
- beginInterval: interval.beginInterval,
725
- roundingMod,
726
- };
727
- });
728
-
729
- return roundingIntervals;
730
- };