Skip to content

Commit

Permalink
Merge pull request #216 from helix-bridge/master
Browse files Browse the repository at this point in the history
Add helixbridge
  • Loading branch information
vrtnd authored Jun 22, 2024
2 parents b1f5550 + 9274198 commit da34551
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/adapters/helixbridge/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type";
import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions";
import { Chain } from "@defillama/sdk/build/general";

const depositParams = (contractAddress: string): PartialContractEventParams => {
return {
target: contractAddress,
topic: "TokenLocked((uint256,address,address,address,uint112,uint112,address,uint256),bytes32,uint112,uint112)",
abi: [
"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)",
],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
argKeys: {
token: "params.sourceToken",
amount: "targetAmount",
to: "params.receiver",
},
txKeys: {
from: "from",
},
isDeposit: true,
};
}

const withdrawalParams = (contractAddress: string): PartialContractEventParams => {
return {
target: contractAddress,
topic: "TransferFilled(bytes32,address)",
abi: [
"event TransferFilled(bytes32 transferId, address provider)",
],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
txKeys: {
to: "to",
},
inputDataExtraction: {
inputDataABI: [
"function relay((uint256 remoteChainId, address provider, address sourceToken, address targetToken, uint112 sourceAmount, uint112 targetAmount, address receiver, uint256 timestamp) params, bytes32 expectedTransferId, bool relayBySelf)",
],
inputDataFnName: "relay",
inputDataKeys: {
token: "params.targetToken",
amount: "params.targetAmount",
},
},
fixedEventData: {
from: contractAddress,
},
isDeposit: false,
};
}

const constructParams = (chain: Chain) => {
const contractAddress = "0xbA5D580B18b6436411562981e02c8A9aA1776D10"

const eventParams: PartialContractEventParams[] = [
depositParams(contractAddress),
withdrawalParams(contractAddress)
];

return async (fromBlock: number, toBlock: number) =>
getTxDataFromEVMEventLogs("helixbridge", chain as Chain, fromBlock, toBlock, eventParams);
}

const adapter: BridgeAdapter = {
arbitrum: constructParams("arbitrum"),
darwinia: constructParams("darwinia"),
polygon: constructParams("polygon"),
bsc: constructParams("bsc"),
linea: constructParams("linea"),
mantle: constructParams("mantle"),
scroll: constructParams("scroll"),
optimism: constructParams("optimism"),
gnosis: constructParams("gnosis"),
};

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 @@ -59,6 +59,7 @@ import connext from "./connext";
import xswap from "./xswap";
import owlto from "./owlto";
import zkbridge from "./zkbridge";
import helixbridge from "./helixbridge"

export default {
polygon,
Expand Down Expand Up @@ -121,6 +122,7 @@ export default {
owlto,
zkbridge,
zkbridge111: zkbridge,
helixbridge,
} as {
[bridge: string]: BridgeAdapter;
};
22 changes: 22 additions & 0 deletions src/data/bridgeNetworkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1258,4 +1258,26 @@ export default [
bitlayer: "btr",
},
},
{
id: 64,
displayName: "helixBridge",
bridgeDbName: "helixbridge",
iconLink: "icons:helixbridge",
largeTxThreshold: 10000,
url: "https://helixbridge.app/",
chains: [
"Arbitrum",
"Darwinia",
"Polygon",
"BSC",
"Linea",
"Mantle",
"Scroll",
"Optimism",
"Gnosis",
],
chainMapping: {
gnosis: "xdai",
},
},
] as BridgeNetwork[];

0 comments on commit da34551

Please sign in to comment.