@gearbox-protocol/sdk 14.12.0-next.23 → 14.12.0-next.24
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.
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +31 -9
- package/dist/cjs/plugins/adapters/contracts/AbstractCurveAdapter.js +8 -5
- package/dist/cjs/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/CamelotV3AdapterContract.js +6 -9
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +7 -5
- package/dist/cjs/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/DaiUsdsAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/ERC4626AdapterContract.js +13 -4
- package/dist/cjs/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/FluidDexAdapterContract.js +8 -8
- package/dist/cjs/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +8 -5
- package/dist/cjs/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/LidoV1AdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/MellowClaimerAdapterContract.js +29 -0
- package/dist/cjs/plugins/adapters/contracts/MellowDVVAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +11 -4
- package/dist/cjs/plugins/adapters/contracts/MellowWrapperAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +31 -4
- package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/PendleRouterAdapterContract.js +14 -16
- package/dist/cjs/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +14 -13
- package/dist/cjs/plugins/adapters/contracts/StakingRewardsAdapterContract.js +7 -5
- package/dist/cjs/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/UniswapV2AdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/UniswapV3AdapterContract.js +6 -9
- package/dist/cjs/plugins/adapters/contracts/UniswapV4AdapterContract.js +8 -8
- package/dist/cjs/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +6 -4
- package/dist/cjs/plugins/adapters/contracts/VelodromeV2AdapterContract.js +4 -3
- package/dist/cjs/plugins/adapters/contracts/WstETHV1AdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +31 -9
- package/dist/esm/plugins/adapters/contracts/AbstractCurveAdapter.js +8 -5
- package/dist/esm/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/CamelotV3AdapterContract.js +6 -9
- package/dist/esm/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +7 -5
- package/dist/esm/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/DaiUsdsAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +13 -4
- package/dist/esm/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/FluidDexAdapterContract.js +8 -8
- package/dist/esm/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +8 -5
- package/dist/esm/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/LidoV1AdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/MellowClaimerAdapterContract.js +32 -1
- package/dist/esm/plugins/adapters/contracts/MellowDVVAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +11 -4
- package/dist/esm/plugins/adapters/contracts/MellowWrapperAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +33 -5
- package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/PendleRouterAdapterContract.js +14 -16
- package/dist/esm/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +14 -13
- package/dist/esm/plugins/adapters/contracts/StakingRewardsAdapterContract.js +7 -5
- package/dist/esm/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/UniswapV2AdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/UniswapV3AdapterContract.js +6 -9
- package/dist/esm/plugins/adapters/contracts/UniswapV4AdapterContract.js +8 -8
- package/dist/esm/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +6 -4
- package/dist/esm/plugins/adapters/contracts/VelodromeV2AdapterContract.js +4 -3
- package/dist/esm/plugins/adapters/contracts/WstETHV1AdapterContract.js +6 -4
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +27 -7
- package/dist/types/plugins/adapters/contracts/AbstractCurveAdapter.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/BalancerV3RouterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/CamelotV3AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/DaiUsdsAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ERC4626AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/ERC4626ReferralAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/FluidDexAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/InfinifiGatewayAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/LidoV1AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MellowClaimerAdapterContract.d.ts +3 -2
- package/dist/types/plugins/adapters/contracts/MellowDVVAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MellowWrapperAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/PendleRouterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/StakingRewardsAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/TraderJoeRouterAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UniswapV2AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UniswapV3AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UniswapV4AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/UpshiftVaultAdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/VelodromeV2AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/contracts/WstETHV1AdapterContract.d.ts +2 -3
- package/dist/types/plugins/adapters/types.d.ts +0 -10
- package/package.json +1 -1
|
@@ -116,8 +116,10 @@ class AbstractAdapterContract extends import_sdk.BaseContract {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
|
-
* Applies the balance changes implied by a
|
|
120
|
-
*
|
|
119
|
+
* Applies the balance changes implied by an adapter call to a map of
|
|
120
|
+
* credit-account token balances. Handles both router-generated diff-style
|
|
121
|
+
* calls and exact-input calls (e.g. those emitted by the withdrawal
|
|
122
|
+
* compressor).
|
|
121
123
|
*
|
|
122
124
|
* @param balances - Token balances before the call. Mutated in place.
|
|
123
125
|
* @param calldata - Raw ABI-encoded adapter calldata.
|
|
@@ -134,23 +136,43 @@ class AbstractAdapterContract extends import_sdk.BaseContract {
|
|
|
134
136
|
{ cause: e }
|
|
135
137
|
);
|
|
136
138
|
}
|
|
137
|
-
|
|
138
|
-
for (const { tokenIn, leftoverAmount } of leftovers) {
|
|
139
|
-
balances.upsert(tokenIn, leftoverAmount);
|
|
140
|
-
}
|
|
139
|
+
this.applyBalanceChanges(balances, decoded);
|
|
141
140
|
}
|
|
142
141
|
/**
|
|
143
|
-
*
|
|
142
|
+
* Applies the balance changes of a decoded adapter call to the running
|
|
143
|
+
* balances, mutating them in place. Overrides should express changes via
|
|
144
|
+
* {@link setLeftover} (diff-style calls) and {@link spendExact}
|
|
145
|
+
* (exact-input calls), and should resolve all tokens/amounts before the
|
|
146
|
+
* first write so a throw never leaves balances partially mutated.
|
|
144
147
|
*
|
|
148
|
+
* @param _balances - Token balances before the call. Mutated in place.
|
|
145
149
|
* @param decoded - The viem-decoded adapter call
|
|
146
|
-
* @param _balances - Token balances before the call
|
|
147
150
|
* @throws When the adapter (or the specific function) has no balance-changes support
|
|
148
151
|
*/
|
|
149
|
-
|
|
152
|
+
applyBalanceChanges(_balances, decoded) {
|
|
150
153
|
throw new Error(
|
|
151
154
|
`previewBalanceChanges is not supported for ${decoded.functionName} on ${this.contractType} adapter at ${this.address}`
|
|
152
155
|
);
|
|
153
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
159
|
+
* consumed token down to the exact `leftoverAmount` encoded in its
|
|
160
|
+
* calldata, so the post-call balance of `tokenIn` is `leftoverAmount`
|
|
161
|
+
* regardless of the actual amount spent.
|
|
162
|
+
*/
|
|
163
|
+
setLeftover(balances, tokenIn, leftoverAmount) {
|
|
164
|
+
balances.upsert(tokenIn, leftoverAmount);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Exact-input call semantics: spends exactly `amount` of `tokenIn` from
|
|
168
|
+
* the running balance, clamping at zero. Used for non-diff adapter calls
|
|
169
|
+
* (e.g. those generated by the withdrawal compressor) whose spent amount
|
|
170
|
+
* is present in calldata.
|
|
171
|
+
*/
|
|
172
|
+
spendExact(balances, tokenIn, amount) {
|
|
173
|
+
const balance = balances.getOrZero(tokenIn);
|
|
174
|
+
balances.upsert(tokenIn, balance > amount ? balance - amount : 0n);
|
|
175
|
+
}
|
|
154
176
|
/**
|
|
155
177
|
* Classifies an adapter call into a {@link LegacyAdapterOperation} using the
|
|
156
178
|
* parsed call and credit-account transfer deltas.
|
|
@@ -28,23 +28,26 @@ class AbstractCurveAdapterContract extends import_AbstractAdapter.AbstractAdapte
|
|
|
28
28
|
classifyLegacyOperation(parsed, transfers) {
|
|
29
29
|
return (0, import_transferHelpers.classifyCurveOperation)(parsed.functionName, transfers) ?? super.classifyLegacyOperation(parsed, transfers);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
applyBalanceChanges(balances, decoded) {
|
|
32
32
|
const { functionName, args } = decoded;
|
|
33
33
|
switch (functionName) {
|
|
34
34
|
case "exchange_diff": {
|
|
35
35
|
const [i, , leftoverAmount] = args;
|
|
36
|
-
|
|
36
|
+
this.setLeftover(balances, this.curveCoin(i), leftoverAmount);
|
|
37
|
+
break;
|
|
37
38
|
}
|
|
38
39
|
case "add_diff_liquidity_one_coin": {
|
|
39
40
|
const [leftoverAmount, i] = args;
|
|
40
|
-
|
|
41
|
+
this.setLeftover(balances, this.curveCoin(i), leftoverAmount);
|
|
42
|
+
break;
|
|
41
43
|
}
|
|
42
44
|
case "remove_diff_liquidity_one_coin": {
|
|
43
45
|
const [leftoverAmount] = args;
|
|
44
|
-
|
|
46
|
+
this.setLeftover(balances, this.lpToken, leftoverAmount);
|
|
47
|
+
break;
|
|
45
48
|
}
|
|
46
49
|
default:
|
|
47
|
-
|
|
50
|
+
super.applyBalanceChanges(balances, decoded);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
@@ -93,23 +93,25 @@ class BalancerV3RouterAdapterContract extends import_AbstractAdapter.AbstractAda
|
|
|
93
93
|
}))
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
applyBalanceChanges(balances, decoded) {
|
|
97
97
|
switch (decoded.functionName) {
|
|
98
98
|
case "swapSingleTokenDiffIn": {
|
|
99
99
|
const [, tokenIn, , leftoverAmount] = decoded.args;
|
|
100
|
-
|
|
100
|
+
this.setLeftover(balances, tokenIn, leftoverAmount);
|
|
101
|
+
break;
|
|
101
102
|
}
|
|
102
103
|
// BPT (pool token) is spent down to the leftover
|
|
103
104
|
case "removeLiquiditySingleTokenDiff": {
|
|
104
105
|
const [pool, leftoverAmount] = decoded.args;
|
|
105
|
-
|
|
106
|
+
this.setLeftover(balances, pool, leftoverAmount);
|
|
107
|
+
break;
|
|
106
108
|
}
|
|
107
109
|
case "addLiquidityUnbalancedDiff":
|
|
108
110
|
throw new Error(
|
|
109
111
|
`previewBalanceChanges cannot resolve pool tokens for addLiquidityUnbalancedDiff on ${this.contractType} adapter at ${this.address}`
|
|
110
112
|
);
|
|
111
113
|
default:
|
|
112
|
-
|
|
114
|
+
super.applyBalanceChanges(balances, decoded);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
}
|
|
@@ -55,19 +55,21 @@ class BalancerV3WrapperAdapterContract extends import_AbstractAdapter.AbstractAd
|
|
|
55
55
|
balancerPoolToken: this.#balancerPoolToken ? this.labelAddress(this.#balancerPoolToken) : void 0
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
applyBalanceChanges(balances, decoded) {
|
|
59
59
|
switch (decoded.functionName) {
|
|
60
60
|
// mint spends the pool token, burn spends the wrapper (target contract)
|
|
61
61
|
case "mintDiff": {
|
|
62
62
|
const [leftoverAmount] = decoded.args;
|
|
63
|
-
|
|
63
|
+
this.setLeftover(balances, this.balancerPoolToken, leftoverAmount);
|
|
64
|
+
break;
|
|
64
65
|
}
|
|
65
66
|
case "burnDiff": {
|
|
66
67
|
const [leftoverAmount] = decoded.args;
|
|
67
|
-
|
|
68
|
+
this.setLeftover(balances, this.targetContract, leftoverAmount);
|
|
69
|
+
break;
|
|
68
70
|
}
|
|
69
71
|
default:
|
|
70
|
-
|
|
72
|
+
super.applyBalanceChanges(balances, decoded);
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
}
|
|
@@ -68,24 +68,21 @@ class CamelotV3AdapterContract extends import_AbstractAdapter.AbstractAdapterCon
|
|
|
68
68
|
}))
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
applyBalanceChanges(balances, decoded) {
|
|
72
72
|
switch (decoded.functionName) {
|
|
73
73
|
case "exactDiffInputSingle": {
|
|
74
74
|
const [params] = decoded.args;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
tokenIn: params.tokenIn,
|
|
78
|
-
leftoverAmount: params.leftoverAmount
|
|
79
|
-
}
|
|
80
|
-
];
|
|
75
|
+
this.setLeftover(balances, params.tokenIn, params.leftoverAmount);
|
|
76
|
+
break;
|
|
81
77
|
}
|
|
82
78
|
case "exactDiffInput": {
|
|
83
79
|
const [params] = decoded.args;
|
|
84
80
|
const tokenIn = `0x${params.path.replace("0x", "").slice(0, 40)}`;
|
|
85
|
-
|
|
81
|
+
this.setLeftover(balances, tokenIn, params.leftoverAmount);
|
|
82
|
+
break;
|
|
86
83
|
}
|
|
87
84
|
default:
|
|
88
|
-
|
|
85
|
+
super.applyBalanceChanges(balances, decoded);
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
}
|
|
@@ -128,22 +128,24 @@ class ConvexV1BaseRewardPoolAdapterContract extends import_AbstractAdapter.Abstr
|
|
|
128
128
|
withdrawAmount: swap.toAmount
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
applyBalanceChanges(balances, decoded) {
|
|
132
132
|
switch (decoded.functionName) {
|
|
133
133
|
case "stakeDiff": {
|
|
134
134
|
const [leftoverAmount] = decoded.args;
|
|
135
|
-
|
|
135
|
+
this.setLeftover(balances, this.stakingToken, leftoverAmount);
|
|
136
|
+
break;
|
|
136
137
|
}
|
|
137
138
|
case "withdrawDiff":
|
|
138
139
|
case "withdrawDiffAndUnwrap": {
|
|
139
140
|
const [leftoverAmount] = decoded.args;
|
|
140
|
-
|
|
141
|
+
this.setLeftover(balances, this.stakedPhantomToken, leftoverAmount);
|
|
142
|
+
break;
|
|
141
143
|
}
|
|
142
144
|
// no accrued rewards on a freshly opened account
|
|
143
145
|
case "getReward":
|
|
144
|
-
|
|
146
|
+
break;
|
|
145
147
|
default:
|
|
146
|
-
|
|
148
|
+
super.applyBalanceChanges(balances, decoded);
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
151
|
}
|
|
@@ -102,21 +102,23 @@ class ConvexV1BoosterAdapterContract extends import_AbstractAdapter.AbstractAdap
|
|
|
102
102
|
}
|
|
103
103
|
return super.classifyLegacyOperation(parsed, transfers);
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
applyBalanceChanges(balances, decoded) {
|
|
106
106
|
switch (decoded.functionName) {
|
|
107
107
|
// deposit spends the curve LP token, withdraw spends the convex token
|
|
108
108
|
case "depositDiff": {
|
|
109
109
|
const [pid, leftoverAmount] = decoded.args;
|
|
110
110
|
const pool = this.#mustFindPool(Number(pid));
|
|
111
|
-
|
|
111
|
+
this.setLeftover(balances, pool.curveToken, leftoverAmount);
|
|
112
|
+
break;
|
|
112
113
|
}
|
|
113
114
|
case "withdrawDiff": {
|
|
114
115
|
const [pid, leftoverAmount] = decoded.args;
|
|
115
116
|
const pool = this.#mustFindPool(Number(pid));
|
|
116
|
-
|
|
117
|
+
this.setLeftover(balances, pool.convexToken, leftoverAmount);
|
|
118
|
+
break;
|
|
117
119
|
}
|
|
118
120
|
default:
|
|
119
|
-
|
|
121
|
+
super.applyBalanceChanges(balances, decoded);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
#mustFindPool(pid) {
|
|
@@ -74,18 +74,20 @@ class DaiUsdsAdapterContract extends import_AbstractAdapter.AbstractAdapterContr
|
|
|
74
74
|
}
|
|
75
75
|
return super.classifyLegacyOperation(parsed, transfers);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
applyBalanceChanges(balances, decoded) {
|
|
78
78
|
switch (decoded.functionName) {
|
|
79
79
|
case "daiToUsdsDiff": {
|
|
80
80
|
const [leftoverAmount] = decoded.args;
|
|
81
|
-
|
|
81
|
+
this.setLeftover(balances, this.dai, leftoverAmount);
|
|
82
|
+
break;
|
|
82
83
|
}
|
|
83
84
|
case "usdsToDaiDiff": {
|
|
84
85
|
const [leftoverAmount] = decoded.args;
|
|
85
|
-
|
|
86
|
+
this.setLeftover(balances, this.usds, leftoverAmount);
|
|
87
|
+
break;
|
|
86
88
|
}
|
|
87
89
|
default:
|
|
88
|
-
|
|
90
|
+
super.applyBalanceChanges(balances, decoded);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
@@ -99,18 +99,27 @@ class ERC4626AdapterContract extends import_AbstractAdapter.AbstractAdapterContr
|
|
|
99
99
|
}
|
|
100
100
|
return super.classifyLegacyOperation(parsed, transfers);
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
applyBalanceChanges(balances, decoded) {
|
|
103
103
|
switch (decoded.functionName) {
|
|
104
104
|
case "depositDiff": {
|
|
105
105
|
const [leftoverAmount] = decoded.args;
|
|
106
|
-
|
|
106
|
+
this.setLeftover(balances, this.asset, leftoverAmount);
|
|
107
|
+
break;
|
|
107
108
|
}
|
|
108
109
|
case "redeemDiff": {
|
|
109
110
|
const [leftoverAmount] = decoded.args;
|
|
110
|
-
|
|
111
|
+
this.setLeftover(balances, this.share, leftoverAmount);
|
|
112
|
+
break;
|
|
111
113
|
}
|
|
114
|
+
case "redeem": {
|
|
115
|
+
const [shares] = decoded.args;
|
|
116
|
+
this.spendExact(balances, this.share, shares);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
// `withdraw`/`deposit`/`mint` stay unsupported: they are not emitted
|
|
120
|
+
// by the router (which uses diff variants) or the withdrawal compressor
|
|
112
121
|
default:
|
|
113
|
-
|
|
122
|
+
super.applyBalanceChanges(balances, decoded);
|
|
114
123
|
}
|
|
115
124
|
}
|
|
116
125
|
}
|
|
@@ -74,18 +74,20 @@ class ERC4626ReferralAdapterContract extends import_AbstractAdapter.AbstractAdap
|
|
|
74
74
|
}
|
|
75
75
|
return super.classifyLegacyOperation(parsed, transfers);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
applyBalanceChanges(balances, decoded) {
|
|
78
78
|
switch (decoded.functionName) {
|
|
79
79
|
case "depositDiff": {
|
|
80
80
|
const [leftoverAmount] = decoded.args;
|
|
81
|
-
|
|
81
|
+
this.setLeftover(balances, this.asset, leftoverAmount);
|
|
82
|
+
break;
|
|
82
83
|
}
|
|
83
84
|
case "redeemDiff": {
|
|
84
85
|
const [leftoverAmount] = decoded.args;
|
|
85
|
-
|
|
86
|
+
this.setLeftover(balances, this.targetContract, leftoverAmount);
|
|
87
|
+
break;
|
|
86
88
|
}
|
|
87
89
|
default:
|
|
88
|
-
|
|
90
|
+
super.applyBalanceChanges(balances, decoded);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
@@ -62,19 +62,19 @@ class FluidDexAdapterContract extends import_AbstractAdapter.AbstractAdapterCont
|
|
|
62
62
|
token1: this.#token1 ? this.labelAddress(this.#token1) : void 0
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
applyBalanceChanges(balances, decoded) {
|
|
66
66
|
switch (decoded.functionName) {
|
|
67
67
|
case "swapInDiff": {
|
|
68
68
|
const [swap0to1, leftoverAmount] = decoded.args;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
this.setLeftover(
|
|
70
|
+
balances,
|
|
71
|
+
swap0to1 ? this.token0 : this.token1,
|
|
72
|
+
leftoverAmount
|
|
73
|
+
);
|
|
74
|
+
break;
|
|
75
75
|
}
|
|
76
76
|
default:
|
|
77
|
-
|
|
77
|
+
super.applyBalanceChanges(balances, decoded);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -84,25 +84,28 @@ class InfinifiGatewayAdapterContract extends import_AbstractAdapter.AbstractAdap
|
|
|
84
84
|
)
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
applyBalanceChanges(balances, decoded) {
|
|
88
88
|
switch (decoded.functionName) {
|
|
89
89
|
case "mintDiff": {
|
|
90
90
|
const [leftoverAmount] = decoded.args;
|
|
91
|
-
|
|
91
|
+
this.setLeftover(balances, this.usdc, leftoverAmount);
|
|
92
|
+
break;
|
|
92
93
|
}
|
|
93
94
|
// redeem, stake and lock all spend iUSD
|
|
94
95
|
case "redeemDiff":
|
|
95
96
|
case "stakeDiff":
|
|
96
97
|
case "createPositionDiff": {
|
|
97
98
|
const [leftoverAmount] = decoded.args;
|
|
98
|
-
|
|
99
|
+
this.setLeftover(balances, this.iusd, leftoverAmount);
|
|
100
|
+
break;
|
|
99
101
|
}
|
|
100
102
|
case "unstakeDiff": {
|
|
101
103
|
const [leftoverAmount] = decoded.args;
|
|
102
|
-
|
|
104
|
+
this.setLeftover(balances, this.siusd, leftoverAmount);
|
|
105
|
+
break;
|
|
103
106
|
}
|
|
104
107
|
default:
|
|
105
|
-
|
|
108
|
+
super.applyBalanceChanges(balances, decoded);
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
}
|
|
@@ -54,14 +54,15 @@ class KelpLRTDepositPoolAdapterContract extends import_AbstractAdapter.AbstractA
|
|
|
54
54
|
allowedAssets: this.#allowedAssets?.map((a) => this.labelAddress(a))
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
applyBalanceChanges(balances, decoded) {
|
|
58
58
|
switch (decoded.functionName) {
|
|
59
59
|
case "depositAssetDiff": {
|
|
60
60
|
const [tokenIn, leftoverAmount] = decoded.args;
|
|
61
|
-
|
|
61
|
+
this.setLeftover(balances, tokenIn, leftoverAmount);
|
|
62
|
+
break;
|
|
62
63
|
}
|
|
63
64
|
default:
|
|
64
|
-
|
|
65
|
+
super.applyBalanceChanges(balances, decoded);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -75,15 +75,16 @@ class LidoV1AdapterContract extends import_AbstractAdapter.AbstractAdapterContra
|
|
|
75
75
|
classifyLegacyOperation(_parsed, transfers) {
|
|
76
76
|
return { operation: "LidoSubmit", ...(0, import_transferHelpers.swapFromTransfers)(transfers) };
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
applyBalanceChanges(balances, decoded) {
|
|
79
79
|
switch (decoded.functionName) {
|
|
80
80
|
// the adapter targets the WETH gateway, so WETH is spent
|
|
81
81
|
case "submitDiff": {
|
|
82
82
|
const [leftoverAmount] = decoded.args;
|
|
83
|
-
|
|
83
|
+
this.setLeftover(balances, this.weth, leftoverAmount);
|
|
84
|
+
break;
|
|
84
85
|
}
|
|
85
86
|
default:
|
|
86
|
-
|
|
87
|
+
super.applyBalanceChanges(balances, decoded);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -57,6 +57,35 @@ class MellowClaimerAdapterContract extends import_AbstractAdapter.AbstractAdapte
|
|
|
57
57
|
)
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
+
applyBalanceChanges(balances, decoded) {
|
|
61
|
+
switch (decoded.functionName) {
|
|
62
|
+
// pure "accept" of transferred pending assets, coupled with a Mellow
|
|
63
|
+
// withdrawal request: it moves no ERC-20s, and the withdrawal phantom
|
|
64
|
+
// token effect is credited by the storeExpectedBalances bracket delta
|
|
65
|
+
// built from the compressor's outputs
|
|
66
|
+
case "multiAccept":
|
|
67
|
+
break;
|
|
68
|
+
case "withdrawPhantomToken": {
|
|
69
|
+
const [token, amount] = decoded.args;
|
|
70
|
+
this.spendExact(balances, token, amount);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
// TODO:
|
|
74
|
+
// `multiAcceptAndClaim` (the claim call emitted by the withdrawal
|
|
75
|
+
// compressor) cannot be previewed offline: the burn amount IS in
|
|
76
|
+
// calldata (`maxAssets` == the compressor's `withdrawalTokenSpent`),
|
|
77
|
+
// but the withdrawal phantom token to debit cannot be resolved from
|
|
78
|
+
// the `multiVault` argument. The on-chain adapter only serializes
|
|
79
|
+
// (creditManager, targetContract, allowedMultiVaults) and drops its
|
|
80
|
+
// `phantomTokenToMultiVault` mapping (unlike Midas/Kelp adapters,
|
|
81
|
+
// which serialize aligned token/phantom arrays). Resolving it would
|
|
82
|
+
// require DelayedWithdrawalPlugin state (WithdrawableAsset maps
|
|
83
|
+
// multiVault -> withdrawalPhantomToken) or a contract-side
|
|
84
|
+
// `serialize()` fix.
|
|
85
|
+
default:
|
|
86
|
+
super.applyBalanceChanges(balances, decoded);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
60
89
|
}
|
|
61
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
62
91
|
0 && (module.exports = {
|
|
@@ -73,19 +73,21 @@ class MellowDVVAdapterContract extends import_AbstractAdapter.AbstractAdapterCon
|
|
|
73
73
|
}
|
|
74
74
|
return super.classifyLegacyOperation(parsed, transfers);
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
applyBalanceChanges(balances, decoded) {
|
|
77
77
|
const share = this.#vault ?? this.targetContract;
|
|
78
78
|
switch (decoded.functionName) {
|
|
79
79
|
case "depositDiff": {
|
|
80
80
|
const [leftoverAmount] = decoded.args;
|
|
81
|
-
|
|
81
|
+
this.setLeftover(balances, this.asset, leftoverAmount);
|
|
82
|
+
break;
|
|
82
83
|
}
|
|
83
84
|
case "redeemDiff": {
|
|
84
85
|
const [leftoverAmount] = decoded.args;
|
|
85
|
-
|
|
86
|
+
this.setLeftover(balances, share, leftoverAmount);
|
|
87
|
+
break;
|
|
86
88
|
}
|
|
87
89
|
default:
|
|
88
|
-
|
|
90
|
+
super.applyBalanceChanges(balances, decoded);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
@@ -108,19 +108,26 @@ class MellowERC4626VaultAdapterContract extends import_AbstractAdapter.AbstractA
|
|
|
108
108
|
}
|
|
109
109
|
return super.classifyLegacyOperation(parsed, transfers);
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
applyBalanceChanges(balances, decoded) {
|
|
112
112
|
const share = this.#vault ?? this.targetContract;
|
|
113
113
|
switch (decoded.functionName) {
|
|
114
114
|
case "depositDiff": {
|
|
115
115
|
const [leftoverAmount] = decoded.args;
|
|
116
|
-
|
|
116
|
+
this.setLeftover(balances, this.asset, leftoverAmount);
|
|
117
|
+
break;
|
|
117
118
|
}
|
|
118
119
|
case "redeemDiff": {
|
|
119
120
|
const [leftoverAmount] = decoded.args;
|
|
120
|
-
|
|
121
|
+
this.setLeftover(balances, share, leftoverAmount);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "redeem": {
|
|
125
|
+
const [shares] = decoded.args;
|
|
126
|
+
this.spendExact(balances, share, shares);
|
|
127
|
+
break;
|
|
121
128
|
}
|
|
122
129
|
default:
|
|
123
|
-
|
|
130
|
+
super.applyBalanceChanges(balances, decoded);
|
|
124
131
|
}
|
|
125
132
|
}
|
|
126
133
|
}
|
|
@@ -55,15 +55,16 @@ class MellowWrapperAdapterContract extends import_AbstractAdapter.AbstractAdapte
|
|
|
55
55
|
allowedVaults: this.#allowedVaults?.map((v) => this.labelAddress(v))
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
applyBalanceChanges(balances, decoded) {
|
|
59
59
|
switch (decoded.functionName) {
|
|
60
60
|
case "depositDiff": {
|
|
61
61
|
const weth = this.tokensMeta.mustFindBySymbol("WETH").addr;
|
|
62
62
|
const [leftoverAmount] = decoded.args;
|
|
63
|
-
|
|
63
|
+
this.setLeftover(balances, weth, leftoverAmount);
|
|
64
|
+
break;
|
|
64
65
|
}
|
|
65
66
|
default:
|
|
66
|
-
|
|
67
|
+
super.applyBalanceChanges(balances, decoded);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -97,21 +97,48 @@ class MidasGatewayAdapterContract extends import_AbstractAdapter.AbstractAdapter
|
|
|
97
97
|
}))
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
applyBalanceChanges(balances, decoded) {
|
|
101
101
|
switch (decoded.functionName) {
|
|
102
102
|
case "depositInstantDiff": {
|
|
103
103
|
const [tokenIn, leftoverAmount] = decoded.args;
|
|
104
|
-
|
|
104
|
+
this.setLeftover(balances, tokenIn, leftoverAmount);
|
|
105
|
+
break;
|
|
105
106
|
}
|
|
106
107
|
// redemptions spend the mToken down to the leftover, tokenOut arg is
|
|
107
108
|
// the received token
|
|
108
109
|
case "redeemInstantDiff":
|
|
109
110
|
case "redeemRequestDiff": {
|
|
110
111
|
const [, leftoverAmount] = decoded.args;
|
|
111
|
-
|
|
112
|
+
this.setLeftover(balances, this.mToken, leftoverAmount);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
// exact-input redemption request emitted in-bracket by the withdrawal
|
|
116
|
+
// compressor
|
|
117
|
+
case "redeemRequest": {
|
|
118
|
+
const [, amountMTokenIn] = decoded.args;
|
|
119
|
+
this.spendExact(balances, this.mToken, amountMTokenIn);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
// claim call emitted by the withdrawal compressor
|
|
123
|
+
case "withdrawFromRedeemer": {
|
|
124
|
+
const [, tokenOut, amount] = decoded.args;
|
|
125
|
+
const phantomToken = this.allowedOutputTokens.find(
|
|
126
|
+
(t) => (0, import_viem.isAddressEqual)(t.token, tokenOut)
|
|
127
|
+
)?.phantomToken;
|
|
128
|
+
if (!phantomToken) {
|
|
129
|
+
super.applyBalanceChanges(balances, decoded);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
this.spendExact(balances, phantomToken, amount);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "withdrawPhantomToken": {
|
|
136
|
+
const [token, amount] = decoded.args;
|
|
137
|
+
this.spendExact(balances, token, amount);
|
|
138
|
+
break;
|
|
112
139
|
}
|
|
113
140
|
default:
|
|
114
|
-
|
|
141
|
+
super.applyBalanceChanges(balances, decoded);
|
|
115
142
|
}
|
|
116
143
|
}
|
|
117
144
|
}
|
|
@@ -72,14 +72,15 @@ class MidasIssuanceVaultAdapterContract extends import_AbstractAdapter.AbstractA
|
|
|
72
72
|
allowedTokens: this.#allowedTokens?.map((t) => this.labelAddress(t))
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
applyBalanceChanges(balances, decoded) {
|
|
76
76
|
switch (decoded.functionName) {
|
|
77
77
|
case "depositInstantDiff": {
|
|
78
78
|
const [tokenIn, leftoverAmount] = decoded.args;
|
|
79
|
-
|
|
79
|
+
this.setLeftover(balances, tokenIn, leftoverAmount);
|
|
80
|
+
break;
|
|
80
81
|
}
|
|
81
82
|
default:
|
|
82
|
-
|
|
83
|
+
super.applyBalanceChanges(balances, decoded);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -77,16 +77,17 @@ class MidasRedemptionVaultAdapterContract extends import_AbstractAdapter.Abstrac
|
|
|
77
77
|
}))
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
applyBalanceChanges(balances, decoded) {
|
|
81
81
|
switch (decoded.functionName) {
|
|
82
82
|
// redemption spends the mToken down to the leftover, tokenOut arg is
|
|
83
83
|
// the received token
|
|
84
84
|
case "redeemInstantDiff": {
|
|
85
85
|
const [, leftoverAmount] = decoded.args;
|
|
86
|
-
|
|
86
|
+
this.setLeftover(balances, this.mToken, leftoverAmount);
|
|
87
|
+
break;
|
|
87
88
|
}
|
|
88
89
|
default:
|
|
89
|
-
|
|
90
|
+
super.applyBalanceChanges(balances, decoded);
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
}
|