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

App perp pool banners config #98

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 10 additions & 0 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`transfer_options` |`object` |true |A collection of blockchain networks along with their associated priority numbers, used to establish their order in the transfer options list for deposit and withdrawal forms. |Blockchain network listed here **MUST** match the valid chainName of the bridges listed under BridgeAll RPC call.<br /><br /> To view the values of BridgeAll RPC call, simply run `yarn get-bridges [network]` on the command line. Sample for mainnet: `yarn get-bridges mainnet`|
|`network_fees` |`object` |true |List of token denoms along with their associated priority numbers, used to establish their default order in the network fees preference list. |Token denoms listed here **MUST** match the valid denoms listed under MinGasPriceAll RPC call.<br /><br /> To view the values of MinGasPriceAll RPC call, simply run `yarn get-min-gas-prices [network]` on the command line. Sample for mainnet: `yarn get-min-gas-prices mainnet`|
|`maintenance` |`Maintenance` |false |Object that dictates whether or not the maintenance page is displayed on each particular network. The maintenance page is displayed when the Carbon chain is down (i.e. blocks are not moving). | If the `maintenance` property is omitted, the maintenance page will not be shown.
|`perp_pool_banners` |`PerpPoolBanner` |false |Object that dictates whether or not the maintenance page is displayed on each particular network. The maintenance page is displayed when the Carbon chain is down (i.e. blocks are not moving). | If the `maintenance` property is omitted, the maintenance page will not be shown.

## Maintenance Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`title` |`string` |false |Title to be shown on the maintenance page |If not defined, the title defaults to `Service Maintenance`. |
|`message` |`string` |false |Description to be shown on the maintenace page (below the title). |If not defined, the message will default to `Website is temporily unavailable due to planned maintenance. We will be back soon.`. |

## PerpPoolBanner Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`perp_pool_id` |`string` |true |Perp pool id where the banner will be shown. |Perp pool id **MUST** match one of the existing perp pool ids from the PerpPool PoolInfoAll RPC call.<br /><br /> To view the values of PoolInfoAll RPC call, simply run `yarn get-perp-pool-ids [network]` on the command line. Sample for mainnet: `yarn get-perp-pool-ids mainnet` |
|`show_from` |`string` |false |The date and time when the perp pool 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 perp pool 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) |
|`title` |`string` |true |The title shown on the perp pool banner. |
|`subtext` |`string` |true |The subtext shown on the perp pool banner (below the title). |
55 changes: 54 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"blacklisted_pools",
"blacklisted_tokens",
"transfer_options",
"network_fees"
"network_fees",
"perp_pool_banners"
],
"properties": {
"network": {
Expand Down Expand Up @@ -89,6 +90,35 @@
"description": "Description shown on maintenance page (optional). If not provided, the description of the page will default to \"Website is temporily unavailable due to planned maintenance. We will be back soon.\""
}
}
},
"perp_pool_banners": {
"type": "array",
"description": "List of blacklisted token denoms",
"items": {
"type": "object",
"required": [
"perp_pool_id",
"title",
"subtext"
],
"properties": {
"perp_pool_id": {
"$ref": "#/$defs/perp_pool_id"
},
"show_from": {
"$ref": "#/$defs/show_from"
},
"show_until": {
"$ref": "#/$defs/show_until"
},
"title": {
"$ref": "#/$defs/title"
},
"subtext": {
"$ref": "#/$defs/subtext"
}
}
}
}
},
"$defs": {
Expand All @@ -112,6 +142,29 @@
"blacklisted_token": {
"type": "string",
"description": "Blacklisted token denom"
},
"perp_pool_id": {
"type": "string",
"description": "Perp pool id (type: string)",
"pattern": "^\\d+$"
},
"show_from": {
"type": "string",
"description": "The date and time when the perp pool banner is scheduled to begin displaying (optional). If not provided, the banner will be shown immediately.",
"pattern": "^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$"
},
"show_until": {
"type": "string",
"description": "The date and time when the perp pool banner is scheduled to stop displaying (optional). If not provided, the banner will continue to display indefinitely.",
"pattern": "^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$"
},
"title": {
"type": "string",
"description": "The title shown on the banner"
},
"subtext": {
"type": "string",
"description": "The subtext shown on the banner"
}
}
}
3 changes: 2 additions & 1 deletion configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"swth": 0,
"usdc": 1,
"eth": 2
}
},
"perp_pool_banners": []
}
3 changes: 2 additions & 1 deletion configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@
"bneo.1.14.e2e5f6": 20,
"eth.1.2.942d87": 21,
"usdc.1.2.343151": 22
}
},
"perp_pool_banners": []
}
11 changes: 10 additions & 1 deletion configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@
"swth": 0,
"usdc": 1,
"eth": 2
}
},
"perp_pool_banners": [
{
"perp_pool_id": "1",
"show_from" : "2024-02-06T09:00+00:00",
"show_until" : "2024-03-06T09:00+00:00",
"title": "Market changes pending",
"subtext": "BTCETH Perp will be removed on 6 Mar, 09:00AM UTC"
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"check-configs": "ts-node scripts/check_configs",
"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-min-gas-prices": "ts-node scripts/get_all_network_fees",
"get-perp-pool-ids": "ts-node scripts/get_perp_pool_ids"
},
"dependencies": {
"@cosmjs/tendermint-rpc": "^0.29.4",
Expand Down
38 changes: 38 additions & 0 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ConfigJSON {
network_fees: {
[denom: string]: number
},
perp_pool_banners: PerpPoolBanner[]
}

interface InvalidEntry {
Expand All @@ -31,6 +32,14 @@ interface DuplicateEntry {
numberOfDuplicates?: number;
}

interface PerpPoolBanner {
perp_pool_id: string;
show_from: string;
show_until: string;
title: string;
subtext: string;
}

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

const outcomeMap: OutcomeMap = {
Expand Down Expand Up @@ -287,6 +296,35 @@ async function main() {
console.error(`ERROR: ${network}.json has the following network fee token denoms under network_fees field: ${listOfInvalidFeeDenoms}. Please make sure to only input valid network fee token denoms in ${network}`);
outcomeMap[network] = false;
}

// Checking perp pool banners
const perpPoolsQuery = await sdk.query.perpspool.PoolInfoAll({
pagination: {
key: new Uint8Array(),
limit: new Long(10000),
offset: Long.UZERO,
countTotal: true,
reverse: false,
},
})

const perpPoolIds = perpPoolsQuery.pools.map((pool) => pool.poolId.toString())
const perpPoolBannerIds = Object.values(jsonData.perp_pool_banners).map((banner) => banner.perp_pool_id)

const hasInvalidPerpPoolIds = checkValidEntries(perpPoolBannerIds, perpPoolIds)
const hasDuplicatePerpPoolIds = checkDuplicateEntries(perpPoolBannerIds)

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

if (hasDuplicatePerpPoolIds.status && hasDuplicatePerpPoolIds.entry) {
let listOfDuplicates: string = hasDuplicatePerpPoolIds.entry.join(", ");
console.error(`ERROR: ${network}.json has duplicated perp pool banners for the following perp pool ids: ${listOfDuplicates}. Please make sure to input each perp pool banner only once in ${network}`);
outcomeMap[network] = false;
}
}
}
const outcomeArr = Object.values(outcomeMap);
Expand Down
36 changes: 36 additions & 0 deletions scripts/get_perp_pool_ids.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { CarbonSDK } from "carbon-js-sdk";
import Long from "long";
const myArgs = process.argv.slice(2);

(async () => {
const net = myArgs[0]
let network: CarbonSDK.Network;
switch (net.toLowerCase()) {
case "mainnet":
network = CarbonSDK.Network.MainNet;
break;
case "testnet":
network = CarbonSDK.Network.TestNet;
break;
case "devnet":
network = CarbonSDK.Network.DevNet;
break;
default:
console.log("ERROR: Invalid network keyed");
process.exit(1);
}

const sdk = await CarbonSDK.instance({ network });
const pools = await sdk.query.perpspool.PoolInfoAll({
pagination: {
key: new Uint8Array(),
limit: new Long(10000),
offset: Long.UZERO,
countTotal: true,
reverse: false,
},
})
const poolIds = pools.pools.map((p) => p.poolId.toString())

console.log(poolIds)
})().catch(console.error).finally(() => process.exit(0));
Loading