From 31050aeaa827195ff7c83380a3c8593ad9957142 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Tue, 2 Jan 2024 05:07:07 +0100 Subject: [PATCH 1/3] chore: Bump version (#483) Make the HubPoolClient Hub <-> Spoke token updates available. Bumping the minor since it's a breaking change. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e53e20303..b0b54f1c5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@across-protocol/sdk-v2", "author": "UMA Team", - "version": "0.18.1", + "version": "0.19.0", "license": "AGPL-3.0", "homepage": "https://docs.across.to/v/developer-docs/developers/across-sdk", "files": [ From a2d665137858fb398773046320996de99480d8b0 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Wed, 3 Jan 2024 01:18:43 +0100 Subject: [PATCH 2/3] chore: Remove redundant log message (#485) --- src/clients/SpokePoolClient.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/clients/SpokePoolClient.ts b/src/clients/SpokePoolClient.ts index e397b5d85..e59cd83e9 100644 --- a/src/clients/SpokePoolClient.ts +++ b/src/clients/SpokePoolClient.ts @@ -672,20 +672,13 @@ export class SpokePoolClient extends BaseAbstractClient { } }); this.earlyDeposits = earlyDeposits; - - const dataForQuoteTime = await this.batchComputeRealizedLpFeePct(depositEvents); - this.logger.debug({ - at: "SpokePoolClient", - message: `Computed ${dataForQuoteTime.length} realizedLpFees on ${this.chainId}!`, - }); - - // Now add any newly fetched events from RPC. if (depositEvents.length > 0) { this.log("debug", `Using ${depositEvents.length} newly queried deposit events for chain ${this.chainId}`, { earliestEvent: depositEvents[0].blockNumber, }); } + const dataForQuoteTime = await this.batchComputeRealizedLpFeePct(depositEvents); for (const [index, event] of Array.from(depositEvents.entries())) { const rawDeposit = spreadEventWithBlockNumber(event) as DepositWithBlock; From b62c83c2adea35f7d07b160951bec17177e7b501 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Wed, 3 Jan 2024 01:19:35 +0100 Subject: [PATCH 3/3] feat: Permit querying SpokePool relayFills mapping directly (#484) Can be useful as an RPC polygraph test. --- src/utils/SpokeUtils.ts | 24 +++++++++++++++++++++++- src/utils/index.ts | 1 + test/SpokePoolClient.ValidateFill.ts | 14 +++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/utils/SpokeUtils.ts b/src/utils/SpokeUtils.ts index ba1ba7f3e..00a2159a8 100644 --- a/src/utils/SpokeUtils.ts +++ b/src/utils/SpokeUtils.ts @@ -1,4 +1,6 @@ -import { Contract } from "ethers"; +import { getRelayHash } from "@across-protocol/contracts-v2/dist/test-utils"; +import { BigNumber, Contract } from "ethers"; +import { RelayData } from "../interfaces"; import { SpokePoolClient } from "../clients"; /** @@ -155,3 +157,23 @@ export async function getDepositIdAtBlock(contract: Contract, blockTag: number): } return depositIdAtBlock; } + +export function relayFilledAmount( + spokePool: Contract, + relayData: RelayData, + blockTag?: number | "latest" +): Promise { + const hash = getRelayHash( + relayData.depositor, + relayData.recipient, + relayData.depositId, + relayData.originChainId, + relayData.destinationChainId, + relayData.destinationToken, + relayData.amount, + relayData.realizedLpFeePct, + relayData.relayerFeePct + ).relayHash; + + return spokePool.relayFills(hash, { blockTag }); +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 7aa0996c7..99c712a3f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -25,3 +25,4 @@ export * from "./ReviverUtils"; export * from "./DepositUtils"; export * from "./ValidatorUtils"; export * from "./AddressUtils"; +export * from "./SpokeUtils"; diff --git a/test/SpokePoolClient.ValidateFill.ts b/test/SpokePoolClient.ValidateFill.ts index c9f8f9d7f..4b2b0bdf0 100644 --- a/test/SpokePoolClient.ValidateFill.ts +++ b/test/SpokePoolClient.ValidateFill.ts @@ -1,3 +1,4 @@ +import { RelayData } from "../src/interfaces"; import { expect, toBNWei, @@ -28,7 +29,7 @@ import { import { SpokePoolClient } from "../src/clients"; import { MockConfigStoreClient, MockHubPoolClient, MockSpokePoolClient } from "./mocks"; -import { validateFillForDeposit, queryHistoricalDepositForFill } from "../src/utils"; +import { relayFilledAmount, validateFillForDeposit, queryHistoricalDepositForFill } from "../src/utils"; import { CHAIN_ID_TEST_LIST, repaymentChainId } from "./constants"; let spokePool_1: Contract, erc20_1: Contract, spokePool_2: Contract, erc20_2: Contract, hubPool: Contract; @@ -103,6 +104,17 @@ describe("SpokePoolClient: Fill Validation", function () { await spokePool_1.setCurrentTime(await getLastBlockTime(spokePool_1.provider)); }); + it("Tracks fill status", async function () { + const deposit = await buildDeposit(hubPoolClient, spokePool_1, erc20_1, depositor, destinationChainId); + + let filled = await relayFilledAmount(spokePool_2, deposit as RelayData); + expect(filled.eq(0)).is.true; + + await buildFill(spokePool_2, erc20_2, depositor, relayer, deposit, 1); + filled = await relayFilledAmount(spokePool_2, deposit as RelayData); + expect(filled.eq(deposit.amount)).is.true; + }); + it("Accepts valid fills", async function () { const deposit = await buildDeposit(hubPoolClient, spokePool_1, erc20_1, depositor, destinationChainId); await buildFill(spokePool_2, erc20_2, depositor, relayer, deposit, 1);