# Stablecoin Peg Monitor (on-chain DEX pools, multi-chain) (`galterapp/stablecoin-peg-monitor`) Actor

Live on-chain stablecoin peg deviations (bp) from Uniswap-v3-style pools, with liquidity, tick and a dislocation flag. Includes the Polygon USDC.e/USDC/USDT pools behind Polymarket's pUSD plus pUSD supply; add any pool on Polygon, Base, Ethereum or Arbitrum. No keys.

- **URL**: https://apify.com/galterapp/stablecoin-peg-monitor.md
- **Developed by:** [Galter Time](https://apify.com/galterapp) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 result rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Stablecoin Peg Monitor — live on-chain DEX peg deviations

**What you get in one run:** the current pool price of each stablecoin pair read **directly from the chain**
(Uniswap-v3-style `slot0`), its **deviation from peg in basis points**, on-range liquidity, tick, and a
`dislocated` flag. No API keys, no accounts, ~3 seconds.

Ships with the pools that matter most for prediction-market flow: Polymarket's pUSD is minted 1:1 from
**USDC.e** only, so every event surge has to cross the Polygon USDC.e/USDC and USDC.e/USDT pools first.
The run also reports **pUSD total supply** — the collateral gauge for those inflows/outflows.

Use it to:

- **Catch peg dislocations** — schedule every 5 minutes with `onlyDislocated: true` and wire the dataset to an alert.
- **Screen permissionless DEX arb windows** — a 20+ bp gap between two USD stables in a 0.01% pool is a tradeable spread.
- **Track prediction-market collateral** — pUSD supply deltas between runs = net Polymarket inflow/outflow.
- **Monitor your own pools** — add any Uniswap v3 / Slipstream-compatible pool on Polygon, Base, Ethereum, or Arbitrum.

![Stablecoin peg monitor output table](https://files.catbox.moe/58cc9t.png)

### Sample row

```json
{"chain":"polygon","label":"USDC.e/USDC 0.01%","pool":"0xd36e…a418","token0":"USDC.e","token1":"USDC",
 "price_token1_per_token0":0.99992,"expected_price":1.0,"deviation_bp":-0.8,"tick":-1,
 "liquidity_raw":"18732041125893","dislocated":false,"direction":"token0_premium","ts":1788360000}
```

The `OUTPUT` record holds the summary: `max_abs_deviation_bp`, `dislocations[]`, `polymarket_pusd_supply_usd`.

### Input

| Field | Default | Meaning |
|---|---|---|
| `alertBp` | 20 | |deviation| ≥ this → `dislocated: true` |
| `includeDefaultPools` | true | the three Polygon USDC.e pools |
| `includePusdSupply` | true | pUSD totalSupply in OUTPUT |
| `extraPools` | \[] | `{chain, address, label, token0, token1, dec0, dec1, expectedPrice}` |
| `onlyDislocated` | false | return only flagged pools (pay only for signals) |
| `rpcUrl` | — | your own endpoint, tried first |

### Conventions

- `price_token1_per_token0 = (sqrtPriceX96 / 2^96)^2 × 10^(dec0 − dec1)`; `deviation_bp = (price / expectedPrice − 1) × 10⁴`.
- Negative deviation = token0 trades at a premium (you get less token1 per token0).
- `expectedPrice` defaults to 1.0 (USD/USD pairs); set it for non-1:1 pegs (e.g. EUR stables).

### Notes

- Read-only `eth_call` against public RPCs with fallbacks; nothing is stored, no wallet involved.
- Pool addresses in the default list were resolved from the Uniswap v3 factory, not guessed.
- Pricing: pay per pool row returned.

# Actor input Schema

## `alertBp` (type: `integer`):

A pool is flagged `dislocated` when |deviation| is at least this many bp from the expected price.

## `includeDefaultPools` (type: `boolean`):

USDC.e/USDC 0.01%, USDC.e/USDC 0.05%, USDC.e/USDT 0.01% on Polygon — the pUSD (Polymarket) on-ramp chokepoint.

## `includePusdSupply` (type: `boolean`):

Adds pUSD totalSupply (USD) to the OUTPUT summary — a gauge of prediction-market collateral inflow/outflow.

## `extraPools` (type: `array`):

Any Uniswap-v3-style pool. Fields: chain (polygon|base|ethereum|arbitrum), address, label, token0, token1, dec0, dec1, expectedPrice (default 1.0).

## `onlyDislocated` (type: `boolean`):

Return (and pay for) only pools beyond the threshold. Useful for alerting schedules.

## `rpcUrl` (type: `string`):

Your own JSON-RPC endpoint, tried first. Public endpoints are used as fallback.

## Actor input object example

```json
{
  "alertBp": 20,
  "includeDefaultPools": true,
  "includePusdSupply": true,
  "extraPools": [],
  "onlyDislocated": false
}
```

# Actor output Schema

## `rows` (type: `string`):

Dataset items: chain, label, pool, token0, token1, price\_token1\_per\_token0, expected\_price, deviation\_bp, tick, liquidity\_raw, dislocated, direction, ts.

## `summary` (type: `string`):

Key-value store record with pools\_checked, max\_abs\_deviation\_bp, dislocations\[] and polymarket\_pusd\_supply\_usd.

# 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 = {
    "extraPools": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("galterapp/stablecoin-peg-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 = { "extraPools": [] }

# Run the Actor and wait for it to finish
run = client.actor("galterapp/stablecoin-peg-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 '{
  "extraPools": []
}' |
apify call galterapp/stablecoin-peg-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,galterapp/stablecoin-peg-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/FhGZHogZTU9PkngxJ/builds/dZRr6W1COtZmQVwci/openapi.json
