From c1c0dfa3c82fc8882de4aae61175b421fb10d363 Mon Sep 17 00:00:00 2001 From: nicholaspai <9457025+nicholaspai@users.noreply.github.com> Date: Tue, 10 Oct 2023 11:39:18 -0400 Subject: [PATCH] fix(adapter-manager): Catch undefined per-chain wrapEther config (#984) * improve(relayer): Clear out token data explicitly and log token balances Based on an issue we're seeing where L1 to L2 rebalances are still getting duplicated, even after wrapping ETH, perhaps suggesting that the `tokenClient` is using stale data the logic written [here](https://github.com/across-protocol/relayer-v2/blob/master/src/relayer/RelayerClientHelper.ts#L159) should be reading updated balances post-ETH-unwrap but it may not. This PR adds more logs we can use to better debug * Update InventoryClient.ts * Update RelayerConfig.ts * fix(adapter-manager): Handle undefined chain-specific wrapEther config * lint Signed-off-by: nicholaspai --------- Signed-off-by: nicholaspai --- src/clients/InventoryClient.ts | 4 ++-- src/clients/bridges/AdapterManager.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/clients/InventoryClient.ts b/src/clients/InventoryClient.ts index ffca512bc..8667b2bfe 100644 --- a/src/clients/InventoryClient.ts +++ b/src/clients/InventoryClient.ts @@ -634,9 +634,9 @@ export class InventoryClient { } async wrapL2EthIfAboveThreshold(): Promise { - // If inventoryConfig is defined, there will be a default wrapEtherTarget and wrapEtherThreshold + // If inventoryConfig is defined, there should be a default wrapEtherTarget and wrapEtherThreshold // set by RelayerConfig.ts - if (!this?.inventoryConfig) { + if (!this?.inventoryConfig?.wrapEtherThreshold || !this?.inventoryConfig?.wrapEtherTarget) { return; } this.log("Checking ETH->WETH Wrap status"); diff --git a/src/clients/bridges/AdapterManager.ts b/src/clients/bridges/AdapterManager.ts index d3329d518..3ee1fe64c 100644 --- a/src/clients/bridges/AdapterManager.ts +++ b/src/clients/bridges/AdapterManager.ts @@ -84,8 +84,9 @@ export class AdapterManager { await utils.mapAsync( this.chainsToWrapEtherOn.filter((chainId) => isDefined(this.spokePoolClients[chainId])), async (chainId) => { - const wrapThreshold = inventoryConfig.wrapEtherThresholdPerChain[chainId] ?? inventoryConfig.wrapEtherThreshold; - const wrapTarget = inventoryConfig.wrapEtherTargetPerChain[chainId] ?? inventoryConfig.wrapEtherTarget; + const wrapThreshold = + inventoryConfig?.wrapEtherThresholdPerChain?.[chainId] ?? inventoryConfig.wrapEtherThreshold; + const wrapTarget = inventoryConfig?.wrapEtherTargetPerChain?.[chainId] ?? inventoryConfig.wrapEtherTarget; assert( wrapThreshold.gte(wrapTarget), `wrapEtherThreshold ${wrapThreshold.toString()} must be >= wrapEtherTarget ${wrapTarget.toString()}`