Skip to content

Commit 693ce6c

Browse files
committed
fix: comments
1 parent 7d8ee76 commit 693ce6c

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

src/sdk/market/ZapperRegister.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class ZapperRegister extends SDKConstruct {
125125
}
126126
/**
127127
* Zappers that are broken and should be skipped
128+
* Zapper with this adress was deployed with broken contract and shouldn't be used
128129
*/
129130
const BROKEN_ZAPPERS: AddressMap<boolean> = new AddressMap(
130131
[["0x90D66b03EC4D462e42e3c7741049FB46a4a03B69", true]],

src/sdk/pools/PoolService.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import type {
2323

2424
const NATIVE_ADDRESS: Address = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
2525

26+
/**
27+
* This map is used to filter out zappers with tokenIn === v2 diesel tokens
28+
* such zappers are returned by compressor but useless for v3 pools on deposit step
29+
*/
2630
const POOL_TOKENS_TO_MIGRATE: AddressMap<string> = new AddressMap([
2731
// v2 diesels
2832
["0x6CFaF95457d7688022FC53e7AbE052ef8DFBbdBA", "dDAI"],
@@ -254,9 +258,16 @@ export class PoolService extends SDKConstruct implements IPoolsService {
254258
return this.#withdrawalMetadata("classic", pool, tokenIn, tokenOut, true);
255259
}
256260

261+
/**
262+
* Filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
263+
* Also omits "migration" zappers (v3 -> v3.1) since they are treated in a different way
264+
*/
257265
#getDepositZappers(poolAddr: Address) {
258266
const zappers = this.sdk.marketRegister.poolZappers(poolAddr);
259-
return zappers.filter(z => z.type !== "migration");
267+
return zappers.filter(
268+
z =>
269+
z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr),
270+
);
260271
}
261272

262273
#depositTokensIn(poolAddr: Address, allowDirectDeposit: boolean): Address[] {
@@ -270,11 +281,7 @@ export class PoolService extends SDKConstruct implements IPoolsService {
270281
// find all zappers that produce pool.dieselToken (=== pool.address)
271282
const zappers = this.#getDepositZappers(poolAddr);
272283
for (const z of zappers) {
273-
// filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
274-
if (
275-
hexEq(z.tokenOut.addr, poolAddr) &&
276-
!POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
277-
) {
284+
if (hexEq(z.tokenOut.addr, poolAddr)) {
278285
result.add(z.tokenIn.addr);
279286
}
280287
}
@@ -303,10 +310,7 @@ export class PoolService extends SDKConstruct implements IPoolsService {
303310
// fall zappers tokenOut (since withdrawing is allowed from any asset)
304311
const zappers = this.#getDepositZappers(poolAddr);
305312
for (const z of zappers) {
306-
// filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
307-
if (!POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)) {
308-
result.add(z.tokenOut.addr);
309-
}
313+
result.add(z.tokenOut.addr);
310314
}
311315

312316
if (result.size === 0) {
@@ -330,10 +334,7 @@ export class PoolService extends SDKConstruct implements IPoolsService {
330334
const zappers = this.#getDepositZappers(poolAddr);
331335
for (const z of zappers) {
332336
// filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
333-
if (
334-
hexEq(z.tokenIn.addr, tokenIn) &&
335-
!POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
336-
) {
337+
if (hexEq(z.tokenIn.addr, tokenIn)) {
337338
result.add(z.tokenOut.addr);
338339
}
339340
}
@@ -365,10 +366,7 @@ export class PoolService extends SDKConstruct implements IPoolsService {
365366
// find all zappers by tokenIn, get their tokenOuts
366367
const zappers = this.#getDepositZappers(poolAddr);
367368
for (const z of zappers) {
368-
if (
369-
hexEq(z.tokenOut.addr, tokenIn) &&
370-
!POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr)
371-
) {
369+
if (hexEq(z.tokenOut.addr, tokenIn)) {
372370
result.add(z.tokenIn.addr);
373371
}
374372
}
@@ -390,14 +388,21 @@ export class PoolService extends SDKConstruct implements IPoolsService {
390388
return r;
391389
}
392390

391+
/**
392+
* Filter out v2 diesel tokens (can come from migration v2 -> v3 zappers)
393+
* Also omits "migration" zappers (v3 -> v3.1) since they are treated in a different way
394+
*/
393395
#getDepositZapper(
394396
poolAddr: Address,
395397
tokenIn: Address,
396398
tokenOut: Address,
397399
): ZapperData | undefined {
398400
const zappers = this.sdk.marketRegister
399401
.getZapper(poolAddr, tokenIn, tokenOut)
400-
?.filter(z => z.type !== "migration");
402+
?.filter(
403+
z =>
404+
z.type !== "migration" && !POOL_TOKENS_TO_MIGRATE.has(z.tokenIn.addr),
405+
);
401406
if (zappers && zappers.length > 1) {
402407
throw new Error(
403408
`Multiple zappers found for tokenIn ${this.labelAddress(

0 commit comments

Comments
 (0)