From 4c2f533188379d758709ba8ec6dc9e434f95213f Mon Sep 17 00:00:00 2001 From: Aki Wu Date: Thu, 6 Jun 2024 21:49:02 +0800 Subject: [PATCH 1/2] add helixbridge --- src/adapters/helixbridge/index.ts | 83 +++++++++++++++++++++++++++++++ src/data/bridgeNetworkData.ts | 22 ++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/adapters/helixbridge/index.ts diff --git a/src/adapters/helixbridge/index.ts b/src/adapters/helixbridge/index.ts new file mode 100644 index 00000000..b8dc7f25 --- /dev/null +++ b/src/adapters/helixbridge/index.ts @@ -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; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 697beee5..55090929 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1223,4 +1223,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[]; From 927419869d4c3314b2ff850bc289beced93992bc Mon Sep 17 00:00:00 2001 From: Aki Wu Date: Fri, 7 Jun 2024 16:10:18 +0800 Subject: [PATCH 2/2] add helixbridge to adapters index --- src/adapters/index.ts | 2 ++ src/data/bridgeNetworkData.ts | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/adapters/index.ts b/src/adapters/index.ts index 2c1cf373..12ce8a66 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -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, @@ -121,6 +122,7 @@ export default { owlto, zkbridge, zkbridge111: zkbridge, + helixbridge, } as { [bridge: string]: BridgeAdapter; }; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 55090929..3ed49436 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1231,15 +1231,15 @@ export default [ largeTxThreshold: 10000, url: "https://helixbridge.app/", chains: [ - "arbitrum", - "darwinia", - "polygon", - "bsc", - "linea", - "mantle", - "scroll", - "optimism", - "gnosis", + "Arbitrum", + "Darwinia", + "Polygon", + "BSC", + "Linea", + "Mantle", + "Scroll", + "Optimism", + "Gnosis", ], chainMapping: { gnosis: "xdai",