From 110df734947cd8f817f6183ff80ad575f4005e82 Mon Sep 17 00:00:00 2001 From: Jarrett0203 Date: Mon, 8 Jul 2024 12:34:15 +0800 Subject: [PATCH] Add promo markets and upgrade sdk --- .github/markets/pr_template.md | 1 + README.md | 6 ++++++ config.schema.json | 12 ++++++++++++ configs/devnet.json | 1 + configs/mainnet.json | 3 +++ configs/testnet.json | 3 +++ package.json | 4 ++-- scripts/check_configs.ts | 22 ++++++++++++++++++++++ yarn.lock | 8 ++++---- 9 files changed, 54 insertions(+), 6 deletions(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index ed4bd64..45021fd 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -7,6 +7,7 @@ Each json file under the [configs](../../configs) folder correspond to their res |---|---|---|---|---| |`network` |`string` |true |The network that the json file corresponds to |The networks available are: **mainnet, testnet, devnet** | |`prelaunch_markets` |`string[]` |true |The array of market names which are designated as Pre-Launch markets. When added to this list, the markets will have a `Pre-Launch` tag attached to it. |The market names listed here **MUST** match the market names listed under the Carbon [Markets API](https://api.carbon.network/carbon/market/v1/markets?pagination.limit=10000). | +|`promo_markets` |`string[]` |true |The array of market names which are designated as Promo markets. Mainly used to determine the markets for Demex Trading League. |The market names listed here **MUST** match the market names listed under the Carbon [Markets API](https://api.carbon.network/carbon/market/v1/markets?pagination.limit=10000). | |`blacklisted_markets` |`string[]` |true |The array of market names that are blacklisted. A market can be blacklisted for a number of reasons, such as it being invalid/duplicate/wrongly-added/etc. |The market names listed here **MUST** match the market names listed under the Carbon [Markets API](https://api.carbon.network/carbon/market/v1/markets?pagination.limit=10000). The market names listed here **CANNOT** be under the `prelaunch_markets` field at the same time. | |`blacklisted_pools` |`string[]` |true |The array of pool ids that are blacklisted. A pool can be blacklisted for a number of reasons, such as it being invalid/duplicate/wrongly-added/etc. |The pool ids listed here **MUST** match the pool ids listed under the Carbon [Liquidity Pool API](https://api.carbon.network/carbon/liquiditypool/v1/pools?pagination.limit=10000). | |`blacklisted_tokens` |`string[]` |true |The array of token denoms that are blacklisted. A token can be blacklisted for a number of reasons, such as it being invalid/deprecated/etc. |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | diff --git a/README.md b/README.md index b29a604..6fa0154 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ The config JSON schema can be found [here](/config.schema.json). Currently, each JSON file contain the following data on its corresponding network (mainnet, testnet, devnet): - list of pre-launch markets +- promo markets - blacklisted markets - blacklisted pools - blacklisted tokens @@ -25,6 +26,11 @@ More metadata will be added in the future if required by the Demex frontend. Ple "market_1", "market_2" ], + "promo_markets": [ + "promo_market_1", + "promo_market_2", + "promo_market_3" + ], "blacklisted_markets": [ "blacklisted_market_1", "blacklisted_market_2", diff --git a/config.schema.json b/config.schema.json index 61e0aa3..ae70009 100644 --- a/config.schema.json +++ b/config.schema.json @@ -5,6 +5,7 @@ "required": [ "network", "prelaunch_markets", + "promo_markets", "blacklisted_markets", "blacklisted_pools", "blacklisted_tokens", @@ -29,6 +30,13 @@ "$ref": "#/$defs/prelaunch_market" } }, + "promo_markets": { + "type": "array", + "description": "List of market names designated as Promo markets", + "items": { + "$ref": "#/$defs/promo_market" + } + }, "blacklisted_markets": { "type": "array", "description": "List of blacklisted market names", @@ -172,6 +180,10 @@ "type": "string", "description": "Market name of Pre-launch market" }, + "promo_market": { + "type": "string", + "description": "Market name of Promo market" + }, "blacklisted_market": { "type": "string", "description": "Blacklisted market name" diff --git a/configs/devnet.json b/configs/devnet.json index b38ffa1..92627d9 100644 --- a/configs/devnet.json +++ b/configs/devnet.json @@ -1,6 +1,7 @@ { "network": "devnet", "prelaunch_markets": [], + "promo_markets": [], "blacklisted_markets": [ "swth_btc2", "ETH_PERP.USDC", diff --git a/configs/mainnet.json b/configs/mainnet.json index 5431d80..159c94a 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -1,6 +1,9 @@ { "network": "mainnet", "prelaunch_markets": [], + "promo_markets": [ + "cmkt/201" + ], "blacklisted_markets": [ "gm1_busd1", "SWTH_UST", diff --git a/configs/testnet.json b/configs/testnet.json index e4fd90b..9625085 100644 --- a/configs/testnet.json +++ b/configs/testnet.json @@ -1,6 +1,9 @@ { "network": "testnet", "prelaunch_markets": [], + "promo_markets": [ + "ATOM_PERP.CGUSD" + ], "blacklisted_markets": [ "swth_btc", "swth_btc2", diff --git a/package.json b/package.json index 900c78d..24628b7 100644 --- a/package.json +++ b/package.json @@ -18,11 +18,11 @@ "@cosmjs/tendermint-rpc": "~0.31.3", "@types/node": "^18.11.9", "@types/node-fetch": "^2.6.2", - "carbon-js-sdk": "^0.10.5", + "carbon-js-sdk": "^0.11.1", "long": "^4.0.0", "node-fetch": "^2.6.1", "pajv": "^1.2.0", "ts-node": "^10.9.1", "typescript": "^4.9.3" } -} \ No newline at end of file +} diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index b915aaa..9dc8f21 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -8,6 +8,7 @@ const myArgs = process.argv.slice(2); interface ConfigJSON { network: CarbonSDK.Network; prelaunch_markets: string[]; + promo_markets: string[]; blacklisted_markets: string[]; blacklisted_pools: string[]; blacklisted_tokens: string[]; @@ -167,6 +168,13 @@ async function main() { outcomeMap[network] = false; } + const hasInvalidPromoMarkets = checkValidEntries(jsonData.promo_markets, markets); + if (hasInvalidPromoMarkets.status && hasInvalidPromoMarkets.entry) { + let listOfInvalidMarkets: string = hasInvalidPromoMarkets.entry.join(', '); + console.error(`ERROR: ${network}.json has the following invalid promo market entries: ${listOfInvalidMarkets}. Please make sure to only input valid markets in ${network}`); + outcomeMap[network] = false; + } + const hasInvalidBlacklistedMarkets = checkValidEntries(jsonData.blacklisted_markets, markets); if (hasInvalidBlacklistedMarkets.status && hasInvalidBlacklistedMarkets.entry) { let listOfInvalidMarkets: string = hasInvalidBlacklistedMarkets.entry.join(', '); @@ -182,6 +190,13 @@ async function main() { outcomeMap[network] = false; } + const hasDuplicatePromoMarkets = checkDuplicateEntries(jsonData.promo_markets); + if (hasDuplicatePromoMarkets.status && hasDuplicatePromoMarkets.entry) { + let listOfDuplicates: string = hasDuplicatePromoMarkets.entry.join(", "); + console.error(`ERROR: ${network}.json has the following duplicated promo market entries: ${listOfDuplicates}. Please make sure to only input each market once in ${network}`); + outcomeMap[network] = false; + } + const hasDuplicateBlacklistedMarkets = checkDuplicateEntries(jsonData.blacklisted_markets); if (hasDuplicateBlacklistedMarkets.status && hasDuplicateBlacklistedMarkets.entry) { let listOfDuplicates: string = hasDuplicateBlacklistedMarkets.entry.join(", "); @@ -197,6 +212,13 @@ async function main() { outcomeMap[network] = false; } + const hasBlacklistedMarketsInPromo = checkBlacklistedMarkets(jsonData.promo_markets, jsonData.blacklisted_markets); + if (hasBlacklistedMarketsInPromo.status && hasBlacklistedMarketsInPromo.entry) { + let listOfBlacklistedMarkets: string = hasBlacklistedMarketsInPromo.entry.join(", "); + console.error(`ERROR: ${network}.json has the following blacklisted market entries in promo markets entries: ${listOfBlacklistedMarkets}. Please make sure that blacklisted markets are not found in promo markets in ${network}`); + outcomeMap[network] = false; + } + // query all liquidity pools const allPools = await sdk.query.liquiditypool.PoolAll({ pagination: { diff --git a/yarn.lock b/yarn.lock index 4ab090a..c63cb1a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1702,10 +1702,10 @@ camelcase@^6.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -carbon-js-sdk@^0.10.5: - version "0.10.5" - resolved "https://registry.yarnpkg.com/carbon-js-sdk/-/carbon-js-sdk-0.10.5.tgz#61e3afe83eef163d0baba0da861556494b3e0a94" - integrity sha512-G+OLLt4G2u6e+mg7JOJrCgADivlgTFf2uRb+vvH7dq4HBA6bAAJHfoNTo4B5h10UC2Ma0BVanJ9CO/U+uY5Rqw== +carbon-js-sdk@^0.11.1: + version "0.11.1" + resolved "https://registry.yarnpkg.com/carbon-js-sdk/-/carbon-js-sdk-0.11.1.tgz#d61f446d61161c5b0be613848ec97f229c7d0ec3" + integrity sha512-MMt/JbcqCPMxXqSvyoC7R87uMe5ZEa3K5qtZ9VSeG0O+P1jMENuNswMQWSMK+RESYITAbGj8rpe3HYXwvyR5qQ== dependencies: "@cityofzion/neon-api" "^4.9.0" "@cityofzion/neon-core" "^4.9.0"