UNPKG

@admin-jigsaw/jigsaw-sdk

Version:

Returns predefined data for Jigsaw platform and exposes functionality to retrieve the necessary data

19 lines (18 loc) 795 B
import { getChainConfig } from "../constants/chains"; /** * Returns the protocol name based on the provided strategy address. * @param {Address} stratAddress - The strategy address to look up. * @param {number} chainId - The chain ID to get the correct constants. * @returns {string | null} - The corresponding protocol name or null if not found. */ export function getProtocolByStrategy(stratAddress, chainId = 1) { const chainConfig = getChainConfig(chainId); if (chainConfig.protocolStrategyMap === null) return null; for (const [protocol, strategies] of Object.entries(chainConfig.protocolStrategyMap)) { if (strategies.includes(stratAddress)) { return protocol; } } return null; // Return null if no matching strategy is found }