From fc151b2a14b10f86153feccb5831e8dc2118130b Mon Sep 17 00:00:00 2001 From: fewensa <37804932+fewensa@users.noreply.github.com> Date: Tue, 24 Sep 2024 06:07:16 +0000 Subject: [PATCH 1/4] Update helixbridge (#1) * format and update link * Update parse * add more chains * update chains * end coma --------- Co-authored-by: xiaoch05 --- src/adapters/helixbridge/index.ts | 64 ++++++++++++++++++++++--------- src/data/bridgeNetworkData.ts | 18 ++++++++- 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/adapters/helixbridge/index.ts b/src/adapters/helixbridge/index.ts index 31c345c7..8990f091 100644 --- a/src/adapters/helixbridge/index.ts +++ b/src/adapters/helixbridge/index.ts @@ -2,7 +2,7 @@ import type { BridgeAdapter, PartialContractEventParams } from "../../helpers/br import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; import type { Chain } from "@defillama/sdk/build/general"; -const depositParams = (contractAddress: string): PartialContractEventParams => { +const depositParams = (chain: Chain, contractAddress: string): PartialContractEventParams => { return { target: contractAddress, topic: "TokenLocked((uint256,address,address,address,uint112,uint112,address,uint256),bytes32,uint112,uint112)", @@ -15,9 +15,21 @@ const depositParams = (contractAddress: string): PartialContractEventParams => { }, argKeys: { token: "params.sourceToken", - amount: "targetAmount", + amount: "params.amount", to: "params.receiver", }, + argGetters: { + token: (args: any) => { + if (chain !== 'darwinia') return undefined; + + const sourceToken = args.params?.sourceToken; + if (sourceToken != '0x0000000000000000000000000000000000000000') { + return undefined; + } + + return '0xe7578598aac020abfb918f33a20fad5b71d670b4'; + }, + }, txKeys: { from: "from", }, @@ -25,43 +37,53 @@ const depositParams = (contractAddress: string): PartialContractEventParams => { }; } -const withdrawalParams = (contractAddress: string): PartialContractEventParams => { +const withdrawalParams = (chain: Chain, contractAddress: string): PartialContractEventParams => { return { target: contractAddress, - topic: "TransferFilled(bytes32,address)", + topic: "TransferFilledExt(bytes32,(uint256,address,address,address,uint112,uint112,address,uint256))", abi: [ - "event TransferFilled(bytes32 transferId, address provider)", + "event TransferFilledExt(bytes32 transferId, (uint256 remoteChainId,address provider,address sourceToken, address targetToken, uint112 sourceAmount, uint112 targetAmount, address receiver, uint256 timestamp) params)", ], logKeys: { blockNumber: "blockNumber", txHash: "transactionHash", }, txKeys: { + from: "from", 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", - }, + argKeys: { + token: "params.targetToken", + amount: "params.targetAmount", + to: "params.receiver", }, - fixedEventData: { - from: contractAddress, + argGetters: { + token: (args: any) => { + console.log(chain); + if (chain !== 'darwinia') return undefined; + + const targetToken = args.params?.targetToken; + if (targetToken != '0x0000000000000000000000000000000000000000') { + return undefined; + } + + return '0xe7578598aac020abfb918f33a20fad5b71d670b4'; + }, }, isDeposit: false, }; } const constructParams = (chain: Chain) => { - const contractAddress = "0xbA5D580B18b6436411562981e02c8A9aA1776D10" + let contractAddress = '0xbA5D580B18b6436411562981e02c8A9aA1776D10'; + + if (chain === 'blast') { + contractAddress = '0xB180D7DcB5CC161C862aD60442FA37527546cAFC'; + } const eventParams: PartialContractEventParams[] = [ - depositParams(contractAddress), - withdrawalParams(contractAddress) + depositParams(chain, contractAddress), + withdrawalParams(chain, contractAddress), ]; return async (fromBlock: number, toBlock: number) => @@ -78,6 +100,10 @@ const adapter: BridgeAdapter = { scroll: constructParams("scroll"), optimism: constructParams("optimism"), gnosis: constructParams("xdai"), + blast: constructParams("blast"), + moonbeam: constructParams("moonbeam"), + base: constructParams("base"), + avalanche: constructParams("avalanche"), }; export default adapter; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index dd2e31ef..44c0c1a1 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1276,8 +1276,22 @@ export default [ bridgeDbName: "helixbridge", iconLink: "icons:helixbridge", largeTxThreshold: 10000, - url: "https://helixbridge.app/", - chains: ["Arbitrum", "Darwinia", "Polygon", "BSC", "Linea", "Mantle", "Scroll", "Optimism", "Gnosis"], + url: "https://bridge.helix.box", + chains: [ + "Arbitrum", + "Darwinia", + "Polygon", + "BSC", + "Linea", + "Mantle", + "Scroll", + "Optimism", + "Gnosis", + "Blast", + "Moonbeam", + "Base", + "Avalanche", + ], chainMapping: { gnosis: "xdai", }, From c4aac95cc32239c13af423f959750caca42f2999 Mon Sep 17 00:00:00 2001 From: xiaoch05 Date: Tue, 24 Sep 2024 23:22:30 +0800 Subject: [PATCH 2/4] revert update link --- src/data/bridgeNetworkData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 44c0c1a1..192e035a 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1276,7 +1276,7 @@ export default [ bridgeDbName: "helixbridge", iconLink: "icons:helixbridge", largeTxThreshold: 10000, - url: "https://bridge.helix.box", + url: "https://helixbridge.app", chains: [ "Arbitrum", "Darwinia", From df4b381922b5d77db04aea27a2d9771ee1672f05 Mon Sep 17 00:00:00 2001 From: fewensa <37804932+fewensa@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:35:36 +0000 Subject: [PATCH 3/4] Remove argGetter; https://github.com/DefiLlama/defillama-app/issues/1752#issuecomment-2370850845 --- src/adapters/helixbridge/index.ts | 33 ++++--------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/adapters/helixbridge/index.ts b/src/adapters/helixbridge/index.ts index 8990f091..697488ef 100644 --- a/src/adapters/helixbridge/index.ts +++ b/src/adapters/helixbridge/index.ts @@ -2,7 +2,7 @@ import type { BridgeAdapter, PartialContractEventParams } from "../../helpers/br import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; import type { Chain } from "@defillama/sdk/build/general"; -const depositParams = (chain: Chain, contractAddress: string): PartialContractEventParams => { +const depositParams = (contractAddress: string): PartialContractEventParams => { return { target: contractAddress, topic: "TokenLocked((uint256,address,address,address,uint112,uint112,address,uint256),bytes32,uint112,uint112)", @@ -18,18 +18,6 @@ const depositParams = (chain: Chain, contractAddress: string): PartialContractEv amount: "params.amount", to: "params.receiver", }, - argGetters: { - token: (args: any) => { - if (chain !== 'darwinia') return undefined; - - const sourceToken = args.params?.sourceToken; - if (sourceToken != '0x0000000000000000000000000000000000000000') { - return undefined; - } - - return '0xe7578598aac020abfb918f33a20fad5b71d670b4'; - }, - }, txKeys: { from: "from", }, @@ -37,7 +25,7 @@ const depositParams = (chain: Chain, contractAddress: string): PartialContractEv }; } -const withdrawalParams = (chain: Chain, contractAddress: string): PartialContractEventParams => { +const withdrawalParams = (contractAddress: string): PartialContractEventParams => { return { target: contractAddress, topic: "TransferFilledExt(bytes32,(uint256,address,address,address,uint112,uint112,address,uint256))", @@ -57,19 +45,6 @@ const withdrawalParams = (chain: Chain, contractAddress: string): PartialContrac amount: "params.targetAmount", to: "params.receiver", }, - argGetters: { - token: (args: any) => { - console.log(chain); - if (chain !== 'darwinia') return undefined; - - const targetToken = args.params?.targetToken; - if (targetToken != '0x0000000000000000000000000000000000000000') { - return undefined; - } - - return '0xe7578598aac020abfb918f33a20fad5b71d670b4'; - }, - }, isDeposit: false, }; } @@ -82,8 +57,8 @@ const constructParams = (chain: Chain) => { } const eventParams: PartialContractEventParams[] = [ - depositParams(chain, contractAddress), - withdrawalParams(chain, contractAddress), + depositParams(contractAddress), + withdrawalParams(contractAddress), ]; return async (fromBlock: number, toBlock: number) => From 3c8d51ffe6ca1c4f24b1412086cd0a101e56c7e4 Mon Sep 17 00:00:00 2001 From: vrtnd Date: Thu, 3 Oct 2024 22:23:47 +0300 Subject: [PATCH 4/4] Fix helixbridge --- src/adapters/helixbridge/index.ts | 2 +- src/data/bridgeNetworkData.ts | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/adapters/helixbridge/index.ts b/src/adapters/helixbridge/index.ts index 697488ef..c3655115 100644 --- a/src/adapters/helixbridge/index.ts +++ b/src/adapters/helixbridge/index.ts @@ -78,7 +78,7 @@ const adapter: BridgeAdapter = { blast: constructParams("blast"), moonbeam: constructParams("moonbeam"), base: constructParams("base"), - avalanche: constructParams("avalanche"), + avalanche: constructParams("avax"), }; export default adapter; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 192e035a..73501203 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1294,6 +1294,7 @@ export default [ ], chainMapping: { gnosis: "xdai", + avalanche: "avax", }, }, { @@ -1491,12 +1492,6 @@ export default [ iconLink: "icons:crowdswap", largeTxThreshold: 10000, url: "https://scanner.crowdswap.org/", - chains: [ - "Ethereum", - "Arbitrum", - "Optimism", - "BSC", - "Polygon" - ] + chains: ["Ethereum", "Arbitrum", "Optimism", "BSC", "Polygon"], }, ] as BridgeNetwork[];