Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pheasant network #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -82,6 +83,7 @@ export default {
rhinofi,
pepeteam_bridge,
pnetwork,
pheasant_network
} as {
[bridge: string]: BridgeAdapter;
};
102 changes: 102 additions & 0 deletions src/adapters/pheasant-network/index.ts
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions src/data/bridgeNetworkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,4 +649,13 @@ export default [
chains: ["Ethereum", "BSC", "Polygon"],
destinationChain: "Waves",
},
{
id: 44,
displayName: "Pheasant Network",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u need to list your protocol on defillama

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[];