@ember-finance/sdk 2.21.0-ccip.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/src/abis/index.d.ts +1 -3
  2. package/dist/src/abis/index.js +1 -4
  3. package/dist/src/api/v2/models/account-transaction-transaction-data.d.ts +1 -2
  4. package/dist/src/api/v2/models/account-transaction.d.ts +0 -2
  5. package/dist/src/api/v2/models/account-transaction.js +1 -3
  6. package/dist/src/api/v2/models/chain.d.ts +0 -6
  7. package/dist/src/api/v2/models/evm-contracts.d.ts +0 -9
  8. package/dist/src/api/v2/models/evm-oftadapter.d.ts +0 -11
  9. package/dist/src/api/v2/models/evm-oftadapter.js +1 -4
  10. package/dist/src/api/v2/models/evm-oftpeer.d.ts +0 -12
  11. package/dist/src/api/v2/models/index.d.ts +0 -4
  12. package/dist/src/api/v2/models/index.js +0 -4
  13. package/dist/src/evm-vaults/interfaces/index.d.ts +0 -39
  14. package/dist/src/evm-vaults/on-chain-calls/tx-builder.d.ts +1 -15
  15. package/dist/src/evm-vaults/on-chain-calls/tx-builder.js +0 -36
  16. package/dist/src/evm-vaults/on-chain-calls/user.d.ts +1 -40
  17. package/dist/src/evm-vaults/on-chain-calls/user.js +0 -75
  18. package/dist/src/evm-vaults/on-chain-calls/vault-reader.d.ts +1 -14
  19. package/dist/src/evm-vaults/on-chain-calls/vault-reader.js +0 -30
  20. package/dist/src/evm-vaults/utils/deployment-parser.d.ts +1 -46
  21. package/dist/src/evm-vaults/utils/deployment-parser.js +0 -74
  22. package/dist/src/evm-vaults/utils/index.d.ts +0 -1
  23. package/dist/src/evm-vaults/utils/index.js +0 -1
  24. package/dist/src/sui-vaults/on-chain-calls/operator.d.ts +10 -64
  25. package/dist/src/sui-vaults/on-chain-calls/operator.js +22 -92
  26. package/dist/src/sui-vaults/on-chain-calls/protocol-config-reader.d.ts +8 -0
  27. package/dist/src/sui-vaults/on-chain-calls/protocol-config-reader.js +10 -0
  28. package/dist/src/sui-vaults/on-chain-calls/tx-builder.d.ts +7 -120
  29. package/dist/src/sui-vaults/on-chain-calls/tx-builder.js +32 -357
  30. package/dist/src/sui-vaults/on-chain-calls/user.d.ts +0 -58
  31. package/dist/src/sui-vaults/on-chain-calls/user.js +3 -96
  32. package/dist/src/sui-vaults/on-chain-calls/vault-admin.d.ts +0 -21
  33. package/dist/src/sui-vaults/on-chain-calls/vault-admin.js +0 -32
  34. package/package.json +1 -1
  35. package/dist/src/abis/CcipRouter.json +0 -58
  36. package/dist/src/api/v2/models/bridge-transaction.d.ts +0 -50
  37. package/dist/src/api/v2/models/bridge-transaction.js +0 -14
  38. package/dist/src/api/v2/models/evm-ccip-lane.d.ts +0 -73
  39. package/dist/src/api/v2/models/evm-ccip-lane.js +0 -14
  40. package/dist/src/api/v2/models/evm-ccip-rate-limits.d.ts +0 -36
  41. package/dist/src/api/v2/models/evm-ccip-rate-limits.js +0 -14
  42. package/dist/src/api/v2/models/evm-ccip-token-pool.d.ts +0 -122
  43. package/dist/src/api/v2/models/evm-ccip-token-pool.js +0 -17
  44. package/dist/src/evm-vaults/utils/ccip.d.ts +0 -23
  45. package/dist/src/evm-vaults/utils/ccip.js +0 -32
@@ -206,78 +206,4 @@ export class EVMDeploymentParser {
206
206
  }
207
207
  return entry;
208
208
  }
209
- /**
210
- * Finds the CCIP token pool entry for a given vault address.
211
- * @param vaultAddress The vault address (receipt token address in EVM deployment data)
212
- */
213
- getCcipTokenPoolByVaultAddress(vaultAddress) {
214
- return Object.values(this.deployment.contracts?.ccipTokenPools ?? {}).find(pool => pool.vaultAddress?.toLowerCase() === vaultAddress.toLowerCase());
215
- }
216
- /**
217
- * Reports which bridge a vault uses, or undefined if it has none.
218
- *
219
- * A vault has exactly one active bridge, but different vaults use different
220
- * ones, so call this before choosing between the LayerZero and CCIP send
221
- * methods rather than assuming either.
222
- *
223
- * @param vaultAddress The vault address (receipt token address in EVM deployment data)
224
- */
225
- getBridgeTransportByVaultAddress(vaultAddress) {
226
- if (this.getCcipTokenPoolByVaultAddress(vaultAddress))
227
- return "CCIP";
228
- if (this.getOFTAdapterObjectByVaultAddress(vaultAddress))
229
- return "LayerZero";
230
- return undefined;
231
- }
232
- /**
233
- * Lists the networks a vault can bridge to, whichever transport it uses.
234
- *
235
- * Returns an empty array for a vault with no bridge, so it is safe to render
236
- * directly. Names are as the deployment records them, which is what
237
- * bridgeSendTokenViaCcip takes as its destination.
238
- *
239
- * @param vaultAddress The vault address (receipt token address in EVM deployment data)
240
- */
241
- getBridgeDestinationsByVaultAddress(vaultAddress) {
242
- // Both transports record the far end the same way, under remoteNetwork,
243
- // but one keys its map by CCIP chain selector and the other by LayerZero
244
- // endpoint id — neither of which a caller has any way to resolve. Reading
245
- // the values rather than the keys is what keeps the two symmetric.
246
- const pool = this.getCcipTokenPoolByVaultAddress(vaultAddress);
247
- const adapter = this.getOFTAdapterObjectByVaultAddress(vaultAddress);
248
- const networks = [
249
- ...Object.values(pool?.lanes ?? {}),
250
- ...Object.values(adapter?.peers ?? {})
251
- ]
252
- .map(entry => entry.remoteNetwork)
253
- .filter((network) => !!network);
254
- return [...new Set(networks)];
255
- }
256
- /**
257
- * Finds the configured CCIP lane from a vault to a destination chain selector.
258
- *
259
- * A missing lane means the route is not configured and a send would revert.
260
- *
261
- * @param vaultAddress The vault address on the source chain
262
- * @param remoteChainSelector The destination CCIP chain selector
263
- */
264
- getCcipLaneByVaultAndSelector(vaultAddress, remoteChainSelector) {
265
- // Lanes are keyed by selector, so this is a direct hit rather than the
266
- // scan the by-network lookup has to do.
267
- return this.getCcipTokenPoolByVaultAddress(vaultAddress)?.lanes?.[remoteChainSelector];
268
- }
269
- /**
270
- * Finds the configured CCIP lane from a vault to a destination network.
271
- *
272
- * Lanes are keyed by the destination's CCIP chain selector, which nothing
273
- * outside CCIP knows, so this looks the lane up by network name instead.
274
- * A missing lane means the route is not configured — sending would revert.
275
- *
276
- * @param vaultAddress The vault address on the source chain
277
- * @param destinationNetwork The destination network name, e.g. "atlantic"
278
- */
279
- getCcipLaneByVaultAndNetwork(vaultAddress, destinationNetwork) {
280
- const pool = this.getCcipTokenPoolByVaultAddress(vaultAddress);
281
- return Object.values(pool?.lanes ?? {}).find(lane => lane.remoteNetwork?.toLowerCase() === destinationNetwork.toLowerCase());
282
- }
283
209
  }
@@ -1,3 +1,2 @@
1
1
  export * from "./deployment-parser.js";
2
2
  export * from "./permit-utils.js";
3
- export * from "./ccip.js";
@@ -1,3 +1,2 @@
1
1
  export * from "./deployment-parser.js";
2
2
  export * from "./permit-utils.js";
3
- export * from "./ccip.js";
@@ -6,12 +6,21 @@ import { NumStr } from "@firefly-exchange/library-sui";
6
6
  export declare class OperatorCalls extends OnChainCalls {
7
7
  constructor(_network: string, _suiClient: SuiClient, _deployment: ISuiDeployment, _signer?: Signer, _walletAddress?: string);
8
8
  /**
9
- * Collect platform fee from a vault
9
+ * Collect platform fee from a vault, through whichever entry the protocol's
10
+ * current version accepts: `collect_platform_fee_v2` from VERSION 6, the
11
+ * legacy `collect_platform_fee` before it.
10
12
  * @param vaultId The id of the vault to collect platform fee from
11
13
  * @param options Optional tx execution params
12
14
  * @returns OnChainCallResponse
13
15
  */
14
16
  collectPlatformFee(vaultId: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
17
+ /**
18
+ * Collect platform fee from a vault via `collect_platform_fee_v2` (VERSION 6+)
19
+ * @param vaultId The id of the vault to collect platform fee from
20
+ * @param options Optional tx execution params
21
+ * @returns OnChainCallResponse
22
+ */
23
+ collectPlatformFeeV2(vaultId: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
15
24
  /**
16
25
  * Charge platform fee from a vault
17
26
  * @param vaultId The id of the vault to charge platform fee from
@@ -197,19 +206,6 @@ export declare class OperatorCalls extends OnChainCalls {
197
206
  * @returns OnChainCallResponse
198
207
  */
199
208
  atomicWithdrawSuilendSecondaryCollateralSui(vaultId: string, poolCoinType: string, lendingMarketId: string, subAccount: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
200
- /**
201
- * Collect accrued AlphaLend rewards into an allowlisted sub-account. Call
202
- * once per reward type BEFORE exiting the strategy — the exit burns the
203
- * PositionCap and strands anything uncollected. Requires an AlphaLend Pyth
204
- * price refresh earlier in the same PTB. `rewardType` must not be SUI.
205
- * @param vaultId The id of the atomic vault
206
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
207
- * @param rewardType Coin type of the reward being collected
208
- * @param subAccount Allowlisted sub-account to receive the reward
209
- * @param options Optional tx execution params
210
- * @returns OnChainCallResponse
211
- */
212
- atomicCollectAlphalendStrategyReward(vaultId: string, lendingProtocolId: string, rewardType: string, subAccount: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
213
209
  /**
214
210
  * Supply collateral from an atomic vault into the Suilend strategy
215
211
  * @param vaultId The id of the atomic vault
@@ -220,15 +216,6 @@ export declare class OperatorCalls extends OnChainCalls {
220
216
  * @returns OnChainCallResponse
221
217
  */
222
218
  atomicSupplyToSuilendStrategy(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
223
- /**
224
- * Supply collateral from an atomic vault into the AlphaLend strategy
225
- * @param vaultId The id of the atomic vault
226
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
227
- * @param amount The amount to supply
228
- * @param options Optional tx execution params
229
- * @returns OnChainCallResponse
230
- */
231
- atomicSupplyToAlphalendStrategy(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
232
219
  /**
233
220
  * Withdraw collateral from the Suilend strategy back into an atomic vault
234
221
  * @param vaultId The id of the atomic vault
@@ -239,15 +226,6 @@ export declare class OperatorCalls extends OnChainCalls {
239
226
  * @returns OnChainCallResponse
240
227
  */
241
228
  atomicWithdrawFromSuilendStrategy(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
242
- /**
243
- * Withdraw collateral from the AlphaLend strategy back into an atomic vault
244
- * @param vaultId The id of the atomic vault
245
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
246
- * @param amount The amount to withdraw
247
- * @param options Optional tx execution params
248
- * @returns OnChainCallResponse
249
- */
250
- atomicWithdrawFromAlphalendStrategy(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
251
229
  /**
252
230
  * Supply collateral from an atomic vault to one of its sub accounts
253
231
  * @param vaultId The id of the atomic vault
@@ -322,16 +300,6 @@ export declare class OperatorCalls extends OnChainCalls {
322
300
  * @returns OnChainCallResponse
323
301
  */
324
302
  atomicSetStrategyNoneFromSuilendSui(vaultId: string, poolCoinType: string, lendingMarketId: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
325
- /**
326
- * Exits the AlphaLend strategy on a SUI-collateral vault
327
- * @param vaultId Id of the atomic vault (collateral must be SUI)
328
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
329
- * @param acceptResidual Abandon a dust residual rather than aborting the
330
- * exit. Only pass true deliberately: the residual is forfeited.
331
- * @param options Optional tx execution params
332
- * @returns OnChainCallResponse
333
- */
334
- atomicSetStrategyNoneFromAlphalendSui(vaultId: string, lendingProtocolId: string, acceptResidual: boolean, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
335
303
  /**
336
304
  * Withdraws collateral from the Suilend strategy on a SUI-collateral vault
337
305
  * @param vaultId Id of the atomic vault (collateral must be SUI)
@@ -342,26 +310,4 @@ export declare class OperatorCalls extends OnChainCalls {
342
310
  * @returns OnChainCallResponse
343
311
  */
344
312
  atomicWithdrawFromSuilendStrategySui(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
345
- /**
346
- * Withdraws collateral from the AlphaLend strategy on a SUI-collateral vault
347
- * @param vaultId Id of the atomic vault (collateral must be SUI)
348
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
349
- * @param amount Amount of collateral to withdraw, in base units
350
- * @param options Optional tx execution params
351
- * @returns OnChainCallResponse
352
- */
353
- atomicWithdrawFromAlphalendStrategySui(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
354
- /**
355
- * Collects accrued AlphaLend rewards through the SUI system state and
356
- * forwards them to an allowlisted sub-account.
357
- *
358
- * Call before exiting the strategy — the exit burns the `PositionCap` and
359
- * strands anything uncollected.
360
- * @param vaultId Id of the atomic vault
361
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
362
- * @param subAccount Allowlisted sub-account to receive the rewards
363
- * @param options Optional tx execution params
364
- * @returns OnChainCallResponse
365
- */
366
- atomicCollectAlphalendStrategyRewardSui(vaultId: string, lendingProtocolId: string, subAccount: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
367
313
  }
@@ -1,19 +1,39 @@
1
1
  import { OnChainCalls } from "./onchain-calls.js";
2
2
  import { TransactionBlock } from "@firefly-exchange/library-sui";
3
3
  import { CoinUtils } from "@firefly-exchange/library-sui";
4
+ import { SuiProtocolConfigReader, usesCollectPlatformFeeV2 } from "./protocol-config-reader.js";
4
5
  export class OperatorCalls extends OnChainCalls {
5
6
  constructor(_network, _suiClient, _deployment, _signer, _walletAddress) {
6
7
  super(_network, _suiClient, _deployment, _signer, _walletAddress);
7
8
  }
8
9
  /**
9
- * Collect platform fee from a vault
10
+ * Collect platform fee from a vault, through whichever entry the protocol's
11
+ * current version accepts: `collect_platform_fee_v2` from VERSION 6, the
12
+ * legacy `collect_platform_fee` before it.
10
13
  * @param vaultId The id of the vault to collect platform fee from
11
14
  * @param options Optional tx execution params
12
15
  * @returns OnChainCallResponse
13
16
  */
14
17
  async collectPlatformFee(vaultId, options) {
18
+ const { version } = await new SuiProtocolConfigReader(this.suiClient, this.parser.getProtocolConfig()).getProtocolConfigState();
15
19
  const txb = options?.txBlock || new TransactionBlock();
16
- this.txBuilder.collectPlatformFee(vaultId, { ...options, txBlock: txb });
20
+ if (usesCollectPlatformFeeV2(version)) {
21
+ this.txBuilder.collectPlatformFeeV2(vaultId, { ...options, txBlock: txb });
22
+ }
23
+ else {
24
+ this.txBuilder.collectPlatformFee(vaultId, { ...options, txBlock: txb });
25
+ }
26
+ return this.execCall(txb, options);
27
+ }
28
+ /**
29
+ * Collect platform fee from a vault via `collect_platform_fee_v2` (VERSION 6+)
30
+ * @param vaultId The id of the vault to collect platform fee from
31
+ * @param options Optional tx execution params
32
+ * @returns OnChainCallResponse
33
+ */
34
+ async collectPlatformFeeV2(vaultId, options) {
35
+ const txb = options?.txBlock || new TransactionBlock();
36
+ this.txBuilder.collectPlatformFeeV2(vaultId, { ...options, txBlock: txb });
17
37
  return this.execCall(txb, options);
18
38
  }
19
39
  /**
@@ -323,23 +343,6 @@ export class OperatorCalls extends OnChainCalls {
323
343
  this.txBuilder.atomicWithdrawSuilendSecondaryCollateralSui(vaultId, poolCoinType, lendingMarketId, subAccount, { ...options, txBlock: txb });
324
344
  return this.execCall(txb, options);
325
345
  }
326
- /**
327
- * Collect accrued AlphaLend rewards into an allowlisted sub-account. Call
328
- * once per reward type BEFORE exiting the strategy — the exit burns the
329
- * PositionCap and strands anything uncollected. Requires an AlphaLend Pyth
330
- * price refresh earlier in the same PTB. `rewardType` must not be SUI.
331
- * @param vaultId The id of the atomic vault
332
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
333
- * @param rewardType Coin type of the reward being collected
334
- * @param subAccount Allowlisted sub-account to receive the reward
335
- * @param options Optional tx execution params
336
- * @returns OnChainCallResponse
337
- */
338
- async atomicCollectAlphalendStrategyReward(vaultId, lendingProtocolId, rewardType, subAccount, options) {
339
- const txb = options?.txBlock || new TransactionBlock();
340
- this.txBuilder.atomicCollectAlphalendStrategyReward(vaultId, lendingProtocolId, rewardType, subAccount, { ...options, txBlock: txb });
341
- return this.execCall(txb, options);
342
- }
343
346
  /**
344
347
  * Supply collateral from an atomic vault into the Suilend strategy
345
348
  * @param vaultId The id of the atomic vault
@@ -354,22 +357,6 @@ export class OperatorCalls extends OnChainCalls {
354
357
  this.txBuilder.atomicSupplyToSuilendStrategy(vaultId, poolCoinType, lendingMarketId, amount, { ...options, txBlock: txb });
355
358
  return this.execCall(txb, options);
356
359
  }
357
- /**
358
- * Supply collateral from an atomic vault into the AlphaLend strategy
359
- * @param vaultId The id of the atomic vault
360
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
361
- * @param amount The amount to supply
362
- * @param options Optional tx execution params
363
- * @returns OnChainCallResponse
364
- */
365
- async atomicSupplyToAlphalendStrategy(vaultId, lendingProtocolId, amount, options) {
366
- const txb = options?.txBlock || new TransactionBlock();
367
- this.txBuilder.atomicSupplyToAlphalendStrategy(vaultId, lendingProtocolId, amount, {
368
- ...options,
369
- txBlock: txb
370
- });
371
- return this.execCall(txb, options);
372
- }
373
360
  /**
374
361
  * Withdraw collateral from the Suilend strategy back into an atomic vault
375
362
  * @param vaultId The id of the atomic vault
@@ -384,19 +371,6 @@ export class OperatorCalls extends OnChainCalls {
384
371
  this.txBuilder.atomicWithdrawFromSuilendStrategy(vaultId, poolCoinType, lendingMarketId, amount, { ...options, txBlock: txb });
385
372
  return this.execCall(txb, options);
386
373
  }
387
- /**
388
- * Withdraw collateral from the AlphaLend strategy back into an atomic vault
389
- * @param vaultId The id of the atomic vault
390
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
391
- * @param amount The amount to withdraw
392
- * @param options Optional tx execution params
393
- * @returns OnChainCallResponse
394
- */
395
- async atomicWithdrawFromAlphalendStrategy(vaultId, lendingProtocolId, amount, options) {
396
- const txb = options?.txBlock || new TransactionBlock();
397
- this.txBuilder.atomicWithdrawFromAlphalendStrategy(vaultId, lendingProtocolId, amount, { ...options, txBlock: txb });
398
- return this.execCall(txb, options);
399
- }
400
374
  /**
401
375
  * Supply collateral from an atomic vault to one of its sub accounts
402
376
  * @param vaultId The id of the atomic vault
@@ -522,20 +496,6 @@ export class OperatorCalls extends OnChainCalls {
522
496
  this.txBuilder.atomicSetStrategyNoneFromSuilendSui(vaultId, poolCoinType, lendingMarketId, { ...options, txBlock: txb });
523
497
  return this.execCall(txb, options);
524
498
  }
525
- /**
526
- * Exits the AlphaLend strategy on a SUI-collateral vault
527
- * @param vaultId Id of the atomic vault (collateral must be SUI)
528
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
529
- * @param acceptResidual Abandon a dust residual rather than aborting the
530
- * exit. Only pass true deliberately: the residual is forfeited.
531
- * @param options Optional tx execution params
532
- * @returns OnChainCallResponse
533
- */
534
- async atomicSetStrategyNoneFromAlphalendSui(vaultId, lendingProtocolId, acceptResidual, options) {
535
- const txb = options?.txBlock || new TransactionBlock();
536
- this.txBuilder.atomicSetStrategyNoneFromAlphalendSui(vaultId, lendingProtocolId, acceptResidual, { ...options, txBlock: txb });
537
- return this.execCall(txb, options);
538
- }
539
499
  /**
540
500
  * Withdraws collateral from the Suilend strategy on a SUI-collateral vault
541
501
  * @param vaultId Id of the atomic vault (collateral must be SUI)
@@ -550,34 +510,4 @@ export class OperatorCalls extends OnChainCalls {
550
510
  this.txBuilder.atomicWithdrawFromSuilendStrategySui(vaultId, poolCoinType, lendingMarketId, amount, { ...options, txBlock: txb });
551
511
  return this.execCall(txb, options);
552
512
  }
553
- /**
554
- * Withdraws collateral from the AlphaLend strategy on a SUI-collateral vault
555
- * @param vaultId Id of the atomic vault (collateral must be SUI)
556
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
557
- * @param amount Amount of collateral to withdraw, in base units
558
- * @param options Optional tx execution params
559
- * @returns OnChainCallResponse
560
- */
561
- async atomicWithdrawFromAlphalendStrategySui(vaultId, lendingProtocolId, amount, options) {
562
- const txb = options?.txBlock || new TransactionBlock();
563
- this.txBuilder.atomicWithdrawFromAlphalendStrategySui(vaultId, lendingProtocolId, amount, { ...options, txBlock: txb });
564
- return this.execCall(txb, options);
565
- }
566
- /**
567
- * Collects accrued AlphaLend rewards through the SUI system state and
568
- * forwards them to an allowlisted sub-account.
569
- *
570
- * Call before exiting the strategy — the exit burns the `PositionCap` and
571
- * strands anything uncollected.
572
- * @param vaultId Id of the atomic vault
573
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
574
- * @param subAccount Allowlisted sub-account to receive the rewards
575
- * @param options Optional tx execution params
576
- * @returns OnChainCallResponse
577
- */
578
- async atomicCollectAlphalendStrategyRewardSui(vaultId, lendingProtocolId, subAccount, options) {
579
- const txb = options?.txBlock || new TransactionBlock();
580
- this.txBuilder.atomicCollectAlphalendStrategyRewardSui(vaultId, lendingProtocolId, subAccount, { ...options, txBlock: txb });
581
- return this.execCall(txb, options);
582
- }
583
513
  }
@@ -2,6 +2,14 @@ import { BaseClient as SuiClient } from "@mysten/sui/client";
2
2
  import { IProtocolConfigState } from "../interfaces/index.js";
3
3
  /** The protocol's sentinel for "no guardian". */
4
4
  export declare const SUI_ZERO_ADDRESS: string;
5
+ /** First ProtocolConfig.version whose package aborts `collect_platform_fee`. */
6
+ export declare const SUI_COLLECT_PLATFORM_FEE_V2_VERSION = 6;
7
+ /**
8
+ * Whether platform fees must be collected through `collect_platform_fee_v2`.
9
+ * @param protocolVersion ProtocolConfig.version
10
+ * @returns True from VERSION 6 on
11
+ */
12
+ export declare function usesCollectPlatformFeeV2(protocolVersion: string | number): boolean;
5
13
  export declare class SuiProtocolConfigReader {
6
14
  suiClient: SuiClient;
7
15
  protocolConfigId: string;
@@ -4,6 +4,16 @@ import { normalizeSuiAddress } from "@mysten/sui/utils";
4
4
  const GUARDIAN_FIELD_KEY = "guardian";
5
5
  /** The protocol's sentinel for "no guardian". */
6
6
  export const SUI_ZERO_ADDRESS = normalizeSuiAddress("0x0");
7
+ /** First ProtocolConfig.version whose package aborts `collect_platform_fee`. */
8
+ export const SUI_COLLECT_PLATFORM_FEE_V2_VERSION = 6;
9
+ /**
10
+ * Whether platform fees must be collected through `collect_platform_fee_v2`.
11
+ * @param protocolVersion ProtocolConfig.version
12
+ * @returns True from VERSION 6 on
13
+ */
14
+ export function usesCollectPlatformFeeV2(protocolVersion) {
15
+ return Number(protocolVersion) >= SUI_COLLECT_PLATFORM_FEE_V2_VERSION;
16
+ }
7
17
  /** gRPC flattens Move structs; JSON-RPC keeps a `fields` wrapper. */
8
18
  const unwrapMoveFields = (value) => value?.fields ?? value;
9
19
  export class SuiProtocolConfigReader {
@@ -353,6 +353,13 @@ export declare class TxBuilder {
353
353
  * @returns TransactionBlock
354
354
  */
355
355
  collectPlatformFee(vaultId: string, options?: ITxBuilderOptionalParams): TransactionBlock;
356
+ /**
357
+ * Collect platform fee (package VERSION 6+, where `collect_platform_fee` aborts)
358
+ * @param vaultId Id of the vault
359
+ * @param options Optional tx building params
360
+ * @returns TransactionBlock
361
+ */
362
+ collectPlatformFeeV2(vaultId: string, options?: ITxBuilderOptionalParams): TransactionBlock;
356
363
  /**
357
364
  * Deposit asset
358
365
  * @param vaultId Id of the vault
@@ -615,15 +622,6 @@ export declare class TxBuilder {
615
622
  * @returns TransactionBlock
616
623
  */
617
624
  atomicSetStrategyNoneFromSuilend(vaultId: string, poolCoinType: string, lendingMarketId: string, options?: ITxBuilderOptionalParams): TransactionBlock;
618
- /**
619
- * Switches an atomic vault from the AlphaLend strategy to STRATEGY_NONE,
620
- * draining the full position collateral back into the vault balance.
621
- * @param vaultId Id of the atomic vault
622
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
623
- * @param options Optional tx building params
624
- * @returns TransactionBlock
625
- */
626
- atomicSetStrategyNoneFromAlphalend(vaultId: string, lendingProtocolId: string, acceptResidual: boolean, options?: ITxBuilderOptionalParams): TransactionBlock;
627
625
  /**
628
626
  * Step 1 of 2 for Suilend activation: commits the reserve index, the market
629
627
  * object and the collateral type. Step 2 is `atomicOpenSuilendObligation`,
@@ -724,34 +722,6 @@ export declare class TxBuilder {
724
722
  * @returns TransactionBlock
725
723
  */
726
724
  atomicWithdrawSuilendSecondaryCollateralSui(vaultId: string, poolCoinType: string, lendingMarketId: string, subAccount: string, options?: ITxBuilderOptionalParams): TransactionBlock;
727
- /**
728
- * Collects accrued AlphaLend rewards of coin type `rewardType` and forwards
729
- * them to an allowlisted sub-account.
730
- *
731
- * Call once per reward type BEFORE exiting the strategy — the exit burns
732
- * the `PositionCap` and strands anything uncollected. `rewardType` must not
733
- * be SUI; AlphaLend settles SUI through the staking system and needs the
734
- * monomorphic variant, which this SDK does not yet expose.
735
- *
736
- * PTB REQUIREMENT: refresh AlphaLend Pyth prices for the active market
737
- * earlier in the same transaction.
738
- * @param vaultId Id of the atomic vault
739
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
740
- * @param rewardType Coin type of the reward being collected
741
- * @param subAccount Allowlisted sub-account to receive the reward
742
- * @param options Optional tx building params
743
- * @returns TransactionBlock
744
- */
745
- atomicCollectAlphalendStrategyReward(vaultId: string, lendingProtocolId: string, rewardType: string, subAccount: string, options?: ITxBuilderOptionalParams): TransactionBlock;
746
- /**
747
- * Sets the AlphaLend strategy for an atomic vault
748
- * @param vaultId Id of the atomic vault
749
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
750
- * @param marketId AlphaLend market id
751
- * @param options Optional tx building params
752
- * @returns TransactionBlock
753
- */
754
- atomicSetStrategyAlphalend(vaultId: string, lendingProtocolId: string, marketId: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
755
725
  /**
756
726
  * Sets / unsets a blacklisted account on an atomic vault
757
727
  * @param vaultId Id of the atomic vault
@@ -822,15 +792,6 @@ export declare class TxBuilder {
822
792
  * @returns TransactionBlock
823
793
  */
824
794
  atomicSupplyToSuilendStrategy(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
825
- /**
826
- * Supplies collateral from an atomic vault into the AlphaLend strategy
827
- * @param vaultId Id of the atomic vault
828
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
829
- * @param amount Amount to supply
830
- * @param options Optional tx building params
831
- * @returns TransactionBlock
832
- */
833
- atomicSupplyToAlphalendStrategy(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
834
795
  /**
835
796
  * Withdraws collateral from the Suilend strategy back into an atomic vault
836
797
  * @param vaultId Id of the atomic vault
@@ -841,15 +802,6 @@ export declare class TxBuilder {
841
802
  * @returns TransactionBlock
842
803
  */
843
804
  atomicWithdrawFromSuilendStrategy(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
844
- /**
845
- * Withdraws collateral from the AlphaLend strategy back into an atomic vault
846
- * @param vaultId Id of the atomic vault
847
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
848
- * @param amount Amount to withdraw
849
- * @param options Optional tx building params
850
- * @returns TransactionBlock
851
- */
852
- atomicWithdrawFromAlphalendStrategy(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
853
805
  /**
854
806
  * Releases users' holdback for an ember share source vault
855
807
  * @param vaultId Id of the atomic vault
@@ -943,16 +895,6 @@ export declare class TxBuilder {
943
895
  * @returns TransactionBlock
944
896
  */
945
897
  atomicInstantWithdrawWithSuilend(vaultId: string, poolCoinType: string, lendingMarketId: string, shares: NumStr, receiver: string | null | undefined, options?: ITxBuilderOptionalParams): TransactionBlock;
946
- /**
947
- * Performs an instant withdraw from an atomic vault routed through AlphaLend
948
- * @param vaultId Id of the atomic vault
949
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
950
- * @param shares Number of shares to withdraw
951
- * @param receiver Optional receiver address (defaults on-chain to the sender)
952
- * @param options Optional tx building params
953
- * @returns TransactionBlock
954
- */
955
- atomicInstantWithdrawWithAlphalend(vaultId: string, lendingProtocolId: string, shares: NumStr, receiver: string | null | undefined, options?: ITxBuilderOptionalParams): TransactionBlock;
956
898
  /**
957
899
  * Swaps ember shares (Coin<R>) into an atomic vault, minting atomic shares
958
900
  * @param vaultId Id of the atomic vault
@@ -990,25 +932,6 @@ export declare class TxBuilder {
990
932
  * @returns TransactionBlock
991
933
  */
992
934
  atomicSwapEmberSharesWithSuilend(vaultId: string, sourceReceiptType: string, poolCoinType: string, sourceVaultId: string, lendingMarketId: string, shareCoinId: string, receiver: string | null | undefined, minNetOut: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
993
- /**
994
- * Swaps ember shares (Coin<R>) into an atomic vault, routing collateral
995
- * through the AlphaLend strategy
996
- * @param vaultId Id of the atomic vault
997
- * @param sourceReceiptType Receipt coin type of the source vault (R)
998
- * @param sourceVaultId Object id of the source Vault<T, R>
999
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
1000
- * @param shareCoinId Object id of the Coin<R> to swap
1001
- * @param receiver Optional receiver address (defaults on-chain to the sender)
1002
- * @param minNetOut Minimum collateral to receive, in base units. The swap
1003
- * aborts below it. This is the A-9 slippage guard: the payout is
1004
- * gross - fee - holdback, and both the fee multiplier (which moves with
1005
- * utilization) and the source rate can change between quoting and
1006
- * landing. Pass the value from `previewSwapInstantWithdraw`; 0 disables
1007
- * the guard entirely.
1008
- * @param options Optional tx building params
1009
- * @returns TransactionBlock
1010
- */
1011
- atomicSwapEmberSharesWithAlphalend(vaultId: string, sourceReceiptType: string, sourceVaultId: string, lendingProtocolId: string, shareCoinId: string, receiver: string | null | undefined, minNetOut: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
1012
935
  /**
1013
936
  * Swaps ember shares into a SUI-collateral atomic vault, sourcing payout
1014
937
  * liquidity from Suilend.
@@ -1026,50 +949,14 @@ export declare class TxBuilder {
1026
949
  * @returns TransactionBlock
1027
950
  */
1028
951
  atomicSwapEmberSharesWithSuilendSui(vaultId: string, sourceReceiptType: string, poolCoinType: string, sourceVaultId: string, lendingMarketId: string, shareCoinId: string, receiver: string, minNetOut: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
1029
- /**
1030
- * Swaps ember shares into a SUI-collateral atomic vault, sourcing payout
1031
- * liquidity from AlphaLend.
1032
- * @param vaultId Id of the atomic vault (collateral must be SUI)
1033
- * @param sourceReceiptType Receipt coin type of the source vault (R)
1034
- * @param sourceVaultId Object id of the source Vault<SUI, R>
1035
- * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
1036
- * @param shareCoinId Object id of the Coin<R> to swap
1037
- * @param receiver Optional receiver address (defaults on-chain to the sender)
1038
- * @param minNetOut Minimum collateral to receive, in base units (A-9 guard)
1039
- * @param options Optional tx building params
1040
- * @returns TransactionBlock
1041
- */
1042
- atomicSwapEmberSharesWithAlphalendSui(vaultId: string, sourceReceiptType: string, sourceVaultId: string, lendingProtocolId: string, shareCoinId: string, receiver: string | null | undefined, minNetOut: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
1043
952
  /**
1044
953
  * Instant withdraw from a SUI-collateral atomic vault, pulling liquidity
1045
954
  * from Suilend.
1046
955
  * @param receiver Payout recipient. REQUIRED — bare address on chain.
1047
956
  */
1048
957
  atomicInstantWithdrawWithSuilendSui(vaultId: string, poolCoinType: string, lendingMarketId: string, shares: NumStr, receiver: string, options?: ITxBuilderOptionalParams): TransactionBlock;
1049
- /**
1050
- * Instant withdraw from a SUI-collateral atomic vault, pulling liquidity
1051
- * from AlphaLend.
1052
- * @param receiver Optional receiver address (defaults on-chain to the sender)
1053
- */
1054
- atomicInstantWithdrawWithAlphalendSui(vaultId: string, lendingProtocolId: string, shares: NumStr, receiver: string | null | undefined, options?: ITxBuilderOptionalParams): TransactionBlock;
1055
958
  /** Exits the Suilend strategy on a SUI-collateral vault (operator). */
1056
959
  atomicSetStrategyNoneFromSuilendSui(vaultId: string, poolCoinType: string, lendingMarketId: string, options?: ITxBuilderOptionalParams): TransactionBlock;
1057
- /**
1058
- * Exits the AlphaLend strategy on a SUI-collateral vault (operator).
1059
- * @param acceptResidual Abandon a dust residual rather than aborting the exit
1060
- */
1061
- atomicSetStrategyNoneFromAlphalendSui(vaultId: string, lendingProtocolId: string, acceptResidual: boolean, options?: ITxBuilderOptionalParams): TransactionBlock;
1062
960
  /** Withdraws from the Suilend strategy on a SUI-collateral vault (operator). */
1063
961
  atomicWithdrawFromSuilendStrategySui(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
1064
- /** Withdraws from the AlphaLend strategy on a SUI-collateral vault (operator). */
1065
- atomicWithdrawFromAlphalendStrategySui(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
1066
- /**
1067
- * Collects AlphaLend rewards through the SUI system state and forwards them
1068
- * to an allowlisted sub-account (operator).
1069
- *
1070
- * Unlike the other `_sui` entrypoints this one is still generic in `T` — it
1071
- * is the reward path, not the collateral path, so the vault's own collateral
1072
- * type is still a type argument.
1073
- */
1074
- atomicCollectAlphalendStrategyRewardSui(vaultId: string, lendingProtocolId: string, subAccount: string, options?: ITxBuilderOptionalParams): TransactionBlock;
1075
962
  }