aftermath-ts-sdk 1.2.61 → 1.2.63

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 (32) hide show
  1. package/dist/general/apiHelpers/eventsApiHelpers.d.ts +1 -1
  2. package/dist/general/apiHelpers/eventsApiHelpers.d.ts.map +1 -1
  3. package/dist/general/apiHelpers/eventsApiHelpers.js +4 -1
  4. package/dist/general/types/castingTypes.d.ts +15 -0
  5. package/dist/general/types/castingTypes.d.ts.map +1 -1
  6. package/dist/general/types/configTypes.d.ts +5 -0
  7. package/dist/general/types/configTypes.d.ts.map +1 -1
  8. package/dist/general/utils/helpers.d.ts +1 -1
  9. package/dist/general/utils/helpers.d.ts.map +1 -1
  10. package/dist/general/utils/helpers.js +1 -1
  11. package/dist/packages/farms/api/farmsApi.d.ts +711 -60
  12. package/dist/packages/farms/api/farmsApi.d.ts.map +1 -1
  13. package/dist/packages/farms/api/farmsApi.js +1138 -156
  14. package/dist/packages/farms/api/farmsApiCasting.d.ts +34 -18
  15. package/dist/packages/farms/api/farmsApiCasting.d.ts.map +1 -1
  16. package/dist/packages/farms/api/farmsApiCasting.js +218 -17
  17. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts +117 -21
  18. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts.map +1 -1
  19. package/dist/packages/farms/farms.d.ts +4 -2
  20. package/dist/packages/farms/farms.d.ts.map +1 -1
  21. package/dist/packages/farms/farms.js +8 -2
  22. package/dist/packages/farms/farmsStakedPosition.d.ts +2 -1
  23. package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
  24. package/dist/packages/farms/farmsStakedPosition.js +36 -12
  25. package/dist/packages/farms/farmsStakingPool.d.ts +2 -1
  26. package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
  27. package/dist/packages/farms/farmsStakingPool.js +36 -7
  28. package/dist/packages/farms/farmsTypes.d.ts +21 -2
  29. package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
  30. package/dist/packages/router/routerTypes.d.ts +1 -1
  31. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  32. package/package.json +1 -1
@@ -19,6 +19,11 @@ class FarmsApi {
19
19
  // =========================================================================
20
20
  // Constructor
21
21
  // =========================================================================
22
+ /**
23
+ * Constructor for FarmsApi
24
+ * @param Provider The AftermathApi provider instance
25
+ * @throws Error if not all required addresses have been set in provider
26
+ */
22
27
  constructor(Provider) {
23
28
  this.Provider = Provider;
24
29
  // =========================================================================
@@ -30,83 +35,91 @@ class FarmsApi {
30
35
  // =========================================================================
31
36
  // Staking Pool Objects
32
37
  // =========================================================================
38
+ /**
39
+ * Fetches the owner caps for staking pools owned by a specific wallet address
40
+ * @param inputs Object containing wallet address
41
+ * @returns Array of StakingPoolOwnerCapObject
42
+ */
33
43
  this.fetchOwnedStakingPoolOwnerCaps = (inputs) => __awaiter(this, void 0, void 0, function* () {
34
44
  const { walletAddress } = inputs;
35
- return this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
36
- walletAddress,
37
- objectType: this.objectTypes.stakingPoolOwnerCap,
38
- objectFromSuiObjectResponse: utils_1.Casting.farms.stakingPoolOwnerCapObjectFromSuiObjectResponse,
39
- });
45
+ const [capsV1, capsV2] = yield Promise.all([
46
+ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
47
+ walletAddress,
48
+ objectType: this.objectTypes.stakingPoolOwnerCapV1,
49
+ objectFromSuiObjectResponse: utils_1.Casting.farms
50
+ .stakingPoolOwnerCapObjectFromSuiObjectResponseV1,
51
+ }),
52
+ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
53
+ walletAddress,
54
+ objectType: this.objectTypes.stakingPoolOwnerCapV2,
55
+ objectFromSuiObjectResponse: utils_1.Casting.farms
56
+ .stakingPoolOwnerCapObjectFromSuiObjectResponseV2,
57
+ }),
58
+ ]);
59
+ return [...capsV1, ...capsV2];
40
60
  });
61
+ /**
62
+ * Fetches the one-time admin caps for staking pools owned by a specific wallet address
63
+ * @param inputs Object containing wallet address
64
+ * @returns Array of StakingPoolOneTimeAdminCapObject
65
+ */
41
66
  this.fetchOwnedStakingPoolOneTimeAdminCaps = (inputs) => __awaiter(this, void 0, void 0, function* () {
42
67
  const { walletAddress } = inputs;
43
- return this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
44
- walletAddress,
45
- objectType: this.objectTypes.stakingPoolOneTimeAdminCap,
46
- objectFromSuiObjectResponse: utils_1.Casting.farms
47
- .stakingPoolOneTimeAdminCapObjectFromSuiObjectResponse,
48
- });
68
+ const [capsV1, capsV2] = yield Promise.all([
69
+ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
70
+ walletAddress,
71
+ objectType: this.objectTypes.stakingPoolOneTimeAdminCapV1,
72
+ objectFromSuiObjectResponse: utils_1.Casting.farms
73
+ .stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV1,
74
+ }),
75
+ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
76
+ walletAddress,
77
+ objectType: this.objectTypes.stakingPoolOneTimeAdminCapV2,
78
+ objectFromSuiObjectResponse: utils_1.Casting.farms
79
+ .stakingPoolOneTimeAdminCapObjectFromSuiObjectResponseV2,
80
+ }),
81
+ ]);
82
+ return [...capsV1, ...capsV2];
49
83
  });
50
84
  // =========================================================================
51
85
  // Staked Position Objects
52
86
  // =========================================================================
87
+ /**
88
+ * Fetches partial staked positions owned by a specific wallet address
89
+ * @param inputs Object containing wallet address
90
+ * @returns Array of PartialFarmsStakedPositionObject
91
+ */
53
92
  this.fetchOwnedPartialStakedPositions = (inputs) => __awaiter(this, void 0, void 0, function* () {
54
93
  const { walletAddress } = inputs;
55
- return this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
56
- walletAddress,
57
- objectType: this.objectTypes.stakedPosition,
58
- objectFromSuiObjectResponse: utils_1.Casting.farms.partialStakedPositionObjectFromSuiObjectResponse,
59
- });
94
+ const [positionsV1, positionsV2] = yield Promise.all([
95
+ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
96
+ walletAddress,
97
+ objectType: this.objectTypes.stakedPositionV1,
98
+ objectFromSuiObjectResponse: utils_1.Casting.farms
99
+ .partialStakedPositionObjectFromSuiObjectResponseV1,
100
+ }),
101
+ this.Provider.Objects().fetchCastObjectsOwnedByAddressOfType({
102
+ walletAddress,
103
+ objectType: this.objectTypes.stakedPositionV2,
104
+ objectFromSuiObjectResponse: utils_1.Casting.farms
105
+ .partialStakedPositionObjectFromSuiObjectResponseV2,
106
+ }),
107
+ ]);
108
+ return [...positionsV1, ...positionsV2];
60
109
  });
61
110
  // =========================================================================
62
- // Events
63
- // =========================================================================
64
- // =========================================================================
65
- // Created Vault
66
- // =========================================================================
67
- this.fetchCreatedVaultEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
68
- MoveEventType: this.eventTypes.createdVault,
69
- }, eventFromEventOnChain: utils_1.Casting.farms.createdVaultEventFromOnChain }));
70
- // =========================================================================
71
- // Staking Position Creation
72
- // =========================================================================
73
- this.fetchStakedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
74
- MoveEventType: this.eventTypes.staked,
75
- }, eventFromEventOnChain: utils_1.Casting.farms.stakedEventFromOnChain }));
76
- this.fetchStakedRelaxedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
77
- MoveEventType: this.eventTypes.stakedRelaxed,
78
- }, eventFromEventOnChain: utils_1.Casting.farms.stakedRelaxedEventFromOnChain }));
79
- // =========================================================================
80
- // Staking Position Locking
81
- // =========================================================================
82
- this.fetchLockedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
83
- MoveEventType: this.eventTypes.locked,
84
- }, eventFromEventOnChain: utils_1.Casting.farms.lockedEventFromOnChain }));
85
- this.fetchUnlockedEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
86
- MoveEventType: this.eventTypes.unlocked,
87
- }, eventFromEventOnChain: utils_1.Casting.farms.unlockedEventFromOnChain }));
88
- // =========================================================================
89
- // Staking Position Staking
90
- // =========================================================================
91
- this.fetchDepositedPrincipalEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
92
- MoveEventType: this.eventTypes.depositedPrincipal,
93
- }, eventFromEventOnChain: utils_1.Casting.farms.depositedPrincipalEventFromOnChain }));
94
- this.fetchWithdrewPrincipalEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
95
- MoveEventType: this.eventTypes.withdrewPrincipal,
96
- }, eventFromEventOnChain: utils_1.Casting.farms.withdrewPrincipalEventFromOnChain }));
97
- // =========================================================================
98
- // Staking Position Reward Harvesting
99
- // =========================================================================
100
- this.fetchHarvestedRewardsEvents = (inputs) => this.Provider.Events().fetchCastEventsWithCursor(Object.assign(Object.assign({}, inputs), { query: {
101
- MoveEventType: this.eventTypes.harvestedRewards,
102
- }, eventFromEventOnChain: utils_1.Casting.farms.harvestedRewardsEventFromOnChain }));
103
- // =========================================================================
104
111
  // Transaction Commands
105
112
  // =========================================================================
106
113
  // =========================================================================
107
114
  // Staking Transaction Commands
108
115
  // =========================================================================
109
- this.stakeTx = (inputs) => {
116
+ /**
117
+ * @deprecated use stakeTxV2 instead
118
+ * Creates a transaction to stake coins in a staking pool (original version)
119
+ * @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, and coin type
120
+ * @returns Transaction object argument for StakedPosition
121
+ */
122
+ this.stakeTxV1 = (inputs) => {
110
123
  const { tx, stakeCoinId } = inputs;
111
124
  return tx.moveCall({
112
125
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "stake"),
@@ -121,7 +134,35 @@ class FarmsApi {
121
134
  ],
122
135
  });
123
136
  };
124
- this.depositPrincipalTx = (inputs) => {
137
+ /**
138
+ * Creates a transaction to stake coins in a staking pool
139
+ * @param inputs Staking parameters including transaction, pool ID, coin ID, lock duration, lock enforcement, and coin type
140
+ * @returns Transaction object argument for StakedPosition
141
+ */
142
+ this.stakeTxV2 = (inputs) => {
143
+ const { tx, stakeCoinId } = inputs;
144
+ return tx.moveCall({
145
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "stake"),
146
+ typeArguments: [inputs.stakeCoinType],
147
+ arguments: [
148
+ tx.object(inputs.stakingPoolId),
149
+ tx.object(this.addresses.objects.version),
150
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
151
+ typeof stakeCoinId === "string"
152
+ ? tx.object(stakeCoinId)
153
+ : stakeCoinId,
154
+ tx.pure.u8(inputs.lockEnforcement === "Strict" ? 0 : 1),
155
+ tx.pure.u64(inputs.lockDurationMs), // lock_duration_ms
156
+ ],
157
+ });
158
+ };
159
+ /**
160
+ * @deprecated use depositPrincipalTxV2 instead
161
+ * Creates a transaction to deposit additional principal to a staked position (original version)
162
+ * @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type
163
+ * @returns Transaction command to deposit principal
164
+ */
165
+ this.depositPrincipalTxV1 = (inputs) => {
125
166
  const { tx, stakeCoinId } = inputs;
126
167
  return tx.moveCall({
127
168
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "deposit_principal"),
@@ -136,7 +177,34 @@ class FarmsApi {
136
177
  ],
137
178
  });
138
179
  };
139
- this.withdrawPrincipalTx = (inputs) => {
180
+ /**
181
+ * Creates a transaction to deposit additional principal to a staked position
182
+ * @param inputs Deposit parameters including transaction, position ID, pool ID, coin ID, and coin type
183
+ * @returns Transaction command to deposit principal
184
+ */
185
+ this.depositPrincipalTxV2 = (inputs) => {
186
+ const { tx, stakeCoinId } = inputs;
187
+ return tx.moveCall({
188
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "deposit_principal"),
189
+ typeArguments: [inputs.stakeCoinType],
190
+ arguments: [
191
+ tx.object(inputs.stakedPositionId),
192
+ tx.object(inputs.stakingPoolId),
193
+ tx.object(this.addresses.objects.version),
194
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
195
+ typeof stakeCoinId === "string"
196
+ ? tx.object(stakeCoinId)
197
+ : stakeCoinId, // Coin
198
+ ],
199
+ });
200
+ };
201
+ /**
202
+ * @deprecated use withdrawPrincipalTxV2 instead
203
+ * Creates a transaction to withdraw principal from a staked position (original version)
204
+ * @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type
205
+ * @returns Transaction object argument for the withdrawn Coin
206
+ */
207
+ this.withdrawPrincipalTxV1 = (inputs) => {
140
208
  const { tx } = inputs;
141
209
  return tx.moveCall({
142
210
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "withdraw_principal"),
@@ -149,7 +217,32 @@ class FarmsApi {
149
217
  ],
150
218
  });
151
219
  };
152
- this.destroyStakedPositionTx = (inputs) => {
220
+ /**
221
+ * Creates a transaction to withdraw principal from a staked position
222
+ * @param inputs Withdrawal parameters including transaction, position ID, pool ID, amount, and coin type
223
+ * @returns Transaction object argument for the withdrawn Coin
224
+ */
225
+ this.withdrawPrincipalTxV2 = (inputs) => {
226
+ const { tx } = inputs;
227
+ return tx.moveCall({
228
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "withdraw_principal"),
229
+ typeArguments: [inputs.stakeCoinType],
230
+ arguments: [
231
+ tx.object(inputs.stakedPositionId),
232
+ tx.object(inputs.stakingPoolId),
233
+ tx.object(this.addresses.objects.version),
234
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
235
+ tx.pure.u64(inputs.withdrawAmount),
236
+ ],
237
+ });
238
+ };
239
+ /**
240
+ * @deprecated use destroyStakedPositionTxV2 instead
241
+ * Creates a transaction to destroy a staked position (original version)
242
+ * @param inputs Destroy parameters including transaction, position ID, pool ID, and coin type
243
+ * @returns Transaction command to destroy the position
244
+ */
245
+ this.destroyStakedPositionTxV1 = (inputs) => {
153
246
  const { tx } = inputs;
154
247
  return tx.moveCall({
155
248
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "destroy"),
@@ -161,7 +254,29 @@ class FarmsApi {
161
254
  ],
162
255
  });
163
256
  };
164
- this.updatePositionTx = (inputs) => {
257
+ /**
258
+ * Creates a transaction to destroy a staked position
259
+ * @param inputs Destroy parameters including transaction, position ID, and coin type
260
+ * @returns Transaction command to destroy the position
261
+ */
262
+ this.destroyStakedPositionTxV2 = (inputs) => {
263
+ const { tx } = inputs;
264
+ return tx.moveCall({
265
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "destroy"),
266
+ typeArguments: [inputs.stakeCoinType],
267
+ arguments: [
268
+ tx.object(inputs.stakedPositionId),
269
+ tx.object(this.addresses.objects.version), // Version
270
+ ],
271
+ });
272
+ };
273
+ /**
274
+ * @deprecated use updatePositionTxV2 instead
275
+ * Creates a transaction to update a staked position, recalculating rewards (original version)
276
+ * @param inputs Update parameters including transaction, position ID, pool ID, and coin type
277
+ * @returns Transaction command to update the position
278
+ */
279
+ this.updatePositionTxV1 = (inputs) => {
165
280
  const { tx } = inputs;
166
281
  return tx.moveCall({
167
282
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "update_position"),
@@ -173,10 +288,34 @@ class FarmsApi {
173
288
  ],
174
289
  });
175
290
  };
291
+ /**
292
+ * Creates a transaction to update a staked position, recalculating rewards
293
+ * @param inputs Update parameters including transaction, position ID, pool ID, and coin type
294
+ * @returns Transaction command to update the position
295
+ */
296
+ this.updatePositionTxV2 = (inputs) => {
297
+ const { tx } = inputs;
298
+ return tx.moveCall({
299
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "update_position"),
300
+ typeArguments: [inputs.stakeCoinType],
301
+ arguments: [
302
+ tx.object(inputs.stakedPositionId),
303
+ tx.object(inputs.stakingPoolId),
304
+ tx.object(this.addresses.objects.version),
305
+ tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock
306
+ ],
307
+ });
308
+ };
176
309
  // =========================================================================
177
310
  // Locking Transaction Commands
178
311
  // =========================================================================
179
- this.lockTx = (inputs) => {
312
+ /**
313
+ * @deprecated use lockTxV2 instead
314
+ * Creates a transaction to lock a staked position for a specific duration (original version)
315
+ * @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type
316
+ * @returns Transaction command to lock the position
317
+ */
318
+ this.lockTxV1 = (inputs) => {
180
319
  const { tx } = inputs;
181
320
  return tx.moveCall({
182
321
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "lock"),
@@ -189,7 +328,32 @@ class FarmsApi {
189
328
  ],
190
329
  });
191
330
  };
192
- this.renewLockTx = (inputs) => {
331
+ /**
332
+ * Creates a transaction to lock a staked position for a specific duration
333
+ * @param inputs Lock parameters including transaction, position ID, pool ID, lock duration, and coin type
334
+ * @returns Transaction command to lock the position
335
+ */
336
+ this.lockTxV2 = (inputs) => {
337
+ const { tx } = inputs;
338
+ return tx.moveCall({
339
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "lock"),
340
+ typeArguments: [inputs.stakeCoinType],
341
+ arguments: [
342
+ tx.object(inputs.stakedPositionId),
343
+ tx.object(inputs.stakingPoolId),
344
+ tx.object(this.addresses.objects.version),
345
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
346
+ tx.pure.u64(inputs.lockDurationMs),
347
+ ],
348
+ });
349
+ };
350
+ /**
351
+ * @deprecated use renewLockTxV2 instead
352
+ * Creates a transaction to renew the lock on a staked position (original version)
353
+ * @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type
354
+ * @returns Transaction command to renew the lock
355
+ */
356
+ this.renewLockTxV1 = (inputs) => {
193
357
  const { tx } = inputs;
194
358
  return tx.moveCall({
195
359
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "renew_lock"),
@@ -201,7 +365,31 @@ class FarmsApi {
201
365
  ],
202
366
  });
203
367
  };
204
- this.unlockTx = (inputs) => {
368
+ /**
369
+ * Creates a transaction to renew the lock on a staked position
370
+ * @param inputs Renew lock parameters including transaction, position ID, pool ID, and coin type
371
+ * @returns Transaction command to renew the lock
372
+ */
373
+ this.renewLockTxV2 = (inputs) => {
374
+ const { tx } = inputs;
375
+ return tx.moveCall({
376
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "renew_lock"),
377
+ typeArguments: [inputs.stakeCoinType],
378
+ arguments: [
379
+ tx.object(inputs.stakedPositionId),
380
+ tx.object(inputs.stakingPoolId),
381
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
382
+ tx.object(this.addresses.objects.version), // Version
383
+ ],
384
+ });
385
+ };
386
+ /**
387
+ * @deprecated use unlockTxV2 instead
388
+ * Creates a transaction to unlock a staked position (original version)
389
+ * @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type
390
+ * @returns Transaction command to unlock the position
391
+ */
392
+ this.unlockTxV1 = (inputs) => {
205
393
  const { tx } = inputs;
206
394
  return tx.moveCall({
207
395
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "unlock"),
@@ -213,10 +401,34 @@ class FarmsApi {
213
401
  ],
214
402
  });
215
403
  };
404
+ /**
405
+ * Creates a transaction to unlock a staked position
406
+ * @param inputs Unlock parameters including transaction, position ID, pool ID, and coin type
407
+ * @returns Transaction command to unlock the position
408
+ */
409
+ this.unlockTxV2 = (inputs) => {
410
+ const { tx } = inputs;
411
+ return tx.moveCall({
412
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "unlock"),
413
+ typeArguments: [inputs.stakeCoinType],
414
+ arguments: [
415
+ tx.object(inputs.stakedPositionId),
416
+ tx.object(inputs.stakingPoolId),
417
+ tx.object(this.addresses.objects.version),
418
+ tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock
419
+ ],
420
+ });
421
+ };
216
422
  // =========================================================================
217
423
  // Reward Harvesting Transaction Commands
218
424
  // =========================================================================
219
- this.beginHarvestTx = (inputs) => {
425
+ /**
426
+ * @deprecated use beginHarvestTxV2 instead
427
+ * Creates a transaction to begin the reward harvesting process (original version)
428
+ * @param inputs Begin harvest parameters including transaction, pool ID, and coin type
429
+ * @returns Transaction object argument for the harvest metadata
430
+ */
431
+ this.beginHarvestTxV1 = (inputs) => {
220
432
  const { tx } = inputs;
221
433
  return tx.moveCall({
222
434
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "begin_harvest"),
@@ -226,7 +438,30 @@ class FarmsApi {
226
438
  ],
227
439
  });
228
440
  };
229
- this.harvestRewardsTx = (inputs) => {
441
+ /**
442
+ * Creates a transaction to begin the reward harvesting process
443
+ * @param inputs Begin harvest parameters including transaction, position ID, pool ID, and coin type
444
+ * @returns Transaction object argument for the harvest cap
445
+ */
446
+ this.beginHarvestTxV2 = (inputs) => {
447
+ const { tx } = inputs;
448
+ return tx.moveCall({
449
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "begin_harvest_tx"),
450
+ typeArguments: [inputs.stakeCoinType],
451
+ arguments: [
452
+ tx.object(inputs.stakedPositionId),
453
+ tx.object(inputs.stakingPoolId),
454
+ tx.object(this.addresses.objects.version), // Version
455
+ ],
456
+ });
457
+ };
458
+ /**
459
+ * @deprecated use harvestRewardsTxV2 instead
460
+ * Creates a transaction to harvest rewards from a staked position (original version)
461
+ * @param inputs Harvest parameters including transaction, position ID, pool ID, harvest metadata, stake coin type, and reward coin type
462
+ * @returns Transaction object argument for the harvested rewards
463
+ */
464
+ this.harvestRewardsTxV1 = (inputs) => {
230
465
  const { tx, harvestedRewardsEventMetadataId } = inputs;
231
466
  return tx.moveCall({
232
467
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "harvest_rewards"),
@@ -241,7 +476,34 @@ class FarmsApi {
241
476
  ],
242
477
  });
243
478
  };
244
- this.endHarvestTx = (inputs) => {
479
+ /**
480
+ * Creates a transaction to harvest rewards from a staked position
481
+ * @param inputs Harvest parameters including transaction, harvest cap, position ID, pool ID, stake coin type, and reward coin type
482
+ * @returns Transaction object argument for the harvested rewards
483
+ */
484
+ this.harvestRewardsTxV2 = (inputs) => {
485
+ const { tx, harvestRewardsCap } = inputs;
486
+ return tx.moveCall({
487
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "harvest_rewards"),
488
+ typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
489
+ arguments: [
490
+ typeof harvestRewardsCap === "string"
491
+ ? tx.object(harvestRewardsCap)
492
+ : harvestRewardsCap,
493
+ tx.object(inputs.stakedPositionId),
494
+ tx.object(inputs.stakingPoolId),
495
+ tx.object(this.addresses.objects.version),
496
+ tx.object(sui_1.Sui.constants.addresses.suiClockId), // Clock
497
+ ],
498
+ });
499
+ };
500
+ /**
501
+ * @deprecated use endHarvestTxV2 instead
502
+ * Creates a transaction to end the reward harvesting process (original version)
503
+ * @param inputs End harvest parameters including transaction and harvest metadata
504
+ * @returns Transaction command to end the harvest
505
+ */
506
+ this.endHarvestTxV1 = (inputs) => {
245
507
  const { tx, harvestedRewardsEventMetadataId } = inputs;
246
508
  return tx.moveCall({
247
509
  target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.stakedPosition, "end_harvest"),
@@ -253,13 +515,37 @@ class FarmsApi {
253
515
  ],
254
516
  });
255
517
  };
518
+ /**
519
+ * Creates a transaction to end the reward harvesting process
520
+ * @param inputs End harvest parameters including transaction and harvest cap
521
+ * @returns Transaction command to end the harvest
522
+ */
523
+ this.endHarvestTxV2 = (inputs) => {
524
+ const { tx, harvestRewardsCap } = inputs;
525
+ return tx.moveCall({
526
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.stakedPosition, "end_harvest_tx"),
527
+ typeArguments: [],
528
+ arguments: [
529
+ typeof harvestRewardsCap === "string"
530
+ ? tx.object(harvestRewardsCap)
531
+ : harvestRewardsCap,
532
+ tx.object(this.addresses.objects.version), // Version
533
+ ],
534
+ });
535
+ };
256
536
  // =========================================================================
257
537
  // Staking Pool Creation Transaction Commands
258
538
  // =========================================================================
259
- this.newStakingPoolTx = (inputs) => {
539
+ /**
540
+ * @deprecated use newStakingPoolTxV2 instead
541
+ * Creates a transaction for the deprecated version of staking pool creation
542
+ * @param inputs Pool creation parameters including transaction, lock enforcement, durations, multiplier, stake amount, and coin type
543
+ * @returns Transaction objects for the vault and owner cap
544
+ */
545
+ this.newStakingPoolTxV1 = (inputs) => {
260
546
  const { tx } = inputs;
261
547
  return tx.moveCall({
262
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "new"),
548
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "new"),
263
549
  typeArguments: [inputs.stakeCoinType],
264
550
  arguments: [
265
551
  tx.pure.u64(inputs.lockEnforcement === "Strict" ? 0 : 1),
@@ -270,10 +556,36 @@ class FarmsApi {
270
556
  ],
271
557
  });
272
558
  };
273
- this.shareStakingPoolTx = (inputs) => {
559
+ /**
560
+ * Creates a transaction for the current version of staking pool creation
561
+ * @param inputs Pool creation parameters including transaction, lock enforcements array, durations, multiplier, stake amount, and coin type
562
+ * @returns Transaction objects for the vault and authority cap
563
+ */
564
+ this.newStakingPoolTxV2 = (inputs) => {
565
+ const { tx } = inputs;
566
+ return tx.moveCall({
567
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "new"),
568
+ typeArguments: [inputs.stakeCoinType],
569
+ arguments: [
570
+ tx.object(this.addresses.objects.version),
571
+ tx.pure.vector("u8", inputs.lockEnforcements.map((lockEnforcement) => lockEnforcement === "Strict" ? 0 : 1)),
572
+ tx.pure.u64(inputs.minLockDurationMs),
573
+ tx.pure.u64(inputs.maxLockDurationMs),
574
+ tx.pure.u64(inputs.maxLockMultiplier),
575
+ tx.pure.u64(inputs.minStakeAmount),
576
+ ],
577
+ });
578
+ };
579
+ /**
580
+ * @deprecated use shareStakingPoolTxV2 instead
581
+ * Creates a transaction to share a staking pool, making it public
582
+ * @param inputs Share pool parameters including transaction, pool ID, and coin type
583
+ * @returns Transaction command to share the pool
584
+ */
585
+ this.shareStakingPoolTxV1 = (inputs) => {
274
586
  const { tx, stakingPoolId } = inputs;
275
587
  return tx.moveCall({
276
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "share_vault"),
588
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "share_vault"),
277
589
  typeArguments: [inputs.stakeCoinType],
278
590
  arguments: [
279
591
  typeof stakingPoolId === "string"
@@ -282,10 +594,33 @@ class FarmsApi {
282
594
  ],
283
595
  });
284
596
  };
285
- this.transferOwnerCapTx = (inputs) => {
597
+ /**
598
+ * Creates a transaction to share a staking pool, making it public
599
+ * @param inputs Share pool parameters including transaction, pool ID, and coin type
600
+ * @returns Transaction command to share the pool
601
+ */
602
+ this.shareStakingPoolTxV2 = (inputs) => {
603
+ const { tx, stakingPoolId } = inputs;
604
+ return tx.moveCall({
605
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "share"),
606
+ typeArguments: [inputs.stakeCoinType],
607
+ arguments: [
608
+ typeof stakingPoolId === "string"
609
+ ? tx.object(stakingPoolId)
610
+ : stakingPoolId, // AfterburnerVault
611
+ ],
612
+ });
613
+ };
614
+ /**
615
+ * @deprecated use transferOwnerCapTxV2 instead
616
+ * Creates a transaction to transfer ownership of a staking pool
617
+ * @param inputs Transfer parameters including transaction, owner cap ID, and recipient address
618
+ * @returns Transaction command to transfer the owner cap
619
+ */
620
+ this.transferOwnerCapTxV1 = (inputs) => {
286
621
  const { tx, ownerCapId } = inputs;
287
622
  return tx.moveCall({
288
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "transfer_owner_cap"),
623
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "transfer_owner_cap"),
289
624
  typeArguments: [],
290
625
  arguments: [
291
626
  typeof ownerCapId === "string"
@@ -295,10 +630,16 @@ class FarmsApi {
295
630
  ],
296
631
  });
297
632
  };
298
- this.grantOneTimeAdminCapTx = (inputs) => {
633
+ /**
634
+ * @deprecated use grantOneTimeAdminCapTxV2 instead
635
+ * Creates a transaction to grant a one-time admin capability for a staking pool (original version)
636
+ * @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type
637
+ * @returns Transaction command to grant the one-time admin cap
638
+ */
639
+ this.grantOneTimeAdminCapTxV1 = (inputs) => {
299
640
  const { tx, ownerCapId } = inputs;
300
641
  return tx.moveCall({
301
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "grant_one_time_admin_cap"),
642
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "grant_one_time_admin_cap"),
302
643
  typeArguments: [inputs.rewardCoinType],
303
644
  arguments: [
304
645
  typeof ownerCapId === "string"
@@ -308,20 +649,74 @@ class FarmsApi {
308
649
  ],
309
650
  });
310
651
  };
652
+ /**
653
+ * Creates a transaction to grant a one-time admin capability for a staking pool
654
+ * @param inputs Grant parameters including transaction, owner cap ID, recipient address, and reward coin type
655
+ * @returns Transaction command to grant the one-time admin cap
656
+ */
657
+ this.grantOneTimeAdminCapTxV2 = (inputs) => {
658
+ const { tx, ownerCapId } = inputs;
659
+ return tx.moveCall({
660
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "grant_one_time_admin_cap"),
661
+ typeArguments: [inputs.rewardCoinType],
662
+ arguments: [
663
+ typeof ownerCapId === "string"
664
+ ? tx.object(ownerCapId)
665
+ : ownerCapId,
666
+ tx.object(this.addresses.objects.version),
667
+ tx.pure.address(inputs.recipientAddress),
668
+ ],
669
+ });
670
+ };
311
671
  // =========================================================================
312
672
  // Staking Pool Mutation Transaction Commands
313
673
  // =========================================================================
314
- this.initializeStakingPoolRewardTx = (inputs) => {
674
+ /**
675
+ * @deprecated use initializeStakingPoolRewardTxV2 instead
676
+ * Creates a transaction to initialize rewards for a staking pool (original version)
677
+ * @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type
678
+ * @returns Transaction command to initialize the reward
679
+ */
680
+ this.initializeStakingPoolRewardTxV1 = (inputs) => {
681
+ const { tx, rewardCoinId } = inputs;
682
+ const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
683
+ const capId = FarmsApi.farmCapId(inputs);
684
+ return tx.moveCall({
685
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, isOneTimeAdminCap
686
+ ? "initialize_reward_and_consume_admin_cap"
687
+ : "initialize_reward"),
688
+ typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
689
+ arguments: [
690
+ tx.object(capId),
691
+ tx.object(inputs.stakingPoolId),
692
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
693
+ typeof rewardCoinId === "string"
694
+ ? tx.object(rewardCoinId)
695
+ : rewardCoinId,
696
+ tx.pure.u64(inputs.emissionScheduleMs),
697
+ tx.pure.u64(inputs.emissionRate),
698
+ tx.pure.u64(inputs.emissionDelayTimestampMs),
699
+ ],
700
+ });
701
+ };
702
+ /**
703
+ * Creates a transaction to initialize rewards for a staking pool
704
+ * @param inputs Initialize reward parameters including transaction, pool ID, reward coin ID, emission parameters, stake coin type, and reward coin type
705
+ * @returns Transaction command to initialize the reward
706
+ */
707
+ this.initializeStakingPoolRewardTxV2 = (inputs) => {
315
708
  const { tx, rewardCoinId } = inputs;
709
+ const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
710
+ const capId = FarmsApi.farmCapId(inputs);
316
711
  return tx.moveCall({
317
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "initialize_reward" +
318
- (FarmsApi.isFarmOneTimeAdminCapId(inputs)
319
- ? "_and_consume_admin_cap"
320
- : "")),
712
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, isOneTimeAdminCap
713
+ ? "initialize_reward_and_consume_admin_cap"
714
+ : "initialize_reward"),
321
715
  typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
322
716
  arguments: [
323
- tx.object(FarmsApi.farmCapId(inputs)),
717
+ tx.object(capId),
324
718
  tx.object(inputs.stakingPoolId),
719
+ tx.object(this.addresses.objects.version),
325
720
  tx.object(sui_1.Sui.constants.addresses.suiClockId),
326
721
  typeof rewardCoinId === "string"
327
722
  ? tx.object(rewardCoinId)
@@ -332,45 +727,126 @@ class FarmsApi {
332
727
  ],
333
728
  });
334
729
  };
335
- this.topUpStakingPoolRewardTx = (inputs) => {
730
+ /**
731
+ * @deprecated use topUpStakingPoolRewardTxV2 instead
732
+ * Creates a transaction to add more rewards to a staking pool (original version)
733
+ * @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type
734
+ * @returns Transaction command to add rewards
735
+ */
736
+ this.topUpStakingPoolRewardTxV1 = (inputs) => {
737
+ const { tx, rewardCoinId } = inputs;
738
+ const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
739
+ const capId = FarmsApi.farmCapId(inputs);
740
+ return tx.moveCall({
741
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, isOneTimeAdminCap
742
+ ? "add_reward_and_consume_admin_cap"
743
+ : "add_reward"),
744
+ typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
745
+ arguments: [
746
+ tx.object(capId),
747
+ tx.object(inputs.stakingPoolId),
748
+ typeof rewardCoinId === "string"
749
+ ? tx.object(rewardCoinId)
750
+ : rewardCoinId, // Coin
751
+ ],
752
+ });
753
+ };
754
+ /**
755
+ * Creates a transaction to add more rewards to a staking pool
756
+ * @param inputs Top up parameters including transaction, pool ID, reward coin ID, stake coin type, and reward coin type
757
+ * @returns Transaction command to add rewards
758
+ */
759
+ this.topUpStakingPoolRewardTxV2 = (inputs) => {
336
760
  const { tx, rewardCoinId } = inputs;
761
+ const isOneTimeAdminCap = FarmsApi.isFarmOneTimeAdminCapId(inputs);
762
+ const capId = FarmsApi.farmCapId(inputs);
337
763
  return tx.moveCall({
338
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "add_reward" +
339
- (FarmsApi.isFarmOneTimeAdminCapId(inputs)
340
- ? "_and_consume_admin_cap"
341
- : "")),
764
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, isOneTimeAdminCap
765
+ ? "add_reward_and_consume_admin_cap"
766
+ : "add_reward"),
342
767
  typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
343
768
  arguments: [
344
- tx.object(FarmsApi.farmCapId(inputs)),
769
+ tx.object(capId),
345
770
  tx.object(inputs.stakingPoolId),
771
+ tx.object(this.addresses.objects.version),
346
772
  typeof rewardCoinId === "string"
347
773
  ? tx.object(rewardCoinId)
348
774
  : rewardCoinId, // Coin
349
775
  ],
350
776
  });
351
777
  };
352
- this.increaseStakingPoolRewardEmissionsTx = (inputs) => {
778
+ /**
779
+ * @deprecated use increaseStakingPoolRewardEmissionsTxV2 instead
780
+ * Creates a transaction to increase the emission rate for a staking pool reward (original version)
781
+ * @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type
782
+ * @returns Transaction command to update emissions
783
+ */
784
+ this.increaseStakingPoolRewardEmissionsTxV1 = (inputs) => {
785
+ const { tx } = inputs;
786
+ return tx.moveCall({
787
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "update_emissions_for"),
788
+ typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
789
+ arguments: [
790
+ tx.object(inputs.ownerCapId),
791
+ tx.object(inputs.stakingPoolId),
792
+ tx.object(sui_1.Sui.constants.addresses.suiClockId),
793
+ tx.pure.u64(inputs.emissionScheduleMs),
794
+ tx.pure.u64(inputs.emissionRate),
795
+ ],
796
+ });
797
+ };
798
+ /**
799
+ * Creates a transaction to increase the emission rate for a staking pool reward
800
+ * @param inputs Increase emissions parameters including transaction, owner cap ID, pool ID, emission parameters, stake coin type, and reward coin type
801
+ * @returns Transaction command to update emissions
802
+ */
803
+ this.increaseStakingPoolRewardEmissionsTxV2 = (inputs) => {
353
804
  const { tx } = inputs;
354
805
  return tx.moveCall({
355
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "update_emissions_for"),
806
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "update_emission_schedule"),
356
807
  typeArguments: [inputs.stakeCoinType, inputs.rewardCoinType],
357
808
  arguments: [
358
809
  tx.object(inputs.ownerCapId),
359
810
  tx.object(inputs.stakingPoolId),
811
+ tx.object(this.addresses.objects.version),
360
812
  tx.object(sui_1.Sui.constants.addresses.suiClockId),
361
813
  tx.pure.u64(inputs.emissionScheduleMs),
362
814
  tx.pure.u64(inputs.emissionRate),
363
815
  ],
364
816
  });
365
817
  };
366
- this.setStakingPoolMinStakeAmountTx = (inputs) => {
818
+ /**
819
+ * @deprecated use setStakingPoolMinStakeAmountTxV2 instead
820
+ * Creates a transaction to set the minimum stake amount for a staking pool (original version)
821
+ * @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type
822
+ * @returns Transaction command to set the minimum stake amount
823
+ */
824
+ this.setStakingPoolMinStakeAmountTxV1 = (inputs) => {
825
+ const { tx } = inputs;
826
+ return tx.moveCall({
827
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "set_min_stake_amount"),
828
+ typeArguments: [inputs.stakeCoinType],
829
+ arguments: [
830
+ tx.object(inputs.ownerCapId),
831
+ tx.object(inputs.stakingPoolId),
832
+ tx.pure.u64(inputs.minStakeAmount),
833
+ ],
834
+ });
835
+ };
836
+ /**
837
+ * Creates a transaction to set the minimum stake amount for a staking pool
838
+ * @param inputs Min stake amount parameters including transaction, owner cap ID, pool ID, minimum amount, and stake coin type
839
+ * @returns Transaction command to set the minimum stake amount
840
+ */
841
+ this.setStakingPoolMinStakeAmountTxV2 = (inputs) => {
367
842
  const { tx } = inputs;
368
843
  return tx.moveCall({
369
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "set_min_stake_amount"),
844
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaultsV2, FarmsApi.constants.moduleNames.vaultV2, "set_min_stake_amount"),
370
845
  typeArguments: [inputs.stakeCoinType],
371
846
  arguments: [
372
847
  tx.object(inputs.ownerCapId),
373
848
  tx.object(inputs.stakingPoolId),
849
+ tx.object(this.addresses.objects.version),
374
850
  tx.pure.u64(inputs.minStakeAmount),
375
851
  ],
376
852
  });
@@ -378,20 +854,30 @@ class FarmsApi {
378
854
  // =========================================================================
379
855
  // Staking Pool Inspection Transaction Commands
380
856
  // =========================================================================
381
- this.isVaultUnlockedTx = (inputs) => {
857
+ /**
858
+ * Creates a transaction to check if a staking pool is unlocked
859
+ * @param inputs Check parameters including transaction, pool ID, and coin type
860
+ * @returns Transaction object argument for the boolean result
861
+ */
862
+ this.isVaultUnlockedTxV1 = (inputs) => {
382
863
  const { tx } = inputs;
383
864
  return tx.moveCall({
384
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "is_vault_unlocked"),
865
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "is_vault_unlocked"),
385
866
  typeArguments: [inputs.stakeCoinType],
386
867
  arguments: [
387
868
  tx.object(inputs.stakingPoolId), // AfterburnerVault
388
869
  ],
389
870
  });
390
871
  };
391
- this.remainingRewardsTx = (inputs) => {
872
+ /**
873
+ * Creates a transaction to get the remaining rewards for a staking pool
874
+ * @param inputs Remaining rewards parameters including transaction, pool ID, and coin type
875
+ * @returns Transaction object argument for the vector of remaining rewards
876
+ */
877
+ this.remainingRewardsTxV1 = (inputs) => {
392
878
  const { tx } = inputs;
393
879
  return tx.moveCall({
394
- target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vault, "remaining_rewards"),
880
+ target: utils_1.Helpers.transactions.createTxTarget(this.addresses.packages.vaults, FarmsApi.constants.moduleNames.vaultV1, "remaining_rewards"),
395
881
  typeArguments: [inputs.stakeCoinType],
396
882
  arguments: [
397
883
  tx.object(inputs.stakingPoolId), // AfterburnerVault
@@ -404,7 +890,34 @@ class FarmsApi {
404
890
  // =========================================================================
405
891
  // Staking Transactions
406
892
  // =========================================================================
407
- this.fetchBuildStakeTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
893
+ /**
894
+ * @deprecated use fetchBuildStakeTxV2 instead
895
+ * Builds a complete transaction for staking coins
896
+ * @param inputs Staking parameters including wallet address, lock enforcement, stake amount, pool ID, lock duration, and coin type
897
+ * @returns Complete transaction ready for signing and execution
898
+ */
899
+ this.fetchBuildStakeTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
900
+ const { walletAddress, isSponsoredTx } = inputs;
901
+ const tx = new transactions_1.Transaction();
902
+ tx.setSender(walletAddress);
903
+ const stakeCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
904
+ tx,
905
+ walletAddress,
906
+ coinType: inputs.stakeCoinType,
907
+ coinAmount: inputs.stakeAmount,
908
+ isSponsoredTx,
909
+ });
910
+ const stakedPosition = this.stakeTxV1(Object.assign(Object.assign({}, inputs), { tx,
911
+ stakeCoinId }));
912
+ tx.transferObjects([stakedPosition], walletAddress);
913
+ return tx;
914
+ });
915
+ /**
916
+ * Builds a complete transaction for staking coins
917
+ * @param inputs Staking parameters including wallet address, lock enforcement, stake amount, pool ID, lock duration, and coin type
918
+ * @returns Complete transaction ready for signing and execution
919
+ */
920
+ this.fetchBuildStakeTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
408
921
  const { walletAddress, isSponsoredTx } = inputs;
409
922
  const tx = new transactions_1.Transaction();
410
923
  tx.setSender(walletAddress);
@@ -415,11 +928,18 @@ class FarmsApi {
415
928
  coinAmount: inputs.stakeAmount,
416
929
  isSponsoredTx,
417
930
  });
418
- const stakedPosition = this.stakeTx(Object.assign(Object.assign({}, inputs), { tx, stakeCoinId }));
931
+ const stakedPosition = this.stakeTxV2(Object.assign(Object.assign({}, inputs), { tx,
932
+ stakeCoinId, lockEnforcement: "Strict" }));
419
933
  tx.transferObjects([stakedPosition], walletAddress);
420
934
  return tx;
421
935
  });
422
- this.fetchBuildDepositPrincipalTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
936
+ /**
937
+ * @deprecated use fetchBuildDepositPrincipalTxV2 instead
938
+ * Builds a complete transaction for depositing additional principal to a staked position
939
+ * @param inputs Deposit parameters including wallet address, position ID, pool ID, deposit amount, and coin type
940
+ * @returns Complete transaction ready for signing and execution
941
+ */
942
+ this.fetchBuildDepositPrincipalTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
423
943
  const { walletAddress, isSponsoredTx } = inputs;
424
944
  const tx = new transactions_1.Transaction();
425
945
  tx.setSender(walletAddress);
@@ -430,24 +950,98 @@ class FarmsApi {
430
950
  coinAmount: inputs.depositAmount,
431
951
  isSponsoredTx,
432
952
  });
433
- this.depositPrincipalTx(Object.assign(Object.assign({}, inputs), { tx,
953
+ this.depositPrincipalTxV1(Object.assign(Object.assign({}, inputs), { tx,
434
954
  stakeCoinId }));
435
955
  return tx;
436
956
  });
437
- this.fetchBuildWithdrawPrincipalTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
957
+ /**
958
+ * Builds a complete transaction for depositing additional principal to a staked position
959
+ * @param inputs Deposit parameters including wallet address, position ID, pool ID, deposit amount, and coin type
960
+ * @returns Complete transaction ready for signing and execution
961
+ */
962
+ this.fetchBuildDepositPrincipalTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
963
+ const { walletAddress, isSponsoredTx } = inputs;
964
+ const tx = new transactions_1.Transaction();
965
+ tx.setSender(walletAddress);
966
+ const stakeCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
967
+ tx,
968
+ walletAddress,
969
+ coinType: inputs.stakeCoinType,
970
+ coinAmount: inputs.depositAmount,
971
+ isSponsoredTx,
972
+ });
973
+ this.depositPrincipalTxV2(Object.assign(Object.assign({}, inputs), { tx,
974
+ stakeCoinId }));
975
+ return tx;
976
+ });
977
+ /**
978
+ * @deprecated use fetchBuildWithdrawPrincipalTxV2 instead
979
+ * Builds a complete transaction for withdrawing principal from a staked position
980
+ * @param inputs Withdraw parameters including wallet address, position ID, pool ID, withdraw amount, and coin type
981
+ * @returns Complete transaction ready for signing and execution
982
+ */
983
+ this.fetchBuildWithdrawPrincipalTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
438
984
  const { walletAddress } = inputs;
439
985
  const tx = new transactions_1.Transaction();
440
986
  tx.setSender(walletAddress);
441
- const withdrawnCoin = this.withdrawPrincipalTx(Object.assign(Object.assign({}, inputs), { tx }));
987
+ const withdrawnCoin = this.withdrawPrincipalTxV1(Object.assign(Object.assign({}, inputs), { tx }));
988
+ tx.transferObjects([withdrawnCoin], walletAddress);
989
+ return tx;
990
+ });
991
+ /**
992
+ * Builds a complete transaction for withdrawing principal from a staked position
993
+ * @param inputs Withdraw parameters including wallet address, position ID, pool ID, withdraw amount, and coin type
994
+ * @returns Complete transaction ready for signing and execution
995
+ */
996
+ this.fetchBuildWithdrawPrincipalTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
997
+ const { walletAddress } = inputs;
998
+ const tx = new transactions_1.Transaction();
999
+ tx.setSender(walletAddress);
1000
+ const withdrawnCoin = this.withdrawPrincipalTxV2(Object.assign(Object.assign({}, inputs), { tx }));
1001
+ tx.transferObjects([withdrawnCoin], walletAddress);
1002
+ return tx;
1003
+ });
1004
+ /**
1005
+ * @deprecated use fetchBuildUnstakeTxV2 instead
1006
+ * Builds a complete transaction for unstaking (withdrawing and destroying a position)
1007
+ * @param inputs Unstake parameters including wallet address, position ID, pool ID, reward coin types, and coin type
1008
+ * @returns Complete transaction ready for signing and execution
1009
+ */
1010
+ this.fetchBuildUnstakeTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
1011
+ const { walletAddress } = inputs;
1012
+ let tx;
1013
+ if (inputs.rewardCoinTypes.length > 0) {
1014
+ // harvest rewards
1015
+ tx = yield this.fetchBuildHarvestRewardsTxV1(Object.assign(Object.assign({}, inputs), { stakedPositionIds: [inputs.stakedPositionId] }));
1016
+ }
1017
+ else {
1018
+ // no rewards to harvest
1019
+ tx = new transactions_1.Transaction();
1020
+ tx.setSender(walletAddress);
1021
+ }
1022
+ // withdraw principal
1023
+ const withdrawnCoin = this.withdrawPrincipalTxV1(Object.assign(Object.assign({}, inputs), { tx }));
442
1024
  tx.transferObjects([withdrawnCoin], walletAddress);
1025
+ // destroy position
1026
+ this.destroyStakedPositionTxV1({
1027
+ tx,
1028
+ stakingPoolId: inputs.stakingPoolId,
1029
+ stakedPositionId: inputs.stakedPositionId,
1030
+ stakeCoinType: inputs.stakeCoinType,
1031
+ });
443
1032
  return tx;
444
1033
  });
445
- this.fetchBuildUnstakeTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
1034
+ /**
1035
+ * Builds a complete transaction for unstaking (withdrawing and destroying a position)
1036
+ * @param inputs Unstake parameters including wallet address, position ID, pool ID, reward coin types, and coin type
1037
+ * @returns Complete transaction ready for signing and execution
1038
+ */
1039
+ this.fetchBuildUnstakeTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
446
1040
  const { walletAddress } = inputs;
447
1041
  let tx;
448
1042
  if (inputs.rewardCoinTypes.length > 0) {
449
1043
  // harvest rewards
450
- tx = yield this.fetchBuildHarvestRewardsTx(Object.assign(Object.assign({}, inputs), { stakedPositionIds: [inputs.stakedPositionId] }));
1044
+ tx = yield this.fetchBuildHarvestRewardsTxV2(Object.assign(Object.assign({}, inputs), { stakedPositionIds: [inputs.stakedPositionId] }));
451
1045
  }
452
1046
  else {
453
1047
  // no rewards to harvest
@@ -455,33 +1049,140 @@ class FarmsApi {
455
1049
  tx.setSender(walletAddress);
456
1050
  }
457
1051
  // withdraw principal
458
- const withdrawnCoin = this.withdrawPrincipalTx(Object.assign(Object.assign({}, inputs), { tx }));
1052
+ const withdrawnCoin = this.withdrawPrincipalTxV2(Object.assign(Object.assign({}, inputs), { tx }));
459
1053
  tx.transferObjects([withdrawnCoin], walletAddress);
460
1054
  // destroy position
461
- this.destroyStakedPositionTx(Object.assign(Object.assign({}, inputs), { tx }));
1055
+ this.destroyStakedPositionTxV2({
1056
+ tx,
1057
+ stakedPositionId: inputs.stakedPositionId,
1058
+ stakeCoinType: inputs.stakeCoinType,
1059
+ });
462
1060
  return tx;
463
1061
  });
464
- this.buildUpdatePositionTx = utils_1.Helpers.transactions.createBuildTxFunc(this.updatePositionTx);
1062
+ /**
1063
+ * @deprecated use buildUpdatePositionTxV2 instead
1064
+ * Builds a transaction for updating a staked position
1065
+ * @param parameters for updatePositionTx
1066
+ * @returns Complete transaction ready for signing and execution
1067
+ */
1068
+ this.buildUpdatePositionTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.updatePositionTxV1);
1069
+ /**
1070
+ * Builds a transaction for updating a staked position
1071
+ * @param parameters for updatePositionTx
1072
+ * @returns Complete transaction ready for signing and execution
1073
+ */
1074
+ this.buildUpdatePositionTx2 = utils_1.Helpers.transactions.createBuildTxFunc(this.updatePositionTxV2);
465
1075
  // =========================================================================
466
1076
  // Locking Transactions
467
1077
  // =========================================================================
468
- this.buildLockTx = utils_1.Helpers.transactions.createBuildTxFunc(this.lockTx);
469
- this.buildRenewLockTx = utils_1.Helpers.transactions.createBuildTxFunc(this.renewLockTx);
470
- this.buildUnlockTx = utils_1.Helpers.transactions.createBuildTxFunc(this.unlockTx);
1078
+ /**
1079
+ * @deprecated use buildLockTxV2 instead
1080
+ * Builds a transaction for locking a staked position
1081
+ * @param parameters for lockTx
1082
+ * @returns Complete transaction ready for signing and execution
1083
+ */
1084
+ this.buildLockTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.lockTxV1);
1085
+ /**
1086
+ * Builds a transaction for locking a staked position
1087
+ * @param parameters for lockTx
1088
+ * @returns Complete transaction ready for signing and execution
1089
+ */
1090
+ this.buildLockTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.lockTxV2);
1091
+ /**
1092
+ * @deprecated use buildRenewLockTxV2 instead
1093
+ * Builds a transaction for renewing the lock on a staked position
1094
+ * @param parameters for renewLockTx
1095
+ * @returns Complete transaction ready for signing and execution
1096
+ */
1097
+ this.buildRenewLockTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.renewLockTxV1);
1098
+ /**
1099
+ * Builds a transaction for renewing the lock on a staked position
1100
+ * @param parameters for renewLockTx
1101
+ * @returns Complete transaction ready for signing and execution
1102
+ */
1103
+ this.buildRenewLockTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.renewLockTxV2);
1104
+ /**
1105
+ * @deprecated use buildUnlockTxV2 instead
1106
+ * Builds a transaction for unlocking a staked position
1107
+ * @param parameters for unlockTx
1108
+ * @returns Complete transaction ready for signing and execution
1109
+ */
1110
+ this.buildUnlockTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.unlockTxV1);
1111
+ /**
1112
+ * Builds a transaction for unlocking a staked position
1113
+ * @param parameters for unlockTx
1114
+ * @returns Complete transaction ready for signing and execution
1115
+ */
1116
+ this.buildUnlockTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.unlockTxV2);
471
1117
  // =========================================================================
472
1118
  // Reward Harvesting Transactions
473
1119
  // =========================================================================
474
- this.fetchBuildHarvestRewardsTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
1120
+ /**
1121
+ * @deprecated use fetchBuildHarvestRewardsTxV2 instead
1122
+ * Builds a complete transaction for harvesting rewards from staked positions
1123
+ * @param inputs Harvest parameters including wallet address, position IDs, pool ID, reward coin types, and optional claim as AfSui flag
1124
+ * @returns Complete transaction ready for signing and execution
1125
+ */
1126
+ this.fetchBuildHarvestRewardsTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
475
1127
  const { walletAddress, stakedPositionIds } = inputs;
476
1128
  const tx = new transactions_1.Transaction();
477
1129
  tx.setSender(walletAddress);
478
- const harvestedRewardsEventMetadataId = this.beginHarvestTx(Object.assign(Object.assign({}, inputs), { tx }));
1130
+ const harvestRewardsCap = this.beginHarvestTxV1(Object.assign(Object.assign({}, inputs), { tx }));
479
1131
  let harvestedCoins = {};
480
1132
  for (const stakedPositionId of stakedPositionIds) {
481
1133
  for (const rewardCoinType of inputs.rewardCoinTypes) {
482
- const harvestedCoin = this.harvestRewardsTx(Object.assign(Object.assign({}, inputs), { tx,
1134
+ const harvestedCoin = this.harvestRewardsTxV1(Object.assign(Object.assign({}, inputs), { tx,
483
1135
  stakedPositionId,
484
- harvestedRewardsEventMetadataId,
1136
+ rewardCoinType, harvestedRewardsEventMetadataId: harvestRewardsCap }));
1137
+ if (rewardCoinType in harvestedCoins) {
1138
+ harvestedCoins[rewardCoinType].push(harvestedCoin);
1139
+ }
1140
+ else {
1141
+ harvestedCoins[rewardCoinType] = [harvestedCoin];
1142
+ }
1143
+ }
1144
+ }
1145
+ this.endHarvestTxV1({
1146
+ tx,
1147
+ harvestedRewardsEventMetadataId: harvestRewardsCap,
1148
+ });
1149
+ for (const [coinType, harvestedCoinIds] of Object.entries(harvestedCoins)) {
1150
+ const coinToTransfer = harvestedCoinIds[0];
1151
+ if (harvestedCoinIds.length > 1)
1152
+ tx.mergeCoins(coinToTransfer, harvestedCoinIds.slice(1));
1153
+ if (inputs.claimSuiAsAfSui && __1.Coin.isCoinObjectType(coinType)) {
1154
+ this.Provider.Staking().stakeTx({
1155
+ tx,
1156
+ suiCoin: coinToTransfer,
1157
+ withTransfer: true,
1158
+ validatorAddress: this.Provider.Staking().addresses.objects
1159
+ .aftermathValidator,
1160
+ });
1161
+ }
1162
+ else {
1163
+ tx.transferObjects([coinToTransfer], walletAddress);
1164
+ }
1165
+ }
1166
+ return tx;
1167
+ });
1168
+ /**
1169
+ * Builds a complete transaction for harvesting rewards from staked positions
1170
+ * @param inputs Harvest parameters including wallet address, position IDs, pool ID, reward coin types, and optional claim as AfSui flag
1171
+ * @returns Complete transaction ready for signing and execution
1172
+ */
1173
+ this.fetchBuildHarvestRewardsTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
1174
+ const { walletAddress, stakedPositionIds } = inputs;
1175
+ const tx = new transactions_1.Transaction();
1176
+ tx.setSender(walletAddress);
1177
+ // For the first position, begin harvest
1178
+ const firstPositionId = stakedPositionIds[0];
1179
+ const harvestRewardsCap = this.beginHarvestTxV2(Object.assign(Object.assign({}, inputs), { tx, stakedPositionId: firstPositionId }));
1180
+ let harvestedCoins = {};
1181
+ for (const stakedPositionId of stakedPositionIds) {
1182
+ for (const rewardCoinType of inputs.rewardCoinTypes) {
1183
+ const harvestedCoin = this.harvestRewardsTxV2(Object.assign(Object.assign({}, inputs), { tx,
1184
+ stakedPositionId,
1185
+ harvestRewardsCap,
485
1186
  rewardCoinType }));
486
1187
  if (rewardCoinType in harvestedCoins) {
487
1188
  harvestedCoins[rewardCoinType].push(harvestedCoin);
@@ -491,7 +1192,7 @@ class FarmsApi {
491
1192
  }
492
1193
  }
493
1194
  }
494
- this.endHarvestTx({ tx, harvestedRewardsEventMetadataId });
1195
+ this.endHarvestTxV2({ tx, harvestRewardsCap });
495
1196
  for (const [coinType, harvestedCoinIds] of Object.entries(harvestedCoins)) {
496
1197
  const coinToTransfer = harvestedCoinIds[0];
497
1198
  if (harvestedCoinIds.length > 1)
@@ -517,27 +1218,57 @@ class FarmsApi {
517
1218
  // =========================================================================
518
1219
  // Staking Pool Creation Transactions
519
1220
  // =========================================================================
520
- this.fetchBuildCreateStakingPoolTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
1221
+ /**
1222
+ * @deprecated use fetchBuildCreateStakingPoolTxV2 instead
1223
+ * Builds a complete transaction for creating a new staking pool
1224
+ * @param inputs Pool creation parameters including wallet address, lock enforcements, durations, multiplier, stake amount, and coin type
1225
+ * @returns Complete transaction ready for signing and execution
1226
+ */
1227
+ this.fetchBuildCreateStakingPoolTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
521
1228
  const { walletAddress } = inputs;
522
1229
  const tx = new transactions_1.Transaction();
523
1230
  tx.setSender(walletAddress);
524
- const [stakingPoolId, ownerCapId] = this.newStakingPoolTx(Object.assign(Object.assign({}, inputs), { tx }));
525
- this.shareStakingPoolTx({
1231
+ const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV1(Object.assign(Object.assign({}, inputs), { tx, lockEnforcement: "Strict" }));
1232
+ this.shareStakingPoolTxV1({
526
1233
  tx,
527
1234
  stakingPoolId,
528
1235
  stakeCoinType: inputs.stakeCoinType,
529
1236
  });
530
- this.transferOwnerCapTx({
1237
+ this.transferOwnerCapTxV1({
531
1238
  tx,
532
1239
  ownerCapId,
533
1240
  recipientAddress: walletAddress,
534
1241
  });
535
1242
  return tx;
536
1243
  });
1244
+ /**
1245
+ * Builds a complete transaction for creating a new staking pool
1246
+ * @param inputs Pool creation parameters including wallet address, lock enforcements, durations, multiplier, stake amount, and coin type
1247
+ * @returns Complete transaction ready for signing and execution
1248
+ */
1249
+ this.fetchBuildCreateStakingPoolTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
1250
+ const { walletAddress } = inputs;
1251
+ const tx = new transactions_1.Transaction();
1252
+ tx.setSender(walletAddress);
1253
+ const [stakingPoolId, ownerCapId] = this.newStakingPoolTxV2(Object.assign(Object.assign({}, inputs), { tx, lockEnforcements: ["Strict"] }));
1254
+ this.shareStakingPoolTxV2({
1255
+ tx,
1256
+ stakingPoolId,
1257
+ stakeCoinType: inputs.stakeCoinType,
1258
+ });
1259
+ tx.transferObjects([ownerCapId], walletAddress);
1260
+ return tx;
1261
+ });
537
1262
  // =========================================================================
538
1263
  // Staking Pool Mutation Transactions
539
1264
  // =========================================================================
540
- this.fetchBuildInitializeStakingPoolRewardTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
1265
+ /**
1266
+ * @deprecated use fetchBuildInitializeStakingPoolRewardTxV2 instead
1267
+ * Builds a complete transaction for initializing rewards for a staking pool
1268
+ * @param inputs Initialize rewards parameters including wallet address, owner cap ID, pool ID, reward amount, emission parameters, stake coin type, and reward coin type
1269
+ * @returns Complete transaction ready for signing and execution
1270
+ */
1271
+ this.fetchBuildInitializeStakingPoolRewardTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
541
1272
  const { walletAddress, isSponsoredTx } = inputs;
542
1273
  const tx = new transactions_1.Transaction();
543
1274
  tx.setSender(walletAddress);
@@ -548,10 +1279,35 @@ class FarmsApi {
548
1279
  coinAmount: inputs.rewardAmount,
549
1280
  isSponsoredTx,
550
1281
  });
551
- this.initializeStakingPoolRewardTx(Object.assign(Object.assign({}, inputs), { tx, rewardCoinId }));
1282
+ this.initializeStakingPoolRewardTxV1(Object.assign(Object.assign({}, inputs), { tx, rewardCoinId }));
552
1283
  return tx;
553
1284
  });
554
- this.fetchBuildTopUpStakingPoolRewardsTx = (inputs) => __awaiter(this, void 0, void 0, function* () {
1285
+ /**
1286
+ * Builds a complete transaction for initializing rewards for a staking pool
1287
+ * @param inputs Initialize rewards parameters including wallet address, owner cap ID, pool ID, reward amount, emission parameters, stake coin type, and reward coin type
1288
+ * @returns Complete transaction ready for signing and execution
1289
+ */
1290
+ this.fetchBuildInitializeStakingPoolRewardTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
1291
+ const { walletAddress, isSponsoredTx } = inputs;
1292
+ const tx = new transactions_1.Transaction();
1293
+ tx.setSender(walletAddress);
1294
+ const rewardCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
1295
+ tx,
1296
+ walletAddress,
1297
+ coinType: inputs.rewardCoinType,
1298
+ coinAmount: inputs.rewardAmount,
1299
+ isSponsoredTx,
1300
+ });
1301
+ this.initializeStakingPoolRewardTxV2(Object.assign(Object.assign({}, inputs), { tx, rewardCoinId }));
1302
+ return tx;
1303
+ });
1304
+ /**
1305
+ * @deprecated use fetchBuildTopUpStakingPoolRewardsTxV2 instead
1306
+ * Builds a complete transaction for adding more rewards to a staking pool
1307
+ * @param inputs Top up rewards parameters including wallet address, owner cap ID, pool ID, rewards array with amounts and coin types, and stake coin type
1308
+ * @returns Complete transaction ready for signing and execution
1309
+ */
1310
+ this.fetchBuildTopUpStakingPoolRewardsTxV1 = (inputs) => __awaiter(this, void 0, void 0, function* () {
555
1311
  const { walletAddress, isSponsoredTx } = inputs;
556
1312
  const tx = new transactions_1.Transaction();
557
1313
  tx.setSender(walletAddress);
@@ -563,22 +1319,88 @@ class FarmsApi {
563
1319
  coinAmount: reward.rewardAmount,
564
1320
  isSponsoredTx,
565
1321
  });
566
- this.topUpStakingPoolRewardTx(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx,
1322
+ this.topUpStakingPoolRewardTxV1(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx,
567
1323
  rewardCoinId }));
568
1324
  }
569
1325
  return tx;
570
1326
  });
571
- this.fetchIncreaseStakingPoolRewardsEmissionsTx = (inputs) => {
1327
+ /**
1328
+ * Builds a complete transaction for adding more rewards to a staking pool
1329
+ * @param inputs Top up rewards parameters including wallet address, owner cap ID, pool ID, rewards array with amounts and coin types, and stake coin type
1330
+ * @returns Complete transaction ready for signing and execution
1331
+ */
1332
+ this.fetchBuildTopUpStakingPoolRewardsTxV2 = (inputs) => __awaiter(this, void 0, void 0, function* () {
1333
+ const { walletAddress, isSponsoredTx } = inputs;
1334
+ const tx = new transactions_1.Transaction();
1335
+ tx.setSender(walletAddress);
1336
+ for (const reward of inputs.rewards) {
1337
+ const rewardCoinId = yield this.Provider.Coin().fetchCoinWithAmountTx({
1338
+ tx,
1339
+ walletAddress,
1340
+ coinType: reward.rewardCoinType,
1341
+ coinAmount: reward.rewardAmount,
1342
+ isSponsoredTx,
1343
+ });
1344
+ this.topUpStakingPoolRewardTxV2(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx,
1345
+ rewardCoinId }));
1346
+ }
1347
+ return tx;
1348
+ });
1349
+ /**
1350
+ * @deprecated use fetchIncreaseStakingPoolRewardsEmissionsTxV2 instead
1351
+ * Builds a complete transaction for increasing the emission rate of rewards for a staking pool
1352
+ * @param inputs Increase emissions parameters including wallet address, owner cap ID, pool ID, rewards array with emission parameters and coin types, and stake coin type
1353
+ * @returns Complete transaction ready for signing and execution
1354
+ */
1355
+ this.fetchIncreaseStakingPoolRewardsEmissionsTxV1 = (inputs) => {
572
1356
  const { walletAddress } = inputs;
573
1357
  const tx = new transactions_1.Transaction();
574
1358
  tx.setSender(walletAddress);
575
1359
  for (const reward of inputs.rewards) {
576
- this.increaseStakingPoolRewardEmissionsTx(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx }));
1360
+ this.increaseStakingPoolRewardEmissionsTxV1(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx }));
577
1361
  }
578
1362
  return tx;
579
1363
  };
580
- this.buildSetStakingPoolMinStakeAmountTx = utils_1.Helpers.transactions.createBuildTxFunc(this.setStakingPoolMinStakeAmountTx);
581
- this.buildGrantOneTimeAdminCapTx = utils_1.Helpers.transactions.createBuildTxFunc(this.grantOneTimeAdminCapTx);
1364
+ /**
1365
+ * Builds a complete transaction for increasing the emission rate of rewards for a staking pool
1366
+ * @param inputs Increase emissions parameters including wallet address, owner cap ID, pool ID, rewards array with emission parameters and coin types, and stake coin type
1367
+ * @returns Complete transaction ready for signing and execution
1368
+ */
1369
+ this.fetchIncreaseStakingPoolRewardsEmissionsTxV2 = (inputs) => {
1370
+ const { walletAddress } = inputs;
1371
+ const tx = new transactions_1.Transaction();
1372
+ tx.setSender(walletAddress);
1373
+ for (const reward of inputs.rewards) {
1374
+ this.increaseStakingPoolRewardEmissionsTxV2(Object.assign(Object.assign(Object.assign({}, inputs), reward), { tx }));
1375
+ }
1376
+ return tx;
1377
+ };
1378
+ /**
1379
+ * @deprecated use buildSetStakingPoolMinStakeAmountTxV2 instead
1380
+ * Builds a transaction for setting the minimum stake amount for a staking pool
1381
+ * @param parameters for setStakingPoolMinStakeAmountTx
1382
+ * @returns Complete transaction ready for signing and execution
1383
+ */
1384
+ this.buildSetStakingPoolMinStakeAmountTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.setStakingPoolMinStakeAmountTxV1);
1385
+ /**
1386
+ * Builds a transaction for setting the minimum stake amount for a staking pool
1387
+ * @param parameters for setStakingPoolMinStakeAmountTx
1388
+ * @returns Complete transaction ready for signing and execution
1389
+ */
1390
+ this.buildSetStakingPoolMinStakeAmountTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.setStakingPoolMinStakeAmountTxV2);
1391
+ /**
1392
+ * @deprecated use buildGrantOneTimeAdminCapTxV2 instead
1393
+ * Builds a transaction for granting a one-time admin capability for a staking pool
1394
+ * @param parameters for grantOneTimeAdminCapTx
1395
+ * @returns Complete transaction ready for signing and execution
1396
+ */
1397
+ this.buildGrantOneTimeAdminCapTxV1 = utils_1.Helpers.transactions.createBuildTxFunc(this.grantOneTimeAdminCapTxV1);
1398
+ /**
1399
+ * Builds a transaction for granting a one-time admin capability for a staking pool
1400
+ * @param parameters for grantOneTimeAdminCapTx
1401
+ * @returns Complete transaction ready for signing and execution
1402
+ */
1403
+ this.buildGrantOneTimeAdminCapTxV2 = utils_1.Helpers.transactions.createBuildTxFunc(this.grantOneTimeAdminCapTxV2);
582
1404
  // =========================================================================
583
1405
  // Private Methods
584
1406
  // =========================================================================
@@ -588,65 +1410,159 @@ class FarmsApi {
588
1410
  // =========================================================================
589
1411
  // Vault Creation
590
1412
  // =========================================================================
591
- this.createdVaultEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.createdVault);
1413
+ this.eventWrapperType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, "Event");
1414
+ /**
1415
+ * Creates the event type for vault creation events
1416
+ * @returns Fully qualified event type string
1417
+ */
1418
+ this.createdVaultEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1419
+ ? this.addresses.packages.vaultsInitial
1420
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.createdVault, version === 1 ? undefined : this.eventWrapperType());
592
1421
  // =========================================================================
593
1422
  // Vault Mutation
594
1423
  // =========================================================================
595
- this.initializedRewardEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.initializedReward);
596
- this.addedRewardEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.addedReward);
1424
+ /**
1425
+ * Creates the event type for reward initialization events
1426
+ * @returns Fully qualified event type string
1427
+ */
1428
+ this.initializedRewardEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1429
+ ? this.addresses.packages.vaultsInitial
1430
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.initializedReward, version === 1 ? undefined : this.eventWrapperType());
1431
+ /**
1432
+ * Creates the event type for reward addition events
1433
+ * @returns Fully qualified event type string
1434
+ */
1435
+ this.addedRewardEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1436
+ ? this.addresses.packages.vaultsInitial
1437
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.addedReward, version === 1 ? undefined : this.eventWrapperType());
1438
+ /**
1439
+ * Creates the event type for emission increase events
1440
+ * @returns Fully qualified event type string
1441
+ */
597
1442
  this.increasedEmissionsEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.increasedEmissions);
1443
+ /**
1444
+ * Creates the event type for emission update events
1445
+ * @returns Fully qualified event type string
1446
+ */
1447
+ this.updatedEmissionsEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.increasedEmissions, this.eventWrapperType());
598
1448
  // =========================================================================
599
1449
  // Staking Position Creation
600
1450
  // =========================================================================
601
- this.stakedEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.staked);
602
- this.stakedRelaxedEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.stakedRelaxed);
1451
+ /**
1452
+ * Creates the event type for strict staking events
1453
+ * @returns Fully qualified event type string
1454
+ */
1455
+ this.stakedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1456
+ ? this.addresses.packages.vaultsInitial
1457
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.staked, version === 1 ? undefined : this.eventWrapperType());
1458
+ /**
1459
+ * Creates the event type for relaxed staking events
1460
+ * @returns Fully qualified event type string
1461
+ */
1462
+ this.stakedRelaxedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1463
+ ? this.addresses.packages.vaultsInitial
1464
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.stakedRelaxed, version === 1 ? undefined : this.eventWrapperType());
603
1465
  // =========================================================================
604
1466
  // Staking Position Locking
605
1467
  // =========================================================================
606
- this.lockedEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.locked);
607
- this.unlockedEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.unlocked);
1468
+ /**
1469
+ * Creates the event type for position locking events
1470
+ * @returns Fully qualified event type string
1471
+ */
1472
+ this.lockedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1473
+ ? this.addresses.packages.vaultsInitial
1474
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.locked, version === 1 ? undefined : this.eventWrapperType());
1475
+ /**
1476
+ * Creates the event type for position unlocking events
1477
+ * @returns Fully qualified event type string
1478
+ */
1479
+ this.unlockedEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1480
+ ? this.addresses.packages.vaultsInitial
1481
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.unlocked, version === 1 ? undefined : this.eventWrapperType());
608
1482
  // =========================================================================
609
1483
  // Staking Position Staking
610
1484
  // =========================================================================
611
- this.depositedPrincipalEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.depositedPrincipal);
612
- this.withdrewPrincipalEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.withdrewPrincipal);
1485
+ /**
1486
+ * Creates the event type for principal deposit events
1487
+ * @returns Fully qualified event type string
1488
+ */
1489
+ this.depositedPrincipalEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1490
+ ? this.addresses.packages.vaultsInitial
1491
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.depositedPrincipal, version === 1 ? undefined : this.eventWrapperType());
1492
+ /**
1493
+ * Creates the event type for principal withdrawal events
1494
+ * @returns Fully qualified event type string
1495
+ */
1496
+ this.withdrewPrincipalEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1497
+ ? this.addresses.packages.vaultsInitial
1498
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.withdrewPrincipal, version === 1 ? undefined : this.eventWrapperType());
613
1499
  // =========================================================================
614
1500
  // Staking Position Reward Harvesting
615
1501
  // =========================================================================
616
- this.harvestedRewardsEventType = () => eventsApiHelpers_1.EventsApiHelpers.createEventType(this.addresses.packages.vaultsInitial, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.harvestedRewards);
1502
+ /**
1503
+ * Creates the event type for reward harvesting events
1504
+ * @returns Fully qualified event type string
1505
+ */
1506
+ this.harvestedRewardsEventType = (version) => eventsApiHelpers_1.EventsApiHelpers.createEventType(version === 1
1507
+ ? this.addresses.packages.vaultsInitial
1508
+ : this.addresses.packages.eventsV2, FarmsApi.constants.moduleNames.events, FarmsApi.constants.eventNames.harvestedRewards, version === 1 ? undefined : this.eventWrapperType());
617
1509
  const addresses = this.Provider.addresses.farms;
618
1510
  if (!addresses)
619
1511
  throw new Error("not all required addresses have been set in provider");
620
1512
  this.addresses = addresses;
621
1513
  this.objectTypes = {
622
- stakedPosition: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.stakedPosition}::StakedPosition`,
623
- stakingPoolOwnerCap: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vault}::OwnerCap`,
624
- stakingPoolOneTimeAdminCap: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vault}::OneTimeAdminCap`,
1514
+ stakedPositionV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.stakedPosition}::StakedPosition`,
1515
+ stakingPoolOwnerCapV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vaultV1}::OwnerCap`,
1516
+ stakingPoolOneTimeAdminCapV1: `${addresses.packages.vaultsInitial}::${FarmsApi.constants.moduleNames.vaultV1}::OneTimeAdminCap`,
1517
+ stakedPositionV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.stakedPosition}::StakedPosition`,
1518
+ stakingPoolOwnerCapV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::AuthorityCap<${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::VAULT<${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.authority}::ADMIN>>`,
1519
+ // NOTE: will this work with `<phantom Role, phantom Reward>` ?
1520
+ stakingPoolOneTimeAdminCapV2: `${addresses.packages.eventsV2}::${FarmsApi.constants.moduleNames.vaultV2}::OneTime`,
625
1521
  };
626
1522
  this.eventTypes = {
1523
+ // v1
1524
+ // staking pools
1525
+ // creation
1526
+ createdVaultV1: this.createdVaultEventType(1),
1527
+ // mutation
1528
+ initializedRewardV1: this.initializedRewardEventType(1),
1529
+ addedRewardV1: this.addedRewardEventType(1),
1530
+ increasedEmissionsV1: this.increasedEmissionsEventType(),
1531
+ // staking positions
1532
+ // creation
1533
+ stakedV1: this.stakedEventType(1),
1534
+ stakedRelaxedV1: this.stakedRelaxedEventType(1),
1535
+ // locking
1536
+ lockedV1: this.lockedEventType(1),
1537
+ unlockedV1: this.unlockedEventType(1),
1538
+ // staking
1539
+ depositedPrincipalV1: this.depositedPrincipalEventType(1),
1540
+ withdrewPrincipalV1: this.withdrewPrincipalEventType(1),
1541
+ // reward harvesting
1542
+ harvestedRewardsV1: this.harvestedRewardsEventType(1),
1543
+ // v2
627
1544
  // staking pools
628
1545
  // creation
629
- createdVault: this.createdVaultEventType(),
1546
+ createdVaultV2: this.createdVaultEventType(2),
630
1547
  // mutation
631
- initializedReward: this.initializedRewardEventType(),
632
- addedReward: this.addedRewardEventType(),
633
- increasedEmissions: this.increasedEmissionsEventType(),
1548
+ initializedRewardV2: this.initializedRewardEventType(2),
1549
+ addedRewardV2: this.addedRewardEventType(2),
1550
+ updatedEmissionsV2: this.updatedEmissionsEventType(),
634
1551
  // staking positions
635
1552
  // creation
636
- staked: this.stakedEventType(),
637
- stakedRelaxed: this.stakedRelaxedEventType(),
1553
+ stakedV2: this.stakedEventType(2),
638
1554
  // locking
639
- locked: this.lockedEventType(),
640
- unlocked: this.unlockedEventType(),
1555
+ lockedV2: this.lockedEventType(2),
1556
+ unlockedV2: this.unlockedEventType(2),
641
1557
  // staking
642
- depositedPrincipal: this.depositedPrincipalEventType(),
643
- withdrewPrincipal: this.withdrewPrincipalEventType(),
1558
+ depositedPrincipalV2: this.depositedPrincipalEventType(2),
1559
+ withdrewPrincipalV2: this.withdrewPrincipalEventType(2),
644
1560
  // reward harvesting
645
- harvestedRewards: this.harvestedRewardsEventType(),
1561
+ harvestedRewardsV2: this.harvestedRewardsEventType(2),
646
1562
  };
647
1563
  this.moveErrors = {
648
1564
  [this.addresses.packages.vaults]: {
649
- [FarmsApi.constants.moduleNames.vault]: {
1565
+ [FarmsApi.constants.moduleNames.vaultV1]: {
650
1566
  /// A user attempts provides a `Coin` or `u64` with value zero.
651
1567
  0: "Zero",
652
1568
  /// A user provides a `StakedPosition` and a `AfterburnerVault` that don't correspond with one
@@ -701,6 +1617,60 @@ class FarmsApi {
701
1617
  10: "Zero Rewards",
702
1618
  },
703
1619
  },
1620
+ [this.addresses.packages.vaultsV2]: {
1621
+ [FarmsApi.constants.moduleNames.vaultV2]: {
1622
+ /// A user provides a `Coin` with value zero.
1623
+ 0: "Zero",
1624
+ /// A user tries to create a `Vault` where `min_lock_duration_ms` is strictly greater than
1625
+ /// `max_lock_duration_ms`.
1626
+ 1: "Invalid Min Max Lock Durations",
1627
+ /// A user tries to create a `Vault` and provides a `u8` that does not map to a valid lock
1628
+ /// enforcement policy.
1629
+ 2: "Invalid Lock Enforcement",
1630
+ /// The creator of a `Vault` tries to update the emission schedule or add more of a specific
1631
+ /// reward type that has not yet been initialized into the `Vault`.
1632
+ 3: "Emissions Not Initialized",
1633
+ /// A `Reward` `Coin` type was passed to a function and either the `Reward` type does not
1634
+ /// correspond to any of the `Vault`'s reward types--for the functions that act on the `Reward`
1635
+ /// type--or, for `initialize_reward`, the `Reward` type has already had its emissions initialized.
1636
+ 4: "Invalid Reward Coin Type",
1637
+ /// A user attempts to withdraw an amount of principal that would bring their position below the
1638
+ /// `Vault`'s `min_stake_amount`.
1639
+ 5: "Invalid Stake Amount",
1640
+ /// A user tries to claim zero rewards
1641
+ 6: "Zero Claim",
1642
+ /// A user provided a max lock multiplier that was strictly less than the minimum lower bound.
1643
+ 7: "Invalid Lock Multiplier",
1644
+ },
1645
+ [FarmsApi.constants.moduleNames.stakedPosition]: {
1646
+ /// A user attempts to perform a restricted action on a `StakedPosition` that is still locked. For
1647
+ /// example `unlock` can only be called on a `StakedPosition` that is no longer locked.
1648
+ 0: "Locked",
1649
+ /// A user provides a `StakedPosition` and a `Vault` that don't correspond with one another.
1650
+ /// This can only occur if two `Vault`s with the same underlying `Stake` generic are created.
1651
+ 1: "Invalid Vault",
1652
+ /// A user tries to stake into a `Vault` with a `lock_duration_ms` below the vault's
1653
+ /// `min_lock_duration_ms`.
1654
+ 2: "Invalid Lock Duration",
1655
+ /// A user attempts to withdraw an amount of principal that would bring their position below the
1656
+ /// `Vault`'s `min_stake_amount`.
1657
+ 3: "Invalid Stake Amount",
1658
+ /// A user attempts to withdraw more principal than their `StakedPosition` holds.
1659
+ 4: "Invalid Withdraw Amount",
1660
+ /// A user attempts to split more principal than their `StakedPosition` holds.
1661
+ 5: "Invalid Split Amount",
1662
+ /// A user attempts to stake into a `Vault` that has no rewards.
1663
+ 6: "Vault Is Inactive",
1664
+ /// A user requested to harvest a reward type for which they've only accrued less than the minimal
1665
+ /// claim amount.
1666
+ 7: "Zero Rewards",
1667
+ /// A user attempts to stake into a `Vault` with a `LockEnforcement` policy that the vault does
1668
+ /// not support.
1669
+ 8: "Invalid Lock Enforcement",
1670
+ /// A user attempts to call `destroy` on a `StakedPosition` that has unharvested rewards.
1671
+ 9: "Position Has Unclaimed Rewards",
1672
+ },
1673
+ },
704
1674
  };
705
1675
  }
706
1676
  }
@@ -710,10 +1680,12 @@ exports.FarmsApi = FarmsApi;
710
1680
  // =========================================================================
711
1681
  FarmsApi.constants = {
712
1682
  moduleNames: {
713
- vault: "afterburner_vault",
1683
+ vaultV1: "afterburner_vault",
1684
+ vaultV2: "vault",
714
1685
  stakedPosition: "staked_position",
715
1686
  vaultRegistry: "vault_registry",
716
- events: "vents",
1687
+ events: "events",
1688
+ authority: "authority",
717
1689
  },
718
1690
  eventNames: {
719
1691
  // staking pools
@@ -723,6 +1695,7 @@ FarmsApi.constants = {
723
1695
  initializedReward: "InitializedRewardEvent",
724
1696
  addedReward: "AddedRewardEvent",
725
1697
  increasedEmissions: "IncreasedEmissionsEvent",
1698
+ updatedEmissions: "UpdatedEmissionsEvent",
726
1699
  // staking positions
727
1700
  // creation
728
1701
  staked: "StakedEvent",
@@ -748,6 +1721,15 @@ FarmsApi.constants = {
748
1721
  // =========================================================================
749
1722
  // Helpers
750
1723
  // =========================================================================
751
- FarmsApi.isFarmOwnerCapId = (inputs) => "ownerCapId" in inputs;
1724
+ /**
1725
+ * Checks if the input contains a one-time admin cap ID
1726
+ * @param inputs FarmOwnerOrOneTimeAdminCap object
1727
+ * @returns True if the input contains a one-time admin cap ID
1728
+ */
752
1729
  FarmsApi.isFarmOneTimeAdminCapId = (inputs) => "oneTimeAdminCapId" in inputs;
1730
+ /**
1731
+ * Gets the appropriate cap ID from the input
1732
+ * @param inputs FarmOwnerOrOneTimeAdminCap object
1733
+ * @returns Either the owner cap ID or one-time admin cap ID
1734
+ */
753
1735
  FarmsApi.farmCapId = (inputs) => "ownerCapId" in inputs ? inputs.ownerCapId : inputs.oneTimeAdminCapId;