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

0.16.1: implement getChainProtocols, minor fix #38

Merged
merged 1 commit into from
Oct 12, 2024
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -122,6 +123,7 @@ DeFi organizations, protocols, their integration statuses, usage and other infor
#### Methods

* `getIntegrationStatus(p: DeFiProtocol): IntegrationStatus`
* `getChainProtocols(chainId: string): DeFiProtocol[]`

### 📌 Addresses

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/bridges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -64,6 +65,7 @@ export {
getStrategyShortId,
getStrategyProtocols,
getIntegrationStatus,
getChainProtocols,
getSupportedChainNames,
assets,
Asset,
Expand Down
17 changes: 16 additions & 1 deletion src/integrations.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}
6 changes: 5 additions & 1 deletion tests/integrations.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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)
})
})
Loading