@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
@@ -3,13 +3,13 @@ export { Bytes } from './bytes.cjs';
3
3
  export { ALL_CHAIN_ENVS, ChainEnv, LOCAL_CHAIN_ENVS, MAINNET_CHAIN_ENVS, TESTNET_CHAIN_ENVS } from './ChainEnv.cjs';
4
4
  export { HealthGroup, HealthStatus, HealthStatusByType, HealthType } from './healthTypes.cjs';
5
5
  export { Market, MarketWithProduct, PerpMarket, SpotMarket } from './marketTypes.cjs';
6
+ export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.cjs';
7
+ export { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.cjs';
8
+ export { OrderExecutionType } from './OrderExecutionType.cjs';
6
9
  export { PerpProduct, Product, ProductEngineType, SpotProduct, toProductEngineType } from './productTypes.cjs';
7
10
  export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccountTypes.cjs';
8
- export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.cjs';
9
11
  export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './viemTypes.cjs';
10
- export { OrderExecutionType } from './OrderExecutionType.cjs';
11
- export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.cjs';
12
12
  import 'bignumber.js';
13
13
  import '../abis/nadoAbis.cjs';
14
+ import '../utils/math/bigNumber.cjs';
14
15
  import 'viem';
15
- import '../utils/math/bigDecimal.cjs';
@@ -3,13 +3,13 @@ export { Bytes } from './bytes.js';
3
3
  export { ALL_CHAIN_ENVS, ChainEnv, LOCAL_CHAIN_ENVS, MAINNET_CHAIN_ENVS, TESTNET_CHAIN_ENVS } from './ChainEnv.js';
4
4
  export { HealthGroup, HealthStatus, HealthStatusByType, HealthType } from './healthTypes.js';
5
5
  export { Market, MarketWithProduct, PerpMarket, SpotMarket } from './marketTypes.js';
6
+ export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.js';
7
+ export { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.js';
8
+ export { OrderExecutionType } from './OrderExecutionType.js';
6
9
  export { PerpProduct, Product, ProductEngineType, SpotProduct, toProductEngineType } from './productTypes.js';
7
10
  export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccountTypes.js';
8
- export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.js';
9
11
  export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './viemTypes.js';
10
- export { OrderExecutionType } from './OrderExecutionType.js';
11
- export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.js';
12
12
  import 'bignumber.js';
13
13
  import '../abis/nadoAbis.js';
14
+ import '../utils/math/bigNumber.js';
14
15
  import 'viem';
15
- import '../utils/math/bigDecimal.js';
@@ -4,10 +4,10 @@ export * from "./bytes.js";
4
4
  export * from "./ChainEnv.js";
5
5
  export * from "./healthTypes.js";
6
6
  export * from "./marketTypes.js";
7
+ export * from "./nadoContractTypes.js";
8
+ export * from "./orderAppendixTypes.js";
9
+ export * from "./OrderExecutionType.js";
7
10
  export * from "./productTypes.js";
8
11
  export * from "./subaccountTypes.js";
9
- export * from "./nadoContractTypes.js";
10
12
  export * from "./viemTypes.js";
11
- export * from "./OrderExecutionType.js";
12
- export * from "./orderAppendixTypes.js";
13
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from './balanceTypes';\nexport * from './bytes';\nexport * from './ChainEnv';\nexport * from './healthTypes';\nexport * from './marketTypes';\nexport * from './productTypes';\nexport * from './subaccountTypes';\nexport * from './nadoContractTypes';\nexport * from './viemTypes';\nexport * from './OrderExecutionType';\nexport * from './orderAppendixTypes';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from './balanceTypes';\nexport * from './bytes';\nexport * from './ChainEnv';\nexport * from './healthTypes';\nexport * from './marketTypes';\nexport * from './nadoContractTypes';\nexport * from './orderAppendixTypes';\nexport * from './OrderExecutionType';\nexport * from './productTypes';\nexport * from './subaccountTypes';\nexport * from './viemTypes';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/marketTypes.ts"],"sourcesContent":["import { BigDecimal } from '../utils/math';\nimport {\n PerpProduct,\n Product,\n ProductEngineType,\n SpotProduct,\n} from './productTypes';\n\n/**\n * Shared properties of a market\n */\nexport interface Market {\n productId: number;\n type: ProductEngineType;\n product: Product;\n // Minimum order size to be placed on the book (i.e. not an IOC order)\n minSize: BigDecimal;\n // Price increment for the orderbook, order prices must be placed at multiples of this increment\n priceIncrement: BigDecimal;\n // Size increment for the orderbook, order sizes must be placed at multiples of this increment\n sizeIncrement: BigDecimal;\n}\n\n/**\n * Perp market with perp product info\n */\nexport interface PerpMarket extends Market {\n type: ProductEngineType.PERP;\n product: PerpProduct;\n}\n\n/**\n * Spot market with spot product info\n */\nexport interface SpotMarket extends Market {\n type: ProductEngineType.SPOT;\n product: SpotProduct;\n}\n\nexport type MarketWithProduct = PerpMarket | SpotMarket;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/marketTypes.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport {\n PerpProduct,\n Product,\n ProductEngineType,\n SpotProduct,\n} from './productTypes';\n\n/**\n * Shared properties of a market\n */\nexport interface Market {\n productId: number;\n type: ProductEngineType;\n product: Product;\n // Minimum order size to be placed on the book (i.e. not an IOC order)\n minSize: BigNumber;\n // Price increment for the orderbook, order prices must be placed at multiples of this increment\n priceIncrement: BigNumber;\n // Size increment for the orderbook, order sizes must be placed at multiples of this increment\n sizeIncrement: BigNumber;\n}\n\n/**\n * Perp market with perp product info\n */\nexport interface PerpMarket extends Market {\n type: ProductEngineType.PERP;\n product: PerpProduct;\n}\n\n/**\n * Spot market with spot product info\n */\nexport interface SpotMarket extends Market {\n type: ProductEngineType.SPOT;\n product: SpotProduct;\n}\n\nexport type MarketWithProduct = PerpMarket | SpotMarket;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,4 +1,4 @@
1
- import BigDecimal from 'bignumber.js';
1
+ import BigNumber__default from 'bignumber.js';
2
2
  import { ProductEngineType, Product, PerpProduct, SpotProduct } from './productTypes.cjs';
3
3
 
4
4
  /**
@@ -8,9 +8,9 @@ interface Market {
8
8
  productId: number;
9
9
  type: ProductEngineType;
10
10
  product: Product;
11
- minSize: BigDecimal;
12
- priceIncrement: BigDecimal;
13
- sizeIncrement: BigDecimal;
11
+ minSize: BigNumber__default;
12
+ priceIncrement: BigNumber__default;
13
+ sizeIncrement: BigNumber__default;
14
14
  }
15
15
  /**
16
16
  * Perp market with perp product info
@@ -1,4 +1,4 @@
1
- import BigDecimal from 'bignumber.js';
1
+ import BigNumber__default from 'bignumber.js';
2
2
  import { ProductEngineType, Product, PerpProduct, SpotProduct } from './productTypes.js';
3
3
 
4
4
  /**
@@ -8,9 +8,9 @@ interface Market {
8
8
  productId: number;
9
9
  type: ProductEngineType;
10
10
  product: Product;
11
- minSize: BigDecimal;
12
- priceIncrement: BigDecimal;
13
- sizeIncrement: BigDecimal;
11
+ minSize: BigNumber__default;
12
+ priceIncrement: BigNumber__default;
13
+ sizeIncrement: BigNumber__default;
14
14
  }
15
15
  /**
16
16
  * Perp market with perp product info
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/orderAppendixTypes.ts"],"sourcesContent":["import { BigDecimalish } from '../utils/math';\nimport { OrderExecutionType } from './OrderExecutionType';\n\n/**\n * Encodes whether the order will be sent to the trigger service\n */\nexport type OrderAppendixTriggerType =\n | 'price'\n | 'twap'\n // TWAP with specified order amounts, which will be specified in the Trigger Order itself\n | 'twap_custom_amounts';\n\n/**\n * Fields associated with a TWAP trigger order.\n */\nexport interface OrderAppendixTwapFields {\n /**\n * Number of TWAP orders to be placed.\n */\n numOrders: number;\n /**\n * Maximum slippage on each TWAP order, based on the oracle price at time of order execution.\n * Ex: 0.01 means 1% slippage.\n */\n slippageFrac: number;\n}\n\n/**\n * Fields associated with an isolated order\n */\nexport interface OrderAppendixIsolatedFields {\n /**\n * Amount of margin to transfer into the isolated position.\n */\n margin: BigDecimalish;\n}\n\n/**\n * All the fields encoded by the order appendix\n */\nexport interface OrderAppendix {\n reduceOnly?: boolean;\n orderExecutionType: OrderExecutionType;\n /**\n * Specify the type of trigger that will be used for the order if the order will be sent to the trigger service.\n */\n triggerType?: OrderAppendixTriggerType;\n /**\n * Specify if the order is for an isolated position\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n isolated?: OrderAppendixIsolatedFields;\n /**\n * Specify if the order is a TWAP order\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n twap?: OrderAppendixTwapFields;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/orderAppendixTypes.ts"],"sourcesContent":["import { BigNumberish } from '../utils/math';\nimport { OrderExecutionType } from './OrderExecutionType';\n\n/**\n * Encodes whether the order will be sent to the trigger service\n */\nexport type OrderAppendixTriggerType =\n | 'price'\n | 'twap'\n // TWAP with specified order amounts, which will be specified in the Trigger Order itself\n | 'twap_custom_amounts';\n\n/**\n * Fields associated with a TWAP trigger order.\n */\nexport interface OrderAppendixTwapFields {\n /**\n * Number of TWAP orders to be placed.\n */\n numOrders: number;\n /**\n * Maximum slippage on each TWAP order, based on the oracle price at time of order execution.\n * Ex: 0.01 means 1% slippage.\n */\n slippageFrac: number;\n}\n\n/**\n * Fields associated with an isolated order\n */\nexport interface OrderAppendixIsolatedFields {\n /**\n * Amount of margin to transfer into the isolated position.\n *\n * Implementation Note:\n * Packed appendix uses precision of 6 decimals on backend.\n * SDK automatically converts to/from x18 during packing/unpacking.\n */\n margin: BigNumberish;\n}\n\n/**\n * Fields for specifying a builder (fee recipient) for the order\n */\nexport interface OrderAppendixBuilderFields {\n /**\n * The builder ID (registered builder identifier)\n */\n builderId: number;\n /**\n * The builder fee rate. This is a raw 10-bit integer (0-1023) where each unit = 0.1 bps.\n * The actual fee is calculated on notional value: builder_fee = price * amount * rate\n */\n builderFeeRate: number;\n}\n\n/**\n * All the fields encoded by the order appendix\n */\nexport interface OrderAppendix {\n reduceOnly?: boolean;\n orderExecutionType: OrderExecutionType;\n /**\n * Specify the type of trigger that will be used for the order if the order will be sent to the trigger service.\n */\n triggerType?: OrderAppendixTriggerType;\n /**\n * Specify if the order is for an isolated position\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n isolated?: OrderAppendixIsolatedFields;\n /**\n * Specify if the order is a TWAP order\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n twap?: OrderAppendixTwapFields;\n /**\n * Specify the builder for fee sharing.\n * Builder ID is encoded in bits 48-63 (16 bits).\n * Builder fee rate is encoded in bits 38-47 (10 bits).\n */\n builder?: OrderAppendixBuilderFields;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,4 +1,4 @@
1
- import { BigDecimalish } from '../utils/math/bigDecimal.cjs';
1
+ import { BigNumberish } from '../utils/math/bigNumber.cjs';
2
2
  import { OrderExecutionType } from './OrderExecutionType.cjs';
3
3
  import 'bignumber.js';
4
4
 
@@ -26,8 +26,26 @@ interface OrderAppendixTwapFields {
26
26
  interface OrderAppendixIsolatedFields {
27
27
  /**
28
28
  * Amount of margin to transfer into the isolated position.
29
+ *
30
+ * Implementation Note:
31
+ * Packed appendix uses precision of 6 decimals on backend.
32
+ * SDK automatically converts to/from x18 during packing/unpacking.
29
33
  */
30
- margin: BigDecimalish;
34
+ margin: BigNumberish;
35
+ }
36
+ /**
37
+ * Fields for specifying a builder (fee recipient) for the order
38
+ */
39
+ interface OrderAppendixBuilderFields {
40
+ /**
41
+ * The builder ID (registered builder identifier)
42
+ */
43
+ builderId: number;
44
+ /**
45
+ * The builder fee rate. This is a raw 10-bit integer (0-1023) where each unit = 0.1 bps.
46
+ * The actual fee is calculated on notional value: builder_fee = price * amount * rate
47
+ */
48
+ builderFeeRate: number;
31
49
  }
32
50
  /**
33
51
  * All the fields encoded by the order appendix
@@ -49,6 +67,12 @@ interface OrderAppendix {
49
67
  * An order CANNOT be both a TWAP order and an isolated order.
50
68
  */
51
69
  twap?: OrderAppendixTwapFields;
70
+ /**
71
+ * Specify the builder for fee sharing.
72
+ * Builder ID is encoded in bits 48-63 (16 bits).
73
+ * Builder fee rate is encoded in bits 38-47 (10 bits).
74
+ */
75
+ builder?: OrderAppendixBuilderFields;
52
76
  }
53
77
 
54
- export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
78
+ export type { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
@@ -1,4 +1,4 @@
1
- import { BigDecimalish } from '../utils/math/bigDecimal.js';
1
+ import { BigNumberish } from '../utils/math/bigNumber.js';
2
2
  import { OrderExecutionType } from './OrderExecutionType.js';
3
3
  import 'bignumber.js';
4
4
 
@@ -26,8 +26,26 @@ interface OrderAppendixTwapFields {
26
26
  interface OrderAppendixIsolatedFields {
27
27
  /**
28
28
  * Amount of margin to transfer into the isolated position.
29
+ *
30
+ * Implementation Note:
31
+ * Packed appendix uses precision of 6 decimals on backend.
32
+ * SDK automatically converts to/from x18 during packing/unpacking.
29
33
  */
30
- margin: BigDecimalish;
34
+ margin: BigNumberish;
35
+ }
36
+ /**
37
+ * Fields for specifying a builder (fee recipient) for the order
38
+ */
39
+ interface OrderAppendixBuilderFields {
40
+ /**
41
+ * The builder ID (registered builder identifier)
42
+ */
43
+ builderId: number;
44
+ /**
45
+ * The builder fee rate. This is a raw 10-bit integer (0-1023) where each unit = 0.1 bps.
46
+ * The actual fee is calculated on notional value: builder_fee = price * amount * rate
47
+ */
48
+ builderFeeRate: number;
31
49
  }
32
50
  /**
33
51
  * All the fields encoded by the order appendix
@@ -49,6 +67,12 @@ interface OrderAppendix {
49
67
  * An order CANNOT be both a TWAP order and an isolated order.
50
68
  */
51
69
  twap?: OrderAppendixTwapFields;
70
+ /**
71
+ * Specify the builder for fee sharing.
72
+ * Builder ID is encoded in bits 48-63 (16 bits).
73
+ * Builder fee rate is encoded in bits 38-47 (10 bits).
74
+ */
75
+ builder?: OrderAppendixBuilderFields;
52
76
  }
53
77
 
54
- export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
78
+ export type { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/productTypes.ts"],"sourcesContent":["import { BigDecimal } from '../utils/math';\n\n/**\n * Representation of the ProductEngineType enum used within the contract\n * Enums do not get reflected in the ABI, so this must be manually defined\n */\nexport enum ProductEngineType {\n SPOT,\n PERP,\n}\n\n/**\n * Maps a raw ProductEngineType enum value to the proper type\n * @param val\n */\nexport function toProductEngineType(val: number): ProductEngineType {\n switch (val) {\n case 0:\n return ProductEngineType.SPOT;\n case 1:\n return ProductEngineType.PERP;\n default:\n throw new Error(`Unknown product engine type: ${val}`);\n }\n}\n\n/**\n * Shared properties across products\n */\ninterface BaseProduct {\n type: ProductEngineType;\n productId: number;\n // Latest price given by oracle\n oraclePrice: BigDecimal;\n // Weight used to calculate initial health for a long position\n longWeightInitial: BigDecimal;\n // Weight used to calculate initial health for a short position\n shortWeightInitial: BigDecimal;\n // Weight used to calculate maint. health for a long position\n longWeightMaintenance: BigDecimal;\n // Weight used to calculate maint. health for a short position\n shortWeightMaintenance: BigDecimal;\n}\n\n/**\n * Represents a product stored in PerpEngine\n */\nexport interface PerpProduct extends BaseProduct {\n type: ProductEngineType.PERP;\n // Current open interest\n openInterest: BigDecimal;\n cumulativeFundingLong: BigDecimal;\n cumulativeFundingShort: BigDecimal;\n}\n\n/**\n * Represents a product stored in SpotEngine.\n *\n * @see {@link calcBorrowRatePerSecond} for more details on the calculation and interest parameters\n */\nexport interface SpotProduct extends BaseProduct {\n type: ProductEngineType.SPOT;\n tokenAddr: string;\n interestFloor: BigDecimal;\n interestInflectionUtil: BigDecimal;\n interestSmallCap: BigDecimal;\n interestLargeCap: BigDecimal;\n minDepositRate: BigDecimal;\n\n // Total deposited for this product\n totalDeposited: BigDecimal;\n // Total borrowed for this product\n totalBorrowed: BigDecimal;\n}\n\nexport type Product = PerpProduct | SpotProduct;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,sCAAA;AACA,EAAAA,sCAAA;AAFU,SAAAA;AAAA,GAAA;AASL,SAAS,oBAAoB,KAAgC;AAClE,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,gCAAgC,GAAG,EAAE;AAAA,EACzD;AACF;","names":["ProductEngineType"]}
1
+ {"version":3,"sources":["../../src/types/productTypes.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\n\n/**\n * Representation of the ProductEngineType enum used within the contract\n * Enums do not get reflected in the ABI, so this must be manually defined\n */\nexport enum ProductEngineType {\n SPOT,\n PERP,\n}\n\n/**\n * Maps a raw ProductEngineType enum value to the proper type\n * @param val\n */\nexport function toProductEngineType(val: number): ProductEngineType {\n switch (val) {\n case 0:\n return ProductEngineType.SPOT;\n case 1:\n return ProductEngineType.PERP;\n default:\n throw new Error(`Unknown product engine type: ${val}`);\n }\n}\n\n/**\n * Shared properties across products\n */\ninterface BaseProduct {\n type: ProductEngineType;\n productId: number;\n // Latest price given by oracle\n oraclePrice: BigNumber;\n // Weight used to calculate initial health for a long position\n longWeightInitial: BigNumber;\n // Weight used to calculate initial health for a short position\n shortWeightInitial: BigNumber;\n // Weight used to calculate maint. health for a long position\n longWeightMaintenance: BigNumber;\n // Weight used to calculate maint. health for a short position\n shortWeightMaintenance: BigNumber;\n}\n\n/**\n * Represents a product stored in PerpEngine\n */\nexport interface PerpProduct extends BaseProduct {\n type: ProductEngineType.PERP;\n // Current open interest\n openInterest: BigNumber;\n cumulativeFundingLong: BigNumber;\n cumulativeFundingShort: BigNumber;\n}\n\n/**\n * Represents a product stored in SpotEngine.\n *\n * @see {@link calcBorrowRatePerSecond} for more details on the calculation and interest parameters\n */\nexport interface SpotProduct extends BaseProduct {\n type: ProductEngineType.SPOT;\n tokenAddr: string;\n interestFloor: BigNumber;\n interestInflectionUtil: BigNumber;\n interestSmallCap: BigNumber;\n interestLargeCap: BigNumber;\n minDepositRate: BigNumber;\n\n // Total deposited for this product\n totalDeposited: BigNumber;\n // Total borrowed for this product\n totalBorrowed: BigNumber;\n}\n\nexport type Product = PerpProduct | SpotProduct;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,sCAAA;AACA,EAAAA,sCAAA;AAFU,SAAAA;AAAA,GAAA;AASL,SAAS,oBAAoB,KAAgC;AAClE,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,gCAAgC,GAAG,EAAE;AAAA,EACzD;AACF;","names":["ProductEngineType"]}
@@ -1,4 +1,4 @@
1
- import BigDecimal from 'bignumber.js';
1
+ import BigNumber__default from 'bignumber.js';
2
2
 
3
3
  /**
4
4
  * Representation of the ProductEngineType enum used within the contract
@@ -19,20 +19,20 @@ declare function toProductEngineType(val: number): ProductEngineType;
19
19
  interface BaseProduct {
20
20
  type: ProductEngineType;
21
21
  productId: number;
22
- oraclePrice: BigDecimal;
23
- longWeightInitial: BigDecimal;
24
- shortWeightInitial: BigDecimal;
25
- longWeightMaintenance: BigDecimal;
26
- shortWeightMaintenance: BigDecimal;
22
+ oraclePrice: BigNumber__default;
23
+ longWeightInitial: BigNumber__default;
24
+ shortWeightInitial: BigNumber__default;
25
+ longWeightMaintenance: BigNumber__default;
26
+ shortWeightMaintenance: BigNumber__default;
27
27
  }
28
28
  /**
29
29
  * Represents a product stored in PerpEngine
30
30
  */
31
31
  interface PerpProduct extends BaseProduct {
32
32
  type: ProductEngineType.PERP;
33
- openInterest: BigDecimal;
34
- cumulativeFundingLong: BigDecimal;
35
- cumulativeFundingShort: BigDecimal;
33
+ openInterest: BigNumber__default;
34
+ cumulativeFundingLong: BigNumber__default;
35
+ cumulativeFundingShort: BigNumber__default;
36
36
  }
37
37
  /**
38
38
  * Represents a product stored in SpotEngine.
@@ -42,13 +42,13 @@ interface PerpProduct extends BaseProduct {
42
42
  interface SpotProduct extends BaseProduct {
43
43
  type: ProductEngineType.SPOT;
44
44
  tokenAddr: string;
45
- interestFloor: BigDecimal;
46
- interestInflectionUtil: BigDecimal;
47
- interestSmallCap: BigDecimal;
48
- interestLargeCap: BigDecimal;
49
- minDepositRate: BigDecimal;
50
- totalDeposited: BigDecimal;
51
- totalBorrowed: BigDecimal;
45
+ interestFloor: BigNumber__default;
46
+ interestInflectionUtil: BigNumber__default;
47
+ interestSmallCap: BigNumber__default;
48
+ interestLargeCap: BigNumber__default;
49
+ minDepositRate: BigNumber__default;
50
+ totalDeposited: BigNumber__default;
51
+ totalBorrowed: BigNumber__default;
52
52
  }
53
53
  type Product = PerpProduct | SpotProduct;
54
54
 
@@ -1,4 +1,4 @@
1
- import BigDecimal from 'bignumber.js';
1
+ import BigNumber__default from 'bignumber.js';
2
2
 
3
3
  /**
4
4
  * Representation of the ProductEngineType enum used within the contract
@@ -19,20 +19,20 @@ declare function toProductEngineType(val: number): ProductEngineType;
19
19
  interface BaseProduct {
20
20
  type: ProductEngineType;
21
21
  productId: number;
22
- oraclePrice: BigDecimal;
23
- longWeightInitial: BigDecimal;
24
- shortWeightInitial: BigDecimal;
25
- longWeightMaintenance: BigDecimal;
26
- shortWeightMaintenance: BigDecimal;
22
+ oraclePrice: BigNumber__default;
23
+ longWeightInitial: BigNumber__default;
24
+ shortWeightInitial: BigNumber__default;
25
+ longWeightMaintenance: BigNumber__default;
26
+ shortWeightMaintenance: BigNumber__default;
27
27
  }
28
28
  /**
29
29
  * Represents a product stored in PerpEngine
30
30
  */
31
31
  interface PerpProduct extends BaseProduct {
32
32
  type: ProductEngineType.PERP;
33
- openInterest: BigDecimal;
34
- cumulativeFundingLong: BigDecimal;
35
- cumulativeFundingShort: BigDecimal;
33
+ openInterest: BigNumber__default;
34
+ cumulativeFundingLong: BigNumber__default;
35
+ cumulativeFundingShort: BigNumber__default;
36
36
  }
37
37
  /**
38
38
  * Represents a product stored in SpotEngine.
@@ -42,13 +42,13 @@ interface PerpProduct extends BaseProduct {
42
42
  interface SpotProduct extends BaseProduct {
43
43
  type: ProductEngineType.SPOT;
44
44
  tokenAddr: string;
45
- interestFloor: BigDecimal;
46
- interestInflectionUtil: BigDecimal;
47
- interestSmallCap: BigDecimal;
48
- interestLargeCap: BigDecimal;
49
- minDepositRate: BigDecimal;
50
- totalDeposited: BigDecimal;
51
- totalBorrowed: BigDecimal;
45
+ interestFloor: BigNumber__default;
46
+ interestInflectionUtil: BigNumber__default;
47
+ interestSmallCap: BigNumber__default;
48
+ interestLargeCap: BigNumber__default;
49
+ minDepositRate: BigNumber__default;
50
+ totalDeposited: BigNumber__default;
51
+ totalBorrowed: BigNumber__default;
52
52
  }
53
53
  type Product = PerpProduct | SpotProduct;
54
54
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/productTypes.ts"],"sourcesContent":["import { BigDecimal } from '../utils/math';\n\n/**\n * Representation of the ProductEngineType enum used within the contract\n * Enums do not get reflected in the ABI, so this must be manually defined\n */\nexport enum ProductEngineType {\n SPOT,\n PERP,\n}\n\n/**\n * Maps a raw ProductEngineType enum value to the proper type\n * @param val\n */\nexport function toProductEngineType(val: number): ProductEngineType {\n switch (val) {\n case 0:\n return ProductEngineType.SPOT;\n case 1:\n return ProductEngineType.PERP;\n default:\n throw new Error(`Unknown product engine type: ${val}`);\n }\n}\n\n/**\n * Shared properties across products\n */\ninterface BaseProduct {\n type: ProductEngineType;\n productId: number;\n // Latest price given by oracle\n oraclePrice: BigDecimal;\n // Weight used to calculate initial health for a long position\n longWeightInitial: BigDecimal;\n // Weight used to calculate initial health for a short position\n shortWeightInitial: BigDecimal;\n // Weight used to calculate maint. health for a long position\n longWeightMaintenance: BigDecimal;\n // Weight used to calculate maint. health for a short position\n shortWeightMaintenance: BigDecimal;\n}\n\n/**\n * Represents a product stored in PerpEngine\n */\nexport interface PerpProduct extends BaseProduct {\n type: ProductEngineType.PERP;\n // Current open interest\n openInterest: BigDecimal;\n cumulativeFundingLong: BigDecimal;\n cumulativeFundingShort: BigDecimal;\n}\n\n/**\n * Represents a product stored in SpotEngine.\n *\n * @see {@link calcBorrowRatePerSecond} for more details on the calculation and interest parameters\n */\nexport interface SpotProduct extends BaseProduct {\n type: ProductEngineType.SPOT;\n tokenAddr: string;\n interestFloor: BigDecimal;\n interestInflectionUtil: BigDecimal;\n interestSmallCap: BigDecimal;\n interestLargeCap: BigDecimal;\n minDepositRate: BigDecimal;\n\n // Total deposited for this product\n totalDeposited: BigDecimal;\n // Total borrowed for this product\n totalBorrowed: BigDecimal;\n}\n\nexport type Product = PerpProduct | SpotProduct;\n"],"mappings":";;;AAMO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,sCAAA;AACA,EAAAA,sCAAA;AAFU,SAAAA;AAAA,GAAA;AASL,SAAS,oBAAoB,KAAgC;AAClE,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,gCAAgC,GAAG,EAAE;AAAA,EACzD;AACF;","names":["ProductEngineType"]}
1
+ {"version":3,"sources":["../../src/types/productTypes.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\n\n/**\n * Representation of the ProductEngineType enum used within the contract\n * Enums do not get reflected in the ABI, so this must be manually defined\n */\nexport enum ProductEngineType {\n SPOT,\n PERP,\n}\n\n/**\n * Maps a raw ProductEngineType enum value to the proper type\n * @param val\n */\nexport function toProductEngineType(val: number): ProductEngineType {\n switch (val) {\n case 0:\n return ProductEngineType.SPOT;\n case 1:\n return ProductEngineType.PERP;\n default:\n throw new Error(`Unknown product engine type: ${val}`);\n }\n}\n\n/**\n * Shared properties across products\n */\ninterface BaseProduct {\n type: ProductEngineType;\n productId: number;\n // Latest price given by oracle\n oraclePrice: BigNumber;\n // Weight used to calculate initial health for a long position\n longWeightInitial: BigNumber;\n // Weight used to calculate initial health for a short position\n shortWeightInitial: BigNumber;\n // Weight used to calculate maint. health for a long position\n longWeightMaintenance: BigNumber;\n // Weight used to calculate maint. health for a short position\n shortWeightMaintenance: BigNumber;\n}\n\n/**\n * Represents a product stored in PerpEngine\n */\nexport interface PerpProduct extends BaseProduct {\n type: ProductEngineType.PERP;\n // Current open interest\n openInterest: BigNumber;\n cumulativeFundingLong: BigNumber;\n cumulativeFundingShort: BigNumber;\n}\n\n/**\n * Represents a product stored in SpotEngine.\n *\n * @see {@link calcBorrowRatePerSecond} for more details on the calculation and interest parameters\n */\nexport interface SpotProduct extends BaseProduct {\n type: ProductEngineType.SPOT;\n tokenAddr: string;\n interestFloor: BigNumber;\n interestInflectionUtil: BigNumber;\n interestSmallCap: BigNumber;\n interestLargeCap: BigNumber;\n minDepositRate: BigNumber;\n\n // Total deposited for this product\n totalDeposited: BigNumber;\n // Total borrowed for this product\n totalBorrowed: BigNumber;\n}\n\nexport type Product = PerpProduct | SpotProduct;\n"],"mappings":";;;AAMO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,sCAAA;AACA,EAAAA,sCAAA;AAFU,SAAAA;AAAA,GAAA;AASL,SAAS,oBAAoB,KAAgC;AAClE,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,gCAAgC,GAAG,EAAE;AAAA,EACzD;AACF;","names":["ProductEngineType"]}
@@ -1,4 +1,4 @@
1
- import { WalletClient, Transport, Chain, Account, RpcSchema, Abi, GetContractReturnType, PublicClient } from 'viem';
1
+ import { Account, Abi, GetContractReturnType, WalletClient, Transport, Chain, RpcSchema, PublicClient } from 'viem';
2
2
 
3
3
  /**
4
4
  * An account with its corresponding private key. Viem does not allow private keys to be accessible from an account
@@ -1,4 +1,4 @@
1
- import { WalletClient, Transport, Chain, Account, RpcSchema, Abi, GetContractReturnType, PublicClient } from 'viem';
1
+ import { Account, Abi, GetContractReturnType, WalletClient, Transport, Chain, RpcSchema, PublicClient } from 'viem';
2
2
 
3
3
  /**
4
4
  * An account with its corresponding private key. Viem does not allow private keys to be accessible from an account
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/balanceValue.ts"],"sourcesContent":["import {\n PerpBalanceWithProduct,\n SpotBalanceWithProduct,\n} from '../types/balanceTypes';\nimport { BigDecimal } from './math';\n\n/**\n * Calculates the quote value of a spot balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcSpotBalanceValue(\n balanceWithProduct: SpotBalanceWithProduct,\n): BigDecimal {\n return balanceWithProduct.amount.multipliedBy(balanceWithProduct.oraclePrice);\n}\n\n/**\n * Calculates the notional value of a perp balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceNotionalValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigDecimal {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .abs();\n}\n\n/**\n * Calculates the true quote value of a perp balance, which is the same as its unrealized pnl / unsettled quote, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigDecimal {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .plus(balanceWithProduct.vQuoteBalance);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,qBACd,oBACY;AACZ,SAAO,mBAAmB,OAAO,aAAa,mBAAmB,WAAW;AAC9E;AAOO,SAAS,6BACd,oBACY;AACZ,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,IAAI;AACT;AAOO,SAAS,qBACd,oBACY;AACZ,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,KAAK,mBAAmB,aAAa;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/balanceValue.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport {\n PerpBalanceWithProduct,\n SpotBalanceWithProduct,\n} from '../types/balanceTypes';\n\n/**\n * Calculates the quote value of a spot balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcSpotBalanceValue(\n balanceWithProduct: SpotBalanceWithProduct,\n): BigNumber {\n return balanceWithProduct.amount.multipliedBy(balanceWithProduct.oraclePrice);\n}\n\n/**\n * Calculates the notional value of a perp balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceNotionalValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigNumber {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .abs();\n}\n\n/**\n * Calculates the true quote value of a perp balance, which is the same as its unrealized pnl / unsettled quote, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigNumber {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .plus(balanceWithProduct.vQuoteBalance);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,qBACd,oBACW;AACX,SAAO,mBAAmB,OAAO,aAAa,mBAAmB,WAAW;AAC9E;AAOO,SAAS,6BACd,oBACW;AACX,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,IAAI;AACT;AAOO,SAAS,qBACd,oBACW;AACX,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,KAAK,mBAAmB,aAAa;AAC1C;","names":[]}
@@ -1,5 +1,5 @@
1
- import { SpotBalanceWithProduct, PerpBalanceWithProduct } from '../types/balanceTypes.cjs';
2
- import BigDecimal from 'bignumber.js';
1
+ import BigNumber__default from 'bignumber.js';
2
+ import { PerpBalanceWithProduct, SpotBalanceWithProduct } from '../types/balanceTypes.cjs';
3
3
  import '../types/healthTypes.cjs';
4
4
  import '../types/productTypes.cjs';
5
5
 
@@ -8,18 +8,18 @@ import '../types/productTypes.cjs';
8
8
  *
9
9
  * @param balanceWithProduct
10
10
  */
11
- declare function calcSpotBalanceValue(balanceWithProduct: SpotBalanceWithProduct): BigDecimal;
11
+ declare function calcSpotBalanceValue(balanceWithProduct: SpotBalanceWithProduct): BigNumber__default;
12
12
  /**
13
13
  * Calculates the notional value of a perp balance, in terms of quote units
14
14
  *
15
15
  * @param balanceWithProduct
16
16
  */
17
- declare function calcPerpBalanceNotionalValue(balanceWithProduct: PerpBalanceWithProduct): BigDecimal;
17
+ declare function calcPerpBalanceNotionalValue(balanceWithProduct: PerpBalanceWithProduct): BigNumber__default;
18
18
  /**
19
19
  * Calculates the true quote value of a perp balance, which is the same as its unrealized pnl / unsettled quote, in terms of quote units
20
20
  *
21
21
  * @param balanceWithProduct
22
22
  */
23
- declare function calcPerpBalanceValue(balanceWithProduct: PerpBalanceWithProduct): BigDecimal;
23
+ declare function calcPerpBalanceValue(balanceWithProduct: PerpBalanceWithProduct): BigNumber__default;
24
24
 
25
25
  export { calcPerpBalanceNotionalValue, calcPerpBalanceValue, calcSpotBalanceValue };
@@ -1,5 +1,5 @@
1
- import { SpotBalanceWithProduct, PerpBalanceWithProduct } from '../types/balanceTypes.js';
2
- import BigDecimal from 'bignumber.js';
1
+ import BigNumber__default from 'bignumber.js';
2
+ import { PerpBalanceWithProduct, SpotBalanceWithProduct } from '../types/balanceTypes.js';
3
3
  import '../types/healthTypes.js';
4
4
  import '../types/productTypes.js';
5
5
 
@@ -8,18 +8,18 @@ import '../types/productTypes.js';
8
8
  *
9
9
  * @param balanceWithProduct
10
10
  */
11
- declare function calcSpotBalanceValue(balanceWithProduct: SpotBalanceWithProduct): BigDecimal;
11
+ declare function calcSpotBalanceValue(balanceWithProduct: SpotBalanceWithProduct): BigNumber__default;
12
12
  /**
13
13
  * Calculates the notional value of a perp balance, in terms of quote units
14
14
  *
15
15
  * @param balanceWithProduct
16
16
  */
17
- declare function calcPerpBalanceNotionalValue(balanceWithProduct: PerpBalanceWithProduct): BigDecimal;
17
+ declare function calcPerpBalanceNotionalValue(balanceWithProduct: PerpBalanceWithProduct): BigNumber__default;
18
18
  /**
19
19
  * Calculates the true quote value of a perp balance, which is the same as its unrealized pnl / unsettled quote, in terms of quote units
20
20
  *
21
21
  * @param balanceWithProduct
22
22
  */
23
- declare function calcPerpBalanceValue(balanceWithProduct: PerpBalanceWithProduct): BigDecimal;
23
+ declare function calcPerpBalanceValue(balanceWithProduct: PerpBalanceWithProduct): BigNumber__default;
24
24
 
25
25
  export { calcPerpBalanceNotionalValue, calcPerpBalanceValue, calcSpotBalanceValue };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/balanceValue.ts"],"sourcesContent":["import {\n PerpBalanceWithProduct,\n SpotBalanceWithProduct,\n} from '../types/balanceTypes';\nimport { BigDecimal } from './math';\n\n/**\n * Calculates the quote value of a spot balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcSpotBalanceValue(\n balanceWithProduct: SpotBalanceWithProduct,\n): BigDecimal {\n return balanceWithProduct.amount.multipliedBy(balanceWithProduct.oraclePrice);\n}\n\n/**\n * Calculates the notional value of a perp balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceNotionalValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigDecimal {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .abs();\n}\n\n/**\n * Calculates the true quote value of a perp balance, which is the same as its unrealized pnl / unsettled quote, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigDecimal {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .plus(balanceWithProduct.vQuoteBalance);\n}\n"],"mappings":";;;AAWO,SAAS,qBACd,oBACY;AACZ,SAAO,mBAAmB,OAAO,aAAa,mBAAmB,WAAW;AAC9E;AAOO,SAAS,6BACd,oBACY;AACZ,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,IAAI;AACT;AAOO,SAAS,qBACd,oBACY;AACZ,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,KAAK,mBAAmB,aAAa;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/balanceValue.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport {\n PerpBalanceWithProduct,\n SpotBalanceWithProduct,\n} from '../types/balanceTypes';\n\n/**\n * Calculates the quote value of a spot balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcSpotBalanceValue(\n balanceWithProduct: SpotBalanceWithProduct,\n): BigNumber {\n return balanceWithProduct.amount.multipliedBy(balanceWithProduct.oraclePrice);\n}\n\n/**\n * Calculates the notional value of a perp balance, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceNotionalValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigNumber {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .abs();\n}\n\n/**\n * Calculates the true quote value of a perp balance, which is the same as its unrealized pnl / unsettled quote, in terms of quote units\n *\n * @param balanceWithProduct\n */\nexport function calcPerpBalanceValue(\n balanceWithProduct: PerpBalanceWithProduct,\n): BigNumber {\n return balanceWithProduct.amount\n .multipliedBy(balanceWithProduct.oraclePrice)\n .plus(balanceWithProduct.vQuoteBalance);\n}\n"],"mappings":";;;AAWO,SAAS,qBACd,oBACW;AACX,SAAO,mBAAmB,OAAO,aAAa,mBAAmB,WAAW;AAC9E;AAOO,SAAS,6BACd,oBACW;AACX,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,IAAI;AACT;AAOO,SAAS,qBACd,oBACW;AACX,SAAO,mBAAmB,OACvB,aAAa,mBAAmB,WAAW,EAC3C,KAAK,mBAAmB,aAAa;AAC1C;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import { Hex } from 'viem';
2
2
  import { Bytes } from '../types/bytes.cjs';
3
- import { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from '../types/subaccountTypes.cjs';
3
+ import { SubaccountBytes32, Subaccount, SubaccountNameBytes12 } from '../types/subaccountTypes.cjs';
4
4
 
5
5
  /**
6
6
  * Converts a subaccount object (owner + name) to its bytes32 representation.
@@ -1,6 +1,6 @@
1
1
  import { Hex } from 'viem';
2
2
  import { Bytes } from '../types/bytes.js';
3
- import { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from '../types/subaccountTypes.js';
3
+ import { SubaccountBytes32, Subaccount, SubaccountNameBytes12 } from '../types/subaccountTypes.js';
4
4
 
5
5
  /**
6
6
  * Converts a subaccount object (owner + name) to its bytes32 representation.
@@ -25,9 +25,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  mod
26
26
  ));
27
27
 
28
- // ../../node_modules/@jest/globals/build/index.js
28
+ // ../../node_modules/.bun/@jest+globals@30.2.0/node_modules/@jest/globals/build/index.js
29
29
  var require_build = __commonJS({
30
- "../../node_modules/@jest/globals/build/index.js"(exports2, module2) {
30
+ "../../node_modules/.bun/@jest+globals@30.2.0/node_modules/@jest/globals/build/index.js"(exports2, module2) {
31
31
  "use strict";
32
32
  (() => {
33
33
  "use strict";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../node_modules/@jest/globals/build/index.js","../../src/utils/bytes32.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 { Subaccount } from '../types/subaccountTypes';\nimport {\n subaccountFromBytes32,\n subaccountFromHex,\n subaccountNameBytesToStr,\n subaccountNameToBytes12,\n subaccountToBytes32,\n subaccountToHex,\n} from './bytes32';\n\nconst TEST_ADDRESS = '0xb92EFcF519EDC2f1FE60b4491Ef51d97Ed4d7685';\n\ndescribe('bytes32', () => {\n it('converts a subaccount to bytes', () => {\n const expectedBytes = new Uint8Array([\n 185, 46, 252, 245, 25, 237, 194, 241, 254, 96, 180, 73, 30, 245, 29, 151,\n 237, 77, 118, 133, 116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0,\n ]);\n expect(\n subaccountToBytes32({\n subaccountName: 'test',\n subaccountOwner: TEST_ADDRESS,\n }),\n ).toStrictEqual(expectedBytes);\n });\n\n it('converts bytes to a subaccount', () => {\n const subaccountBytes = new Uint8Array([\n 185, 46, 252, 245, 25, 237, 194, 241, 254, 96, 180, 73, 30, 245, 29, 151,\n 237, 77, 118, 133, 116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0,\n ]);\n const expectedSubaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n subaccountName: 'test',\n };\n const convertedSubaccount = subaccountFromBytes32(subaccountBytes);\n\n expect(convertedSubaccount.subaccountOwner.toLowerCase()).toBe(\n expectedSubaccount.subaccountOwner.toLowerCase(),\n );\n expect(convertedSubaccount.subaccountName).toBe(\n expectedSubaccount.subaccountName,\n );\n });\n\n it('converts a string subaccount name to bytes', () => {\n const nameBytes = subaccountNameToBytes12('test');\n\n expect(nameBytes).toStrictEqual(\n new Uint8Array([116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0]),\n );\n });\n\n it('converts a hex string subaccount name to bytes', () => {\n // `test` in hex form\n const nameBytes = subaccountNameToBytes12('0x74657374');\n\n expect(nameBytes).toStrictEqual(\n new Uint8Array([116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0]),\n );\n });\n\n it('converts a subaccount with a string subaccount name to a hex string', () => {\n const subaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n subaccountName: 'test',\n };\n\n expect(subaccountToHex(subaccount)).toBe(\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d7685746573740000000000000000',\n );\n });\n\n it('converts a subaccount with a hex subaccount name to a hex string', () => {\n const subaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n // `test` in hex form\n subaccountName: '0x74657374',\n };\n\n expect(subaccountToHex(subaccount)).toBe(\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d7685746573740000000000000000',\n );\n });\n\n it('converts a hex string to a subaccount', () => {\n const convertedSubaccount = subaccountFromHex(\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d7685746573740000000000000000',\n );\n\n expect(convertedSubaccount.subaccountOwner.toLowerCase()).toBe(\n TEST_ADDRESS.toLowerCase(),\n );\n expect(convertedSubaccount.subaccountName).toBe('test');\n });\n\n it('handles leading zero bytes in subaccount name properly', () => {\n const subaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n subaccountName: '\\u0000\\u0000\\u0002\\u0000iso\\u0000',\n };\n const subaccountHex =\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d76850000020069736f0000000000';\n\n expect(subaccountToHex(subaccount)).toBe(subaccountHex);\n // Trailing 0 bytes are trimmed\n expect(subaccountFromHex(subaccountHex).subaccountName).toBe(\n '\\u0000\\u0000\\u0002\\u0000iso',\n );\n });\n\n it('handles converting non-utf8 byte sequences by converting bytes to a hex string', () => {\n const invalidUtf8Array = new Uint8Array([0x80, 0x81, 0x82]);\n expect(subaccountNameBytesToStr(invalidUtf8Array)).toBe('0x808182');\n });\n});\n"],"mappings":"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","names":["exports","module"]}
1
+ {"version":3,"sources":["../../../../node_modules/.bun/@jest+globals@30.2.0/node_modules/@jest/globals/build/index.js","../../src/utils/bytes32.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 { Subaccount } from '../types/subaccountTypes';\nimport {\n subaccountFromBytes32,\n subaccountFromHex,\n subaccountNameBytesToStr,\n subaccountNameToBytes12,\n subaccountToBytes32,\n subaccountToHex,\n} from './bytes32';\n\nconst TEST_ADDRESS = '0xb92EFcF519EDC2f1FE60b4491Ef51d97Ed4d7685';\n\ndescribe('bytes32', () => {\n it('converts a subaccount to bytes', () => {\n const expectedBytes = new Uint8Array([\n 185, 46, 252, 245, 25, 237, 194, 241, 254, 96, 180, 73, 30, 245, 29, 151,\n 237, 77, 118, 133, 116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0,\n ]);\n expect(\n subaccountToBytes32({\n subaccountName: 'test',\n subaccountOwner: TEST_ADDRESS,\n }),\n ).toStrictEqual(expectedBytes);\n });\n\n it('converts bytes to a subaccount', () => {\n const subaccountBytes = new Uint8Array([\n 185, 46, 252, 245, 25, 237, 194, 241, 254, 96, 180, 73, 30, 245, 29, 151,\n 237, 77, 118, 133, 116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0,\n ]);\n const expectedSubaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n subaccountName: 'test',\n };\n const convertedSubaccount = subaccountFromBytes32(subaccountBytes);\n\n expect(convertedSubaccount.subaccountOwner.toLowerCase()).toBe(\n expectedSubaccount.subaccountOwner.toLowerCase(),\n );\n expect(convertedSubaccount.subaccountName).toBe(\n expectedSubaccount.subaccountName,\n );\n });\n\n it('converts a string subaccount name to bytes', () => {\n const nameBytes = subaccountNameToBytes12('test');\n\n expect(nameBytes).toStrictEqual(\n new Uint8Array([116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0]),\n );\n });\n\n it('converts a hex string subaccount name to bytes', () => {\n // `test` in hex form\n const nameBytes = subaccountNameToBytes12('0x74657374');\n\n expect(nameBytes).toStrictEqual(\n new Uint8Array([116, 101, 115, 116, 0, 0, 0, 0, 0, 0, 0, 0]),\n );\n });\n\n it('converts a subaccount with a string subaccount name to a hex string', () => {\n const subaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n subaccountName: 'test',\n };\n\n expect(subaccountToHex(subaccount)).toBe(\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d7685746573740000000000000000',\n );\n });\n\n it('converts a subaccount with a hex subaccount name to a hex string', () => {\n const subaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n // `test` in hex form\n subaccountName: '0x74657374',\n };\n\n expect(subaccountToHex(subaccount)).toBe(\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d7685746573740000000000000000',\n );\n });\n\n it('converts a hex string to a subaccount', () => {\n const convertedSubaccount = subaccountFromHex(\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d7685746573740000000000000000',\n );\n\n expect(convertedSubaccount.subaccountOwner.toLowerCase()).toBe(\n TEST_ADDRESS.toLowerCase(),\n );\n expect(convertedSubaccount.subaccountName).toBe('test');\n });\n\n it('handles leading zero bytes in subaccount name properly', () => {\n const subaccount: Subaccount = {\n subaccountOwner: TEST_ADDRESS,\n subaccountName: '\\u0000\\u0000\\u0002\\u0000iso\\u0000',\n };\n const subaccountHex =\n '0xb92efcf519edc2f1fe60b4491ef51d97ed4d76850000020069736f0000000000';\n\n expect(subaccountToHex(subaccount)).toBe(subaccountHex);\n // Trailing 0 bytes are trimmed\n expect(subaccountFromHex(subaccountHex).subaccountName).toBe(\n '\\u0000\\u0000\\u0002\\u0000iso',\n );\n });\n\n it('handles converting non-utf8 byte sequences by converting bytes to a hex string', () => {\n const invalidUtf8Array = new Uint8Array([0x80, 0x81, 0x82]);\n expect(subaccountNameBytesToStr(invalidUtf8Array)).toBe('0x808182');\n });\n});\n"],"mappings":"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","names":["exports","module"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_build
3
- } from "../chunk-TUJ4HQKF.js";
3
+ } from "../chunk-2GPIH63F.js";
4
4
  import {
5
5
  __toESM
6
6
  } from "../chunk-5WRI5ZAA.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/createDeterministicLinkedSignerPrivateKey.ts"],"sourcesContent":["import { keccak256 } from 'viem';\nimport { Subaccount } from '../types/subaccountTypes';\nimport { WalletClientWithAccount } from '../types/viemTypes';\nimport { getNadoEIP712Domain } from '../eip712/getNadoEIP712Domain';\nimport { subaccountToHex } from './bytes32';\n\ninterface Params extends Subaccount {\n walletClient: WalletClientWithAccount;\n chainId: number;\n endpointAddress: string;\n}\n\n/**\n * Deterministically creates a new private key from a predetermined EIP712 message. This is used to\n * reliably create an authorized signer delegate for the subaccount across different clients. Used on the FE in order\n * to have a consistent private key for the subaccount linked signer across different clients.\n *\n * @param params\n */\nexport async function createDeterministicLinkedSignerPrivateKey(\n params: Params,\n) {\n const {\n chainId,\n endpointAddress,\n walletClient,\n subaccountName,\n subaccountOwner,\n } = params;\n\n const signedMessage = await walletClient.signTypedData({\n domain: getNadoEIP712Domain(endpointAddress, chainId),\n types: {\n CreateLinkedSignerWallet: [{ name: 'subaccount', type: 'bytes32' }],\n },\n primaryType: 'CreateLinkedSignerWallet',\n message: {\n subaccount: subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n },\n });\n\n return keccak256(signedMessage);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAG1B,iCAAoC;AACpC,qBAAgC;AAehC,eAAsB,0CACpB,QACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,gBAAgB,MAAM,aAAa,cAAc;AAAA,IACrD,YAAQ,gDAAoB,iBAAiB,OAAO;AAAA,IACpD,OAAO;AAAA,MACL,0BAA0B,CAAC,EAAE,MAAM,cAAc,MAAM,UAAU,CAAC;AAAA,IACpE;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,MACP,gBAAY,gCAAgB;AAAA,QAC1B;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,aAAO,uBAAU,aAAa;AAChC;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/createDeterministicLinkedSignerPrivateKey.ts"],"sourcesContent":["import { keccak256 } from 'viem';\nimport { getNadoEIP712Domain } from '../eip712/getNadoEIP712Domain';\nimport { Subaccount } from '../types/subaccountTypes';\nimport { WalletClientWithAccount } from '../types/viemTypes';\nimport { subaccountToHex } from './bytes32';\n\ninterface Params extends Subaccount {\n walletClient: WalletClientWithAccount;\n chainId: number;\n endpointAddress: string;\n}\n\n/**\n * Deterministically creates a new private key from a predetermined EIP712 message. This is used to\n * reliably create an authorized signer delegate for the subaccount across different clients. Used on the FE in order\n * to have a consistent private key for the subaccount linked signer across different clients.\n *\n * @param params\n */\nexport async function createDeterministicLinkedSignerPrivateKey(\n params: Params,\n) {\n const {\n chainId,\n endpointAddress,\n walletClient,\n subaccountName,\n subaccountOwner,\n } = params;\n\n const signedMessage = await walletClient.signTypedData({\n domain: getNadoEIP712Domain(endpointAddress, chainId),\n types: {\n CreateLinkedSignerWallet: [{ name: 'subaccount', type: 'bytes32' }],\n },\n primaryType: 'CreateLinkedSignerWallet',\n message: {\n subaccount: subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n },\n });\n\n return keccak256(signedMessage);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,iCAAoC;AAGpC,qBAAgC;AAehC,eAAsB,0CACpB,QACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,gBAAgB,MAAM,aAAa,cAAc;AAAA,IACrD,YAAQ,gDAAoB,iBAAiB,OAAO;AAAA,IACpD,OAAO;AAAA,MACL,0BAA0B,CAAC,EAAE,MAAM,cAAc,MAAM,UAAU,CAAC;AAAA,IACpE;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,MACP,gBAAY,gCAAgB;AAAA,QAC1B;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,aAAO,uBAAU,aAAa;AAChC;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/createDeterministicLinkedSignerPrivateKey.ts"],"sourcesContent":["import { keccak256 } from 'viem';\nimport { Subaccount } from '../types/subaccountTypes';\nimport { WalletClientWithAccount } from '../types/viemTypes';\nimport { getNadoEIP712Domain } from '../eip712/getNadoEIP712Domain';\nimport { subaccountToHex } from './bytes32';\n\ninterface Params extends Subaccount {\n walletClient: WalletClientWithAccount;\n chainId: number;\n endpointAddress: string;\n}\n\n/**\n * Deterministically creates a new private key from a predetermined EIP712 message. This is used to\n * reliably create an authorized signer delegate for the subaccount across different clients. Used on the FE in order\n * to have a consistent private key for the subaccount linked signer across different clients.\n *\n * @param params\n */\nexport async function createDeterministicLinkedSignerPrivateKey(\n params: Params,\n) {\n const {\n chainId,\n endpointAddress,\n walletClient,\n subaccountName,\n subaccountOwner,\n } = params;\n\n const signedMessage = await walletClient.signTypedData({\n domain: getNadoEIP712Domain(endpointAddress, chainId),\n types: {\n CreateLinkedSignerWallet: [{ name: 'subaccount', type: 'bytes32' }],\n },\n primaryType: 'CreateLinkedSignerWallet',\n message: {\n subaccount: subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n },\n });\n\n return keccak256(signedMessage);\n}\n"],"mappings":";;;AAAA,SAAS,iBAAiB;AAG1B,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAehC,eAAsB,0CACpB,QACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,gBAAgB,MAAM,aAAa,cAAc;AAAA,IACrD,QAAQ,oBAAoB,iBAAiB,OAAO;AAAA,IACpD,OAAO;AAAA,MACL,0BAA0B,CAAC,EAAE,MAAM,cAAc,MAAM,UAAU,CAAC;AAAA,IACpE;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,MACP,YAAY,gBAAgB;AAAA,QAC1B;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO,UAAU,aAAa;AAChC;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/createDeterministicLinkedSignerPrivateKey.ts"],"sourcesContent":["import { keccak256 } from 'viem';\nimport { getNadoEIP712Domain } from '../eip712/getNadoEIP712Domain';\nimport { Subaccount } from '../types/subaccountTypes';\nimport { WalletClientWithAccount } from '../types/viemTypes';\nimport { subaccountToHex } from './bytes32';\n\ninterface Params extends Subaccount {\n walletClient: WalletClientWithAccount;\n chainId: number;\n endpointAddress: string;\n}\n\n/**\n * Deterministically creates a new private key from a predetermined EIP712 message. This is used to\n * reliably create an authorized signer delegate for the subaccount across different clients. Used on the FE in order\n * to have a consistent private key for the subaccount linked signer across different clients.\n *\n * @param params\n */\nexport async function createDeterministicLinkedSignerPrivateKey(\n params: Params,\n) {\n const {\n chainId,\n endpointAddress,\n walletClient,\n subaccountName,\n subaccountOwner,\n } = params;\n\n const signedMessage = await walletClient.signTypedData({\n domain: getNadoEIP712Domain(endpointAddress, chainId),\n types: {\n CreateLinkedSignerWallet: [{ name: 'subaccount', type: 'bytes32' }],\n },\n primaryType: 'CreateLinkedSignerWallet',\n message: {\n subaccount: subaccountToHex({\n subaccountOwner,\n subaccountName,\n }),\n },\n });\n\n return keccak256(signedMessage);\n}\n"],"mappings":";;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAGpC,SAAS,uBAAuB;AAehC,eAAsB,0CACpB,QACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,gBAAgB,MAAM,aAAa,cAAc;AAAA,IACrD,QAAQ,oBAAoB,iBAAiB,OAAO;AAAA,IACpD,OAAO;AAAA,MACL,0BAA0B,CAAC,EAAE,MAAM,cAAc,MAAM,UAAU,CAAC;AAAA,IACpE;AAAA,IACA,aAAa;AAAA,IACb,SAAS;AAAA,MACP,YAAY,gBAAgB;AAAA,QAC1B;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO,UAAU,aAAa;AAChC;","names":[]}
@@ -17,36 +17,36 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
17
17
  // src/utils/index.ts
18
18
  var utils_exports = {};
19
19
  module.exports = __toCommonJS(utils_exports);
20
- __reExport(utils_exports, require("./orders/index.cjs"), module.exports);
21
- __reExport(utils_exports, require("./interest.cjs"), module.exports);
22
- __reExport(utils_exports, require("./productTypeFilter.cjs"), module.exports);
20
+ __reExport(utils_exports, require("./asyncResult.cjs"), module.exports);
23
21
  __reExport(utils_exports, require("./balanceValue.cjs"), module.exports);
24
22
  __reExport(utils_exports, require("./bytes32.cjs"), module.exports);
25
23
  __reExport(utils_exports, require("./createDeterministicLinkedSignerPrivateKey.cjs"), module.exports);
26
- __reExport(utils_exports, require("./isWriteableContract.cjs"), module.exports);
27
24
  __reExport(utils_exports, require("./errors/index.cjs"), module.exports);
28
- __reExport(utils_exports, require("./math/index.cjs"), module.exports);
29
- __reExport(utils_exports, require("./asyncResult.cjs"), module.exports);
30
25
  __reExport(utils_exports, require("./getValidatedAddress.cjs"), module.exports);
31
26
  __reExport(utils_exports, require("./getValidatedHex.cjs"), module.exports);
27
+ __reExport(utils_exports, require("./interest.cjs"), module.exports);
28
+ __reExport(utils_exports, require("./isWriteableContract.cjs"), module.exports);
32
29
  __reExport(utils_exports, require("./mapValues.cjs"), module.exports);
30
+ __reExport(utils_exports, require("./math/index.cjs"), module.exports);
31
+ __reExport(utils_exports, require("./orders/index.cjs"), module.exports);
32
+ __reExport(utils_exports, require("./productTypeFilter.cjs"), module.exports);
33
33
  __reExport(utils_exports, require("./time.cjs"), module.exports);
34
34
  __reExport(utils_exports, require("./toPrintableObject.cjs"), module.exports);
35
35
  // Annotate the CommonJS export names for ESM import in node:
36
36
  0 && (module.exports = {
37
- ...require("./orders/index.cjs"),
38
- ...require("./interest.cjs"),
39
- ...require("./productTypeFilter.cjs"),
37
+ ...require("./asyncResult.cjs"),
40
38
  ...require("./balanceValue.cjs"),
41
39
  ...require("./bytes32.cjs"),
42
40
  ...require("./createDeterministicLinkedSignerPrivateKey.cjs"),
43
- ...require("./isWriteableContract.cjs"),
44
41
  ...require("./errors/index.cjs"),
45
- ...require("./math/index.cjs"),
46
- ...require("./asyncResult.cjs"),
47
42
  ...require("./getValidatedAddress.cjs"),
48
43
  ...require("./getValidatedHex.cjs"),
44
+ ...require("./interest.cjs"),
45
+ ...require("./isWriteableContract.cjs"),
49
46
  ...require("./mapValues.cjs"),
47
+ ...require("./math/index.cjs"),
48
+ ...require("./orders/index.cjs"),
49
+ ...require("./productTypeFilter.cjs"),
50
50
  ...require("./time.cjs"),
51
51
  ...require("./toPrintableObject.cjs")
52
52
  });