Skip to content

Commit 4ec672e

Browse files
committed
normalize token argument to lowercase
1 parent c16b8f0 commit 4ec672e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/graphinator.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {type AddressLike, ethers, type TransactionLike} from "ethers";
1+
import { type AddressLike, ethers, type TransactionLike } from "ethers";
22
import DataFetcher from "./datafetcher.ts";
3-
import type {Flow} from "./types/types.ts";
3+
import type { Flow } from "./types/types.ts";
44
import sfMeta from "@superfluid-finance/metadata";
55
const BatchLiquidatorAbi = require("@superfluid-finance/ethereum-contracts/build/hardhat/contracts/utils/BatchLiquidator.sol/BatchLiquidator.json").abi;
66
const GDAv1ForwarderAbi = require("@superfluid-finance/ethereum-contracts/build/hardhat/contracts/utils/GDAv1Forwarder.sol/GDAv1Forwarder.json").abi;
77

88
const tokenPricesAllNetworks = require("../data/token_prices.json") || undefined;
99

1010
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}`);
1212

1313

1414
/**
@@ -92,7 +92,13 @@ export default class Graphinator {
9292
* @param token - The address of the token to process. If not provided, all tokens will be processed.
9393
*/
9494
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+
}
96102
log(`Processing ${tokenAddrs.length} tokens, isListed: ${this.isListed ? "true" : "false"}`);
97103
for (const tokenAddr of tokenAddrs) {
98104
const flowsToLiquidate = await this.dataFetcher.getFlowsToLiquidate(tokenAddr, this.gdaForwarder, this.depositConsumedPctThreshold);
@@ -180,9 +186,9 @@ export default class Graphinator {
180186
* Fetches all super tokens.
181187
* @returns A promise that resolves to an array of super token addresses.
182188
*/
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
184190
return (await this.dataFetcher.getSuperTokens(isListed))
185-
.map(token => token.id);
191+
.map(token => token.id.toLowerCase()); // Ensure lowercase
186192
}
187193

188194
/**

0 commit comments

Comments
 (0)