diff --git a/src/adapters/index.ts b/src/adapters/index.ts index 38381d20..22c22331 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -53,6 +53,7 @@ import tokenbridge from "./rootstock-token-bridge"; import butterswap from "./butterswap"; import mesprotocol from "./mesprotocol"; import fuse from "./fuse"; +import sygma from "./sygma"; export default { polygon, @@ -108,6 +109,7 @@ export default { butterswap, mesprotocol, fuse, + sygma, } as { [bridge: string]: BridgeAdapter; }; diff --git a/src/adapters/sygma/index.ts b/src/adapters/sygma/index.ts new file mode 100644 index 00000000..c19d2257 --- /dev/null +++ b/src/adapters/sygma/index.ts @@ -0,0 +1,56 @@ +import { BridgeAdapter, ContractEventParams } from "../../helpers/bridgeAdapter.type"; +import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; + +// Define the parameters for listening to deposit and withdrawal events +const depositEventParams: ContractEventParams = { + target: "0x4D878E8Fb90178588Cda4cf1DCcdC9a6d2757089", + topic: "Deposit(uint8,bytes32,uint64,address,bytes,bytes)", + abi: [ + "event Deposit(uint8 destinationDomainID, bytes32 resourceID, uint64 depositNonce, address indexed user, bytes data, bytes handlerResponse)" + ], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash", + }, + txKeys: { + from: "from", + }, + // not sure if "inputDataExtraction" is the right way to go to decode deposit function input data + inputDataExtraction: { + inputDataABI: [ + "function deposit(uint8 destinationDomainID, bytes32 resourceID, bytes depositData, bytes feeData)", + ], + inputDataFnName: "deposit", + inputDataKeys: { + token: "_token", + amount: "_amount", + }, + }, + isDeposit: true +}; + +const withdrawalEventParams: ContractEventParams = { + target: "0x4D878E8Fb90178588Cda4cf1DCcdC9a6d2757089", + topic: "ProposalExecution(uint8,uint64,bytes32,bytes)", + abi: [ + "event ProposalExecution(uint8 originDomainID, uint64 depositNonce, bytes32 dataHash, bytes handlerResponse)" + ], + txKeys: { + to: "to", + }, + isDeposit: false +}; + +// This function constructs the parameters based on the events defined above +const constructParams = () => { + const eventParams = [depositEventParams, withdrawalEventParams]; + return async (fromBlock: number, toBlock: number) => + getTxDataFromEVMEventLogs("sygma", "ethereum", fromBlock, toBlock, eventParams); +}; + +// Define the adapter for each chain your bridge operates on +const adapter: BridgeAdapter = { + ethereum: constructParams(), +}; + +export default adapter; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 08831fb3..6eeab6e0 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -883,4 +883,13 @@ export default [ // }, // destinationChain: "MAP Relay Chain", // }, + { + id: 59, + displayName: "Sygma", + bridgeDbName: "sygma", + iconLink: "icons:sygma", + url: "https://buildwithsygma.com/", + largeTxThreshold: 10000, + chains: ["Ethereum"], + }, ] as BridgeNetwork[];