diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index 6dcdab6..6580fba 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -10,12 +10,5 @@ Each json file under the [configs](../../configs) folder correspond to their res |`blacklisted_markets` |`string[]` |true |The array of market names that are blacklisted. A market can be blacklisted for a number of reasons, such as it being invalid/duplicate/wrongly-added/etc. |The market names listed here **MUST** match the market names listed under the Carbon [Markets API](https://api.carbon.network/carbon/market/v1/markets?pagination.limit=10000). The market names listed here **CANNOT** be under the `featured_markets` field at the same time. | |`blacklisted_pools` |`string[]` |true |The array of pool ids that are blacklisted. A pool can be blacklisted for a number of reasons, such as it being invalid/duplicate/wrongly-added/etc. |The pool ids listed here **MUST** match the pool ids listed under the Carbon [Liquidity Pool API](https://api.carbon.network/carbon/liquiditypool/v1/pools?pagination.limit=10000). | |`blacklisted_tokens` |`string[]` |true |The array of token denoms that are blacklisted. A token can be blacklisted for a number of reasons, such as it being invalid/deprecated/etc. |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | -|`ibc_tokens_total_supply` |`IBCTotalSuppply[]` |true |The array of IBC fee token denoms with their respective total supply on Coingecko. |Please refer to the [IBC total supply data structure](#ibc-total-supply-data-structure) for the data to include in each `IBCTotalSuppply` object | |`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.

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.

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`| - -## IBC total supply Data Structure -|Field |Type |Required |Description |Notes | -|---|---|---|---|---| -|`denom` |`string` |true |Denom of IBC fee token on Carbon |This denom **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | -|`amount` |`string` |true |The total supply amount of the IBC fee token on Coingecko |This value is auto-generated by the script update_ibc_total_supply.ts. To update, simply run `yarn update-total-supply` on the command line and push the updates to a new branch. | \ No newline at end of file diff --git a/.github/workflows/market-config-validation.yml b/.github/workflows/market-config-validation.yml index edb6d8a..0888451 100644 --- a/.github/workflows/market-config-validation.yml +++ b/.github/workflows/market-config-validation.yml @@ -10,18 +10,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + + - name: Set Node-js version + uses: actions/setup-node@v3 + with: + node-version: '18.14.2' - name: Install Dependencies - uses: borales/actions-yarn@v3.0.0 - with: - cmd: install --ignore-engines # will run `yarn install` command + run: yarn install --ignore-engines # will run `yarn install` command - name: Validate featured markets schema - uses: borales/actions-yarn@v3.0.0 - with: - cmd: validate # validate using json schema + run: yarn validate # validate using json schema - name: Test market entries for invalid/duplicate markets - uses: borales/actions-yarn@v3.0.0 - with: - cmd: check-configs mainnet testnet devnet # check using check_configs.ts script \ No newline at end of file + run: yarn check-configs mainnet testnet devnet # check using check_configs.ts script \ No newline at end of file diff --git a/README.md b/README.md index 4594678..9619209 100644 --- a/README.md +++ b/README.md @@ -8,57 +8,43 @@ Currently, each JSON file contain the following data on its corresponding networ - blacklisted markets - blacklisted pools - blacklisted tokens -- total supply of IBC fee tokens on Mintscan - default blockchain transfer option order in deposit/withdrawal forms dropdown - default network token fee order More metadata will be added in the future if required by the Demex frontend. Please see below the structure of the JSON file: -``` +```json { - "network": "testnet", - "featured_markets": [ - "market_1", - "market_2", - "market_3", - ... - ], - "blacklisted_markets": [ - "blacklisted_market_1", - "blacklisted_market_2", - "blacklisted_market_3", - ... - ], - "blacklisted_pools": [ - "blacklisted_pool_1", - "blacklisted_pool_2", - "blacklisted_pool_3", - ... - ], - "blacklisted_tokens": [ - "blacklisted_token_1", - "blacklisted_token_2", - "blacklisted_token_3", - ... - ], - "": [{ - denom: "ibc-token-denom-1", - amount: "1000000", - }, { - denom: "ibc-token-denom-2", - amount: "1000000000", - }], - "transfer_options": { - "chain_1": 0, - "chain_2": 1, - "chain_3": 2, - ... - }, - "network_fees": { - "token_denom_1": 0, - "token_denom_2": 1, - "token_denom_3": 2, - ... - } + "network": "testnet", + "featured_markets": [ + "market_1", + "market_2", + "market_3" + ], + "blacklisted_markets": [ + "blacklisted_market_1", + "blacklisted_market_2", + "blacklisted_market_3" + ], + "blacklisted_pools": [ + "blacklisted_pool_1", + "blacklisted_pool_2", + "blacklisted_pool_3" + ], + "blacklisted_tokens": [ + "blacklisted_token_1", + "blacklisted_token_2", + "blacklisted_token_3" + ], + "transfer_options": { + "chain_1": 0, + "chain_2": 1, + "chain_3": 2 + }, + "network_fees": { + "token_denom_1": 0, + "token_denom_2": 1, + "token_denom_3": 2 + } } ``` diff --git a/config.schema.json b/config.schema.json index aa48a99..c5b5c0e 100644 --- a/config.schema.json +++ b/config.schema.json @@ -1,114 +1,89 @@ { - "title": "Demex Webapp Config", - "description": "demex-webapp-config is a repository to allow frontends to fetch metadata associated with Demex", - "type": "object", - "required": [ - "network", - "featured_markets", - "blacklisted_markets", - "blacklisted_pools", - "blacklisted_tokens", - "ibc_tokens_total_supply" - ], - "properties": { - "network": { - "type": "string", - "enum": [ - "mainnet", - "testnet", - "devnet" - ] - }, - "featured_markets": { - "type": "array", - "items": { - "$ref": "#/$defs/featured_market" - } - }, - "blacklisted_markets": { - "type": "array", - "description": "List of blacklisted market names", - "items": { - "$ref": "#/$defs/blacklisted_market" - } - }, - "blacklisted_pools": { - "type": "array", - "description": "List of blacklisted pool ids", - "items": { - "$ref": "#/$defs/blacklisted_pool" - } - }, - "blacklisted_tokens": { - "type": "array", - "description": "List of blacklisted token denoms", - "items": { - "$ref": "#/$defs/blacklisted_token" - } - }, - "ibc_tokens_total_supply": { - "type": "array", - "description": "List of ibc denoms with their respective total supply on Coingecko", - "items": { - "$ref": "#/$defs/ibc_total_supply" - } - }, - "transfer_options": { - "type": "object", - "description": "List of blockchain networks and their priority numbers, used to set their order in deposit and withdrawal forms transfer option dropdown", - "patternProperties": { - ".*": { - "type": "integer" - } - }, - "additionalProperties": false - }, - "network_fees": { - "type": "object", - "description": "List of token denoms and their priority numbers, used to set their order in network fee preferences", - "patternProperties": { - ".*": { - "type": "integer" - } - }, - "additionalProperties": false + "title": "Demex Webapp Config", + "description": "demex-webapp-config is a repository to allow frontends to fetch metadata associated with Demex", + "type": "object", + "required": [ + "network", + "featured_markets", + "blacklisted_markets", + "blacklisted_pools", + "blacklisted_tokens", + "transfer_options", + "network_fees" + ], + "properties": { + "network": { + "type": "string", + "enum": [ + "mainnet", + "testnet", + "devnet" + ] + }, + "featured_markets": { + "type": "array", + "items": { + "$ref": "#/$defs/featured_market" + } + }, + "blacklisted_markets": { + "type": "array", + "description": "List of blacklisted market names", + "items": { + "$ref": "#/$defs/blacklisted_market" + } + }, + "blacklisted_pools": { + "type": "array", + "description": "List of blacklisted pool ids", + "items": { + "$ref": "#/$defs/blacklisted_pool" + } + }, + "blacklisted_tokens": { + "type": "array", + "description": "List of blacklisted token denoms", + "items": { + "$ref": "#/$defs/blacklisted_token" + } + }, + "transfer_options": { + "type": "object", + "description": "List of blockchain networks and their priority numbers, used to set their order in deposit and withdrawal forms transfer option dropdown", + "patternProperties": { + ".*": { + "type": "integer" } + }, + "additionalProperties": false }, - "$defs": { - "featured_market": { - "type": "string" - }, - "blacklisted_market": { - "type": "string", - "description": "Blacklisted market name" - }, - "blacklisted_pool": { - "type": "string", - "description": "Blacklisted pool id (type: string)", - "pattern": "^\\d+$" - }, - "blacklisted_token": { - "type": "string", - "description": "Blacklisted token denom" - }, - "ibc_total_supply": { - "type": "object", - "description": "Total supply amount of each IBC token listed here", - "required": [ - "denom", - "amount" - ], - "properties": { - "denom": { - "type": "string", - "description": "Denom of IBC token on Carbon (e.g. ibc/07FA7831E1920D0C87C9388F86B0108677F6ED0C9DE7E4063F05ED675192405C => STARS)" - }, - "amount": { - "type": "string", - "description": "total supply of each IBC token on Coingecko", - "pattern": "^\\d+$" - } - } + "network_fees": { + "type": "object", + "description": "List of token denoms and their priority numbers, used to set their order in network fee preferences", + "patternProperties": { + ".*": { + "type": "integer" } + }, + "additionalProperties": false + } + }, + "$defs": { + "featured_market": { + "type": "string" + }, + "blacklisted_market": { + "type": "string", + "description": "Blacklisted market name" + }, + "blacklisted_pool": { + "type": "string", + "description": "Blacklisted pool id (type: string)", + "pattern": "^\\d+$" + }, + "blacklisted_token": { + "type": "string", + "description": "Blacklisted token denom" } + } } \ No newline at end of file diff --git a/configs/devnet.json b/configs/devnet.json index a28244e..c70e039 100644 --- a/configs/devnet.json +++ b/configs/devnet.json @@ -1,16 +1,15 @@ { - "network": "devnet", - "featured_markets": [], - "blacklisted_markets": [ - "swth_btc2" - ], - "blacklisted_pools": [], - "blacklisted_tokens": [], - "ibc_tokens_total_supply": [], - "transfer_options": {}, - "network_fees": { - "swth": 0, - "usdc": 1, - "eth": 2 - } -} \ No newline at end of file + "network": "devnet", + "featured_markets": [], + "blacklisted_markets": [ + "swth_btc2" + ], + "blacklisted_pools": [], + "blacklisted_tokens": [], + "transfer_options": {}, + "network_fees": { + "swth": 0, + "usdc": 1, + "eth": 2 + } +} \ No newline at end of file diff --git a/configs/mainnet.json b/configs/mainnet.json index 59e9a65..983bb0f 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -1,136 +1,98 @@ { - "network": "mainnet", - "featured_markets": [ - "cmkt/117", - "cmkt/118", - "cmkt/129", - "cmkt/120", - "cmkt/147", - "cmkt/142", - "cmkt/109", - "cmkt/115", - "cmkt/110", - "cmkt/149", - "cmkt/151", - "cmkt/152", - "cmkt/153" - ], - "blacklisted_markets": [ - "gm1_busd1", - "SWTH_UST", - "LUNA_SWTH" - ], - "blacklisted_pools": [ - "34", - "43", - "44", - "74", - "83" - ], - "blacklisted_tokens": [ - "swthb.1.6.d04123", - "swth.1.18.94d5fe", - "bneo.1.14.59a1d7", - "ibc/F7E92EE59B5428793F3EF5C1A4CB2494F61A9D0C9A69469D02390714A1372E16", - "ibc/4128D5DDF2EF8776B5C704C3153E1CBEC5DABC04DB0CC6221EDCC342EB04779C", - "ibc/1B03A71B8E6F6EF424411DC9326A8E0D25D096E4D2616425CFAF2AF06F0FE717", - "ibc/731D16914CB3304BD7D177D3D4B210D82C04E5DF86E08AC994A8675C3E00C366", - "ibc/A59A9C955F1AB8B76671B00C1A0482C64A6590352944BB5880E5122358F7E1CE", - "ibc/D70B0FBF97AEB04491E9ABF4467A7F66CD6250F4382CE5192D856114B83738D2", - "ibc/4294C3DB67564CF4A0B2BFACC8415A59B38243F6FF9E288FBA34F9B4823BA16E", - "usdc.1.6.e70e14" - ], - "ibc_tokens_total_supply": [ - { - "denom": "ibc/07FA7831E1920D0C87C9388F86B0108677F6ED0C9DE7E4063F05ED675192405C", - "amount": "1289451288622070" - }, - { - "denom": "ibc/2B58B8C147E8718EECCB3713271DF46DEE8A3A00A27242628604E31C2F370EF5", - "amount": "297139581048487" - }, - { - "denom": "ibc/3552CECB7BCE1891DB6070D37EC6E954C972B1400141308FCD85FD148BD06DE5", - "amount": "85594497558724" - }, - { - "denom": "ibc/35E771B8682D828173F4B795F6C307780F96DC64D6F914FAE4CC9B4666F66364", - "amount": "525080023117301000000000000" - }, - { - "denom": "ibc/662914D0C1CEBCB070C68F061D035E8B10A07C79AB286E7342C85F3BE74612C5", - "amount": "115213863862302" - }, - { - "denom": "ibc/92E974290AF9E2BC3AEEEC35305C8FD76AC5A22A74CF8D91270FDF5A1C41E861", - "amount": "502370222129589000000000000" - }, - { - "denom": "ibc/A4DB47A9D3CF9A068D454513891B526702455D3EF08FB9EB558C561F9DC2B701", - "amount": "292586163827428" - }, - { - "denom": "ibc/B7864B03E1B9FD4F049243E92ABD691586F682137037A9F3FCA5222815620B3C", - "amount": "0" - }, - { - "denom": "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518", - "amount": "600527806000000" - } - ], - "transfer_options": { - "Cosmos Hub": 0, - "Osmosis": 1, - "Evmos": 2, - "Axelar": 3, - "Juno": 4, - "Stride": 5, - "Kujira": 6, - "Terra": 7, - "Comdex": 8, - "Stafihub": 9, - "Persistence Core": 10, - "Stargaze": 11, - "Canto": 12, - "Sommelier": 13, - "IRIS Hub": 14, - "Noble": 15, - "Ethereum": 16, - "Arbitrum": 17, - "Polygon": 18, - "OKC": 19, - "Binance Smart Chain": 20, - "Carbon": 21, - "Neo": 22, - "Neo3": 23, - "Zilliqa": 24 - }, - "network_fees": { - "swth": 0, - "cgt/1": 1, - "usc": 2, - "ibc/A4DB47A9D3CF9A068D454513891B526702455D3EF08FB9EB558C561F9DC2B701": 3, - "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518": 4, - "ibc/2B58B8C147E8718EECCB3713271DF46DEE8A3A00A27242628604E31C2F370EF5": 5, - "ibc/662914D0C1CEBCB070C68F061D035E8B10A07C79AB286E7342C85F3BE74612C5": 6, - "ibc/3552CECB7BCE1891DB6070D37EC6E954C972B1400141308FCD85FD148BD06DE5": 7, - "ibc/92E974290AF9E2BC3AEEEC35305C8FD76AC5A22A74CF8D91270FDF5A1C41E861": 8, - "ibc/35E771B8682D828173F4B795F6C307780F96DC64D6F914FAE4CC9B4666F66364": 9, - "ibc/07FA7831E1920D0C87C9388F86B0108677F6ED0C9DE7E4063F05ED675192405C": 10, - "ibc/75249A18DEFBEFE55F83B1C70CAD234DF164F174C6BC51682EE92C2C81C18C93": 11, - "ibc/B7864B03E1B9FD4F049243E92ABD691586F682137037A9F3FCA5222815620B3C": 12, - "ibc/4E06CF24FEBFB3F5AF645377DCC0B70AA6183BAF6B918B8B6243FCDEB7D38118": 13, - "bnb.1.6.773edb": 14, - "usdc.1.6.53ff75": 15, - "busd.1.6.754a80": 16, - "eth.1.19.c3b805": 17, - "cglp.1.19.1698d3": 18, - "zil.1.18.1a4a06": 19, - "bneo.1.14.e2e5f6": 20, - "eth.1.2.942d87": 21, - "usdc.1.2.343151": 22 - }, - "maintenance": { - "title": "" - } + "network": "mainnet", + "featured_markets": [ + "cmkt/117", + "cmkt/118", + "cmkt/129", + "cmkt/120", + "cmkt/147", + "cmkt/142", + "cmkt/109", + "cmkt/115", + "cmkt/110", + "cmkt/149", + "cmkt/151", + "cmkt/152", + "cmkt/153" + ], + "blacklisted_markets": [ + "gm1_busd1", + "SWTH_UST", + "LUNA_SWTH" + ], + "blacklisted_pools": [ + "34", + "43", + "44", + "74", + "83" + ], + "blacklisted_tokens": [ + "swthb.1.6.d04123", + "swth.1.18.94d5fe", + "bneo.1.14.59a1d7", + "ibc/F7E92EE59B5428793F3EF5C1A4CB2494F61A9D0C9A69469D02390714A1372E16", + "ibc/4128D5DDF2EF8776B5C704C3153E1CBEC5DABC04DB0CC6221EDCC342EB04779C", + "ibc/1B03A71B8E6F6EF424411DC9326A8E0D25D096E4D2616425CFAF2AF06F0FE717", + "ibc/731D16914CB3304BD7D177D3D4B210D82C04E5DF86E08AC994A8675C3E00C366", + "ibc/A59A9C955F1AB8B76671B00C1A0482C64A6590352944BB5880E5122358F7E1CE", + "ibc/D70B0FBF97AEB04491E9ABF4467A7F66CD6250F4382CE5192D856114B83738D2", + "ibc/4294C3DB67564CF4A0B2BFACC8415A59B38243F6FF9E288FBA34F9B4823BA16E", + "usdc.1.6.e70e14" + ], + "transfer_options": { + "Cosmos Hub": 0, + "Osmosis": 1, + "Evmos": 2, + "Axelar": 3, + "Juno": 4, + "Stride": 5, + "Kujira": 6, + "Terra": 7, + "Comdex": 8, + "Stafihub": 9, + "Persistence Core": 10, + "Stargaze": 11, + "Canto": 12, + "Sommelier": 13, + "IRIS Hub": 14, + "Noble": 15, + "Ethereum": 16, + "Arbitrum": 17, + "Polygon": 18, + "OKC": 19, + "Binance Smart Chain": 20, + "Carbon": 21, + "Neo": 22, + "Neo3": 23, + "Zilliqa": 24 + }, + "network_fees": { + "swth": 0, + "cgt/1": 1, + "usc": 2, + "ibc/A4DB47A9D3CF9A068D454513891B526702455D3EF08FB9EB558C561F9DC2B701": 3, + "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518": 4, + "ibc/2B58B8C147E8718EECCB3713271DF46DEE8A3A00A27242628604E31C2F370EF5": 5, + "ibc/662914D0C1CEBCB070C68F061D035E8B10A07C79AB286E7342C85F3BE74612C5": 6, + "ibc/3552CECB7BCE1891DB6070D37EC6E954C972B1400141308FCD85FD148BD06DE5": 7, + "ibc/92E974290AF9E2BC3AEEEC35305C8FD76AC5A22A74CF8D91270FDF5A1C41E861": 8, + "ibc/35E771B8682D828173F4B795F6C307780F96DC64D6F914FAE4CC9B4666F66364": 9, + "ibc/07FA7831E1920D0C87C9388F86B0108677F6ED0C9DE7E4063F05ED675192405C": 10, + "ibc/75249A18DEFBEFE55F83B1C70CAD234DF164F174C6BC51682EE92C2C81C18C93": 11, + "ibc/B7864B03E1B9FD4F049243E92ABD691586F682137037A9F3FCA5222815620B3C": 12, + "ibc/4E06CF24FEBFB3F5AF645377DCC0B70AA6183BAF6B918B8B6243FCDEB7D38118": 13, + "bnb.1.6.773edb": 14, + "usdc.1.6.53ff75": 15, + "busd.1.6.754a80": 16, + "eth.1.19.c3b805": 17, + "cglp.1.19.1698d3": 18, + "zil.1.18.1a4a06": 19, + "bneo.1.14.e2e5f6": 20, + "eth.1.2.942d87": 21, + "usdc.1.2.343151": 22 + }, + "maintenance": { + "title": "" } +} \ No newline at end of file diff --git a/configs/testnet.json b/configs/testnet.json index 934f911..b658505 100644 --- a/configs/testnet.json +++ b/configs/testnet.json @@ -1,23 +1,22 @@ { - "network": "testnet", - "featured_markets": [ - "BTC_PERP.USDC", - "swth_eth" - ], - "blacklisted_markets": [ - "swth_btc", - "swth_btc2", - "swth_nex", - "swth_nexo", - "swth_dai" - ], - "blacklisted_pools": [], - "blacklisted_tokens": [], - "ibc_tokens_total_supply": [], - "transfer_options": {}, - "network_fees": { - "swth": 0, - "usdc": 1, - "eth": 2 - } + "network": "testnet", + "featured_markets": [ + "BTC_PERP.USDC", + "swth_eth" + ], + "blacklisted_markets": [ + "swth_btc", + "swth_btc2", + "swth_nex", + "swth_nexo", + "swth_dai" + ], + "blacklisted_pools": [], + "blacklisted_tokens": [], + "transfer_options": {}, + "network_fees": { + "swth": 0, + "usdc": 1, + "eth": 2 } +} \ No newline at end of file diff --git a/package.json b/package.json index 6fbad50..7370b58 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "preinstall": "yarn config set ignore-engines true", "validate": "pajv validate -s config.schema.json -d \"configs/*.json\" --verbose", "check-configs": "ts-node scripts/check_configs", - "update-total-supply": "ts-node scripts/update_ibc_total_supply", "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" @@ -18,7 +17,7 @@ "@cosmjs/tendermint-rpc": "^0.29.4", "@types/node": "^18.11.9", "@types/node-fetch": "^2.6.2", - "carbon-js-sdk": "^0.4.16-beta.6", + "carbon-js-sdk": "^0.7.1-beta.2", "long": "^4.0.0", "node-fetch": "^2.6.1", "pajv": "^1.2.0", diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index cebabb0..386998b 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -5,18 +5,12 @@ import Long from 'long'; const cwd = process.cwd(); const myArgs = process.argv.slice(2); -interface TotalSupplyItem { - denom: string; - amount: string; -} - interface ConfigJSON { network: CarbonSDK.Network; featured_markets: string[]; blacklisted_markets: string[]; blacklisted_pools: string[]; blacklisted_tokens: string[]; - ibc_tokens_total_supply: TotalSupplyItem[] transfer_options: { [chainKey: string]: number }, @@ -227,32 +221,6 @@ async function main() { outcomeMap[network] = false; } - // IBC total supply map checks - const feeTokens = await sdk.query.fee.MinGasPriceAll({ - pagination: { - limit: new Long(100000), - offset: new Long(0), - key: new Uint8Array(), - countTotal: true, - reverse: false, - } - }); - const feeTokensArr: string[] = feeTokens.minGasPrices.map(gasPrice => gasPrice.denom); - const denomsArr = jsonData.ibc_tokens_total_supply.map((totalSupply: TotalSupplyItem) => totalSupply.denom); - const hasInvalidIbcFeeTokens = checkValidEntries(denomsArr, feeTokensArr); - if (hasInvalidIbcFeeTokens.status && hasInvalidIbcFeeTokens.entry) { - let listOfInvalidIbcTokens: string = hasInvalidIbcFeeTokens.entry.join(', '); - console.error(`ERROR: ${network}.json has the following invalid fee token denom entries under ibc_tokens_total_supply field: ${listOfInvalidIbcTokens}. Please make sure to only input valid fee token denom in ${network}`); - outcomeMap[network] = false; - } - - const hasDuplicateIbcFeeTokens = checkDuplicateEntries(denomsArr); - if (hasDuplicateIbcFeeTokens.status && hasDuplicateIbcFeeTokens.entry) { - let listOfIbcFeeDuplicates: string = hasDuplicateIbcFeeTokens.entry.join(", "); - console.error(`ERROR: ${network}.json has the following duplicated fee token denom entries under ibc_tokens_total_supply field: ${listOfIbcFeeDuplicates}. Please make sure to input each fee token denom only once in ${network}`); - outcomeMap[network] = false; - } - // Checking transfer options const transferOptionsArr = Object.keys(jsonData.transfer_options) const bridgesQuery = await sdk.query.coin.BridgeAll({ diff --git a/scripts/get_all_bridges.ts b/scripts/get_all_bridges.ts index c5efb5d..26b7f8e 100644 --- a/scripts/get_all_bridges.ts +++ b/scripts/get_all_bridges.ts @@ -2,7 +2,6 @@ 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; diff --git a/scripts/get_all_network_fees.ts b/scripts/get_all_network_fees.ts index 6b22750..bc1e710 100644 --- a/scripts/get_all_network_fees.ts +++ b/scripts/get_all_network_fees.ts @@ -2,7 +2,6 @@ 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; diff --git a/scripts/update_ibc_total_supply.ts b/scripts/update_ibc_total_supply.ts deleted file mode 100644 index aae3803..0000000 --- a/scripts/update_ibc_total_supply.ts +++ /dev/null @@ -1,102 +0,0 @@ -// import { BigNumber } from "bignumber.js"; -import { CarbonSDK, Models, NumberUtils } from "carbon-js-sdk"; -import * as fs from "fs"; -import Long from "long"; -const nodeFetch = require("node-fetch"); - -interface TotalSupplyItem { - denom: string; - amount: string; -} - -interface ConfigJSON { - network: CarbonSDK.Network; - featured_markets: string[]; - blacklisted_markets: string[]; - blacklisted_pools: string[]; - blacklisted_tokens: string[]; - ibc_tokens_total_supply: TotalSupplyItem[]; -} - -const cwd = process.cwd(); - -const skipTotalSupply: string[] = [ - "ibc/75249A18DEFBEFE55F83B1C70CAD234DF164F174C6BC51682EE92C2C81C18C93" // stOSMO -]; - -async function getTotalSupplyMap(feeTokens: Models.MinGasPrice[], sdk: CarbonSDK): Promise { - const allIBCTokens = feeTokens.filter((token: Models.MinGasPrice) => ( - CarbonSDK.TokenClient.isIBCDenom(token.denom) - )); - - const totalSupplyMap: TotalSupplyItem[] = []; - for (let ii = 0; ii < allIBCTokens.length; ii++) { - const coingeckoId = sdk.token.geckoTokenNames[allIBCTokens[ii].denom]; - if (skipTotalSupply.includes(allIBCTokens[ii].denom) || !coingeckoId) continue; - - const tokenDecimals = sdk.token.getDecimals(allIBCTokens[ii].denom) ?? 0; - const tokenResponse = await nodeFetch(`https://api.coingecko.com/api/v3/coins/${coingeckoId}`); - const tokenData = await tokenResponse.json(); - const circulatingSupply = NumberUtils.bnOrZero(tokenData?.market_data?.circulating_supply ?? 0).shiftedBy(tokenDecimals).toString(10); - totalSupplyMap.push({ - denom: allIBCTokens[ii].denom, - amount: circulatingSupply, - }); - } - return totalSupplyMap; -} - -(async () => { - const networkArr = Object.values(CarbonSDK.Network); - - for (let jj = 0; jj < networkArr.length; jj++) { - if (networkArr[jj] === CarbonSDK.Network.LocalHost) { - continue; - } - - let sdk: CarbonSDK | undefined; - try { - sdk = await CarbonSDK.instance({ - network: networkArr[jj], - }); - await sdk.token.reloadDenomGeckoMap(); - } catch (err) { - const errorTyped = err as Error; - console.log(`error: ibc total supply update incomplete for ${networkArr[jj]}.json: ${errorTyped.message}`); - }; - if (!sdk) continue; - - // get all ibc tokens - const feeTokens = await sdk.query.fee.MinGasPriceAll({ - pagination: { - limit: new Long(100000), - offset: new Long(0), - key: new Uint8Array(), - countTotal: true, - reverse: false, - }, - }); - - const totalSupplyMap: TotalSupplyItem[] = await getTotalSupplyMap(feeTokens.minGasPrices, sdk); - - const filePath = `${cwd}/configs/${networkArr[jj]}.json`; - const dataString = fs.readFileSync(filePath, "utf-8"); - let jsonData: ConfigJSON = { - network: networkArr[jj], - featured_markets: [], - blacklisted_markets: [], - blacklisted_tokens: [], - blacklisted_pools: [], - ibc_tokens_total_supply: [], - }; - try { - jsonData = JSON.parse(dataString) as ConfigJSON; - } catch (err) { } - - jsonData.ibc_tokens_total_supply = totalSupplyMap; - - const data = JSON.stringify(jsonData, null, 4); - fs.writeFileSync(filePath, data); - console.log(`success: ibc total supply update complete for ${networkArr[jj]}.json`); - } -})().catch(console.error).finally(() => process.exit(0));