From 4d9002d89eac02afbcd8741be5fcf5413bd393bc Mon Sep 17 00:00:00 2001 From: Alien Deployer Date: Wed, 16 Oct 2024 03:35:27 +0300 Subject: [PATCH] 0.18.0: contests --- README.md | 16 +++++ package.json | 5 +- src/contests.ts | 142 +++++++++++++++++++++++++++++++++++++++ src/index.ts | 2 + tests/contests.test.ts | 9 +++ tools/create-contests.ts | 25 +++++++ tools/overview-full.ts | 12 +++- tools/overview.ts | 3 +- 8 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 src/contests.ts create mode 100644 tests/contests.test.ts create mode 100644 tools/create-contests.ts diff --git a/README.md b/README.md index 6f96f0d..2d8fcf5 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/package.json b/package.json index 3d7e543..c1970ea 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/contests.ts b/src/contests.ts new file mode 100644 index 0000000..9c548f8 --- /dev/null +++ b/src/contests.ts @@ -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 + ] + }, + }, + ], + }, +} + diff --git a/src/index.ts b/src/index.ts index 770044e..99b538d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, @@ -82,4 +83,5 @@ export { Bridge, BridgeName, getChainBridges, + contests, } diff --git a/tests/contests.test.ts b/tests/contests.test.ts new file mode 100644 index 0000000..758cadf --- /dev/null +++ b/tests/contests.test.ts @@ -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) + } + }) +}) diff --git a/tools/create-contests.ts b/tools/create-contests.ts new file mode 100644 index 0000000..889b586 --- /dev/null +++ b/tools/create-contests.ts @@ -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 +} diff --git a/tools/overview-full.ts b/tools/overview-full.ts index fdb5920..dd5abcb 100644 --- a/tools/overview-full.ts +++ b/tools/overview-full.ts @@ -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'; @@ -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('') diff --git a/tools/overview.ts b/tools/overview.ts index c77a302..e3ba673 100644 --- a/tools/overview.ts +++ b/tools/overview.ts @@ -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' @@ -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(``)