@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
@@ -11,7 +11,7 @@ describe('OrderAppendix packing/unpacking', () => {
11
11
  };
12
12
  const packed = packOrderAppendix(appendix);
13
13
  const unpacked = unpackOrderAppendix(packed);
14
- expect(packed).toBe(4096n);
14
+ expect(packed).toBe(4097n);
15
15
  expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
16
16
  expect(unpacked.triggerType).toBe(appendix.triggerType);
17
17
  expect(unpacked.reduceOnly).toBeFalsy();
@@ -25,7 +25,7 @@ describe('OrderAppendix packing/unpacking', () => {
25
25
  };
26
26
  const packed = packOrderAppendix(appendix);
27
27
  const unpacked = unpackOrderAppendix(packed);
28
- expect(packed).toBe(6144n);
28
+ expect(packed).toBe(6145n);
29
29
  expect(unpacked.reduceOnly).toBe(true);
30
30
  });
31
31
 
@@ -60,12 +60,12 @@ describe('OrderAppendix packing/unpacking', () => {
60
60
  orderExecutionType: 'default',
61
61
  triggerType: 'price',
62
62
 
63
- isolated: { margin: 123456789012345678901234n },
63
+ isolated: { margin: 12345678901000000000000n },
64
64
  };
65
65
  const packed = packOrderAppendix(appendix);
66
66
  const unpacked = unpackOrderAppendix(packed);
67
- expect(packed).toBe(530242871277196831127717244047616n);
68
- expect(unpacked.isolated?.margin).toBe(123456789012345678901234n);
67
+ expect(packed).toBe(227737579102942800187821658369n);
68
+ expect(unpacked.isolated?.margin).toBe(appendix.isolated?.margin);
69
69
  });
70
70
 
71
71
  it('should handle TWAP fields', () => {
@@ -77,7 +77,7 @@ describe('OrderAppendix packing/unpacking', () => {
77
77
  };
78
78
  const packed = packOrderAppendix(appendix);
79
79
  const unpacked = unpackOrderAppendix(packed);
80
- expect(packed).toBe(792281717376363744483197591552n);
80
+ expect(packed).toBe(792281717376363744483197591553n);
81
81
  expect(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 0.005 });
82
82
  });
83
83
 
@@ -86,16 +86,16 @@ describe('OrderAppendix packing/unpacking', () => {
86
86
  orderExecutionType: 'post_only',
87
87
  triggerType: undefined,
88
88
  reduceOnly: true,
89
- isolated: { margin: 79228162514264337593543950335n }, // 2^96-1
89
+ isolated: { margin: 18446744073709551615n }, // 2^64-1
90
90
  };
91
91
  const packed = packOrderAppendix(appendix);
92
92
  const unpacked = unpackOrderAppendix(packed);
93
93
  expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
94
94
  expect(unpacked.triggerType).toBe(appendix.triggerType);
95
95
  expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);
96
- expect(unpacked.isolated?.margin).toBe(79228162514264337593543950335n);
96
+ expect(unpacked.isolated?.margin).toBe(18446744000000000000n);
97
97
  expect(unpacked.twap).toBe(undefined);
98
- expect(packed).toBe(340282366920938463463374607427473248000n);
98
+ expect(packed).toBe(340282365561237229015142145n);
99
99
  });
100
100
 
101
101
  it('should handle max values for all fields for TWAP orders', () => {
@@ -104,7 +104,6 @@ describe('OrderAppendix packing/unpacking', () => {
104
104
  triggerType: 'twap_custom_amounts',
105
105
  reduceOnly: true,
106
106
  twap: {
107
- // max 32-bit unsigned int
108
107
  numOrders: 4294967295,
109
108
  slippageFrac: 0.000001,
110
109
  },
@@ -116,6 +115,64 @@ describe('OrderAppendix packing/unpacking', () => {
116
115
  expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);
117
116
  expect(unpacked.twap?.slippageFrac).toBe(0.000001);
118
117
  expect(unpacked.twap?.numOrders).toBe(4294967295);
119
- expect(packed).toBe(340282366841710300967557013911933828608n);
118
+ expect(packed).toBe(340282366841710300967557013911933828609n);
119
+ });
120
+
121
+ it('should handle builder fields', () => {
122
+ const appendix: OrderAppendix = {
123
+ orderExecutionType: 'default',
124
+ builder: { builderId: 123, builderFeeRate: 500 },
125
+ };
126
+ const packed = packOrderAppendix(appendix);
127
+ const unpacked = unpackOrderAppendix(packed);
128
+ expect(unpacked.builder?.builderId).toBe(123);
129
+ expect(unpacked.builder?.builderFeeRate).toBe(500);
130
+ });
131
+
132
+ it('should handle builder with zero fee rate', () => {
133
+ const appendix: OrderAppendix = {
134
+ orderExecutionType: 'default',
135
+ builder: { builderId: 42, builderFeeRate: 0 },
136
+ };
137
+ const packed = packOrderAppendix(appendix);
138
+ const unpacked = unpackOrderAppendix(packed);
139
+ expect(unpacked.builder?.builderId).toBe(42);
140
+ expect(unpacked.builder?.builderFeeRate).toBe(0);
141
+ });
142
+
143
+ it('should handle builder with max values', () => {
144
+ const appendix: OrderAppendix = {
145
+ orderExecutionType: 'default',
146
+ builder: { builderId: 65535, builderFeeRate: 1023 }, // 16 bits, 10 bits max
147
+ };
148
+ const packed = packOrderAppendix(appendix);
149
+ const unpacked = unpackOrderAppendix(packed);
150
+ expect(unpacked.builder?.builderId).toBe(65535);
151
+ expect(unpacked.builder?.builderFeeRate).toBe(1023);
152
+ });
153
+
154
+ it('should handle builder combined with other flags', () => {
155
+ const appendix: OrderAppendix = {
156
+ orderExecutionType: 'ioc',
157
+ reduceOnly: true,
158
+ triggerType: 'price',
159
+ builder: { builderId: 5, builderFeeRate: 100 },
160
+ };
161
+ const packed = packOrderAppendix(appendix);
162
+ const unpacked = unpackOrderAppendix(packed);
163
+ expect(unpacked.orderExecutionType).toBe('ioc');
164
+ expect(unpacked.reduceOnly).toBe(true);
165
+ expect(unpacked.triggerType).toBe('price');
166
+ expect(unpacked.builder?.builderId).toBe(5);
167
+ expect(unpacked.builder?.builderFeeRate).toBe(100);
168
+ });
169
+
170
+ it('should not return builder fields when builderId is 0', () => {
171
+ const appendix: OrderAppendix = {
172
+ orderExecutionType: 'default',
173
+ };
174
+ const packed = packOrderAppendix(appendix);
175
+ const unpacked = unpackOrderAppendix(packed);
176
+ expect(unpacked.builder).toBeUndefined();
120
177
  });
121
178
  });
@@ -1,5 +1,5 @@
1
1
  import { OrderAppendix } from '../../../types/orderAppendixTypes';
2
- import { toBigInt } from '../../math/toBigInt';
2
+ import { packIsolatedOrderAppendixValue } from './appendixIsolatedValue';
3
3
  import { packTwapOrderAppendixValue } from './appendixTwapValue';
4
4
  import { bitMaskValue } from './bitMaskValue';
5
5
  import { PackedOrderAppendixBits } from './types';
@@ -12,7 +12,7 @@ function mapOrderAppendixToBitValues(
12
12
  return packTwapOrderAppendixValue(appendix.twap);
13
13
  }
14
14
  if (appendix.isolated) {
15
- return toBigInt(appendix.isolated.margin);
15
+ return packIsolatedOrderAppendixValue(appendix.isolated);
16
16
  }
17
17
  return 0n;
18
18
  })();
@@ -43,12 +43,14 @@ function mapOrderAppendixToBitValues(
43
43
 
44
44
  return {
45
45
  value,
46
+ builderId: appendix.builder?.builderId ?? 0,
47
+ builderFeeRate: appendix.builder?.builderFeeRate ?? 0,
46
48
  reserved: 0,
47
49
  trigger,
48
50
  reduceOnly: appendix.reduceOnly ? 1 : 0,
49
51
  orderType,
50
52
  isolated: appendix.isolated ? 1 : 0,
51
- version: 0,
53
+ version: 1,
52
54
  };
53
55
  }
54
56
 
@@ -59,9 +61,11 @@ function mapOrderAppendixToBitValues(
59
61
  export function packOrderAppendix(appendix: OrderAppendix): bigint {
60
62
  const bits = mapOrderAppendixToBitValues(appendix);
61
63
 
62
- // Ensure value is within 96 bits
63
- let packed = bitMaskValue(bits.value, 96);
64
- packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);
64
+ // Ensure value is within 64 bits
65
+ let packed = bitMaskValue(bits.value, 64);
66
+ packed = (packed << 16n) | bitMaskValue(bits.builderId, 16);
67
+ packed = (packed << 10n) | bitMaskValue(bits.builderFeeRate, 10);
68
+ packed = (packed << 24n) | bitMaskValue(bits.reserved, 24);
65
69
  packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);
66
70
  packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);
67
71
  packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);
@@ -1,17 +1,19 @@
1
1
  /**
2
2
  * Bit layout for OrderAppendix packing (MSB → LSB):
3
3
  *
4
- * | value | reserved | trigger | reduceOnly | orderType | isolated | version |
5
- * |-----------|----------|---------|------------|-----------|----------|---------|
6
- * | 127..32 | 31..14 | 13..12 | 11 | 10..9 | 8 | 7..0 |
7
- * | 96 bits | 18 bits | 2 bits | 1 bit | 2 bits | 1 bit | 8 bits |
4
+ * | value | builderId | builderFeeRate | reserved | trigger | reduceOnly | orderType | isolated | version |
5
+ * |-----------|-----------|----------------|----------|---------|------------|-----------|----------|---------|
6
+ * | 127..64 | 63..48 | 47..38 | 37..14 | 13..12 | 11 | 10..9 | 8 | 7..0 |
7
+ * | 64 bits | 16 bits | 10 bits | 24 bits | 2 bits | 1 bit | 2 bits | 1 bit | 8 bits |
8
8
  */
9
9
  export interface PackedOrderAppendixBits {
10
- value: bigint; // 96 bits
11
- reserved: number; // 18 bits, set to 0
10
+ value: bigint; // 64 bits
11
+ builderId: number; // 16 bits
12
+ builderFeeRate: number; // 10 bits
13
+ reserved: number; // 24 bits, set to 0
12
14
  trigger: number; // 2 bits
13
15
  reduceOnly: number; // 1 bit
14
16
  orderType: number; // 2 bits
15
17
  isolated: number; // 1 bit
16
- version: number; // 8 bits, set to 0
18
+ version: number; // 8 bits, set to 1
17
19
  }
@@ -1,5 +1,6 @@
1
1
  import { OrderAppendix } from '../../../types/orderAppendixTypes';
2
- import { BigDecimalish, toBigInt } from '../../math';
2
+ import { BigNumberish, toBigInt } from '../../math';
3
+ import { unpackIsolatedOrderAppendixValue } from './appendixIsolatedValue';
3
4
  import { unpackTwapOrderAppendixValue } from './appendixTwapValue';
4
5
  import { bitMaskValue } from './bitMaskValue';
5
6
  import { PackedOrderAppendixBits } from './types';
@@ -35,7 +36,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
35
36
  })();
36
37
  const isolatedFields = (() => {
37
38
  if (bits.isolated) {
38
- return { margin: bits.value };
39
+ return unpackIsolatedOrderAppendixValue(bits.value);
39
40
  }
40
41
  return undefined;
41
42
  })();
@@ -44,6 +45,15 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
44
45
  return unpackTwapOrderAppendixValue(bits.value);
45
46
  }
46
47
  })();
48
+ const builderFields = (() => {
49
+ if (bits.builderId) {
50
+ return {
51
+ builderId: bits.builderId,
52
+ builderFeeRate: bits.builderFeeRate,
53
+ };
54
+ }
55
+ return undefined;
56
+ })();
47
57
 
48
58
  return {
49
59
  reduceOnly: !!bits.reduceOnly,
@@ -51,6 +61,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
51
61
  triggerType,
52
62
  isolated: isolatedFields,
53
63
  twap: twapFields,
64
+ builder: builderFields,
54
65
  };
55
66
  }
56
67
 
@@ -58,7 +69,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
58
69
  * Unpack the OrderAppendix fields from a packed bigint.
59
70
  * @param packed
60
71
  */
61
- export function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {
72
+ export function unpackOrderAppendix(packed: BigNumberish): OrderAppendix {
62
73
  let temp = toBigInt(packed);
63
74
  // Bitmasks lowest 8 bits for version
64
75
  const version = Number(bitMaskValue(temp, 8));
@@ -73,13 +84,19 @@ export function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {
73
84
  temp >>= 1n;
74
85
  const trigger = Number(bitMaskValue(temp, 2));
75
86
  temp >>= 2n;
76
- const reserved = Number(bitMaskValue(temp, 18));
77
- temp >>= 18n;
78
- // The remaining bits are the value, which should be 96 bits
79
- const value = bitMaskValue(temp, 96);
87
+ const reserved = Number(bitMaskValue(temp, 24));
88
+ temp >>= 24n;
89
+ const builderFeeRate = Number(bitMaskValue(temp, 10));
90
+ temp >>= 10n;
91
+ const builderId = Number(bitMaskValue(temp, 16));
92
+ temp >>= 16n;
93
+ // The remaining bits are the value, which should be 64 bits
94
+ const value = bitMaskValue(temp, 64);
80
95
 
81
96
  return mapBitValuesToAppendix({
82
97
  value,
98
+ builderId,
99
+ builderFeeRate,
83
100
  reserved,
84
101
  trigger,
85
102
  reduceOnly,
@@ -1,3 +1,3 @@
1
+ export * from './appendix';
1
2
  export * from './orderNonce';
2
3
  export * from './recvTime';
3
- export * from './appendix';
@@ -1,9 +1,9 @@
1
1
  import { Balance, PerpBalance, SpotBalance } from '../types/balanceTypes';
2
2
  import {
3
- ProductEngineType,
4
3
  PerpProduct,
5
- SpotProduct,
6
4
  Product,
5
+ ProductEngineType,
6
+ SpotProduct,
7
7
  } from '../types/productTypes';
8
8
 
9
9
  export function isSpotProduct(product: Product): product is SpotProduct {
@@ -1,25 +1,45 @@
1
- import { BigDecimal } from './math/bigDecimal';
1
+ import BigNumber from 'bignumber.js';
2
2
 
3
3
  /**
4
- * Util for converting any BigDecimal types into a string so that it can be logged nicely
4
+ * Util for converting any BigNumber types into a string so that it can be logged nicely.
5
+ * Handles cyclic references by returning '[Circular]' for already-visited objects.
5
6
  */
6
- export function toPrintableObject(obj: unknown): unknown {
7
- if (obj == null) {
7
+ export function toPrintableObject(
8
+ obj: null | undefined,
9
+ seen?: WeakSet<object>,
10
+ ): null;
11
+ export function toPrintableObject(
12
+ obj: BigNumber | bigint,
13
+ seen?: WeakSet<object>,
14
+ ): string;
15
+ export function toPrintableObject(obj: unknown, seen?: WeakSet<object>): object;
16
+ export function toPrintableObject(obj: unknown, seen = new WeakSet()): unknown {
17
+ if (obj === null || obj === undefined) {
8
18
  return null;
9
19
  }
10
- if (obj instanceof BigDecimal || typeof obj === 'bigint') {
20
+ if (obj instanceof BigNumber || typeof obj === 'bigint') {
11
21
  return obj.toString();
12
22
  }
13
23
  if (Array.isArray(obj)) {
14
- return obj.map(toPrintableObject);
24
+ return obj.map((item) => toPrintableObject(item, seen));
15
25
  }
16
26
  if (typeof obj === 'object') {
17
- return Object.fromEntries(
18
- Object.entries(obj).map(([key, value]) => [
19
- key,
20
- toPrintableObject(value),
21
- ]),
22
- );
27
+ // Detect cyclic references
28
+ if (seen.has(obj)) {
29
+ return '[Circular]';
30
+ }
31
+ seen.add(obj);
32
+
33
+ try {
34
+ return Object.fromEntries(
35
+ Object.entries(obj).map(([key, value]) => [
36
+ key,
37
+ toPrintableObject(value, seen),
38
+ ]),
39
+ );
40
+ } catch {
41
+ return { error: '[Unserializable Object]' };
42
+ }
23
43
  }
24
44
  return obj;
25
45
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../node_modules/@jest/globals/build/index.js"],"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;"],"mappings":";;;;;AAAA;AAAA;AAAA;AAQS,KAAC,MAAM;AACN;AACV,UAAI,sBAAsB,CAAC;AAY3B,YAAM,IAAI,MAAM,oEAAoE;AACpF,aAAO,UAAU;AAAA,IACR,GAAG;AAAA;AAAA;","names":[]}
@@ -1,13 +0,0 @@
1
- {
2
- "nodeUrl": "https://rpc-gel-sepolia.inkonchain.com",
3
- "explorerUrl": "https://explorer-sepolia.inkonchain.com",
4
- "startBlock": 27233833,
5
- "deployer": "0x8177A1b5bFaAa10A4b1178c6D42aDaa4b75c8146",
6
- "quote": "0x5F65358d61A9a281ea3BB930d05889ACa21E3f4f",
7
- "querier": "0x5A62e748b2630560Ffe9E928780cF9Fe0e086A21",
8
- "clearinghouse": "0x5E9b4336104069467E57E843033e62c79C667F8F",
9
- "endpoint": "0xf8963f7860aF7DE9b94893EDb9A3b5c155e1Fc0c",
10
- "spotEngine": "0x61AA7A636df5e72eBe34c70a340eB76ABB3A15bE",
11
- "perpEngine": "0x3D6Ac7105cA399884739a8CC19cAdB4178844466",
12
- "withdrawPool": "0xa59613a3e4ce46E20d83b0632E3D857e3f116F66"
13
- }
@@ -1,18 +0,0 @@
1
- {
2
- "nodeUrl": "https://arb1.arbitrum.io/rpc",
3
- "explorerUrl": "https://explorer.arbitrum.io",
4
- "subgraphCoreUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-core",
5
- "subgraphMarketsUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-markets",
6
- "subgraphCandleSticksUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-candlesticks",
7
- "startBlock": 67108377,
8
- "deployer": "0xB746472C10f9F128FF9F5029f424cC91bb1D8C3a",
9
- "quote": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
10
- "querier": "0x1693273B443699bee277eCbc60e2C8027E91995d",
11
- "feeCalculator": "0x2259440579447D0625a5E28dfF3E743d207e8890",
12
- "clearinghouse": "0xAE1ec28d6225dCE2ff787dcb8CE11cF6D3AE064f",
13
- "clearinghouseLiq": "0xca007C51Fc14eEA88252Cc4FD71e91E44026F020",
14
- "endpoint": "0xbbEE07B3e8121227AfCFe1E2B82772246226128e",
15
- "spotEngine": "0x32d91Af2B17054D575A7bF1ACfa7615f41CCEfaB",
16
- "perpEngine": "0xb74C78cca0FADAFBeE52B2f48A67eE8c834b5fd1",
17
- "withdrawPool": "0x3567a1f8d79046A7e93Fd76d71104A978cDC6d05"
18
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/math/BigDecimals.ts"],"sourcesContent":["import { toBigDecimal } from './bigDecimal';\n\nexport const BigDecimals = Object.freeze({\n ZERO: toBigDecimal(0),\n ONE: toBigDecimal(1),\n INF: toBigDecimal(Infinity),\n MAX_I128: toBigDecimal('170141183460469231731687303715884105727'),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA6B;AAEtB,IAAM,cAAc,OAAO,OAAO;AAAA,EACvC,UAAM,gCAAa,CAAC;AAAA,EACpB,SAAK,gCAAa,CAAC;AAAA,EACnB,SAAK,gCAAa,QAAQ;AAAA,EAC1B,cAAU,gCAAa,yCAAyC;AAClE,CAAC;","names":[]}
@@ -1,8 +0,0 @@
1
- declare const BigDecimals: Readonly<{
2
- ZERO: BigNumber;
3
- ONE: BigNumber;
4
- INF: BigNumber;
5
- MAX_I128: BigNumber;
6
- }>;
7
-
8
- export { BigDecimals };
@@ -1,8 +0,0 @@
1
- declare const BigDecimals: Readonly<{
2
- ZERO: BigNumber;
3
- ONE: BigNumber;
4
- INF: BigNumber;
5
- MAX_I128: BigNumber;
6
- }>;
7
-
8
- export { BigDecimals };
@@ -1,14 +0,0 @@
1
- import "../../chunk-5WRI5ZAA.js";
2
-
3
- // src/utils/math/BigDecimals.ts
4
- import { toBigDecimal } from "./bigDecimal.js";
5
- var BigDecimals = Object.freeze({
6
- ZERO: toBigDecimal(0),
7
- ONE: toBigDecimal(1),
8
- INF: toBigDecimal(Infinity),
9
- MAX_I128: toBigDecimal("170141183460469231731687303715884105727")
10
- });
11
- export {
12
- BigDecimals
13
- };
14
- //# sourceMappingURL=BigDecimals.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/math/BigDecimals.ts"],"sourcesContent":["import { toBigDecimal } from './bigDecimal';\n\nexport const BigDecimals = Object.freeze({\n ZERO: toBigDecimal(0),\n ONE: toBigDecimal(1),\n INF: toBigDecimal(Infinity),\n MAX_I128: toBigDecimal('170141183460469231731687303715884105727'),\n});\n"],"mappings":";;;AAAA,SAAS,oBAAoB;AAEtB,IAAM,cAAc,OAAO,OAAO;AAAA,EACvC,MAAM,aAAa,CAAC;AAAA,EACpB,KAAK,aAAa,CAAC;AAAA,EACnB,KAAK,aAAa,QAAQ;AAAA,EAC1B,UAAU,aAAa,yCAAyC;AAClE,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n const bnConstructorVal = (() => {\n if (val instanceof BigDecimal) {\n return val;\n } else if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsC;AAGtC,IAAAA,oBAAsC;AAe/B,SAAS,aAAa,KAAgC;AAC3D,QAAM,oBAAoB,MAAM;AAC9B,QAAI,eAAe,iBAAAC,SAAY;AAC7B,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AAC7D,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,iBAAAA,QAAW,gBAAgB;AACxC;","names":["import_bignumber","BigDecimal"]}
@@ -1,18 +0,0 @@
1
- import BigDecimal from 'bignumber.js';
2
- export { default as BigDecimal } from 'bignumber.js';
3
-
4
- /**
5
- * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
6
- * Includes valid values & instances for BigDecimal.
7
- *
8
- * @see https://mikemcl.github.io/bignumber.js/
9
- */
10
- type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
11
- /**
12
- * Converts a value to an instance of BigDecimal
13
- *
14
- * @param val
15
- */
16
- declare function toBigDecimal(val: BigDecimalish): BigDecimal;
17
-
18
- export { type BigDecimalish, toBigDecimal };
@@ -1,18 +0,0 @@
1
- import BigDecimal from 'bignumber.js';
2
- export { default as BigDecimal } from 'bignumber.js';
3
-
4
- /**
5
- * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
6
- * Includes valid values & instances for BigDecimal.
7
- *
8
- * @see https://mikemcl.github.io/bignumber.js/
9
- */
10
- type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
11
- /**
12
- * Converts a value to an instance of BigDecimal
13
- *
14
- * @param val
15
- */
16
- declare function toBigDecimal(val: BigDecimalish): BigDecimal;
17
-
18
- export { type BigDecimalish, toBigDecimal };
@@ -1,23 +0,0 @@
1
- import "../../chunk-5WRI5ZAA.js";
2
-
3
- // src/utils/math/bigDecimal.ts
4
- import { default as BigDecimal } from "bignumber.js";
5
- import { default as default2 } from "bignumber.js";
6
- function toBigDecimal(val) {
7
- const bnConstructorVal = (() => {
8
- if (val instanceof BigDecimal) {
9
- return val;
10
- } else if (typeof val === "string" || typeof val === "number") {
11
- return val;
12
- } else if (typeof val === "bigint") {
13
- return val.toString();
14
- }
15
- return JSON.stringify(val);
16
- })();
17
- return new BigDecimal(bnConstructorVal);
18
- }
19
- export {
20
- default2 as BigDecimal,
21
- toBigDecimal
22
- };
23
- //# sourceMappingURL=bigDecimal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n const bnConstructorVal = (() => {\n if (val instanceof BigDecimal) {\n return val;\n } else if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;AAAA,SAAS,WAAW,kBAAkB;AAGtC,SAAoB,WAAXA,gBAA6B;AAe/B,SAAS,aAAa,KAAgC;AAC3D,QAAM,oBAAoB,MAAM;AAC9B,QAAI,eAAe,YAAY;AAC7B,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AAC7D,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,WAAW,gBAAgB;AACxC;","names":["default"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/math/sumBigDecimalBy.ts"],"sourcesContent":["import { BigDecimal } from './bigDecimal';\nimport { BigDecimals } from './BigDecimals';\n\n/**\n * Util function to sum BigDecimal values, inspired by Lodash\n * @param collection\n * @param iteratee\n */\nexport function sumBigDecimalBy<T>(\n collection: T[] | null | undefined,\n iteratee: (value: T) => BigDecimal.Value,\n): BigDecimal {\n return (\n collection?.reduce((total, item) => {\n return total.plus(iteratee(item));\n }, BigDecimals.ZERO) ?? BigDecimals.ZERO\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA4B;AAOrB,SAAS,gBACd,YACA,UACY;AACZ,SACE,YAAY,OAAO,CAAC,OAAO,SAAS;AAClC,WAAO,MAAM,KAAK,SAAS,IAAI,CAAC;AAAA,EAClC,GAAG,+BAAY,IAAI,KAAK,+BAAY;AAExC;","names":[]}
@@ -1,10 +0,0 @@
1
- import BigDecimal from 'bignumber.js';
2
-
3
- /**
4
- * Util function to sum BigDecimal values, inspired by Lodash
5
- * @param collection
6
- * @param iteratee
7
- */
8
- declare function sumBigDecimalBy<T>(collection: T[] | null | undefined, iteratee: (value: T) => BigDecimal.Value): BigDecimal;
9
-
10
- export { sumBigDecimalBy };
@@ -1,10 +0,0 @@
1
- import BigDecimal from 'bignumber.js';
2
-
3
- /**
4
- * Util function to sum BigDecimal values, inspired by Lodash
5
- * @param collection
6
- * @param iteratee
7
- */
8
- declare function sumBigDecimalBy<T>(collection: T[] | null | undefined, iteratee: (value: T) => BigDecimal.Value): BigDecimal;
9
-
10
- export { sumBigDecimalBy };
@@ -1,13 +0,0 @@
1
- import "../../chunk-5WRI5ZAA.js";
2
-
3
- // src/utils/math/sumBigDecimalBy.ts
4
- import { BigDecimals } from "./BigDecimals.js";
5
- function sumBigDecimalBy(collection, iteratee) {
6
- return collection?.reduce((total, item) => {
7
- return total.plus(iteratee(item));
8
- }, BigDecimals.ZERO) ?? BigDecimals.ZERO;
9
- }
10
- export {
11
- sumBigDecimalBy
12
- };
13
- //# sourceMappingURL=sumBigDecimalBy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/math/sumBigDecimalBy.ts"],"sourcesContent":["import { BigDecimal } from './bigDecimal';\nimport { BigDecimals } from './BigDecimals';\n\n/**\n * Util function to sum BigDecimal values, inspired by Lodash\n * @param collection\n * @param iteratee\n */\nexport function sumBigDecimalBy<T>(\n collection: T[] | null | undefined,\n iteratee: (value: T) => BigDecimal.Value,\n): BigDecimal {\n return (\n collection?.reduce((total, item) => {\n return total.plus(iteratee(item));\n }, BigDecimals.ZERO) ?? BigDecimals.ZERO\n );\n}\n"],"mappings":";;;AACA,SAAS,mBAAmB;AAOrB,SAAS,gBACd,YACA,UACY;AACZ,SACE,YAAY,OAAO,CAAC,OAAO,SAAS;AAClC,WAAO,MAAM,KAAK,SAAS,IAAI,CAAC;AAAA,EAClC,GAAG,YAAY,IAAI,KAAK,YAAY;AAExC;","names":[]}
@@ -1,13 +0,0 @@
1
- {
2
- "nodeUrl": "https://rpc-gel-sepolia.inkonchain.com",
3
- "explorerUrl": "https://explorer-sepolia.inkonchain.com",
4
- "startBlock": 27233833,
5
- "deployer": "0x8177A1b5bFaAa10A4b1178c6D42aDaa4b75c8146",
6
- "quote": "0x5F65358d61A9a281ea3BB930d05889ACa21E3f4f",
7
- "querier": "0x5A62e748b2630560Ffe9E928780cF9Fe0e086A21",
8
- "clearinghouse": "0x5E9b4336104069467E57E843033e62c79C667F8F",
9
- "endpoint": "0xf8963f7860aF7DE9b94893EDb9A3b5c155e1Fc0c",
10
- "spotEngine": "0x61AA7A636df5e72eBe34c70a340eB76ABB3A15bE",
11
- "perpEngine": "0x3D6Ac7105cA399884739a8CC19cAdB4178844466",
12
- "withdrawPool": "0xa59613a3e4ce46E20d83b0632E3D857e3f116F66"
13
- }
@@ -1,18 +0,0 @@
1
- {
2
- "nodeUrl": "https://arb1.arbitrum.io/rpc",
3
- "explorerUrl": "https://explorer.arbitrum.io",
4
- "subgraphCoreUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-core",
5
- "subgraphMarketsUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-markets",
6
- "subgraphCandleSticksUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-candlesticks",
7
- "startBlock": 67108377,
8
- "deployer": "0xB746472C10f9F128FF9F5029f424cC91bb1D8C3a",
9
- "quote": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
10
- "querier": "0x1693273B443699bee277eCbc60e2C8027E91995d",
11
- "feeCalculator": "0x2259440579447D0625a5E28dfF3E743d207e8890",
12
- "clearinghouse": "0xAE1ec28d6225dCE2ff787dcb8CE11cF6D3AE064f",
13
- "clearinghouseLiq": "0xca007C51Fc14eEA88252Cc4FD71e91E44026F020",
14
- "endpoint": "0xbbEE07B3e8121227AfCFe1E2B82772246226128e",
15
- "spotEngine": "0x32d91Af2B17054D575A7bF1ACfa7615f41CCEfaB",
16
- "perpEngine": "0xb74C78cca0FADAFBeE52B2f48A67eE8c834b5fd1",
17
- "withdrawPool": "0x3567a1f8d79046A7e93Fd76d71104A978cDC6d05"
18
- }
@@ -1,8 +0,0 @@
1
- import { toBigDecimal } from './bigDecimal';
2
-
3
- export const BigDecimals = Object.freeze({
4
- ZERO: toBigDecimal(0),
5
- ONE: toBigDecimal(1),
6
- INF: toBigDecimal(Infinity),
7
- MAX_I128: toBigDecimal('170141183460469231731687303715884105727'),
8
- });
@@ -1,32 +0,0 @@
1
- import { default as BigDecimal } from 'bignumber.js';
2
-
3
- // Renames `BigNumber` type from `bignumber.js`.
4
- export { default as BigDecimal } from 'bignumber.js';
5
-
6
- /**
7
- * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
8
- * Includes valid values & instances for BigDecimal.
9
- *
10
- * @see https://mikemcl.github.io/bignumber.js/
11
- */
12
- export type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
13
-
14
- /**
15
- * Converts a value to an instance of BigDecimal
16
- *
17
- * @param val
18
- */
19
- export function toBigDecimal(val: BigDecimalish): BigDecimal {
20
- const bnConstructorVal = (() => {
21
- if (val instanceof BigDecimal) {
22
- return val;
23
- } else if (typeof val === 'string' || typeof val === 'number') {
24
- return val;
25
- } else if (typeof val === 'bigint') {
26
- return val.toString();
27
- }
28
- // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives
29
- return JSON.stringify(val);
30
- })();
31
- return new BigDecimal(bnConstructorVal);
32
- }