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

Feat: nps config #327

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`disabled_transfer_banner_config` |`DisabledTransferBannerConfig` |false |Config parameters for displaying banner to inform users that transfers for the relevant tokens are disabled |
|`trading_leagues` |`TradingLeague[]` |false |Map of trading league config with their path. |
|`lst_native_aprs` |`LSTNativeAPR[]` |false |List of LST native APR APIs. |
|`nps_config` | `NPSConfig` | false | Config parameters for managing NPS survey |

## Maintenance Data Structure
|Field |Type |Required |Description |Notes |
Expand Down Expand Up @@ -155,3 +156,8 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`api_url` |`string` |true |The API to fetch LST Native APR |
|`lst_denoms` |`object` |true |The key value object for mapping denom of protocol api and carbon lst denom |

## NPSConfig Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`start` |`string` |false |Start time of the NPS survey | This field **MUST** follow the valid ISO 8601 format <br /> e.g. *2024-01-23T09:00+00:00* (23 Jan 2024, 9am UTC) |
|`end` |`string` |true |End time of the NPS survey | This field **MUST** follow the valid ISO 8601 format <br /> e.g. *2024-01-23T09:00+00:00* (23 Jan 2024, 9am UTC) |
15 changes: 14 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,19 @@
"items": {
"$ref": "#/$defs/lst_native_apr"
}
},
"nps_config": {
"type": "object",
"description": "Config parameters for managing NPS survey",
"required": ["end"],
"properties": {
"start": {
"$ref": "#/$defs/start"
},
"end": {
"$ref": "#/$defs/end"
}
}
}
}
}
}
5 changes: 4 additions & 1 deletion configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@
"label_denom": "dai",
"target_denom" : "dai"
}
]
],
"nps_config": {
"end": "2025-02-16T12:00:00Z"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add start time also

}
}
5 changes: 4 additions & 1 deletion configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,5 +547,8 @@
"milkTIA": "ibc/16065EE5282C5217685C8F084FC44864C25C706AC37356B0D62811D50B96920F"
}
}
]
],
"nps_config": {
"end": "2025-02-16T12:00:00Z"
}
}
27 changes: 6 additions & 21 deletions configs/testnet.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"network": "testnet",
"prelaunch_markets": [],
"blacklisted_markets": [
"swth_btc",
"swth_btc2",
"swth_nex",
"swth_nexo",
"swth_dai"
],
"blacklisted_markets": [],
"blacklisted_pools": [],
"blacklisted_tokens": [],
"transfer_options": {},
Expand All @@ -28,7 +22,7 @@
"external_chain_channels": {},
"additional_ibc_token_config": [],
"demex_trading_league_config": {
"promoMarkets": ["ATOM_PERP.CGUSD"],
"promoMarkets": [],
"currentPrizeSymbol": "USDC",
"currentCompPerpPoolId": 1
},
Expand Down Expand Up @@ -66,18 +60,9 @@
{
"label_denom": "swth",
"target_denom" : "swth"
},
{
"label_denom": "usdc",
"target_denom" : "usdc"
},
{
"label_denom": "eth",
"target_denom" : "eth"
},
{
"label_denom": "dai",
"target_denom" : "dai"
}
]
],
"nps_config": {
"end": "2025-02-16T12:00:00Z"
}
}
23 changes: 23 additions & 0 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface ConfigJSON {
announcement_banner: AnnouncementBanner;
quick_select_deposit_options?: QuickSelectToken[];
lst_native_aprs?: LstNativeAPR[];
nps_config?: NPSConfig;
}

interface InvalidEntry {
Expand Down Expand Up @@ -162,6 +163,11 @@ interface LstNativeAPR {
lst_denoms: SimpleMap<string>;
}

interface NPSConfig {
start?: string;
end: string;
}

type OutcomeMap = { [key in CarbonSDK.Network]: boolean }; // true = success, false = failure

const outcomeMap: OutcomeMap = {
Expand Down Expand Up @@ -530,6 +536,19 @@ function isValidLSTNativeDenom(lstNativeAPRs: LstNativeAPR[], network: CarbonSDK
return true;
}

function isValidNPSConfig(npsConfig: NPSConfig, network: CarbonSDK.Network): boolean {
const { start, end } = npsConfig;
if (start && end) {
const startTime = new Date(start);
const endTime = new Date(end);
if (endTime < startTime) {
console.error(`ERROR: nps_config.end is before nps_config.start in ${network}.json`);
return false;
}
}
return true;
}

async function main() {
for (const net of myArgs) {
let network: CarbonSDK.Network;
Expand Down Expand Up @@ -925,6 +944,10 @@ async function main() {
if (jsonData.lst_native_aprs && !isValidLSTNativeDenom(jsonData.lst_native_aprs, network, tokens)) {
outcomeMap[network] = false;
}
// check for NPS config
if (jsonData.nps_config && !isValidNPSConfig(jsonData.nps_config, network)) {
outcomeMap[network] = false;
}
}
}
const outcomeArr = Object.values(outcomeMap);
Expand Down
Loading