@1delta/margin-fetcher 0.0.402 → 0.0.404
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 +124 -5
- package/dist/index.js +445 -60
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -329,6 +329,76 @@ interface FixedTermProvider {
|
|
|
329
329
|
/** The single counterparty/venue contract, when there is one (Lista broker, Term servicer). */
|
|
330
330
|
address?: string;
|
|
331
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Origination window for a fixed-term market whose terms are only obtainable
|
|
334
|
+
* during a bounded round rather than continuously (`provider.kind: 'auction'`
|
|
335
|
+
* — Term Finance).
|
|
336
|
+
*
|
|
337
|
+
* This is the difference between "the rate card is empty right now" and "this
|
|
338
|
+
* market is dead": between rounds a Term repo still has a maturity, collateral
|
|
339
|
+
* params and a last-cleared rate, but nothing can be borrowed until the next
|
|
340
|
+
* round is listed. Without it every closed repo renders as an ordinary
|
|
341
|
+
* borrowable market whose action silently cannot be built.
|
|
342
|
+
*
|
|
343
|
+
* `status` is a snapshot at fetch time; the timestamps are raw so a consumer
|
|
344
|
+
* can re-derive it live (and drive a countdown) against a cached response.
|
|
345
|
+
*/
|
|
346
|
+
interface FixedTermAuction {
|
|
347
|
+
/**
|
|
348
|
+
* Round lifecycle at fetch time:
|
|
349
|
+
* - `upcoming` — listed but not yet accepting submissions (`now < startTime`)
|
|
350
|
+
* - `open` — accepting sealed bids/offers (`startTime ≤ now < revealTime`)
|
|
351
|
+
* - `revealing` — submissions closed, prices revealing / clearing pending
|
|
352
|
+
* (`revealTime ≤ now < endTime`)
|
|
353
|
+
* - `closed` — no round is currently listed for this market. Borrowing is
|
|
354
|
+
* unavailable until the next one; lending may still be
|
|
355
|
+
* possible on the secondary repo-token book.
|
|
356
|
+
*/
|
|
357
|
+
status: 'upcoming' | 'open' | 'revealing' | 'closed';
|
|
358
|
+
/**
|
|
359
|
+
* Can a NEW borrow be opened right now? True only inside an open round —
|
|
360
|
+
* Term borrow origination is a sealed bid, so there is no other entry point.
|
|
361
|
+
*
|
|
362
|
+
* Consume this rather than re-deriving from `status`: it is the single flag
|
|
363
|
+
* a borrow CTA should gate on, and it stays correct if more statuses appear.
|
|
364
|
+
* It is NOT the same as `canLend` — see below.
|
|
365
|
+
*/
|
|
366
|
+
canBorrow: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Can a NEW lend position be opened right now? Deliberately decoupled from
|
|
369
|
+
* `canBorrow`: the primary auction is only one of two lend surfaces, and
|
|
370
|
+
* buying repo tokens on the secondary book works between rounds. So a closed
|
|
371
|
+
* round leaves the market lend-only rather than fully inert, and a UI that
|
|
372
|
+
* greys out the whole market would be wrong.
|
|
373
|
+
*/
|
|
374
|
+
canLend: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Seconds until submissions close (`revealTime − now`), or undefined when no
|
|
377
|
+
* round is open. A snapshot — for a live countdown, derive from `revealTime`.
|
|
378
|
+
*/
|
|
379
|
+
secondsUntilClose?: number;
|
|
380
|
+
/**
|
|
381
|
+
* Ready-to-display consequences of this market's origination model, most
|
|
382
|
+
* important first. Mirrors `params.market.teller.implications`: auction
|
|
383
|
+
* mechanics are unusual enough that a UI showing only a rate misleads.
|
|
384
|
+
*/
|
|
385
|
+
implications?: string[];
|
|
386
|
+
/** Round id. Absent when `status: 'closed'`. */
|
|
387
|
+
id?: string;
|
|
388
|
+
/** Submissions open (unix seconds). Absent when `status: 'closed'`. */
|
|
389
|
+
startTime?: number;
|
|
390
|
+
/** Submissions CLOSE / reveal begins (unix seconds). Absent when closed. */
|
|
391
|
+
revealTime?: number;
|
|
392
|
+
/** Round clears (unix seconds). Absent when closed. */
|
|
393
|
+
endTime?: number;
|
|
394
|
+
/**
|
|
395
|
+
* Minimum submission size in loan-token base units (raw). Term rounds carry a
|
|
396
|
+
* real floor (e.g. 1000 USDC) — an amount below it cannot be submitted at all,
|
|
397
|
+
* so it belongs next to the terms rather than surfacing as a failed action.
|
|
398
|
+
*/
|
|
399
|
+
minBorrowAmount?: string;
|
|
400
|
+
minLendAmount?: string;
|
|
401
|
+
}
|
|
332
402
|
/**
|
|
333
403
|
* Canonical fixed-term market descriptor, emitted on `params.market.fixedTerm`
|
|
334
404
|
* for EVERY fixed-rate / fixed-maturity market (Lista brokered + Morpho
|
|
@@ -367,6 +437,12 @@ interface FixedTermInfo {
|
|
|
367
437
|
earlyRepay: FixedTermEarlyRepay;
|
|
368
438
|
/** Who offers the term (Lista broker vs Midnight order book). */
|
|
369
439
|
provider?: FixedTermProvider;
|
|
440
|
+
/**
|
|
441
|
+
* Origination window, for `provider.kind: 'auction'` markets only (Term
|
|
442
|
+
* Finance). Absent for lenders whose terms are continuously available — a
|
|
443
|
+
* missing `auction` means "no window applies", NOT "closed".
|
|
444
|
+
*/
|
|
445
|
+
auction?: FixedTermAuction;
|
|
370
446
|
}
|
|
371
447
|
/** A Lista loan, attached to its own entry in the positions array. */
|
|
372
448
|
interface ListaTermLoan {
|
|
@@ -2234,14 +2310,48 @@ interface TermBookSource {
|
|
|
2234
2310
|
getTopAndBook?(config: TermMarketConfig, maxLevels?: number): Promise<{
|
|
2235
2311
|
top: TermBookTop;
|
|
2236
2312
|
book: TermBook;
|
|
2313
|
+
/** Live/upcoming auction round; null when none is listed. */
|
|
2314
|
+
auction: TermAuctionWindow | null;
|
|
2237
2315
|
} | null>;
|
|
2238
2316
|
}
|
|
2317
|
+
/**
|
|
2318
|
+
* The repo's CURRENT primary auction round, when one is listed.
|
|
2319
|
+
*
|
|
2320
|
+
* Term borrow origination is a periodic sealed-bid auction, not a continuous
|
|
2321
|
+
* book: outside the submission window there is nothing to bid on, so a repo
|
|
2322
|
+
* whose auction has cleared is lend-only (buy repo tokens on the secondary
|
|
2323
|
+
* book) until the next round is listed. Timestamps are raw so consumers can
|
|
2324
|
+
* derive a live countdown; `status` is a snapshot at fetch time.
|
|
2325
|
+
*/
|
|
2326
|
+
interface TermAuctionWindow {
|
|
2327
|
+
/** Auction round id (the TermAuction entity id). */
|
|
2328
|
+
id: string;
|
|
2329
|
+
/** Submissions open (unix seconds). */
|
|
2330
|
+
startTime: number;
|
|
2331
|
+
/** Submissions CLOSE and the sealed prices start revealing (unix seconds). */
|
|
2332
|
+
revealTime: number;
|
|
2333
|
+
/** Auction clears (unix seconds). Equal to `revealTime` on current deployments. */
|
|
2334
|
+
endTime: number;
|
|
2335
|
+
/** Minimum bid (borrow) size, loan-token base units (raw string; '0' when unset). */
|
|
2336
|
+
minBidAmount: string;
|
|
2337
|
+
/** Minimum offer (lend) size, loan-token base units (raw string; '0' when unset). */
|
|
2338
|
+
minOfferAmount: string;
|
|
2339
|
+
/** Highest accepted bid rate, WAD (raw string; '0' when unset). */
|
|
2340
|
+
maxBidPriceWad: string;
|
|
2341
|
+
/** Highest accepted offer rate, WAD (raw string; '0' when unset). */
|
|
2342
|
+
maxOfferPriceWad: string;
|
|
2343
|
+
}
|
|
2239
2344
|
/** A Term repo paired with its current top-of-book (null when the fetch failed). */
|
|
2240
2345
|
interface TermMarketRaw {
|
|
2241
2346
|
config: TermMarketConfig;
|
|
2242
2347
|
top: TermBookTop | null;
|
|
2243
2348
|
/** Bounded book slice (top-N levels/side); null/absent when unavailable. */
|
|
2244
2349
|
book?: TermBook | null;
|
|
2350
|
+
/**
|
|
2351
|
+
* The live/upcoming auction round, or null when no round is currently listed
|
|
2352
|
+
* (the common case between auctions — the repo is then lend-only).
|
|
2353
|
+
*/
|
|
2354
|
+
auction?: TermAuctionWindow | null;
|
|
2245
2355
|
}
|
|
2246
2356
|
|
|
2247
2357
|
/**
|
|
@@ -2287,15 +2397,24 @@ declare class TermSubgraphSource implements TermBookSource {
|
|
|
2287
2397
|
getBookTop(config: TermMarketConfig): Promise<TermBookTop | null>;
|
|
2288
2398
|
/**
|
|
2289
2399
|
* ONE query → the aggregate top (best APR + FULL depth) PLUS a bounded book
|
|
2290
|
-
* slice (top `maxLevels` open orders per side)
|
|
2291
|
-
*
|
|
2292
|
-
*
|
|
2293
|
-
*
|
|
2294
|
-
* clearing APR; the levels
|
|
2400
|
+
* slice (top `maxLevels` open orders per side) PLUS the repo's current
|
|
2401
|
+
* auction round. `asks` = orders selling repo tokens (the secondary LEND
|
|
2402
|
+
* book); `bids` = the rest (borrow side, usually empty — Term borrow is
|
|
2403
|
+
* sealed-bid auction, not a continuous book). Term secondary orders carry no
|
|
2404
|
+
* per-order rate, so every level shares the market's clearing APR; the levels
|
|
2405
|
+
* expose per-order SIZE for filtering.
|
|
2406
|
+
*
|
|
2407
|
+
* Two auction reads, deliberately distinct:
|
|
2408
|
+
* - `cleared` — the latest COMPLETE round, whose clearing price IS the
|
|
2409
|
+
* market's fixed APR (and stays the reference rate between auctions).
|
|
2410
|
+
* - `pending` — rounds not yet complete/cancelled. Only one of these is a
|
|
2411
|
+
* real, actionable round; the rest are abandoned listings the subgraph
|
|
2412
|
+
* never marked complete, filtered out below.
|
|
2295
2413
|
*/
|
|
2296
2414
|
getTopAndBook(config: TermMarketConfig, maxLevels?: number): Promise<{
|
|
2297
2415
|
top: TermBookTop;
|
|
2298
2416
|
book: TermBook;
|
|
2417
|
+
auction: TermAuctionWindow | null;
|
|
2299
2418
|
} | null>;
|
|
2300
2419
|
getListings(config: TermMarketConfig): Promise<TermListing[] | null>;
|
|
2301
2420
|
/**
|