Skip to content

Commit

Permalink
improve(relayer): Check v3 fillstatus before filling (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl authored Feb 21, 2024
1 parent 23f63d3 commit 60f77dd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert";
import { utils as sdkUtils } from "@across-protocol/sdk-v2";
import { utils as ethersUtils } from "ethers";
import { Deposit, DepositWithBlock, L1Token, V2Deposit, V3Deposit } from "../interfaces";
import { Deposit, DepositWithBlock, FillStatus, L1Token, V2Deposit, V3Deposit } from "../interfaces";
import {
BigNumber,
bnZero,
Expand Down Expand Up @@ -55,7 +55,7 @@ export class Relayer {
const unfilledDeposits = await getUnfilledDeposits(spokePoolClients, hubPoolClient, this.config.maxRelayerLookBack);

const maxVersion = configStoreClient.configStoreVersion;
return unfilledDeposits.filter(({ deposit, version, invalidFills, unfilledAmount }) => {
return sdkUtils.filterAsync(unfilledDeposits, async ({ deposit, version, invalidFills, unfilledAmount }) => {
const { quoteTimestamp, depositId, depositor, recipient, originChainId, destinationChainId } = deposit;
const destinationChain = getNetworkName(destinationChainId);

Expand Down Expand Up @@ -135,6 +135,17 @@ export class Relayer {
});
return false;
}

const destSpokePool = this.clients.spokePoolClients[destinationChainId].spokePool;
const fillStatus = await sdkUtils.relayFillStatus(destSpokePool, deposit, "latest", destinationChainId);
if (fillStatus === FillStatus.Filled) {
this.logger.debug({
at: "Relayer::getUnfilledDeposits",
message: "Skipping deposit that was already filled.",
deposit,
});
return false;
}
}

// Skip deposit with message if sending fills with messages is not supported.
Expand Down

0 comments on commit 60f77dd

Please sign in to comment.