@gearbox-protocol/sdk 13.5.0-next.2 → 13.5.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.
- package/dist/cjs/sdk/market/ZapperRegister.js +0 -119
- package/dist/cjs/sdk/pools/PoolService.js +46 -15
- package/dist/esm/sdk/market/ZapperRegister.js +0 -119
- package/dist/esm/sdk/pools/PoolService.js +46 -15
- package/package.json +1 -1
- package/dist/cjs/sdk/pools/constants.js +0 -37
- package/dist/esm/sdk/pools/constants.js +0 -13
- package/dist/types/sdk/pools/constants.d.ts +0 -7
|
@@ -73,14 +73,8 @@ class ZapperRegister extends import_base.SDKConstruct {
|
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
for (const z of MIGRATION_ZAPPERS[this.networkType] ?? []) {
|
|
77
|
-
this.#addZapper({ ...z, type: "migration" });
|
|
78
|
-
}
|
|
79
76
|
}
|
|
80
77
|
#addZapper(z) {
|
|
81
|
-
if (BROKEN_ZAPPERS.has(z.baseParams.addr)) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
78
|
const existing = this.zappers.get(z.pool);
|
|
85
79
|
if (existing) {
|
|
86
80
|
const hasZapper = existing.some(
|
|
@@ -117,119 +111,6 @@ class ZapperRegister extends import_base.SDKConstruct {
|
|
|
117
111
|
return zappers;
|
|
118
112
|
}
|
|
119
113
|
}
|
|
120
|
-
const BROKEN_ZAPPERS = new import_utils.AddressMap(
|
|
121
|
-
[["0x90D66b03EC4D462e42e3c7741049FB46a4a03B69", true]],
|
|
122
|
-
"brokenZappers"
|
|
123
|
-
);
|
|
124
|
-
const MIGRATION_ZAPPERS = {
|
|
125
|
-
Mainnet: [
|
|
126
|
-
{
|
|
127
|
-
baseParams: {
|
|
128
|
-
addr: "0x85f540c9d5b3be85dbad54085aa18d49e23cd254",
|
|
129
|
-
version: 310n,
|
|
130
|
-
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
131
|
-
serializedParams: "0x0000000000000000000000000418feb7d0b25c411eb77cd654305d29fcbff685000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
|
|
132
|
-
},
|
|
133
|
-
tokenIn: {
|
|
134
|
-
addr: "0x0418fEB7d0B25C411EB77cD654305d29FcbFf685",
|
|
135
|
-
symbol: "farmdWETHV3",
|
|
136
|
-
name: "Farming of Trade WETH v3",
|
|
137
|
-
decimals: 18
|
|
138
|
-
},
|
|
139
|
-
tokenOut: {
|
|
140
|
-
addr: "0x9396DCbf78fc526bb003665337C5E73b699571EF",
|
|
141
|
-
symbol: "kpkWETH",
|
|
142
|
-
name: "WETH Market",
|
|
143
|
-
decimals: 18
|
|
144
|
-
},
|
|
145
|
-
pool: "0x9396DCbf78fc526bb003665337C5E73b699571EF"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
baseParams: {
|
|
149
|
-
addr: "0x5A5F69e134765Cb0169f280c2f2A7d8AdF8eFd29",
|
|
150
|
-
version: 310n,
|
|
151
|
-
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
152
|
-
serializedParams: "0x000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
|
|
153
|
-
},
|
|
154
|
-
tokenIn: {
|
|
155
|
-
addr: "0xda0002859B2d05F66a753d8241fCDE8623f26F4f",
|
|
156
|
-
symbol: "dWETHV3",
|
|
157
|
-
name: "Trade WETH v3",
|
|
158
|
-
decimals: 18
|
|
159
|
-
},
|
|
160
|
-
tokenOut: {
|
|
161
|
-
addr: "0x9396DCbf78fc526bb003665337C5E73b699571EF",
|
|
162
|
-
symbol: "kpkWETH",
|
|
163
|
-
name: "WETH Market",
|
|
164
|
-
decimals: 18
|
|
165
|
-
},
|
|
166
|
-
pool: "0x9396DCbf78fc526bb003665337C5E73b699571EF"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
baseParams: {
|
|
170
|
-
addr: "0xbff5E156779aDCE4C61ecc6bCc32cba89eD7dfa6",
|
|
171
|
-
version: 310n,
|
|
172
|
-
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
173
|
-
serializedParams: "0x000000000000000000000000ff94993fa7ea27efc943645f95adb36c1b81244b"
|
|
174
|
-
},
|
|
175
|
-
tokenIn: {
|
|
176
|
-
addr: "0xFF94993fA7EA27Efc943645F95Adb36C1b81244b",
|
|
177
|
-
symbol: "dWSTETHV3",
|
|
178
|
-
name: "wstETH v3",
|
|
179
|
-
decimals: 18
|
|
180
|
-
},
|
|
181
|
-
tokenOut: {
|
|
182
|
-
addr: "0xA9d17f6D3285208280a1Fd9B94479c62e0AABa64",
|
|
183
|
-
symbol: "kpkwstETH",
|
|
184
|
-
name: "wstETH v3",
|
|
185
|
-
decimals: 18
|
|
186
|
-
},
|
|
187
|
-
pool: "0xA9d17f6D3285208280a1Fd9B94479c62e0AABa64"
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
baseParams: {
|
|
191
|
-
addr: "0x62af1fc6e54e66aba5322a3491b5ce1808a6fe89",
|
|
192
|
-
version: 310n,
|
|
193
|
-
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
194
|
-
serializedParams: "0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
195
|
-
},
|
|
196
|
-
tokenIn: {
|
|
197
|
-
addr: "0xda00000035fef4082F78dEF6A8903bee419FbF8E",
|
|
198
|
-
symbol: "dUSDCV3",
|
|
199
|
-
name: "Trade USDC v3",
|
|
200
|
-
decimals: 6
|
|
201
|
-
},
|
|
202
|
-
tokenOut: {
|
|
203
|
-
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
204
|
-
symbol: "rUSDC",
|
|
205
|
-
name: "Tulipa USDC",
|
|
206
|
-
decimals: 6
|
|
207
|
-
},
|
|
208
|
-
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
baseParams: {
|
|
212
|
-
addr: "0x70383bac778f0285ddb5f35afbd631e5a4675c58",
|
|
213
|
-
version: 310n,
|
|
214
|
-
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
215
|
-
serializedParams: "0x0000000000000000000000009ef444a6d7f4a5adcd68fd5329aa5240c90e14d2000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
216
|
-
},
|
|
217
|
-
tokenIn: {
|
|
218
|
-
addr: "0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2",
|
|
219
|
-
symbol: "farmdUSDCV3",
|
|
220
|
-
name: "Farming of Trade USDC v3",
|
|
221
|
-
decimals: 6
|
|
222
|
-
},
|
|
223
|
-
tokenOut: {
|
|
224
|
-
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
225
|
-
symbol: "rUSDC",
|
|
226
|
-
name: "Tulipa USDC",
|
|
227
|
-
decimals: 6
|
|
228
|
-
},
|
|
229
|
-
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
};
|
|
233
114
|
// Annotate the CommonJS export names for ESM import in node:
|
|
234
115
|
0 && (module.exports = {
|
|
235
116
|
ZapperRegister
|
|
@@ -28,7 +28,6 @@ var import_iZapper = require("../../abi/iZapper.js");
|
|
|
28
28
|
var import_base = require("../base/index.js");
|
|
29
29
|
var import_constants = require("../constants/index.js");
|
|
30
30
|
var import_utils = require("../utils/index.js");
|
|
31
|
-
var import_constants2 = require("./constants.js");
|
|
32
31
|
class PoolService extends import_base.SDKConstruct {
|
|
33
32
|
/**
|
|
34
33
|
* @inheritdoc IPoolsService.getDepositTokensIn
|
|
@@ -142,16 +141,19 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
142
141
|
return this.#withdrawalMetadata("classic", pool, tokenIn, tokenOut, true);
|
|
143
142
|
}
|
|
144
143
|
/**
|
|
145
|
-
*
|
|
146
|
-
* Filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
|
|
147
|
-
* Also omits "migration" zappers (v3 -> v3.1) since they are treated in a different way
|
|
144
|
+
* Returns non-migration zappers available for the pool.
|
|
148
145
|
*/
|
|
149
146
|
#getDepositZappers(poolAddr) {
|
|
150
147
|
const zappers = this.sdk.marketRegister.poolZappers(poolAddr);
|
|
151
|
-
return zappers.filter(
|
|
152
|
-
(z) => z.type !== "migration" && !import_constants2.POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
|
|
153
|
-
);
|
|
148
|
+
return zappers.filter((z) => z.type !== "migration");
|
|
154
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns all supported deposit input tokens for a pool.
|
|
152
|
+
*
|
|
153
|
+
* Includes:
|
|
154
|
+
* - zapper `tokenIn` where zapper output is pool diesel token
|
|
155
|
+
* - pool underlying token when direct deposit is enabled
|
|
156
|
+
*/
|
|
155
157
|
#depositTokensIn(poolAddr, allowDirectDeposit) {
|
|
156
158
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
157
159
|
const result = new import_utils.AddressSet();
|
|
@@ -171,6 +173,13 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
171
173
|
}
|
|
172
174
|
return result.asArray();
|
|
173
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns all supported withdrawal input tokens for a pool.
|
|
178
|
+
*
|
|
179
|
+
* Includes:
|
|
180
|
+
* - pool diesel token when direct withdrawal is enabled
|
|
181
|
+
* - all zapper that can be redeemed from the pool
|
|
182
|
+
*/
|
|
174
183
|
#withdrawalTokensIn(poolAddr, allowDirectDeposit) {
|
|
175
184
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
176
185
|
const result = new import_utils.AddressSet();
|
|
@@ -188,6 +197,13 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
188
197
|
}
|
|
189
198
|
return result.asArray();
|
|
190
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Returns possible deposit outputs for a given input token.
|
|
202
|
+
*
|
|
203
|
+
* Includes:
|
|
204
|
+
* - zapper `tokenOut` for `z.tokenIn` matching `tokenIn`
|
|
205
|
+
* - pool diesel token for direct underlying deposit when enabled
|
|
206
|
+
*/
|
|
191
207
|
#depositTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
|
|
192
208
|
const result = new import_utils.AddressSet();
|
|
193
209
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
@@ -210,6 +226,13 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
210
226
|
const r = result.asArray();
|
|
211
227
|
return r;
|
|
212
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Returns possible withdrawal outputs for a given input token.
|
|
231
|
+
*
|
|
232
|
+
* Includes:
|
|
233
|
+
* - zapper `tokenIn` where zapper `z.tokenOut` matches requested `tokenIn`
|
|
234
|
+
* - pool underlying token for direct diesel-token redemption when enabled
|
|
235
|
+
*/
|
|
213
236
|
#withdrawalTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
|
|
214
237
|
const result = new import_utils.AddressSet();
|
|
215
238
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
@@ -233,14 +256,12 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
233
256
|
return r;
|
|
234
257
|
}
|
|
235
258
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
259
|
+
* Returns a single non-migration zapper route for the given token pair.
|
|
260
|
+
*
|
|
261
|
+
* Throws when multiple matching zappers exist to keep call construction deterministic.
|
|
239
262
|
*/
|
|
240
263
|
#getDepositZapper(poolAddr, tokenIn, tokenOut) {
|
|
241
|
-
const zappers = this.sdk.marketRegister.getZapper(poolAddr, tokenIn, tokenOut)?.filter(
|
|
242
|
-
(z) => z.type !== "migration" && !import_constants2.POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
|
|
243
|
-
);
|
|
264
|
+
const zappers = this.sdk.marketRegister.getZapper(poolAddr, tokenIn, tokenOut)?.filter((z) => z.type !== "migration");
|
|
244
265
|
if (zappers && zappers.length > 1) {
|
|
245
266
|
throw new Error(
|
|
246
267
|
`Multiple zappers found for tokenIn ${this.labelAddress(
|
|
@@ -252,6 +273,11 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
252
273
|
}
|
|
253
274
|
return zappers?.[0];
|
|
254
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Builds metadata required to execute a deposit operation.
|
|
278
|
+
*
|
|
279
|
+
* Includes selected zapper route (if any), approve target, and permit support flag.
|
|
280
|
+
*/
|
|
255
281
|
#depositMetadata(type, poolAddr, tokenIn, tokenOut, allowDirectDeposit) {
|
|
256
282
|
if (!tokenOut) {
|
|
257
283
|
throw new Error("tokenOut is required for classic pool deposit");
|
|
@@ -269,7 +295,7 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
269
295
|
}
|
|
270
296
|
return {
|
|
271
297
|
zapper,
|
|
272
|
-
// zapper
|
|
298
|
+
// Approval target is zapper when routed, otherwise the pool contract.
|
|
273
299
|
approveTarget: zapper?.baseParams.addr ?? pool.pool.address,
|
|
274
300
|
// TODO: instead of permissible, return permitType depending on tokenIn
|
|
275
301
|
// "none" | "eip2612" | "dai_like";
|
|
@@ -277,6 +303,11 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
277
303
|
type
|
|
278
304
|
};
|
|
279
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Builds metadata required to execute a withdrawal operation.
|
|
308
|
+
*
|
|
309
|
+
* Includes selected zapper route (if any), approve target, and permit support flag.
|
|
310
|
+
*/
|
|
280
311
|
#withdrawalMetadata(type, poolAddr, tokenIn, tokenOut, allowDirectDeposit) {
|
|
281
312
|
if (!tokenOut) {
|
|
282
313
|
throw new Error("tokenOut is required for classic pool deposit");
|
|
@@ -293,7 +324,7 @@ class PoolService extends import_base.SDKConstruct {
|
|
|
293
324
|
}
|
|
294
325
|
return {
|
|
295
326
|
zapper,
|
|
296
|
-
//
|
|
327
|
+
// Approval target exists only for zapper-based withdrawals.
|
|
297
328
|
approveTarget: zapper?.baseParams.addr,
|
|
298
329
|
// TODO: instead of permissible, return permitType depending on tokenIn
|
|
299
330
|
// "none" | "eip2612" | "dai_like";
|
|
@@ -53,14 +53,8 @@ class ZapperRegister extends SDKConstruct {
|
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
for (const z of MIGRATION_ZAPPERS[this.networkType] ?? []) {
|
|
57
|
-
this.#addZapper({ ...z, type: "migration" });
|
|
58
|
-
}
|
|
59
56
|
}
|
|
60
57
|
#addZapper(z) {
|
|
61
|
-
if (BROKEN_ZAPPERS.has(z.baseParams.addr)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
58
|
const existing = this.zappers.get(z.pool);
|
|
65
59
|
if (existing) {
|
|
66
60
|
const hasZapper = existing.some(
|
|
@@ -97,119 +91,6 @@ class ZapperRegister extends SDKConstruct {
|
|
|
97
91
|
return zappers;
|
|
98
92
|
}
|
|
99
93
|
}
|
|
100
|
-
const BROKEN_ZAPPERS = new AddressMap(
|
|
101
|
-
[["0x90D66b03EC4D462e42e3c7741049FB46a4a03B69", true]],
|
|
102
|
-
"brokenZappers"
|
|
103
|
-
);
|
|
104
|
-
const MIGRATION_ZAPPERS = {
|
|
105
|
-
Mainnet: [
|
|
106
|
-
{
|
|
107
|
-
baseParams: {
|
|
108
|
-
addr: "0x85f540c9d5b3be85dbad54085aa18d49e23cd254",
|
|
109
|
-
version: 310n,
|
|
110
|
-
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
111
|
-
serializedParams: "0x0000000000000000000000000418feb7d0b25c411eb77cd654305d29fcbff685000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
|
|
112
|
-
},
|
|
113
|
-
tokenIn: {
|
|
114
|
-
addr: "0x0418fEB7d0B25C411EB77cD654305d29FcbFf685",
|
|
115
|
-
symbol: "farmdWETHV3",
|
|
116
|
-
name: "Farming of Trade WETH v3",
|
|
117
|
-
decimals: 18
|
|
118
|
-
},
|
|
119
|
-
tokenOut: {
|
|
120
|
-
addr: "0x9396DCbf78fc526bb003665337C5E73b699571EF",
|
|
121
|
-
symbol: "kpkWETH",
|
|
122
|
-
name: "WETH Market",
|
|
123
|
-
decimals: 18
|
|
124
|
-
},
|
|
125
|
-
pool: "0x9396DCbf78fc526bb003665337C5E73b699571EF"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
baseParams: {
|
|
129
|
-
addr: "0x5A5F69e134765Cb0169f280c2f2A7d8AdF8eFd29",
|
|
130
|
-
version: 310n,
|
|
131
|
-
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
132
|
-
serializedParams: "0x000000000000000000000000da0002859b2d05f66a753d8241fcde8623f26f4f"
|
|
133
|
-
},
|
|
134
|
-
tokenIn: {
|
|
135
|
-
addr: "0xda0002859B2d05F66a753d8241fCDE8623f26F4f",
|
|
136
|
-
symbol: "dWETHV3",
|
|
137
|
-
name: "Trade WETH v3",
|
|
138
|
-
decimals: 18
|
|
139
|
-
},
|
|
140
|
-
tokenOut: {
|
|
141
|
-
addr: "0x9396DCbf78fc526bb003665337C5E73b699571EF",
|
|
142
|
-
symbol: "kpkWETH",
|
|
143
|
-
name: "WETH Market",
|
|
144
|
-
decimals: 18
|
|
145
|
-
},
|
|
146
|
-
pool: "0x9396DCbf78fc526bb003665337C5E73b699571EF"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
baseParams: {
|
|
150
|
-
addr: "0xbff5E156779aDCE4C61ecc6bCc32cba89eD7dfa6",
|
|
151
|
-
version: 310n,
|
|
152
|
-
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
153
|
-
serializedParams: "0x000000000000000000000000ff94993fa7ea27efc943645f95adb36c1b81244b"
|
|
154
|
-
},
|
|
155
|
-
tokenIn: {
|
|
156
|
-
addr: "0xFF94993fA7EA27Efc943645F95Adb36C1b81244b",
|
|
157
|
-
symbol: "dWSTETHV3",
|
|
158
|
-
name: "wstETH v3",
|
|
159
|
-
decimals: 18
|
|
160
|
-
},
|
|
161
|
-
tokenOut: {
|
|
162
|
-
addr: "0xA9d17f6D3285208280a1Fd9B94479c62e0AABa64",
|
|
163
|
-
symbol: "kpkwstETH",
|
|
164
|
-
name: "wstETH v3",
|
|
165
|
-
decimals: 18
|
|
166
|
-
},
|
|
167
|
-
pool: "0xA9d17f6D3285208280a1Fd9B94479c62e0AABa64"
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
baseParams: {
|
|
171
|
-
addr: "0x62af1fc6e54e66aba5322a3491b5ce1808a6fe89",
|
|
172
|
-
version: 310n,
|
|
173
|
-
contractType: "0x5a41505045523a3a455243343632360000000000000000000000000000000000",
|
|
174
|
-
serializedParams: "0x000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
175
|
-
},
|
|
176
|
-
tokenIn: {
|
|
177
|
-
addr: "0xda00000035fef4082F78dEF6A8903bee419FbF8E",
|
|
178
|
-
symbol: "dUSDCV3",
|
|
179
|
-
name: "Trade USDC v3",
|
|
180
|
-
decimals: 6
|
|
181
|
-
},
|
|
182
|
-
tokenOut: {
|
|
183
|
-
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
184
|
-
symbol: "rUSDC",
|
|
185
|
-
name: "Tulipa USDC",
|
|
186
|
-
decimals: 6
|
|
187
|
-
},
|
|
188
|
-
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
baseParams: {
|
|
192
|
-
addr: "0x70383bac778f0285ddb5f35afbd631e5a4675c58",
|
|
193
|
-
version: 310n,
|
|
194
|
-
contractType: "0x5a41505045523a3a5354414b45445f4552433436323600000000000000000000",
|
|
195
|
-
serializedParams: "0x0000000000000000000000009ef444a6d7f4a5adcd68fd5329aa5240c90e14d2000000000000000000000000da00000035fef4082f78def6a8903bee419fbf8e"
|
|
196
|
-
},
|
|
197
|
-
tokenIn: {
|
|
198
|
-
addr: "0x9ef444a6d7F4A5adcd68FD5329aA5240C90E14d2",
|
|
199
|
-
symbol: "farmdUSDCV3",
|
|
200
|
-
name: "Farming of Trade USDC v3",
|
|
201
|
-
decimals: 6
|
|
202
|
-
},
|
|
203
|
-
tokenOut: {
|
|
204
|
-
addr: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4",
|
|
205
|
-
symbol: "rUSDC",
|
|
206
|
-
name: "Tulipa USDC",
|
|
207
|
-
decimals: 6
|
|
208
|
-
},
|
|
209
|
-
pool: "0xF0795C47fA58d00f5F77F4D5c01F31eE891E21B4"
|
|
210
|
-
}
|
|
211
|
-
]
|
|
212
|
-
};
|
|
213
94
|
export {
|
|
214
95
|
ZapperRegister
|
|
215
96
|
};
|
|
@@ -5,7 +5,6 @@ import { iZapperAbi } from "../../abi/iZapper.js";
|
|
|
5
5
|
import { SDKConstruct } from "../base/index.js";
|
|
6
6
|
import { NATIVE_ADDRESS } from "../constants/index.js";
|
|
7
7
|
import { AddressSet, hexEq } from "../utils/index.js";
|
|
8
|
-
import { POOL_TOKENS_TO_MIGRATE } from "./constants.js";
|
|
9
8
|
class PoolService extends SDKConstruct {
|
|
10
9
|
/**
|
|
11
10
|
* @inheritdoc IPoolsService.getDepositTokensIn
|
|
@@ -119,16 +118,19 @@ class PoolService extends SDKConstruct {
|
|
|
119
118
|
return this.#withdrawalMetadata("classic", pool, tokenIn, tokenOut, true);
|
|
120
119
|
}
|
|
121
120
|
/**
|
|
122
|
-
*
|
|
123
|
-
* Filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
|
|
124
|
-
* Also omits "migration" zappers (v3 -> v3.1) since they are treated in a different way
|
|
121
|
+
* Returns non-migration zappers available for the pool.
|
|
125
122
|
*/
|
|
126
123
|
#getDepositZappers(poolAddr) {
|
|
127
124
|
const zappers = this.sdk.marketRegister.poolZappers(poolAddr);
|
|
128
|
-
return zappers.filter(
|
|
129
|
-
(z) => z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
|
|
130
|
-
);
|
|
125
|
+
return zappers.filter((z) => z.type !== "migration");
|
|
131
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns all supported deposit input tokens for a pool.
|
|
129
|
+
*
|
|
130
|
+
* Includes:
|
|
131
|
+
* - zapper `tokenIn` where zapper output is pool diesel token
|
|
132
|
+
* - pool underlying token when direct deposit is enabled
|
|
133
|
+
*/
|
|
132
134
|
#depositTokensIn(poolAddr, allowDirectDeposit) {
|
|
133
135
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
134
136
|
const result = new AddressSet();
|
|
@@ -148,6 +150,13 @@ class PoolService extends SDKConstruct {
|
|
|
148
150
|
}
|
|
149
151
|
return result.asArray();
|
|
150
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns all supported withdrawal input tokens for a pool.
|
|
155
|
+
*
|
|
156
|
+
* Includes:
|
|
157
|
+
* - pool diesel token when direct withdrawal is enabled
|
|
158
|
+
* - all zapper that can be redeemed from the pool
|
|
159
|
+
*/
|
|
151
160
|
#withdrawalTokensIn(poolAddr, allowDirectDeposit) {
|
|
152
161
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
153
162
|
const result = new AddressSet();
|
|
@@ -165,6 +174,13 @@ class PoolService extends SDKConstruct {
|
|
|
165
174
|
}
|
|
166
175
|
return result.asArray();
|
|
167
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns possible deposit outputs for a given input token.
|
|
179
|
+
*
|
|
180
|
+
* Includes:
|
|
181
|
+
* - zapper `tokenOut` for `z.tokenIn` matching `tokenIn`
|
|
182
|
+
* - pool diesel token for direct underlying deposit when enabled
|
|
183
|
+
*/
|
|
168
184
|
#depositTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
|
|
169
185
|
const result = new AddressSet();
|
|
170
186
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
@@ -187,6 +203,13 @@ class PoolService extends SDKConstruct {
|
|
|
187
203
|
const r = result.asArray();
|
|
188
204
|
return r;
|
|
189
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Returns possible withdrawal outputs for a given input token.
|
|
208
|
+
*
|
|
209
|
+
* Includes:
|
|
210
|
+
* - zapper `tokenIn` where zapper `z.tokenOut` matches requested `tokenIn`
|
|
211
|
+
* - pool underlying token for direct diesel-token redemption when enabled
|
|
212
|
+
*/
|
|
190
213
|
#withdrawalTokensOut(poolAddr, tokenIn, allowDirectDeposit) {
|
|
191
214
|
const result = new AddressSet();
|
|
192
215
|
const { pool } = this.sdk.marketRegister.findByPool(poolAddr);
|
|
@@ -210,14 +233,12 @@ class PoolService extends SDKConstruct {
|
|
|
210
233
|
return r;
|
|
211
234
|
}
|
|
212
235
|
/**
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
236
|
+
* Returns a single non-migration zapper route for the given token pair.
|
|
237
|
+
*
|
|
238
|
+
* Throws when multiple matching zappers exist to keep call construction deterministic.
|
|
216
239
|
*/
|
|
217
240
|
#getDepositZapper(poolAddr, tokenIn, tokenOut) {
|
|
218
|
-
const zappers = this.sdk.marketRegister.getZapper(poolAddr, tokenIn, tokenOut)?.filter(
|
|
219
|
-
(z) => z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
|
|
220
|
-
);
|
|
241
|
+
const zappers = this.sdk.marketRegister.getZapper(poolAddr, tokenIn, tokenOut)?.filter((z) => z.type !== "migration");
|
|
221
242
|
if (zappers && zappers.length > 1) {
|
|
222
243
|
throw new Error(
|
|
223
244
|
`Multiple zappers found for tokenIn ${this.labelAddress(
|
|
@@ -229,6 +250,11 @@ class PoolService extends SDKConstruct {
|
|
|
229
250
|
}
|
|
230
251
|
return zappers?.[0];
|
|
231
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Builds metadata required to execute a deposit operation.
|
|
255
|
+
*
|
|
256
|
+
* Includes selected zapper route (if any), approve target, and permit support flag.
|
|
257
|
+
*/
|
|
232
258
|
#depositMetadata(type, poolAddr, tokenIn, tokenOut, allowDirectDeposit) {
|
|
233
259
|
if (!tokenOut) {
|
|
234
260
|
throw new Error("tokenOut is required for classic pool deposit");
|
|
@@ -246,7 +272,7 @@ class PoolService extends SDKConstruct {
|
|
|
246
272
|
}
|
|
247
273
|
return {
|
|
248
274
|
zapper,
|
|
249
|
-
// zapper
|
|
275
|
+
// Approval target is zapper when routed, otherwise the pool contract.
|
|
250
276
|
approveTarget: zapper?.baseParams.addr ?? pool.pool.address,
|
|
251
277
|
// TODO: instead of permissible, return permitType depending on tokenIn
|
|
252
278
|
// "none" | "eip2612" | "dai_like";
|
|
@@ -254,6 +280,11 @@ class PoolService extends SDKConstruct {
|
|
|
254
280
|
type
|
|
255
281
|
};
|
|
256
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Builds metadata required to execute a withdrawal operation.
|
|
285
|
+
*
|
|
286
|
+
* Includes selected zapper route (if any), approve target, and permit support flag.
|
|
287
|
+
*/
|
|
257
288
|
#withdrawalMetadata(type, poolAddr, tokenIn, tokenOut, allowDirectDeposit) {
|
|
258
289
|
if (!tokenOut) {
|
|
259
290
|
throw new Error("tokenOut is required for classic pool deposit");
|
|
@@ -270,7 +301,7 @@ class PoolService extends SDKConstruct {
|
|
|
270
301
|
}
|
|
271
302
|
return {
|
|
272
303
|
zapper,
|
|
273
|
-
//
|
|
304
|
+
// Approval target exists only for zapper-based withdrawals.
|
|
274
305
|
approveTarget: zapper?.baseParams.addr,
|
|
275
306
|
// TODO: instead of permissible, return permitType depending on tokenIn
|
|
276
307
|
// "none" | "eip2612" | "dai_like";
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var constants_exports = {};
|
|
20
|
-
__export(constants_exports, {
|
|
21
|
-
POOL_TOKENS_TO_MIGRATE: () => POOL_TOKENS_TO_MIGRATE
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(constants_exports);
|
|
24
|
-
var import_utils = require("../utils/index.js");
|
|
25
|
-
const POOL_TOKENS_TO_MIGRATE = new import_utils.AddressMap([
|
|
26
|
-
// v2 diesels
|
|
27
|
-
["0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA", "dDAI"],
|
|
28
|
-
["0xc411dB5f5Eb3f7d552F9B8454B2D74097ccdE6E3", "dUSDC"],
|
|
29
|
-
["0xe753260F1955e8678DCeA8887759e07aa57E8c54", "dWBTC"],
|
|
30
|
-
["0xF21fc650C1B34eb0FDE786D52d23dA99Db3D6278", "dWETH"],
|
|
31
|
-
["0x2158034dB06f06dcB9A786D2F1F8c38781bA779d", "dwstETH"],
|
|
32
|
-
["0x8A1112AFef7F4FC7c066a77AABBc01b3Fff31D47", "dFRAX"]
|
|
33
|
-
]);
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
POOL_TOKENS_TO_MIGRATE
|
|
37
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AddressMap } from "../utils/index.js";
|
|
2
|
-
const POOL_TOKENS_TO_MIGRATE = new AddressMap([
|
|
3
|
-
// v2 diesels
|
|
4
|
-
["0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA", "dDAI"],
|
|
5
|
-
["0xc411dB5f5Eb3f7d552F9B8454B2D74097ccdE6E3", "dUSDC"],
|
|
6
|
-
["0xe753260F1955e8678DCeA8887759e07aa57E8c54", "dWBTC"],
|
|
7
|
-
["0xF21fc650C1B34eb0FDE786D52d23dA99Db3D6278", "dWETH"],
|
|
8
|
-
["0x2158034dB06f06dcB9A786D2F1F8c38781bA779d", "dwstETH"],
|
|
9
|
-
["0x8A1112AFef7F4FC7c066a77AABBc01b3Fff31D47", "dFRAX"]
|
|
10
|
-
]);
|
|
11
|
-
export {
|
|
12
|
-
POOL_TOKENS_TO_MIGRATE
|
|
13
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AddressMap } from "../utils/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* TODO: is it still needed after v3.0 deprecation?
|
|
4
|
-
* This map is used to filter out zappers with tokenIn === v2 diesel tokens
|
|
5
|
-
* such zappers are returned by compressor but useless for v3 pools on deposit step
|
|
6
|
-
*/
|
|
7
|
-
export declare const POOL_TOKENS_TO_MIGRATE: AddressMap<string>;
|