From b798c7c34f374e821f19601822e3917d850e276e Mon Sep 17 00:00:00 2001 From: arkeysun <120470846+arkeysun@users.noreply.github.com> Date: Sun, 3 Dec 2023 12:33:11 +0000 Subject: [PATCH] add pheasant network --- src/adapters/index.ts | 2 + src/adapters/pheasant-network/index.ts | 102 +++++++++++++++++++++++++ src/data/bridgeNetworkData.ts | 9 +++ 3 files changed, 113 insertions(+) create mode 100644 src/adapters/pheasant-network/index.ts diff --git a/src/adapters/index.ts b/src/adapters/index.ts index ca70b4e3..cb0707f5 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -40,6 +40,7 @@ import eywa from "./eywa"; import rhinofi from './rhinofi'; import pepeteam_bridge from './pepeteam-bridge'; import pnetwork from './pnetwork'; +import pheasant_network from './pheasant-network'; export default { polygon, @@ -82,6 +83,7 @@ export default { rhinofi, pepeteam_bridge, pnetwork, + pheasant_network } as { [bridge: string]: BridgeAdapter; }; diff --git a/src/adapters/pheasant-network/index.ts b/src/adapters/pheasant-network/index.ts new file mode 100644 index 00000000..b619a63b --- /dev/null +++ b/src/adapters/pheasant-network/index.ts @@ -0,0 +1,102 @@ +import { Chain } from "@defillama/sdk/build/general"; +import { BridgeAdapter, ContractEventParams, PartialContractEventParams } from "../../helpers/bridgeAdapter.type"; +import { getTxDataFromEVMEventLogs } from "../../helpers/processTransactions"; + +const contractAddresses = { + // ethereum: "", + polygon: "0x84F90083e4aA00B5FD4DAaaEEc75bdF8978EDCD2", + optimism: "0x558F7547A472a6897126e20440453e57AC320794", + arbitrum: "0xb9ACb5601C091B39960a6c4974b979483132B30A", + scroll: "0x27cb8546F60fD5d7869a223F40b8036a9eBe3a4f", + era: "0x77201FC74123Ea148C836418a08Da3322B3201D3", + base: "0x0890f8A7b193A3eEE810DE3AdcFAd181b9ce294E", + polygon_zkevm: "0x9F28AC2c1a2A82db54DFED6B9784a7A950EfEc08", + linea: "0x9E7FCb2c0b8a5461BCc7078a2E37886f254B060b" +} as any; + +const ethTokenAddresses = { + // ethereum: "", + polygon: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", + optimism: "0x558F7547A472a6897126e20440453e57AC320794", + arbitrum: "0xb9ACb5601C091B39960a6c4974b979483132B30A", + scroll: "0x27cb8546F60fD5d7869a223F40b8036a9eBe3a4f", + era: "0x77201FC74123Ea148C836418a08Da3322B3201D3", + base: "0x0890f8A7b193A3eEE810DE3AdcFAd181b9ce294E", + polygon_zkevm: "0x9F28AC2c1a2A82db54DFED6B9784a7A950EfEc08", + linea: "0x9E7FCb2c0b8a5461BCc7078a2E37886f254B060b" +} as any; + +const depositParams: PartialContractEventParams = { + target: "", + topic: "Accept(address,bytes32,uint256)", + abi: [ + "event Accept(address indexed userAddress, bytes32 indexed txHash, uint256 index)", + ], + argKeys: { + from: "userAddress", + amount: "index", + }, + isDeposit: true, +}; + +const withdrawalParams: ContractEventParams = { + target: "", + topic: "NewTrade(address,uint256)", + abi: ["event NewTrade(address indexed userAddress, uint256 index)"], + argKeys: { + from: "userAddress", + }, + inputDataExtraction: { + inputDataABI: [ + "function newTrade(uint256 _amount,address _to,uint256 _fee,uint8 _tokenTypeIndex,uint256 _destCode)", + ], + inputDataFnName: "newTrade", + inputDataKeys: { + amount: "_amount", + }, + }, + isDeposit: false, +}; + +const constructParams = (chain: Chain) => { + let eventParams = [] as any; + const contractAddress = contractAddresses[chain]; + + // We don't use amount in deposit function as an argument and event, so we can not show deposit amount in this time. + // const finalDepositParams = { + // ...depositParams, + // target: contractAddress, + // fixedEventData: { + // token: "0x0000000000000000000000000000000000000000", + // to: contractAddress, + // amount: 0 + // }, + // }; + + const finalWithdrawalParams = { + ...withdrawalParams, + target: contractAddress, + fixedEventData: { + token: "0x0000000000000000000000000000000000000000", + to: contractAddress + }, + }; + eventParams.push(finalWithdrawalParams); + + return async (fromBlock: number, toBlock: number) => + getTxDataFromEVMEventLogs("pheasantnetwork", chain, fromBlock, toBlock, eventParams); +}; + +const adapter: BridgeAdapter = { + // ethereum: constructParams("ethereum"), + polygon: constructParams("polygon"), + optimism: constructParams("optimism"), + arbitrum: constructParams("arbitrum"), + scroll: constructParams("scroll"), + era: constructParams("era"), + base: constructParams("base"), + polygon_zkevm: constructParams("polygon_zkevm"), + linea: constructParams("linea") +}; + +export default adapter; \ No newline at end of file diff --git a/src/data/bridgeNetworkData.ts b/src/data/bridgeNetworkData.ts index 51919cf7..97a9d3c4 100644 --- a/src/data/bridgeNetworkData.ts +++ b/src/data/bridgeNetworkData.ts @@ -649,4 +649,13 @@ export default [ chains: ["Ethereum", "BSC", "Polygon"], destinationChain: "Waves", }, + { + id: 44, + displayName: "Pheasant Network", + bridgeDbName: "pheasant_network", + iconLink: "protocols:pheasant_network", + largeTxThreshold: 10000, + url: "https://pheasant.network", + chains: ["Ethereum", "Polygon", "Optimism", "Arbitrum", "Scroll", "zkSync Era", "Base", "Polygon zkEVM", "Linea"], + }, ] as BridgeNetwork[];