Skip to content

Commit

Permalink
Add config for quick select tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhpn committed Dec 16, 2024
1 parent e72b263 commit d29c142
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 4 deletions.
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 |
|`transfer_quick_select_tokens` |`TransferQuickSelectTokens[]` |true |List quick select tokens for deposit and transfer. |

## 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 |

## TransferQuickSelectTokens Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`show` |`string` |true |The default token will be show on UI transfer/withdraw |
|`real` |`string` |true |The default token will be use to transfer/withdraw |
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"
}
}
},
"transfer_quick_select_token": {
"type": "object",
"description": "Token for quick select in transfer form",
"required": ["show", "real"],
"properties": {
"show": {
"type": "string",
"description": "Token to show on UI"
},
"real": {
"type": "string",
"description": "Token to use in transfer"
}
}
},
"transfer_quick_select_tokens": {
"type": "array",
"description": "List of tokens for quick select in transfer form",
"items": {
"$ref": "#/$defs/transfer_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
}
},
"transfer_quick_select_tokens": [
{
"show": "swth",
"real" : "swth"
},
{
"show": "usdc",
"real" : "usdc"
},
{
"show": "eth",
"real" : "eth"
},
{
"show": "dai",
"real" : "dai"
}
]
}
20 changes: 19 additions & 1 deletion configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,5 +477,23 @@
},
"spot_pool_config": {
"show_apr_tooltip": true
}
},
"transfer_quick_select_tokens": [
{
"show": "brdg/4b90a8d1225d11ed7af0661ff7309714189a527302892cad03ace7615d417d38",
"real" : "cgt/1"
},
{
"show": "swth",
"real" : "swth"
},
{
"show": "eth.1.2.942d87",
"real" : "eth.1.2.942d87"
},
{
"show": "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f",
"real" : "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
}
},
"transfer_quick_select_tokens": [
{
"show": "swth",
"real" : "swth"
},
{
"show": "usdc",
"real" : "usdc"
},
{
"show": "eth",
"real" : "eth"
},
{
"show": "dai",
"real" : "dai"
}
]
}
44 changes: 44 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;
transfer_quick_select_tokens?: TransferQuickSelectToken[];
}

interface InvalidEntry {
Expand Down Expand Up @@ -132,6 +133,11 @@ interface SpotPoolConfig {
show_apr_tooltip: boolean;
}

interface TransferQuickSelectToken {
show: string;
real: string;
}

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

const outcomeMap: OutcomeMap = {
Expand Down Expand Up @@ -420,6 +426,39 @@ function isValidMarketPromo(marketPromo: {[marketId: string]: MarketPromo}, netw
return true;
}

function isValidQuickSelectTokens(quickSelectTokens: TransferQuickSelectToken[], network: CarbonSDK.Network, denoms: string[]): boolean {
const duplicateQuickSelectTokens = checkDuplicateEntries(quickSelectTokens.map(token => token.show));
const invalidQuickSelectTokens = checkValidEntries(quickSelectTokens.map(token => token.show), denoms);

const duplicateRealTokens = checkDuplicateEntries(quickSelectTokens.map(token => token.real));
const invalidRealTokens = checkValidEntries(quickSelectTokens.map(token => token.real), denoms);

if (duplicateQuickSelectTokens.status && duplicateQuickSelectTokens.entry) {
let listOfDuplicates: string = duplicateQuickSelectTokens.entry.join(", ");
console.error(`ERROR: ${network}.json has the following duplicated quick select tokens: ${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 quick select token denoms: ${listOfInvalidTokens}. Please make sure to only input valid token denoms in ${network}`);
return false;
}

if (duplicateRealTokens.status && duplicateRealTokens.entry) {
let listOfDuplicates: string = duplicateRealTokens.entry.join(", ");
console.error(`ERROR: ${network}.json has the following duplicated real tokens: ${listOfDuplicates}. Please make sure to input each token only once in ${network}`);
return false;
}

if (invalidRealTokens.status && invalidRealTokens.entry) {
let listOfInvalidTokens: string = invalidRealTokens.entry.join(", ");
console.error(`ERROR: ${network}.json has the following invalid real 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 +814,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.transfer_quick_select_tokens && !isValidQuickSelectTokens(jsonData.transfer_quick_select_tokens, network, tokens)) {
outcomeMap[network] = false;
}
}
}
const outcomeArr = Object.values(outcomeMap);
Expand Down

0 comments on commit d29c142

Please sign in to comment.