Skip to content

Commit

Permalink
improve(spokepool): Dump relayData hash on fill logs
Browse files Browse the repository at this point in the history
This implementation is a bit hacky, but it works and is quite useful.
  • Loading branch information
pxrl committed Oct 4, 2024
1 parent d3a88d5 commit 7670839
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/spokepool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Contract, ethers, Signer } from "ethers";
import { LogDescription } from "@ethersproject/abi";
import { constants as sdkConsts, utils as sdkUtils } from "@across-protocol/sdk";
import { ExpandedERC20__factory as ERC20 } from "@across-protocol/contracts";
import { RelayData } from "../src/interfaces";
import {
BigNumber,
formatFeePct,
Expand Down Expand Up @@ -62,11 +63,18 @@ function printDeposit(originChainId: number, log: LogDescription): void {
function printFill(destinationChainId: number, log: LogDescription): void {
const { originChainId, outputToken } = log.args;
const eventArgs = Object.keys(log.args).filter((key) => isNaN(Number(key)));
const padLeft = eventArgs.reduce((acc, cur) => (cur.length > acc ? cur.length : acc), 0);

const relayDataHash = sdkUtils.getRelayDataHash(
Object.fromEntries(eventArgs.map((arg) => [arg, log.args[arg]])) as RelayData,
destinationChainId
);

const padLeft = [...eventArgs, "relayDataHash" ].reduce((acc, cur) => (cur.length > acc ? cur.length : acc), 0);

const fields = {
tokenSymbol: resolveTokenSymbols([outputToken], destinationChainId)[0],
...Object.fromEntries(eventArgs.map((key) => [key, log.args[key]])),
relayDataHash,
};
console.log(
`Fill for ${getNetworkName(originChainId)} deposit # ${log.args.depositId}:\n` +
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type SetPoolRebalanceRoot = interfaces.SetPoolRebalanceRoot;
export type PendingRootBundle = interfaces.PendingRootBundle;

// SpokePool interfaces
export type RelayData = interfaces.RelayData;
export type FundsDepositedEvent = interfaces.FundsDepositedEvent;
export type Deposit = interfaces.Deposit;
export type DepositWithBlock = interfaces.DepositWithBlock;
Expand Down

0 comments on commit 7670839

Please sign in to comment.