From 8639a9937bbcf8fa9579ea2099052a25457bd45b Mon Sep 17 00:00:00 2001 From: lolieatapple Date: Thu, 6 Apr 2023 11:19:19 +0800 Subject: [PATCH 1/9] add wan-bridge --- src/adapters/index.ts | 2 +- src/adapters/wanbridge/index.ts | 122 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/adapters/wanbridge/index.ts diff --git a/src/adapters/index.ts b/src/adapters/index.ts index ff7c5ffc..208b44f1 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -36,7 +36,7 @@ import axelarsatellite from "./axelar-satellite"; import manta from "./manta"; import squidrouter from "./squid"; import eywa from "./eywa"; -import rhinofi from './rhinofi'; +import rhinofi from "./rhinofi"; export default { polygon, diff --git a/src/adapters/wanbridge/index.ts b/src/adapters/wanbridge/index.ts new file mode 100644 index 00000000..0455a2ba --- /dev/null +++ b/src/adapters/wanbridge/index.ts @@ -0,0 +1,122 @@ +import { + BridgeAdapter, + PartialContractEventParams, +} from "../../helpers/bridgeAdapter.type"; +import {getTxDataFromEVMEventLogs} from "../../helpers/processTransactions"; +import {constructTransferParams} from "../../helpers/eventParams"; + +const contracts = { + arbitrum: { + pools: [ + '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' + ] + }, + astar: { + pools: [ + '0x592de30bebff484b5a43a6e8e3ec1a814902e0b6' + ] + }, + avax: { + pools: [ + '0x74e121a34a66d54c33f3291f2cdf26b1cd037c3a' + ] + }, + bsc: { + pools: [ + '0xc3711bdbe7e3063bf6c22e7fed42f782ac82baee' + ] + }, + clv: { + pools: [ + '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' + ] + }, + ethereum: { + pools: [ + '0xfceaaaeb8d564a9d0e71ef36f027b9d162bc334e' + ] + }, + fantom: { + pools: [ + '0xccffe9d337f3c1b16bd271d109e691246fd69ee3' + ] + }, + moonbeam: { + pools: [ + '0x6372aec6263aa93eacedc994d38aa9117b6b95b5' + ] + }, + moonriver: { + pools: [ + '0xde1ae3c465354f01189150f3836c7c15a1d6671d' + ] + }, + okexchain: { + pools: [ + '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' + ] + }, + optimism: { + pools: [ + '0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf' + ] + }, + polygon: { + pools: [ + '0x2216072a246a84f7b9ce0f1415dd239c9bf201ab' + ] + }, + telos: { + pools: [ + '0x201e5de97dfc46aace142b2009332c524c9d8d82' + ] + }, + wan: { + pools: [ + '0xe85b0d89cbc670733d6a40a9450d8788be13da47' + ] + }, + xdc: { + pools: [ + '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' + ] + } +}; + +const constructParams = (chain: keyof typeof contracts) => { + const eventParams: PartialContractEventParams[] = []; + + for (const poolAddress of contracts[chain].pools) { + eventParams.push(constructTransferParams( + poolAddress, + true + ),constructTransferParams( + poolAddress, + false + )); + + } + + return async (fromBlock: number, toBlock: number) => + getTxDataFromEVMEventLogs("allbridge", chain, fromBlock, toBlock, eventParams); + +} +const adapter: BridgeAdapter = { + arbitrum: constructParams('arbitrum'), + astar: constructParams('astar'), + avax: constructParams('avax'), + bsc: constructParams('bsc'), + clv: constructParams('clv'), + ethereum: constructParams('ethereum'), + fantom: constructParams('fantom'), + moonbeam: constructParams('moonbeam'), + moonriver: constructParams('moonriver'), + okexchain: constructParams('okexchain'), + optimism: constructParams('optimism'), + polygon: constructParams('polygon'), + telos: constructParams('telos'), + wan: constructParams('wan'), + xdc: constructParams('xdc'), +}; + +export default adapter; From 1385e40c092997232e5e5bfe105b8483ca9d0c2d Mon Sep 17 00:00:00 2001 From: lolieatapple Date: Sat, 7 Oct 2023 15:36:00 +0800 Subject: [PATCH 2/9] update for wanbridge --- src/adapters/wanbridge/index.ts | 178 ++++++++++++-------------------- 1 file changed, 68 insertions(+), 110 deletions(-) diff --git a/src/adapters/wanbridge/index.ts b/src/adapters/wanbridge/index.ts index 0455a2ba..7d96b7f0 100644 --- a/src/adapters/wanbridge/index.ts +++ b/src/adapters/wanbridge/index.ts @@ -1,122 +1,80 @@ -import { - BridgeAdapter, - PartialContractEventParams, -} from "../../helpers/bridgeAdapter.type"; -import {getTxDataFromEVMEventLogs} from "../../helpers/processTransactions"; -import {constructTransferParams} from "../../helpers/eventParams"; +import { Chain } from "@defillama/sdk/build/general"; +import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type"; +import { constructTransferParams } from "../../helpers/eventParams"; +import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; -const contracts = { - arbitrum: { - pools: [ - '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' - ] - }, - astar: { - pools: [ - '0x592de30bebff484b5a43a6e8e3ec1a814902e0b6' - ] - }, - avax: { - pools: [ - '0x74e121a34a66d54c33f3291f2cdf26b1cd037c3a' - ] - }, - bsc: { - pools: [ - '0xc3711bdbe7e3063bf6c22e7fed42f782ac82baee' - ] - }, - clv: { - pools: [ - '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' - ] - }, - ethereum: { - pools: [ - '0xfceaaaeb8d564a9d0e71ef36f027b9d162bc334e' - ] - }, - fantom: { - pools: [ - '0xccffe9d337f3c1b16bd271d109e691246fd69ee3' - ] - }, - moonbeam: { - pools: [ - '0x6372aec6263aa93eacedc994d38aa9117b6b95b5' - ] - }, - moonriver: { - pools: [ - '0xde1ae3c465354f01189150f3836c7c15a1d6671d' - ] - }, - okexchain: { - pools: [ - '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' - ] - }, - optimism: { - pools: [ - '0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf' - ] - }, - polygon: { - pools: [ - '0x2216072a246a84f7b9ce0f1415dd239c9bf201ab' - ] - }, - telos: { - pools: [ - '0x201e5de97dfc46aace142b2009332c524c9d8d82' - ] - }, - wan: { - pools: [ - '0xe85b0d89cbc670733d6a40a9450d8788be13da47' - ] - }, - xdc: { - pools: [ - '0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613' - ] - } +const gatewayAddresses = { + arbitrum: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", + wanchain: "0xe85b0d89cbc670733d6a40a9450d8788be13da47", + ethereum: "0xfceaaaeb8d564a9d0e71ef36f027b9d162bc334e", + avalanche: "0x74e121a34a66d54c33f3291f2cdf26b1cd037c3a", + moonbeam: "0x6372aec6263aa93eacedc994d38aa9117b6b95b5", + moonriver: "0xde1ae3c465354f01189150f3836c7c15a1d6671d", + functionX: "0xdf935552fac687123c642f589296762b632a9aaf", + telos: "0x201e5de97dfc46aace142b2009332c524c9d8d82", + polygon: "0x2216072a246a84f7b9ce0f1415dd239c9bf201ab", + okexchain: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", + optimism: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf", + xdc: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", + bsc: "0xc3711bdbe7e3063bf6c22e7fed42f782ac82baee", + astar: "0x592de30bebff484b5a43a6e8e3ec1a814902e0b6", + metis: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf", + horizen: "0x97e0883493e8bb7a119a1e36e53ee9e7a2d3ca7b", + fantom: "0xccffe9d337f3c1b16bd271d109e691246fd69ee3", + clover: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", + gather: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf", + tron: "0xfe464ebd5bb5d95731f90aa7b9e39df920a61c97", + vinuchain: "0x72ccf64ee5e2c7629ee4eee3e6ad6990289178ae", +} as { + [chain: string]: string; }; -const constructParams = (chain: keyof typeof contracts) => { - const eventParams: PartialContractEventParams[] = []; +const nullAddress = "0x0000000000000000000000000000000000000000"; - for (const poolAddress of contracts[chain].pools) { - eventParams.push(constructTransferParams( - poolAddress, - true - ),constructTransferParams( - poolAddress, - false - )); +const constructParams = (chain: string) => { + let eventParams = [] as PartialContractEventParams[]; + const addy = gatewayAddresses[chain]; - } + const userLock = constructTransferParams(addy, true, { + excludeFrom: [addy, nullAddress], + excludeTo: [nullAddress], + includeTo: [addy], + }); + + const smgRelease = constructTransferParams(addy, false, { + excludeFrom: [nullAddress], + excludeTo: [nullAddress, addy], + includeFrom: [addy], + }); + + eventParams.push(userLock, smgRelease); return async (fromBlock: number, toBlock: number) => - getTxDataFromEVMEventLogs("allbridge", chain, fromBlock, toBlock, eventParams); + await getTxDataFromEVMEventLogs("wanbridge", chain as Chain, fromBlock, toBlock, eventParams); +}; -} const adapter: BridgeAdapter = { - arbitrum: constructParams('arbitrum'), - astar: constructParams('astar'), - avax: constructParams('avax'), - bsc: constructParams('bsc'), - clv: constructParams('clv'), - ethereum: constructParams('ethereum'), - fantom: constructParams('fantom'), - moonbeam: constructParams('moonbeam'), - moonriver: constructParams('moonriver'), - okexchain: constructParams('okexchain'), - optimism: constructParams('optimism'), - polygon: constructParams('polygon'), - telos: constructParams('telos'), - wan: constructParams('wan'), - xdc: constructParams('xdc'), + polygon: constructParams("polygon"), + arbitrum: constructParams("arbitrum"), + bsc: constructParams("bsc"), + ethereum: constructParams("ethereum"), + avalanche: constructParams("avalanche"), + moonbeam: constructParams("moonbeam"), + moonriver: constructParams("moonriver"), + functionX: constructParams("functionX"), + telos: constructParams("telos"), + okexchain: constructParams("okexchain"), + optimism: constructParams("optimism"), + xdc: constructParams("xdc"), + astar: constructParams("astar"), + metis: constructParams("metis"), + horizen: constructParams("horizen"), + fantom: constructParams("fantom"), + clover: constructParams("clover"), + gather: constructParams("gather"), + tron: constructParams("tron"), + vinuchain: constructParams("vinuchain"), + wanchain: constructParams("wanchain"), }; export default adapter; From ad0618b084a166d8a12b837519eb97f24e925b45 Mon Sep 17 00:00:00 2001 From: lolieatapple Date: Sat, 7 Oct 2023 16:25:11 +0800 Subject: [PATCH 3/9] update for wan-bridge --- src/adapters/wanbridge/index.ts | 227 ++++++++++++++++++++++---------- src/data/bridgeNetworkData.ts | 34 +++++ 2 files changed, 195 insertions(+), 66 deletions(-) diff --git a/src/adapters/wanbridge/index.ts b/src/adapters/wanbridge/index.ts index 7d96b7f0..707decdf 100644 --- a/src/adapters/wanbridge/index.ts +++ b/src/adapters/wanbridge/index.ts @@ -1,80 +1,175 @@ -import { Chain } from "@defillama/sdk/build/general"; -import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type"; -import { constructTransferParams } from "../../helpers/eventParams"; +import { BridgeAdapter, ContractEventParams } from "../../helpers/bridgeAdapter.type"; import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; -const gatewayAddresses = { - arbitrum: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", - wanchain: "0xe85b0d89cbc670733d6a40a9450d8788be13da47", - ethereum: "0xfceaaaeb8d564a9d0e71ef36f027b9d162bc334e", - avalanche: "0x74e121a34a66d54c33f3291f2cdf26b1cd037c3a", - moonbeam: "0x6372aec6263aa93eacedc994d38aa9117b6b95b5", - moonriver: "0xde1ae3c465354f01189150f3836c7c15a1d6671d", - functionX: "0xdf935552fac687123c642f589296762b632a9aaf", - telos: "0x201e5de97dfc46aace142b2009332c524c9d8d82", - polygon: "0x2216072a246a84f7b9ce0f1415dd239c9bf201ab", - okexchain: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", - optimism: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf", - xdc: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", - bsc: "0xc3711bdbe7e3063bf6c22e7fed42f782ac82baee", - astar: "0x592de30bebff484b5a43a6e8e3ec1a814902e0b6", - metis: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf", - horizen: "0x97e0883493e8bb7a119a1e36e53ee9e7a2d3ca7b", - fantom: "0xccffe9d337f3c1b16bd271d109e691246fd69ee3", - clover: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613", - gather: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf", - tron: "0xfe464ebd5bb5d95731f90aa7b9e39df920a61c97", - vinuchain: "0x72ccf64ee5e2c7629ee4eee3e6ad6990289178ae", -} as { - [chain: string]: string; -}; - -const nullAddress = "0x0000000000000000000000000000000000000000"; +enum Chains { + arbitrum = "arbitrum", + wanchain = "wanchain", + ethereum = "ethereum", + avalanche = "avalanche", + moonbeam = "moonbeam", + moonriver = "moonriver", + functionX = "functionX", + telos = "telos", + polygon = "polygon", + okexchain = "okexchain", + optimism = "optimism", + xdc = "xdc", + bsc = "bsc", + astar = "astar", + metis = "metis", + horizen = "horizen", + fantom = "fantom", + clover = "clover", + gather = "gather", + tron = "tron", + vinuchain = "vinuchain", +} -const constructParams = (chain: string) => { - let eventParams = [] as PartialContractEventParams[]; - const addy = gatewayAddresses[chain]; - const userLock = constructTransferParams(addy, true, { - excludeFrom: [addy, nullAddress], - excludeTo: [nullAddress], - includeTo: [addy], - }); +const contractAddresses = { + [Chains.arbitrum]: { + portal: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613" + }, + [Chains.wanchain]: { + portal: "0xe85b0d89cbc670733d6a40a9450d8788be13da47" + }, + [Chains.ethereum]: { + portal: "0xfceaaaeb8d564a9d0e71ef36f027b9d162bc334e" + }, + [Chains.avalanche]: { + portal: "0x74e121a34a66d54c33f3291f2cdf26b1cd037c3a" + }, + [Chains.moonbeam]: { + portal: "0x6372aec6263aa93eacedc994d38aa9117b6b95b5" + }, + [Chains.moonriver]: { + portal: "0xde1ae3c465354f01189150f3836c7c15a1d6671d" + }, + [Chains.functionX]: { + portal: "0xdf935552fac687123c642f589296762b632a9aaf" + }, + [Chains.telos]: { + portal: "0x201e5de97dfc46aace142b2009332c524c9d8d82" + }, + [Chains.polygon]: { + portal: "0x2216072a246a84f7b9ce0f1415dd239c9bf201ab" + }, + [Chains.okexchain]: { + portal: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613" + }, + [Chains.optimism]: { + portal: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf" + }, + [Chains.xdc]: { + portal: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613" + }, + [Chains.bsc]: { + portal: "0xc3711bdbe7e3063bf6c22e7fed42f782ac82baee" + }, + [Chains.astar]: { + portal: "0x592de30bebff484b5a43a6e8e3ec1a814902e0b6" + }, + [Chains.metis]: { + portal: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf" + }, + [Chains.horizen]: { + portal: "0x97e0883493e8bb7a119a1e36e53ee9e7a2d3ca7b" + }, + [Chains.fantom]: { + portal: "0xccffe9d337f3c1b16bd271d109e691246fd69ee3" + }, + [Chains.clover]: { + portal: "0xf7ba155556e2cd4dfe3fe26e506a14d2f4b97613" + }, + [Chains.gather]: { + portal: "0xc6ae1db6c66d909f7bfeeeb24f9adb8620bf9dbf" + }, + [Chains.tron]: { + portal: "0xfe464ebd5bb5d95731f90aa7b9e39df920a61c97" + }, + [Chains.vinuchain]: { + portal: "0x72ccf64ee5e2c7629ee4eee3e6ad6990289178ae" + }, +}; - const smgRelease = constructTransferParams(addy, false, { - excludeFrom: [nullAddress], - excludeTo: [nullAddress, addy], - includeFrom: [addy], - }); +const userLockPortalEventParams: ContractEventParams = { + target: "", + topic: "UserLockLogger(bytes32,uint256,address,uint256,uint256, bytes)", + abi: ["event UserLockLogger(bytes32 indexed smgID, uint indexed tokenPairID, address indexed tokenAccount, uint value, uint serviceFee, bytes userAccount)"], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + argKeys: { + to: "userAccount", + amount: "value", + token: "tokenAccount", + }, + isDeposit: true, +}; - eventParams.push(userLock, smgRelease); +const smgReleasePortalEventParams: ContractEventParams = { + target: "", + topic: "SmgReleaseLogger(bytes32,bytes32,uint256,uint256,address,address)", + abi: ["event SmgReleaseLogger(bytes32 indexed uniqueID, bytes32 indexed smgID, uint indexed tokenPairID, uint value, address tokenAccount, address userAccount)"], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + argKeys: { + to: "userAccount", + amount: "value", + token: "tokenAccount", + }, + isDeposit: false, +}; +const constructParams = (chain: Chains) => { + const { portal } = contractAddresses[chain]; + const eventParams: ContractEventParams[] = [ + { + ...userLockPortalEventParams, + target: portal, + fixedEventData: { + to: portal, + }, + }, + { + ...smgReleasePortalEventParams, + target: portal, + fixedEventData: { + from: portal, + }, + }, + ]; return async (fromBlock: number, toBlock: number) => - await getTxDataFromEVMEventLogs("wanbridge", chain as Chain, fromBlock, toBlock, eventParams); + getTxDataFromEVMEventLogs("eywa", chain, fromBlock, toBlock, eventParams); }; const adapter: BridgeAdapter = { - polygon: constructParams("polygon"), - arbitrum: constructParams("arbitrum"), - bsc: constructParams("bsc"), - ethereum: constructParams("ethereum"), - avalanche: constructParams("avalanche"), - moonbeam: constructParams("moonbeam"), - moonriver: constructParams("moonriver"), - functionX: constructParams("functionX"), - telos: constructParams("telos"), - okexchain: constructParams("okexchain"), - optimism: constructParams("optimism"), - xdc: constructParams("xdc"), - astar: constructParams("astar"), - metis: constructParams("metis"), - horizen: constructParams("horizen"), - fantom: constructParams("fantom"), - clover: constructParams("clover"), - gather: constructParams("gather"), - tron: constructParams("tron"), - vinuchain: constructParams("vinuchain"), - wanchain: constructParams("wanchain"), + arbitrum: constructParams(Chains.arbitrum), + polygon: constructParams(Chains.polygon), + bsc: constructParams(Chains.bsc), + ethereum: constructParams(Chains.ethereum), + avalanche: constructParams(Chains.avalanche), + optimism: constructParams(Chains.optimism), + fantom: constructParams(Chains.fantom), + moonbeam: constructParams(Chains.moonbeam), + moonriver: constructParams(Chains.moonriver), + telos: constructParams(Chains.telos), + okexchain: constructParams(Chains.okexchain), + xdc: constructParams(Chains.xdc), + astar: constructParams(Chains.astar), + metis: constructParams(Chains.metis), + wan: constructParams(Chains.wanchain), + + // vinuchain: constructParams(Chains.vinuchain), + // functionX: constructParams(Chains.functionX), + // horizen: constructParams(Chains.horizen), + // clover: constructParams(Chains.clover), + // gather: constructParams(Chains.gather), + + // tron: constructParams(Chains.tron), }; export default adapter; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 6fbbda33..30f4c2ef 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -583,4 +583,38 @@ export default [ "polygon zkevm": "polygon_zkevm", }, }, + { + id: 40, + displayName: "WanBridge", + bridgeDbName: "wanbridge", + iconLink: "icons:wanbridge", + largeTxThreshold: 10000, + url: "https://bridge.wanchain.org", + chains: [ + "Ethereum", + "Polygon", + "Fantom", + "Avalanche", + "Arbitrum", + "Optimism", + "BSC", + "Moonbeam", + "Moonriver", + "FunctionX", + "Telos", + "Okexchain", + "Horizen", + "Metis", + "Astar", + "Vinuchain", + "Tron", + "Wanchain", + "Clover", + "Gather", + "XDC", + ], + chainMapping: { + avalanche: "avax", + }, + }, ] as BridgeNetwork[]; From 4b8d58f2408001193c3d5af340766ec40a237aee Mon Sep 17 00:00:00 2001 From: lolieatapple Date: Wed, 11 Oct 2023 17:31:56 +0800 Subject: [PATCH 4/9] update for 4 chains --- package.json | 5 +++-- src/adapters/wanbridge/index.ts | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 468b698a..2aa74421 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "ts-loader": "^9.3.1" }, "dependencies": { - "@defillama/sdk": "^4.0.43", + "@defillama/sdk": "^4.0.64", "async-retry": "^1.3.1", "axios": "^0.21.0", "axios-rate-limit": "^1.3.0", @@ -30,6 +30,7 @@ "graphql-request": "^4.0.0", "node-fetch": "^2.6.7", "postgres": "^3.2.4", - "serverless-webpack": "^5.8.0" + "serverless-webpack": "^5.8.0", + "typescript": "^5.2.2" } } diff --git a/src/adapters/wanbridge/index.ts b/src/adapters/wanbridge/index.ts index 707decdf..c48a4150 100644 --- a/src/adapters/wanbridge/index.ts +++ b/src/adapters/wanbridge/index.ts @@ -143,7 +143,7 @@ const constructParams = (chain: Chains) => { }, ]; return async (fromBlock: number, toBlock: number) => - getTxDataFromEVMEventLogs("eywa", chain, fromBlock, toBlock, eventParams); + getTxDataFromEVMEventLogs("wanbridge", chain, fromBlock, toBlock, eventParams); }; const adapter: BridgeAdapter = { @@ -163,11 +163,11 @@ const adapter: BridgeAdapter = { metis: constructParams(Chains.metis), wan: constructParams(Chains.wanchain), - // vinuchain: constructParams(Chains.vinuchain), - // functionX: constructParams(Chains.functionX), - // horizen: constructParams(Chains.horizen), - // clover: constructParams(Chains.clover), - // gather: constructParams(Chains.gather), + vinu: constructParams(Chains.vinuchain), + // functionx: constructParams(Chains.functionX), + eon: constructParams(Chains.horizen), + clv: constructParams(Chains.clover), + gth: constructParams(Chains.gather), // tron: constructParams(Chains.tron), }; From a95b21afe83ff8b7cc448d062574a0e320b528f9 Mon Sep 17 00:00:00 2001 From: Defi-Moses <103143573+Defi-Moses@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:09:01 +0100 Subject: [PATCH 5/9] Adding Base and DFK chain to bridgeNetworkData --- src/data/bridgeNetworkData.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 30f4c2ef..64c98075 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -194,8 +194,9 @@ export default [ // "Boba", "Harmony", // "Dogechain", - // "DFK Chain", + "DFK Chain", // "Cronos", + "Base, ], chainMapping: { avalanche: "avax", From b69f2d6617fa4ad345a1b25066791d3e03c540de Mon Sep 17 00:00:00 2001 From: Defi-Moses <103143573+Defi-Moses@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:38:28 +0100 Subject: [PATCH 6/9] Update bridgeNetworkData.ts --- 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 64c98075..cd1368cd 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -196,7 +196,7 @@ export default [ // "Dogechain", "DFK Chain", // "Cronos", - "Base, + "Base", ], chainMapping: { avalanche: "avax", From 353ad8cb666531e55393cd58d0316c7ce80de551 Mon Sep 17 00:00:00 2001 From: Defi-Moses <103143573+Defi-Moses@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:03:06 +0100 Subject: [PATCH 7/9] Adding Base & CCTP events --- src/adapters/synapse/index.ts | 91 +++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/src/adapters/synapse/index.ts b/src/adapters/synapse/index.ts index ad37c087..a41bbc36 100644 --- a/src/adapters/synapse/index.ts +++ b/src/adapters/synapse/index.ts @@ -3,12 +3,11 @@ import { BridgeAdapter, ContractEventParams, PartialContractEventParams } from " import { constructTransferParams } from "../../helpers/eventParams"; import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; -const nullAddress = "0x0000000000000000000000000000000000000000"; - //Synapse Bridge Contracts on all supported chains const contractAddresses = { arbitrum: { synapseBridge: "0x6F4e8eBa4D337f874Ab57478AcC2Cb5BACdc19c9", + synapseCCTP: "0xfb2bfc368a7edfd51aa2cbec513ad50edea74e84", }, aurora: { synapseBridge: "0xaeD5b25BE1c3163c907a471082640450F928DDFE", @@ -36,6 +35,7 @@ const contractAddresses = { }, ethereum: { synapseBridge: "0x2796317b0fF8538F253012862c06787Adfb8cEb6", + synapseCCTP: "0xfb2bfc368a7edfd51aa2cbec513ad50edea74e84", }, fantom: { synapseBridge: "0xAf41a65F786339e7911F4acDAD6BD49426F2Dc6b", @@ -51,6 +51,7 @@ const contractAddresses = { }, optimism: { synapseBridge: "0xAf41a65F786339e7911F4acDAD6BD49426F2Dc6b", + synapseCCTP: "0xfb2bfc368a7edfd51aa2cbec513ad50edea74e84", }, polygon: { synapseBridge: "0x8F5BBB2BB8c2Ee94639E55d5F41de9b4839C1280", @@ -67,6 +68,7 @@ const contractAddresses = { } as { [chain: string]: { synapseBridge: string; + synapseCCTP?: string; }; }; @@ -261,52 +263,99 @@ const TokenWithdrawWithdrawParams: PartialContractEventParams = { }, isDeposit: false, }; + //CCTP Deposit + const CircleRequestSentParams: PartialContractEventParams = { + target: "", + topic: "CircleRequestSent(uint256,address,uint64,address,uint256,uint32,bytes,bytes32)", + abi: [ + "event CircleRequestSent(uint256 chainId, address indexed sender, uint64 nonce, address token, uint256 amount, uint32 requestVersion, bytes formattedRequest, bytes32 requestID)", + ], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + from: "address", + }, + argKeys: { + amount: "amount", + token: "token", + to: "sender", + }, + isDeposit: true, + }; +// CCTP Withdraw + const CircleRequestFulfilledParams: PartialContractEventParams = { + target: "", + topic: "CircleRequestFulfilled(uint32,address,address,uint256,address,uint256,bytes32)", + abi: [ + "event CircleRequestFulfilled(uint32 originDomain, address indexed recipient, address mintToken, uint256 fee, address token, uint256 amount, bytes32 requestID)", + ], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + from: "address", + }, + argKeys: { + amount: "amount", + token: "token", + to: "recipient", + }, + isDeposit: false, + }; //Add all partial events to eventParams const constructParams = (chain:string) => { + const { synapseBridge = '', synapseCCTP = null } = contractAddresses[chain]; //Deposits: const finalTokenDepositDepositParams = { ...TokenDepositDepositParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenDepositAndSwapDepositParams = { ...TokenDepositAndSwapDepositParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenRedeemDepositParams = { ...TokenRedeemDepositParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenRedeemAndSwapDepositParams = { ...TokenRedeemAndSwapDepositParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenRedeemAndRemoveDepositParams = { ...TokenRedeemAndRemoveDepositParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenRedeemV2DepositParams = { ...TokenRedeemV2DepositParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge + } + const finalCircleRequestSentParams = { + ...CircleRequestSentParams, + target: synapseCCTP || synapseBridge } // Withdraws const finalTokenWithdrawWithdrawParams = { ...TokenWithdrawWithdrawParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenWithdrawAndRemoveWithdrawParams = { ...TokenWithdrawAndRemoveWithdrawParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenMintWithdrawParams = { ...TokenMintWithdrawParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge } const finalTokenMintAndSwapWithdrawParams = { ...TokenMintAndSwapWithdrawParams, - target:contractAddresses[chain].synapseBridge + target: synapseBridge + } + const finalCircleRequestFulfilledParams = { + ...CircleRequestFulfilledParams, + target: synapseCCTP || synapseBridge } @@ -322,8 +371,11 @@ const constructParams = (chain:string) => { finalTokenWithdrawAndRemoveWithdrawParams, finalTokenMintWithdrawParams, finalTokenMintAndSwapWithdrawParams, + finalCircleRequestSentParams, + finalCircleRequestFulfilledParams, ] + return async (fromBlock: number, toBlock: number) => getTxDataFromEVMEventLogs("synapse", chain, fromBlock, toBlock, eventParams); @@ -335,12 +387,7 @@ const adapter: BridgeAdapter = { arbitrum: constructParams("arbitrum"), aurora: constructParams("aurora"), avalanche: constructParams("avax"), - // boba: constructParams("boba"), bsc: constructParams("bsc"), - // canto: constructParams("canto"), - // cronos: constructParams("cronos"), - dfk: constructParams("dfk"), - // dogechain: constructParams("dogechain"), ethereum: constructParams("ethereum"), fantom: constructParams("fantom"), harmony: constructParams("harmony"), @@ -348,9 +395,15 @@ const adapter: BridgeAdapter = { moonbeam: constructParams("moonbeam"), optimism: constructParams("optimism"), polygon: constructParams("polygon"), - // metis: constructParams("metis"), klaytn: constructParams("klaytn"), base: constructParams("base"), + metis: constructParams("metis"), + // dfk: constructParams("dfk"), + // boba: constructParams("boba"), + // canto: constructParams("canto"), + // cronos: constructParams("cronos"), + // dogechain: constructParams("dogechain"), + }; @@ -365,5 +418,3 @@ const adapter: BridgeAdapter = { // Using bridge Zap contract : https://polygonscan.com/tx/0x2cec1d015aef431b5363e7e68afc3c7bd9eecb17a7ea997dc7b5067ecb2167dc // Using Router Contract: https://polygonscan.com/tx/0xf94193d101fdc9240aafd6069b3e02397a8bc5aff3c2e2f08b969689c7d9f290 // Using regular Bridge Contract: https://polygonscan.com/tx/0x3ffe45b68bb42661b0081b76fc04699ca76944e3113f1c10a397ec0fc5e16f2b - - From a96e9a2c5b87f99885369379a51844945dfbe9cd Mon Sep 17 00:00:00 2001 From: Defi-Moses <103143573+Defi-Moses@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:03:49 +0100 Subject: [PATCH 8/9] Adding chains for synapse, and commenting out dfk --- src/data/bridgeNetworkData.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index cd1368cd..9ef1c837 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -187,16 +187,16 @@ export default [ "Aurora", "Klaytn", "BSC", - // "Metis", + "Metis", "Moonbeam", "Moonriver", - // "Canto", - // "Boba", + "Base", "Harmony", // "Dogechain", - "DFK Chain", + // "DFK Chain", // "Cronos", - "Base", + // "Canto", + // "Boba", ], chainMapping: { avalanche: "avax", From f7b27ffe4e4a480d937779bbff41f40bf1738b95 Mon Sep 17 00:00:00 2001 From: defi-moses Date: Wed, 13 Dec 2023 12:38:27 +0000 Subject: [PATCH 9/9] updating cctp contracts --- src/adapters/synapse/index.ts | 30 ++++++++++-------------------- src/data/bridgeNetworkData.ts | 4 ++-- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/adapters/synapse/index.ts b/src/adapters/synapse/index.ts index a41bbc36..df4574e7 100644 --- a/src/adapters/synapse/index.ts +++ b/src/adapters/synapse/index.ts @@ -7,13 +7,14 @@ import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; const contractAddresses = { arbitrum: { synapseBridge: "0x6F4e8eBa4D337f874Ab57478AcC2Cb5BACdc19c9", - synapseCCTP: "0xfb2bfc368a7edfd51aa2cbec513ad50edea74e84", + synapseCCTP: "0x12715a66773BD9C54534a01aBF01d05F6B4Bd35E", }, aurora: { synapseBridge: "0xaeD5b25BE1c3163c907a471082640450F928DDFE", }, avax: { synapseBridge: "0xC05e61d0E7a63D27546389B7aD62FdFf5A91aACE", + synapseCCTP: "0x12715a66773BD9C54534a01aBF01d05F6B4Bd35E" }, boba: { synapseBridge: "0x432036208d2717394d2614d6697c46DF3Ed69540", @@ -35,7 +36,7 @@ const contractAddresses = { }, ethereum: { synapseBridge: "0x2796317b0fF8538F253012862c06787Adfb8cEb6", - synapseCCTP: "0xfb2bfc368a7edfd51aa2cbec513ad50edea74e84", + synapseCCTP: "0x12715a66773BD9C54534a01aBF01d05F6B4Bd35E", }, fantom: { synapseBridge: "0xAf41a65F786339e7911F4acDAD6BD49426F2Dc6b", @@ -51,10 +52,11 @@ const contractAddresses = { }, optimism: { synapseBridge: "0xAf41a65F786339e7911F4acDAD6BD49426F2Dc6b", - synapseCCTP: "0xfb2bfc368a7edfd51aa2cbec513ad50edea74e84", + synapseCCTP: "0x12715a66773BD9C54534a01aBF01d05F6B4Bd35E", }, polygon: { synapseBridge: "0x8F5BBB2BB8c2Ee94639E55d5F41de9b4839C1280", + synapseCCTP: "0x12715a66773BD9C54534a01aBF01d05F6B4Bd35E", }, metis: { synapseBridge: "0x06Fea8513FF03a0d3f61324da709D4cf06F42A5c", @@ -64,6 +66,7 @@ const contractAddresses = { }, base: { synapseBridge: "0xf07d1C752fAb503E47FEF309bf14fbDD3E867089", + synapseCCTP: "0x12715a66773BD9C54534a01aBF01d05F6B4Bd35E" } } as { [chain: string]: { @@ -358,8 +361,6 @@ const constructParams = (chain:string) => { target: synapseCCTP || synapseBridge } - - const eventParams = [ finalTokenDepositDepositParams, finalTokenDepositAndSwapDepositParams, @@ -375,14 +376,11 @@ const constructParams = (chain:string) => { finalCircleRequestFulfilledParams, ] - return async (fromBlock: number, toBlock: number) => - getTxDataFromEVMEventLogs("synapse", chain, fromBlock, toBlock, eventParams); + getTxDataFromEVMEventLogs("synapse", chain as Chain, fromBlock, toBlock, eventParams); } - - const adapter: BridgeAdapter = { arbitrum: constructParams("arbitrum"), aurora: constructParams("aurora"), @@ -390,20 +388,19 @@ const adapter: BridgeAdapter = { bsc: constructParams("bsc"), ethereum: constructParams("ethereum"), fantom: constructParams("fantom"), - harmony: constructParams("harmony"), + // harmony: constructParams("harmony"), moonriver: constructParams("moonriver"), moonbeam: constructParams("moonbeam"), optimism: constructParams("optimism"), polygon: constructParams("polygon"), - klaytn: constructParams("klaytn"), + // // klaytn: constructParams("klaytn"), base: constructParams("base"), metis: constructParams("metis"), // dfk: constructParams("dfk"), // boba: constructParams("boba"), - // canto: constructParams("canto"), + // // canto: constructParams("canto"), // cronos: constructParams("cronos"), // dogechain: constructParams("dogechain"), - }; @@ -411,10 +408,3 @@ const adapter: BridgeAdapter = { - - - - // Example contracts: -// Using bridge Zap contract : https://polygonscan.com/tx/0x2cec1d015aef431b5363e7e68afc3c7bd9eecb17a7ea997dc7b5067ecb2167dc -// Using Router Contract: https://polygonscan.com/tx/0xf94193d101fdc9240aafd6069b3e02397a8bc5aff3c2e2f08b969689c7d9f290 -// Using regular Bridge Contract: https://polygonscan.com/tx/0x3ffe45b68bb42661b0081b76fc04699ca76944e3113f1c10a397ec0fc5e16f2b diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 9ef1c837..018b8507 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -185,13 +185,13 @@ export default [ "Arbitrum", "Optimism", "Aurora", - "Klaytn", + // "Klaytn", "BSC", "Metis", "Moonbeam", "Moonriver", "Base", - "Harmony", + // "Harmony", // "Dogechain", // "DFK Chain", // "Cronos",