@gearbox-protocol/sdk 15.1.0-next.7 → 15.1.0-next.8
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/charts.js +147 -0
- package/dist/cjs/model/charts.schema.js +240 -0
- package/dist/cjs/model/index.js +27 -22
- package/dist/cjs/model/liquidations.schema.js +1 -1
- package/dist/cjs/model/opportunities.schema.js +1 -1
- package/dist/cjs/model/positions.schema.js +2 -2
- package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +2 -6
- package/dist/cjs/new-sdk/positions/PositionsNamespace.js +2 -6
- package/dist/cjs/new-sdk/utils/index.js +0 -1
- package/dist/cjs/offchain/AbstractOffchainNamespace.js +10 -7
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +4 -8
- package/dist/cjs/offchain/positions/OffchainPositions.js +8 -11
- package/dist/esm/model/charts.js +140 -0
- package/dist/esm/model/charts.schema.js +226 -0
- package/dist/esm/model/index.js +7 -7
- package/dist/esm/model/liquidations.schema.js +1 -1
- package/dist/esm/model/opportunities.schema.js +1 -1
- package/dist/esm/model/positions.schema.js +2 -2
- package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +2 -6
- package/dist/esm/new-sdk/positions/PositionsNamespace.js +2 -6
- package/dist/esm/new-sdk/utils/index.js +0 -1
- package/dist/esm/offchain/AbstractOffchainNamespace.js +10 -7
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +4 -8
- package/dist/esm/offchain/positions/OffchainPositions.js +8 -11
- package/dist/types/model/charts.d.ts +349 -0
- package/dist/types/model/charts.schema.d.ts +364 -0
- package/dist/types/model/index.d.ts +5 -5
- package/dist/types/model/positions.d.ts +1 -1
- package/dist/types/new-sdk/index.d.ts +1 -2
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +4 -5
- package/dist/types/new-sdk/opportunities/types.d.ts +9 -7
- package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +4 -5
- package/dist/types/new-sdk/positions/types.d.ts +9 -9
- package/dist/types/new-sdk/utils/index.d.ts +1 -2
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +5 -21
- package/dist/types/offchain/index.d.ts +2 -2
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +8 -4
- package/dist/types/offchain/positions/OffchainPositions.d.ts +11 -5
- package/package.json +1 -1
- package/dist/cjs/model/history.js +0 -53
- package/dist/cjs/model/history.schema.js +0 -128
- package/dist/cjs/new-sdk/utils/history.js +0 -1
- package/dist/esm/model/history.js +0 -49
- package/dist/esm/model/history.schema.js +0 -116
- package/dist/esm/new-sdk/utils/history.js +0 -1
- package/dist/types/model/history.d.ts +0 -153
- package/dist/types/model/history.schema.d.ts +0 -95
- package/dist/types/new-sdk/utils/history.d.ts +0 -18
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
2
|
+
import { Opportunity, OpportunityFilter, OpportunityKey, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { GearboxAPIOptions } from "../types.js";
|
|
5
5
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
6
6
|
//#region src/offchain/opportunities/OffchainOpportunities.d.ts
|
|
7
|
+
type OpportunityChartMetricFor<K extends OpportunityKey> = {
|
|
8
|
+
pool: PoolOpportunityChartMetric;
|
|
9
|
+
strategy: StrategyOpportunityChartMetric;
|
|
10
|
+
}[K["kind"]];
|
|
7
11
|
/**
|
|
8
12
|
* Backend counterpart of the `opportunities` namespace.
|
|
9
13
|
**/
|
|
@@ -24,9 +28,9 @@ declare class OffchainOpportunities extends AbstractOffchainNamespace {
|
|
|
24
28
|
**/
|
|
25
29
|
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Charts of one opportunity: one series per metric, on a shared grid.
|
|
28
32
|
**/
|
|
29
|
-
|
|
33
|
+
getCharts<K extends OpportunityKey, const Metrics extends readonly OpportunityChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
30
34
|
}
|
|
31
35
|
//#endregion
|
|
32
36
|
export { OffchainOpportunities };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
2
|
+
import { Position, PositionKey } from "../../model/positions.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { ListPositionsPropsBase } from "../../sdk/positions/types.js";
|
|
5
5
|
import { GearboxAPIOptions } from "../types.js";
|
|
6
6
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
7
7
|
//#region src/offchain/positions/OffchainPositions.d.ts
|
|
8
|
+
type PositionChartMetricFor<K extends PositionKey> = {
|
|
9
|
+
pool: PoolPositionChartMetric;
|
|
10
|
+
strategy: StrategyPositionChartMetric;
|
|
11
|
+
}[K["kind"]];
|
|
8
12
|
/**
|
|
9
13
|
* Backend counterpart of the `positions` namespace.
|
|
10
14
|
**/
|
|
@@ -16,11 +20,13 @@ declare class OffchainPositions extends AbstractOffchainNamespace {
|
|
|
16
20
|
**/
|
|
17
21
|
list(props: ListPositionsPropsBase): Promise<DataResponse<Position[]>>;
|
|
18
22
|
/**
|
|
19
|
-
*
|
|
23
|
+
* Charts of one position: one series per metric, on a shared grid.
|
|
20
24
|
*
|
|
21
|
-
* @
|
|
25
|
+
* @throws {OffchainNotImplementedError} Until the backend serves it. An empty
|
|
26
|
+
* bundle would be the one answer this model exists to rule out: a chart that
|
|
27
|
+
* could not be read is not a chart with no points.
|
|
22
28
|
**/
|
|
23
|
-
|
|
29
|
+
getCharts<K extends PositionKey, const Metrics extends readonly PositionChartMetricFor<K>[]>(key: K, _metrics: Metrics, _range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
|
|
24
30
|
}
|
|
25
31
|
//#endregion
|
|
26
32
|
export { OffchainPositions };
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/model/history.ts
|
|
3
|
-
/**
|
|
4
|
-
* Every {@link PoolHistoryMetric}, for callers that enumerate them.
|
|
5
|
-
**/
|
|
6
|
-
const POOL_HISTORY_METRICS = [
|
|
7
|
-
"depositApy",
|
|
8
|
-
"borrowApy",
|
|
9
|
-
"dieselRate",
|
|
10
|
-
"supplied",
|
|
11
|
-
"borrowed",
|
|
12
|
-
"availableLiquidity"
|
|
13
|
-
];
|
|
14
|
-
/**
|
|
15
|
-
* Every {@link StrategyHistoryMetric}, for callers that enumerate them.
|
|
16
|
-
**/
|
|
17
|
-
const STRATEGY_HISTORY_METRICS = [
|
|
18
|
-
"netApy",
|
|
19
|
-
"borrowApy",
|
|
20
|
-
"collateralApy",
|
|
21
|
-
"tvl",
|
|
22
|
-
"collateralPrice",
|
|
23
|
-
"collateralUsdPrice",
|
|
24
|
-
"underlyingUsdPrice"
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* Every {@link PoolPositionHistoryMetric}, for callers that enumerate them.
|
|
28
|
-
**/
|
|
29
|
-
const POOL_POSITION_HISTORY_METRICS = [
|
|
30
|
-
"depositApy",
|
|
31
|
-
"borrowApy",
|
|
32
|
-
"dieselRate",
|
|
33
|
-
"supplied",
|
|
34
|
-
"borrowed",
|
|
35
|
-
"availableLiquidity"
|
|
36
|
-
];
|
|
37
|
-
/**
|
|
38
|
-
* Every {@link StrategyPositionHistoryMetric}, for callers that enumerate them.
|
|
39
|
-
**/
|
|
40
|
-
const STRATEGY_POSITION_HISTORY_METRICS = [
|
|
41
|
-
"netApy",
|
|
42
|
-
"borrowApy",
|
|
43
|
-
"collateralApy",
|
|
44
|
-
"tvl",
|
|
45
|
-
"collateralPrice",
|
|
46
|
-
"collateralUsdPrice",
|
|
47
|
-
"underlyingUsdPrice"
|
|
48
|
-
];
|
|
49
|
-
//#endregion
|
|
50
|
-
exports.POOL_HISTORY_METRICS = POOL_HISTORY_METRICS;
|
|
51
|
-
exports.POOL_POSITION_HISTORY_METRICS = POOL_POSITION_HISTORY_METRICS;
|
|
52
|
-
exports.STRATEGY_HISTORY_METRICS = STRATEGY_HISTORY_METRICS;
|
|
53
|
-
exports.STRATEGY_POSITION_HISTORY_METRICS = STRATEGY_POSITION_HISTORY_METRICS;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
3
|
-
const require_model_opportunities_schema = require("./opportunities.schema.js");
|
|
4
|
-
const require_model_positions_schema = require("./positions.schema.js");
|
|
5
|
-
let zod_v4 = require("zod/v4");
|
|
6
|
-
//#region src/model/history.schema.ts
|
|
7
|
-
/**
|
|
8
|
-
* Runtime schemas for {@link ./history.js}, see the note in
|
|
9
|
-
* `primitives.schema.ts` on why they are written by hand.
|
|
10
|
-
**/
|
|
11
|
-
/**
|
|
12
|
-
* {@link HistoryRange}
|
|
13
|
-
**/
|
|
14
|
-
const historyRangeSchema = zod_v4.z.union([
|
|
15
|
-
zod_v4.z.literal("1d"),
|
|
16
|
-
zod_v4.z.literal("1w"),
|
|
17
|
-
zod_v4.z.literal("1m"),
|
|
18
|
-
zod_v4.z.literal("1y"),
|
|
19
|
-
zod_v4.z.literal("max")
|
|
20
|
-
]);
|
|
21
|
-
/**
|
|
22
|
-
* {@link PoolHistoryMetric}
|
|
23
|
-
**/
|
|
24
|
-
const poolHistoryMetricSchema = zod_v4.z.union([
|
|
25
|
-
zod_v4.z.literal("depositApy"),
|
|
26
|
-
zod_v4.z.literal("borrowApy"),
|
|
27
|
-
zod_v4.z.literal("dieselRate"),
|
|
28
|
-
zod_v4.z.literal("supplied"),
|
|
29
|
-
zod_v4.z.literal("borrowed"),
|
|
30
|
-
zod_v4.z.literal("availableLiquidity")
|
|
31
|
-
]);
|
|
32
|
-
/**
|
|
33
|
-
* {@link StrategyHistoryMetric}
|
|
34
|
-
**/
|
|
35
|
-
const strategyHistoryMetricSchema = zod_v4.z.union([
|
|
36
|
-
zod_v4.z.literal("netApy"),
|
|
37
|
-
zod_v4.z.literal("borrowApy"),
|
|
38
|
-
zod_v4.z.literal("collateralApy"),
|
|
39
|
-
zod_v4.z.literal("tvl"),
|
|
40
|
-
zod_v4.z.literal("collateralPrice"),
|
|
41
|
-
zod_v4.z.literal("collateralUsdPrice"),
|
|
42
|
-
zod_v4.z.literal("underlyingUsdPrice")
|
|
43
|
-
]);
|
|
44
|
-
/**
|
|
45
|
-
* {@link PoolPositionHistoryMetric}
|
|
46
|
-
**/
|
|
47
|
-
const poolPositionHistoryMetricSchema = zod_v4.z.union([
|
|
48
|
-
zod_v4.z.literal("depositApy"),
|
|
49
|
-
zod_v4.z.literal("borrowApy"),
|
|
50
|
-
zod_v4.z.literal("dieselRate"),
|
|
51
|
-
zod_v4.z.literal("supplied"),
|
|
52
|
-
zod_v4.z.literal("borrowed"),
|
|
53
|
-
zod_v4.z.literal("availableLiquidity")
|
|
54
|
-
]);
|
|
55
|
-
/**
|
|
56
|
-
* {@link StrategyPositionHistoryMetric}
|
|
57
|
-
**/
|
|
58
|
-
const strategyPositionHistoryMetricSchema = zod_v4.z.union([
|
|
59
|
-
zod_v4.z.literal("netApy"),
|
|
60
|
-
zod_v4.z.literal("borrowApy"),
|
|
61
|
-
zod_v4.z.literal("collateralApy"),
|
|
62
|
-
zod_v4.z.literal("tvl"),
|
|
63
|
-
zod_v4.z.literal("collateralPrice"),
|
|
64
|
-
zod_v4.z.literal("collateralUsdPrice"),
|
|
65
|
-
zod_v4.z.literal("underlyingUsdPrice")
|
|
66
|
-
]);
|
|
67
|
-
/**
|
|
68
|
-
* {@link PositionHistoryMetric}
|
|
69
|
-
**/
|
|
70
|
-
const positionHistoryMetricSchema = zod_v4.z.union([poolPositionHistoryMetricSchema, strategyPositionHistoryMetricSchema]);
|
|
71
|
-
/**
|
|
72
|
-
* {@link HistoryMetric}
|
|
73
|
-
**/
|
|
74
|
-
const historyMetricSchema = zod_v4.z.union([
|
|
75
|
-
poolHistoryMetricSchema,
|
|
76
|
-
strategyHistoryMetricSchema,
|
|
77
|
-
positionHistoryMetricSchema
|
|
78
|
-
]);
|
|
79
|
-
/**
|
|
80
|
-
* {@link HistoryPoint}
|
|
81
|
-
**/
|
|
82
|
-
const historyPointSchema = zod_v4.z.object({
|
|
83
|
-
timestamp: require_model_primitives_schema.timestampSchema,
|
|
84
|
-
value: zod_v4.z.number()
|
|
85
|
-
});
|
|
86
|
-
/**
|
|
87
|
-
* {@link HistoryChartMetadata}
|
|
88
|
-
*
|
|
89
|
-
* TODO: empty until the backend specifies the payload.
|
|
90
|
-
**/
|
|
91
|
-
const historyChartMetadataSchema = zod_v4.z.object({});
|
|
92
|
-
/**
|
|
93
|
-
* {@link HistorySeries}
|
|
94
|
-
**/
|
|
95
|
-
const historySeriesSchema = zod_v4.z.object({
|
|
96
|
-
metric: historyMetricSchema,
|
|
97
|
-
points: zod_v4.z.array(historyPointSchema),
|
|
98
|
-
metadata: historyChartMetadataSchema
|
|
99
|
-
});
|
|
100
|
-
/**
|
|
101
|
-
* {@link OpportunityHistoryQuery}
|
|
102
|
-
**/
|
|
103
|
-
const opportunityHistoryQuerySchema = zod_v4.z.object({
|
|
104
|
-
opportunity: require_model_opportunities_schema.opportunityKeySchema,
|
|
105
|
-
range: historyRangeSchema,
|
|
106
|
-
metric: historyMetricSchema
|
|
107
|
-
});
|
|
108
|
-
/**
|
|
109
|
-
* {@link PositionHistoryQuery}
|
|
110
|
-
**/
|
|
111
|
-
const positionHistoryQuerySchema = zod_v4.z.object({
|
|
112
|
-
position: require_model_positions_schema.positionKeySchema,
|
|
113
|
-
range: historyRangeSchema,
|
|
114
|
-
metric: positionHistoryMetricSchema
|
|
115
|
-
});
|
|
116
|
-
//#endregion
|
|
117
|
-
exports.historyChartMetadataSchema = historyChartMetadataSchema;
|
|
118
|
-
exports.historyMetricSchema = historyMetricSchema;
|
|
119
|
-
exports.historyPointSchema = historyPointSchema;
|
|
120
|
-
exports.historyRangeSchema = historyRangeSchema;
|
|
121
|
-
exports.historySeriesSchema = historySeriesSchema;
|
|
122
|
-
exports.opportunityHistoryQuerySchema = opportunityHistoryQuerySchema;
|
|
123
|
-
exports.poolHistoryMetricSchema = poolHistoryMetricSchema;
|
|
124
|
-
exports.poolPositionHistoryMetricSchema = poolPositionHistoryMetricSchema;
|
|
125
|
-
exports.positionHistoryMetricSchema = positionHistoryMetricSchema;
|
|
126
|
-
exports.positionHistoryQuerySchema = positionHistoryQuerySchema;
|
|
127
|
-
exports.strategyHistoryMetricSchema = strategyHistoryMetricSchema;
|
|
128
|
-
exports.strategyPositionHistoryMetricSchema = strategyPositionHistoryMetricSchema;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//#region src/model/history.ts
|
|
2
|
-
/**
|
|
3
|
-
* Every {@link PoolHistoryMetric}, for callers that enumerate them.
|
|
4
|
-
**/
|
|
5
|
-
const POOL_HISTORY_METRICS = [
|
|
6
|
-
"depositApy",
|
|
7
|
-
"borrowApy",
|
|
8
|
-
"dieselRate",
|
|
9
|
-
"supplied",
|
|
10
|
-
"borrowed",
|
|
11
|
-
"availableLiquidity"
|
|
12
|
-
];
|
|
13
|
-
/**
|
|
14
|
-
* Every {@link StrategyHistoryMetric}, for callers that enumerate them.
|
|
15
|
-
**/
|
|
16
|
-
const STRATEGY_HISTORY_METRICS = [
|
|
17
|
-
"netApy",
|
|
18
|
-
"borrowApy",
|
|
19
|
-
"collateralApy",
|
|
20
|
-
"tvl",
|
|
21
|
-
"collateralPrice",
|
|
22
|
-
"collateralUsdPrice",
|
|
23
|
-
"underlyingUsdPrice"
|
|
24
|
-
];
|
|
25
|
-
/**
|
|
26
|
-
* Every {@link PoolPositionHistoryMetric}, for callers that enumerate them.
|
|
27
|
-
**/
|
|
28
|
-
const POOL_POSITION_HISTORY_METRICS = [
|
|
29
|
-
"depositApy",
|
|
30
|
-
"borrowApy",
|
|
31
|
-
"dieselRate",
|
|
32
|
-
"supplied",
|
|
33
|
-
"borrowed",
|
|
34
|
-
"availableLiquidity"
|
|
35
|
-
];
|
|
36
|
-
/**
|
|
37
|
-
* Every {@link StrategyPositionHistoryMetric}, for callers that enumerate them.
|
|
38
|
-
**/
|
|
39
|
-
const STRATEGY_POSITION_HISTORY_METRICS = [
|
|
40
|
-
"netApy",
|
|
41
|
-
"borrowApy",
|
|
42
|
-
"collateralApy",
|
|
43
|
-
"tvl",
|
|
44
|
-
"collateralPrice",
|
|
45
|
-
"collateralUsdPrice",
|
|
46
|
-
"underlyingUsdPrice"
|
|
47
|
-
];
|
|
48
|
-
//#endregion
|
|
49
|
-
export { POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { timestampSchema } from "./primitives.schema.js";
|
|
2
|
-
import { opportunityKeySchema } from "./opportunities.schema.js";
|
|
3
|
-
import { positionKeySchema } from "./positions.schema.js";
|
|
4
|
-
import { z } from "zod/v4";
|
|
5
|
-
//#region src/model/history.schema.ts
|
|
6
|
-
/**
|
|
7
|
-
* Runtime schemas for {@link ./history.js}, see the note in
|
|
8
|
-
* `primitives.schema.ts` on why they are written by hand.
|
|
9
|
-
**/
|
|
10
|
-
/**
|
|
11
|
-
* {@link HistoryRange}
|
|
12
|
-
**/
|
|
13
|
-
const historyRangeSchema = z.union([
|
|
14
|
-
z.literal("1d"),
|
|
15
|
-
z.literal("1w"),
|
|
16
|
-
z.literal("1m"),
|
|
17
|
-
z.literal("1y"),
|
|
18
|
-
z.literal("max")
|
|
19
|
-
]);
|
|
20
|
-
/**
|
|
21
|
-
* {@link PoolHistoryMetric}
|
|
22
|
-
**/
|
|
23
|
-
const poolHistoryMetricSchema = z.union([
|
|
24
|
-
z.literal("depositApy"),
|
|
25
|
-
z.literal("borrowApy"),
|
|
26
|
-
z.literal("dieselRate"),
|
|
27
|
-
z.literal("supplied"),
|
|
28
|
-
z.literal("borrowed"),
|
|
29
|
-
z.literal("availableLiquidity")
|
|
30
|
-
]);
|
|
31
|
-
/**
|
|
32
|
-
* {@link StrategyHistoryMetric}
|
|
33
|
-
**/
|
|
34
|
-
const strategyHistoryMetricSchema = z.union([
|
|
35
|
-
z.literal("netApy"),
|
|
36
|
-
z.literal("borrowApy"),
|
|
37
|
-
z.literal("collateralApy"),
|
|
38
|
-
z.literal("tvl"),
|
|
39
|
-
z.literal("collateralPrice"),
|
|
40
|
-
z.literal("collateralUsdPrice"),
|
|
41
|
-
z.literal("underlyingUsdPrice")
|
|
42
|
-
]);
|
|
43
|
-
/**
|
|
44
|
-
* {@link PoolPositionHistoryMetric}
|
|
45
|
-
**/
|
|
46
|
-
const poolPositionHistoryMetricSchema = z.union([
|
|
47
|
-
z.literal("depositApy"),
|
|
48
|
-
z.literal("borrowApy"),
|
|
49
|
-
z.literal("dieselRate"),
|
|
50
|
-
z.literal("supplied"),
|
|
51
|
-
z.literal("borrowed"),
|
|
52
|
-
z.literal("availableLiquidity")
|
|
53
|
-
]);
|
|
54
|
-
/**
|
|
55
|
-
* {@link StrategyPositionHistoryMetric}
|
|
56
|
-
**/
|
|
57
|
-
const strategyPositionHistoryMetricSchema = z.union([
|
|
58
|
-
z.literal("netApy"),
|
|
59
|
-
z.literal("borrowApy"),
|
|
60
|
-
z.literal("collateralApy"),
|
|
61
|
-
z.literal("tvl"),
|
|
62
|
-
z.literal("collateralPrice"),
|
|
63
|
-
z.literal("collateralUsdPrice"),
|
|
64
|
-
z.literal("underlyingUsdPrice")
|
|
65
|
-
]);
|
|
66
|
-
/**
|
|
67
|
-
* {@link PositionHistoryMetric}
|
|
68
|
-
**/
|
|
69
|
-
const positionHistoryMetricSchema = z.union([poolPositionHistoryMetricSchema, strategyPositionHistoryMetricSchema]);
|
|
70
|
-
/**
|
|
71
|
-
* {@link HistoryMetric}
|
|
72
|
-
**/
|
|
73
|
-
const historyMetricSchema = z.union([
|
|
74
|
-
poolHistoryMetricSchema,
|
|
75
|
-
strategyHistoryMetricSchema,
|
|
76
|
-
positionHistoryMetricSchema
|
|
77
|
-
]);
|
|
78
|
-
/**
|
|
79
|
-
* {@link HistoryPoint}
|
|
80
|
-
**/
|
|
81
|
-
const historyPointSchema = z.object({
|
|
82
|
-
timestamp: timestampSchema,
|
|
83
|
-
value: z.number()
|
|
84
|
-
});
|
|
85
|
-
/**
|
|
86
|
-
* {@link HistoryChartMetadata}
|
|
87
|
-
*
|
|
88
|
-
* TODO: empty until the backend specifies the payload.
|
|
89
|
-
**/
|
|
90
|
-
const historyChartMetadataSchema = z.object({});
|
|
91
|
-
/**
|
|
92
|
-
* {@link HistorySeries}
|
|
93
|
-
**/
|
|
94
|
-
const historySeriesSchema = z.object({
|
|
95
|
-
metric: historyMetricSchema,
|
|
96
|
-
points: z.array(historyPointSchema),
|
|
97
|
-
metadata: historyChartMetadataSchema
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* {@link OpportunityHistoryQuery}
|
|
101
|
-
**/
|
|
102
|
-
const opportunityHistoryQuerySchema = z.object({
|
|
103
|
-
opportunity: opportunityKeySchema,
|
|
104
|
-
range: historyRangeSchema,
|
|
105
|
-
metric: historyMetricSchema
|
|
106
|
-
});
|
|
107
|
-
/**
|
|
108
|
-
* {@link PositionHistoryQuery}
|
|
109
|
-
**/
|
|
110
|
-
const positionHistoryQuerySchema = z.object({
|
|
111
|
-
position: positionKeySchema,
|
|
112
|
-
range: historyRangeSchema,
|
|
113
|
-
metric: positionHistoryMetricSchema
|
|
114
|
-
});
|
|
115
|
-
//#endregion
|
|
116
|
-
export { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, poolPositionHistoryMetricSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, strategyHistoryMetricSchema, strategyPositionHistoryMetricSchema };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { Timestamp } from "./primitives.js";
|
|
2
|
-
import { OpportunityKey } from "./opportunities.js";
|
|
3
|
-
import { PositionKey } from "./positions.js";
|
|
4
|
-
//#region src/model/history.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Historical time series of an opportunity.
|
|
7
|
-
*
|
|
8
|
-
* History is backend-only by construction: the chain serves the present, and
|
|
9
|
-
* reconstructing a series from it would mean archive-node reads per point.
|
|
10
|
-
**/
|
|
11
|
-
/**
|
|
12
|
-
* Time window a series covers, ending at the present.
|
|
13
|
-
*
|
|
14
|
-
* `"max"` is the full history the backend retains for the opportunity.
|
|
15
|
-
**/
|
|
16
|
-
type HistoryRange = "1d" | "1w" | "1m" | "1y" | "max";
|
|
17
|
-
/**
|
|
18
|
-
* Series available for a pool opportunity.
|
|
19
|
-
**/
|
|
20
|
-
type PoolHistoryMetric = "depositApy" | "borrowApy" | "dieselRate" | "supplied" | "borrowed" | "availableLiquidity";
|
|
21
|
-
/**
|
|
22
|
-
* Every {@link PoolHistoryMetric}, for callers that enumerate them.
|
|
23
|
-
**/
|
|
24
|
-
declare const POOL_HISTORY_METRICS: readonly ["depositApy", "borrowApy", "dieselRate", "supplied", "borrowed", "availableLiquidity"];
|
|
25
|
-
/**
|
|
26
|
-
* Series available for a strategy opportunity.
|
|
27
|
-
*
|
|
28
|
-
* `collateralPrice` is the collateral/underlying series a liquidation-price
|
|
29
|
-
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
30
|
-
**/
|
|
31
|
-
type StrategyHistoryMetric = "netApy" | "borrowApy" | "collateralApy" | "tvl" | "collateralPrice" | "collateralUsdPrice" | "underlyingUsdPrice";
|
|
32
|
-
/**
|
|
33
|
-
* Every {@link StrategyHistoryMetric}, for callers that enumerate them.
|
|
34
|
-
**/
|
|
35
|
-
declare const STRATEGY_HISTORY_METRICS: readonly ["netApy", "borrowApy", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
36
|
-
/**
|
|
37
|
-
* Series available for a pool position.
|
|
38
|
-
*
|
|
39
|
-
* Spelled out rather than aliased to {@link PoolHistoryMetric}: an opportunity
|
|
40
|
-
* and a position are separate contracts with the backend, and the position
|
|
41
|
-
* series are expected to grow their own members (PnL above all) without that
|
|
42
|
-
* change reaching the opportunity charts.
|
|
43
|
-
**/
|
|
44
|
-
type PoolPositionHistoryMetric = "depositApy" | "borrowApy" | "dieselRate" | "supplied" | "borrowed" | "availableLiquidity";
|
|
45
|
-
/**
|
|
46
|
-
* Every {@link PoolPositionHistoryMetric}, for callers that enumerate them.
|
|
47
|
-
**/
|
|
48
|
-
declare const POOL_POSITION_HISTORY_METRICS: readonly ["depositApy", "borrowApy", "dieselRate", "supplied", "borrowed", "availableLiquidity"];
|
|
49
|
-
/**
|
|
50
|
-
* Series available for a strategy position, see the note on
|
|
51
|
-
* {@link PoolPositionHistoryMetric} for why these are spelled out separately
|
|
52
|
-
* from {@link StrategyHistoryMetric}.
|
|
53
|
-
**/
|
|
54
|
-
type StrategyPositionHistoryMetric = "netApy" | "borrowApy" | "collateralApy" | "tvl" | "collateralPrice" | "collateralUsdPrice" | "underlyingUsdPrice";
|
|
55
|
-
/**
|
|
56
|
-
* Every {@link StrategyPositionHistoryMetric}, for callers that enumerate them.
|
|
57
|
-
**/
|
|
58
|
-
declare const STRATEGY_POSITION_HISTORY_METRICS: readonly ["netApy", "borrowApy", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
59
|
-
/**
|
|
60
|
-
* Any series a position can return.
|
|
61
|
-
**/
|
|
62
|
-
type PositionHistoryMetric = PoolPositionHistoryMetric | StrategyPositionHistoryMetric;
|
|
63
|
-
/**
|
|
64
|
-
* Any series the read model can return.
|
|
65
|
-
**/
|
|
66
|
-
type HistoryMetric = PoolHistoryMetric | StrategyHistoryMetric | PositionHistoryMetric;
|
|
67
|
-
/**
|
|
68
|
-
* One sample of a series.
|
|
69
|
-
**/
|
|
70
|
-
interface HistoryPoint {
|
|
71
|
-
/**
|
|
72
|
-
* When the sample was taken.
|
|
73
|
-
**/
|
|
74
|
-
timestamp: Timestamp;
|
|
75
|
-
/**
|
|
76
|
-
* Sampled value. The unit follows from the metric: APY metrics are in basis
|
|
77
|
-
* points, amount metrics are in the underlying's base units expressed as a
|
|
78
|
-
* float, price metrics are plain prices.
|
|
79
|
-
*
|
|
80
|
-
* @example `842` for an 8.42% APY sample
|
|
81
|
-
**/
|
|
82
|
-
value: number;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Annotations the backend ships alongside a series, e.g. what a chart drawn
|
|
86
|
-
* from it should say beyond the points themselves.
|
|
87
|
-
*
|
|
88
|
-
* TODO: the backend has not specified this payload yet. It stays empty until
|
|
89
|
-
* it does, so that filling it in later is additive rather than a rename.
|
|
90
|
-
**/
|
|
91
|
-
interface HistoryChartMetadata {}
|
|
92
|
-
/**
|
|
93
|
-
* A named series of samples ordered by ascending timestamp.
|
|
94
|
-
*
|
|
95
|
-
* @typeParam M - Metric the series carries.
|
|
96
|
-
**/
|
|
97
|
-
interface HistorySeries<M extends string = HistoryMetric> {
|
|
98
|
-
/**
|
|
99
|
-
* Metric the samples belong to; it also defines their unit, so no separate
|
|
100
|
-
* unit field ships.
|
|
101
|
-
**/
|
|
102
|
-
metric: M;
|
|
103
|
-
/**
|
|
104
|
-
* Samples, oldest first.
|
|
105
|
-
**/
|
|
106
|
-
points: HistoryPoint[];
|
|
107
|
-
/**
|
|
108
|
-
* What the backend says about the series, see {@link HistoryChartMetadata}.
|
|
109
|
-
**/
|
|
110
|
-
metadata: HistoryChartMetadata;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* A request for one series of a single opportunity.
|
|
114
|
-
*
|
|
115
|
-
* @typeParam M - Metric requested.
|
|
116
|
-
**/
|
|
117
|
-
interface OpportunityHistoryQuery<M extends HistoryMetric = HistoryMetric> {
|
|
118
|
-
/**
|
|
119
|
-
* Opportunity the series belongs to.
|
|
120
|
-
**/
|
|
121
|
-
opportunity: OpportunityKey;
|
|
122
|
-
/**
|
|
123
|
-
* Window to cover.
|
|
124
|
-
**/
|
|
125
|
-
range: HistoryRange;
|
|
126
|
-
/**
|
|
127
|
-
* Metric to return. A metric that does not apply to the opportunity's kind
|
|
128
|
-
* has no series.
|
|
129
|
-
**/
|
|
130
|
-
metric: M;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* A request for one series of a single position.
|
|
134
|
-
*
|
|
135
|
-
* @typeParam M - Metric requested.
|
|
136
|
-
**/
|
|
137
|
-
interface PositionHistoryQuery<M extends PositionHistoryMetric = PositionHistoryMetric> {
|
|
138
|
-
/**
|
|
139
|
-
* Position the series belongs to.
|
|
140
|
-
**/
|
|
141
|
-
position: PositionKey;
|
|
142
|
-
/**
|
|
143
|
-
* Window to cover.
|
|
144
|
-
**/
|
|
145
|
-
range: HistoryRange;
|
|
146
|
-
/**
|
|
147
|
-
* Metric to return. A metric that does not apply to the position's kind has
|
|
148
|
-
* no series.
|
|
149
|
-
**/
|
|
150
|
-
metric: M;
|
|
151
|
-
}
|
|
152
|
-
//#endregion
|
|
153
|
-
export { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, OpportunityHistoryQuery, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PoolHistoryMetric, PoolPositionHistoryMetric, PositionHistoryMetric, PositionHistoryQuery, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyPositionHistoryMetric };
|