HEDGEFUND.md

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.

The paste-ready promptmodel.md

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

watch

1.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

watch

1.7927

One stdev is 7.448% over 90 days. Chance of touching 7.3015%.

Slippage selling at the line

breach

23.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

breach

663,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

breach

63.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.

  1. 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.

  2. 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.

  3. 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.

  • breach
    The LTV of 70% is over the 63.98% that leaves 3 stdevs over the redemption time. over_buffer
  • watch
    The 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
  • breach
    A 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.
Chance of touching the line as the window grows%
01020050100150Days20.49
The data

Distance to the line

WindowTimeOne stdev %Stdevs to the lineChance of touching it %
Oracle lag24 hours0.785117.010
Redemption90 days7.44851.79277.3015

Liquidating the whole position

CaseOracle valueProceedsSlippage %After penaltyBad debtBack to the borrower
Today's value, through the pool10,000,0007,500,000257,125,0000125,000
At the line, through the pool8,750,0006,670,20023.776,336,690663,3100
At the line then 3 stdevs over the oracle lag, through the pool8,546,3106,533,10623.566,206,451793,5490
At the line then 3 stdevs over the redemption time, by redemption6,997,8306,997,83006,647,939352,0610

Repeated borrowing at 70% LTV, hypothetical, from the sent collateral with no debt. Exposure limit 3.3333 per 1 of capital

LoopsExposure per 1Debt per 1Overall LTV %Health factorFall to the line %Hypothetical carry on capital %Vol on capital %Slippage at the line %Bad debt at the line
11.70.741.181.942948.5310.425.528.91,090,123
22.191.1954.341.472332.0811.3832.8537.563,076,956
32.5331.53360.521.321924.3512.0737.9942.344,833,830
42.77311.773163.941.251220.0812.5541.645.256,202,463
52.94121.9412661.212117.512.8844.1247.17,218,311

Hypothetical, computed from the numbers sent and any stated default, with hindsight. Nobody traded it, and costs and liquidity are only as assumed. Not a forecast, a recommendation, an offer, or a record of real trading. Don't use it to market an investment.

formula Health = 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).

inputs_hash 6f06a0c9cc236355

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.

prompt.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/terms

Call 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.

terminal
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}'

Inputs

InputTypeRangeRequiredWhat it is
collateral_valuenumberover 0 to 10000000000000yesCollateral at the oracle's price.
debtnumberover 0 to 10000000000000yesDebt owed. Above zero: with no debt there is no line.
liquidation_threshold_pctnumberover 0 to 100yesDebt can reach this share of collateral before liquidation. 80 means 80%.
liquidation_penalty_pctnumber0 to 50yesShare of liquidation proceeds taken first as the penalty. 5 means 5%.
asset_vol_pctnumber0 to 500yesAnnual volatility of the token's value. 15 means 15%.
oracle_lag_hoursnumber0 to 8760yesHours the oracle's price can lag.
redemption_daysnumber0 to 3650yesDays to turn the token into cash by redemption.
pool_cash_depthnumberover 0 to 10000000000000yesCash in the constant-product pool.
pool_token_depthnumberover 0 to 10000000000000yesTokens in the constant-product pool.
borrow_rate_pctnumber0 to 100yesInterest on the debt. 7 means 7%.
asset_yield_pctnumber0 to 100yesYield on the collateral. 9 means 9%.
buffer_sigmasnumber0 to 10noOptional. Stdevs of cushion for the highest LTV. Default 3.
oracle_pricenumberover 0 to 1000000000noOptional. Oracle's price per token. Default: the pool's mid, y / x.
loop_ltv_pctnumber0 to 99noOptional. 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.

1.0Use at your own risk: hedgefund.md is not a fund, not an offer of any security, token or fund interest, and not advice. Results are hypothetical, may be wrong, and are not a record of real trading. Don't use them to market an investment. See the terms.