From 88eb9130b8c89cc93a917d53026fed39d27aa0f7 Mon Sep 17 00:00:00 2001 From: Alien Deployer Date: Tue, 11 Jun 2024 12:04:55 +0300 Subject: [PATCH] add getStrategyShortId --- README.md | 9 +++++++++ src/strategies.ts | 9 +++++++++ tests/strategies.test.ts | 7 ++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d323528..d34e0e9 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ console.log('Platform address on Polygon', deployments["137"].platform) Comprehensive information about platform strategies for managing DeFi assets. Includes developed strategies and those currently in development or awaiting development. +#### Methods + +* `getMerklStrategies()` +* `getStrategyShortId(id: string): StrategyShortId|undefined` + ### Networks Blockchains known to the platform and their integration statuses. @@ -34,6 +39,10 @@ Blockchains known to the platform and their integration statuses. DeFi organizations, protocols, their integration statuses, usage and other information. +#### Methods + +* `getIntegrationStatus(p: DeFiProtocol): IntegrationStatus` + ## Develop ```shell diff --git a/src/strategies.ts b/src/strategies.ts index 3dfbe0d..cb6802a 100644 --- a/src/strategies.ts +++ b/src/strategies.ts @@ -200,3 +200,12 @@ export const getMerklStrategies = (): string[] => { return strategy.id }) } + +export const getStrategyShortId = (strategyId: string): StrategyShortId|undefined => { + for (const strategyShortId of Object.keys(strategies)) { + if (strategies[strategyShortId as StrategyShortId].id === strategyId) { + return strategyShortId as StrategyShortId; + } + } + return undefined +} diff --git a/tests/strategies.test.ts b/tests/strategies.test.ts index ca7205e..6077be5 100644 --- a/tests/strategies.test.ts +++ b/tests/strategies.test.ts @@ -1,6 +1,11 @@ -import {getMerklStrategies} from "../src/strategies"; +import {getMerklStrategies, getStrategyShortId} from "../src/strategies"; +import {StrategyShortId} from "../src"; describe('testing strategies', () => { + test('get merkl strategies', () => { + expect(getStrategyShortId('QuickSwap Static Merkl Farm')).toBe(StrategyShortId.QSMF) + expect(getStrategyShortId('unknown')).toBe(undefined) + }) test('get merkl strategies', () => { const merklStrategies = getMerklStrategies(); expect(merklStrategies.includes('Gamma UniswapV3 Merkl Farm')).toBe(true);