Skip to content

Commit b719736

Browse files
pxrljames-a-morris
authored andcommitted
refactor: Simplify inventory client parsing
This helps to drop an UMA dependency, and is arguably nicer because it doesn't corce the js Object to and from a string type.
1 parent fc471e1 commit b719736

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/relayer/RelayerConfig.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BigNumber, toBNWei, assert, toBN, replaceAddressCase, ethers } from "../utils";
1+
import { BigNumber, toBNWei, assert, toBN, ethers } from "../utils";
22
import { CommonConfig, ProcessEnv } from "../common";
33
import * as Constants from "../common/Constants";
44
import { InventoryConfig } from "../interfaces";
@@ -65,11 +65,12 @@ export class RelayerConfig extends CommonConfig {
6565
this.slowDepositors = SLOW_DEPOSITORS
6666
? JSON.parse(SLOW_DEPOSITORS).map((depositor) => ethers.utils.getAddress(depositor))
6767
: [];
68-
this.inventoryConfig = RELAYER_INVENTORY_CONFIG ? JSON.parse(RELAYER_INVENTORY_CONFIG) : {};
68+
this.inventoryConfig = JSON.parse(
69+
RELAYER_INVENTORY_CONFIG?.replace(/0x[a-fA-F0-9]{40}/g, ethers.utils.getAddress) ?? "{}"
70+
);
6971
this.minRelayerFeePct = toBNWei(MIN_RELAYER_FEE_PCT || Constants.RELAYER_MIN_FEE_PCT);
7072

7173
if (Object.keys(this.inventoryConfig).length > 0) {
72-
this.inventoryConfig = replaceAddressCase(this.inventoryConfig); // Cast any non-address case addresses.
7374
this.inventoryConfig.wrapEtherThreshold = this.inventoryConfig.wrapEtherThreshold
7475
? toBNWei(this.inventoryConfig.wrapEtherThreshold)
7576
: toBNWei(1); // default to keeping 2 Eth on the target chains and wrapping the rest to WETH.

src/utils/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export {
2727
export type { Block, TransactionResponse, TransactionReceipt, Provider } from "@ethersproject/abstract-provider";
2828

2929
export { config } from "dotenv";
30-
31-
export { replaceAddressCase } from "@uma/common";
3230
export { Logger } from "@uma/financial-templates-lib";
3331

3432
// TypeChain exports used in the bot.

0 commit comments

Comments
 (0)