Skip to content

Commit

Permalink
Merge pull request #49 from stabilitydao/dev
Browse files Browse the repository at this point in the history
0.18.3
  • Loading branch information
a17 authored Oct 18, 2024
2 parents 0f2a044 + 6dd0ede commit 4f360f3
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Blockchains known to the platform and their integration statuses. Each chain has

* `getSupportedChainNames(): ChainName[]`
* `getChainsTotals(): {[status in ChainStatus]: number}`
* `getChainByName(chainName: ChainName): Chain`

### 🌐 Integrations

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.18.2",
"version": "0.18.3",
"description": "Stability Integration Library",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down
10 changes: 10 additions & 0 deletions src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,13 @@ export const getChainsTotals = (): { [status in ChainStatus]: number } => {
[ChainStatus.NOT_SUPPORTED]: ids.filter(networkId => chains[networkId].status == ChainStatus.NOT_SUPPORTED).length,
}
}

export const getChainByName = (chainName: ChainName): Chain => {
for (const chainId in chains) {
const chain = chains[chainId]
if (chain && chain.name === chainName) {
return chain
}
}
throw new Error(`Incorrect chain name ${chainName}`)
}
21 changes: 19 additions & 2 deletions src/contests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export interface YieldContest {
start: number,
// end timestamp
end: number,
minEarn: number,
// minimal USD income to pass contest
minEarn: number|"TBA",
// contest rewards
rewards: Reward[],
rewards: Reward[]|"TBA",
// integration of quest platform campaign
integration?: {
// Intract campaign id
Expand Down Expand Up @@ -144,4 +145,20 @@ export const contests: { [contestId: string]: YieldContest } = {
},
],
},
"y4": {
// 05 Dec 2024 - 18 Dec 2024
name: "Yield Contest #4",
start: 1733356800, // Thu, 05 Dec 2024 00:00:00 GMT
end: 1734566399, // Wed, 18 Dec 2024 23:59:59 GMT
minEarn: "TBA",
rewards: "TBA",
},
"y5": {
// 19 Dec 2024 - 01 Jan 2025
name: "Yield Contest #5",
start: 1734566400, // Thu, 19 Dec 2024 00:00:00 GMT
end: 1735775999, // Wed, 01 Jan 2025 23:59:59 GMT
minEarn: "TBA",
rewards: "TBA",
},
}
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Chain,
ChainStatusInfo,
getSupportedChainNames,
getChainsTotals
getChainsTotals,
getChainByName
} from "./chains";
import {
strategies,
Expand Down Expand Up @@ -71,6 +72,7 @@ export {
getChainProtocols,
getChainStrategies,
getSupportedChainNames,
getChainByName,
assets,
Asset,
getAsset,
Expand Down
19 changes: 19 additions & 0 deletions tests/chains.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {ChainName, getChainByName, getChainsTotals, getSupportedChainNames} from "../src";

describe('testing chains', () => {
test('get supported chain names', () => {
expect(getSupportedChainNames().length).toBeGreaterThan(1)
})
test('getChainsTotals', () => {
const s = getChainsTotals()
expect(s.SUPPORTED).toBeGreaterThan(1)
})
test('getChainByName', () => {
let s = getChainByName(ChainName.POLYGON)
expect(s.name).toEqual("Polygon")
const t = () => {
s = getChainByName('incorrect' as ChainName)
};
expect(t).toThrow(Error);
})
})
6 changes: 5 additions & 1 deletion tests/contests.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {contests} from "../src";
import {contests, Reward, RewardType, YieldContest} from "../src";

describe('testing contests', () => {
test('check start less then end', () => {
for (const contestId of Object.keys(contests)) {
expect(contests[contestId].start).toBeLessThan(contests[contestId].end)
}
})
test('types', () => {
const c: YieldContest = contests["y1"]
expect((c.rewards[0] as Reward).type).toEqual(RewardType.POINTS)
})
})
11 changes: 0 additions & 11 deletions tests/networks.test.ts

This file was deleted.

2 changes: 2 additions & 0 deletions tools/create-contests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ for (let i = +(lastId.replace('y', '') || 0) + 1; i < +(lastId.replace('y', '')
name: "${name}",
start: ${start}, // ${new Date(start * 1000).toUTCString()}
end: ${end}, // ${new Date(end * 1000).toUTCString()}
minEarn: "TBA",
rewards: "TBA",
\},`)
prevTs += PERIOD
}

0 comments on commit 4f360f3

Please sign in to comment.