Skip to content

Commit

Permalink
fix: resolve incorrect slack messages (#909)
Browse files Browse the repository at this point in the history
* fix: resolve incorrect slack messages

* improve: reduce need for refactored functions

* chore: introduce utf8ToHex

* chore: revert destructuring

* chore: further revert destructuring

---------

Co-authored-by: Paul <108695806+pxrl@users.noreply.github.com>
  • Loading branch information
james-a-morris and pxrl committed Aug 30, 2023
1 parent 027f1fe commit 3949e92
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 148 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@across-protocol/contracts-v2": "2.4.3",
"@across-protocol/sdk-v2": "0.15.18",
"@across-protocol/sdk-v2": "0.15.20",
"@arbitrum/sdk": "^3.1.3",
"@defi-wonderland/smock": "^2.3.5",
"@eth-optimism/sdk": "^3.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/clients/InventoryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
toBN,
getNetworkName,
createFormatFunction,
etherscanLink,
blockExplorerLink,
Contract,
runTransaction,
isDefined,
Expand Down Expand Up @@ -362,7 +362,7 @@ export class InventoryClient {
cumulativeBalance.toString()
)} ${symbol} over all chains (ignoring hubpool repayments). This chain has a shortfall of ` +
`${formatter(this.getTokenShortFall(l1Token, chainId).toString())} ${symbol} ` +
`tx: ${etherscanLink(hash, this.hubPoolClient.chainId)}\n`;
`tx: ${blockExplorerLink(hash, this.hubPoolClient.chainId)}\n`;
}
}

Expand Down Expand Up @@ -502,7 +502,7 @@ export class InventoryClient {
`${this.formatWei(unwrapWethTarget.toString())} (trigger of ` +
`${this.formatWei(unwrapWethThreshold.toString())} ETH), ` +
`current balance of ${this.formatWei(balance.toString())} ` +
`tx: ${etherscanLink(hash, chainId)}\n`;
`tx: ${blockExplorerLink(hash, chainId)}\n`;
}

for (const { chainInfo, amount } of unexecutedUnwraps) {
Expand Down
14 changes: 7 additions & 7 deletions src/clients/TokenClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber, winston, assign, ERC20, Contract, toBN, MAX_SAFE_ALLOWANCE } from "../utils";
import { runTransaction, getNetworkName, etherscanLink, MAX_UINT_VAL } from "../utils";
import { runTransaction, getNetworkName, blockExplorerLink, MAX_UINT_VAL } from "../utils";
import { HubPoolClient, SpokePoolClient } from ".";
import { Deposit } from "../interfaces";

Expand Down Expand Up @@ -133,9 +133,9 @@ export class TokenClient {
const contract = new Contract(token, ERC20.abi, targetSpokePool.signer);
const tx = await runTransaction(this.logger, contract, "approve", [targetSpokePool.address, MAX_UINT_VAL]);
mrkdwn +=
` - Approved SpokePool ${etherscanLink(targetSpokePool.address, chainId)} ` +
`to spend ${await contract.symbol()} ${etherscanLink(token, chainId)} on ${getNetworkName(chainId)}. ` +
`tx: ${etherscanLink(tx.hash, chainId)}\n`;
` - Approved SpokePool ${blockExplorerLink(targetSpokePool.address, chainId)} ` +
`to spend ${await contract.symbol()} ${blockExplorerLink(token, chainId)} on ${getNetworkName(chainId)}. ` +
`tx: ${blockExplorerLink(tx.hash, chainId)}\n`;
}
this.logger.info({ at: "TokenBalanceClient", message: "Approved whitelisted tokens! 💰", mrkdwn });
}
Expand All @@ -155,9 +155,9 @@ export class TokenClient {
MAX_UINT_VAL,
]);
const mrkdwn =
` - Approved HubPool ${etherscanLink(this.hubPoolClient.hubPool.address, 1)} ` +
`to spend ${await this.bondToken.symbol()} ${etherscanLink(this.bondToken.address, 1)}. ` +
`tx ${etherscanLink(tx.hash, 1)}\n`;
` - Approved HubPool ${blockExplorerLink(this.hubPoolClient.hubPool.address, 1)} ` +
`to spend ${await this.bondToken.symbol()} ${blockExplorerLink(this.bondToken.address, 1)}. ` +
`tx ${blockExplorerLink(tx.hash, 1)}\n`;
this.logger.info({ at: "hubPoolClient", message: "Approved bond tokens! 💰", mrkdwn });
} else {
this.logger.debug({ at: "hubPoolClient", message: "Bond token approval set" });
Expand Down
4 changes: 2 additions & 2 deletions src/clients/TransactionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Contract,
runTransaction,
BigNumber,
etherscanLink,
blockExplorerLink,
toBNWei,
TransactionResponse,
TransactionSimulationResult,
Expand Down Expand Up @@ -102,7 +102,7 @@ export class TransactionClient {
}

nonce = response.nonce + 1;
const blockExplorer = etherscanLink(response.hash, txn.chainId);
const blockExplorer = blockExplorerLink(response.hash, txn.chainId);
mrkdwn += ` ${idx + 1}. ${txn.message || "No message"} (${blockExplorer}): ${txn.mrkdwn || "No markdown"}\n`;
txnResponses.push(response);
}
Expand Down
11 changes: 6 additions & 5 deletions src/clients/bridges/BaseAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ import {
assert,
compareAddressesSimple,
formatUnitsForToken,
createFormatFunction,
BigNumberish,
} from "../../utils";
import { etherscanLink, getNetworkName, MAX_UINT_VAL, runTransaction } from "../../utils";
import { blockExplorerLink, getNetworkName, MAX_UINT_VAL, runTransaction } from "../../utils";

import { OutstandingTransfers, SortableEvent } from "../../interfaces";
import { TransactionResponse } from "../../utils";
import { CONTRACT_ADDRESSES } from "../../common";
import { BigNumberish, createFormatFunction } from "../../utils/FormattingUtils";
interface DepositEvent extends SortableEvent {
amount: BigNumber;
to: string;
Expand Down Expand Up @@ -149,9 +150,9 @@ export abstract class BaseAdapter {
const hubNetwork = getNetworkName(hubChainId);
const spokeNetwork = getNetworkName(this.chainId);
mrkdwn +=
` - Approved canonical ${spokeNetwork} token bridge ${etherscanLink(targetContract, hubChainId)} ` +
`to spend ${await l1Token.symbol()} ${etherscanLink(l1Token.address, hubChainId)} on ${hubNetwork}.` +
`tx: ${etherscanLink(receipt.transactionHash, hubChainId)}\n`;
` - Approved canonical ${spokeNetwork} token bridge ${blockExplorerLink(targetContract, hubChainId)} ` +
`to spend ${await l1Token.symbol()} ${blockExplorerLink(l1Token.address, hubChainId)} on ${hubNetwork}.` +
`tx: ${blockExplorerLink(receipt.transactionHash, hubChainId)}\n`;
}
this.log("Approved whitelisted tokens! 💰", { mrkdwn }, "info");
}
Expand Down
3 changes: 1 addition & 2 deletions src/clients/bridges/ZKSyncAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber, Contract } from "ethers";
import { BigNumber, BigNumberish, Contract } from "ethers";
import { BaseAdapter } from "./BaseAdapter";
import { OutstandingTransfers, SortableEvent } from "../../interfaces";
import {
Expand All @@ -19,7 +19,6 @@ import { TOKEN_SYMBOLS_MAP } from "@across-protocol/contracts-v2";
import { isDefined } from "../../utils/TypeGuards";
import { gasPriceOracle, utils } from "@across-protocol/sdk-v2";
import { zkSync as zkSyncUtils } from "../../utils/chains";
import { BigNumberish } from "../../utils/FormattingUtils";

/**
* Responsible for providing a common interface for interacting with the ZKSync Era
Expand Down
6 changes: 3 additions & 3 deletions src/finalizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
startupLogLevel,
processEndPollingLoop,
getNetworkName,
etherscanLink,
blockExplorerLink,
getBlockForTimestamp,
getCurrentTime,
disconnectRedisClient,
Expand Down Expand Up @@ -126,15 +126,15 @@ export async function finalize(
logger.info({
at: "Finalizer",
message: `Submitted proof on chain ${hubChain} to initiate ${spokeChain} withdrawal of ${amount} ${symbol} 🔜`,
transactionHash: etherscanLink(txn.transactionHash, hubChainId),
transactionHash: blockExplorerLink(txn.transactionHash, hubChainId),
});
});
withdrawals.forEach(({ l2ChainId, amount, l1TokenSymbol: symbol }) => {
const spokeChain = getNetworkName(l2ChainId);
logger.info({
at: "Finalizer",
message: `Finalized ${spokeChain} withdrawal for ${amount} ${symbol} 🪃`,
transactionHash: etherscanLink(txn.transactionHash, hubChainId),
transactionHash: blockExplorerLink(txn.transactionHash, hubChainId),
});
});
} catch (_error) {
Expand Down
24 changes: 12 additions & 12 deletions src/monitor/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
createFormatFunction,
ERC20,
ethers,
etherscanLink,
etherscanLinks,
blockExplorerLink,
blockExplorerLinks,
getEthAddressForChain,
getGasPrice,
getNativeTokenSymbol,
Expand Down Expand Up @@ -134,7 +134,7 @@ export class Monitor {
if (l1TokenUtilization.utilization.gt(toBN(this.monitorConfig.utilizationThreshold).mul(toBN(toWei("0.01"))))) {
const utilizationString = l1TokenUtilization.utilization.mul(100).toString();
const mrkdwn = `${l1TokenUtilization.poolCollateralSymbol} pool token at \
${etherscanLink(l1TokenUtilization.l1Token, l1TokenUtilization.chainId)} on \
${blockExplorerLink(l1TokenUtilization.l1Token, l1TokenUtilization.chainId)} on \
${getNetworkName(l1TokenUtilization.chainId)} is at \
${createFormatFunction(0, 2)(utilizationString)}% utilization!"`;
this.logger.debug({ at: "Monitor#checkUtilization", message: "High pool utilization warning 🏊", mrkdwn });
Expand Down Expand Up @@ -184,8 +184,8 @@ export class Monitor {
}

const mrkdwn =
`An unknown relayer ${etherscanLink(fill.relayer, chainId)}` +
` filled a deposit on ${getNetworkName(chainId)}\ntx: ${etherscanLink(fill.transactionHash, chainId)}`;
`An unknown relayer ${blockExplorerLink(fill.relayer, chainId)}` +
` filled a deposit on ${getNetworkName(chainId)}\ntx: ${blockExplorerLink(fill.transactionHash, chainId)}`;
this.logger.warn({ at: "Monitor#checkUnknownRelayers", message: "Unknown relayer 🛺", mrkdwn });
}
}
Expand Down Expand Up @@ -360,7 +360,7 @@ export class Monitor {
).symbol();
return {
level: trippedThreshold.level,
text: ` ${getNetworkName(chainId)} ${symbol} balance for ${etherscanLink(
text: ` ${getNetworkName(chainId)} ${symbol} balance for ${blockExplorerLink(
account,
chainId
)} is ${ethers.utils.formatUnits(balance, decimals)}. Threshold: ${trippedThreshold.threshold}`,
Expand Down Expand Up @@ -465,7 +465,7 @@ export class Monitor {
deficit,
decimals
)} ${nativeSymbolForChain} for ${account} from ${signerAddress} 🫡!`,
transactionHash: etherscanLink(receipt.transactionHash, chainId),
transactionHash: blockExplorerLink(receipt.transactionHash, chainId),
});
}
} else {
Expand Down Expand Up @@ -541,7 +541,7 @@ export class Monitor {
chainId,
l1Token.address
);
const outstandingDepositTxs = etherscanLinks(
const outstandingDepositTxs = blockExplorerLinks(
this.clients.crossChainTransferClient.getOutstandingCrossChainTransferTxs(
spokePoolAddress,
chainId,
Expand Down Expand Up @@ -746,7 +746,7 @@ export class Monitor {
const totalAmount = this.getTotalTransferAmount(transfers);
let mrkdwn = `other: ${convertFromWei(totalAmount.toString(), decimals)}\n`;
const transactionHashes = [...new Set(transfers.map((transfer) => transfer.transactionHash))];
mrkdwn += etherscanLinks(transactionHashes, chainId);
mrkdwn += blockExplorerLinks(transactionHashes, chainId);
return mrkdwn;
}

Expand Down Expand Up @@ -852,13 +852,13 @@ export class Monitor {
}

const mrkdwn =
`An unknown EOA ${etherscanLink(caller, 1)} has ${action} a bundle on ${getNetworkName(1)}` +
`\ntx: ${etherscanLink(transactionHash, 1)}`;
`An unknown EOA ${blockExplorerLink(caller, 1)} has ${action} a bundle on ${getNetworkName(1)}` +
`\ntx: ${blockExplorerLink(transactionHash, 1)}`;
this.logger.error({
at: "Monitor#notifyIfUnknownCaller",
message: `Unknown bundle caller (${action}) ${emoji}${
action === BundleAction.PROPOSED
? `. If proposer identity cannot be determined quickly, then the safe response is to call "disputeRootBundle" on the HubPool here ${etherscanLink(
? `. If proposer identity cannot be determined quickly, then the safe response is to call "disputeRootBundle" on the HubPool here ${blockExplorerLink(
this.clients.hubPoolClient.hubPool.address,
1
)}. Note that you will need to approve the HubPool to transfer 0.4 WETH from your wallet as a dispute bond.`
Expand Down
8 changes: 4 additions & 4 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isDepositSpedUp,
RelayerUnfilledDeposit,
} from "../utils";
import { createFormatFunction, etherscanLink, formatFeePct, toBN, toBNWei } from "../utils";
import { createFormatFunction, blockExplorerLink, formatFeePct, toBN, toBNWei } from "../utils";
import { RelayerClients } from "./RelayerClientHelper";
import { Deposit, DepositWithBlock, FillWithBlock, L1Token, RefundRequestWithBlock } from "../interfaces";
import { RelayerConfig } from "./RelayerConfig";
Expand Down Expand Up @@ -619,9 +619,9 @@ export class Relayer {
const { symbol, decimals } = this.clients.hubPoolClient.getTokenInfoForDeposit(deposit);
const formatFunction = createFormatFunction(2, 4, false, decimals);
const gasFormatFunction = createFormatFunction(2, 10, false, 18);
const depositEtherscanLink = etherscanLink(deposit.transactionHash, deposit.originChainId);
const depositblockExplorerLink = blockExplorerLink(deposit.transactionHash, deposit.originChainId);
depositMrkdwn +=
`- DepositId ${deposit.depositId} (tx: ${depositEtherscanLink}) of amount ${formatFunction(
`- DepositId ${deposit.depositId} (tx: ${depositblockExplorerLink}) of amount ${formatFunction(
deposit.amount.toString()
)} ${symbol}` +
` with a relayerFeePct ${formatFeePct(deposit.relayerFeePct)}% and gas cost ${gasFormatFunction(gasCost)}` +
Expand Down Expand Up @@ -658,7 +658,7 @@ export class Relayer {
`Relayed depositId ${deposit.depositId} from ${getNetworkName(deposit.originChainId)} ` +
`to ${getNetworkName(deposit.destinationChainId)} of ` +
`${createFormatFunction(2, 4, false, decimals)(deposit.amount.toString())} ${symbol}. ` +
`with depositor ${etherscanLink(deposit.depositor, deposit.originChainId)}. ` +
`with depositor ${blockExplorerLink(deposit.depositor, deposit.originChainId)}. ` +
`Fill amount of ${createFormatFunction(2, 4, false, decimals)(fillAmount.toString())} ${symbol} with ` +
`relayerFee ${formatFeePct(deposit.relayerFeePct)}% & ` +
`realizedLpFee ${formatFeePct(deposit.realizedLpFeePct)}%. `
Expand Down
9 changes: 0 additions & 9 deletions src/utils/BigNumberUtils.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/FillMathUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Fill } from "../interfaces";
import { toBNWei, BigNumber, toBN } from ".";
import { BigNumber, toBN, toBNWei } from ".";

export function _getRefundForFill(fill: Fill): BigNumber {
return fill.fillAmount.mul(toBNWei(1).sub(fill.realizedLpFeePct)).div(toBNWei(1));
Expand Down
2 changes: 1 addition & 1 deletion src/utils/FillUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
getRefundForFills,
isDefined,
sortEventsDescending,
toBN,
sortEventsAscending,
toBN,
} from "./";
import { getBlockRangeForChain } from "../dataworker/DataworkerUtils";
import { clients } from "@across-protocol/sdk-v2";
Expand Down
92 changes: 0 additions & 92 deletions src/utils/FormattingUtils.ts

This file was deleted.

Loading

0 comments on commit 3949e92

Please sign in to comment.