Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions automation/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ profiles:
- { name: "usdai", script: protocols/usdai/main.py }
- { name: "usdai-large-mints", script: protocols/usdai/large_mints.py }
- { name: "stables-dune-large-transfers", script: protocols/stables/dune_large_transfers.py }
- { name: "stables-oracles", script: protocols/stables/oracles.py }
- { name: "yearn-alert-large-flows", script: protocols/yearn/alert_large_flows.py }
# Cache: tks-trigger-cache.json under $CACHE_DIR (check_stuck_triggers.DEFAULT_CACHE_FILE).
- { name: "yearn-check-stuck-triggers", script: protocols/yearn/check_stuck_triggers.py, enabled: false }
Expand Down
2 changes: 1 addition & 1 deletion protocols/lrt-pegs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Curve pools that are checked are:

- ETH+/WETH
- weETH-WETH
- frxETH-WETH
- OETH/ETH
- stETH/ETH (Lido) — canonical wstETH-vs-ETH depeg gauge; wstETH deterministically wraps stETH

### Uniswap V3 pools - DISABLED ⚠️

Expand Down
26 changes: 16 additions & 10 deletions protocols/lrt-pegs/curve/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,34 @@
("OETH/ETH Curve Pool", "0xcc7d5785AD5755B6164e21495E07aDb0Ff11C2A8", 0, 1, THRESHOLD_RATIO, "origin"),
# NOTE: bool is unbalanced, whole liquidity is moved to univ3: https://app.uniswap.org/explore/pools/ethereum/0x202a6012894ae5c288ea824cbc8a9bfb26a49b93
("weETH-WETH Curve Pool", "0xDB74dfDD3BB46bE8Ce6C33dC9D82777BCFc3dEd5", 1, 0, THRESHOLD_RATIO, "weeth"),
# Lido stETH/ETH — deepest stETH<>ETH venue and the canonical wstETH depeg
# gauge (wstETH deterministically wraps stETH). Legacy pool: exposes
# balances(i) but not get_balances(). idx 0 = ETH, idx 1 = stETH.
("stETH/ETH Curve Pool", "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022", 1, 0, THRESHOLD_RATIO, "wsteth"),
]


def process_pools(chain: Chain = Chain.MAINNET):
client = ChainManager.get_client(chain)
contracts = []

# Prepare batch calls
# Read each pool's two relevant coin balances. Using ``balances(i)`` (instead
# of ``get_balances()``) keeps a single code path for both modern pools and
# legacy pools like Lido stETH/ETH that don't expose ``get_balances()``.
with client.batch_requests() as batch:
for _, pool_address, _, _, _, _ in POOL_CONFIGS:
for _, pool_address, idx_lrt, idx_other_token, _, _ in POOL_CONFIGS:
pool = client.eth.contract(address=pool_address, abi=ABI_CURVE_POOL)
contracts.append(pool)

batch.add(pool.functions.get_balances())
batch.add(pool.functions.balances(idx_lrt))
batch.add(pool.functions.balances(idx_other_token))

responses = client.execute_batch(batch)
if len(responses) != len(POOL_CONFIGS):
raise ValueError(f"Expected {len(POOL_CONFIGS)} responses from batch, got: {len(responses)}")
if len(responses) != len(POOL_CONFIGS) * 2:
raise ValueError(f"Expected {len(POOL_CONFIGS) * 2} responses from batch, got: {len(responses)}")

# Process results
for (pool_name, _, idx_lrt, idx_other_token, peg_threshold, protocol), balances in zip(POOL_CONFIGS, responses):
percentage = (balances[idx_lrt] / (balances[idx_lrt] + balances[idx_other_token])) * 100
for i, (pool_name, _, _, _, peg_threshold, protocol) in enumerate(POOL_CONFIGS):
lrt_balance = responses[i * 2]
other_balance = responses[i * 2 + 1]
percentage = (lrt_balance / (lrt_balance + other_balance)) * 100
logger.info("%s ratio is %s%%", pool_name, f"{percentage:.2f}")
if percentage > peg_threshold:
message = f"🚨 Curve Alert! {pool_name} ratio is {percentage:.2f}%"
Expand Down
Loading