Skip to content

Commit 4bd9fb7

Browse files
committed
fix: loading zappers
1 parent db191dc commit 4bd9fb7

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/dev/SDKExample.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export class SDKExample {
6060
ignoreUpdateablePrices: true,
6161
marketConfigurators,
6262
});
63+
try {
64+
await this.#sdk.marketRegister.loadZappers();
65+
} catch (e) {
66+
this.#logger?.error(`failed to load zappers: ${e}`);
67+
}
6368
await this.#safeMigrateFaucet(addressProvider);
6469

6570
const puTx =
@@ -77,11 +82,6 @@ export class SDKExample {
7782
await publicClient.waitForTransactionReceipt({ hash });
7883

7984
await this.#sdk.marketRegister.loadMarkets(marketConfigurators, true);
80-
try {
81-
await this.#sdk.marketRegister.loadZappers();
82-
} catch (e) {
83-
this.#logger?.error(`failed to load zappers: ${e}`);
84-
}
8585

8686
this.#logger?.info("attached sdk");
8787
if (outFile) {

src/sdk/market/MarketRegister.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,26 @@ export class MarketRegister extends SDKConstruct {
7474
abi: iPeripheryCompressorAbi,
7575
address: pcAddr,
7676
functionName: "getZappers",
77-
args: [m.configurator, m.pool.pool.address],
77+
args: [m.configurator.address, m.pool.pool.address],
7878
})),
79-
allowFailure: false,
79+
allowFailure: true,
8080
});
81-
this.#zappers = resp.flat() as any as ZapperData[];
81+
82+
const zappers: ZapperData[] = [];
83+
for (let i = 0; i < resp.length; i++) {
84+
const { status, result, error } = resp[i];
85+
const marketConfigurator = this.markets[i].configurator.address;
86+
const pool = this.markets[i].pool.pool.address;
87+
if (status === "success") {
88+
zappers.push(...(result as any as ZapperData[]));
89+
} else {
90+
this.#logger?.error(
91+
`failed to load zapper for market configurator ${this.labelAddress(marketConfigurator)} and pool ${this.labelAddress(pool)}: ${error}`,
92+
);
93+
}
94+
}
95+
this.#zappers = zappers;
96+
8297
const zappersTokens = this.#zappers.flatMap(z => [z.tokenIn, z.tokenOut]);
8398
for (const t of zappersTokens) {
8499
this.sdk.tokensMeta.upsert(t.addr, t);

0 commit comments

Comments
 (0)