Skip to content

Commit

Permalink
fix inventory for undefined config (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaree authored Jun 11, 2022
1 parent ee583fb commit b4c1dc7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/clients/InventoryClient/InventoryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ export class InventoryClient {
if (!this.isInventoryManagementEnabled()) return deposit.destinationChainId;
if (deposit.destinationChainId === 1) return 1; // Always refund on L1 if the transfer is to L1.
const l1Token = this.hubPoolClient.getL1TokenForDeposit(deposit);

// If there is no inventory config for this token or this token and destination chain the return the destination chain.
if (
this.inventoryConfig.tokenConfig[l1Token] == undefined ||
this.inventoryConfig.tokenConfig?.[l1Token]?.[deposit.destinationChainId] == undefined
)
return deposit.destinationChainId;
const chainShortfall = this.getTokenShortFall(l1Token, deposit.destinationChainId);
const chainVirtualBalance = this.getBalanceOnChainForL1Token(deposit.destinationChainId, l1Token);
const chainVirtualBalanceWithShortfall = chainVirtualBalance.sub(chainShortfall);
Expand Down

0 comments on commit b4c1dc7

Please sign in to comment.