@1delta/margin-fetcher 0.0.245 → 0.0.247

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.
@@ -1,17 +1,27 @@
1
1
  /**
2
- * Builds the multicall descriptor for Gearbox V3 public data.
2
+ * Builds the multicall descriptor for Gearbox V3.1 public data.
3
3
  *
4
- * Two calls:
5
- * [0] DataCompressorV3.getPoolsV3List() pool liquidity, rates, quotas
6
- * [1] DataCompressorV3.getCreditManagersV3List() — CM metadata: allowed
7
- * collateral tokens + parallel liquidationThresholds, debt caps, facade
4
+ * Single call to `MarketCompressor.getMarkets(filter)` with:
5
+ * - `configurators`: all curators registered for the chain (cp0x,
6
+ * Chaos Labs, Re7, …) — discovered from the resolver JSON
7
+ * - `pools: []` no narrowing, return every market run by those
8
+ * configurators
9
+ * - `underlying: 0x0` — no underlying filter
8
10
  *
9
- * The CM list is NOT embedded in PoolData on the deployed DataCompressorV3,
10
- * so the public-data parser joins the two by `cm.pool` pool addr.
11
+ * The response carries pool + creditManagers + facades + oracle info
12
+ * in one nested struct per market. Parser fans out to per-CM
13
+ * `GEARBOX_V3_<CM_HEX>` buckets.
14
+ *
15
+ * Returns `[]` when the chain has no configurators or MarketCompressor
16
+ * isn't configured — safe no-op.
11
17
  */
12
18
  export declare const buildGearboxCall: (chainId: string, _lender?: string) => {
13
19
  address: string;
14
20
  name: string;
15
- params: never[];
21
+ params: {
22
+ configurators: string[];
23
+ pools: string[];
24
+ underlying: "0x0000000000000000000000000000000000000000";
25
+ }[];
16
26
  }[];
17
27
  //# sourceMappingURL=publicCallBuild.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publicCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/public-data/gearbox/publicCallBuild.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM;;;;GAgBjE,CAAA"}
1
+ {"version":3,"file":"publicCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/public-data/gearbox/publicCallBuild.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM;;;;;eAe3C,MAAM,EAAE;;;GAM9B,CAAA"}
@@ -1,20 +1,28 @@
1
1
  import { AdditionalYields, GenericTokenList } from '../../../types';
2
2
  /**
3
- * Parser for the 2-slot Gearbox V3 public data fetch.
3
+ * Parser for the single-call Gearbox V3.1 public data fetch.
4
4
  *
5
- * data[0] = PoolData[] (getPoolsV3List)
6
- * data[1] = CreditManagerData[] (getCreditManagersV3List)
5
+ * data[0] = MarketData[] (MarketCompressor.getMarkets(filter))
7
6
  *
8
- * Each CreditManager is an isolated lending venue (positions are per-CA and
9
- * one CA is bound to exactly one CM CM-A cannot see positions in CM-B even
10
- * when both draw from the same pool). We therefore emit one bucket per CM,
11
- * keyed by `GEARBOX_V3_<CM_HEX>` via `gearboxV3LenderKey`, and join to the
12
- * pool via `cm.pool` to recover per-pool supply/borrow rates.
7
+ * MarketCompressor collapses the old `getPoolsV3List + getCreditManagersV3List`
8
+ * pair into one nested struct per market:
13
9
  *
14
- * Inside each CM bucket we emit:
15
- * - one LOAN entry for the pool's underlying (borrow-side)
16
- * - one COLLATERAL entry per `collateralTokens[i]`, using the parallel
17
- * `liquidationThresholds[i]` (BPS) as the collateral factor.
10
+ * MarketData { pool, quotaKeeper, priceOracle, creditManagers[], ... }
11
+ *
12
+ * Each `creditManagers[i]` carries its own `creditFacade` sub-struct
13
+ * (with minDebt / maxDebt / expirationDate / isPaused / degenNFT /
14
+ * forbiddenTokensMask) plus the `creditManager` sub-struct
15
+ * (collateralTokens[{token, liquidationThreshold}], maxEnabledTokens,
16
+ * fees). We fan out to per-CM `GEARBOX_V3_<CM_HEX>` buckets — one CA is
17
+ * bound to exactly one CM, so CMs are the isolation unit.
18
+ *
19
+ * Filtering applied here:
20
+ * - skip the whole market if the pool is paused
21
+ * - skip individual CMs that are paused, expired, or in degen-NFT mode
22
+ * (can't be operated without a DegenNFT, which we don't support)
23
+ *
24
+ * Per-CM totals (totalDebt, availableToBorrow) come from the pool's
25
+ * `creditManagerDebtParams[]` array, indexed by the CM address.
18
26
  *
19
27
  * The passive ERC-4626 lender side (PoolV3) is NOT modeled here — it's a
20
28
  * standalone vault with no borrow and lives under `vaults/gearbox/`.
@@ -1 +1 @@
1
- {"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../../src/lending/public-data/gearbox/publicCallParse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAmBnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,+BAA+B,GAC1C,SAAS,MAAM,EACf,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,EAAE,MAAM,CAoNjE,CAAA"}
1
+ {"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../../src/lending/public-data/gearbox/publicCallParse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAmBnE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,+BAA+B,GAC1C,SAAS,MAAM,EACf,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,EAAE,MAAM,CAwQjE,CAAA"}
@@ -1,19 +1,22 @@
1
1
  import { Call } from '../../../utils/multicall';
2
2
  /**
3
- * Number of multicall slots consumed by one
4
- * `getCreditAccountsByBorrower(account)` call.
3
+ * Number of multicall slots consumed by one user-data fetch for Gearbox V3.1:
4
+ * one `getCreditAccounts(cmFilter, caFilter, offset, limit)` call that
5
+ * returns every Credit Account the borrower owns across all known curators.
5
6
  */
6
7
  export declare const GEARBOX_V3_USER_CALL_COUNT = 1;
7
8
  /**
8
- * Build the user-data multicall descriptor for Gearbox V3.
9
+ * Build the user-data multicall descriptor for Gearbox V3.1.
9
10
  *
10
- * Single call: `DataCompressorV3.getCreditAccountsByBorrower(account)` returns
11
- * every Credit Account the borrower owns across every CreditManager on the
12
- * chain in one shot.
11
+ * Single call: `CreditAccountCompressor.getCreditAccounts(cmFilter,
12
+ * caFilter, 0, 128)` with
13
+ * - `cmFilter.configurators` = every curator registered for this chain
14
+ * in `gearbox-resolvers.json`
15
+ * - `caFilter.owner` = the borrower address
13
16
  *
14
- * The parser groups returned accounts by their `creditManager` address and
15
- * emits one `UserData` per CM under `GEARBOX_V3_<CM_HEX>` matching the
16
- * multi-market isolation pattern (one CA is bound to exactly one CM).
17
+ * Returns `(CreditAccountData[], uint256 nextOffset)`. The parser keeps
18
+ * the CA array and ignores `nextOffset` see `CA_QUERY_LIMIT` for the
19
+ * pagination caveat.
17
20
  */
18
21
  export declare const buildGearboxV3UserCall: (chainId: string, _lender: string, account: string) => Call[];
19
22
  //# sourceMappingURL=userCallBuild.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/gearbox/userCallBuild.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAE/C;;;GAGG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,SAAS,MAAM,EACf,SAAS,MAAM,KACd,IAAI,EAaN,CAAA"}
1
+ {"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/gearbox/userCallBuild.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAU/C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAE3C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,SAAS,MAAM,EACf,SAAS,MAAM,KACd,IAAI,EAoCN,CAAA"}
@@ -1,23 +1,27 @@
1
1
  import { LenderToLenderCrossPoolMeta, UserData } from '../utils/types';
2
2
  /**
3
- * Returns a [converter, expectedCallCount] tuple for Gearbox V3 user data.
3
+ * Returns a [converter, expectedCallCount] tuple for Gearbox V3.1 user
4
+ * data.
4
5
  *
5
- * Single call `getCreditAccountsByBorrower(account)` returns a
6
- * `CreditAccountData[]`. Each element is one isolated Credit Account owned
7
- * by exactly one CreditManager.
6
+ * Single call `CreditAccountCompressor.getCreditAccounts(cmFilter,
7
+ * caFilter, offset, limit)` returns
8
+ * `(CreditAccountData[] data, uint256 nextOffset)`.
8
9
  *
9
- * Output is keyed by `GEARBOX_V3_<CM_HEX>` one UserData per
10
- * CreditManager, with each Credit Account appearing as a sub-account
11
- * (mirrors the Fluid NFT / Init subAccount pattern).
10
+ * Each `CreditAccountData` describes one isolated Credit Account owned
11
+ * by exactly one CreditManager. We fan out by `creditManager` address
12
+ * and emit one `UserData` per CM under `GEARBOX_V3_<CM_HEX>` — each
13
+ * Credit Account becomes a sub-account under its CM (mirroring the
14
+ * Fluid-NFT / Init-subAccount pattern).
12
15
  *
13
- * Per-sub-account positions:
14
- * - one entry per non-zero `balances[i]` collateral token (with deposits
15
- * scaled by the token's own decimals)
16
- * - one entry for the pool underlying carrying the debt
16
+ * V3.0 → V3.1 field renames handled here:
17
+ * - `isSuccessful` → `success`
18
+ * - `ca.addr` → `ca.creditAccount`
19
+ * - `ca.balances[]` `ca.tokens[]` (with `{token, mask, balance,
20
+ * quota, success}`; "quoted" is
21
+ * now derived from `quota > 0`)
17
22
  *
18
- * A collateral balance that is NOT `isQuoted` contributes zero to health
19
- * in Gearbox V3 (quotas gate which tokens count). We still surface it as
20
- * a deposit entry so the UI can show "held but uncollateralized".
23
+ * `ca.owner` replaces the old implicit "caller passed as borrower"
24
+ * semantic we don't use it directly since the filter pinned it.
21
25
  */
22
26
  export declare const getGearboxV3UserDataConverter: (_lender: string, chainId: string, account: string, meta?: LenderToLenderCrossPoolMeta) => [(data: any[]) => {
23
27
  [lender: string]: UserData;
@@ -1 +1 @@
1
- {"version":3,"file":"userCallParse.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/gearbox/userCallParse.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,2BAA2B,EAC3B,QAAQ,EACT,MAAM,gBAAgB,CAAA;AAiBvB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,SAAS,MAAM,EACf,SAAS,MAAM,EACf,OAAO,2BAA2B,KACjC,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,GAAG,SAAS,EAAE,MAAM,CAuMtE,CAAA"}
1
+ {"version":3,"file":"userCallParse.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/gearbox/userCallParse.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,2BAA2B,EAC3B,QAAQ,EACT,MAAM,gBAAgB,CAAA;AAiBvB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B,GACxC,SAAS,MAAM,EACf,SAAS,MAAM,EACf,SAAS,MAAM,EACf,OAAO,2BAA2B,KACjC,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,GAAG,SAAS,EAAE,MAAM,CAsNtE,CAAA"}