@gearbox-protocol/sdk 16.0.0-next.53 → 16.0.0-next.55

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 (107) hide show
  1. package/dist/cjs/dev/mode-parity/compareOpportunities.js +4 -5
  2. package/dist/cjs/dev/mode-parity/comparePositions.js +6 -7
  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 +117 -0
  6. package/dist/cjs/model/charts.schema.js +1 -1
  7. package/dist/cjs/model/index.js +18 -7
  8. package/dist/cjs/model/liquidations.schema.js +2 -2
  9. package/dist/cjs/model/opportunities.schema.js +3 -3
  10. package/dist/cjs/model/positions.schema.js +2 -2
  11. package/dist/cjs/offchain/GearboxAPI.js +5 -0
  12. package/dist/cjs/offchain/analytics/OffchainAnalytics.js +12 -0
  13. package/dist/cjs/offchain/analytics/OffchainAnalyticsPositions.js +24 -0
  14. package/dist/cjs/offchain/analytics/index.js +6 -0
  15. package/dist/cjs/offchain/index.js +5 -0
  16. package/dist/cjs/rewards/errors.js +27 -0
  17. package/dist/cjs/rewards/index.js +6 -7
  18. package/dist/cjs/rewards/merkl-api.js +45 -0
  19. package/dist/cjs/rewards/multichain.js +40 -0
  20. package/dist/cjs/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
  21. package/dist/cjs/sdk/GearboxSDK.js +5 -0
  22. package/dist/cjs/sdk/analytics/AnalyticsNamespace.js +11 -0
  23. package/dist/cjs/sdk/analytics/index.js +4 -0
  24. package/dist/cjs/sdk/index.js +3 -0
  25. package/dist/esm/dev/mode-parity/compareOpportunities.js +4 -5
  26. package/dist/esm/dev/mode-parity/comparePositions.js +6 -7
  27. package/dist/esm/dev/mode-parity/fieldDiff.js +4 -6
  28. package/dist/esm/dev/mode-parity/scriptUtils.js +142 -6
  29. package/dist/esm/model/analytics.schema.js +108 -0
  30. package/dist/esm/model/charts.schema.js +1 -1
  31. package/dist/esm/model/index.js +10 -8
  32. package/dist/esm/model/liquidations.schema.js +2 -2
  33. package/dist/esm/model/opportunities.schema.js +3 -3
  34. package/dist/esm/model/positions.schema.js +2 -2
  35. package/dist/esm/offchain/GearboxAPI.js +5 -0
  36. package/dist/esm/offchain/analytics/OffchainAnalytics.js +11 -0
  37. package/dist/esm/offchain/analytics/OffchainAnalyticsPositions.js +23 -0
  38. package/dist/esm/offchain/analytics/index.js +4 -0
  39. package/dist/esm/offchain/index.js +4 -1
  40. package/dist/esm/rewards/errors.js +26 -0
  41. package/dist/esm/rewards/index.js +4 -5
  42. package/dist/esm/rewards/merkl-api.js +42 -0
  43. package/dist/esm/rewards/multichain.js +39 -0
  44. package/dist/esm/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
  45. package/dist/esm/sdk/GearboxSDK.js +5 -0
  46. package/dist/esm/sdk/analytics/AnalyticsNamespace.js +10 -0
  47. package/dist/esm/sdk/analytics/index.js +3 -0
  48. package/dist/esm/sdk/index.js +3 -1
  49. package/dist/types/dev/mode-parity/compareOpportunities.d.ts +3 -7
  50. package/dist/types/dev/mode-parity/comparePositions.d.ts +4 -8
  51. package/dist/types/dev/mode-parity/fieldDiff.d.ts +9 -8
  52. package/dist/types/dev/mode-parity/scriptUtils.d.ts +26 -1
  53. package/dist/types/model/analytics.d.ts +62 -0
  54. package/dist/types/model/analytics.schema.d.ts +149 -0
  55. package/dist/types/model/index.d.ts +10 -8
  56. package/dist/types/model/opportunities.d.ts +1 -1
  57. package/dist/types/model/previews.d.ts +2 -2
  58. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
  59. package/dist/types/offchain/GearboxAPI.d.ts +4 -0
  60. package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +11 -0
  61. package/dist/types/offchain/analytics/OffchainAnalyticsPositions.d.ts +14 -0
  62. package/dist/types/offchain/analytics/index.d.ts +4 -0
  63. package/dist/types/offchain/analytics/types.d.ts +17 -0
  64. package/dist/types/offchain/index.d.ts +5 -1
  65. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -1
  66. package/dist/types/offchain/opportunities/types.d.ts +1 -1
  67. package/dist/types/offchain/positions/OffchainPositions.d.ts +1 -1
  68. package/dist/types/offchain/positions/types.d.ts +1 -1
  69. package/dist/types/rewards/errors.d.ts +18 -0
  70. package/dist/types/rewards/index.d.ts +4 -7
  71. package/dist/types/rewards/merkl-api.d.ts +64 -0
  72. package/dist/types/rewards/multichain.d.ts +33 -0
  73. package/dist/types/rewards/toMerklRewards.d.ts +42 -0
  74. package/dist/types/sdk/GearboxSDK.d.ts +4 -0
  75. package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +11 -0
  76. package/dist/types/sdk/analytics/index.d.ts +3 -0
  77. package/dist/types/sdk/analytics/types.d.ts +15 -0
  78. package/dist/types/sdk/index.d.ts +4 -1
  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/dist/types/sdk/types.d.ts +3 -0
  84. package/package.json +1 -3
  85. package/dist/cjs/_virtual/_rolldown/runtime.js +0 -23
  86. package/dist/cjs/rewards/apy/index.js +0 -3
  87. package/dist/cjs/rewards/rewards/extra-apy.js +0 -71
  88. package/dist/cjs/rewards/rewards/index.js +0 -6
  89. package/dist/cjs/rewards/rewards/merkl-api.js +0 -22
  90. package/dist/esm/rewards/apy/index.js +0 -3
  91. package/dist/esm/rewards/rewards/extra-apy.js +0 -67
  92. package/dist/esm/rewards/rewards/index.js +0 -3
  93. package/dist/esm/rewards/rewards/merkl-api.js +0 -19
  94. package/dist/types/rewards/apy/index.d.ts +0 -3
  95. package/dist/types/rewards/apy/output-details.d.ts +0 -99
  96. package/dist/types/rewards/apy/output.d.ts +0 -25
  97. package/dist/types/rewards/rewards/api.d.ts +0 -60
  98. package/dist/types/rewards/rewards/common.d.ts +0 -9
  99. package/dist/types/rewards/rewards/extra-apy.d.ts +0 -37
  100. package/dist/types/rewards/rewards/index.d.ts +0 -3
  101. package/dist/types/rewards/rewards/merkl-api.d.ts +0 -54
  102. /package/dist/cjs/{rewards/apy/output-details.js → model/analytics.js} +0 -0
  103. /package/dist/cjs/{rewards/apy/output.js → offchain/analytics/types.js} +0 -0
  104. /package/dist/cjs/{rewards/rewards/common.js → sdk/analytics/types.js} +0 -0
  105. /package/dist/esm/{rewards/apy/output-details.js → model/analytics.js} +0 -0
  106. /package/dist/esm/{rewards/apy/output.js → offchain/analytics/types.js} +0 -0
  107. /package/dist/esm/{rewards/rewards/common.js → sdk/analytics/types.js} +0 -0
@@ -1,21 +1,23 @@
1
- import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS } from "./charts.js";
1
+ import "./analytics.js";
2
+ import { FILTER_ALL, isFilterSet } from "./filters.js";
3
+ import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
2
4
  import { backendPreferred, compareTagOf, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
5
+ import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
3
6
  import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
7
+ import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
8
+ import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
9
+ import { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
10
+ import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema } from "./analytics.schema.js";
11
+ import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS } from "./charts.js";
4
12
  import { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema } from "./charts.schema.js";
5
13
  import "./curators.js";
6
- import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
7
14
  import "./delayed-intents.js";
8
15
  import "./errors.js";
9
- import { FILTER_ALL, isFilterSet } from "./filters.js";
10
- import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
11
16
  import { matchesLiquidatableAccountFilter } from "./liquidations.js";
12
- import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
13
17
  import "./notices.js";
14
18
  import { noticeKindSchema, noticeSchema } from "./notices.schema.js";
15
19
  import { matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
16
- import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
17
20
  import { STRATEGY_POSITION_COLLATERAL_ERROR, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
18
- import { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
19
21
  import { asEstimated } from "./previews.js";
20
22
  import "./primitives.js";
21
23
  import "./response.js";
@@ -23,4 +25,4 @@ import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourc
23
25
  import { isSDKError, safeValue, sdkErr, sdkOk } from "./result.js";
24
26
  import "./withdrawals.js";
25
27
  import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
26
- export { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, amountSchema, 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, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, 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 };
@@ -1,7 +1,7 @@
1
1
  import { ZodAddress } from "../onchain/utils/zod.js";
2
- import { assetTypeSchema, bpsSchema, chainIdSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
3
- import { curatorSchema } from "./curators.schema.js";
4
2
  import { filterable } from "./filters.schema.js";
3
+ import { curatorSchema } from "./curators.schema.js";
4
+ import { assetTypeSchema, bpsSchema, chainIdSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
5
5
  import { z } from "zod/v4";
6
6
  //#region src/model/liquidations.schema.ts
7
7
  /**
@@ -1,9 +1,9 @@
1
1
  import { ZodAddress } from "../onchain/utils/zod.js";
2
- import { offchainOnly, tolerance } from "./compare.schema.js";
3
- import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
4
- import { curatorSchema } from "./curators.schema.js";
5
2
  import { isFilterSet } from "./filters.js";
6
3
  import { booleanParamSchema, encodeFlag, filterable } from "./filters.schema.js";
4
+ import { offchainOnly, tolerance } from "./compare.schema.js";
5
+ import { curatorSchema } from "./curators.schema.js";
6
+ import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
7
7
  import { z } from "zod/v4";
8
8
  //#region src/model/opportunities.schema.ts
9
9
  /**
@@ -1,8 +1,8 @@
1
1
  import { ZodAddress, ZodBigInt, ZodHex } from "../onchain/utils/zod.js";
2
- import { backendPreferred, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
3
- import { assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
4
2
  import { isFilterSet } from "./filters.js";
5
3
  import { booleanParamSchema, encodeFlag, filterable } from "./filters.schema.js";
4
+ import { backendPreferred, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
5
+ import { assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
6
6
  import { delayedReceivedAssetSchema, liquidationPositionSchema } from "./liquidations.schema.js";
7
7
  import { apyBreakdownSchema, pointsProgramSchema } from "./opportunities.schema.js";
8
8
  import { z } from "zod/v4";
@@ -1,3 +1,5 @@
1
+ import { OffchainAnalytics } from "./analytics/OffchainAnalytics.js";
2
+ import "./analytics/index.js";
1
3
  import { OffchainNotices } from "./notices/OffchainNotices.js";
2
4
  import "./notices/index.js";
3
5
  import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
@@ -27,6 +29,8 @@ var GearboxAPI = class {
27
29
  * Chains every read of this client is scoped to.
28
30
  **/
29
31
  chainIds;
32
+ /** Protocol-wide, backend-only analytics. */
33
+ analytics;
30
34
  /**
31
35
  * Namespace for pool and strategy opportunities.
32
36
  **/
@@ -41,6 +45,7 @@ var GearboxAPI = class {
41
45
  notices;
42
46
  constructor(options) {
43
47
  this.chainIds = [...options.chainIds];
48
+ this.analytics = new OffchainAnalytics(options);
44
49
  this.opportunities = new OffchainOpportunities(options);
45
50
  this.positions = new OffchainPositions(options);
46
51
  this.notices = new OffchainNotices(options);
@@ -0,0 +1,11 @@
1
+ import { OffchainAnalyticsPositions } from "./OffchainAnalyticsPositions.js";
2
+ //#region src/offchain/analytics/OffchainAnalytics.ts
3
+ /** Backend-only protocol analytics, grouped by subject. */
4
+ var OffchainAnalytics = class {
5
+ positions;
6
+ constructor(options) {
7
+ this.positions = new OffchainAnalyticsPositions(options);
8
+ }
9
+ };
10
+ //#endregion
11
+ export { OffchainAnalytics };
@@ -0,0 +1,23 @@
1
+ import { analyticsPositionListQuerySchema, analyticsPositionPageSchema } from "../../model/analytics.schema.js";
2
+ import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
3
+ import { z } from "zod/v4";
4
+ //#region src/offchain/analytics/OffchainAnalyticsPositions.ts
5
+ /** Backend client for protocol-wide position analytics. */
6
+ var OffchainAnalyticsPositions = class extends AbstractOffchainNamespace {
7
+ constructor(options) {
8
+ super("OffchainAnalyticsPositions", options);
9
+ }
10
+ /** {@inheritDoc IOffchainAnalyticsPositions.list} */
11
+ async list(options) {
12
+ return this.get({
13
+ path: "/v2/analytics/positions",
14
+ query: z.encode(analyticsPositionListQuerySchema, {
15
+ ...options,
16
+ chainIds: this.scopedChainIds(options)
17
+ }),
18
+ schema: analyticsPositionPageSchema
19
+ });
20
+ }
21
+ };
22
+ //#endregion
23
+ export { OffchainAnalyticsPositions };
@@ -0,0 +1,4 @@
1
+ import { OffchainAnalyticsPositions } from "./OffchainAnalyticsPositions.js";
2
+ import { OffchainAnalytics } from "./OffchainAnalytics.js";
3
+ import "./types.js";
4
+ export { OffchainAnalytics, OffchainAnalyticsPositions };
@@ -10,6 +10,9 @@ import { OffchainValidationError } from "./errors/OffchainValidationError.js";
10
10
  import { readResponseBody } from "./errors/readResponseBody.js";
11
11
  import "./errors/index.js";
12
12
  import { AbstractOffchainNamespace } from "./AbstractOffchainNamespace.js";
13
+ import { OffchainAnalyticsPositions } from "./analytics/OffchainAnalyticsPositions.js";
14
+ import { OffchainAnalytics } from "./analytics/OffchainAnalytics.js";
15
+ import "./analytics/index.js";
13
16
  import { OffchainNotices } from "./notices/OffchainNotices.js";
14
17
  import "./notices/index.js";
15
18
  import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
@@ -18,4 +21,4 @@ import { OffchainPositions } from "./positions/OffchainPositions.js";
18
21
  import "./positions/index.js";
19
22
  import { GearboxAPI } from "./GearboxAPI.js";
20
23
  import "./types.js";
21
- export { AbstractOffchainNamespace, GearboxAPI, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainValidationError, backendMessage, errorCause, readResponseBody };
24
+ export { AbstractOffchainNamespace, GearboxAPI, OffchainAnalytics, OffchainAnalyticsPositions, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainValidationError, backendMessage, errorCause, readResponseBody };
@@ -0,0 +1,26 @@
1
+ import { BaseError } from "viem";
2
+ //#region src/rewards/errors.ts
3
+ /**
4
+ * Thrown when none of Merkl's domains answered for a chain.
5
+ *
6
+ * Everything a reader needs is in the message: this error travels to consumers
7
+ * inside a chain's {@link ChainFailed} metadata, where it is typed `unknown`
8
+ * and may be serialised by something that turns an arbitrary object into `{}`.
9
+ */
10
+ var MerklRequestFailedError = class extends BaseError {
11
+ name = "MerklRequestFailedError";
12
+ chainId;
13
+ constructor(chainId, path, attempts) {
14
+ super(`Merkl could not be reached for chain ${chainId}.`, {
15
+ cause: attempts.find(([, c]) => c instanceof Error)?.[1],
16
+ metaMessages: attempts.map(([domain, cause]) => `${domain}${path} — ${describe(cause)}`)
17
+ });
18
+ this.chainId = chainId;
19
+ }
20
+ };
21
+ function describe(cause) {
22
+ if (cause instanceof Error) return cause.name === "TimeoutError" ? "timed out" : cause.message;
23
+ return String(cause);
24
+ }
25
+ //#endregion
26
+ export { MerklRequestFailedError };
@@ -1,5 +1,4 @@
1
- import "./apy/index.js";
2
- import { getMerklRewards } from "./rewards/api.js";
3
- import { PoolPointsAPI, getKeyForPoolPointsInfo } from "./rewards/extra-apy.js";
4
- import "./rewards/index.js";
5
- export { PoolPointsAPI, getKeyForPoolPointsInfo, getMerklRewards };
1
+ import { MerklRequestFailedError } from "./errors.js";
2
+ import { toMerklRewards } from "./toMerklRewards.js";
3
+ import { getMerklRewardsMultichain } from "./multichain.js";
4
+ export { MerklRequestFailedError, getMerklRewardsMultichain, toMerklRewards };
@@ -0,0 +1,42 @@
1
+ import { MerklRequestFailedError } from "./errors.js";
2
+ //#region src/rewards/merkl-api.ts
3
+ /**
4
+ * Merkl's own host and the Angle mirror, tried in this order.
5
+ */
6
+ const MERKL_DOMAINS = ["https://api.merkl.xyz", "https://api-merkl.angle.money"];
7
+ const MERKL_API_KEY_HEADER = "X-API-Key";
8
+ /**
9
+ * Per-attempt budget. Merkl has no timeout of its own, and a hung connection
10
+ * would otherwise stall its leg of a fan-out for as long as the socket lives.
11
+ */
12
+ const ATTEMPT_TIMEOUT = 1e4;
13
+ /**
14
+ * The wallet's raw Merkl rewards on one chain.
15
+ *
16
+ * Rejects with {@link MerklRequestFailedError} when neither domain answers, so
17
+ * a caller can tell an unreachable Merkl from a wallet with nothing to claim.
18
+ * A non-2xx counts as no answer and moves to the next domain: it carries no
19
+ * rewards either way, and treating it as success would report emptiness that
20
+ * was never established.
21
+ */
22
+ async function fetchMerklUserRewards({ chainId, user, apiKey }) {
23
+ const path = `/v4/users/${user}/rewards?chainId=${chainId}`;
24
+ const headers = apiKey ? { [MERKL_API_KEY_HEADER]: apiKey } : void 0;
25
+ const attempts = [];
26
+ for (const domain of MERKL_DOMAINS) try {
27
+ const response = await fetch(`${domain}${path}`, {
28
+ headers,
29
+ signal: AbortSignal.timeout(ATTEMPT_TIMEOUT)
30
+ });
31
+ if (!response.ok) {
32
+ attempts.push([domain, /* @__PURE__ */ new Error(`answered ${response.status}`)]);
33
+ continue;
34
+ }
35
+ return await response.json();
36
+ } catch (error) {
37
+ attempts.push([domain, error]);
38
+ }
39
+ throw new MerklRequestFailedError(chainId, path, attempts);
40
+ }
41
+ //#endregion
42
+ export { MERKL_API_KEY_HEADER, MERKL_DOMAINS, fetchMerklUserRewards };
@@ -0,0 +1,39 @@
1
+ import { MultichainConstruct } from "../onchain/base/MultichainConstruct.js";
2
+ import "../onchain/index.js";
3
+ import { fetchMerklUserRewards } from "./merkl-api.js";
4
+ import { toMerklRewards } from "./toMerklRewards.js";
5
+ import { getAddress } from "viem";
6
+ //#region src/rewards/multichain.ts
7
+ /**
8
+ * The fan-out itself. Private because rewards are not an SDK namespace yet:
9
+ * the read is a free function, and this is only how it reaches `queryChains`.
10
+ **/
11
+ var MerklRewardsFanOut = class extends MultichainConstruct {
12
+ async list(wallet, chainIds, apiKey) {
13
+ const user = getAddress(wallet);
14
+ return this.queryChains({
15
+ chainIds,
16
+ label: "list rewards",
17
+ block: "state",
18
+ run: async (sdk) => toMerklRewards(sdk, await fetchMerklUserRewards({
19
+ chainId: sdk.chainId,
20
+ user,
21
+ apiKey
22
+ }))
23
+ });
24
+ }
25
+ };
26
+ /**
27
+ * Every claimable Merkl reward a wallet holds, across the chains the handle
28
+ * carries.
29
+ *
30
+ * Answers the read model's own envelope, so a chain that could not be reached
31
+ * is `status: "error"` in `meta.chains` while a chain with nothing to claim is
32
+ * a `"success"` that contributed no rows. That distinction is the point: the
33
+ * single-chain read this replaces resolved empty either way.
34
+ **/
35
+ async function getMerklRewardsMultichain({ sdk, wallet, chainIds, apiKey }) {
36
+ return new MerklRewardsFanOut(sdk).list(wallet, chainIds, apiKey);
37
+ }
38
+ //#endregion
39
+ export { getMerklRewardsMultichain };
@@ -1,27 +1,16 @@
1
- import { AddressMap } from "../../onchain/utils/AddressMap.js";
2
- import { BigIntMath } from "../../onchain/utils/bigint-math.js";
3
- import { toBigInt } from "../../onchain/utils/formatter.js";
4
- import "../../onchain/index.js";
5
- import { MerkleXYZApi } from "./merkl-api.js";
1
+ import { AddressMap } from "../onchain/utils/AddressMap.js";
2
+ import { BigIntMath } from "../onchain/utils/bigint-math.js";
3
+ import { toBigInt } from "../onchain/utils/formatter.js";
4
+ import "../onchain/index.js";
6
5
  import { formatUnits, getAddress, isAddress } from "viem";
7
- //#region src/rewards/rewards/api.ts
6
+ //#region src/rewards/toMerklRewards.ts
8
7
  /**
9
- * The wallet's claimable Merkl rewards on one chain.
10
- *
11
- * Never rejects on a transport failure: the fetch is settled rather than
12
- * awaited, and a failure goes to `reportError` and yields an empty list. A
13
- * caller that must tell "this chain is down" from "this chain has no rewards"
14
- * has to watch that callback.
8
+ * Merkl's answer for one chain, turned into rows of the read model.
15
9
  */
16
- async function getMerklRewards({ sdk, account, reportError, apiKey }) {
17
- const [merkleXYZLMResponse] = await Promise.allSettled([MerkleXYZApi.fetchWithFallback(MerkleXYZApi.getUserRewardsUrl({ params: {
18
- chainId: sdk.chainId,
19
- user: getAddress(account)
20
- } }), apiKey)]);
21
- const merkleXYZLm = extractFulfilled(merkleXYZLMResponse, reportError, "merkleXYZLm")?.data;
10
+ function toMerklRewards(sdk, response) {
22
11
  const poolByItsToken = AddressMap.fromMappedArray(sdk.marketRegister.pools.map(({ pool }) => pool.address), (address) => address);
23
12
  const claimable = /* @__PURE__ */ new Map();
24
- for (const chainRewards of merkleXYZLm || []) for (const reward of chainRewards.rewards) {
13
+ for (const chainRewards of response) for (const reward of chainRewards.rewards) {
25
14
  if (!isAddress(reward.token.address, { strict: false })) continue;
26
15
  const rewardTokenAddress = getAddress(reward.token.address);
27
16
  for (const reason of reward.breakdowns) {
@@ -29,9 +18,9 @@ async function getMerklRewards({ sdk, account, reportError, apiKey }) {
29
18
  if (!isAddress(poolTokenAddress, { strict: false })) continue;
30
19
  const pool = poolByItsToken.get(poolTokenAddress);
31
20
  if (!pool) continue;
32
- const total = toBigInt(reason.amount || 0);
33
- const claimed = toBigInt(reason.claimed || 0);
34
- const amount = BigIntMath.max(total - claimed, 0n);
21
+ const amounts = toAmounts(reason);
22
+ if (!amounts) continue;
23
+ const amount = BigIntMath.max(amounts.total - amounts.claimed, 0n);
35
24
  if (amount === 0n) continue;
36
25
  const key = `${pool}_${rewardTokenAddress}`;
37
26
  const seen = claimable.get(key);
@@ -53,6 +42,20 @@ async function getMerklRewards({ sdk, account, reportError, apiKey }) {
53
42
  }
54
43
  return [...claimable.values()].map(toReward);
55
44
  }
45
+ /**
46
+ * `toBigInt` throws on anything `BigInt()` cannot parse, and Merkl's amounts
47
+ * are free-form strings.
48
+ */
49
+ function toAmounts(reason) {
50
+ try {
51
+ return {
52
+ total: toBigInt(reason.amount || 0),
53
+ claimed: toBigInt(reason.claimed || 0)
54
+ };
55
+ } catch {
56
+ return;
57
+ }
58
+ }
56
59
  function toReward({ price, token, value, ...rest }) {
57
60
  return {
58
61
  ...rest,
@@ -77,10 +80,5 @@ function toRewardToken(sdk, address, merkl) {
77
80
  decimals: merkl.decimals || 18
78
81
  };
79
82
  }
80
- function extractFulfilled(r, reportError, description) {
81
- if (r.status === "fulfilled") return r.value;
82
- if (reportError) reportError(r.reason, description);
83
- else console.error(r.reason);
84
- }
85
83
  //#endregion
86
- export { getMerklRewards };
84
+ export { toMerklRewards };
@@ -6,6 +6,8 @@ import "../offchain/index.js";
6
6
  import { assertSameChains } from "./errors/assertSameChains.js";
7
7
  import { MissingSourceError } from "./errors/MissingSourceError.js";
8
8
  import "./errors/index.js";
9
+ import { AnalyticsNamespace } from "./analytics/AnalyticsNamespace.js";
10
+ import "./analytics/index.js";
9
11
  import { LiquidationsNamespace } from "./liquidations/LiquidationsNamespace.js";
10
12
  import "./liquidations/index.js";
11
13
  import "./utils/mergeChains.js";
@@ -50,6 +52,8 @@ var GearboxSDK = class {
50
52
  * Chains this instance covers, which every read is scoped to.
51
53
  **/
52
54
  networks;
55
+ /** Protocol-wide analytics. Undefined in `onchain` mode. */
56
+ analytics;
53
57
  /**
54
58
  * Namespace for pool and strategy opportunities.
55
59
  **/
@@ -130,6 +134,7 @@ var GearboxSDK = class {
130
134
  ensureFresh: this.#onchain ? (chainIds) => this.#ensureFresh(chainIds) : void 0,
131
135
  logger
132
136
  };
137
+ this.analytics = this.#offchain ? new AnalyticsNamespace(this.#offchain) : void 0;
133
138
  this.opportunities = new OpportunitiesNamespace(this.#onchain, this.#offchain, namespaceOptions);
134
139
  this.positions = new PositionsNamespace(this.#onchain, this.#offchain, namespaceOptions);
135
140
  this.liquidations = this.#onchain ? new LiquidationsNamespace(this.#onchain, namespaceOptions) : void 0;
@@ -0,0 +1,10 @@
1
+ //#region src/sdk/analytics/AnalyticsNamespace.ts
2
+ /** Backend-only protocol analytics exposed by {@link GearboxSDK}. */
3
+ var AnalyticsNamespace = class {
4
+ positions;
5
+ constructor(backend) {
6
+ this.positions = backend.analytics.positions;
7
+ }
8
+ };
9
+ //#endregion
10
+ export { AnalyticsNamespace };
@@ -0,0 +1,3 @@
1
+ import { AnalyticsNamespace } from "./AnalyticsNamespace.js";
2
+ import "./types.js";
3
+ export { AnalyticsNamespace };
@@ -8,6 +8,8 @@ import { NoSourceServedError } from "./errors/NoSourceServedError.js";
8
8
  import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
9
9
  import "./errors/index.js";
10
10
  import { AbstractNamespace } from "./AbstractNamespace.js";
11
+ import { AnalyticsNamespace } from "./analytics/AnalyticsNamespace.js";
12
+ import "./analytics/index.js";
11
13
  import { LiquidationsNamespace } from "./liquidations/LiquidationsNamespace.js";
12
14
  import "./liquidations/index.js";
13
15
  import { ExecuteApi } from "./execute/ExecuteApi.js";
@@ -26,4 +28,4 @@ import { PreviewNamespace } from "./preview/PreviewNamespace.js";
26
28
  import "./preview/index.js";
27
29
  import { DEFAULT_MAX_STATE_AGE, GearboxSDK } from "./GearboxSDK.js";
28
30
  import "./types.js";
29
- export { AbstractNamespace, AllSourcesFailedError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, IntentPreviewError, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, raise, refuse, toRefusalError, unexpectedFailure };
31
+ export { AbstractNamespace, AllSourcesFailedError, AnalyticsNamespace, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, IntentPreviewError, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, raise, refuse, toRefusalError, unexpectedFailure };
@@ -36,14 +36,10 @@ interface OpportunityMatch {
36
36
  **/
37
37
  onchainName: string;
38
38
  offchainName: string;
39
- /**
40
- * No diffs at all, including the documented offchain-only ones.
41
- **/
42
- identical: boolean;
43
39
  /**
44
40
  * No unexpected diffs: every disagreement is mode-scoped or within tolerance.
45
41
  **/
46
- clean: boolean;
42
+ similar: boolean;
47
43
  diffs: FieldDiff[];
48
44
  }
49
45
  /**
@@ -93,8 +89,8 @@ interface CompareOpportunitiesInput {
93
89
  *
94
90
  * Nothing is filtered out. A field only the backend can fill, or a USD value
95
91
  * that drifted within snapshot-lag noise, is still reported — tagged
96
- * {@link FieldDiff.expected} so that {@link CompareCounts.clean} can ignore it
97
- * while {@link CompareCounts.identical} stays strict.
92
+ * {@link FieldDiff.expected} so that {@link CompareCounts.similar} can ignore
93
+ * it.
98
94
  **/
99
95
  declare function compareOpportunities(input: CompareOpportunitiesInput): OpportunityCompareReport;
100
96
  /**
@@ -34,15 +34,11 @@ interface PositionMatch {
34
34
  chainId: ChainId;
35
35
  onchainName: string;
36
36
  offchainName: string;
37
- /**
38
- * No diffs at all, including the documented mode-scoped ones.
39
- **/
40
- identical: boolean;
41
37
  /**
42
38
  * No unexpected diffs: every disagreement is mode-scoped, backend-preferred,
43
39
  * or within tolerance.
44
40
  **/
45
- clean: boolean;
41
+ similar: boolean;
46
42
  diffs: FieldDiff[];
47
43
  }
48
44
  /**
@@ -78,7 +74,7 @@ interface PositionsCompareSummary extends CompareCounts {
78
74
  * Wallets whose listings were read and that have no membership gaps and no
79
75
  * unexpected field diffs.
80
76
  **/
81
- walletsClean: number;
77
+ walletsSimilar: number;
82
78
  walletsFailed: number;
83
79
  byChain: ChainCompareCounts[];
84
80
  byWallet: WalletCompareCounts[];
@@ -139,8 +135,8 @@ interface ComparePositionsInput {
139
135
  * Nothing is filtered out. A field only one mode can fill, a strategy field
140
136
  * both-mode merge overlays from the backend, or a USD value that drifted
141
137
  * within snapshot-lag noise, is still reported — tagged
142
- * {@link FieldDiff.expected} so that {@link CompareCounts.clean} can ignore it
143
- * while {@link CompareCounts.identical} stays strict.
138
+ * {@link FieldDiff.expected} so that {@link CompareCounts.similar} can ignore
139
+ * it.
144
140
  **/
145
141
  declare function comparePositions(input: ComparePositionsInput): PositionsCompareReport;
146
142
  /**
@@ -42,7 +42,7 @@ interface FieldDiff {
42
42
  kind: DiffKind;
43
43
  /**
44
44
  * Present when this disagreement is documented or within snapshot-lag noise,
45
- * so it does not keep the row from being counted as clean.
45
+ * so it does not keep the row from being counted as similar.
46
46
  **/
47
47
  expected?: true;
48
48
  reason?: ExpectedDiffReason;
@@ -102,12 +102,14 @@ interface CompareCounts {
102
102
  onchainRows: number;
103
103
  offchainRows: number;
104
104
  matched: number;
105
- identical: number;
106
105
  /**
107
- * Matched rows with no unexpected diffs, including the identical ones.
106
+ * Matched rows with no unexpected diffs.
108
107
  **/
109
- clean: number;
110
- differing: number;
108
+ similar: number;
109
+ /**
110
+ * Matched rows with at least one unexpected diff.
111
+ **/
112
+ different: number;
111
113
  onlyOnchain: number;
112
114
  onlyOffchain: number;
113
115
  }
@@ -157,7 +159,7 @@ declare function diffValue(path: string, onchain: unknown, offchain: unknown, ou
157
159
  **/
158
160
  declare function diffObjects(onchain: unknown, offchain: unknown, options?: DiffOptions): FieldDiff[];
159
161
  /**
160
- * Mark a diff expected, so a later `clean` count can ignore it.
162
+ * Mark a diff expected, so a later `similar` count can ignore it.
161
163
  **/
162
164
  declare function withExpected(diff: FieldDiff, reason: ExpectedDiffReason): FieldDiff;
163
165
  /**
@@ -174,8 +176,7 @@ declare function collapseArrayKeys(path: string): string;
174
176
  * Membership and match totals of one comparison, from already-built lists.
175
177
  **/
176
178
  declare function toCompareCounts(onchainRows: number, offchainRows: number, onlyOnchain: number, onlyOffchain: number, matched: ReadonlyArray<{
177
- identical: boolean;
178
- clean: boolean;
179
+ similar: boolean;
179
180
  }>): CompareCounts;
180
181
  /**
181
182
  * USD floats within {@link USD_RELATIVE_EPSILON}.
@@ -16,6 +16,10 @@ declare const TIMEOUT = 480000;
16
16
  interface PrintableCompareSummary extends CompareCounts {
17
17
  byChain: ChainCompareCounts[];
18
18
  diffsByPath: DiffPathCount[];
19
+ /**
20
+ * Present on position reports: wallets whose listings could not be read.
21
+ **/
22
+ walletsFailed?: number;
19
23
  }
20
24
  /**
21
25
  * Per-source chain metadata both compare reports carry.
@@ -38,10 +42,31 @@ declare function mapPool<T>(items: readonly T[], concurrency: number, fn: (item:
38
42
  * Formats a relative difference in bps as a percent, e.g. 12.5 → `"0.125%"`.
39
43
  **/
40
44
  declare function formatBpsAsPercent(bps: number): string;
45
+ /**
46
+ * Reasons a compare run should fail CI: unexpected membership or field diffs,
47
+ * both sources empty, a chain that could not be read, or wallets that failed
48
+ * to list. Expected diffs (mode-scoped, backend-preferred, tolerance) do not
49
+ * fail the run.
50
+ **/
51
+ declare function evaluateCompareFailure(report: PrintableCompareReport): string[];
41
52
  /**
42
53
  * Prints the shared membership table, the fields that differed most often,
43
54
  * and any chain that failed to answer.
44
55
  **/
45
56
  declare function printCompareSummary(noun: string, report: PrintableCompareReport, extraLines?: string[]): void;
57
+ /**
58
+ * Markdown of the same summary printed to the console, for GitHub job summaries.
59
+ **/
60
+ declare function formatCompareMarkdown(noun: string, report: PrintableCompareReport, extraLines?: string[], reasons?: string[]): string;
61
+ /**
62
+ * Appends {@link formatCompareMarkdown} to `GITHUB_STEP_SUMMARY` when running
63
+ * in GitHub Actions. No-op locally.
64
+ **/
65
+ declare function writeGithubJobSummary(noun: string, report: PrintableCompareReport, extraLines?: string[], reasons?: string[]): void;
66
+ /**
67
+ * Console + job-summary output for a compare run. Returns the failure reasons
68
+ * so the caller can exit 1 when the report is not similar.
69
+ **/
70
+ declare function reportCompare(noun: string, report: PrintableCompareReport, extraLines?: string[]): string[];
46
71
  //#endregion
47
- export { BACKEND_URL, ComparedNetwork, NETWORKS, PrintableCompareReport, PrintableCompareSummary, TIMEOUT, createLogger, errorMessage, formatBpsAsPercent, mapPool, printCompareSummary, requireEnv, rpcUrls };
72
+ export { BACKEND_URL, ComparedNetwork, NETWORKS, PrintableCompareReport, PrintableCompareSummary, TIMEOUT, createLogger, errorMessage, evaluateCompareFailure, formatBpsAsPercent, formatCompareMarkdown, mapPool, printCompareSummary, reportCompare, requireEnv, rpcUrls, writeGithubJobSummary };