From e295d57c77b225f4c711b43981e5feb4fc54b6b6 Mon Sep 17 00:00:00 2001 From: Sirapop Na Ranong Date: Fri, 10 May 2024 14:39:24 +0700 Subject: [PATCH 1/3] chore: update url for lockUnlock --- methods/tvl/getTVL.js | 2 +- package.json | 2 +- terraform/mainnet/variables.tf.example | 2 +- terraform/stagenet/variables.tf.example | 2 +- terraform/testnet/variables.tf.example | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/methods/tvl/getTVL.js b/methods/tvl/getTVL.js index 4ba53dfa..e1919c6c 100644 --- a/methods/tvl/getTVL.js +++ b/methods/tvl/getTVL.js @@ -131,7 +131,7 @@ module.exports = async params => { contract_data, gateway_address, gateway_balance, ...(isLockUnlock ? { token_manager_address, token_manager_type, token_manager_balance } : undefined), supply, total: isNativeOnCosmos ? 0 : gateway_balance + supply, - url: url && `${url}${(address === ZeroAddress ? address_path : contract_path).replace('{address}', address === ZeroAddress ? gateway_address : address)}${isNative && address !== ZeroAddress && gateway_address && assetType !== 'its' ? `?a=${gateway_address}` : ''}`, + url: url && `${url}${(address === ZeroAddress ? address_path : contract_path).replace('{address}', address === ZeroAddress ? gateway_address : address)}${isNative && address !== ZeroAddress ? gateway_address && assetType !== 'its' ? `?a=${gateway_address}` : isLockUnlock ? `?a=${token_manager_address}` : '' : ''}`, success: isNumber(isNative && assetType !== 'its' ? gateway_balance : supply), }; } diff --git a/package.json b/package.json index 35897206..6d3f2e92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "axelarscan-api", - "version": "0.0.10", + "version": "0.0.11", "description": "Axelarscan API", "main": "index.js", "scripts": { diff --git a/terraform/mainnet/variables.tf.example b/terraform/mainnet/variables.tf.example index a3414acd..4838bdfc 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.10" + default = "0.0.11" 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 cf0eacae..ca1f88ee 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.10" + default = "0.0.11" 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 08ad857b..c90db8cf 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.10" + default = "0.0.11" 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 9d6dd37e9098099d0f0a57affe969c03d207cde3 Mon Sep 17 00:00:00 2001 From: Sirapop Na Ranong Date: Fri, 10 May 2024 15:03:26 +0700 Subject: [PATCH 2/3] chore: filter its out from check alert --- methods/tvl/getTVLAlert.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/methods/tvl/getTVLAlert.js b/methods/tvl/getTVLAlert.js index 21ea2cb3..593efbfe 100644 --- a/methods/tvl/getTVLAlert.js +++ b/methods/tvl/getTVLAlert.js @@ -15,10 +15,10 @@ module.exports = async params => { test = toBoolean(test, false); const { alert_asset_value_threshold } = { ...getTVLConfig() }; - let { data } = { ...await read(TVL_COLLECTION, { range: { updated_at: { gt: moment().subtract(MAX_INTERVAL_UPDATE_SECONDS, 'seconds').unix() } } }, { size: 100 }) }; + 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).map(d => _.head(d.data))).map(d => { + data = _.orderBy(toArray(toArray(data).filter(d => d.assetType !== 'its').map(d => _.head(d.data))).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 33196d1235d34720df9d36d88e477d6ef77f1792 Mon Sep 17 00:00:00 2001 From: Sirapop Na Ranong Date: Fri, 10 May 2024 15:23:15 +0700 Subject: [PATCH 3/3] feat: set total TVL = gateway balance + secret-snip escrow balance --- methods/tvl/getTVL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/methods/tvl/getTVL.js b/methods/tvl/getTVL.js index e1919c6c..d3457419 100644 --- a/methods/tvl/getTVL.js +++ b/methods/tvl/getTVL.js @@ -222,7 +222,7 @@ module.exports = async params => { 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.values(tvl).map(d => isNativeOnEVM ? d.gateway_balance : d.total))); + 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 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}`]);