@nadohq/shared 0.1.0-alpha.8 → 0.1.0

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 (290) hide show
  1. package/dist/abis/index.cjs +12 -12
  2. package/dist/abis/index.cjs.map +1 -1
  3. package/dist/abis/index.d.cts +6 -6
  4. package/dist/abis/index.d.ts +6 -6
  5. package/dist/abis/index.js +6 -6
  6. package/dist/abis/index.js.map +1 -1
  7. package/dist/{chunk-TUJ4HQKF.js → chunk-2GPIH63F.js} +3 -3
  8. package/dist/chunk-2GPIH63F.js.map +1 -0
  9. package/dist/consts/chainEnvToChain.cjs +2 -2
  10. package/dist/consts/chainEnvToChain.cjs.map +1 -1
  11. package/dist/consts/chainEnvToChain.d.cts +329 -39
  12. package/dist/consts/chainEnvToChain.d.ts +329 -39
  13. package/dist/consts/chainEnvToChain.js +3 -3
  14. package/dist/consts/chainEnvToChain.js.map +1 -1
  15. package/dist/consts/productIds.cjs +1 -1
  16. package/dist/consts/productIds.cjs.map +1 -1
  17. package/dist/consts/productIds.d.cts +1 -1
  18. package/dist/consts/productIds.d.ts +1 -1
  19. package/dist/consts/productIds.js +1 -1
  20. package/dist/consts/productIds.js.map +1 -1
  21. package/dist/deployments/core/deployment.inkMainnet.json +13 -0
  22. package/dist/deployments/core/deployment.inkSepolia.json +13 -0
  23. package/dist/deployments/index.cjs +6 -6
  24. package/dist/deployments/index.cjs.map +1 -1
  25. package/dist/deployments/index.js +5 -5
  26. package/dist/deployments/index.js.map +1 -1
  27. package/dist/eip712/eip712ValueTypes.cjs.map +1 -1
  28. package/dist/eip712/eip712ValueTypes.d.cts +3 -3
  29. package/dist/eip712/eip712ValueTypes.d.ts +3 -3
  30. package/dist/eip712/getNadoEIP712Domain.cjs.map +1 -1
  31. package/dist/eip712/getNadoEIP712Domain.js.map +1 -1
  32. package/dist/eip712/getNadoEIP712PrimaryType.d.cts +1 -1
  33. package/dist/eip712/getNadoEIP712PrimaryType.d.ts +1 -1
  34. package/dist/eip712/getNadoEIP712Types.d.cts +1 -1
  35. package/dist/eip712/getNadoEIP712Types.d.ts +1 -1
  36. package/dist/eip712/getNadoEIP712Values.d.cts +1 -1
  37. package/dist/eip712/getNadoEIP712Values.d.ts +1 -1
  38. package/dist/eip712/getSignedTransactionRequest.d.cts +1 -1
  39. package/dist/eip712/getSignedTransactionRequest.d.ts +1 -1
  40. package/dist/eip712/index.cjs +13 -13
  41. package/dist/eip712/index.cjs.map +1 -1
  42. package/dist/eip712/index.d.cts +9 -9
  43. package/dist/eip712/index.d.ts +9 -9
  44. package/dist/eip712/index.js +6 -6
  45. package/dist/eip712/index.js.map +1 -1
  46. package/dist/eip712/orderDigest.d.cts +1 -1
  47. package/dist/eip712/orderDigest.d.ts +1 -1
  48. package/dist/eip712/signableRequestType.d.cts +1 -1
  49. package/dist/eip712/signableRequestType.d.ts +1 -1
  50. package/dist/eip712/signatureParamTypes.cjs.map +1 -1
  51. package/dist/eip712/signatureParamTypes.d.cts +13 -13
  52. package/dist/eip712/signatureParamTypes.d.ts +13 -13
  53. package/dist/encoding/encoding.cjs +21 -0
  54. package/dist/encoding/encoding.cjs.map +1 -1
  55. package/dist/encoding/encoding.d.cts +28 -4
  56. package/dist/encoding/encoding.d.ts +28 -4
  57. package/dist/encoding/encoding.js +24 -1
  58. package/dist/encoding/encoding.js.map +1 -1
  59. package/dist/encoding/index.d.cts +3 -3
  60. package/dist/encoding/index.d.ts +3 -3
  61. package/dist/execute/approveDepositAllowance.cjs.map +1 -1
  62. package/dist/execute/approveDepositAllowance.d.cts +2 -2
  63. package/dist/execute/approveDepositAllowance.d.ts +2 -2
  64. package/dist/execute/approveDepositAllowance.js.map +1 -1
  65. package/dist/execute/depositCollateral.cjs.map +1 -1
  66. package/dist/execute/depositCollateral.d.cts +2 -2
  67. package/dist/execute/depositCollateral.d.ts +2 -2
  68. package/dist/execute/depositCollateral.js.map +1 -1
  69. package/dist/execute/index.d.cts +1 -1
  70. package/dist/execute/index.d.ts +1 -1
  71. package/dist/index.d.cts +35 -35
  72. package/dist/index.d.ts +35 -35
  73. package/dist/types/ChainEnv.cjs +1 -1
  74. package/dist/types/ChainEnv.cjs.map +1 -1
  75. package/dist/types/ChainEnv.d.cts +2 -2
  76. package/dist/types/ChainEnv.d.ts +2 -2
  77. package/dist/types/ChainEnv.js +1 -1
  78. package/dist/types/ChainEnv.js.map +1 -1
  79. package/dist/types/balanceTypes.cjs.map +1 -1
  80. package/dist/types/balanceTypes.d.cts +5 -5
  81. package/dist/types/balanceTypes.d.ts +5 -5
  82. package/dist/types/healthTypes.cjs.map +1 -1
  83. package/dist/types/healthTypes.d.cts +4 -4
  84. package/dist/types/healthTypes.d.ts +4 -4
  85. package/dist/types/index.cjs +7 -7
  86. package/dist/types/index.cjs.map +1 -1
  87. package/dist/types/index.d.cts +4 -4
  88. package/dist/types/index.d.ts +4 -4
  89. package/dist/types/index.js +3 -3
  90. package/dist/types/index.js.map +1 -1
  91. package/dist/types/marketTypes.cjs.map +1 -1
  92. package/dist/types/marketTypes.d.cts +4 -4
  93. package/dist/types/marketTypes.d.ts +4 -4
  94. package/dist/types/orderAppendixTypes.cjs.map +1 -1
  95. package/dist/types/orderAppendixTypes.d.cts +27 -3
  96. package/dist/types/orderAppendixTypes.d.ts +27 -3
  97. package/dist/types/productTypes.cjs.map +1 -1
  98. package/dist/types/productTypes.d.cts +16 -16
  99. package/dist/types/productTypes.d.ts +16 -16
  100. package/dist/types/productTypes.js.map +1 -1
  101. package/dist/types/viemTypes.d.cts +1 -1
  102. package/dist/types/viemTypes.d.ts +1 -1
  103. package/dist/utils/balanceValue.cjs.map +1 -1
  104. package/dist/utils/balanceValue.d.cts +5 -5
  105. package/dist/utils/balanceValue.d.ts +5 -5
  106. package/dist/utils/balanceValue.js.map +1 -1
  107. package/dist/utils/bytes32.d.cts +1 -1
  108. package/dist/utils/bytes32.d.ts +1 -1
  109. package/dist/utils/bytes32.test.cjs +2 -2
  110. package/dist/utils/bytes32.test.cjs.map +1 -1
  111. package/dist/utils/bytes32.test.js +1 -1
  112. package/dist/utils/createDeterministicLinkedSignerPrivateKey.cjs.map +1 -1
  113. package/dist/utils/createDeterministicLinkedSignerPrivateKey.js.map +1 -1
  114. package/dist/utils/index.cjs +12 -12
  115. package/dist/utils/index.cjs.map +1 -1
  116. package/dist/utils/index.d.cts +22 -22
  117. package/dist/utils/index.d.ts +22 -22
  118. package/dist/utils/index.js +6 -6
  119. package/dist/utils/index.js.map +1 -1
  120. package/dist/utils/interest.cjs +9 -9
  121. package/dist/utils/interest.cjs.map +1 -1
  122. package/dist/utils/interest.d.cts +8 -8
  123. package/dist/utils/interest.d.ts +8 -8
  124. package/dist/utils/interest.js +10 -14
  125. package/dist/utils/interest.js.map +1 -1
  126. package/dist/utils/math/{BigDecimals.cjs → BigNumbers.cjs} +13 -13
  127. package/dist/utils/math/BigNumbers.cjs.map +1 -0
  128. package/dist/utils/math/BigNumbers.d.cts +10 -0
  129. package/dist/utils/math/BigNumbers.d.ts +10 -0
  130. package/dist/utils/math/BigNumbers.js +14 -0
  131. package/dist/utils/math/BigNumbers.js.map +1 -0
  132. package/dist/utils/math/{bigDecimal.cjs → bigNumber.cjs} +12 -14
  133. package/dist/utils/math/bigNumber.cjs.map +1 -0
  134. package/dist/utils/math/bigNumber.d.cts +17 -0
  135. package/dist/utils/math/bigNumber.d.ts +17 -0
  136. package/dist/utils/math/bigNumber.js +22 -0
  137. package/dist/utils/math/bigNumber.js.map +1 -0
  138. package/dist/utils/math/clamp.cjs +3 -3
  139. package/dist/utils/math/clamp.cjs.map +1 -1
  140. package/dist/utils/math/clamp.d.cts +5 -5
  141. package/dist/utils/math/clamp.d.ts +5 -5
  142. package/dist/utils/math/clamp.js +2 -2
  143. package/dist/utils/math/clamp.js.map +1 -1
  144. package/dist/utils/math/decimalAdjustment.cjs +5 -5
  145. package/dist/utils/math/decimalAdjustment.cjs.map +1 -1
  146. package/dist/utils/math/decimalAdjustment.d.cts +6 -6
  147. package/dist/utils/math/decimalAdjustment.d.ts +6 -6
  148. package/dist/utils/math/decimalAdjustment.js +5 -5
  149. package/dist/utils/math/decimalAdjustment.js.map +1 -1
  150. package/dist/utils/math/index.cjs +10 -10
  151. package/dist/utils/math/index.cjs.map +1 -1
  152. package/dist/utils/math/index.d.cts +7 -7
  153. package/dist/utils/math/index.d.ts +7 -7
  154. package/dist/utils/math/index.js +5 -5
  155. package/dist/utils/math/index.js.map +1 -1
  156. package/dist/utils/math/{sumBigDecimalBy.cjs → sumBigNumberBy.cjs} +10 -10
  157. package/dist/utils/math/sumBigNumberBy.cjs.map +1 -0
  158. package/dist/utils/math/sumBigNumberBy.d.cts +10 -0
  159. package/dist/utils/math/sumBigNumberBy.d.ts +10 -0
  160. package/dist/utils/math/sumBigNumberBy.js +13 -0
  161. package/dist/utils/math/sumBigNumberBy.js.map +1 -0
  162. package/dist/utils/math/toBigInt.cjs.map +1 -1
  163. package/dist/utils/math/toBigInt.d.cts +3 -3
  164. package/dist/utils/math/toBigInt.d.ts +3 -3
  165. package/dist/utils/math/toBigInt.js.map +1 -1
  166. package/dist/utils/math/toIntegerString.cjs +2 -2
  167. package/dist/utils/math/toIntegerString.cjs.map +1 -1
  168. package/dist/utils/math/toIntegerString.d.cts +3 -3
  169. package/dist/utils/math/toIntegerString.d.ts +3 -3
  170. package/dist/utils/math/toIntegerString.js +2 -2
  171. package/dist/utils/math/toIntegerString.js.map +1 -1
  172. package/dist/utils/orders/appendix/appendixIsolatedValue.cjs +50 -0
  173. package/dist/utils/orders/appendix/appendixIsolatedValue.cjs.map +1 -0
  174. package/dist/utils/orders/appendix/appendixIsolatedValue.d.cts +26 -0
  175. package/dist/utils/orders/appendix/appendixIsolatedValue.d.ts +26 -0
  176. package/dist/utils/orders/appendix/appendixIsolatedValue.js +31 -0
  177. package/dist/utils/orders/appendix/appendixIsolatedValue.js.map +1 -0
  178. package/dist/utils/orders/appendix/appendixTwapValue.cjs +3 -4
  179. package/dist/utils/orders/appendix/appendixTwapValue.cjs.map +1 -1
  180. package/dist/utils/orders/appendix/appendixTwapValue.d.cts +12 -14
  181. package/dist/utils/orders/appendix/appendixTwapValue.d.ts +12 -14
  182. package/dist/utils/orders/appendix/appendixTwapValue.js +3 -4
  183. package/dist/utils/orders/appendix/appendixTwapValue.js.map +1 -1
  184. package/dist/utils/orders/appendix/index.cjs +4 -4
  185. package/dist/utils/orders/appendix/index.cjs.map +1 -1
  186. package/dist/utils/orders/appendix/index.d.cts +3 -3
  187. package/dist/utils/orders/appendix/index.d.ts +3 -3
  188. package/dist/utils/orders/appendix/index.js +2 -2
  189. package/dist/utils/orders/appendix/index.js.map +1 -1
  190. package/dist/utils/orders/appendix/orderAppendix.test.cjs +67 -14
  191. package/dist/utils/orders/appendix/orderAppendix.test.cjs.map +1 -1
  192. package/dist/utils/orders/appendix/orderAppendix.test.js +66 -13
  193. package/dist/utils/orders/appendix/orderAppendix.test.js.map +1 -1
  194. package/dist/utils/orders/appendix/packOrderAppendix.cjs +9 -5
  195. package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -1
  196. package/dist/utils/orders/appendix/packOrderAppendix.d.cts +1 -1
  197. package/dist/utils/orders/appendix/packOrderAppendix.d.ts +1 -1
  198. package/dist/utils/orders/appendix/packOrderAppendix.js +9 -5
  199. package/dist/utils/orders/appendix/packOrderAppendix.js.map +1 -1
  200. package/dist/utils/orders/appendix/types.cjs.map +1 -1
  201. package/dist/utils/orders/appendix/types.d.cts +6 -4
  202. package/dist/utils/orders/appendix/types.d.ts +6 -4
  203. package/dist/utils/orders/appendix/unpackOrderAppendix.cjs +22 -5
  204. package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -1
  205. package/dist/utils/orders/appendix/unpackOrderAppendix.d.cts +2 -2
  206. package/dist/utils/orders/appendix/unpackOrderAppendix.d.ts +2 -2
  207. package/dist/utils/orders/appendix/unpackOrderAppendix.js +22 -5
  208. package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -1
  209. package/dist/utils/orders/index.cjs +3 -3
  210. package/dist/utils/orders/index.cjs.map +1 -1
  211. package/dist/utils/orders/index.d.cts +5 -5
  212. package/dist/utils/orders/index.d.ts +5 -5
  213. package/dist/utils/orders/index.js +1 -1
  214. package/dist/utils/orders/index.js.map +1 -1
  215. package/dist/utils/productTypeFilter.cjs.map +1 -1
  216. package/dist/utils/productTypeFilter.d.cts +2 -2
  217. package/dist/utils/productTypeFilter.d.ts +2 -2
  218. package/dist/utils/productTypeFilter.js.map +1 -1
  219. package/dist/utils/toPrintableObject.cjs +29 -11
  220. package/dist/utils/toPrintableObject.cjs.map +1 -1
  221. package/dist/utils/toPrintableObject.d.cts +7 -2
  222. package/dist/utils/toPrintableObject.d.ts +7 -2
  223. package/dist/utils/toPrintableObject.js +19 -11
  224. package/dist/utils/toPrintableObject.js.map +1 -1
  225. package/package.json +14 -7
  226. package/src/abis/index.ts +6 -6
  227. package/src/consts/chainEnvToChain.ts +2 -2
  228. package/src/consts/productIds.ts +1 -1
  229. package/src/deployments/core/deployment.inkMainnet.json +13 -0
  230. package/src/deployments/core/deployment.inkSepolia.json +13 -0
  231. package/src/deployments/index.ts +5 -5
  232. package/src/eip712/eip712ValueTypes.ts +2 -2
  233. package/src/eip712/getNadoEIP712Domain.ts +1 -1
  234. package/src/eip712/index.ts +6 -6
  235. package/src/eip712/signatureParamTypes.ts +13 -13
  236. package/src/encoding/encoding.ts +43 -1
  237. package/src/execute/approveDepositAllowance.ts +2 -2
  238. package/src/execute/depositCollateral.ts +2 -2
  239. package/src/types/ChainEnv.ts +1 -1
  240. package/src/types/balanceTypes.ts +4 -4
  241. package/src/types/healthTypes.ts +4 -4
  242. package/src/types/index.ts +3 -3
  243. package/src/types/marketTypes.ts +4 -4
  244. package/src/types/orderAppendixTypes.ts +27 -2
  245. package/src/types/productTypes.ts +16 -16
  246. package/src/utils/balanceValue.ts +4 -4
  247. package/src/utils/createDeterministicLinkedSignerPrivateKey.ts +1 -1
  248. package/src/utils/index.ts +6 -6
  249. package/src/utils/interest.ts +26 -31
  250. package/src/utils/math/BigNumbers.ts +8 -0
  251. package/src/utils/math/bigNumber.ts +31 -0
  252. package/src/utils/math/clamp.ts +4 -7
  253. package/src/utils/math/decimalAdjustment.ts +11 -10
  254. package/src/utils/math/index.ts +5 -5
  255. package/src/utils/math/sumBigNumberBy.ts +18 -0
  256. package/src/utils/math/toBigInt.ts +3 -3
  257. package/src/utils/math/toIntegerString.ts +4 -4
  258. package/src/utils/orders/appendix/appendixIsolatedValue.ts +49 -0
  259. package/src/utils/orders/appendix/appendixTwapValue.ts +14 -19
  260. package/src/utils/orders/appendix/index.ts +2 -2
  261. package/src/utils/orders/appendix/orderAppendix.test.ts +68 -11
  262. package/src/utils/orders/appendix/packOrderAppendix.ts +10 -6
  263. package/src/utils/orders/appendix/types.ts +9 -7
  264. package/src/utils/orders/appendix/unpackOrderAppendix.ts +24 -7
  265. package/src/utils/orders/index.ts +1 -1
  266. package/src/utils/productTypeFilter.ts +2 -2
  267. package/src/utils/toPrintableObject.ts +32 -12
  268. package/dist/chunk-TUJ4HQKF.js.map +0 -1
  269. package/dist/deployments/core/deployment.InkSepolia.json +0 -13
  270. package/dist/deployments/core/deployment.arbitrumOne.json +0 -18
  271. package/dist/utils/math/BigDecimals.cjs.map +0 -1
  272. package/dist/utils/math/BigDecimals.d.cts +0 -8
  273. package/dist/utils/math/BigDecimals.d.ts +0 -8
  274. package/dist/utils/math/BigDecimals.js +0 -14
  275. package/dist/utils/math/BigDecimals.js.map +0 -1
  276. package/dist/utils/math/bigDecimal.cjs.map +0 -1
  277. package/dist/utils/math/bigDecimal.d.cts +0 -18
  278. package/dist/utils/math/bigDecimal.d.ts +0 -18
  279. package/dist/utils/math/bigDecimal.js +0 -23
  280. package/dist/utils/math/bigDecimal.js.map +0 -1
  281. package/dist/utils/math/sumBigDecimalBy.cjs.map +0 -1
  282. package/dist/utils/math/sumBigDecimalBy.d.cts +0 -10
  283. package/dist/utils/math/sumBigDecimalBy.d.ts +0 -10
  284. package/dist/utils/math/sumBigDecimalBy.js +0 -13
  285. package/dist/utils/math/sumBigDecimalBy.js.map +0 -1
  286. package/src/deployments/core/deployment.InkSepolia.json +0 -13
  287. package/src/deployments/core/deployment.arbitrumOne.json +0 -18
  288. package/src/utils/math/BigDecimals.ts +0 -8
  289. package/src/utils/math/bigDecimal.ts +0 -32
  290. package/src/utils/math/sumBigDecimalBy.ts +0 -18
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/orders/appendix/appendixIsolatedValue.ts
21
+ var appendixIsolatedValue_exports = {};
22
+ __export(appendixIsolatedValue_exports, {
23
+ packIsolatedOrderAppendixValue: () => packIsolatedOrderAppendixValue,
24
+ unpackIsolatedOrderAppendixValue: () => unpackIsolatedOrderAppendixValue
25
+ });
26
+ module.exports = __toCommonJS(appendixIsolatedValue_exports);
27
+ var import_math = require("../../math/index.cjs");
28
+ var import_bitMaskValue = require("./bitMaskValue.cjs");
29
+ var APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;
30
+ var MARGIN_DECIMAL_ADJUSTMENT = import_math.NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;
31
+ function packIsolatedOrderAppendixValue({
32
+ margin
33
+ }) {
34
+ return (0, import_bitMaskValue.bitMaskValue)(
35
+ (0, import_math.toBigInt)((0, import_math.removeDecimals)(margin, MARGIN_DECIMAL_ADJUSTMENT)),
36
+ 64
37
+ );
38
+ }
39
+ function unpackIsolatedOrderAppendixValue(value) {
40
+ const margin = (0, import_bitMaskValue.bitMaskValue)(value, 64);
41
+ return {
42
+ margin: (0, import_math.toBigInt)((0, import_math.addDecimals)(margin, MARGIN_DECIMAL_ADJUSTMENT))
43
+ };
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ packIsolatedOrderAppendixValue,
48
+ unpackIsolatedOrderAppendixValue
49
+ });
50
+ //# sourceMappingURL=appendixIsolatedValue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixIsolatedValue.ts"],"sourcesContent":["import { OrderAppendixIsolatedFields } from '../../../types';\nimport {\n addDecimals,\n NADO_PRODUCT_DECIMALS,\n removeDecimals,\n toBigInt,\n} from '../../math';\nimport { bitMaskValue } from './bitMaskValue';\n\nconst APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;\n\n/* Appendix v1 uses x6 precision, so we need to adjust precision to/from SDK's usual precision */\nconst MARGIN_DECIMAL_ADJUSTMENT =\n NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;\n\n/**\n * Packs the provided margin into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | margin_x6 |\n * |-----------|\n * | 63..0 |\n * | 64 bits |\n *\n */\nexport function packIsolatedOrderAppendixValue({\n margin,\n}: OrderAppendixIsolatedFields): bigint {\n return bitMaskValue(\n toBigInt(removeDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n 64,\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for Isolated orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - margin_x6: bigint, from bits 63..0\n */\nexport function unpackIsolatedOrderAppendixValue(\n value: bigint,\n): OrderAppendixIsolatedFields {\n const margin = bitMaskValue(value, 64);\n return {\n margin: toBigInt(addDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAKO;AACP,0BAA6B;AAE7B,IAAM,kCAAkC;AAGxC,IAAM,4BACJ,oCAAwB;AAYnB,SAAS,+BAA+B;AAAA,EAC7C;AACF,GAAwC;AACtC,aAAO;AAAA,QACL,0BAAS,4BAAe,QAAQ,yBAAyB,CAAC;AAAA,IAC1D;AAAA,EACF;AACF;AASO,SAAS,iCACd,OAC6B;AAC7B,QAAM,aAAS,kCAAa,OAAO,EAAE;AACrC,SAAO;AAAA,IACL,YAAQ,0BAAS,yBAAY,QAAQ,yBAAyB,CAAC;AAAA,EACjE;AACF;","names":[]}
@@ -0,0 +1,26 @@
1
+ import { OrderAppendixIsolatedFields } from '../../../types/orderAppendixTypes.cjs';
2
+ import '../../math/bigNumber.cjs';
3
+ import 'bignumber.js';
4
+ import '../../../types/OrderExecutionType.cjs';
5
+
6
+ /**
7
+ * Packs the provided margin into a single 64-bit bigint.
8
+ *
9
+ * Bit layout (MSB → LSB):
10
+ * | margin_x6 |
11
+ * |-----------|
12
+ * | 63..0 |
13
+ * | 64 bits |
14
+ *
15
+ */
16
+ declare function packIsolatedOrderAppendixValue({ margin, }: OrderAppendixIsolatedFields): bigint;
17
+ /**
18
+ * Unpacks a 64-bit bigint into its component fields for Isolated orders.
19
+ *
20
+ * @param value 64-bit bigint to unpack
21
+ * @returns Object with:
22
+ * - margin_x6: bigint, from bits 63..0
23
+ */
24
+ declare function unpackIsolatedOrderAppendixValue(value: bigint): OrderAppendixIsolatedFields;
25
+
26
+ export { packIsolatedOrderAppendixValue, unpackIsolatedOrderAppendixValue };
@@ -0,0 +1,26 @@
1
+ import { OrderAppendixIsolatedFields } from '../../../types/orderAppendixTypes.js';
2
+ import '../../math/bigNumber.js';
3
+ import 'bignumber.js';
4
+ import '../../../types/OrderExecutionType.js';
5
+
6
+ /**
7
+ * Packs the provided margin into a single 64-bit bigint.
8
+ *
9
+ * Bit layout (MSB → LSB):
10
+ * | margin_x6 |
11
+ * |-----------|
12
+ * | 63..0 |
13
+ * | 64 bits |
14
+ *
15
+ */
16
+ declare function packIsolatedOrderAppendixValue({ margin, }: OrderAppendixIsolatedFields): bigint;
17
+ /**
18
+ * Unpacks a 64-bit bigint into its component fields for Isolated orders.
19
+ *
20
+ * @param value 64-bit bigint to unpack
21
+ * @returns Object with:
22
+ * - margin_x6: bigint, from bits 63..0
23
+ */
24
+ declare function unpackIsolatedOrderAppendixValue(value: bigint): OrderAppendixIsolatedFields;
25
+
26
+ export { packIsolatedOrderAppendixValue, unpackIsolatedOrderAppendixValue };
@@ -0,0 +1,31 @@
1
+ import "../../../chunk-5WRI5ZAA.js";
2
+
3
+ // src/utils/orders/appendix/appendixIsolatedValue.ts
4
+ import {
5
+ addDecimals,
6
+ NADO_PRODUCT_DECIMALS,
7
+ removeDecimals,
8
+ toBigInt
9
+ } from "../../math/index.js";
10
+ import { bitMaskValue } from "./bitMaskValue.js";
11
+ var APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;
12
+ var MARGIN_DECIMAL_ADJUSTMENT = NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;
13
+ function packIsolatedOrderAppendixValue({
14
+ margin
15
+ }) {
16
+ return bitMaskValue(
17
+ toBigInt(removeDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),
18
+ 64
19
+ );
20
+ }
21
+ function unpackIsolatedOrderAppendixValue(value) {
22
+ const margin = bitMaskValue(value, 64);
23
+ return {
24
+ margin: toBigInt(addDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT))
25
+ };
26
+ }
27
+ export {
28
+ packIsolatedOrderAppendixValue,
29
+ unpackIsolatedOrderAppendixValue
30
+ };
31
+ //# sourceMappingURL=appendixIsolatedValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixIsolatedValue.ts"],"sourcesContent":["import { OrderAppendixIsolatedFields } from '../../../types';\nimport {\n addDecimals,\n NADO_PRODUCT_DECIMALS,\n removeDecimals,\n toBigInt,\n} from '../../math';\nimport { bitMaskValue } from './bitMaskValue';\n\nconst APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;\n\n/* Appendix v1 uses x6 precision, so we need to adjust precision to/from SDK's usual precision */\nconst MARGIN_DECIMAL_ADJUSTMENT =\n NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;\n\n/**\n * Packs the provided margin into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | margin_x6 |\n * |-----------|\n * | 63..0 |\n * | 64 bits |\n *\n */\nexport function packIsolatedOrderAppendixValue({\n margin,\n}: OrderAppendixIsolatedFields): bigint {\n return bitMaskValue(\n toBigInt(removeDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n 64,\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for Isolated orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - margin_x6: bigint, from bits 63..0\n */\nexport function unpackIsolatedOrderAppendixValue(\n value: bigint,\n): OrderAppendixIsolatedFields {\n const margin = bitMaskValue(value, 64);\n return {\n margin: toBigInt(addDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n };\n}\n"],"mappings":";;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAE7B,IAAM,kCAAkC;AAGxC,IAAM,4BACJ,wBAAwB;AAYnB,SAAS,+BAA+B;AAAA,EAC7C;AACF,GAAwC;AACtC,SAAO;AAAA,IACL,SAAS,eAAe,QAAQ,yBAAyB,CAAC;AAAA,IAC1D;AAAA,EACF;AACF;AASO,SAAS,iCACd,OAC6B;AAC7B,QAAM,SAAS,aAAa,OAAO,EAAE;AACrC,SAAO;AAAA,IACL,QAAQ,SAAS,YAAY,QAAQ,yBAAyB,CAAC;AAAA,EACjE;AACF;","names":[]}
@@ -31,12 +31,11 @@ function packTwapOrderAppendixValue({
31
31
  }) {
32
32
  const numOrdersBigInt = (0, import_math.toBigInt)(numOrders);
33
33
  const slippageX6BigInt = (0, import_math.toBigInt)((0, import_math.addDecimals)(slippageFrac, 6));
34
- return (numOrdersBigInt & 0xffffffffn) << 64n | (slippageX6BigInt & 0xffffffffn) << 32n | // The last reserved 32 bits are set to 0
35
- 0n & 0xffffffffn;
34
+ return (numOrdersBigInt & 0xffffffffn) << 32n | slippageX6BigInt & 0xffffffffn;
36
35
  }
37
36
  function unpackTwapOrderAppendixValue(value) {
38
- const numOrders = value >> 64n & 0xffffffffn;
39
- const slippageX6 = value >> 32n & 0xffffffffn;
37
+ const numOrders = value >> 32n & 0xffffffffn;
38
+ const slippageX6 = value & 0xffffffffn;
40
39
  return {
41
40
  numOrders: Number(numOrders),
42
41
  slippageFrac: (0, import_math.removeDecimals)(slippageX6, 6).toNumber()
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsD;AAe/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,sBAAkB,sBAAS,SAAS;AAC1C,QAAM,uBAAmB,0BAAS,yBAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,kBAAc,4BAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 |\n * |-----------|-------------|\n * | 63..32 | 31..0 |\n * | 32 bits | 32 bits |\n *\n * - `times` occupies bits 63..32 (most significant 32 bits)\n * - `slippage_x6` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 32n) | (slippageX6BigInt & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for TWAP orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 63..32\n * - slippage_x6: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 32n) & 0xffffffffn;\n const slippageX6 = value & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsD;AAc/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,sBAAkB,sBAAS,SAAS;AAC1C,QAAM,uBAAmB,0BAAS,yBAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,MAAQ,mBAAmB;AAEnE;AAUO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAa,QAAQ;AAE3B,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,kBAAc,4BAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
@@ -1,30 +1,28 @@
1
1
  import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes.cjs';
2
- import '../../math/bigDecimal.cjs';
2
+ import '../../math/bigNumber.cjs';
3
3
  import 'bignumber.js';
4
4
  import '../../../types/OrderExecutionType.cjs';
5
5
 
6
6
  /**
7
- * Packs the provided fields into a single 96-bit bigint.
7
+ * Packs the provided fields into a single 64-bit bigint.
8
8
  *
9
9
  * Bit layout (MSB → LSB):
10
- * | times | slippage_x6 | reserved |
11
- * |-----------|-------------|----------|
12
- * | 95..64 | 63..32 | 31..0 |
13
- * | 32 bits | 32 bits | 32 bits |
10
+ * | times | slippage_x6 |
11
+ * |-----------|-------------|
12
+ * | 63..32 | 31..0 |
13
+ * | 32 bits | 32 bits |
14
14
  *
15
- * - `times` occupies bits 95..64 (most significant 32 bits)
16
- * - `slippage_x6` occupies bits 63..32 (middle 32 bits)
17
- * - `reserved` occupies bits 31..0 (least significant 32 bits)
15
+ * - `times` occupies bits 63..32 (most significant 32 bits)
16
+ * - `slippage_x6` occupies bits 31..0 (least significant 32 bits)
18
17
  */
19
18
  declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
20
19
  /**
21
- * Unpacks a 96-bit bigint into its component fields for TWAP orders.
20
+ * Unpacks a 64-bit bigint into its component fields for TWAP orders.
22
21
  *
23
- * @param value 96-bit bigint to unpack
22
+ * @param value 64-bit bigint to unpack
24
23
  * @returns Object with:
25
- * - times: number, from bits 95..64
26
- * - slippage_x6: number, from bits 63..32
27
- * - reserved: number, from bits 31..0
24
+ * - times: number, from bits 63..32
25
+ * - slippage_x6: number, from bits 31..0
28
26
  */
29
27
  declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
30
28
 
@@ -1,30 +1,28 @@
1
1
  import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes.js';
2
- import '../../math/bigDecimal.js';
2
+ import '../../math/bigNumber.js';
3
3
  import 'bignumber.js';
4
4
  import '../../../types/OrderExecutionType.js';
5
5
 
6
6
  /**
7
- * Packs the provided fields into a single 96-bit bigint.
7
+ * Packs the provided fields into a single 64-bit bigint.
8
8
  *
9
9
  * Bit layout (MSB → LSB):
10
- * | times | slippage_x6 | reserved |
11
- * |-----------|-------------|----------|
12
- * | 95..64 | 63..32 | 31..0 |
13
- * | 32 bits | 32 bits | 32 bits |
10
+ * | times | slippage_x6 |
11
+ * |-----------|-------------|
12
+ * | 63..32 | 31..0 |
13
+ * | 32 bits | 32 bits |
14
14
  *
15
- * - `times` occupies bits 95..64 (most significant 32 bits)
16
- * - `slippage_x6` occupies bits 63..32 (middle 32 bits)
17
- * - `reserved` occupies bits 31..0 (least significant 32 bits)
15
+ * - `times` occupies bits 63..32 (most significant 32 bits)
16
+ * - `slippage_x6` occupies bits 31..0 (least significant 32 bits)
18
17
  */
19
18
  declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
20
19
  /**
21
- * Unpacks a 96-bit bigint into its component fields for TWAP orders.
20
+ * Unpacks a 64-bit bigint into its component fields for TWAP orders.
22
21
  *
23
- * @param value 96-bit bigint to unpack
22
+ * @param value 64-bit bigint to unpack
24
23
  * @returns Object with:
25
- * - times: number, from bits 95..64
26
- * - slippage_x6: number, from bits 63..32
27
- * - reserved: number, from bits 31..0
24
+ * - times: number, from bits 63..32
25
+ * - slippage_x6: number, from bits 31..0
28
26
  */
29
27
  declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
30
28
 
@@ -8,12 +8,11 @@ function packTwapOrderAppendixValue({
8
8
  }) {
9
9
  const numOrdersBigInt = toBigInt(numOrders);
10
10
  const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));
11
- return (numOrdersBigInt & 0xffffffffn) << 64n | (slippageX6BigInt & 0xffffffffn) << 32n | // The last reserved 32 bits are set to 0
12
- 0n & 0xffffffffn;
11
+ return (numOrdersBigInt & 0xffffffffn) << 32n | slippageX6BigInt & 0xffffffffn;
13
12
  }
14
13
  function unpackTwapOrderAppendixValue(value) {
15
- const numOrders = value >> 64n & 0xffffffffn;
16
- const slippageX6 = value >> 32n & 0xffffffffn;
14
+ const numOrders = value >> 32n & 0xffffffffn;
15
+ const slippageX6 = value & 0xffffffffn;
17
16
  return {
18
17
  numOrders: Number(numOrders),
19
18
  slippageFrac: removeDecimals(slippageX6, 6).toNumber()
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;AACA,SAAS,aAAa,gBAAgB,gBAAgB;AAe/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,kBAAkB,SAAS,SAAS;AAC1C,QAAM,mBAAmB,SAAS,YAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,cAAc,eAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 |\n * |-----------|-------------|\n * | 63..32 | 31..0 |\n * | 32 bits | 32 bits |\n *\n * - `times` occupies bits 63..32 (most significant 32 bits)\n * - `slippage_x6` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 32n) | (slippageX6BigInt & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for TWAP orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 63..32\n * - slippage_x6: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 32n) & 0xffffffffn;\n const slippageX6 = value & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;AACA,SAAS,aAAa,gBAAgB,gBAAgB;AAc/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,kBAAkB,SAAS,SAAS;AAC1C,QAAM,mBAAmB,SAAS,YAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,MAAQ,mBAAmB;AAEnE;AAUO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAa,QAAQ;AAE3B,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,cAAc,eAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
@@ -18,16 +18,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
18
18
  var appendix_exports = {};
19
19
  module.exports = __toCommonJS(appendix_exports);
20
20
  __reExport(appendix_exports, require("./appendixTwapValue.cjs"), module.exports);
21
- __reExport(appendix_exports, require("./unpackOrderAppendix.cjs"), module.exports);
21
+ __reExport(appendix_exports, require("./bitMaskValue.cjs"), module.exports);
22
22
  __reExport(appendix_exports, require("./packOrderAppendix.cjs"), module.exports);
23
23
  __reExport(appendix_exports, require("./types.cjs"), module.exports);
24
- __reExport(appendix_exports, require("./bitMaskValue.cjs"), module.exports);
24
+ __reExport(appendix_exports, require("./unpackOrderAppendix.cjs"), module.exports);
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  ...require("./appendixTwapValue.cjs"),
28
- ...require("./unpackOrderAppendix.cjs"),
28
+ ...require("./bitMaskValue.cjs"),
29
29
  ...require("./packOrderAppendix.cjs"),
30
30
  ...require("./types.cjs"),
31
- ...require("./bitMaskValue.cjs")
31
+ ...require("./unpackOrderAppendix.cjs")
32
32
  });
33
33
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,oCAAd;AACA,6BAAc,sCADd;AAEA,6BAAc,oCAFd;AAGA,6BAAc,wBAHd;AAIA,6BAAc,+BAJd;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './bitMaskValue';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './unpackOrderAppendix';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,oCAAd;AACA,6BAAc,+BADd;AAEA,6BAAc,oCAFd;AAGA,6BAAc,wBAHd;AAIA,6BAAc,sCAJd;","names":[]}
@@ -1,9 +1,9 @@
1
1
  export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendixTwapValue.cjs';
2
- export { unpackOrderAppendix } from './unpackOrderAppendix.cjs';
2
+ export { bitMaskValue } from './bitMaskValue.cjs';
3
3
  export { packOrderAppendix } from './packOrderAppendix.cjs';
4
4
  export { PackedOrderAppendixBits } from './types.cjs';
5
- export { bitMaskValue } from './bitMaskValue.cjs';
5
+ export { unpackOrderAppendix } from './unpackOrderAppendix.cjs';
6
6
  import '../../../types/orderAppendixTypes.cjs';
7
- import '../../math/bigDecimal.cjs';
7
+ import '../../math/bigNumber.cjs';
8
8
  import 'bignumber.js';
9
9
  import '../../../types/OrderExecutionType.cjs';
@@ -1,9 +1,9 @@
1
1
  export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendixTwapValue.js';
2
- export { unpackOrderAppendix } from './unpackOrderAppendix.js';
2
+ export { bitMaskValue } from './bitMaskValue.js';
3
3
  export { packOrderAppendix } from './packOrderAppendix.js';
4
4
  export { PackedOrderAppendixBits } from './types.js';
5
- export { bitMaskValue } from './bitMaskValue.js';
5
+ export { unpackOrderAppendix } from './unpackOrderAppendix.js';
6
6
  import '../../../types/orderAppendixTypes.js';
7
- import '../../math/bigDecimal.js';
7
+ import '../../math/bigNumber.js';
8
8
  import 'bignumber.js';
9
9
  import '../../../types/OrderExecutionType.js';
@@ -1,7 +1,7 @@
1
1
  // src/utils/orders/appendix/index.ts
2
2
  export * from "./appendixTwapValue.js";
3
- export * from "./unpackOrderAppendix.js";
3
+ export * from "./bitMaskValue.js";
4
4
  export * from "./packOrderAppendix.js";
5
5
  export * from "./types.js";
6
- export * from "./bitMaskValue.js";
6
+ export * from "./unpackOrderAppendix.js";
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './bitMaskValue';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './unpackOrderAppendix';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -25,9 +25,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
 
28
- // ../../node_modules/@jest/globals/build/index.js
28
+ // ../../node_modules/.bun/@jest+globals@30.2.0/node_modules/@jest/globals/build/index.js
29
29
  var require_build = __commonJS({
30
- "../../node_modules/@jest/globals/build/index.js"(exports2, module2) {
30
+ "../../node_modules/.bun/@jest+globals@30.2.0/node_modules/@jest/globals/build/index.js"(exports2, module2) {
31
31
  "use strict";
32
32
  (() => {
33
33
  "use strict";
@@ -50,7 +50,7 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
50
50
  };
51
51
  const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
52
52
  const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
53
- (0, import_globals.expect)(packed).toBe(4096n);
53
+ (0, import_globals.expect)(packed).toBe(4097n);
54
54
  (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
55
55
  (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
56
56
  (0, import_globals.expect)(unpacked.reduceOnly).toBeFalsy();
@@ -63,7 +63,7 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
63
63
  };
64
64
  const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
65
65
  const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
66
- (0, import_globals.expect)(packed).toBe(6144n);
66
+ (0, import_globals.expect)(packed).toBe(6145n);
67
67
  (0, import_globals.expect)(unpacked.reduceOnly).toBe(true);
68
68
  });
69
69
  (0, import_globals.it)("should handle all orderExecutionType values", () => {
@@ -94,12 +94,12 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
94
94
  const appendix = {
95
95
  orderExecutionType: "default",
96
96
  triggerType: "price",
97
- isolated: { margin: 123456789012345678901234n }
97
+ isolated: { margin: 12345678901000000000000n }
98
98
  };
99
99
  const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
100
100
  const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
101
- (0, import_globals.expect)(packed).toBe(530242871277196831127717244047616n);
102
- (0, import_globals.expect)(unpacked.isolated?.margin).toBe(123456789012345678901234n);
101
+ (0, import_globals.expect)(packed).toBe(227737579102942800187821658369n);
102
+ (0, import_globals.expect)(unpacked.isolated?.margin).toBe(appendix.isolated?.margin);
103
103
  });
104
104
  (0, import_globals.it)("should handle TWAP fields", () => {
105
105
  const appendix = {
@@ -109,7 +109,7 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
109
109
  };
110
110
  const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
111
111
  const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
112
- (0, import_globals.expect)(packed).toBe(792281717376363744483197591552n);
112
+ (0, import_globals.expect)(packed).toBe(792281717376363744483197591553n);
113
113
  (0, import_globals.expect)(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 5e-3 });
114
114
  });
115
115
  (0, import_globals.it)("should handle max values for all fields for iso orders", () => {
@@ -117,17 +117,17 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
117
117
  orderExecutionType: "post_only",
118
118
  triggerType: void 0,
119
119
  reduceOnly: true,
120
- isolated: { margin: 79228162514264337593543950335n }
121
- // 2^96-1
120
+ isolated: { margin: 18446744073709551615n }
121
+ // 2^64-1
122
122
  };
123
123
  const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
124
124
  const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
125
125
  (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
126
126
  (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
127
127
  (0, import_globals.expect)(unpacked.reduceOnly).toBe(appendix.reduceOnly);
128
- (0, import_globals.expect)(unpacked.isolated?.margin).toBe(79228162514264337593543950335n);
128
+ (0, import_globals.expect)(unpacked.isolated?.margin).toBe(18446744000000000000n);
129
129
  (0, import_globals.expect)(unpacked.twap).toBe(void 0);
130
- (0, import_globals.expect)(packed).toBe(340282366920938463463374607427473248000n);
130
+ (0, import_globals.expect)(packed).toBe(340282365561237229015142145n);
131
131
  });
132
132
  (0, import_globals.it)("should handle max values for all fields for TWAP orders", () => {
133
133
  const appendix = {
@@ -135,7 +135,6 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
135
135
  triggerType: "twap_custom_amounts",
136
136
  reduceOnly: true,
137
137
  twap: {
138
- // max 32-bit unsigned int
139
138
  numOrders: 4294967295,
140
139
  slippageFrac: 1e-6
141
140
  }
@@ -147,7 +146,61 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
147
146
  (0, import_globals.expect)(unpacked.reduceOnly).toBe(appendix.reduceOnly);
148
147
  (0, import_globals.expect)(unpacked.twap?.slippageFrac).toBe(1e-6);
149
148
  (0, import_globals.expect)(unpacked.twap?.numOrders).toBe(4294967295);
150
- (0, import_globals.expect)(packed).toBe(340282366841710300967557013911933828608n);
149
+ (0, import_globals.expect)(packed).toBe(340282366841710300967557013911933828609n);
150
+ });
151
+ (0, import_globals.it)("should handle builder fields", () => {
152
+ const appendix = {
153
+ orderExecutionType: "default",
154
+ builder: { builderId: 123, builderFeeRate: 500 }
155
+ };
156
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
157
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
158
+ (0, import_globals.expect)(unpacked.builder?.builderId).toBe(123);
159
+ (0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(500);
160
+ });
161
+ (0, import_globals.it)("should handle builder with zero fee rate", () => {
162
+ const appendix = {
163
+ orderExecutionType: "default",
164
+ builder: { builderId: 42, builderFeeRate: 0 }
165
+ };
166
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
167
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
168
+ (0, import_globals.expect)(unpacked.builder?.builderId).toBe(42);
169
+ (0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(0);
170
+ });
171
+ (0, import_globals.it)("should handle builder with max values", () => {
172
+ const appendix = {
173
+ orderExecutionType: "default",
174
+ builder: { builderId: 65535, builderFeeRate: 1023 }
175
+ // 16 bits, 10 bits max
176
+ };
177
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
178
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
179
+ (0, import_globals.expect)(unpacked.builder?.builderId).toBe(65535);
180
+ (0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(1023);
181
+ });
182
+ (0, import_globals.it)("should handle builder combined with other flags", () => {
183
+ const appendix = {
184
+ orderExecutionType: "ioc",
185
+ reduceOnly: true,
186
+ triggerType: "price",
187
+ builder: { builderId: 5, builderFeeRate: 100 }
188
+ };
189
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
190
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
191
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe("ioc");
192
+ (0, import_globals.expect)(unpacked.reduceOnly).toBe(true);
193
+ (0, import_globals.expect)(unpacked.triggerType).toBe("price");
194
+ (0, import_globals.expect)(unpacked.builder?.builderId).toBe(5);
195
+ (0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(100);
196
+ });
197
+ (0, import_globals.it)("should not return builder fields when builderId is 0", () => {
198
+ const appendix = {
199
+ orderExecutionType: "default"
200
+ };
201
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
202
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
203
+ (0, import_globals.expect)(unpacked.builder).toBeUndefined();
151
204
  });
152
205
  });
153
206
  /*! Bundled license information:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../node_modules/@jest/globals/build/index.js","../../../../src/utils/orders/appendix/orderAppendix.test.ts"],"sourcesContent":["/*!\n * /**\n * * Copyright (c) Meta Platforms, Inc. and affiliates.\n * *\n * * This source code is licensed under the MIT license found in the\n * * LICENSE file in the root directory of this source tree.\n * * /\n */\n/******/ (() => { // webpackBootstrap\n/******/ \t\"use strict\";\nvar __webpack_exports__ = {};\n\n\n/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\n\nthrow new Error('Do not import `@jest/globals` outside of the Jest test environment');\nmodule.exports = __webpack_exports__;\n/******/ })()\n;","import { describe, expect, it } from '@jest/globals';\nimport { OrderAppendix, OrderExecutionType } from '../../../types';\nimport { packOrderAppendix } from './packOrderAppendix';\nimport { unpackOrderAppendix } from './unpackOrderAppendix';\n\ndescribe('OrderAppendix packing/unpacking', () => {\n it('should pack and unpack an order appendix without iso/twap values', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(4096n);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBeFalsy();\n });\n\n it('should handle reduceOnly true', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n reduceOnly: true,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(6144n);\n expect(unpacked.reduceOnly).toBe(true);\n });\n\n it('should handle all orderExecutionType values', () => {\n const types: OrderExecutionType[] = ['default', 'ioc', 'fok', 'post_only'];\n for (const type of types) {\n const appendix: OrderAppendix = {\n orderExecutionType: type,\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(type);\n }\n });\n\n it('should handle all triggerType values', () => {\n const triggers = ['price', 'twap', 'twap_custom_amounts'] as const;\n for (const trigger of triggers) {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: trigger,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.triggerType).toBe(trigger);\n }\n });\n\n it('should handle isolated margin', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n\n isolated: { margin: 123456789012345678901234n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(530242871277196831127717244047616n);\n expect(unpacked.isolated?.margin).toBe(123456789012345678901234n);\n });\n\n it('should handle TWAP fields', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'twap',\n\n twap: { numOrders: 10, slippageFrac: 0.005 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(792281717376363744483197591552n);\n expect(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 0.005 });\n });\n\n it('should handle max values for all fields for iso orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: undefined,\n reduceOnly: true,\n isolated: { margin: 79228162514264337593543950335n }, // 2^96-1\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.isolated?.margin).toBe(79228162514264337593543950335n);\n expect(unpacked.twap).toBe(undefined);\n expect(packed).toBe(340282366920938463463374607427473248000n);\n });\n\n it('should handle max values for all fields for TWAP orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: 'twap_custom_amounts',\n reduceOnly: true,\n twap: {\n // max 32-bit unsigned int\n numOrders: 4294967295,\n slippageFrac: 0.000001,\n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.twap?.slippageFrac).toBe(0.000001);\n expect(unpacked.twap?.numOrders).toBe(4294967295);\n expect(packed).toBe(340282366841710300967557013911933828608n);\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,oDAAAA,UAA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KAAK,SAAS,WAAW;AACtD,+BAAO,SAAS,UAAU,EAAE,KAAK,SAAS,UAAU;AACpD,+BAAO,SAAS,UAAU,MAAM,EAAE,KAAK,8BAA8B;AACrE,+BAAO,SAAS,IAAI,EAAE,KAAK,MAAS;AACpC,+BAAO,MAAM,EAAE,KAAK,wCAAwC;AAAA,EAC9D,CAAC;AAED,yBAAG,2DAA2D,MAAM;AAClE,UAAM,WAA0B;AAAA,MAC9B,oBAAoB;AAAA,MACpB,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,MAAM;AAAA;AAAA,QAEJ,WAAW;AAAA,QACX,cAAc;AAAA,MAChB;AAAA,IACF;AACA,UAAM,aAAS,4CAAkB,QAAQ;AACzC,UAAM,eAAW,gDAAoB,MAAM;AAC3C,+BAAO,SAAS,kBAAkB,EAAE,KAAK,SAAS,kBAAkB;AACpE,+BAAO,SAAS,WAAW,EAAE,KAAK,SAAS,WAAW;AACtD,+BAAO,SAAS,UAAU,EAAE,KAAK,SAAS,UAAU;AACpD,+BAAO,SAAS,MAAM,YAAY,EAAE,KAAK,IAAQ;AACjD,+BAAO,SAAS,MAAM,SAAS,EAAE,KAAK,UAAU;AAChD,+BAAO,MAAM,EAAE,KAAK,wCAAwC;AAAA,EAC9D,CAAC;AACH,CAAC;","names":["exports","module"]}
1
+ {"version":3,"sources":["../../../../../../node_modules/.bun/@jest+globals@30.2.0/node_modules/@jest/globals/build/index.js","../../../../src/utils/orders/appendix/orderAppendix.test.ts"],"sourcesContent":["/*!\n * /**\n * * Copyright (c) Meta Platforms, Inc. and affiliates.\n * *\n * * This source code is licensed under the MIT license found in the\n * * LICENSE file in the root directory of this source tree.\n * * /\n */\n/******/ (() => { // webpackBootstrap\n/******/ \t\"use strict\";\nvar __webpack_exports__ = {};\n\n\n/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\n\nthrow new Error('Do not import `@jest/globals` outside of the Jest test environment');\nmodule.exports = __webpack_exports__;\n/******/ })()\n;","import { describe, expect, it } from '@jest/globals';\nimport { OrderAppendix, OrderExecutionType } from '../../../types';\nimport { packOrderAppendix } from './packOrderAppendix';\nimport { unpackOrderAppendix } from './unpackOrderAppendix';\n\ndescribe('OrderAppendix packing/unpacking', () => {\n it('should pack and unpack an order appendix without iso/twap values', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(4097n);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBeFalsy();\n });\n\n it('should handle reduceOnly true', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n reduceOnly: true,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(6145n);\n expect(unpacked.reduceOnly).toBe(true);\n });\n\n it('should handle all orderExecutionType values', () => {\n const types: OrderExecutionType[] = ['default', 'ioc', 'fok', 'post_only'];\n for (const type of types) {\n const appendix: OrderAppendix = {\n orderExecutionType: type,\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(type);\n }\n });\n\n it('should handle all triggerType values', () => {\n const triggers = ['price', 'twap', 'twap_custom_amounts'] as const;\n for (const trigger of triggers) {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: trigger,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.triggerType).toBe(trigger);\n }\n });\n\n it('should handle isolated margin', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n\n isolated: { margin: 12345678901000000000000n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(227737579102942800187821658369n);\n expect(unpacked.isolated?.margin).toBe(appendix.isolated?.margin);\n });\n\n it('should handle TWAP fields', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'twap',\n\n twap: { numOrders: 10, slippageFrac: 0.005 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(792281717376363744483197591553n);\n expect(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 0.005 });\n });\n\n it('should handle max values for all fields for iso orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: undefined,\n reduceOnly: true,\n isolated: { margin: 18446744073709551615n }, // 2^64-1\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.isolated?.margin).toBe(18446744000000000000n);\n expect(unpacked.twap).toBe(undefined);\n expect(packed).toBe(340282365561237229015142145n);\n });\n\n it('should handle max values for all fields for TWAP orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: 'twap_custom_amounts',\n reduceOnly: true,\n twap: {\n numOrders: 4294967295,\n slippageFrac: 0.000001,\n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.twap?.slippageFrac).toBe(0.000001);\n expect(unpacked.twap?.numOrders).toBe(4294967295);\n expect(packed).toBe(340282366841710300967557013911933828609n);\n });\n\n it('should handle builder fields', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n builder: { builderId: 123, builderFeeRate: 500 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder?.builderId).toBe(123);\n expect(unpacked.builder?.builderFeeRate).toBe(500);\n });\n\n it('should handle builder with zero fee rate', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n builder: { builderId: 42, builderFeeRate: 0 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder?.builderId).toBe(42);\n expect(unpacked.builder?.builderFeeRate).toBe(0);\n });\n\n it('should handle builder with max values', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n builder: { builderId: 65535, builderFeeRate: 1023 }, // 16 bits, 10 bits max\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder?.builderId).toBe(65535);\n expect(unpacked.builder?.builderFeeRate).toBe(1023);\n });\n\n it('should handle builder combined with other flags', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'ioc',\n reduceOnly: true,\n triggerType: 'price',\n builder: { builderId: 5, builderFeeRate: 100 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe('ioc');\n expect(unpacked.reduceOnly).toBe(true);\n expect(unpacked.triggerType).toBe('price');\n expect(unpacked.builder?.builderId).toBe(5);\n expect(unpacked.builder?.builderFeeRate).toBe(100);\n });\n\n it('should not return builder fields when builderId is 0', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder).toBeUndefined();\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,2FAAAA,UAAAC,SAAA;AAAA;AAQS,KAAC,MAAM;AACN;AACV,UAAI,sBAAsB,CAAC;AAY3B,YAAM,IAAI,MAAM,oEAAoE;AACpF,MAAAA,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