@gearbox-protocol/sdk 14.12.0-next.20 → 14.12.0-next.21

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.
@@ -783,10 +783,16 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
783
783
  async previewDelayedWithdrawal({
784
784
  creditAccount,
785
785
  amount,
786
- token
786
+ token,
787
+ intent
787
788
  }) {
788
789
  const compressor = this.sdk.withdrawalCompressor();
789
- return compressor.getWithdrawalRequestResult(creditAccount, token, amount);
790
+ return compressor.getWithdrawalRequestResult(
791
+ creditAccount,
792
+ token,
793
+ amount,
794
+ intent
795
+ );
790
796
  }
791
797
  /**
792
798
  * {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
@@ -802,17 +808,12 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
802
808
  };
803
809
  }
804
810
  /**
805
- * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
811
+ * {@inheritDoc ICreditAccountsService.assembleStartDelayedWithdrawalCalls}
806
812
  **/
807
- async startDelayedWithdrawal({
808
- creditAccount,
809
- minQuota,
810
- averageQuota,
813
+ assembleStartDelayedWithdrawalCalls({
814
+ creditFacade,
811
815
  preview
812
816
  }) {
813
- const cm = this.sdk.marketRegister.findCreditManager(
814
- creditAccount.creditManager
815
- );
816
817
  const record = preview.outputs.reduce((acc, o) => {
817
818
  const token = o.token.toLowerCase();
818
819
  acc[token] = (acc[token] || 0n) + o.amount;
@@ -820,7 +821,7 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
820
821
  }, {});
821
822
  const balances = Object.entries(record).filter(([, a]) => a > 10n);
822
823
  const storeExpectedBalances = {
823
- target: cm.creditFacade.address,
824
+ target: creditFacade,
824
825
  callData: (0, import_viem.encodeFunctionData)({
825
826
  abi: import_generated.iCreditFacadeMulticallV310Abi,
826
827
  functionName: "storeExpectedBalances",
@@ -833,18 +834,33 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
833
834
  })
834
835
  };
835
836
  const compareBalances = {
836
- target: cm.creditFacade.address,
837
+ target: creditFacade,
837
838
  callData: (0, import_viem.encodeFunctionData)({
838
839
  abi: import_generated.iCreditFacadeMulticallV310Abi,
839
840
  functionName: "compareBalances",
840
841
  args: []
841
842
  })
842
843
  };
844
+ return [storeExpectedBalances, ...preview.requestCalls, compareBalances];
845
+ }
846
+ /**
847
+ * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
848
+ **/
849
+ async startDelayedWithdrawal({
850
+ creditAccount,
851
+ minQuota,
852
+ averageQuota,
853
+ preview
854
+ }) {
855
+ const cm = this.sdk.marketRegister.findCreditManager(
856
+ creditAccount.creditManager
857
+ );
843
858
  const operationCalls = [
844
- storeExpectedBalances,
845
- ...preview.requestCalls,
846
- compareBalances,
847
- ...this.#prepareUpdateQuotas(creditAccount.creditFacade, {
859
+ ...this.assembleStartDelayedWithdrawalCalls({
860
+ creditFacade: cm.creditFacade.address,
861
+ preview
862
+ }),
863
+ ...this.#prepareUpdateQuotas(cm.creditFacade.address, {
848
864
  minQuota,
849
865
  averageQuota
850
866
  })
@@ -900,7 +916,7 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
900
916
  args: []
901
917
  })
902
918
  };
903
- const quotaCalls = zeroDebt ? [] : this.#prepareUpdateQuotas(creditAccount.creditFacade, {
919
+ const quotaCalls = zeroDebt ? [] : this.#prepareUpdateQuotas(cm.creditFacade.address, {
904
920
  minQuota,
905
921
  averageQuota
906
922
  });
@@ -1263,13 +1279,13 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
1263
1279
  const operationCalls = [
1264
1280
  ...assetsToWithdraw.map(
1265
1281
  (a) => this.#prepareWithdrawToken(
1266
- creditAccount.creditFacade,
1282
+ cm.creditFacade.address,
1267
1283
  a.token,
1268
1284
  a.balance,
1269
1285
  to
1270
1286
  )
1271
1287
  ),
1272
- ...this.#prepareUpdateQuotas(creditAccount.creditFacade, {
1288
+ ...this.#prepareUpdateQuotas(cm.creditFacade.address, {
1273
1289
  minQuota,
1274
1290
  averageQuota
1275
1291
  })
@@ -779,10 +779,16 @@ class CreditAccountsServiceV310 extends SDKConstruct {
779
779
  async previewDelayedWithdrawal({
780
780
  creditAccount,
781
781
  amount,
782
- token
782
+ token,
783
+ intent
783
784
  }) {
784
785
  const compressor = this.sdk.withdrawalCompressor();
785
- return compressor.getWithdrawalRequestResult(creditAccount, token, amount);
786
+ return compressor.getWithdrawalRequestResult(
787
+ creditAccount,
788
+ token,
789
+ amount,
790
+ intent
791
+ );
786
792
  }
787
793
  /**
788
794
  * {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
@@ -798,17 +804,12 @@ class CreditAccountsServiceV310 extends SDKConstruct {
798
804
  };
799
805
  }
800
806
  /**
801
- * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
807
+ * {@inheritDoc ICreditAccountsService.assembleStartDelayedWithdrawalCalls}
802
808
  **/
803
- async startDelayedWithdrawal({
804
- creditAccount,
805
- minQuota,
806
- averageQuota,
809
+ assembleStartDelayedWithdrawalCalls({
810
+ creditFacade,
807
811
  preview
808
812
  }) {
809
- const cm = this.sdk.marketRegister.findCreditManager(
810
- creditAccount.creditManager
811
- );
812
813
  const record = preview.outputs.reduce((acc, o) => {
813
814
  const token = o.token.toLowerCase();
814
815
  acc[token] = (acc[token] || 0n) + o.amount;
@@ -816,7 +817,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
816
817
  }, {});
817
818
  const balances = Object.entries(record).filter(([, a]) => a > 10n);
818
819
  const storeExpectedBalances = {
819
- target: cm.creditFacade.address,
820
+ target: creditFacade,
820
821
  callData: encodeFunctionData({
821
822
  abi: iCreditFacadeMulticallV310Abi,
822
823
  functionName: "storeExpectedBalances",
@@ -829,18 +830,33 @@ class CreditAccountsServiceV310 extends SDKConstruct {
829
830
  })
830
831
  };
831
832
  const compareBalances = {
832
- target: cm.creditFacade.address,
833
+ target: creditFacade,
833
834
  callData: encodeFunctionData({
834
835
  abi: iCreditFacadeMulticallV310Abi,
835
836
  functionName: "compareBalances",
836
837
  args: []
837
838
  })
838
839
  };
840
+ return [storeExpectedBalances, ...preview.requestCalls, compareBalances];
841
+ }
842
+ /**
843
+ * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
844
+ **/
845
+ async startDelayedWithdrawal({
846
+ creditAccount,
847
+ minQuota,
848
+ averageQuota,
849
+ preview
850
+ }) {
851
+ const cm = this.sdk.marketRegister.findCreditManager(
852
+ creditAccount.creditManager
853
+ );
839
854
  const operationCalls = [
840
- storeExpectedBalances,
841
- ...preview.requestCalls,
842
- compareBalances,
843
- ...this.#prepareUpdateQuotas(creditAccount.creditFacade, {
855
+ ...this.assembleStartDelayedWithdrawalCalls({
856
+ creditFacade: cm.creditFacade.address,
857
+ preview
858
+ }),
859
+ ...this.#prepareUpdateQuotas(cm.creditFacade.address, {
844
860
  minQuota,
845
861
  averageQuota
846
862
  })
@@ -896,7 +912,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
896
912
  args: []
897
913
  })
898
914
  };
899
- const quotaCalls = zeroDebt ? [] : this.#prepareUpdateQuotas(creditAccount.creditFacade, {
915
+ const quotaCalls = zeroDebt ? [] : this.#prepareUpdateQuotas(cm.creditFacade.address, {
900
916
  minQuota,
901
917
  averageQuota
902
918
  });
@@ -1259,13 +1275,13 @@ class CreditAccountsServiceV310 extends SDKConstruct {
1259
1275
  const operationCalls = [
1260
1276
  ...assetsToWithdraw.map(
1261
1277
  (a) => this.#prepareWithdrawToken(
1262
- creditAccount.creditFacade,
1278
+ cm.creditFacade.address,
1263
1279
  a.token,
1264
1280
  a.balance,
1265
1281
  to
1266
1282
  )
1267
1283
  ),
1268
- ...this.#prepareUpdateQuotas(creditAccount.creditFacade, {
1284
+ ...this.#prepareUpdateQuotas(cm.creditFacade.address, {
1269
1285
  minQuota,
1270
1286
  averageQuota
1271
1287
  })
@@ -6,7 +6,7 @@ import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
6
6
  import type { OnchainSDK } from "../OnchainSDK.js";
7
7
  import type { RouterCASlice } from "../router/index.js";
8
8
  import type { MultiCall, RawTx } from "../types/index.js";
9
- import type { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
9
+ import type { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
10
10
  import type { RequestableWithdrawal } from "./withdrawal-compressor/index.js";
11
11
  /**
12
12
  * Options for configuring the credit account service.
@@ -94,11 +94,15 @@ export declare class CreditAccountsServiceV310 extends SDKConstruct implements I
94
94
  /**
95
95
  * {@inheritDoc ICreditAccountsService.previewDelayedWithdrawal}
96
96
  **/
97
- previewDelayedWithdrawal({ creditAccount, amount, token, }: PreviewDelayedWithdrawalProps): Promise<RequestableWithdrawal>;
97
+ previewDelayedWithdrawal({ creditAccount, amount, token, intent, }: PreviewDelayedWithdrawalProps): Promise<RequestableWithdrawal>;
98
98
  /**
99
99
  * {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
100
100
  **/
101
101
  getPendingWithdrawals({ creditAccount, }: GetPendingWithdrawalsProps): Promise<GetPendingWithdrawalsResult>;
102
+ /**
103
+ * {@inheritDoc ICreditAccountsService.assembleStartDelayedWithdrawalCalls}
104
+ **/
105
+ assembleStartDelayedWithdrawalCalls({ creditFacade, preview, }: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
102
106
  /**
103
107
  * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
104
108
  **/
@@ -6,7 +6,7 @@ import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
6
6
  import type { OnchainSDK } from "../OnchainSDK.js";
7
7
  import type { RouterCASlice, RouterCloseResult } from "../router/index.js";
8
8
  import type { MultiCall, RawTx } from "../types/index.js";
9
- import type { ClaimableWithdrawal, PendingWithdrawal, RequestableWithdrawal } from "./withdrawal-compressor/index.js";
9
+ import type { ClaimableWithdrawal, DelayedIntent, PendingWithdrawal, RequestableWithdrawal } from "./withdrawal-compressor/index.js";
10
10
  /**
11
11
  * @internal
12
12
  * Arguments tuple for the credit account compressor's `getCreditAccounts` view method.
@@ -340,6 +340,7 @@ export interface PreviewDelayedWithdrawalProps {
340
340
  * Minimal credit account data on which operation is performed
341
341
  */
342
342
  creditAccount: Address;
343
+ intent?: DelayedIntent;
343
344
  }
344
345
  export interface GetPendingWithdrawalsProps {
345
346
  /**
@@ -360,6 +361,19 @@ export interface GetPendingWithdrawalsResult {
360
361
  **/
361
362
  pending: Array<PendingWithdrawal>;
362
363
  }
364
+ /**
365
+ * Input for {@link ICreditAccountsService.assembleStartDelayedWithdrawalCalls}.
366
+ */
367
+ export type AssembleStartDelayedWithdrawalCallsProps = {
368
+ /**
369
+ * Credit facade that receives `storeExpectedBalances` / `compareBalances`.
370
+ */
371
+ creditFacade: Address;
372
+ /**
373
+ * Withdrawal preview: `outputs` for expected balances, `requestCalls` for the body.
374
+ */
375
+ preview: Pick<RequestableWithdrawal, "outputs" | "requestCalls">;
376
+ };
363
377
  export interface StartDelayedWithdrawalProps extends PrepareUpdateQuotasProps {
364
378
  /**
365
379
  * Withdrawal preview
@@ -871,6 +885,19 @@ export interface ICreditAccountsService extends Construct {
871
885
  * @returns All necessary data to execute the transaction (call, credit facade)
872
886
  */
873
887
  startDelayedWithdrawal(props: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
888
+ /**
889
+ * Builds start-delayed-withdrawal multicall calls without price feed updates
890
+ * or quota updates.
891
+ *
892
+ * Same balance bracket as {@link startDelayedWithdrawal}:
893
+ * `storeExpectedBalances` → `preview.requestCalls` → `compareBalances`.
894
+ *
895
+ * Does not prepend price updates and does not build the facade transaction.
896
+ *
897
+ * @param props - {@link AssembleStartDelayedWithdrawalCallsProps}
898
+ * @returns Raw facade multicall payload for the delayed-withdrawal request
899
+ */
900
+ assembleStartDelayedWithdrawalCalls(props: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
874
901
  /**
875
902
  * Preview delayed withdrawal for given token
876
903
  * @param props - {@link PreviewDelayedWithdrawalProps}
@@ -977,9 +1004,10 @@ export interface ICreditAccountsService extends Construct {
977
1004
  * Each operation must already carry concrete encoding data (e.g. swap/wrap
978
1005
  * `calls`). Unknown operation types throw.
979
1006
  *
980
- * Does not handle close or repay — use
1007
+ * Does not handle close, repay, or start delayed withdrawal — use
981
1008
  * {@link ICreditAccountsService.assembleCloseCreditAccountCalls} /
982
- * {@link ICreditAccountsService.assembleRepayCreditAccountCalls}.
1009
+ * {@link ICreditAccountsService.assembleRepayCreditAccountCalls} /
1010
+ * {@link ICreditAccountsService.assembleStartDelayedWithdrawalCalls}.
983
1011
  *
984
1012
  * @param props - Encodable operations and account context
985
1013
  * @returns Array of facade / adapter multicall calls (without price feed updates)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.20",
3
+ "version": "14.12.0-next.21",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {