aftermath-ts-sdk 1.3.28 → 2.0.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 (410) hide show
  1. package/dist/index.d.ts +16828 -5
  2. package/dist/index.js +22695 -19
  3. package/dist/index.js.map +1 -0
  4. package/package.json +69 -60
  5. package/dist/general/apiHelpers/dynamicFieldsApiHelpers.d.ts +0 -41
  6. package/dist/general/apiHelpers/dynamicFieldsApiHelpers.d.ts.map +0 -1
  7. package/dist/general/apiHelpers/dynamicFieldsApiHelpers.js +0 -110
  8. package/dist/general/apiHelpers/eventsApiHelpers.d.ts +0 -43
  9. package/dist/general/apiHelpers/eventsApiHelpers.d.ts.map +0 -1
  10. package/dist/general/apiHelpers/eventsApiHelpers.js +0 -170
  11. package/dist/general/apiHelpers/inspectionsApiHelpers.d.ts +0 -28
  12. package/dist/general/apiHelpers/inspectionsApiHelpers.d.ts.map +0 -1
  13. package/dist/general/apiHelpers/inspectionsApiHelpers.js +0 -58
  14. package/dist/general/apiHelpers/objectsApiHelpers.d.ts +0 -77
  15. package/dist/general/apiHelpers/objectsApiHelpers.d.ts.map +0 -1
  16. package/dist/general/apiHelpers/objectsApiHelpers.js +0 -197
  17. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts +0 -50
  18. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +0 -1
  19. package/dist/general/apiHelpers/transactionsApiHelpers.js +0 -256
  20. package/dist/general/dynamicGas/dynamicGas.d.ts +0 -48
  21. package/dist/general/dynamicGas/dynamicGas.d.ts.map +0 -1
  22. package/dist/general/dynamicGas/dynamicGas.js +0 -69
  23. package/dist/general/dynamicGas/dynamicGasTypes.d.ts +0 -37
  24. package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +0 -1
  25. package/dist/general/dynamicGas/dynamicGasTypes.js +0 -2
  26. package/dist/general/nfts/nftsApi.d.ts +0 -35
  27. package/dist/general/nfts/nftsApi.d.ts.map +0 -1
  28. package/dist/general/nfts/nftsApi.js +0 -124
  29. package/dist/general/nfts/nftsApiCasting.d.ts +0 -11
  30. package/dist/general/nfts/nftsApiCasting.d.ts.map +0 -1
  31. package/dist/general/nfts/nftsApiCasting.js +0 -115
  32. package/dist/general/nfts/nftsTypes.d.ts +0 -31
  33. package/dist/general/nfts/nftsTypes.d.ts.map +0 -1
  34. package/dist/general/nfts/nftsTypes.js +0 -2
  35. package/dist/general/priceFeeds/priceFeeds.d.ts +0 -3
  36. package/dist/general/priceFeeds/priceFeeds.d.ts.map +0 -1
  37. package/dist/general/priceFeeds/priceFeeds.js +0 -26
  38. package/dist/general/priceFeeds/priceFeedsApi.d.ts +0 -3
  39. package/dist/general/priceFeeds/priceFeedsApi.d.ts.map +0 -1
  40. package/dist/general/priceFeeds/priceFeedsApi.js +0 -33
  41. package/dist/general/priceFeeds/priceFeedsTypes.d.ts +0 -3
  42. package/dist/general/priceFeeds/priceFeedsTypes.d.ts.map +0 -1
  43. package/dist/general/priceFeeds/priceFeedsTypes.js +0 -7
  44. package/dist/general/prices/coinGeckoTypes.d.ts +0 -16
  45. package/dist/general/prices/coinGeckoTypes.d.ts.map +0 -1
  46. package/dist/general/prices/coinGeckoTypes.js +0 -2
  47. package/dist/general/prices/prices.d.ts +0 -92
  48. package/dist/general/prices/prices.d.ts.map +0 -1
  49. package/dist/general/prices/prices.js +0 -124
  50. package/dist/general/providers/aftermath.d.ts +0 -200
  51. package/dist/general/providers/aftermath.d.ts.map +0 -1
  52. package/dist/general/providers/aftermath.js +0 -258
  53. package/dist/general/providers/aftermathApi.d.ts +0 -197
  54. package/dist/general/providers/aftermathApi.d.ts.map +0 -1
  55. package/dist/general/providers/aftermathApi.js +0 -255
  56. package/dist/general/providers/index.d.ts +0 -3
  57. package/dist/general/providers/index.d.ts.map +0 -1
  58. package/dist/general/providers/index.js +0 -18
  59. package/dist/general/types/castingTypes.d.ts +0 -51
  60. package/dist/general/types/castingTypes.d.ts.map +0 -1
  61. package/dist/general/types/castingTypes.js +0 -8
  62. package/dist/general/types/configTypes.d.ts +0 -187
  63. package/dist/general/types/configTypes.d.ts.map +0 -1
  64. package/dist/general/types/configTypes.js +0 -2
  65. package/dist/general/types/generalTypes.d.ts +0 -349
  66. package/dist/general/types/generalTypes.d.ts.map +0 -1
  67. package/dist/general/types/generalTypes.js +0 -2
  68. package/dist/general/types/index.d.ts +0 -7
  69. package/dist/general/types/index.d.ts.map +0 -1
  70. package/dist/general/types/index.js +0 -22
  71. package/dist/general/types/moveErrorsInterface.d.ts +0 -6
  72. package/dist/general/types/moveErrorsInterface.d.ts.map +0 -1
  73. package/dist/general/types/moveErrorsInterface.js +0 -2
  74. package/dist/general/types/suiTypes.d.ts +0 -2
  75. package/dist/general/types/suiTypes.d.ts.map +0 -1
  76. package/dist/general/types/suiTypes.js +0 -5
  77. package/dist/general/utils/caller.d.ts +0 -58
  78. package/dist/general/utils/caller.d.ts.map +0 -1
  79. package/dist/general/utils/caller.js +0 -231
  80. package/dist/general/utils/casting.d.ts +0 -212
  81. package/dist/general/utils/casting.d.ts.map +0 -1
  82. package/dist/general/utils/casting.js +0 -273
  83. package/dist/general/utils/fixedUtils.d.ts +0 -109
  84. package/dist/general/utils/fixedUtils.d.ts.map +0 -1
  85. package/dist/general/utils/fixedUtils.js +0 -100
  86. package/dist/general/utils/helpers.d.ts +0 -408
  87. package/dist/general/utils/helpers.d.ts.map +0 -1
  88. package/dist/general/utils/helpers.js +0 -725
  89. package/dist/general/utils/iFixedUtils.d.ts +0 -78
  90. package/dist/general/utils/iFixedUtils.d.ts.map +0 -1
  91. package/dist/general/utils/iFixedUtils.js +0 -109
  92. package/dist/general/utils/index.d.ts +0 -3
  93. package/dist/general/utils/index.d.ts.map +0 -1
  94. package/dist/general/utils/index.js +0 -18
  95. package/dist/general/wallet/wallet.d.ts +0 -89
  96. package/dist/general/wallet/wallet.d.ts.map +0 -1
  97. package/dist/general/wallet/wallet.js +0 -120
  98. package/dist/general/wallet/walletApi.d.ts +0 -20
  99. package/dist/general/wallet/walletApi.d.ts.map +0 -1
  100. package/dist/general/wallet/walletApi.js +0 -66
  101. package/dist/index.d.ts.map +0 -1
  102. package/dist/packages/auth/auth.d.ts +0 -135
  103. package/dist/packages/auth/auth.d.ts.map +0 -1
  104. package/dist/packages/auth/auth.js +0 -289
  105. package/dist/packages/auth/authTypes.d.ts +0 -102
  106. package/dist/packages/auth/authTypes.d.ts.map +0 -1
  107. package/dist/packages/auth/authTypes.js +0 -2
  108. package/dist/packages/auth/index.d.ts +0 -2
  109. package/dist/packages/auth/index.d.ts.map +0 -1
  110. package/dist/packages/auth/index.js +0 -17
  111. package/dist/packages/coin/api/coinApi.d.ts +0 -33
  112. package/dist/packages/coin/api/coinApi.d.ts.map +0 -1
  113. package/dist/packages/coin/api/coinApi.js +0 -167
  114. package/dist/packages/coin/coin.d.ts +0 -320
  115. package/dist/packages/coin/coin.d.ts.map +0 -1
  116. package/dist/packages/coin/coin.js +0 -467
  117. package/dist/packages/coin/coinTypes.d.ts +0 -139
  118. package/dist/packages/coin/coinTypes.d.ts.map +0 -1
  119. package/dist/packages/coin/coinTypes.js +0 -2
  120. package/dist/packages/coin/index.d.ts +0 -2
  121. package/dist/packages/coin/index.d.ts.map +0 -1
  122. package/dist/packages/coin/index.js +0 -17
  123. package/dist/packages/dca/api/dcaApi.d.ts +0 -26
  124. package/dist/packages/dca/api/dcaApi.d.ts.map +0 -1
  125. package/dist/packages/dca/api/dcaApi.js +0 -60
  126. package/dist/packages/dca/dca.d.ts +0 -174
  127. package/dist/packages/dca/dca.d.ts.map +0 -1
  128. package/dist/packages/dca/dca.js +0 -230
  129. package/dist/packages/dca/dcaTypes.d.ts +0 -319
  130. package/dist/packages/dca/dcaTypes.d.ts.map +0 -1
  131. package/dist/packages/dca/dcaTypes.js +0 -2
  132. package/dist/packages/dca/index.d.ts +0 -2
  133. package/dist/packages/dca/index.d.ts.map +0 -1
  134. package/dist/packages/dca/index.js +0 -17
  135. package/dist/packages/farms/api/farmsApi.d.ts +0 -996
  136. package/dist/packages/farms/api/farmsApi.d.ts.map +0 -1
  137. package/dist/packages/farms/api/farmsApi.js +0 -1826
  138. package/dist/packages/farms/api/farmsApiCasting.d.ts +0 -39
  139. package/dist/packages/farms/api/farmsApiCasting.d.ts.map +0 -1
  140. package/dist/packages/farms/api/farmsApiCasting.js +0 -427
  141. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts +0 -235
  142. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts.map +0 -1
  143. package/dist/packages/farms/api/farmsApiCastingTypes.js +0 -2
  144. package/dist/packages/farms/farms.d.ts +0 -221
  145. package/dist/packages/farms/farms.d.ts.map +0 -1
  146. package/dist/packages/farms/farms.js +0 -302
  147. package/dist/packages/farms/farmsStakedPosition.d.ts +0 -229
  148. package/dist/packages/farms/farmsStakedPosition.d.ts.map +0 -1
  149. package/dist/packages/farms/farmsStakedPosition.js +0 -473
  150. package/dist/packages/farms/farmsStakingPool.d.ts +0 -285
  151. package/dist/packages/farms/farmsStakingPool.d.ts.map +0 -1
  152. package/dist/packages/farms/farmsStakingPool.js +0 -488
  153. package/dist/packages/farms/farmsTypes.d.ts +0 -571
  154. package/dist/packages/farms/farmsTypes.d.ts.map +0 -1
  155. package/dist/packages/farms/farmsTypes.js +0 -49
  156. package/dist/packages/farms/index.d.ts +0 -4
  157. package/dist/packages/farms/index.d.ts.map +0 -1
  158. package/dist/packages/farms/index.js +0 -19
  159. package/dist/packages/faucet/api/faucetApi.d.ts +0 -37
  160. package/dist/packages/faucet/api/faucetApi.d.ts.map +0 -1
  161. package/dist/packages/faucet/api/faucetApi.js +0 -145
  162. package/dist/packages/faucet/api/faucetApiCasting.d.ts +0 -7
  163. package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +0 -1
  164. package/dist/packages/faucet/api/faucetApiCasting.js +0 -33
  165. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +0 -10
  166. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +0 -1
  167. package/dist/packages/faucet/api/faucetApiCastingTypes.js +0 -2
  168. package/dist/packages/faucet/faucet.d.ts +0 -16
  169. package/dist/packages/faucet/faucet.d.ts.map +0 -1
  170. package/dist/packages/faucet/faucet.js +0 -64
  171. package/dist/packages/faucet/faucetTypes.d.ts +0 -20
  172. package/dist/packages/faucet/faucetTypes.d.ts.map +0 -1
  173. package/dist/packages/faucet/faucetTypes.js +0 -2
  174. package/dist/packages/faucet/index.d.ts +0 -2
  175. package/dist/packages/faucet/index.d.ts.map +0 -1
  176. package/dist/packages/faucet/index.js +0 -17
  177. package/dist/packages/index.d.ts +0 -14
  178. package/dist/packages/index.d.ts.map +0 -1
  179. package/dist/packages/index.js +0 -29
  180. package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts +0 -202
  181. package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts.map +0 -1
  182. package/dist/packages/leveragedStaking/api/leveragedStakingApi.js +0 -1104
  183. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.d.ts +0 -12
  184. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.d.ts.map +0 -1
  185. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.js +0 -69
  186. package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.d.ts +0 -39
  187. package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.d.ts.map +0 -1
  188. package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.js +0 -2
  189. package/dist/packages/leveragedStaking/index.d.ts +0 -2
  190. package/dist/packages/leveragedStaking/index.d.ts.map +0 -1
  191. package/dist/packages/leveragedStaking/index.js +0 -17
  192. package/dist/packages/leveragedStaking/leveragedStaking.d.ts +0 -68
  193. package/dist/packages/leveragedStaking/leveragedStaking.d.ts.map +0 -1
  194. package/dist/packages/leveragedStaking/leveragedStaking.js +0 -154
  195. package/dist/packages/leveragedStaking/leveragedStakingTypes.d.ts +0 -48
  196. package/dist/packages/leveragedStaking/leveragedStakingTypes.d.ts.map +0 -1
  197. package/dist/packages/leveragedStaking/leveragedStakingTypes.js +0 -16
  198. package/dist/packages/limitOrders/api/limitOrdersApi.d.ts +0 -12
  199. package/dist/packages/limitOrders/api/limitOrdersApi.d.ts.map +0 -1
  200. package/dist/packages/limitOrders/api/limitOrdersApi.js +0 -25
  201. package/dist/packages/limitOrders/index.d.ts +0 -2
  202. package/dist/packages/limitOrders/index.d.ts.map +0 -1
  203. package/dist/packages/limitOrders/index.js +0 -17
  204. package/dist/packages/limitOrders/limitOrders.d.ts +0 -143
  205. package/dist/packages/limitOrders/limitOrders.d.ts.map +0 -1
  206. package/dist/packages/limitOrders/limitOrders.js +0 -190
  207. package/dist/packages/limitOrders/limitOrdersTypes.d.ts +0 -211
  208. package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +0 -1
  209. package/dist/packages/limitOrders/limitOrdersTypes.js +0 -2
  210. package/dist/packages/multisig/api/multisigApi.d.ts +0 -10
  211. package/dist/packages/multisig/api/multisigApi.d.ts.map +0 -1
  212. package/dist/packages/multisig/api/multisigApi.js +0 -39
  213. package/dist/packages/multisig/index.d.ts +0 -2
  214. package/dist/packages/multisig/index.d.ts.map +0 -1
  215. package/dist/packages/multisig/index.js +0 -17
  216. package/dist/packages/multisig/multisig.d.ts +0 -46
  217. package/dist/packages/multisig/multisig.d.ts.map +0 -1
  218. package/dist/packages/multisig/multisig.js +0 -65
  219. package/dist/packages/multisig/multisigTypes.d.ts +0 -26
  220. package/dist/packages/multisig/multisigTypes.d.ts.map +0 -1
  221. package/dist/packages/multisig/multisigTypes.js +0 -2
  222. package/dist/packages/nftAmm/api/nftAmmApi.d.ts +0 -93
  223. package/dist/packages/nftAmm/api/nftAmmApi.d.ts.map +0 -1
  224. package/dist/packages/nftAmm/api/nftAmmApi.js +0 -250
  225. package/dist/packages/nftAmm/api/nftAmmApiCasting.d.ts +0 -6
  226. package/dist/packages/nftAmm/api/nftAmmApiCasting.d.ts.map +0 -1
  227. package/dist/packages/nftAmm/api/nftAmmApiCasting.js +0 -43
  228. package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.d.ts +0 -10
  229. package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.d.ts.map +0 -1
  230. package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.js +0 -2
  231. package/dist/packages/nftAmm/index.d.ts +0 -2
  232. package/dist/packages/nftAmm/index.d.ts.map +0 -1
  233. package/dist/packages/nftAmm/index.js +0 -17
  234. package/dist/packages/nftAmm/nftAmm.d.ts +0 -18
  235. package/dist/packages/nftAmm/nftAmm.d.ts.map +0 -1
  236. package/dist/packages/nftAmm/nftAmm.js +0 -73
  237. package/dist/packages/nftAmm/nftAmmMarket.d.ts +0 -54
  238. package/dist/packages/nftAmm/nftAmmMarket.d.ts.map +0 -1
  239. package/dist/packages/nftAmm/nftAmmMarket.js +0 -154
  240. package/dist/packages/nftAmm/nftAmmTypes.d.ts +0 -51
  241. package/dist/packages/nftAmm/nftAmmTypes.d.ts.map +0 -1
  242. package/dist/packages/nftAmm/nftAmmTypes.js +0 -2
  243. package/dist/packages/perpetuals/api/perpetualsApi.d.ts +0 -44
  244. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +0 -1
  245. package/dist/packages/perpetuals/api/perpetualsApi.js +0 -1420
  246. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +0 -27
  247. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +0 -1
  248. package/dist/packages/perpetuals/api/perpetualsApiCasting.js +0 -463
  249. package/dist/packages/perpetuals/index.d.ts +0 -5
  250. package/dist/packages/perpetuals/index.d.ts.map +0 -1
  251. package/dist/packages/perpetuals/index.js +0 -20
  252. package/dist/packages/perpetuals/perpetuals.d.ts +0 -860
  253. package/dist/packages/perpetuals/perpetuals.d.ts.map +0 -1
  254. package/dist/packages/perpetuals/perpetuals.js +0 -1102
  255. package/dist/packages/perpetuals/perpetualsAccount.d.ts +0 -780
  256. package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +0 -1
  257. package/dist/packages/perpetuals/perpetualsAccount.js +0 -1406
  258. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +0 -170
  259. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +0 -1
  260. package/dist/packages/perpetuals/perpetualsCastingTypes.js +0 -2
  261. package/dist/packages/perpetuals/perpetualsMarket.d.ts +0 -360
  262. package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +0 -1
  263. package/dist/packages/perpetuals/perpetualsMarket.js +0 -475
  264. package/dist/packages/perpetuals/perpetualsTypes.d.ts +0 -2968
  265. package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +0 -1
  266. package/dist/packages/perpetuals/perpetualsTypes.js +0 -165
  267. package/dist/packages/perpetuals/perpetualsVault.d.ts +0 -438
  268. package/dist/packages/perpetuals/perpetualsVault.d.ts.map +0 -1
  269. package/dist/packages/perpetuals/perpetualsVault.js +0 -601
  270. package/dist/packages/perpetuals/utils/index.d.ts +0 -2
  271. package/dist/packages/perpetuals/utils/index.d.ts.map +0 -1
  272. package/dist/packages/perpetuals/utils/index.js +0 -17
  273. package/dist/packages/perpetuals/utils/perpetualsOrderUtils.d.ts +0 -12
  274. package/dist/packages/perpetuals/utils/perpetualsOrderUtils.d.ts.map +0 -1
  275. package/dist/packages/perpetuals/utils/perpetualsOrderUtils.js +0 -60
  276. package/dist/packages/pools/api/poolsApi.d.ts +0 -342
  277. package/dist/packages/pools/api/poolsApi.d.ts.map +0 -1
  278. package/dist/packages/pools/api/poolsApi.js +0 -857
  279. package/dist/packages/pools/api/poolsApiCasting.d.ts +0 -13
  280. package/dist/packages/pools/api/poolsApiCasting.d.ts.map +0 -1
  281. package/dist/packages/pools/api/poolsApiCasting.js +0 -91
  282. package/dist/packages/pools/api/poolsApiCastingTypes.d.ts +0 -64
  283. package/dist/packages/pools/api/poolsApiCastingTypes.d.ts.map +0 -1
  284. package/dist/packages/pools/api/poolsApiCastingTypes.js +0 -2
  285. package/dist/packages/pools/index.d.ts +0 -3
  286. package/dist/packages/pools/index.d.ts.map +0 -1
  287. package/dist/packages/pools/index.js +0 -18
  288. package/dist/packages/pools/pool.d.ts +0 -459
  289. package/dist/packages/pools/pool.d.ts.map +0 -1
  290. package/dist/packages/pools/pool.js +0 -647
  291. package/dist/packages/pools/pools.d.ts +0 -405
  292. package/dist/packages/pools/pools.d.ts.map +0 -1
  293. package/dist/packages/pools/pools.js +0 -533
  294. package/dist/packages/pools/poolsTypes.d.ts +0 -469
  295. package/dist/packages/pools/poolsTypes.d.ts.map +0 -1
  296. package/dist/packages/pools/poolsTypes.js +0 -2
  297. package/dist/packages/pools/utils/cmmmCalculations.d.ts +0 -42
  298. package/dist/packages/pools/utils/cmmmCalculations.d.ts.map +0 -1
  299. package/dist/packages/pools/utils/cmmmCalculations.js +0 -1380
  300. package/dist/packages/referralVault/api/referralVaultApi.d.ts +0 -39
  301. package/dist/packages/referralVault/api/referralVaultApi.d.ts.map +0 -1
  302. package/dist/packages/referralVault/api/referralVaultApi.js +0 -125
  303. package/dist/packages/referralVault/index.d.ts +0 -2
  304. package/dist/packages/referralVault/index.d.ts.map +0 -1
  305. package/dist/packages/referralVault/index.js +0 -17
  306. package/dist/packages/referralVault/referralVault.d.ts +0 -47
  307. package/dist/packages/referralVault/referralVault.d.ts.map +0 -1
  308. package/dist/packages/referralVault/referralVault.js +0 -71
  309. package/dist/packages/referralVault/referralVaultTypes.d.ts +0 -2
  310. package/dist/packages/referralVault/referralVaultTypes.d.ts.map +0 -1
  311. package/dist/packages/referralVault/referralVaultTypes.js +0 -2
  312. package/dist/packages/referrals/index.d.ts +0 -2
  313. package/dist/packages/referrals/index.d.ts.map +0 -1
  314. package/dist/packages/referrals/index.js +0 -17
  315. package/dist/packages/referrals/referrals.d.ts +0 -27
  316. package/dist/packages/referrals/referrals.d.ts.map +0 -1
  317. package/dist/packages/referrals/referrals.js +0 -95
  318. package/dist/packages/referrals/referralsTypes.d.ts +0 -166
  319. package/dist/packages/referrals/referralsTypes.d.ts.map +0 -1
  320. package/dist/packages/referrals/referralsTypes.js +0 -2
  321. package/dist/packages/rewards/index.d.ts +0 -2
  322. package/dist/packages/rewards/index.d.ts.map +0 -1
  323. package/dist/packages/rewards/index.js +0 -17
  324. package/dist/packages/rewards/rewards.d.ts +0 -21
  325. package/dist/packages/rewards/rewards.d.ts.map +0 -1
  326. package/dist/packages/rewards/rewards.js +0 -65
  327. package/dist/packages/rewards/rewardsTypes.d.ts +0 -169
  328. package/dist/packages/rewards/rewardsTypes.d.ts.map +0 -1
  329. package/dist/packages/rewards/rewardsTypes.js +0 -2
  330. package/dist/packages/router/api/routerApi.d.ts +0 -35
  331. package/dist/packages/router/api/routerApi.d.ts.map +0 -1
  332. package/dist/packages/router/api/routerApi.js +0 -88
  333. package/dist/packages/router/api/routerApiCasting.d.ts +0 -6
  334. package/dist/packages/router/api/routerApiCasting.d.ts.map +0 -1
  335. package/dist/packages/router/api/routerApiCasting.js +0 -22
  336. package/dist/packages/router/api/routerApiCastingTypes.d.ts +0 -12
  337. package/dist/packages/router/api/routerApiCastingTypes.d.ts.map +0 -1
  338. package/dist/packages/router/api/routerApiCastingTypes.js +0 -2
  339. package/dist/packages/router/index.d.ts +0 -2
  340. package/dist/packages/router/index.d.ts.map +0 -1
  341. package/dist/packages/router/index.js +0 -17
  342. package/dist/packages/router/router.d.ts +0 -224
  343. package/dist/packages/router/router.d.ts.map +0 -1
  344. package/dist/packages/router/router.js +0 -283
  345. package/dist/packages/router/routerTypes.d.ts +0 -300
  346. package/dist/packages/router/routerTypes.d.ts.map +0 -1
  347. package/dist/packages/router/routerTypes.js +0 -2
  348. package/dist/packages/staking/api/stakingApi.d.ts +0 -129
  349. package/dist/packages/staking/api/stakingApi.d.ts.map +0 -1
  350. package/dist/packages/staking/api/stakingApi.js +0 -487
  351. package/dist/packages/staking/api/stakingApiCasting.d.ts +0 -11
  352. package/dist/packages/staking/api/stakingApiCasting.d.ts.map +0 -1
  353. package/dist/packages/staking/api/stakingApiCasting.js +0 -87
  354. package/dist/packages/staking/api/stakingApiCastingTypes.d.ts +0 -97
  355. package/dist/packages/staking/api/stakingApiCastingTypes.d.ts.map +0 -1
  356. package/dist/packages/staking/api/stakingApiCastingTypes.js +0 -2
  357. package/dist/packages/staking/index.d.ts +0 -2
  358. package/dist/packages/staking/index.d.ts.map +0 -1
  359. package/dist/packages/staking/index.js +0 -17
  360. package/dist/packages/staking/staking.d.ts +0 -385
  361. package/dist/packages/staking/staking.d.ts.map +0 -1
  362. package/dist/packages/staking/staking.js +0 -501
  363. package/dist/packages/staking/stakingTypes.d.ts +0 -575
  364. package/dist/packages/staking/stakingTypes.d.ts.map +0 -1
  365. package/dist/packages/staking/stakingTypes.js +0 -45
  366. package/dist/packages/sui/api/suiApi.d.ts +0 -21
  367. package/dist/packages/sui/api/suiApi.d.ts.map +0 -1
  368. package/dist/packages/sui/api/suiApi.js +0 -46
  369. package/dist/packages/sui/index.d.ts +0 -2
  370. package/dist/packages/sui/index.d.ts.map +0 -1
  371. package/dist/packages/sui/index.js +0 -17
  372. package/dist/packages/sui/sui.d.ts +0 -53
  373. package/dist/packages/sui/sui.d.ts.map +0 -1
  374. package/dist/packages/sui/sui.js +0 -77
  375. package/dist/packages/suiFrens/api/suiFrensApi.d.ts +0 -204
  376. package/dist/packages/suiFrens/api/suiFrensApi.d.ts.map +0 -1
  377. package/dist/packages/suiFrens/api/suiFrensApi.js +0 -756
  378. package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts +0 -21
  379. package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts.map +0 -1
  380. package/dist/packages/suiFrens/api/suiFrensApiCasting.js +0 -181
  381. package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts +0 -77
  382. package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts.map +0 -1
  383. package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.js +0 -2
  384. package/dist/packages/suiFrens/index.d.ts +0 -4
  385. package/dist/packages/suiFrens/index.d.ts.map +0 -1
  386. package/dist/packages/suiFrens/index.js +0 -19
  387. package/dist/packages/suiFrens/stakedSuiFren.d.ts +0 -31
  388. package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +0 -1
  389. package/dist/packages/suiFrens/stakedSuiFren.js +0 -90
  390. package/dist/packages/suiFrens/suiFren.d.ts +0 -32
  391. package/dist/packages/suiFrens/suiFren.d.ts.map +0 -1
  392. package/dist/packages/suiFrens/suiFren.js +0 -150
  393. package/dist/packages/suiFrens/suiFrens.d.ts +0 -56
  394. package/dist/packages/suiFrens/suiFrens.d.ts.map +0 -1
  395. package/dist/packages/suiFrens/suiFrens.js +0 -218
  396. package/dist/packages/suiFrens/suiFrensTypes.d.ts +0 -148
  397. package/dist/packages/suiFrens/suiFrensTypes.d.ts.map +0 -1
  398. package/dist/packages/suiFrens/suiFrensTypes.js +0 -8
  399. package/dist/packages/userData/index.d.ts +0 -2
  400. package/dist/packages/userData/index.d.ts.map +0 -1
  401. package/dist/packages/userData/index.js +0 -17
  402. package/dist/packages/userData/userData.d.ts +0 -89
  403. package/dist/packages/userData/userData.d.ts.map +0 -1
  404. package/dist/packages/userData/userData.js +0 -119
  405. package/dist/packages/userData/userDataTypes.d.ts +0 -29
  406. package/dist/packages/userData/userDataTypes.d.ts.map +0 -1
  407. package/dist/packages/userData/userDataTypes.js +0 -2
  408. package/dist/types.d.ts +0 -15
  409. package/dist/types.d.ts.map +0 -1
  410. package/dist/types.js +0 -31
@@ -1,1102 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.Perpetuals = void 0;
24
- const caller_1 = require("../../general/utils/caller");
25
- const types_1 = require("../../types");
26
- const perpetualsMarket_1 = require("./perpetualsMarket");
27
- const perpetualsAccount_1 = require("./perpetualsAccount");
28
- const fixedUtils_1 = require("../../general/utils/fixedUtils");
29
- const utils_1 = require("./utils");
30
- const transactions_1 = require("@mysten/sui/transactions");
31
- const perpetualsVault_1 = require("./perpetualsVault");
32
- /**
33
- * High-level client for interacting with Aftermath Perpetuals.
34
- *
35
- * This class exposes a typed, ergonomic interface over the Perpetuals HTTP API
36
- * and websocket endpoints, including:
37
- *
38
- * - Market discovery (`getAllMarkets`, `getMarkets`, `getMarket`)
39
- * - Vault discovery (`getAllVaults`, `getVaults`, `getVault`)
40
- * - Account & position data (`getAccount`, `getAccounts`, `getAccountObjects`)
41
- * - Ownership queries (`getOwnedAccountCaps`, `getOwnedVaultCaps`)
42
- * - Historical data & stats (`getMarketCandleHistory`, `getMarkets24hrStats`)
43
- * - Pricing helpers (`getPrices`, `getLpCoinPrices`)
44
- * - Transaction builders (`getCreateAccountTx`, `getCreateVaultCapTx`, `getCreateVaultTx`)
45
- * - Websocket feeds (`openUpdatesWebsocketStream`, `openMarketCandlesWebsocketStream`)
46
- *
47
- * Typical usage via the root SDK:
48
- *
49
- * ```ts
50
- * import { Aftermath } from "@aftermath/sdk";
51
- *
52
- * const afSdk = new Aftermath("MAINNET");
53
- * await afSdk.init();
54
- *
55
- * const perps = afSdk.Perpetuals();
56
- *
57
- * // Fetch markets for a given collateral coin type
58
- * const markets = await perps.getAllMarkets({
59
- * collateralCoinType: "0x2::sui::SUI",
60
- * });
61
- *
62
- * // Fetch account + positions for a given account cap
63
- * const [accountCap] = await perps.getOwnedAccountCaps({
64
- * walletAddress: "0x...",
65
- * });
66
- *
67
- * const account = await perps.getAccount({ accountCap });
68
- *
69
- * // Build a create-account transaction (not signed or sent)
70
- * const createAccountTx = await perps.getCreateAccountTx({
71
- * walletAddress: "0x...",
72
- * collateralCoinType: "0x2::sui::SUI",
73
- * });
74
- * ```
75
- */
76
- class Perpetuals extends caller_1.Caller {
77
- // =========================================================================
78
- // Constructor
79
- // =========================================================================
80
- /**
81
- * Creates a new Perpetuals client.
82
- *
83
- * @param config - Optional caller configuration (network, auth token, etc.).
84
- * @param Provider - Optional shared {@link AftermathApi} provider instance. When
85
- * provided, transaction-building helpers can derive serialized `txKind`
86
- * from a {@link Transaction} object via `Provider.Transactions().fetchBase64TxKindFromTx`.
87
- *
88
- * @remarks
89
- * This class extends {@link Caller} with the `"perpetuals"` route prefix, meaning:
90
- * - HTTP calls resolve under `/perpetuals/...`
91
- * - Websocket calls resolve under `/perpetuals/ws/...`
92
- */
93
- constructor(config, Provider) {
94
- super(config, "perpetuals");
95
- this.Provider = Provider;
96
- }
97
- // =========================================================================
98
- // Markets
99
- // =========================================================================
100
- /**
101
- * Fetch all perpetual markets for a given collateral coin type.
102
- *
103
- * This method returns *wrapped* {@link PerpetualsMarket} instances, not the raw
104
- * market structs. Each instance provides additional helpers for pricing, margin,
105
- * and order parsing.
106
- *
107
- * @param inputs.collateralCoinType - Coin type used as collateral, e.g. `"0x2::sui::SUI"`.
108
- * @returns Object containing `markets`.
109
- *
110
- * @example
111
- * ```ts
112
- * const { markets } = await perps.getAllMarkets({
113
- * collateralCoinType: "0x2::sui::SUI",
114
- * });
115
- * ```
116
- */
117
- getAllMarkets(inputs) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- const res = yield this.fetchApi("all-markets", inputs);
120
- return {
121
- markets: res.markets.map((marketData) => new perpetualsMarket_1.PerpetualsMarket(marketData, this.config, this.Provider)),
122
- };
123
- });
124
- }
125
- /**
126
- * Fetch a single market by ID.
127
- *
128
- * Internally calls {@link getMarkets} and returns the first entry.
129
- *
130
- * @param inputs.marketId - The market (clearing house) object ID.
131
- * @returns Object containing `market`.
132
- *
133
- * @throws If the backend returns an empty list for the given `marketId`,
134
- * this will still attempt to return `markets[0]` (which would be `undefined`).
135
- * Callers may want to validate the result.
136
- *
137
- * @example
138
- * ```ts
139
- * const { market } = await perps.getMarket({ marketId: "0x..." });
140
- * ```
141
- */
142
- getMarket(inputs) {
143
- return __awaiter(this, void 0, void 0, function* () {
144
- const { markets } = yield this.getMarkets({
145
- marketIds: [inputs.marketId],
146
- });
147
- return {
148
- market: markets[0],
149
- };
150
- });
151
- }
152
- /**
153
- * Fetch multiple markets by ID.
154
- *
155
- * Backend note:
156
- * - The API supports returning orderbooks. This SDK currently constructs
157
- * {@link PerpetualsMarket} from the returned `marketDatas[].market`.
158
- *
159
- * @param inputs.marketIds - Array of market object IDs to fetch.
160
- * @returns Object containing `markets` in the same order as `marketIds`.
161
- *
162
- * @example
163
- * ```ts
164
- * const { markets } = await perps.getMarkets({
165
- * marketIds: ["0x..A", "0x..B"],
166
- * });
167
- * ```
168
- */
169
- getMarkets(inputs) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- const res = yield this.fetchApi("markets", inputs);
172
- return {
173
- markets: res.marketDatas.map((marketData) => new perpetualsMarket_1.PerpetualsMarket(marketData.market, this.config, this.Provider)),
174
- };
175
- });
176
- }
177
- // =========================================================================
178
- // Vaults
179
- // =========================================================================
180
- /**
181
- * Fetch all vaults on the current network.
182
- *
183
- * Vaults are managed accounts that can hold positions; LPs deposit collateral
184
- * and receive an LP coin (see pricing helpers like {@link getLpCoinPrices}).
185
- *
186
- * @returns Object containing `vaults`.
187
- *
188
- * @example
189
- * ```ts
190
- * const { vaults } = await perps.getAllVaults();
191
- * ```
192
- */
193
- getAllVaults() {
194
- return __awaiter(this, void 0, void 0, function* () {
195
- const res = yield this.fetchApi("vaults", {});
196
- return {
197
- vaults: res.vaults.map((vaultObject) => new perpetualsVault_1.PerpetualsVault(vaultObject, this.config, this.Provider)),
198
- };
199
- });
200
- }
201
- /**
202
- * Fetch a single vault by ID.
203
- *
204
- * Internally calls {@link getVaults} and returns the first entry.
205
- *
206
- * @param inputs.vaultId - Vault object ID.
207
- * @returns Object containing `vault`.
208
- */
209
- getVault(inputs) {
210
- return __awaiter(this, void 0, void 0, function* () {
211
- const { vaults } = yield this.getVaults({
212
- vaultIds: [inputs.vaultId],
213
- });
214
- return {
215
- vault: vaults[0],
216
- };
217
- });
218
- }
219
- /**
220
- * Fetch multiple vaults by ID.
221
- *
222
- * @param inputs.vaultIds - Array of vault object IDs.
223
- * @returns Object containing `vaults` in the same order as `vaultIds`.
224
- */
225
- getVaults(inputs) {
226
- return __awaiter(this, void 0, void 0, function* () {
227
- const res = yield this.fetchApi("vaults", inputs);
228
- return {
229
- vaults: res.vaults.map((vaultObject) => new perpetualsVault_1.PerpetualsVault(vaultObject, this.config, this.Provider)),
230
- };
231
- });
232
- }
233
- // =========================================================================
234
- // Accounts
235
- // =========================================================================
236
- /**
237
- * Convenience helper to fetch a single account (positions + account object) from an account cap.
238
- *
239
- * Internally calls {@link getAccounts} and returns the first entry.
240
- *
241
- * @param inputs.accountCap - Account cap or partial vault cap object to derive account metadata from.
242
- * @param inputs.marketIds - Optional list of markets to filter positions by.
243
- * @returns Object containing `account`.
244
- *
245
- * @example
246
- * ```ts
247
- * const [accountCap] = await perps.getOwnedAccountCaps({ walletAddress: "0x..." });
248
- * const { account } = await perps.getAccount({ accountCap });
249
- * ```
250
- */
251
- // TODO: merge this with `getAccountObjects` as an option ?
252
- getAccount(inputs) {
253
- return __awaiter(this, void 0, void 0, function* () {
254
- const { accountCap, marketIds } = inputs;
255
- return {
256
- account: (yield this.getAccounts({
257
- accountCaps: [accountCap],
258
- marketIds,
259
- })).accounts[0],
260
- };
261
- });
262
- }
263
- /**
264
- * Fetch one or more accounts (positions + account objects) from account caps.
265
- *
266
- * This composes:
267
- * 1) {@link getAccountObjects} to fetch {@link PerpetualsAccountObject}s by account ID
268
- * 2) Local pairing of returned account objects with `accountCaps`
269
- *
270
- * The returned {@link PerpetualsAccount} instances encapsulate:
271
- * - The account snapshot (positions, balances, etc.)
272
- * - The ownership/cap metadata (accountId, collateral type, vaultId, etc.)
273
- *
274
- * @param inputs.accountCaps - Array of account caps or partial vault cap objects.
275
- * @param inputs.marketIds - Optional list of market IDs to filter positions by.
276
- * @returns Object containing `accounts` in the same order as `accountCaps`.
277
- *
278
- * @remarks
279
- * If `accountCaps` is empty, this returns `{ accounts: [] }` without making an API call.
280
- */
281
- getAccounts(inputs) {
282
- return __awaiter(this, void 0, void 0, function* () {
283
- const { accountCaps, marketIds } = inputs;
284
- if (accountCaps.length <= 0)
285
- return {
286
- accounts: [],
287
- };
288
- const accountObjects = (yield this.getAccountObjects({
289
- accountIds: accountCaps.map((accountCap) => accountCap.accountId),
290
- marketIds,
291
- })).accounts;
292
- return {
293
- accounts: accountObjects.map((account, index) => new perpetualsAccount_1.PerpetualsAccount(account, accountCaps[index], this.config, this.Provider)),
294
- };
295
- });
296
- }
297
- /**
298
- * Fetch raw account objects (including positions) for one or more account IDs.
299
- *
300
- * This is the lower-level primitive used by {@link getAccounts}.
301
- *
302
- * @param inputs.accountIds - List of account IDs to query.
303
- * @param inputs.marketIds - Optional list of market IDs to filter positions by.
304
- *
305
- * @returns {@link ApiPerpetualsAccountPositionsResponse} containing `accounts`.
306
- *
307
- * @remarks
308
- * If `accountIds` is empty, this returns `{ accounts: [] }` without making an API call.
309
- */
310
- getAccountObjects(inputs) {
311
- return __awaiter(this, void 0, void 0, function* () {
312
- const { accountIds, marketIds } = inputs;
313
- if (accountIds.length <= 0)
314
- return {
315
- accounts: [],
316
- };
317
- return this.fetchApi("accounts/positions", {
318
- accountIds,
319
- marketIds,
320
- });
321
- });
322
- }
323
- // =========================================================================
324
- // Ownership Queries
325
- // =========================================================================
326
- /**
327
- * Fetch all account caps (perpetuals accounts) owned by a wallet, optionally
328
- * filtered by collateral coin types.
329
- *
330
- * Returned values are “caps” (ownership objects), not full account snapshots.
331
- * To fetch account positions, use {@link getAccount} or {@link getAccounts}.
332
- *
333
- * @param inputs.walletAddress - Owner wallet address.
334
- * @param inputs.collateralCoinTypes - Optional list of collateral coin types to filter by.
335
- * @returns {@link ApiPerpetualsOwnedAccountCapsResponse} containing `accounts`.
336
- *
337
- * @example
338
- * ```ts
339
- * const { accounts } = await perps.getOwnedAccountCaps({
340
- * walletAddress: "0x...",
341
- * collateralCoinTypes: ["0x2::sui::SUI"],
342
- * });
343
- * ```
344
- */
345
- getOwnedAccountCaps(inputs) {
346
- return __awaiter(this, void 0, void 0, function* () {
347
- const { walletAddress, collateralCoinTypes } = inputs;
348
- return this.fetchApi("accounts/owned", {
349
- walletAddress,
350
- collateralCoinTypes,
351
- });
352
- });
353
- }
354
- /**
355
- * Fetch all vault caps owned by a wallet.
356
- *
357
- * Vault caps represent ownership/administrative authority over a vault.
358
- *
359
- * @param inputs.walletAddress - Owner wallet address.
360
- * @returns {@link ApiPerpetualsOwnedVaultCapsResponse} containing vault caps.
361
- */
362
- getOwnedVaultCaps(inputs) {
363
- return __awaiter(this, void 0, void 0, function* () {
364
- return this.fetchApi("vaults/owned-vault-caps", inputs);
365
- });
366
- }
367
- /**
368
- * Fetch all pending vault withdrawal requests created by a given wallet.
369
- *
370
- * Withdraw requests are typically created when LPs request to exit a vault
371
- * and may be subject to lock periods / delays depending on vault configuration.
372
- *
373
- * @param inputs.walletAddress - Wallet address that created the withdraw requests.
374
- * @returns {@link ApiPerpetualsVaultOwnedWithdrawRequestsResponse} containing requests.
375
- */
376
- getOwnedVaultWithdrawRequests(inputs) {
377
- return __awaiter(this, void 0, void 0, function* () {
378
- return this.fetchApi("vaults/owned-withdraw-requests", Object.assign({}, inputs));
379
- });
380
- }
381
- /**
382
- * Fetch all Perpetuals vault LP coins owned by a wallet.
383
- *
384
- * This returns coin objects (or summaries) representing LP token holdings.
385
- * Use {@link getLpCoinPrices} to value them in collateral units.
386
- *
387
- * @param inputs - {@link ApiPerpetualsVaultOwnedLpCoinsBody}.
388
- * @returns {@link ApiPerpetualsVaultOwnedLpCoinsResponse}.
389
- */
390
- getOwnedVaultLpCoins(inputs) {
391
- return __awaiter(this, void 0, void 0, function* () {
392
- return this.fetchApi("vaults/owned-lp-coins", inputs);
393
- });
394
- }
395
- /**
396
- * Fetch account caps by their account IDs.
397
- *
398
- * @param inputs.accountCapIds - List of account IDs.
399
- * @returns {@link ApiPerpetualsAccountCapsResponse} containing caps.
400
- */
401
- getAdminAccountCaps(inputs) {
402
- return __awaiter(this, void 0, void 0, function* () {
403
- return this.fetchApi("accounts", inputs);
404
- });
405
- }
406
- // =========================================================================
407
- // Historical Data & Stats
408
- // =========================================================================
409
- /**
410
- * Fetch historical OHLCV candle data for a single market.
411
- *
412
- * @param inputs.marketId - Market ID to query.
413
- * @param inputs.fromTimestamp - Start timestamp (inclusive).
414
- * @param inputs.toTimestamp - End timestamp (exclusive).
415
- * @param inputs.intervalMs - Candle interval in milliseconds.
416
- *
417
- * @returns {@link ApiPerpetualsMarketCandleHistoryResponse} containing candle points.
418
- *
419
- * @remarks
420
- * This is currently implemented on the Perpetuals root client, but it may be
421
- * relocated to {@link PerpetualsMarket} in the future.
422
- */
423
- // TODO: move to market class ?
424
- getMarketCandleHistory(inputs) {
425
- const { marketId, fromTimestamp, toTimestamp, intervalMs } = inputs;
426
- return this.fetchApi("market/candle-history", {
427
- marketId,
428
- fromTimestamp,
429
- toTimestamp,
430
- intervalMs,
431
- });
432
- }
433
- /**
434
- * Fetch 24-hour volume and price change stats for multiple markets.
435
- *
436
- * Returns volume, price change, and the latest base, collateral,
437
- * mid, and mark prices for each requested market.
438
- *
439
- * @param inputs.marketIds - Market IDs to query.
440
- * @returns {@link ApiPerpetualsMarkets24hrStatsResponse}.
441
- */
442
- getMarkets24hrStats(inputs) {
443
- return this.fetchApi("markets/24hr-stats", inputs);
444
- }
445
- // =========================================================================
446
- // Prices
447
- // =========================================================================
448
- /**
449
- * Fetch the latest prices for one or more markets.
450
- *
451
- * Returns base, collateral, order book mid, and mark prices for each
452
- * requested market.
453
- *
454
- * @param inputs.marketIds - List of market IDs to query.
455
- * @returns {@link ApiPerpetualsMarketsPricesResponse} containing `marketsPrices`.
456
- *
457
- * @remarks
458
- * If `marketIds` is empty, returns `{ marketsPrices: [] }` without making an API call.
459
- */
460
- getPrices(inputs) {
461
- return __awaiter(this, void 0, void 0, function* () {
462
- if (inputs.marketIds.length <= 0)
463
- return {
464
- marketsPrices: [],
465
- };
466
- return this.fetchApi("markets/prices", inputs);
467
- });
468
- }
469
- /**
470
- * Fetch LP coin prices (in collateral units) for a set of vaults.
471
- *
472
- * @param inputs.vaultIds - List of vault IDs to query.
473
- * @returns {@link ApiPerpetualsVaultLpCoinPricesResponse} containing `lpCoinPrices`.
474
- *
475
- * @remarks
476
- * If `vaultIds` is empty, returns `{ lpCoinPrices: [] }` without making an API call.
477
- */
478
- getLpCoinPrices(inputs) {
479
- return __awaiter(this, void 0, void 0, function* () {
480
- if (inputs.vaultIds.length <= 0)
481
- return {
482
- lpCoinPrices: [],
483
- };
484
- return this.fetchApi("vaults/lp-coin-prices", inputs);
485
- });
486
- }
487
- // =========================================================================
488
- // Transactions
489
- // =========================================================================
490
- /**
491
- * Build a `transfer-cap` transaction that transfers a Perpetuals capability object (cap)
492
- * to another wallet.
493
- *
494
- * Provide the `capObjectId` of the capability you want to transfer (e.g., an account cap
495
- * or vault cap) and the `recipientAddress` that should receive it.
496
- *
497
- * This endpoint builds a transaction only; it does not submit it on-chain.
498
- *
499
- * @param inputs.recipientAddress - Recipient wallet address that should receive the cap.
500
- * @param inputs.capObjectId - Object ID of the capability to transfer.
501
- * @param inputs.tx - Optional transaction to extend.
502
- *
503
- * @returns Transaction response containing a `tx`.
504
- */
505
- getTransferCapTx(inputs) {
506
- return __awaiter(this, void 0, void 0, function* () {
507
- var _a;
508
- const { tx, recipientAddress, capObjectId } = inputs;
509
- return this.fetchApiTxObject("transactions/transfer-cap", {
510
- recipientAddress,
511
- capObjectId,
512
- txKind: yield ((_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Transactions().fetchBase64TxKindFromTx({
513
- tx: tx !== null && tx !== void 0 ? tx : new transactions_1.Transaction(),
514
- })),
515
- }, undefined, {
516
- txKind: true,
517
- });
518
- });
519
- }
520
- /**
521
- * Build a `create-account` transaction for Aftermath Perpetuals.
522
- *
523
- * @param inputs.walletAddress - Wallet address that will own the new account.
524
- * @param inputs.collateralCoinType - Collateral coin type used by the account.
525
- * @param inputs.tx - Optional {@link Transaction} to extend; if provided, the
526
- * create-account commands are appended to this transaction.
527
- *
528
- * @returns {@link SdkTransactionResponse} with `tx`.
529
- */
530
- getCreateAccountTx(inputs) {
531
- return __awaiter(this, void 0, void 0, function* () {
532
- var _a;
533
- const { walletAddress, collateralCoinType, tx } = inputs;
534
- return this.fetchApiTxObject("transactions/create-account", {
535
- walletAddress,
536
- collateralCoinType,
537
- txKind: yield ((_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Transactions().fetchBase64TxKindFromTx({ tx })),
538
- }, undefined, {
539
- txKind: true,
540
- });
541
- });
542
- }
543
- /**
544
- * Build a `create-vault-cap` transaction.
545
- *
546
- * A vault cap is an ownership/admin object for interacting with vault management
547
- * flows. This method returns a transaction kind that mints/creates that cap.
548
- *
549
- * @param inputs - {@link ApiPerpetualsCreateVaultCapBody}.
550
- * @returns {@link SdkTransactionResponse} with `tx`.
551
- */
552
- getCreateVaultCapTx(inputs) {
553
- return __awaiter(this, void 0, void 0, function* () {
554
- return this.fetchApiTxObject("vault/transactions/create-vault-cap", inputs, undefined, {
555
- txKind: true,
556
- });
557
- });
558
- }
559
- /**
560
- * Build a `create-vault` transaction.
561
- *
562
- * This creates a new vault plus its on-chain metadata and initial LP supply
563
- * seeded by the initial deposit.
564
- *
565
- * Deposit input:
566
- * - Use `initialDepositAmount` to have the API select/merge coins as needed, OR
567
- * - Use `initialDepositCoinArg` if you already have a coin argument in a larger tx.
568
- *
569
- * Metadata:
570
- * - Stored on-chain (or in a referenced object) as part of vault creation.
571
- * - `extraFields` allows forward-compatible additions (e.g. social links).
572
- *
573
- * @param inputs.walletAddress - Address of vault owner/curator.
574
- * @param inputs.metadata - Vault display metadata (name, description, curator info).
575
- * @param inputs.metadata - Vault display metadata (name, description, curator info).
576
- * @param inputs.coinMetadataId - Coin metadata object id obtained from create vault cap tx
577
- * @param inputs.treasuryCapId - Treasury cap object id obtained from create vault cap tx
578
- * @param inputs.collateralCoinType - Collateral coin type for deposits.
579
- * @param inputs.lockPeriodMs - Lock-in period for deposits in milliseconds.
580
- * @param inputs.performanceFeePercentage - Fraction of profits taken as curator fee.
581
- * @param inputs.forceWithdrawDelayMs - Delay before forced withdrawals can be processed.
582
- * @param inputs.isSponsoredTx - Whether this tx is sponsored (gas paid by another party).
583
- * @param inputs.initialDepositAmount - Initial deposit amount (mutually exclusive with `initialDepositCoinArg`).
584
- * @param inputs.initialDepositCoinArg - Transaction object argument referencing the deposit coin.
585
- * @param inputs.tx - Optional {@link Transaction} to extend.
586
- *
587
- * @returns {@link SdkTransactionResponse} with `tx`.
588
- */
589
- getCreateVaultTx(inputs) {
590
- return __awaiter(this, void 0, void 0, function* () {
591
- var _a;
592
- const { tx } = inputs, otherInputs = __rest(inputs, ["tx"]);
593
- return this.fetchApiTxObject("vault/transactions/create-vault", Object.assign(Object.assign({}, otherInputs), { txKind: yield ((_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Transactions().fetchBase64TxKindFromTx({ tx })) }), undefined, {
594
- txKind: true,
595
- });
596
- });
597
- }
598
- // =========================================================================
599
- // Builder Codes Transactions
600
- // =========================================================================
601
- /**
602
- * Build a transaction to create an integrator configuration.
603
- *
604
- * This endpoint creates a transaction that allows a user to grant permission to an
605
- * integrator to receive fees on orders placed on their behalf. The user specifies
606
- * a maximum taker fee that the integrator can charge. The integrator can then
607
- * include their address and fee (up to the maximum) when placing orders for the user.
608
- *
609
- * The resulting transaction must be signed by the account owner and executed on-chain.
610
- *
611
- * @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorConfigTxBody}.
612
- * @returns {@link SdkTransactionResponse} with `tx`.
613
- *
614
- * @example
615
- * ```ts
616
- * const tx = await perps.getCreateBuilderCodeIntegratorConfigTx({
617
- * accountId: 123n,
618
- * integratorAddress: "0x...",
619
- * maxTakerFee: 0.001, // 0.1% max fee
620
- * });
621
- * ```
622
- */
623
- getCreateBuilderCodeIntegratorConfigTx(inputs) {
624
- return __awaiter(this, void 0, void 0, function* () {
625
- return this.fetchApiTxObject("builder-codes/transactions/create-integrator-config", inputs, undefined, {
626
- txKind: true,
627
- });
628
- });
629
- }
630
- /**
631
- * Build a transaction to remove an integrator configuration.
632
- *
633
- * This endpoint creates a transaction that removes an integrator's approval to
634
- * collect fees on orders placed on behalf of the user. Once revoked, the integrator
635
- * will no longer be able to submit orders with integrator fees for this account.
636
- * The user can re-approve the integrator at any time by calling
637
- * {@link getCreateIntegratorConfigTx} again.
638
- *
639
- * The resulting transaction must be signed by the account owner and executed on-chain.
640
- *
641
- * @param inputs - {@link ApiPerpetualsBuilderCodesRemoveIntegratorConfigTxBody}.
642
- * @returns {@link SdkTransactionResponse} with `tx`.
643
- *
644
- * @example
645
- * ```ts
646
- * const tx = await perps.getRemoveBuilderCodeIntegratorConfigTx({
647
- * accountId: 123n,
648
- * integratorAddress: "0x...",
649
- * });
650
- * ```
651
- */
652
- getRemoveBuilderCodeIntegratorConfigTx(inputs) {
653
- return __awaiter(this, void 0, void 0, function* () {
654
- return this.fetchApiTxObject("builder-codes/transactions/remove-integrator-config", inputs, undefined, {
655
- txKind: true,
656
- });
657
- });
658
- }
659
- /**
660
- * Build a transaction to initialize an integrator fee vault for a specific market.
661
- *
662
- * This endpoint creates a transaction that initializes a vault where an integrator's
663
- * fees will accumulate for a specific market (clearing house). This is a one-time
664
- * setup operation that must be performed before the integrator can claim fees from
665
- * that market. Once created, the vault will automatically collect fees as the
666
- * integrator submits orders on behalf of users in that market.
667
- *
668
- * The resulting transaction must be signed by the integrator and executed on-chain.
669
- *
670
- * @param inputs - {@link ApiPerpetualsBuilderCodesCreateIntegratorVaultTxBody}.
671
- * @returns {@link SdkTransactionResponse} with `tx`.
672
- *
673
- * @example
674
- * ```ts
675
- * const tx = await perps.getCreateBuilderCodeIntegratorVaultTx({
676
- * marketId: "0x...",
677
- * integratorAddress: "0x...",
678
- * });
679
- * ```
680
- */
681
- getCreateBuilderCodeIntegratorVaultTx(inputs) {
682
- return __awaiter(this, void 0, void 0, function* () {
683
- return this.fetchApiTxObject("builder-codes/transactions/create-integrator-vault", inputs, undefined, {
684
- txKind: true,
685
- });
686
- });
687
- }
688
- /**
689
- * Build a transaction to claim accumulated integrator fees from a vault.
690
- *
691
- * This endpoint creates a transaction that allows an integrator to claim the fees
692
- * they have earned from orders placed on behalf of users. Fees accumulate in a vault
693
- * specific to each market (clearing house) and can be claimed at any moment by the
694
- * integrator. The fees are proportional to the taker volume generated by the users'
695
- * orders that the integrator submitted.
696
- *
697
- * If a `recipientAddress` is provided, the claimed fees will be automatically
698
- * transferred to that address. Otherwise, the coin output is exposed as a transaction
699
- * argument for further use in the transaction.
700
- *
701
- * The resulting transaction must be signed by the integrator and executed on-chain.
702
- *
703
- * @param inputs - {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxBody}.
704
- * @returns {@link ApiPerpetualsBuilderCodesClaimIntegratorVaultFeesTxResponse} containing
705
- * `txKind` and optionally `coinOutArg`.
706
- *
707
- * @example
708
- * ```ts
709
- * // Claim with automatic transfer to recipient
710
- * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
711
- * marketId: "0x...",
712
- * integratorAddress: "0x...",
713
- * recipientAddress: "0x...",
714
- * });
715
- *
716
- * // Claim with coin output for further use
717
- * const response = await perps.getClaimBuilderCodeIntegratorVaultFeesTx({
718
- * marketId: "0x...",
719
- * integratorAddress: "0x...",
720
- * });
721
- * // response.coinOutArg can be used in subsequent transaction commands
722
- * ```
723
- */
724
- getClaimBuilderCodeIntegratorVaultFeesTx(inputs) {
725
- return __awaiter(this, void 0, void 0, function* () {
726
- return this.fetchApiTxObject("builder-codes/transactions/claim-integrator-vault-fees", inputs, undefined, {
727
- txKind: true,
728
- });
729
- });
730
- }
731
- // =========================================================================
732
- // Builder Codes Inspections
733
- // =========================================================================
734
- /**
735
- * Fetch integrator configuration for a specific account and integrator.
736
- *
737
- * This endpoint queries whether an integrator has been approved by an account to collect
738
- * fees on orders placed on behalf of the account. If approved, it returns the maximum
739
- * taker fee the integrator is authorized to charge. This information is useful for:
740
- * - Verifying integrator permissions before placing orders
741
- * - Displaying authorized integrators and their fee limits in UIs
742
- * - Validating that an integrator's requested fee doesn't exceed the approved maximum
743
- *
744
- * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorConfigBody}.
745
- * @returns {@link ApiPerpetualsBuilderCodesIntegratorConfigResponse} containing
746
- * `maxTakerFee` and `exists` flag.
747
- *
748
- * @example
749
- * ```ts
750
- * const config = await perps.getBuilderCodeIntegratorConfig({
751
- * accountId: 123n,
752
- * integratorAddress: "0x...",
753
- * });
754
- *
755
- * if (config.exists) {
756
- * console.log(`Integrator is approved with max fee: ${config.maxTakerFee}`);
757
- * } else {
758
- * console.log("Integrator is not approved for this account");
759
- * }
760
- * ```
761
- */
762
- getBuilderCodeIntegratorConfig(inputs) {
763
- return __awaiter(this, void 0, void 0, function* () {
764
- return this.fetchApi("builder-codes/integrator-config", inputs);
765
- });
766
- }
767
- /**
768
- * Fetch accumulated integrator vault fees across multiple markets.
769
- *
770
- * This endpoint queries the total fees an integrator has earned and accumulated in their
771
- * vaults across one or more markets (clearing houses). Integrators earn fees proportional
772
- * to the taker volume generated by orders they submit on behalf of users. These fees
773
- * accumulate in per-market vaults and can be claimed at any time using
774
- * {@link getClaimIntegratorVaultFeesTx}.
775
- *
776
- * This information is useful for:
777
- * - Displaying total claimable fees to integrators in dashboards
778
- * - Monitoring fee accrual across different markets
779
- * - Determining which markets have fees ready to be claimed
780
- *
781
- * @param inputs - {@link ApiPerpetualsBuilderCodesIntegratorVaultsBody}.
782
- * @returns {@link ApiPerpetualsBuilderCodesIntegratorVaultsResponse} containing
783
- * a vector of market vault data with accumulated fees.
784
- *
785
- * @example
786
- * ```ts
787
- * const vaultFees = await perps.getBuilderCodeIntegratorVaults({
788
- * marketIds: ["0x...BTCUSD", "0x...SUIUSD"],
789
- * integratorAddress: "0x...",
790
- * });
791
- *
792
- * for (const vault of vaultFees.integratorVaults) {
793
- * console.log(`Market ${vault.marketId}: ${vault.fees} collateral units claimable`);
794
- * }
795
- *
796
- * const totalFees = vaultFees.integratorVaults.reduce((sum, vault) => sum + vault.fees, 0);
797
- * console.log(`Total claimable: ${totalFees}`);
798
- * ```
799
- */
800
- getBuilderCodeIntegratorVaults(inputs) {
801
- return __awaiter(this, void 0, void 0, function* () {
802
- return this.fetchApi("builder-codes/integrator-vaults", inputs);
803
- });
804
- }
805
- // =========================================================================
806
- // Public Static Helpers
807
- // =========================================================================
808
- /**
809
- * Determine the logical order side (Bid/Ask) from a signed base asset amount.
810
- *
811
- * @param inputs.baseAssetAmount - Position base size. Positive/zero => Bid (long), negative => Ask (short).
812
- * @returns {@link PerpetualsOrderSide}.
813
- */
814
- static positionSide(inputs) {
815
- const baseAmount = inputs.baseAssetAmount;
816
- const isLong = Math.sign(baseAmount);
817
- const side = isLong >= 0 ? types_1.PerpetualsOrderSide.Bid : types_1.PerpetualsOrderSide.Ask;
818
- return side;
819
- }
820
- /**
821
- * Compute the effective trade price from a {@link FilledTakerOrderEvent}.
822
- *
823
- * Uses the ratio: `quoteAssetDelta / baseAssetDelta`.
824
- *
825
- * @param inputs.orderEvent - Filled taker order event.
826
- * @returns Trade price.
827
- */
828
- static orderPriceFromEvent(inputs) {
829
- const { orderEvent } = inputs;
830
- return orderEvent.quoteAssetDelta / orderEvent.baseAssetDelta;
831
- }
832
- /**
833
- * Extract the floating-point price from an encoded order ID.
834
- *
835
- * Internally uses {@link PerpetualsOrderUtils.price} and converts the fixed-point
836
- * {@link PerpetualsOrderPrice} into a `number`.
837
- *
838
- * @param inputs.orderId - Encoded order ID.
839
- * @returns Price as a `number`.
840
- */
841
- static orderPriceFromOrderId(inputs) {
842
- const { orderId } = inputs;
843
- const orderPrice = utils_1.PerpetualsOrderUtils.price(orderId);
844
- return this.orderPriceToPrice({ orderPrice });
845
- }
846
- /**
847
- * Convert a fixed-point lot/tick size (9 decimals) to a `number`.
848
- *
849
- * @param lotOrTickSize - Fixed-point size as `bigint`.
850
- * @returns Floating-point size.
851
- */
852
- static lotOrTickSizeToNumber(lotOrTickSize) {
853
- return Number(lotOrTickSize) / fixedUtils_1.FixedUtils.fixedOneN9;
854
- }
855
- /**
856
- * Convert a floating-point lot/tick size to its fixed-point representation (9 decimals).
857
- *
858
- * @param lotOrTickSize - Floating-point size.
859
- * @returns Fixed-point size as `bigint`.
860
- */
861
- static lotOrTickSizeToBigInt(lotOrTickSize) {
862
- return BigInt(Math.round(lotOrTickSize * fixedUtils_1.FixedUtils.fixedOneN9));
863
- }
864
- // =========================================================================
865
- // Websocket
866
- // =========================================================================
867
- /**
868
- * Open the main updates websocket: `/perpetuals/ws/updates`.
869
- *
870
- * The stream emits {@link PerpetualsWsUpdatesResponseMessage} envelopes and supports
871
- * multiple subscription types. This method returns a small controller with
872
- * convenience subscribe/unsubscribe functions.
873
- *
874
- * Subscription types supported by the controller:
875
- * - `market`: market state updates
876
- * - `user`: user account updates (optionally including stop orders)
877
- * - `oracle`: oracle price updates
878
- * - `orderbook`: orderbook deltas
879
- * - `marketOrders`: public market trades/orders
880
- * - `userOrders`: user trade/order events
881
- * - `userCollateralChanges`: user collateral change events
882
- * - `topOfOrderbook`: bucketed orderbook snapshots (top of orderbook)
883
- *
884
- * @param args.onMessage - Handler for parsed messages from the websocket.
885
- * @param args.onOpen - Optional handler for the `open` event.
886
- * @param args.onError - Optional handler for the `error` event.
887
- * @param args.onClose - Optional handler for the `close` event.
888
- *
889
- * @returns A controller object containing:
890
- * - `ws`: underlying {@link WebSocket}
891
- * - subscribe/unsubscribe helpers for each subscription type
892
- * - `close()`: closes the websocket
893
- */
894
- openUpdatesWebsocketStream(args) {
895
- const { onMessage, onOpen, onError, onClose } = args;
896
- const ctl = this.openWsStream({
897
- path: "ws/updates",
898
- onMessage,
899
- onOpen,
900
- onError,
901
- onClose,
902
- });
903
- /**
904
- * Subscription helpers
905
- *
906
- * Each helper sends a structured subscription message of the form:
907
- * `{ action: "subscribe" | "unsubscribe", subscriptionType: { ... } }`
908
- */
909
- const subscribeMarket = ({ marketId, }) => ctl.send({
910
- action: "subscribe",
911
- subscriptionType: { market: { marketId } },
912
- });
913
- const unsubscribeMarket = ({ marketId, }) => ctl.send({
914
- action: "unsubscribe",
915
- subscriptionType: { market: { marketId } },
916
- });
917
- const subscribeUser = ({ accountId, withStopOrders, }) => ctl.send({
918
- action: "subscribe",
919
- subscriptionType: { user: { accountId, withStopOrders } },
920
- });
921
- const unsubscribeUser = ({ accountId, withStopOrders, }) => ctl.send({
922
- action: "unsubscribe",
923
- subscriptionType: { user: { accountId, withStopOrders } },
924
- });
925
- const subscribeOracle = ({ marketId, }) => ctl.send({
926
- action: "subscribe",
927
- subscriptionType: { oracle: { marketId } },
928
- });
929
- const unsubscribeOracle = ({ marketId, }) => ctl.send({
930
- action: "unsubscribe",
931
- subscriptionType: { oracle: { marketId } },
932
- });
933
- const subscribeOrderbook = ({ marketId, }) => ctl.send({
934
- action: "subscribe",
935
- subscriptionType: { orderbook: { marketId } },
936
- });
937
- const unsubscribeOrderbook = ({ marketId, }) => ctl.send({
938
- action: "unsubscribe",
939
- subscriptionType: { orderbook: { marketId } },
940
- });
941
- const subscribeMarketOrders = ({ marketId, }) => ctl.send({
942
- action: "subscribe",
943
- subscriptionType: { marketOrders: { marketId } },
944
- });
945
- const unsubscribeMarketOrders = ({ marketId, }) => ctl.send({
946
- action: "unsubscribe",
947
- subscriptionType: { marketOrders: { marketId } },
948
- });
949
- const subscribeUserOrders = ({ accountId, }) => ctl.send({
950
- action: "subscribe",
951
- subscriptionType: { userOrders: { accountId } },
952
- });
953
- const unsubscribeUserOrders = ({ accountId, }) => ctl.send({
954
- action: "unsubscribe",
955
- subscriptionType: { userOrders: { accountId } },
956
- });
957
- const subscribeUserCollateralChanges = ({ accountId, }) => ctl.send({
958
- action: "subscribe",
959
- subscriptionType: { userCollateralChanges: { accountId } },
960
- });
961
- const unsubscribeUserCollateralChanges = ({ accountId, }) => ctl.send({
962
- action: "unsubscribe",
963
- subscriptionType: { userCollateralChanges: { accountId } },
964
- });
965
- const subscribeTopOfOrderbook = ({ marketId, priceBucketSize, bucketsNumber, }) => ctl.send({
966
- action: "subscribe",
967
- subscriptionType: {
968
- topOfOrderbook: {
969
- marketId,
970
- priceBucketSize,
971
- bucketsNumber,
972
- },
973
- },
974
- });
975
- const unsubscribeTopOfOrderbook = ({ marketId, priceBucketSize, bucketsNumber, }) => ctl.send({
976
- action: "unsubscribe",
977
- subscriptionType: {
978
- topOfOrderbook: {
979
- marketId,
980
- priceBucketSize,
981
- bucketsNumber,
982
- },
983
- },
984
- });
985
- return {
986
- ws: ctl.ws,
987
- subscribeMarket,
988
- unsubscribeMarket,
989
- subscribeUser,
990
- unsubscribeUser,
991
- subscribeOracle,
992
- unsubscribeOracle,
993
- subscribeOrderbook,
994
- unsubscribeOrderbook,
995
- subscribeMarketOrders,
996
- unsubscribeMarketOrders,
997
- subscribeUserOrders,
998
- unsubscribeUserOrders,
999
- subscribeUserCollateralChanges,
1000
- unsubscribeUserCollateralChanges,
1001
- subscribeTopOfOrderbook,
1002
- unsubscribeTopOfOrderbook,
1003
- close: ctl.close,
1004
- };
1005
- }
1006
- /**
1007
- * Open a market-candles websocket stream for a single market/interval:
1008
- * `/perpetuals/ws/market-candles/{market_id}/{interval_ms}`.
1009
- *
1010
- * The stream emits {@link PerpetualsWsCandleResponseMessage} messages,
1011
- * typically containing the latest candle for the specified interval.
1012
- *
1013
- * @param args.marketId - Market ID to subscribe to.
1014
- * @param args.intervalMs - Candle interval in milliseconds.
1015
- * @param args.onMessage - Handler for incoming candle updates.
1016
- * @param args.onOpen - Optional hook called when the websocket opens.
1017
- * @param args.onError - Optional hook called on websocket error.
1018
- * @param args.onClose - Optional hook called when the websocket closes.
1019
- *
1020
- * @returns A controller containing the raw websocket and a `close()` helper.
1021
- *
1022
- * @example
1023
- * ```ts
1024
- * const stream = perps.openMarketCandlesWebsocketStream({
1025
- * marketId: "0x...",
1026
- * intervalMs: 60_000,
1027
- * onMessage: ({ lastCandle }) => console.log(lastCandle),
1028
- * });
1029
- * ```
1030
- */
1031
- openMarketCandlesWebsocketStream(args) {
1032
- const { marketId, intervalMs, onMessage, onOpen, onError, onClose } = args;
1033
- const path = `ws/market-candles/${encodeURIComponent(marketId)}/${intervalMs}`;
1034
- const ctl = this.openWsStream({
1035
- path,
1036
- onMessage,
1037
- onOpen,
1038
- onError,
1039
- onClose,
1040
- });
1041
- return {
1042
- ws: ctl.ws,
1043
- close: ctl.close,
1044
- };
1045
- }
1046
- }
1047
- exports.Perpetuals = Perpetuals;
1048
- // =========================================================================
1049
- // Constants
1050
- // =========================================================================
1051
- /**
1052
- * Helper namespace for order-specific utilities such as parsing order IDs,
1053
- * extracting price bits, etc.
1054
- *
1055
- * This is a direct alias of {@link PerpetualsOrderUtils}.
1056
- */
1057
- Perpetuals.OrderUtils = utils_1.PerpetualsOrderUtils;
1058
- /**
1059
- * Convert a floating-point price into a fixed-point {@link PerpetualsOrderPrice}
1060
- * using 9 decimal places of precision.
1061
- *
1062
- * @param inputs.price - Price as a float.
1063
- * @returns Fixed-point order price.
1064
- */
1065
- Perpetuals.priceToOrderPrice = (inputs) => {
1066
- const { price } = inputs;
1067
- return BigInt(Math.round(price * fixedUtils_1.FixedUtils.fixedOneN9));
1068
- };
1069
- /**
1070
- * Convert a fixed-point {@link PerpetualsOrderPrice} to a float price.
1071
- *
1072
- * @param inputs.orderPrice - Fixed-point order price.
1073
- * @returns Price as a float.
1074
- */
1075
- Perpetuals.orderPriceToPrice = (inputs) => {
1076
- const { orderPrice } = inputs;
1077
- return Number(orderPrice) / fixedUtils_1.FixedUtils.fixedOneN9;
1078
- };
1079
- /**
1080
- * Infer the order side from an encoded order ID.
1081
- *
1082
- * @param orderId - Encoded order ID.
1083
- * @returns {@link PerpetualsOrderSide}.
1084
- */
1085
- Perpetuals.orderIdToSide = (orderId) => {
1086
- return Perpetuals.OrderUtils.isAsk(orderId)
1087
- ? types_1.PerpetualsOrderSide.Ask
1088
- : types_1.PerpetualsOrderSide.Bid;
1089
- };
1090
- /**
1091
- * Construct a collateral-specialized Move event type string.
1092
- *
1093
- * Many Move events are generic over a collateral coin type. This helper appends
1094
- * `<collateralCoinType>` to a base `eventType`.
1095
- *
1096
- * @param inputs.eventType - Base event type without type parameters.
1097
- * @param inputs.collateralCoinType - Collateral coin type (e.g. `"0x2::sui::SUI"`).
1098
- * @returns Fully-qualified event type string.
1099
- */
1100
- Perpetuals.eventTypeForCollateral = (inputs) => {
1101
- return `${inputs.eventType}<${inputs.collateralCoinType}>`;
1102
- };