Skip to content

Commit

Permalink
Add market banners config
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhpn committed Oct 23, 2024
1 parent 5bc2b58 commit 5dc9289
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
1 change: 1 addition & 0 deletions .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` |`object[]` |true |market banner configs. |

## Maintenance Data Structure
|Field |Type |Required |Description |Notes |
Expand Down
10 changes: 9 additions & 1 deletion configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@
},
"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"
}
]
}
3 changes: 2 additions & 1 deletion configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,6 @@
}
]
},
"wswth_contract": "0x0e59f6Cf81B5Fae9F7a5912062Fe53909e7221C2"
"wswth_contract": "0x0e59f6Cf81B5Fae9F7a5912062Fe53909e7221C2",
"market_banners": []
}
10 changes: 9 additions & 1 deletion configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,13 @@
},
"banners": []
},
"wswth_contract": "0x325f60362040B40DC2f3C5652095Ed262cf581F7"
"wswth_contract": "0x325f60362040B40DC2f3C5652095Ed262cf581F7",
"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"
}
]
}
30 changes: 29 additions & 1 deletion 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,13 @@ interface PerpPoolConfig {
banners: PerpPoolBanner[]
}

interface MarketBanner {
market_id: string;
show_from: string;
show_until: string;
content: string;
}

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

const outcomeMap: OutcomeMap = {
Expand Down Expand Up @@ -594,6 +602,26 @@ async function main() {
}
}

if(jsonData.market_banners) {
const marketBanners = jsonData.market_banners
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}`)
outcomeMap[network] = 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 input each market banner only once in ${network}`);
outcomeMap[network] = false;
}
}

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

0 comments on commit 5dc9289

Please sign in to comment.