diff --git a/package.json b/package.json index 3d43f5b57..7963f1346 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "dependencies": { "@across-protocol/constants-v2": "1.0.14", "@across-protocol/contracts-v2": "2.5.4", - "@across-protocol/sdk-v2": "0.22.19", + "@across-protocol/sdk-v2": "0.23.1", "@arbitrum/sdk": "^3.1.3", "@consensys/linea-sdk": "^0.2.1", "@defi-wonderland/smock": "^2.3.5", diff --git a/src/clients/BundleDataClient.ts b/src/clients/BundleDataClient.ts index a1c38103a..131ebacd7 100644 --- a/src/clients/BundleDataClient.ts +++ b/src/clients/BundleDataClient.ts @@ -7,8 +7,6 @@ import { V3FillWithBlock, FillType, FillStatus, - V2DepositWithBlock, - V2FillWithBlock, } from "../interfaces"; import { SpokePoolClient } from "../clients"; import { @@ -497,9 +495,8 @@ export class BundleDataClient { originClient .getDepositsForDestinationChain(destinationChainId) .filter((deposit) => deposit.blockNumber <= originChainBlockRange[1]) - .filter(utils.isV3Deposit) .forEach((deposit) => { - const relayDataHash = utils.getV3RelayHashFromEvent(deposit); + const relayDataHash = utils.getRelayHashFromEvent(deposit); if (v3RelayHashes[relayDataHash]) { // If we've seen this deposit before, then skip this deposit. This can happen if our RPC provider // gives us bad data. @@ -554,10 +551,9 @@ export class BundleDataClient { await utils.forEachAsync( destinationClient .getFillsForOriginChain(originChainId) - .filter((fill) => fill.blockNumber <= destinationChainBlockRange[1]) - .filter(utils.isV3Fill), + .filter((fill) => fill.blockNumber <= destinationChainBlockRange[1]), async (fill) => { - const relayDataHash = utils.getV3RelayHashFromEvent(fill); + const relayDataHash = utils.getRelayHashFromEvent(fill); if (v3RelayHashes[relayDataHash]) { if (!v3RelayHashes[relayDataHash].fill) { @@ -600,13 +596,12 @@ export class BundleDataClient { if (!historicalDeposit.found) { bundleInvalidFillsV3.push(fill); } else { - assert(utils.isV3Deposit(historicalDeposit.deposit)); const matchedDeposit = historicalDeposit.deposit; // @dev Since queryHistoricalDepositForFill validates the fill by checking individual // object property values against the deposit's, we // sanity check it here by comparing the full relay hashes. If there's an error here then the // historical deposit query is not working as expected. - assert(utils.getV3RelayHashFromEvent(matchedDeposit) === relayDataHash); + assert(utils.getRelayHashFromEvent(matchedDeposit) === relayDataHash); validatedBundleV3Fills.push({ ...fill, quoteTimestamp: matchedDeposit.quoteTimestamp, @@ -625,7 +620,7 @@ export class BundleDataClient { .getSlowFillRequestsForOriginChain(originChainId) .filter((request) => request.blockNumber <= destinationChainBlockRange[1]), async (slowFillRequest: SlowFillRequestWithBlock) => { - const relayDataHash = utils.getV3RelayHashFromEvent(slowFillRequest); + const relayDataHash = utils.getRelayHashFromEvent(slowFillRequest); if (v3RelayHashes[relayDataHash]) { if (!v3RelayHashes[relayDataHash].slowFillRequest) { @@ -684,7 +679,7 @@ export class BundleDataClient { // older deposit in case the spoke pool client's lookback isn't old enough to find the matching deposit. if (slowFillRequest.blockNumber >= destinationChainBlockRange[0]) { const historicalDeposit = await queryHistoricalDepositForFill(originClient, slowFillRequest); - if (!historicalDeposit.found || !utils.isV3Deposit(historicalDeposit.deposit)) { + if (!historicalDeposit.found) { // TODO: Invalid slow fill request. Maybe worth logging. return; } @@ -693,7 +688,7 @@ export class BundleDataClient { // object property values against the deposit's, we // sanity check it here by comparing the full relay hashes. If there's an error here then the // historical deposit query is not working as expected. - assert(utils.getV3RelayHashFromEvent(matchedDeposit) === relayDataHash); + assert(utils.getRelayHashFromEvent(matchedDeposit) === relayDataHash); v3RelayHashes[relayDataHash].deposit = matchedDeposit; // Note: we don't need to query for a historical fill at this point because a fill diff --git a/src/clients/ProfitClient.ts b/src/clients/ProfitClient.ts index b0b920270..3fcdcdcc6 100644 --- a/src/clients/ProfitClient.ts +++ b/src/clients/ProfitClient.ts @@ -227,7 +227,7 @@ export class ProfitClient { async getTotalGasCost(deposit: V3Deposit, fillAmount?: BigNumber): Promise { const { destinationChainId: chainId } = deposit; - fillAmount ??= sdkUtils.getDepositOutputAmount(deposit); + fillAmount ??= deposit.outputAmount; // If there's no attached message, gas consumption from previous fills can be used in most cases. // @todo: Simulate this per-token in future, because some ERC20s consume more gas. @@ -257,7 +257,7 @@ export class ProfitClient { fillAmount?: BigNumber ): Promise> { const { destinationChainId: chainId } = deposit; - fillAmount ??= sdkUtils.getDepositOutputAmount(deposit); + fillAmount ??= deposit.outputAmount; const gasToken = this.resolveGasToken(chainId); const gasTokenPriceUsd = this.getPriceOfToken(gasToken.symbol); @@ -404,7 +404,7 @@ export class ProfitClient { getFillAmountInUsd(deposit: Deposit, fillAmount: BigNumber): BigNumber { const l1TokenInfo = this.hubPoolClient.getTokenInfoForDeposit(deposit); if (!l1TokenInfo) { - const inputToken = sdkUtils.getDepositInputToken(deposit); + const { inputToken } = deposit; throw new Error( `ProfitClient#getFillAmountInUsd missing l1TokenInfo for deposit with origin token: ${inputToken}` ); diff --git a/src/dataworker/Dataworker.ts b/src/dataworker/Dataworker.ts index 1afeb08c7..412c08c51 100644 --- a/src/dataworker/Dataworker.ts +++ b/src/dataworker/Dataworker.ts @@ -23,8 +23,6 @@ import { PoolRebalanceLeaf, RelayerRefundLeaf, V3SlowFillLeaf, - V2FillWithBlock, - V3FillWithBlock, } from "../interfaces"; import { DataworkerClients } from "./DataworkerClientHelper"; import { SpokePoolClient, BalanceAllocator } from "../clients"; @@ -127,9 +125,9 @@ export class Dataworker { } } - isV3(blockNumber: number): boolean { - const versionAtBlock = this.clients.configStoreClient.getConfigStoreVersionForBlock(blockNumber); - return sdk.utils.isV3(versionAtBlock); + isV3(_blockNumber: number): boolean { + _blockNumber; // lint + return true; } // This should be called whenever it's possible that the loadData information for a block range could have changed. @@ -1058,7 +1056,7 @@ export class Dataworker { continue; } - const leavesForChain = leaves.filter((leaf) => sdkUtils.getSlowFillLeafChainId(leaf) === chainId); + const leavesForChain = leaves.filter((leaf) => leaf.chainId === chainId); const unexecutedLeaves = leavesForChain.filter((leaf) => { const executedLeaf = slowFillsForChain.find( (event) => @@ -1137,7 +1135,7 @@ export class Dataworker { const chainId = client.chainId; - const sortedFills = client.getFills().filter(sdkUtils.isV3Fill); + const sortedFills = client.getFills(); const latestFills = leaves.map((slowFill) => { const { relayData, chainId: slowFillChainId } = slowFill; @@ -1147,7 +1145,7 @@ export class Dataworker { !( fill.depositId === relayData.depositId && fill.originChainId === relayData.originChainId && - sdkUtils.getV3RelayHash(fill, chainId) === sdkUtils.getV3RelayHash(relayData, slowFillChainId) + sdkUtils.getRelayDataHash(fill, chainId) === sdkUtils.getRelayDataHash(relayData, slowFillChainId) ) ) { return false; @@ -1162,7 +1160,7 @@ export class Dataworker { const fundedLeaves = ( await Promise.all( leaves.map(async (slowFill, idx) => { - const destinationChainId = sdkUtils.getSlowFillLeafChainId(slowFill); + const destinationChainId = slowFill.chainId; if (destinationChainId !== chainId) { throw new Error(`Leaf chainId does not match input chainId (${destinationChainId} != ${chainId})`); } @@ -1207,7 +1205,7 @@ export class Dataworker { const hubChainId = this.clients.hubPoolClient.chainId; fundedLeaves.forEach((leaf) => { - assert(sdkUtils.getSlowFillLeafChainId(leaf) === chainId); + assert(leaf.chainId === chainId); const { relayData } = leaf; const { outputAmount } = relayData; @@ -1396,7 +1394,7 @@ export class Dataworker { // Now, execute refund and slow fill leaves for Mainnet using new funds. These methods will return early if there // are no relevant leaves to execute. await this._executeSlowFillLeaf( - expectedTrees.slowRelayTree.leaves.filter((leaf) => sdkUtils.getSlowFillLeafChainId(leaf) === hubPoolChainId), + expectedTrees.slowRelayTree.leaves.filter((leaf) => leaf.chainId === hubPoolChainId), balanceAllocator, spokePoolClients[hubPoolChainId], expectedTrees.slowRelayTree.tree, diff --git a/src/dataworker/DataworkerUtils.ts b/src/dataworker/DataworkerUtils.ts index 577a101c5..82accc633 100644 --- a/src/dataworker/DataworkerUtils.ts +++ b/src/dataworker/DataworkerUtils.ts @@ -198,7 +198,7 @@ export function _buildSlowRelayRoot(bundleSlowFillsV3: BundleSlowFills): { }; } -function buildV3SlowFillLeaf(deposit: interfaces.V3Deposit): V3SlowFillLeaf { +function buildV3SlowFillLeaf(deposit: interfaces.Deposit): V3SlowFillLeaf { const lpFee = deposit.inputAmount.mul(deposit.realizedLpFeePct).div(fixedPointAdjustment); return { diff --git a/src/dataworker/PoolRebalanceUtils.ts b/src/dataworker/PoolRebalanceUtils.ts index e191ed976..1236b4847 100644 --- a/src/dataworker/PoolRebalanceUtils.ts +++ b/src/dataworker/PoolRebalanceUtils.ts @@ -390,8 +390,8 @@ export function generateMarkdownForRootBundle( let slowRelayLeavesPretty = ""; slowRelayLeaves.forEach((leaf, index) => { - const outputToken = sdkUtils.getRelayDataOutputToken(leaf.relayData); - const destinationChainId = sdkUtils.getSlowFillLeafChainId(leaf); + const { outputToken } = leaf.relayData; + const destinationChainId = leaf.chainId; const outputTokenDecimals = hubPoolClient.getTokenInfo(destinationChainId, outputToken).decimals; const lpFeePct = sdkUtils.getSlowFillLeafLpFeePct(leaf); diff --git a/src/interfaces/BundleData.ts b/src/interfaces/BundleData.ts index c206276c3..deda66c81 100644 --- a/src/interfaces/BundleData.ts +++ b/src/interfaces/BundleData.ts @@ -2,17 +2,17 @@ import { interfaces } from "@across-protocol/sdk-v2"; import { BigNumber } from "../utils"; export type ExpiredDepositsToRefundV3 = { [originChainId: number]: { - [originToken: string]: interfaces.V3DepositWithBlock[]; + [originToken: string]: interfaces.DepositWithBlock[]; }; }; export type BundleDepositsV3 = { [originChainId: number]: { - [originToken: string]: interfaces.V3DepositWithBlock[]; + [originToken: string]: interfaces.DepositWithBlock[]; }; }; -export interface BundleFillV3 extends interfaces.V3FillWithBlock { +export interface BundleFillV3 extends interfaces.FillWithBlock { lpFeePct: BigNumber; } @@ -29,12 +29,12 @@ export type BundleFillsV3 = { export type BundleExcessSlowFills = { [destinationChainId: number]: { - [destinationToken: string]: interfaces.V3DepositWithBlock[]; + [destinationToken: string]: interfaces.DepositWithBlock[]; }; }; export type BundleSlowFills = { [destinationChainId: number]: { - [destinationToken: string]: interfaces.V3DepositWithBlock[]; + [destinationToken: string]: interfaces.DepositWithBlock[]; }; }; diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index e064ccab9..243985ddc 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -59,17 +59,11 @@ export const { FillType, FillStatus } = interfaces; export type CachingMechanismInterface = interfaces.CachingMechanismInterface; -// V2 / V3 interfaces -export type V2RelayData = interfaces.V2RelayData; -export type V3RelayData = interfaces.V3RelayData; -export type V2Deposit = interfaces.V2Deposit; -export type V3Deposit = interfaces.V3Deposit; -export type V2DepositWithBlock = interfaces.V2DepositWithBlock; -export type V3DepositWithBlock = interfaces.V3DepositWithBlock; -export type V2SpeedUp = interfaces.V2SpeedUp; -export type V3SpeedUp = interfaces.V3SpeedUp; -export type V2Fill = interfaces.V2Fill; -export type V3Fill = interfaces.V3Fill; -export type V2FillWithBlock = interfaces.V2FillWithBlock; -export type V3FillWithBlock = interfaces.V3FillWithBlock; -export type V3SlowFillLeaf = interfaces.V3SlowFillLeaf; +// V3 shims (to be removed later) +export type V3RelayData = interfaces.RelayData; +export type V3Deposit = interfaces.Deposit; +export type V3DepositWithBlock = interfaces.DepositWithBlock; +export type V3SpeedUp = interfaces.SpeedUp; +export type V3Fill = interfaces.Fill; +export type V3FillWithBlock = interfaces.FillWithBlock; +export type V3SlowFillLeaf = interfaces.SlowFillLeaf; diff --git a/src/scripts/validateRunningBalances.ts b/src/scripts/validateRunningBalances.ts index d2d2e3e92..944473466 100644 --- a/src/scripts/validateRunningBalances.ts +++ b/src/scripts/validateRunningBalances.ts @@ -19,7 +19,6 @@ // which also indicates an amount of tokens that need to be taken out of the spoke pool to execute those refunds // - excess_t_c_{i,i+1,i+2,...} should therefore be consistent unless tokens are dropped onto the spoke pool. -import { utils as sdkUtils } from "@across-protocol/sdk-v2"; import { bnZero, winston, @@ -257,7 +256,7 @@ export async function runScript(_logger: winston.Logger, baseSigner: Signer): Pr if (slowFillsForPoolRebalanceLeaf.length > 0) { for (const slowFillForChain of slowFillsForPoolRebalanceLeaf) { - const destinationChainId = sdkUtils.getSlowFillLeafChainId(slowFillForChain); + const destinationChainId = slowFillForChain.chainId; const fillsForSameDeposit = bundleSpokePoolClients[destinationChainId] .getFillsForOriginChain(slowFillForChain.relayData.originChainId) .filter( diff --git a/src/utils/FillUtils.ts b/src/utils/FillUtils.ts index 457db033b..85ab25b88 100644 --- a/src/utils/FillUtils.ts +++ b/src/utils/FillUtils.ts @@ -1,7 +1,7 @@ import assert from "assert"; import { utils as sdkUtils } from "@across-protocol/sdk-v2"; import { HubPoolClient, SpokePoolClient } from "../clients"; -import { Fill, FillStatus, SpokePoolClientsByChain, V2DepositWithBlock, V3DepositWithBlock } from "../interfaces"; +import { Fill, FillStatus, SpokePoolClientsByChain, V3DepositWithBlock } from "../interfaces"; import { getBlockForTimestamp, getRedisCache } from "../utils"; import { isDefined } from "./"; import { getBlockRangeForChain } from "../dataworker/DataworkerUtils"; @@ -25,20 +25,13 @@ export function getRefundInformationFromFill( hubPoolClient.chainId, chainIdListForBundleEvaluationBlockNumbers )[1]; - let l1TokenCounterpart: string; - if (sdkUtils.isV3Fill(fill)) { - l1TokenCounterpart = hubPoolClient.getL1TokenForL2TokenAtBlock( - fill.inputToken, - fill.originChainId, - endBlockForMainnet - ); - } else { - l1TokenCounterpart = hubPoolClient.getL1TokenForL2TokenAtBlock( - sdkUtils.getFillOutputToken(fill), - fill.destinationChainId, - endBlockForMainnet - ); - } + + const l1TokenCounterpart = hubPoolClient.getL1TokenForL2TokenAtBlock( + fill.inputToken, + fill.originChainId, + endBlockForMainnet + ); + const repaymentToken = hubPoolClient.getL2TokenForL1TokenAtBlock( l1TokenCounterpart, chainToSendRefundTo, @@ -102,8 +95,7 @@ export async function getUnfilledDeposits( // Find all unfilled deposits for the current loops originChain -> destinationChain. return originClient .getDepositsForDestinationChain(destinationChainId) - .filter((deposit) => deposit.blockNumber >= earliestBlockNumber) - .filter(sdkUtils.isV3Deposit); // @todo: Remove after v2 deprecated. + .filter((deposit) => deposit.blockNumber >= earliestBlockNumber); }) .flat(); diff --git a/test/Dataworker.buildRoots.ts b/test/Dataworker.buildRoots.ts index 760d72cd6..1443fad44 100644 --- a/test/Dataworker.buildRoots.ts +++ b/test/Dataworker.buildRoots.ts @@ -1,12 +1,6 @@ +import { interfaces } from "@across-protocol/sdk-v2"; import { HubPoolClient, SpokePoolClient } from "../src/clients"; -import { - RelayerRefundLeaf, - RunningBalances, - V2DepositWithBlock, - V2FillWithBlock, - V3DepositWithBlock, - V3FillWithBlock, -} from "../src/interfaces"; +import { RelayerRefundLeaf, RunningBalances } from "../src/interfaces"; import { assert, bnZero, fixedPointAdjustment } from "../src/utils"; import { amountToDeposit, destinationChainId, mockTreeRoot, originChainId, repaymentChainId } from "./constants"; import { setupFastDataworker } from "./fixtures/Dataworker.Fixture"; @@ -24,7 +18,6 @@ import { toBN, buildV3SlowRelayTree, } from "./utils"; -import { utils as sdkUtils, interfaces } from "@across-protocol/sdk-v2"; // Tested import { Dataworker } from "../src/dataworker/Dataworker"; @@ -114,21 +107,15 @@ describe("Dataworker: Build merkle roots", async function () { amountToDeposit ); await updateAllClients(); - const deposit1 = spokePoolClients[originChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; - const deposit2 = spokePoolClients[destinationChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; + const [deposit1] = spokePoolClients[originChainId].getDeposits(); + const [deposit2] = spokePoolClients[destinationChainId].getDeposits(); + await fillV3(spokePool_2, relayer, deposit1, repaymentChainId); await fillV3(spokePool_1, relayer, deposit2, repaymentChainId); await updateAllClients(); - const fill1 = spokePoolClients[destinationChainId] - .getFills() - .filter(sdkUtils.isV3Fill)[0]; - const fill2 = spokePoolClients[originChainId] - .getFills() - .filter(sdkUtils.isV3Fill)[0]; + const [fill1] = spokePoolClients[destinationChainId].getFills(); + const [fill2] = spokePoolClients[originChainId].getFills(); + const merkleRoot1 = await dataworkerInstance.buildPoolRebalanceRoot(getDefaultBlockRange(2), spokePoolClients); // Deposits should not add to bundle LP fees, but fills should. LP fees are taken out of running balances @@ -172,9 +159,7 @@ describe("Dataworker: Build merkle roots", async function () { amountToDeposit ); await updateAllClients(); - const deposit = spokePoolClients[originChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; + const [deposit] = spokePoolClients[originChainId].getDeposits(); await requestSlowFill(spokePool_2, relayer, deposit); await updateAllClients(); const slowFillRequest = spokePoolClients[destinationChainId].getSlowFillRequestsForOriginChain(originChainId)[0]; @@ -208,9 +193,7 @@ describe("Dataworker: Build merkle roots", async function () { amountToDeposit ); await updateAllClients(); - const deposit = spokePoolClients[originChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; + const [deposit] = spokePoolClients[originChainId].getDeposits(); await requestSlowFill(spokePool_2, relayer, deposit); await updateAllClients(); @@ -240,9 +223,8 @@ describe("Dataworker: Build merkle roots", async function () { // Send a fast fill in a second bundle block range. await fillV3(spokePool_2, relayer, deposit, repaymentChainId); await updateAllClients(); - const fill = spokePoolClients[destinationChainId] - .getFills() - .filter(sdkUtils.isV3Fill)[0]; + const [fill] = spokePoolClients[destinationChainId].getFills(); + expect(fill.relayExecutionInfo.fillType).to.equal(interfaces.FillType.ReplacedSlowFill); const blockRange2 = dataworkerInstance.chainIdListForBundleEvaluationBlockNumbers.map((_chain, index) => [ blockRange1[index][1] + 1, @@ -314,9 +296,8 @@ describe("Dataworker: Build merkle roots", async function () { amountToDeposit ); await updateAllClients(); - const deposit = spokePoolClients[originChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; + const [deposit] = spokePoolClients[originChainId].getDeposits(); + await fillV3(spokePool_2, relayer, deposit, repaymentChainId); await updateAllClients(); const { runningBalances, leaves } = await dataworkerInstance.buildPoolRebalanceRoot( @@ -367,9 +348,8 @@ describe("Dataworker: Build merkle roots", async function () { amountToDeposit ); await updateAllClients(); - const deposit = spokePoolClients[originChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; + const [deposit] = spokePoolClients[originChainId].getDeposits(); + const lpFeePct = ( await hubPoolClient.computeRealizedLpFeePct({ ...deposit, paymentChainId: deposit.destinationChainId }) ).realizedLpFeePct; @@ -446,9 +426,8 @@ describe("Dataworker: Build merkle roots", async function () { } ); await updateAllClients(); - const deposit = spokePoolClients[originChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; + const [deposit] = spokePoolClients[originChainId].getDeposits(); + const { runningBalances, leaves } = await dataworkerInstance.buildPoolRebalanceRoot( getDefaultBlockRange(2), spokePoolClients @@ -486,9 +465,8 @@ describe("Dataworker: Build merkle roots", async function () { amountToDeposit ); await updateAllClients(); - const deposit = spokePoolClients[originChainId] - .getDeposits() - .filter(sdkUtils.isV3Deposit)[0]; + const [deposit] = spokePoolClients[originChainId].getDeposits(); + await requestSlowFill(spokePool_2, relayer, deposit); await updateAllClients(); const merkleRoot1 = await dataworkerInstance.buildSlowRelayRoot(getDefaultBlockRange(2), spokePoolClients); diff --git a/test/Dataworker.loadData.ts b/test/Dataworker.loadData.ts index d0de7e664..781d8b11a 100644 --- a/test/Dataworker.loadData.ts +++ b/test/Dataworker.loadData.ts @@ -891,7 +891,7 @@ describe("Dataworker: Load data used in all functions", async function () { await updateAllClients(); const requests = spokePoolClient_2.getSlowFillRequestsForOriginChain(originChainId); expect(requests.length).to.equal(1); - expect(sdkUtils.getV3RelayHashFromEvent(requests[0])).to.equal(sdkUtils.getV3RelayHashFromEvent(depositObject)); + expect(sdkUtils.getRelayHashFromEvent(requests[0])).to.equal(sdkUtils.getRelayHashFromEvent(depositObject)); const data1 = await dataworkerInstance.clients.bundleDataClient.loadData(getDefaultBlockRange(5), { ...spokePoolClients, @@ -942,7 +942,7 @@ describe("Dataworker: Load data used in all functions", async function () { await mockOriginSpokePoolClient.update(["V3FundsDeposited"]); // Let's make fill status for the relay hash always return Filled. - const expiredDepositHash = sdkUtils.getV3RelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); + const expiredDepositHash = sdkUtils.getRelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); mockDestinationSpokePool.fillStatuses.whenCalledWith(expiredDepositHash).returns(interfaces.FillStatus.Filled); // Now, load a bundle that doesn't include the deposit in its range. @@ -996,7 +996,7 @@ describe("Dataworker: Load data used in all functions", async function () { await mockOriginSpokePoolClient.update(["V3FundsDeposited"]); // Let's make fill status for the relay hash always return RequestedSlowFill. - const expiredDepositHash = sdkUtils.getV3RelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); + const expiredDepositHash = sdkUtils.getRelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); mockDestinationSpokePool.fillStatuses .whenCalledWith(expiredDepositHash) .returns(interfaces.FillStatus.RequestedSlowFill); @@ -1025,7 +1025,7 @@ describe("Dataworker: Load data used in all functions", async function () { await mockOriginSpokePoolClient.update(["V3FundsDeposited"]); // Let's make fill status for the relay hash always return Unfilled. - const expiredDepositHash = sdkUtils.getV3RelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); + const expiredDepositHash = sdkUtils.getRelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); mockDestinationSpokePool.fillStatuses.whenCalledWith(expiredDepositHash).returns(interfaces.FillStatus.Unfilled); // Now, load a bundle that doesn't include the deposit in its range. @@ -1058,7 +1058,7 @@ describe("Dataworker: Load data used in all functions", async function () { await mockDestinationSpokePoolClient.update(["RequestedV3SlowFill"]); // Let's make fill status for the relay hash always return RequestedSlowFill. - const expiredDepositHash = sdkUtils.getV3RelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); + const expiredDepositHash = sdkUtils.getRelayHashFromEvent(mockOriginSpokePoolClient.getDeposits()[0]); mockDestinationSpokePool.fillStatuses .whenCalledWith(expiredDepositHash) .returns(interfaces.FillStatus.RequestedSlowFill); diff --git a/test/Relayer.BasicFill.ts b/test/Relayer.BasicFill.ts index 86516b01b..4d71dfc46 100644 --- a/test/Relayer.BasicFill.ts +++ b/test/Relayer.BasicFill.ts @@ -1,6 +1,5 @@ import { clients, constants, utils as sdkUtils } from "@across-protocol/sdk-v2"; import { AcrossApiClient, ConfigStoreClient, MultiCallerClient, TokenClient } from "../src/clients"; -import { V2FillWithBlock, V3FillWithBlock } from "../src/interfaces"; import { CONFIG_STORE_VERSION } from "../src/common"; import { bnOne, getUnfilledDeposits } from "../src/utils"; import { Relayer } from "../src/relayer/Relayer"; @@ -30,7 +29,7 @@ import { expect, fillV3Relay, getLastBlockTime, - getV3RelayHash, + getRelayDataHash, lastSpyLogIncludes, randomAddress, setupTokensForWallet, @@ -205,14 +204,12 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () { expect(tx.length).to.equal(1); // There should have been exactly one transaction. await Promise.all([spokePoolClient_1.update(), spokePoolClient_2.update(), hubPoolClient.update()]); - const fills = spokePoolClient_2 - .getFillsForOriginChain(deposit.originChainId) - .filter(sdkUtils.isV3Fill); - expect(fills.length).to.equal(1); - const fill = fills.at(-1)!; - - expect(getV3RelayHash(fill, fill.destinationChainId)).to.equal( - getV3RelayHash(deposit, deposit.destinationChainId) + let fill = spokePoolClient_2.getFillsForOriginChain(deposit.originChainId).at(-1); + expect(fill).to.exist; + fill = fill!; + + expect(getRelayDataHash(fill, fill.destinationChainId)).to.equal( + getRelayDataHash(deposit, deposit.destinationChainId) ); // Re-run the execution loop and validate that no additional relays are sent. @@ -519,15 +516,12 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () { expect(tx.length).to.equal(1); // There should have been exactly one transaction. await spokePoolClient_2.update(); - const fills = spokePoolClient_2 - .getFillsForRelayer(relayer.address) - .filter(sdkUtils.isV3Fill); - expect(fills.length).to.equal(1); - const fill = fills.at(-1)!; - - expect(sdkUtils.isV3Fill(fill)).to.be.true; - expect(getV3RelayHash(fill, fill.destinationChainId)).to.equal( - getV3RelayHash(deposit, deposit.destinationChainId) + let fill = spokePoolClient_2.getFillsForRelayer(relayer.address).at(-1); + expect(fill).to.exist; + fill = fill!; + + expect(getRelayDataHash(fill, fill.destinationChainId)).to.equal( + getRelayDataHash(deposit, deposit.destinationChainId) ); expect(fill.relayExecutionInfo.updatedOutputAmount.eq(deposit.outputAmount)).to.be.false; diff --git a/test/Relayer.SlowFill.ts b/test/Relayer.SlowFill.ts index 9d70952c5..9e8b5f32c 100644 --- a/test/Relayer.SlowFill.ts +++ b/test/Relayer.SlowFill.ts @@ -30,7 +30,7 @@ import { ethers, expect, getLastBlockTime, - getV3RelayHash, + getRelayDataHash, lastSpyLogIncludes, setupTokensForWallet, sinon, @@ -206,8 +206,8 @@ describe("Relayer: Initiates slow fill requests", async function () { expect(slowFillRequest).to.exist; slowFillRequest = slowFillRequest!; // tsc coersion - expect(getV3RelayHash(slowFillRequest, slowFillRequest.destinationChainId)).to.equal( - getV3RelayHash(deposit, deposit.destinationChainId) + expect(getRelayDataHash(slowFillRequest, slowFillRequest.destinationChainId)).to.equal( + getRelayDataHash(deposit, deposit.destinationChainId) ); await relayerInstance.checkForUnfilledDepositsAndFill(); diff --git a/test/Relayer.UnfilledDeposits.ts b/test/Relayer.UnfilledDeposits.ts index 88bc585f0..2be9f668c 100644 --- a/test/Relayer.UnfilledDeposits.ts +++ b/test/Relayer.UnfilledDeposits.ts @@ -12,7 +12,6 @@ import { } from "./constants"; import { MockInventoryClient, MockProfitClient, MockConfigStoreClient, MockedMultiCallerClient } from "./mocks"; import { - assert, BigNumber, Contract, SignerWithAddress, @@ -287,7 +286,6 @@ describe("Relayer: Unfilled Deposits", async function () { expect(unfilledDeposit.deposit.depositId).to.equal(deposit.depositId); // expect unfilled deposit to have the same outputAmount, but a lower updatedOutputAmount. - assert(sdkUtils.isV3Deposit(unfilledDeposit.deposit)); expect(unfilledDeposit.deposit.outputAmount).to.deep.eq(outputAmount); expect(unfilledDeposit.deposit.updatedOutputAmount).to.deep.eq(updatedOutputAmount); }); @@ -307,9 +305,8 @@ describe("Relayer: Unfilled Deposits", async function () { await updateAllClients(); unfilledDeposits = await _getUnfilledDeposits(); expect(unfilledDeposits.length).to.equal(1); - assert(sdkUtils.isV3Deposit(unfilledDeposits[0].deposit)); - expect(sdkUtils.getV3RelayHash(unfilledDeposits[0].deposit, destinationChainId)).to.equal( - sdkUtils.getV3RelayHash(deposit, deposit.destinationChainId) + expect(sdkUtils.getRelayDataHash(unfilledDeposits[0].deposit, destinationChainId)).to.equal( + sdkUtils.getRelayDataHash(deposit, deposit.destinationChainId) ); await fillV3Relay(spokePool_2, deposit, relayer); diff --git a/test/utils/utils.ts b/test/utils/utils.ts index 30fb13051..78c59bc42 100644 --- a/test/utils/utils.ts +++ b/test/utils/utils.ts @@ -57,7 +57,7 @@ export const { modifyRelayHelper, randomAddress, } = utils; -export const { getV3RelayHash } = sdkUtils; +export const { getRelayDataHash } = sdkUtils; export type SignerWithAddress = utils.SignerWithAddress; export { assert, chai, expect, BigNumber, Contract, FakeContract, sinon, toBN, toBNWei, toWei, utf8ToHex, winston }; diff --git a/yarn.lock b/yarn.lock index db96e1b87..b98a48c8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -45,10 +45,10 @@ "@openzeppelin/contracts" "4.1.0" "@uma/core" "^2.18.0" -"@across-protocol/sdk-v2@0.22.19": - version "0.22.19" - resolved "https://registry.yarnpkg.com/@across-protocol/sdk-v2/-/sdk-v2-0.22.19.tgz#65531294f3ccaacf3b2323f400e530a1e2ab6210" - integrity sha512-7b6eT9nKKnrBZVxzB+h3QsSNonsQbCfnbN3vSME/ZPjCmJGgWJj1O8LVwLn/6xNpOoLg13TD6aOkZQAjG+Oeyg== +"@across-protocol/sdk-v2@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@across-protocol/sdk-v2/-/sdk-v2-0.23.1.tgz#1d60d9aa0654311d69ab89fd6065038d1ffd3a2b" + integrity sha512-xwNmf9SQuSrObc/uhFLyrzmo+dircsZNQMedsqU2oqJLTV2Tet5/r2GOa7d5PRp1XektBFKPE6fZ3z3BSikTOQ== dependencies: "@across-protocol/across-token" "^1.0.0" "@across-protocol/constants-v2" "^1.0.14"