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

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.
@@ -843,6 +843,45 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
843
843
  };
844
844
  return [storeExpectedBalances, ...preview.requestCalls, compareBalances];
845
845
  }
846
+ /**
847
+ * {@inheritDoc ICreditAccountsService.assembleClaimDelayedCalls}
848
+ **/
849
+ assembleClaimDelayedCalls({
850
+ creditFacade,
851
+ claimableNow
852
+ }) {
853
+ const record = claimableNow.outputs.reduce(
854
+ (acc, o) => {
855
+ const token = o.token.toLowerCase();
856
+ acc[token] = (acc[token] || 0n) + o.amount;
857
+ return acc;
858
+ },
859
+ {}
860
+ );
861
+ const balances = Object.entries(record).filter(([, a]) => a > 10n);
862
+ const storeExpectedBalances = {
863
+ target: creditFacade,
864
+ callData: (0, import_viem.encodeFunctionData)({
865
+ abi: import_generated.iCreditFacadeMulticallV310Abi,
866
+ functionName: "storeExpectedBalances",
867
+ args: [
868
+ balances.map(([token, amount]) => ({
869
+ token,
870
+ amount: amount > 10n ? amount - 10n : 0n
871
+ }))
872
+ ]
873
+ })
874
+ };
875
+ const compareBalances = {
876
+ target: creditFacade,
877
+ callData: (0, import_viem.encodeFunctionData)({
878
+ abi: import_generated.iCreditFacadeMulticallV310Abi,
879
+ functionName: "compareBalances",
880
+ args: []
881
+ })
882
+ };
883
+ return [storeExpectedBalances, ...claimableNow.claimCalls, compareBalances];
884
+ }
846
885
  /**
847
886
  * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
848
887
  **/
@@ -886,44 +925,15 @@ class CreditAccountsServiceV310 extends import_base.SDKConstruct {
886
925
  const cm = this.sdk.marketRegister.findCreditManager(
887
926
  creditAccount.creditManager
888
927
  );
889
- const record = claimableNow.outputs.reduce(
890
- (acc, o) => {
891
- const token = o.token.toLowerCase();
892
- acc[token] = (acc[token] || 0n) + o.amount;
893
- return acc;
894
- },
895
- {}
896
- );
897
- const balances = Object.entries(record).filter(([, a]) => a > 10n);
898
- const storeExpectedBalances = {
899
- target: cm.creditFacade.address,
900
- callData: (0, import_viem.encodeFunctionData)({
901
- abi: import_generated.iCreditFacadeMulticallV310Abi,
902
- functionName: "storeExpectedBalances",
903
- args: [
904
- balances.map(([token, amount]) => ({
905
- token,
906
- amount: amount > 10n ? amount - 10n : 0n
907
- }))
908
- ]
909
- })
910
- };
911
- const compareBalances = {
912
- target: cm.creditFacade.address,
913
- callData: (0, import_viem.encodeFunctionData)({
914
- abi: import_generated.iCreditFacadeMulticallV310Abi,
915
- functionName: "compareBalances",
916
- args: []
917
- })
918
- };
919
928
  const quotaCalls = zeroDebt ? [] : this.#prepareUpdateQuotas(cm.creditFacade.address, {
920
929
  minQuota,
921
930
  averageQuota
922
931
  });
923
932
  const operationCalls = [
924
- storeExpectedBalances,
925
- ...claimableNow.claimCalls,
926
- compareBalances,
933
+ ...this.assembleClaimDelayedCalls({
934
+ creditFacade: cm.creditFacade.address,
935
+ claimableNow
936
+ }),
927
937
  ...quotaCalls
928
938
  ];
929
939
  const calls = zeroDebt ? operationCalls : await this.#prependPriceUpdates(
@@ -839,6 +839,45 @@ class CreditAccountsServiceV310 extends SDKConstruct {
839
839
  };
840
840
  return [storeExpectedBalances, ...preview.requestCalls, compareBalances];
841
841
  }
842
+ /**
843
+ * {@inheritDoc ICreditAccountsService.assembleClaimDelayedCalls}
844
+ **/
845
+ assembleClaimDelayedCalls({
846
+ creditFacade,
847
+ claimableNow
848
+ }) {
849
+ const record = claimableNow.outputs.reduce(
850
+ (acc, o) => {
851
+ const token = o.token.toLowerCase();
852
+ acc[token] = (acc[token] || 0n) + o.amount;
853
+ return acc;
854
+ },
855
+ {}
856
+ );
857
+ const balances = Object.entries(record).filter(([, a]) => a > 10n);
858
+ const storeExpectedBalances = {
859
+ target: creditFacade,
860
+ callData: encodeFunctionData({
861
+ abi: iCreditFacadeMulticallV310Abi,
862
+ functionName: "storeExpectedBalances",
863
+ args: [
864
+ balances.map(([token, amount]) => ({
865
+ token,
866
+ amount: amount > 10n ? amount - 10n : 0n
867
+ }))
868
+ ]
869
+ })
870
+ };
871
+ const compareBalances = {
872
+ target: creditFacade,
873
+ callData: encodeFunctionData({
874
+ abi: iCreditFacadeMulticallV310Abi,
875
+ functionName: "compareBalances",
876
+ args: []
877
+ })
878
+ };
879
+ return [storeExpectedBalances, ...claimableNow.claimCalls, compareBalances];
880
+ }
842
881
  /**
843
882
  * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
844
883
  **/
@@ -882,44 +921,15 @@ class CreditAccountsServiceV310 extends SDKConstruct {
882
921
  const cm = this.sdk.marketRegister.findCreditManager(
883
922
  creditAccount.creditManager
884
923
  );
885
- const record = claimableNow.outputs.reduce(
886
- (acc, o) => {
887
- const token = o.token.toLowerCase();
888
- acc[token] = (acc[token] || 0n) + o.amount;
889
- return acc;
890
- },
891
- {}
892
- );
893
- const balances = Object.entries(record).filter(([, a]) => a > 10n);
894
- const storeExpectedBalances = {
895
- target: cm.creditFacade.address,
896
- callData: encodeFunctionData({
897
- abi: iCreditFacadeMulticallV310Abi,
898
- functionName: "storeExpectedBalances",
899
- args: [
900
- balances.map(([token, amount]) => ({
901
- token,
902
- amount: amount > 10n ? amount - 10n : 0n
903
- }))
904
- ]
905
- })
906
- };
907
- const compareBalances = {
908
- target: cm.creditFacade.address,
909
- callData: encodeFunctionData({
910
- abi: iCreditFacadeMulticallV310Abi,
911
- functionName: "compareBalances",
912
- args: []
913
- })
914
- };
915
924
  const quotaCalls = zeroDebt ? [] : this.#prepareUpdateQuotas(cm.creditFacade.address, {
916
925
  minQuota,
917
926
  averageQuota
918
927
  });
919
928
  const operationCalls = [
920
- storeExpectedBalances,
921
- ...claimableNow.claimCalls,
922
- compareBalances,
929
+ ...this.assembleClaimDelayedCalls({
930
+ creditFacade: cm.creditFacade.address,
931
+ claimableNow
932
+ }),
923
933
  ...quotaCalls
924
934
  ];
925
935
  const calls = zeroDebt ? operationCalls : await this.#prependPriceUpdates(
@@ -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, 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";
9
+ import type { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, 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.
@@ -103,6 +103,10 @@ export declare class CreditAccountsServiceV310 extends SDKConstruct implements I
103
103
  * {@inheritDoc ICreditAccountsService.assembleStartDelayedWithdrawalCalls}
104
104
  **/
105
105
  assembleStartDelayedWithdrawalCalls({ creditFacade, preview, }: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
106
+ /**
107
+ * {@inheritDoc ICreditAccountsService.assembleClaimDelayedCalls}
108
+ **/
109
+ assembleClaimDelayedCalls({ creditFacade, claimableNow, }: AssembleClaimDelayedCallsProps): Array<MultiCall>;
106
110
  /**
107
111
  * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
108
112
  **/
@@ -374,6 +374,19 @@ export type AssembleStartDelayedWithdrawalCallsProps = {
374
374
  */
375
375
  preview: Pick<RequestableWithdrawal, "outputs" | "requestCalls">;
376
376
  };
377
+ /**
378
+ * Input for {@link ICreditAccountsService.assembleClaimDelayedCalls}.
379
+ */
380
+ export type AssembleClaimDelayedCallsProps = {
381
+ /**
382
+ * Credit facade that receives `storeExpectedBalances` / `compareBalances`.
383
+ */
384
+ creditFacade: Address;
385
+ /**
386
+ * Claimable withdrawal: `outputs` for expected balances, `claimCalls` for the body.
387
+ */
388
+ claimableNow: Pick<ClaimableWithdrawal, "outputs" | "claimCalls">;
389
+ };
377
390
  export interface StartDelayedWithdrawalProps extends PrepareUpdateQuotasProps {
378
391
  /**
379
392
  * Withdrawal preview
@@ -898,6 +911,21 @@ export interface ICreditAccountsService extends Construct {
898
911
  * @returns Raw facade multicall payload for the delayed-withdrawal request
899
912
  */
900
913
  assembleStartDelayedWithdrawalCalls(props: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
914
+ /**
915
+ * Builds claim-delayed-withdrawal multicall calls without price feed updates
916
+ * or quota updates.
917
+ *
918
+ * Same balance bracket as {@link claimDelayed}:
919
+ * `storeExpectedBalances` → `claimableNow.claimCalls` → `compareBalances`.
920
+ *
921
+ * Does not prepend price updates, does not update quotas, and does not build
922
+ * the facade transaction. Use for resume / intent assembly where claim is
923
+ * followed by other ops and quotas/prices are applied separately.
924
+ *
925
+ * @param props - {@link AssembleClaimDelayedCallsProps}
926
+ * @returns Raw facade multicall payload for the claim
927
+ */
928
+ assembleClaimDelayedCalls(props: AssembleClaimDelayedCallsProps): Array<MultiCall>;
901
929
  /**
902
930
  * Preview delayed withdrawal for given token
903
931
  * @param props - {@link PreviewDelayedWithdrawalProps}
@@ -1004,10 +1032,11 @@ export interface ICreditAccountsService extends Construct {
1004
1032
  * Each operation must already carry concrete encoding data (e.g. swap/wrap
1005
1033
  * `calls`). Unknown operation types throw.
1006
1034
  *
1007
- * Does not handle close, repay, or start delayed withdrawal — use
1008
- * {@link ICreditAccountsService.assembleCloseCreditAccountCalls} /
1035
+ * Does not handle close, repay, start delayed withdrawal, or claim delayed
1036
+ * use {@link ICreditAccountsService.assembleCloseCreditAccountCalls} /
1009
1037
  * {@link ICreditAccountsService.assembleRepayCreditAccountCalls} /
1010
- * {@link ICreditAccountsService.assembleStartDelayedWithdrawalCalls}.
1038
+ * {@link ICreditAccountsService.assembleStartDelayedWithdrawalCalls} /
1039
+ * {@link ICreditAccountsService.assembleClaimDelayedCalls}.
1011
1040
  *
1012
1041
  * @param props - Encodable operations and account context
1013
1042
  * @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.21",
3
+ "version": "14.12.0-next.22",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {