Skip to content

Commit

Permalink
Merge from master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Minh Đức Đào authored and Minh Đức Đào committed Nov 4, 2024
2 parents f1ae1c9 + 741189c commit 0d72d29
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 48 deletions.
12 changes: 11 additions & 1 deletion .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`demex_trading_league_config` |`DemexTradingLeagueConfig` |false |Object that contains the parameters for the current trading league. |
|`perp_pools` |`PerpPoolConfig` |false |Object that contains the configs for Perp Pools |
|`wswth_contract` |`string` |false |wSWTH ERC-20 contract. |
|`market_banners` |`MarketBanner[]` |true |market banner configs. |

## Maintenance Data Structure
|Field |Type |Required |Description |Notes |
Expand Down Expand Up @@ -85,4 +86,13 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`title` |`string` |true |The title shown on the perp pool banner. |
|`removed_markets` |`string` |false |The message describing markets being removed, shown below the perp-pool banner title. | e.g. "BTCETH Perp will be removed on 6 Mar, 09:00AM UTC". If the field is omitted, no message describing markets being removed will be shown. |
|`added_markets` |`string` |false |The message describing markets being added, shown below the markets being removed (if any). | e.g. "ATOM Perp & SOL Perp will be added on 8 Mar, 12:00AM UTC". If the field is omitted, no message describing markets being added will be shown. |
|`subtext` |`string` |false |The subtext shown on the perp pool banner (below the removed and added market descriptions). |
|`subtext` |`string` |false |The subtext shown on the perp pool banner (below the removed and added market descriptions). |

## MarketBanner
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`market_id` |`string` |true |Market id where the banner will be shown. |Market id **MUST** match one of the existing market ids from the Market MarketAll RPC call.<br /><br /> To view the values of MarketAll RPC call, simply run `yarn get-market-ids [network]` on the command line. Sample for mainnet: `yarn get-market-ids mainnet` |
|`show_from` |`string` |false |The date and time when the market banner is scheduled to begin displaying. |If not provided, the banner will be shown immediately.<br /><br /> This field **MUST** follow the valid ISO 8601 format <br /> e.g. *2024-01-23T09:00+00:00* (23 Jan 2024, 9am UTC) |
|`show_until` |`string` |false |The date and time when the market banner is scheduled to stop displaying. |If not provided, the banner will continue to display indefinitely.<br /><br /> This field **MUST** follow the valid ISO 8601 format <br /> e.g. *2024-01-23T09:00+00:00* (23 Jan 2024, 9am UTC) |
|`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. |
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Additionally, the JSON file for mainnet contains the following data to support o
- config for the Demex Trading League competition
- perp pool promotion parameters
- typeform survey parameters
- market banner parameters for information banners to be displayed on the TradingView charts on Trade UI

More metadata will be added in the future if required by the Demex frontend. Please see below the structure of the JSON file:

Expand Down
44 changes: 42 additions & 2 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,34 @@
"type": "string",
"description": "ERC-20 contract for wrapped SWTH"
},
"market_banners": {
"type": "array",
"description": "List of banner information to be displayed over the TradingView chart for the required market",
"items": {
"type": "object",
"required": [
"market_id",
"content"
],
"properties": {
"market_id": {
"$ref": "#/$defs/market_id"
},
"show_from": {
"$ref": "#/$defs/show_from"
},
"show_until": {
"$ref": "#/$defs/show_until"
},
"content": {
"$ref": "#/$defs/content"
},
"hideable": {
"$ref": "#/$defs/hideable"
}
}
}
},
"$defs": {
"prelaunch_market": {
"type": "string",
Expand Down Expand Up @@ -279,7 +307,7 @@
"type": "string",
"description": "The message shown on the banner describing markets being added"
},
"subtext": {
"subtext": {
"type": "string",
"description": "The subtext shown on the banner"
},
Expand Down Expand Up @@ -310,6 +338,18 @@
"description": "The end time of the tyepform survey",
"pattern": "^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$"
},
"market_id": {
"type": "string",
"description": "Market id (type: string)"
},
"hideable": {
"type": "boolean",
"description": "Whether the banner can be hidden by the user"
},
"content": {
"type": "string",
"description": "The content shown on the banner, we can render hyperlink in the content eg: You can visit [here](url)"
},
"additional_ibc_token_info": {
"type": "object",
"description": "Information for token that (1) is not added on Carbon blockchain or (2) requires packet forwarding.",
Expand Down Expand Up @@ -389,4 +429,4 @@
}
}
}
}
}
11 changes: 10 additions & 1 deletion configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,14 @@
},
"cross_selling_source_tokens": [],
"external_chain_channels": {},
"additional_ibc_token_config": []
"additional_ibc_token_config": [],
"market_banners": [
{
"market_id": "swth_dai",
"show_from": "2024-09-30T08:00+00:00",
"show_until": "2024-10-30T08:00+00:00",
"content": "Hello World",
"hideable": true
}
]
}
86 changes: 52 additions & 34 deletions configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,33 @@
"usdc.1.6.e70e14"
],
"transfer_options": {
"Osmosis": 0,
"Noble": 1,
"Cosmos Hub": 2,
"Evmos": 3,
"Axelar": 4,
"Juno": 5,
"Stride": 6,
"Kujira": 7,
"Terra": 8,
"Comdex": 9,
"Stafihub": 10,
"Persistence Core": 11,
"Stargaze": 12,
"Canto": 13,
"Sommelier": 14,
"IRIS Hub": 15,
"Ethereum": 16,
"Arbitrum": 17,
"Polygon": 18,
"OKC": 19,
"Binance Smart Chain": 20,
"Carbon": 21,
"Neo": 22,
"Neo3": 23,
"Zilliqa": 24
"Mantle": 0,
"Base": 1,
"Osmosis": 2,
"Noble": 3,
"Cosmos Hub": 4,
"Evmos": 5,
"Axelar": 6,
"Juno": 7,
"Stride": 8,
"Kujira": 9,
"Terra": 10,
"Comdex": 11,
"Stafihub": 12,
"Persistence Core": 13,
"Stargaze": 14,
"Canto": 15,
"Sommelier": 16,
"IRIS Hub": 17,
"Ethereum": 18,
"Arbitrum": 19,
"Polygon": 20,
"OKC": 21,
"Binance Smart Chain": 22,
"Carbon": 23,
"Neo": 24,
"Neo3": 25,
"Zilliqa": 26
},
"network_fees": {
"swth": 0,
Expand Down Expand Up @@ -116,7 +118,7 @@
"cmkt/226": "BINANCE:SOLETH",
"cmkt/235": "BINANCE:NEIROETHUSDT.P",
"cmkt/237": "CRYPTO:KASUSD",
"cmkt/244": "OKX:GRASSUSDT",
"cmkt/244": "BYBIT:GRASSUSDT",
"cmkt/245": "BINANCE:GOATUSDT.P"
},
"perp_pool_pie_chart_colors": {
Expand Down Expand Up @@ -200,33 +202,39 @@
"cmkt/243": "#f80cb4",
"cmkt/244": "#aaec0f",
"cmkt/245": "#59615e",
"cmkt/246": "#96fde4",
"Unused": "#7798E4"
},
"markets_override": {
"cmkt/181": {
"base": {
"symbol": "1000PEPE"
}
},
"groupQuantity": 1000
},
"cmkt/202": {
"base": {
"symbol": "1000SHIB"
}
},
"groupQuantity": 1000
},
"cmkt/207": {
"base": {
"symbol": "1000BONK"
}
},
"groupQuantity": 1000
},
"cmkt/209": {
"base": {
"symbol": "1000FLOKI"
}
},
"groupQuantity": 1000
},
"cmkt/215": {
"base": {
"symbol": "1MMOG"
}
},
"groupQuantity": 1000000
}
},
"demex_points_config": {
Expand Down Expand Up @@ -366,7 +374,8 @@
"0xF1bE2Db4A62e3AeDEd389224B15b370E27e1e9A1",
"0x6a09bC65Ef703466187f59083239399e1948fEbB",
"0x8c6A1123744a78bf48B7b58Ae0ce02F364c30F8e",
"0x4Ea7639a37d229914F64e832bF5038Bc634E51Fd"
"0x4Ea7639a37d229914F64e832bF5038Bc634E51Fd",
"0x88c49cd7F44C611c4DF37a605843284eEf5583Eb"
]
},
"banners": [
Expand All @@ -379,7 +388,15 @@
"past_tense_text": "GRASS (Grass) perp was added to this pool on 28 Oct 02:00 PM UTC."
},
{
"perp_pool_id": "8",
"perp_pool_id": "10",
"show_until": "2025-12-30T08:00+00:00",
"title": "New Markets Added",
"added_markets": "HYPE (Hyperliquid) pre-launch perp will be added to this pool on 4 Nov 08:00 AM UTC. Learn about pre-launch perps here: https://guide.dem.exchange/trade/futures/market-specifications/pre-launch-perpetuals.",
"action_trigger_date": "2024-11-04T08:00+00:00",
"past_tense_text": "HYPE (Hyperliquid) pre-launch perp was added to this pool on 4 Nov 08:00 AM UTC. Learn about pre-launch perps here: https://guide.dem.exchange/trade/futures/market-specifications/pre-launch-perpetuals."
},
{
"perp_pool_id": "7",
"show_until": "2024-11-14T08:00+00:00",
"title": "New Markets Added",
"added_markets": "GOAT (Goatseus Maximus) perp will be added to this pool on 29 Oct 08:00 AM UTC.",
Expand All @@ -403,5 +420,6 @@
"tokenAddress": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000"
}
},
"native_depositor_contract": "0xd91a2AcbE1f9635277120fc200F73574f1Cdad65"
"native_depositor_contract": "0xd91a2AcbE1f9635277120fc200F73574f1Cdad65",
"market_banners": []
}
14 changes: 12 additions & 2 deletions configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"cmkt/13": {
"base": {
"symbol": "1000PEPE"
}
},
"groupQuantity": 1000
}
},
"cross_selling_source_tokens": ["swth"],
Expand All @@ -38,5 +39,14 @@
},
"banners": []
},
"wswth_contract": "0xb4A23b09eBBA7dbA01A7bF95EFd41b3600fF22F9"
"wswth_contract": "0xb4A23b09eBBA7dbA01A7bF95EFd41b3600fF22F9",
"market_banners": [
{
"market_id": "cmkt/2",
"show_from": "2024-09-30T08:00+00:00",
"show_until": "2024-10-30T08:00+00:00",
"content": "Hello World",
"hideable": true
}
]
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
"upgrade-sdk": "yarn upgrade carbon-js-sdk@latest",
"get-bridges": "ts-node scripts/get_all_bridges",
"get-min-gas-prices": "ts-node scripts/get_all_network_fees",
"get-perp-pool-ids": "ts-node scripts/get_perp_pool_ids"
"get-perp-pool-ids": "ts-node scripts/get_perp_pool_ids",
"get-market-ids": "ts-node scripts/get_market_ids"
},
"dependencies": {
"@cosmjs/tendermint-rpc": "~0.31.3",
"@types/node": "^18.11.9",
"@types/node-fetch": "^2.6.2",
"carbon-js-sdk": "^0.11.20",
"carbon-js-sdk": "^0.11.23",
"long": "^4.0.0",
"node-fetch": "^2.6.1",
"pajv": "^1.2.0",
Expand Down
38 changes: 36 additions & 2 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ interface ConfigJSON {
additional_ibc_token_config: AdditionalIbcTokenConfigItem[];
demex_trading_league_config?: DemexTradingLeagueConfig;
perp_pools: PerpPoolConfig;
wswth_contract?: string
wswth_contract?: string;
market_banners?: MarketBanner[];
}

interface InvalidEntry {
Expand Down Expand Up @@ -100,6 +101,14 @@ interface PerpPoolConfig {
banners: PerpPoolBanner[]
}

interface MarketBanner {
market_id: string;
show_from?: string;
show_until?: string;
content: string;
hideable?: boolean;
}

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

const outcomeMap: OutcomeMap = {
Expand Down Expand Up @@ -280,6 +289,25 @@ function isValidDemexTradingLeagueConfig(
return true;
}

function isValidMarketBanners(marketBanners: MarketBanner[], network: CarbonSDK.Network, marketIds: string[]): boolean {
const marketBannerIds = marketBanners.map((banner) => banner.market_id);
const hasInvalidMarketBannerIds = checkValidEntries(marketBannerIds, marketIds);
const hasDuplicateMarketBannerIds = checkDuplicateEntries(marketBannerIds);

if (hasInvalidMarketBannerIds.status && hasInvalidMarketBannerIds.entry) {
let listOfInvalidIds: string = hasInvalidMarketBannerIds.entry.join(", ");
console.error(`ERROR: ${network}.json has the following invalid market ids under the market_banners field: ${listOfInvalidIds}`);
return false;
}

if (hasDuplicateMarketBannerIds.status && hasDuplicateMarketBannerIds.entry) {
let listOfDuplicates: string = hasDuplicateMarketBannerIds.entry.join(", ");
console.error(`ERROR: ${network}.json has duplicated market banners for the following market ids: ${listOfDuplicates}. Please make sure to add only 1 market banner for each market id in ${network}.json`);
return false;
}
return true;
}

async function main() {
for (const net of myArgs) {
let network: CarbonSDK.Network;
Expand Down Expand Up @@ -419,7 +447,9 @@ async function main() {
const transferOptionsArr = Object.keys(jsonData.transfer_options)
const ibcBridgeNames = sdk.token.getIbcBlockchainNames();
if (!ibcBridgeNames.includes("Carbon")) ibcBridgeNames.push("Carbon");
const validTransferOptionChains = sdk.token.getPolynetworkBlockchainNames().concat(ibcBridgeNames);
const validTransferOptionChains = sdk.token.getPolynetworkBlockchainNames()
.concat(sdk.token.getAxelarBlockchainNames())
.concat(ibcBridgeNames);

const hasInvalidChains = checkValidEntries(transferOptionsArr, validTransferOptionChains);
if (hasInvalidChains.status && hasInvalidChains.entry) {
Expand Down Expand Up @@ -594,6 +624,10 @@ async function main() {
}
}

if(jsonData.market_banners && !isValidMarketBanners(jsonData.market_banners, network, marketIds)) {
outcomeMap[network] = false;
}

// external chain channels check
const isExternalChannelsValid = isValidExternalChainChannels(jsonData.external_chain_channels, ibcBridgeNames, network);
if (!isExternalChannelsValid) outcomeMap[network] = false;
Expand Down
Loading

0 comments on commit 0d72d29

Please sign in to comment.