From 4d0ce02fef0535c42be8f35ef3851ca1313d7de9 Mon Sep 17 00:00:00 2001 From: vrtnd Date: Mon, 16 Dec 2024 19:07:54 +0300 Subject: [PATCH] add hyperliquid --- src/adapters/hyperliquid/index.ts | 26 ++++++++++++++++++++++++++ src/adapters/index.ts | 2 ++ src/data/bridgeNetworkData.ts | 12 +++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/adapters/hyperliquid/index.ts diff --git a/src/adapters/hyperliquid/index.ts b/src/adapters/hyperliquid/index.ts new file mode 100644 index 00000000..0e4e9e2a --- /dev/null +++ b/src/adapters/hyperliquid/index.ts @@ -0,0 +1,26 @@ +import { Chain } from "@defillama/sdk/build/general"; +import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type"; +import { constructTransferParams } from "../../helpers/eventParams"; +import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; + +const HYPERLIQUID_BRIDGE_ADDRESS = "0x2Df1c51E09aECF9cacB7bc98cB1742757f163dF7"; + +const erc20WithdrawalEventParams: PartialContractEventParams = constructTransferParams( + HYPERLIQUID_BRIDGE_ADDRESS, + false +); + +const erc20DepositEventParams: PartialContractEventParams = constructTransferParams(HYPERLIQUID_BRIDGE_ADDRESS, true); + +const constructParams = (chain: string) => { + let eventParams = [] as PartialContractEventParams[]; + eventParams.push(erc20WithdrawalEventParams, erc20DepositEventParams); + return async (fromBlock: number, toBlock: number) => + getTxDataFromEVMEventLogs("hyperliquid", chain as Chain, fromBlock, toBlock, eventParams); +}; + +const adapter: BridgeAdapter = { + arbitrum: constructParams("arbitrum"), +}; + +export default adapter; diff --git a/src/adapters/index.ts b/src/adapters/index.ts index 0942b253..ac9d1ec2 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -75,6 +75,7 @@ import hyperlane from "./hyperlane"; import wormhole from "./wormhole"; import thresholdnetwork from "./threshold-network"; import zircuit from "./zircuit"; +import hyperliquid from "./hyperliquid"; export default { polygon, @@ -153,6 +154,7 @@ export default { wormhole, thresholdnetwork, zircuit, + hyperliquid, } as { [bridge: string]: BridgeAdapter | AsyncBridgeAdapter; }; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index ec37e6d7..4ab1c009 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1739,7 +1739,7 @@ export default [ iconLink: "icons:threshold-network", largeTxThreshold: 10000, url: "https://threshold.network/", - chains: ["Ethereum", "Bitcoin"], + chains: ["Ethereum", "Bitcoin"], destinationChain: "Bitcoin", }, { @@ -1752,4 +1752,14 @@ export default [ chains: ["Ethereum", "Zircuit"], destinationChain: "Zircuit", }, + { + id: 80, + displayName: "Hyperliquid", + bridgeDbName: "hyperliquid", + iconLink: "icons:hyperliquid", + largeTxThreshold: 10000, + url: "https://app.hyperliquid.xyz/trade", + chains: ["Arbitrum", "Hyperliquid"], + destinationChain: "Hyperliquid", + }, ] as BridgeNetwork[];