Skip to content

Commit

Permalink
improve(SpokePoolClient): Drop unnecessary BN conversions (#747)
Browse files Browse the repository at this point in the history
The deposit outputAmount is already a BigNumber, so there's no need to
pass it through toBN(). This function is typically called repeatedly in
a tight loop by the relayer so it makes sense to drop the inefficiency.
  • Loading branch information
pxrl authored Oct 2, 2024
1 parent be49aef commit 3064ebd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/clients/SpokePoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,10 @@ export class SpokePoolClient extends BaseAbstractClient {
} {
const { outputAmount } = deposit;
const fillsForDeposit = this.depositHashesToFills[this.getDepositHash(deposit)];

// If no fills then the full amount is remaining.
if (fillsForDeposit === undefined || fillsForDeposit.length === 0) {
return { unfilledAmount: toBN(outputAmount), fillCount: 0, invalidFills: [] };
return { unfilledAmount: outputAmount, fillCount: 0, invalidFills: [] };
}

const { validFills, invalidFills } = fillsForDeposit.reduce(
Expand Down Expand Up @@ -365,7 +366,7 @@ export class SpokePoolClient extends BaseAbstractClient {

// If all fills are invalid we can consider this unfilled.
if (validFills.length === 0) {
return { unfilledAmount: toBN(outputAmount), fillCount: 0, invalidFills };
return { unfilledAmount: outputAmount, fillCount: 0, invalidFills };
}

return {
Expand Down

0 comments on commit 3064ebd

Please sign in to comment.