@gearbox-protocol/sdk 14.12.0-next.71 → 14.12.0-next.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/history.js +25 -0
- package/dist/cjs/model/history.schema.js +45 -1
- package/dist/cjs/model/index.js +17 -3
- package/dist/cjs/model/positions.js +89 -0
- package/dist/cjs/model/positions.schema.js +28 -0
- package/dist/cjs/new-sdk/GearboxSDK.js +7 -0
- package/dist/cjs/new-sdk/index.js +3 -0
- package/dist/cjs/new-sdk/positions/PositionsNamespace.js +119 -0
- package/dist/cjs/new-sdk/positions/index.js +4 -0
- package/dist/cjs/new-sdk/positions/types.js +1 -0
- package/dist/cjs/offchain/GearboxAPI.js +9 -2
- package/dist/cjs/offchain/index.js +5 -2
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +3 -14
- package/dist/cjs/offchain/opportunities/index.js +0 -1
- package/dist/cjs/offchain/positions/OffchainPositions.js +69 -0
- package/dist/cjs/offchain/positions/index.js +3 -0
- package/dist/cjs/offchain/types.js +17 -0
- package/dist/cjs/sdk/MultichainSDK.js +7 -0
- package/dist/cjs/sdk/OnchainSDK.js +7 -0
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +84 -0
- package/dist/cjs/sdk/accounts/constants.js +12 -0
- package/dist/cjs/sdk/accounts/dominantCollateral.js +33 -0
- package/dist/cjs/sdk/accounts/index.js +4 -1
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +3 -10
- package/dist/cjs/sdk/accounts/liquidations/constants.js +2 -6
- package/dist/cjs/sdk/accounts/liquidations/index.js +2 -1
- package/dist/cjs/sdk/index.js +11 -1
- package/dist/cjs/sdk/market/MarketSuite.js +7 -1
- package/dist/cjs/sdk/market/credit/CreditSuite.js +10 -1
- package/dist/cjs/sdk/market/math.js +37 -0
- package/dist/cjs/sdk/opportunities/index.js +2 -0
- package/dist/cjs/sdk/pools/PoolService.js +37 -0
- package/dist/cjs/sdk/positions/MultichainPositionsService.js +48 -0
- package/dist/cjs/sdk/positions/PositionsService.js +39 -0
- package/dist/cjs/sdk/positions/index.js +6 -0
- package/dist/cjs/sdk/positions/types.js +1 -0
- package/dist/esm/model/history.js +24 -1
- package/dist/esm/model/history.schema.js +42 -2
- package/dist/esm/model/index.js +6 -6
- package/dist/esm/model/positions.js +85 -1
- package/dist/esm/model/positions.schema.js +26 -1
- package/dist/esm/new-sdk/GearboxSDK.js +7 -0
- package/dist/esm/new-sdk/index.js +3 -1
- package/dist/esm/new-sdk/positions/PositionsNamespace.js +118 -0
- package/dist/esm/new-sdk/positions/index.js +3 -0
- package/dist/esm/new-sdk/positions/types.js +1 -0
- package/dist/esm/offchain/GearboxAPI.js +9 -2
- package/dist/esm/offchain/index.js +5 -3
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +2 -12
- package/dist/esm/offchain/opportunities/index.js +2 -2
- package/dist/esm/offchain/positions/OffchainPositions.js +68 -0
- package/dist/esm/offchain/positions/index.js +2 -0
- package/dist/esm/offchain/types.js +17 -1
- package/dist/esm/sdk/MultichainSDK.js +7 -0
- package/dist/esm/sdk/OnchainSDK.js +7 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +84 -0
- package/dist/esm/sdk/accounts/constants.js +11 -0
- package/dist/esm/sdk/accounts/dominantCollateral.js +32 -0
- package/dist/esm/sdk/accounts/index.js +4 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +3 -10
- package/dist/esm/sdk/accounts/liquidations/constants.js +1 -5
- package/dist/esm/sdk/accounts/liquidations/index.js +2 -1
- package/dist/esm/sdk/index.js +8 -3
- package/dist/esm/sdk/market/MarketSuite.js +7 -1
- package/dist/esm/sdk/market/credit/CreditSuite.js +10 -1
- package/dist/esm/sdk/market/math.js +37 -2
- package/dist/esm/sdk/opportunities/index.js +2 -2
- package/dist/esm/sdk/pools/PoolService.js +37 -0
- package/dist/esm/sdk/positions/MultichainPositionsService.js +47 -0
- package/dist/esm/sdk/positions/PositionsService.js +38 -0
- package/dist/esm/sdk/positions/index.js +4 -0
- package/dist/esm/sdk/positions/types.js +1 -0
- package/dist/types/model/history.d.ts +50 -2
- package/dist/types/model/history.schema.d.ts +32 -3
- package/dist/types/model/index.d.ts +5 -5
- package/dist/types/model/positions.d.ts +100 -1
- package/dist/types/model/positions.schema.d.ts +29 -1
- package/dist/types/new-sdk/AbstractNamespace.d.ts +2 -2
- package/dist/types/new-sdk/GearboxSDK.d.ts +6 -0
- package/dist/types/new-sdk/index.d.ts +4 -1
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
- package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +62 -0
- package/dist/types/new-sdk/positions/index.d.ts +3 -0
- package/dist/types/new-sdk/positions/types.d.ts +62 -0
- package/dist/types/new-sdk/utils/history.d.ts +6 -2
- package/dist/types/offchain/GearboxAPI.d.ts +8 -2
- package/dist/types/offchain/index.d.ts +5 -3
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -9
- package/dist/types/offchain/opportunities/index.d.ts +2 -2
- package/dist/types/offchain/positions/OffchainPositions.d.ts +47 -0
- package/dist/types/offchain/positions/index.d.ts +2 -0
- package/dist/types/offchain/types.d.ts +12 -1
- package/dist/types/sdk/MultichainSDK.d.ts +6 -0
- package/dist/types/sdk/OnchainSDK.d.ts +6 -0
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +7 -1
- package/dist/types/sdk/accounts/constants.d.ts +11 -0
- package/dist/types/sdk/accounts/dominantCollateral.d.ts +22 -0
- package/dist/types/sdk/accounts/index.d.ts +5 -3
- package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +2 -2
- package/dist/types/sdk/accounts/liquidations/constants.d.ts +1 -5
- package/dist/types/sdk/accounts/liquidations/index.d.ts +2 -1
- package/dist/types/sdk/accounts/liquidations/types.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +26 -1
- package/dist/types/sdk/base/TokensMeta.d.ts +1 -1
- package/dist/types/sdk/index.d.ts +11 -5
- package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +1 -1
- package/dist/types/sdk/market/MarketSuite.d.ts +5 -1
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +1 -1
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +8 -1
- package/dist/types/sdk/market/credit/types.d.ts +1 -1
- package/dist/types/sdk/market/math.d.ts +29 -1
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -2
- package/dist/types/sdk/market/oracle/types.d.ts +2 -2
- package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +1 -1
- package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +1 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +1 -1
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +1 -1
- package/dist/types/sdk/market/pool/types.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/types.d.ts +1 -1
- package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +2 -2
- package/dist/types/sdk/opportunities/index.d.ts +2 -2
- package/dist/types/sdk/pools/PoolService.d.ts +7 -1
- package/dist/types/sdk/pools/index.d.ts +2 -2
- package/dist/types/sdk/pools/types.d.ts +18 -1
- package/dist/types/sdk/positions/MultichainPositionsService.d.ts +33 -0
- package/dist/types/sdk/positions/PositionsService.d.ts +22 -0
- package/dist/types/sdk/positions/index.d.ts +4 -0
- package/dist/types/sdk/positions/types.d.ts +25 -0
- package/package.json +1 -1
|
@@ -22,5 +22,28 @@ const STRATEGY_HISTORY_METRICS = [
|
|
|
22
22
|
"collateralUsdPrice",
|
|
23
23
|
"underlyingUsdPrice"
|
|
24
24
|
];
|
|
25
|
+
/**
|
|
26
|
+
* Every {@link PoolPositionHistoryMetric}, for callers that enumerate them.
|
|
27
|
+
**/
|
|
28
|
+
const POOL_POSITION_HISTORY_METRICS = [
|
|
29
|
+
"depositApy",
|
|
30
|
+
"borrowApy",
|
|
31
|
+
"dieselRate",
|
|
32
|
+
"supplied",
|
|
33
|
+
"borrowed",
|
|
34
|
+
"availableLiquidity"
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Every {@link StrategyPositionHistoryMetric}, for callers that enumerate them.
|
|
38
|
+
**/
|
|
39
|
+
const STRATEGY_POSITION_HISTORY_METRICS = [
|
|
40
|
+
"netApy",
|
|
41
|
+
"borrowApy",
|
|
42
|
+
"collateralApy",
|
|
43
|
+
"tvl",
|
|
44
|
+
"collateralPrice",
|
|
45
|
+
"collateralUsdPrice",
|
|
46
|
+
"underlyingUsdPrice"
|
|
47
|
+
];
|
|
25
48
|
//#endregion
|
|
26
|
-
export { POOL_HISTORY_METRICS, STRATEGY_HISTORY_METRICS };
|
|
49
|
+
export { POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { timestampSchema } from "./primitives.schema.js";
|
|
2
2
|
import { opportunityKeySchema } from "./opportunities.schema.js";
|
|
3
|
+
import { positionKeySchema } from "./positions.schema.js";
|
|
3
4
|
import { z } from "zod/v4";
|
|
4
5
|
//#region src/model/history.schema.ts
|
|
5
6
|
/**
|
|
@@ -40,9 +41,40 @@ const strategyHistoryMetricSchema = z.union([
|
|
|
40
41
|
z.literal("underlyingUsdPrice")
|
|
41
42
|
]);
|
|
42
43
|
/**
|
|
44
|
+
* {@link PoolPositionHistoryMetric}
|
|
45
|
+
**/
|
|
46
|
+
const poolPositionHistoryMetricSchema = z.union([
|
|
47
|
+
z.literal("depositApy"),
|
|
48
|
+
z.literal("borrowApy"),
|
|
49
|
+
z.literal("dieselRate"),
|
|
50
|
+
z.literal("supplied"),
|
|
51
|
+
z.literal("borrowed"),
|
|
52
|
+
z.literal("availableLiquidity")
|
|
53
|
+
]);
|
|
54
|
+
/**
|
|
55
|
+
* {@link StrategyPositionHistoryMetric}
|
|
56
|
+
**/
|
|
57
|
+
const strategyPositionHistoryMetricSchema = z.union([
|
|
58
|
+
z.literal("netApy"),
|
|
59
|
+
z.literal("borrowApy"),
|
|
60
|
+
z.literal("collateralApy"),
|
|
61
|
+
z.literal("tvl"),
|
|
62
|
+
z.literal("collateralPrice"),
|
|
63
|
+
z.literal("collateralUsdPrice"),
|
|
64
|
+
z.literal("underlyingUsdPrice")
|
|
65
|
+
]);
|
|
66
|
+
/**
|
|
67
|
+
* {@link PositionHistoryMetric}
|
|
68
|
+
**/
|
|
69
|
+
const positionHistoryMetricSchema = z.union([poolPositionHistoryMetricSchema, strategyPositionHistoryMetricSchema]);
|
|
70
|
+
/**
|
|
43
71
|
* {@link HistoryMetric}
|
|
44
72
|
**/
|
|
45
|
-
const historyMetricSchema = z.union([
|
|
73
|
+
const historyMetricSchema = z.union([
|
|
74
|
+
poolHistoryMetricSchema,
|
|
75
|
+
strategyHistoryMetricSchema,
|
|
76
|
+
positionHistoryMetricSchema
|
|
77
|
+
]);
|
|
46
78
|
/**
|
|
47
79
|
* {@link HistoryPoint}
|
|
48
80
|
**/
|
|
@@ -72,5 +104,13 @@ const opportunityHistoryQuerySchema = z.object({
|
|
|
72
104
|
range: historyRangeSchema,
|
|
73
105
|
metric: historyMetricSchema
|
|
74
106
|
});
|
|
107
|
+
/**
|
|
108
|
+
* {@link PositionHistoryQuery}
|
|
109
|
+
**/
|
|
110
|
+
const positionHistoryQuerySchema = z.object({
|
|
111
|
+
position: positionKeySchema,
|
|
112
|
+
range: historyRangeSchema,
|
|
113
|
+
metric: positionHistoryMetricSchema
|
|
114
|
+
});
|
|
75
115
|
//#endregion
|
|
76
|
-
export { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, strategyHistoryMetricSchema };
|
|
116
|
+
export { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, poolPositionHistoryMetricSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, strategyHistoryMetricSchema, strategyPositionHistoryMetricSchema };
|
package/dist/esm/model/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { POOL_HISTORY_METRICS, STRATEGY_HISTORY_METRICS } from "./history.js";
|
|
1
|
+
import { POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS } from "./history.js";
|
|
2
2
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
|
|
3
3
|
import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
|
|
4
|
-
import { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, strategyHistoryMetricSchema } from "./history.schema.js";
|
|
5
|
-
import { matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
6
4
|
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
5
|
+
import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
6
|
+
import { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, poolPositionHistoryMetricSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, strategyHistoryMetricSchema, strategyPositionHistoryMetricSchema } from "./history.schema.js";
|
|
7
|
+
import { matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
7
8
|
import { matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
|
|
8
|
-
import "./positions.js";
|
|
9
|
-
import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
9
|
+
import { liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
|
|
10
10
|
import "./primitives.js";
|
|
11
|
-
export { POOL_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorSchema, delayedReceivedAssetSchema, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
|
|
11
|
+
export { POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorSchema, delayedReceivedAssetSchema, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
|
|
@@ -1 +1,85 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/model/positions.ts
|
|
2
|
+
/**
|
|
3
|
+
* Builds the canonical id of a pool position.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* poolPositionId(1, "0xda00...") // "1:pool:0xda00..."
|
|
8
|
+
* ```
|
|
9
|
+
**/
|
|
10
|
+
function poolPositionId(chainId, pool) {
|
|
11
|
+
return `${chainId}:pool:${pool.toLowerCase()}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Builds the canonical id of a strategy position. The credit account address
|
|
15
|
+
* identifies it on its own, the credit manager is not part of the id.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* strategyPositionId(1, "0x9c4c...") // "1:strategy:0x9c4c..."
|
|
20
|
+
* ```
|
|
21
|
+
**/
|
|
22
|
+
function strategyPositionId(chainId, creditAccount) {
|
|
23
|
+
return `${chainId}:strategy:${creditAccount.toLowerCase()}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Builds the canonical id of a liquidation position.
|
|
27
|
+
*
|
|
28
|
+
* The redeemer is the withdrawal's own contract and therefore identifies it,
|
|
29
|
+
* but compressor versions below 313 do not report one; those fall back to the
|
|
30
|
+
* source token plus the moment the withdrawal becomes claimable, which is what
|
|
31
|
+
* distinguishes two withdrawals of the same asset.
|
|
32
|
+
**/
|
|
33
|
+
function liquidationPositionId(chainId, position) {
|
|
34
|
+
const { redeemer, sourceToken, claimableAt } = position;
|
|
35
|
+
return `${chainId}:liquidation:${redeemer ? redeemer.toLowerCase() : `${sourceToken.address.toLowerCase()}:${claimableAt ?? "claimable"}`}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Canonical id of any position, dispatching on {@link Position.kind}.
|
|
39
|
+
**/
|
|
40
|
+
function positionId(position) {
|
|
41
|
+
switch (position.kind) {
|
|
42
|
+
case "pool": return poolPositionId(position.chainId, position.pool);
|
|
43
|
+
case "strategy": return strategyPositionId(position.chainId, position.creditAccount);
|
|
44
|
+
case "liquidation": return liquidationPositionId(position.chainId, position);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether a position satisfies every criterion of a filter.
|
|
49
|
+
*
|
|
50
|
+
* This is the single definition of what each criterion means: every source
|
|
51
|
+
* builds its rows first and runs them through here, so the chain and the
|
|
52
|
+
* backend cannot disagree on what a filter selects.
|
|
53
|
+
*
|
|
54
|
+
* A criterion that does not apply to a position's kind keeps the row rather
|
|
55
|
+
* than dropping it: `isZeroDebt` says nothing about a pool position, and
|
|
56
|
+
* `underlyingType` says nothing about a liquidation position, which is
|
|
57
|
+
* denominated in whatever its withdrawal pays out.
|
|
58
|
+
*
|
|
59
|
+
* @param position - Row to test.
|
|
60
|
+
* @param filter - Criteria to test against. An absent filter matches anything.
|
|
61
|
+
**/
|
|
62
|
+
function matchesPositionFilter(position, filter) {
|
|
63
|
+
if (!filter) return true;
|
|
64
|
+
if (filter.kind && position.kind !== filter.kind) return false;
|
|
65
|
+
if (filter.chainIds && !filter.chainIds.includes(position.chainId)) return false;
|
|
66
|
+
if (filter.isZeroDebt !== void 0 && position.kind === "strategy" && position.totalDebt.value === 0n !== filter.isZeroDebt) return false;
|
|
67
|
+
if (filter.underlyingType) {
|
|
68
|
+
const underlying = positionUnderlying(position);
|
|
69
|
+
if (underlying && underlying.assetType !== filter.underlyingType) return false;
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Token a position's headline amount is denominated in, or `undefined` for a
|
|
75
|
+
* kind that has no single underlying.
|
|
76
|
+
**/
|
|
77
|
+
function positionUnderlying(position) {
|
|
78
|
+
switch (position.kind) {
|
|
79
|
+
case "pool": return position.netValue.token;
|
|
80
|
+
case "strategy": return position.totalValue.token;
|
|
81
|
+
case "liquidation": return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId };
|
|
@@ -105,5 +105,30 @@ const positionFilterSchema = z.object({
|
|
|
105
105
|
chainIds: z.array(chainIdSchema).optional(),
|
|
106
106
|
underlyingType: assetTypeSchema.optional()
|
|
107
107
|
});
|
|
108
|
+
/**
|
|
109
|
+
* {@link PoolPositionKey}
|
|
110
|
+
**/
|
|
111
|
+
const poolPositionKeySchema = z.object({
|
|
112
|
+
chainId: chainIdSchema,
|
|
113
|
+
pool: ZodAddress(),
|
|
114
|
+
wallet: ZodAddress()
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* {@link StrategyPositionKey}
|
|
118
|
+
**/
|
|
119
|
+
const strategyPositionKeySchema = z.object({
|
|
120
|
+
chainId: chainIdSchema,
|
|
121
|
+
creditAccount: ZodAddress()
|
|
122
|
+
});
|
|
123
|
+
/**
|
|
124
|
+
* {@link PositionKey}
|
|
125
|
+
**/
|
|
126
|
+
const positionKeySchema = z.discriminatedUnion("kind", [z.object({
|
|
127
|
+
kind: z.literal("pool"),
|
|
128
|
+
...poolPositionKeySchema.shape
|
|
129
|
+
}), z.object({
|
|
130
|
+
kind: z.literal("strategy"),
|
|
131
|
+
...strategyPositionKeySchema.shape
|
|
132
|
+
})]);
|
|
108
133
|
//#endregion
|
|
109
|
-
export { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionSchema, tokenRewardsPnLSchema };
|
|
134
|
+
export { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema };
|
|
@@ -4,6 +4,8 @@ import { GearboxAPI } from "../offchain/GearboxAPI.js";
|
|
|
4
4
|
import "../offchain/index.js";
|
|
5
5
|
import { OpportunitiesNamespace } from "./opportunities/OpportunitiesNamespace.js";
|
|
6
6
|
import "./opportunities/index.js";
|
|
7
|
+
import { PositionsNamespace } from "./positions/PositionsNamespace.js";
|
|
8
|
+
import "./positions/index.js";
|
|
7
9
|
//#region src/new-sdk/GearboxSDK.ts
|
|
8
10
|
/**
|
|
9
11
|
* Combined entry point over both sources of Gearbox data: the chain and the
|
|
@@ -45,6 +47,10 @@ var GearboxSDK = class {
|
|
|
45
47
|
* Namespace for pool and strategy opportunities.
|
|
46
48
|
**/
|
|
47
49
|
opportunities;
|
|
50
|
+
/**
|
|
51
|
+
* Namespace for the positions a wallet holds.
|
|
52
|
+
**/
|
|
53
|
+
positions;
|
|
48
54
|
#attachOptions;
|
|
49
55
|
#onchain;
|
|
50
56
|
#offchain;
|
|
@@ -78,6 +84,7 @@ var GearboxSDK = class {
|
|
|
78
84
|
});
|
|
79
85
|
this.#attached = !this.#ownsOnchain;
|
|
80
86
|
this.opportunities = new OpportunitiesNamespace(this.#onchain, this.#offchain, logger);
|
|
87
|
+
this.positions = new PositionsNamespace(this.#onchain, this.#offchain, logger);
|
|
81
88
|
}
|
|
82
89
|
/**
|
|
83
90
|
* Attaches the on-chain SDK when this instance owns one.
|
|
@@ -2,6 +2,8 @@ import { AllSourcesFailedError } from "./types.js";
|
|
|
2
2
|
import { AbstractNamespace } from "./AbstractNamespace.js";
|
|
3
3
|
import { OpportunitiesNamespace } from "./opportunities/OpportunitiesNamespace.js";
|
|
4
4
|
import "./opportunities/index.js";
|
|
5
|
+
import { PositionsNamespace } from "./positions/PositionsNamespace.js";
|
|
6
|
+
import "./positions/index.js";
|
|
5
7
|
import { GearboxSDK } from "./GearboxSDK.js";
|
|
6
8
|
import "./utils/index.js";
|
|
7
|
-
export { AbstractNamespace, AllSourcesFailedError, GearboxSDK, OpportunitiesNamespace };
|
|
9
|
+
export { AbstractNamespace, AllSourcesFailedError, GearboxSDK, OpportunitiesNamespace, PositionsNamespace };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { positionId } from "../../model/positions.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
|
+
import { AbstractNamespace } from "../AbstractNamespace.js";
|
|
4
|
+
//#region src/new-sdk/positions/PositionsNamespace.ts
|
|
5
|
+
/**
|
|
6
|
+
* Fields the backend owns even when the chain also fills them.
|
|
7
|
+
*
|
|
8
|
+
* The yield and PnL groups are derived from a position's history and from
|
|
9
|
+
* incentive programs, neither of which the chain has. `targetCollateral` is
|
|
10
|
+
* there for a subtler reason: the read model defines it as the collateral the
|
|
11
|
+
* position was opened into, which only the backend can know, while the chain
|
|
12
|
+
* approximates it with the dominant collateral held right now.
|
|
13
|
+
**/
|
|
14
|
+
const OFFCHAIN_OWNED_FIELDS = /* @__PURE__ */ new Set([
|
|
15
|
+
"apy",
|
|
16
|
+
"netApy",
|
|
17
|
+
"pnl",
|
|
18
|
+
"targetCollateral"
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* The `positions` namespace of the combined SDK.
|
|
22
|
+
*
|
|
23
|
+
* A stateless router over the two sources, see {@link AbstractNamespace} for the
|
|
24
|
+
* routing itself. What is specific to positions is the reads below and the merge
|
|
25
|
+
* policy at the bottom of the class.
|
|
26
|
+
*
|
|
27
|
+
* The class implements the methods of every mode; {@link GearboxSDK} exposes it
|
|
28
|
+
* as its mode's slice of {@link PositionsByMode}, so calling a method the mode
|
|
29
|
+
* does not have is a compile error rather than a runtime one.
|
|
30
|
+
**/
|
|
31
|
+
var PositionsNamespace = class extends AbstractNamespace {
|
|
32
|
+
constructor(onchain, offchain, logger) {
|
|
33
|
+
super("Positions", onchain, offchain, logger);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* {@inheritDoc PositionsBase.list}
|
|
37
|
+
**/
|
|
38
|
+
async list(wallet, filter) {
|
|
39
|
+
return this.readList("list positions", async (sdk) => {
|
|
40
|
+
const { result, meta } = await sdk.positions.list({
|
|
41
|
+
wallet,
|
|
42
|
+
filter
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
value: result,
|
|
46
|
+
chains: meta
|
|
47
|
+
};
|
|
48
|
+
}, (api) => api.positions.list(wallet, filter));
|
|
49
|
+
}
|
|
50
|
+
history(key) {
|
|
51
|
+
return { chart: (metric, range) => this.#chart(key, metric, range) };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reads one chart of one position from the backend.
|
|
55
|
+
*
|
|
56
|
+
* The metric a caller may name is gated by the reader's type, so the kind of
|
|
57
|
+
* the key is not re-checked here.
|
|
58
|
+
**/
|
|
59
|
+
async #chart(key, metric, range) {
|
|
60
|
+
const { result, meta } = await this.readOffchain(`get ${metric} history`, (api) => api.positions.getHistory({
|
|
61
|
+
position: key,
|
|
62
|
+
range,
|
|
63
|
+
metric
|
|
64
|
+
}), {
|
|
65
|
+
metric,
|
|
66
|
+
points: [],
|
|
67
|
+
metadata: {}
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
data: result.points,
|
|
71
|
+
metadata: {
|
|
72
|
+
...result.metadata,
|
|
73
|
+
source: meta
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Merges the two versions of one position.
|
|
79
|
+
*
|
|
80
|
+
* The chain wins every field it fills; the backend fills the rest and owns
|
|
81
|
+
* {@link OFFCHAIN_OWNED_FIELDS}.
|
|
82
|
+
*
|
|
83
|
+
* The rule is onchain-first, field-wise, and never deeper than one level: a
|
|
84
|
+
* group like `totalValue` or `apy` is taken whole from one source, so a row
|
|
85
|
+
* never mixes an on-chain token amount with a backend dollar value derived
|
|
86
|
+
* from a different block.
|
|
87
|
+
**/
|
|
88
|
+
mergeOne(onchain, offchain) {
|
|
89
|
+
const merged = { ...onchain };
|
|
90
|
+
for (const [field, value] of Object.entries(offchain)) {
|
|
91
|
+
if (value === void 0) continue;
|
|
92
|
+
if (OFFCHAIN_OWNED_FIELDS.has(field) || merged[field] === void 0) merged[field] = value;
|
|
93
|
+
}
|
|
94
|
+
return merged;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Unions the two lists by canonical position id.
|
|
98
|
+
*
|
|
99
|
+
* Rows present in both are merged by {@link PositionsNamespace.mergeOne}.
|
|
100
|
+
* Rows only the backend knows are appended: a chain the SDK does not cover,
|
|
101
|
+
* or a market it has not loaded, must not hide a position the wallet actually
|
|
102
|
+
* holds.
|
|
103
|
+
**/
|
|
104
|
+
mergeList(onchain, offchain) {
|
|
105
|
+
const byId = /* @__PURE__ */ new Map();
|
|
106
|
+
for (const row of onchain) byId.set(positionId(row), row);
|
|
107
|
+
const extra = [];
|
|
108
|
+
for (const row of offchain) {
|
|
109
|
+
const id = positionId(row);
|
|
110
|
+
const existing = byId.get(id);
|
|
111
|
+
if (existing) byId.set(id, this.mergeOne(existing, row));
|
|
112
|
+
else extra.push(row);
|
|
113
|
+
}
|
|
114
|
+
return [...byId.values(), ...extra];
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
export { PositionsNamespace };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
2
2
|
import "./opportunities/index.js";
|
|
3
|
+
import { OffchainPositions } from "./positions/OffchainPositions.js";
|
|
4
|
+
import "./positions/index.js";
|
|
3
5
|
//#region src/offchain/GearboxAPI.ts
|
|
4
6
|
/**
|
|
5
7
|
* Client for the Gearbox backend, the off-chain source of the read model.
|
|
@@ -16,16 +18,21 @@ import "./opportunities/index.js";
|
|
|
16
18
|
* return those types directly, so there is no wire DTO layer here — only
|
|
17
19
|
* transport and schema validation.
|
|
18
20
|
*
|
|
19
|
-
* The transport is not implemented yet; see {@link OffchainOpportunities}
|
|
20
|
-
* what each stubbed endpoint currently answers.
|
|
21
|
+
* The transport is not implemented yet; see {@link OffchainOpportunities} and
|
|
22
|
+
* {@link OffchainPositions} for what each stubbed endpoint currently answers.
|
|
21
23
|
**/
|
|
22
24
|
var GearboxAPI = class {
|
|
23
25
|
/**
|
|
24
26
|
* Namespace for pool and strategy opportunities.
|
|
25
27
|
**/
|
|
26
28
|
opportunities;
|
|
29
|
+
/**
|
|
30
|
+
* Namespace for the positions a wallet holds.
|
|
31
|
+
**/
|
|
32
|
+
positions;
|
|
27
33
|
constructor(options) {
|
|
28
34
|
this.opportunities = new OffchainOpportunities(options);
|
|
35
|
+
this.positions = new OffchainPositions(options);
|
|
29
36
|
}
|
|
30
37
|
};
|
|
31
38
|
//#endregion
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { OffchainNotImplementedError
|
|
1
|
+
import { OffchainNotImplementedError } from "./types.js";
|
|
2
|
+
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
2
3
|
import "./opportunities/index.js";
|
|
4
|
+
import { OffchainPositions } from "./positions/OffchainPositions.js";
|
|
5
|
+
import "./positions/index.js";
|
|
3
6
|
import { GearboxAPI } from "./GearboxAPI.js";
|
|
4
|
-
|
|
5
|
-
export { GearboxAPI, OffchainNotImplementedError, OffchainOpportunities };
|
|
7
|
+
export { GearboxAPI, OffchainNotImplementedError, OffchainOpportunities, OffchainPositions };
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
+
import { OffchainNotImplementedError } from "../types.js";
|
|
1
2
|
//#region src/offchain/opportunities/OffchainOpportunities.ts
|
|
2
3
|
/**
|
|
3
|
-
* Thrown by the endpoints that have no stub answer, so that a caller in
|
|
4
|
-
* `offchain` mode fails loudly instead of reading an empty detail page as a
|
|
5
|
-
* missing opportunity.
|
|
6
|
-
**/
|
|
7
|
-
var OffchainNotImplementedError = class extends Error {
|
|
8
|
-
constructor(endpoint) {
|
|
9
|
-
super(`GearboxAPI: ${endpoint} is not implemented yet`);
|
|
10
|
-
this.name = "OffchainNotImplementedError";
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
4
|
* Backend counterpart of the `opportunities` namespace.
|
|
15
5
|
*
|
|
16
6
|
* This is a stub: the HTTP client is not written yet, so list reads answer with
|
|
@@ -92,4 +82,4 @@ var OffchainOpportunities = class {
|
|
|
92
82
|
}
|
|
93
83
|
};
|
|
94
84
|
//#endregion
|
|
95
|
-
export {
|
|
85
|
+
export { OffchainOpportunities };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { OffchainOpportunities } from "./OffchainOpportunities.js";
|
|
2
|
+
export { OffchainOpportunities };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/offchain/positions/OffchainPositions.ts
|
|
2
|
+
/**
|
|
3
|
+
* Backend counterpart of the `positions` namespace.
|
|
4
|
+
*
|
|
5
|
+
* This is a stub: the HTTP client is not written yet, so reads answer with an
|
|
6
|
+
* empty payload. Every signature is already the final one, because the backend
|
|
7
|
+
* returns the read model types directly — there is no wire DTO and no mapper
|
|
8
|
+
* between the two.
|
|
9
|
+
*
|
|
10
|
+
* When the transport lands, each method will validate the response against the
|
|
11
|
+
* matching schema from `src/model` before returning it. A validation failure is
|
|
12
|
+
* a version-skew error and is handled exactly like a transport error: the
|
|
13
|
+
* combined SDK drops the backend's contribution in `both` mode and rethrows in
|
|
14
|
+
* `offchain` mode.
|
|
15
|
+
**/
|
|
16
|
+
var OffchainPositions = class {
|
|
17
|
+
#baseUrl;
|
|
18
|
+
#logger;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.#baseUrl = options?.baseUrl;
|
|
21
|
+
this.#logger = options?.logger?.child?.({ name: "OffchainPositions" });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Base URL the client will call once the transport is implemented.
|
|
25
|
+
**/
|
|
26
|
+
get baseUrl() {
|
|
27
|
+
return this.#baseUrl;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Everything a wallet holds, optionally narrowed by {@link PositionFilter}.
|
|
31
|
+
*
|
|
32
|
+
* @returns An empty list until the backend client is implemented.
|
|
33
|
+
**/
|
|
34
|
+
async list(wallet, filter) {
|
|
35
|
+
this.#logger?.debug({
|
|
36
|
+
wallet,
|
|
37
|
+
filter
|
|
38
|
+
}, "offchain positions list is not implemented, serving empty list");
|
|
39
|
+
return {
|
|
40
|
+
result: [],
|
|
41
|
+
meta: { status: "success" }
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One historical series of one position. History exists only here: rebuilding
|
|
46
|
+
* it from the chain would mean an archive read per point.
|
|
47
|
+
*
|
|
48
|
+
* The requested metric types the response, so a caller asking for one metric
|
|
49
|
+
* does not have to narrow the union back down. When the transport lands,
|
|
50
|
+
* validation is what upholds it: a response carrying a different metric than
|
|
51
|
+
* the one asked for is a version-skew error like any other.
|
|
52
|
+
*
|
|
53
|
+
* @returns An empty series until the backend client is implemented.
|
|
54
|
+
**/
|
|
55
|
+
async getHistory(query) {
|
|
56
|
+
this.#logger?.debug({ query }, "offchain positions history is not implemented, serving empty series");
|
|
57
|
+
return {
|
|
58
|
+
result: {
|
|
59
|
+
metric: query.metric,
|
|
60
|
+
points: [],
|
|
61
|
+
metadata: {}
|
|
62
|
+
},
|
|
63
|
+
meta: { status: "success" }
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { OffchainPositions };
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/offchain/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Thrown by the endpoints that have no stub answer, so that a caller in
|
|
4
|
+
* `offchain` mode fails loudly instead of reading an empty detail page as a
|
|
5
|
+
* missing entity.
|
|
6
|
+
*
|
|
7
|
+
* Lives here rather than in one namespace because every stubbed namespace
|
|
8
|
+
* throws it.
|
|
9
|
+
**/
|
|
10
|
+
var OffchainNotImplementedError = class extends Error {
|
|
11
|
+
constructor(endpoint) {
|
|
12
|
+
super(`GearboxAPI: ${endpoint} is not implemented yet`);
|
|
13
|
+
this.name = "OffchainNotImplementedError";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { OffchainNotImplementedError };
|
|
@@ -7,6 +7,8 @@ import "./accounts/index.js";
|
|
|
7
7
|
import "./core/index.js";
|
|
8
8
|
import { MultichainOpportunitiesService } from "./opportunities/MultichainOpportunitiesService.js";
|
|
9
9
|
import "./opportunities/index.js";
|
|
10
|
+
import { MultichainPositionsService } from "./positions/MultichainPositionsService.js";
|
|
11
|
+
import "./positions/index.js";
|
|
10
12
|
import { OnchainSDK } from "./OnchainSDK.js";
|
|
11
13
|
//#region src/sdk/MultichainSDK.ts
|
|
12
14
|
/**
|
|
@@ -29,6 +31,10 @@ var MultichainSDK = class {
|
|
|
29
31
|
* chains.
|
|
30
32
|
*/
|
|
31
33
|
opportunities;
|
|
34
|
+
/**
|
|
35
|
+
* Namespace for the positions a wallet holds on all configured chains.
|
|
36
|
+
*/
|
|
37
|
+
positions;
|
|
32
38
|
constructor(options) {
|
|
33
39
|
this.#chains = /* @__PURE__ */ new Map();
|
|
34
40
|
this.#logger = options.logger;
|
|
@@ -47,6 +53,7 @@ var MultichainSDK = class {
|
|
|
47
53
|
}
|
|
48
54
|
this.liquidations = new MultichainLiquidationsService(this);
|
|
49
55
|
this.opportunities = new MultichainOpportunitiesService(this);
|
|
56
|
+
this.positions = new MultichainPositionsService(this);
|
|
50
57
|
}
|
|
51
58
|
/**
|
|
52
59
|
* Attach all configured chains in parallel.
|
|
@@ -30,6 +30,8 @@ import { PluginStateVersionError } from "./plugins/errors.js";
|
|
|
30
30
|
import "./plugins/index.js";
|
|
31
31
|
import { PoolService } from "./pools/PoolService.js";
|
|
32
32
|
import "./pools/index.js";
|
|
33
|
+
import { PositionsService } from "./positions/PositionsService.js";
|
|
34
|
+
import "./positions/index.js";
|
|
33
35
|
import { createRouter } from "./router/createRouter.js";
|
|
34
36
|
import "./router/index.js";
|
|
35
37
|
import { createPublicClient, fallback, http, parseEventLogs } from "viem";
|
|
@@ -112,6 +114,10 @@ var OnchainSDK = class extends ChainContractsRegister {
|
|
|
112
114
|
*/
|
|
113
115
|
opportunities;
|
|
114
116
|
/**
|
|
117
|
+
* Namespace for the positions a wallet holds on this chain.
|
|
118
|
+
*/
|
|
119
|
+
positions;
|
|
120
|
+
/**
|
|
115
121
|
* @param network - Gearbox network type (e.g. `"Mainnet"`, `"Monad"`).
|
|
116
122
|
* @param clientOptions - Connection options (RPC URLs, transport, or client).
|
|
117
123
|
* @param options - SDK configuration options.
|
|
@@ -133,6 +139,7 @@ var OnchainSDK = class extends ChainContractsRegister {
|
|
|
133
139
|
this.pools = new PoolService(this);
|
|
134
140
|
this.liquidations = new LiquidationsService(this);
|
|
135
141
|
this.opportunities = new OpportunitiesService(this);
|
|
142
|
+
this.positions = new PositionsService(this);
|
|
136
143
|
this.#withdrawalCompressor = createWithdrawalCompressor(this);
|
|
137
144
|
}
|
|
138
145
|
/**
|