Skip to content

Commit

Permalink
fix(Relayer): Fix Relayer realizedLpFeePct computation (#783)
Browse files Browse the repository at this point in the history
Rather than the SpokePool block mapped to a HubPool block, the relevant
block for the LP fee is resolved via the quoteTimestamp on the deposit.

Spotted by Nick.

Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com>
  • Loading branch information
pxrl and nicholaspai committed Jun 28, 2023
1 parent 75a9d8a commit dba8f42
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,30 +375,26 @@ export class Relayer {

protected async computeRealizedLpFeePct(
version: number,
deposit: Deposit,
deposit: DepositWithBlock,
symbol: string,
hubPoolTokenAddress: string,
hubPoolBlockNumber?: number
hubPoolTokenAddress: string
): Promise<BigNumber> {
if (!sdkUtils.isUBA(version)) {
return deposit.realizedLpFeePct;
}

const { hubPoolClient, ubaClient } = this.clients;
hubPoolBlockNumber ??= hubPoolClient.latestBlockNumber;

const { originChainId, depositId, destinationChainId, amount } = deposit;
const { originChainId, depositId, destinationChainId, amount, quoteBlockNumber } = deposit;
const {
lpFee,
depositBalancingFee: depositFee,
systemFee: realizedLpFeePct,
} = await ubaClient.computeSystemFee(
} = await this.clients.ubaClient.computeSystemFee(
originChainId,
destinationChainId,
symbol,
hubPoolTokenAddress,
amount,
hubPoolBlockNumber
quoteBlockNumber
);

const chain = getNetworkName(deposit.originChainId);
Expand Down

0 comments on commit dba8f42

Please sign in to comment.