Skip to content

Commit

Permalink
Merge branch 'master' into pxrl/bump
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl authored Feb 13, 2024
2 parents 7d5cf2a + 54378dc commit db5f27f
Show file tree
Hide file tree
Showing 33 changed files with 527 additions and 2,904 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
},
"dependencies": {
"@across-protocol/across-token": "^1.0.0",
"@across-protocol/constants-v2": "^1.0.9",
"@across-protocol/constants-v2": "^1.0.11",
"@across-protocol/contracts-v2": "2.5.0-beta.5",
"@eth-optimism/sdk": "^3.1.8",
"@pinata/sdk": "^2.1.0",
Expand Down
22 changes: 5 additions & 17 deletions src/clients/SpokePoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ import {
TokensBridged,
V2DepositWithBlock,
V2FillWithBlock,
V2RelayerRefundExecutionWithBlock,
V2SpeedUp,
V3DepositWithBlock,
V3FillWithBlock,
V3FundsDepositedEvent,
V3RelayData,
V3RelayerRefundExecutionWithBlock,
V3SpeedUp,
} from "../interfaces";
import { SpokePool } from "../typechain";
Expand Down Expand Up @@ -129,8 +127,8 @@ export class SpokePoolClient extends BaseAbstractClient {
"ExecutedRelayerRefundRoot",
"V3FundsDeposited",
"RequestedSpeedUpV3Deposit",
"RequestedV3SlowFill",
"FilledV3Relay",
"ExecutedV3RelayerRefundRoot",
];
return Object.fromEntries(
this.spokePool.interface.fragments
Expand Down Expand Up @@ -868,20 +866,10 @@ export class SpokePoolClient extends BaseAbstractClient {
// Exact sequencing of relayer refund executions doesn't seem to be important. There are very few consumers of
// these objects, and they are typically used to search for a specific rootBundleId & leafId pair. Therefore,
// relayerRefundExecutions don't need exact sequencing and parsing of v2/v3 events can occur without sorting.
if (eventsToQuery.includes("ExecutedRelayerRefundRoot") || eventsToQuery.includes("ExecutedV3RelayerRefundRoot")) {
const v2RefundEvents = queryResults[eventsToQuery.indexOf("ExecutedRelayerRefundRoot")] ?? [];
for (const event of v2RefundEvents) {
const executedRefund = spreadEventWithBlockNumber(event) as V2RelayerRefundExecutionWithBlock;
executedRefund.l2TokenAddress = SpokePoolClient.getExecutedRefundLeafL2Token(
executedRefund.chainId,
executedRefund.l2TokenAddress
);
this.relayerRefundExecutions.push(executedRefund);
}

const v3RefundEvents = queryResults[eventsToQuery.indexOf("ExecutedV3RelayerRefundRoot")] ?? [];
for (const event of v3RefundEvents) {
const executedRefund = spreadEventWithBlockNumber(event) as V3RelayerRefundExecutionWithBlock;
if (eventsToQuery.includes("ExecutedRelayerRefundRoot")) {
const refundEvents = queryResults[eventsToQuery.indexOf("ExecutedRelayerRefundRoot")];
for (const event of refundEvents) {
const executedRefund = spreadEventWithBlockNumber(event) as RelayerRefundExecutionWithBlock;
executedRefund.l2TokenAddress = SpokePoolClient.getExecutedRefundLeafL2Token(
executedRefund.chainId,
executedRefund.l2TokenAddress
Expand Down
46 changes: 8 additions & 38 deletions src/clients/mocks/MockSpokePoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import {
FillType,
FundsDepositedEvent,
RealizedLpFee,
RelayerRefundExecutionWithBlock,
SlowFillRequestWithBlock,
V2DepositWithBlock,
V2FillWithBlock,
V2RelayerRefundExecutionWithBlock,
V2SpeedUp,
V3DepositWithBlock,
V3Fill,
V3FillWithBlock,
V3RelayerRefundExecutionWithBlock,
V3SlowFillLeaf,
V3SpeedUp,
} from "../../interfaces";
Expand Down Expand Up @@ -323,11 +322,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,
},
};

Expand Down Expand Up @@ -392,7 +391,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,
Expand All @@ -403,7 +402,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
return this.fillV3Relay(fill as V3FillWithBlock);
}

executeRelayerRefundLeaf(refund: V2RelayerRefundExecutionWithBlock): Event {
executeRelayerRefundLeaf(refund: RelayerRefundExecutionWithBlock): Event {
const event = "ExecutedRelayerRefundRoot";

const chainId = refund.chainId ?? this.chainId;
Expand All @@ -430,35 +429,6 @@ export class MockSpokePoolClient extends SpokePoolClient {
});
}

executeV3RelayerRefundLeaf(refund: V3RelayerRefundExecutionWithBlock): Event {
const event = "ExecutedV3RelayerRefundRoot";

const chainId = refund.chainId ?? this.chainId;
assert(chainId === this.chainId);

const { rootBundleId, leafId } = refund;
const topics = [chainId, rootBundleId, leafId];
const args = {
chainId,
rootBundleId,
leafId,
amountToReturn: refund.amountToReturn,
l2TokenAddress: refund.l2TokenAddress,
refundAddresses: refund.refundAddresses,
refundAmounts: refund.refundAmounts,
fillsRefundedRoot: refund.fillsRefundedRoot,
fillsRefundedHash: refund.fillsRefundedHash,
};

return this.eventManager.generateEvent({
event,
address: this.spokePool.address,
topics: topics.map((topic) => topic.toString()),
args,
blockNumber: refund.blockNumber,
});
}

setEnableRoute(
originToken: string,
destinationChainId: number,
Expand Down
26 changes: 24 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as acxConstants from "@across-protocol/constants-v2";
import { constants as ethersConstants, BigNumber, utils } from "ethers";
export { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants-v2";

Expand Down Expand Up @@ -27,8 +28,29 @@ export const TRANSFER_THRESHOLD_MAX_CONFIG_STORE_VERSION = 1;
export const PROTOCOL_DEFAULT_CHAIN_ID_INDICES = [1, 10, 137, 288, 42161];

// See src/utils/NetworkUtils for helpers.
export const PRODUCTION_CHAIN_IDS = [1, 10, 137, 324, 8453, 42161];
export const TESTNET_CHAIN_IDS = [5, 280, 420, 80001, 84531, 421613];
export const PRODUCTION_CHAIN_IDS = [
acxConstants.MAINNET_CHAIN_IDs.MAINNET,
acxConstants.MAINNET_CHAIN_IDs.OPTIMISM,
acxConstants.MAINNET_CHAIN_IDs.POLYGON,
acxConstants.MAINNET_CHAIN_IDs.ZK_SYNC,
acxConstants.MAINNET_CHAIN_IDs.BASE,
acxConstants.MAINNET_CHAIN_IDs.ARBITRUM,
];

export const TESTNET_CHAIN_IDS = [
acxConstants.TESTNET_CHAIN_IDs.GOERLI,
acxConstants.TESTNET_CHAIN_IDs.ZK_SYNC_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.ZK_SYNC_SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.OPTIMISM_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.MUMBAI,
acxConstants.TESTNET_CHAIN_IDs.POLYGON_AMOY,
acxConstants.TESTNET_CHAIN_IDs.BASE_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.BASE_SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.ARBITRUM_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.ARBITRUM_SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.OPTIMISM_SEPOLIA,
];

export const PUBLIC_NETWORKS: { [chainId: number]: { name: string; etherscan: string } } = {
1: {
Expand Down
10 changes: 1 addition & 9 deletions src/interfaces/HubPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface PoolRebalanceLeaf {
l1Tokens: string[];
}

export interface RelayerRefundLeafCommon {
export interface RelayerRefundLeaf {
amountToReturn: BigNumber;
chainId: number;
refundAmounts: BigNumber[];
Expand All @@ -20,14 +20,6 @@ export interface RelayerRefundLeafCommon {
refundAddresses: string[];
}

export interface V2RelayerRefundLeaf extends RelayerRefundLeafCommon {}
export interface V3RelayerRefundLeaf extends RelayerRefundLeafCommon {
fillsRefundedRoot: string;
fillsRefundedHash: string;
}

export type RelayerRefundLeaf = V2RelayerRefundLeaf;

export interface ProposedRootBundle extends SortableEvent {
challengePeriodEndTimestamp: number;
poolRebalanceLeafCount: number;
Expand Down
16 changes: 4 additions & 12 deletions src/interfaces/SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BigNumber } from "ethers";
import { SortableEvent } from "./Common";
import { FilledRelayEvent, FilledV3RelayEvent, FundsDepositedEvent, V3FundsDepositedEvent } from "../typechain";
import { SpokePoolClient } from "../clients";
import { V2RelayerRefundLeaf, V3RelayerRefundLeaf } from "./HubPool";
import { RelayerRefundLeaf } from "./HubPool";

export type { FilledRelayEvent, FilledV3RelayEvent, FundsDepositedEvent, V3FundsDepositedEvent };

Expand Down Expand Up @@ -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 {}
Expand Down Expand Up @@ -159,19 +159,11 @@ export interface RootBundleRelay {

export interface RootBundleRelayWithBlock extends RootBundleRelay, SortableEvent {}

export interface V2RelayerRefundExecution extends V2RelayerRefundLeaf {
export interface RelayerRefundExecution extends RelayerRefundLeaf {
rootBundleId: number;
}

export interface V3RelayerRefundExecution extends V3RelayerRefundLeaf {
rootBundleId: number;
}

export interface V2RelayerRefundExecutionWithBlock extends V2RelayerRefundExecution, SortableEvent {}
export interface V3RelayerRefundExecutionWithBlock extends V3RelayerRefundExecution, SortableEvent {}

export type RelayerRefundExecution = V2RelayerRefundExecution | V3RelayerRefundExecution;
export type RelayerRefundExecutionWithBlock = V2RelayerRefundExecutionWithBlock | V3RelayerRefundExecutionWithBlock;
export interface RelayerRefundExecutionWithBlock extends RelayerRefundExecution, SortableEvent {}

export interface UnfilledDeposit {
deposit: Deposit;
Expand Down
27 changes: 0 additions & 27 deletions src/interfaces/UBA.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
17 changes: 17 additions & 0 deletions src/relayFeeCalculator/chain-queries/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class ArbitrumQueries extends QueryBase {
}
}

/**
* @deprecated Use ArbitrumSepoliaQueries instead
*/
export class ArbitrumGoerliQueries extends QueryBase {
constructor(
provider: providers.Provider,
Expand All @@ -36,3 +39,17 @@ export class ArbitrumGoerliQueries extends QueryBase {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}

export class ArbitrumSepoliaQueries extends QueryBase {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.ARBITRUM_SEPOLIA),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}
18 changes: 18 additions & 0 deletions src/relayFeeCalculator/chain-queries/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class EthereumQueries extends QueryBase {

/**
* Query class for Ethereum Görli.
* @deprecated Use EthereumSepoliaQueries instead.
*/
export class EthereumGoerliQueries extends QueryBase {
constructor(
Expand All @@ -39,3 +40,20 @@ export class EthereumGoerliQueries extends QueryBase {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}

/**
* Query class for Ethereum Sepolia.
*/
export class EthereumSepoliaQueries extends QueryBase {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.SEPOLIA),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}
26 changes: 26 additions & 0 deletions src/relayFeeCalculator/chain-queries/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class OptimismQueries extends QueryBase {
}
}

/**
* Queries for the Optimism Goerli chain
* @deprecated Use OptimismSepoliaQueries instead
*/
export class OptimismGoerliQueries extends QueryBase {
constructor(
provider: providers.Provider,
Expand All @@ -53,3 +57,25 @@ export class OptimismGoerliQueries extends QueryBase {
);
}
}

export class OptimismSepoliaQueries extends QueryBase {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.OPTIMISM_SEPOLIA),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(
asL2Provider(provider),
symbolMapping,
spokePoolAddress,
simulatedRelayerAddress,
gasMarkup,
logger,
coingeckoProApiKey
);
}
}
Loading

0 comments on commit db5f27f

Please sign in to comment.