From 37248c2077d4f92566e1db1af85b270e0f244d66 Mon Sep 17 00:00:00 2001 From: Sirapop Na Ranong Date: Fri, 10 May 2024 15:38:41 +0700 Subject: [PATCH 1/4] chore: filter its out from alert details --- methods/tvl/getTVLAlert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/methods/tvl/getTVLAlert.js b/methods/tvl/getTVLAlert.js index 593efbfe..6a294022 100644 --- a/methods/tvl/getTVLAlert.js +++ b/methods/tvl/getTVLAlert.js @@ -18,7 +18,7 @@ module.exports = async params => { let { data } = { ...await read(TVL_COLLECTION, { range: { updated_at: { gt: moment().subtract(MAX_INTERVAL_UPDATE_SECONDS, 'seconds').unix() } } }, { size: 1000 }) }; const { updated_at } = { ..._.head(data) }; - data = _.orderBy(toArray(toArray(data).filter(d => d.assetType !== 'its').map(d => _.head(d.data))).map(d => { + data = _.orderBy(toArray(toArray(data).map(d => _.head(toArray(d.data).filter(d => d.assetType !== 'its')))).map(d => { const { price, total, percent_diff_supply } = { ...d }; return { ...d, value: toNumber(total * price), value_diff: toNumber(total * (percent_diff_supply / 100) * price) }; }), ['value_diff', 'value', 'total'], ['desc', 'desc', 'desc']); From 5b698951fca3510882e0733eb0f8ea6d874722c9 Mon Sep 17 00:00:00 2001 From: Sirapop Na Ranong Date: Fri, 10 May 2024 15:39:10 +0700 Subject: [PATCH 2/4] chore: update lcd for osmosis --- config/chains.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/chains.yml b/config/chains.yml index 860453e5..3780bbb3 100644 --- a/config/chains.yml +++ b/config/chains.yml @@ -560,8 +560,8 @@ mainnet: chain_name: "osmosis" endpoints: lcd: - - "https://lcd.osmosis.zone" - "https://api-osmosis-ia.cosmosia.notional.ventures" + - "https://lcd.osmosis.zone" - "https://lcd-osmosis.blockapsis.com" - "https://rest-osmosis.ecostake.com" - "https://api.osmosis.interbloc.org" From 4dfc64ea9f08475d78a18b36cba659f09cf27f9b Mon Sep 17 00:00:00 2001 From: Sirapop Na Ranong Date: Fri, 10 May 2024 15:39:30 +0700 Subject: [PATCH 3/4] chore: update version --- package.json | 2 +- terraform/mainnet/variables.tf.example | 2 +- terraform/stagenet/variables.tf.example | 2 +- terraform/testnet/variables.tf.example | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6d3f2e92..af5a8d81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "axelarscan-api", - "version": "0.0.11", + "version": "0.0.12", "description": "Axelarscan API", "main": "index.js", "scripts": { diff --git a/terraform/mainnet/variables.tf.example b/terraform/mainnet/variables.tf.example index 4838bdfc..9080f1b3 100644 --- a/terraform/mainnet/variables.tf.example +++ b/terraform/mainnet/variables.tf.example @@ -45,7 +45,7 @@ variable "log_level" { variable "app_version" { description = "App version, same as docker image version" - default = "0.0.11" + default = "0.0.12" validation { error_message = "Must be valid semantic version. $Major.$Minor.$Patch" condition = can(regex("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$", var.app_version)) diff --git a/terraform/stagenet/variables.tf.example b/terraform/stagenet/variables.tf.example index ca1f88ee..0a652ddd 100644 --- a/terraform/stagenet/variables.tf.example +++ b/terraform/stagenet/variables.tf.example @@ -45,7 +45,7 @@ variable "log_level" { variable "app_version" { description = "App version, same as docker image version" - default = "0.0.11" + default = "0.0.12" validation { error_message = "Must be valid semantic version. $Major.$Minor.$Patch" condition = can(regex("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$", var.app_version)) diff --git a/terraform/testnet/variables.tf.example b/terraform/testnet/variables.tf.example index c90db8cf..c02f4f69 100644 --- a/terraform/testnet/variables.tf.example +++ b/terraform/testnet/variables.tf.example @@ -45,7 +45,7 @@ variable "log_level" { variable "app_version" { description = "App version, same as docker image version" - default = "0.0.11" + default = "0.0.12" validation { error_message = "Must be valid semantic version. $Major.$Minor.$Patch" condition = can(regex("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$", var.app_version)) From 3cff76dd159269bfed843feae7d80af4252ef341 Mon Sep 17 00:00:00 2001 From: Sirapop Na Ranong Date: Fri, 10 May 2024 15:59:11 +0700 Subject: [PATCH 4/4] feat: total = gateway balance, total on cosmos = sum(escrow except secret-snip) --- methods/tvl/getTVL.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/methods/tvl/getTVL.js b/methods/tvl/getTVL.js index d3457419..23a9b77d 100644 --- a/methods/tvl/getTVL.js +++ b/methods/tvl/getTVL.js @@ -217,12 +217,12 @@ module.exports = async params => { tvl = Object.fromEntries(Object.entries(tvl).map(([k, v]) => { const { supply, total } = { ...v }; - return [k, { ...v, supply: getChainData(k)?.chain_type !== 'cosmos' ? supply : k === 'axelarnet' && assetType !== 'its' ? isNativeOnEVM ? total - _.sum(toArray(Object.entries(tvl).filter(([k, v]) => getChainData(k)?.chain_type === 'cosmos').map(([k, v]) => v.supply))) : isNativeOnCosmos ? total ? total - _.sum(toArray(Object.entries(tvl).filter(([k, v]) => getChainData(k)?.chain_type === 'evm').map(([k, v]) => v.supply))) : 0 : supply : supply }]; + return [k, { ...v, supply: getChainData(k)?.chain_type !== 'cosmos' ? supply : k === 'axelarnet' && assetType !== 'its' ? isNativeOnEVM ? total - _.sum(toArray(Object.entries(tvl).filter(([k, v]) => getChainData(k)?.chain_type === 'cosmos').map(([k, v]) => k === 'secret-snip' ? v.total : v.supply))) : isNativeOnCosmos ? total ? total - _.sum(toArray(Object.entries(tvl).filter(([k, v]) => getChainData(k)?.chain_type === 'evm').map(([k, v]) => v.supply))) : 0 : supply : supply }]; })); const total_on_evm = _.sum(toArray(Object.entries(tvl).filter(([k, v]) => getChainData(k)?.chain_type === 'evm' && !v.token_manager_type?.startsWith('lockUnlock')).map(([k, v]) => v.supply))); - const total_on_cosmos = _.sum(toArray(Object.entries(tvl).filter(([k, v]) => getChainData(k)?.chain_type === 'cosmos' && k !== native_chain).map(([k, v]) => v[hasAllCosmosChains ? isNativeOnCosmos ? 'supply' : 'total' : 'escrow_balance']))); - const total = isNativeOnCosmos || isNativeOnAxelarnet ? total_on_evm + total_on_cosmos : assetType === 'its' ? isCanonicalITS ? _.sum(toArray(Object.values(tvl).map(d => d.token_manager_balance))) : toNumber(await getTokenCirculatingSupply(coingecko_id)) : _.sum(toArray(Object.entries(tvl).map(([k, v]) => isNativeOnEVM && k !== 'secret-snip' ? v.gateway_balance : v.total))); + const total_on_cosmos = _.sum(toArray(Object.entries(tvl).filter(([k, v]) => getChainData(k)?.chain_type === 'cosmos' && k !== native_chain).map(([k, v]) => v[hasAllCosmosChains ? isNativeOnCosmos || k === 'secret-snip' ? 'supply' : 'total' : 'escrow_balance']))); + const total = isNativeOnCosmos || isNativeOnAxelarnet ? total_on_evm + total_on_cosmos : assetType === 'its' ? isCanonicalITS ? _.sum(toArray(Object.values(tvl).map(d => d.token_manager_balance))) : toNumber(await getTokenCirculatingSupply(coingecko_id)) : _.sum(toArray(Object.entries(tvl).map(([k, v]) => isNativeOnEVM ? v.gateway_balance : v.total))); const evm_escrow_address = isNativeOnCosmos ? getAddress(isNativeOnAxelarnet ? asset : `ibc/${toHash(`transfer/${_.last(tvl[native_chain]?.ibc_channels)?.channel_id}/${asset}`)}`, axelarnet.prefix_address, 32) : undefined; const evm_escrow_balance = evm_escrow_address ? toNumber(await getCosmosBalance('axelarnet', evm_escrow_address, { ...assetData, ...addresses?.axelarnet })) : 0; const evm_escrow_address_urls = evm_escrow_address && toArray([axelarnet.explorer?.url && axelarnet.explorer.address_path && `${axelarnet.explorer.url}${axelarnet.explorer.address_path.replace('{address}', evm_escrow_address)}`, `${axelarnetLCDUrl}/cosmos/bank/v1beta1/balances/${evm_escrow_address}`]);