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 Market promotion boosted tag #280

Merged
merged 2 commits into from
Dec 5, 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
10 changes: 9 additions & 1 deletion .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`market_banners` |`MarketBanner[]` |true |market banner configs. |
| `native_token_contracts_map` | `object` | false | Map of token denoms to their respective contract addresses on the native chain. | |
| `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. |

## Maintenance Data Structure
|Field |Type |Required |Description |Notes |
Expand Down Expand Up @@ -97,4 +98,11 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`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. |
|`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. |

## MarketPromo Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`start` |`string` |true |Start time of the promo. |
|`end` |`string` |true |End time of the promo. |
|`tooltip` |`string` |false |Tooltip message for perp trading boost tag. |
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Additionally, the JSON file for mainnet contains the following data to support o
- perp pool promotion parameters
- typeform survey parameters
- market banner parameters for information banners to be displayed on the TradingView charts on Trade UI
- market promo parameters for showing boosted tag on market select 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
28 changes: 28 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,30 @@
}
}
},
"market_promo": {
"type": "object",
"description": "Market Promo config",
"patternProperties": {
"^\\d+$": {
"type": "object",
"required": [
"start",
"end"
],
"properties": {
"start": {
"$ref": "#/$defs/start"
},
"end": {
"$ref": "#/$defs/end"
},
"tooltip": {
"$ref": "#/$defs/tooltip"
}
}
}
}
},
"$defs": {
"prelaunch_market": {
"type": "string",
Expand Down Expand Up @@ -357,6 +381,10 @@
"type": "string",
"description": "The content shown on the banner, we can render hyperlink in the content eg: You can visit [here](url)"
},
"tooltip": {
"type": "string",
"description": "The tooltip shown on the market select dropdown tag"
},
"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
7 changes: 7 additions & 0 deletions configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,12 @@
"show_from": "2024-11-04T09:00+00:00"
}
],
"market_promo": {
"cmkt/142": {
"start": "2024-11-20T08:00:00Z",
"end": "2024-12-20T08:00:00Z",
"tooltip": "Trade MNT-PERP to earn 3x points in the Mantle Trading League!"
}
},
"maintenance": {}
}
46 changes: 46 additions & 0 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface ConfigJSON {
perp_pools: PerpPoolConfig;
wswth_contract?: string;
market_banners?: MarketBanner[];
market_promo?: {[marketId: string]: MarketPromo};
}

interface InvalidEntry {
Expand Down Expand Up @@ -109,6 +110,12 @@ interface MarketBanner {
hideable?: boolean;
}

interface MarketPromo {
start: string;
end: string;
tooltip?: string;
}

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

const outcomeMap: OutcomeMap = {
Expand Down Expand Up @@ -308,6 +315,41 @@ function isValidMarketBanners(marketBanners: MarketBanner[], network: CarbonSDK.
return true;
}

function isValidMarketPromo(marketPromo: {[marketId: string]: MarketPromo}, network: CarbonSDK.Network, marketIds: string[]): boolean {
const marketPromoIds = Object.keys(marketPromo)
const hasInvalidMarketPromoIds = checkValidEntries(marketPromoIds, marketIds)
const hasDuplicateMarketPromoIds = checkDuplicateEntries(marketPromoIds)

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

if (hasDuplicateMarketPromoIds.status && hasDuplicateMarketPromoIds.entry) {
let listOfDuplicates: string = hasDuplicateMarketPromoIds.entry.join(", ");
console.error(`ERROR: ${network}.json has duplicated market promos for the following market ids: ${listOfDuplicates}. Please make sure to input each market promo only once in ${network}`);
outcomeMap[network] = false;
}

for (const promoId in marketPromoIds) {
const promoInfo = marketPromo[promoId];
const startTimeStr = promoInfo.start;
const endTimeStr = promoInfo.end;

const startTime = new Date(startTimeStr);
const endTime = new Date(endTimeStr);

if (endTime < startTime) {
console.error(`ERROR: ${network}.json has invalid end time (${endTimeStr}) is before start time (${startTimeStr}) for market promo id ${promoId}.`);
outcomeMap[network] = false;
break;
}
}

return true;
}

async function main() {
for (const net of myArgs) {
let network: CarbonSDK.Network;
Expand Down Expand Up @@ -629,6 +671,10 @@ async function main() {
outcomeMap[network] = false;
}

if(jsonData.market_promo && !isValidMarketPromo(jsonData.market_promo, 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