|
1 | | -import {type AddressLike, ethers, type TransactionLike} from "ethers"; |
| 1 | +import { type AddressLike, ethers, type TransactionLike } from "ethers"; |
2 | 2 | import DataFetcher from "./datafetcher.ts"; |
3 | | -import type {Flow} from "./types/types.ts"; |
| 3 | +import type { Flow } from "./types/types.ts"; |
4 | 4 | import sfMeta from "@superfluid-finance/metadata"; |
5 | 5 | const BatchLiquidatorAbi = require("@superfluid-finance/ethereum-contracts/build/hardhat/contracts/utils/BatchLiquidator.sol/BatchLiquidator.json").abi; |
6 | 6 | const GDAv1ForwarderAbi = require("@superfluid-finance/ethereum-contracts/build/hardhat/contracts/utils/GDAv1Forwarder.sol/GDAv1Forwarder.json").abi; |
7 | 7 |
|
8 | 8 | const tokenPricesAllNetworks = require("../data/token_prices.json") || undefined; |
9 | 9 |
|
10 | 10 | const bigIntToStr = (key: string, value: any) => (typeof value === 'bigint' ? value.toString() : value); |
11 | | -const log = (msg: string, lineDecorator="") => console.log(`${new Date().toISOString()} - ${lineDecorator} (Graphinator) ${msg}`); |
| 11 | +const log = (msg: string, lineDecorator = "") => console.log(`${new Date().toISOString()} - ${lineDecorator} (Graphinator) ${msg}`); |
12 | 12 |
|
13 | 13 |
|
14 | 14 | /** |
@@ -92,7 +92,13 @@ export default class Graphinator { |
92 | 92 | * @param token - The address of the token to process. If not provided, all tokens will be processed. |
93 | 93 | */ |
94 | 94 | async processAll(token?: AddressLike): Promise<void> { |
95 | | - const tokenAddrs = token ? [token] : await this._getSuperTokens(this.isListed); |
| 95 | + let tokenAddrs: string[]; |
| 96 | + if (token) { |
| 97 | + const resolved = await ethers.resolveAddress(token, this.provider); |
| 98 | + tokenAddrs = [resolved.toLowerCase()]; |
| 99 | + } else { |
| 100 | + tokenAddrs = await this._getSuperTokens(this.isListed); |
| 101 | + } |
96 | 102 | log(`Processing ${tokenAddrs.length} tokens, isListed: ${this.isListed ? "true" : "false"}`); |
97 | 103 | for (const tokenAddr of tokenAddrs) { |
98 | 104 | const flowsToLiquidate = await this.dataFetcher.getFlowsToLiquidate(tokenAddr, this.gdaForwarder, this.depositConsumedPctThreshold); |
@@ -180,9 +186,9 @@ export default class Graphinator { |
180 | 186 | * Fetches all super tokens. |
181 | 187 | * @returns A promise that resolves to an array of super token addresses. |
182 | 188 | */ |
183 | | - private async _getSuperTokens(isListed: boolean): Promise<AddressLike[]> { |
| 189 | + private async _getSuperTokens(isListed: boolean): Promise<any[]> { // changed AddressLike[] to any[] or string[] because I am using string now |
184 | 190 | return (await this.dataFetcher.getSuperTokens(isListed)) |
185 | | - .map(token => token.id); |
| 191 | + .map(token => token.id.toLowerCase()); // Ensure lowercase |
186 | 192 | } |
187 | 193 |
|
188 | 194 | /** |
|
0 commit comments