@1delta/margin-fetcher 5.0.5 → 5.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +31 -2
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -8416,7 +8416,37 @@ interface TermAssetRef {
|
|
|
8416
8416
|
* `tags.ts` — never hand-written per lender, so they cannot drift from the
|
|
8417
8417
|
* numbers they summarize.
|
|
8418
8418
|
*/
|
|
8419
|
-
type TermTag = Open<'fixed-rate' | 'variable-rate' | 'user-set-rate' | 'zero-interest' | 'prepaid-interest' | 'nav-accrual' | 'has-maturity' | 'perpetual' | 'rolling-duration' | 'static-debt' | 'accruing-debt' | 'time-liquidation' | 'price-liquidation' | 'redeemable' | 'no-liquidation' | 'full-collateral-seizure' | 'early-exit-free' | 'early-exit-penalty' | 'early-exit-discount' | 'exit-instant' | 'exit-capped' | 'exit-cooldown'
|
|
8419
|
+
type TermTag = Open<'fixed-rate' | 'variable-rate' | 'user-set-rate' | 'zero-interest' | 'prepaid-interest' | 'nav-accrual' | 'has-maturity' | 'perpetual' | 'rolling-duration' | 'static-debt' | 'accruing-debt' | 'time-liquidation' | 'price-liquidation' | 'redeemable' | 'no-liquidation' | 'full-collateral-seizure' | 'early-exit-free' | 'early-exit-penalty' | 'early-exit-discount' | 'exit-instant' | 'exit-capped' | 'exit-cooldown'
|
|
8420
|
+
/**
|
|
8421
|
+
* The DEBT cannot be repaid for a period after opening or topping up.
|
|
8422
|
+
*
|
|
8423
|
+
* Deliberately distinct from `exit-cooldown` (a supply-side withdrawal
|
|
8424
|
+
* delay): this one means the position cannot be closed, deleveraged or
|
|
8425
|
+
* migrated out — and, on the lender that has it, that an incoming
|
|
8426
|
+
* liquidation cannot be averted by repaying.
|
|
8427
|
+
*/
|
|
8428
|
+
| 'repay-locked' | 'exit-queued' | 'exit-market-sale' | 'exit-may-be-impossible' | 'permissioned' | 'capped' | 'cap-full' | 'first-loss' | 'socialized-loss' | 'physical-delivery' | 'undercollateralized' | 'nav-attested' | 'immutable' | 'no-timelock' | 'eoa-controlled' | 'points-rewards'
|
|
8429
|
+
/**
|
|
8430
|
+
* The headline yield is MOSTLY the asset's own (staking / RWA / savings)
|
|
8431
|
+
* yield, not interest this market pays. Set at >= 50 % of `aprTotal`.
|
|
8432
|
+
*
|
|
8433
|
+
* Worth a tag rather than only a detail row, because the two are not
|
|
8434
|
+
* interchangeable and the difference is invisible in a single percentage: a
|
|
8435
|
+
* market rate is paid by borrowers and moves with utilization, while
|
|
8436
|
+
* intrinsic yield you would earn holding the asset in your wallet — you are
|
|
8437
|
+
* taking this market's risk for the DIFFERENCE, not for the headline.
|
|
8438
|
+
* Decisive when looping: a loop only carries if the collateral out-earns the
|
|
8439
|
+
* debt, and intrinsic yield does not scale with leverage the way a lending
|
|
8440
|
+
* spread does.
|
|
8441
|
+
*/
|
|
8442
|
+
| 'intrinsic-yield'
|
|
8443
|
+
/**
|
|
8444
|
+
* This market pays NO interest of its own — the entire headline is intrinsic
|
|
8445
|
+
* yield and/or rewards. Curvance's collateral-only legs are the canonical
|
|
8446
|
+
* case (`debtCap == 0` ⇒ 0 % supply APR by construction), but any market
|
|
8447
|
+
* with no borrowers reads the same way.
|
|
8448
|
+
*/
|
|
8449
|
+
| 'no-market-interest' | 'oracle-flagged' | 'no-oracle'>;
|
|
8420
8450
|
/** Human-facing copy for one side of a term sheet. */
|
|
8421
8451
|
interface TermInfo {
|
|
8422
8452
|
/**
|
|
@@ -9445,7 +9475,6 @@ declare function duration(secs: number | undefined): string;
|
|
|
9445
9475
|
declare function shortDate(unixSecs: number | undefined): string;
|
|
9446
9476
|
/** One fee → a self-contained phrase, correct even for an unrecognised `id`. */
|
|
9447
9477
|
declare function feePhrase(fee: FeeTerm): string;
|
|
9448
|
-
/** Supply-side headline: ≤ ~100 chars, always populated. */
|
|
9449
9478
|
declare function supplyHeadline(s: SupplyTermSheet): string;
|
|
9450
9479
|
/** Borrow-side headline. */
|
|
9451
9480
|
declare function borrowHeadline(b: BorrowTermSheet): string;
|
package/dist/index.js
CHANGED
|
@@ -62207,6 +62207,13 @@ function rateTags(rate) {
|
|
|
62207
62207
|
}
|
|
62208
62208
|
if (rate.rewards?.some((r) => r.indicative || r.kind === "points"))
|
|
62209
62209
|
push(out, "points-rewards");
|
|
62210
|
+
const total = rate.aprTotal;
|
|
62211
|
+
const base = rate.components?.base ?? 0;
|
|
62212
|
+
const intrinsic = rate.components?.intrinsic ?? 0;
|
|
62213
|
+
if (total > 0) {
|
|
62214
|
+
if (intrinsic > 0 && intrinsic >= total / 2) push(out, "intrinsic-yield");
|
|
62215
|
+
if (base <= 1e-4 && intrinsic > 0) push(out, "no-market-interest");
|
|
62216
|
+
}
|
|
62210
62217
|
return [...out];
|
|
62211
62218
|
}
|
|
62212
62219
|
function maturityTags(maturity) {
|
|
@@ -62286,9 +62293,11 @@ function deriveBorrowTags(borrow, market = {}) {
|
|
|
62286
62293
|
if (borrow.liquidation.redeemable) push(out, "redeemable");
|
|
62287
62294
|
if (borrow.liquidation.seizure === "full-collateral")
|
|
62288
62295
|
push(out, "full-collateral-seizure");
|
|
62296
|
+
const repayLocked = (borrow.exit.cooldownSecs ?? 0) > 0;
|
|
62297
|
+
if (repayLocked) push(out, "repay-locked");
|
|
62289
62298
|
switch (borrow.exit.earlyRepay) {
|
|
62290
62299
|
case "free":
|
|
62291
|
-
push(out, "early-exit-free");
|
|
62300
|
+
if (!repayLocked) push(out, "early-exit-free");
|
|
62292
62301
|
break;
|
|
62293
62302
|
case "penalty":
|
|
62294
62303
|
push(out, "early-exit-penalty");
|
|
@@ -62414,11 +62423,22 @@ var exitPhrase = {
|
|
|
62414
62423
|
"off-chain": "exit off-chain",
|
|
62415
62424
|
"dex-only": "exit only via a DEX"
|
|
62416
62425
|
};
|
|
62426
|
+
function provenance(rate) {
|
|
62427
|
+
const total = rate.aprTotal;
|
|
62428
|
+
const base = rate.components?.base ?? 0;
|
|
62429
|
+
const intrinsic = rate.components?.intrinsic ?? 0;
|
|
62430
|
+
if (!(intrinsic > 0) || !(total > 0)) return "";
|
|
62431
|
+
if (base <= 1e-4) return " (all from the asset itself)";
|
|
62432
|
+
if (intrinsic >= total / 2) {
|
|
62433
|
+
return ` (${pct(intrinsic)} from the asset, ${pct(base)} from the market)`;
|
|
62434
|
+
}
|
|
62435
|
+
return ` (incl. ${pct(intrinsic)} from the asset)`;
|
|
62436
|
+
}
|
|
62417
62437
|
function supplyHeadline(s) {
|
|
62418
62438
|
if (s.role === "collateral") {
|
|
62419
62439
|
return `Collateral only \xB7 ${maturityPhrase(s.maturity)}`;
|
|
62420
62440
|
}
|
|
62421
|
-
const rate = `${rateLabel(s)} ${pct(s.rate.aprTotal)}`;
|
|
62441
|
+
const rate = `${rateLabel(s)} ${pct(s.rate.aprTotal)}${provenance(s.rate)}`;
|
|
62422
62442
|
const exit = exitPhrase[String(s.exit.mode)] ?? (s.exit.settlement === "sync" ? "withdraw any time" : "delayed withdrawal");
|
|
62423
62443
|
const cooldown = s.exit.cooldownSecs ? ` (${duration(s.exit.cooldownSecs)})` : "";
|
|
62424
62444
|
const mat = s.maturity.kind === "perpetual" ? "" : ` ${maturityPhrase(s.maturity)}`;
|
|
@@ -62433,6 +62453,9 @@ function borrowHeadline(b) {
|
|
|
62433
62453
|
) : `${rateLabel(b)} ${pct(b.rate.apr)}`;
|
|
62434
62454
|
const mat = b.maturity.kind === "perpetual" ? "" : ` ${maturityPhrase(b.maturity)}`;
|
|
62435
62455
|
const exit = earlyRepayPhrase[String(b.exit.earlyRepay)] ?? "see repay terms";
|
|
62456
|
+
if (b.exit.cooldownSecs) {
|
|
62457
|
+
return `${rate}${mat} \xB7 no repayment for ${duration(b.exit.cooldownSecs)}, then ${exit}`;
|
|
62458
|
+
}
|
|
62436
62459
|
return `${rate}${mat} \xB7 ${exit}`;
|
|
62437
62460
|
}
|
|
62438
62461
|
function supplyDescription(s, sheet = {}) {
|
|
@@ -63615,6 +63638,16 @@ function supplyFindings(supply) {
|
|
|
63615
63638
|
function borrowFindings(borrow) {
|
|
63616
63639
|
const out = [];
|
|
63617
63640
|
const liq = borrow.liquidation;
|
|
63641
|
+
if (borrow.exit.cooldownSecs) {
|
|
63642
|
+
out.push({
|
|
63643
|
+
severity: "critical",
|
|
63644
|
+
id: "repay-locked",
|
|
63645
|
+
side: "borrow",
|
|
63646
|
+
message: `The debt CANNOT be repaid for ${fmtSecs(
|
|
63647
|
+
borrow.exit.cooldownSecs
|
|
63648
|
+
)} after opening or topping up: the position cannot be closed, deleveraged or migrated out in that window, and an incoming liquidation cannot be averted by repaying (adding collateral still works).`
|
|
63649
|
+
});
|
|
63650
|
+
}
|
|
63618
63651
|
if (liq.seizure === "full-collateral") {
|
|
63619
63652
|
out.push({
|
|
63620
63653
|
severity: "critical",
|