@gearbox-protocol/sdk 16.0.0-next.52 → 16.0.0-next.54
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 +1 -1
- package/dist/cjs/dev/mode-parity/comparePositions.js +1 -1
- package/dist/cjs/model/analytics.js +1 -0
- 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/analytics/types.js +1 -0
- package/dist/cjs/offchain/index.js +5 -0
- package/dist/cjs/onchain/market/credit/CreditSuite.js +2 -2
- 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/analytics/types.js +1 -0
- package/dist/cjs/sdk/index.js +3 -0
- package/dist/esm/dev/mode-parity/compareOpportunities.js +1 -1
- package/dist/esm/dev/mode-parity/comparePositions.js +1 -1
- package/dist/esm/model/analytics.js +1 -0
- 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/analytics/types.js +1 -0
- package/dist/esm/offchain/index.js +4 -1
- package/dist/esm/onchain/market/credit/CreditSuite.js +3 -3
- 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/analytics/types.js +1 -0
- package/dist/esm/sdk/index.js +3 -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/onchain/market/credit/CreditSuite.d.ts +1 -2
- 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 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ZodAddress } from "../onchain/utils/zod.js";
|
|
2
|
-
import { offchainOnly, tolerance } from "./compare.schema.js";
|
|
3
|
-
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
4
|
-
import { curatorSchema } from "./curators.schema.js";
|
|
5
2
|
import { isFilterSet } from "./filters.js";
|
|
6
3
|
import { booleanParamSchema, encodeFlag, filterable } from "./filters.schema.js";
|
|
4
|
+
import { offchainOnly, tolerance } from "./compare.schema.js";
|
|
5
|
+
import { curatorSchema } from "./curators.schema.js";
|
|
6
|
+
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
7
7
|
import { z } from "zod/v4";
|
|
8
8
|
//#region src/model/opportunities.schema.ts
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ZodAddress, ZodBigInt, ZodHex } from "../onchain/utils/zod.js";
|
|
2
|
-
import { backendPreferred, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
3
|
-
import { assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
4
2
|
import { isFilterSet } from "./filters.js";
|
|
5
3
|
import { booleanParamSchema, encodeFlag, filterable } from "./filters.schema.js";
|
|
4
|
+
import { backendPreferred, offchainOnly, onchainOnly, tolerance } from "./compare.schema.js";
|
|
5
|
+
import { assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, underlyingTokenSchema } from "./primitives.schema.js";
|
|
6
6
|
import { delayedReceivedAssetSchema, liquidationPositionSchema } from "./liquidations.schema.js";
|
|
7
7
|
import { apyBreakdownSchema, pointsProgramSchema } from "./opportunities.schema.js";
|
|
8
8
|
import { z } from "zod/v4";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { OffchainAnalytics } from "./analytics/OffchainAnalytics.js";
|
|
2
|
+
import "./analytics/index.js";
|
|
1
3
|
import { OffchainNotices } from "./notices/OffchainNotices.js";
|
|
2
4
|
import "./notices/index.js";
|
|
3
5
|
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
@@ -27,6 +29,8 @@ var GearboxAPI = class {
|
|
|
27
29
|
* Chains every read of this client is scoped to.
|
|
28
30
|
**/
|
|
29
31
|
chainIds;
|
|
32
|
+
/** Protocol-wide, backend-only analytics. */
|
|
33
|
+
analytics;
|
|
30
34
|
/**
|
|
31
35
|
* Namespace for pool and strategy opportunities.
|
|
32
36
|
**/
|
|
@@ -41,6 +45,7 @@ var GearboxAPI = class {
|
|
|
41
45
|
notices;
|
|
42
46
|
constructor(options) {
|
|
43
47
|
this.chainIds = [...options.chainIds];
|
|
48
|
+
this.analytics = new OffchainAnalytics(options);
|
|
44
49
|
this.opportunities = new OffchainOpportunities(options);
|
|
45
50
|
this.positions = new OffchainPositions(options);
|
|
46
51
|
this.notices = new OffchainNotices(options);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OffchainAnalyticsPositions } from "./OffchainAnalyticsPositions.js";
|
|
2
|
+
//#region src/offchain/analytics/OffchainAnalytics.ts
|
|
3
|
+
/** Backend-only protocol analytics, grouped by subject. */
|
|
4
|
+
var OffchainAnalytics = class {
|
|
5
|
+
positions;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.positions = new OffchainAnalyticsPositions(options);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OffchainAnalytics };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { analyticsPositionListQuerySchema, analyticsPositionPageSchema } from "../../model/analytics.schema.js";
|
|
2
|
+
import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
|
+
//#region src/offchain/analytics/OffchainAnalyticsPositions.ts
|
|
5
|
+
/** Backend client for protocol-wide position analytics. */
|
|
6
|
+
var OffchainAnalyticsPositions = class extends AbstractOffchainNamespace {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super("OffchainAnalyticsPositions", options);
|
|
9
|
+
}
|
|
10
|
+
/** {@inheritDoc IOffchainAnalyticsPositions.list} */
|
|
11
|
+
async list(options) {
|
|
12
|
+
return this.get({
|
|
13
|
+
path: "/v2/analytics/positions",
|
|
14
|
+
query: z.encode(analyticsPositionListQuerySchema, {
|
|
15
|
+
...options,
|
|
16
|
+
chainIds: this.scopedChainIds(options)
|
|
17
|
+
}),
|
|
18
|
+
schema: analyticsPositionPageSchema
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { OffchainAnalyticsPositions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,6 +10,9 @@ import { OffchainValidationError } from "./errors/OffchainValidationError.js";
|
|
|
10
10
|
import { readResponseBody } from "./errors/readResponseBody.js";
|
|
11
11
|
import "./errors/index.js";
|
|
12
12
|
import { AbstractOffchainNamespace } from "./AbstractOffchainNamespace.js";
|
|
13
|
+
import { OffchainAnalyticsPositions } from "./analytics/OffchainAnalyticsPositions.js";
|
|
14
|
+
import { OffchainAnalytics } from "./analytics/OffchainAnalytics.js";
|
|
15
|
+
import "./analytics/index.js";
|
|
13
16
|
import { OffchainNotices } from "./notices/OffchainNotices.js";
|
|
14
17
|
import "./notices/index.js";
|
|
15
18
|
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
@@ -18,4 +21,4 @@ import { OffchainPositions } from "./positions/OffchainPositions.js";
|
|
|
18
21
|
import "./positions/index.js";
|
|
19
22
|
import { GearboxAPI } from "./GearboxAPI.js";
|
|
20
23
|
import "./types.js";
|
|
21
|
-
export { AbstractOffchainNamespace, GearboxAPI, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainValidationError, backendMessage, errorCause, readResponseBody };
|
|
24
|
+
export { AbstractOffchainNamespace, GearboxAPI, OffchainAnalytics, OffchainAnalyticsPositions, OffchainInvalidJsonError, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainNotices, OffchainOpportunities, OffchainPositions, OffchainRequestFailedError, OffchainStatusError, OffchainTransportError, OffchainValidationError, backendMessage, errorCause, readResponseBody };
|
|
@@ -8,7 +8,7 @@ import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
|
8
8
|
import "../../base/index.js";
|
|
9
9
|
import { calcBorrowApy, calcQuotaRate, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount } from "../math.js";
|
|
10
10
|
import { strategyName } from "../strategyName.js";
|
|
11
|
-
import { dominantCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
|
|
11
|
+
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
|
|
12
12
|
import createCreditConfigurator from "./createCreditConfigurator.js";
|
|
13
13
|
import createCreditFacade from "./createCreditFacade.js";
|
|
14
14
|
import createCreditManager from "./createCreditManager.js";
|
|
@@ -290,13 +290,13 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
292
|
* Describes this suite's leveraged strategy as the shared read model does,
|
|
293
|
-
* or `undefined` when
|
|
294
|
-
* {@link maxBorrowAmount} is at or below {@link MIN_STRATEGY_BORROW_AMOUNT}.
|
|
293
|
+
* or `undefined` when credit suite does not offer a strategy opportunity.
|
|
295
294
|
*/
|
|
296
295
|
strategyOpportunity() {
|
|
297
296
|
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
|
|
298
297
|
const collateral = this.strategyTargetCollateral;
|
|
299
298
|
if (!collateral) return;
|
|
299
|
+
if (!isStrategyCollateral(this.#strategyCollateralProps(collateral), true)) return;
|
|
300
300
|
const { market, creditManager: cm } = this;
|
|
301
301
|
const { pool } = market.pool;
|
|
302
302
|
const oracle = market.priceOracle;
|
|
@@ -6,6 +6,8 @@ import "../offchain/index.js";
|
|
|
6
6
|
import { assertSameChains } from "./errors/assertSameChains.js";
|
|
7
7
|
import { MissingSourceError } from "./errors/MissingSourceError.js";
|
|
8
8
|
import "./errors/index.js";
|
|
9
|
+
import { AnalyticsNamespace } from "./analytics/AnalyticsNamespace.js";
|
|
10
|
+
import "./analytics/index.js";
|
|
9
11
|
import { LiquidationsNamespace } from "./liquidations/LiquidationsNamespace.js";
|
|
10
12
|
import "./liquidations/index.js";
|
|
11
13
|
import "./utils/mergeChains.js";
|
|
@@ -50,6 +52,8 @@ var GearboxSDK = class {
|
|
|
50
52
|
* Chains this instance covers, which every read is scoped to.
|
|
51
53
|
**/
|
|
52
54
|
networks;
|
|
55
|
+
/** Protocol-wide analytics. Undefined in `onchain` mode. */
|
|
56
|
+
analytics;
|
|
53
57
|
/**
|
|
54
58
|
* Namespace for pool and strategy opportunities.
|
|
55
59
|
**/
|
|
@@ -130,6 +134,7 @@ var GearboxSDK = class {
|
|
|
130
134
|
ensureFresh: this.#onchain ? (chainIds) => this.#ensureFresh(chainIds) : void 0,
|
|
131
135
|
logger
|
|
132
136
|
};
|
|
137
|
+
this.analytics = this.#offchain ? new AnalyticsNamespace(this.#offchain) : void 0;
|
|
133
138
|
this.opportunities = new OpportunitiesNamespace(this.#onchain, this.#offchain, namespaceOptions);
|
|
134
139
|
this.positions = new PositionsNamespace(this.#onchain, this.#offchain, namespaceOptions);
|
|
135
140
|
this.liquidations = this.#onchain ? new LiquidationsNamespace(this.#onchain, namespaceOptions) : void 0;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/sdk/analytics/AnalyticsNamespace.ts
|
|
2
|
+
/** Backend-only protocol analytics exposed by {@link GearboxSDK}. */
|
|
3
|
+
var AnalyticsNamespace = class {
|
|
4
|
+
positions;
|
|
5
|
+
constructor(backend) {
|
|
6
|
+
this.positions = backend.analytics.positions;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { AnalyticsNamespace };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -8,6 +8,8 @@ import { NoSourceServedError } from "./errors/NoSourceServedError.js";
|
|
|
8
8
|
import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
|
|
9
9
|
import "./errors/index.js";
|
|
10
10
|
import { AbstractNamespace } from "./AbstractNamespace.js";
|
|
11
|
+
import { AnalyticsNamespace } from "./analytics/AnalyticsNamespace.js";
|
|
12
|
+
import "./analytics/index.js";
|
|
11
13
|
import { LiquidationsNamespace } from "./liquidations/LiquidationsNamespace.js";
|
|
12
14
|
import "./liquidations/index.js";
|
|
13
15
|
import { ExecuteApi } from "./execute/ExecuteApi.js";
|
|
@@ -26,4 +28,4 @@ import { PreviewNamespace } from "./preview/PreviewNamespace.js";
|
|
|
26
28
|
import "./preview/index.js";
|
|
27
29
|
import { DEFAULT_MAX_STATE_AGE, GearboxSDK } from "./GearboxSDK.js";
|
|
28
30
|
import "./types.js";
|
|
29
|
-
export { AbstractNamespace, AllSourcesFailedError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, IntentPreviewError, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, raise, refuse, toRefusalError, unexpectedFailure };
|
|
31
|
+
export { AbstractNamespace, AllSourcesFailedError, AnalyticsNamespace, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, IntentPreviewError, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, raise, refuse, toRefusalError, unexpectedFailure };
|
|
@@ -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";
|