Skip to content

Commit da34551

Browse files
authored
Merge pull request #216 from helix-bridge/master
Add helixbridge
2 parents b1f5550 + 9274198 commit da34551

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

src/adapters/helixbridge/index.ts

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type";
2+
import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions";
3+
import { Chain } from "@defillama/sdk/build/general";
4+
5+
const depositParams = (contractAddress: string): PartialContractEventParams => {
6+
return {
7+
target: contractAddress,
8+
topic: "TokenLocked((uint256,address,address,address,uint112,uint112,address,uint256),bytes32,uint112,uint112)",
9+
abi: [
10+
"event TokenLocked((uint256 remoteChainId, address provider, address sourceToken, address targetToken, uint112 totalFee, uint112 amount, address receiver, uint256 timestamp) params, bytes32 transferId, uint112 targetAmount, uint112 fee)",
11+
],
12+
logKeys: {
13+
blockNumber: "blockNumber",
14+
txHash: "transactionHash",
15+
},
16+
argKeys: {
17+
token: "params.sourceToken",
18+
amount: "targetAmount",
19+
to: "params.receiver",
20+
},
21+
txKeys: {
22+
from: "from",
23+
},
24+
isDeposit: true,
25+
};
26+
}
27+
28+
const withdrawalParams = (contractAddress: string): PartialContractEventParams => {
29+
return {
30+
target: contractAddress,
31+
topic: "TransferFilled(bytes32,address)",
32+
abi: [
33+
"event TransferFilled(bytes32 transferId, address provider)",
34+
],
35+
logKeys: {
36+
blockNumber: "blockNumber",
37+
txHash: "transactionHash",
38+
},
39+
txKeys: {
40+
to: "to",
41+
},
42+
inputDataExtraction: {
43+
inputDataABI: [
44+
"function relay((uint256 remoteChainId, address provider, address sourceToken, address targetToken, uint112 sourceAmount, uint112 targetAmount, address receiver, uint256 timestamp) params, bytes32 expectedTransferId, bool relayBySelf)",
45+
],
46+
inputDataFnName: "relay",
47+
inputDataKeys: {
48+
token: "params.targetToken",
49+
amount: "params.targetAmount",
50+
},
51+
},
52+
fixedEventData: {
53+
from: contractAddress,
54+
},
55+
isDeposit: false,
56+
};
57+
}
58+
59+
const constructParams = (chain: Chain) => {
60+
const contractAddress = "0xbA5D580B18b6436411562981e02c8A9aA1776D10"
61+
62+
const eventParams: PartialContractEventParams[] = [
63+
depositParams(contractAddress),
64+
withdrawalParams(contractAddress)
65+
];
66+
67+
return async (fromBlock: number, toBlock: number) =>
68+
getTxDataFromEVMEventLogs("helixbridge", chain as Chain, fromBlock, toBlock, eventParams);
69+
}
70+
71+
const adapter: BridgeAdapter = {
72+
arbitrum: constructParams("arbitrum"),
73+
darwinia: constructParams("darwinia"),
74+
polygon: constructParams("polygon"),
75+
bsc: constructParams("bsc"),
76+
linea: constructParams("linea"),
77+
mantle: constructParams("mantle"),
78+
scroll: constructParams("scroll"),
79+
optimism: constructParams("optimism"),
80+
gnosis: constructParams("gnosis"),
81+
};
82+
83+
export default adapter;

src/adapters/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import connext from "./connext";
5959
import xswap from "./xswap";
6060
import owlto from "./owlto";
6161
import zkbridge from "./zkbridge";
62+
import helixbridge from "./helixbridge"
6263

6364
export default {
6465
polygon,
@@ -121,6 +122,7 @@ export default {
121122
owlto,
122123
zkbridge,
123124
zkbridge111: zkbridge,
125+
helixbridge,
124126
} as {
125127
[bridge: string]: BridgeAdapter;
126128
};

src/data/bridgeNetworkData.ts

+22
Original file line numberDiff line numberDiff line change
@@ -1258,4 +1258,26 @@ export default [
12581258
bitlayer: "btr",
12591259
},
12601260
},
1261+
{
1262+
id: 64,
1263+
displayName: "helixBridge",
1264+
bridgeDbName: "helixbridge",
1265+
iconLink: "icons:helixbridge",
1266+
largeTxThreshold: 10000,
1267+
url: "https://helixbridge.app/",
1268+
chains: [
1269+
"Arbitrum",
1270+
"Darwinia",
1271+
"Polygon",
1272+
"BSC",
1273+
"Linea",
1274+
"Mantle",
1275+
"Scroll",
1276+
"Optimism",
1277+
"Gnosis",
1278+
],
1279+
chainMapping: {
1280+
gnosis: "xdai",
1281+
},
1282+
},
12611283
] as BridgeNetwork[];

0 commit comments

Comments
 (0)