Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions api/_exclusivity/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ethers } from "ethers";
import * as sdk from "@across-protocol/sdk";
import { getCachedTokenBalances, getCachedLatestBlock } from "../_utils";

Check warning on line 3 in api/_exclusivity/index.ts

View workflow job for this annotation

GitHub Actions / format-and-lint

'getCachedLatestBlock' is defined but never used
import { getExclusivityPeriod, getRelayerConfig, getStrategy } from "./config";
import { ExclusiveRelayer } from "./types";

type BigNumber = ethers.BigNumber;
const { parseUnits } = ethers.utils;
const { ZERO_ADDRESS, CHAIN_IDs } = sdk.constants;

Check warning on line 9 in api/_exclusivity/index.ts

View workflow job for this annotation

GitHub Actions / format-and-lint

'CHAIN_IDs' is assigned a value but never used
const { fixedPointAdjustment: fixedPoint } = sdk.utils;
const REORG_CHAINS = [CHAIN_IDs.MAINNET, CHAIN_IDs.POLYGON, CHAIN_IDs.SCROLL];
// const REORG_CHAINS = [CHAIN_IDs.MAINNET, CHAIN_IDs.POLYGON, CHAIN_IDs.SCROLL];

/**
* Select a specific relayer exclusivity strategy to apply.
Expand Down Expand Up @@ -58,11 +58,10 @@
);

if (relayers.length > 0) {
// Only get the latest block if we are doing an exclusive relay and on a chain which re-orgs.
if (REORG_CHAINS.includes(originChainId)) {
const currentBlock = await getCachedLatestBlock(originChainId);
exclusivityPeriodSec += currentBlock.timestamp;
}
// if (REORG_CHAINS.includes(originChainId)) {
// const currentBlock = await getCachedLatestBlock(originChainId);
// exclusivityPeriodSec += currentBlock.timestamp;
// }

exclusiveRelayer = selectorFn(relayers);
exclusivityPeriod =
Expand Down
9 changes: 9 additions & 0 deletions src/views/Bridge/hooks/useBridgeAction/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ export function createBridgeActionHook(strategy: BridgeActionStrategy) {
ampli.depositNetworkMismatch(networkMismatchProperties);
});
};

// Before sending, fetch a new timestamp if it's on Mainnet or Polygon and use that for
// the exclusivity
const REORG_CHAIN_IDS = [1, 137, 534352];
if (REORG_CHAIN_IDS.includes(frozenDepositArgs.fromChain)) {
const currTimestampInSeconds = Math.floor(Date.now() / 1000);
frozenDepositArgs.exclusivityDeadline =
currTimestampInSeconds + frozenDepositArgs.exclusivityDeadline;
}
const txHash = await strategy.sendDepositTx({
depositArgs: frozenDepositArgs,
transferQuote: frozenTransferQuote,
Expand Down