Skip to content

Commit

Permalink
Update RelayerConfig.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Oct 10, 2023
1 parent 3d0678f commit 8b10252
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/relayer/RelayerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,28 @@ export class RelayerConfig extends CommonConfig {
);
}
});
if (this.inventoryConfig.tokenConfig !== undefined) {
Object.keys(this.inventoryConfig.tokenConfig).forEach((l1Token) => {
Object.keys(this.inventoryConfig.tokenConfig[l1Token]).forEach((chainId) => {
const { targetPct, thresholdPct, unwrapWethThreshold, unwrapWethTarget } =
this.inventoryConfig.tokenConfig[l1Token][chainId];
assert(
targetPct !== undefined && thresholdPct !== undefined,
`Bad config. Must specify targetPct, thresholdPct for ${l1Token} on ${chainId}`
);
assert(
toBN(thresholdPct).lte(toBN(targetPct)),
`Bad config. thresholdPct<=targetPct for ${l1Token} on ${chainId}`
);
this.inventoryConfig.tokenConfig[l1Token][chainId].targetPct = toBNWei(targetPct).div(100);
this.inventoryConfig.tokenConfig[l1Token][chainId].thresholdPct = toBNWei(thresholdPct).div(100);
if (unwrapWethThreshold !== undefined) {
this.inventoryConfig.tokenConfig[l1Token][chainId].unwrapWethThreshold = toBNWei(unwrapWethThreshold);
}
this.inventoryConfig.tokenConfig[l1Token][chainId].unwrapWethTarget = unwrapWethTarget
? toBNWei(unwrapWethTarget)
: toBNWei(2);
});
Object.keys(this.inventoryConfig?.tokenConfig ?? {}).forEach((l1Token) => {
Object.keys(this.inventoryConfig.tokenConfig[l1Token]).forEach((chainId) => {
const { targetPct, thresholdPct, unwrapWethThreshold, unwrapWethTarget } =
this.inventoryConfig.tokenConfig[l1Token][chainId];
assert(
targetPct !== undefined && thresholdPct !== undefined,
`Bad config. Must specify targetPct, thresholdPct for ${l1Token} on ${chainId}`
);
assert(
toBN(thresholdPct).lte(toBN(targetPct)),
`Bad config. thresholdPct<=targetPct for ${l1Token} on ${chainId}`
);
this.inventoryConfig.tokenConfig[l1Token][chainId].targetPct = toBNWei(targetPct).div(100);
this.inventoryConfig.tokenConfig[l1Token][chainId].thresholdPct = toBNWei(thresholdPct).div(100);
if (unwrapWethThreshold !== undefined) {
this.inventoryConfig.tokenConfig[l1Token][chainId].unwrapWethThreshold = toBNWei(unwrapWethThreshold);
}
this.inventoryConfig.tokenConfig[l1Token][chainId].unwrapWethTarget = unwrapWethTarget
? toBNWei(unwrapWethTarget)
: toBNWei(2);
});
}
});
}
this.debugProfitability = DEBUG_PROFITABILITY === "true";
this.relayerGasMultiplier = toBNWei(RELAYER_GAS_MULTIPLIER || Constants.DEFAULT_RELAYER_GAS_MULTIPLIER);
Expand Down

0 comments on commit 8b10252

Please sign in to comment.