Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Mar 26, 2024
1 parent 9536efc commit 6343e22
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
5 changes: 2 additions & 3 deletions src/clients/BundleDataClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
ExpiredDepositsToRefundV3,
LoadDataReturnValue,
} from "../interfaces/BundleData";
import { findLast } from "lodash";

type DataCache = Record<string, Promise<LoadDataReturnValue>>;

Expand Down Expand Up @@ -248,7 +247,7 @@ export class BundleDataClient {
// @dev Search from right to left since there can be multiple root bundles with the same relayer refund root.
// The caller should take caution if they're trying to use this function to find matching refunds for older
// root bundles as opposed to more recent ones.
const bundle = findLast(
const bundle = _.findLast(
spokePoolClient.getRootBundleRelays(),
(bundle) => bundle.relayerRefundRoot === relayerRefundRoot
);
Expand Down Expand Up @@ -602,7 +601,7 @@ export class BundleDataClient {
bundleInvalidFillsV3.push(fill);
} else {
assert(utils.isV3Deposit(historicalDeposit.deposit));
const matchedDeposit: V3DepositWithBlock = historicalDeposit.deposit;
const matchedDeposit = historicalDeposit.deposit;
// @dev Since queryHistoricalDepositForFill validates the fill by checking individual
// object property values against the deposit's, we
// sanity check it here by comparing the full relay hashes. If there's an error here then the
Expand Down
20 changes: 4 additions & 16 deletions src/dataworker/Dataworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1147,23 +1147,11 @@ export class Dataworker {
!(
fill.depositId === relayData.depositId &&
fill.originChainId === relayData.originChainId &&
fill.destinationChainId === sdkUtils.getSlowFillLeafChainId(slowFill) &&
fill.depositor === relayData.depositor &&
fill.recipient === relayData.recipient &&
fill.inputToken === relayData.inputToken &&
sdkUtils.getFillOutputToken(fill) === sdkUtils.getRelayDataOutputToken(relayData) &&
sdkUtils.getFillOutputAmount(fill).eq(sdkUtils.getRelayDataOutputAmount(relayData)) &&
fill.message === relayData.message
sdkUtils.getV3RelayHash(fill, chainId) === sdkUtils.getV3RelayHash(relayData, chainId)
)
) {
return false;
}

return (
fill.fillDeadline === relayData.fillDeadline &&
fill.exclusivityDeadline === relayData.exclusivityDeadline &&
fill.exclusiveRelayer === relayData.exclusiveRelayer
);
});

return fill;
Expand All @@ -1178,7 +1166,7 @@ export class Dataworker {
throw new Error(`Leaf chainId does not match input chainId (${destinationChainId} != ${chainId})`);
}

const outputAmount = sdkUtils.getRelayDataOutputAmount(slowFill.relayData);
const { outputAmount } = slowFill.relayData;
const fill = latestFills[idx];
const amountRequired = isDefined(fill) ? bnZero : slowFill.updatedOutputAmount;

Expand All @@ -1187,7 +1175,7 @@ export class Dataworker {
return undefined;
}

const outputToken = sdkUtils.getRelayDataOutputToken(slowFill.relayData);
const { outputToken } = slowFill.relayData;
const success = await balanceAllocator.requestBalanceAllocation(
destinationChainId,
l2TokensToCountTowardsSpokePoolLeafExecutionCapital(outputToken, destinationChainId),
Expand Down Expand Up @@ -1221,7 +1209,7 @@ export class Dataworker {
assert(sdkUtils.getSlowFillLeafChainId(leaf) === chainId);

const { relayData } = leaf;
const outputAmount = sdkUtils.getRelayDataOutputAmount(relayData);
const { outputAmount } = relayData;
const mrkdwn =
`rootBundleId: ${rootBundleId}\n` +
`slowRelayRoot: ${slowRelayTree.getHexRoot()}\n` +
Expand Down
1 change: 0 additions & 1 deletion src/dataworker/DataworkerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export function _buildSlowRelayRoot(bundleSlowFillsV3: BundleSlowFills): {
}

function buildV3SlowFillLeaf(deposit: interfaces.V3Deposit): V3SlowFillLeaf {
assert(utils.isV3Deposit(deposit));
const lpFee = deposit.inputAmount.mul(deposit.realizedLpFeePct).div(fixedPointAdjustment);

return {
Expand Down
8 changes: 2 additions & 6 deletions src/scripts/validateRunningBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ export async function runScript(_logger: winston.Logger, baseSigner: Signer): Pr
// Compute how much the slow fill will execute by checking if any fills were sent after the slow fill amount
// was sent to the spoke pool. This would reduce the amount transferred when when the slow fill is executed.
const slowFillsForPoolRebalanceLeaf = slowFills.filter(
(f) =>
sdkUtils.getSlowFillLeafChainId(f) === leaf.chainId &&
sdkUtils.getRelayDataOutputToken(f.relayData) === l2Token
(f) => f.chainId === leaf.chainId && f.relayData.outputToken === l2Token
);

if (slowFillsForPoolRebalanceLeaf.length > 0) {
Expand Down Expand Up @@ -295,9 +293,7 @@ export async function runScript(_logger: winston.Logger, baseSigner: Signer): Pr
mostRecentValidatedBundle
);
const slowFillsForPoolRebalanceLeaf = slowFills.filter(
(f) =>
sdkUtils.getSlowFillLeafChainId(f) === leaf.chainId &&
sdkUtils.getRelayDataOutputToken(f.relayData) === l2Token
(f) => f.chainId === leaf.chainId && f.relayData.outputToken === l2Token
);
if (slowFillsForPoolRebalanceLeaf.length > 0) {
for (const slowFillForChain of slowFillsForPoolRebalanceLeaf) {
Expand Down

0 comments on commit 6343e22

Please sign in to comment.