From e2cc36d53f80c12a0c5487392147b8e5dde9f33e Mon Sep 17 00:00:00 2001 From: spiehdid Date: Tue, 25 Jul 2023 13:00:11 +0300 Subject: [PATCH 1/4] Add EYWA --- src/adapters/eywa/index.ts | 172 ++++++++++++++++++++++++++++++++++ src/adapters/index.ts | 2 + src/data/bridgeNetworkData.ts | 8 ++ 3 files changed, 182 insertions(+) create mode 100644 src/adapters/eywa/index.ts diff --git a/src/adapters/eywa/index.ts b/src/adapters/eywa/index.ts new file mode 100644 index 00000000..da0fa76c --- /dev/null +++ b/src/adapters/eywa/index.ts @@ -0,0 +1,172 @@ +import { BridgeAdapter, ContractEventParams } from "../../helpers/bridgeAdapter.type"; +import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; + +enum Chains { + arbitrum = "arbitrum", + bsc = "bsc", + polygon = "polygon", + avax = "avax", + fantom = "fantom", + ethereum = "ethereum", + optimism = "optimism", +} + +const contractAddresses = { + [Chains.arbitrum]: { + portal: "0xBf0b5D561b986809924f88099c4FF0e6BccE60c9", + synthesis: "0x530aF883f135F135BE12A69DC33296fb8149f593", + }, + [Chains.bsc]: { + portal: "0xBf0b5D561b986809924f88099c4FF0e6BccE60c9", + synthesis: "0x530aF883f135F135BE12A69DC33296fb8149f593", + }, + [Chains.polygon]: { + portal: "0xBf0b5D561b986809924f88099c4FF0e6BccE60c9", + synthesis: "0x530aF883f135F135BE12A69DC33296fb8149f593", + }, + [Chains.avax]: { + portal: "0xBf0b5D561b986809924f88099c4FF0e6BccE60c9", + synthesis: "0x530aF883f135F135BE12A69DC33296fb8149f593", + }, + [Chains.fantom]: { + portal: "0xBf0b5D561b986809924f88099c4FF0e6BccE60c9", + synthesis: "0x530aF883f135F135BE12A69DC33296fb8149f593", + }, + [Chains.ethereum]: { + portal: "0xBf0b5D561b986809924f88099c4FF0e6BccE60c9", + synthesis: "0x530aF883f135F135BE12A69DC33296fb8149f593", + }, + [Chains.optimism]: { + portal: "0xBf0b5D561b986809924f88099c4FF0e6BccE60c9", + synthesis: "0x530aF883f135F135BE12A69DC33296fb8149f593", + }, +}; + +const depositPortalEventParams: ContractEventParams = { + target: "", + topic: "Locked(address,uint256,uint256,address)", + abi: ["event Locked(address token, uint256 amount, address from, address to)"], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + argKeys: { + from: "from", + amount: "amount", + token: "token", + }, + isDeposit: true, +}; + +const withdrawalPortalEventParams: ContractEventParams = { + target: "", + topic: "Unlocked(address,uint256,address,address)", + abi: ["event Unlocked(address token, uint256 amount, address from, address to)"], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + argKeys: { + to: "to", + amount: "amount", + token: "token", + }, + isDeposit: false, +}; + +const burnSynthesisEventParams: ContractEventParams = { + target: "", + topic: "Burn(address,uint256,address,address)", + abi: ["event Burn(address token, uint256 amount, address from, address to)"], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + argKeys: { + from: "from", + to: "to", + amount: "amount", + token: "token", + }, + isDeposit: true, +}; + +const moveSynthesisEventParams: ContractEventParams = { + target: "", + topic: "Move(address,uint256,address,address,uint64)", + abi: ["event Move(address token, uint256 amount, address from, address to, uint64 chainIdTo)"], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + argKeys: { + from: "from", + to: "to", + amount: "amount", + token: "token", + }, + isDeposit: true, +}; + +const mintSynthesisEventParams: ContractEventParams = { + target: "", + topic: "Synthesized(address,uint256,address,address)", + abi: ["event Synthesized(address token, uint256 amount, address from, address to)"], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + argKeys: { + from: "from", + to: "to", + amount: "amount", + token: "token", + }, + isDeposit: false, +}; + +const constructParams = (chain: Chains) => { + const { portal, synthesis } = contractAddresses[chain]; + const eventParams: ContractEventParams[] = [ + { + ...depositPortalEventParams, + target: portal, + fixedEventData: { + to: portal, + }, + }, + { + ...withdrawalPortalEventParams, + target: portal, + fixedEventData: { + from: portal, + }, + }, + { + ...burnSynthesisEventParams, + target: synthesis, + }, + { + ...moveSynthesisEventParams, + target: synthesis, + }, + { + ...mintSynthesisEventParams, + target: synthesis, + }, + ]; + return async (fromBlock: number, toBlock: number) => + getTxDataFromEVMEventLogs("eywa", chain, fromBlock, toBlock, eventParams); +}; + +const adapter: BridgeAdapter = { + [Chains.arbitrum]: constructParams(Chains.arbitrum), + [Chains.bsc]: constructParams(Chains.bsc), + [Chains.polygon]: constructParams(Chains.polygon), + [Chains.avax]: constructParams(Chains.avax), + [Chains.fantom]: constructParams(Chains.fantom), + [Chains.ethereum]: constructParams(Chains.ethereum), + [Chains.optimism]: constructParams(Chains.optimism), +}; + +export default adapter; diff --git a/src/adapters/index.ts b/src/adapters/index.ts index 0cf72e47..227ba894 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -32,6 +32,7 @@ import meson from "./meson"; import base from "./base"; import mantle from "./mantle"; import neuron from "./neuron"; +import eywa from "./eywa"; export default { polygon, @@ -66,6 +67,7 @@ export default { base, mantle, neuron, + eywa, } as { [bridge: string]: BridgeAdapter; }; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 5ec95199..22e470a1 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -471,4 +471,12 @@ export default [ // url: "", // chains: ["Arbitrum", "Linea", "Optimism", "Base"], // }, + { + displayName: "Eywa", + bridgeDbName: "eywa", + iconLink: "icons:eywa", + largeTxThreshold: 10000, + url: "", + chains: ["Ethereum", "Polygon", "Fantom", "Avalanche", "Arbitrum", "Optimism", "BSC"], + }, ] as BridgeNetwork[]; From f47ea1d19b46e22dfa81a743b8fbc2e1f34b5aa8 Mon Sep 17 00:00:00 2001 From: spiehdid Date: Mon, 14 Aug 2023 11:42:45 +0300 Subject: [PATCH 2/4] Add id to bridge data --- src/data/bridgeNetworkData.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 22e470a1..ae145582 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -472,6 +472,7 @@ export default [ // chains: ["Arbitrum", "Linea", "Optimism", "Base"], // }, { + id: 32, displayName: "Eywa", bridgeDbName: "eywa", iconLink: "icons:eywa", From fe33c629787f8a447b7ebc78b914cfc1097bf3d3 Mon Sep 17 00:00:00 2001 From: spiehdid Date: Mon, 28 Aug 2023 17:50:56 +0300 Subject: [PATCH 3/4] fix --- src/data/bridgeNetworkData.ts | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index eff11014..73f3a99f 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -477,31 +477,31 @@ export default [ // url: "", // chains: ["Arbitrum", "Linea", "Optimism", "Base"], // }, - { - id: 32, - displayName: "SquidRouter", - bridgeDbName: "squidrouter", - iconLink: "icons:axelar", - largeTxThreshold: 10000, - url: "", - chains: [ - "Ethereum", - "Polygon", - "Avalanche", - "BSC", - "Fantom", - "Arbitrum", - "Base", - "Linea", - "Celo", - "Moonbeam", - "Kava", - "Filecoin", - ], - chainMapping: { - avalanche: "avax", // this is needed temporarily, need to fix and remove - }, - }, + // { + // id: 32, + // displayName: "SquidRouter", + // bridgeDbName: "squidrouter", + // iconLink: "icons:axelar", + // largeTxThreshold: 10000, + // url: "", + // chains: [ + // "Ethereum", + // "Polygon", + // "Avalanche", + // "BSC", + // "Fantom", + // "Arbitrum", + // "Base", + // "Linea", + // "Celo", + // "Moonbeam", + // "Kava", + // "Filecoin", + // ], + // chainMapping: { + // avalanche: "avax", // this is needed temporarily, need to fix and remove + // }, + // }, { id: 33, displayName: "Eywa", From 4e7f72cf1cba5501a435b5ecd81f7c404823f9b3 Mon Sep 17 00:00:00 2001 From: vrtnd Date: Tue, 19 Sep 2023 22:30:15 +0300 Subject: [PATCH 4/4] add eywa --- src/adapters/eywa/index.ts | 2 +- src/data/bridgeNetworkData.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/adapters/eywa/index.ts b/src/adapters/eywa/index.ts index da0fa76c..2a1c6229 100644 --- a/src/adapters/eywa/index.ts +++ b/src/adapters/eywa/index.ts @@ -163,10 +163,10 @@ const adapter: BridgeAdapter = { [Chains.arbitrum]: constructParams(Chains.arbitrum), [Chains.bsc]: constructParams(Chains.bsc), [Chains.polygon]: constructParams(Chains.polygon), - [Chains.avax]: constructParams(Chains.avax), [Chains.fantom]: constructParams(Chains.fantom), [Chains.ethereum]: constructParams(Chains.ethereum), [Chains.optimism]: constructParams(Chains.optimism), + avalanche: constructParams(Chains.avax), }; export default adapter; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 7d426f70..487af3ba 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -518,12 +518,15 @@ export default [ }, }, { - id: 33, + id: 35, displayName: "Eywa", bridgeDbName: "eywa", iconLink: "icons:eywa", largeTxThreshold: 10000, url: "", chains: ["Ethereum", "Polygon", "Fantom", "Avalanche", "Arbitrum", "Optimism", "BSC"], + chainMapping: { + avalanche: "avax", + }, }, ] as BridgeNetwork[];