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

Add config quick select tokens for deposit/withdrawal forms #290

Merged
merged 2 commits into from
Dec 18, 2024
Merged
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
9 changes: 8 additions & 1 deletion .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
|`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 |
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
20 changes: 19 additions & 1 deletion configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
2 changes: 1 addition & 1 deletion configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,4 @@
"target_denom": "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f"
}
]
}
}
20 changes: 19 additions & 1 deletion configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
37 changes: 37 additions & 0 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading