Skip to content

Commit

Permalink
Merge branch 'master' into feat/custom-announcement-banner-
Browse files Browse the repository at this point in the history
  • Loading branch information
huy9x101 committed Dec 18, 2024
2 parents 453f449 + 9f4bb85 commit f7e9329
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .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 @@ -130,3 +131,9 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`content` |`string` |true |The content shown on the market banner. |
|`hideable` |`boolean` |false |Indicates if user can hide the banner by clicking on the close button |If set to `false`, the close button will not be rendered on the banner, and user will not be able to dismiss the banner. |
|`show_only_on` |`string[]` |true |Default is empty list, then banner will be shown on all pages |If list has specified path(s), the banner will be shown on these/that path(s) only, sample: `['/rewards', '/nitron']` |

## 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 @@ -562,6 +562,28 @@
"minItems": 0
}
}
},
"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 @@ -55,5 +55,23 @@
"/rewards",
"/nitron"
]
}
},
"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"
}
]
}
42 changes: 30 additions & 12 deletions configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@
"ibc/75249A18DEFBEFE55F83B1C70CAD234DF164F174C6BC51682EE92C2C81C18C93": 11,
"ibc/B7864B03E1B9FD4F049243E92ABD691586F682137037A9F3FCA5222815620B3C": 12,
"ibc/4E06CF24FEBFB3F5AF645377DCC0B70AA6183BAF6B918B8B6243FCDEB7D38118": 13,
"usdc.1.6.53ff75": 15,
"busd.1.6.754a80": 16,
"eth.1.19.c3b805": 17,
"cglp.1.19.1698d3": 18,
"zil.1.18.1a4a06": 19,
"bneo.1.14.e2e5f6": 20,
"eth.1.2.942d87": 21,
"usdc.1.2.343151": 22
"usdc.1.6.53ff75": 14,
"busd.1.6.754a80": 15,
"eth.1.19.c3b805": 16,
"cglp.1.19.1698d3": 17,
"zil.1.18.1a4a06": 18,
"bneo.1.14.e2e5f6": 19,
"eth.1.2.942d87": 20,
"usdc.1.2.343151": 21
},
"spot_history_market_list": {
"cmkt/117": "BINANCE:ETHUSD",
Expand Down Expand Up @@ -468,9 +468,9 @@
},
"market_banners": [
{
"market_id": "cmkt/246",
"content": "This is a pre-launch perp for Hyperliquid's HYPE and assumes a total supply of 1 billion. [Learn more.](https://guide.dem.exchange/trade/futures/market-specifications/pre-launch-perpetuals)",
"show_from": "2024-11-04T09:00+00:00"
"market_id": "cmkt/253",
"content": "Trade Pudgy Penguins floor price movements without owning the NFT. This market is based on the floor price of the Pudgy Penguins NFT collection, aggregated from top NFT marketplaces, denominated in USD.",
"show_from": "2024-12-06T09:00+00:00"
}
],
"market_promo": {
Expand All @@ -489,5 +489,23 @@
"content": "",
"hideable": true,
"show_only_on": []
}
},
"quick_select_deposit_options": [
{
"label_denom": "brdg/d8c3db91ad4ba11fe52971b4c387b0110c8951ec0f5b8f0fb445ef0306a349e1",
"target_denom": "cgt/1"
},
{
"label_denom": "swth",
"target_denom": "swth"
},
{
"label_denom": "eth.1.2.942d87",
"target_denom": "eth.1.2.942d87"
},
{
"label_denom": "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f",
"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 @@ -66,5 +66,23 @@
"content": "",
"hideable": true,
"show_only_on": []
}
},
"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 @@ -35,6 +35,7 @@ interface ConfigJSON {
market_promo?: {[marketId: string]: MarketPromo};
spot_pool_config?: SpotPoolConfig;
announcement_banner: AnnouncementBanner;
quick_select_deposit_options?: QuickSelectToken[];
}

interface InvalidEntry {
Expand Down Expand Up @@ -141,6 +142,11 @@ interface AnnouncementBanner {
show_only_on: string[];
}

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 @@ -443,6 +449,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 @@ -802,6 +834,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

0 comments on commit f7e9329

Please sign in to comment.