From e999e0445bfe246b06f2dd932f1e3fc7dd08a820 Mon Sep 17 00:00:00 2001 From: vrtnd Date: Wed, 8 Jan 2025 09:35:39 +0300 Subject: [PATCH] Revert "Merge pull request #318 from pedromcunha/master" This reverts commit 85ab5ab12d38a8465c6caf89020377b3f5731b6f, reversing changes made to 7347cd2a3da921bd38ab9bbcef79891a5336ac0e. --- src/adapters/index.ts | 2 - src/adapters/relay/index.ts | 218 ---------------------------------- src/adapters/relay/type.ts | 213 --------------------------------- src/data/bridgeNetworkData.ts | 52 -------- src/utils/adapter.ts | 2 +- 5 files changed, 1 insertion(+), 486 deletions(-) delete mode 100644 src/adapters/relay/index.ts delete mode 100644 src/adapters/relay/type.ts diff --git a/src/adapters/index.ts b/src/adapters/index.ts index cd8d7cb7..745ad108 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -75,7 +75,6 @@ import hyperlane from "./hyperlane"; import wormhole from "./wormhole"; import thresholdnetwork from "./threshold-network"; import zircuit from "./zircuit"; -import relay from "./relay"; import hyperliquid from "./hyperliquid"; import flyover from "./rootstock-flyover"; @@ -156,7 +155,6 @@ export default { wormhole, thresholdnetwork, zircuit, - relay, hyperliquid, flyover } as { diff --git a/src/adapters/relay/index.ts b/src/adapters/relay/index.ts deleted file mode 100644 index 1f63ca75..00000000 --- a/src/adapters/relay/index.ts +++ /dev/null @@ -1,218 +0,0 @@ -import { BridgeAdapter } from "../../helpers/bridgeAdapter.type"; -import fetch from "node-fetch"; -import { EventData } from "../../utils/types"; -import { RelayRequestsResponse } from "./type"; -const retry = require("async-retry"); - -/** - * Relay is a cross-chain payments system that enables low cost instant bridging and cross-chain execution. - * Contract addresses: https://docs.relay.link/resources/contract-addresses - * - * - */ - -const startingBlocks: Record = { - 1: 18976112, - 10: 114647896, - 56: 39739873, - 100: 33619680, - 137: 55172593, - 185: 3417903, - 288: 2353048, - 324: 25006838, - 360: 2691201, - 480: 3466510, - 690: 254553, - 1101: 12491343, - 1135: 761002, - 1329: 118912096, - 2741: 4116, - 2911: 2136055, - 4321: 138647, - 5000: 72911632, - 5112: 1462668, - 7560: 896262, - 8333: 144055, - 8453: 9046270, - 17071: 58343, - 33139: 636958, - 33979: 238923, - 34443: 7297896, - 42161: 169028419, - 42170: 38963884, - 43114: 44583244, - 55244: 30, - 57073: 275058, - 59144: 1814719, - 60808: 275964, - 70700: 19, - 70701: 1543, - 81457: 216675, - 534352: 5560094, - 543210: 1282, - 660279: 4759873, - 984122: 2655107, - 7777777: 9094029, - 8253038: 865885, - 666666666: 1310814, - 792703809: 279758248, - 888888888: 1278785, - 1380012617: 205727, -}; - -const convertRequestToEvent = ( - request: NonNullable["0"] -): { deposit?: EventData; withdraw?: EventData; depositChainId?: number; withdrawChainId?: number } => { - const deposit = request.data?.metadata?.currencyIn; - const withdraw = request.data?.metadata?.currencyOut; - - const depositTx = request.data?.inTxs?.[0]; - const withdrawTx = request.data?.outTxs?.[0]; - - return { - depositChainId: depositTx?.chainId, - deposit: - depositTx && depositTx.data && deposit - ? { - blockNumber: depositTx.block!, - txHash: depositTx.hash as string, - timestamp: depositTx.timestamp! * 1000, - from: (depositTx.data as any).from - ? (depositTx.data as any).from - : depositTx.data - ? (depositTx.data as any).signer - : undefined, - to: (depositTx.data as any).to - ? (depositTx.data as any).to - : withdrawTx?.data - ? (withdrawTx.data as any).signer - : undefined, - token: deposit?.currency?.address!, - amount: deposit?.amountUsd as any, - isDeposit: true, - isUSDVolume: true, - } - : undefined, - withdrawChainId: withdrawTx?.chainId, - withdraw: - withdrawTx && withdrawTx.data && withdraw - ? { - blockNumber: withdrawTx.block!, - txHash: withdrawTx.hash!, - timestamp: withdrawTx.timestamp! * 1000, - from: (withdrawTx.data as any).from - ? (withdrawTx.data as any).from - : withdrawTx.data - ? (withdrawTx.data as any).signer - : undefined, - to: (withdrawTx.data as any).to ? (withdrawTx.data as any).to : request.data?.metadata?.recipient, - token: withdraw?.currency?.address!, - amount: withdraw?.amountUsd as any, - isDeposit: false, - isUSDVolume: true, - } - : undefined, - }; -}; - -const fetchRequests = async ( - chainId: number, - fromBlock: number, - toBlock: number, - continuation?: string -): Promise => { - let url = `https://api.relay.link/requests/v2?chainId=${chainId}&startBlock=${fromBlock}&endBlock=${toBlock}`; - - if (continuation) { - url = `${url}&continuation=${continuation}`; - } - return retry(() => fetch(url).then((res) => res.json())); -}; - -const fetchAllRequests = async ( - chainId: number, - fromBlock: number, - toBlock: number -): Promise => { - let allRequests: RelayRequestsResponse["requests"] = []; - const response = await fetchRequests(chainId, fromBlock, toBlock); - allRequests = [...(response.requests ?? [])]; - let continuation = response.continuation; - let maxRequests = 10000; - let requestCount = 0; - while (continuation !== undefined && requestCount < maxRequests) { - const response = await fetchRequests(chainId, fromBlock, toBlock, continuation); - continuation = response.continuation; - allRequests = [...allRequests, ...(response.requests ?? [])]; - } - return allRequests; -}; - -const constructParams = (chainId: number) => { - return async (fromBlock: number, toBlock: number): Promise => { - //Performance optimization to limit empty requests - const startingBlock = startingBlocks[chainId]; - if (startingBlock !== undefined && toBlock < startingBlock) { - return []; - } - const requests = await fetchAllRequests(chainId, fromBlock, toBlock); - const events: EventData[] = []; - requests?.forEach((request) => { - const event = convertRequestToEvent(request); - if (event.depositChainId === chainId && event.deposit) { - events.push(event.deposit); - } - if (event.withdrawChainId === chainId && event.withdraw) { - events.push(event.withdraw); - } - }); - return events; - }; -}; - -const adapter: BridgeAdapter = { - ethereum: constructParams(1), - optimism: constructParams(10), - bnb: constructParams(56), - gnosis: constructParams(100), - polygon: constructParams(137), - mint: constructParams(185), - boba: constructParams(288), - zksync: constructParams(324), - shape: constructParams(360), - "world-chain": constructParams(480), - redstone: constructParams(690), - "polygon-zkevm": constructParams(1101), - lisk: constructParams(1135), - sei: constructParams(1329), - hychain: constructParams(2911), - mantle: constructParams(5000), - ham: constructParams(5112), - cyber: constructParams(7560), - B3: constructParams(8333), - base: constructParams(8453), - arbitrum: constructParams(42161), - "arbitrum-nova": constructParams(42170), - avalanche: constructParams(43114), - superposition: constructParams(55244), - linea: constructParams(59144), - bob: constructParams(60808), - apex: constructParams(70700), - boss: constructParams(70701), - blast: constructParams(81457), - scroll: constructParams(534352), - "zero-network": constructParams(543210), - xai: constructParams(660279), - forma: constructParams(984122), - solana: constructParams(792703809), - ancient8: constructParams(888888888), - rari: constructParams(1380012617), - bitcoin: constructParams(8253038), - degen: constructParams(666666666), - funki: constructParams(33979), - mode: constructParams(34443), - "proof-of-play": constructParams(70700), - "proof-of-play-boss": constructParams(70701), -}; - -export default adapter; diff --git a/src/adapters/relay/type.ts b/src/adapters/relay/type.ts deleted file mode 100644 index 6337ce9a..00000000 --- a/src/adapters/relay/type.ts +++ /dev/null @@ -1,213 +0,0 @@ -export type RelayRequestsResponse = { - requests?: { - id?: string; - /** - * @description Note that fallback is returned in the case of a refund - * @enum {string} - */ - status?: "refund" | "delayed" | "waiting" | "failure" | "pending" | "success"; - user?: string; - recipient?: string; - data?: { - /** @enum {string} */ - failReason?: - | "UNKNOWN" - | "AMOUNT_TOO_LOW_TO_REFUND" - | "DEPOSIT_ADDRESS_MISMATCH" - | "DEPOSIT_CHAIN_MISMATCH" - | "N/A"; - fees?: { - /** @description Estimated gas cost required for execution, in wei */ - gas?: string; - /** @description The fixed fee which is always added to execution, in wei */ - fixed?: string; - /** @description The dynamic fee which is a result of the chain and the amount, in wei */ - price?: string; - }; - feesUsd?: { - gas?: string; - fixed?: string; - price?: string; - }; - inTxs?: { - /** @description Total fees in wei */ - fee?: string; - data?: unknown; - stateChanges?: unknown; - hash?: string; - block?: number; - /** @description The type of transaction, always set to onchain */ - type?: string; - chainId?: number; - timestamp?: number; - }[]; - currency?: string; - currencyObject?: { - chainId?: number; - address?: string; - symbol?: string; - name?: string; - decimals?: number; - metadata?: { - logoURI?: string; - verified?: boolean; - isNative?: boolean; - }; - }; - feeCurrency?: string; - feeCurrencyObject?: { - chainId?: number; - address?: string; - symbol?: string; - name?: string; - decimals?: number; - metadata?: { - logoURI?: string; - verified?: boolean; - isNative?: boolean; - }; - }; - /** - * @example { - * "currency": { - * "chainId": 8453, - * "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", - * "symbol": "USDC", - * "name": "USD Coin", - * "decimals": 6, - * "metadata": { - * "logoURI": "https://ethereum-optimism.github.io/data/USDC/logo.png", - * "verified": false, - * "isNative": false - * } - * }, - * "amount": "30754920", - * "amountFormatted": "30.75492", - * "amountUsd": "30.901612", - * "minimumAmount": "30454920" - * } - */ - refundCurrencyData?: { - currency?: { - chainId?: number; - address?: string; - symbol?: string; - name?: string; - decimals?: number; - metadata?: { - logoURI?: string; - verified?: boolean; - isNative?: boolean; - }; - }; - amount?: string; - amountFormatted?: string; - amountUsd?: string; - minimumAmount?: string; - }; - appFees?: { - recipient?: string; - amount?: string; - }[]; - metadata?: { - sender?: string; - recipient?: string; - /** - * @example { - * "currency": { - * "chainId": 8453, - * "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", - * "symbol": "USDC", - * "name": "USD Coin", - * "decimals": 6, - * "metadata": { - * "logoURI": "https://ethereum-optimism.github.io/data/USDC/logo.png", - * "verified": false, - * "isNative": false - * } - * }, - * "amount": "30754920", - * "amountFormatted": "30.75492", - * "amountUsd": "30.901612", - * "minimumAmount": "30454920" - * } - */ - currencyIn?: { - currency?: { - chainId?: number; - address?: string; - symbol?: string; - name?: string; - decimals?: number; - metadata?: { - logoURI?: string; - verified?: boolean; - isNative?: boolean; - }; - }; - amount?: string; - amountFormatted?: string; - amountUsd?: string; - minimumAmount?: string; - }; - /** - * @example { - * "currency": { - * "chainId": 8453, - * "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", - * "symbol": "USDC", - * "name": "USD Coin", - * "decimals": 6, - * "metadata": { - * "logoURI": "https://ethereum-optimism.github.io/data/USDC/logo.png", - * "verified": false, - * "isNative": false - * } - * }, - * "amount": "30754920", - * "amountFormatted": "30.75492", - * "amountUsd": "30.901612", - * "minimumAmount": "30454920" - * } - */ - currencyOut?: { - currency?: { - chainId?: number; - address?: string; - symbol?: string; - name?: string; - decimals?: number; - metadata?: { - logoURI?: string; - verified?: boolean; - isNative?: boolean; - }; - }; - amount?: string; - amountFormatted?: string; - amountUsd?: string; - minimumAmount?: string; - }; - rate?: string; - }; - price?: string; - usesExternalLiquidity?: boolean; - timeEstimate?: number; - outTxs?: { - /** @description Total fees in wei */ - fee?: string; - data?: unknown; - stateChanges?: unknown; - hash?: string; - block?: number; - /** @description The type of transaction, always set to onchain */ - type?: string; - chainId?: number; - timestamp?: number; - }[]; - }; - createdAt?: string; - updatedAt?: string; - }[]; - continuation?: string; -}; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 11060bab..ae1b747d 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1781,58 +1781,6 @@ export default [ chains: ["Ethereum", "Zircuit"], destinationChain: "Zircuit", }, - { - id: 100, - displayName: "Relay", - bridgeDbName: "relay", - iconLink: "icons:relay", - largeTxThreshold: 10000, - url: "https://docs.relay.link/", - chains: [ - "Ethereum", - "Optimism", - "BNB", - "Gnosis", - "Polygon", - "Mint", - "Boba", - "Zksync", - "Shape", - "World Chain", - "Redstone", - "Polygon Zkevm", - "Lisk", - "Sei", - "Hychain", - "Mantle", - "Ham", - "Cyber", - "B3", - "Base", - "Arbitrum", - "Arbitrum Nova", - "Avalanche", - "Superposition", - "Linea", - "Bob", - "Apex", - "Boss", - "Blast", - "Scroll", - "Zero Network", - "Xai", - "Solana", - "Ancient8", - "Rari", - "Bitcoin", - "Eclipse", - "Degen", - "Funki", - "Mode", - "Proof of Play", - "Proof of Play Boss", - ], - }, { id: 80, displayName: "Hyperliquid", diff --git a/src/utils/adapter.ts b/src/utils/adapter.ts index 6817f32e..20d96821 100644 --- a/src/utils/adapter.ts +++ b/src/utils/adapter.ts @@ -506,7 +506,7 @@ export const runAdapterHistorical = async ( let solanaTimestampsMap = {} as { [blockNumber: number]: number }; - if (chain === "solana" && !["debridgedln", "portal", "relay"].includes(bridgeDbName)) { + if (chain === "solana" && !["debridgedln", "portal"].includes(bridgeDbName)) { latestSolanaBlock = await getLatestBlock("solana"); const connection = getConnection();