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,1420 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PerpetualsApi = void 0;
4
- const eventsApiHelpers_1 = require("../../../general/apiHelpers/eventsApiHelpers");
5
- class PerpetualsApi {
6
- // =========================================================================
7
- // Constructor
8
- // =========================================================================
9
- constructor(Provider) {
10
- this.Provider = Provider;
11
- // =========================================================================
12
- // Objects
13
- // =========================================================================
14
- // public fetchMarket = async (inputs: {
15
- // marketId: PerpetualsMarketId;
16
- // collateralCoinType: CoinType;
17
- // }): Promise<PerpetualsMarketData> => {
18
- // const { collateralCoinType } = inputs;
19
- // return this.Provider.Objects().fetchCastObject({
20
- // objectId: inputs.marketId,
21
- // objectFromSuiObjectResponse: (data) =>
22
- // Casting.perpetuals.clearingHouseFromOnChain(
23
- // data,
24
- // collateralCoinType
25
- // ),
26
- // });
27
- // };
28
- // =========================================================================
29
- // Inspections
30
- // =========================================================================
31
- // public fetchOrderbookPrice = async (inputs: {
32
- // collateralCoinType: ObjectId;
33
- // marketId: PerpetualsMarketId;
34
- // // marketInitialSharedVersion: ObjectVersion;
35
- // }): Promise<number> => {
36
- // const {
37
- // collateralCoinType,
38
- // marketId,
39
- // // marketInitialSharedVersion
40
- // } = inputs;
41
- // const tx = new Transaction();
42
- // this.getBookPriceTx({
43
- // tx,
44
- // marketId,
45
- // collateralCoinType,
46
- // // marketInitialSharedVersion,
47
- // });
48
- // const bytes =
49
- // await this.Provider.Inspections().fetchFirstBytesFromTxOutput({
50
- // tx,
51
- // });
52
- // return PerpetualsApiCasting.orderbookPriceFromBytes(bytes);
53
- // };
54
- // public fetchAllMarketIds = async (inputs: {
55
- // collateralCoinType: CoinType;
56
- // }): Promise<PerpetualsMarketId[]> => {
57
- // const { collateralCoinType } = inputs;
58
- // const marketIdsData = await this.Provider.indexerCaller.fetchIndexer<
59
- // {
60
- // marketId: ObjectId;
61
- // }[]
62
- // >(
63
- // `perpetuals/markets/${Helpers.addLeadingZeroesToType(
64
- // collateralCoinType
65
- // )}`
66
- // );
67
- // return marketIdsData.map((data) =>
68
- // Helpers.addLeadingZeroesToType(data.marketId)
69
- // );
70
- // };
71
- // =========================================================================
72
- // Transaction Commands
73
- // =========================================================================
74
- // public depositCollateralTx = (
75
- // inputs: {
76
- // tx: Transaction;
77
- // collateralCoinType: CoinType;
78
- // accountCapId: ObjectId | TransactionArgument;
79
- // } & (
80
- // | {
81
- // coinId: ObjectId | TransactionArgument;
82
- // }
83
- // | {
84
- // coinBytes: Uint8Array;
85
- // }
86
- // )
87
- // ) => {
88
- // const { tx, collateralCoinType, accountCapId } = inputs;
89
- // return tx.moveCall({
90
- // target: Helpers.transactions.createTxTarget(
91
- // this.addresses.packages.perpetuals,
92
- // PerpetualsApi.constants.moduleNames.interface,
93
- // "deposit_collateral"
94
- // ),
95
- // typeArguments: [collateralCoinType],
96
- // arguments: [
97
- // typeof accountCapId === "string"
98
- // ? tx.object(accountCapId)
99
- // : accountCapId,
100
- // "coinBytes" in inputs
101
- // ? tx.pure(inputs.coinBytes)
102
- // : typeof inputs.coinId === "string"
103
- // ? tx.object(inputs.coinId)
104
- // : inputs.coinId,
105
- // ],
106
- // });
107
- // };
108
- // public allocateCollateralTx = (inputs: {
109
- // tx: Transaction;
110
- // packageId: PackageId;
111
- // collateralCoinType: CoinType;
112
- // accountCapId: ObjectId | TransactionArgument;
113
- // marketId: PerpetualsMarketId;
114
- // marketInitialSharedVersion: ObjectVersion;
115
- // amount: Balance;
116
- // }) => {
117
- // const { tx, collateralCoinType, accountCapId, marketId, amount } =
118
- // inputs;
119
- // return tx.moveCall({
120
- // target: Helpers.transactions.createTxTarget(
121
- // inputs.packageId,
122
- // PerpetualsApi.constants.moduleNames.interface,
123
- // "allocate_collateral"
124
- // ),
125
- // typeArguments: [collateralCoinType],
126
- // arguments: [
127
- // tx.sharedObjectRef({
128
- // objectId: marketId,
129
- // initialSharedVersion: inputs.marketInitialSharedVersion,
130
- // mutable: true,
131
- // }),
132
- // typeof accountCapId === "string"
133
- // ? tx.object(accountCapId)
134
- // : accountCapId,
135
- // tx.pure.u64(amount),
136
- // ],
137
- // });
138
- // };
139
- // public deallocateCollateralTx = (inputs: {
140
- // tx: Transaction;
141
- // packageId: PackageId;
142
- // collateralCoinType: CoinType;
143
- // accountCapId: ObjectId;
144
- // basePriceFeedId: ObjectId;
145
- // collateralPriceFeedId: ObjectId;
146
- // marketId: PerpetualsMarketId;
147
- // marketInitialSharedVersion: ObjectVersion;
148
- // amount: Balance;
149
- // }) => {
150
- // const { tx, collateralCoinType, accountCapId, marketId, amount } =
151
- // inputs;
152
- // return tx.moveCall({
153
- // target: Helpers.transactions.createTxTarget(
154
- // inputs.packageId,
155
- // PerpetualsApi.constants.moduleNames.interface,
156
- // "deallocate_collateral"
157
- // ),
158
- // typeArguments: [collateralCoinType],
159
- // arguments: [
160
- // tx.sharedObjectRef({
161
- // objectId: marketId,
162
- // initialSharedVersion: inputs.marketInitialSharedVersion,
163
- // mutable: true,
164
- // }),
165
- // tx.object(accountCapId),
166
- // tx.object(inputs.basePriceFeedId),
167
- // tx.object(inputs.collateralPriceFeedId),
168
- // tx.object(Sui.constants.addresses.suiClockId),
169
- // tx.pure.u64(amount),
170
- // ],
171
- // });
172
- // };
173
- // public createMarketPositionTx = (inputs: {
174
- // tx: Transaction;
175
- // packageId: PackageId;
176
- // collateralCoinType: CoinType;
177
- // accountCapId: ObjectId | TransactionArgument;
178
- // marketId: PerpetualsMarketId;
179
- // marketInitialSharedVersion: ObjectVersion;
180
- // }) => {
181
- // const { tx, collateralCoinType, accountCapId, marketId } = inputs;
182
- // return tx.moveCall({
183
- // target: Helpers.transactions.createTxTarget(
184
- // inputs.packageId,
185
- // PerpetualsApi.constants.moduleNames.interface,
186
- // "create_market_position"
187
- // ),
188
- // typeArguments: [collateralCoinType],
189
- // arguments: [
190
- // tx.sharedObjectRef({
191
- // objectId: marketId,
192
- // initialSharedVersion: inputs.marketInitialSharedVersion,
193
- // mutable: true,
194
- // }),
195
- // typeof accountCapId === "string"
196
- // ? tx.object(accountCapId)
197
- // : accountCapId,
198
- // ],
199
- // });
200
- // };
201
- // public shareClearingHouseTx = (inputs: {
202
- // tx: Transaction;
203
- // packageId: PackageId;
204
- // collateralCoinType: CoinType;
205
- // marketId: PerpetualsMarketId | TransactionArgument;
206
- // }) => {
207
- // const { tx, collateralCoinType, marketId } = inputs;
208
- // return tx.moveCall({
209
- // target: Helpers.transactions.createTxTarget(
210
- // inputs.packageId,
211
- // PerpetualsApi.constants.moduleNames.interface,
212
- // "share_clearing_house"
213
- // ),
214
- // typeArguments: [collateralCoinType],
215
- // arguments: [
216
- // typeof marketId === "string" ? tx.object(marketId) : marketId,
217
- // ],
218
- // });
219
- // };
220
- // public startSessionTx = (inputs: {
221
- // tx: Transaction;
222
- // packageId: PackageId;
223
- // collateralCoinType: CoinType;
224
- // accountCapId: ObjectId | TransactionArgument;
225
- // basePriceFeedId: ObjectId;
226
- // collateralPriceFeedId: ObjectId;
227
- // marketId: PerpetualsMarketId;
228
- // marketInitialSharedVersion: ObjectVersion;
229
- // }) /* SessionHotPotato<T> */ => {
230
- // const { tx, collateralCoinType, accountCapId, marketId } = inputs;
231
- // return tx.moveCall({
232
- // target: Helpers.transactions.createTxTarget(
233
- // inputs.packageId,
234
- // PerpetualsApi.constants.moduleNames.interface,
235
- // "start_session"
236
- // ),
237
- // typeArguments: [collateralCoinType],
238
- // arguments: [
239
- // tx.sharedObjectRef({
240
- // objectId: marketId,
241
- // initialSharedVersion: inputs.marketInitialSharedVersion,
242
- // mutable: true,
243
- // }),
244
- // typeof accountCapId === "string"
245
- // ? tx.object(accountCapId)
246
- // : accountCapId,
247
- // tx.object(inputs.basePriceFeedId),
248
- // tx.object(inputs.collateralPriceFeedId),
249
- // tx.object(Sui.constants.addresses.suiClockId),
250
- // ],
251
- // });
252
- // };
253
- // public endSessionTx = (inputs: {
254
- // tx: Transaction;
255
- // packageId: PackageId;
256
- // collateralCoinType: CoinType;
257
- // sessionPotatoId: ObjectId | TransactionArgument;
258
- // }) /* ClearingHouse<T> */ => {
259
- // const { tx, collateralCoinType, sessionPotatoId } = inputs;
260
- // return tx.moveCall({
261
- // target: Helpers.transactions.createTxTarget(
262
- // inputs.packageId,
263
- // PerpetualsApi.constants.moduleNames.interface,
264
- // "end_session"
265
- // ),
266
- // typeArguments: [collateralCoinType],
267
- // arguments: [
268
- // typeof sessionPotatoId === "string"
269
- // ? tx.object(sessionPotatoId)
270
- // : sessionPotatoId,
271
- // ],
272
- // });
273
- // };
274
- // public placeMarketOrderTx = (inputs: {
275
- // tx: Transaction;
276
- // packageId: PackageId;
277
- // collateralCoinType: CoinType;
278
- // sessionPotatoId: ObjectId | TransactionArgument;
279
- // side: PerpetualsOrderSide;
280
- // size: bigint;
281
- // }) => {
282
- // const { tx, collateralCoinType, sessionPotatoId, side, size } = inputs;
283
- // return tx.moveCall({
284
- // target: Helpers.transactions.createTxTarget(
285
- // inputs.packageId,
286
- // PerpetualsApi.constants.moduleNames.interface,
287
- // "place_market_order"
288
- // ),
289
- // typeArguments: [collateralCoinType],
290
- // arguments: [
291
- // typeof sessionPotatoId === "string"
292
- // ? tx.object(sessionPotatoId)
293
- // : sessionPotatoId,
294
- // tx.pure.bool(Boolean(side)),
295
- // tx.pure.u64(size),
296
- // ],
297
- // });
298
- // };
299
- // public placeLimitOrderTx = (inputs: {
300
- // tx: Transaction;
301
- // packageId: PackageId;
302
- // collateralCoinType: CoinType;
303
- // sessionPotatoId: ObjectId | TransactionArgument;
304
- // side: PerpetualsOrderSide;
305
- // size: bigint;
306
- // price: bigint;
307
- // orderType: PerpetualsOrderType;
308
- // }) => {
309
- // const {
310
- // tx,
311
- // collateralCoinType,
312
- // sessionPotatoId,
313
- // side,
314
- // size,
315
- // price,
316
- // orderType,
317
- // } = inputs;
318
- // return tx.moveCall({
319
- // target: Helpers.transactions.createTxTarget(
320
- // inputs.packageId,
321
- // PerpetualsApi.constants.moduleNames.interface,
322
- // "place_limit_order"
323
- // ),
324
- // typeArguments: [collateralCoinType],
325
- // arguments: [
326
- // typeof sessionPotatoId === "string"
327
- // ? tx.object(sessionPotatoId)
328
- // : sessionPotatoId,
329
- // tx.pure.bool(Boolean(side)),
330
- // tx.pure.u64(size),
331
- // tx.pure.u64(price),
332
- // tx.pure.u64(BigInt(orderType)),
333
- // ],
334
- // });
335
- // };
336
- // public cancelOrdersTx = (inputs: {
337
- // tx: Transaction;
338
- // packageId: PackageId;
339
- // collateralCoinType: CoinType;
340
- // accountCapId: ObjectId;
341
- // marketId: PerpetualsMarketId;
342
- // marketInitialSharedVersion: ObjectVersion;
343
- // orderIds: PerpetualsOrderId[];
344
- // }) => {
345
- // const { tx, collateralCoinType, accountCapId, marketId, orderIds } =
346
- // inputs;
347
- // return tx.moveCall({
348
- // target: Helpers.transactions.createTxTarget(
349
- // inputs.packageId,
350
- // PerpetualsApi.constants.moduleNames.interface,
351
- // "cancel_orders"
352
- // ),
353
- // typeArguments: [collateralCoinType],
354
- // arguments: [
355
- // tx.sharedObjectRef({
356
- // objectId: marketId,
357
- // initialSharedVersion: inputs.marketInitialSharedVersion,
358
- // mutable: true,
359
- // }),
360
- // tx.object(accountCapId),
361
- // tx.pure(bcs.vector(bcs.u128()).serialize(orderIds)),
362
- // ],
363
- // });
364
- // };
365
- // public reduceOrdersTx = (inputs: {
366
- // tx: Transaction;
367
- // packageId: PackageId;
368
- // collateralCoinType: CoinType;
369
- // accountCapId: ObjectId;
370
- // marketId: PerpetualsMarketId;
371
- // marketInitialSharedVersion: ObjectVersion;
372
- // orderIds: PerpetualsOrderId[];
373
- // sizesToSubtract: bigint[];
374
- // }) => {
375
- // const {
376
- // tx,
377
- // packageId,
378
- // collateralCoinType,
379
- // accountCapId,
380
- // marketId,
381
- // orderIds,
382
- // sizesToSubtract,
383
- // } = inputs;
384
- // return tx.moveCall({
385
- // target: Helpers.transactions.createTxTarget(
386
- // packageId,
387
- // PerpetualsApi.constants.moduleNames.interface,
388
- // "reduce_orders"
389
- // ),
390
- // typeArguments: [collateralCoinType],
391
- // arguments: [
392
- // tx.sharedObjectRef({
393
- // objectId: marketId,
394
- // initialSharedVersion: inputs.marketInitialSharedVersion,
395
- // mutable: true,
396
- // }),
397
- // tx.object(accountCapId),
398
- // tx.pure(bcs.vector(bcs.u128()).serialize(orderIds)),
399
- // tx.pure(bcs.vector(bcs.u64()).serialize(sizesToSubtract)),
400
- // ],
401
- // });
402
- // };
403
- // public withdrawCollateralTx = (inputs: {
404
- // tx: Transaction;
405
- // collateralCoinType: CoinType;
406
- // accountCapId: ObjectId | TransactionArgument;
407
- // amount: Balance;
408
- // }): TransactionArgument => {
409
- // const { tx, collateralCoinType, accountCapId, amount } = inputs;
410
- // return tx.moveCall({
411
- // target: Helpers.transactions.createTxTarget(
412
- // this.addresses.packages.perpetuals,
413
- // PerpetualsApi.constants.moduleNames.interface,
414
- // "withdraw_collateral"
415
- // ),
416
- // typeArguments: [collateralCoinType],
417
- // arguments: [
418
- // typeof accountCapId === "string"
419
- // ? tx.object(accountCapId)
420
- // : accountCapId,
421
- // tx.pure.u64(amount),
422
- // ],
423
- // });
424
- // };
425
- // public createAccountTx = (inputs: {
426
- // tx: Transaction;
427
- // collateralCoinType: CoinType;
428
- // }) /* Account<T> */ => {
429
- // const { tx, collateralCoinType } = inputs;
430
- // return tx.moveCall({
431
- // target: Helpers.transactions.createTxTarget(
432
- // this.addresses.packages.perpetuals,
433
- // PerpetualsApi.constants.moduleNames.interface,
434
- // "create_account"
435
- // ),
436
- // typeArguments: [collateralCoinType],
437
- // arguments: [tx.object(this.addresses.objects.registry)],
438
- // });
439
- // };
440
- // public getHotPotatoFieldsTx = (
441
- // inputs: {
442
- // tx: Transaction;
443
- // collateralCoinType: CoinType;
444
- // sessionPotatoId: ObjectId | TransactionArgument;
445
- // }
446
- // /*
447
- // (
448
- // lot_size,
449
- // tick_size,
450
- // timestamp_ms,
451
- // collateral_price,
452
- // index_price,
453
- // book_price,
454
- // fills,
455
- // post
456
- // ): (
457
- // u64,
458
- // u64,
459
- // u64,
460
- // u64,
461
- // u256,
462
- // u256,
463
- // u256,
464
- // &vector<FillReceipt>,
465
- // &PostReceipt
466
- // )
467
- // */
468
- // ) => {
469
- // const { tx, collateralCoinType, sessionPotatoId } = inputs;
470
- // return tx.moveCall({
471
- // target: Helpers.transactions.createTxTarget(
472
- // inputs.packageId,
473
- // PerpetualsApi.constants.moduleNames.clearingHouse,
474
- // "get_hot_potato_fields"
475
- // ),
476
- // typeArguments: [collateralCoinType],
477
- // arguments: [
478
- // typeof sessionPotatoId === "string"
479
- // ? tx.object(sessionPotatoId)
480
- // : sessionPotatoId,
481
- // ],
482
- // });
483
- // };
484
- // public getPositionTx = (inputs: {
485
- // tx: Transaction;
486
- // packageId: PackageId;
487
- // collateralCoinType: CoinType;
488
- // accountId: PerpetualsAccountId;
489
- // marketId: PerpetualsMarketId;
490
- // marketInitialSharedVersion: ObjectVersion;
491
- // }) /* Position */ => {
492
- // const { tx, marketId, collateralCoinType } = inputs;
493
- // return tx.moveCall({
494
- // target: Helpers.transactions.createTxTarget(
495
- // inputs.packageId,
496
- // PerpetualsApi.constants.moduleNames.clearingHouse,
497
- // "get_position"
498
- // ),
499
- // typeArguments: [collateralCoinType],
500
- // arguments: [
501
- // tx.sharedObjectRef({
502
- // objectId: marketId,
503
- // initialSharedVersion: inputs.marketInitialSharedVersion,
504
- // mutable: false,
505
- // }),
506
- // tx.pure.u64(inputs.accountId),
507
- // ],
508
- // });
509
- // };
510
- // public getOrderbookTx = (inputs: {
511
- // tx: Transaction;
512
- // packageId: PackageId;
513
- // collateralCoinType: CoinType;
514
- // marketId: PerpetualsMarketId;
515
- // }) /* Orderbook */ => {
516
- // const { tx, collateralCoinType } = inputs;
517
- // return tx.moveCall({
518
- // target: Helpers.transactions.createTxTarget(
519
- // inputs.packageId,
520
- // PerpetualsApi.constants.moduleNames.clearingHouse,
521
- // "get_orderbook"
522
- // ),
523
- // typeArguments: [collateralCoinType],
524
- // arguments: [tx.object(inputs.marketId)],
525
- // });
526
- // };
527
- // public getBookPriceTx = (inputs: {
528
- // tx: Transaction;
529
- // packageId: PackageId;
530
- // marketId: PerpetualsMarketId;
531
- // // marketInitialSharedVersion: ObjectVersion;
532
- // collateralCoinType: CoinType;
533
- // }) /* Option<u256> */ => {
534
- // const { tx, marketId, collateralCoinType } = inputs;
535
- // return tx.moveCall({
536
- // target: Helpers.transactions.createTxTarget(
537
- // inputs.packageId,
538
- // PerpetualsApi.constants.moduleNames.clearingHouse,
539
- // "get_book_price"
540
- // ),
541
- // typeArguments: [collateralCoinType],
542
- // arguments: [
543
- // tx.object(marketId),
544
- // // tx.sharedObjectRef({
545
- // // objectId: marketId,
546
- // // initialSharedVersion: inputs.marketInitialSharedVersion,
547
- // // mutable: false,
548
- // // }),
549
- // ],
550
- // });
551
- // };
552
- // public getBestPriceTx = (inputs: {
553
- // tx: Transaction;
554
- // packageId: PackageId;
555
- // marketId: PerpetualsMarketId;
556
- // marketInitialSharedVersion: ObjectVersion;
557
- // side: PerpetualsOrderSide;
558
- // collateralCoinType: CoinType;
559
- // }) /* Option<u256> */ => {
560
- // const { tx, marketId, collateralCoinType } = inputs;
561
- // return tx.moveCall({
562
- // target: Helpers.transactions.createTxTarget(
563
- // inputs.packageId,
564
- // PerpetualsApi.constants.moduleNames.clearingHouse,
565
- // "get_best_price"
566
- // ),
567
- // typeArguments: [collateralCoinType],
568
- // arguments: [
569
- // tx.sharedObjectRef({
570
- // objectId: marketId,
571
- // initialSharedVersion: inputs.marketInitialSharedVersion,
572
- // mutable: false,
573
- // }), // ClearingHouse
574
- // tx.pure.bool(Boolean(inputs.side)), // side
575
- // ],
576
- // });
577
- // };
578
- // public inspectOrdersTx = (inputs: {
579
- // tx: Transaction;
580
- // packageId: PackageId;
581
- // orderbookId: ObjectId | TransactionArgument;
582
- // side: PerpetualsOrderSide;
583
- // fromPrice: number;
584
- // toPrice: number;
585
- // }) /* vector<OrderInfo> */ => {
586
- // const { tx, orderbookId } = inputs;
587
- // return tx.moveCall({
588
- // target: Helpers.transactions.createTxTarget(
589
- // inputs.packageId,
590
- // PerpetualsApi.constants.moduleNames.orderbook,
591
- // "inspect_orders"
592
- // ),
593
- // typeArguments: [],
594
- // arguments: [
595
- // typeof orderbookId === "string"
596
- // ? tx.object(orderbookId)
597
- // : orderbookId, // Orderbook
598
- // tx.pure.bool(Boolean(inputs.side)), // side
599
- // tx.pure.u64(inputs.fromPrice), // price_from
600
- // tx.pure.u64(inputs.toPrice), // price_to
601
- // ],
602
- // });
603
- // };
604
- // public getOrderSizeTx = (inputs: {
605
- // tx: Transaction;
606
- // packageId: PackageId;
607
- // orderbookId: ObjectId | TransactionArgument;
608
- // orderId: PerpetualsOrderId;
609
- // }) /* u64 */ => {
610
- // const { tx, orderbookId } = inputs;
611
- // return tx.moveCall({
612
- // target: Helpers.transactions.createTxTarget(
613
- // inputs.packageId,
614
- // PerpetualsApi.constants.moduleNames.orderbook,
615
- // "get_order_size"
616
- // ),
617
- // typeArguments: [],
618
- // arguments: [
619
- // typeof orderbookId === "string"
620
- // ? tx.object(orderbookId)
621
- // : orderbookId, // Orderbook
622
- // tx.pure.u128(inputs.orderId), // order_id
623
- // ],
624
- // });
625
- // };
626
- // =========================================================================
627
- // Transaction Builders
628
- // =========================================================================
629
- // public fetchBuildDepositCollateralTx = async (
630
- // inputs: ApiPerpetualsDepositCollateralBody
631
- // ): Promise<Transaction> => {
632
- // const tx = new Transaction();
633
- // tx.setSender(inputs.walletAddress);
634
- // const { walletAddress, collateralCoinType, amount } = inputs;
635
- // const coinId = await this.Provider.Coin().fetchCoinWithAmountTx({
636
- // tx,
637
- // walletAddress,
638
- // coinType: collateralCoinType,
639
- // coinAmount: amount,
640
- // });
641
- // this.depositCollateralTx({
642
- // tx,
643
- // coinId,
644
- // ...inputs,
645
- // });
646
- // return tx;
647
- // };
648
- // public buildCancelOrderTx = (
649
- // inputs: ApiPerpetualsCancelOrderBody
650
- // ): Transaction => {
651
- // const {
652
- // packageId,
653
- // orderId,
654
- // marketId,
655
- // marketInitialSharedVersion,
656
- // collateralChange,
657
- // basePriceFeedId,
658
- // collateralPriceFeedId,
659
- // ...otherInputs
660
- // } = inputs;
661
- // return this.buildCancelOrdersTx({
662
- // ...otherInputs,
663
- // orderDatas: [
664
- // {
665
- // packageId,
666
- // orderId,
667
- // marketId,
668
- // marketInitialSharedVersion,
669
- // collateralChange,
670
- // basePriceFeedId,
671
- // collateralPriceFeedId,
672
- // },
673
- // ],
674
- // });
675
- // };
676
- // public buildCancelOrdersTx = (
677
- // inputs: ApiPerpetualsCancelOrdersBody
678
- // ): Transaction => {
679
- // const { orderDatas, collateralCoinType, accountCapId } = inputs;
680
- // if (orderDatas.length <= 0)
681
- // throw new Error("cannot have order datas of length zero");
682
- // const tx = new Transaction();
683
- // tx.setSender(inputs.walletAddress);
684
- // const marketIdToOrderIds = orderDatas.reduce(
685
- // (acc, order) => {
686
- // if (order.marketId in acc) {
687
- // return {
688
- // ...acc,
689
- // [order.marketId]: [...acc[order.marketId], order],
690
- // };
691
- // }
692
- // return {
693
- // ...acc,
694
- // [order.marketId]: [order],
695
- // };
696
- // },
697
- // {} as Record<
698
- // PerpetualsMarketId,
699
- // {
700
- // packageId: PackageId;
701
- // orderId: PerpetualsOrderId;
702
- // marketId: PerpetualsMarketId;
703
- // marketInitialSharedVersion: ObjectVersion;
704
- // collateralChange: Balance;
705
- // basePriceFeedId: ObjectId;
706
- // collateralPriceFeedId: ObjectId;
707
- // }[]
708
- // >
709
- // );
710
- // for (const [marketId, orders] of Object.entries(marketIdToOrderIds)) {
711
- // if (orders.length <= 0) continue;
712
- // const marketInitialSharedVersion =
713
- // orders[0].marketInitialSharedVersion;
714
- // const packageId = orders[0].packageId;
715
- // this.cancelOrdersTx({
716
- // tx,
717
- // collateralCoinType,
718
- // accountCapId,
719
- // marketId,
720
- // marketInitialSharedVersion,
721
- // packageId,
722
- // orderIds: orders.map((order) => order.orderId),
723
- // });
724
- // const netCollateralChange = Helpers.sumBigInt(
725
- // orders.map((order) => order.collateralChange)
726
- // );
727
- // if (netCollateralChange < BigInt(0)) {
728
- // this.deallocateCollateralTx({
729
- // tx,
730
- // accountCapId,
731
- // collateralCoinType,
732
- // marketId,
733
- // marketInitialSharedVersion,
734
- // packageId,
735
- // amount: Helpers.absBigInt(netCollateralChange),
736
- // basePriceFeedId: orders[0].basePriceFeedId,
737
- // collateralPriceFeedId: orders[0].collateralPriceFeedId,
738
- // });
739
- // } else if (netCollateralChange > BigInt(0)) {
740
- // this.allocateCollateralTx({
741
- // tx,
742
- // accountCapId,
743
- // collateralCoinType,
744
- // marketId,
745
- // marketInitialSharedVersion,
746
- // packageId,
747
- // amount: netCollateralChange,
748
- // });
749
- // } else {
750
- // // no collateral change
751
- // }
752
- // }
753
- // return tx;
754
- // };
755
- // public buildTransferCollateralTx = (inputs: {
756
- // walletAddress: SuiAddress;
757
- // collateralCoinType: CoinType;
758
- // fromAccountCapId: ObjectId | TransactionArgument;
759
- // toAccountCapId: ObjectId | TransactionArgument;
760
- // amount: Balance;
761
- // }): Transaction => {
762
- // const {
763
- // walletAddress,
764
- // collateralCoinType,
765
- // fromAccountCapId,
766
- // toAccountCapId,
767
- // amount,
768
- // } = inputs;
769
- // const tx = new Transaction();
770
- // tx.setSender(walletAddress);
771
- // const coinId = this.withdrawCollateralTx({
772
- // tx,
773
- // collateralCoinType,
774
- // amount,
775
- // accountCapId: fromAccountCapId,
776
- // });
777
- // this.depositCollateralTx({
778
- // tx,
779
- // collateralCoinType,
780
- // coinId,
781
- // accountCapId: toAccountCapId,
782
- // });
783
- // return tx;
784
- // };
785
- // public buildAllocateCollateralTx = TransactionsApiHelpers.createBuildTxFunc(
786
- // this.allocateCollateralTx
787
- // );
788
- // public buildDeallocateCollateralTx =
789
- // TransactionsApiHelpers.createBuildTxFunc(this.deallocateCollateralTx);
790
- // public buildReduceOrdersTx = (
791
- // inputs: ApiPerpetualsReduceOrdersBody
792
- // ): Transaction => {
793
- // const {
794
- // walletAddress,
795
- // collateralChange,
796
- // accountCapId,
797
- // collateralCoinType,
798
- // marketId,
799
- // marketInitialSharedVersion,
800
- // packageId,
801
- // basePriceFeedId,
802
- // collateralPriceFeedId,
803
- // orderIds,
804
- // sizesToSubtract,
805
- // } = inputs;
806
- // const tx = new Transaction();
807
- // tx.setSender(walletAddress);
808
- // this.reduceOrdersTx({
809
- // tx,
810
- // packageId,
811
- // collateralCoinType,
812
- // accountCapId,
813
- // marketId,
814
- // marketInitialSharedVersion,
815
- // orderIds,
816
- // sizesToSubtract,
817
- // });
818
- // if (collateralChange < BigInt(0)) {
819
- // this.deallocateCollateralTx({
820
- // tx,
821
- // accountCapId,
822
- // collateralCoinType,
823
- // marketId,
824
- // marketInitialSharedVersion,
825
- // packageId,
826
- // basePriceFeedId,
827
- // collateralPriceFeedId,
828
- // amount: Helpers.absBigInt(collateralChange),
829
- // });
830
- // } else if (collateralChange > BigInt(0)) {
831
- // this.allocateCollateralTx({
832
- // tx,
833
- // accountCapId,
834
- // collateralCoinType,
835
- // marketId,
836
- // marketInitialSharedVersion,
837
- // packageId,
838
- // amount: collateralChange,
839
- // });
840
- // } else {
841
- // // no collateral change
842
- // }
843
- // return tx;
844
- // };
845
- // =========================================================================
846
- // Helpers
847
- // =========================================================================
848
- this.getAccountCapType = (inputs) => {
849
- return `${this.addresses.packages.events}::${PerpetualsApi.constants.moduleNames.account}::Account<${inputs.collateralCoinType}>`;
850
- };
851
- // =========================================================================
852
- // Private Helpers
853
- // =========================================================================
854
- // private fetchOrdersSizes = async (inputs: {
855
- // orderIds: PerpetualsOrderId[];
856
- // collateralCoinType: ObjectId;
857
- // marketId: PerpetualsMarketId;
858
- // }): Promise<bigint[]> => {
859
- // const { orderIds, marketId, collateralCoinType } = inputs;
860
- // if (orderIds.length <= 0) return [];
861
- // const tx = new Transaction();
862
- // const orderbookId = this.getOrderbookTx({
863
- // tx,
864
- // collateralCoinType,
865
- // marketId,
866
- // });
867
- // for (const orderId of orderIds) {
868
- // this.getOrderSizeTx({
869
- // tx,
870
- // orderId,
871
- // orderbookId,
872
- // });
873
- // }
874
- // const { allBytes } =
875
- // await this.Provider.Inspections().fetchAllBytesFromTx({
876
- // tx,
877
- // });
878
- // const sizes = allBytes
879
- // .slice(1)
880
- // .map((bytes) => Casting.bigIntFromBytes(bytes[0]));
881
- // return sizes;
882
- // };
883
- // private fetchOrderbookOrders = async (inputs: {
884
- // collateralCoinType: ObjectId;
885
- // marketId: PerpetualsMarketId;
886
- // side: PerpetualsOrderSide;
887
- // fromPrice: PerpetualsOrderPrice;
888
- // toPrice: PerpetualsOrderPrice;
889
- // }): Promise<PerpetualsOrderInfo[]> => {
890
- // const { collateralCoinType, marketId, side, fromPrice, toPrice } =
891
- // inputs;
892
- // const tx = new Transaction();
893
- // const orderbookId = this.getOrderbookTx({
894
- // tx,
895
- // collateralCoinType,
896
- // marketId,
897
- // });
898
- // this.inspectOrdersTx({ tx, orderbookId, side, fromPrice, toPrice });
899
- // const bytes =
900
- // await this.Provider.Inspections().fetchFirstBytesFromTxOutput({
901
- // tx,
902
- // });
903
- // const orderInfos: any[] = bcs
904
- // .vector(perpetualsRegistry.OrderInfo)
905
- // .parse(new Uint8Array(bytes));
906
- // return orderInfos.map((orderInfo) =>
907
- // Casting.perpetuals.orderInfoFromRaw(orderInfo)
908
- // );
909
- // };
910
- // public fetchExecutionPrice = async (
911
- // inputs: ApiPerpetualsExecutionPriceBody & {
912
- // collateralCoinType: CoinType;
913
- // marketId: PerpetualsMarketId;
914
- // }
915
- // ): Promise<ApiPerpetualsExecutionPriceResponse> => {
916
- // const {
917
- // // collateral,
918
- // collateralCoinType,
919
- // marketId,
920
- // side,
921
- // size,
922
- // price,
923
- // lotSize,
924
- // basePriceFeedId,
925
- // collateralPriceFeedId,
926
- // } = inputs;
927
- // // TODO: change this
928
- // const collateral = BigInt(1000000000000000);
929
- // // const accountCapId = perpetualsBcsRegistry
930
- // // .ser(`Account<${collateralCoinType}>`, {
931
- // // id: {
932
- // // id: {
933
- // // bytes: "0x0000000000000000000000000000000000000000000000000000000000000321",
934
- // // },
935
- // // },
936
- // // accountId: 0,
937
- // // collateral,
938
- // // })
939
- // // .toBytes();
940
- // const depositCoinBytes = perpetualsRegistry.Coin.serialize({
941
- // id: "0x0000000000000000000000000000000000000000000000000000000000000123",
942
- // balance: {
943
- // value: BigInt(1000000000000000),
944
- // },
945
- // }).toBytes();
946
- // const walletAddress = InspectionsApiHelpers.constants.devInspectSigner;
947
- // const tx = new Transaction();
948
- // tx.setSender(walletAddress);
949
- // const accountCapId = this.createAccountTx({
950
- // ...inputs,
951
- // tx,
952
- // });
953
- // this.depositCollateralTx({
954
- // tx,
955
- // collateralCoinType,
956
- // accountCapId,
957
- // coinBytes: depositCoinBytes,
958
- // });
959
- // const { sessionPotatoId } = this.createTxAndStartSession({
960
- // tx,
961
- // accountCapId,
962
- // collateralCoinType,
963
- // marketId,
964
- // walletAddress,
965
- // basePriceFeedId,
966
- // collateralPriceFeedId,
967
- // collateralChange: collateral,
968
- // hasPosition: false,
969
- // });
970
- // this.placeLimitOrderTx({
971
- // tx,
972
- // side,
973
- // size,
974
- // collateralCoinType,
975
- // sessionPotatoId,
976
- // orderType: PerpetualsOrderType.Standard,
977
- // price:
978
- // price ??
979
- // (side === PerpetualsOrderSide.Bid
980
- // ? BigInt("0x7FFFFFFFFFFFFFFF") // 2^63 - 1
981
- // : BigInt(1)),
982
- // });
983
- // this.getHotPotatoFieldsTx({
984
- // tx,
985
- // collateralCoinType,
986
- // sessionPotatoId,
987
- // });
988
- // this.endSessionAndTransferAccount({
989
- // ...inputs,
990
- // tx,
991
- // sessionPotatoId,
992
- // walletAddress,
993
- // collateralChange: BigInt(0),
994
- // });
995
- // const { events } =
996
- // await this.Provider.Inspections().fetchAllBytesFromTx({
997
- // tx,
998
- // });
999
- // const filledTakerEvent = EventsApiHelpers.findCastEventOrUndefined({
1000
- // events,
1001
- // eventType: this.eventTypes.filledTakerOrder,
1002
- // castFunction: Casting.perpetuals.filledTakerOrderEventFromOnChain,
1003
- // });
1004
- // const sizeNum = lotSize * Math.abs(Number(size));
1005
- // if (!filledTakerEvent) {
1006
- // return {
1007
- // executionPrice: 0,
1008
- // sizeFilled: 0,
1009
- // sizePosted: sizeNum,
1010
- // fills: [],
1011
- // };
1012
- // }
1013
- // const filledOrderEvents =
1014
- // Aftermath.helpers.events.findCastEventsOrUndefined({
1015
- // events,
1016
- // eventType: this.eventTypes.filledTakerOrder,
1017
- // castFunction:
1018
- // Casting.perpetuals.filledTakerOrderEventFromOnChain,
1019
- // });
1020
- // const fills: PerpetualsFilledOrderData[] = filledOrderEvents.map(
1021
- // (event) => {
1022
- // const size = Math.abs(
1023
- // Casting.IFixed.numberFromIFixed(event.baseAssetDelta)
1024
- // );
1025
- // const sizeUsd = Math.abs(
1026
- // Casting.IFixed.numberFromIFixed(event.quoteAssetDelta)
1027
- // );
1028
- // const price = sizeUsd / size;
1029
- // return {
1030
- // size,
1031
- // price,
1032
- // };
1033
- // }
1034
- // );
1035
- // const executionPrice = Perpetuals.calcEntryPrice(filledTakerEvent);
1036
- // const sizeFilled = Math.abs(
1037
- // Casting.IFixed.numberFromIFixed(filledTakerEvent.baseAssetDelta)
1038
- // );
1039
- // const sizePosted = sizeNum - sizeFilled;
1040
- // return {
1041
- // executionPrice,
1042
- // sizeFilled,
1043
- // sizePosted,
1044
- // fills,
1045
- // };
1046
- // // const { fillReceipts, postReceipt } =
1047
- // // await this.fetchMarketOrderReceipts(inputs);
1048
- // // const sizePosted = postReceipt !== undefined ? postReceipt.size : 0;
1049
- // // if (fillReceipts.length <= 0)
1050
- // // return price !== undefined
1051
- // // ? // simulating limit order
1052
- // // {
1053
- // // executionPrice: Perpetuals.orderPriceToPrice({
1054
- // // orderPrice: price,
1055
- // // lotSize,
1056
- // // tickSize,
1057
- // // }),
1058
- // // sizeFilled: 0,
1059
- // // sizePosted: Number(sizePosted),
1060
- // // }
1061
- // // : // simulating market order
1062
- // // {
1063
- // // executionPrice: 0,
1064
- // // sizeFilled: 0,
1065
- // // sizePosted: 0,
1066
- // // };
1067
- // // const sizeFilled = Helpers.sumBigInt(
1068
- // // fillReceipts.map((receipt) => receipt.size)
1069
- // // );
1070
- // // const executionPrice = fillReceipts.reduce((acc, receipt) => {
1071
- // // const orderPrice = PerpetualsOrderUtils.price(
1072
- // // receipt.orderId,
1073
- // // inputs.side === PerpetualsOrderSide.Ask
1074
- // // ? PerpetualsOrderSide.Bid
1075
- // // : PerpetualsOrderSide.Ask
1076
- // // );
1077
- // // const orderPriceNum = Perpetuals.orderPriceToPrice({
1078
- // // orderPrice,
1079
- // // lotSize,
1080
- // // tickSize,
1081
- // // });
1082
- // // return (
1083
- // // acc +
1084
- // // orderPriceNum * (Number(receipt.size) / Number(sizeFilled))
1085
- // // );
1086
- // // }, 0);
1087
- // // return {
1088
- // // executionPrice,
1089
- // // sizeFilled: Number(sizeFilled),
1090
- // // sizePosted: Number(sizePosted),
1091
- // // };
1092
- // };
1093
- // private createTxAndStartSession = (inputs: {
1094
- // tx?: Transaction;
1095
- // collateralCoinType: CoinType;
1096
- // accountCapId: ObjectId | TransactionArgument;
1097
- // marketId: PerpetualsMarketId;
1098
- // marketInitialSharedVersion: ObjectVersion;
1099
- // basePriceFeedId: ObjectId;
1100
- // collateralPriceFeedId: ObjectId;
1101
- // walletAddress: SuiAddress;
1102
- // collateralChange: Balance;
1103
- // hasPosition: boolean;
1104
- // }) => {
1105
- // const { collateralChange, walletAddress, hasPosition } = inputs;
1106
- // const { tx: inputsTx, ...nonTxInputs } = inputs;
1107
- // const tx = inputsTx ?? new Transaction();
1108
- // tx.setSender(walletAddress);
1109
- // if (!hasPosition) {
1110
- // this.createMarketPositionTx({
1111
- // ...nonTxInputs,
1112
- // tx,
1113
- // });
1114
- // }
1115
- // if (collateralChange > BigInt(0)) {
1116
- // this.allocateCollateralTx({
1117
- // ...nonTxInputs,
1118
- // tx,
1119
- // amount: collateralChange,
1120
- // });
1121
- // }
1122
- // const sessionPotatoId = this.startSessionTx({
1123
- // ...nonTxInputs,
1124
- // tx,
1125
- // });
1126
- // return { tx, sessionPotatoId };
1127
- // };
1128
- // private endSessionAndShareMarket = (inputs: {
1129
- // tx: Transaction;
1130
- // collateralCoinType: CoinType;
1131
- // sessionPotatoId: ObjectId | TransactionArgument;
1132
- // }) => {
1133
- // const marketId = this.endSessionTx(inputs);
1134
- // this.shareClearingHouseTx({
1135
- // ...inputs,
1136
- // marketId,
1137
- // });
1138
- // };
1139
- // =========================================================================
1140
- // Public Static Helpers
1141
- // =========================================================================
1142
- // public static bucketOrders = (inputs: {
1143
- // orders: PerpetualsOrderInfo[];
1144
- // side: PerpetualsOrderSide;
1145
- // lotSize: number;
1146
- // tickSize: number;
1147
- // priceBucketSize: number;
1148
- // initialBucketedOrders?: OrderbookDataPoint[];
1149
- // }): OrderbookDataPoint[] => {
1150
- // const {
1151
- // orders,
1152
- // side,
1153
- // lotSize,
1154
- // tickSize,
1155
- // priceBucketSize,
1156
- // initialBucketedOrders,
1157
- // } = inputs;
1158
- // let dataPoints: OrderbookDataPoint[] = initialBucketedOrders ?? [];
1159
- // const roundPrice = (price: number, bucketSize: number): number => {
1160
- // return Math.round(price / bucketSize) * bucketSize;
1161
- // };
1162
- // const comparePrices = (
1163
- // price1: number,
1164
- // price2: number,
1165
- // bucketSize: number
1166
- // ): boolean => {
1167
- // return Math.abs(price1 - price2) < bucketSize;
1168
- // };
1169
- // orders.forEach((order) => {
1170
- // const actualPrice = Perpetuals.orderPriceToPrice({
1171
- // lotSize,
1172
- // tickSize: Math.abs(tickSize),
1173
- // orderPrice: order.price,
1174
- // });
1175
- // const roundedPrice = roundPrice(actualPrice, priceBucketSize);
1176
- // const size =
1177
- // lotSize *
1178
- // Math.abs(Number(order.size)) *
1179
- // (tickSize < 0 ? -1 : 1);
1180
- // const sizeUsd = size * actualPrice;
1181
- // const placementIndex = dataPoints.findIndex(
1182
- // (dataPoint: OrderbookDataPoint) =>
1183
- // comparePrices(
1184
- // roundedPrice,
1185
- // dataPoint.price,
1186
- // priceBucketSize
1187
- // )
1188
- // );
1189
- // if (placementIndex < 0) {
1190
- // if (size > 0) {
1191
- // const newDataPoint: OrderbookDataPoint = {
1192
- // size,
1193
- // sizeUsd,
1194
- // totalSize: size,
1195
- // totalSizeUsd: sizeUsd,
1196
- // price: roundedPrice,
1197
- // };
1198
- // const insertIndex = dataPoints.findIndex((dataPoint) =>
1199
- // side === PerpetualsOrderSide.Ask
1200
- // ? roundedPrice < dataPoint.price
1201
- // : roundedPrice > dataPoint.price
1202
- // );
1203
- // if (insertIndex < 0) {
1204
- // dataPoints.push(newDataPoint);
1205
- // } else {
1206
- // dataPoints.splice(insertIndex, 0, newDataPoint);
1207
- // }
1208
- // }
1209
- // } else {
1210
- // dataPoints[placementIndex].size += size;
1211
- // dataPoints[placementIndex].sizeUsd += sizeUsd;
1212
- // dataPoints[placementIndex].totalSize += size;
1213
- // dataPoints[placementIndex].totalSizeUsd += sizeUsd;
1214
- // }
1215
- // });
1216
- // dataPoints = dataPoints.filter((data) => data.size >= lotSize);
1217
- // for (let index = 0; index < dataPoints.length; index++) {
1218
- // if (index > 0) {
1219
- // dataPoints[index].totalSize =
1220
- // dataPoints[index - 1].totalSize + dataPoints[index].size;
1221
- // dataPoints[index].totalSizeUsd =
1222
- // dataPoints[index - 1].totalSizeUsd +
1223
- // dataPoints[index].sizeUsd;
1224
- // } else {
1225
- // dataPoints[index].totalSize = dataPoints[index].size;
1226
- // dataPoints[index].totalSizeUsd = dataPoints[index].sizeUsd;
1227
- // }
1228
- // }
1229
- // if (side === PerpetualsOrderSide.Ask) {
1230
- // dataPoints.reverse();
1231
- // }
1232
- // return dataPoints;
1233
- // };
1234
- // =========================================================================
1235
- // Event Types
1236
- // =========================================================================
1237
- this.eventType = (eventName) => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.events, PerpetualsApi.constants.moduleNames.events, eventName);
1238
- const addresses = this.Provider.addresses.perpetuals;
1239
- if (!addresses)
1240
- throw new Error("not all required addresses have been set in provider");
1241
- this.addresses = addresses;
1242
- this.eventTypes = {
1243
- // Collateral
1244
- withdrewCollateral: this.eventType("WithdrewCollateral"),
1245
- depositedCollateral: this.eventType("DepositedCollateral"),
1246
- settledFunding: this.eventType("SettledFunding"),
1247
- allocatedCollateral: this.eventType("AllocatedCollateral"),
1248
- deallocatedCollateral: this.eventType("DeallocatedCollateral"),
1249
- // Liquidation
1250
- liquidated: this.eventType("LiquidatedPosition"),
1251
- filledTakerOrderLiquidator: this.eventType("FilledTakerOrderLiquidator"),
1252
- performedLiquidation: this.eventType("PerformedLiquidation"),
1253
- // Account
1254
- createdAccount: this.eventType("CreatedAccount"),
1255
- // Order
1256
- canceledOrder: this.eventType("CanceledOrder"),
1257
- filledMakerOrders: this.eventType("FilledMakerOrders"),
1258
- filledMakerOrder: this.eventType("FilledMakerOrder"),
1259
- filledTakerOrder: this.eventType("FilledTakerOrder"),
1260
- reducedOrder: this.eventType("ReducedOrder"),
1261
- postedOrder: this.eventType("PostedOrder"),
1262
- // Twap
1263
- updatedPremiumTwap: this.eventType("UpdatedPremiumTwap"),
1264
- updatedSpreadTwap: this.eventType("UpdatedSpreadTwap"),
1265
- // Funding
1266
- updatedFunding: this.eventType("UpdatedFunding"),
1267
- // Version
1268
- updatedMarketVersion: this.eventType("UpdatedClearingHouseVersion"),
1269
- // Stop Order
1270
- createdStopOrderTicket: this.eventType("CreatedStopOrderTicket"),
1271
- deletedStopOrderTicket: this.eventType("DeletedStopOrderTicket"),
1272
- editedStopOrderTicketExecutor: this.eventType("EditedStopOrderTicketExecutor"),
1273
- addedStopOrderTicketCollateral: this.eventType("AddedStopOrderTicketCollateral"),
1274
- removedStopOrderTicketCollateral: this.eventType("RemovedStopOrderTicketCollateral"),
1275
- editedStopOrderTicketDetails: this.eventType("EditedStopOrderTicketDetails"),
1276
- executedStopOrderTicket: this.eventType("ExecutedStopOrderTicket"),
1277
- // ADL
1278
- performedAdl: this.eventType("PerformedADL"),
1279
- };
1280
- this.moveErrors = {
1281
- // TODO: add support for this back in some way ?
1282
- // [this.addresses.packages.perpetuals]: {
1283
- // ["ANY"]: {
1284
- // // ClearingHouse
1285
- // /// Cannot deposit/withdraw zero coins to/from the account's collateral.
1286
- // 0: "Deposit Or Withdraw Amount Zero",
1287
- // /// Orderbook size or price are invalid values
1288
- // 1: "Invalid Size Or Price",
1289
- // /// Index price returned from oracle is 0 or invalid value
1290
- // 2: "Bad Index Price",
1291
- // /// Order value in USD is too low
1292
- // 4: "Order Usd Value Too Low",
1293
- // /// Passed a vector of invalid order ids to perform force cancellation during liquidation
1294
- // 5: "Invalid Force Cancel Ids",
1295
- // /// Liquidate must be the first operation of the session, if performed.
1296
- // 6: "Liquidate Not First Operation",
1297
- // /// Passed a vector of invalid order ids to cancel
1298
- // 7: "Invalid Cancel Order Ids",
1299
- // /// Ticket has already passed `expire_timestamp` and can only be cancelled
1300
- // 8: "Stop Order Ticket Expired",
1301
- // /// Index price is not at correct value to satisfy stop order conditions
1302
- // 9: "Stop Order Conditions Violated",
1303
- // /// Index price is not at correct value to satisfy stop order conditions
1304
- // 10: "Wrong Order Details",
1305
- // /// Invalid base price feed storage for the clearing house
1306
- // 11: "Invalid Base Price Feed Storage",
1307
- // /// Same liquidator and liqee account ids
1308
- // 12: "Self Liquidation",
1309
- // /// User trying to access the subaccount is not the one specified by parent
1310
- // 13: "Invalid Sub Account User",
1311
- // /// The parent `Account` trying to delete the subaccount is not the correct one.
1312
- // 14: "Wrong Parent For Sub Account",
1313
- // /// Raised when trying to delete a subaccount still containing collateral.
1314
- // 15: "Sub Account Contains Collateral",
1315
- // /// Raised when trying to call a function with the wrong package's version
1316
- // 16: "Wrong Version",
1317
- // /// Raised when trying to have a session composed by only `start_session` and `end_session`
1318
- // 17: "Empty Session",
1319
- // /// Market already registered in the registry
1320
- // 18: "Market Already Registered",
1321
- // /// Collateral is not registered in the registry
1322
- // 19: "Collateral Is Not Registered",
1323
- // /// Market is not registered in the registry
1324
- // 20: "Market Is Not Registered",
1325
- // /// Invalid collateral price feed storage for the clearing house
1326
- // 21: "Invalid Collateral Price Feed Storage",
1327
- // /// Fees accrued are negative
1328
- // 22: "Negative Fees Accrued",
1329
- // /// Reduce-only conditions are not respected for stop order execution
1330
- // 23: "Not Reduce Only Stop Order",
1331
- // /// Stop order gas cost provided is not enough
1332
- // 24: "Not Enough Gas For Stop Order",
1333
- // /// Stop order collateral to allocate provided is not enough
1334
- // 25: "Not Enough Collateral To Allocate For Stop Order",
1335
- // /// Invalid account trying to perform an action on a StopOrderTicket
1336
- // 26: "Invalid Account For Stop Order",
1337
- // /// Invalid executor trying to execute the StopOrderTicket
1338
- // 27: "Invalid Executor For Stop Order",
1339
- // /// Raised when the market's max open interest is surpassed as a result of the session's actions
1340
- // 28: "Max Open Interest Surpassed",
1341
- // /// Raised when a position would get a base amount higher than the allowed percentage of open interest
1342
- // 29: "Max Open Interest Position Percent Surpassed",
1343
- // // Market
1344
- // /// While creating ordered map with invalid parameters, or changing them improperly for an existent map.
1345
- // 1000: "Invalid Market Parameters",
1346
- // /// Tried to call `update_funding` before enough time has passed since the last update.
1347
- // 1001: "Updating Funding Too Early",
1348
- // /// Margin-ratio update proposal already exists for market
1349
- // 1002: "Proposal Already Exists",
1350
- // /// Margin-ratio update proposal cannot be committed too early
1351
- // 1003: "Premature Proposal",
1352
- // /// Margin-ratio update proposal delay is outside the valid range
1353
- // 1004: "Invalid Proposal Delay",
1354
- // /// Margin-ratio update proposal does not exist for market
1355
- // 1005: "Proposal Does Not Exist",
1356
- // /// Exchange has no available fees to withdraw
1357
- // 1006: "No Fees Accrued",
1358
- // /// Tried to withdraw more insurance funds than the allowed amount
1359
- // 1007: "Insufficient Insurance Surplus",
1360
- // /// Cannot create a market for which a price feed does not exist
1361
- // 1008: "No Price Feed For Market",
1362
- // /// Cannot delete a proposal that already matured. It can only be committed.
1363
- // 1009: "Proposal Already Matured",
1364
- // // Position
1365
- // /// Tried placing a new pending order when the position already has the maximum allowed number of pending orders.
1366
- // 2000: "Max Pending Orders Exceeded",
1367
- // /// Used for checking both liqee and liqor positions during liquidation
1368
- // 2001: "Position Below IMR",
1369
- // ///When leaving liqee's position with a margin ratio above tolerance,
1370
- // /// meaning that liqor has overbought position
1371
- // 2002: "Position Above Tolerance",
1372
- // /// An operation brought an account below initial margin requirements.
1373
- // 2003: "Initial Margin Requirement Violated",
1374
- // /// Position is above MMR, so can't be liquidated.
1375
- // 2004: "Position Above MMR",
1376
- // /// Cannot realize bad debt via means other than calling 'liquidate'.
1377
- // 2005: "Position Bad Debt",
1378
- // /// Cannot withdraw more than the account's free collateral.
1379
- // 2006: "Insufficient Free Collateral",
1380
- // /// Cannot have more than 1 position in a market.
1381
- // 2007: "Position Already Exists",
1382
- // /// Cannot compute deallocate amount for a target MR < IMR.
1383
- // 2008: "Deallocate Target MR Too Low",
1384
- // // Orderbook & OrderedMap
1385
- // /// While creating ordered map with wrong parameters.
1386
- // 3000: "Invalid Map Parameters",
1387
- // /// While searching for a key, but it doesn't exist.
1388
- // 3001: "Key Not Exist",
1389
- // /// While inserting already existing key.
1390
- // 3002: "Key Already Exists",
1391
- // /// When attempting to destroy a non-empty map
1392
- // 3003: "Destroy Not Empty",
1393
- // /// Invalid user tries to modify an order
1394
- // 3004: "Invalid User For Order",
1395
- // /// Orderbook flag requirements violated
1396
- // 3005: "Flag Requirements Violated",
1397
- // /// Minimum size matched not reached
1398
- // 3006: "Not Enough Liquidity",
1399
- // /// When trying to change a map configuration, but the map has length less than 4
1400
- // 3007: "Map Too Small",
1401
- // /// When taker matches its own order
1402
- // 3008: "Self Trading",
1403
- // },
1404
- // },
1405
- };
1406
- }
1407
- }
1408
- exports.PerpetualsApi = PerpetualsApi;
1409
- // =========================================================================
1410
- // Class Members
1411
- // =========================================================================
1412
- PerpetualsApi.constants = {
1413
- moduleNames: {
1414
- interface: "interface",
1415
- orderbook: "orderbook",
1416
- events: "events",
1417
- clearingHouse: "clearing_house",
1418
- account: "account",
1419
- },
1420
- };