Skip to content

Commit

Permalink
fix(adapter-manager): Catch undefined per-chain wrapEther config (#984)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Signed-off-by: nicholaspai <[email protected]>
  • Loading branch information
nicholaspai authored Oct 10, 2023
1 parent 4d42f7f commit c1c0dfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/clients/InventoryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,9 @@ export class InventoryClient {
}

async wrapL2EthIfAboveThreshold(): Promise<void> {
// 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");
Expand Down
5 changes: 3 additions & 2 deletions src/clients/bridges/AdapterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`
Expand Down

0 comments on commit c1c0dfa

Please sign in to comment.