@nadohq/shared 0.1.0-alpha.4

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 (551) hide show
  1. package/README.md +2 -0
  2. package/dist/abis/Clearinghouse.cjs +891 -0
  3. package/dist/abis/Clearinghouse.cjs.map +1 -0
  4. package/dist/abis/Clearinghouse.d.cts +669 -0
  5. package/dist/abis/Clearinghouse.d.ts +669 -0
  6. package/dist/abis/Clearinghouse.js +868 -0
  7. package/dist/abis/Clearinghouse.js.map +1 -0
  8. package/dist/abis/ERC20.cjs +215 -0
  9. package/dist/abis/ERC20.cjs.map +1 -0
  10. package/dist/abis/ERC20.d.cts +143 -0
  11. package/dist/abis/ERC20.d.ts +143 -0
  12. package/dist/abis/ERC20.js +192 -0
  13. package/dist/abis/ERC20.js.map +1 -0
  14. package/dist/abis/Endpoint.cjs +589 -0
  15. package/dist/abis/Endpoint.cjs.map +1 -0
  16. package/dist/abis/Endpoint.d.cts +433 -0
  17. package/dist/abis/Endpoint.d.ts +433 -0
  18. package/dist/abis/Endpoint.js +566 -0
  19. package/dist/abis/Endpoint.js.map +1 -0
  20. package/dist/abis/MockERC20.cjs +341 -0
  21. package/dist/abis/MockERC20.cjs.map +1 -0
  22. package/dist/abis/MockERC20.d.cts +239 -0
  23. package/dist/abis/MockERC20.d.ts +239 -0
  24. package/dist/abis/MockERC20.js +318 -0
  25. package/dist/abis/MockERC20.js.map +1 -0
  26. package/dist/abis/PerpEngine.cjs +886 -0
  27. package/dist/abis/PerpEngine.cjs.map +1 -0
  28. package/dist/abis/PerpEngine.d.cts +661 -0
  29. package/dist/abis/PerpEngine.d.ts +661 -0
  30. package/dist/abis/PerpEngine.js +863 -0
  31. package/dist/abis/PerpEngine.js.map +1 -0
  32. package/dist/abis/Querier.cjs +1522 -0
  33. package/dist/abis/Querier.cjs.map +1 -0
  34. package/dist/abis/Querier.d.cts +1149 -0
  35. package/dist/abis/Querier.d.ts +1149 -0
  36. package/dist/abis/Querier.js +1499 -0
  37. package/dist/abis/Querier.js.map +1 -0
  38. package/dist/abis/SpotEngine.cjs +937 -0
  39. package/dist/abis/SpotEngine.cjs.map +1 -0
  40. package/dist/abis/SpotEngine.d.cts +701 -0
  41. package/dist/abis/SpotEngine.d.ts +701 -0
  42. package/dist/abis/SpotEngine.js +914 -0
  43. package/dist/abis/SpotEngine.js.map +1 -0
  44. package/dist/abis/WithdrawPool.cjs +307 -0
  45. package/dist/abis/WithdrawPool.cjs.map +1 -0
  46. package/dist/abis/WithdrawPool.d.cts +214 -0
  47. package/dist/abis/WithdrawPool.d.ts +214 -0
  48. package/dist/abis/WithdrawPool.js +284 -0
  49. package/dist/abis/WithdrawPool.js.map +1 -0
  50. package/dist/abis/index.cjs +41 -0
  51. package/dist/abis/index.cjs.map +1 -0
  52. package/dist/abis/index.d.cts +9 -0
  53. package/dist/abis/index.d.ts +9 -0
  54. package/dist/abis/index.js +11 -0
  55. package/dist/abis/index.js.map +1 -0
  56. package/dist/abis/nadoAbis.cjs +44 -0
  57. package/dist/abis/nadoAbis.cjs.map +1 -0
  58. package/dist/abis/nadoAbis.d.cts +3821 -0
  59. package/dist/abis/nadoAbis.d.ts +3821 -0
  60. package/dist/abis/nadoAbis.js +21 -0
  61. package/dist/abis/nadoAbis.js.map +1 -0
  62. package/dist/chunk-5WRI5ZAA.js +31 -0
  63. package/dist/chunk-5WRI5ZAA.js.map +1 -0
  64. package/dist/chunk-TUJ4HQKF.js +33 -0
  65. package/dist/chunk-TUJ4HQKF.js.map +1 -0
  66. package/dist/consts/chainEnvToChain.cjs +44 -0
  67. package/dist/consts/chainEnvToChain.cjs.map +1 -0
  68. package/dist/consts/chainEnvToChain.d.cts +388 -0
  69. package/dist/consts/chainEnvToChain.d.ts +388 -0
  70. package/dist/consts/chainEnvToChain.js +20 -0
  71. package/dist/consts/chainEnvToChain.js.map +1 -0
  72. package/dist/consts/index.cjs +27 -0
  73. package/dist/consts/index.cjs.map +1 -0
  74. package/dist/consts/index.d.cts +6 -0
  75. package/dist/consts/index.d.ts +6 -0
  76. package/dist/consts/index.js +4 -0
  77. package/dist/consts/index.js.map +1 -0
  78. package/dist/consts/productIds.cjs +34 -0
  79. package/dist/consts/productIds.cjs.map +1 -0
  80. package/dist/consts/productIds.d.cts +4 -0
  81. package/dist/consts/productIds.d.ts +4 -0
  82. package/dist/consts/productIds.js +10 -0
  83. package/dist/consts/productIds.js.map +1 -0
  84. package/dist/deployments/core/deployment.InkSepolia.json +13 -0
  85. package/dist/deployments/core/deployment.arbitrumOne.json +18 -0
  86. package/dist/deployments/core/deployment.localhost.json +18 -0
  87. package/dist/deployments/index.cjs +65 -0
  88. package/dist/deployments/index.cjs.map +1 -0
  89. package/dist/deployments/index.d.cts +13 -0
  90. package/dist/deployments/index.d.ts +13 -0
  91. package/dist/deployments/index.js +32 -0
  92. package/dist/deployments/index.js.map +1 -0
  93. package/dist/eip712/eip712ValueTypes.cjs +19 -0
  94. package/dist/eip712/eip712ValueTypes.cjs.map +1 -0
  95. package/dist/eip712/eip712ValueTypes.d.cts +48 -0
  96. package/dist/eip712/eip712ValueTypes.d.ts +48 -0
  97. package/dist/eip712/eip712ValueTypes.js +1 -0
  98. package/dist/eip712/eip712ValueTypes.js.map +1 -0
  99. package/dist/eip712/getNadoEIP712Domain.cjs +39 -0
  100. package/dist/eip712/getNadoEIP712Domain.cjs.map +1 -0
  101. package/dist/eip712/getNadoEIP712Domain.d.cts +11 -0
  102. package/dist/eip712/getNadoEIP712Domain.d.ts +11 -0
  103. package/dist/eip712/getNadoEIP712Domain.js +16 -0
  104. package/dist/eip712/getNadoEIP712Domain.js.map +1 -0
  105. package/dist/eip712/getNadoEIP712PrimaryType.cjs +35 -0
  106. package/dist/eip712/getNadoEIP712PrimaryType.cjs.map +1 -0
  107. package/dist/eip712/getNadoEIP712PrimaryType.d.cts +16 -0
  108. package/dist/eip712/getNadoEIP712PrimaryType.d.ts +16 -0
  109. package/dist/eip712/getNadoEIP712PrimaryType.js +12 -0
  110. package/dist/eip712/getNadoEIP712PrimaryType.js.map +1 -0
  111. package/dist/eip712/getNadoEIP712Types.cjs +129 -0
  112. package/dist/eip712/getNadoEIP712Types.cjs.map +1 -0
  113. package/dist/eip712/getNadoEIP712Types.d.cts +20 -0
  114. package/dist/eip712/getNadoEIP712Types.d.ts +20 -0
  115. package/dist/eip712/getNadoEIP712Types.js +106 -0
  116. package/dist/eip712/getNadoEIP712Types.js.map +1 -0
  117. package/dist/eip712/getNadoEIP712Values.cjs +206 -0
  118. package/dist/eip712/getNadoEIP712Values.cjs.map +1 -0
  119. package/dist/eip712/getNadoEIP712Values.d.cts +20 -0
  120. package/dist/eip712/getNadoEIP712Values.d.ts +20 -0
  121. package/dist/eip712/getNadoEIP712Values.js +183 -0
  122. package/dist/eip712/getNadoEIP712Values.js.map +1 -0
  123. package/dist/eip712/getOrderVerifyingAddress.cjs +34 -0
  124. package/dist/eip712/getOrderVerifyingAddress.cjs.map +1 -0
  125. package/dist/eip712/getOrderVerifyingAddress.d.cts +9 -0
  126. package/dist/eip712/getOrderVerifyingAddress.d.ts +9 -0
  127. package/dist/eip712/getOrderVerifyingAddress.js +11 -0
  128. package/dist/eip712/getOrderVerifyingAddress.js.map +1 -0
  129. package/dist/eip712/getSignedTransactionRequest.cjs +42 -0
  130. package/dist/eip712/getSignedTransactionRequest.cjs.map +1 -0
  131. package/dist/eip712/getSignedTransactionRequest.d.cts +19 -0
  132. package/dist/eip712/getSignedTransactionRequest.d.ts +19 -0
  133. package/dist/eip712/getSignedTransactionRequest.js +19 -0
  134. package/dist/eip712/getSignedTransactionRequest.js.map +1 -0
  135. package/dist/eip712/index.cjs +43 -0
  136. package/dist/eip712/index.cjs.map +1 -0
  137. package/dist/eip712/index.d.cts +17 -0
  138. package/dist/eip712/index.d.ts +17 -0
  139. package/dist/eip712/index.js +12 -0
  140. package/dist/eip712/index.js.map +1 -0
  141. package/dist/eip712/orderDigest.cjs +45 -0
  142. package/dist/eip712/orderDigest.cjs.map +1 -0
  143. package/dist/eip712/orderDigest.d.cts +20 -0
  144. package/dist/eip712/orderDigest.d.ts +20 -0
  145. package/dist/eip712/orderDigest.js +22 -0
  146. package/dist/eip712/orderDigest.js.map +1 -0
  147. package/dist/eip712/signableRequestType.cjs +19 -0
  148. package/dist/eip712/signableRequestType.cjs.map +1 -0
  149. package/dist/eip712/signableRequestType.d.cts +26 -0
  150. package/dist/eip712/signableRequestType.d.ts +26 -0
  151. package/dist/eip712/signableRequestType.js +1 -0
  152. package/dist/eip712/signableRequestType.js.map +1 -0
  153. package/dist/eip712/signatureParamTypes.cjs +19 -0
  154. package/dist/eip712/signatureParamTypes.cjs.map +1 -0
  155. package/dist/eip712/signatureParamTypes.d.cts +68 -0
  156. package/dist/eip712/signatureParamTypes.d.ts +68 -0
  157. package/dist/eip712/signatureParamTypes.js +1 -0
  158. package/dist/eip712/signatureParamTypes.js.map +1 -0
  159. package/dist/encoding/encoding.cjs +73 -0
  160. package/dist/encoding/encoding.cjs.map +1 -0
  161. package/dist/encoding/encoding.d.cts +11 -0
  162. package/dist/encoding/encoding.d.ts +11 -0
  163. package/dist/encoding/encoding.js +49 -0
  164. package/dist/encoding/encoding.js.map +1 -0
  165. package/dist/encoding/index.cjs +25 -0
  166. package/dist/encoding/index.cjs.map +1 -0
  167. package/dist/encoding/index.d.cts +7 -0
  168. package/dist/encoding/index.d.ts +7 -0
  169. package/dist/encoding/index.js +3 -0
  170. package/dist/encoding/index.js.map +1 -0
  171. package/dist/execute/approveDepositAllowance.cjs +38 -0
  172. package/dist/execute/approveDepositAllowance.cjs.map +1 -0
  173. package/dist/execute/approveDepositAllowance.d.cts +18 -0
  174. package/dist/execute/approveDepositAllowance.d.ts +18 -0
  175. package/dist/execute/approveDepositAllowance.js +15 -0
  176. package/dist/execute/approveDepositAllowance.js.map +1 -0
  177. package/dist/execute/depositCollateral.cjs +59 -0
  178. package/dist/execute/depositCollateral.cjs.map +1 -0
  179. package/dist/execute/depositCollateral.d.cts +21 -0
  180. package/dist/execute/depositCollateral.d.ts +21 -0
  181. package/dist/execute/depositCollateral.js +36 -0
  182. package/dist/execute/depositCollateral.js.map +1 -0
  183. package/dist/execute/index.cjs +27 -0
  184. package/dist/execute/index.cjs.map +1 -0
  185. package/dist/execute/index.d.cts +9 -0
  186. package/dist/execute/index.d.ts +9 -0
  187. package/dist/execute/index.js +4 -0
  188. package/dist/execute/index.js.map +1 -0
  189. package/dist/index.cjs +39 -0
  190. package/dist/index.cjs.map +1 -0
  191. package/dist/index.d.cts +67 -0
  192. package/dist/index.d.ts +67 -0
  193. package/dist/index.js +10 -0
  194. package/dist/index.js.map +1 -0
  195. package/dist/types/ChainEnv.cjs +44 -0
  196. package/dist/types/ChainEnv.cjs.map +1 -0
  197. package/dist/types/ChainEnv.d.cts +7 -0
  198. package/dist/types/ChainEnv.d.ts +7 -0
  199. package/dist/types/ChainEnv.js +18 -0
  200. package/dist/types/ChainEnv.js.map +1 -0
  201. package/dist/types/OrderExecutionType.cjs +19 -0
  202. package/dist/types/OrderExecutionType.cjs.map +1 -0
  203. package/dist/types/OrderExecutionType.d.cts +10 -0
  204. package/dist/types/OrderExecutionType.d.ts +10 -0
  205. package/dist/types/OrderExecutionType.js +1 -0
  206. package/dist/types/OrderExecutionType.js.map +1 -0
  207. package/dist/types/balanceTypes.cjs +19 -0
  208. package/dist/types/balanceTypes.cjs.map +1 -0
  209. package/dist/types/balanceTypes.d.cts +38 -0
  210. package/dist/types/balanceTypes.d.ts +38 -0
  211. package/dist/types/balanceTypes.js +1 -0
  212. package/dist/types/balanceTypes.js.map +1 -0
  213. package/dist/types/bytes.cjs +19 -0
  214. package/dist/types/bytes.cjs.map +1 -0
  215. package/dist/types/bytes.d.cts +3 -0
  216. package/dist/types/bytes.d.ts +3 -0
  217. package/dist/types/bytes.js +1 -0
  218. package/dist/types/bytes.js.map +1 -0
  219. package/dist/types/healthTypes.cjs +19 -0
  220. package/dist/types/healthTypes.cjs.map +1 -0
  221. package/dist/types/healthTypes.d.cts +15 -0
  222. package/dist/types/healthTypes.d.ts +15 -0
  223. package/dist/types/healthTypes.js +1 -0
  224. package/dist/types/healthTypes.js.map +1 -0
  225. package/dist/types/index.cjs +45 -0
  226. package/dist/types/index.cjs.map +1 -0
  227. package/dist/types/index.d.cts +15 -0
  228. package/dist/types/index.d.ts +15 -0
  229. package/dist/types/index.js +13 -0
  230. package/dist/types/index.js.map +1 -0
  231. package/dist/types/marketTypes.cjs +19 -0
  232. package/dist/types/marketTypes.cjs.map +1 -0
  233. package/dist/types/marketTypes.d.cts +31 -0
  234. package/dist/types/marketTypes.d.ts +31 -0
  235. package/dist/types/marketTypes.js +1 -0
  236. package/dist/types/marketTypes.js.map +1 -0
  237. package/dist/types/nadoContractTypes.cjs +19 -0
  238. package/dist/types/nadoContractTypes.cjs.map +1 -0
  239. package/dist/types/nadoContractTypes.d.cts +14 -0
  240. package/dist/types/nadoContractTypes.d.ts +14 -0
  241. package/dist/types/nadoContractTypes.js +1 -0
  242. package/dist/types/nadoContractTypes.js.map +1 -0
  243. package/dist/types/orderAppendixTypes.cjs +19 -0
  244. package/dist/types/orderAppendixTypes.cjs.map +1 -0
  245. package/dist/types/orderAppendixTypes.d.cts +54 -0
  246. package/dist/types/orderAppendixTypes.d.ts +54 -0
  247. package/dist/types/orderAppendixTypes.js +1 -0
  248. package/dist/types/orderAppendixTypes.js.map +1 -0
  249. package/dist/types/productTypes.cjs +47 -0
  250. package/dist/types/productTypes.cjs.map +1 -0
  251. package/dist/types/productTypes.d.cts +55 -0
  252. package/dist/types/productTypes.d.ts +55 -0
  253. package/dist/types/productTypes.js +23 -0
  254. package/dist/types/productTypes.js.map +1 -0
  255. package/dist/types/subaccountTypes.cjs +19 -0
  256. package/dist/types/subaccountTypes.cjs.map +1 -0
  257. package/dist/types/subaccountTypes.d.cts +13 -0
  258. package/dist/types/subaccountTypes.d.ts +13 -0
  259. package/dist/types/subaccountTypes.js +1 -0
  260. package/dist/types/subaccountTypes.js.map +1 -0
  261. package/dist/types/viemTypes.cjs +19 -0
  262. package/dist/types/viemTypes.cjs.map +1 -0
  263. package/dist/types/viemTypes.d.cts +23 -0
  264. package/dist/types/viemTypes.d.ts +23 -0
  265. package/dist/types/viemTypes.js +1 -0
  266. package/dist/types/viemTypes.js.map +1 -0
  267. package/dist/utils/asyncResult.cjs +36 -0
  268. package/dist/utils/asyncResult.cjs.map +1 -0
  269. package/dist/utils/asyncResult.d.cts +4 -0
  270. package/dist/utils/asyncResult.d.ts +4 -0
  271. package/dist/utils/asyncResult.js +13 -0
  272. package/dist/utils/asyncResult.js.map +1 -0
  273. package/dist/utils/balanceValue.cjs +43 -0
  274. package/dist/utils/balanceValue.cjs.map +1 -0
  275. package/dist/utils/balanceValue.d.cts +25 -0
  276. package/dist/utils/balanceValue.d.ts +25 -0
  277. package/dist/utils/balanceValue.js +18 -0
  278. package/dist/utils/balanceValue.js.map +1 -0
  279. package/dist/utils/bytes32.cjs +92 -0
  280. package/dist/utils/bytes32.cjs.map +1 -0
  281. package/dist/utils/bytes32.d.cts +47 -0
  282. package/dist/utils/bytes32.d.ts +47 -0
  283. package/dist/utils/bytes32.js +64 -0
  284. package/dist/utils/bytes32.js.map +1 -0
  285. package/dist/utils/bytes32.test.cjs +203 -0
  286. package/dist/utils/bytes32.test.cjs.map +1 -0
  287. package/dist/utils/bytes32.test.d.cts +2 -0
  288. package/dist/utils/bytes32.test.d.ts +2 -0
  289. package/dist/utils/bytes32.test.js +165 -0
  290. package/dist/utils/bytes32.test.js.map +1 -0
  291. package/dist/utils/createDeterministicLinkedSignerPrivateKey.cjs +56 -0
  292. package/dist/utils/createDeterministicLinkedSignerPrivateKey.cjs.map +1 -0
  293. package/dist/utils/createDeterministicLinkedSignerPrivateKey.d.cts +20 -0
  294. package/dist/utils/createDeterministicLinkedSignerPrivateKey.d.ts +20 -0
  295. package/dist/utils/createDeterministicLinkedSignerPrivateKey.js +33 -0
  296. package/dist/utils/createDeterministicLinkedSignerPrivateKey.js.map +1 -0
  297. package/dist/utils/errors/WalletNotProvidedError.cjs +36 -0
  298. package/dist/utils/errors/WalletNotProvidedError.cjs.map +1 -0
  299. package/dist/utils/errors/WalletNotProvidedError.d.cts +5 -0
  300. package/dist/utils/errors/WalletNotProvidedError.d.ts +5 -0
  301. package/dist/utils/errors/WalletNotProvidedError.js +13 -0
  302. package/dist/utils/errors/WalletNotProvidedError.js.map +1 -0
  303. package/dist/utils/errors/index.cjs +25 -0
  304. package/dist/utils/errors/index.cjs.map +1 -0
  305. package/dist/utils/errors/index.d.cts +1 -0
  306. package/dist/utils/errors/index.d.ts +1 -0
  307. package/dist/utils/errors/index.js +3 -0
  308. package/dist/utils/errors/index.js.map +1 -0
  309. package/dist/utils/getValidatedAddress.cjs +37 -0
  310. package/dist/utils/getValidatedAddress.cjs.map +1 -0
  311. package/dist/utils/getValidatedAddress.d.cts +9 -0
  312. package/dist/utils/getValidatedAddress.d.ts +9 -0
  313. package/dist/utils/getValidatedAddress.js +14 -0
  314. package/dist/utils/getValidatedAddress.js.map +1 -0
  315. package/dist/utils/getValidatedHex.cjs +37 -0
  316. package/dist/utils/getValidatedHex.cjs.map +1 -0
  317. package/dist/utils/getValidatedHex.d.cts +9 -0
  318. package/dist/utils/getValidatedHex.d.ts +9 -0
  319. package/dist/utils/getValidatedHex.js +14 -0
  320. package/dist/utils/getValidatedHex.js.map +1 -0
  321. package/dist/utils/index.cjs +53 -0
  322. package/dist/utils/index.cjs.map +1 -0
  323. package/dist/utils/index.d.cts +37 -0
  324. package/dist/utils/index.d.ts +37 -0
  325. package/dist/utils/index.js +17 -0
  326. package/dist/utils/index.js.map +1 -0
  327. package/dist/utils/interest.cjs +94 -0
  328. package/dist/utils/interest.cjs.map +1 -0
  329. package/dist/utils/interest.d.cts +50 -0
  330. package/dist/utils/interest.d.ts +50 -0
  331. package/dist/utils/interest.js +70 -0
  332. package/dist/utils/interest.js.map +1 -0
  333. package/dist/utils/isWriteableContract.cjs +33 -0
  334. package/dist/utils/isWriteableContract.cjs.map +1 -0
  335. package/dist/utils/isWriteableContract.d.cts +6 -0
  336. package/dist/utils/isWriteableContract.d.ts +6 -0
  337. package/dist/utils/isWriteableContract.js +10 -0
  338. package/dist/utils/isWriteableContract.js.map +1 -0
  339. package/dist/utils/mapValues.cjs +38 -0
  340. package/dist/utils/mapValues.cjs.map +1 -0
  341. package/dist/utils/mapValues.d.cts +6 -0
  342. package/dist/utils/mapValues.d.ts +6 -0
  343. package/dist/utils/mapValues.js +15 -0
  344. package/dist/utils/mapValues.js.map +1 -0
  345. package/dist/utils/math/BigDecimals.cjs +37 -0
  346. package/dist/utils/math/BigDecimals.cjs.map +1 -0
  347. package/dist/utils/math/BigDecimals.d.cts +8 -0
  348. package/dist/utils/math/BigDecimals.d.ts +8 -0
  349. package/dist/utils/math/BigDecimals.js +14 -0
  350. package/dist/utils/math/BigDecimals.js.map +1 -0
  351. package/dist/utils/math/bigDecimal.cjs +57 -0
  352. package/dist/utils/math/bigDecimal.cjs.map +1 -0
  353. package/dist/utils/math/bigDecimal.d.cts +18 -0
  354. package/dist/utils/math/bigDecimal.d.ts +18 -0
  355. package/dist/utils/math/bigDecimal.js +23 -0
  356. package/dist/utils/math/bigDecimal.js.map +1 -0
  357. package/dist/utils/math/clamp.cjs +38 -0
  358. package/dist/utils/math/clamp.cjs.map +1 -0
  359. package/dist/utils/math/clamp.d.cts +15 -0
  360. package/dist/utils/math/clamp.d.ts +15 -0
  361. package/dist/utils/math/clamp.js +15 -0
  362. package/dist/utils/math/clamp.js.map +1 -0
  363. package/dist/utils/math/decimalAdjustment.cjs +60 -0
  364. package/dist/utils/math/decimalAdjustment.cjs.map +1 -0
  365. package/dist/utils/math/decimalAdjustment.d.cts +31 -0
  366. package/dist/utils/math/decimalAdjustment.d.ts +31 -0
  367. package/dist/utils/math/decimalAdjustment.js +35 -0
  368. package/dist/utils/math/decimalAdjustment.js.map +1 -0
  369. package/dist/utils/math/index.cjs +37 -0
  370. package/dist/utils/math/index.cjs.map +1 -0
  371. package/dist/utils/math/index.d.cts +8 -0
  372. package/dist/utils/math/index.d.ts +8 -0
  373. package/dist/utils/math/index.js +9 -0
  374. package/dist/utils/math/index.js.map +1 -0
  375. package/dist/utils/math/sumBigDecimalBy.cjs +36 -0
  376. package/dist/utils/math/sumBigDecimalBy.cjs.map +1 -0
  377. package/dist/utils/math/sumBigDecimalBy.d.cts +10 -0
  378. package/dist/utils/math/sumBigDecimalBy.d.ts +10 -0
  379. package/dist/utils/math/sumBigDecimalBy.js +13 -0
  380. package/dist/utils/math/sumBigDecimalBy.js.map +1 -0
  381. package/dist/utils/math/toBigInt.cjs +34 -0
  382. package/dist/utils/math/toBigInt.cjs.map +1 -0
  383. package/dist/utils/math/toBigInt.d.cts +11 -0
  384. package/dist/utils/math/toBigInt.d.ts +11 -0
  385. package/dist/utils/math/toBigInt.js +11 -0
  386. package/dist/utils/math/toBigInt.js.map +1 -0
  387. package/dist/utils/math/toIntegerString.cjs +34 -0
  388. package/dist/utils/math/toIntegerString.cjs.map +1 -0
  389. package/dist/utils/math/toIntegerString.d.cts +11 -0
  390. package/dist/utils/math/toIntegerString.d.ts +11 -0
  391. package/dist/utils/math/toIntegerString.js +11 -0
  392. package/dist/utils/math/toIntegerString.js.map +1 -0
  393. package/dist/utils/orders/appendix/appendixTWAPValue.cjs +50 -0
  394. package/dist/utils/orders/appendix/appendixTWAPValue.cjs.map +1 -0
  395. package/dist/utils/orders/appendix/appendixTWAPValue.d.cts +31 -0
  396. package/dist/utils/orders/appendix/appendixTWAPValue.d.ts +31 -0
  397. package/dist/utils/orders/appendix/appendixTWAPValue.js +26 -0
  398. package/dist/utils/orders/appendix/appendixTWAPValue.js.map +1 -0
  399. package/dist/utils/orders/appendix/bitMaskValue.cjs +34 -0
  400. package/dist/utils/orders/appendix/bitMaskValue.cjs.map +1 -0
  401. package/dist/utils/orders/appendix/bitMaskValue.d.cts +10 -0
  402. package/dist/utils/orders/appendix/bitMaskValue.d.ts +10 -0
  403. package/dist/utils/orders/appendix/bitMaskValue.js +11 -0
  404. package/dist/utils/orders/appendix/bitMaskValue.js.map +1 -0
  405. package/dist/utils/orders/appendix/index.cjs +33 -0
  406. package/dist/utils/orders/appendix/index.cjs.map +1 -0
  407. package/dist/utils/orders/appendix/index.d.cts +9 -0
  408. package/dist/utils/orders/appendix/index.d.ts +9 -0
  409. package/dist/utils/orders/appendix/index.js +7 -0
  410. package/dist/utils/orders/appendix/index.js.map +1 -0
  411. package/dist/utils/orders/appendix/orderAppendix.test.cjs +165 -0
  412. package/dist/utils/orders/appendix/orderAppendix.test.cjs.map +1 -0
  413. package/dist/utils/orders/appendix/orderAppendix.test.d.cts +2 -0
  414. package/dist/utils/orders/appendix/orderAppendix.test.d.ts +2 -0
  415. package/dist/utils/orders/appendix/orderAppendix.test.js +120 -0
  416. package/dist/utils/orders/appendix/orderAppendix.test.js.map +1 -0
  417. package/dist/utils/orders/appendix/packOrderAppendix.cjs +88 -0
  418. package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -0
  419. package/dist/utils/orders/appendix/packOrderAppendix.d.cts +12 -0
  420. package/dist/utils/orders/appendix/packOrderAppendix.d.ts +12 -0
  421. package/dist/utils/orders/appendix/packOrderAppendix.js +65 -0
  422. package/dist/utils/orders/appendix/packOrderAppendix.js.map +1 -0
  423. package/dist/utils/orders/appendix/types.cjs +19 -0
  424. package/dist/utils/orders/appendix/types.cjs.map +1 -0
  425. package/dist/utils/orders/appendix/types.d.cts +19 -0
  426. package/dist/utils/orders/appendix/types.d.ts +19 -0
  427. package/dist/utils/orders/appendix/types.js +1 -0
  428. package/dist/utils/orders/appendix/types.js.map +1 -0
  429. package/dist/utils/orders/appendix/unpackOrderAppendix.cjs +106 -0
  430. package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -0
  431. package/dist/utils/orders/appendix/unpackOrderAppendix.d.cts +12 -0
  432. package/dist/utils/orders/appendix/unpackOrderAppendix.d.ts +12 -0
  433. package/dist/utils/orders/appendix/unpackOrderAppendix.js +83 -0
  434. package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -0
  435. package/dist/utils/orders/index.cjs +29 -0
  436. package/dist/utils/orders/index.cjs.map +1 -0
  437. package/dist/utils/orders/index.d.cts +11 -0
  438. package/dist/utils/orders/index.d.ts +11 -0
  439. package/dist/utils/orders/index.js +5 -0
  440. package/dist/utils/orders/index.js.map +1 -0
  441. package/dist/utils/orders/orderNonce.cjs +44 -0
  442. package/dist/utils/orders/orderNonce.cjs.map +1 -0
  443. package/dist/utils/orders/orderNonce.d.cts +14 -0
  444. package/dist/utils/orders/orderNonce.d.ts +14 -0
  445. package/dist/utils/orders/orderNonce.js +20 -0
  446. package/dist/utils/orders/orderNonce.js.map +1 -0
  447. package/dist/utils/orders/recvTime.cjs +33 -0
  448. package/dist/utils/orders/recvTime.cjs.map +1 -0
  449. package/dist/utils/orders/recvTime.d.cts +9 -0
  450. package/dist/utils/orders/recvTime.d.ts +9 -0
  451. package/dist/utils/orders/recvTime.js +10 -0
  452. package/dist/utils/orders/recvTime.js.map +1 -0
  453. package/dist/utils/productTypeFilter.cjs +49 -0
  454. package/dist/utils/productTypeFilter.cjs.map +1 -0
  455. package/dist/utils/productTypeFilter.d.cts +11 -0
  456. package/dist/utils/productTypeFilter.d.ts +11 -0
  457. package/dist/utils/productTypeFilter.js +25 -0
  458. package/dist/utils/productTypeFilter.js.map +1 -0
  459. package/dist/utils/time.cjs +47 -0
  460. package/dist/utils/time.cjs.map +1 -0
  461. package/dist/utils/time.d.cts +17 -0
  462. package/dist/utils/time.d.ts +17 -0
  463. package/dist/utils/time.js +22 -0
  464. package/dist/utils/time.js.map +1 -0
  465. package/dist/utils/toPrintableObject.cjs +51 -0
  466. package/dist/utils/toPrintableObject.cjs.map +1 -0
  467. package/dist/utils/toPrintableObject.d.cts +6 -0
  468. package/dist/utils/toPrintableObject.d.ts +6 -0
  469. package/dist/utils/toPrintableObject.js +28 -0
  470. package/dist/utils/toPrintableObject.js.map +1 -0
  471. package/package.json +49 -0
  472. package/src/abis/Clearinghouse.ts +861 -0
  473. package/src/abis/ERC20.ts +185 -0
  474. package/src/abis/Endpoint.ts +559 -0
  475. package/src/abis/MockERC20.ts +311 -0
  476. package/src/abis/PerpEngine.ts +856 -0
  477. package/src/abis/Querier.ts +1492 -0
  478. package/src/abis/SpotEngine.ts +907 -0
  479. package/src/abis/WithdrawPool.ts +277 -0
  480. package/src/abis/index.ts +9 -0
  481. package/src/abis/nadoAbis.ts +19 -0
  482. package/src/consts/chainEnvToChain.ts +16 -0
  483. package/src/consts/index.ts +2 -0
  484. package/src/consts/productIds.ts +3 -0
  485. package/src/deployments/core/deployment.InkSepolia.json +13 -0
  486. package/src/deployments/core/deployment.arbitrumOne.json +18 -0
  487. package/src/deployments/core/deployment.localhost.json +18 -0
  488. package/src/deployments/index.ts +40 -0
  489. package/src/eip712/eip712ValueTypes.ts +83 -0
  490. package/src/eip712/getNadoEIP712Domain.ts +20 -0
  491. package/src/eip712/getNadoEIP712PrimaryType.ts +13 -0
  492. package/src/eip712/getNadoEIP712Types.ts +113 -0
  493. package/src/eip712/getNadoEIP712Values.ts +248 -0
  494. package/src/eip712/getOrderVerifyingAddress.ts +9 -0
  495. package/src/eip712/getSignedTransactionRequest.ts +30 -0
  496. package/src/eip712/index.ts +10 -0
  497. package/src/eip712/orderDigest.ts +28 -0
  498. package/src/eip712/signableRequestType.ts +32 -0
  499. package/src/eip712/signatureParamTypes.ts +84 -0
  500. package/src/encoding/encoding.ts +50 -0
  501. package/src/encoding/index.ts +1 -0
  502. package/src/execute/approveDepositAllowance.ts +20 -0
  503. package/src/execute/depositCollateral.ts +43 -0
  504. package/src/execute/index.ts +2 -0
  505. package/src/index.ts +8 -0
  506. package/src/types/ChainEnv.ts +13 -0
  507. package/src/types/OrderExecutionType.ts +8 -0
  508. package/src/types/balanceTypes.ts +47 -0
  509. package/src/types/bytes.ts +1 -0
  510. package/src/types/healthTypes.ts +17 -0
  511. package/src/types/index.ts +11 -0
  512. package/src/types/marketTypes.ts +40 -0
  513. package/src/types/nadoContractTypes.ts +14 -0
  514. package/src/types/orderAppendixTypes.ts +58 -0
  515. package/src/types/productTypes.ts +76 -0
  516. package/src/types/subaccountTypes.ts +13 -0
  517. package/src/types/viemTypes.ts +42 -0
  518. package/src/utils/asyncResult.ts +12 -0
  519. package/src/utils/balanceValue.ts +42 -0
  520. package/src/utils/bytes32.test.ts +117 -0
  521. package/src/utils/bytes32.ts +110 -0
  522. package/src/utils/createDeterministicLinkedSignerPrivateKey.ts +46 -0
  523. package/src/utils/errors/WalletNotProvidedError.ts +6 -0
  524. package/src/utils/errors/index.ts +1 -0
  525. package/src/utils/getValidatedAddress.ts +13 -0
  526. package/src/utils/getValidatedHex.ts +13 -0
  527. package/src/utils/index.ts +15 -0
  528. package/src/utils/interest.ts +133 -0
  529. package/src/utils/isWriteableContract.ts +11 -0
  530. package/src/utils/mapValues.ts +18 -0
  531. package/src/utils/math/BigDecimals.ts +8 -0
  532. package/src/utils/math/bigDecimal.ts +32 -0
  533. package/src/utils/math/clamp.ts +26 -0
  534. package/src/utils/math/decimalAdjustment.ts +65 -0
  535. package/src/utils/math/index.ts +7 -0
  536. package/src/utils/math/sumBigDecimalBy.ts +18 -0
  537. package/src/utils/math/toBigInt.ts +11 -0
  538. package/src/utils/math/toIntegerString.ts +11 -0
  539. package/src/utils/orders/appendix/appendixTWAPValue.ts +51 -0
  540. package/src/utils/orders/appendix/bitMaskValue.ts +11 -0
  541. package/src/utils/orders/appendix/index.ts +5 -0
  542. package/src/utils/orders/appendix/orderAppendix.test.ts +121 -0
  543. package/src/utils/orders/appendix/packOrderAppendix.ts +71 -0
  544. package/src/utils/orders/appendix/types.ts +17 -0
  545. package/src/utils/orders/appendix/unpackOrderAppendix.ts +90 -0
  546. package/src/utils/orders/index.ts +3 -0
  547. package/src/utils/orders/orderNonce.ts +32 -0
  548. package/src/utils/orders/recvTime.ts +9 -0
  549. package/src/utils/productTypeFilter.ts +23 -0
  550. package/src/utils/time.ts +21 -0
  551. package/src/utils/toPrintableObject.ts +25 -0
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // ../../node_modules/@jest/globals/build/index.js
29
+ var require_build = __commonJS({
30
+ "../../node_modules/@jest/globals/build/index.js"(exports2, module2) {
31
+ "use strict";
32
+ (() => {
33
+ "use strict";
34
+ var __webpack_exports__ = {};
35
+ throw new Error("Do not import `@jest/globals` outside of the Jest test environment");
36
+ module2.exports = __webpack_exports__;
37
+ })();
38
+ }
39
+ });
40
+
41
+ // src/utils/orders/appendix/orderAppendix.test.ts
42
+ var import_globals = __toESM(require_build(), 1);
43
+ var import_packOrderAppendix = require("./packOrderAppendix.cjs");
44
+ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
45
+ (0, import_globals.describe)("OrderAppendix packing/unpacking", () => {
46
+ (0, import_globals.it)("should pack and unpack an order appendix without iso/twap values", () => {
47
+ const appendix = {
48
+ orderExecutionType: "default",
49
+ triggerType: "price"
50
+ };
51
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
52
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
53
+ (0, import_globals.expect)(packed).toBe(4096n);
54
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
55
+ (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
56
+ (0, import_globals.expect)(unpacked.reduceOnly).toBeFalsy();
57
+ });
58
+ (0, import_globals.it)("should handle reduceOnly true", () => {
59
+ const appendix = {
60
+ orderExecutionType: "default",
61
+ triggerType: "price",
62
+ reduceOnly: true
63
+ };
64
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
65
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
66
+ (0, import_globals.expect)(packed).toBe(6144n);
67
+ (0, import_globals.expect)(unpacked.reduceOnly).toBe(true);
68
+ });
69
+ (0, import_globals.it)("should handle all orderExecutionType values", () => {
70
+ const types = ["default", "ioc", "fok", "post_only"];
71
+ for (const type of types) {
72
+ const appendix = {
73
+ orderExecutionType: type,
74
+ triggerType: "price"
75
+ };
76
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
77
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
78
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(type);
79
+ }
80
+ });
81
+ (0, import_globals.it)("should handle all triggerType values", () => {
82
+ const triggers = ["price", "twap", "twap_custom_amounts"];
83
+ for (const trigger of triggers) {
84
+ const appendix = {
85
+ orderExecutionType: "default",
86
+ triggerType: trigger
87
+ };
88
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
89
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
90
+ (0, import_globals.expect)(unpacked.triggerType).toBe(trigger);
91
+ }
92
+ });
93
+ (0, import_globals.it)("should handle isolated margin", () => {
94
+ const appendix = {
95
+ orderExecutionType: "default",
96
+ triggerType: "price",
97
+ isolated: { margin: 123456789012345678901234n }
98
+ };
99
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
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);
103
+ });
104
+ (0, import_globals.it)("should handle TWAP fields", () => {
105
+ const appendix = {
106
+ orderExecutionType: "default",
107
+ triggerType: "twap",
108
+ twap: { numOrders: 10, slippageFrac: 5e-3 }
109
+ };
110
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
111
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
112
+ (0, import_globals.expect)(packed).toBe(792281717376363744483197591552n);
113
+ (0, import_globals.expect)(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 5e-3 });
114
+ });
115
+ (0, import_globals.it)("should handle max values for all fields for iso orders", () => {
116
+ const appendix = {
117
+ orderExecutionType: "post_only",
118
+ triggerType: void 0,
119
+ reduceOnly: true,
120
+ isolated: { margin: 79228162514264337593543950335n }
121
+ // 2^96-1
122
+ };
123
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
124
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
125
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
126
+ (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
127
+ (0, import_globals.expect)(unpacked.reduceOnly).toBe(appendix.reduceOnly);
128
+ (0, import_globals.expect)(unpacked.isolated?.margin).toBe(79228162514264337593543950335n);
129
+ (0, import_globals.expect)(unpacked.twap).toBe(void 0);
130
+ (0, import_globals.expect)(packed).toBe(340282366920938463463374607427473248000n);
131
+ });
132
+ (0, import_globals.it)("should handle max values for all fields for TWAP orders", () => {
133
+ const appendix = {
134
+ orderExecutionType: "post_only",
135
+ triggerType: "twap_custom_amounts",
136
+ reduceOnly: true,
137
+ twap: {
138
+ // max 32-bit unsigned int
139
+ numOrders: 4294967295,
140
+ slippageFrac: 1e-6
141
+ }
142
+ };
143
+ const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
144
+ const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
145
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
146
+ (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
147
+ (0, import_globals.expect)(unpacked.reduceOnly).toBe(appendix.reduceOnly);
148
+ (0, import_globals.expect)(unpacked.twap?.slippageFrac).toBe(1e-6);
149
+ (0, import_globals.expect)(unpacked.twap?.numOrders).toBe(4294967295);
150
+ (0, import_globals.expect)(packed).toBe(340282366841710300967557013911933828608n);
151
+ });
152
+ });
153
+ /*! Bundled license information:
154
+
155
+ @jest/globals/build/index.js:
156
+ (*!
157
+ * /**
158
+ * * Copyright (c) Meta Platforms, Inc. and affiliates.
159
+ * *
160
+ * * This source code is licensed under the MIT license found in the
161
+ * * LICENSE file in the root directory of this source tree.
162
+ * * /
163
+ *)
164
+ */
165
+ //# sourceMappingURL=orderAppendix.test.cjs.map
@@ -0,0 +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":"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","names":["exports","module"]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,120 @@
1
+ import {
2
+ require_build
3
+ } from "../../../chunk-TUJ4HQKF.js";
4
+ import {
5
+ __toESM
6
+ } from "../../../chunk-5WRI5ZAA.js";
7
+
8
+ // src/utils/orders/appendix/orderAppendix.test.ts
9
+ var import_globals = __toESM(require_build(), 1);
10
+ import { packOrderAppendix } from "./packOrderAppendix.js";
11
+ import { unpackOrderAppendix } from "./unpackOrderAppendix.js";
12
+ (0, import_globals.describe)("OrderAppendix packing/unpacking", () => {
13
+ (0, import_globals.it)("should pack and unpack an order appendix without iso/twap values", () => {
14
+ const appendix = {
15
+ orderExecutionType: "default",
16
+ triggerType: "price"
17
+ };
18
+ const packed = packOrderAppendix(appendix);
19
+ const unpacked = unpackOrderAppendix(packed);
20
+ (0, import_globals.expect)(packed).toBe(4096n);
21
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
22
+ (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
23
+ (0, import_globals.expect)(unpacked.reduceOnly).toBeFalsy();
24
+ });
25
+ (0, import_globals.it)("should handle reduceOnly true", () => {
26
+ const appendix = {
27
+ orderExecutionType: "default",
28
+ triggerType: "price",
29
+ reduceOnly: true
30
+ };
31
+ const packed = packOrderAppendix(appendix);
32
+ const unpacked = unpackOrderAppendix(packed);
33
+ (0, import_globals.expect)(packed).toBe(6144n);
34
+ (0, import_globals.expect)(unpacked.reduceOnly).toBe(true);
35
+ });
36
+ (0, import_globals.it)("should handle all orderExecutionType values", () => {
37
+ const types = ["default", "ioc", "fok", "post_only"];
38
+ for (const type of types) {
39
+ const appendix = {
40
+ orderExecutionType: type,
41
+ triggerType: "price"
42
+ };
43
+ const packed = packOrderAppendix(appendix);
44
+ const unpacked = unpackOrderAppendix(packed);
45
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(type);
46
+ }
47
+ });
48
+ (0, import_globals.it)("should handle all triggerType values", () => {
49
+ const triggers = ["price", "twap", "twap_custom_amounts"];
50
+ for (const trigger of triggers) {
51
+ const appendix = {
52
+ orderExecutionType: "default",
53
+ triggerType: trigger
54
+ };
55
+ const packed = packOrderAppendix(appendix);
56
+ const unpacked = unpackOrderAppendix(packed);
57
+ (0, import_globals.expect)(unpacked.triggerType).toBe(trigger);
58
+ }
59
+ });
60
+ (0, import_globals.it)("should handle isolated margin", () => {
61
+ const appendix = {
62
+ orderExecutionType: "default",
63
+ triggerType: "price",
64
+ isolated: { margin: 123456789012345678901234n }
65
+ };
66
+ const packed = packOrderAppendix(appendix);
67
+ const unpacked = unpackOrderAppendix(packed);
68
+ (0, import_globals.expect)(packed).toBe(530242871277196831127717244047616n);
69
+ (0, import_globals.expect)(unpacked.isolated?.margin).toBe(123456789012345678901234n);
70
+ });
71
+ (0, import_globals.it)("should handle TWAP fields", () => {
72
+ const appendix = {
73
+ orderExecutionType: "default",
74
+ triggerType: "twap",
75
+ twap: { numOrders: 10, slippageFrac: 5e-3 }
76
+ };
77
+ const packed = packOrderAppendix(appendix);
78
+ const unpacked = unpackOrderAppendix(packed);
79
+ (0, import_globals.expect)(packed).toBe(792281717376363744483197591552n);
80
+ (0, import_globals.expect)(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 5e-3 });
81
+ });
82
+ (0, import_globals.it)("should handle max values for all fields for iso orders", () => {
83
+ const appendix = {
84
+ orderExecutionType: "post_only",
85
+ triggerType: void 0,
86
+ reduceOnly: true,
87
+ isolated: { margin: 79228162514264337593543950335n }
88
+ // 2^96-1
89
+ };
90
+ const packed = packOrderAppendix(appendix);
91
+ const unpacked = unpackOrderAppendix(packed);
92
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
93
+ (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
94
+ (0, import_globals.expect)(unpacked.reduceOnly).toBe(appendix.reduceOnly);
95
+ (0, import_globals.expect)(unpacked.isolated?.margin).toBe(79228162514264337593543950335n);
96
+ (0, import_globals.expect)(unpacked.twap).toBe(void 0);
97
+ (0, import_globals.expect)(packed).toBe(340282366920938463463374607427473248000n);
98
+ });
99
+ (0, import_globals.it)("should handle max values for all fields for TWAP orders", () => {
100
+ const appendix = {
101
+ orderExecutionType: "post_only",
102
+ triggerType: "twap_custom_amounts",
103
+ reduceOnly: true,
104
+ twap: {
105
+ // max 32-bit unsigned int
106
+ numOrders: 4294967295,
107
+ slippageFrac: 1e-6
108
+ }
109
+ };
110
+ const packed = packOrderAppendix(appendix);
111
+ const unpacked = unpackOrderAppendix(packed);
112
+ (0, import_globals.expect)(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
113
+ (0, import_globals.expect)(unpacked.triggerType).toBe(appendix.triggerType);
114
+ (0, import_globals.expect)(unpacked.reduceOnly).toBe(appendix.reduceOnly);
115
+ (0, import_globals.expect)(unpacked.twap?.slippageFrac).toBe(1e-6);
116
+ (0, import_globals.expect)(unpacked.twap?.numOrders).toBe(4294967295);
117
+ (0, import_globals.expect)(packed).toBe(340282366841710300967557013911933828608n);
118
+ });
119
+ });
120
+ //# sourceMappingURL=orderAppendix.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/orderAppendix.test.ts"],"sourcesContent":["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,qBAAqC;AAErC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AAAA,IAEpC,yBAAS,mCAAmC,MAAM;AAChD,yBAAG,oEAAoE,MAAM;AAC3E,UAAM,WAA0B;AAAA,MAC9B,oBAAoB;AAAA,MACpB,aAAa;AAAA,IACf;AACA,UAAM,SAAS,kBAAkB,QAAQ;AACzC,UAAM,WAAW,oBAAoB,MAAM;AAC3C,+BAAO,MAAM,EAAE,KAAK,KAAK;AACzB,+BAAO,SAAS,kBAAkB,EAAE,KAAK,SAAS,kBAAkB;AACpE,+BAAO,SAAS,WAAW,EAAE,KAAK,SAAS,WAAW;AACtD,+BAAO,SAAS,UAAU,EAAE,UAAU;AAAA,EACxC,CAAC;AAED,yBAAG,iCAAiC,MAAM;AACxC,UAAM,WAA0B;AAAA,MAC9B,oBAAoB;AAAA,MACpB,aAAa;AAAA,MACb,YAAY;AAAA,IACd;AACA,UAAM,SAAS,kBAAkB,QAAQ;AACzC,UAAM,WAAW,oBAAoB,MAAM;AAC3C,+BAAO,MAAM,EAAE,KAAK,KAAK;AACzB,+BAAO,SAAS,UAAU,EAAE,KAAK,IAAI;AAAA,EACvC,CAAC;AAED,yBAAG,+CAA+C,MAAM;AACtD,UAAM,QAA8B,CAAC,WAAW,OAAO,OAAO,WAAW;AACzE,eAAW,QAAQ,OAAO;AACxB,YAAM,WAA0B;AAAA,QAC9B,oBAAoB;AAAA,QACpB,aAAa;AAAA,MACf;AACA,YAAM,SAAS,kBAAkB,QAAQ;AACzC,YAAM,WAAW,oBAAoB,MAAM;AAC3C,iCAAO,SAAS,kBAAkB,EAAE,KAAK,IAAI;AAAA,IAC/C;AAAA,EACF,CAAC;AAED,yBAAG,wCAAwC,MAAM;AAC/C,UAAM,WAAW,CAAC,SAAS,QAAQ,qBAAqB;AACxD,eAAW,WAAW,UAAU;AAC9B,YAAM,WAA0B;AAAA,QAC9B,oBAAoB;AAAA,QACpB,aAAa;AAAA,MACf;AACA,YAAM,SAAS,kBAAkB,QAAQ;AACzC,YAAM,WAAW,oBAAoB,MAAM;AAC3C,iCAAO,SAAS,WAAW,EAAE,KAAK,OAAO;AAAA,IAC3C;AAAA,EACF,CAAC;AAED,yBAAG,iCAAiC,MAAM;AACxC,UAAM,WAA0B;AAAA,MAC9B,oBAAoB;AAAA,MACpB,aAAa;AAAA,MAEb,UAAU,EAAE,QAAQ,0BAA0B;AAAA,IAChD;AACA,UAAM,SAAS,kBAAkB,QAAQ;AACzC,UAAM,WAAW,oBAAoB,MAAM;AAC3C,+BAAO,MAAM,EAAE,KAAK,kCAAkC;AACtD,+BAAO,SAAS,UAAU,MAAM,EAAE,KAAK,yBAAyB;AAAA,EAClE,CAAC;AAED,yBAAG,6BAA6B,MAAM;AACpC,UAAM,WAA0B;AAAA,MAC9B,oBAAoB;AAAA,MACpB,aAAa;AAAA,MAEb,MAAM,EAAE,WAAW,IAAI,cAAc,KAAM;AAAA,IAC7C;AACA,UAAM,SAAS,kBAAkB,QAAQ;AACzC,UAAM,WAAW,oBAAoB,MAAM;AAC3C,+BAAO,MAAM,EAAE,KAAK,+BAA+B;AACnD,+BAAO,SAAS,IAAI,EAAE,cAAc,EAAE,WAAW,IAAI,cAAc,KAAM,CAAC;AAAA,EAC5E,CAAC;AAED,yBAAG,0DAA0D,MAAM;AACjE,UAAM,WAA0B;AAAA,MAC9B,oBAAoB;AAAA,MACpB,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,UAAU,EAAE,QAAQ,+BAA+B;AAAA;AAAA,IACrD;AACA,UAAM,SAAS,kBAAkB,QAAQ;AACzC,UAAM,WAAW,oBAAoB,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,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,SAAS,kBAAkB,QAAQ;AACzC,UAAM,WAAW,oBAAoB,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":[]}
@@ -0,0 +1,88 @@
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/packOrderAppendix.ts
21
+ var packOrderAppendix_exports = {};
22
+ __export(packOrderAppendix_exports, {
23
+ packOrderAppendix: () => packOrderAppendix
24
+ });
25
+ module.exports = __toCommonJS(packOrderAppendix_exports);
26
+ var import_toBigInt = require("../../math/toBigInt.cjs");
27
+ var import_appendixTWAPValue = require("./appendixTWAPValue.cjs");
28
+ var import_bitMaskValue = require("./bitMaskValue.cjs");
29
+ function mapOrderAppendixToBitValues(appendix) {
30
+ const value = (() => {
31
+ if (appendix.twap) {
32
+ return (0, import_appendixTWAPValue.packTWAPOrderAppendixValue)(appendix.twap);
33
+ }
34
+ if (appendix.isolated) {
35
+ return (0, import_toBigInt.toBigInt)(appendix.isolated.margin);
36
+ }
37
+ return 0n;
38
+ })();
39
+ const trigger = (() => {
40
+ switch (appendix.triggerType) {
41
+ case "price":
42
+ return 1;
43
+ case "twap":
44
+ return 2;
45
+ case "twap_custom_amounts":
46
+ return 3;
47
+ default:
48
+ return 0;
49
+ }
50
+ })();
51
+ const orderType = (() => {
52
+ switch (appendix.orderExecutionType) {
53
+ case "default":
54
+ return 0;
55
+ case "ioc":
56
+ return 1;
57
+ case "fok":
58
+ return 2;
59
+ case "post_only":
60
+ return 3;
61
+ }
62
+ })();
63
+ return {
64
+ value,
65
+ reserved: 0,
66
+ trigger,
67
+ reduceOnly: appendix.reduceOnly ? 1 : 0,
68
+ orderType,
69
+ isolated: appendix.isolated ? 1 : 0,
70
+ version: 0
71
+ };
72
+ }
73
+ function packOrderAppendix(appendix) {
74
+ const bits = mapOrderAppendixToBitValues(appendix);
75
+ let packed = (0, import_bitMaskValue.bitMaskValue)(bits.value, 96);
76
+ packed = packed << 18n | (0, import_bitMaskValue.bitMaskValue)(bits.reserved, 18);
77
+ packed = packed << 2n | (0, import_bitMaskValue.bitMaskValue)(bits.trigger, 2);
78
+ packed = packed << 1n | (0, import_bitMaskValue.bitMaskValue)(bits.reduceOnly, 1);
79
+ packed = packed << 2n | (0, import_bitMaskValue.bitMaskValue)(bits.orderType, 2);
80
+ packed = packed << 1n | (0, import_bitMaskValue.bitMaskValue)(bits.isolated, 1);
81
+ packed = packed << 8n | (0, import_bitMaskValue.bitMaskValue)(bits.version, 8);
82
+ return packed;
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ packOrderAppendix
87
+ });
88
+ //# sourceMappingURL=packOrderAppendix.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTWAPOrderAppendixValue } from './appendixTWAPValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTWAPOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAyB;AACzB,+BAA2C;AAC3C,0BAA6B;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,iBAAO,qDAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,iBAAO,0BAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,aAAS,kCAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,UAAO,kCAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,SAAM,kCAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,SAAM,kCAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { OrderAppendix } from '../../../types/orderAppendixTypes.cjs';
2
+ import '../../math/bigDecimal.cjs';
3
+ import 'bignumber.js';
4
+ import '../../../types/OrderExecutionType.cjs';
5
+
6
+ /**
7
+ * Pack the OrderAppendix fields into a single bigint.
8
+ * @param appendix
9
+ */
10
+ declare function packOrderAppendix(appendix: OrderAppendix): bigint;
11
+
12
+ export { packOrderAppendix };
@@ -0,0 +1,12 @@
1
+ import { OrderAppendix } from '../../../types/orderAppendixTypes.js';
2
+ import '../../math/bigDecimal.js';
3
+ import 'bignumber.js';
4
+ import '../../../types/OrderExecutionType.js';
5
+
6
+ /**
7
+ * Pack the OrderAppendix fields into a single bigint.
8
+ * @param appendix
9
+ */
10
+ declare function packOrderAppendix(appendix: OrderAppendix): bigint;
11
+
12
+ export { packOrderAppendix };
@@ -0,0 +1,65 @@
1
+ import "../../../chunk-5WRI5ZAA.js";
2
+
3
+ // src/utils/orders/appendix/packOrderAppendix.ts
4
+ import { toBigInt } from "../../math/toBigInt.js";
5
+ import { packTWAPOrderAppendixValue } from "./appendixTWAPValue.js";
6
+ import { bitMaskValue } from "./bitMaskValue.js";
7
+ function mapOrderAppendixToBitValues(appendix) {
8
+ const value = (() => {
9
+ if (appendix.twap) {
10
+ return packTWAPOrderAppendixValue(appendix.twap);
11
+ }
12
+ if (appendix.isolated) {
13
+ return toBigInt(appendix.isolated.margin);
14
+ }
15
+ return 0n;
16
+ })();
17
+ const trigger = (() => {
18
+ switch (appendix.triggerType) {
19
+ case "price":
20
+ return 1;
21
+ case "twap":
22
+ return 2;
23
+ case "twap_custom_amounts":
24
+ return 3;
25
+ default:
26
+ return 0;
27
+ }
28
+ })();
29
+ const orderType = (() => {
30
+ switch (appendix.orderExecutionType) {
31
+ case "default":
32
+ return 0;
33
+ case "ioc":
34
+ return 1;
35
+ case "fok":
36
+ return 2;
37
+ case "post_only":
38
+ return 3;
39
+ }
40
+ })();
41
+ return {
42
+ value,
43
+ reserved: 0,
44
+ trigger,
45
+ reduceOnly: appendix.reduceOnly ? 1 : 0,
46
+ orderType,
47
+ isolated: appendix.isolated ? 1 : 0,
48
+ version: 0
49
+ };
50
+ }
51
+ function packOrderAppendix(appendix) {
52
+ const bits = mapOrderAppendixToBitValues(appendix);
53
+ let packed = bitMaskValue(bits.value, 96);
54
+ packed = packed << 18n | bitMaskValue(bits.reserved, 18);
55
+ packed = packed << 2n | bitMaskValue(bits.trigger, 2);
56
+ packed = packed << 1n | bitMaskValue(bits.reduceOnly, 1);
57
+ packed = packed << 2n | bitMaskValue(bits.orderType, 2);
58
+ packed = packed << 1n | bitMaskValue(bits.isolated, 1);
59
+ packed = packed << 8n | bitMaskValue(bits.version, 8);
60
+ return packed;
61
+ }
62
+ export {
63
+ packOrderAppendix
64
+ };
65
+ //# sourceMappingURL=packOrderAppendix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTWAPOrderAppendixValue } from './appendixTWAPValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTWAPOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;AACA,SAAS,gBAAgB;AACzB,SAAS,kCAAkC;AAC3C,SAAS,oBAAoB;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,aAAO,2BAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,aAAO,SAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,SAAS,aAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,MAAO,aAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,KAAM,aAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,KAAM,aAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
@@ -0,0 +1,19 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/utils/orders/appendix/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
19
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/utils/orders/appendix/types.ts"],"sourcesContent":["/**\n * Bit layout for OrderAppendix packing (MSB → LSB):\n *\n * | value | reserved | trigger | reduceOnly | orderType | isolated | version |\n * |-----------|----------|---------|------------|-----------|----------|---------|\n * | 127..32 | 31..14 | 13..12 | 11 | 10..9 | 8 | 7..0 |\n * | 96 bits | 18 bits | 2 bits | 1 bit | 2 bits | 1 bit | 8 bits |\n */\nexport interface PackedOrderAppendixBits {\n value: bigint; // 96 bits\n reserved: number; // 18 bits, set to 0\n trigger: number; // 2 bits\n reduceOnly: number; // 1 bit\n orderType: number; // 2 bits\n isolated: number; // 1 bit\n version: number; // 8 bits, set to 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Bit layout for OrderAppendix packing (MSB → LSB):
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 |
8
+ */
9
+ interface PackedOrderAppendixBits {
10
+ value: bigint;
11
+ reserved: number;
12
+ trigger: number;
13
+ reduceOnly: number;
14
+ orderType: number;
15
+ isolated: number;
16
+ version: number;
17
+ }
18
+
19
+ export type { PackedOrderAppendixBits };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Bit layout for OrderAppendix packing (MSB → LSB):
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 |
8
+ */
9
+ interface PackedOrderAppendixBits {
10
+ value: bigint;
11
+ reserved: number;
12
+ trigger: number;
13
+ reduceOnly: number;
14
+ orderType: number;
15
+ isolated: number;
16
+ version: number;
17
+ }
18
+
19
+ export type { PackedOrderAppendixBits };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}