@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.
- package/dist/cjs/dev/mode-parity/compareOpportunities.js +4 -5
- package/dist/cjs/dev/mode-parity/comparePositions.js +6 -7
- package/dist/cjs/dev/mode-parity/fieldDiff.js +4 -6
- package/dist/cjs/dev/mode-parity/scriptUtils.js +145 -5
- package/dist/cjs/model/analytics.schema.js +117 -0
- package/dist/cjs/model/charts.schema.js +1 -1
- package/dist/cjs/model/index.js +18 -7
- package/dist/cjs/model/liquidations.schema.js +2 -2
- package/dist/cjs/model/opportunities.schema.js +3 -3
- package/dist/cjs/model/positions.schema.js +2 -2
- package/dist/cjs/offchain/GearboxAPI.js +5 -0
- package/dist/cjs/offchain/analytics/OffchainAnalytics.js +12 -0
- package/dist/cjs/offchain/analytics/OffchainAnalyticsPositions.js +24 -0
- package/dist/cjs/offchain/analytics/index.js +6 -0
- package/dist/cjs/offchain/index.js +5 -0
- package/dist/cjs/rewards/errors.js +27 -0
- package/dist/cjs/rewards/index.js +6 -7
- package/dist/cjs/rewards/merkl-api.js +45 -0
- package/dist/cjs/rewards/multichain.js +40 -0
- package/dist/cjs/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
- package/dist/cjs/sdk/GearboxSDK.js +5 -0
- package/dist/cjs/sdk/analytics/AnalyticsNamespace.js +11 -0
- package/dist/cjs/sdk/analytics/index.js +4 -0
- package/dist/cjs/sdk/index.js +3 -0
- package/dist/esm/dev/mode-parity/compareOpportunities.js +4 -5
- package/dist/esm/dev/mode-parity/comparePositions.js +6 -7
- package/dist/esm/dev/mode-parity/fieldDiff.js +4 -6
- package/dist/esm/dev/mode-parity/scriptUtils.js +142 -6
- package/dist/esm/model/analytics.schema.js +108 -0
- package/dist/esm/model/charts.schema.js +1 -1
- package/dist/esm/model/index.js +10 -8
- package/dist/esm/model/liquidations.schema.js +2 -2
- package/dist/esm/model/opportunities.schema.js +3 -3
- package/dist/esm/model/positions.schema.js +2 -2
- package/dist/esm/offchain/GearboxAPI.js +5 -0
- package/dist/esm/offchain/analytics/OffchainAnalytics.js +11 -0
- package/dist/esm/offchain/analytics/OffchainAnalyticsPositions.js +23 -0
- package/dist/esm/offchain/analytics/index.js +4 -0
- package/dist/esm/offchain/index.js +4 -1
- package/dist/esm/rewards/errors.js +26 -0
- package/dist/esm/rewards/index.js +4 -5
- package/dist/esm/rewards/merkl-api.js +42 -0
- package/dist/esm/rewards/multichain.js +39 -0
- package/dist/esm/rewards/{rewards/api.js → toMerklRewards.js} +26 -28
- package/dist/esm/sdk/GearboxSDK.js +5 -0
- package/dist/esm/sdk/analytics/AnalyticsNamespace.js +10 -0
- package/dist/esm/sdk/analytics/index.js +3 -0
- package/dist/esm/sdk/index.js +3 -1
- package/dist/types/dev/mode-parity/compareOpportunities.d.ts +3 -7
- package/dist/types/dev/mode-parity/comparePositions.d.ts +4 -8
- package/dist/types/dev/mode-parity/fieldDiff.d.ts +9 -8
- package/dist/types/dev/mode-parity/scriptUtils.d.ts +26 -1
- package/dist/types/model/analytics.d.ts +62 -0
- package/dist/types/model/analytics.schema.d.ts +149 -0
- package/dist/types/model/index.d.ts +10 -8
- package/dist/types/model/opportunities.d.ts +1 -1
- package/dist/types/model/previews.d.ts +2 -2
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
- package/dist/types/offchain/GearboxAPI.d.ts +4 -0
- package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +11 -0
- package/dist/types/offchain/analytics/OffchainAnalyticsPositions.d.ts +14 -0
- package/dist/types/offchain/analytics/index.d.ts +4 -0
- package/dist/types/offchain/analytics/types.d.ts +17 -0
- package/dist/types/offchain/index.d.ts +5 -1
- 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/rewards/errors.d.ts +18 -0
- package/dist/types/rewards/index.d.ts +4 -7
- package/dist/types/rewards/merkl-api.d.ts +64 -0
- package/dist/types/rewards/multichain.d.ts +33 -0
- package/dist/types/rewards/toMerklRewards.d.ts +42 -0
- package/dist/types/sdk/GearboxSDK.d.ts +4 -0
- package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +11 -0
- package/dist/types/sdk/analytics/index.d.ts +3 -0
- package/dist/types/sdk/analytics/types.d.ts +15 -0
- package/dist/types/sdk/index.d.ts +4 -1
- 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/dist/types/sdk/types.d.ts +3 -0
- package/package.json +1 -3
- package/dist/cjs/_virtual/_rolldown/runtime.js +0 -23
- package/dist/cjs/rewards/apy/index.js +0 -3
- package/dist/cjs/rewards/rewards/extra-apy.js +0 -71
- package/dist/cjs/rewards/rewards/index.js +0 -6
- package/dist/cjs/rewards/rewards/merkl-api.js +0 -22
- package/dist/esm/rewards/apy/index.js +0 -3
- package/dist/esm/rewards/rewards/extra-apy.js +0 -67
- package/dist/esm/rewards/rewards/index.js +0 -3
- package/dist/esm/rewards/rewards/merkl-api.js +0 -19
- package/dist/types/rewards/apy/index.d.ts +0 -3
- package/dist/types/rewards/apy/output-details.d.ts +0 -99
- package/dist/types/rewards/apy/output.d.ts +0 -25
- package/dist/types/rewards/rewards/api.d.ts +0 -60
- package/dist/types/rewards/rewards/common.d.ts +0 -9
- package/dist/types/rewards/rewards/extra-apy.d.ts +0 -37
- package/dist/types/rewards/rewards/index.d.ts +0 -3
- package/dist/types/rewards/rewards/merkl-api.d.ts +0 -54
- /package/dist/cjs/{rewards/apy/output-details.js → model/analytics.js} +0 -0
- /package/dist/cjs/{rewards/apy/output.js → offchain/analytics/types.js} +0 -0
- /package/dist/cjs/{rewards/rewards/common.js → sdk/analytics/types.js} +0 -0
- /package/dist/esm/{rewards/apy/output-details.js → model/analytics.js} +0 -0
- /package/dist/esm/{rewards/apy/output.js → offchain/analytics/types.js} +0 -0
- /package/dist/esm/{rewards/rewards/common.js → sdk/analytics/types.js} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PoolPosition, PositionFilter, StrategyPosition } from "./positions.js";
|
|
2
|
+
import { LiquidationPosition } from "./liquidations.js";
|
|
3
|
+
import { Address } from "viem";
|
|
4
|
+
//#region src/model/analytics.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A protocol-wide position row together with the wallet that owns it.
|
|
7
|
+
*
|
|
8
|
+
* The position fields stay flat, so consumers can render this row exactly as
|
|
9
|
+
* they render a wallet-scoped {@link Position}; `borrower` is the only extra
|
|
10
|
+
* identity the protocol-wide list needs.
|
|
11
|
+
**/
|
|
12
|
+
type AnalyticsPosition = AnalyticsPoolPosition | AnalyticsStrategyPosition | AnalyticsLiquidationPosition;
|
|
13
|
+
/** Pool position with its owner on the protocol-wide list. */
|
|
14
|
+
type AnalyticsPoolPosition = PoolPosition & AnalyticsPositionOwner;
|
|
15
|
+
/** Strategy position with its borrower on the protocol-wide list. */
|
|
16
|
+
type AnalyticsStrategyPosition = StrategyPosition & AnalyticsPositionOwner;
|
|
17
|
+
/** Liquidation position with its owner on the protocol-wide list. */
|
|
18
|
+
type AnalyticsLiquidationPosition = LiquidationPosition & AnalyticsPositionOwner;
|
|
19
|
+
/** Ownership added to every protocol-wide position row. */
|
|
20
|
+
interface AnalyticsPositionOwner {
|
|
21
|
+
/** Wallet that owns the pool shares or opened the credit account. */
|
|
22
|
+
borrower: Address;
|
|
23
|
+
}
|
|
24
|
+
/** Fields the protocol-wide position list can order by. */
|
|
25
|
+
type AnalyticsPositionSortField = "netValueUsd" | "totalValueUsd" | "totalDebtUsd" | "pnlUsd" | "apy" | "healthFactor" | "leverage" | "chainId" | "name" | "borrower";
|
|
26
|
+
/** Direction of one analytics list ordering. */
|
|
27
|
+
type AnalyticsSortDirection = "asc" | "desc";
|
|
28
|
+
/**
|
|
29
|
+
* Filtering, ordering and offset pagination of the protocol-wide position
|
|
30
|
+
* list. Omitted position criteria have the same meaning as they do on
|
|
31
|
+
* {@link PositionFilter}.
|
|
32
|
+
**/
|
|
33
|
+
interface AnalyticsPositionListOptions extends PositionFilter {
|
|
34
|
+
/** Keep only positions owned by this wallet. */
|
|
35
|
+
borrower?: Address;
|
|
36
|
+
/**
|
|
37
|
+
* Field to order by. Values that do not apply to a position kind, and USD
|
|
38
|
+
* values that cannot be priced, are always placed after concrete values.
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue `"netValueUsd"`
|
|
41
|
+
*/
|
|
42
|
+
sortBy?: AnalyticsPositionSortField;
|
|
43
|
+
/** @defaultValue `"desc"` */
|
|
44
|
+
sortDirection?: AnalyticsSortDirection;
|
|
45
|
+
/** Number of matching rows to skip. @defaultValue `0` */
|
|
46
|
+
offset?: number;
|
|
47
|
+
/** Number of rows to return, from 1 through 100. @defaultValue `25` */
|
|
48
|
+
limit?: number;
|
|
49
|
+
}
|
|
50
|
+
/** One page of the protocol-wide position list. */
|
|
51
|
+
interface AnalyticsPositionPage {
|
|
52
|
+
/** Requested slice after filtering and ordering. */
|
|
53
|
+
items: AnalyticsPosition[];
|
|
54
|
+
/** Number of rows matching the filter before pagination. */
|
|
55
|
+
total: number;
|
|
56
|
+
/** Effective number of rows skipped. */
|
|
57
|
+
offset: number;
|
|
58
|
+
/** Effective maximum number of rows returned. */
|
|
59
|
+
limit: number;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { AnalyticsPosition } from "./analytics.js";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
//#region src/model/analytics.schema.d.ts
|
|
4
|
+
/** Default page size of the protocol-wide positions list. */
|
|
5
|
+
declare const ANALYTICS_POSITIONS_DEFAULT_LIMIT = 25;
|
|
6
|
+
/** Largest page the protocol-wide positions list accepts. */
|
|
7
|
+
declare const ANALYTICS_POSITIONS_MAX_LIMIT = 100;
|
|
8
|
+
/** {@link AnalyticsPositionSortField} */
|
|
9
|
+
declare const analyticsPositionSortFieldSchema: z.ZodEnum<{
|
|
10
|
+
apy: "apy";
|
|
11
|
+
borrower: "borrower";
|
|
12
|
+
chainId: "chainId";
|
|
13
|
+
healthFactor: "healthFactor";
|
|
14
|
+
leverage: "leverage";
|
|
15
|
+
name: "name";
|
|
16
|
+
netValueUsd: "netValueUsd";
|
|
17
|
+
pnlUsd: "pnlUsd";
|
|
18
|
+
totalDebtUsd: "totalDebtUsd";
|
|
19
|
+
totalValueUsd: "totalValueUsd";
|
|
20
|
+
}>;
|
|
21
|
+
/** {@link AnalyticsSortDirection} */
|
|
22
|
+
declare const analyticsSortDirectionSchema: z.ZodEnum<{
|
|
23
|
+
asc: "asc";
|
|
24
|
+
desc: "desc";
|
|
25
|
+
}>;
|
|
26
|
+
/** {@link AnalyticsPosition} */
|
|
27
|
+
declare const analyticsPositionSchema: z.ZodType<AnalyticsPosition>;
|
|
28
|
+
/** {@link AnalyticsPositionListOptions} */
|
|
29
|
+
declare const analyticsPositionListOptionsSchema: z.ZodObject<{
|
|
30
|
+
borrower: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
31
|
+
kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>, z.ZodLiteral<"all">]>>;
|
|
32
|
+
isZeroDebt: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
|
|
33
|
+
chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
34
|
+
underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
|
|
35
|
+
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
36
|
+
apy: "apy";
|
|
37
|
+
borrower: "borrower";
|
|
38
|
+
chainId: "chainId";
|
|
39
|
+
healthFactor: "healthFactor";
|
|
40
|
+
leverage: "leverage";
|
|
41
|
+
name: "name";
|
|
42
|
+
netValueUsd: "netValueUsd";
|
|
43
|
+
pnlUsd: "pnlUsd";
|
|
44
|
+
totalDebtUsd: "totalDebtUsd";
|
|
45
|
+
totalValueUsd: "totalValueUsd";
|
|
46
|
+
}>>;
|
|
47
|
+
sortDirection: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
asc: "asc";
|
|
49
|
+
desc: "desc";
|
|
50
|
+
}>>;
|
|
51
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
/**
|
|
55
|
+
* {@link AnalyticsPositionListOptions} as URL query parameters.
|
|
56
|
+
**/
|
|
57
|
+
declare const analyticsPositionListQueryParamsSchema: z.ZodObject<{
|
|
58
|
+
borrower: z.ZodOptional<z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>>;
|
|
59
|
+
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>>;
|
|
60
|
+
isZeroDebt: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
false: "false";
|
|
62
|
+
true: "true";
|
|
63
|
+
}>>;
|
|
64
|
+
chainIds: z.ZodOptional<z.ZodString>;
|
|
65
|
+
underlyingType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
66
|
+
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
67
|
+
apy: "apy";
|
|
68
|
+
borrower: "borrower";
|
|
69
|
+
chainId: "chainId";
|
|
70
|
+
healthFactor: "healthFactor";
|
|
71
|
+
leverage: "leverage";
|
|
72
|
+
name: "name";
|
|
73
|
+
netValueUsd: "netValueUsd";
|
|
74
|
+
pnlUsd: "pnlUsd";
|
|
75
|
+
totalDebtUsd: "totalDebtUsd";
|
|
76
|
+
totalValueUsd: "totalValueUsd";
|
|
77
|
+
}>>;
|
|
78
|
+
sortDirection: z.ZodOptional<z.ZodEnum<{
|
|
79
|
+
asc: "asc";
|
|
80
|
+
desc: "desc";
|
|
81
|
+
}>>;
|
|
82
|
+
offset: z.ZodOptional<z.ZodString>;
|
|
83
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
/**
|
|
86
|
+
* Codec for an analytics position-list query. It is shared by the SDK client
|
|
87
|
+
* and backend controller so both sides interpret every parameter identically.
|
|
88
|
+
**/
|
|
89
|
+
declare const analyticsPositionListQuerySchema: z.ZodCodec<z.ZodObject<{
|
|
90
|
+
borrower: z.ZodOptional<z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>>;
|
|
91
|
+
kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>>;
|
|
92
|
+
isZeroDebt: z.ZodOptional<z.ZodEnum<{
|
|
93
|
+
false: "false";
|
|
94
|
+
true: "true";
|
|
95
|
+
}>>;
|
|
96
|
+
chainIds: z.ZodOptional<z.ZodString>;
|
|
97
|
+
underlyingType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
98
|
+
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
99
|
+
apy: "apy";
|
|
100
|
+
borrower: "borrower";
|
|
101
|
+
chainId: "chainId";
|
|
102
|
+
healthFactor: "healthFactor";
|
|
103
|
+
leverage: "leverage";
|
|
104
|
+
name: "name";
|
|
105
|
+
netValueUsd: "netValueUsd";
|
|
106
|
+
pnlUsd: "pnlUsd";
|
|
107
|
+
totalDebtUsd: "totalDebtUsd";
|
|
108
|
+
totalValueUsd: "totalValueUsd";
|
|
109
|
+
}>>;
|
|
110
|
+
sortDirection: z.ZodOptional<z.ZodEnum<{
|
|
111
|
+
asc: "asc";
|
|
112
|
+
desc: "desc";
|
|
113
|
+
}>>;
|
|
114
|
+
offset: z.ZodOptional<z.ZodString>;
|
|
115
|
+
limit: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
117
|
+
borrower: z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
118
|
+
kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>, z.ZodLiteral<"all">]>>;
|
|
119
|
+
isZeroDebt: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
|
|
120
|
+
chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
121
|
+
underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
|
|
122
|
+
sortBy: z.ZodOptional<z.ZodEnum<{
|
|
123
|
+
apy: "apy";
|
|
124
|
+
borrower: "borrower";
|
|
125
|
+
chainId: "chainId";
|
|
126
|
+
healthFactor: "healthFactor";
|
|
127
|
+
leverage: "leverage";
|
|
128
|
+
name: "name";
|
|
129
|
+
netValueUsd: "netValueUsd";
|
|
130
|
+
pnlUsd: "pnlUsd";
|
|
131
|
+
totalDebtUsd: "totalDebtUsd";
|
|
132
|
+
totalValueUsd: "totalValueUsd";
|
|
133
|
+
}>>;
|
|
134
|
+
sortDirection: z.ZodOptional<z.ZodEnum<{
|
|
135
|
+
asc: "asc";
|
|
136
|
+
desc: "desc";
|
|
137
|
+
}>>;
|
|
138
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
140
|
+
}, z.core.$strip>>;
|
|
141
|
+
/** {@link AnalyticsPositionPage} */
|
|
142
|
+
declare const analyticsPositionPageSchema: z.ZodObject<{
|
|
143
|
+
items: z.ZodArray<z.ZodType<AnalyticsPosition, unknown, z.core.$ZodTypeInternals<AnalyticsPosition, unknown>>>;
|
|
144
|
+
total: z.ZodNumber;
|
|
145
|
+
offset: z.ZodNumber;
|
|
146
|
+
limit: z.ZodNumber;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema };
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { Amount, Asset, AssetType, Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, TxCall, UnderlyingToken } from "./primitives.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CompareTag, CompareTolerance, ToleranceCompareTag, backendPreferred, compareTagOf, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
2
|
+
import { ChainScopedFilter, FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
|
|
3
|
+
import { IGearboxError } from "./errors.js";
|
|
5
4
|
import { Curator, CuratorName } from "./curators.js";
|
|
6
|
-
import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
|
|
7
5
|
import { DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedWithdrawCollateralIntent } from "./delayed-intents.js";
|
|
8
|
-
import { IGearboxError } from "./errors.js";
|
|
9
|
-
import { ChainScopedFilter, FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
|
|
10
|
-
import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
|
|
11
6
|
import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
|
|
12
7
|
import { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
|
|
13
8
|
import { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdapterCallOutsideBracketError, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, InvalidTransactionValueError, MalformedBracketError, MalformedBracketKind, MalformedPreviewError, NonAdapterCallInBracketError, OpenStrategyPositionPreview, OperationPreview, OperationPreviewError, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError, asEstimated } from "./previews.js";
|
|
14
9
|
import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
10
|
+
import { AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition } from "./analytics.js";
|
|
11
|
+
import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema } from "./analytics.schema.js";
|
|
12
|
+
import { CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, GridSampling, OpportunityChartMetric, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PoolOpportunityChartMetric, PoolPositionChartMetric, PositionChartMetric, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, StrategyOpportunityChartMetric, StrategyPositionChartMetric } from "./charts.js";
|
|
13
|
+
import { chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, poolOpportunityChartMetricSchema, poolPositionChartMetricSchema, strategyOpportunityChartMetricSchema, strategyPositionChartMetricSchema } from "./charts.schema.js";
|
|
14
|
+
import { CompareTag, CompareTolerance, ToleranceCompareTag, backendPreferred, compareTagOf, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
15
|
+
import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
|
|
16
|
+
import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
|
|
15
17
|
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
16
18
|
import { Notice, NoticeKind, NoticeSubject } from "./notices.js";
|
|
17
19
|
import { noticeKindSchema, noticeSchema } from "./notices.schema.js";
|
|
@@ -23,4 +25,4 @@ import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourc
|
|
|
23
25
|
import { SDKError, SDKResult, SDKReturn, SafeValue, isSDKError, safeValue, sdkErr, sdkOk } from "./result.js";
|
|
24
26
|
import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
|
|
25
27
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
26
|
-
export { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdapterCallOutsideBracketError, AdjustStrategyPositionPreview, Amount, ApyBreakdown, Asset, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InvalidTransactionValueError, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, MalformedBracketError, MalformedBracketKind, MalformedPreviewError, NonAdapterCallInBracketError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError, WithdrawalOutputAmount, amountSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, isSDKError, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, withdrawalOutputAmountSchema };
|
|
28
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdapterCallOutsideBracketError, AdjustStrategyPositionPreview, Amount, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InvalidTransactionValueError, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, MalformedBracketError, MalformedBracketKind, MalformedPreviewError, NonAdapterCallInBracketError, Notice, NoticeKind, NoticeSubject, OpenStrategyPositionPreview, OperationPreview, OperationPreviewError, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError, WithdrawalOutputAmount, amountSchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, instantReceivedAssetSchema, isFilterSet, isSDKError, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, withdrawalOutputAmountSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Amount, AssetType, Bps, ChainId, Leverage, Timestamp, Token, UnderlyingToken } from "./primitives.js";
|
|
2
|
-
import { Curator } from "./curators.js";
|
|
3
2
|
import { ChainScopedFilter, Filterable } from "./filters.js";
|
|
3
|
+
import { Curator } from "./curators.js";
|
|
4
4
|
import { Address } from "viem";
|
|
5
5
|
//#region src/model/opportunities.d.ts
|
|
6
6
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, UnderlyingToken } from "./primitives.js";
|
|
2
|
-
import { Curator } from "./curators.js";
|
|
3
|
-
import { DelayedIntent } from "./delayed-intents.js";
|
|
4
2
|
import { IGearboxError } from "./errors.js";
|
|
5
3
|
import { UnpriceableTokenError } from "../onchain/market/oracle/errors.js";
|
|
4
|
+
import { Curator } from "./curators.js";
|
|
5
|
+
import { DelayedIntent } from "./delayed-intents.js";
|
|
6
6
|
import { BorrowRateBreakdown } from "./positions.js";
|
|
7
7
|
import { Address, Hex } from "viem";
|
|
8
8
|
//#region src/model/previews.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILogger } from "../onchain/types/logger.js";
|
|
2
2
|
import { ChainId } from "../model/primitives.js";
|
|
3
|
-
import { ChartBundle, ChartMetric, ChartRange } from "../model/charts.js";
|
|
4
3
|
import { ChainScopedFilter } from "../model/filters.js";
|
|
4
|
+
import { ChartBundle, ChartMetric, ChartRange } from "../model/charts.js";
|
|
5
5
|
import { DataResponse } from "../model/response.js";
|
|
6
6
|
import { GearboxAPIOptions } from "./types.js";
|
|
7
7
|
import { z } from "zod/v4";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ChainId } from "../model/primitives.js";
|
|
2
2
|
import { GearboxAPIOptions } from "./types.js";
|
|
3
|
+
import { OffchainAnalytics } from "./analytics/OffchainAnalytics.js";
|
|
4
|
+
import "./analytics/index.js";
|
|
3
5
|
import { OffchainNotices } from "./notices/OffchainNotices.js";
|
|
4
6
|
import "./notices/index.js";
|
|
5
7
|
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
@@ -29,6 +31,8 @@ declare class GearboxAPI {
|
|
|
29
31
|
* Chains every read of this client is scoped to.
|
|
30
32
|
**/
|
|
31
33
|
readonly chainIds: readonly ChainId[];
|
|
34
|
+
/** Protocol-wide, backend-only analytics. */
|
|
35
|
+
readonly analytics: OffchainAnalytics;
|
|
32
36
|
/**
|
|
33
37
|
* Namespace for pool and strategy opportunities.
|
|
34
38
|
**/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GearboxAPIOptions } from "../types.js";
|
|
2
|
+
import { IOffchainAnalytics } from "./types.js";
|
|
3
|
+
import { OffchainAnalyticsPositions } from "./OffchainAnalyticsPositions.js";
|
|
4
|
+
//#region src/offchain/analytics/OffchainAnalytics.d.ts
|
|
5
|
+
/** Backend-only protocol analytics, grouped by subject. */
|
|
6
|
+
declare class OffchainAnalytics implements IOffchainAnalytics {
|
|
7
|
+
readonly positions: OffchainAnalyticsPositions;
|
|
8
|
+
constructor(options: GearboxAPIOptions);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OffchainAnalytics };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AnalyticsPositionListOptions, AnalyticsPositionPage } from "../../model/analytics.js";
|
|
2
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
|
+
import { GearboxAPIOptions } from "../types.js";
|
|
4
|
+
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
5
|
+
import { IOffchainAnalyticsPositions } from "./types.js";
|
|
6
|
+
//#region src/offchain/analytics/OffchainAnalyticsPositions.d.ts
|
|
7
|
+
/** Backend client for protocol-wide position analytics. */
|
|
8
|
+
declare class OffchainAnalyticsPositions extends AbstractOffchainNamespace implements IOffchainAnalyticsPositions {
|
|
9
|
+
constructor(options: GearboxAPIOptions);
|
|
10
|
+
/** {@inheritDoc IOffchainAnalyticsPositions.list} */
|
|
11
|
+
list(options?: AnalyticsPositionListOptions): Promise<DataResponse<AnalyticsPositionPage>>;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { OffchainAnalyticsPositions };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IOffchainAnalytics, IOffchainAnalyticsPositions } from "./types.js";
|
|
2
|
+
import { OffchainAnalyticsPositions } from "./OffchainAnalyticsPositions.js";
|
|
3
|
+
import { OffchainAnalytics } from "./OffchainAnalytics.js";
|
|
4
|
+
export { IOffchainAnalytics, IOffchainAnalyticsPositions, OffchainAnalytics, OffchainAnalyticsPositions };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnalyticsPositionListOptions, AnalyticsPositionPage } from "../../model/analytics.js";
|
|
2
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
|
+
//#region src/offchain/analytics/types.d.ts
|
|
4
|
+
/** Protocol-wide position reads served by the backend. */
|
|
5
|
+
interface IOffchainAnalyticsPositions {
|
|
6
|
+
/**
|
|
7
|
+
* Every current position in the protocol, with its owning borrower, after
|
|
8
|
+
* applying the requested filter, ordering and pagination.
|
|
9
|
+
**/
|
|
10
|
+
list(options?: AnalyticsPositionListOptions): Promise<DataResponse<AnalyticsPositionPage>>;
|
|
11
|
+
}
|
|
12
|
+
/** Backend-only protocol analytics, grouped by subject. */
|
|
13
|
+
interface IOffchainAnalytics {
|
|
14
|
+
readonly positions: IOffchainAnalyticsPositions;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { IOffchainAnalytics, IOffchainAnalyticsPositions };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { GearboxAPIOptions } from "./types.js";
|
|
2
2
|
import { AbstractOffchainNamespace, OffchainGetRequest, OffchainQuery } from "./AbstractOffchainNamespace.js";
|
|
3
|
+
import { IOffchainAnalytics, IOffchainAnalyticsPositions } from "./analytics/types.js";
|
|
4
|
+
import { OffchainAnalyticsPositions } from "./analytics/OffchainAnalyticsPositions.js";
|
|
5
|
+
import { OffchainAnalytics } from "./analytics/OffchainAnalytics.js";
|
|
6
|
+
import "./analytics/index.js";
|
|
3
7
|
import { OffchainNotices } from "./notices/OffchainNotices.js";
|
|
4
8
|
import "./notices/index.js";
|
|
5
9
|
import { IOffchainOpportunities, OpportunityChartMetricFor } from "./opportunities/types.js";
|
|
@@ -20,4 +24,4 @@ import { backendMessage } from "./errors/backendMessage.js";
|
|
|
20
24
|
import { ErrorCause, errorCause } from "./errors/errorCause.js";
|
|
21
25
|
import { readResponseBody } from "./errors/readResponseBody.js";
|
|
22
26
|
import "./errors/index.js";
|
|
23
|
-
export { AbstractOffchainNamespace, ErrorCause, GearboxAPI, GearboxAPIOptions, IOffchainOpportunities, IOffchainPositions, OffchainGetRequest, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainQuery, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainTransportErrorParams, OffchainValidationError, OpportunityChartMetricFor, PositionChartMetricFor, backendMessage, errorCause, readResponseBody };
|
|
27
|
+
export { AbstractOffchainNamespace, ErrorCause, GearboxAPI, GearboxAPIOptions, IOffchainAnalytics, IOffchainAnalyticsPositions, IOffchainOpportunities, IOffchainPositions, OffchainAnalytics, OffchainAnalyticsPositions, OffchainGetRequest, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainQuery, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainTransportErrorParams, OffchainValidationError, OpportunityChartMetricFor, PositionChartMetricFor, backendMessage, errorCause, readResponseBody };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange } from "../../model/charts.js";
|
|
2
1
|
import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
2
|
+
import { ChartBundle, ChartRange } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { GearboxAPIOptions } from "../types.js";
|
|
5
5
|
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
2
1
|
import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
2
|
+
import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
//#region src/offchain/opportunities/types.d.ts
|
|
5
5
|
type OpportunityChartMetricFor<K extends OpportunityKey> = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange } from "../../model/charts.js";
|
|
2
1
|
import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
|
|
2
|
+
import { ChartBundle, ChartRange } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
|
|
5
5
|
import { GearboxAPIOptions } from "../types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
2
1
|
import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
|
|
2
|
+
import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
|
|
3
3
|
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
|
|
5
5
|
import { Address } from "viem";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChainId } from "../model/primitives.js";
|
|
2
|
+
import "../model/index.js";
|
|
3
|
+
import { BaseError } from "viem";
|
|
4
|
+
//#region src/rewards/errors.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when none of Merkl's domains answered for a chain.
|
|
7
|
+
*
|
|
8
|
+
* Everything a reader needs is in the message: this error travels to consumers
|
|
9
|
+
* inside a chain's {@link ChainFailed} metadata, where it is typed `unknown`
|
|
10
|
+
* and may be serialised by something that turns an arbitrary object into `{}`.
|
|
11
|
+
*/
|
|
12
|
+
declare class MerklRequestFailedError extends BaseError {
|
|
13
|
+
name: string;
|
|
14
|
+
readonly chainId: ChainId;
|
|
15
|
+
constructor(chainId: ChainId, path: string, attempts: ReadonlyArray<[domain: string, cause: unknown]>);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { MerklRequestFailedError };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
|
|
5
|
-
import { GetPointsByPoolProps, GetTotalTokensOnProtocolProps, PoolPointsAPI, PoolPointsBase, getKeyForPoolPointsInfo } from "./rewards/extra-apy.js";
|
|
6
|
-
import "./rewards/index.js";
|
|
7
|
-
export { Apy, ApyDetails, DataResult, DebtReward, ExternalApy, ExtraCollateralAPY, ExtraCollateralPointsInfo, FarmInfo, GearAPY, GearAPYDetails, GetMerklRewardsProps, GetPointsByPoolProps, GetTotalTokensOnProtocolProps, MerklReward, MerklRewardsSdk, Output, PointsInfo, PointsReward, PoolExtraApy, PoolOutputDetails, PoolPointsAPI, PoolPointsBase, PoolPointsInfo, TokenOutputDetails, getKeyForPoolPointsInfo, getMerklRewards };
|
|
1
|
+
import { MerklRequestFailedError } from "./errors.js";
|
|
2
|
+
import { MerklReward, MerklRewardsSdk, toMerklRewards } from "./toMerklRewards.js";
|
|
3
|
+
import { GetMerklRewardsMultichainProps, getMerklRewardsMultichain } from "./multichain.js";
|
|
4
|
+
export { GetMerklRewardsMultichainProps, MerklRequestFailedError, MerklReward, MerklRewardsSdk, getMerklRewardsMultichain, toMerklRewards };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ChainId } from "../model/primitives.js";
|
|
2
|
+
import "../model/index.js";
|
|
3
|
+
import { Address } from "viem";
|
|
4
|
+
//#region src/rewards/merkl-api.d.ts
|
|
5
|
+
interface MerkleXYZUserRewardsV4 {
|
|
6
|
+
chain: MerkleXYZChain;
|
|
7
|
+
rewards: Array<{
|
|
8
|
+
root: Address;
|
|
9
|
+
recipient: Address;
|
|
10
|
+
amount: string;
|
|
11
|
+
claimed: string;
|
|
12
|
+
pending: string;
|
|
13
|
+
proofs: Array<Address>;
|
|
14
|
+
token: {
|
|
15
|
+
address: Address;
|
|
16
|
+
chainId: number;
|
|
17
|
+
symbol: string;
|
|
18
|
+
decimals: number;
|
|
19
|
+
/**
|
|
20
|
+
* USD price of one whole token. Optional because Merkl omits the key
|
|
21
|
+
* outright for the tokens it does not price — points and the like —
|
|
22
|
+
* rather than sending a null.
|
|
23
|
+
*/
|
|
24
|
+
price?: number;
|
|
25
|
+
};
|
|
26
|
+
breakdowns: Array<{
|
|
27
|
+
reason: string;
|
|
28
|
+
amount: string;
|
|
29
|
+
claimed: string;
|
|
30
|
+
pending: string;
|
|
31
|
+
campaignId: Address;
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
type MerkleXYZUserRewardsV4Response = Array<MerkleXYZUserRewardsV4>;
|
|
36
|
+
interface MerkleXYZChain {
|
|
37
|
+
id: number;
|
|
38
|
+
name: string;
|
|
39
|
+
icon: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Merkl's own host and the Angle mirror, tried in this order.
|
|
43
|
+
*/
|
|
44
|
+
declare const MERKL_DOMAINS: readonly ["https://api.merkl.xyz", "https://api-merkl.angle.money"];
|
|
45
|
+
declare const MERKL_API_KEY_HEADER = "X-API-Key";
|
|
46
|
+
interface FetchMerklUserRewardsProps {
|
|
47
|
+
chainId: ChainId;
|
|
48
|
+
/** Checksummed by the caller — Merkl keys its answer on the exact string. */
|
|
49
|
+
user: Address;
|
|
50
|
+
/** Raises Merkl's rate limit; the keyless path answers too. */
|
|
51
|
+
apiKey?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The wallet's raw Merkl rewards on one chain.
|
|
55
|
+
*
|
|
56
|
+
* Rejects with {@link MerklRequestFailedError} when neither domain answers, so
|
|
57
|
+
* a caller can tell an unreachable Merkl from a wallet with nothing to claim.
|
|
58
|
+
* A non-2xx counts as no answer and moves to the next domain: it carries no
|
|
59
|
+
* rewards either way, and treating it as success would report emptiness that
|
|
60
|
+
* was never established.
|
|
61
|
+
*/
|
|
62
|
+
declare function fetchMerklUserRewards({ chainId, user, apiKey }: FetchMerklUserRewardsProps): Promise<MerkleXYZUserRewardsV4Response>;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { FetchMerklUserRewardsProps, MERKL_API_KEY_HEADER, MERKL_DOMAINS, MerkleXYZUserRewardsV4, MerkleXYZUserRewardsV4Response, fetchMerklUserRewards };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ChainId } from "../model/primitives.js";
|
|
2
|
+
import { DataResponse } from "../model/response.js";
|
|
3
|
+
import "../model/index.js";
|
|
4
|
+
import { PluginsMap } from "../onchain/plugins/types.js";
|
|
5
|
+
import { MultichainSDK } from "../onchain/MultichainSDK.js";
|
|
6
|
+
import "../onchain/index.js";
|
|
7
|
+
import { MerklReward } from "./toMerklRewards.js";
|
|
8
|
+
import { Address } from "viem";
|
|
9
|
+
//#region src/rewards/multichain.d.ts
|
|
10
|
+
interface GetMerklRewardsMultichainProps<Plugins extends PluginsMap = {}> {
|
|
11
|
+
/** Handle whose chains are asked. */
|
|
12
|
+
sdk: MultichainSDK<Plugins>;
|
|
13
|
+
/** Wallet whose claimable rewards to list. */
|
|
14
|
+
wallet: Address;
|
|
15
|
+
/**
|
|
16
|
+
* Chains to ask, defaulting to every chain the handle carries.
|
|
17
|
+
**/
|
|
18
|
+
chainIds?: ChainId[];
|
|
19
|
+
/** Raises Merkl's rate limit; the keyless path answers too. */
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Every claimable Merkl reward a wallet holds, across the chains the handle
|
|
24
|
+
* carries.
|
|
25
|
+
*
|
|
26
|
+
* Answers the read model's own envelope, so a chain that could not be reached
|
|
27
|
+
* is `status: "error"` in `meta.chains` while a chain with nothing to claim is
|
|
28
|
+
* a `"success"` that contributed no rows. That distinction is the point: the
|
|
29
|
+
* single-chain read this replaces resolved empty either way.
|
|
30
|
+
**/
|
|
31
|
+
declare function getMerklRewardsMultichain<const Plugins extends PluginsMap = {}>({ sdk, wallet, chainIds, apiKey }: GetMerklRewardsMultichainProps<Plugins>): Promise<DataResponse<MerklReward[]>>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { GetMerklRewardsMultichainProps, getMerklRewardsMultichain };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ChainId, Token, TokenAmount } from "../model/primitives.js";
|
|
2
|
+
import "../model/index.js";
|
|
3
|
+
import { OnchainSDK } from "../onchain/OnchainSDK.js";
|
|
4
|
+
import "../onchain/index.js";
|
|
5
|
+
import { MerkleXYZUserRewardsV4Response } from "./merkl-api.js";
|
|
6
|
+
import { Address } from "viem";
|
|
7
|
+
//#region src/rewards/toMerklRewards.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* One claimable Merkl liquidity-mining reward, denominated and priced.
|
|
10
|
+
*
|
|
11
|
+
* Both tokens arrive resolved, so a consumer neither looks one up nor
|
|
12
|
+
* reassembles one out of the loose fields Merkl sends.
|
|
13
|
+
*/
|
|
14
|
+
interface MerklReward {
|
|
15
|
+
readonly chainId: ChainId;
|
|
16
|
+
/** Market pool whose depositors the campaign rewards. */
|
|
17
|
+
readonly pool: Address;
|
|
18
|
+
/** That pool's share token — what the campaign is keyed on. */
|
|
19
|
+
readonly poolToken: Token;
|
|
20
|
+
/**
|
|
21
|
+
* The incentive token being handed out, how much of it is claimable
|
|
22
|
+
* (distributed minus already claimed, always > 0) and what that is worth.
|
|
23
|
+
*
|
|
24
|
+
* Priced by Merkl, not by the market oracles: a campaign's incentive token
|
|
25
|
+
* is rarely collateral in the pool it incentivises, so the oracles usually
|
|
26
|
+
* do not know it — GEAR, which most Gearbox campaigns pay in, among them.
|
|
27
|
+
* `valueUsd` is `null` for a token Merkl does not price either.
|
|
28
|
+
*/
|
|
29
|
+
readonly amount: TokenAmount;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What the mapping needs off a chain's SDK: which chain the rows belong to,
|
|
33
|
+
* the pools a campaign can be keyed on, and the registry that names their
|
|
34
|
+
* tokens. Nothing else, and nothing asynchronous.
|
|
35
|
+
*/
|
|
36
|
+
type MerklRewardsSdk = Pick<OnchainSDK, "chainId" | "marketRegister" | "tokensMeta">;
|
|
37
|
+
/**
|
|
38
|
+
* Merkl's answer for one chain, turned into rows of the read model.
|
|
39
|
+
*/
|
|
40
|
+
declare function toMerklRewards(sdk: MerklRewardsSdk, response: MerkleXYZUserRewardsV4Response): MerklReward[];
|
|
41
|
+
//#endregion
|
|
42
|
+
export { MerklReward, MerklRewardsSdk, toMerklRewards };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { NetworkType } from "../onchain/chain/chains.js";
|
|
2
2
|
import "../onchain/index.js";
|
|
3
|
+
import { IAnalyticsByMode } from "./analytics/types.js";
|
|
3
4
|
import { ILiquidationsByMode } from "./liquidations/types.js";
|
|
4
5
|
import { IOpportunities } from "./opportunities/types.js";
|
|
5
6
|
import { IPositions } from "./positions/types.js";
|
|
6
7
|
import { IPreviewByMode } from "./preview/types.js";
|
|
7
8
|
import { GearboxSDKOptions, IGearboxSDK, INoticesByMode, Mode, OffchainByMode, OnchainByMode } from "./types.js";
|
|
9
|
+
import "./analytics/index.js";
|
|
8
10
|
import "./liquidations/index.js";
|
|
9
11
|
import "./opportunities/index.js";
|
|
10
12
|
import "./positions/index.js";
|
|
@@ -44,6 +46,8 @@ declare class GearboxSDK<const M extends Mode = Mode> implements IGearboxSDK<M>
|
|
|
44
46
|
* Chains this instance covers, which every read is scoped to.
|
|
45
47
|
**/
|
|
46
48
|
readonly networks: readonly NetworkType[];
|
|
49
|
+
/** Protocol-wide analytics. Undefined in `onchain` mode. */
|
|
50
|
+
readonly analytics: IAnalyticsByMode[M];
|
|
47
51
|
/**
|
|
48
52
|
* Namespace for pool and strategy opportunities.
|
|
49
53
|
**/
|