diff --git a/README.md b/README.md index 76c286d..eaabf02 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Comprehensive information about platform strategies for managing DeFi assets. In * `getMerklStrategies()` * `getStrategyShortId(id: string): StrategyShortId|undefined` * `getStrategiesTotals(): {[state in StrategyState]: number}` +* `getStrategyProtocols(shortId: StrategyShortId): DeFiProtocol[]` ### #️⃣ Deployments @@ -122,6 +123,7 @@ DeFi organizations, protocols, their integration statuses, usage and other infor #### Methods * `getIntegrationStatus(p: DeFiProtocol): IntegrationStatus` +* `getChainProtocols(chainId: string): DeFiProtocol[]` ### 📌 Addresses diff --git a/package.json b/package.json index 4a1072a..c65adb5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stabilitydao/stability", - "version": "0.16.0", + "version": "0.16.1", "description": "Stability Integration Library", "main": "out/index.js", "types": "out/index.d.ts", diff --git a/src/bridges.ts b/src/bridges.ts index e8671dd..222ef4d 100644 --- a/src/bridges.ts +++ b/src/bridges.ts @@ -28,7 +28,7 @@ export const enum BridgeName { CORE_APP = 'Core Tools Bridge', MODE = 'Mode App', MANTLE = 'Mantle Bridge', - REAL = 're.al Bridge', + REAL = 'Re.al Bridge', } export const bridges: Bridge[] = [ diff --git a/src/index.ts b/src/index.ts index 5fa476b..1e8278b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,8 @@ import { DeFiOrganization, DeFiProtocol, IntegrationStatus, - getIntegrationStatus + getIntegrationStatus, + getChainProtocols } from "./integrations"; import {ApiMainReply, ApiAggSwapData, ApiPostBody, ApiPostReply, InteractionType} from "./api.types" import tokenlist from "./stability.tokenlist.json" @@ -64,6 +65,7 @@ export { getStrategyShortId, getStrategyProtocols, getIntegrationStatus, + getChainProtocols, getSupportedChainNames, assets, Asset, diff --git a/src/integrations.ts b/src/integrations.ts index 6b961ef..5334ac6 100644 --- a/src/integrations.ts +++ b/src/integrations.ts @@ -1,5 +1,5 @@ import {strategies, StrategyShortId, StrategyState} from "./strategies"; -import {ChainName, getSupportedChainNames} from "./chains"; +import {ChainName, chains, getSupportedChainNames} from "./chains"; export type DeFiOrganization = { name: string @@ -869,3 +869,18 @@ export const getIntegrationStatus = (p: DeFiProtocol): IntegrationStatus => { return isSupportedNetwork ? IntegrationStatus.POSSIBLE : IntegrationStatus.PROPOSED } + +export const getChainProtocols = (chainId: string): DeFiProtocol[] => { + const r: DeFiProtocol[] = [] + for (const orgSlug of Object.keys(integrations)) { + const org = integrations[orgSlug] + for (const protocolSlug of Object.keys(org.protocols)) { + const protocol = org.protocols[protocolSlug] + if (protocol.chains.includes(chains[chainId].name)) { + protocol.organization = orgSlug + r.push(protocol) + } + } + } + return r +} diff --git a/tests/integrations.test.ts b/tests/integrations.test.ts index edb91bc..ec368da 100644 --- a/tests/integrations.test.ts +++ b/tests/integrations.test.ts @@ -1,4 +1,4 @@ -import { getIntegrationStatus} from "../src"; +import {getChainProtocols, getIntegrationStatus} from "../src"; import {ChainName, strategies, StrategyShortId, StrategyState, DefiCategory, DeFiProtocol, IntegrationStatus} from "../src"; describe('testing integrations', () => { @@ -43,4 +43,8 @@ describe('testing integrations', () => { strategies[StrategyShortId.IQMF].state = StrategyState.PROPOSAL expect(getIntegrationStatus(protocol)).toBe(IntegrationStatus.AWAITING) }) + test('get chain protocols', () => { + const protocols = getChainProtocols("111188") + expect(protocols.length).toBeGreaterThan(3) + }) })