@gearbox-protocol/sdk 16.0.0 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/analytics.schema.js +44 -1
- package/dist/cjs/model/charts.js +15 -1
- package/dist/cjs/model/charts.schema.js +9 -3
- package/dist/cjs/model/index.js +9 -4
- package/dist/cjs/model/liquidations.schema.js +1 -1
- package/dist/cjs/model/opportunities.schema.js +2 -2
- package/dist/cjs/model/positions.schema.js +2 -2
- package/dist/cjs/offchain/analytics/OffchainAnalytics.js +25 -2
- package/dist/cjs/sdk/analytics/AnalyticsNamespace.js +6 -0
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/analytics.schema.js +42 -2
- package/dist/esm/model/charts.js +15 -2
- package/dist/esm/model/charts.schema.js +9 -4
- package/dist/esm/model/index.js +6 -6
- package/dist/esm/model/liquidations.schema.js +1 -1
- package/dist/esm/model/opportunities.schema.js +2 -2
- package/dist/esm/model/positions.schema.js +2 -2
- package/dist/esm/offchain/analytics/OffchainAnalytics.js +25 -2
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/analytics/AnalyticsNamespace.js +6 -0
- package/dist/types/model/analytics.d.ts +22 -1
- package/dist/types/model/analytics.schema.d.ts +65 -1
- package/dist/types/model/charts.d.ts +20 -2
- package/dist/types/model/charts.schema.d.ts +14 -2
- package/dist/types/model/index.d.ts +5 -5
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
- package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +14 -2
- package/dist/types/offchain/analytics/types.d.ts +11 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -1
- package/dist/types/offchain/opportunities/types.d.ts +1 -1
- package/dist/types/offchain/positions/OffchainPositions.d.ts +1 -1
- package/dist/types/offchain/positions/types.d.ts +1 -1
- package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +6 -0
- package/dist/types/sdk/analytics/types.d.ts +16 -0
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
- package/dist/types/sdk/opportunities/types.d.ts +1 -1
- package/dist/types/sdk/positions/PositionsNamespace.d.ts +1 -1
- package/dist/types/sdk/positions/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_utils_zod = require("../onchain/utils/zod.js");
|
|
3
|
+
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
4
|
+
const require_model_charts_schema = require("./charts.schema.js");
|
|
3
5
|
const require_model_filters = require("./filters.js");
|
|
4
6
|
const require_model_filters_schema = require("./filters.schema.js");
|
|
5
|
-
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
6
7
|
const require_model_liquidations_schema = require("./liquidations.schema.js");
|
|
7
8
|
const require_model_positions_schema = require("./positions.schema.js");
|
|
8
9
|
let viem = require("viem");
|
|
@@ -105,9 +106,51 @@ const analyticsPositionPageSchema = zod_v4.z.object({
|
|
|
105
106
|
offset: zod_v4.z.number().int().nonnegative(),
|
|
106
107
|
limit: zod_v4.z.number().int().positive().max(100)
|
|
107
108
|
});
|
|
109
|
+
/**
|
|
110
|
+
* {@link AnalyticsChartQuery}
|
|
111
|
+
*
|
|
112
|
+
* The metric list is narrowed to {@link ProtocolChartMetric} here rather than
|
|
113
|
+
* on the route, so asking the protocol chart for an opportunity metric is
|
|
114
|
+
* rejected by the one codec both sides share instead of by a check only the
|
|
115
|
+
* backend runs.
|
|
116
|
+
**/
|
|
117
|
+
const analyticsChartQueryOptionsSchema = zod_v4.z.object({
|
|
118
|
+
metrics: zod_v4.z.array(require_model_charts_schema.protocolChartMetricSchema).readonly().refine((metrics) => metrics.length > 0, { error: "a chart read needs at least one metric" }).refine((metrics) => new Set(metrics).size === metrics.length, { error: "a chart read needs distinct metrics" }),
|
|
119
|
+
range: require_model_charts_schema.chartRangeSchema,
|
|
120
|
+
chainIds: zod_v4.z.array(require_model_primitives_schema.chainIdSchema).optional()
|
|
121
|
+
});
|
|
122
|
+
/**
|
|
123
|
+
* {@link AnalyticsChartQuery} as URL query parameters: the metrics comma-joined
|
|
124
|
+
* like every other chart read, and the chains comma-joined like every other
|
|
125
|
+
* analytics read.
|
|
126
|
+
**/
|
|
127
|
+
const analyticsChartQueryParamsSchema = zod_v4.z.object({
|
|
128
|
+
metrics: zod_v4.z.string().regex(/^\w+(,\w+)*$/),
|
|
129
|
+
range: require_model_charts_schema.chartRangeSchema,
|
|
130
|
+
chainIds: zod_v4.z.string().regex(/^$|^\d+(,\d+)*$/).optional()
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Codec for a protocol-wide chart query. It is shared by the SDK client and
|
|
134
|
+
* backend controller so both sides interpret every parameter identically.
|
|
135
|
+
**/
|
|
136
|
+
const analyticsChartQuerySchema = zod_v4.z.codec(analyticsChartQueryParamsSchema, analyticsChartQueryOptionsSchema, {
|
|
137
|
+
decode: (params) => ({
|
|
138
|
+
metrics: params.metrics.split(","),
|
|
139
|
+
range: params.range,
|
|
140
|
+
...params.chainIds === void 0 ? {} : { chainIds: params.chainIds === "" ? [] : params.chainIds.split(",").map(Number) }
|
|
141
|
+
}),
|
|
142
|
+
encode: (query) => ({
|
|
143
|
+
metrics: query.metrics.join(","),
|
|
144
|
+
range: query.range,
|
|
145
|
+
chainIds: query.chainIds?.join(",")
|
|
146
|
+
})
|
|
147
|
+
});
|
|
108
148
|
//#endregion
|
|
109
149
|
exports.ANALYTICS_POSITIONS_DEFAULT_LIMIT = ANALYTICS_POSITIONS_DEFAULT_LIMIT;
|
|
110
150
|
exports.ANALYTICS_POSITIONS_MAX_LIMIT = ANALYTICS_POSITIONS_MAX_LIMIT;
|
|
151
|
+
exports.analyticsChartQueryOptionsSchema = analyticsChartQueryOptionsSchema;
|
|
152
|
+
exports.analyticsChartQueryParamsSchema = analyticsChartQueryParamsSchema;
|
|
153
|
+
exports.analyticsChartQuerySchema = analyticsChartQuerySchema;
|
|
111
154
|
exports.analyticsPositionListOptionsSchema = analyticsPositionListOptionsSchema;
|
|
112
155
|
exports.analyticsPositionListQueryParamsSchema = analyticsPositionListQueryParamsSchema;
|
|
113
156
|
exports.analyticsPositionListQuerySchema = analyticsPositionListQuerySchema;
|
package/dist/cjs/model/charts.js
CHANGED
|
@@ -85,6 +85,18 @@ const STRATEGY_POSITION_CHART_METRICS = [
|
|
|
85
85
|
"netApy7d"
|
|
86
86
|
];
|
|
87
87
|
/**
|
|
88
|
+
* Every metric the protocol as a whole can chart.
|
|
89
|
+
*
|
|
90
|
+
* Protocol-wide rather than per subject: the series describes Gearbox itself
|
|
91
|
+
* over every chain the read covers, so it has no address to hang off and is
|
|
92
|
+
* read from the analytics namespace rather than from an opportunity.
|
|
93
|
+
*
|
|
94
|
+
* `tvlUsd` is deliberately not spelled `tvl`: that key is already the credit
|
|
95
|
+
* manager's TVL in whole underlying tokens, and one metric has exactly one
|
|
96
|
+
* unit in {@link CHART_METRIC_UNITS}.
|
|
97
|
+
**/
|
|
98
|
+
const PROTOCOL_CHART_METRICS = ["tvlUsd"];
|
|
99
|
+
/**
|
|
88
100
|
* Unit of every metric, the one place either side decides it.
|
|
89
101
|
*
|
|
90
102
|
* A metric added to a union above fails to compile here until its unit is
|
|
@@ -114,7 +126,8 @@ const CHART_METRIC_UNITS = {
|
|
|
114
126
|
totalValueUnderlying: "token",
|
|
115
127
|
debt: "token",
|
|
116
128
|
healthFactor: "bps",
|
|
117
|
-
netApy7d: "bps"
|
|
129
|
+
netApy7d: "bps",
|
|
130
|
+
tvlUsd: "usd"
|
|
118
131
|
};
|
|
119
132
|
/**
|
|
120
133
|
* Reason a series could not be produced at all, which is not the same as a
|
|
@@ -133,5 +146,6 @@ exports.CHART_RANGES = CHART_RANGES;
|
|
|
133
146
|
exports.CHART_UNAVAILABLE_CODES = CHART_UNAVAILABLE_CODES;
|
|
134
147
|
exports.POOL_OPPORTUNITY_CHART_METRICS = POOL_OPPORTUNITY_CHART_METRICS;
|
|
135
148
|
exports.POOL_POSITION_CHART_METRICS = POOL_POSITION_CHART_METRICS;
|
|
149
|
+
exports.PROTOCOL_CHART_METRICS = PROTOCOL_CHART_METRICS;
|
|
136
150
|
exports.STRATEGY_OPPORTUNITY_CHART_METRICS = STRATEGY_OPPORTUNITY_CHART_METRICS;
|
|
137
151
|
exports.STRATEGY_POSITION_CHART_METRICS = STRATEGY_POSITION_CHART_METRICS;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
3
2
|
const require_model_charts = require("./charts.js");
|
|
3
|
+
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
4
4
|
let zod_v4 = require("zod/v4");
|
|
5
5
|
//#region src/model/charts.schema.ts
|
|
6
6
|
/**
|
|
@@ -33,13 +33,18 @@ const poolPositionChartMetricSchema = zod_v4.z.enum(require_model_charts.POOL_PO
|
|
|
33
33
|
**/
|
|
34
34
|
const strategyPositionChartMetricSchema = zod_v4.z.enum(require_model_charts.STRATEGY_POSITION_CHART_METRICS);
|
|
35
35
|
/**
|
|
36
|
-
* {@link
|
|
36
|
+
* {@link ProtocolChartMetric}
|
|
37
|
+
**/
|
|
38
|
+
const protocolChartMetricSchema = zod_v4.z.enum(require_model_charts.PROTOCOL_CHART_METRICS);
|
|
39
|
+
/**
|
|
40
|
+
* {@link ChartMetric}, every metric any subject can chart.
|
|
37
41
|
**/
|
|
38
42
|
const chartMetricSchema = zod_v4.z.union([
|
|
39
43
|
poolOpportunityChartMetricSchema,
|
|
40
44
|
strategyOpportunityChartMetricSchema,
|
|
41
45
|
poolPositionChartMetricSchema,
|
|
42
|
-
strategyPositionChartMetricSchema
|
|
46
|
+
strategyPositionChartMetricSchema,
|
|
47
|
+
protocolChartMetricSchema
|
|
43
48
|
]);
|
|
44
49
|
/**
|
|
45
50
|
* {@link ChartQuery}
|
|
@@ -236,5 +241,6 @@ exports.chartValueSchema = chartValueSchema;
|
|
|
236
241
|
exports.chartWindowSchema = chartWindowSchema;
|
|
237
242
|
exports.poolOpportunityChartMetricSchema = poolOpportunityChartMetricSchema;
|
|
238
243
|
exports.poolPositionChartMetricSchema = poolPositionChartMetricSchema;
|
|
244
|
+
exports.protocolChartMetricSchema = protocolChartMetricSchema;
|
|
239
245
|
exports.strategyOpportunityChartMetricSchema = strategyOpportunityChartMetricSchema;
|
|
240
246
|
exports.strategyPositionChartMetricSchema = strategyPositionChartMetricSchema;
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./analytics.js");
|
|
3
|
+
const require_model_charts = require("./charts.js");
|
|
4
|
+
const require_model_compare_schema = require("./compare.schema.js");
|
|
5
|
+
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
6
|
+
const require_model_charts_schema = require("./charts.schema.js");
|
|
3
7
|
const require_model_filters = require("./filters.js");
|
|
4
8
|
const require_model_filters_schema = require("./filters.schema.js");
|
|
5
|
-
const require_model_compare_schema = require("./compare.schema.js");
|
|
6
9
|
const require_model_curators_schema = require("./curators.schema.js");
|
|
7
|
-
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
8
10
|
const require_model_liquidations_schema = require("./liquidations.schema.js");
|
|
9
11
|
const require_model_opportunities_schema = require("./opportunities.schema.js");
|
|
10
12
|
const require_model_positions_schema = require("./positions.schema.js");
|
|
11
13
|
const require_model_analytics_schema = require("./analytics.schema.js");
|
|
12
|
-
const require_model_charts = require("./charts.js");
|
|
13
|
-
const require_model_charts_schema = require("./charts.schema.js");
|
|
14
14
|
require("./curators.js");
|
|
15
15
|
require("./delayed-intents.js");
|
|
16
16
|
require("./errors.js");
|
|
@@ -34,10 +34,14 @@ exports.CHART_UNAVAILABLE_CODES = require_model_charts.CHART_UNAVAILABLE_CODES;
|
|
|
34
34
|
exports.FILTER_ALL = require_model_filters.FILTER_ALL;
|
|
35
35
|
exports.POOL_OPPORTUNITY_CHART_METRICS = require_model_charts.POOL_OPPORTUNITY_CHART_METRICS;
|
|
36
36
|
exports.POOL_POSITION_CHART_METRICS = require_model_charts.POOL_POSITION_CHART_METRICS;
|
|
37
|
+
exports.PROTOCOL_CHART_METRICS = require_model_charts.PROTOCOL_CHART_METRICS;
|
|
37
38
|
exports.STRATEGY_OPPORTUNITY_CHART_METRICS = require_model_charts.STRATEGY_OPPORTUNITY_CHART_METRICS;
|
|
38
39
|
exports.STRATEGY_POSITION_CHART_METRICS = require_model_charts.STRATEGY_POSITION_CHART_METRICS;
|
|
39
40
|
exports.STRATEGY_POSITION_COLLATERAL_ERROR = require_model_positions.STRATEGY_POSITION_COLLATERAL_ERROR;
|
|
40
41
|
exports.amountSchema = require_model_primitives_schema.amountSchema;
|
|
42
|
+
exports.analyticsChartQueryOptionsSchema = require_model_analytics_schema.analyticsChartQueryOptionsSchema;
|
|
43
|
+
exports.analyticsChartQueryParamsSchema = require_model_analytics_schema.analyticsChartQueryParamsSchema;
|
|
44
|
+
exports.analyticsChartQuerySchema = require_model_analytics_schema.analyticsChartQuerySchema;
|
|
41
45
|
exports.analyticsPositionListOptionsSchema = require_model_analytics_schema.analyticsPositionListOptionsSchema;
|
|
42
46
|
exports.analyticsPositionListQueryParamsSchema = require_model_analytics_schema.analyticsPositionListQueryParamsSchema;
|
|
43
47
|
exports.analyticsPositionListQuerySchema = require_model_analytics_schema.analyticsPositionListQuerySchema;
|
|
@@ -131,6 +135,7 @@ exports.positionWithdrawalsSchema = require_model_withdrawals_schema.positionWit
|
|
|
131
135
|
exports.positionsTotalsSchema = require_model_positions_schema.positionsTotalsSchema;
|
|
132
136
|
exports.priceFeedDataSchema = require_model_opportunities_schema.priceFeedDataSchema;
|
|
133
137
|
exports.priceFeedSummarySchema = require_model_opportunities_schema.priceFeedSummarySchema;
|
|
138
|
+
exports.protocolChartMetricSchema = require_model_charts_schema.protocolChartMetricSchema;
|
|
134
139
|
exports.quotaAssetSchema = require_model_opportunities_schema.quotaAssetSchema;
|
|
135
140
|
exports.rateCurvePointSchema = require_model_opportunities_schema.rateCurvePointSchema;
|
|
136
141
|
exports.rateCurveSchema = require_model_opportunities_schema.rateCurveSchema;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_utils_zod = require("../onchain/utils/zod.js");
|
|
3
|
+
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
3
4
|
const require_model_filters_schema = require("./filters.schema.js");
|
|
4
5
|
const require_model_curators_schema = require("./curators.schema.js");
|
|
5
|
-
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
6
6
|
let zod_v4 = require("zod/v4");
|
|
7
7
|
//#region src/model/liquidations.schema.ts
|
|
8
8
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_utils_zod = require("../onchain/utils/zod.js");
|
|
3
|
+
const require_model_compare_schema = require("./compare.schema.js");
|
|
4
|
+
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
3
5
|
const require_model_filters = require("./filters.js");
|
|
4
6
|
const require_model_filters_schema = require("./filters.schema.js");
|
|
5
|
-
const require_model_compare_schema = require("./compare.schema.js");
|
|
6
7
|
const require_model_curators_schema = require("./curators.schema.js");
|
|
7
|
-
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
8
8
|
let zod_v4 = require("zod/v4");
|
|
9
9
|
//#region src/model/opportunities.schema.ts
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_utils_zod = require("../onchain/utils/zod.js");
|
|
3
|
-
const require_model_filters = require("./filters.js");
|
|
4
|
-
const require_model_filters_schema = require("./filters.schema.js");
|
|
5
3
|
const require_model_compare_schema = require("./compare.schema.js");
|
|
6
4
|
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
5
|
+
const require_model_filters = require("./filters.js");
|
|
6
|
+
const require_model_filters_schema = require("./filters.schema.js");
|
|
7
7
|
const require_model_liquidations_schema = require("./liquidations.schema.js");
|
|
8
8
|
const require_model_opportunities_schema = require("./opportunities.schema.js");
|
|
9
9
|
let zod_v4 = require("zod/v4");
|
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_charts_schema = require("../../model/charts.schema.js");
|
|
3
|
+
const require_model_analytics_schema = require("../../model/analytics.schema.js");
|
|
4
|
+
const require_offchain_AbstractOffchainNamespace = require("../AbstractOffchainNamespace.js");
|
|
2
5
|
const require_offchain_analytics_OffchainAnalyticsPositions = require("./OffchainAnalyticsPositions.js");
|
|
6
|
+
let zod_v4 = require("zod/v4");
|
|
3
7
|
//#region src/offchain/analytics/OffchainAnalytics.ts
|
|
4
|
-
/**
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Backend-only protocol analytics, grouped by subject.
|
|
10
|
+
*
|
|
11
|
+
* It owns the protocol-wide charts itself rather than through a sub-namespace:
|
|
12
|
+
* their subject is Gearbox as a whole, so there is nothing narrower for them to
|
|
13
|
+
* hang off.
|
|
14
|
+
**/
|
|
15
|
+
var OffchainAnalytics = class extends require_offchain_AbstractOffchainNamespace.AbstractOffchainNamespace {
|
|
6
16
|
positions;
|
|
7
17
|
constructor(options) {
|
|
18
|
+
super("OffchainAnalytics", options);
|
|
8
19
|
this.positions = new require_offchain_analytics_OffchainAnalyticsPositions.OffchainAnalyticsPositions(options);
|
|
9
20
|
}
|
|
21
|
+
/** {@inheritDoc IOffchainAnalytics.getCharts} */
|
|
22
|
+
async getCharts(metrics, range, filter) {
|
|
23
|
+
return this.get({
|
|
24
|
+
path: "/v2/analytics/charts",
|
|
25
|
+
query: zod_v4.z.encode(require_model_analytics_schema.analyticsChartQuerySchema, {
|
|
26
|
+
metrics,
|
|
27
|
+
range,
|
|
28
|
+
chainIds: this.scopedChainIds(filter)
|
|
29
|
+
}),
|
|
30
|
+
schema: require_model_charts_schema.chartBundleSchemaFor(metrics, range)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
10
33
|
};
|
|
11
34
|
//#endregion
|
|
12
35
|
exports.OffchainAnalytics = OffchainAnalytics;
|
|
@@ -3,9 +3,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
/** Backend-only protocol analytics exposed by {@link GearboxSDK}. */
|
|
4
4
|
var AnalyticsNamespace = class {
|
|
5
5
|
positions;
|
|
6
|
+
#backend;
|
|
6
7
|
constructor(backend) {
|
|
8
|
+
this.#backend = backend;
|
|
7
9
|
this.positions = backend.analytics.positions;
|
|
8
10
|
}
|
|
11
|
+
/** {@inheritDoc IAnalytics.charts} */
|
|
12
|
+
async charts(metrics, range, filter) {
|
|
13
|
+
return this.#backend.analytics.getCharts(metrics, range, filter);
|
|
14
|
+
}
|
|
9
15
|
};
|
|
10
16
|
//#endregion
|
|
11
17
|
exports.AnalyticsNamespace = AnalyticsNamespace;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
2
1
|
import { ierc20Abi } from "../abi/iERC20.js";
|
|
2
|
+
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
3
3
|
import { AddressMap } from "../onchain/utils/AddressMap.js";
|
|
4
4
|
import { AddressSet } from "../onchain/utils/AddressSet.js";
|
|
5
5
|
import { AssetsMap } from "../onchain/utils/AssetsMap.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { getNetworkType } from "../onchain/chain/chains.js";
|
|
2
3
|
import { getWithdrawalCompressorAddress } from "../onchain/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../onchain/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ZodAddress } from "../onchain/utils/zod.js";
|
|
2
|
+
import { assetTypeSchema, chainIdSchema } from "./primitives.schema.js";
|
|
3
|
+
import { chartRangeSchema, protocolChartMetricSchema } from "./charts.schema.js";
|
|
2
4
|
import { isFilterSet } from "./filters.js";
|
|
3
5
|
import { encodeFlag, filterable } from "./filters.schema.js";
|
|
4
|
-
import { assetTypeSchema, chainIdSchema } from "./primitives.schema.js";
|
|
5
6
|
import { liquidationPositionSchema } from "./liquidations.schema.js";
|
|
6
7
|
import { poolPositionSchema, positionKindSchema, strategyPositionSchema } from "./positions.schema.js";
|
|
7
8
|
import { isAddress } from "viem";
|
|
@@ -104,5 +105,44 @@ const analyticsPositionPageSchema = z.object({
|
|
|
104
105
|
offset: z.number().int().nonnegative(),
|
|
105
106
|
limit: z.number().int().positive().max(100)
|
|
106
107
|
});
|
|
108
|
+
/**
|
|
109
|
+
* {@link AnalyticsChartQuery}
|
|
110
|
+
*
|
|
111
|
+
* The metric list is narrowed to {@link ProtocolChartMetric} here rather than
|
|
112
|
+
* on the route, so asking the protocol chart for an opportunity metric is
|
|
113
|
+
* rejected by the one codec both sides share instead of by a check only the
|
|
114
|
+
* backend runs.
|
|
115
|
+
**/
|
|
116
|
+
const analyticsChartQueryOptionsSchema = z.object({
|
|
117
|
+
metrics: z.array(protocolChartMetricSchema).readonly().refine((metrics) => metrics.length > 0, { error: "a chart read needs at least one metric" }).refine((metrics) => new Set(metrics).size === metrics.length, { error: "a chart read needs distinct metrics" }),
|
|
118
|
+
range: chartRangeSchema,
|
|
119
|
+
chainIds: z.array(chainIdSchema).optional()
|
|
120
|
+
});
|
|
121
|
+
/**
|
|
122
|
+
* {@link AnalyticsChartQuery} as URL query parameters: the metrics comma-joined
|
|
123
|
+
* like every other chart read, and the chains comma-joined like every other
|
|
124
|
+
* analytics read.
|
|
125
|
+
**/
|
|
126
|
+
const analyticsChartQueryParamsSchema = z.object({
|
|
127
|
+
metrics: z.string().regex(/^\w+(,\w+)*$/),
|
|
128
|
+
range: chartRangeSchema,
|
|
129
|
+
chainIds: z.string().regex(/^$|^\d+(,\d+)*$/).optional()
|
|
130
|
+
});
|
|
131
|
+
/**
|
|
132
|
+
* Codec for a protocol-wide chart query. It is shared by the SDK client and
|
|
133
|
+
* backend controller so both sides interpret every parameter identically.
|
|
134
|
+
**/
|
|
135
|
+
const analyticsChartQuerySchema = z.codec(analyticsChartQueryParamsSchema, analyticsChartQueryOptionsSchema, {
|
|
136
|
+
decode: (params) => ({
|
|
137
|
+
metrics: params.metrics.split(","),
|
|
138
|
+
range: params.range,
|
|
139
|
+
...params.chainIds === void 0 ? {} : { chainIds: params.chainIds === "" ? [] : params.chainIds.split(",").map(Number) }
|
|
140
|
+
}),
|
|
141
|
+
encode: (query) => ({
|
|
142
|
+
metrics: query.metrics.join(","),
|
|
143
|
+
range: query.range,
|
|
144
|
+
chainIds: query.chainIds?.join(",")
|
|
145
|
+
})
|
|
146
|
+
});
|
|
107
147
|
//#endregion
|
|
108
|
-
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema };
|
|
148
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema };
|
package/dist/esm/model/charts.js
CHANGED
|
@@ -84,6 +84,18 @@ const STRATEGY_POSITION_CHART_METRICS = [
|
|
|
84
84
|
"netApy7d"
|
|
85
85
|
];
|
|
86
86
|
/**
|
|
87
|
+
* Every metric the protocol as a whole can chart.
|
|
88
|
+
*
|
|
89
|
+
* Protocol-wide rather than per subject: the series describes Gearbox itself
|
|
90
|
+
* over every chain the read covers, so it has no address to hang off and is
|
|
91
|
+
* read from the analytics namespace rather than from an opportunity.
|
|
92
|
+
*
|
|
93
|
+
* `tvlUsd` is deliberately not spelled `tvl`: that key is already the credit
|
|
94
|
+
* manager's TVL in whole underlying tokens, and one metric has exactly one
|
|
95
|
+
* unit in {@link CHART_METRIC_UNITS}.
|
|
96
|
+
**/
|
|
97
|
+
const PROTOCOL_CHART_METRICS = ["tvlUsd"];
|
|
98
|
+
/**
|
|
87
99
|
* Unit of every metric, the one place either side decides it.
|
|
88
100
|
*
|
|
89
101
|
* A metric added to a union above fails to compile here until its unit is
|
|
@@ -113,7 +125,8 @@ const CHART_METRIC_UNITS = {
|
|
|
113
125
|
totalValueUnderlying: "token",
|
|
114
126
|
debt: "token",
|
|
115
127
|
healthFactor: "bps",
|
|
116
|
-
netApy7d: "bps"
|
|
128
|
+
netApy7d: "bps",
|
|
129
|
+
tvlUsd: "usd"
|
|
117
130
|
};
|
|
118
131
|
/**
|
|
119
132
|
* Reason a series could not be produced at all, which is not the same as a
|
|
@@ -127,4 +140,4 @@ const CHART_UNAVAILABLE_CODES = [
|
|
|
127
140
|
"internal"
|
|
128
141
|
];
|
|
129
142
|
//#endregion
|
|
130
|
-
export { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS };
|
|
143
|
+
export { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS } from "./charts.js";
|
|
1
2
|
import { timestampSchema, tokenSchema } from "./primitives.schema.js";
|
|
2
|
-
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";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/model/charts.schema.ts
|
|
5
5
|
/**
|
|
@@ -32,13 +32,18 @@ const poolPositionChartMetricSchema = z.enum(POOL_POSITION_CHART_METRICS);
|
|
|
32
32
|
**/
|
|
33
33
|
const strategyPositionChartMetricSchema = z.enum(STRATEGY_POSITION_CHART_METRICS);
|
|
34
34
|
/**
|
|
35
|
-
* {@link
|
|
35
|
+
* {@link ProtocolChartMetric}
|
|
36
|
+
**/
|
|
37
|
+
const protocolChartMetricSchema = z.enum(PROTOCOL_CHART_METRICS);
|
|
38
|
+
/**
|
|
39
|
+
* {@link ChartMetric}, every metric any subject can chart.
|
|
36
40
|
**/
|
|
37
41
|
const chartMetricSchema = z.union([
|
|
38
42
|
poolOpportunityChartMetricSchema,
|
|
39
43
|
strategyOpportunityChartMetricSchema,
|
|
40
44
|
poolPositionChartMetricSchema,
|
|
41
|
-
strategyPositionChartMetricSchema
|
|
45
|
+
strategyPositionChartMetricSchema,
|
|
46
|
+
protocolChartMetricSchema
|
|
42
47
|
]);
|
|
43
48
|
/**
|
|
44
49
|
* {@link ChartQuery}
|
|
@@ -223,4 +228,4 @@ function chartBundleSchemaFor(metrics, range) {
|
|
|
223
228
|
return chartBundleSchemaWith(z.union(literals), range);
|
|
224
229
|
}
|
|
225
230
|
//#endregion
|
|
226
|
-
export { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema };
|
|
231
|
+
export { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, protocolChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema };
|
package/dist/esm/model/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import "./analytics.js";
|
|
2
|
+
import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS } from "./charts.js";
|
|
3
|
+
import { backendPreferred, compareTagOf, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
4
|
+
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
5
|
+
import { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, protocolChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema } from "./charts.schema.js";
|
|
2
6
|
import { FILTER_ALL, isFilterSet } from "./filters.js";
|
|
3
7
|
import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
|
|
4
|
-
import { backendPreferred, compareTagOf, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
5
8
|
import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
|
|
6
|
-
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
7
9
|
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
8
10
|
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
11
|
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";
|
|
12
|
-
import { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema } from "./charts.schema.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
13
|
import "./curators.js";
|
|
14
14
|
import "./delayed-intents.js";
|
|
15
15
|
import "./errors.js";
|
|
@@ -25,4 +25,4 @@ import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourc
|
|
|
25
25
|
import { isSDKError, safeValue, sdkErr, sdkOk } from "./result.js";
|
|
26
26
|
import "./withdrawals.js";
|
|
27
27
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
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 };
|
|
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, PROTOCOL_CHART_METRICS, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, 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 { ZodAddress } from "../onchain/utils/zod.js";
|
|
2
|
+
import { assetTypeSchema, bpsSchema, chainIdSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
2
3
|
import { filterable } from "./filters.schema.js";
|
|
3
4
|
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";
|
|
2
4
|
import { isFilterSet } from "./filters.js";
|
|
3
5
|
import { booleanParamSchema, encodeFlag, filterable } from "./filters.schema.js";
|
|
4
|
-
import { offchainOnly, tolerance } from "./compare.schema.js";
|
|
5
6
|
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 { isFilterSet } from "./filters.js";
|
|
3
|
-
import { booleanParamSchema, encodeFlag, filterable } from "./filters.schema.js";
|
|
4
2
|
import { backendPreferred, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
5
3
|
import { assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
4
|
+
import { isFilterSet } from "./filters.js";
|
|
5
|
+
import { booleanParamSchema, encodeFlag, filterable } from "./filters.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,11 +1,34 @@
|
|
|
1
|
+
import { chartBundleSchemaFor } from "../../model/charts.schema.js";
|
|
2
|
+
import { analyticsChartQuerySchema } from "../../model/analytics.schema.js";
|
|
3
|
+
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
1
4
|
import { OffchainAnalyticsPositions } from "./OffchainAnalyticsPositions.js";
|
|
5
|
+
import { z } from "zod/v4";
|
|
2
6
|
//#region src/offchain/analytics/OffchainAnalytics.ts
|
|
3
|
-
/**
|
|
4
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Backend-only protocol analytics, grouped by subject.
|
|
9
|
+
*
|
|
10
|
+
* It owns the protocol-wide charts itself rather than through a sub-namespace:
|
|
11
|
+
* their subject is Gearbox as a whole, so there is nothing narrower for them to
|
|
12
|
+
* hang off.
|
|
13
|
+
**/
|
|
14
|
+
var OffchainAnalytics = class extends AbstractOffchainNamespace {
|
|
5
15
|
positions;
|
|
6
16
|
constructor(options) {
|
|
17
|
+
super("OffchainAnalytics", options);
|
|
7
18
|
this.positions = new OffchainAnalyticsPositions(options);
|
|
8
19
|
}
|
|
20
|
+
/** {@inheritDoc IOffchainAnalytics.getCharts} */
|
|
21
|
+
async getCharts(metrics, range, filter) {
|
|
22
|
+
return this.get({
|
|
23
|
+
path: "/v2/analytics/charts",
|
|
24
|
+
query: z.encode(analyticsChartQuerySchema, {
|
|
25
|
+
metrics,
|
|
26
|
+
range,
|
|
27
|
+
chainIds: this.scopedChainIds(filter)
|
|
28
|
+
}),
|
|
29
|
+
schema: chartBundleSchemaFor(metrics, range)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
9
32
|
};
|
|
10
33
|
//#endregion
|
|
11
34
|
export { OffchainAnalytics };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
1
3
|
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
4
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
3
5
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
@@ -8,8 +10,6 @@ import "../base/index.js";
|
|
|
8
10
|
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
9
11
|
import "./bots/index.js";
|
|
10
12
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
11
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
13
|
import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
1
2
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
2
3
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
4
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -19,7 +20,6 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
|
|
|
19
20
|
import "../../market/rwa/securitize/index.js";
|
|
20
21
|
import "../../market/index.js";
|
|
21
22
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
22
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
23
23
|
import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
|
|
24
24
|
//#region src/onchain/accounts/liquidations/LiquidationsService.ts
|
|
25
25
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
1
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
2
3
|
import "../../base/index.js";
|
|
3
4
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
4
5
|
import "../../../model/index.js";
|
|
5
6
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
6
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
7
7
|
//#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
8
8
|
const abi = iRedemptionLoggerV310Abi;
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
1
|
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
|
+
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
3
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
1
2
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
2
3
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
2
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
3
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
4
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
2
5
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
6
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
4
7
|
import { getAssetType } from "../chain/chains.js";
|
|
5
8
|
import { formatBN } from "../utils/formatter.js";
|
|
6
9
|
import "../utils/index.js";
|
|
7
|
-
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
8
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
9
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
10
10
|
import { SdkRWADataNotLoadedError } from "../core/errors.js";
|
|
11
11
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
12
12
|
//#region src/onchain/base/TokensMeta.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
1
2
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
2
3
|
import { isV310 } from "../constants/versions.js";
|
|
3
4
|
import "../constants/index.js";
|
|
4
5
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/onchain/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|