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,488 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.FarmsStakingPool = void 0;
16
- const caller_1 = require("../../general/utils/caller");
17
- const utils_1 = require("../../general/utils");
18
- const dayjs_1 = __importDefault(require("dayjs"));
19
- const duration_1 = __importDefault(require("dayjs/plugin/duration"));
20
- const fixedUtils_1 = require("../../general/utils/fixedUtils");
21
- const coin_1 = require("../coin/coin");
22
- const farms_1 = require("./farms");
23
- /**
24
- * The `FarmsStakingPool` class represents a staking pool (also referred
25
- * to as a "vault" in some contexts). It allows reading details about
26
- * emission schedules, reward tokens, stake coin type, and lock durations,
27
- * as well as constructing transactions to stake, harvest, and mutate the
28
- * pool parameters if the user has the correct admin privileges.
29
- */
30
- class FarmsStakingPool extends caller_1.Caller {
31
- /**
32
- * Creates a `FarmsStakingPool` instance based on on-chain pool data.
33
- *
34
- * @param stakingPool - The on-chain data object describing the pool.
35
- * @param config - An optional `CallerConfig` for network settings.
36
- * @param Provider - An optional `AftermathApi` for transaction building.
37
- */
38
- constructor(stakingPool, config, Provider) {
39
- super(config, "farms");
40
- this.stakingPool = stakingPool;
41
- this.Provider = Provider;
42
- // =========================================================================
43
- // Getters
44
- // =========================================================================
45
- /**
46
- * Retrieves the version of this staking pool (1 or 2).
47
- */
48
- this.version = () => {
49
- return this.stakingPool.version;
50
- };
51
- /**
52
- * Returns whether this pool uses strict lock enforcement.
53
- * Strict: positions must be unlocked before any principal can be withdrawn.
54
- */
55
- this.isStrictLockEnforcement = () => {
56
- return this.stakingPool.lockEnforcement === "Strict";
57
- };
58
- /**
59
- * Returns whether this pool uses relaxed lock enforcement.
60
- * Relaxed: positions can withdraw principal while locked, forfeiting pro-rata locked rewards.
61
- */
62
- this.isRelaxedLockEnforcement = () => {
63
- return this.stakingPool.lockEnforcement === "Relaxed";
64
- };
65
- /**
66
- * Lists all reward coin types offered by this staking pool.
67
- *
68
- * @returns An array of `CoinType` strings.
69
- */
70
- this.rewardCoinTypes = () => {
71
- return this.stakingPool.rewardCoins.map((coin) => coin.coinType);
72
- };
73
- /**
74
- * Lists all reward coin types for which this pool currently has a non-zero actual reward balance.
75
- *
76
- * @returns An array of `CoinType` strings that have > 0 actual rewards.
77
- */
78
- this.nonZeroRewardCoinTypes = () => {
79
- return this.stakingPool.rewardCoins
80
- .filter((coin) => coin.emissionRate <= coin.actualRewards &&
81
- coin.actualRewards > BigInt(0))
82
- .map((coin) => coin.coinType);
83
- };
84
- /**
85
- * Retrieves the on-chain record for a specific reward coin type in this pool.
86
- *
87
- * @param inputs - Contains the `coinType` to look up.
88
- * @throws If the specified coinType is not found in `rewardCoins`.
89
- * @returns A `FarmsStakingPoolRewardCoin` object.
90
- */
91
- this.rewardCoin = (inputs) => {
92
- const foundCoin = this.stakingPool.rewardCoins.find((coin) => coin.coinType === inputs.coinType);
93
- if (!foundCoin)
94
- throw new Error("Invalid coin type");
95
- return foundCoin;
96
- };
97
- /**
98
- * Computes the maximum lock duration (in ms) that remains valid in this staking pool,
99
- * factoring in the current time and the pool's emission end.
100
- *
101
- * @returns The maximum possible lock duration in milliseconds, or 0 if the pool is effectively closed.
102
- */
103
- this.maxLockDurationMs = () => {
104
- return Math.max(Math.min(this.stakingPool.maxLockDurationMs, this.stakingPool.emissionEndTimestamp - (0, dayjs_1.default)().valueOf()), 0);
105
- };
106
- // =========================================================================
107
- // Calculations
108
- // =========================================================================
109
- /**
110
- * Calculates and applies newly emitted rewards for each reward coin in this pool,
111
- * updating the `rewardsAccumulatedPerShare`. This simulates the on-chain
112
- * `emitRewards` logic.
113
- *
114
- * @example
115
- * ```typescript
116
- * someFarmsPool.emitRewards();
117
- * // The pool's rewardsAccumulatedPerShare fields are now updated.
118
- * ```
119
- */
120
- this.emitRewards = () => {
121
- const currentTimestamp = (0, dayjs_1.default)().valueOf();
122
- // If no staked amount, no distribution
123
- if (this.stakingPool.stakedAmount === BigInt(0))
124
- return;
125
- const rewardCoins = utils_1.Helpers.deepCopy(this.stakingPool.rewardCoins);
126
- for (const [rewardCoinIndex, rewardCoin] of rewardCoins.entries()) {
127
- // ib. Check that enough time has passed since the last emission.
128
- if (currentTimestamp <
129
- rewardCoin.lastRewardTimestamp + rewardCoin.emissionSchedulesMs)
130
- continue;
131
- // iia. Calculate how many rewards have to be emitted.
132
- const rewardsToEmit = this.calcRewardsToEmit({ rewardCoin });
133
- if (rewardsToEmit === BigInt(0))
134
- continue;
135
- // iii. Increase the amount of rewards emitted per share.
136
- this.increaseRewardsAccumulatedPerShare({
137
- rewardsToEmit,
138
- rewardCoinIndex,
139
- });
140
- const numberOfEmissions = (currentTimestamp - rewardCoin.lastRewardTimestamp) /
141
- rewardCoin.emissionSchedulesMs;
142
- // IMPORTANT: only increase by multiples of `emission_schedule_ms`.
143
- //
144
- // iv. Update reward's `last_reward_timestamp`.
145
- this.stakingPool.rewardCoins[rewardCoinIndex].lastRewardTimestamp =
146
- rewardCoin.lastRewardTimestamp +
147
- numberOfEmissions * rewardCoin.emissionSchedulesMs;
148
- }
149
- };
150
- /**
151
- * Computes an approximate APR for a specific reward coin, based on the current
152
- * emission rate, coin price, pool TVL, and the lock multiplier range. This assumes
153
- * maximum lock multiplier for the final APR result.
154
- *
155
- * @param inputs - Includes the `coinType`, its `price` and `decimals`, plus the total `tvlUsd` in the pool.
156
- * @returns A numeric APR (0.05 = 5%).
157
- */
158
- this.calcApr = (inputs) => {
159
- const { coinType, price, decimals, tvlUsd } = inputs;
160
- if (price <= 0 || tvlUsd <= 0)
161
- return 0;
162
- const rewardCoin = this.rewardCoin({ coinType });
163
- const currentTimestamp = (0, dayjs_1.default)().valueOf();
164
- // If the current emission rate is below the actual supply, or if the pool hasn't started or is ended, yield 0
165
- if (rewardCoin.emissionRate > rewardCoin.actualRewards)
166
- return 0;
167
- if (rewardCoin.emissionStartTimestamp > currentTimestamp ||
168
- currentTimestamp > this.stakingPool.emissionEndTimestamp) {
169
- return 0;
170
- }
171
- const emissionRateTokens = rewardCoin.emissionRate;
172
- const emissionRateUsd = coin_1.Coin.balanceWithDecimals(emissionRateTokens, decimals) * price;
173
- dayjs_1.default.extend(duration_1.default);
174
- const oneYearMs = dayjs_1.default.duration(1, "year").asMilliseconds();
175
- const rewardsUsdOneYear = emissionRateUsd * (oneYearMs / rewardCoin.emissionSchedulesMs);
176
- // The final APR is normalized by total staked value and the maximum lock multiplier
177
- const apr = rewardsUsdOneYear /
178
- tvlUsd /
179
- utils_1.Casting.bigIntToFixedNumber(this.stakingPool.maxLockMultiplier);
180
- return apr < 0 ? 0 : isNaN(apr) ? 0 : apr;
181
- };
182
- /**
183
- * Computes the total APR contributed by all reward coin types in this pool, summing
184
- * up the individual APR for each coin type. This also assumes max lock multiplier.
185
- *
186
- * @param inputs - Contains price data (`coinsToPrice`), decimal data (`coinsToDecimals`), and the total TVL in USD.
187
- * @returns The sum of all coin APRs (0.10 = 10%).
188
- */
189
- this.calcTotalApr = (inputs) => {
190
- const { coinsToPrice, coinsToDecimals, tvlUsd } = inputs;
191
- const aprs = this.rewardCoinTypes().map((coinType) => this.calcApr({
192
- coinType,
193
- price: coinsToPrice[coinType],
194
- decimals: coinsToDecimals[coinType],
195
- tvlUsd,
196
- }));
197
- return utils_1.Helpers.sum(aprs);
198
- };
199
- /**
200
- * Given a lock duration in ms, calculates the lock multiplier to be used by staked positions.
201
- * This function clamps the input duration between the pool's `minLockDurationMs` and
202
- * `maxLockDurationMs`.
203
- *
204
- * @param inputs - An object containing the `lockDurationMs` for which to calculate a multiplier.
205
- * @returns A `FarmsMultiplier` (bigint) representing the scaled factor (1.0 = 1e9 if using fixedOneB).
206
- */
207
- this.calcMultiplier = (inputs) => {
208
- const lockDurationMs = inputs.lockDurationMs > this.stakingPool.maxLockDurationMs
209
- ? this.stakingPool.maxLockDurationMs
210
- : inputs.lockDurationMs < this.stakingPool.minLockDurationMs
211
- ? this.stakingPool.minLockDurationMs
212
- : inputs.lockDurationMs;
213
- const totalPossibleLockDurationMs = this.stakingPool.maxLockDurationMs -
214
- this.stakingPool.minLockDurationMs;
215
- const newMultiplier = 1 +
216
- ((lockDurationMs - this.stakingPool.minLockDurationMs) /
217
- (totalPossibleLockDurationMs <= 0
218
- ? 1
219
- : totalPossibleLockDurationMs)) *
220
- (utils_1.Casting.bigIntToFixedNumber(this.stakingPool.maxLockMultiplier) -
221
- 1);
222
- const multiplier = utils_1.Casting.numberToFixedBigInt(newMultiplier);
223
- return multiplier < fixedUtils_1.FixedUtils.fixedOneB
224
- ? fixedUtils_1.FixedUtils.fixedOneB
225
- : utils_1.Helpers.minBigInt(multiplier, this.stakingPool.maxLockMultiplier);
226
- };
227
- // =========================================================================
228
- // Helpers
229
- // =========================================================================
230
- /**
231
- * Provides access to the farm-specific provider methods for building transactions.
232
- */
233
- this.useProvider = () => {
234
- var _a;
235
- const provider = (_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Farms();
236
- if (!provider)
237
- throw new Error("missing AftermathApi Provider");
238
- return provider;
239
- };
240
- this.stakingPool = stakingPool;
241
- }
242
- // =========================================================================
243
- // Public
244
- // =========================================================================
245
- // =========================================================================
246
- // Stats
247
- // =========================================================================
248
- /**
249
- * Fetches the total value locked (TVL) for this staking pool alone.
250
- *
251
- * @returns A `number` representing this pool's TVL in USD (or another currency).
252
- *
253
- * @example
254
- * ```typescript
255
- * const poolTvl = await someFarmsPool.getTVL();
256
- * console.log(poolTvl);
257
- * ```
258
- */
259
- getTVL() {
260
- return __awaiter(this, void 0, void 0, function* () {
261
- return new farms_1.Farms(this.config, this.Provider).getTVL({
262
- farmIds: [this.stakingPool.objectId],
263
- });
264
- });
265
- }
266
- /**
267
- * Fetches the total value locked (TVL) of the reward coins in this specific staking pool.
268
- *
269
- * @returns A `number` representing this pool's reward TVL.
270
- *
271
- * @example
272
- * ```typescript
273
- * const rewardTvl = await someFarmsPool.getRewardsTVL();
274
- * console.log(rewardTvl);
275
- * ```
276
- */
277
- getRewardsTVL() {
278
- return __awaiter(this, void 0, void 0, function* () {
279
- return new farms_1.Farms(this.config, this.Provider).getRewardsTVL({
280
- farmIds: [this.stakingPool.objectId],
281
- });
282
- });
283
- }
284
- // =========================================================================
285
- // Transactions
286
- // =========================================================================
287
- // =========================================================================
288
- // Staking Transactions
289
- // =========================================================================
290
- /**
291
- * Builds a transaction to stake tokens into this pool, optionally locking them.
292
- *
293
- * @param inputs - Contains `stakeAmount`, `lockDurationMs`, `walletAddress`, and optional sponsorship.
294
- * @returns A transaction object (or bytes) that can be signed and executed to create a staked position.
295
- */
296
- getStakeTransaction(inputs) {
297
- return __awaiter(this, void 0, void 0, function* () {
298
- const args = Object.assign(Object.assign({}, inputs), { stakeCoinType: this.stakingPool.stakeCoinType, stakingPoolId: this.stakingPool.objectId });
299
- return this.version() === 1
300
- ? this.useProvider().fetchBuildStakeTxV1(args)
301
- : this.useProvider().fetchBuildStakeTxV2(Object.assign({}, args));
302
- });
303
- }
304
- // =========================================================================
305
- // Reward Harvesting Transactions
306
- // =========================================================================
307
- /**
308
- * Builds a transaction to harvest rewards from multiple staked positions in this pool.
309
- *
310
- * @param inputs - Contains `stakedPositionIds`, the `walletAddress`, and optionally any others.
311
- * @returns A transaction that can be signed and executed to claim rewards from multiple positions.
312
- */
313
- getHarvestRewardsTransaction(inputs) {
314
- return __awaiter(this, void 0, void 0, function* () {
315
- const args = Object.assign(Object.assign({}, inputs), { stakeCoinType: this.stakingPool.stakeCoinType, stakingPoolId: this.stakingPool.objectId, rewardCoinTypes: this.nonZeroRewardCoinTypes() });
316
- return this.version() === 1
317
- ? this.useProvider().buildHarvestRewardsTxV1(args)
318
- : this.useProvider().buildHarvestRewardsTxV2(args);
319
- });
320
- }
321
- // =========================================================================
322
- // Mutation/Creation Transactions (Owner Only)
323
- // =========================================================================
324
- /**
325
- * Builds a transaction to increase the emission rate (or schedule) for specific reward coins.
326
- *
327
- * @param inputs - Contains the `ownerCapId` that authorizes changes, plus an array of `rewards` with new emission details.
328
- * @returns A transaction to be signed and executed by the owner cap holder.
329
- */
330
- getIncreaseRewardsEmissionsTransaction(inputs) {
331
- return __awaiter(this, void 0, void 0, function* () {
332
- const args = Object.assign(Object.assign({}, inputs), { stakeCoinType: this.stakingPool.stakeCoinType, stakingPoolId: this.stakingPool.objectId });
333
- return this.version() === 1
334
- ? this.useProvider().buildIncreaseStakingPoolRewardsEmissionsTxV1(args)
335
- : this.useProvider().buildIncreaseStakingPoolRewardsEmissionsTxV2(args);
336
- });
337
- }
338
- /**
339
- * Builds a transaction to update the pool's minimum stake amount, only authorized by the `ownerCapId`.
340
- *
341
- * @param inputs - Contains the new `minStakeAmount`, the `ownerCapId`, and the calling `walletAddress`.
342
- * @returns A transaction that can be signed and executed to change the minimum stake requirement.
343
- */
344
- getUpdateMinStakeAmountTransaction(inputs) {
345
- return __awaiter(this, void 0, void 0, function* () {
346
- const args = Object.assign(Object.assign({}, inputs), { stakeCoinType: this.stakingPool.stakeCoinType, stakingPoolId: this.stakingPool.objectId });
347
- return this.version() === 1
348
- ? this.useProvider().buildSetStakingPoolMinStakeAmountTxV1(args)
349
- : this.useProvider().buildSetStakingPoolMinStakeAmountTxV2(args);
350
- });
351
- }
352
- /**
353
- * Builds a transaction granting a one-time admin cap to another address, allowing them to perform specific
354
- * one-time administrative actions (like initializing a reward).
355
- *
356
- * @param inputs - Body containing the `ownerCapId`, the `recipientAddress`, and the `rewardCoinType`.
357
- * @returns A transaction to be executed by the current pool owner.
358
- */
359
- getGrantOneTimeAdminCapTransaction(inputs) {
360
- return this.version() === 1
361
- ? this.useProvider().buildGrantOneTimeAdminCapTxV1(inputs)
362
- : this.useProvider().buildGrantOneTimeAdminCapTxV2(inputs);
363
- }
364
- // =========================================================================
365
- // Mutation Transactions (Owner/Admin Only)
366
- // =========================================================================
367
- /**
368
- * Builds a transaction to initialize a new reward coin in this pool, specifying the amount, emission rate,
369
- * and schedule parameters. This can be done by either the `ownerCapId` or a `oneTimeAdminCapId`.
370
- *
371
- * @param inputs - Contains emission info (rate, schedule) and which cap is used (`ownerCapId` or `oneTimeAdminCapId`).
372
- * @returns A transaction object for the reward initialization.
373
- */
374
- getInitializeRewardTransaction(inputs) {
375
- return __awaiter(this, void 0, void 0, function* () {
376
- const args = Object.assign(Object.assign({}, inputs), { stakeCoinType: this.stakingPool.stakeCoinType, stakingPoolId: this.stakingPool.objectId });
377
- return this.version() === 1
378
- ? this.useProvider().fetchBuildInitializeStakingPoolRewardTxV1(args)
379
- : this.useProvider().fetchBuildInitializeStakingPoolRewardTxV2(args);
380
- });
381
- }
382
- /**
383
- * Builds a transaction to add more reward coins (top-up) to an existing reward
384
- * coin configuration, either as the owner or via a one-time admin cap.
385
- *
386
- * @param inputs - Contains an array of reward objects, each specifying amount and coin type.
387
- * @returns A transaction that can be signed and executed to increase the reward distribution pool.
388
- */
389
- getTopUpRewardsTransaction(inputs) {
390
- return __awaiter(this, void 0, void 0, function* () {
391
- const args = Object.assign(Object.assign({}, inputs), { stakeCoinType: this.stakingPool.stakeCoinType, stakingPoolId: this.stakingPool.objectId });
392
- return this.version() === 1
393
- ? this.useProvider().fetchBuildTopUpStakingPoolRewardsTxV1(args)
394
- : this.useProvider().fetchBuildTopUpStakingPoolRewardsTxV2(args);
395
- });
396
- }
397
- /**
398
- * Builds a transaction to **remove (withdraw) undistributed reward coins** from the
399
- * staking pool for **one or more reward coin types** in a single call.
400
- *
401
- * Only the **pool owner** (via `ownerCapId`) can remove rewards. One-time admin caps
402
- * are **not** permitted for removals. This operation reduces the pool’s remaining
403
- * undistributed reward balances; it does **not** affect rewards already accrued/claimed
404
- * by stakers.
405
- *
406
- * Versioning:
407
- * - V1 → calls `buildRemoveStakingPoolRewardTxV1`
408
- * - V2 → calls `buildRemoveStakingPoolRewardTxV2`
409
- *
410
- * Notes:
411
- * - The effective `stakingPoolId` and `stakeCoinType` are taken from this instance’s
412
- * `this.stakingPool` and override any values passed in `inputs`.
413
- *
414
- * @param inputs Parameters for reward removal.
415
- * @param inputs.rewards Array of removal entries. Each entry specifies:
416
- * - `rewardCoinType`: Coin type to withdraw.
417
- * - `rewardAmount`: Amount to withdraw (base units).
418
- * @param inputs.ownerCapId Object ID of the pool OwnerCap that authorizes the removal.
419
- * @param inputs.walletAddress Address that will sign/submit the transaction.
420
- * @returns A transaction object ready to sign and execute that removes the specified
421
- * undistributed rewards for each entry in `inputs.rewards`.
422
- */
423
- getRemoveRewardsTransaction(inputs) {
424
- const args = Object.assign(Object.assign({}, inputs), { stakeCoinType: this.stakingPool.stakeCoinType, stakingPoolId: this.stakingPool.objectId });
425
- return this.version() === 1
426
- ? this.useProvider().buildRemoveStakingPoolRewardTxV1(args)
427
- : this.useProvider().buildRemoveStakingPoolRewardTxV2(args);
428
- }
429
- // =========================================================================
430
- // Private
431
- // =========================================================================
432
- // =========================================================================
433
- // Calculations
434
- // =========================================================================
435
- /**
436
- * Updates `rewardsAccumulatedPerShare` by distributing `rewardsToEmit` among
437
- * the total staked amount with multiplier. This mimics on-chain distribution logic.
438
- *
439
- * @param inputs - Contains the `rewardsToEmit` and which `rewardCoinIndex` to update.
440
- */
441
- increaseRewardsAccumulatedPerShare(inputs) {
442
- const { rewardsToEmit, rewardCoinIndex } = inputs;
443
- const stakedWithMultiplier = this.stakingPool.stakedAmountWithMultiplier;
444
- if (stakedWithMultiplier === BigInt(0))
445
- return;
446
- // Distribute proportionally
447
- const newRewardsAccumulatedPerShare = (rewardsToEmit * BigInt(1000000000000000000)) /
448
- stakedWithMultiplier;
449
- if (newRewardsAccumulatedPerShare === BigInt(0))
450
- return;
451
- this.stakingPool.rewardCoins[rewardCoinIndex].rewardsAccumulatedPerShare += newRewardsAccumulatedPerShare;
452
- }
453
- /**
454
- * Computes how many rewards to emit based on the time since `lastRewardTimestamp` and
455
- * the pool's emission schedule, clamped by the total `rewardsRemaining`.
456
- */
457
- calcRewardsToEmit(inputs) {
458
- const { rewardCoin } = inputs;
459
- const currentTimestamp = (0, dayjs_1.default)().valueOf();
460
- // Calculate the number of rewards that have been emitted since the last time this reward was emitted.
461
- const rewardsToEmit = this.calcRewardsEmittedFromTimeTmToTn({
462
- timestampTm: rewardCoin.lastRewardTimestamp,
463
- timestampTn: currentTimestamp,
464
- rewardCoin,
465
- });
466
- const { rewardsRemaining } = rewardCoin;
467
- // IMPORTANT: Cap the amount of rewards to emit by the amount of remaining rewards.
468
- return rewardsRemaining < rewardsToEmit
469
- ? rewardsRemaining
470
- : rewardsToEmit;
471
- }
472
- /**
473
- * Calculates how many tokens were emitted between two timestamps (Tm and Tn) for a given reward coin,
474
- * based on the discrete `emissionRate` and `emissionSchedulesMs`.
475
- *
476
- * @param inputs - Contains `timestampTm`, `timestampTn`, and the relevant `rewardCoin`.
477
- * @returns The total number of tokens emitted in that time window.
478
- */
479
- calcRewardsEmittedFromTimeTmToTn(inputs) {
480
- const { timestampTm, timestampTn, rewardCoin } = inputs;
481
- const numberOfEmissionsFromTimeTmToTn = rewardCoin.emissionSchedulesMs === 0
482
- ? 0
483
- : (timestampTn - timestampTm) / rewardCoin.emissionSchedulesMs;
484
- return (BigInt(Math.floor(numberOfEmissionsFromTimeTmToTn)) *
485
- rewardCoin.emissionRate);
486
- }
487
- }
488
- exports.FarmsStakingPool = FarmsStakingPool;