Skip to content

Commit

Permalink
refactor(relayer): Use precomputed LP fees for self-fill (#1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl authored Apr 29, 2024
1 parent b8722a8 commit 9673494
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,11 @@ export class Relayer {
profitClient.captureUnprofitableFill(deposit, realizedLpFeePct, relayerFeePct, gasCost);
}
} else if (selfRelay) {
const { realizedLpFeePct } = await hubPoolClient.computeRealizedLpFeePct({
...deposit,
paymentChainId: destinationChainId,
});

// A relayer can fill its own deposit without an ERC20 transfer. Only bypass profitability requirements if the
// relayer is both the depositor and the recipient, because a deposit on a cheap SpokePool chain could cause
// expensive fills on (for example) mainnet.
this.fillRelay(deposit, destinationChainId, realizedLpFeePct);
const { lpFeePct } = lpFees.find((lpFee) => lpFee.paymentChainId === destinationChainId);
this.fillRelay(deposit, destinationChainId, lpFeePct);
} else {
// TokenClient.getBalance returns that we don't have enough balance to submit the fast fill.
// At this point, capture the shortfall so that the inventory manager can rebalance the token inventory.
Expand Down

0 comments on commit 9673494

Please sign in to comment.