@atomicfinance/bitcoin-wallet-provider 4.0.3 → 4.1.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.
Files changed (230) hide show
  1. package/.turbo/turbo-build.log +3 -0
  2. package/CHANGELOG.md +31 -0
  3. package/LICENSE +674 -0
  4. package/dist/BitcoinWalletProvider.d.ts +8 -11
  5. package/dist/BitcoinWalletProvider.js +18 -10
  6. package/dist/BitcoinWalletProvider.js.map +1 -1
  7. package/lib/BitcoinWalletProvider.ts +0 -2
  8. package/package.json +14 -13
  9. package/.turbo/turbo-lint.log +0 -1
  10. package/.turbo/turbo-test.log +0 -0
  11. package/.yalc/@node-dlc/core/.nyc_output/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
  12. package/.yalc/@node-dlc/core/.nyc_output/processinfo/687a3c14-9765-45fd-a1fe-f7db3d56fee4.json +0 -1
  13. package/.yalc/@node-dlc/core/.nyc_output/processinfo/index.json +0 -1
  14. package/.yalc/@node-dlc/core/README.md +0 -11
  15. package/.yalc/@node-dlc/core/__tests__/core.spec.ts +0 -7
  16. package/.yalc/@node-dlc/core/__tests__/dlc/CETCalculator.spec.ts +0 -1029
  17. package/.yalc/@node-dlc/core/__tests__/dlc/CoinSelect.spec.ts +0 -179
  18. package/.yalc/@node-dlc/core/__tests__/dlc/PolynomialPayoutCurve.spec.ts +0 -345
  19. package/.yalc/@node-dlc/core/__tests__/dlc/TxBuilder.spec.ts +0 -424
  20. package/.yalc/@node-dlc/core/__tests__/dlc/finance/Builder.spec.ts +0 -492
  21. package/.yalc/@node-dlc/core/__tests__/dlc/finance/CoveredCall.spec.ts +0 -112
  22. package/.yalc/@node-dlc/core/__tests__/dlc/finance/CsoInfo.spec.ts +0 -1124
  23. package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongCall.spec.ts +0 -55
  24. package/.yalc/@node-dlc/core/__tests__/dlc/finance/LongPut.spec.ts +0 -55
  25. package/.yalc/@node-dlc/core/__tests__/dlc/finance/OptionInfo.spec.ts +0 -226
  26. package/.yalc/@node-dlc/core/__tests__/dlc/finance/ShortPut.spec.ts +0 -62
  27. package/.yalc/@node-dlc/core/__tests__/tsconfig.json +0 -8
  28. package/.yalc/@node-dlc/core/__tests__/utils/precision.spec.ts +0 -40
  29. package/.yalc/@node-dlc/core/coverage/lcov-report/base.css +0 -224
  30. package/.yalc/@node-dlc/core/coverage/lcov-report/block-navigation.js +0 -79
  31. package/.yalc/@node-dlc/core/coverage/lcov-report/favicon.png +0 -0
  32. package/.yalc/@node-dlc/core/coverage/lcov-report/index.html +0 -171
  33. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/AsyncProcessingQueue.ts.html +0 -269
  34. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Base32.ts.html +0 -86
  35. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BigIntUtils.ts.html +0 -86
  36. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/BitField.ts.html +0 -86
  37. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ChannelId.ts.html +0 -86
  38. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedList.ts.html +0 -413
  39. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/LinkedListNode.ts.html +0 -122
  40. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/Queue.ts.html +0 -188
  41. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelId.ts.html +0 -86
  42. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/ShortChannelIdUtils.ts.html +0 -107
  43. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CETCalculator.ts.html +0 -1430
  44. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/CoinSelect.ts.html +0 -431
  45. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/HyperbolaPayoutCurve.ts.html +0 -644
  46. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/PolynomialPayoutCurve.ts.html +0 -878
  47. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxBuilder.ts.html +0 -1088
  48. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/TxFinalizer.ts.html +0 -731
  49. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/Builder.ts.html +0 -2270
  50. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CoveredCall.ts.html +0 -410
  51. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/CsoInfo.ts.html +0 -1574
  52. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LinearPayout.ts.html +0 -362
  53. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongCall.ts.html +0 -302
  54. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/LongPut.ts.html +0 -302
  55. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/OptionInfo.ts.html +0 -626
  56. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/ShortPut.ts.html +0 -305
  57. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/finance/index.html +0 -216
  58. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/dlc/index.html +0 -186
  59. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.html +0 -261
  60. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/index.ts.html +0 -278
  61. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelId.ts.html +0 -242
  62. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ChannelKeys.ts.html +0 -407
  63. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentNumber.ts.html +0 -362
  64. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecret.ts.html +0 -203
  65. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/CommitmentSecretStore.ts.html +0 -332
  66. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/Htlc.ts.html +0 -236
  67. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/HtlcDirection.ts.html +0 -131
  68. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/ScriptFactory.ts.html +0 -530
  69. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/TxFactory.ts.html +0 -1094
  70. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/lightning/index.html +0 -231
  71. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/BigIntUtils.ts.html +0 -272
  72. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/Precision.ts.html +0 -149
  73. package/.yalc/@node-dlc/core/coverage/lcov-report/lib/utils/index.html +0 -126
  74. package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.css +0 -1
  75. package/.yalc/@node-dlc/core/coverage/lcov-report/prettify.js +0 -2
  76. package/.yalc/@node-dlc/core/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  77. package/.yalc/@node-dlc/core/coverage/lcov-report/sorter.js +0 -170
  78. package/.yalc/@node-dlc/core/coverage/lcov.info +0 -2426
  79. package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.d.ts +0 -22
  80. package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js +0 -55
  81. package/.yalc/@node-dlc/core/dist/AsyncProcessingQueue.js.map +0 -1
  82. package/.yalc/@node-dlc/core/dist/Base32.d.ts +0 -1
  83. package/.yalc/@node-dlc/core/dist/Base32.js +0 -7
  84. package/.yalc/@node-dlc/core/dist/Base32.js.map +0 -1
  85. package/.yalc/@node-dlc/core/dist/BigIntUtils.d.ts +0 -1
  86. package/.yalc/@node-dlc/core/dist/BigIntUtils.js +0 -8
  87. package/.yalc/@node-dlc/core/dist/BigIntUtils.js.map +0 -1
  88. package/.yalc/@node-dlc/core/dist/BitField.d.ts +0 -1
  89. package/.yalc/@node-dlc/core/dist/BitField.js +0 -7
  90. package/.yalc/@node-dlc/core/dist/BitField.js.map +0 -1
  91. package/.yalc/@node-dlc/core/dist/ChannelId.d.ts +0 -1
  92. package/.yalc/@node-dlc/core/dist/ChannelId.js +0 -7
  93. package/.yalc/@node-dlc/core/dist/ChannelId.js.map +0 -1
  94. package/.yalc/@node-dlc/core/dist/LinkedList.d.ts +0 -30
  95. package/.yalc/@node-dlc/core/dist/LinkedList.js +0 -104
  96. package/.yalc/@node-dlc/core/dist/LinkedList.js.map +0 -1
  97. package/.yalc/@node-dlc/core/dist/LinkedListNode.d.ts +0 -9
  98. package/.yalc/@node-dlc/core/dist/LinkedListNode.js +0 -15
  99. package/.yalc/@node-dlc/core/dist/LinkedListNode.js.map +0 -1
  100. package/.yalc/@node-dlc/core/dist/Queue.d.ts +0 -22
  101. package/.yalc/@node-dlc/core/dist/Queue.js +0 -38
  102. package/.yalc/@node-dlc/core/dist/Queue.js.map +0 -1
  103. package/.yalc/@node-dlc/core/dist/ShortChannelId.d.ts +0 -1
  104. package/.yalc/@node-dlc/core/dist/ShortChannelId.js +0 -7
  105. package/.yalc/@node-dlc/core/dist/ShortChannelId.js.map +0 -1
  106. package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.d.ts +0 -1
  107. package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js +0 -12
  108. package/.yalc/@node-dlc/core/dist/ShortChannelIdUtils.js.map +0 -1
  109. package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.d.ts +0 -50
  110. package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js +0 -332
  111. package/.yalc/@node-dlc/core/dist/dlc/CETCalculator.js.map +0 -1
  112. package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.d.ts +0 -23
  113. package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js +0 -77
  114. package/.yalc/@node-dlc/core/dist/dlc/CoinSelect.js.map +0 -1
  115. package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.d.ts +0 -20
  116. package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js +0 -117
  117. package/.yalc/@node-dlc/core/dist/dlc/HyperbolaPayoutCurve.js.map +0 -1
  118. package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.d.ts +0 -5
  119. package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js +0 -3
  120. package/.yalc/@node-dlc/core/dist/dlc/PayoutCurve.js.map +0 -1
  121. package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.d.ts +0 -52
  122. package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js +0 -173
  123. package/.yalc/@node-dlc/core/dist/dlc/PolynomialPayoutCurve.js.map +0 -1
  124. package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.d.ts +0 -55
  125. package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js +0 -217
  126. package/.yalc/@node-dlc/core/dist/dlc/TxBuilder.js.map +0 -1
  127. package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.d.ts +0 -40
  128. package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js +0 -146
  129. package/.yalc/@node-dlc/core/dist/dlc/TxFinalizer.js.map +0 -1
  130. package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.d.ts +0 -193
  131. package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js +0 -422
  132. package/.yalc/@node-dlc/core/dist/dlc/finance/Builder.js.map +0 -1
  133. package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.d.ts +0 -13
  134. package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js +0 -67
  135. package/.yalc/@node-dlc/core/dist/dlc/finance/CoveredCall.js.map +0 -1
  136. package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.d.ts +0 -114
  137. package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js +0 -290
  138. package/.yalc/@node-dlc/core/dist/dlc/finance/CsoInfo.js.map +0 -1
  139. package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.d.ts +0 -6
  140. package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js +0 -79
  141. package/.yalc/@node-dlc/core/dist/dlc/finance/LinearPayout.js.map +0 -1
  142. package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.d.ts +0 -13
  143. package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js +0 -47
  144. package/.yalc/@node-dlc/core/dist/dlc/finance/LongCall.js.map +0 -1
  145. package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.d.ts +0 -13
  146. package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js +0 -47
  147. package/.yalc/@node-dlc/core/dist/dlc/finance/LongPut.js.map +0 -1
  148. package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.d.ts +0 -20
  149. package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js +0 -101
  150. package/.yalc/@node-dlc/core/dist/dlc/finance/OptionInfo.js.map +0 -1
  151. package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.d.ts +0 -12
  152. package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js +0 -46
  153. package/.yalc/@node-dlc/core/dist/dlc/finance/ShortPut.js.map +0 -1
  154. package/.yalc/@node-dlc/core/dist/index.d.ts +0 -39
  155. package/.yalc/@node-dlc/core/dist/index.js +0 -78
  156. package/.yalc/@node-dlc/core/dist/index.js.map +0 -1
  157. package/.yalc/@node-dlc/core/dist/lightning/ChannelId.d.ts +0 -31
  158. package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js +0 -52
  159. package/.yalc/@node-dlc/core/dist/lightning/ChannelId.js.map +0 -1
  160. package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.d.ts +0 -55
  161. package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js +0 -105
  162. package/.yalc/@node-dlc/core/dist/lightning/ChannelKeys.js.map +0 -1
  163. package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.d.ts +0 -55
  164. package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js +0 -76
  165. package/.yalc/@node-dlc/core/dist/lightning/CommitmentNumber.js.map +0 -1
  166. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.d.ts +0 -26
  167. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js +0 -44
  168. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecret.js.map +0 -1
  169. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.d.ts +0 -41
  170. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js +0 -79
  171. package/.yalc/@node-dlc/core/dist/lightning/CommitmentSecretStore.js.map +0 -1
  172. package/.yalc/@node-dlc/core/dist/lightning/Htlc.d.ts +0 -46
  173. package/.yalc/@node-dlc/core/dist/lightning/Htlc.js +0 -46
  174. package/.yalc/@node-dlc/core/dist/lightning/Htlc.js.map +0 -1
  175. package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.d.ts +0 -16
  176. package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js +0 -21
  177. package/.yalc/@node-dlc/core/dist/lightning/HtlcDirection.js.map +0 -1
  178. package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.d.ts +0 -76
  179. package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js +0 -102
  180. package/.yalc/@node-dlc/core/dist/lightning/ScriptFactory.js.map +0 -1
  181. package/.yalc/@node-dlc/core/dist/lightning/TxFactory.d.ts +0 -83
  182. package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js +0 -222
  183. package/.yalc/@node-dlc/core/dist/lightning/TxFactory.js.map +0 -1
  184. package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.d.ts +0 -9
  185. package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js +0 -59
  186. package/.yalc/@node-dlc/core/dist/utils/BigIntUtils.js.map +0 -1
  187. package/.yalc/@node-dlc/core/dist/utils/Precision.d.ts +0 -13
  188. package/.yalc/@node-dlc/core/dist/utils/Precision.js +0 -28
  189. package/.yalc/@node-dlc/core/dist/utils/Precision.js.map +0 -1
  190. package/.yalc/@node-dlc/core/lib/AsyncProcessingQueue.ts +0 -63
  191. package/.yalc/@node-dlc/core/lib/Base32.ts +0 -2
  192. package/.yalc/@node-dlc/core/lib/BigIntUtils.ts +0 -2
  193. package/.yalc/@node-dlc/core/lib/BitField.ts +0 -2
  194. package/.yalc/@node-dlc/core/lib/ChannelId.ts +0 -2
  195. package/.yalc/@node-dlc/core/lib/LinkedList.ts +0 -111
  196. package/.yalc/@node-dlc/core/lib/LinkedListNode.ts +0 -14
  197. package/.yalc/@node-dlc/core/lib/Queue.ts +0 -36
  198. package/.yalc/@node-dlc/core/lib/ShortChannelId.ts +0 -2
  199. package/.yalc/@node-dlc/core/lib/ShortChannelIdUtils.ts +0 -9
  200. package/.yalc/@node-dlc/core/lib/dlc/CETCalculator.ts +0 -450
  201. package/.yalc/@node-dlc/core/lib/dlc/CoinSelect.ts +0 -117
  202. package/.yalc/@node-dlc/core/lib/dlc/HyperbolaPayoutCurve.ts +0 -188
  203. package/.yalc/@node-dlc/core/lib/dlc/PayoutCurve.ts +0 -6
  204. package/.yalc/@node-dlc/core/lib/dlc/PolynomialPayoutCurve.ts +0 -266
  205. package/.yalc/@node-dlc/core/lib/dlc/TxBuilder.ts +0 -336
  206. package/.yalc/@node-dlc/core/lib/dlc/TxFinalizer.ts +0 -217
  207. package/.yalc/@node-dlc/core/lib/dlc/finance/Builder.ts +0 -730
  208. package/.yalc/@node-dlc/core/lib/dlc/finance/CoveredCall.ts +0 -110
  209. package/.yalc/@node-dlc/core/lib/dlc/finance/CsoInfo.ts +0 -498
  210. package/.yalc/@node-dlc/core/lib/dlc/finance/LinearPayout.ts +0 -94
  211. package/.yalc/@node-dlc/core/lib/dlc/finance/LongCall.ts +0 -74
  212. package/.yalc/@node-dlc/core/lib/dlc/finance/LongPut.ts +0 -74
  213. package/.yalc/@node-dlc/core/lib/dlc/finance/OptionInfo.ts +0 -182
  214. package/.yalc/@node-dlc/core/lib/dlc/finance/ShortPut.ts +0 -75
  215. package/.yalc/@node-dlc/core/lib/index.ts +0 -66
  216. package/.yalc/@node-dlc/core/lib/lightning/ChannelId.ts +0 -54
  217. package/.yalc/@node-dlc/core/lib/lightning/ChannelKeys.ts +0 -109
  218. package/.yalc/@node-dlc/core/lib/lightning/CommitmentNumber.ts +0 -94
  219. package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecret.ts +0 -41
  220. package/.yalc/@node-dlc/core/lib/lightning/CommitmentSecretStore.ts +0 -84
  221. package/.yalc/@node-dlc/core/lib/lightning/Htlc.ts +0 -52
  222. package/.yalc/@node-dlc/core/lib/lightning/HtlcDirection.ts +0 -17
  223. package/.yalc/@node-dlc/core/lib/lightning/ScriptFactory.ts +0 -150
  224. package/.yalc/@node-dlc/core/lib/lightning/TxFactory.ts +0 -338
  225. package/.yalc/@node-dlc/core/lib/utils/BigIntUtils.ts +0 -64
  226. package/.yalc/@node-dlc/core/lib/utils/Precision.ts +0 -23
  227. package/.yalc/@node-dlc/core/package.json +0 -38
  228. package/.yalc/@node-dlc/core/tsconfig.json +0 -8
  229. package/.yalc/@node-dlc/core/yalc.sig +0 -1
  230. package/yalc.lock +0 -10
@@ -1,55 +0,0 @@
1
- import { HyperbolaPayoutCurvePiece } from '@node-dlc/messaging';
2
- import { expect } from 'chai';
3
-
4
- import { LongCall } from '../../../lib/dlc/finance/LongCall';
5
- import { HyperbolaPayoutCurve } from '../../../lib/dlc/HyperbolaPayoutCurve';
6
-
7
- describe('LongCall', () => {
8
- describe('1BTC-50k-base2-18digit curve', () => {
9
- const strikePrice = BigInt(50000);
10
- const contractSize = BigInt(10) ** BigInt(8);
11
- const oracleBase = 2;
12
- const oracleDigits = 18;
13
-
14
- const { payoutCurve } = LongCall.buildCurve(
15
- strikePrice,
16
- contractSize,
17
- oracleBase,
18
- oracleDigits,
19
- );
20
-
21
- describe('payout', () => {
22
- const priceIncrease = BigInt(1000);
23
-
24
- it('should be positive as the position goes ITM', () => {
25
- expect(
26
- payoutCurve
27
- .getPayout(strikePrice + priceIncrease)
28
- .integerValue()
29
- .toNumber(),
30
- ).to.equal(
31
- Number(
32
- (contractSize * priceIncrease) / (strikePrice + priceIncrease),
33
- ),
34
- );
35
- });
36
-
37
- it('should be zero at strike price', () => {
38
- expect(payoutCurve.getPayout(strikePrice).toNumber()).to.equal(0);
39
- });
40
- });
41
-
42
- it('should serialize and deserialize properly', () => {
43
- const payout = payoutCurve.getPayout(strikePrice);
44
-
45
- const _tlv = payoutCurve.toPayoutCurvePiece().serialize();
46
- const pf = HyperbolaPayoutCurvePiece.deserialize(_tlv);
47
-
48
- const deserializedCurve = HyperbolaPayoutCurve.fromPayoutCurvePiece(pf);
49
-
50
- expect(payout.toNumber()).to.be.eq(
51
- deserializedCurve.getPayout(strikePrice).toNumber(),
52
- );
53
- });
54
- });
55
- });
@@ -1,55 +0,0 @@
1
- import { HyperbolaPayoutCurvePiece } from '@node-dlc/messaging';
2
- import { expect } from 'chai';
3
-
4
- import { LongPut } from '../../../lib';
5
- import { HyperbolaPayoutCurve } from '../../../lib/dlc/HyperbolaPayoutCurve';
6
-
7
- describe('LongPut', () => {
8
- describe('1BTC-50k-base2-18digit curve', () => {
9
- const strikePrice = BigInt(50000);
10
- const contractSize = BigInt(10) ** BigInt(8);
11
- const oracleBase = 2;
12
- const oracleDigits = 18;
13
-
14
- const { payoutCurve } = LongPut.buildCurve(
15
- strikePrice,
16
- contractSize,
17
- oracleBase,
18
- oracleDigits,
19
- );
20
-
21
- describe('payout', () => {
22
- const priceDecrease = BigInt(1000);
23
-
24
- it('should be positive as the position goes ITM', () => {
25
- expect(
26
- payoutCurve
27
- .getPayout(strikePrice - priceDecrease)
28
- .integerValue()
29
- .toNumber(),
30
- ).to.equal(
31
- Number(
32
- (contractSize * priceDecrease) / (strikePrice - priceDecrease),
33
- ),
34
- );
35
- });
36
-
37
- it('should be zero at strike price', () => {
38
- expect(payoutCurve.getPayout(strikePrice).toNumber()).to.equal(0);
39
- });
40
- });
41
-
42
- it('should serialize and deserialize properly', () => {
43
- const payout = payoutCurve.getPayout(strikePrice);
44
-
45
- const _tlv = payoutCurve.toPayoutCurvePiece().serialize();
46
- const pf = HyperbolaPayoutCurvePiece.deserialize(_tlv);
47
-
48
- const deserializedCurve = HyperbolaPayoutCurve.fromPayoutCurvePiece(pf);
49
-
50
- expect(payout.toNumber()).to.be.eq(
51
- deserializedCurve.getPayout(strikePrice).toNumber(),
52
- );
53
- });
54
- });
55
- });
@@ -1,226 +0,0 @@
1
- import { F64 } from '@node-dlc/messaging';
2
- import {
3
- DigitDecompositionEventDescriptorV0,
4
- DlcOffer,
5
- HyperbolaPayoutCurvePiece,
6
- NumericalDescriptor,
7
- OracleAnnouncement,
8
- OracleEvent,
9
- PayoutFunction,
10
- SingleContractInfo,
11
- SingleOracleInfo,
12
- } from '@node-dlc/messaging';
13
- import { expect } from 'chai';
14
-
15
- import { CoveredCall } from '../../../lib/dlc/finance/CoveredCall';
16
- import {
17
- getOptionInfoFromContractInfo,
18
- getOptionInfoFromOffer,
19
- } from '../../../lib/dlc/finance/OptionInfo';
20
- import { ShortPut } from '../../../lib/dlc/finance/ShortPut';
21
-
22
- describe('OptionInfo', () => {
23
- describe('OptionInfo from covered call messages', () => {
24
- const strikePrice = BigInt(50000);
25
- const contractSize = BigInt(10) ** BigInt(8);
26
- const premium = BigInt(50000);
27
- const expiry = new Date(1620014750000);
28
-
29
- const oracleBase = 2;
30
- const oracleDigits = 17;
31
-
32
- const { totalCollateral, payoutFunction } = CoveredCall.buildPayoutFunction(
33
- strikePrice,
34
- contractSize,
35
- oracleBase,
36
- oracleDigits,
37
- );
38
-
39
- const dlcOffer = buildDlcOfferFixture(
40
- oracleDigits,
41
- expiry,
42
- payoutFunction,
43
- totalCollateral,
44
- premium,
45
- );
46
-
47
- const contractInfo = dlcOffer.contractInfo;
48
-
49
- it('should get correct OptionInfo from ContractInfo', () => {
50
- const optionInfo = getOptionInfoFromContractInfo(contractInfo);
51
-
52
- expect(optionInfo).to.deep.equal({
53
- contractSize,
54
- strikePrice,
55
- expiry,
56
- type: 'call',
57
- });
58
- });
59
-
60
- it('should get correct OptionInfoWithPremium from DlcOffer', () => {
61
- const optionInfo = getOptionInfoFromOffer(dlcOffer);
62
-
63
- expect(optionInfo).to.deep.equal({
64
- contractSize,
65
- strikePrice,
66
- expiry,
67
- premium,
68
- type: 'call',
69
- });
70
- });
71
-
72
- it('should throw on an invalid curve', () => {
73
- const {
74
- totalCollateral,
75
- payoutFunction,
76
- } = CoveredCall.buildPayoutFunction(
77
- strikePrice,
78
- contractSize,
79
- oracleBase,
80
- oracleDigits,
81
- );
82
-
83
- const invalidDlcOffer = buildDlcOfferFixture(
84
- oracleDigits,
85
- expiry,
86
- payoutFunction,
87
- totalCollateral,
88
- premium,
89
- );
90
-
91
- const contractInfo = invalidDlcOffer.contractInfo as SingleContractInfo;
92
- const contractDescriptor = contractInfo.contractDescriptor as NumericalDescriptor;
93
- const payoutFunc = contractDescriptor.payoutFunction as PayoutFunction;
94
- const hyperbolaPiece = payoutFunc.payoutFunctionPieces[0]
95
- .payoutCurvePiece as HyperbolaPayoutCurvePiece;
96
-
97
- hyperbolaPiece.translateOutcome = F64.fromNumber(4);
98
-
99
- expect(() => {
100
- getOptionInfoFromOffer(invalidDlcOffer);
101
- }).to.throw();
102
- });
103
- });
104
-
105
- describe('OptionInfo from short call messages', () => {
106
- const strikePrice = BigInt(50000);
107
- const contractSize = BigInt(10) ** BigInt(8);
108
- const totalCollateral = BigInt(9) ** BigInt(8);
109
-
110
- const premium = BigInt(50000);
111
- const expiry = new Date(1620014750000);
112
-
113
- const oracleBase = 2;
114
- const oracleDigits = 17;
115
-
116
- const { payoutFunction } = ShortPut.buildPayoutFunction(
117
- strikePrice,
118
- contractSize,
119
- totalCollateral,
120
- oracleBase,
121
- oracleDigits,
122
- );
123
-
124
- const dlcOffer = buildDlcOfferFixture(
125
- oracleDigits,
126
- expiry,
127
- payoutFunction,
128
- totalCollateral,
129
- premium,
130
- );
131
-
132
- const contractInfo = dlcOffer.contractInfo;
133
-
134
- it('should get correct OptionInfo from ContractInfo', () => {
135
- const optionInfo = getOptionInfoFromContractInfo(contractInfo);
136
-
137
- expect(optionInfo).to.deep.equal({
138
- contractSize,
139
- strikePrice,
140
- expiry,
141
- type: 'put',
142
- });
143
- });
144
-
145
- it('should get correct OptionInfoWithPremium from DlcOffer', () => {
146
- const optionInfo = getOptionInfoFromOffer(dlcOffer);
147
-
148
- expect(optionInfo).to.deep.equal({
149
- contractSize,
150
- strikePrice,
151
- expiry,
152
- premium,
153
- type: 'put',
154
- });
155
- });
156
-
157
- it('should throw on an invalid curve', () => {
158
- const { payoutFunction } = ShortPut.buildPayoutFunction(
159
- strikePrice,
160
- contractSize,
161
- totalCollateral,
162
- oracleBase,
163
- oracleDigits,
164
- );
165
-
166
- const invalidDlcOffer = buildDlcOfferFixture(
167
- oracleDigits,
168
- expiry,
169
- payoutFunction,
170
- totalCollateral,
171
- premium,
172
- );
173
-
174
- const contractInfo = invalidDlcOffer.contractInfo as SingleContractInfo;
175
- const contractDescriptor = contractInfo.contractDescriptor as NumericalDescriptor;
176
- const payoutFunc = contractDescriptor.payoutFunction as PayoutFunction;
177
- const hyperbolaPiece = payoutFunc.payoutFunctionPieces[0]
178
- .payoutCurvePiece as HyperbolaPayoutCurvePiece;
179
-
180
- hyperbolaPiece.translateOutcome = F64.fromNumber(4);
181
-
182
- expect(() => {
183
- getOptionInfoFromOffer(invalidDlcOffer);
184
- }).to.throw();
185
- });
186
- });
187
- });
188
-
189
- function buildDlcOfferFixture(
190
- oracleDigits: number,
191
- expiry: Date,
192
- payoutFunction: PayoutFunction,
193
- totalCollateral: bigint,
194
- premium: bigint,
195
- ) {
196
- const eventDescriptor = new DigitDecompositionEventDescriptorV0();
197
- eventDescriptor.base = 2;
198
- eventDescriptor.isSigned = false;
199
- eventDescriptor.unit = 'BTC-USD';
200
- eventDescriptor.precision = 0;
201
- eventDescriptor.nbDigits = oracleDigits;
202
-
203
- const oracleEvent = new OracleEvent();
204
- oracleEvent.eventMaturityEpoch = Math.floor(expiry.getTime() / 1000);
205
- oracleEvent.eventDescriptor = eventDescriptor;
206
-
207
- const oracleAnnouncement = new OracleAnnouncement();
208
- oracleAnnouncement.oracleEvent = oracleEvent;
209
-
210
- const oracleInfo = new SingleOracleInfo();
211
- oracleInfo.announcement = oracleAnnouncement;
212
-
213
- const contractDescriptor = new NumericalDescriptor();
214
- contractDescriptor.numDigits = oracleDigits;
215
- contractDescriptor.payoutFunction = payoutFunction;
216
-
217
- const contractInfo = new SingleContractInfo();
218
- contractInfo.totalCollateral = totalCollateral;
219
- contractInfo.contractDescriptor = contractDescriptor;
220
- contractInfo.oracleInfo = oracleInfo;
221
-
222
- const dlcOffer = new DlcOffer();
223
- dlcOffer.contractInfo = contractInfo;
224
- dlcOffer.offerCollateral = totalCollateral - premium;
225
- return dlcOffer;
226
- }
@@ -1,62 +0,0 @@
1
- import { HyperbolaPayoutCurvePiece } from '@node-dlc/messaging';
2
- import { expect } from 'chai';
3
-
4
- import { ShortPut } from '../../../lib/dlc/finance/ShortPut';
5
- import { HyperbolaPayoutCurve } from '../../../lib/dlc/HyperbolaPayoutCurve';
6
-
7
- describe('ShortPut', () => {
8
- describe('1BTC-50k-base2-20digit curve', () => {
9
- const strikePrice = BigInt(50000);
10
- const contractSize = BigInt(10) ** BigInt(8);
11
- const totalCollateral = contractSize;
12
- const oracleBase = 2;
13
- const oracleDigits = 20;
14
-
15
- const { payoutCurve } = ShortPut.buildCurve(
16
- strikePrice,
17
- contractSize,
18
- totalCollateral,
19
- oracleBase,
20
- oracleDigits,
21
- );
22
-
23
- describe('payout', () => {
24
- it('should be zero at half of strike price', () => {
25
- expect(
26
- payoutCurve.getPayout(strikePrice / BigInt(2)).toNumber(),
27
- ).to.be.equal(0);
28
- });
29
-
30
- it('should be correct at $30,000 settlement price', () => {
31
- const settlementPrice = BigInt(30000);
32
-
33
- expect(payoutCurve.getPayout(settlementPrice).toFixed(3)).to.be.eq(
34
- (
35
- 2 * Number(contractSize) -
36
- (Number(contractSize) * Number(strikePrice)) /
37
- Number(settlementPrice)
38
- ).toFixed(3),
39
- );
40
- });
41
-
42
- it('should be equal to totalCollateral at strike price', () => {
43
- expect(payoutCurve.getPayout(strikePrice).toNumber()).to.equal(
44
- Number(totalCollateral),
45
- );
46
- });
47
- });
48
-
49
- it('should serialize and deserialize properly', () => {
50
- const payout = payoutCurve.getPayout(strikePrice);
51
-
52
- const _tlv = payoutCurve.toPayoutCurvePiece().serialize();
53
- const pf = HyperbolaPayoutCurvePiece.deserialize(_tlv);
54
-
55
- const deserializedCurve = HyperbolaPayoutCurve.fromPayoutCurvePiece(pf);
56
-
57
- expect(payout.toNumber()).to.be.eq(
58
- deserializedCurve.getPayout(strikePrice).toNumber(),
59
- );
60
- });
61
- });
62
- });
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "noEmit": true
5
- },
6
- "include": ["**/*.spec.ts"],
7
- "exclude": []
8
- }
@@ -1,40 +0,0 @@
1
- // write tests for getPrecision and fromPrecision
2
-
3
- import BigNumber from 'bignumber.js';
4
- import { expect } from 'chai';
5
-
6
- import { fromPrecision, getPrecision } from '../../lib/utils/Precision';
7
-
8
- describe('getPrecision', () => {
9
- it('should get correct precision for integers', () => {
10
- const num = new BigNumber(1);
11
- expect(getPrecision(num)).eq(0);
12
- });
13
-
14
- it('should get correct precision for multiple decimal points', () => {
15
- const num = new BigNumber(1.123456789);
16
- expect(getPrecision(num)).eq(1234567890000000);
17
- });
18
-
19
- it('should get correct precision for max decimal points', () => {
20
- const num = new BigNumber('1.112233445566778899');
21
- expect(getPrecision(num)).eq(1122334455667789);
22
- });
23
- });
24
-
25
- describe('fromPrecision', () => {
26
- it('should create correct number from precision', () => {
27
- const num = 12345;
28
- expect(fromPrecision(num).toFormat()).eq('0.0000000000012345');
29
- });
30
-
31
- it('should create correct number from precision for max precision', () => {
32
- const num = 1122334455667788;
33
- expect(fromPrecision(num).toFormat()).eq('0.1122334455667788');
34
- });
35
-
36
- it('should throw error if precision is too large', () => {
37
- const num = Number('11223344556677889');
38
- expect(() => fromPrecision(num)).to.throw(Error);
39
- });
40
- });
@@ -1,224 +0,0 @@
1
- body, html {
2
- margin:0; padding: 0;
3
- height: 100%;
4
- }
5
- body {
6
- font-family: Helvetica Neue, Helvetica, Arial;
7
- font-size: 14px;
8
- color:#333;
9
- }
10
- .small { font-size: 12px; }
11
- *, *:after, *:before {
12
- -webkit-box-sizing:border-box;
13
- -moz-box-sizing:border-box;
14
- box-sizing:border-box;
15
- }
16
- h1 { font-size: 20px; margin: 0;}
17
- h2 { font-size: 14px; }
18
- pre {
19
- font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
20
- margin: 0;
21
- padding: 0;
22
- -moz-tab-size: 2;
23
- -o-tab-size: 2;
24
- tab-size: 2;
25
- }
26
- a { color:#0074D9; text-decoration:none; }
27
- a:hover { text-decoration:underline; }
28
- .strong { font-weight: bold; }
29
- .space-top1 { padding: 10px 0 0 0; }
30
- .pad2y { padding: 20px 0; }
31
- .pad1y { padding: 10px 0; }
32
- .pad2x { padding: 0 20px; }
33
- .pad2 { padding: 20px; }
34
- .pad1 { padding: 10px; }
35
- .space-left2 { padding-left:55px; }
36
- .space-right2 { padding-right:20px; }
37
- .center { text-align:center; }
38
- .clearfix { display:block; }
39
- .clearfix:after {
40
- content:'';
41
- display:block;
42
- height:0;
43
- clear:both;
44
- visibility:hidden;
45
- }
46
- .fl { float: left; }
47
- @media only screen and (max-width:640px) {
48
- .col3 { width:100%; max-width:100%; }
49
- .hide-mobile { display:none!important; }
50
- }
51
-
52
- .quiet {
53
- color: #7f7f7f;
54
- color: rgba(0,0,0,0.5);
55
- }
56
- .quiet a { opacity: 0.7; }
57
-
58
- .fraction {
59
- font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
60
- font-size: 10px;
61
- color: #555;
62
- background: #E8E8E8;
63
- padding: 4px 5px;
64
- border-radius: 3px;
65
- vertical-align: middle;
66
- }
67
-
68
- div.path a:link, div.path a:visited { color: #333; }
69
- table.coverage {
70
- border-collapse: collapse;
71
- margin: 10px 0 0 0;
72
- padding: 0;
73
- }
74
-
75
- table.coverage td {
76
- margin: 0;
77
- padding: 0;
78
- vertical-align: top;
79
- }
80
- table.coverage td.line-count {
81
- text-align: right;
82
- padding: 0 5px 0 20px;
83
- }
84
- table.coverage td.line-coverage {
85
- text-align: right;
86
- padding-right: 10px;
87
- min-width:20px;
88
- }
89
-
90
- table.coverage td span.cline-any {
91
- display: inline-block;
92
- padding: 0 5px;
93
- width: 100%;
94
- }
95
- .missing-if-branch {
96
- display: inline-block;
97
- margin-right: 5px;
98
- border-radius: 3px;
99
- position: relative;
100
- padding: 0 4px;
101
- background: #333;
102
- color: yellow;
103
- }
104
-
105
- .skip-if-branch {
106
- display: none;
107
- margin-right: 10px;
108
- position: relative;
109
- padding: 0 4px;
110
- background: #ccc;
111
- color: white;
112
- }
113
- .missing-if-branch .typ, .skip-if-branch .typ {
114
- color: inherit !important;
115
- }
116
- .coverage-summary {
117
- border-collapse: collapse;
118
- width: 100%;
119
- }
120
- .coverage-summary tr { border-bottom: 1px solid #bbb; }
121
- .keyline-all { border: 1px solid #ddd; }
122
- .coverage-summary td, .coverage-summary th { padding: 10px; }
123
- .coverage-summary tbody { border: 1px solid #bbb; }
124
- .coverage-summary td { border-right: 1px solid #bbb; }
125
- .coverage-summary td:last-child { border-right: none; }
126
- .coverage-summary th {
127
- text-align: left;
128
- font-weight: normal;
129
- white-space: nowrap;
130
- }
131
- .coverage-summary th.file { border-right: none !important; }
132
- .coverage-summary th.pct { }
133
- .coverage-summary th.pic,
134
- .coverage-summary th.abs,
135
- .coverage-summary td.pct,
136
- .coverage-summary td.abs { text-align: right; }
137
- .coverage-summary td.file { white-space: nowrap; }
138
- .coverage-summary td.pic { min-width: 120px !important; }
139
- .coverage-summary tfoot td { }
140
-
141
- .coverage-summary .sorter {
142
- height: 10px;
143
- width: 7px;
144
- display: inline-block;
145
- margin-left: 0.5em;
146
- background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
147
- }
148
- .coverage-summary .sorted .sorter {
149
- background-position: 0 -20px;
150
- }
151
- .coverage-summary .sorted-desc .sorter {
152
- background-position: 0 -10px;
153
- }
154
- .status-line { height: 10px; }
155
- /* yellow */
156
- .cbranch-no { background: yellow !important; color: #111; }
157
- /* dark red */
158
- .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
159
- .low .chart { border:1px solid #C21F39 }
160
- .highlighted,
161
- .highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
162
- background: #C21F39 !important;
163
- }
164
- /* medium red */
165
- .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
166
- /* light red */
167
- .low, .cline-no { background:#FCE1E5 }
168
- /* light green */
169
- .high, .cline-yes { background:rgb(230,245,208) }
170
- /* medium green */
171
- .cstat-yes { background:rgb(161,215,106) }
172
- /* dark green */
173
- .status-line.high, .high .cover-fill { background:rgb(77,146,33) }
174
- .high .chart { border:1px solid rgb(77,146,33) }
175
- /* dark yellow (gold) */
176
- .status-line.medium, .medium .cover-fill { background: #f9cd0b; }
177
- .medium .chart { border:1px solid #f9cd0b; }
178
- /* light yellow */
179
- .medium { background: #fff4c2; }
180
-
181
- .cstat-skip { background: #ddd; color: #111; }
182
- .fstat-skip { background: #ddd; color: #111 !important; }
183
- .cbranch-skip { background: #ddd !important; color: #111; }
184
-
185
- span.cline-neutral { background: #eaeaea; }
186
-
187
- .coverage-summary td.empty {
188
- opacity: .5;
189
- padding-top: 4px;
190
- padding-bottom: 4px;
191
- line-height: 1;
192
- color: #888;
193
- }
194
-
195
- .cover-fill, .cover-empty {
196
- display:inline-block;
197
- height: 12px;
198
- }
199
- .chart {
200
- line-height: 0;
201
- }
202
- .cover-empty {
203
- background: white;
204
- }
205
- .cover-full {
206
- border-right: none !important;
207
- }
208
- pre.prettyprint {
209
- border: none !important;
210
- padding: 0 !important;
211
- margin: 0 !important;
212
- }
213
- .com { color: #999 !important; }
214
- .ignore-none { color: #999; font-weight: normal; }
215
-
216
- .wrapper {
217
- min-height: 100%;
218
- height: auto !important;
219
- height: 100%;
220
- margin: 0 auto -48px;
221
- }
222
- .footer, .push {
223
- height: 48px;
224
- }