UNPKG

@admin-jigsaw/jigsaw-sdk

Version:

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

22 lines (21 loc) 929 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getProtocolByStrategy = getProtocolByStrategy; const chains_1 = require("../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. */ function getProtocolByStrategy(stratAddress, chainId = 1) { const chainConfig = (0, chains_1.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 }