@gearbox-protocol/sdk 16.0.0-next.54 → 16.0.0-next.56

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 (106) hide show
  1. package/dist/cjs/dev/mode-parity/compareOpportunities.js +3 -4
  2. package/dist/cjs/dev/mode-parity/comparePositions.js +5 -6
  3. package/dist/cjs/dev/mode-parity/fieldDiff.js +4 -6
  4. package/dist/cjs/dev/mode-parity/scriptUtils.js +145 -5
  5. package/dist/cjs/model/analytics.schema.js +44 -1
  6. package/dist/cjs/model/charts.js +15 -1
  7. package/dist/cjs/model/charts.schema.js +9 -3
  8. package/dist/cjs/model/index.js +9 -4
  9. package/dist/cjs/model/liquidations.schema.js +1 -1
  10. package/dist/cjs/model/opportunities.schema.js +2 -2
  11. package/dist/cjs/model/positions.schema.js +2 -2
  12. package/dist/cjs/offchain/analytics/OffchainAnalytics.js +25 -2
  13. package/dist/cjs/rewards/errors.js +27 -0
  14. package/dist/cjs/rewards/index.js +6 -7
  15. package/dist/cjs/rewards/merkl-api.js +45 -0
  16. package/dist/cjs/rewards/multichain.js +40 -0
  17. package/dist/cjs/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
  18. package/dist/cjs/sdk/analytics/AnalyticsNamespace.js +6 -0
  19. package/dist/esm/dev/AccountOpener.js +1 -1
  20. package/dist/esm/dev/mode-parity/compareOpportunities.js +3 -4
  21. package/dist/esm/dev/mode-parity/comparePositions.js +5 -6
  22. package/dist/esm/dev/mode-parity/fieldDiff.js +4 -6
  23. package/dist/esm/dev/mode-parity/scriptUtils.js +142 -6
  24. package/dist/esm/dev/withdrawalUtils.js +1 -1
  25. package/dist/esm/model/analytics.schema.js +42 -2
  26. package/dist/esm/model/charts.js +15 -2
  27. package/dist/esm/model/charts.schema.js +9 -4
  28. package/dist/esm/model/index.js +6 -6
  29. package/dist/esm/model/liquidations.schema.js +1 -1
  30. package/dist/esm/model/opportunities.schema.js +2 -2
  31. package/dist/esm/model/positions.schema.js +2 -2
  32. package/dist/esm/offchain/analytics/OffchainAnalytics.js +25 -2
  33. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  34. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  35. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  36. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  37. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  38. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  39. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  40. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  41. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  42. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  43. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  44. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  45. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  46. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  47. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  48. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  49. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  50. package/dist/esm/rewards/errors.js +26 -0
  51. package/dist/esm/rewards/index.js +4 -5
  52. package/dist/esm/rewards/merkl-api.js +42 -0
  53. package/dist/esm/rewards/multichain.js +39 -0
  54. package/dist/esm/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
  55. package/dist/esm/sdk/analytics/AnalyticsNamespace.js +6 -0
  56. package/dist/types/dev/mode-parity/compareOpportunities.d.ts +3 -7
  57. package/dist/types/dev/mode-parity/comparePositions.d.ts +4 -8
  58. package/dist/types/dev/mode-parity/fieldDiff.d.ts +9 -8
  59. package/dist/types/dev/mode-parity/scriptUtils.d.ts +26 -1
  60. package/dist/types/model/analytics.d.ts +22 -1
  61. package/dist/types/model/analytics.schema.d.ts +65 -1
  62. package/dist/types/model/charts.d.ts +20 -2
  63. package/dist/types/model/charts.schema.d.ts +14 -2
  64. package/dist/types/model/index.d.ts +5 -5
  65. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
  66. package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +14 -2
  67. package/dist/types/offchain/analytics/types.d.ts +11 -0
  68. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -1
  69. package/dist/types/offchain/opportunities/types.d.ts +1 -1
  70. package/dist/types/offchain/positions/OffchainPositions.d.ts +1 -1
  71. package/dist/types/offchain/positions/types.d.ts +1 -1
  72. package/dist/types/rewards/errors.d.ts +18 -0
  73. package/dist/types/rewards/index.d.ts +4 -7
  74. package/dist/types/rewards/merkl-api.d.ts +64 -0
  75. package/dist/types/rewards/multichain.d.ts +33 -0
  76. package/dist/types/rewards/toMerklRewards.d.ts +42 -0
  77. package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +6 -0
  78. package/dist/types/sdk/analytics/types.d.ts +16 -0
  79. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
  80. package/dist/types/sdk/opportunities/types.d.ts +1 -1
  81. package/dist/types/sdk/positions/PositionsNamespace.d.ts +1 -1
  82. package/dist/types/sdk/positions/types.d.ts +1 -1
  83. package/package.json +1 -3
  84. package/dist/cjs/_virtual/_rolldown/runtime.js +0 -23
  85. package/dist/cjs/rewards/apy/index.js +0 -3
  86. package/dist/cjs/rewards/apy/output-details.js +0 -1
  87. package/dist/cjs/rewards/apy/output.js +0 -1
  88. package/dist/cjs/rewards/rewards/common.js +0 -1
  89. package/dist/cjs/rewards/rewards/extra-apy.js +0 -71
  90. package/dist/cjs/rewards/rewards/index.js +0 -6
  91. package/dist/cjs/rewards/rewards/merkl-api.js +0 -22
  92. package/dist/esm/rewards/apy/index.js +0 -3
  93. package/dist/esm/rewards/apy/output-details.js +0 -1
  94. package/dist/esm/rewards/apy/output.js +0 -1
  95. package/dist/esm/rewards/rewards/common.js +0 -1
  96. package/dist/esm/rewards/rewards/extra-apy.js +0 -67
  97. package/dist/esm/rewards/rewards/index.js +0 -3
  98. package/dist/esm/rewards/rewards/merkl-api.js +0 -19
  99. package/dist/types/rewards/apy/index.d.ts +0 -3
  100. package/dist/types/rewards/apy/output-details.d.ts +0 -99
  101. package/dist/types/rewards/apy/output.d.ts +0 -25
  102. package/dist/types/rewards/rewards/api.d.ts +0 -60
  103. package/dist/types/rewards/rewards/common.d.ts +0 -9
  104. package/dist/types/rewards/rewards/extra-apy.d.ts +0 -37
  105. package/dist/types/rewards/rewards/index.d.ts +0 -3
  106. package/dist/types/rewards/rewards/merkl-api.d.ts +0 -54
@@ -74,6 +74,23 @@ declare const STRATEGY_POSITION_CHART_METRICS: readonly ["totalValueUnderlying",
74
74
  * token or a token argument on the read.
75
75
  **/
76
76
  type StrategyPositionChartMetric = (typeof STRATEGY_POSITION_CHART_METRICS)[number];
77
+ /**
78
+ * Every metric the protocol as a whole can chart.
79
+ *
80
+ * Protocol-wide rather than per subject: the series describes Gearbox itself
81
+ * over every chain the read covers, so it has no address to hang off and is
82
+ * read from the analytics namespace rather than from an opportunity.
83
+ *
84
+ * `tvlUsd` is deliberately not spelled `tvl`: that key is already the credit
85
+ * manager's TVL in whole underlying tokens, and one metric has exactly one
86
+ * unit in {@link CHART_METRIC_UNITS}.
87
+ **/
88
+ declare const PROTOCOL_CHART_METRICS: readonly ["tvlUsd"];
89
+ /**
90
+ * Metric the protocol as a whole can chart, derived from
91
+ * {@link PROTOCOL_CHART_METRICS}.
92
+ **/
93
+ type ProtocolChartMetric = (typeof PROTOCOL_CHART_METRICS)[number];
77
94
  /**
78
95
  * Any metric an opportunity can chart.
79
96
  **/
@@ -89,7 +106,7 @@ type PositionChartMetric = PoolPositionChartMetric | StrategyPositionChartMetric
89
106
  * the same rate whether an opportunity or a position charts it — so one metric
90
107
  * has one unit in {@link CHART_METRIC_UNITS} no matter who asks for it.
91
108
  **/
92
- type ChartMetric = OpportunityChartMetric | PositionChartMetric;
109
+ type ChartMetric = OpportunityChartMetric | PositionChartMetric | ProtocolChartMetric;
93
110
  /**
94
111
  * What one chart read asks for, beyond the subject its route names.
95
112
  *
@@ -181,6 +198,7 @@ declare const CHART_METRIC_UNITS: {
181
198
  readonly debt: "token";
182
199
  readonly healthFactor: "bps";
183
200
  readonly netApy7d: "bps";
201
+ readonly tvlUsd: "usd";
184
202
  };
185
203
  /**
186
204
  * A unit together with what it is denominated in.
@@ -341,4 +359,4 @@ interface ChartBundle<Metrics extends readonly ChartMetric[]> {
341
359
  }
342
360
  type ChartSeriesMap<Metrics extends readonly ChartMetric[]> = number extends Metrics["length"] ? Partial<Record<Metrics[number], ChartSeries>> : Record<Metrics[number], ChartSeries>;
343
361
  //#endregion
344
- export { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, GridSampling, OpportunityChartMetric, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PoolOpportunityChartMetric, PoolPositionChartMetric, PositionChartMetric, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunityChartMetric, StrategyPositionChartMetric };
362
+ export { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, GridSampling, OpportunityChartMetric, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PoolOpportunityChartMetric, PoolPositionChartMetric, PositionChartMetric, ProtocolChartMetric, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunityChartMetric, StrategyPositionChartMetric };
@@ -68,7 +68,13 @@ declare const strategyPositionChartMetricSchema: z.ZodEnum<{
68
68
  totalValueUnderlying: "totalValueUnderlying";
69
69
  }>;
70
70
  /**
71
- * {@link ChartMetric}, every metric either kind of subject can chart.
71
+ * {@link ProtocolChartMetric}
72
+ **/
73
+ declare const protocolChartMetricSchema: z.ZodEnum<{
74
+ tvlUsd: "tvlUsd";
75
+ }>;
76
+ /**
77
+ * {@link ChartMetric}, every metric any subject can chart.
72
78
  **/
73
79
  declare const chartMetricSchema: z.ZodUnion<readonly [z.ZodEnum<{
74
80
  borrowed: "borrowed";
@@ -101,6 +107,8 @@ declare const chartMetricSchema: z.ZodUnion<readonly [z.ZodEnum<{
101
107
  netApy7d: "netApy7d";
102
108
  pnl: "pnl";
103
109
  totalValueUnderlying: "totalValueUnderlying";
110
+ }>, z.ZodEnum<{
111
+ tvlUsd: "tvlUsd";
104
112
  }>]>;
105
113
  /**
106
114
  * {@link ChartQuery}
@@ -137,6 +145,8 @@ declare const chartQuerySchema: z.ZodObject<{
137
145
  netApy7d: "netApy7d";
138
146
  pnl: "pnl";
139
147
  totalValueUnderlying: "totalValueUnderlying";
148
+ }>, z.ZodEnum<{
149
+ tvlUsd: "tvlUsd";
140
150
  }>]>>>;
141
151
  range: z.ZodEnum<{
142
152
  "1d": "1d";
@@ -210,6 +220,8 @@ declare const chartQueryCodec: z.ZodCodec<z.ZodObject<{
210
220
  netApy7d: "netApy7d";
211
221
  pnl: "pnl";
212
222
  totalValueUnderlying: "totalValueUnderlying";
223
+ }>, z.ZodEnum<{
224
+ tvlUsd: "tvlUsd";
213
225
  }>]>>>;
214
226
  range: z.ZodEnum<{
215
227
  "1d": "1d";
@@ -341,4 +353,4 @@ declare const chartWindowSchema: z.ZodObject<{
341
353
  **/
342
354
  declare function chartBundleSchemaFor<const Metrics extends readonly ChartMetric[]>(metrics: Metrics, range: ChartRange): z.ZodType<ChartBundle<Metrics>>;
343
355
  //#endregion
344
- export { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema };
356
+ export { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, protocolChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema };
@@ -1,4 +1,5 @@
1
1
  import { Amount, Asset, AssetType, Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, TxCall, UnderlyingToken } from "./primitives.js";
2
+ import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, GridSampling, OpportunityChartMetric, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PoolOpportunityChartMetric, PoolPositionChartMetric, PositionChartMetric, ProtocolChartMetric, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunityChartMetric, StrategyPositionChartMetric } from "./charts.js";
2
3
  import { ChainScopedFilter, FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
3
4
  import { IGearboxError } from "./errors.js";
4
5
  import { Curator, CuratorName } from "./curators.js";
@@ -7,10 +8,9 @@ import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, Opportun
7
8
  import { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
8
9
  import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdapterCallOutsideBracketError, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, InvalidTransactionValueError, MalformedBracketError, MalformedBracketKind, MalformedPreviewError, NonAdapterCallInBracketError, OpenStrategyPositionPreview, OperationPreview, OperationPreviewError, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError, asEstimated } from "./previews.js";
9
10
  import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
10
- import { AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition } from "./analytics.js";
11
- import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema } from "./analytics.schema.js";
12
- import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, GridSampling, OpportunityChartMetric, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PoolOpportunityChartMetric, PoolPositionChartMetric, PositionChartMetric, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunityChartMetric, StrategyPositionChartMetric } from "./charts.js";
13
- import { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema } from "./charts.schema.js";
11
+ import { AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition } from "./analytics.js";
12
+ import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema } from "./analytics.schema.js";
13
+ import { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, protocolChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema } from "./charts.schema.js";
14
14
  import { CompareTag, CompareTolerance, ToleranceCompareTag, backendPreferred, compareTagOf, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
15
15
  import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
16
16
  import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
@@ -25,4 +25,4 @@ import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourc
25
25
  import { SDKError, SDKResult, SDKReturn, SafeValue, isSDKError, safeValue, sdkErr, sdkOk } from "./result.js";
26
26
  import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
27
27
  import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
28
- export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdapterCallOutsideBracketError, AdjustStrategyPositionPreview, Amount, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InvalidTransactionValueError, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, MalformedBracketError, MalformedBracketKind, MalformedPreviewError, NonAdapterCallInBracketError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError, WithdrawalOutputAmount, amountSchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, isSDKError, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, withdrawalOutputAmountSchema };
28
+ export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdapterCallOutsideBracketError, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InvalidTransactionValueError, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, MalformedBracketError, MalformedBracketKind, MalformedPreviewError, NonAdapterCallInBracketError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError, WithdrawalOutputAmount, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, isSDKError, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, withdrawalOutputAmountSchema };
@@ -1,7 +1,7 @@
1
1
  import { ILogger } from "../onchain/types/logger.js";
2
2
  import { ChainId } from "../model/primitives.js";
3
- import { ChainScopedFilter } from "../model/filters.js";
4
3
  import { ChartBundle, ChartMetric, ChartRange } from "../model/charts.js";
4
+ import { ChainScopedFilter } from "../model/filters.js";
5
5
  import { DataResponse } from "../model/response.js";
6
6
  import { GearboxAPIOptions } from "./types.js";
7
7
  import { z } from "zod/v4";
@@ -1,11 +1,23 @@
1
+ import { ChartBundle, ChartRange, ProtocolChartMetric } from "../../model/charts.js";
2
+ import { ChainScopedFilter } from "../../model/filters.js";
3
+ import { DataResponse } from "../../model/response.js";
1
4
  import { GearboxAPIOptions } from "../types.js";
5
+ import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
2
6
  import { IOffchainAnalytics } from "./types.js";
3
7
  import { OffchainAnalyticsPositions } from "./OffchainAnalyticsPositions.js";
4
8
  //#region src/offchain/analytics/OffchainAnalytics.d.ts
5
- /** Backend-only protocol analytics, grouped by subject. */
6
- declare class OffchainAnalytics implements IOffchainAnalytics {
9
+ /**
10
+ * Backend-only protocol analytics, grouped by subject.
11
+ *
12
+ * It owns the protocol-wide charts itself rather than through a sub-namespace:
13
+ * their subject is Gearbox as a whole, so there is nothing narrower for them to
14
+ * hang off.
15
+ **/
16
+ declare class OffchainAnalytics extends AbstractOffchainNamespace implements IOffchainAnalytics {
7
17
  readonly positions: OffchainAnalyticsPositions;
8
18
  constructor(options: GearboxAPIOptions);
19
+ /** {@inheritDoc IOffchainAnalytics.getCharts} */
20
+ getCharts<const Metrics extends readonly ProtocolChartMetric[]>(metrics: Metrics, range: ChartRange, filter?: ChainScopedFilter): Promise<DataResponse<ChartBundle<Metrics>>>;
9
21
  }
10
22
  //#endregion
11
23
  export { OffchainAnalytics };
@@ -1,3 +1,5 @@
1
+ import { ChartBundle, ChartRange, ProtocolChartMetric } from "../../model/charts.js";
2
+ import { ChainScopedFilter } from "../../model/filters.js";
1
3
  import { AnalyticsPositionListOptions, AnalyticsPositionPage } from "../../model/analytics.js";
2
4
  import { DataResponse } from "../../model/response.js";
3
5
  //#region src/offchain/analytics/types.d.ts
@@ -12,6 +14,15 @@ interface IOffchainAnalyticsPositions {
12
14
  /** Backend-only protocol analytics, grouped by subject. */
13
15
  interface IOffchainAnalytics {
14
16
  readonly positions: IOffchainAnalyticsPositions;
17
+ /**
18
+ * Charts of the protocol as a whole: one series per metric named, onto the
19
+ * one grid that lets them be compared at an index.
20
+ *
21
+ * The series sums the chains the read covers, which are the client's own
22
+ * narrowed by `filter` — so a client built for one chain charts that chain,
23
+ * not the protocol.
24
+ **/
25
+ getCharts<const Metrics extends readonly ProtocolChartMetric[]>(metrics: Metrics, range: ChartRange, filter?: ChainScopedFilter): Promise<DataResponse<ChartBundle<Metrics>>>;
15
26
  }
16
27
  //#endregion
17
28
  export { IOffchainAnalytics, IOffchainAnalyticsPositions };
@@ -1,5 +1,5 @@
1
- import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
2
1
  import { ChartBundle, ChartRange } from "../../model/charts.js";
2
+ import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { GearboxAPIOptions } from "../types.js";
5
5
  import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
@@ -1,5 +1,5 @@
1
- import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
2
1
  import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
2
+ import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  //#region src/offchain/opportunities/types.d.ts
5
5
  type OpportunityChartMetricFor<K extends OpportunityKey> = {
@@ -1,5 +1,5 @@
1
- import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
2
1
  import { ChartBundle, ChartRange } from "../../model/charts.js";
2
+ import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
5
5
  import { GearboxAPIOptions } from "../types.js";
@@ -1,5 +1,5 @@
1
- import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
2
1
  import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
2
+ import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
5
5
  import { Address } from "viem";
@@ -0,0 +1,18 @@
1
+ import { ChainId } from "../model/primitives.js";
2
+ import "../model/index.js";
3
+ import { BaseError } from "viem";
4
+ //#region src/rewards/errors.d.ts
5
+ /**
6
+ * Thrown when none of Merkl's domains answered for a chain.
7
+ *
8
+ * Everything a reader needs is in the message: this error travels to consumers
9
+ * inside a chain's {@link ChainFailed} metadata, where it is typed `unknown`
10
+ * and may be serialised by something that turns an arbitrary object into `{}`.
11
+ */
12
+ declare class MerklRequestFailedError extends BaseError {
13
+ name: string;
14
+ readonly chainId: ChainId;
15
+ constructor(chainId: ChainId, path: string, attempts: ReadonlyArray<[domain: string, cause: unknown]>);
16
+ }
17
+ //#endregion
18
+ export { MerklRequestFailedError };
@@ -1,7 +1,4 @@
1
- import { Apy, ApyDetails, DebtReward, ExternalApy, ExtraCollateralAPY, ExtraCollateralPointsInfo, FarmInfo, GearAPY, GearAPYDetails, PointsInfo, PointsReward, PoolExtraApy, PoolOutputDetails, PoolPointsInfo, TokenOutputDetails } from "./apy/output-details.js";
2
- import { DataResult, Output } from "./apy/output.js";
3
- import "./apy/index.js";
4
- import { GetMerklRewardsProps, MerklReward, MerklRewardsSdk, getMerklRewards } from "./rewards/api.js";
5
- import { GetPointsByPoolProps, GetTotalTokensOnProtocolProps, PoolPointsAPI, PoolPointsBase, getKeyForPoolPointsInfo } from "./rewards/extra-apy.js";
6
- import "./rewards/index.js";
7
- export { Apy, ApyDetails, DataResult, DebtReward, ExternalApy, ExtraCollateralAPY, ExtraCollateralPointsInfo, FarmInfo, GearAPY, GearAPYDetails, GetMerklRewardsProps, GetPointsByPoolProps, GetTotalTokensOnProtocolProps, MerklReward, MerklRewardsSdk, Output, PointsInfo, PointsReward, PoolExtraApy, PoolOutputDetails, PoolPointsAPI, PoolPointsBase, PoolPointsInfo, TokenOutputDetails, getKeyForPoolPointsInfo, getMerklRewards };
1
+ import { MerklRequestFailedError } from "./errors.js";
2
+ import { MerklReward, MerklRewardsSdk, toMerklRewards } from "./toMerklRewards.js";
3
+ import { GetMerklRewardsMultichainProps, getMerklRewardsMultichain } from "./multichain.js";
4
+ export { GetMerklRewardsMultichainProps, MerklRequestFailedError, MerklReward, MerklRewardsSdk, getMerklRewardsMultichain, toMerklRewards };
@@ -0,0 +1,64 @@
1
+ import { ChainId } from "../model/primitives.js";
2
+ import "../model/index.js";
3
+ import { Address } from "viem";
4
+ //#region src/rewards/merkl-api.d.ts
5
+ interface MerkleXYZUserRewardsV4 {
6
+ chain: MerkleXYZChain;
7
+ rewards: Array<{
8
+ root: Address;
9
+ recipient: Address;
10
+ amount: string;
11
+ claimed: string;
12
+ pending: string;
13
+ proofs: Array<Address>;
14
+ token: {
15
+ address: Address;
16
+ chainId: number;
17
+ symbol: string;
18
+ decimals: number;
19
+ /**
20
+ * USD price of one whole token. Optional because Merkl omits the key
21
+ * outright for the tokens it does not price — points and the like —
22
+ * rather than sending a null.
23
+ */
24
+ price?: number;
25
+ };
26
+ breakdowns: Array<{
27
+ reason: string;
28
+ amount: string;
29
+ claimed: string;
30
+ pending: string;
31
+ campaignId: Address;
32
+ }>;
33
+ }>;
34
+ }
35
+ type MerkleXYZUserRewardsV4Response = Array<MerkleXYZUserRewardsV4>;
36
+ interface MerkleXYZChain {
37
+ id: number;
38
+ name: string;
39
+ icon: string;
40
+ }
41
+ /**
42
+ * Merkl's own host and the Angle mirror, tried in this order.
43
+ */
44
+ declare const MERKL_DOMAINS: readonly ["https://api.merkl.xyz", "https://api-merkl.angle.money"];
45
+ declare const MERKL_API_KEY_HEADER = "X-API-Key";
46
+ interface FetchMerklUserRewardsProps {
47
+ chainId: ChainId;
48
+ /** Checksummed by the caller — Merkl keys its answer on the exact string. */
49
+ user: Address;
50
+ /** Raises Merkl's rate limit; the keyless path answers too. */
51
+ apiKey?: string;
52
+ }
53
+ /**
54
+ * The wallet's raw Merkl rewards on one chain.
55
+ *
56
+ * Rejects with {@link MerklRequestFailedError} when neither domain answers, so
57
+ * a caller can tell an unreachable Merkl from a wallet with nothing to claim.
58
+ * A non-2xx counts as no answer and moves to the next domain: it carries no
59
+ * rewards either way, and treating it as success would report emptiness that
60
+ * was never established.
61
+ */
62
+ declare function fetchMerklUserRewards({ chainId, user, apiKey }: FetchMerklUserRewardsProps): Promise<MerkleXYZUserRewardsV4Response>;
63
+ //#endregion
64
+ export { FetchMerklUserRewardsProps, MERKL_API_KEY_HEADER, MERKL_DOMAINS, MerkleXYZUserRewardsV4, MerkleXYZUserRewardsV4Response, fetchMerklUserRewards };
@@ -0,0 +1,33 @@
1
+ import { ChainId } from "../model/primitives.js";
2
+ import { DataResponse } from "../model/response.js";
3
+ import "../model/index.js";
4
+ import { PluginsMap } from "../onchain/plugins/types.js";
5
+ import { MultichainSDK } from "../onchain/MultichainSDK.js";
6
+ import "../onchain/index.js";
7
+ import { MerklReward } from "./toMerklRewards.js";
8
+ import { Address } from "viem";
9
+ //#region src/rewards/multichain.d.ts
10
+ interface GetMerklRewardsMultichainProps<Plugins extends PluginsMap = {}> {
11
+ /** Handle whose chains are asked. */
12
+ sdk: MultichainSDK<Plugins>;
13
+ /** Wallet whose claimable rewards to list. */
14
+ wallet: Address;
15
+ /**
16
+ * Chains to ask, defaulting to every chain the handle carries.
17
+ **/
18
+ chainIds?: ChainId[];
19
+ /** Raises Merkl's rate limit; the keyless path answers too. */
20
+ apiKey?: string;
21
+ }
22
+ /**
23
+ * Every claimable Merkl reward a wallet holds, across the chains the handle
24
+ * carries.
25
+ *
26
+ * Answers the read model's own envelope, so a chain that could not be reached
27
+ * is `status: "error"` in `meta.chains` while a chain with nothing to claim is
28
+ * a `"success"` that contributed no rows. That distinction is the point: the
29
+ * single-chain read this replaces resolved empty either way.
30
+ **/
31
+ declare function getMerklRewardsMultichain<const Plugins extends PluginsMap = {}>({ sdk, wallet, chainIds, apiKey }: GetMerklRewardsMultichainProps<Plugins>): Promise<DataResponse<MerklReward[]>>;
32
+ //#endregion
33
+ export { GetMerklRewardsMultichainProps, getMerklRewardsMultichain };
@@ -0,0 +1,42 @@
1
+ import { ChainId, Token, TokenAmount } from "../model/primitives.js";
2
+ import "../model/index.js";
3
+ import { OnchainSDK } from "../onchain/OnchainSDK.js";
4
+ import "../onchain/index.js";
5
+ import { MerkleXYZUserRewardsV4Response } from "./merkl-api.js";
6
+ import { Address } from "viem";
7
+ //#region src/rewards/toMerklRewards.d.ts
8
+ /**
9
+ * One claimable Merkl liquidity-mining reward, denominated and priced.
10
+ *
11
+ * Both tokens arrive resolved, so a consumer neither looks one up nor
12
+ * reassembles one out of the loose fields Merkl sends.
13
+ */
14
+ interface MerklReward {
15
+ readonly chainId: ChainId;
16
+ /** Market pool whose depositors the campaign rewards. */
17
+ readonly pool: Address;
18
+ /** That pool's share token — what the campaign is keyed on. */
19
+ readonly poolToken: Token;
20
+ /**
21
+ * The incentive token being handed out, how much of it is claimable
22
+ * (distributed minus already claimed, always > 0) and what that is worth.
23
+ *
24
+ * Priced by Merkl, not by the market oracles: a campaign's incentive token
25
+ * is rarely collateral in the pool it incentivises, so the oracles usually
26
+ * do not know it — GEAR, which most Gearbox campaigns pay in, among them.
27
+ * `valueUsd` is `null` for a token Merkl does not price either.
28
+ */
29
+ readonly amount: TokenAmount;
30
+ }
31
+ /**
32
+ * What the mapping needs off a chain's SDK: which chain the rows belong to,
33
+ * the pools a campaign can be keyed on, and the registry that names their
34
+ * tokens. Nothing else, and nothing asynchronous.
35
+ */
36
+ type MerklRewardsSdk = Pick<OnchainSDK, "chainId" | "marketRegister" | "tokensMeta">;
37
+ /**
38
+ * Merkl's answer for one chain, turned into rows of the read model.
39
+ */
40
+ declare function toMerklRewards(sdk: MerklRewardsSdk, response: MerkleXYZUserRewardsV4Response): MerklReward[];
41
+ //#endregion
42
+ export { MerklReward, MerklRewardsSdk, toMerklRewards };
@@ -1,11 +1,17 @@
1
+ import { ChartBundle, ChartRange, ProtocolChartMetric } from "../../model/charts.js";
2
+ import { ChainScopedFilter } from "../../model/filters.js";
3
+ import { DataResponse } from "../../model/response.js";
1
4
  import { GearboxAPI } from "../../offchain/GearboxAPI.js";
2
5
  import "../../offchain/index.js";
3
6
  import { IAnalytics } from "./types.js";
4
7
  //#region src/sdk/analytics/AnalyticsNamespace.d.ts
5
8
  /** Backend-only protocol analytics exposed by {@link GearboxSDK}. */
6
9
  declare class AnalyticsNamespace implements IAnalytics {
10
+ #private;
7
11
  readonly positions: GearboxAPI["analytics"]["positions"];
8
12
  constructor(backend: GearboxAPI);
13
+ /** {@inheritDoc IAnalytics.charts} */
14
+ charts<const Metrics extends readonly ProtocolChartMetric[]>(metrics: Metrics, range: ChartRange, filter?: ChainScopedFilter): Promise<DataResponse<ChartBundle<Metrics>>>;
9
15
  }
10
16
  //#endregion
11
17
  export { AnalyticsNamespace };
@@ -1,9 +1,25 @@
1
+ import { ChartBundle, ChartRange, ProtocolChartMetric } from "../../model/charts.js";
2
+ import { ChainScopedFilter } from "../../model/filters.js";
3
+ import { DataResponse } from "../../model/response.js";
1
4
  import { IOffchainAnalyticsPositions } from "../../offchain/analytics/types.js";
2
5
  import "../../offchain/index.js";
3
6
  //#region src/sdk/analytics/types.d.ts
4
7
  /** Backend-only protocol analytics, grouped by subject. */
5
8
  interface IAnalytics {
6
9
  readonly positions: IOffchainAnalyticsPositions;
10
+ /**
11
+ * Charts of the protocol as a whole: one series per metric named, onto the
12
+ * one grid that lets them be compared at an index.
13
+ *
14
+ * ```ts
15
+ * const { data } = await sdk.analytics.charts(["tvlUsd"], "1m");
16
+ * ```
17
+ *
18
+ * The series sums the chains the read covers, which are this instance's own
19
+ * narrowed by `filter` — so an SDK built for one chain charts that chain,
20
+ * not the protocol.
21
+ **/
22
+ charts<const Metrics extends readonly ProtocolChartMetric[]>(metrics: Metrics, range: ChartRange, filter?: ChainScopedFilter): Promise<DataResponse<ChartBundle<Metrics>>>;
7
23
  }
8
24
  /** `sdk.analytics` per mode: absent when the SDK has no backend source. */
9
25
  interface IAnalyticsByMode {
@@ -1,5 +1,5 @@
1
- import { Opportunity, OpportunityFilter, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
2
1
  import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
2
+ import { Opportunity, OpportunityFilter, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import "../../model/index.js";
5
5
  import { MultichainSDK } from "../../onchain/MultichainSDK.js";
@@ -1,5 +1,5 @@
1
- import { Opportunity, OpportunityFilter, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
2
1
  import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
2
+ import { Opportunity, OpportunityFilter, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import "../../model/index.js";
5
5
  import { IMultichainOpportunitiesService } from "../../onchain/opportunities/types.js";
@@ -1,5 +1,5 @@
1
- import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
2
1
  import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
2
+ import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { PositionWithdrawals } from "../../model/withdrawals.js";
5
5
  import "../../model/index.js";
@@ -1,5 +1,5 @@
1
- import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
2
1
  import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
2
+ import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { PositionWithdrawals } from "../../model/withdrawals.js";
5
5
  import "../../model/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.0.0-next.54",
3
+ "version": "16.0.0-next.56",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -107,7 +107,6 @@
107
107
  "@commitlint/cli": "^21.2.1",
108
108
  "@commitlint/config-conventional": "^21.2.0",
109
109
  "@gearbox-protocol/biome-config": "^1.1.6",
110
- "axios": "^1.19.0",
111
110
  "husky": "^9.1.7",
112
111
  "lint-staged": "^17.3.0",
113
112
  "pino": "^10.3.1",
@@ -122,7 +121,6 @@
122
121
  "yaml": "^2.9.0"
123
122
  },
124
123
  "peerDependencies": {
125
- "axios": "^1.0.0",
126
124
  "viem-deal": "^2.0.4"
127
125
  },
128
126
  "peerDependenciesMeta": {
@@ -1,23 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- exports.__toESM = __toESM;
@@ -1,3 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./output.js");
3
- require("./output-details.js");
@@ -1 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });