Skip to content

Commit

Permalink
Merge pull request #41 from stabilitydao/dev
Browse files Browse the repository at this point in the history
0.18.0: contests
  • Loading branch information
a17 authored Oct 16, 2024
2 parents a0691f1 + 4d9002d commit 95fd894
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 4 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,28 @@ import {tokenlist} from '@stabilitydao/stability'

* `getChainBridges(chainName: ChainName): Bridge[]`

### 🏆 Contests

#### Types

* `YieldContest`
* `Reward`

#### Constants

* `contests: { [contestId: string]: YieldContest }`

#### Enums

* `enum RewardType`

## 👷 Develop

```shell
yarn overview
yarn overview-full
yarn draw-chains
yarn create-contests
yarn test
yarn coverage
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stabilitydao/stability",
"version": "0.17.1",
"version": "0.18.0",
"description": "Stability Integration Library",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand All @@ -22,7 +22,8 @@
"overview-full": "ts-node tools/overview-full.ts",
"postbuild": "shx cp src/*.tokenlist.json out/",
"draw-chains": "ts-node tools/draw-chains.ts",
"issue": "ts-node tools/issue.ts"
"issue": "ts-node tools/issue.ts",
"create-contests": "ts-node tools/create-contests.ts"
},
"devDependencies": {
"@types/jest": "^29.5.12",
Expand Down
142 changes: 142 additions & 0 deletions src/contests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import {ChainName} from "./chains";

export interface YieldContest {
// name of the contest
name: string,
// start timestamp
start: number,
// end timestamp
end: number,
// contest rewards
rewards: Reward[],
// integration of quest platform campaign
integration?: {
// Intract campaign id
intract?: string,
},
// XP multiplier
xpMultiplier?: number,
// image file in stabilitydao/.github/contests
img?: string,
// hidden service contest for devs
hidden?: boolean,
}

export interface Reward {
type: RewardType,
// number of winners
winners: number,
// reward per winner
winnerReward: number,
// contract of reward
contract?: {
chain: ChainName,
address: `0x${string}`,
tokenIds?: number[],
},
}

export enum RewardType {
// Any transferable ERC-20 token
// Intract: ERC20 Tokens (USDT, etc claimed on intract) + Custom FTs (claimed on our side)
ERC20 = 'ERC20 Token',
// any our (Vault Manager, Strategy Logic) or external (deployed on quest platform, etc) NFTs
NFT = 'NFTs',
// official points
POINTS = 'Points',
}

export const contests: { [contestId: string]: YieldContest } = {
"d1": {
// 10 Oct 2024 - 16 Oct 2024
name: 'Dev pre contest 1',
start: 1728518400, // Thu Oct 10 2024 00:00:00 GMT+0000
end: 1729123199, // Wed Oct 16 2024 23:59:59 GMT+0000
rewards: [], // no rewards
hidden: true,
},
"d2": {
// 17 Oct 2024 - 23 Oct 2024
name: 'Dev pre contest 2',
start: 1729123200, // Thu Oct 17 2024 00:00:00 GMT+0000
end: 1729727999, // Wed Oct 23 2024 23:59:59 GMT+0000
rewards: [], // no rewards
hidden: true,
},
"y1": {
// 24 Oct 2024 - 06 Nov 2024
name: "Yield Contest #1",
start: 1729728000, // Thu, 24 Oct 2024 00:00:00 GMT
end: 1730937599, // Wed, 06 Nov 2024 23:59:59 GMT
rewards:
[
{
type: RewardType.POINTS,
winners: 50,
winnerReward: 120,
},
],
},
"y2": {
// 07 Nov 2024 - 20 Nov 2024
name: "Yield Contest #2",
start: 1730937600, // Thu, 07 Nov 2024 00:00:00 GMT
end: 1732147199, // Wed, 20 Nov 2024 23:59:59 GMT
rewards: [
{
type: RewardType.POINTS,
winners: 50,
winnerReward: 130,
},
// 200 USDT
{
type: RewardType.ERC20,
winners: 20,
winnerReward: 10,
contract: {
chain: ChainName.POLYGON,
address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
},
},
],
},
"y3": {
// 21 Nov 2024 - 04 Dec 2024
name: "Yield Contest #3",
start: 1732147200, // Thu, 21 Nov 2024 00:00:00 GMT
end: 1733356799, // Wed, 04 Dec 2024 23:59:59 GMT
rewards: [
{
type: RewardType.POINTS,
winners: 100,
winnerReward: 100,
},
// 500 USDT
{
type: RewardType.ERC20,
winners: 50,
winnerReward: 10,
contract: {
chain: ChainName.POLYGON,
address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
},
},
// VaultManager
{
type: RewardType.NFT,
winners: 3,
winnerReward: 1,
contract: {
chain: ChainName.POLYGON,
address: "0x6008b366058B42792A2497972A3312274DC5e1A8",
tokenIds: [
30, // C-DAI-Y
28, // C-USDC-Y
21, // C-E-U-IQMF
]
},
},
],
},
}

2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {almFactories} from "./addresses";
import {assets, Asset, getAsset} from "./assets";
import {seeds} from "./seeds";
import {bridges, Bridge, BridgeName, getChainBridges} from "./bridges";
import {contests} from "./contests";

export {
deployments,
Expand Down Expand Up @@ -82,4 +83,5 @@ export {
Bridge,
BridgeName,
getChainBridges,
contests,
}
9 changes: 9 additions & 0 deletions tests/contests.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {contests} 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)
}
})
})
25 changes: 25 additions & 0 deletions tools/create-contests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {contests} from "../src";

const genTotal = 10
const WEEK = 86400 * 7
const PERIOD = 2 * WEEK

console.log(`=== 🏆 Create Contests`)
const curLen = Object.keys(contests).length
let lastId = Object.keys(contests)[curLen - 1]
let prevTs = contests[lastId].end
for (let i = +(lastId.replace('y', '') || 0) + 1; i < +(lastId.replace('y', '') || 0) + 1 + genTotal; i++) {
const start = prevTs + 1
const end = prevTs + PERIOD
const startDateArr = new Date(start * 1000).toUTCString().split(' ')
const endDateArr = new Date(end * 1000).toUTCString().split(' ')
const name = `Yield Contest #${i}`
const dates = `${startDateArr[1]} ${startDateArr[2]} ${startDateArr[3]} - ${endDateArr[1]} ${endDateArr[2]} ${endDateArr[3]}`
console.log(`"y${i}": \{
// ${dates}
name: "${name}",
start: ${start}, // ${new Date(start * 1000).toUTCString()}
end: ${end}, // ${new Date(end * 1000).toUTCString()}
\},`)
prevTs += PERIOD
}
12 changes: 11 additions & 1 deletion tools/overview-full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
integrations,
IntegrationStatus,
chains, seeds,
strategies, bridges
strategies, bridges, contests
} from "../src";
import {Table} from "console-table-printer";
import {version} from '../package.json';
Expand Down Expand Up @@ -101,3 +101,13 @@ for (const seedNode of seeds) {
console.log(seedNode)
}
console.log('')
// @ts-ignore
console.log(bold`=== Contests: ${Object.keys(contests).filter(c => !contests[c].hidden).length} ===`)
for (const contestId of Object.keys(contests).filter(c => !contests[c].hidden)) {
const contest = contests[contestId]
const startDateArr = new Date(contest.start * 1000).toUTCString().split(' ')
const endDateArr = new Date(contest.end * 1000).toUTCString().split(' ')
const dates = `${startDateArr[1]} ${startDateArr[2]} ${startDateArr[3]} - ${endDateArr[1]} ${endDateArr[2]} ${endDateArr[3]}`
console.log(`[${contestId}] ${contest.name}. ${dates}. Rewards: ${contest.rewards.map(r => r.type).join(', ')}.`)
}
console.log('')
3 changes: 2 additions & 1 deletion tools/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getSupportedChainNames,
integrations,
chains, seeds,
strategies, bridges
strategies, bridges, contests
} from "../src";
import {version} from '../package.json';
import tokenlist from '../src/stability.tokenlist.json'
Expand All @@ -32,4 +32,5 @@ console.log(`Chains: ${Object.keys(chains).length}. ChainLib: ${networkTotal.AWA
console.log(`DeFi organizations: ${Object.keys(integrations).length}. Protocols: ${protocolsTotal}.`)
console.log(`Assets: ${assets.length}. Tokenlist ${tokenlist.version.major}.${tokenlist.version.minor}.${tokenlist.version.patch}: ${tokenlist.tokens.length} tokens for ${tokenlist.tokens.map(t => t.chainId).filter((value, index, array) => array.indexOf(value) === index).length} chains.`)
console.log(`Seed nodes: ${seeds.length}`)
console.log(`Contests: ${Object.keys(contests).filter(c => !contests[c].hidden).length}`)
console.log(``)

0 comments on commit 95fd894

Please sign in to comment.