Depth Gate & Borrow Caps
PredMart's depth gate system is a sophisticated risk management mechanism that dynamically limits how much USDC can be borrowed against each Polymarket token based on the real liquidity available in that token's orderbook. This prevents a scenario where large borrow positions are taken against illiquid markets that cannot be efficiently liquidated.
This page explains why the depth gate exists, how it works technically, how borrow caps are calculated, and how these limits interact with other protocol constraints.
The Problem: Illiquid Markets and Liquidation Risk
When PredMart liquidates a position, the seized collateral (Polymarket shares) must be sold on the open market (Polymarket's CLOB) to convert it back to USDC. This sell pressure is absorbed by the buy-side liquidity in the orderbook.
If a large position is liquidated against a thin (illiquid) market, several problems can occur:
-
Price slippage: Selling a large number of shares into a thin orderbook moves the price significantly. If 10,000 shares need to be sold but only 2,000 shares of buy orders exist near the current price, the remaining 8,000 shares would be sold at much lower prices.
-
Cascading liquidations: The price impact from selling seized collateral could trigger liquidations of other positions in the same token, creating a cascade of selling pressure.
-
Incomplete sales: If there isn't enough buy-side liquidity at any price, some seized shares may not be sellable at all, increasing the protocol's unsold inventory risk.
-
Bad debt: Insufficient liquidation proceeds directly translate to bad debt for the lending pool.
The depth gate addresses these risks by ensuring that the maximum borrowable amount for each token is proportional to the market's ability to absorb liquidation selling pressure.
How the Depth Gate Works
Overview
The depth gate operates through a three-step process:
- Sample: Periodically measure the orderbook depth for each token
- Aggregate: Compute a robust statistic from historical samples
- Cap: Set the maximum borrow amount based on the aggregated depth
Step 1: Depth Sampling
PredMart's backend runs a depth sampling task every 60 minutes (configurable via DEPTH_GATE_SAMPLE_INTERVAL_MIN). For each token that has active collateral positions, the sampler:
- Fetches the full ask-side orderbook from Polymarket's CLOB API
- Calculates the total USDC value available on the ask side (the amount of buy interest in the market)
- Stores the result as a
DepthSnapshotin the database
The ask side is used because during a liquidation, PredMart sells shares into buy orders (the ask side from the liquidator's perspective represents the sell side of the book — but specifically, the protocol is interested in how much buying pressure exists to absorb its sells).
Step 2: Statistical Aggregation
Rather than using a single point-in-time snapshot (which could be manipulated or anomalous), the depth gate uses a robust statistical measure over a historical window:
- Lookback period: 7 days (
DEPTH_GATE_LOOKBACK_DAYS = 7) - Statistic: 25th percentile (
DEPTH_GATE_PERCENTILE = 25)
The 25th percentile over 7 days means: "the depth is at or above this level 75% of the time over the past week." This is conservative — it filters out temporary spikes in depth (e.g., a market maker briefly posting large orders) and focuses on the sustained, reliable liquidity.
Additionally, the system requires a minimum sample uptime of 80% (DEPTH_GATE_MIN_UPTIME = 0.8). If fewer than 80% of the expected depth samples exist for a token's history window, borrowing is blocked entirely. This prevents scenarios where sparse, unreliable data could result in an inaccurate depth estimate.
Ask-Side Depth Measurement
When measuring orderbook depth, PredMart doesn't count the entire ask side of the book. Instead, it only counts asks within $0.10 of the best ask price (DEPTH_GATE_ASK_BAND = 0.10). This focuses the measurement on the realistic, executable liquidity near the current price — not distant orders placed far from the market that would provide no practical cushion during a liquidation.
Pre-Tracking High-Volume Markets
To ensure depth data is available before users start borrowing against a token, PredMart proactively samples depth for high-volume Polymarket markets — specifically, markets with cumulative trading volume of at least $1,000 (DEPTH_GATE_PRETRACK_VOLUME_MIN). This list is refreshed every 30 minutes from Polymarket's Gamma API. Pre-tracking means that when a user first deposits collateral from a popular market, depth history may already be available, reducing the waiting period before borrowing becomes possible.
Step 3: Cap Calculation with Graduated Scaling
The depth-gated cap isn't simply the 25th percentile depth. It also applies a graduated scaling factor based on how long the token has had depth data:
| History Age | Divisor | Effective Cap |
|---|---|---|
| 7+ days | 1.0 | Full pool cap |
| 6 days | 1.5 | 67% of pool cap |
| 5 days | 2.0 | 50% of pool cap |
| 4 days | 2.5 | 40% of pool cap |
| 3 days | 3.0 | 33% of pool cap |
| 2 days | 5.0 | 20% of pool cap |
| 1 day | 7.0 | 14% of pool cap |
| 12 hours | 10.0 | 10% of pool cap |
| 6 hours | 15.0 | 7% of pool cap |
| 2+ hours | 20.0 | 5% of pool cap |
| Less than 2 hours | — | No borrowing allowed |
This graduated scaling ensures that new tokens (which have limited depth history) are treated conservatively. A token that just appeared on Polymarket 3 hours ago shouldn't have the same borrow cap as one with a week of proven liquidity.
Final Borrow Cap
The final maximum borrow amount for any token is the minimum of:
- Pool cap:
totalAssets × poolCapBps / 10000(currently 5% of pool) - Depth-gated cap: The graduated scaled depth value
- Available liquidity: USDC currently available in the pool
maxBorrow = min(poolCap, depthGateCap, availableLiquidity)
This value is signed by the oracle and included in the priceData sent to the smart contract. The contract enforces that:
totalBorrowedPerToken[tokenId] + newBorrow <= priceData.maxBorrow
The Price Drop Guard
In addition to the depth gate, PredMart implements a price drop guard that blocks new borrow transactions during rapid price crashes. This is a separate but complementary safety mechanism.
How It Works
The backend monitors price changes over a rolling 3-minute window (PRICE_DROP_WINDOW = 180 seconds). If the price drops by more than:
- 35% relative (
PRICE_DROP_THRESHOLD_PCT = 0.35) — the price has fallen by more than a third, AND - $0.08 absolute (
PRICE_DROP_THRESHOLD_ABS = 0.08) — the drop is at least 8 cents
Then the oracle refuses to sign borrow transactions for that token. This blocks all new borrowing until the price stabilizes.
Why Both Thresholds?
The dual threshold prevents false positives:
- A share dropping from $0.05 to $0.03 is a 40% relative drop but only $0.02 absolute — this is normal volatility at low prices and shouldn't block borrowing.
- A share dropping from $0.80 to $0.72 is only a 10% relative drop — also normal and shouldn't trigger the guard.
- A share dropping from $0.60 to $0.35 is both a 42% relative drop AND a $0.25 absolute drop — this is likely a market-moving event (possibly resolution-related) and should absolutely block new borrowing.
Timing
The price drop guard uses a sliding window approach:
- Prices are cached with timestamps
- On each borrow request, the system compares the current price to the price 3 minutes ago
- If the drop exceeds both thresholds, the borrow is blocked
- Once the 3-minute window passes without triggering, borrowing resumes
Depth Gate Status API
Developers and users can query the current depth gate status for all active tokens:
GET https://api.predmart.com/lending/depth-status
This endpoint returns, for each token:
- The current depth-gated max borrow
- The pool cap limit
- The effective limit (minimum of the two)
- The number of depth samples available
- The age of the oldest sample
- Whether the price drop guard is active
Practical Implications for Borrowers
High-Liquidity Markets
For popular Polymarket markets (e.g., presidential elections, major sporting events) with deep orderbooks:
- Depth-gated caps are typically at or near the pool cap (5%)
- Borrowing is relatively unrestricted
- Liquidation can be executed efficiently with minimal price impact
Low-Liquidity Markets
For niche or new Polymarket markets with thin orderbooks:
- Depth-gated caps may be significantly below the pool cap
- Borrowing may be limited to smaller amounts
- If the market is very new (< 2 hours of history), borrowing may be blocked entirely
What Happens If Depth Decreases
If a market's liquidity decreases over time (market makers pull orders, volume drops):
- The 25th percentile depth will gradually decrease
- The depth-gated cap will decrease accordingly
- Existing borrow positions are not affected — the cap only applies to new borrows
- However, existing positions are still subject to liquidation, and thin liquidity may make liquidation less efficient
Interaction with Other Limits
The depth gate is one of several borrow-limiting mechanisms in PredMart:
| Limit Type | Applied By | Affects |
|---|---|---|
| LTV ratio | Smart contract | Max borrow per individual position |
| Pool cap | Smart contract | Max total borrow per token (5% of pool) |
| Depth gate | Oracle (signed) | Max total borrow per token (liquidity-based) |
| Price drop guard | Oracle (unsigned) | Blocks all new borrows during crashes |
| Pool liquidity | Smart contract | Can't borrow more than available USDC |
| Min borrow | Smart contract | Minimum $1 USDC per borrow |
All of these limits work together to form a comprehensive risk framework:
- LTV limits individual position risk
- Pool cap limits per-token concentration risk
- Depth gate limits illiquidity risk
- Price drop guard limits timing risk during volatility
- Pool liquidity ensures the pool can actually fund the borrow
Depth Gate Parameters Summary
| Parameter | Value | Description |
|---|---|---|
| Sample Interval | 60 minutes | How often orderbook depth is measured |
| Lookback Period | 7 days | Historical window for percentile calculation |
| Percentile | 25th | Statistical measure used (conservative) |
| Ask Band | $0.10 | Only count asks within $0.10 of best ask |
| Minimum Uptime | 80% | Require 80% of expected samples to exist |
| Minimum History | 2 hours | No borrowing allowed before this |
| Full Cap History | 7+ days | Full pool cap available after 7 days |
| Pretrack Volume | $1,000 | Pre-sample markets with this cumulative volume |
| Pool Cap | 5% (500 BPS) | Maximum per-token borrow as % of pool |
| Price Drop Window | 3 minutes | Rolling window for crash detection |
| Price Drop Threshold (Relative) | 35% | Minimum relative drop to trigger guard |
| Price Drop Threshold (Absolute) | $0.08 | Minimum absolute drop to trigger guard |
Next Steps
- Risk Parameters — The LTV curve and health factor
- Liquidation — How depth affects liquidation efficiency
- Protocol Constants — Full reference of all parameters
- Smart Contract — Technical reference for developers