Skip to content

Commit

Permalink
improve(InventoryClient): Log L2 token balances separately
Browse files Browse the repository at this point in the history
Logs correctly the case where there are multiple L2 tokens defined in the token config for a single l1 token
  • Loading branch information
nicholaspai committed May 10, 2024
1 parent 52f2c35 commit 54016d0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/clients/InventoryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,11 +1007,13 @@ export class InventoryClient {
const logData: {
[symbol: string]: {
[chainId: number]: {
actualBalanceOnChain: string;
virtualBalanceOnChain: string;
outstandingTransfers: string;
tokenShortFalls: string;
proRataShare: string;
[l2TokenAddress: string]: {
actualBalanceOnChain: string;
virtualBalanceOnChain: string;
outstandingTransfers: string;
tokenShortFalls: string;
proRataShare: string;
};
};
};
} = {};
Expand All @@ -1030,6 +1032,7 @@ export class InventoryClient {

Object.keys(distributionForToken).forEach((_chainId) => {
const chainId = Number(_chainId);
logData[symbol][chainId] ??= {};

Object.entries(distributionForToken[chainId]).forEach(([l2Token, amount]) => {
const balanceOnChain = this.getBalanceOnChain(chainId, l1Token, l2Token);
Expand All @@ -1040,8 +1043,7 @@ export class InventoryClient {
l2Token
);
const actualBalanceOnChain = this.tokenClient.getBalance(chainId, l2Token);

logData[symbol][chainId] = {
logData[symbol][chainId][l2Token] = {
actualBalanceOnChain: formatter(actualBalanceOnChain.toString()),
virtualBalanceOnChain: formatter(balanceOnChain.toString()),
outstandingTransfers: formatter(transfers.toString()),
Expand Down

0 comments on commit 54016d0

Please sign in to comment.