From 80b2b621301a3c61caf12c98fb3c8f0e7b73453f Mon Sep 17 00:00:00 2001 From: tuco-gordian Date: Thu, 27 Jun 2024 15:16:36 +0300 Subject: [PATCH] Cetoswap bridge --- src/adapters/ceto-swap/index.ts | 55 +++++++++++++++++++++++++++++++++ src/adapters/index.ts | 3 ++ src/data/bridgeNetworkData.ts | 9 ++++++ 3 files changed, 67 insertions(+) create mode 100644 src/adapters/ceto-swap/index.ts diff --git a/src/adapters/ceto-swap/index.ts b/src/adapters/ceto-swap/index.ts new file mode 100644 index 00000000..28d31d5b --- /dev/null +++ b/src/adapters/ceto-swap/index.ts @@ -0,0 +1,55 @@ +import { Chain } from "@defillama/sdk/build/general"; +import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type"; +import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; + + +const contracts: { [key: string]: string } = { + bsc: '0x56b3e5cdbf4d1dc4d7cdc81e6f16d1404c463773', + manta: '0xF68fa6D10810c91dd97454657b17EcB7dCECc96D', + arbitrum: '0xF68fa6D10810c91dd97454657b17EcB7dCECc96D' +} +// topic: "OrderCompleted(uint256,uint256,bytes32)", +// abi: [ +// "event OrderCompleted(uint256 indexed id, uint256 indexed chainIdFrom, bytes32 orderHash)" +// ], +// topic: "OrderCreated(uint256,tuple(uint256,uint256,address,address,uint256,uint256,uint256,uint256,address,address,bool,uint256,bool),uint256)", +// abi: [ +// "event OrderCreated(uint256 indexed id, tuple(uint256 id, uint256 tokenId, address sender, address recipient, uint256 chainId, uint256 amount, uint256 feeAmount, uint256 decimals, address tokenIn, address tokenOut, bool payInNative, uint256 timestamp, bool closed) order, uint256 feeAmount)" +// ], +const orderCompletedParams: PartialContractEventParams = { + target: "", + topic: "OrderCreated(uint256,tuple(uint256,uint256,address,address,uint256,uint256,uint256,uint256,address,address,bool,uint256,bool),uint256)", + abi: [ + "event OrderCreated(uint256 indexed id, tuple(uint256 id, uint256 tokenId, address sender, address recipient, uint256 chainId, uint256 amount, uint256 feeAmount, uint256 decimals, address tokenIn, address tokenOut, bool payInNative, uint256 timestamp, bool closed) order, uint256 feeAmount)" + ], + logKeys: { + blockNumber: "blockNumber", + txHash: "transactionHash" + }, + argKeys: { + amount: "order.amount", + token: "order.tokenId", + }, + isDeposit: true +}; + + +const constructParams = (chain: string) => { + return async (fromBlock: number, toBlock: number) => { + const events = await getTxDataFromEVMEventLogs("ceto-swap", chain as Chain, fromBlock, toBlock, [ + { + ...orderCompletedParams, + target: contracts[chain] + } + ]); + return events; + }; +} + +const adapter: BridgeAdapter = { + bsc: constructParams('bsc'), + manta: constructParams('manta'), + arbitrum: constructParams('arbitrum'), +}; + +export default adapter; \ No newline at end of file diff --git a/src/adapters/index.ts b/src/adapters/index.ts index 12ce8a66..9eafa7fc 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -60,6 +60,8 @@ import xswap from "./xswap"; import owlto from "./owlto"; import zkbridge from "./zkbridge"; import helixbridge from "./helixbridge" +import cetoSwap from "./ceto-swap"; + export default { polygon, @@ -123,6 +125,7 @@ export default { zkbridge, zkbridge111: zkbridge, helixbridge, + "ceto-swap": cetoSwap, } as { [bridge: string]: BridgeAdapter; }; diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index fd4afb2d..376aa9ac 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -1280,4 +1280,13 @@ export default [ gnosis: "xdai", }, }, + { + id: 66, + displayName: "CetoSwap Bridge", + bridgeDbName: "ceto-swap", + iconLink: "chain:cetoswap", + largeTxThreshold: 10000, + url: "https://cetoswap.com/#/", + chains: ["BSC", "Arbitrum", "Manta"], + }, ] as BridgeNetwork[];