Skip to content

Commit

Permalink
add: base, yeth (#19)
Browse files Browse the repository at this point in the history
* add: base, yeth

* Fix: output tvl=0 if network not up, fix readme

* fix: revert network labels for API routes

---------

Co-authored-by: crebsy <[email protected]>
  • Loading branch information
0xBasically and crebsy authored Oct 31, 2023
1 parent 2421d76 commit ea9a6e1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ $ curl localhost:5000/tvl/eth
}
```
supported networks are:
- `ETH`
- `FTM`
- `OPI`
- `ARB`
- `eth`
- `ftm`
- `opt`
- `arb`
- `base`

### `/tvl/total`
returns the sum of the TVLs of all networks:
Expand Down
2 changes: 1 addition & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
app = Flask(__name__)
CORS(app)

NETWORKS = ['eth', 'ftm', 'opt', 'arb']
NETWORKS = ['eth', 'ftm', 'opt', 'arb', 'base']

UNIT_USD = 'USD'

Expand Down
22 changes: 13 additions & 9 deletions grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@

# Explanation of query
# sum v2 vaults does not subtract delegated deposits
QUERY_FTM_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"FTM\"}))"""
QUERY_FTM_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"FTM\"})) or vector(0)"""

# Explanation of query everything below is only on eth
# Sum of v1 vaults + sum of v2 vaults + sum of earn - sum of v2 vault funds deposited into other v2 vaults + veCRV holdings
QUERY_ETH_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"ETH\"}))"""
QUERY_ETH_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"ETH\"})) or vector(0)"""

QUERY_OPT_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"OPTI\"}))"""
QUERY_styETH_TVL = """yeth{product=\"st-yETH\",param=\"tvl\"}"""

QUERY_ARB_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"ARB\"}))"""
QUERY_OPTI_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"OPTI\"})) or vector(0)"""

QUERY_TOTAL_TVL = QUERY_ETH_TVL + " + " + QUERY_FTM_TVL + " + " + QUERY_OPT_TVL + " + " + QUERY_ARB_TVL
QUERY_BASE_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"BASE\"})) or vector(0)"""

QUERY_ARBI_TVL = """sum(sum by (vault, version, address) (yearn_vault{param=\"tvl\", experimental=\"false\", network=\"ARB\"})) or vector(0)"""

QUERY_TOTAL_TVL = QUERY_ETH_TVL + " + " + QUERY_FTM_TVL + " + " + QUERY_OPTI_TVL + " + " + QUERY_ARBI_TVL + " + " + QUERY_BASE_TVL + " + " + QUERY_styETH_TVL

# Partner queries
# Count of unique entries in the partner field
Expand All @@ -35,8 +37,10 @@
'tvl_total': QUERY_TOTAL_TVL,
'tvl_eth': QUERY_ETH_TVL,
'tvl_ftm': QUERY_FTM_TVL,
'tvl_opt': QUERY_OPT_TVL,
'tvl_arb': QUERY_ARB_TVL,
'tvl_opti': QUERY_OPTI_TVL,
'tvl_arbi': QUERY_ARBI_TVL,
'tvl_base': QUERY_BASE_TVL,
'tvl_styETH': QUERY_styETH_TVL,
'partners_count': QUERY_PAR_CNT,
'partners_total': QUERY_PAR_TOTAL,
}
Expand Down

0 comments on commit ea9a6e1

Please sign in to comment.