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

Refactor/perp pool banner #216

Merged
merged 7 commits into from
Aug 26, 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
12 changes: 12 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@
"type": "string",
"description": "The message shown on the banner describing markets being removed"
},
"action_trigger_date": {
"type": "string",
"description": "The date and time when the action in the banner message is triggered. The past_tense_text will not be shown if this value is omitted",
"pattern": "^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$"
},
"past_tense_text": {
"type": "string",
"description": "The alternative message shown after the date of markets being added or removed has passed"
},
"added_markets": {
"type": "string",
"description": "The message shown on the banner describing markets being added"
Expand Down Expand Up @@ -405,6 +414,9 @@
"added_markets": {
"$ref": "#/$defs/added_markets"
},
"past_tense_text": {
"$ref": "#/$defs/past_tense_text"
},
"subtext": {
"$ref": "#/$defs/subtext"
}
Expand Down
26 changes: 17 additions & 9 deletions configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,22 +369,30 @@
},
"banners": [
{
"perp_pool_id": "8",
"show_until": "2024-07-29T08:00+00:00",
"perp_pool_id": "9",
"show_until": "2024-08-25T08:00+00:00",
"title": "New Markets added",
"added_markets": "ETC Perp Market will be added to this Perp Pool on 24 Jul, 08:00 AM UTC. This banner will disappear on 29 Jul."
"added_markets": "CRV will be added to this Perp Pool on 22 Aug, 08:00 AM UTC. This banner will disappear on 25 Aug."
},
{
"perp_pool_id": "9",
"show_until": "2024-07-29T08:00+00:00",
"perp_pool_id": "7",
"show_until": "2024-08-25T08:00+00:00",
"title": "New Markets added",
"added_markets": "LDO Perp Market will be added to this Perp Pool on 24 Jul, 08:00 AM UTC. This banner will disappear on 29 Jul."
"added_markets": "SUN will be added to this Perp Pool on 22 Aug, 08:00 AM UTC. This banner will disappear on 25 Aug."
},
{
"perp_pool_id": "1",
"show_until": "2024-07-15T08:00+00:00",
"perp_pool_id": "4",
"show_until": "2024-08-30T08:00+00:00",
"title": "New Markets added",
"removed_markets": "[Ticker] Perp Market will be added to this Perp Pool on [Date]. This banner will disappear on [Date] 08:00 AM UTC."
"added_markets": "On 20 Aug, 08:00 AM UTC, this perp pool was renamed to 'Modular'. MNT, MANTA, ARB, OP were added to this Perp Pool"
},
{
"perp_pool_id": "6",
"show_until": "2024-08-30T08:00+00:00",
"title": "Markets removed",
"removed_markets": "On 20 Aug 8AM UTC, all markets in this perp pool will be moved to the Celestia Perp Pool to consolidate liquidity.",
"action_trigger_date": "2024-08-20T08:00+00:00",
"past_tense_text": "On 20 Aug 8AM UTC, all markets in this perp pool have been moved to the Celestia Perp Pool to consolidate liquidity."
}
]
},
Expand Down
26 changes: 12 additions & 14 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ interface PerpPoolBanner {
title: string;
removed_markets?: string;
added_markets?: string;
action_trigger_date?: string;
past_tense_text?: string;
subtext?: string;
}

Expand Down Expand Up @@ -96,7 +98,7 @@ interface Incentives {

interface PerpPoolConfig {
incentives: Incentives
banners: PerpPoolBanner
banners: PerpPoolBanner[]
}

type OutcomeMap = { [key in CarbonSDK.Network]: boolean }; // true = success, false = failure
Expand Down Expand Up @@ -236,13 +238,13 @@ function isValidAdditionalIbcTokenConfig(addTokenConfigArr: AdditionalIbcTokenCo
}

function isValidDemexTradingLeagueConfig(
demexTradingLeagueConfig: DemexTradingLeagueConfig,
network: CarbonSDK.Network,
demexTradingLeagueConfig: DemexTradingLeagueConfig,
network: CarbonSDK.Network,
marketIds: string[],
blacklistedMarkets: string[],
perpPoolIds: string[],
tokenSymbols: string[]) {

const hasInvalidPromoMarkets = checkValidEntries(demexTradingLeagueConfig.promoMarkets, marketIds);
if (hasInvalidPromoMarkets.status && hasInvalidPromoMarkets.entry) {
let listOfInvalidMarkets: string = hasInvalidPromoMarkets.entry.join(', ');
Expand All @@ -256,7 +258,7 @@ function isValidDemexTradingLeagueConfig(
console.error(`ERROR: ${network}.json has the following duplicated promo market entries in demex_trading_league_config: ${listOfDuplicates}. Please make sure to only input each market once in ${network}`);
return false;
}

const hasBlacklistedMarketsInPromo = checkBlacklistedMarkets(demexTradingLeagueConfig.promoMarkets, blacklistedMarkets);
if (hasBlacklistedMarketsInPromo.status && hasBlacklistedMarketsInPromo.entry) {
let listOfBlacklistedMarkets: string = hasBlacklistedMarketsInPromo.entry.join(", ");
Expand Down Expand Up @@ -556,13 +558,13 @@ async function main() {
const hasDuplicateLinks = checkDuplicateEntries(distributorsArr)
if (hasDuplicateLinks.status && hasDuplicateLinks.entry) {
let listOfDuplicates: string = hasDuplicateLinks.entry.join(", ");
console.error(`ERROR: ${network}.json has the following duplicated distributors in the perp pools incentives configs: ${listOfDuplicates}. Please make sure to only input each link once in ${network}`);
console.error(`ERROR: ${network}.json has the following duplicated distributors in the perp_pools incentives configs: ${listOfDuplicates}. Please make sure to only input each link once in ${network}`);
outcomeMap[network] = false;
}

distributorsArr.forEach((address) => {
if (!checkAddressIsEVM(address)) {
console.error(`ERROR: ${network}.json has invalid EVM address in perp pools incentives configs: ${address}`);
console.error(`ERROR: ${network}.json has invalid EVM address in perp_pools incentives configs: ${address}`);
outcomeMap[network] = false;
}
})
Expand All @@ -571,19 +573,15 @@ async function main() {
const proxy = perpPoolConfig.incentives.proxy
if (proxy) {
if (!checkAddressIsEVM(proxy)) {
console.error(`ERROR: ${network}.json has invalid EVM address in perp pools incentives proxy configs: ${proxy}`);
console.error(`ERROR: ${network}.json has invalid EVM address in perp_pools incentives proxy configs: ${proxy}`);
outcomeMap[network] = false;
}
}
}

if (perpPoolConfig.banners) {
const banners = perpPoolConfig.banners
// Checking perp pool banners
const perpPoolsQuery = await sdk.query.perpspool.PoolInfoAll({
pagination: PageRequest.fromPartial({
limit: new Long(10000),
}),
})

const perpPoolIds = perpPoolsQuery.pools.map((pool) => pool.poolId.toString())
const perpPoolBannerIds = Object.values(banners).map((banner) => banner.perp_pool_id)
Expand All @@ -593,7 +591,7 @@ async function main() {

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

Expand Down
Loading