@gearbox-protocol/sdk 18.1.0 → 18.2.0-next.2

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.
Files changed (46) hide show
  1. package/dist/cjs/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +179 -0
  2. package/dist/cjs/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +534 -0
  3. package/dist/cjs/abi/router/treehouseWorker.js +885 -0
  4. package/dist/cjs/onchain/market/adapters/abi/actionAbi.js +1 -0
  5. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +3 -0
  6. package/dist/cjs/onchain/market/adapters/types.js +3 -0
  7. package/dist/cjs/permissionless/api/GearboxPermissionless.js +12 -5
  8. package/dist/cjs/permissionless/api/analytics/PermissionlessAnalytics.js +50 -0
  9. package/dist/cjs/permissionless/api/analytics/index.js +4 -0
  10. package/dist/cjs/permissionless/api/analytics/schemas.js +27 -0
  11. package/dist/cjs/permissionless/api/analytics/types.js +1 -0
  12. package/dist/cjs/permissionless/api/index.js +3 -0
  13. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +69 -0
  14. package/dist/cjs/permissionless/api/oracles/schemas.js +36 -0
  15. package/dist/cjs/permissionless/index.js +2 -0
  16. package/dist/esm/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +178 -0
  17. package/dist/esm/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +533 -0
  18. package/dist/esm/abi/router/treehouseWorker.js +884 -0
  19. package/dist/esm/onchain/market/adapters/abi/actionAbi.js +1 -0
  20. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +3 -0
  21. package/dist/esm/onchain/market/adapters/types.js +3 -0
  22. package/dist/esm/permissionless/api/GearboxPermissionless.js +12 -5
  23. package/dist/esm/permissionless/api/analytics/PermissionlessAnalytics.js +49 -0
  24. package/dist/esm/permissionless/api/analytics/index.js +2 -0
  25. package/dist/esm/permissionless/api/analytics/schemas.js +25 -0
  26. package/dist/esm/permissionless/api/analytics/types.js +1 -0
  27. package/dist/esm/permissionless/api/index.js +3 -1
  28. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +70 -1
  29. package/dist/esm/permissionless/api/oracles/schemas.js +33 -1
  30. package/dist/esm/permissionless/index.js +2 -1
  31. package/dist/types/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.d.ts +148 -0
  32. package/dist/types/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.d.ts +440 -0
  33. package/dist/types/abi/router/treehouseWorker.d.ts +728 -0
  34. package/dist/types/onchain/market/adapters/types.d.ts +4 -1
  35. package/dist/types/permissionless/api/GearboxPermissionless.d.ts +11 -5
  36. package/dist/types/permissionless/api/analytics/PermissionlessAnalytics.d.ts +38 -0
  37. package/dist/types/permissionless/api/analytics/index.d.ts +3 -0
  38. package/dist/types/permissionless/api/analytics/schemas.d.ts +32 -0
  39. package/dist/types/permissionless/api/analytics/types.d.ts +38 -0
  40. package/dist/types/permissionless/api/index.d.ts +5 -2
  41. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +55 -1
  42. package/dist/types/permissionless/api/oracles/index.d.ts +2 -2
  43. package/dist/types/permissionless/api/oracles/schemas.d.ts +55 -0
  44. package/dist/types/permissionless/api/oracles/types.d.ts +92 -0
  45. package/dist/types/permissionless/index.d.ts +4 -2
  46. package/package.json +1 -1
@@ -15,7 +15,7 @@ export interface IAdapterContract extends IBaseContract {
15
15
  openingCalls(): Promise<MultiCall[]>;
16
16
  }
17
17
  export type VersionedAbi = Record<number, readonly AbiParameter[]>;
18
- export type AdapterContractType = "ADAPTER::ACCOUNT_MIGRATOR" | "ADAPTER::BALANCER_V3_ROUTER" | "ADAPTER::BALANCER_V3_WRAPPER" | "ADAPTER::CAMELOT_V3_ROUTER" | "ADAPTER::CURVE_STABLE_NG" | "ADAPTER::CURVE_V1_2ASSETS" | "ADAPTER::CURVE_V1_3ASSETS" | "ADAPTER::CURVE_V1_4ASSETS" | "ADAPTER::CURVE_V1_STECRV_POOL" | "ADAPTER::CVX_V1_BASE_REWARD_POOL" | "ADAPTER::CVX_V1_BOOSTER" | "ADAPTER::DAI_USDS_EXCHANGE" | "ADAPTER::ERC4626_VAULT" | "ADAPTER::ERC4626_VAULT_REFERRAL" | "ADAPTER::FLUID_DEX" | "ADAPTER::INFINIFI_GATEWAY" | "ADAPTER::INFINIFI_UNWINDING" | "ADAPTER::KELP_DEPOSIT_POOL" | "ADAPTER::KELP_WITHDRAWAL" | "ADAPTER::LIDO_V1" | "ADAPTER::LIDO_WSTETH_V1" | "ADAPTER::MELLOW_CLAIMER" | "ADAPTER::MELLOW_DVV" | "ADAPTER::MELLOW_ERC4626_VAULT" | "ADAPTER::MELLOW_WRAPPER" | "ADAPTER::MIDAS_GATEWAY" | "ADAPTER::MIDAS_ISSUANCE_VAULT" | "ADAPTER::MIDAS_REDEMPTION_VAULT" | "ADAPTER::PENDLE_ROUTER" | "ADAPTER::SECURITIZE_ONRAMP" | "ADAPTER::SECURITIZE_REDEMPTION" | "ADAPTER::STAKING_REWARDS" | "ADAPTER::TRADERJOE_ROUTER" | "ADAPTER::UNISWAP_V2_ROUTER" | "ADAPTER::UNISWAP_V3_ROUTER" | "ADAPTER::UNISWAP_V4_GATEWAY" | "ADAPTER::UPSHIFT_VAULT" | "ADAPTER::VELODROME_V2_ROUTER";
18
+ export type AdapterContractType = "ADAPTER::ACCOUNT_MIGRATOR" | "ADAPTER::BALANCER_V3_ROUTER" | "ADAPTER::BALANCER_V3_WRAPPER" | "ADAPTER::CAMELOT_V3_ROUTER" | "ADAPTER::CURVE_STABLE_NG" | "ADAPTER::CURVE_V1_2ASSETS" | "ADAPTER::CURVE_V1_3ASSETS" | "ADAPTER::CURVE_V1_4ASSETS" | "ADAPTER::CURVE_V1_STECRV_POOL" | "ADAPTER::CVX_V1_BASE_REWARD_POOL" | "ADAPTER::CVX_V1_BOOSTER" | "ADAPTER::DAI_USDS_EXCHANGE" | "ADAPTER::ERC4626_VAULT" | "ADAPTER::ERC4626_VAULT_REFERRAL" | "ADAPTER::FLUID_DEX" | "ADAPTER::INFINIFI_GATEWAY" | "ADAPTER::INFINIFI_UNWINDING" | "ADAPTER::KELP_DEPOSIT_POOL" | "ADAPTER::KELP_WITHDRAWAL" | "ADAPTER::LIDO_V1" | "ADAPTER::LIDO_WSTETH_V1" | "ADAPTER::MELLOW_CLAIMER" | "ADAPTER::MELLOW_DVV" | "ADAPTER::MELLOW_ERC4626_VAULT" | "ADAPTER::MELLOW_WRAPPER" | "ADAPTER::MIDAS_GATEWAY" | "ADAPTER::MIDAS_ISSUANCE_VAULT" | "ADAPTER::MIDAS_REDEMPTION_VAULT" | "ADAPTER::PENDLE_ROUTER" | "ADAPTER::SECURITIZE_ONRAMP" | "ADAPTER::SECURITIZE_REDEMPTION" | "ADAPTER::STAKING_REWARDS" | "ADAPTER::TRADERJOE_ROUTER" | "ADAPTER::TREEHOUSE_FASTLANE" | "ADAPTER::TREEHOUSE_GATEWAY" | "ADAPTER::TREEHOUSE_ROUTER" | "ADAPTER::UNISWAP_V2_ROUTER" | "ADAPTER::UNISWAP_V3_ROUTER" | "ADAPTER::UNISWAP_V4_GATEWAY" | "ADAPTER::UPSHIFT_VAULT" | "ADAPTER::VELODROME_V2_ROUTER";
19
19
  export declare enum AdapterType {
20
20
  ACCOUNT_MIGRATOR = "ACCOUNT_MIGRATOR",
21
21
  BALANCER_V3_ROUTER = "BALANCER_V3_ROUTER",
@@ -50,6 +50,9 @@ export declare enum AdapterType {
50
50
  SECURITIZE_REDEMPTION = "SECURITIZE_REDEMPTION",
51
51
  STAKING_REWARDS = "STAKING_REWARDS",
52
52
  TRADERJOE_ROUTER = "TRADERJOE_ROUTER",
53
+ TREEHOUSE_FASTLANE = "TREEHOUSE_FASTLANE",
54
+ TREEHOUSE_GATEWAY = "TREEHOUSE_GATEWAY",
55
+ TREEHOUSE_ROUTER = "TREEHOUSE_ROUTER",
53
56
  UNISWAP_V2_ROUTER = "UNISWAP_V2_ROUTER",
54
57
  UNISWAP_V3_ROUTER = "UNISWAP_V3_ROUTER",
55
58
  UNISWAP_V4_GATEWAY = "UNISWAP_V4_GATEWAY",
@@ -1,4 +1,5 @@
1
1
  import { GearboxPermissionlessOptions } from "./types.js";
2
+ import { PermissionlessAnalytics } from "./analytics/PermissionlessAnalytics.js";
2
3
  import { AttachChainsArgs } from "./chains/types.js";
3
4
  import { ChainsNamespace } from "./chains/ChainsNamespace.js";
4
5
  import { PermissionlessDeploy } from "./deploy/PermissionlessDeploy.js";
@@ -26,11 +27,11 @@ import { InstanceOwnerTransactions } from "./transactions/InstanceOwnerTransacti
26
27
  * const store = await permissionless.oracles.store({ chainId: chain.chainId });
27
28
  * ```
28
29
  *
29
- * Only what needs a server goes to one. {@link chains} and {@link oracles}
30
- * are the backend's reads; {@link deploy} and {@link transactions} read the
31
- * target chain directly, because everything they answer is derived from there
32
- * and a round trip would only move the derivation further from the wallet
33
- * that has to sign for it.
30
+ * Only what needs a server goes to one. {@link chains}, {@link oracles} and
31
+ * {@link analytics} are the backend's reads; {@link deploy} and
32
+ * {@link transactions} read the target chain directly, because everything
33
+ * they answer is derived from there and a round trip would only move the
34
+ * derivation further from the wallet that has to sign for it.
34
35
  **/
35
36
  export declare class GearboxPermissionless {
36
37
  /**
@@ -42,6 +43,11 @@ export declare class GearboxPermissionless {
42
43
  * Namespace for price feeds: the store and its prices.
43
44
  **/
44
45
  readonly oracles: PermissionlessOracles;
46
+ /**
47
+ * Namespace for history: what a feed's price did over a window, see
48
+ * {@link PermissionlessAnalytics}.
49
+ **/
50
+ readonly analytics: PermissionlessAnalytics;
45
51
  /**
46
52
  * Namespace for the Safe batches an instance owner executes. Backend-free,
47
53
  * see {@link InstanceOwnerTransactions}.
@@ -0,0 +1,38 @@
1
+ import { AbstractOffchainNamespace } from "../../../offchain/AbstractOffchainNamespace.js";
2
+ import { GearboxPermissionlessOptions } from "../types.js";
3
+ import { PriceChartArgs, PriceFeedPriceChart } from "./types.js";
4
+ //#region src/permissionless/api/analytics/PermissionlessAnalytics.d.ts
5
+ /**
6
+ * History of the permissionless stack: what a thing did, rather than what it
7
+ * is.
8
+ *
9
+ * Separate from {@link PermissionlessOracles} because the two are read on
10
+ * different clocks. A feed's identity settles when a curator uploads it and
11
+ * is read once per page; its price moves every block and is re-read whenever
12
+ * a window changes. Folding the series into the feed would make every range
13
+ * switch re-fetch the identity, and every identity read carry a series the
14
+ * caller may never draw.
15
+ *
16
+ * ```ts
17
+ * const chart = await permissionless.analytics.priceChart({
18
+ * chainId: 1,
19
+ * address: feed,
20
+ * range: "1w",
21
+ * });
22
+ * ```
23
+ **/
24
+ export declare class PermissionlessAnalytics extends AbstractOffchainNamespace {
25
+ constructor(options: GearboxPermissionlessOptions);
26
+ /**
27
+ * The price one feed reported over a window.
28
+ *
29
+ * Backend-only by construction: the chain serves the present, and
30
+ * reconstructing a series from it would mean an archive read per point.
31
+ *
32
+ * @throws When the PriceFeedStore does not carry the feed. An address the
33
+ * store never held has no indexed history, and answering an empty series
34
+ * would read as "no price yet" rather than as the mistake it is.
35
+ **/
36
+ priceChart({ chainId, address, range }: PriceChartArgs): Promise<PriceFeedPriceChart>;
37
+ }
38
+ //#endregion
@@ -0,0 +1,3 @@
1
+ import { PriceChartArgs, PriceFeedChartPoint, PriceFeedPriceChart } from "./types.js";
2
+ import { PermissionlessAnalytics } from "./PermissionlessAnalytics.js";
3
+ export { PermissionlessAnalytics, PriceChartArgs, PriceFeedChartPoint, PriceFeedPriceChart };
@@ -0,0 +1,32 @@
1
+ import { z } from "zod/v4";
2
+ //#region src/permissionless/api/analytics/schemas.d.ts
3
+ /**
4
+ * Runtime schemas for {@link ./types.js}.
5
+ *
6
+ * Loose for the same reason the oracles schemas are: the backend assembles
7
+ * these rows from its own indexes and may report more about a window than the
8
+ * hand-written types declare.
9
+ **/
10
+ /** {@link PriceFeedChartPoint} */
11
+ export declare const priceFeedChartPointSchema: z.ZodObject<{
12
+ timestamp: z.ZodNumber;
13
+ value: z.ZodNumber;
14
+ }, z.core.$loose>;
15
+ /** {@link PriceFeedPriceChart} */
16
+ export declare const priceFeedChartSchema: z.ZodObject<{
17
+ range: z.ZodEnum<{
18
+ "1d": "1d";
19
+ "1m": "1m";
20
+ "1w": "1w";
21
+ "1y": "1y";
22
+ max: "max";
23
+ }>;
24
+ from: z.ZodNumber;
25
+ to: z.ZodNumber;
26
+ intervalSeconds: z.ZodNumber;
27
+ points: z.ZodArray<z.ZodObject<{
28
+ timestamp: z.ZodNumber;
29
+ value: z.ZodNumber;
30
+ }, z.core.$loose>>;
31
+ }, z.core.$loose>;
32
+ //#endregion
@@ -0,0 +1,38 @@
1
+ import { Timestamp } from "../../../model/primitives.js";
2
+ import { ChartRange } from "../../../model/charts.js";
3
+ import { Address } from "viem";
4
+ //#region src/permissionless/api/analytics/types.d.ts
5
+ /** One sampled price, in whole US dollars. */
6
+ export interface PriceFeedChartPoint {
7
+ timestamp: Timestamp;
8
+ value: number;
9
+ }
10
+ /**
11
+ * A feed's price over one window, sampled onto an epoch-aligned grid.
12
+ *
13
+ * Only the buckets with an observation are present: a gap is an absent point,
14
+ * never a zero and never a value carried over from a neighbour. The window is
15
+ * echoed back because `max` resolves against the feed's own first observation
16
+ * and is therefore not derivable from the range alone.
17
+ *
18
+ * Deliberately not a {@link ChartBundle}. A bundle carries one series per
19
+ * {@link ChartMetric}, and that union is closed over what the read model
20
+ * charts — a price feed's own price is not one of them, and widening it would
21
+ * reach every chart the protocol serves to add a series only this page draws.
22
+ **/
23
+ export interface PriceFeedPriceChart {
24
+ range: ChartRange;
25
+ from: Timestamp;
26
+ to: Timestamp;
27
+ /** Distance between two consecutive buckets. */
28
+ intervalSeconds: number;
29
+ points: PriceFeedChartPoint[];
30
+ }
31
+ /** Args of {@link PermissionlessAnalytics.priceChart}. */
32
+ export interface PriceChartArgs {
33
+ chainId: number;
34
+ address: Address;
35
+ /** Window to cover. The same set every other Gearbox chart offers. */
36
+ range: ChartRange;
37
+ }
38
+ //#endregion
@@ -1,17 +1,20 @@
1
1
  import { GearboxPermissionlessOptions } from "./types.js";
2
+ import { PriceChartArgs, PriceFeedChartPoint, PriceFeedPriceChart } from "./analytics/types.js";
3
+ import { PermissionlessAnalytics } from "./analytics/PermissionlessAnalytics.js";
2
4
  import { AttachChainsArgs, ChainScope, ChainSummaryArgs, PermissionlessChain, PermissionlessChainSummary } from "./chains/types.js";
3
5
  import { ChainsNamespace } from "./chains/ChainsNamespace.js";
4
6
  import { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./deploy/types.js";
5
7
  import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./deploy/PermissionlessDeploy.js";
6
- import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedStore, PermissionlessPrices } from "./oracles/types.js";
8
+ import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs } from "./oracles/types.js";
7
9
  import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./oracles/PermissionlessOracles.js";
8
10
  import { AddFeedsArgs, ChangeNamesArgs, ChangeStalenessPeriodsArgs, ForbidFeedsArgs, InstanceTxsArgs, PriceFeedPair } from "./transactions/types.js";
9
11
  import { InstanceOwnerTransactions } from "./transactions/InstanceOwnerTransactions.js";
10
12
  import { GearboxPermissionless } from "./GearboxPermissionless.js";
13
+ import "./analytics/index.js";
11
14
  import "./chains/index.js";
12
15
  import { deriveEffectiveStalenessPeriod } from "./deploy/effective-staleness.js";
13
16
  import "./deploy/index.js";
14
17
  import { PermissionlessChainUnreachableError, PermissionlessNotAttachedError, PriceFeedNotInStoreError, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError } from "./errors.js";
15
18
  import "./oracles/index.js";
16
19
  import "./transactions/index.js";
17
- export { AddFeedsArgs, AttachChainsArgs, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployPriceFeedArgs, ForbidFeedsArgs, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetPricesArgs, InstanceOwnerTransactions, InstanceTxsArgs, PermissionlessAsset, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedStore, PermissionlessPrices, PreparedDeployment, PreparedPriceFeedDeployment, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, deriveEffectiveStalenessPeriod, priceFeedSalt };
20
+ export { AddFeedsArgs, AttachChainsArgs, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployPriceFeedArgs, ForbidFeedsArgs, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetPricesArgs, InstanceOwnerTransactions, InstanceTxsArgs, PermissionlessAnalytics, PermissionlessAsset, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PreparedDeployment, PreparedPriceFeedDeployment, PriceChartArgs, PriceFeedArgs, PriceFeedChartPoint, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedPriceChart, PriceFeedSaltMissingError, PriceFeedStalenessUnknownError, deriveEffectiveStalenessPeriod, priceFeedSalt };
@@ -1,7 +1,8 @@
1
+ import { PriceFeedData } from "../../../model/opportunities.js";
1
2
  import { AbstractOffchainNamespace } from "../../../offchain/AbstractOffchainNamespace.js";
2
3
  import { GearboxPermissionlessOptions } from "../types.js";
3
4
  import { ChainsNamespace } from "../chains/ChainsNamespace.js";
4
- import { GetPricesArgs, PermissionlessPriceFeedStore, PermissionlessPrices } from "./types.js";
5
+ import { GetPricesArgs, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs } from "./types.js";
5
6
  import { Address } from "viem";
6
7
  //#region src/permissionless/api/oracles/PermissionlessOracles.d.ts
7
8
  export declare const GET_PRICES_GAS_LIMIT_BY_CHAIN_ID: Record<number, bigint>;
@@ -28,10 +29,63 @@ export declare class PermissionlessOracles extends AbstractOffchainNamespace {
28
29
  store({ chainId }: {
29
30
  chainId: number;
30
31
  }): Promise<PermissionlessPriceFeedStore>;
32
+ /**
33
+ * One feed of the store: what it is, which assets it may price, and which
34
+ * market slots it currently fills.
35
+ *
36
+ * Singular where {@link store} is plural, and not a filter over it: the
37
+ * store answers what a list renders, while this answers what a feed is used
38
+ * for, which the store does not carry at all.
39
+ *
40
+ * ```ts
41
+ * const { priceFeed, markets } = await permissionless.oracles.feed({
42
+ * chainId: 1,
43
+ * address: feed,
44
+ * });
45
+ * ```
46
+ *
47
+ * @throws When the store does not carry the feed. A private draft is not
48
+ * here — it lives in whichever app wrote it.
49
+ **/
50
+ feed({ chainId, address }: PriceFeedArgs): Promise<PermissionlessPriceFeedDetails>;
51
+ /**
52
+ * The feeds one feed reads from, recursively.
53
+ *
54
+ * Answers for any feed the chain has indexed, store member or not: a
55
+ * composite feed's children are rarely in the store themselves, and a tree
56
+ * that stopped at the first of them would not be one.
57
+ *
58
+ * ```ts
59
+ * const tree = await permissionless.oracles.dependencies({
60
+ * chainId: 1,
61
+ * address: feed,
62
+ * });
63
+ * ```
64
+ **/
65
+ dependencies({ chainId, address }: PriceFeedArgs): Promise<PriceFeedData>;
66
+ /**
67
+ * What the market values each of one feed's assets at.
68
+ *
69
+ * Prefer this over {@link prices} whenever the caller is looking at a single
70
+ * feed. That one prices the whole store, which costs the backend one
71
+ * `totalSupply` call per asset of every market on the chain; this costs it
72
+ * one price lookup and one multicall over the feed's own assets.
73
+ *
74
+ * ```ts
75
+ * const { marketCaps } = await permissionless.oracles.feedMarketCaps({
76
+ * chainId: 1,
77
+ * address: feed,
78
+ * });
79
+ * ```
80
+ **/
81
+ feedMarketCaps({ chainId, address }: PriceFeedArgs): Promise<PermissionlessPriceFeedMarketCaps>;
31
82
  /**
32
83
  * A price per feed, and a market cap per feed and asset. The feeds the
33
84
  * indexer has not seen are read off the chain by the backend, so the store
34
85
  * is priced whole.
86
+ *
87
+ * Chain-wide, and priced accordingly — see {@link feedMarketCaps} for one
88
+ * feed.
35
89
  **/
36
90
  prices({ chainId }: {
37
91
  chainId: number;
@@ -1,3 +1,3 @@
1
- import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedStore, PermissionlessPrices } from "./types.js";
1
+ import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs } from "./types.js";
2
2
  import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./PermissionlessOracles.js";
3
- export { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GetPricesArgs, PermissionlessAsset, PermissionlessOracles, PermissionlessPriceFeedStore, PermissionlessPrices };
3
+ export { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GetPricesArgs, PermissionlessAsset, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs };
@@ -70,4 +70,59 @@ export declare const pricesSchema: z.ZodObject<{
70
70
  marketCaps: z.ZodType<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, Record<`0x${string}`, string | null>>, unknown>>;
71
71
  time: z.ZodNumber;
72
72
  }, z.core.$loose>;
73
+ /** {@link PermissionlessPriceFeedAsset} */
74
+ export declare const priceFeedAssetSchema: z.ZodObject<{
75
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
76
+ symbol: z.ZodString;
77
+ name: z.ZodString;
78
+ decimals: z.ZodNumber;
79
+ }, z.core.$loose>;
80
+ /** {@link PermissionlessPriceFeedMarket} */
81
+ export declare const priceFeedMarketSchema: z.ZodObject<{
82
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
83
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
84
+ curatorName: z.ZodNullable<z.ZodString>;
85
+ marketName: z.ZodNullable<z.ZodString>;
86
+ token: z.ZodCustom<`0x${string}`, `0x${string}`>;
87
+ tokenSymbol: z.ZodNullable<z.ZodString>;
88
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
89
+ reserve: z.ZodBoolean;
90
+ isUnderlying: z.ZodBoolean;
91
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
92
+ }, z.core.$loose>;
93
+ /** {@link PermissionlessPriceFeedDetails} */
94
+ export declare const priceFeedDetailsSchema: z.ZodObject<{
95
+ chainId: z.ZodNumber;
96
+ priceFeed: z.ZodObject<{
97
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
98
+ contractType: z.ZodString;
99
+ version: z.ZodNumber;
100
+ deployedBy: z.ZodCustom<`0x${string}`, `0x${string}`>;
101
+ stalenessPeriod: z.ZodNumber;
102
+ name: z.ZodString;
103
+ }, z.core.$loose>;
104
+ assets: z.ZodArray<z.ZodObject<{
105
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
106
+ symbol: z.ZodString;
107
+ name: z.ZodString;
108
+ decimals: z.ZodNumber;
109
+ }, z.core.$loose>>;
110
+ markets: z.ZodArray<z.ZodObject<{
111
+ market: z.ZodCustom<`0x${string}`, `0x${string}`>;
112
+ marketConfigurator: z.ZodCustom<`0x${string}`, `0x${string}`>;
113
+ curatorName: z.ZodNullable<z.ZodString>;
114
+ marketName: z.ZodNullable<z.ZodString>;
115
+ token: z.ZodCustom<`0x${string}`, `0x${string}`>;
116
+ tokenSymbol: z.ZodNullable<z.ZodString>;
117
+ underlyingSymbol: z.ZodNullable<z.ZodString>;
118
+ reserve: z.ZodBoolean;
119
+ isUnderlying: z.ZodBoolean;
120
+ quotaLimit: z.ZodNullable<z.ZodNumber>;
121
+ }, z.core.$loose>>;
122
+ }, z.core.$loose>;
123
+ /** {@link PermissionlessPriceFeedMarketCaps} */
124
+ export declare const priceFeedMarketCapsSchema: z.ZodObject<{
125
+ marketCaps: z.ZodType<Record<`0x${string}`, string | null>, unknown, z.core.$ZodTypeInternals<Record<`0x${string}`, string | null>, unknown>>;
126
+ time: z.ZodNumber;
127
+ }, z.core.$loose>;
73
128
  //#endregion
@@ -37,6 +37,98 @@ export interface PermissionlessPrices {
37
37
  marketCaps: Record<Address, Record<Address, string | null>>;
38
38
  time: number;
39
39
  }
40
+ /**
41
+ * An asset the PriceFeedStore currently allows one feed to price.
42
+ *
43
+ * Narrower than {@link PermissionlessAsset} on purpose: this hangs off the
44
+ * feed, so listing the feeds allowed for it would just name the feed back.
45
+ **/
46
+ export interface PermissionlessPriceFeedAsset {
47
+ address: Address;
48
+ symbol: string;
49
+ name: string;
50
+ decimals: number;
51
+ }
52
+ /**
53
+ * One token a market prices with the feed.
54
+ *
55
+ * A row per `(market, token, role)` rather than per market: the same feed can
56
+ * be the main feed of one token and the reserve feed of another in the very
57
+ * same market, and both are reported.
58
+ **/
59
+ export interface PermissionlessPriceFeedMarket {
60
+ market: Address;
61
+ marketConfigurator: Address;
62
+ /** The configurator's own name, as the backend's sync recorded it. */
63
+ curatorName: string | null;
64
+ /**
65
+ * The market's own name, which is the name of its pool token — what the rest
66
+ * of the backend calls a market by as well.
67
+ */
68
+ marketName: string | null;
69
+ token: Address;
70
+ /** `null` for a token the backend has no metadata row for. */
71
+ tokenSymbol: string | null;
72
+ /**
73
+ * Symbol of the market's underlying, which is both what the market is
74
+ * pictured by and what its quota limit is denominated in.
75
+ */
76
+ underlyingSymbol: string | null;
77
+ /** The feed is the market's reserve feed for this token, not its main one. */
78
+ reserve: boolean;
79
+ /** The token is the market's underlying. */
80
+ isUnderlying: boolean;
81
+ /**
82
+ * What the pool will take of this token, in units of the market's
83
+ * underlying.
84
+ *
85
+ * `null` for a token the quota keeper was never told a limit for, which the
86
+ * market's own underlying always is — it is not quota-managed. A zero is a
87
+ * limit the curator has actually set to zero, and the two are different
88
+ * answers.
89
+ */
90
+ quotaLimit: number | null;
91
+ }
92
+ /**
93
+ * One feed of the store, with everywhere the store lets it be used.
94
+ *
95
+ * Feeds a tree carries but the store never added have no identity to report —
96
+ * no status history, hence no name or staleness — so the read throws for them
97
+ * rather than answering a half-filled row.
98
+ **/
99
+ export interface PermissionlessPriceFeedDetails {
100
+ chainId: number;
101
+ priceFeed: PriceFeed;
102
+ assets: PermissionlessPriceFeedAsset[];
103
+ /**
104
+ * Ordered by curator, then by market, then by role with the main feeds
105
+ * ahead of the reserve ones — the grouping a reader wants, so a caller
106
+ * rendering a table does not have to sort it again.
107
+ */
108
+ markets: PermissionlessPriceFeedMarket[];
109
+ }
110
+ /**
111
+ * Market caps of one feed's assets, keyed by the lowercased asset address.
112
+ *
113
+ * Scoped to the feed rather than to the chain, which is what
114
+ * {@link PermissionlessOracles.prices} answers. A cap is
115
+ * `price × totalSupply`, so the chain-wide read pays for one `totalSupply` per
116
+ * asset of every market on it; a screen showing one feed's handful of rows
117
+ * should not.
118
+ *
119
+ * `null` for an asset whose price or supply could not be read — not a zero,
120
+ * since an asset nobody could price is not an asset worth nothing.
121
+ */
122
+ export interface PermissionlessPriceFeedMarketCaps {
123
+ marketCaps: Record<Address, string | null>;
124
+ /** When the backend computed the figures; they are read live, not indexed. */
125
+ time: number;
126
+ }
127
+ /** Args of a read scoped to one feed. */
128
+ export interface PriceFeedArgs {
129
+ chainId: number;
130
+ address: Address;
131
+ }
40
132
  /** Args of {@link PermissionlessOracles.getPrices}. */
41
133
  export interface GetPricesArgs {
42
134
  chainId: number;
@@ -1,4 +1,6 @@
1
1
  import { GearboxPermissionlessOptions } from "./api/types.js";
2
+ import { PriceChartArgs, PriceFeedChartPoint, PriceFeedPriceChart } from "./api/analytics/types.js";
3
+ import { PermissionlessAnalytics } from "./api/analytics/PermissionlessAnalytics.js";
2
4
  import { AttachChainsArgs, ChainScope, ChainSummaryArgs, PermissionlessChain, PermissionlessChainSummary } from "./api/chains/types.js";
3
5
  import { ChainsNamespace } from "./api/chains/ChainsNamespace.js";
4
6
  import { Auditor } from "./core/auditor.js";
@@ -11,7 +13,7 @@ import "./core/index.js";
11
13
  import { FunctionParams, ValueParams, encodeFunctionParams } from "./utils/abi-encoder.js";
12
14
  import { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./api/deploy/types.js";
13
15
  import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./api/deploy/PermissionlessDeploy.js";
14
- import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedStore, PermissionlessPrices } from "./api/oracles/types.js";
16
+ import { GetPricesArgs, PermissionlessAsset, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs } from "./api/oracles/types.js";
15
17
  import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./api/oracles/PermissionlessOracles.js";
16
18
  import { AddressProviderContract } from "./bindings/address-provider.js";
17
19
  import { BytecodeRepositoryContract } from "./bindings/bytecode-repository.js";
@@ -52,4 +54,4 @@ import { getPrices } from "./utils/price-update/get-prices.js";
52
54
  import { GetUpdatablePriceFeedsArgs, getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds.js";
53
55
  import { normalizeSignature } from "./utils/signature.js";
54
56
  import "./utils/index.js";
55
- export { AccessMode, AddAssetParams, AddFeedsArgs, AddressProviderContract, Addresses, AllowTokenParams, ArchiveTransport, ArchiveTransportConfig, AttachChainsArgs, AuditEvent, Auditor, BYTECODE_REPOSITORY, Batch, Bytecode, BytecodeRepositoryContract, CCMConstructorParams, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, ConstructorParams, CreditManagerFees, CrossChainCall, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployParams, DeployPriceFeedArgs, Deployment, DeploymentExtended, ForbidAdapterParams, ForbidFeedsArgs, ForbidTokenParams, FunctionParams, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetPricesArgs, GetUpdatablePriceFeedsArgs, GovernorContract, INSTANCE_MANAGER, InputValueParams, InstanceManagerContract, InstanceOwnerTransactions, InstanceTxs, InstanceTxsArgs, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, Market, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PauseCreditManagerParams, PeripheryDomain, PermissionlessAsset, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedStore, PermissionlessPrices, PreparedDeployment, PreparedPriceFeedDeployment, PriceFeed, PriceFeedConstructorParam, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedParamType, PriceFeedParams, PriceFeedSaltMissingError, PriceFeedSetupParams, PriceFeedStalenessUnknownError, PriceFeedStoreContract, Proposal, QueuedAndExecutedTransaction, RecoveryMessage, RoutingManagerContract, SafeBatch, SafeMeta, SafeTx, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, Signature, TOKEN_COMPRESSOR, TimeLockContract, TimelockTransaction, TimelockTxParams, TimelockTxs, TokenCompressorContract, TreasurySplitterContract, UnpauseCreditManagerParams, ValueParams, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSalt, priceFeedSetupParams, shortenHash, significantTrunc };
57
+ export { AccessMode, AddAssetParams, AddFeedsArgs, AddressProviderContract, Addresses, AllowTokenParams, ArchiveTransport, ArchiveTransportConfig, AttachChainsArgs, AuditEvent, Auditor, BYTECODE_REPOSITORY, Batch, Bytecode, BytecodeRepositoryContract, CCMConstructorParams, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, ConstructorParams, CreditManagerFees, CrossChainCall, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployParams, DeployPriceFeedArgs, Deployment, DeploymentExtended, ForbidAdapterParams, ForbidFeedsArgs, ForbidTokenParams, FunctionParams, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetPricesArgs, GetUpdatablePriceFeedsArgs, GovernorContract, INSTANCE_MANAGER, InputValueParams, InstanceManagerContract, InstanceOwnerTransactions, InstanceTxs, InstanceTxsArgs, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, Market, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PauseCreditManagerParams, PeripheryDomain, PermissionlessAnalytics, PermissionlessAsset, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PreparedDeployment, PreparedPriceFeedDeployment, PriceChartArgs, PriceFeed, PriceFeedArgs, PriceFeedChartPoint, PriceFeedConstructorParam, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedParamType, PriceFeedParams, PriceFeedPriceChart, PriceFeedSaltMissingError, PriceFeedSetupParams, PriceFeedStalenessUnknownError, PriceFeedStoreContract, Proposal, QueuedAndExecutedTransaction, RecoveryMessage, RoutingManagerContract, SafeBatch, SafeMeta, SafeTx, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, Signature, TOKEN_COMPRESSOR, TimeLockContract, TimelockTransaction, TimelockTxParams, TimelockTxs, TokenCompressorContract, TreasurySplitterContract, UnpauseCreditManagerParams, ValueParams, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSalt, priceFeedSetupParams, shortenHash, significantTrunc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "18.1.0",
3
+ "version": "18.2.0-next.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {