Skip to content

Commit

Permalink
Add v3RelayData type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl committed Jan 17, 2024
1 parent 0f01aeb commit d6f2a33
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
28 changes: 22 additions & 6 deletions src/interfaces/SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,20 +302,36 @@ export type RelayerRefundExecutionWithBlockStringified = Omit<
refundAmounts: string[];
};

// Used in pool by spokePool to execute a slow relay.
export interface RelayData {
export interface RelayDataCommon {
originChainId: number;
depositor: string;
recipient: string;
depositId: number;
message: string;
}

// Used in pool by spokePool to execute a slow relay.
export interface v2RelayData extends RelayDataCommon {
destinationChainId: number;
destinationToken: string;
amount: BigNumber;
realizedLpFeePct: BigNumber;
relayerFeePct: BigNumber;
depositId: number;
originChainId: number;
realizedLpFeePct: BigNumber;
}

export interface v3RelayData extends RelayDataCommon {
destinationChainId: number;
message: string;
inputToken: string;
inputAmount: BigNumber;
outputToken: string;
outputAmount: BigNumber;
fillDeadline: number;
exclusiveRelayer: string;
exclusivityDeadline: number;
}

export type RelayData = v2RelayData;

export interface UnfilledDeposit {
deposit: Deposit;
unfilledAmount: BigNumber;
Expand Down
17 changes: 16 additions & 1 deletion src/utils/MigrationUtils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { FillType, v2Deposit, v3Deposit, v2Fill, v3Fill, v2SpeedUp, v3SpeedUp } from "../interfaces";
import {
FillType,
v2Deposit,
v3Deposit,
v2Fill,
v2RelayData,
v2SpeedUp,
v3Fill,
v3RelayData,
v3SpeedUp,
} from "../interfaces";
import { BN } from "./BigNumberUtils";
import { isDefined } from "./TypeGuards";

type Deposit = v2Deposit | v3Deposit;
type Fill = v2Fill | v3Fill;
type SpeedUp = v2SpeedUp | v3SpeedUp;
type RelayData = v2RelayData | v3RelayData;

export function isV2Deposit(deposit: Deposit): deposit is v2Deposit {
return isDefined((deposit as v2Deposit).originToken);
Expand All @@ -30,6 +41,10 @@ export function isV3Fill(fill: Fill): fill is v3Fill {
return isDefined((fill as v3Fill).inputToken);
}

export function isV2RelayData(relayData: RelayData): relayData is v2RelayData {
return isDefined((relayData as v2RelayData).destinationToken);
}

export function isSlowFill(fill: Fill): boolean {
return isV2Fill(fill) ? fill.updatableRelayData.isSlowRelay : fill.updatableRelayData.fillType === FillType.SlowFill;
}
Expand Down

0 comments on commit d6f2a33

Please sign in to comment.