# Stablecoin Depeg Monitor - Peg Deviation Alerts (`centorprat/stablecoin-depeg-monitor`) Actor

Watch stablecoins vs their $1 peg. Each run reads keyless public prices (CoinGecko, cross-checked on Coinbase) and alerts when a coin crosses into a worse peg state or beyond your threshold. Schedule + webhook for a standing depeg alarm. Read-only, agent-callable.

- **URL**: https://apify.com/centorprat/stablecoin-depeg-monitor.md
- **Developed by:** [Centor Prat](https://apify.com/centorprat) (community)
- **Categories:** Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $8.50 / 1,000 watch runs

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Stablecoin Depeg Monitor — Peg Deviation Alerts

Know the moment a stablecoin slips its peg. Watch a basket of stablecoins and each run reads keyless public prices, measures the **deviation from $1.00**, classifies the **peg state**, and — because it remembers the previous run — alerts when a coin crosses into a worse state or beyond your threshold. Anything off-peg is **cross-checked on a second source** so a single bad print doesn't cry wolf. Schedule it + set a webhook for a standing depeg alarm. Read-only, keyless, agent-callable.

For treasuries, funds, DeFi users, risk/ops, and AI agents that need a de-peg trigger.

> Factual price observations, **not financial advice**.

### What it does

- Reads prices for your stablecoins (keyless **CoinGecko**) in one call, with 24h change.
- Measures **pegDeviationPct** = (price − 1) × 100 and classifies: `on-peg` → `minor-deviation` → `depeg-warning` → `depeg` → `severe-depeg`.
- **Cross-checks** anything off-peg against **Coinbase** spot (a second independent source) before alerting.
- **Diffs vs the previous run** (named KV store) and alerts only when a coin worsens or breaks your threshold. First run = silent baseline.

| Field | Meaning |
|---|---|
| `priceUsd`, `pegDeviationPct`, `change24hPct` | current price, distance from peg, 24h move |
| `pegState` | on-peg / minor-deviation / depeg-warning / depeg / severe-depeg |
| `coinbasePriceUsd`, `crossConfirmed` | second-source check (when off peg) |
| `signal` | baseline / on-peg / … / depeg-alert |

### Why not just ask an AI agent?

An agent has no memory and no scheduler, and would trust a single price feed. This keeps per-coin state across runs, measures deviation consistently, and **confirms a depeg on a second exchange** before alerting — so you get a reliable trigger, not a false alarm off one wick.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `stablecoins` | array | USDT, USDC, DAI, FDUSD, PYUSD, FRAX, USDE | Symbols or CoinGecko ids. |
| `depegThresholdPct` | number | 1.0 | Alert at ≥ this % from $1. |
| `webhookUrl` | string | | POST depeg alerts here. |

**Example input**

```json
{ "stablecoins": ["USDT", "USDC", "DAI", "FDUSD", "PYUSD"], "depegThresholdPct": 1.0 }
```

### Output

One record per stablecoin. **Example** (real run, on-peg):

```json
{
  "stablecoin": "USDT",
  "signal": "on-peg",
  "priceUsd": 0.998865,
  "pegDeviationPct": -0.1135,
  "change24hPct": -0.03,
  "pegState": "on-peg"
}
```

When a coin breaks peg: `signal: "depeg-alert"`, `pegState: "depeg"` (or `severe-depeg`), with `coinbasePriceUsd` + `crossConfirmed` and the `previousState` it moved from.

### Alerts / scheduling

1. Set `stablecoins`, `depegThresholdPct` and `webhookUrl`.
2. Schedule the actor (e.g. every 2–10 min).
3. First run is a silent baseline; after that, any coin that worsens past your threshold (and confirms on a second source) is POSTed to Slack/Discord/email via Make/Zapier.

### Ready-made tasks

- [Stablecoin Depeg Alert - USDT, USDC, DAI](https://apify.com/centorprat/stablecoin-depeg-monitor/examples/stablecoin-depeg-alert)

### For AI agents / MCP

```
https://mcp.apify.com/?tools=actors,docs,centorprat/stablecoin-depeg-monitor
```

Loads as `centorprat--stablecoin-depeg-monitor`. Claude Code:

```
claude mcp add apify -- npx -y @apify/actors-mcp-server --actors centorprat/stablecoin-depeg-monitor
```

### FAQ

**Which stablecoins?** Any on CoinGecko — pass symbols (USDT, USDC, DAI, FDUSD, PYUSD, TUSD, FRAX, USDE, …) or CoinGecko ids.

**How does it avoid false alarms?** Anything off-peg is re-checked on Coinbase spot; an alert needs the second source to agree (when available).

**Does it need a key?** No — keyless public price APIs.

**Does the first run alert?** No — it's a silent baseline.

**Cost?** Pay-per-event: a base per run + a premium per depeg alert. Quiet runs cost only the base.

### Data & attribution

Public price data via the keyless CoinGecko API, cross-checked against Coinbase spot. No keys, no personal data. Factual observations, not financial advice.

### Related actors

- [Token Honeypot & Rug Pull Safety Check](https://apify.com/centorprat/token-honeypot-rugpull-check)
- [DEX Token Market Snapshot](https://apify.com/centorprat/dex-token-market-snapshot)
- [Token Price & Liquidity Alert Monitor](https://apify.com/centorprat/token-price-liquidity-alert-monitor)

# Actor input Schema

## `stablecoins` (type: `array`):

Symbols (USDT, USDC, DAI, FDUSD, PYUSD, TUSD, FRAX, USDE, ...) or CoinGecko ids. Leave empty for a default basket.

## `depegThresholdPct` (type: `number`):

Alert when a coin deviates at least this % from $1.00 (e.g. 1.0 = 1 cent).

## `webhookUrl` (type: `string`):

If set, depeg alerts are POSTed here as JSON when a run fires them.

## Actor input object example

```json
{
  "stablecoins": [
    "USDT",
    "USDC",
    "DAI",
    "FDUSD",
    "PYUSD",
    "FRAX",
    "USDE"
  ],
  "depegThresholdPct": 1
}
```

# Actor output Schema

## `monitor` (type: `string`):

Per stablecoin: price, peg deviation %, 24h change, a peg state (on-peg / minor-deviation / depeg-warning / depeg / severe-depeg), a cross-check price from a second source when off peg, and whether this run fired a depeg alert. First run records a silent baseline.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "stablecoins": [
        "USDT",
        "USDC",
        "DAI",
        "FDUSD",
        "PYUSD",
        "FRAX",
        "USDE"
    ],
    "depegThresholdPct": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("centorprat/stablecoin-depeg-monitor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "stablecoins": [
        "USDT",
        "USDC",
        "DAI",
        "FDUSD",
        "PYUSD",
        "FRAX",
        "USDE",
    ],
    "depegThresholdPct": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("centorprat/stablecoin-depeg-monitor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "stablecoins": [
    "USDT",
    "USDC",
    "DAI",
    "FDUSD",
    "PYUSD",
    "FRAX",
    "USDE"
  ],
  "depegThresholdPct": 1
}' |
apify call centorprat/stablecoin-depeg-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,centorprat/stablecoin-depeg-monitor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/FDNyb9bd8mkvsxlyF/builds/de9rj6yF8PlNdLgzP/openapi.json
