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
189 changes: 189 additions & 0 deletions src/adapters/hyperbridge/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type";
import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions";
import { Chain } from "@defillama/sdk/build/general";

const ismpHostAddresses = {
ethereum: "0x792A6236AF69787C40cF76b69B4c8c7B28c4cA20",
arbitrum: "0xE05AFD4Eb2ce6d65c40e1048381BD0Ef8b4B299e",
base: "0x6FFe92e4d7a9D589549644544780e6725E84b248",
bsc: "0x24B5d421Ec373FcA57325dd2F0C074009Af021F7",
polygon: "0xD8d3db17C1dF65b301D45C84405CcAC1395C559a",
unichain: "0x2A17C1c3616Bbc33FCe5aF5B965F166ba76cEDAf",
} as const;

type SupportedChains = keyof typeof ismpHostAddresses;

const constructParams = (chain: SupportedChains) => {
const ismpHost = ismpHostAddresses[chain];

return async (fromBlock: number, toBlock: number) => {
const postRequestEventParams: PartialContractEventParams = {
target: ismpHost,
topic: "PostRequestEvent(string,string,address,bytes,uint256,uint256,bytes,uint256)",
abi: [
"event PostRequestEvent(string source, string dest, address indexed from, bytes to, uint256 nonce, uint256 timeoutTimestamp, bytes body, uint256 fee)",
],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

const postRequestHandledParams: PartialContractEventParams = {
target: ismpHost,
topic: "PostRequestHandled(bytes32,address)",
abi: ["event PostRequestHandled(bytes32 indexed commitment, address relayer)"],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

const postResponseEventParams: PartialContractEventParams = {
target: ismpHost,
topic: "PostResponseEvent(string,string,address,bytes,uint256,uint256,bytes,bytes,uint256,uint256)",
abi: [
"event PostResponseEvent(string source, string dest, address indexed from, bytes to, uint256 nonce, uint256 timeoutTimestamp, bytes body, bytes response, uint256 responseTimeoutTimestamp, uint256 fee)",
],
logKeys: {
blockNumber: "blockNumber",
Copy link
Member

@vrtnd vrtnd Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing from and to in all events
please check by running tests npm run test hyperbridge 1000

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If from and to denotes the transfer direction then I don't think it fits what we are doing here.

These are messaging layer events, and inside these events the transfer of tokens can happen from any dapp integrating Hyperbridge.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dapp at Chain A can dispatch a GetRequest to get some data from Chain B, and when GetResponse is received, there may or may not be events of transfer.

In simple terms, a dapp can integrate Hyperbridge, use the messaging functions to execute certain operations, and in these operations, there can be transfer events.

So if we look at these messaging layer events, we will find the transfer events.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there is from and to in event abi event PostResponseEvent(string source, string dest, address indexed from, bytes to what do they mean?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The events in this PR are all ISMP (Hyperbridge's messaging protocol) events, and the from and to addresses in the event signatures are the contract addresses that send or receive the message.

Our methodology for tracking volume on Hyperbridge is to sum all token Transfer events from any transaction that emits any ISMP event. The core idea is that any token Transfer event found in a transaction that emits an ISMP event was triggered by the processing or dispatch of a cross-chain message on the Hyperbridge protocol.

txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

const postResponseHandledParams: PartialContractEventParams = {
target: ismpHost,
topic: "PostResponseHandled(bytes32,address)",
abi: ["event PostResponseHandled(bytes32 indexed commitment, address relayer)"],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

// ========== ISMP Host Get Request Events ==========

const getRequestEventParams: PartialContractEventParams = {
target: ismpHost,
topic: "GetRequestEvent(string,string,address,bytes[],uint256,uint256,uint256,bytes,uint256)",
abi: [
"event GetRequestEvent(string source, string dest, address indexed from, bytes[] keys, uint256 height, uint256 nonce, uint256 timeoutTimestamp, bytes context, uint256 fee)",
],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

const getRequestHandledParams: PartialContractEventParams = {
target: ismpHost,
topic: "GetRequestHandled(bytes32,address)",
abi: ["event GetRequestHandled(bytes32 indexed commitment, address relayer)"],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

// ========== ISMP Host Timeout Events ==========

const postRequestTimeoutHandledParams: PartialContractEventParams = {
target: ismpHost,
topic: "PostRequestTimeoutHandled(bytes32,string)",
abi: ["event PostRequestTimeoutHandled(bytes32 indexed commitment, string dest)"],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

const postResponseTimeoutHandledParams: PartialContractEventParams = {
target: ismpHost,
topic: "PostResponseTimeoutHandled(bytes32,string)",
abi: ["event PostResponseTimeoutHandled(bytes32 indexed commitment, string dest)"],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

const getRequestTimeoutHandledParams: PartialContractEventParams = {
target: ismpHost,
topic: "GetRequestTimeoutHandled(bytes32,string)",
abi: ["event GetRequestTimeoutHandled(bytes32 indexed commitment, string dest)"],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
getTokenFromReceipt: {
token: true,
amount: true,
},
};

const ismpEventParams = [
postRequestEventParams,
postRequestHandledParams,
postResponseEventParams,
postResponseHandledParams,
getRequestEventParams,
getRequestHandledParams,
postRequestTimeoutHandledParams,
postResponseTimeoutHandledParams,
getRequestTimeoutHandledParams,
];

const ismpEvents = await getTxDataFromEVMEventLogs(
"hyperbridge",
chain as Chain,
fromBlock,
toBlock,
ismpEventParams
);

return ismpEvents;
};
};

const adapter: BridgeAdapter = {
ethereum: constructParams("ethereum"),
arbitrum: constructParams("arbitrum"),
base: constructParams("base"),
bsc: constructParams("bsc"),
polygon: constructParams("polygon"),
unichain: constructParams("unichain"),
};

export default adapter;
2 changes: 2 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import teleswap from "./teleswap";
import agglayer from "./agglayer";
import fxrp from "./flare/fxrp";
import snowbridge from "./snowbridge";
import hyperbridge from "./hyperbridge";

export default {
polygon,
Expand Down Expand Up @@ -197,6 +198,7 @@ export default {
agglayer,
fxrp,
snowbridge,
hyperbridge,
} as {
[bridge: string]: BridgeAdapter | AsyncBridgeAdapter;
};
9 changes: 9 additions & 0 deletions src/data/bridgeNetworkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2594,4 +2594,13 @@ export default [
chains: ["Polkadot", "Ethereum"],
destinationChain: "Ethereum",
},
{
id: 102,
displayName: "Hyperbridge",
bridgeDbName: "hyperbridge",
iconLink: "icons:hyperbridge",
largeTxThreshold: 10000,
url: "https://hyperbridge.network",
chains: ["Ethereum", "Arbitrum", "Base", "BSC", "Polygon", "Optimism", "Soneium", "Unichain"],
},
] as BridgeNetwork[];