Skip to content

Commit

Permalink
feat: set value threshold for diff of escrow balance of each chain to…
Browse files Browse the repository at this point in the history
… 200k (#75)
  • Loading branch information
nrsirapop authored Aug 1, 2024
1 parent 4c6ba84 commit 8dc7e3b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
5 changes: 5 additions & 0 deletions config/tvl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,37 @@
mainnet:
percent_diff_escrow_supply_threshold: 5.0
percent_diff_total_supply_threshold: 5.0
alert_asset_escrow_value_threshold: 200000
alert_asset_value_threshold: 3000000



testnet:
percent_diff_escrow_supply_threshold: 5.0
percent_diff_total_supply_threshold: 5.0
alert_asset_escrow_value_threshold: 200000
alert_asset_value_threshold: 3000000



stagenet:
percent_diff_escrow_supply_threshold: 5.0
percent_diff_total_supply_threshold: 5.0
alert_asset_escrow_value_threshold: 200000
alert_asset_value_threshold: 3000000



devnet-amplifier:
percent_diff_escrow_supply_threshold: 5.0
percent_diff_total_supply_threshold: 5.0
alert_asset_escrow_value_threshold: 200000
alert_asset_value_threshold: 3000000



devnet-verifiers:
percent_diff_escrow_supply_threshold: 5.0
percent_diff_total_supply_threshold: 5.0
alert_asset_escrow_value_threshold: 200000
alert_asset_value_threshold: 3000000
14 changes: 6 additions & 8 deletions methods/tvl/getTVLAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const MAX_INTERVAL_UPDATE_SECONDS = 60 * 60;
module.exports = async params => {
let { test } = { ...params };
test = toBoolean(test, false);
const { alert_asset_value_threshold } = { ...getTVLConfig() };
const { alert_asset_escrow_value_threshold, alert_asset_value_threshold } = { ...getTVLConfig() };

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) };
Expand All @@ -24,13 +24,11 @@ module.exports = async params => {
}), ['value_diff', 'value', 'total'], ['desc', 'desc', 'desc']);

const toAlertData = data.filter(d => (d.is_abnormal_supply && d.value_diff > alert_asset_value_threshold) || (
toArray(Object.values({ ...d.tvl })).findIndex(_d => _d.is_abnormal_supply) > -1 && _.sum(
Object.values(d.tvl).map(_d => {
const { price } = { ...d };
const { supply, escrow_balance, percent_diff_supply } = { ..._d };
return toNumber((supply || escrow_balance) * (percent_diff_supply / 100) * price);
})
) > alert_asset_value_threshold
toArray(Object.values({ ...d.tvl })).findIndex(_d => _d.is_abnormal_supply) > -1 && Object.values(d.tvl).findIndex(_d => {
const { price } = { ...d };
const { supply, escrow_balance, percent_diff_supply } = { ..._d };
return toNumber((supply || escrow_balance) * (percent_diff_supply / 100) * price) > alert_asset_escrow_value_threshold;
}) > -1
));

data = test && toAlertData.length === 0 && data.length > 0 ? _.slice(data, 0, 1) : toAlertData;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axelarscan-api",
"version": "0.0.47",
"version": "0.0.48",
"description": "Axelarscan API",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion terraform/devnet-amplifier/variables.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ variable "log_level" {

variable "app_version" {
description = "App version, same as docker image version"
default = "0.0.47"
default = "0.0.48"
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))
Expand Down
2 changes: 1 addition & 1 deletion terraform/devnet-verifiers/variables.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ variable "log_level" {

variable "app_version" {
description = "App version, same as docker image version"
default = "0.0.47"
default = "0.0.48"
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))
Expand Down
2 changes: 1 addition & 1 deletion terraform/mainnet/variables.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ variable "log_level" {

variable "app_version" {
description = "App version, same as docker image version"
default = "0.0.47"
default = "0.0.48"
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))
Expand Down
2 changes: 1 addition & 1 deletion terraform/stagenet/variables.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ variable "log_level" {

variable "app_version" {
description = "App version, same as docker image version"
default = "0.0.47"
default = "0.0.48"
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))
Expand Down
2 changes: 1 addition & 1 deletion terraform/testnet/variables.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ variable "log_level" {

variable "app_version" {
description = "App version, same as docker image version"
default = "0.0.47"
default = "0.0.48"
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))
Expand Down

0 comments on commit 8dc7e3b

Please sign in to comment.