From 1330fb1974c7662b6f5c63f23193e9eec7e9c953 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:05:14 +0100 Subject: [PATCH 1/2] fix: Correct V3Fill type definition (#550) Identified by Nick in a separate PR. It's proposed separately here because it's a standalone fix that's easy to review and merge now. --- src/clients/mocks/MockSpokePoolClient.ts | 12 +++++------ src/interfaces/SpokePool.ts | 2 +- src/interfaces/UBA.ts | 27 ------------------------ src/interfaces/index.ts | 1 - src/utils/V3Utils.ts | 2 +- test/utils/SpokePoolUtils.ts | 2 +- 6 files changed, 9 insertions(+), 37 deletions(-) delete mode 100644 src/interfaces/UBA.ts diff --git a/src/clients/mocks/MockSpokePoolClient.ts b/src/clients/mocks/MockSpokePoolClient.ts index a12c6c09..7386be2f 100644 --- a/src/clients/mocks/MockSpokePoolClient.ts +++ b/src/clients/mocks/MockSpokePoolClient.ts @@ -323,11 +323,11 @@ export class MockSpokePoolClient extends SpokePoolClient { depositor: fill.depositor ?? randomAddress(), recipient, message, - updatableRelayData: { - updatedRecipient: fill.updatableRelayData?.recipient ?? recipient, - updatedMessage: fill.updatableRelayData?.message ?? message, - updatedOutputAmount: fill.updatableRelayData?.outputAmount ?? outputAmount, - fillType: fill.updatableRelayData?.fillType ?? FillType.FastFill, + relayExecutionInfo: { + updatedRecipient: fill.relayExecutionInfo?.recipient ?? recipient, + updatedMessage: fill.relayExecutionInfo?.message ?? message, + updatedOutputAmount: fill.relayExecutionInfo?.outputAmount ?? outputAmount, + fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill, }, }; @@ -392,7 +392,7 @@ export class MockSpokePoolClient extends SpokePoolClient { destinationChainId: this.chainId, relayer: ZERO_ADDRESS, repaymentChainId: 0, - updatableRelayData: { + relayExecutionInfo: { recipient: leaf.relayData.recipient, outputAmount: leaf.updatedOutputAmount, message: leaf.relayData.message, diff --git a/src/interfaces/SpokePool.ts b/src/interfaces/SpokePool.ts index 0eb69c26..604cb09c 100644 --- a/src/interfaces/SpokePool.ts +++ b/src/interfaces/SpokePool.ts @@ -105,7 +105,7 @@ export interface V3Fill extends V3RelayData { destinationChainId: number; relayer: string; repaymentChainId: number; - updatableRelayData: V3RelayExecutionEventInfo; + relayExecutionInfo: V3RelayExecutionEventInfo; } export interface V2FillWithBlock extends V2Fill, SortableEvent {} diff --git a/src/interfaces/UBA.ts b/src/interfaces/UBA.ts deleted file mode 100644 index a66cee63..00000000 --- a/src/interfaces/UBA.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { BigNumber } from "ethers"; -import { DepositWithBlock, FillWithBlock } from "./"; - -export type UbaInflow = DepositWithBlock; -export type UbaOutflow = FillWithBlock & { matchedDeposit: DepositWithBlock }; -export type UbaFlow = UbaInflow | UbaOutflow; - -export const isUbaInflow = (flow: UbaFlow): flow is UbaInflow => { - return (flow as UbaInflow)?.quoteTimestamp !== undefined; -}; - -export const isUbaOutflow = (flow: UbaFlow): flow is UbaOutflow => { - return !isUbaInflow(flow) && outflowIsFill(flow); -}; - -export const outflowIsFill = (outflow: UbaOutflow): outflow is FillWithBlock & { matchedDeposit: DepositWithBlock } => { - return (outflow as FillWithBlock)?.updatableRelayData !== undefined; -}; - -export type UBASpokeBalanceType = { - chainId: number; - blockNumber: number; - lastValidatedRunningBalance?: BigNumber; - recentRequestFlow: UbaFlow[]; -}; - -export type UBAFeeResult = { depositorFee: BigNumber; refundFee: BigNumber; totalUBAFee: BigNumber }; diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 92373728..a74b85f4 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -3,7 +3,6 @@ export * from "./ConfigStore"; export * from "./HubPool"; export * from "./SpokePool"; export * from "./Bridge"; -export * from "./UBA"; export * from "./Error"; export * from "./TypedData"; export * from "./CachingMechanism"; diff --git a/src/utils/V3Utils.ts b/src/utils/V3Utils.ts index 63a8bd5f..833256a0 100644 --- a/src/utils/V3Utils.ts +++ b/src/utils/V3Utils.ts @@ -85,7 +85,7 @@ export function isV3RelayData; diff --git a/test/utils/SpokePoolUtils.ts b/test/utils/SpokePoolUtils.ts index b2a4f13e..05722d08 100644 --- a/test/utils/SpokePoolUtils.ts +++ b/test/utils/SpokePoolUtils.ts @@ -57,7 +57,7 @@ export function v3FillFromDeposit(deposit: V3DepositWithBlock, relayer: string): // Caller can modify these later. exclusiveRelayer: relayer, repaymentChainId: deposit.destinationChainId, - updatableRelayData: { + relayExecutionInfo: { recipient: deposit.updatedRecipient ?? recipient, message: deposit.updatedMessage ?? message, outputAmount: deposit.updatedOutputAmount ?? deposit.outputAmount, From 713f99323d1b16c13ad6b1ef6d9968a16c4e8e31 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:12:56 +0100 Subject: [PATCH 2/2] improve: Simplify token approvals in test (#548) Approve the entire EOA balance for convenience, and streamline the code a bit. --- test/utils/utils.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/utils/utils.ts b/test/utils/utils.ts index 52bd7a30..d273b333 100644 --- a/test/utils/utils.ts +++ b/test/utils/utils.ts @@ -98,14 +98,16 @@ export async function setupTokensForWallet( weth?: utils.Contract, seedMultiplier = 1 ): Promise { + const approveToken = async (token: Contract) => { + const balance = await token.balanceOf(wallet.address); + await token.connect(wallet).approve(contractToApprove.address, balance); + }; + await utils.seedWallet(wallet, tokens, weth, utils.amountToSeedWallets.mul(seedMultiplier)); - await Promise.all( - tokens.map((token) => - token.connect(wallet).approve(contractToApprove.address, utils.amountToDeposit.mul(seedMultiplier)) - ) - ); + await Promise.all(tokens.map(approveToken)); + if (weth) { - await weth.connect(wallet).approve(contractToApprove.address, utils.amountToDeposit); + await approveToken(weth); } }