Models / Tokenized assets / rwa_collateral
Token as collateral
How far is a loan against a token from liquidation on the oracle's clock and on the redemption clock, and what does a liquidation through the pool leave behind?
Takes a loan against a token: health factor, fall to liquidation, that fall in stdevs over the oracle lag and the redemption time, the driftless chance of touching the line, a whole-position liquidation through a constant-product pool with slippage and bad debt, carry, the highest LTV for a buffer, and repeated borrowing. Every number comes from the caller. Not a price, a rating or advice.
On these numbers, the health factor is 1.143, the line is 17 stdevs away over the oracle lag and 1.79 over the redemption time, a liquidation at the line through the pool leaves 663,310 of bad debt, and the highest LTV for 3 stdevs is 63.98% against 70% now.
Hypothetical, and on made-up numbers until you replace them. Nobody traded this, and nothing here is on offer.
Readings
The numbers, with their units.
Health factor
watch1.1429
Collateral 10,000,000, threshold 80%, debt 7,000,000. LTV 70%.
Fall to the line
12.5%
Collateral value falls to 8,750,000. In log terms 13.353%.
Stdevs to the line, oracle lag
17.01
One stdev is 0.785% over 24 hours. Chance of touching 0%.
Stdevs to the line, redemption
watch1.7927
One stdev is 7.448% over 90 days. Chance of touching 7.3015%.
Slippage selling at the line
breach23.77%
At today's price it would be 25%, with 0 of bad debt. The pool's cash at the line is 28,062,430.
Bad debt at the line
breach663,310
Proceeds 6,670,200, after the penalty 6,336,690, against debt of 7,000,000.
Hypothetical carry a year
410,000
13.67% on equity of 3,000,000. Before any cost of a liquidation.
Highest LTV for the buffer
breach63.98%
3 stdevs over the redemption time, against 70% now.
What flips it
The value of one input where the outcome changes, with the others held.
asset_vol_pct
8.9637%now 15
At this vol the loan sits exactly 3 stdevs from the line over the redemption time. Above it the line is closer than that.
redemption_days
32.14daysnow 90
At this redemption time the loan sits exactly 3 stdevs from the line. Longer than this, the line is closer than that.
pool_cash_depth
49,888,765now 30,000,000
With this much cash in the pool, at the same price, a liquidation at the line just clears the debt after slippage and penalty. With less it leaves bad debt.
Flags
What went past a line, and what to read before you trust the rest.
- breachThe LTV of 70% is over the 63.98% that leaves 3 stdevs over the redemption time. over_buffer
- watchThe line is 17 stdevs away on the oracle's clock and 1.79 on the redemption clock. A liquidator holding the token can't reach its cash for 90 days. clock_mismatch
- breachA liquidation at the line through the pool loses 23.77% to slippage and leaves 663,310 of bad debt, though the collateral there is worth 8,750,000 on the oracle. bad_debt_at_line
What this leaves out
What the formula leaves out, by name.
- Other borrowers liquidating through the same pool at the same time, which is the usual case in a fall.
- Liquidity providers leaving the pool as the price falls, beyond the arbitrage move above.
- Partial liquidation and the capital a liquidator needs. A liquidator may not exist at this size.
- Jumps, and hours when the asset under the token can't trade while the token still can.
- Interest on the debt and yield on the collateral during the window. The line is held still.
- Oracle errors or manipulation, beyond the lag sent.
- Gates, queues and minimums on the redemption route.
- Whether this holder may acquire, hold, mint, redeem, pledge, sell or transfer this token, or use any pool. Those are legal questions for counsel.
- Taxes and transaction costs.
What it took as given (10)
What it took as given to get here.
- Health factor = collateral * threshold / debt. The line is where it equals 1, at a collateral value of debt / threshold.
- Returns are lognormal with no drift. The distance to the line is ln(health factor), not the simple percent fall. z = distance / (vol * sqrt(t)), with t = hours / 8760 or days / 365, a 365-day calendar.
- The chance of touching the line within t is 2 * Phi(-z), the driftless reflection formula. It is an approximation: no drift, constant vol, continuous watching, no jumps. The chance of being under the line at the end of t alone is half of it.
- The pool is constant-product with no fee. Without oracle_price, the tokens to sell are collateral / pool mid, so at value V the proceeds are V * y / (V + y), and token depth cancels out.
- A liquidation at the line comes after the price fall, so arbitrage has already moved the pool: its product holds, cash depth falls to y * sqrt(p) and token depth rises to x / sqrt(p), where p is the price against today. The pool's gap to the oracle stays as it is.
- Liquidation sells the whole position. The penalty comes off the proceeds first. Bad debt = max(0, debt - proceeds * (1 - penalty)). Anything over the debt goes back to the borrower.
- The row for an oracle lag takes a further fall of buffer_sigmas stdevs over the lag, past the line, before the sale. The redemption row has no slippage but takes that fall over the redemption time.
- Carry = collateral * yield - debt * borrow, a year, before costs. On equity it is over collateral less debt.
- Highest LTV = threshold * exp(-buffer_sigmas * vol * sqrt(redemption time)). At that LTV the line is exactly buffer_sigmas stdevs away.
- The loop table starts from the sent collateral with no debt. After n loops at LTV L, exposure is (1 - L^(n+1)) / (1 - L) per 1 of capital, debt is that less 1, and everything stays at the same price.
The data
Distance to the line
| Window | Time | One stdev % | Stdevs to the line | Chance of touching it % |
|---|---|---|---|---|
| Oracle lag | 24 hours | 0.7851 | 17.01 | 0 |
| Redemption | 90 days | 7.4485 | 1.7927 | 7.3015 |
Liquidating the whole position
| Case | Oracle value | Proceeds | Slippage % | After penalty | Bad debt | Back to the borrower |
|---|---|---|---|---|---|---|
| Today's value, through the pool | 10,000,000 | 7,500,000 | 25 | 7,125,000 | 0 | 125,000 |
| At the line, through the pool | 8,750,000 | 6,670,200 | 23.77 | 6,336,690 | 663,310 | 0 |
| At the line then 3 stdevs over the oracle lag, through the pool | 8,546,310 | 6,533,106 | 23.56 | 6,206,451 | 793,549 | 0 |
| At the line then 3 stdevs over the redemption time, by redemption | 6,997,830 | 6,997,830 | 0 | 6,647,939 | 352,061 | 0 |
Repeated borrowing at 70% LTV, hypothetical, from the sent collateral with no debt. Exposure limit 3.3333 per 1 of capital
| Loops | Exposure per 1 | Debt per 1 | Overall LTV % | Health factor | Fall to the line % | Hypothetical carry on capital % | Vol on capital % | Slippage at the line % | Bad debt at the line |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1.7 | 0.7 | 41.18 | 1.9429 | 48.53 | 10.4 | 25.5 | 28.9 | 1,090,123 |
| 2 | 2.19 | 1.19 | 54.34 | 1.4723 | 32.08 | 11.38 | 32.85 | 37.56 | 3,076,956 |
| 3 | 2.533 | 1.533 | 60.52 | 1.3219 | 24.35 | 12.07 | 37.99 | 42.34 | 4,833,830 |
| 4 | 2.7731 | 1.7731 | 63.94 | 1.2512 | 20.08 | 12.55 | 41.6 | 45.25 | 6,202,463 |
| 5 | 2.9412 | 1.9412 | 66 | 1.2121 | 17.5 | 12.88 | 44.12 | 47.1 | 7,218,311 |
Paste it into your agent
No connection needed. This prompt carries the method, the conventions and what this site's engine gives on the made-up numbers, so your agent can check its own work before it touches real ones. Every prompt, with its hash, is listed at /prompts.json. A copy that stays fixed for this version, for a stack to point at: /v/1.0/models/rwa_collateral.md.
# Token as collateral: a prompt from hedgefund.mdPaste this into your AI agent. It needs no connection to hedgefund.md. An agent that can run code should write and run it, and shouldn't work a long series by hand.**Question.** How far is a loan against a token from liquidation on the oracle's clock and on the redemption clock, and what does a liquidation through the pool leave behind?## MethodHealth = C * threshold / D. Fall to the line = 1 - 1 / health. z = ln(health) / (vol * sqrt(t)). Touch chance = 2 * Phi(-z). Pool at a price ratio p: y' = y sqrt(p), x' = x / sqrt(p), proceeds = y' n / (x' + n). Bad debt = max(0, D - proceeds * (1 - penalty)). Carry = C * yield - D * borrow. Highest LTV = threshold * exp(-sigmas * vol * sqrt(t)). Loops: exposure = (1 - L^(n+1)) / (1 - L), limit 1 / (1 - L).## Conventions- Health factor = collateral * threshold / debt. The line is where it equals 1, at a collateral value of debt / threshold.- Returns are lognormal with no drift. The distance to the line is ln(health factor), not the simple percent fall. z = distance / (vol * sqrt(t)), with t = hours / 8760 or days / 365, a 365-day calendar.- The chance of touching the line within t is 2 * Phi(-z), the driftless reflection formula. It is an approximation: no drift, constant vol, continuous watching, no jumps. The chance of being under the line at the end of t alone is half of it.- The pool is constant-product with no fee. Without oracle_price, the tokens to sell are collateral / pool mid, so at value V the proceeds are V * y / (V + y), and token depth cancels out.- A liquidation at the line comes after the price fall, so arbitrage has already moved the pool: its product holds, cash depth falls to y * sqrt(p) and token depth rises to x / sqrt(p), where p is the price against today. The pool's gap to the oracle stays as it is.- Liquidation sells the whole position. The penalty comes off the proceeds first. Bad debt = max(0, debt - proceeds * (1 - penalty)). Anything over the debt goes back to the borrower.- The row for an oracle lag takes a further fall of buffer_sigmas stdevs over the lag, past the line, before the sale. The redemption row has no slippage but takes that fall over the redemption time.- Carry = collateral * yield - debt * borrow, a year, before costs. On equity it is over collateral less debt.- Highest LTV = threshold * exp(-buffer_sigmas * vol * sqrt(redemption time)). At that LTV the line is exactly buffer_sigmas stdevs away.- The loop table starts from the sent collateral with no debt. After n loops at LTV L, exposure is (1 - L^(n+1)) / (1 - L) per 1 of capital, debt is that less 1, and everything stays at the same price.## Step 1: check your method on these made-up numbersThe numbers and names below are made up. They aren't market levels, typical values or anyone's real figures.```json{ "collateral_value": 10000000, "debt": 7000000, "liquidation_threshold_pct": 80, "liquidation_penalty_pct": 5, "asset_vol_pct": 15, "oracle_lag_hours": 24, "redemption_days": 90, "pool_cash_depth": 30000000, "pool_token_depth": 300000, "borrow_rate_pct": 7, "asset_yield_pct": 9, "buffer_sigmas": 3}```Work them out with the method above. Yours should match these within 0.5%.- Health factor: 1.1429- Fall to the line: 12.5 %- Stdevs to the line, oracle lag: 17.0074- Stdevs to the line, redemption: 1.7927- Slippage selling at the line: 23.769 %- Bad debt at the line: 663310.1872- Hypothetical carry a year: 410000- Highest LTV for the buffer: 63.98 %Where the outcome flips, with the other inputs held:- asset_vol_pct at 8.9637: At this vol the loan sits exactly 3 stdevs from the line over the redemption time. Above it the line is closer than that.- redemption_days at 32.1392: At this redemption time the loan sits exactly 3 stdevs from the line. Longer than this, the line is closer than that.- pool_cash_depth at 49888765.16: With this much cash in the pool, at the same price, a liquidation at the line just clears the debt after slippage and penalty. With less it leaves bad debt.If yours differ, stop and tell the person which ones and by how much. Don't go on to real numbers until they match, or until the person has seen the difference. These values come from one engine and can be wrong too.## Step 2: run it on the person's numbersReplace every input with the person's own. Ask for any number you don't have, and don't invent one.## Step 3: reportGive one sentence beginning "On these numbers,", then the values, then where the outcome flips. Always add what this leaves out:- Other borrowers liquidating through the same pool at the same time, which is the usual case in a fall.- Liquidity providers leaving the pool as the price falls, beyond the arbitrage move above.- Partial liquidation and the capital a liquidator needs. A liquidator may not exist at this size.- Jumps, and hours when the asset under the token can't trade while the token still can.- Interest on the debt and yield on the collateral during the window. The line is held still.- Oracle errors or manipulation, beyond the lag sent.- Gates, queues and minimums on the redemption route.- Whether this holder may acquire, hold, mint, redeem, pledge, sell or transfer this token, or use any pool. Those are legal questions for counsel.- Taxes and transaction costs.## LimitsResults are hypothetical: arithmetic on the numbers given, prepared with hindsight. Nobody achieved them, and costs and liquidity are only as assumed. They aren't a forecast, a recommendation, an offer or a record of real trading. Don't say what to buy, sell or hold, and don't use them to market an investment. Whether a person may hold or trade an instrument is a legal question for counsel.Provided as is, at your own risk, by hedgefund.md, which is not a fund and isn't anyone's adviser. Version 1.0. Source: https://hedgefund.md/models/rwa_collateral/prompt.md. Terms: https://hedgefund.md/termsCall it
The same code answers on this page, over HTTP, over MCP and on your own machine, and the same inputs give the same bytes. No key, and nothing is stored. Send positions by POST or run the library, because a URL can land in a server log. model.md holds all of this for your agent.
POST the inputs to /api/v1/rwa_collateral.
curl -s https://hedgefund.md/api/v1/rwa_collateral \ -H 'content-type: application/json' \ -d '{"collateral_value":10000000,"debt":7000000,"liquidation_threshold_pct":80,"liquidation_penalty_pct":5,"asset_vol_pct":15,"oracle_lag_hours":24,"redemption_days":90,"pool_cash_depth":30000000,"pool_token_depth":300000,"borrow_rate_pct":7,"asset_yield_pct":9,"buffer_sigmas":3}' \ | jq '{summary, flags, flips, not_modeled, inputs_hash}'The tool is rwa_collateral on https://hedgefund.md/mcp.
curl -s https://hedgefund.md/mcp \ -H 'content-type: application/json' -H 'accept: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"rwa_collateral","arguments":{"collateral_value":10000000,"debt":7000000,"liquidation_threshold_pct":80,"liquidation_penalty_pct":5,"asset_vol_pct":15,"oracle_lag_hours":24,"redemption_days":90,"pool_cash_depth":30000000,"pool_token_depth":300000,"borrow_rate_pct":7,"asset_yield_pct":9,"buffer_sigmas":3}}}' \ | jq '.result.structuredContent | {summary, flags, flips, not_modeled, inputs_hash}'One file with no dependencies, and nothing is sent anywhere.
curl -fsSL https://hedgefund.md/hedgefund.mjs -o hedgefund.mjs # read it before you run itnode hedgefund.mjs template rwa_collateral > mine.json # replace every number in itnode hedgefund.mjs run rwa_collateral mine.json | jq '{summary, flags, flips, not_modeled, inputs_hash}'Made-up numbers that run as they stand. Replace every one.
{ "collateral_value": 10000000, "debt": 7000000, "liquidation_threshold_pct": 80, "liquidation_penalty_pct": 5, "asset_vol_pct": 15, "oracle_lag_hours": 24, "redemption_days": 90, "pool_cash_depth": 30000000, "pool_token_depth": 300000, "borrow_rate_pct": 7, "asset_yield_pct": 9, "buffer_sigmas": 3}Inputs
| Input | Type | Range | Required | What it is |
|---|---|---|---|---|
| collateral_value | number | over 0 to 10000000000000 | yes | Collateral at the oracle's price. |
| debt | number | over 0 to 10000000000000 | yes | Debt owed. Above zero: with no debt there is no line. |
| liquidation_threshold_pct | number | over 0 to 100 | yes | Debt can reach this share of collateral before liquidation. 80 means 80%. |
| liquidation_penalty_pct | number | 0 to 50 | yes | Share of liquidation proceeds taken first as the penalty. 5 means 5%. |
| asset_vol_pct | number | 0 to 500 | yes | Annual volatility of the token's value. 15 means 15%. |
| oracle_lag_hours | number | 0 to 8760 | yes | Hours the oracle's price can lag. |
| redemption_days | number | 0 to 3650 | yes | Days to turn the token into cash by redemption. |
| pool_cash_depth | number | over 0 to 10000000000000 | yes | Cash in the constant-product pool. |
| pool_token_depth | number | over 0 to 10000000000000 | yes | Tokens in the constant-product pool. |
| borrow_rate_pct | number | 0 to 100 | yes | Interest on the debt. 7 means 7%. |
| asset_yield_pct | number | 0 to 100 | yes | Yield on the collateral. 9 means 9%. |
| buffer_sigmas | number | 0 to 10 | no | Optional. Stdevs of cushion for the highest LTV. Default 3. |
| oracle_price | number | over 0 to 1000000000 | no | Optional. Oracle's price per token. Default: the pool's mid, y / x. |
| loop_ltv_pct | number | 0 to 99 | no | Optional. LTV for the repeated borrowing table. Default: this loan's LTV. |
Hypothetical, and on made-up numbers until you replace them. Nobody traded this, and nothing here is on offer.