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,647 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Pool = void 0;
13
- const cmmmCalculations_1 = require("./utils/cmmmCalculations");
14
- const caller_1 = require("../../general/utils/caller");
15
- const _1 = require(".");
16
- const utils_1 = require("../../general/utils");
17
- /**
18
- * The `Pool` class encapsulates all the functionality needed to interact
19
- * with a specific AMM pool on the Aftermath platform. It allows you to
20
- * calculate trade amounts, deposit/withdraw amounts, fetch transactions,
21
- * and retrieve on-chain statistics and event data.
22
- *
23
- * @example
24
- * ```typescript
25
- * const afSdk = new Aftermath("MAINNET");
26
- * await afSdk.init(); // initialize provider
27
- *
28
- * const pools = afSdk.Pools();
29
- * const pool = await pools.getPool({ objectId: "0x..." });
30
- *
31
- * const stats = await pool.getStats();
32
- * const tradeTx = await pool.getTradeTransaction({
33
- * walletAddress: "0x...",
34
- * coinInType: "0x2::sui::SUI",
35
- * coinInAmount: BigInt(1e9),
36
- * coinOutType: "0x<yourCoin>",
37
- * slippage: 0.01,
38
- * });
39
- * ```
40
- */
41
- class Pool extends caller_1.Caller {
42
- /**
43
- * Creates a new instance of the `Pool` class for on-chain interaction.
44
- *
45
- * @param pool - The fetched `PoolObject` from Aftermath API or on-chain query.
46
- * @param config - Optional caller configuration (e.g., network, access token).
47
- * @param Provider - An optional `AftermathApi` instance for advanced transaction usage.
48
- */
49
- constructor(pool, config, Provider) {
50
- super(config, `pools/${pool.objectId}`);
51
- this.pool = pool;
52
- this.Provider = Provider;
53
- /**
54
- * Retrieves the 24-hour volume for this specific pool.
55
- *
56
- * @returns A promise resolving to a number (volume in 24h).
57
- *
58
- * @example
59
- * ```typescript
60
- * const vol24h = await pool.getVolume24hrs();
61
- * console.log("Pool 24h Volume:", vol24h);
62
- * ```
63
- */
64
- this.getVolume24hrs = () => __awaiter(this, void 0, void 0, function* () {
65
- return this.fetchApi("volume-24hrs");
66
- });
67
- // =========================================================================
68
- // Calculations
69
- // =========================================================================
70
- /**
71
- * Calculates the instantaneous spot price for swapping from `coinInType`
72
- * to `coinOutType` within this pool. Optionally includes fees in the price.
73
- *
74
- * @param inputs - Object specifying input coin, output coin, and a boolean for `withFees`.
75
- * @returns The numerical spot price (float).
76
- *
77
- * @example
78
- * ```typescript
79
- * const price = pool.getSpotPrice({
80
- * coinInType: "0x<coinA>",
81
- * coinOutType: "0x<coinB>",
82
- * withFees: true,
83
- * });
84
- * console.log("Spot Price:", price);
85
- * ```
86
- */
87
- this.getSpotPrice = (inputs) => {
88
- const spotPriceWithDecimals = cmmmCalculations_1.CmmmCalculations.calcSpotPriceWithFees(utils_1.Helpers.deepCopy(this.pool), inputs.coinInType, inputs.coinOutType, !inputs.withFees);
89
- // Adjust for decimals difference
90
- return ((spotPriceWithDecimals *
91
- Number(this.pool.coins[inputs.coinOutType].decimalsScalar)) /
92
- Number(this.pool.coins[inputs.coinInType].decimalsScalar));
93
- };
94
- // TODO: account for referral discount for all calculations
95
- /**
96
- * Calculates how much output coin you would receive when trading
97
- * a given input coin and amount in this pool, factoring in protocol
98
- * and optional DAO fees.
99
- *
100
- * @param inputs - Includes `coinInType`, `coinInAmount`, and `coinOutType`.
101
- * @returns A bigint representing how many output coins you'd get.
102
- * @throws Error if the trade amount is too large relative to the pool balance.
103
- *
104
- * @example
105
- * ```typescript
106
- * const amountOut = pool.getTradeAmountOut({
107
- * coinInType: "0x<coinA>",
108
- * coinInAmount: BigInt(1000000),
109
- * coinOutType: "0x<coinB>",
110
- * });
111
- * ```
112
- */
113
- this.getTradeAmountOut = (inputs) => {
114
- const pool = utils_1.Helpers.deepCopy(this.pool);
115
- const coinInPoolBalance = pool.coins[inputs.coinInType].balance;
116
- const coinOutPoolBalance = pool.coins[inputs.coinOutType].balance;
117
- const coinInAmountWithFees = this.getAmountWithDAOFee({
118
- amount: _1.Pools.getAmountWithProtocolFees({
119
- amount: inputs.coinInAmount,
120
- }),
121
- });
122
- if (Number(coinInAmountWithFees) / Number(coinInPoolBalance) >=
123
- _1.Pools.constants.bounds.maxTradePercentageOfPoolBalance -
124
- Pool.constants.percentageBoundsMarginOfError)
125
- throw new Error("coinInAmountWithFees / coinInPoolBalance >= maxTradePercentageOfPoolBalance");
126
- const coinOutAmount = cmmmCalculations_1.CmmmCalculations.calcOutGivenIn(pool, inputs.coinInType, inputs.coinOutType, coinInAmountWithFees);
127
- if (coinOutAmount <= 0)
128
- throw new Error("coinOutAmount <= 0");
129
- if (Number(coinOutAmount) / Number(coinOutPoolBalance) >=
130
- _1.Pools.constants.bounds.maxTradePercentageOfPoolBalance -
131
- Pool.constants.percentageBoundsMarginOfError)
132
- throw new Error("coinOutAmount / coinOutPoolBalance >= maxTradePercentageOfPoolBalance");
133
- return coinOutAmount;
134
- };
135
- /**
136
- * Calculates how much input coin is required to obtain a certain output coin amount
137
- * from this pool, factoring in fees.
138
- *
139
- * @param inputs - Includes `coinInType`, desired `coinOutAmount`, and `coinOutType`.
140
- * @returns A bigint representing the needed input amount.
141
- * @throws Error if the desired output is too large relative to pool balances.
142
- *
143
- * @example
144
- * ```typescript
145
- * const amountIn = pool.getTradeAmountIn({
146
- * coinInType: "0x<coinA>",
147
- * coinOutAmount: BigInt(1000000),
148
- * coinOutType: "0x<coinB>"
149
- * });
150
- * ```
151
- */
152
- this.getTradeAmountIn = (inputs) => {
153
- const pool = utils_1.Helpers.deepCopy(this.pool);
154
- const coinInPoolBalance = pool.coins[inputs.coinInType].balance;
155
- const coinOutPoolBalance = pool.coins[inputs.coinOutType].balance;
156
- if (Number(inputs.coinOutAmount) / Number(coinOutPoolBalance) >=
157
- _1.Pools.constants.bounds.maxTradePercentageOfPoolBalance -
158
- Pool.constants.percentageBoundsMarginOfError)
159
- throw new Error("coinOutAmount / coinOutPoolBalance >= maxTradePercentageOfPoolBalance");
160
- const coinInAmount = cmmmCalculations_1.CmmmCalculations.calcInGivenOut(pool, inputs.coinInType, inputs.coinOutType, inputs.coinOutAmount);
161
- if (coinInAmount <= 0)
162
- throw new Error("coinInAmount <= 0");
163
- if (Number(coinInAmount) / Number(coinInPoolBalance) >=
164
- _1.Pools.constants.bounds.maxTradePercentageOfPoolBalance -
165
- Pool.constants.percentageBoundsMarginOfError)
166
- throw new Error("coinInAmount / coinInPoolBalance >= maxTradePercentageOfPoolBalance");
167
- const coinInAmountWithoutFees = this.getAmountWithoutDAOFee({
168
- amount: _1.Pools.getAmountWithoutProtocolFees({
169
- amount: coinInAmount,
170
- }),
171
- });
172
- return coinInAmountWithoutFees;
173
- };
174
- /**
175
- * Calculates how many LP tokens you receive for providing liquidity
176
- * in specific coin amounts. Also returns a ratio for reference.
177
- *
178
- * @param inputs - Contains the amounts in for each coin in the pool.
179
- * @returns An object with `lpAmountOut` and `lpRatio`.
180
- *
181
- * @example
182
- * ```typescript
183
- * const depositCalc = pool.getDepositLpAmountOut({
184
- * amountsIn: { "0x<coinA>": BigInt(1000000), "0x<coinB>": BigInt(500000) },
185
- * });
186
- * console.log(depositCalc.lpAmountOut, depositCalc.lpRatio);
187
- * ```
188
- */
189
- this.getDepositLpAmountOut = (inputs) => {
190
- const calcedLpRatio = cmmmCalculations_1.CmmmCalculations.calcDepositFixedAmounts(this.pool, Object.entries(inputs.amountsIn).reduce((acc, [coin, amount]) => (Object.assign(Object.assign({}, acc), { [coin]: this.getAmountWithDAOFee({ amount }) })), {}));
191
- if (calcedLpRatio >= utils_1.Casting.Fixed.fixedOneB)
192
- throw new Error("lpRatio >= 1");
193
- const lpRatio = utils_1.Casting.bigIntToFixedNumber(calcedLpRatio);
194
- const lpAmountOut = BigInt(Math.floor(Number(this.pool.lpCoinSupply) * (1 / lpRatio - 1)));
195
- return {
196
- lpAmountOut,
197
- lpRatio,
198
- };
199
- };
200
- /**
201
- * Calculates how many coins a user will receive when withdrawing a specific ratio or LP amount.
202
- * This method is used in multi-coin withdrawals where you specify how much of each coin you want.
203
- *
204
- * @param inputs - The LP ratio and an object specifying direction amounts for each coin.
205
- * @returns A `CoinsToBalance` object with final amounts out, factoring in DAO fees.
206
- *
207
- * @example
208
- * ```typescript
209
- * const outAmounts = pool.getWithdrawAmountsOut({
210
- * lpRatio: 0.1,
211
- * amountsOutDirection: { "0x<coinA>": BigInt(500000) },
212
- * });
213
- * console.log(outAmounts);
214
- * ```
215
- */
216
- this.getWithdrawAmountsOut = (inputs) => {
217
- const amountsOut = cmmmCalculations_1.CmmmCalculations.calcWithdrawFlpAmountsOut(this.pool, inputs.amountsOutDirection, inputs.lpRatio);
218
- for (const coin of Object.keys(amountsOut)) {
219
- if (!(coin in inputs.amountsOutDirection) ||
220
- inputs.amountsOutDirection[coin] <= BigInt(0))
221
- continue;
222
- const amountOut = amountsOut[coin];
223
- if (amountOut <= 0) {
224
- throw new Error(`amountsOut[${coin}] <= 0`);
225
- }
226
- if (Number(amountOut) / Number(this.pool.coins[coin].balance) >=
227
- _1.Pools.constants.bounds.maxWithdrawPercentageOfPoolBalance) {
228
- throw new Error("coinOutAmount / coinOutPoolBalance >= maxWithdrawPercentageOfPoolBalance");
229
- }
230
- amountsOut[coin] = this.getAmountWithDAOFee({ amount: amountOut });
231
- }
232
- return amountsOut;
233
- };
234
- /**
235
- * A simplified multi-coin withdraw approach: calculates all outputs by proportion of the
236
- * user's LP share among selected coin types. Useful for approximate or "blind" all-coin out logic.
237
- *
238
- * @param inputs - Contains the `lpCoinAmountIn` to burn, and which coin types to receive.
239
- * @returns A record mapping coin type => final amounts out.
240
- */
241
- this.getWithdrawAmountsOutSimple = (inputs) => {
242
- const { lpCoinAmountIn, coinTypesOut, referral } = inputs;
243
- const lpCoinSupply = this.pool.lpCoinSupply;
244
- let withdrawAmountsEstimates = {};
245
- coinTypesOut.forEach((poolCoin) => {
246
- const poolCoinAmountInPool = this.pool.coins[utils_1.Helpers.addLeadingZeroesToType(poolCoin)]
247
- .balance;
248
- const poolCoinAmount = Number(poolCoinAmountInPool) *
249
- (Number(lpCoinAmountIn) / Number(lpCoinSupply));
250
- withdrawAmountsEstimates[utils_1.Helpers.addLeadingZeroesToType(poolCoin)] =
251
- BigInt(Math.floor(poolCoinAmount));
252
- });
253
- const lpRatio = this.getMultiCoinWithdrawLpRatio({
254
- lpCoinAmountIn,
255
- });
256
- const amountsOut = this.getWithdrawAmountsOut({
257
- lpRatio,
258
- amountsOutDirection: withdrawAmountsEstimates,
259
- referral,
260
- });
261
- for (const coin of Object.keys(amountsOut)) {
262
- if (!coinTypesOut
263
- .map((coinOut) => utils_1.Helpers.addLeadingZeroesToType(coinOut))
264
- .includes(coin))
265
- continue;
266
- const amountOut = amountsOut[coin];
267
- if (amountOut <= BigInt(0))
268
- throw new Error(`amountsOut[${coin}] <= 0 `);
269
- if (amountOut / this.pool.coins[coin].balance >=
270
- _1.Pools.constants.bounds.maxWithdrawPercentageOfPoolBalance)
271
- throw new Error("coinOutAmount / coinOutPoolBalance >= maxWithdrawPercentageOfPoolBalance");
272
- amountsOut[coin] = this.getAmountWithDAOFee({
273
- amount: amountOut,
274
- });
275
- }
276
- return amountsOut;
277
- };
278
- /**
279
- * Calculates how many coins you get when withdrawing **all** coin types from the pool,
280
- * given a ratio. This is typically used for proportionate withdrawal.
281
- *
282
- * @param inputs - Includes `lpRatio`, the portion of your LP to burn (0 < ratio < 1).
283
- * @returns A record of coin type => amounts out, after factoring in any fees.
284
- *
285
- * @example
286
- * ```typescript
287
- * const allOut = pool.getAllCoinWithdrawAmountsOut({ lpRatio: 0.1 });
288
- * console.log(allOut); // amounts for each coin
289
- * ```
290
- */
291
- this.getAllCoinWithdrawAmountsOut = (inputs) => {
292
- if (inputs.lpRatio >= 1)
293
- throw new Error("lpRatio >= 1");
294
- const amountsOut = Object.entries(this.pool.coins).reduce((acc, [coin, info]) => {
295
- return Object.assign(Object.assign({}, acc), { [coin]: this.getAmountWithDAOFee({
296
- amount: BigInt(Math.floor(Number(info.balance) * inputs.lpRatio)),
297
- }) });
298
- }, {});
299
- return amountsOut;
300
- };
301
- /**
302
- * For multi-coin withdraw, calculates the ratio of how much LP you are burning
303
- * relative to the total supply. e.g. if user burns 100 of 1000 supply => ratio 0.1.
304
- *
305
- * @param inputs - Contains the `lpCoinAmountIn` to burn.
306
- * @returns A float ratio (0 < ratio < 1).
307
- */
308
- this.getMultiCoinWithdrawLpRatio = (inputs) => Number(this.pool.lpCoinSupply - inputs.lpCoinAmountIn) /
309
- Number(this.pool.lpCoinSupply);
310
- /**
311
- * For an all-coin withdraw, calculates the ratio of how much LP is burned
312
- * relative to total supply. e.g. if user burns 50 of 200 supply => ratio 0.25.
313
- *
314
- * @param inputs - Contains the `lpCoinAmountIn`.
315
- * @returns A float ratio, typically 0 < ratio < 1.
316
- */
317
- this.getAllCoinWithdrawLpRatio = (inputs) => Number(inputs.lpCoinAmountIn) / Number(this.pool.lpCoinSupply);
318
- // =========================================================================
319
- // Getters
320
- // =========================================================================
321
- /**
322
- * Returns an array of coin types in ascending lexicographic order
323
- * for the coins contained in this pool.
324
- *
325
- * @returns An array of coin type strings.
326
- */
327
- this.coins = () => {
328
- return Object.keys(this.pool.coins).sort((a, b) => a.localeCompare(b));
329
- };
330
- /**
331
- * Returns an array of `PoolCoin` objects, one for each coin in this pool,
332
- * sorted lexicographically by coin type.
333
- *
334
- * @returns An array of `PoolCoin`.
335
- */
336
- this.poolCoins = () => {
337
- return Object.entries(this.pool.coins)
338
- .sort((a, b) => a[0].localeCompare(b[0]))
339
- .map((data) => data[1]);
340
- };
341
- /**
342
- * Returns an array of `[CoinType, PoolCoin]` pairs, sorted by coin type.
343
- *
344
- * @returns An array of coin-type => `PoolCoin` pairs.
345
- */
346
- this.poolCoinEntries = () => {
347
- return Object.entries(this.pool.coins).sort((a, b) => a[0].localeCompare(b[0]));
348
- };
349
- /**
350
- * Returns the current DAO fee percentage, if configured (0 < fee <= 100%).
351
- *
352
- * @returns A decimal fraction representing the fee (e.g., 0.01 = 1%) or `undefined`.
353
- */
354
- this.daoFeePercentage = () => {
355
- return this.pool.daoFeePoolObject
356
- ? utils_1.Casting.bpsToPercentage(this.pool.daoFeePoolObject.feeBps)
357
- : undefined;
358
- };
359
- /**
360
- * Returns the Sui address that currently receives the DAO fee portion of
361
- * pool trades, or `undefined` if no DAO fee is configured.
362
- *
363
- * @returns The DAO fee recipient address.
364
- */
365
- this.daoFeeRecipient = () => {
366
- var _a;
367
- return (_a = this.pool.daoFeePoolObject) === null || _a === void 0 ? void 0 : _a.feeRecipient;
368
- };
369
- // =========================================================================
370
- // Private Helpers
371
- // =========================================================================
372
- /**
373
- * Applies the DAO fee (if present) to a given `amount`, effectively reducing
374
- * that amount by the fee fraction. e.g. if fee is 2%, it returns 98% of the input.
375
- *
376
- * @param inputs - Contains `amount` as a bigint.
377
- * @returns The post-fee amount as a bigint.
378
- */
379
- this.getAmountWithDAOFee = (inputs) => {
380
- const daoFeePercentage = this.daoFeePercentage();
381
- if (!daoFeePercentage)
382
- return inputs.amount;
383
- return BigInt(Math.floor(Number(inputs.amount) * (1 - daoFeePercentage)));
384
- };
385
- /**
386
- * The inverse operation of `getAmountWithDAOFee`, used in internal calculations
387
- * when we need to back out how much input was needed prior to the fee cut.
388
- *
389
- * @param inputs - Contains `amount` as a bigint.
390
- * @returns The pre-fee amount as a bigint.
391
- */
392
- this.getAmountWithoutDAOFee = (inputs) => {
393
- const daoFeePercentage = this.daoFeePercentage();
394
- if (!daoFeePercentage)
395
- return inputs.amount;
396
- return BigInt(Math.floor(Number(inputs.amount) * (1 / (1 - daoFeePercentage))));
397
- };
398
- /**
399
- * Provides an instance of the Pools provider from `AftermathApi`.
400
- * Throws an error if not defined.
401
- */
402
- this.useProvider = () => {
403
- var _a;
404
- const provider = (_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Pools();
405
- if (!provider)
406
- throw new Error("missing AftermathApi Provider");
407
- return provider;
408
- };
409
- this.pool = pool;
410
- }
411
- // =========================================================================
412
- // Transactions
413
- // =========================================================================
414
- /**
415
- * Builds or fetches a deposit transaction to add liquidity to this pool.
416
- * The resulting `Transaction` can be signed and submitted by the user.
417
- *
418
- * @param inputs - The deposit parameters including coin amounts, slippage, etc.
419
- * @returns A `Transaction` to deposit funds into the pool.
420
- *
421
- * @example
422
- * ```typescript
423
- * const depositTx = await pool.getDepositTransaction({
424
- * walletAddress: "0x...",
425
- * amountsIn: { "0x<coin>": BigInt(1000000) },
426
- * slippage: 0.01,
427
- * });
428
- * ```
429
- */
430
- getDepositTransaction(inputs) {
431
- return __awaiter(this, void 0, void 0, function* () {
432
- return this.useProvider().fetchBuildDepositTx(Object.assign(Object.assign({}, inputs), { pool: this }));
433
- });
434
- }
435
- /**
436
- * Builds or fetches a withdrawal transaction to remove liquidity from this pool.
437
- *
438
- * @param inputs - The parameters specifying how much LP is burned, desired coins out, slippage, etc.
439
- * @returns A `Transaction` to withdraw funds from the pool.
440
- *
441
- * @example
442
- * ```typescript
443
- * const withdrawTx = await pool.getWithdrawTransaction({
444
- * walletAddress: "0x...",
445
- * amountsOutDirection: {
446
- * "0x<coin>": BigInt(500000),
447
- * },
448
- * lpCoinAmount: BigInt(1000000),
449
- * slippage: 0.01,
450
- * });
451
- * ```
452
- */
453
- getWithdrawTransaction(inputs) {
454
- return __awaiter(this, void 0, void 0, function* () {
455
- return this.useProvider().fetchBuildWithdrawTx(Object.assign(Object.assign({}, inputs), { pool: this }));
456
- });
457
- }
458
- /**
459
- * Builds or fetches a transaction to withdraw all coin types from this pool,
460
- * effectively "burning" an LP position in exchange for multiple coin outputs.
461
- *
462
- * @param inputs - The parameters specifying how much LP to burn.
463
- * @returns A `Transaction` to withdraw all coins from the pool in proportion.
464
- *
465
- * @example
466
- * ```typescript
467
- * const allCoinWithdrawTx = await pool.getAllCoinWithdrawTransaction({
468
- * walletAddress: "0x...",
469
- * lpCoinAmount: BigInt(500000),
470
- * });
471
- * ```
472
- */
473
- getAllCoinWithdrawTransaction(inputs) {
474
- return __awaiter(this, void 0, void 0, function* () {
475
- return this.useProvider().fetchBuildAllCoinWithdrawTx(Object.assign(Object.assign({}, inputs), { pool: this }));
476
- });
477
- }
478
- /**
479
- * Builds or fetches a trade transaction to swap between two coin types in this pool.
480
- *
481
- * @param inputs - The trade parameters including coin in/out, amounts, slippage, etc.
482
- * @returns A `Transaction` that can be signed and executed for the swap.
483
- *
484
- * @example
485
- * ```typescript
486
- * const tradeTx = await pool.getTradeTransaction({
487
- * walletAddress: "0x...",
488
- * coinInType: "0x<coinA>",
489
- * coinInAmount: BigInt(1000000),
490
- * coinOutType: "0x<coinB>",
491
- * slippage: 0.005,
492
- * });
493
- * ```
494
- */
495
- getTradeTransaction(inputs) {
496
- return __awaiter(this, void 0, void 0, function* () {
497
- return this.useProvider().fetchBuildTradeTx(Object.assign(Object.assign({}, inputs), { pool: this }));
498
- });
499
- }
500
- /**
501
- * Builds a transaction to update the DAO fee percentage for this pool,
502
- * if it has a DAO fee configured. The user must own the appropriate
503
- * `daoFeePoolOwnerCap`.
504
- *
505
- * @param inputs - Includes user wallet, `daoFeePoolOwnerCapId`, and the new fee percentage.
506
- * @returns A `Transaction` that can be signed to update the DAO fee on chain.
507
- * @throws If this pool has no DAO fee configuration.
508
- *
509
- * @example
510
- * ```typescript
511
- * const tx = await pool.getUpdateDaoFeeTransaction({
512
- * walletAddress: "0x...",
513
- * daoFeePoolOwnerCapId: "0x<capId>",
514
- * newFeePercentage: 0.01, // 1%
515
- * });
516
- * ```
517
- */
518
- getUpdateDaoFeeTransaction(inputs) {
519
- return __awaiter(this, void 0, void 0, function* () {
520
- var _a;
521
- const daoFeePoolId = (_a = this.pool.daoFeePoolObject) === null || _a === void 0 ? void 0 : _a.objectId;
522
- if (!daoFeePoolId)
523
- throw new Error("this pool has no DAO fee");
524
- return this.useProvider().buildDaoFeePoolUpdateFeeBpsTx(Object.assign(Object.assign({}, inputs), { daoFeePoolId, lpCoinType: this.pool.lpCoinType, newFeeBps: utils_1.Casting.percentageToBps(inputs.newFeePercentage) }));
525
- });
526
- }
527
- /**
528
- * Builds a transaction to update the DAO fee recipient for this pool,
529
- * if it has a DAO fee configured. The user must own the appropriate
530
- * `daoFeePoolOwnerCap`.
531
- *
532
- * @param inputs - Includes user wallet, `daoFeePoolOwnerCapId`, and the new fee recipient.
533
- * @returns A `Transaction` that can be signed to update the DAO fee recipient on chain.
534
- * @throws If this pool has no DAO fee configuration.
535
- *
536
- * @example
537
- * ```typescript
538
- * const tx = await pool.getUpdateDaoFeeRecipientTransaction({
539
- * walletAddress: "0x...",
540
- * daoFeePoolOwnerCapId: "0x<capId>",
541
- * newFeeRecipient: "0x<recipient>",
542
- * });
543
- * ```
544
- */
545
- getUpdateDaoFeeRecipientTransaction(inputs) {
546
- return __awaiter(this, void 0, void 0, function* () {
547
- var _a;
548
- const daoFeePoolId = (_a = this.pool.daoFeePoolObject) === null || _a === void 0 ? void 0 : _a.objectId;
549
- if (!daoFeePoolId)
550
- throw new Error("this pool has no DAO fee");
551
- return this.useProvider().buildDaoFeePoolUpdateFeeRecipientTx(Object.assign(Object.assign({}, inputs), { daoFeePoolId, lpCoinType: this.pool.lpCoinType, newFeeRecipient: utils_1.Helpers.addLeadingZeroesToType(inputs.newFeeRecipient) }));
552
- });
553
- }
554
- // =========================================================================
555
- // Inspections
556
- // =========================================================================
557
- /**
558
- * Fetches comprehensive pool statistics (volume, TVL, fees, APR, etc.) from the Aftermath API.
559
- * Also caches the result in `this.stats`.
560
- *
561
- * @returns A promise resolving to `PoolStats` object.
562
- *
563
- * @example
564
- * ```typescript
565
- * const stats = await pool.getStats();
566
- * console.log(stats.volume, stats.fees, stats.apr);
567
- * ```
568
- */
569
- getStats() {
570
- return __awaiter(this, void 0, void 0, function* () {
571
- const stats = yield this.fetchApi("stats");
572
- this.setStats(stats);
573
- return stats;
574
- });
575
- }
576
- /**
577
- * Caches the provided stats object into `this.stats`.
578
- *
579
- * @param stats - The `PoolStats` object to store.
580
- */
581
- setStats(stats) {
582
- this.stats = stats;
583
- }
584
- /**
585
- * Fetches an array of volume data points for a specified timeframe.
586
- * This is often used for charting or historical references.
587
- *
588
- * @param inputs - Contains a `timeframe` key, such as `"1D"` or `"1W"`.
589
- * @returns A promise resolving to an array of `PoolDataPoint`.
590
- *
591
- * @example
592
- * ```typescript
593
- * const volumeData = await pool.getVolumeData({ timeframe: "1D" });
594
- * console.log(volumeData); // e.g. [{ time: 1686000000, value: 123.45 }, ...]
595
- * ```
596
- */
597
- getVolumeData(inputs) {
598
- return __awaiter(this, void 0, void 0, function* () {
599
- return this.fetchApi(`volume/${inputs.timeframe}`);
600
- });
601
- }
602
- /**
603
- * Fetches an array of fee data points for a specified timeframe.
604
- *
605
- * @param inputs - Contains a `timeframe` key, e.g., `"1D"` or `"1W"`.
606
- * @returns A promise resolving to an array of `PoolDataPoint`.
607
- *
608
- * @example
609
- * ```typescript
610
- * const feeData = await pool.getFeeData({ timeframe: "1D" });
611
- * console.log(feeData);
612
- * ```
613
- */
614
- getFeeData(inputs) {
615
- return __awaiter(this, void 0, void 0, function* () {
616
- return this.fetchApi(`fees/${inputs.timeframe}`);
617
- });
618
- }
619
- // =========================================================================
620
- // Events
621
- // =========================================================================
622
- /**
623
- * Fetches user interaction events (deposit/withdraw) with this pool, optionally paginated.
624
- *
625
- * @param inputs - Includes user `walletAddress` and optional pagination fields.
626
- * @returns A promise that resolves to `PoolDepositEvent | PoolWithdrawEvent` objects with a cursor if more exist.
627
- *
628
- * @example
629
- * ```typescript
630
- * const events = await pool.getInteractionEvents({ walletAddress: "0x...", limit: 10 });
631
- * console.log(events.events, events.nextCursor);
632
- * ```
633
- */
634
- getInteractionEvents(inputs) {
635
- return __awaiter(this, void 0, void 0, function* () {
636
- return this.fetchApiIndexerEvents("interaction-events-by-user", inputs);
637
- });
638
- }
639
- }
640
- exports.Pool = Pool;
641
- /**
642
- * Internal margin of error used in trade calculations to prevent
643
- * exceeding maximum allowed percentages of pool balances.
644
- */
645
- Pool.constants = {
646
- percentageBoundsMarginOfError: 0.001, // 0.1%
647
- };