{"uid":"cap_5tEXijycuAg7GEDPZshJ5","slug":"stablecoin-time-weighted-peg-deviation-014b929f","name":"Stablecoin Time-Weighted Peg Deviation","description":"Time-weighted absolute peg deviation over samples. Call when summarizing depeg severity over a sample window. Returns tw_abs_deviation as deterministic JSON for $0.001 USDC via x402 on Base. First-party local math only—no RPC, live market feed, API keys, storage, or mediagen. Advisory only; the caller owns capital, risk, and production controls.","url":"https://api.delx.ai/api/v1/x402/peg-tw-deviation","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"peg":{"type":"number","description":"Target peg price (usually 1.0)"},"prices":{"type":"array","description":"Market prices / samples depending on tool"},"weights":{"type":"array","description":"Optional sample weights"}}},"responseSchema":{"type":"json","example":{"schema":"delx/util-peg-tw-deviation/v1","tw_abs_deviation":0.005000000000000004}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_WqY7JhSzX7Y8sOI2mc7kB","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes the time-weighted absolute peg deviation across a window of price samples to summarize depeg severity.","exampleAgentPrompt":"Can you compute the time-weighted absolute peg deviation for a stablecoin targeting $1.00 given these price samples [0.998, 1.002, 0.995, 1.001, 0.997] with equal weights? I want a single tw_abs_deviation summary of how bad the depeg was across that window.","exampleUseCases":[{"title":"Post-depeg severity audit","prompt":"We had a depeg event on our stablecoin last week — the sampled prices were [0.97, 0.98, 0.99, 0.985, 0.992, 0.995] against a $1.00 peg. Can you calculate the time-weighted absolute deviation so I can include a single severity number in our incident report?"},{"title":"Real-time stablecoin risk dashboard","prompt":"I'm building a risk dashboard and need to summarize peg quality for DAI over the last 10 samples: [1.001, 0.999, 1.002, 0.998, 1.000, 0.999, 1.001, 0.997, 1.003, 0.998]. Can you give me the tw_abs_deviation from $1.00 with even weights so I can display it as a health metric?"},{"title":"Weighted depeg metric for uneven sampling","prompt":"I have 5 stablecoin price readings taken at uneven intervals — prices [0.993, 0.996, 1.001, 0.998, 1.002] with time weights [0.1, 0.3, 0.2, 0.25, 0.15] — and I want the time-weighted absolute deviation from a $1.00 peg so I can compare depeg severity across different assets fairly."}],"resultDescription":"Returns a JSON object containing tw_abs_deviation, a single deterministic float representing the time-weighted mean absolute deviation of the supplied price samples from the target peg price. Computation is performed locally with pure math — no external data sources are consulted.","failureModes":["Missing or empty prices array returns a validation error","Mismatched lengths between prices and weights arrays causes an error","Non-numeric values in prices or weights cause a parsing/validation error","Peg value not supplied defaults or errors depending on server behavior","Malformed JSON body returns a 400 error"],"whenToPreferThis":"Choose this endpoint when you need a single deterministic, time-weighted summary statistic of peg deviation across a batch of price samples — for example in post-mortem reports, risk dashboards, or compliance summaries. It is ideal when you already have price samples in hand and need pure local computation with no live market feed dependency. Prefer alternatives if you need live price fetching, real-time monitoring, or continuous alerting rather than a one-shot aggregation.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T12:57:57.973Z","isFirstParty":false}