Skip to content

Commit 6d90efb

Browse files
committed
fix: dump more info to s3
1 parent 55738a2 commit 6d90efb

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@gearbox-protocol/cli-utils": "^5.45.15",
3030
"@gearbox-protocol/liquidator-contracts": "^1.36.0-experimental.41",
3131
"@gearbox-protocol/liquidator-v2-contracts": "^2.4.0",
32-
"@gearbox-protocol/sdk": "8.27.9",
32+
"@gearbox-protocol/sdk": "8.27.10",
3333
"@gearbox-protocol/types": "^1.14.8",
3434
"@types/node": "^24.3.1",
3535
"@uniswap/sdk-core": "^7.7.2",

src/MulticallSpy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export default class MulticallSpy {
8080
Body: JSON.stringify(this.#detectedCalls),
8181
}),
8282
);
83+
this.log.debug(`uploaded to ${s3Url}`);
8384
} catch (e) {
8485
this.log.error(e, `failed to upload to ${s3Url}`);
8586
}

src/services/Scanner.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
iCreditManagerV3Abi,
2020
iPartialLiquidationBotV3Abi,
2121
} from "@gearbox-protocol/types/abi";
22-
import type { Address, Block, PublicClient } from "viem";
22+
import type { Address, Block, HttpTransportConfig, PublicClient } from "viem";
2323
import { createPublicClient, getContract, http } from "viem";
2424
import type { Config } from "../config/index.js";
2525
import { DI } from "../di.js";
@@ -53,9 +53,6 @@ export class Scanner {
5353
@DI.Inject(DI.CreditAccountService)
5454
caService!: ICreditAccountsService;
5555

56-
@DI.Inject(DI.MulticallSpy)
57-
multicallSpy!: MulticallSpy;
58-
5956
#processing: bigint | null = null;
6057
#restakingCMAddr?: Address;
6158
#restakingMinHF?: bigint;
@@ -387,6 +384,9 @@ class ScannerDiagnoster {
387384
@DI.Inject(DI.Notifier)
388385
notifier!: INotifier;
389386

387+
@DI.Inject(DI.MulticallSpy)
388+
multicallSpy!: MulticallSpy;
389+
390390
#drpc?: WorkaroundCAS;
391391
#alchemy?: WorkaroundCAS;
392392

@@ -398,7 +398,17 @@ class ScannerDiagnoster {
398398
"http",
399399
);
400400
if (rpcURL) {
401-
this.#drpc = new WorkaroundCAS(this.caService.sdk, { rpcURL });
401+
this.#drpc = new WorkaroundCAS(this.caService.sdk, {
402+
rpcURL,
403+
rpcOptions: {
404+
onFetchRequest: this.config.debugScanner
405+
? (r, o) => this.multicallSpy.multicallRequestSpy(r, o)
406+
: undefined,
407+
onFetchResponse: this.config.debugScanner
408+
? r => this.multicallSpy.multicallResponseSpy(r)
409+
: undefined,
410+
},
411+
});
402412
}
403413
}
404414
if (this.config.alchemyKeys?.length) {
@@ -408,7 +418,17 @@ class ScannerDiagnoster {
408418
"http",
409419
);
410420
if (rpcURL) {
411-
this.#alchemy = new WorkaroundCAS(this.caService.sdk, { rpcURL });
421+
this.#alchemy = new WorkaroundCAS(this.caService.sdk, {
422+
rpcURL,
423+
rpcOptions: {
424+
onFetchRequest: this.config.debugScanner
425+
? (r, o) => this.multicallSpy.multicallRequestSpy(r, o)
426+
: undefined,
427+
onFetchResponse: this.config.debugScanner
428+
? r => this.multicallSpy.multicallResponseSpy(r)
429+
: undefined,
430+
},
431+
});
412432
}
413433
}
414434
if (!!this.#drpc && !!this.#alchemy) {
@@ -460,6 +480,7 @@ class ScannerDiagnoster {
460480
plain: `Found ${numZeroHF} zero HF accounts in block ${blockNumber}, second pass ${dprcZeroHF} drpc, ${alchemyZeroHF} alchemy`,
461481
markdown: `Found ${numZeroHF} zero HF accounts in block ${blockNumber}, second pass ${dprcZeroHF} drpc, ${alchemyZeroHF} alchemy`,
462482
});
483+
await this.multicallSpy.dumpCalls();
463484
return alchemyZeroHF < dprcZeroHF ? alchemyAccs : drpcAccs;
464485
} catch (e) {
465486
this.log.error(e);
@@ -470,6 +491,7 @@ class ScannerDiagnoster {
470491

471492
interface WorkaroundCASOptions extends CreditAccountServiceOptions {
472493
rpcURL: string;
494+
rpcOptions?: HttpTransportConfig;
473495
}
474496

475497
class WorkaroundCAS extends AbstractCreditAccountService {
@@ -478,7 +500,10 @@ class WorkaroundCAS extends AbstractCreditAccountService {
478500
constructor(sdk: GearboxSDK, opts: WorkaroundCASOptions) {
479501
super(sdk, opts);
480502
this.#client = createPublicClient({
481-
transport: http(opts.rpcURL, { timeout: 600_000 }),
503+
transport: http(opts.rpcURL, {
504+
timeout: 600_000,
505+
...opts.rpcOptions,
506+
}),
482507
chain: sdk.provider.chain,
483508
});
484509
}

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ __metadata:
17701770
"@gearbox-protocol/cli-utils": "npm:^5.45.15"
17711771
"@gearbox-protocol/liquidator-contracts": "npm:^1.36.0-experimental.41"
17721772
"@gearbox-protocol/liquidator-v2-contracts": "npm:^2.4.0"
1773-
"@gearbox-protocol/sdk": "npm:8.27.9"
1773+
"@gearbox-protocol/sdk": "npm:8.27.10"
17741774
"@gearbox-protocol/types": "npm:^1.14.8"
17751775
"@types/node": "npm:^24.3.1"
17761776
"@uniswap/sdk-core": "npm:^7.7.2"
@@ -1796,9 +1796,9 @@ __metadata:
17961796
languageName: unknown
17971797
linkType: soft
17981798

1799-
"@gearbox-protocol/sdk@npm:8.27.9":
1800-
version: 8.27.9
1801-
resolution: "@gearbox-protocol/sdk@npm:8.27.9"
1799+
"@gearbox-protocol/sdk@npm:8.27.10":
1800+
version: 8.27.10
1801+
resolution: "@gearbox-protocol/sdk@npm:8.27.10"
18021802
dependencies:
18031803
"@redstone-finance/evm-connector": "npm:^0.7.5"
18041804
"@redstone-finance/protocol": "npm:^0.7.5"
@@ -1812,7 +1812,7 @@ __metadata:
18121812
zod: "npm:^4.1.1"
18131813
peerDependencies:
18141814
axios: ^1.0.0
1815-
checksum: 10c0/5294febc9ac431aed4cfbb8ab4dc30590809d21cc7ad73a47b5e852b9096806c7b086c6421269218b08fa443c26d03230934aa37b86cc03fc5d29627315a066b
1815+
checksum: 10c0/9f35dcd84c52e476b841a33cc02bf65d481b8ef0b904485b4d08a42d00d7bd6a8d58729066f3dfb8af587ba6b0b16b23226fff4f6258e794aa38f538a5385559
18161816
languageName: node
18171817
linkType: hard
18181818

0 commit comments

Comments
 (0)