@gearbox-protocol/sdk 14.12.0-next.28 → 14.12.0-next.29

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.
@@ -162,6 +162,18 @@ class AbstractAdapterContract extends import_sdk.BaseContract {
162
162
  `previewBalanceChanges is not supported for ${decoded.functionName} on ${this.contractType} adapter at ${this.address}`
163
163
  );
164
164
  }
165
+ /**
166
+ * When the given adapter calldata is a delayed-withdrawal request (a call
167
+ * created by the withdrawal compressor that mints a withdrawal phantom
168
+ * token), returns its descriptor; `undefined` for any other call.
169
+ *
170
+ * The base implementation returns `undefined`; delayed-withdrawal adapters
171
+ * (Securitize, Midas, Mellow) override it next to their
172
+ * {@link applyBalanceChanges} cases for the same methods.
173
+ */
174
+ parseDelayedWithdrawalRequest(_calldata) {
175
+ return void 0;
176
+ }
165
177
  /**
166
178
  * Diff-call semantics of a diff-style adapter call: the call spends the
167
179
  * consumed token down to the exact `leftoverAmount` encoded in its
@@ -108,6 +108,31 @@ class MellowERC4626VaultAdapterContract extends import_AbstractAdapter.AbstractA
108
108
  }
109
109
  return super.classifyLegacyOperation(parsed, transfers);
110
110
  }
111
+ /**
112
+ * Plain `redeem` on a Mellow multivault is a delayed-withdrawal request:
113
+ * it is only emitted by the withdrawal compressor (the router uses
114
+ * `redeemDiff`), spends the multivault shares and mints the withdrawal
115
+ * phantom token for the illiquid part. Mellow request calls cannot carry
116
+ * an intent, so `extraData` is always undefined.
117
+ *
118
+ * The withdrawal phantom token is only serialized by v311 adapters;
119
+ * on other versions it cannot be resolved offline and the request is not
120
+ * reported.
121
+ */
122
+ parseDelayedWithdrawalRequest(calldata) {
123
+ if (!this.#stakedPhantomToken || !this.#asset) {
124
+ return void 0;
125
+ }
126
+ const decoded = (0, import_viem.decodeFunctionData)({ abi: this.abi, data: calldata });
127
+ if (decoded.functionName !== "redeem") {
128
+ return void 0;
129
+ }
130
+ return {
131
+ phantomToken: this.#stakedPhantomToken,
132
+ claimToken: this.#asset,
133
+ extraData: void 0
134
+ };
135
+ }
111
136
  async applyBalanceChanges(balances, decoded) {
112
137
  const share = this.#vault ?? this.targetContract;
113
138
  switch (decoded.functionName) {
@@ -97,6 +97,26 @@ class MidasGatewayAdapterContract extends import_AbstractAdapter.AbstractAdapter
97
97
  }))
98
98
  };
99
99
  }
100
+ /**
101
+ * `redeemRequest` (the only request call the withdrawal compressor emits)
102
+ * spends the mToken and mints the phantom token of the requested
103
+ * `tokenOut`, which is received when the redemption is claimed. The 3-arg
104
+ * overload carries the intent `extraData`.
105
+ */
106
+ parseDelayedWithdrawalRequest(calldata) {
107
+ const decoded = (0, import_viem.decodeFunctionData)({ abi: this.abi, data: calldata });
108
+ if (decoded.functionName !== "redeemRequest") {
109
+ return void 0;
110
+ }
111
+ const [tokenOut, , extraData] = decoded.args;
112
+ const phantomToken = this.allowedOutputTokens.find(
113
+ (t) => (0, import_viem.isAddressEqual)(t.token, tokenOut)
114
+ )?.phantomToken;
115
+ if (!phantomToken) {
116
+ return void 0;
117
+ }
118
+ return { phantomToken, claimToken: tokenOut, extraData };
119
+ }
100
120
  async applyBalanceChanges(balances, decoded) {
101
121
  switch (decoded.functionName) {
102
122
  case "depositInstantDiff": {
@@ -104,10 +124,9 @@ class MidasGatewayAdapterContract extends import_AbstractAdapter.AbstractAdapter
104
124
  this.setLeftover(balances, tokenIn, leftoverAmount);
105
125
  break;
106
126
  }
107
- // redemptions spend the mToken down to the leftover, tokenOut arg is
108
- // the received token
109
- case "redeemInstantDiff":
110
- case "redeemRequestDiff": {
127
+ // instant redemption spends the mToken down to the leftover, tokenOut
128
+ // arg is the received token
129
+ case "redeemInstantDiff": {
111
130
  const [, leftoverAmount] = decoded.args;
112
131
  this.setLeftover(balances, this.mToken, leftoverAmount);
113
132
  break;
@@ -72,6 +72,24 @@ class SecuritizeRedemptionGatewayAdapterContract extends import_AbstractAdapter.
72
72
  redemptionPhantomToken: this.#redemptionPhantomToken ? this.labelAddress(this.#redemptionPhantomToken) : void 0
73
73
  };
74
74
  }
75
+ /**
76
+ * `redeem` (the only request call the withdrawal compressor emits) spends
77
+ * the DS token and mints the redemption phantom token; the stable coin is
78
+ * received when the redemption is claimed. The 2-arg overload carries the
79
+ * intent `extraData`.
80
+ */
81
+ parseDelayedWithdrawalRequest(calldata) {
82
+ const decoded = (0, import_viem.decodeFunctionData)({ abi: this.abi, data: calldata });
83
+ if (decoded.functionName !== "redeem") {
84
+ return void 0;
85
+ }
86
+ const [, extraData] = decoded.args;
87
+ return {
88
+ phantomToken: this.redemptionPhantomToken,
89
+ claimToken: this.stableCoinToken,
90
+ extraData
91
+ };
92
+ }
75
93
  async applyBalanceChanges(balances, decoded) {
76
94
  switch (decoded.functionName) {
77
95
  // no-op:
@@ -80,12 +98,6 @@ class SecuritizeRedemptionGatewayAdapterContract extends import_AbstractAdapter.
80
98
  case "redeem": {
81
99
  break;
82
100
  }
83
- // diff-style redemption: spends the DS token down to the leftover
84
- case "redeemDiff": {
85
- const [leftoverAmount] = decoded.args;
86
- this.setLeftover(balances, this.dsToken, leftoverAmount);
87
- break;
88
- }
89
101
  // no-op:
90
102
  // the redemption phantom token burn of a `claim(address[])` is
91
103
  // not recoverable from calldata (it lives in per-redeemer clone
@@ -150,6 +150,18 @@ class AbstractAdapterContract extends BaseContract {
150
150
  `previewBalanceChanges is not supported for ${decoded.functionName} on ${this.contractType} adapter at ${this.address}`
151
151
  );
152
152
  }
153
+ /**
154
+ * When the given adapter calldata is a delayed-withdrawal request (a call
155
+ * created by the withdrawal compressor that mints a withdrawal phantom
156
+ * token), returns its descriptor; `undefined` for any other call.
157
+ *
158
+ * The base implementation returns `undefined`; delayed-withdrawal adapters
159
+ * (Securitize, Midas, Mellow) override it next to their
160
+ * {@link applyBalanceChanges} cases for the same methods.
161
+ */
162
+ parseDelayedWithdrawalRequest(_calldata) {
163
+ return void 0;
164
+ }
153
165
  /**
154
166
  * Diff-call semantics of a diff-style adapter call: the call spends the
155
167
  * consumed token down to the exact `leftoverAmount` encoded in its
@@ -1,5 +1,6 @@
1
1
  import {
2
- decodeAbiParameters
2
+ decodeAbiParameters,
3
+ decodeFunctionData
3
4
  } from "viem";
4
5
  import {
5
6
  MissingSerializedParamsError
@@ -89,6 +90,31 @@ class MellowERC4626VaultAdapterContract extends AbstractAdapterContract {
89
90
  }
90
91
  return super.classifyLegacyOperation(parsed, transfers);
91
92
  }
93
+ /**
94
+ * Plain `redeem` on a Mellow multivault is a delayed-withdrawal request:
95
+ * it is only emitted by the withdrawal compressor (the router uses
96
+ * `redeemDiff`), spends the multivault shares and mints the withdrawal
97
+ * phantom token for the illiquid part. Mellow request calls cannot carry
98
+ * an intent, so `extraData` is always undefined.
99
+ *
100
+ * The withdrawal phantom token is only serialized by v311 adapters;
101
+ * on other versions it cannot be resolved offline and the request is not
102
+ * reported.
103
+ */
104
+ parseDelayedWithdrawalRequest(calldata) {
105
+ if (!this.#stakedPhantomToken || !this.#asset) {
106
+ return void 0;
107
+ }
108
+ const decoded = decodeFunctionData({ abi: this.abi, data: calldata });
109
+ if (decoded.functionName !== "redeem") {
110
+ return void 0;
111
+ }
112
+ return {
113
+ phantomToken: this.#stakedPhantomToken,
114
+ claimToken: this.#asset,
115
+ extraData: void 0
116
+ };
117
+ }
92
118
  async applyBalanceChanges(balances, decoded) {
93
119
  const share = this.#vault ?? this.targetContract;
94
120
  switch (decoded.functionName) {
@@ -1,5 +1,7 @@
1
1
  import {
2
- decodeAbiParameters
2
+ decodeAbiParameters,
3
+ decodeFunctionData,
4
+ isAddressEqual
3
5
  } from "viem";
4
6
  import {
5
7
  MissingSerializedParamsError
@@ -81,6 +83,26 @@ class MidasGatewayAdapterContract extends AbstractAdapterContract {
81
83
  }))
82
84
  };
83
85
  }
86
+ /**
87
+ * `redeemRequest` (the only request call the withdrawal compressor emits)
88
+ * spends the mToken and mints the phantom token of the requested
89
+ * `tokenOut`, which is received when the redemption is claimed. The 3-arg
90
+ * overload carries the intent `extraData`.
91
+ */
92
+ parseDelayedWithdrawalRequest(calldata) {
93
+ const decoded = decodeFunctionData({ abi: this.abi, data: calldata });
94
+ if (decoded.functionName !== "redeemRequest") {
95
+ return void 0;
96
+ }
97
+ const [tokenOut, , extraData] = decoded.args;
98
+ const phantomToken = this.allowedOutputTokens.find(
99
+ (t) => isAddressEqual(t.token, tokenOut)
100
+ )?.phantomToken;
101
+ if (!phantomToken) {
102
+ return void 0;
103
+ }
104
+ return { phantomToken, claimToken: tokenOut, extraData };
105
+ }
84
106
  async applyBalanceChanges(balances, decoded) {
85
107
  switch (decoded.functionName) {
86
108
  case "depositInstantDiff": {
@@ -88,10 +110,9 @@ class MidasGatewayAdapterContract extends AbstractAdapterContract {
88
110
  this.setLeftover(balances, tokenIn, leftoverAmount);
89
111
  break;
90
112
  }
91
- // redemptions spend the mToken down to the leftover, tokenOut arg is
92
- // the received token
93
- case "redeemInstantDiff":
94
- case "redeemRequestDiff": {
113
+ // instant redemption spends the mToken down to the leftover, tokenOut
114
+ // arg is the received token
115
+ case "redeemInstantDiff": {
95
116
  const [, leftoverAmount] = decoded.args;
96
117
  this.setLeftover(balances, this.mToken, leftoverAmount);
97
118
  break;
@@ -1,5 +1,6 @@
1
1
  import {
2
- decodeAbiParameters
2
+ decodeAbiParameters,
3
+ decodeFunctionData
3
4
  } from "viem";
4
5
  import {
5
6
  MissingSerializedParamsError
@@ -53,6 +54,24 @@ class SecuritizeRedemptionGatewayAdapterContract extends AbstractAdapterContract
53
54
  redemptionPhantomToken: this.#redemptionPhantomToken ? this.labelAddress(this.#redemptionPhantomToken) : void 0
54
55
  };
55
56
  }
57
+ /**
58
+ * `redeem` (the only request call the withdrawal compressor emits) spends
59
+ * the DS token and mints the redemption phantom token; the stable coin is
60
+ * received when the redemption is claimed. The 2-arg overload carries the
61
+ * intent `extraData`.
62
+ */
63
+ parseDelayedWithdrawalRequest(calldata) {
64
+ const decoded = decodeFunctionData({ abi: this.abi, data: calldata });
65
+ if (decoded.functionName !== "redeem") {
66
+ return void 0;
67
+ }
68
+ const [, extraData] = decoded.args;
69
+ return {
70
+ phantomToken: this.redemptionPhantomToken,
71
+ claimToken: this.stableCoinToken,
72
+ extraData
73
+ };
74
+ }
56
75
  async applyBalanceChanges(balances, decoded) {
57
76
  switch (decoded.functionName) {
58
77
  // no-op:
@@ -61,12 +80,6 @@ class SecuritizeRedemptionGatewayAdapterContract extends AbstractAdapterContract
61
80
  case "redeem": {
62
81
  break;
63
82
  }
64
- // diff-style redemption: spends the DS token down to the leftover
65
- case "redeemDiff": {
66
- const [leftoverAmount] = decoded.args;
67
- this.setLeftover(balances, this.dsToken, leftoverAmount);
68
- break;
69
- }
70
83
  // no-op:
71
84
  // the redemption phantom token burn of a `claim(address[])` is
72
85
  // not recoverable from calldata (it lives in per-redeemer clone
@@ -3,7 +3,7 @@ import { type CallTrace } from "../../../common-utils/utils/trace.js";
3
3
  import type { AssetsMap, OnchainSDK, ParsedCallV2, RelaxedBaseParams } from "../../../sdk/index.js";
4
4
  import { BaseContract } from "../../../sdk/index.js";
5
5
  import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
6
- import type { AdapterContractStateHuman, AdapterContractType, AdapterProtocolOperation } from "../types.js";
6
+ import type { AdapterContractStateHuman, AdapterContractType, AdapterProtocolOperation, DelayedWithdrawalRequest } from "../types.js";
7
7
  export interface ConcreteAdapterContractOptions {
8
8
  baseParams: RelaxedBaseParams;
9
9
  }
@@ -64,6 +64,16 @@ export declare class AbstractAdapterContract<const abi extends Abi | readonly un
64
64
  * @throws When the adapter (or the specific function) has no balance-changes support
65
65
  */
66
66
  protected applyBalanceChanges(_balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
67
+ /**
68
+ * When the given adapter calldata is a delayed-withdrawal request (a call
69
+ * created by the withdrawal compressor that mints a withdrawal phantom
70
+ * token), returns its descriptor; `undefined` for any other call.
71
+ *
72
+ * The base implementation returns `undefined`; delayed-withdrawal adapters
73
+ * (Securitize, Midas, Mellow) override it next to their
74
+ * {@link applyBalanceChanges} cases for the same methods.
75
+ */
76
+ parseDelayedWithdrawalRequest(_calldata: Hex): DelayedWithdrawalRequest | undefined;
67
77
  /**
68
78
  * Diff-call semantics of a diff-style adapter call: the call spends the
69
79
  * consumed token down to the exact `leftoverAmount` encoded in its
@@ -1,6 +1,7 @@
1
- import { type Address, type DecodeFunctionDataReturnType } from "viem";
1
+ import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
2
2
  import { type AssetsMap, type OnchainSDK, type ParsedCallV2 } from "../../../sdk/index.js";
3
3
  import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
4
+ import type { DelayedWithdrawalRequest } from "../types.js";
4
5
  import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
5
6
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
6
7
  declare const abi: readonly [{
@@ -677,6 +678,18 @@ export declare class MellowERC4626VaultAdapterContract extends AbstractAdapterCo
677
678
  * @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type_v3.go#L32-L38
678
679
  */
679
680
  classifyLegacyOperation(parsed: ParsedCallV2, transfers: Transfers): LegacyAdapterOperation;
681
+ /**
682
+ * Plain `redeem` on a Mellow multivault is a delayed-withdrawal request:
683
+ * it is only emitted by the withdrawal compressor (the router uses
684
+ * `redeemDiff`), spends the multivault shares and mints the withdrawal
685
+ * phantom token for the illiquid part. Mellow request calls cannot carry
686
+ * an intent, so `extraData` is always undefined.
687
+ *
688
+ * The withdrawal phantom token is only serialized by v311 adapters;
689
+ * on other versions it cannot be resolved offline and the request is not
690
+ * reported.
691
+ */
692
+ parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
680
693
  protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
681
694
  }
682
695
  export {};
@@ -1,5 +1,6 @@
1
- import { type Address, type DecodeFunctionDataReturnType } from "viem";
1
+ import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
2
2
  import { type AssetsMap, type OnchainSDK } from "../../../sdk/index.js";
3
+ import type { DelayedWithdrawalRequest } from "../types.js";
3
4
  import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
4
5
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
5
6
  declare const abi: readonly [{
@@ -784,6 +785,13 @@ export declare class MidasGatewayAdapterContract extends AbstractAdapterContract
784
785
  phantomToken: string;
785
786
  }[] | undefined;
786
787
  };
788
+ /**
789
+ * `redeemRequest` (the only request call the withdrawal compressor emits)
790
+ * spends the mToken and mints the phantom token of the requested
791
+ * `tokenOut`, which is received when the redemption is claimed. The 3-arg
792
+ * overload carries the intent `extraData`.
793
+ */
794
+ parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
787
795
  protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
788
796
  }
789
797
  export {};
@@ -1,5 +1,6 @@
1
- import { type Address, type DecodeFunctionDataReturnType } from "viem";
1
+ import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
2
2
  import { type AssetsMap, type OnchainSDK } from "../../../sdk/index.js";
3
+ import type { DelayedWithdrawalRequest } from "../types.js";
3
4
  import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
4
5
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
5
6
  declare const abi: readonly [{
@@ -438,6 +439,13 @@ export declare class SecuritizeRedemptionGatewayAdapterContract extends Abstract
438
439
  stableCoinToken: string | undefined;
439
440
  redemptionPhantomToken: string | undefined;
440
441
  };
442
+ /**
443
+ * `redeem` (the only request call the withdrawal compressor emits) spends
444
+ * the DS token and mints the redemption phantom token; the stable coin is
445
+ * received when the redemption is claimed. The 2-arg overload carries the
446
+ * intent `extraData`.
447
+ */
448
+ parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
441
449
  protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
442
450
  }
443
451
  export {};
@@ -1,4 +1,4 @@
1
- import type { AbiParameter, Address } from "viem";
1
+ import type { AbiParameter, Address, Hex } from "viem";
2
2
  import type { OnchainSDK, PluginsMap } from "../../sdk/index.js";
3
3
  import type { BaseContractStateHuman } from "../../sdk/types/state-human.js";
4
4
  import type { AdaptersPlugin } from "./AdaptersPlugin.js";
@@ -68,6 +68,27 @@ export interface AdapterProtocolOperation {
68
68
  */
69
69
  functionArgs: Record<string, unknown>;
70
70
  }
71
+ /**
72
+ * Descriptor of a delayed-withdrawal request performed by an adapter call
73
+ * (constructed by the withdrawal compressor): the source token is spent now and
74
+ * the withdrawal phantom token is minted in its place; the claim token is
75
+ * received later, when the withdrawal matures and is claimed.
76
+ */
77
+ export interface DelayedWithdrawalRequest {
78
+ /**
79
+ * Withdrawal phantom token minted by this request
80
+ */
81
+ phantomToken: Address;
82
+ /**
83
+ * Token received when the withdrawal is claimed
84
+ */
85
+ claimToken: Address;
86
+ /**
87
+ * Raw extraData arg that may encode a DelayedIntent; absent on adapters
88
+ * whose request methods carry none (e.g. Mellow)
89
+ */
90
+ extraData?: Hex;
91
+ }
71
92
  /**
72
93
  * True when the plugin map `P` contains the {@link AdaptersPlugin} under any key
73
94
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.28",
3
+ "version": "14.12.0-next.29",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {