aftermath-ts-sdk 1.2.63 → 1.2.64-docs.1

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 (117) hide show
  1. package/README.md +61 -27
  2. package/dist/general/dynamicGas/dynamicGas.d.ts +34 -0
  3. package/dist/general/dynamicGas/dynamicGas.d.ts.map +1 -1
  4. package/dist/general/dynamicGas/dynamicGas.js +34 -0
  5. package/dist/general/dynamicGas/dynamicGasTypes.d.ts +25 -0
  6. package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +1 -1
  7. package/dist/general/prices/prices.d.ts +73 -0
  8. package/dist/general/prices/prices.d.ts.map +1 -1
  9. package/dist/general/prices/prices.js +73 -0
  10. package/dist/general/providers/aftermath.d.ts +106 -25
  11. package/dist/general/providers/aftermath.d.ts.map +1 -1
  12. package/dist/general/providers/aftermath.js +108 -27
  13. package/dist/general/providers/aftermathApi.d.ts +127 -8
  14. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  15. package/dist/general/providers/aftermathApi.js +132 -12
  16. package/dist/general/types/castingTypes.d.ts +0 -7
  17. package/dist/general/types/castingTypes.d.ts.map +1 -1
  18. package/dist/general/types/castingTypes.js +6 -0
  19. package/dist/general/types/generalTypes.d.ts +228 -7
  20. package/dist/general/types/generalTypes.d.ts.map +1 -1
  21. package/dist/general/types/suiTypes.d.ts +0 -16
  22. package/dist/general/types/suiTypes.d.ts.map +1 -1
  23. package/dist/general/types/suiTypes.js +3 -25
  24. package/dist/general/utils/casting.d.ts +159 -3
  25. package/dist/general/utils/casting.d.ts.map +1 -1
  26. package/dist/general/utils/casting.js +162 -16
  27. package/dist/general/utils/fixedUtils.d.ts +89 -2
  28. package/dist/general/utils/fixedUtils.d.ts.map +1 -1
  29. package/dist/general/utils/fixedUtils.js +81 -4
  30. package/dist/general/utils/helpers.d.ts +320 -9
  31. package/dist/general/utils/helpers.d.ts.map +1 -1
  32. package/dist/general/utils/helpers.js +350 -89
  33. package/dist/general/utils/iFixedUtils.d.ts +64 -0
  34. package/dist/general/utils/iFixedUtils.d.ts.map +1 -1
  35. package/dist/general/utils/iFixedUtils.js +64 -0
  36. package/dist/general/wallet/wallet.d.ts +75 -0
  37. package/dist/general/wallet/wallet.d.ts.map +1 -1
  38. package/dist/general/wallet/wallet.js +75 -5
  39. package/dist/packages/auth/auth.d.ts +113 -0
  40. package/dist/packages/auth/auth.d.ts.map +1 -1
  41. package/dist/packages/auth/auth.js +129 -15
  42. package/dist/packages/auth/authTypes.d.ts +66 -0
  43. package/dist/packages/auth/authTypes.d.ts.map +1 -1
  44. package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
  45. package/dist/packages/coin/api/coinApi.js +28 -20
  46. package/dist/packages/coin/coin.d.ts +250 -0
  47. package/dist/packages/coin/coin.d.ts.map +1 -1
  48. package/dist/packages/coin/coin.js +238 -14
  49. package/dist/packages/coin/coinTypes.d.ts +93 -0
  50. package/dist/packages/coin/coinTypes.d.ts.map +1 -1
  51. package/dist/packages/dca/dca.d.ts +124 -35
  52. package/dist/packages/dca/dca.d.ts.map +1 -1
  53. package/dist/packages/dca/dca.js +127 -37
  54. package/dist/packages/dca/dcaTypes.d.ts +213 -28
  55. package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
  56. package/dist/packages/farms/farms.d.ts +184 -1
  57. package/dist/packages/farms/farms.d.ts.map +1 -1
  58. package/dist/packages/farms/farms.js +185 -11
  59. package/dist/packages/farms/farmsStakedPosition.d.ts +140 -6
  60. package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
  61. package/dist/packages/farms/farmsStakedPosition.js +189 -144
  62. package/dist/packages/farms/farmsStakingPool.d.ts +161 -1
  63. package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
  64. package/dist/packages/farms/farmsStakingPool.js +176 -70
  65. package/dist/packages/farms/farmsTypes.d.ts +283 -2
  66. package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
  67. package/dist/packages/farms/farmsTypes.js +18 -0
  68. package/dist/packages/limitOrders/limitOrders.d.ts +108 -21
  69. package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -1
  70. package/dist/packages/limitOrders/limitOrders.js +110 -22
  71. package/dist/packages/limitOrders/limitOrdersTypes.d.ts +142 -0
  72. package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -1
  73. package/dist/packages/multisig/multisig.d.ts +33 -4
  74. package/dist/packages/multisig/multisig.d.ts.map +1 -1
  75. package/dist/packages/multisig/multisig.js +33 -4
  76. package/dist/packages/multisig/multisigTypes.d.ts +17 -0
  77. package/dist/packages/multisig/multisigTypes.d.ts.map +1 -1
  78. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
  79. package/dist/packages/pools/pool.d.ts +327 -85
  80. package/dist/packages/pools/pool.d.ts.map +1 -1
  81. package/dist/packages/pools/pool.js +333 -91
  82. package/dist/packages/pools/pools.d.ts +299 -37
  83. package/dist/packages/pools/pools.d.ts.map +1 -1
  84. package/dist/packages/pools/pools.js +306 -52
  85. package/dist/packages/pools/poolsTypes.d.ts +267 -2
  86. package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
  87. package/dist/packages/referralVault/referralVault.d.ts +37 -0
  88. package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
  89. package/dist/packages/referralVault/referralVault.js +37 -0
  90. package/dist/packages/router/router.d.ts +213 -17
  91. package/dist/packages/router/router.d.ts.map +1 -1
  92. package/dist/packages/router/router.js +214 -18
  93. package/dist/packages/router/routerTypes.d.ts +198 -14
  94. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  95. package/dist/packages/staking/staking.d.ts +301 -43
  96. package/dist/packages/staking/staking.d.ts.map +1 -1
  97. package/dist/packages/staking/staking.js +308 -51
  98. package/dist/packages/staking/stakingTypes.d.ts +426 -6
  99. package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
  100. package/dist/packages/staking/stakingTypes.js +19 -0
  101. package/dist/packages/sui/sui.d.ts +39 -0
  102. package/dist/packages/sui/sui.d.ts.map +1 -1
  103. package/dist/packages/sui/sui.js +39 -0
  104. package/dist/packages/userData/userData.d.ts +66 -12
  105. package/dist/packages/userData/userData.d.ts.map +1 -1
  106. package/dist/packages/userData/userData.js +66 -12
  107. package/dist/packages/userData/userDataTypes.d.ts +19 -0
  108. package/dist/packages/userData/userDataTypes.d.ts.map +1 -1
  109. package/dist/types.d.ts.map +1 -1
  110. package/dist/types.js +0 -1
  111. package/package.json +1 -1
  112. package/dist/general/historicalData/historicalData.d.ts +0 -15
  113. package/dist/general/historicalData/historicalData.d.ts.map +0 -1
  114. package/dist/general/historicalData/historicalData.js +0 -45
  115. package/dist/general/historicalData/historicalDataTypes.d.ts +0 -10
  116. package/dist/general/historicalData/historicalDataTypes.d.ts.map +0 -1
  117. package/dist/general/historicalData/historicalDataTypes.js +0 -2
@@ -13,16 +13,34 @@ exports.Farms = void 0;
13
13
  const caller_1 = require("../../general/utils/caller");
14
14
  const farmsStakingPool_1 = require("./farmsStakingPool");
15
15
  const farmsStakedPosition_1 = require("./farmsStakedPosition");
16
+ /**
17
+ * The `Farms` class provides high-level methods for interacting with
18
+ * staking pools (farms) on the Sui network. It allows fetching pool
19
+ * details, user staked positions, and building transactions for creating
20
+ * new pools. This class also enables retrieving user interactions (events)
21
+ * with the farming system.
22
+ */
16
23
  class Farms extends caller_1.Caller {
17
24
  // =========================================================================
18
25
  // Constructor
19
26
  // =========================================================================
27
+ /**
28
+ * Creates a new `Farms` instance for fetching staking pool data and building
29
+ * farm-related transactions.
30
+ *
31
+ * @param config - Optional configuration, including network and access token.
32
+ * @param Provider - An optional `AftermathApi` instance for advanced transaction building.
33
+ */
20
34
  constructor(config, Provider) {
21
35
  super(config, "farms");
22
36
  this.Provider = Provider;
23
37
  // =========================================================================
24
38
  // Private Helpers
25
39
  // =========================================================================
40
+ /**
41
+ * Retrieves an instance of the `Farms` provider from the passed `AftermathApi`,
42
+ * throwing an error if not available.
43
+ */
26
44
  this.useProvider = () => {
27
45
  var _a;
28
46
  const provider = (_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Farms();
@@ -37,12 +55,38 @@ class Farms extends caller_1.Caller {
37
55
  // =========================================================================
38
56
  // Class Objects
39
57
  // =========================================================================
58
+ /**
59
+ * Fetches a single staking pool by its `objectId` from the farm API/indexer.
60
+ *
61
+ * @param inputs - An object containing the `objectId` of the staking pool.
62
+ * @returns A `FarmsStakingPool` object representing the staking pool.
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * const pool = await farms.getStakingPool({ objectId: "0x<pool_id>" });
67
+ * console.log(pool.stakingPool);
68
+ * ```
69
+ */
40
70
  getStakingPool(inputs) {
41
71
  return __awaiter(this, void 0, void 0, function* () {
42
72
  const stakingPool = yield this.fetchApi(inputs.objectId);
43
73
  return new farmsStakingPool_1.FarmsStakingPool(stakingPool, this.config, this.Provider);
44
74
  });
45
75
  }
76
+ /**
77
+ * Fetches multiple staking pools by their `objectIds`.
78
+ *
79
+ * @param inputs - An object containing an array of `objectIds`.
80
+ * @returns An array of `FarmsStakingPool` instances corresponding to each `objectId`.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const pools = await farms.getStakingPools({
85
+ * objectIds: ["0x<id1>", "0x<id2>"]
86
+ * });
87
+ * console.log(pools[0].stakingPool, pools[1].stakingPool);
88
+ * ```
89
+ */
46
90
  getStakingPools(inputs) {
47
91
  return __awaiter(this, void 0, void 0, function* () {
48
92
  const stakingPools = yield this.fetchApi("", {
@@ -51,46 +95,122 @@ class Farms extends caller_1.Caller {
51
95
  return stakingPools.map((stakingPool) => new farmsStakingPool_1.FarmsStakingPool(stakingPool, this.config, this.Provider));
52
96
  });
53
97
  }
98
+ /**
99
+ * Fetches all existing staking pools registered within the indexer or farm API.
100
+ *
101
+ * @returns An array of `FarmsStakingPool` objects.
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const allPools = await farms.getAllStakingPools();
106
+ * console.log(allPools.map(pool => pool.stakingPool));
107
+ * ```
108
+ */
54
109
  getAllStakingPools() {
55
110
  return __awaiter(this, void 0, void 0, function* () {
56
111
  const stakingPools = yield this.fetchApi("", {});
57
112
  return stakingPools.map((pool) => new farmsStakingPool_1.FarmsStakingPool(pool, this.config, this.Provider));
58
113
  });
59
114
  }
115
+ /**
116
+ * Fetches all staked positions owned by a given user.
117
+ *
118
+ * @param inputs - An object containing the user's `walletAddress`.
119
+ * @returns An array of `FarmsStakedPosition` objects representing each of the user's staked positions.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const positions = await farms.getOwnedStakedPositions({
124
+ * walletAddress: "0x<user_address>"
125
+ * });
126
+ * console.log(positions);
127
+ * ```
128
+ */
60
129
  getOwnedStakedPositions(inputs) {
61
130
  return __awaiter(this, void 0, void 0, function* () {
62
131
  const positions = yield this.fetchApi("owned-staked-positions", inputs);
63
132
  return positions.map((pool) => new farmsStakedPosition_1.FarmsStakedPosition(pool, undefined, this.config, this.Provider));
64
133
  });
65
134
  }
135
+ /**
136
+ * Fetches all `StakingPoolOwnerCapObject`s that a given address owns.
137
+ * These caps grant the owner the ability to modify staking pool parameters.
138
+ *
139
+ * @param inputs - An object containing the owner's `walletAddress`.
140
+ * @returns An array of `StakingPoolOwnerCapObject`s.
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const ownerCaps = await farms.getOwnedStakingPoolOwnerCaps({
145
+ * walletAddress: "0x<user_address>"
146
+ * });
147
+ * console.log(ownerCaps);
148
+ * ```
149
+ */
66
150
  getOwnedStakingPoolOwnerCaps(inputs) {
67
151
  return __awaiter(this, void 0, void 0, function* () {
68
- // TODO: remove endpoint eventually ?
69
- // return this.fetchApi<
70
- // StakingPoolOwnerCapObject[],
71
- // ApiFarmsOwnedStakingPoolOwnerCapsBody
72
- // >("owned-staking-pool-owner-caps", inputs);
152
+ // In this code, the direct endpoint is commented out. We use the provider method.
73
153
  return this.useProvider().fetchOwnedStakingPoolOwnerCaps(inputs);
74
154
  });
75
155
  }
156
+ /**
157
+ * Fetches all `StakingPoolOneTimeAdminCapObject`s that a given address owns.
158
+ * These caps grant one-time admin privileges, typically for initializing reward coins.
159
+ *
160
+ * @param inputs - An object containing the admin's `walletAddress`.
161
+ * @returns An array of `StakingPoolOneTimeAdminCapObject`s.
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const adminCaps = await farms.getOwnedStakingPoolOneTimeAdminCaps({
166
+ * walletAddress: "0x<user_address>"
167
+ * });
168
+ * console.log(adminCaps);
169
+ * ```
170
+ */
76
171
  getOwnedStakingPoolOneTimeAdminCaps(inputs) {
77
172
  return __awaiter(this, void 0, void 0, function* () {
78
- // TODO: remove endpoint eventually ?
79
- // return this.fetchApi<
80
- // StakingPoolOneTimeAdminCapObject[],
81
- // ApiFarmsOwnedStakingPoolOneTimeAdminCapsBody
82
- // >("owned-staking-pool-one-time-admin-caps", inputs);
83
173
  return this.useProvider().fetchOwnedStakingPoolOneTimeAdminCaps(inputs);
84
174
  });
85
175
  }
86
176
  // =========================================================================
87
177
  // Stats
88
178
  // =========================================================================
179
+ /**
180
+ * Retrieves the total value locked (TVL) in the specified farm IDs or in all farms if none are specified.
181
+ *
182
+ * @param inputs - An optional object containing an array of `farmIds` to filter TVL by. If not provided, returns global TVL.
183
+ * @returns A promise that resolves to a `number` representing the TVL in USD (or another relevant currency).
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * const tvl = await farms.getTVL();
188
+ * console.log("All farms' TVL:", tvl);
189
+ *
190
+ * const tvlForSpecificFarm = await farms.getTVL({ farmIds: ["0x<farm_id>"] });
191
+ * console.log("Specific farm's TVL:", tvlForSpecificFarm);
192
+ * ```
193
+ */
89
194
  getTVL(inputs) {
90
195
  return __awaiter(this, void 0, void 0, function* () {
91
196
  return this.fetchApi("tvl", inputs !== null && inputs !== void 0 ? inputs : {});
92
197
  });
93
198
  }
199
+ /**
200
+ * Retrieves the total value locked (TVL) of reward coins across specified farm IDs or all farms if none are specified.
201
+ *
202
+ * @param inputs - An optional object containing an array of `farmIds`. If not provided, returns global reward TVL.
203
+ * @returns A promise that resolves to a `number` representing the total rewards TVL in USD (or another relevant currency).
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const rewardsTvl = await farms.getRewardsTVL();
208
+ * console.log("All farms' rewards TVL:", rewardsTvl);
209
+ *
210
+ * const singleFarmRewardsTvl = await farms.getRewardsTVL({ farmIds: ["0x<farm_id>"] });
211
+ * console.log("Single farm's rewards TVL:", singleFarmRewardsTvl);
212
+ * ```
213
+ */
94
214
  getRewardsTVL(inputs) {
95
215
  return __awaiter(this, void 0, void 0, function* () {
96
216
  return this.fetchApi("rewards-tvl", inputs !== null && inputs !== void 0 ? inputs : {});
@@ -99,12 +219,40 @@ class Farms extends caller_1.Caller {
99
219
  // =========================================================================
100
220
  // Transactions
101
221
  // =========================================================================
102
- /** @deprecated use getCreateStakingPoolTransactionV2 instead */
222
+ /**
223
+ * **Deprecated**: Use `getCreateStakingPoolTransactionV2()` instead.
224
+ *
225
+ * Builds a transaction to create a new staking pool (farming vault) on version 1 of the farm system.
226
+ *
227
+ * @param inputs - Contains pool creation parameters such as `minLockDurationMs`, `maxLockDurationMs`, etc.
228
+ * @returns A transaction object (or bytes) that can be signed and submitted.
229
+ *
230
+ * @deprecated Please use `getCreateStakingPoolTransactionV2`.
231
+ */
103
232
  getCreateStakingPoolTransactionV1(inputs) {
104
233
  return __awaiter(this, void 0, void 0, function* () {
105
234
  return this.useProvider().fetchBuildCreateStakingPoolTxV1(inputs);
106
235
  });
107
236
  }
237
+ /**
238
+ * Builds a transaction to create a new staking pool (farming vault) on version 2 of the farm system.
239
+ *
240
+ * @param inputs - Contains pool creation parameters such as `minLockDurationMs`, `maxLockDurationMs`, etc.
241
+ * @returns A transaction object (or bytes) that can be signed and submitted.
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const tx = await farms.getCreateStakingPoolTransactionV2({
246
+ * minLockDurationMs: 604800000, // 1 week
247
+ * maxLockDurationMs: 31536000000, // 1 year
248
+ * maxLockMultiplier: BigInt("2000000000"), // e.g. 2.0x
249
+ * minStakeAmount: BigInt("1000000"),
250
+ * stakeCoinType: "0x<coin_type>",
251
+ * walletAddress: "0x<admin_address>"
252
+ * });
253
+ * // sign and submit the transaction
254
+ * ```
255
+ */
108
256
  getCreateStakingPoolTransactionV2(inputs) {
109
257
  return __awaiter(this, void 0, void 0, function* () {
110
258
  return this.useProvider().fetchBuildCreateStakingPoolTxV2(inputs);
@@ -113,6 +261,22 @@ class Farms extends caller_1.Caller {
113
261
  // =========================================================================
114
262
  // Events
115
263
  // =========================================================================
264
+ /**
265
+ * Fetches user-specific farm interaction events (e.g., staked, unlocked, withdrew) with optional pagination.
266
+ *
267
+ * @param inputs - Includes the user's `walletAddress`, along with `cursor` and `limit` for pagination.
268
+ * @returns A paginated set of events of type `FarmUserEvent`.
269
+ *
270
+ * @example
271
+ * ```typescript
272
+ * const userEvents = await farms.getInteractionEvents({
273
+ * walletAddress: "0x<user_address>",
274
+ * cursor: 0,
275
+ * limit: 10
276
+ * });
277
+ * console.log(userEvents);
278
+ * ```
279
+ */
116
280
  getInteractionEvents(inputs) {
117
281
  return __awaiter(this, void 0, void 0, function* () {
118
282
  return this.fetchApiIndexerEvents("events-by-user", inputs);
@@ -123,7 +287,17 @@ exports.Farms = Farms;
123
287
  // =========================================================================
124
288
  // Constants
125
289
  // =========================================================================
290
+ /**
291
+ * Contains constants relevant to farming, including minimum rewards to claim
292
+ * and maximum lock multipliers.
293
+ */
126
294
  Farms.constants = {
295
+ /**
296
+ * The minimum number of rewards (in smallest units) that can be claimed.
297
+ */
127
298
  minRewardsToClaim: BigInt(10),
299
+ /**
300
+ * The maximum lock multiplier that can be applied when locking a staked position.
301
+ */
128
302
  maxLockMultiplier: 18,
129
303
  };
@@ -2,69 +2,203 @@ import { Caller } from "../../general/utils/caller";
2
2
  import { Balance, CallerConfig, CoinType, CoinsToBalance, FarmsStakedPositionObject, FarmsVersion, SuiAddress, Timestamp } from "../../types";
3
3
  import { FarmsStakingPool } from "./farmsStakingPool";
4
4
  import { AftermathApi } from "../../general/providers";
5
+ /**
6
+ * The `FarmsStakedPosition` class represents a user's individual staked position
7
+ * in a particular staking pool. It provides methods to query position details,
8
+ * calculate potential rewards, lock/unlock stake, and build transactions
9
+ * for depositing, unstaking, or harvesting rewards.
10
+ */
5
11
  export declare class FarmsStakedPosition extends Caller {
6
12
  stakedPosition: FarmsStakedPositionObject;
7
13
  private readonly Provider?;
14
+ /**
15
+ * The timestamp (in ms) when rewards were last harvested for this position, possibly overriding the
16
+ * on-chain data if provided in the constructor.
17
+ */
8
18
  readonly trueLastHarvestRewardsTimestamp: Timestamp;
19
+ /**
20
+ * Creates a `FarmsStakedPosition` instance for a user's staked position in a farm.
21
+ *
22
+ * @param stakedPosition - The on-chain data object representing the user's staked position.
23
+ * @param trueLastHarvestRewardsTimestamp - Optionally overrides the last harvest time from the on-chain data.
24
+ * @param config - Optional configuration for the underlying `Caller`.
25
+ * @param Provider - Optional `AftermathApi` instance for transaction building.
26
+ */
9
27
  constructor(stakedPosition: FarmsStakedPositionObject, trueLastHarvestRewardsTimestamp?: Timestamp | undefined, config?: CallerConfig, Provider?: AftermathApi | undefined);
28
+ /**
29
+ * Returns the version of the farm system that this position belongs to (1 or 2).
30
+ */
10
31
  version: () => FarmsVersion;
32
+ /**
33
+ * Checks whether the position is still locked, based on the current time and the lock parameters.
34
+ *
35
+ * @param inputs - Contains a `FarmsStakingPool` instance to check for system constraints.
36
+ * @returns `true` if the position is locked; otherwise, `false`.
37
+ */
11
38
  isLocked: (inputs: {
12
39
  stakingPool: FarmsStakingPool;
13
40
  }) => boolean;
41
+ /**
42
+ * Checks whether the position has a non-zero lock duration.
43
+ *
44
+ * @returns `true` if the position was created with a lock duration > 0.
45
+ */
14
46
  isLockDuration: () => boolean;
47
+ /**
48
+ * Computes the timestamp (in ms) at which this position's lock will end.
49
+ *
50
+ * @returns The unlock timestamp (lock start + lock duration).
51
+ */
15
52
  unlockTimestamp: () => number;
53
+ /**
54
+ * Computes the user's accrued rewards for each reward coin in this position,
55
+ * returned as a `CoinsToBalance` object keyed by coin type.
56
+ *
57
+ * @param inputs - Contains a reference to the `FarmsStakingPool`.
58
+ * @returns A mapping from `coinType` to the amount of earned rewards.
59
+ */
16
60
  rewardCoinsToClaimableBalance: (inputs: {
17
61
  stakingPool: FarmsStakingPool;
18
62
  }) => CoinsToBalance;
63
+ /**
64
+ * Lists all reward coin types associated with this position.
65
+ *
66
+ * @returns An array of `CoinType` strings representing the reward coins.
67
+ */
19
68
  rewardCoinTypes: () => CoinType[];
69
+ /**
70
+ * Returns only the reward coin types that currently have a non-zero claimable balance.
71
+ *
72
+ * @param inputs - Contains a reference to the `FarmsStakingPool`.
73
+ * @returns An array of `CoinType` strings that have pending rewards > 0.
74
+ */
20
75
  nonZeroRewardCoinTypes: (inputs: {
21
76
  stakingPool: FarmsStakingPool;
22
77
  }) => CoinType[];
78
+ /**
79
+ * Retrieves the reward coin record for a specific coin type in this position.
80
+ *
81
+ * @param inputs - Must contain a `coinType` string to look up.
82
+ * @throws If the coin type is not found in this position.
83
+ * @returns The reward coin object from the position.
84
+ */
23
85
  rewardCoin: (inputs: {
24
86
  coinType: CoinType;
25
87
  }) => import("./farmsTypes").FarmsStakedPositionRewardCoin;
88
+ /**
89
+ * Checks if this position has any claimable rewards across all reward coin types.
90
+ *
91
+ * @param inputs - Contains a reference to the `FarmsStakingPool`.
92
+ * @returns `true` if there are unclaimed rewards; otherwise, `false`.
93
+ */
26
94
  hasClaimableRewards: (inputs: {
27
95
  stakingPool: FarmsStakingPool;
28
96
  }) => boolean;
97
+ /**
98
+ * Calculates the current amount of earned rewards for a specific coin type,
99
+ * factoring in any emission constraints and the pool's actual reward availability.
100
+ *
101
+ * @param inputs - Contains the `coinType` to check and a reference to the `FarmsStakingPool`.
102
+ * @returns The total `BigInt` amount of rewards earned for the specified coin type.
103
+ */
29
104
  rewardsEarned: (inputs: {
30
105
  coinType: CoinType;
31
106
  stakingPool: FarmsStakingPool;
32
- }) => bigint;
107
+ }) => Balance;
108
+ /**
109
+ * Updates the position's reward calculations based on the pool's current
110
+ * emission state, effectively "syncing" the on-chain logic into this local
111
+ * representation. Also checks if the lock duration has elapsed.
112
+ *
113
+ * @param inputs - Contains a reference to the `FarmsStakingPool`.
114
+ * @remarks This method is typically called before computing `rewardsEarned()`.
115
+ */
33
116
  updatePosition: (inputs: {
34
117
  stakingPool: FarmsStakingPool;
35
118
  }) => void;
119
+ /**
120
+ * Builds a transaction to deposit additional principal into this staked position.
121
+ *
122
+ * @param inputs - Contains `depositAmount`, the `walletAddress` performing the deposit, and optional sponsorship.
123
+ * @returns A transaction object (or bytes) that can be signed and executed to increase stake.
124
+ */
36
125
  getDepositPrincipalTransaction(inputs: {
37
126
  depositAmount: Balance;
38
127
  walletAddress: SuiAddress;
39
128
  isSponsoredTx?: boolean;
40
129
  }): Promise<import("@mysten/sui/transactions").Transaction>;
130
+ /**
131
+ * Builds a transaction to unstake this entire position, optionally claiming SUI as afSUI.
132
+ *
133
+ * @param inputs - Contains `walletAddress`, the `FarmsStakingPool` reference, and optional `claimSuiAsAfSui`.
134
+ * @returns A transaction that can be signed and executed to fully withdraw principal and possibly rewards.
135
+ */
41
136
  getUnstakeTransaction(inputs: {
42
137
  walletAddress: SuiAddress;
43
138
  stakingPool: FarmsStakingPool;
44
139
  claimSuiAsAfSui?: boolean;
45
140
  }): Promise<import("@mysten/sui/transactions").Transaction>;
141
+ /**
142
+ * Builds a transaction to lock this position for a specified duration, increasing its lock multiplier (if any).
143
+ *
144
+ * @param inputs - Contains the `lockDurationMs` and the `walletAddress`.
145
+ * @returns A transaction that can be signed and executed to lock the position.
146
+ */
46
147
  getLockTransaction(inputs: {
47
148
  lockDurationMs: Timestamp;
48
149
  walletAddress: SuiAddress;
49
150
  }): Promise<import("@mysten/sui/transactions").Transaction>;
151
+ /**
152
+ * Builds a transaction to re-lock this position (renew lock duration) at the current multiplier.
153
+ *
154
+ * @param inputs - Contains the `walletAddress`.
155
+ * @returns A transaction that can be signed and executed to extend or refresh the lock.
156
+ */
50
157
  getRenewLockTransaction(inputs: {
51
158
  walletAddress: SuiAddress;
52
159
  }): Promise<import("@mysten/sui/transactions").Transaction>;
160
+ /**
161
+ * Builds a transaction to unlock this position, removing any lock-based multiplier.
162
+ *
163
+ * @param inputs - Contains the `walletAddress`.
164
+ * @returns A transaction that can be signed and executed to unlock the position immediately.
165
+ */
53
166
  getUnlockTransaction(inputs: {
54
167
  walletAddress: SuiAddress;
55
168
  }): Promise<import("@mysten/sui/transactions").Transaction>;
169
+ /**
170
+ * Builds a transaction to harvest (claim) the rewards from this position,
171
+ * optionally receiving SUI as afSUI.
172
+ *
173
+ * @param inputs - Includes the `walletAddress`, the `FarmsStakingPool`, and optional `claimSuiAsAfSui`.
174
+ * @returns A transaction that can be signed and executed to claim accrued rewards.
175
+ */
56
176
  getHarvestRewardsTransaction(inputs: {
57
177
  walletAddress: SuiAddress;
58
178
  stakingPool: FarmsStakingPool;
59
179
  claimSuiAsAfSui?: boolean;
60
180
  }): Promise<import("@mysten/sui/transactions").Transaction>;
61
- calcTotalRewardsFromTimeT0(inputs: {
62
- rewardsAccumulatedPerShare: Balance;
63
- multiplierRewardsDebt: Balance;
64
- emissionEndTimestamp: Timestamp;
65
- }): [Balance, Balance];
181
+ /**
182
+ * Calculates the total base + multiplier rewards from time t0 for this position,
183
+ * ensuring that multiplier rewards only apply during the locked period.
184
+ *
185
+ * @param inputs - Contains updated `rewardsAccumulatedPerShare`, the position’s `multiplierRewardsDebt`, and the pool’s `emissionEndTimestamp`.
186
+ * @returns A tuple `[baseRewards, multiplierRewards]`.
187
+ */
188
+ private calcTotalRewardsFromTimeT0;
189
+ /**
190
+ * Removes the lock multiplier from this position if the current time is beyond the lock duration,
191
+ * reverting `lockMultiplier` to 1.0 (fixedOneB).
192
+ */
66
193
  private unlock;
194
+ /**
195
+ * Determines if this position is unlocked based on the lock end timestamp, the emission end timestamp,
196
+ * or a forced unlock condition in the pool.
197
+ */
67
198
  private isUnlocked;
199
+ /**
200
+ * Provides access to the `Farms` provider in the `AftermathApi`.
201
+ */
68
202
  private useProvider;
69
203
  }
70
204
  //# sourceMappingURL=farmsStakedPosition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"farmsStakedPosition.d.ts","sourceRoot":"","sources":["../../../src/packages/farms/farmsStakedPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAQN,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,yBAAyB,EACzB,YAAY,EACZ,UAAU,EAEV,SAAS,EAET,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,mBAAoB,SAAQ,MAAM;IAYtC,cAAc,EAAE,yBAAyB;IAGhD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAV3B,SAAgB,+BAA+B,EAAE,SAAS,CAAC;gBAOnD,cAAc,EAAE,yBAAyB,EAChD,+BAA+B,GAAE,SAAS,GAAG,SAAqB,EAClE,MAAM,CAAC,EAAE,YAAY,EACJ,QAAQ,CAAC,0BAAc;IAiBlC,OAAO,QAAO,YAAY,CAE/B;IAEK,QAAQ,WAAY;QAAE,WAAW,EAAE,gBAAgB,CAAA;KAAE,KAAG,OAAO,CAEpE;IAEK,cAAc,QAAO,OAAO,CAEjC;IAEK,eAAe,QAAO,MAAM,CAKjC;IAEK,6BAA6B,WAAY;QAC/C,WAAW,EAAE,gBAAgB,CAAC;KAC9B,KAAG,cAAc,CAWhB;IAEK,eAAe,QAAO,QAAQ,EAAE,CAErC;IAEK,sBAAsB,WAAY;QACxC,WAAW,EAAE,gBAAgB,CAAC;KAC9B,KAAG,QAAQ,EAAE,CAIZ;IAEK,UAAU,WAAY;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,0DA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