From 4a9c807dd636fdda5d0b78c48d3d5a17c2d6d633 Mon Sep 17 00:00:00 2001 From: thanhpn Date: Mon, 16 Dec 2024 14:44:12 +0700 Subject: [PATCH 1/2] Add config for quick select tokens --- .github/markets/pr_template.md | 9 ++++++++- README.md | 1 + config.schema.json | 22 ++++++++++++++++++++ configs/devnet.json | 20 +++++++++++++++++- configs/mainnet.json | 2 +- configs/testnet.json | 20 +++++++++++++++++- scripts/check_configs.ts | 37 ++++++++++++++++++++++++++++++++++ 7 files changed, 107 insertions(+), 4 deletions(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index 6ecb128..8058e56 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -29,6 +29,7 @@ Each json file under the [configs](../../configs) folder correspond to their res | `native_depositor_contracts_map` | `object` | false | Map of axelar connection ids to their respective native depositor contract addresses |`market_promo` |`MarketPromo` |false |Map of Objects that contains market promo parameters for each market |If the `market_promo` property is omitted, no promo will be shown. The key of each entry is the ids of the market with existing promo. | |`spot_pool_config` |`SpotPoolConfig` |false |Object that contains the config parameters for the [Spot Pools](https://app.dem.exchange/pools/spot) page on Demex | +|`quick_select_tokens` |`QuickSelectToken[]` |true |List of quick select tokens for deposit and withdrawal forms. | ## TransferDisabledTokens Data Structure |Field |Type |Required |Description |Notes | @@ -119,4 +120,10 @@ Each json file under the [configs](../../configs) folder correspond to their res ## SpotPoolConfig Data Structure |Field |Type |Required |Description |Notes | |---|---|---|---|---| -|`show_apr_tooltip` |`boolean` |true |Indicates whether or not to show the Annual Percentage Returns (APR) tooltip on [Spot Pools](https://app.dem.exchange/pools/spot) page | \ No newline at end of file +|`show_apr_tooltip` |`boolean` |true |Indicates whether or not to show the Annual Percentage Returns (APR) tooltip on [Spot Pools](https://app.dem.exchange/pools/spot) page | + +## QuickSelectToken Data Structure +|Field |Type |Required |Description |Notes | +|---|---|---|---|---| +|`label_denom` |`string` |true |The default token will be show on UI deposit/withdrawal forms | +|`target_denom` |`string` |true |The default token will be use to transfer in deposit/withdrawal | \ No newline at end of file diff --git a/README.md b/README.md index 0f7f551..ccb3137 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Currently, each JSON file contain the following data on its corresponding networ - cross selling source tokens - map of IBC channels for external IBC chains (such as Osmosis, Noble, etc.) - information about IBC tokens that are not added on chain or require packet forwarding +- default quick select tokens in deposit/withdrawal forms Additionally, the JSON file for mainnet contains the following data to support ongoing campaigns/promotions: - demex points config diff --git a/config.schema.json b/config.schema.json index 683a082..e8ca37a 100644 --- a/config.schema.json +++ b/config.schema.json @@ -515,6 +515,28 @@ "description": "Indicates whether or not to show APR tooltip on Spot Pools page" } } + }, + "quick_select_token": { + "type": "object", + "description": "Token denom for quick select in transfer form", + "required": ["label_denom", "target_denom"], + "properties": { + "label_denom": { + "type": "string", + "description": "Token denom to show on UI" + }, + "target_denom": { + "type": "string", + "description": "Token denom to use in transfer" + } + } + }, + "quick_select_tokens": { + "type": "array", + "description": "List of tokens for quick select in transfer form", + "items": { + "$ref": "#/$defs/quick_select_token" + } } } } diff --git a/configs/devnet.json b/configs/devnet.json index 86d3aff..b15a558 100644 --- a/configs/devnet.json +++ b/configs/devnet.json @@ -45,5 +45,23 @@ ], "spot_pool_config": { "show_apr_tooltip": false - } + }, + "quick_select_deposit_options": [ + { + "label_denom": "swth", + "target_denom" : "swth" + }, + { + "label_denom": "usdc", + "target_denom" : "usdc" + }, + { + "label_denom": "eth", + "target_denom" : "eth" + }, + { + "label_denom": "dai", + "target_denom" : "dai" + } + ] } \ No newline at end of file diff --git a/configs/mainnet.json b/configs/mainnet.json index 94b3eaf..3f6d81a 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -501,4 +501,4 @@ "target_denom": "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f" } ] -} \ No newline at end of file +} diff --git a/configs/testnet.json b/configs/testnet.json index 2d3c393..39e3b49 100644 --- a/configs/testnet.json +++ b/configs/testnet.json @@ -59,5 +59,23 @@ }, "spot_pool_config": { "show_apr_tooltip": false - } + }, + "quick_select_deposit_options": [ + { + "label_denom": "swth", + "target_denom" : "swth" + }, + { + "label_denom": "usdc", + "target_denom" : "usdc" + }, + { + "label_denom": "eth", + "target_denom" : "eth" + }, + { + "label_denom": "dai", + "target_denom" : "dai" + } + ] } diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index c13f7d3..76467b6 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -34,6 +34,7 @@ interface ConfigJSON { market_banners?: MarketBanner[]; market_promo?: {[marketId: string]: MarketPromo}; spot_pool_config?: SpotPoolConfig; + quick_select_deposit_options?: QuickSelectToken[]; } interface InvalidEntry { @@ -132,6 +133,11 @@ interface SpotPoolConfig { show_apr_tooltip: boolean; } +interface QuickSelectToken { + label_denom: string; + target_denom: string; +} + type OutcomeMap = { [key in CarbonSDK.Network]: boolean }; // true = success, false = failure const outcomeMap: OutcomeMap = { @@ -420,6 +426,32 @@ function isValidMarketPromo(marketPromo: {[marketId: string]: MarketPromo}, netw return true; } +function isValidQuickSelectTokens(quickSelectTokens: QuickSelectToken[], network: CarbonSDK.Network, denoms: string[]): boolean { + const duplicateQuickSelectTokens = checkDuplicateEntries(quickSelectTokens.map(token => token.label_denom)); + const invalidQuickSelectTokens = checkValidEntries(quickSelectTokens.map(token => token.label_denom), denoms); + + const invalidTargetTokens = checkValidEntries(quickSelectTokens.map(token => token.target_denom), denoms); + + if (duplicateQuickSelectTokens.status && duplicateQuickSelectTokens.entry) { + let listOfDuplicates: string = duplicateQuickSelectTokens.entry.join(", "); + console.error(`ERROR: ${network}.json has the following duplicated label token denoms: ${listOfDuplicates}. Please make sure to input each token only once in ${network}`); + return false; + } + + if (invalidQuickSelectTokens.status && invalidQuickSelectTokens.entry) { + let listOfInvalidTokens: string = invalidQuickSelectTokens.entry.join(", "); + console.error(`ERROR: ${network}.json has the following invalid label token denoms: ${listOfInvalidTokens}. Please make sure to only input valid token denoms in ${network}`); + return false; + } + + if (invalidTargetTokens.status && invalidTargetTokens.entry) { + let listOfInvalidTokens: string = invalidTargetTokens.entry.join(", "); + console.error(`ERROR: ${network}.json has the following invalid target token denoms: ${listOfInvalidTokens}. Please make sure to only input valid token denoms in ${network}`); + return false; + } + return true; +} + async function main() { for (const net of myArgs) { let network: CarbonSDK.Network; @@ -775,6 +807,11 @@ async function main() { const isDemexTradingLeagueConfigValid = isValidDemexTradingLeagueConfig(jsonData.demex_trading_league_config, network, marketIds, jsonData.blacklisted_markets, perpPoolIds, tokenSymbols) if (!isDemexTradingLeagueConfigValid) outcomeMap[network] = false; } + + // check for validate quick select tokens + if (jsonData.quick_select_deposit_options && !isValidQuickSelectTokens(jsonData.quick_select_deposit_options, network, tokens)) { + outcomeMap[network] = false; + } } } const outcomeArr = Object.values(outcomeMap); From a836a0ed7ab81c6386a4da49c1f67e8c4019e330 Mon Sep 17 00:00:00 2001 From: thanhpn Date: Tue, 17 Dec 2024 19:55:31 +0700 Subject: [PATCH 2/2] Address reviewser comments --- .github/markets/pr_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index 8058e56..8eb3771 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -126,4 +126,4 @@ Each json file under the [configs](../../configs) folder correspond to their res |Field |Type |Required |Description |Notes | |---|---|---|---|---| |`label_denom` |`string` |true |The default token will be show on UI deposit/withdrawal forms | -|`target_denom` |`string` |true |The default token will be use to transfer in deposit/withdrawal | \ No newline at end of file +|`target_denom` |`string` |true |The default token will be use to transfer in deposit/withdrawal |