@gearbox-protocol/sdk 14.12.0-next.67 → 14.12.0-next.69
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/index.js +13 -0
- package/dist/cjs/model/liquidations.schema.js +3 -1
- package/dist/cjs/model/opportunities.schema.js +10 -7
- package/dist/cjs/model/positions.schema.js +120 -0
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +19 -8
- package/dist/cjs/sdk/market/MarketSuite.js +8 -12
- package/dist/cjs/sdk/market/credit/CreditSuite.js +4 -14
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +8 -63
- package/dist/cjs/sdk/router/RouterV310Contract.js +34 -0
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/index.js +3 -1
- package/dist/esm/model/liquidations.schema.js +3 -1
- package/dist/esm/model/opportunities.schema.js +10 -7
- package/dist/esm/model/positions.schema.js +109 -0
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +20 -9
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/TokensMeta.js +2 -2
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/market/MarketSuite.js +8 -12
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditSuite.js +5 -15
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/opportunities/OpportunitiesService.js +8 -63
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/router/RouterV310Contract.js +34 -0
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/model/index.d.ts +3 -1
- package/dist/types/model/liquidations.d.ts +9 -1
- package/dist/types/model/liquidations.schema.d.ts +5 -3
- package/dist/types/model/opportunities.d.ts +70 -29
- package/dist/types/model/opportunities.schema.d.ts +220 -249
- package/dist/types/model/positions.d.ts +239 -3
- package/dist/types/model/positions.schema.d.ts +701 -0
- package/dist/types/model/primitives.d.ts +3 -2
- package/dist/types/sdk/index.d.ts +3 -3
- package/dist/types/sdk/market/MarketSuite.d.ts +4 -15
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +3 -7
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +6 -11
- package/dist/types/sdk/router/RouterV310Contract.d.ts +5 -1
- package/dist/types/sdk/router/index.d.ts +2 -2
- package/dist/types/sdk/router/types.d.ts +35 -1
- package/package.json +1 -1
package/dist/cjs/model/index.js
CHANGED
|
@@ -6,6 +6,8 @@ const require_model_history_schema = require("./history.schema.js");
|
|
|
6
6
|
const require_model_liquidations = require("./liquidations.js");
|
|
7
7
|
const require_model_liquidations_schema = require("./liquidations.schema.js");
|
|
8
8
|
const require_model_opportunities = require("./opportunities.js");
|
|
9
|
+
require("./positions.js");
|
|
10
|
+
const require_model_positions_schema = require("./positions.schema.js");
|
|
9
11
|
require("./primitives.js");
|
|
10
12
|
exports.POOL_HISTORY_METRICS = require_model_history.POOL_HISTORY_METRICS;
|
|
11
13
|
exports.STRATEGY_HISTORY_METRICS = require_model_history.STRATEGY_HISTORY_METRICS;
|
|
@@ -38,27 +40,38 @@ exports.opportunityId = require_model_opportunities.opportunityId;
|
|
|
38
40
|
exports.opportunityKeySchema = require_model_opportunities_schema.opportunityKeySchema;
|
|
39
41
|
exports.opportunityKindSchema = require_model_opportunities_schema.opportunityKindSchema;
|
|
40
42
|
exports.opportunitySchema = require_model_opportunities_schema.opportunitySchema;
|
|
43
|
+
exports.pnlBreakdownSchema = require_model_positions_schema.pnlBreakdownSchema;
|
|
41
44
|
exports.pointRewardsSchema = require_model_opportunities_schema.pointRewardsSchema;
|
|
45
|
+
exports.pointsProgramPnLSchema = require_model_positions_schema.pointsProgramPnLSchema;
|
|
42
46
|
exports.pointsProgramSchema = require_model_opportunities_schema.pointsProgramSchema;
|
|
47
|
+
exports.pointsRewardsPnLSchema = require_model_positions_schema.pointsRewardsPnLSchema;
|
|
43
48
|
exports.poolHistoryMetricSchema = require_model_history_schema.poolHistoryMetricSchema;
|
|
44
49
|
exports.poolOpportunityDetailSchema = require_model_opportunities_schema.poolOpportunityDetailSchema;
|
|
45
50
|
exports.poolOpportunityId = require_model_opportunities.poolOpportunityId;
|
|
46
51
|
exports.poolOpportunityKeySchema = require_model_opportunities_schema.poolOpportunityKeySchema;
|
|
47
52
|
exports.poolOpportunitySchema = require_model_opportunities_schema.poolOpportunitySchema;
|
|
53
|
+
exports.poolPositionSchema = require_model_positions_schema.poolPositionSchema;
|
|
54
|
+
exports.positionCollateralSchema = require_model_positions_schema.positionCollateralSchema;
|
|
55
|
+
exports.positionFilterSchema = require_model_positions_schema.positionFilterSchema;
|
|
56
|
+
exports.positionKindSchema = require_model_positions_schema.positionKindSchema;
|
|
57
|
+
exports.positionSchema = require_model_positions_schema.positionSchema;
|
|
48
58
|
exports.priceFeedDataSchema = require_model_opportunities_schema.priceFeedDataSchema;
|
|
49
59
|
exports.priceFeedSummarySchema = require_model_opportunities_schema.priceFeedSummarySchema;
|
|
50
60
|
exports.quotaAssetSchema = require_model_opportunities_schema.quotaAssetSchema;
|
|
51
61
|
exports.rateCurvePointSchema = require_model_opportunities_schema.rateCurvePointSchema;
|
|
52
62
|
exports.rateCurveSchema = require_model_opportunities_schema.rateCurveSchema;
|
|
53
63
|
exports.receivedAssetSchema = require_model_liquidations_schema.receivedAssetSchema;
|
|
64
|
+
exports.rewardsPnLSchema = require_model_positions_schema.rewardsPnLSchema;
|
|
54
65
|
exports.rewardsSchema = require_model_opportunities_schema.rewardsSchema;
|
|
55
66
|
exports.strategyHistoryMetricSchema = require_model_history_schema.strategyHistoryMetricSchema;
|
|
56
67
|
exports.strategyOpportunityDetailSchema = require_model_opportunities_schema.strategyOpportunityDetailSchema;
|
|
57
68
|
exports.strategyOpportunityId = require_model_opportunities.strategyOpportunityId;
|
|
58
69
|
exports.strategyOpportunityKeySchema = require_model_opportunities_schema.strategyOpportunityKeySchema;
|
|
59
70
|
exports.strategyOpportunitySchema = require_model_opportunities_schema.strategyOpportunitySchema;
|
|
71
|
+
exports.strategyPositionSchema = require_model_positions_schema.strategyPositionSchema;
|
|
60
72
|
exports.timestampSchema = require_model_primitives_schema.timestampSchema;
|
|
61
73
|
exports.tokenAmountSchema = require_model_primitives_schema.tokenAmountSchema;
|
|
74
|
+
exports.tokenRewardsPnLSchema = require_model_positions_schema.tokenRewardsPnLSchema;
|
|
62
75
|
exports.tokenRewardsSchema = require_model_opportunities_schema.tokenRewardsSchema;
|
|
63
76
|
exports.tokenSchema = require_model_primitives_schema.tokenSchema;
|
|
64
77
|
exports.txCallSchema = require_model_primitives_schema.txCallSchema;
|
|
@@ -45,7 +45,7 @@ const instantReceivedAssetSchema = zod_v4.z.object({
|
|
|
45
45
|
const delayedReceivedAssetSchema = zod_v4.z.object({
|
|
46
46
|
...require_model_primitives_schema.tokenAmountSchema.shape,
|
|
47
47
|
isDelayed: zod_v4.z.literal(true),
|
|
48
|
-
|
|
48
|
+
redeemer: require_sdk_utils_zod.ZodAddress().optional(),
|
|
49
49
|
claimableAt: require_model_primitives_schema.timestampSchema.optional()
|
|
50
50
|
});
|
|
51
51
|
/**
|
|
@@ -60,6 +60,8 @@ const liquidationApprovalSchema = require_model_primitives_schema.tokenAmountSch
|
|
|
60
60
|
* {@link LiquidationPosition}
|
|
61
61
|
**/
|
|
62
62
|
const liquidationPositionSchema = zod_v4.z.object({
|
|
63
|
+
kind: zod_v4.z.literal("liquidation"),
|
|
64
|
+
name: zod_v4.z.string(),
|
|
63
65
|
chainId: require_model_primitives_schema.chainIdSchema,
|
|
64
66
|
sourceToken: require_model_primitives_schema.tokenSchema,
|
|
65
67
|
output: require_model_primitives_schema.tokenAmountSchema,
|
|
@@ -43,22 +43,19 @@ const rewardsSchema = zod_v4.z.discriminatedUnion("kind", [tokenRewardsSchema, p
|
|
|
43
43
|
* {@link ApyBreakdown}
|
|
44
44
|
**/
|
|
45
45
|
const apyBreakdownSchema = zod_v4.z.object({
|
|
46
|
-
totalApy: require_model_primitives_schema.bpsSchema,
|
|
46
|
+
totalApy: require_model_primitives_schema.bpsSchema.optional(),
|
|
47
47
|
organicApy: require_model_primitives_schema.bpsSchema,
|
|
48
|
-
rewards: zod_v4.z.array(rewardsSchema)
|
|
48
|
+
rewards: zod_v4.z.array(rewardsSchema).optional()
|
|
49
49
|
});
|
|
50
50
|
/**
|
|
51
51
|
* {@link OpportunityBase}
|
|
52
52
|
**/
|
|
53
53
|
const opportunityBaseSchema = zod_v4.z.object({
|
|
54
54
|
chainId: require_model_primitives_schema.chainIdSchema,
|
|
55
|
-
|
|
55
|
+
name: zod_v4.z.string(),
|
|
56
56
|
curator: require_model_primitives_schema.curatorSchema,
|
|
57
57
|
underlyingToken: require_model_primitives_schema.tokenSchema,
|
|
58
|
-
totalSupply: require_model_primitives_schema.amountSchema,
|
|
59
58
|
totalBorrow: require_model_primitives_schema.amountSchema,
|
|
60
|
-
utilization: require_model_primitives_schema.bpsSchema,
|
|
61
|
-
supplyApy: apyBreakdownSchema.optional(),
|
|
62
59
|
collateralTokens: zod_v4.z.array(require_model_primitives_schema.tokenSchema),
|
|
63
60
|
paused: zod_v4.z.boolean(),
|
|
64
61
|
rwa: zod_v4.z.boolean(),
|
|
@@ -70,7 +67,10 @@ const opportunityBaseSchema = zod_v4.z.object({
|
|
|
70
67
|
const poolOpportunitySchema = zod_v4.z.object({
|
|
71
68
|
...opportunityBaseSchema.shape,
|
|
72
69
|
kind: zod_v4.z.literal("pool"),
|
|
73
|
-
pool: require_sdk_utils_zod.ZodAddress()
|
|
70
|
+
pool: require_sdk_utils_zod.ZodAddress(),
|
|
71
|
+
totalSupply: require_model_primitives_schema.amountSchema,
|
|
72
|
+
utilization: require_model_primitives_schema.bpsSchema,
|
|
73
|
+
supplyApy: apyBreakdownSchema
|
|
74
74
|
});
|
|
75
75
|
/**
|
|
76
76
|
* {@link StrategyOpportunity}
|
|
@@ -85,8 +85,11 @@ const strategyOpportunitySchema = zod_v4.z.object({
|
|
|
85
85
|
liquidationFee: require_model_primitives_schema.bpsSchema,
|
|
86
86
|
expirationDate: require_model_primitives_schema.timestampSchema.nullable(),
|
|
87
87
|
collateralApy: apyBreakdownSchema.optional(),
|
|
88
|
+
maxLeverageApy: apyBreakdownSchema.optional(),
|
|
88
89
|
borrowApy: require_model_primitives_schema.bpsSchema.optional(),
|
|
89
90
|
additionalBorrowApy: require_model_primitives_schema.bpsSchema.optional(),
|
|
91
|
+
totalValue: require_model_primitives_schema.amountSchema.optional(),
|
|
92
|
+
utilization: require_model_primitives_schema.bpsSchema.optional(),
|
|
90
93
|
maxBorrowAmount: require_model_primitives_schema.amountSchema,
|
|
91
94
|
maxLeverage: require_model_primitives_schema.leverageSchema
|
|
92
95
|
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_utils_zod = require("../sdk/utils/zod.js");
|
|
3
|
+
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
4
|
+
const require_model_opportunities_schema = require("./opportunities.schema.js");
|
|
5
|
+
const require_model_liquidations_schema = require("./liquidations.schema.js");
|
|
6
|
+
let zod_v4 = require("zod/v4");
|
|
7
|
+
//#region src/model/positions.schema.ts
|
|
8
|
+
/**
|
|
9
|
+
* Runtime schemas for {@link ./positions.js}, see the note in
|
|
10
|
+
* `primitives.schema.ts` on why they are written by hand.
|
|
11
|
+
**/
|
|
12
|
+
/**
|
|
13
|
+
* {@link PositionKind}
|
|
14
|
+
**/
|
|
15
|
+
const positionKindSchema = zod_v4.z.union([
|
|
16
|
+
zod_v4.z.literal("pool"),
|
|
17
|
+
zod_v4.z.literal("strategy"),
|
|
18
|
+
zod_v4.z.literal("liquidation")
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* {@link TokenRewardsPnL}
|
|
22
|
+
**/
|
|
23
|
+
const tokenRewardsPnLSchema = zod_v4.z.object({
|
|
24
|
+
...require_model_primitives_schema.tokenAmountSchema.shape,
|
|
25
|
+
kind: zod_v4.z.literal("token")
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* {@link PointsProgramPnL}
|
|
29
|
+
**/
|
|
30
|
+
const pointsProgramPnLSchema = zod_v4.z.object({
|
|
31
|
+
...require_model_opportunities_schema.pointsProgramSchema.shape,
|
|
32
|
+
value: zod_v4.z.number()
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* {@link PointsRewardsPnL}
|
|
36
|
+
**/
|
|
37
|
+
const pointsRewardsPnLSchema = zod_v4.z.object({
|
|
38
|
+
kind: zod_v4.z.literal("point"),
|
|
39
|
+
points: zod_v4.z.array(pointsProgramPnLSchema)
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* {@link RewardsPnL}
|
|
43
|
+
**/
|
|
44
|
+
const rewardsPnLSchema = zod_v4.z.discriminatedUnion("kind", [tokenRewardsPnLSchema, pointsRewardsPnLSchema]);
|
|
45
|
+
/**
|
|
46
|
+
* {@link PnlBreakdown}
|
|
47
|
+
**/
|
|
48
|
+
const pnlBreakdownSchema = zod_v4.z.object({
|
|
49
|
+
organic: require_model_primitives_schema.tokenAmountSchema,
|
|
50
|
+
total: require_model_primitives_schema.tokenAmountSchema,
|
|
51
|
+
rewards: zod_v4.z.array(rewardsPnLSchema)
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* {@link PositionCollateral}
|
|
55
|
+
**/
|
|
56
|
+
const positionCollateralSchema = zod_v4.z.object({
|
|
57
|
+
collateral: require_model_primitives_schema.tokenAmountSchema,
|
|
58
|
+
quota: require_model_primitives_schema.tokenAmountSchema,
|
|
59
|
+
withdrawals: zod_v4.z.array(require_model_liquidations_schema.delayedReceivedAssetSchema)
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* {@link PoolPosition}
|
|
63
|
+
**/
|
|
64
|
+
const poolPositionSchema = zod_v4.z.object({
|
|
65
|
+
kind: zod_v4.z.literal("pool"),
|
|
66
|
+
name: zod_v4.z.string(),
|
|
67
|
+
chainId: require_model_primitives_schema.chainIdSchema,
|
|
68
|
+
pool: require_sdk_utils_zod.ZodAddress(),
|
|
69
|
+
netValue: require_model_primitives_schema.tokenAmountSchema,
|
|
70
|
+
apy: require_model_opportunities_schema.apyBreakdownSchema,
|
|
71
|
+
pnl: pnlBreakdownSchema.optional()
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* {@link StrategyPosition}
|
|
75
|
+
**/
|
|
76
|
+
const strategyPositionSchema = zod_v4.z.object({
|
|
77
|
+
kind: zod_v4.z.literal("strategy"),
|
|
78
|
+
name: zod_v4.z.string(),
|
|
79
|
+
chainId: require_model_primitives_schema.chainIdSchema,
|
|
80
|
+
creditManager: require_sdk_utils_zod.ZodAddress(),
|
|
81
|
+
creditAccount: require_sdk_utils_zod.ZodAddress(),
|
|
82
|
+
targetCollateral: require_model_primitives_schema.tokenSchema.nullable(),
|
|
83
|
+
leverage: require_model_primitives_schema.leverageSchema,
|
|
84
|
+
borrowApy: require_model_primitives_schema.bpsSchema,
|
|
85
|
+
netApy: require_model_opportunities_schema.apyBreakdownSchema.optional(),
|
|
86
|
+
totalDebt: require_model_primitives_schema.tokenAmountSchema,
|
|
87
|
+
totalValue: require_model_primitives_schema.tokenAmountSchema,
|
|
88
|
+
healthFactor: require_model_primitives_schema.bpsSchema,
|
|
89
|
+
pnl: pnlBreakdownSchema.optional(),
|
|
90
|
+
collaterals: zod_v4.z.array(positionCollateralSchema)
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* {@link Position}
|
|
94
|
+
**/
|
|
95
|
+
const positionSchema = zod_v4.z.discriminatedUnion("kind", [
|
|
96
|
+
poolPositionSchema,
|
|
97
|
+
strategyPositionSchema,
|
|
98
|
+
require_model_liquidations_schema.liquidationPositionSchema
|
|
99
|
+
]);
|
|
100
|
+
/**
|
|
101
|
+
* {@link PositionFilter}
|
|
102
|
+
**/
|
|
103
|
+
const positionFilterSchema = zod_v4.z.object({
|
|
104
|
+
kind: positionKindSchema.optional(),
|
|
105
|
+
isZeroDebt: zod_v4.z.boolean().optional(),
|
|
106
|
+
chainIds: zod_v4.z.array(require_model_primitives_schema.chainIdSchema).optional(),
|
|
107
|
+
underlyingType: require_model_primitives_schema.assetTypeSchema.optional()
|
|
108
|
+
});
|
|
109
|
+
//#endregion
|
|
110
|
+
exports.pnlBreakdownSchema = pnlBreakdownSchema;
|
|
111
|
+
exports.pointsProgramPnLSchema = pointsProgramPnLSchema;
|
|
112
|
+
exports.pointsRewardsPnLSchema = pointsRewardsPnLSchema;
|
|
113
|
+
exports.poolPositionSchema = poolPositionSchema;
|
|
114
|
+
exports.positionCollateralSchema = positionCollateralSchema;
|
|
115
|
+
exports.positionFilterSchema = positionFilterSchema;
|
|
116
|
+
exports.positionKindSchema = positionKindSchema;
|
|
117
|
+
exports.positionSchema = positionSchema;
|
|
118
|
+
exports.rewardsPnLSchema = rewardsPnLSchema;
|
|
119
|
+
exports.strategyPositionSchema = strategyPositionSchema;
|
|
120
|
+
exports.tokenRewardsPnLSchema = tokenRewardsPnLSchema;
|
|
@@ -98,17 +98,12 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
|
|
|
98
98
|
await compressor.loadWithdrawableAssets();
|
|
99
99
|
const phantomTokens = new require_sdk_utils_AddressSet.AddressSet(compressor.getWithdrawableAssets().map((a) => a.withdrawalPhantomToken));
|
|
100
100
|
const { claimable, pending } = await compressor.getExternalAccountCurrentWithdrawals(props.liquidator, ...phantomTokens.asArray());
|
|
101
|
-
const chainId = this.sdk.chainId;
|
|
102
101
|
return [...claimable.map((w) => ({
|
|
103
|
-
|
|
104
|
-
sourceToken: this.sdk.tokensMeta.mustGetToken(w.token),
|
|
105
|
-
output: this.#withdrawalOutput(w.outputs, w.token),
|
|
102
|
+
...this.#liquidationPosition(w.token, w.outputs),
|
|
106
103
|
claimTx: this.#claimTx(w.claimCalls, w.token),
|
|
107
104
|
redeemer: w.redeemer
|
|
108
105
|
})), ...pending.map((w) => ({
|
|
109
|
-
|
|
110
|
-
sourceToken: this.sdk.tokensMeta.mustGetToken(w.token),
|
|
111
|
-
output: this.#withdrawalOutput(w.expectedOutputs, w.token),
|
|
106
|
+
...this.#liquidationPosition(w.token, w.expectedOutputs),
|
|
112
107
|
claimableAt: Number(w.claimableAt),
|
|
113
108
|
redeemer: w.redeemer
|
|
114
109
|
}))];
|
|
@@ -163,6 +158,22 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
|
|
|
163
158
|
valueUsd: null
|
|
164
159
|
};
|
|
165
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* The part a claimable and a pending withdrawal describe the same way. What
|
|
163
|
+
* separates them — the claim transaction and the moment it becomes
|
|
164
|
+
* available — is added by the caller.
|
|
165
|
+
**/
|
|
166
|
+
#liquidationPosition(token, outputs) {
|
|
167
|
+
const sourceToken = this.sdk.tokensMeta.mustGetToken(token);
|
|
168
|
+
const output = this.#withdrawalOutput(outputs, token);
|
|
169
|
+
return {
|
|
170
|
+
kind: "liquidation",
|
|
171
|
+
name: `${sourceToken.symbol} → ${output.token.symbol}`,
|
|
172
|
+
chainId: this.sdk.chainId,
|
|
173
|
+
sourceToken,
|
|
174
|
+
output
|
|
175
|
+
};
|
|
176
|
+
}
|
|
166
177
|
#withdrawalOutput(outputs, sourceToken) {
|
|
167
178
|
const [output] = outputs;
|
|
168
179
|
if (outputs.length !== 1 || !output) throw new Error(`expected exactly one output for withdrawal of ${sourceToken}, got ${outputs.length}`);
|
|
@@ -186,7 +197,7 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
|
|
|
186
197
|
return {
|
|
187
198
|
isDelayed: true,
|
|
188
199
|
...amount,
|
|
189
|
-
|
|
200
|
+
redeemer: require_sdk_utils_hex.hexEq(o.redeemerAddress, "0x0000000000000000000000000000000000000000") ? void 0 : o.redeemerAddress,
|
|
190
201
|
claimableAt: o.claimableAt === 0n ? void 0 : Number(o.claimableAt)
|
|
191
202
|
};
|
|
192
203
|
});
|
|
@@ -4,6 +4,7 @@ const require_sdk_chain_chains = require("../chain/chains.js");
|
|
|
4
4
|
require("../utils/index.js");
|
|
5
5
|
const require_sdk_base_SDKConstruct = require("../base/SDKConstruct.js");
|
|
6
6
|
require("../base/index.js");
|
|
7
|
+
const require_sdk_market_math = require("./math.js");
|
|
7
8
|
const require_sdk_market_credit_CreditSuite = require("./credit/CreditSuite.js");
|
|
8
9
|
require("./credit/index.js");
|
|
9
10
|
const require_sdk_market_MarketConfiguratorContract = require("./MarketConfiguratorContract.js");
|
|
@@ -190,17 +191,15 @@ var MarketSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
190
191
|
* Every opportunity this market offers: its pool, plus one row per
|
|
191
192
|
* `(credit manager, target collateral)` pair.
|
|
192
193
|
*
|
|
193
|
-
* @param totals - Resolves the summed worth of the credit accounts backing a
|
|
194
|
-
* strategy, which only a credit-account query can establish.
|
|
195
194
|
* @param filter - Optional narrowing. A filter naming a kind skips building
|
|
196
195
|
* the other kind entirely; every built row is then checked in full by
|
|
197
196
|
* {@link matchesOpportunityFilter}, so there is one definition of what each
|
|
198
197
|
* criterion means.
|
|
199
198
|
*/
|
|
200
|
-
opportunities(
|
|
199
|
+
opportunities(filter) {
|
|
201
200
|
const rows = [];
|
|
202
201
|
if (filter?.kind !== "strategy") rows.push(this.poolOpportunity());
|
|
203
|
-
if (filter?.kind !== "pool") for (const { suite, collateral } of this.strategies) rows.push(suite.strategyOpportunity(collateral
|
|
202
|
+
if (filter?.kind !== "pool") for (const { suite, collateral } of this.strategies) rows.push(suite.strategyOpportunity(collateral));
|
|
204
203
|
return rows.filter((row) => require_model_opportunities.matchesOpportunityFilter(row, filter));
|
|
205
204
|
}
|
|
206
205
|
/**
|
|
@@ -214,15 +213,13 @@ var MarketSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
214
213
|
kind: "pool",
|
|
215
214
|
chainId: this.chainId,
|
|
216
215
|
pool: pool.address,
|
|
217
|
-
|
|
216
|
+
name: `${this.underlyingToken.symbol} Pool`,
|
|
218
217
|
curator: this.curator,
|
|
219
218
|
underlyingToken: this.underlyingToken,
|
|
220
|
-
totalSupply:
|
|
221
|
-
value: pool.totalSupply,
|
|
222
|
-
valueUsd: oracle.safeUsdValue(pool.underlying, pool.totalAssets)
|
|
223
|
-
},
|
|
219
|
+
totalSupply: oracle.toAmount(pool.underlying, pool.totalAssets),
|
|
224
220
|
totalBorrow: oracle.toAmount(pool.underlying, pool.totalBorrowed),
|
|
225
221
|
utilization: pool.utilization,
|
|
222
|
+
supplyApy: { organicApy: require_sdk_market_math.rayToBps(pool.supplyRate) },
|
|
226
223
|
collateralTokens: this.collateralTokens,
|
|
227
224
|
paused: pool.isPaused,
|
|
228
225
|
rwa: this.rwa,
|
|
@@ -257,11 +254,10 @@ var MarketSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
257
254
|
*
|
|
258
255
|
* @param creditManager - Credit manager the position is opened in.
|
|
259
256
|
* @param collateral - Target collateral of the position.
|
|
260
|
-
* @param totalSupply - Summed worth of the credit accounts backing it.
|
|
261
257
|
* @throws If this market has no such strategy, see {@link mustFindStrategy}.
|
|
262
258
|
*/
|
|
263
|
-
strategyOpportunityDetail(creditManager, collateral
|
|
264
|
-
return this.mustFindStrategy(creditManager, collateral).suite.strategyOpportunityDetail(collateral
|
|
259
|
+
strategyOpportunityDetail(creditManager, collateral) {
|
|
260
|
+
return this.mustFindStrategy(creditManager, collateral).suite.strategyOpportunityDetail(collateral);
|
|
265
261
|
}
|
|
266
262
|
/**
|
|
267
263
|
* Whether any child contract wrapper has observed events that require a
|
|
@@ -146,16 +146,9 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
146
146
|
* read model does.
|
|
147
147
|
*
|
|
148
148
|
* @param collateral - Target collateral of the position.
|
|
149
|
-
* @param totalSupply - Summed worth of the credit accounts backing it, which
|
|
150
|
-
* only a credit-account query can establish. Defaults to zero, so a caller
|
|
151
|
-
* that does not care about size can omit it.
|
|
152
149
|
* @throws If the credit manager does not value the collateral.
|
|
153
150
|
*/
|
|
154
|
-
strategyOpportunity(collateral
|
|
155
|
-
const totalSupply = totalSupply_ ?? {
|
|
156
|
-
value: 0n,
|
|
157
|
-
valueUsd: 0
|
|
158
|
-
};
|
|
151
|
+
strategyOpportunity(collateral) {
|
|
159
152
|
const { market, creditManager: cm } = this;
|
|
160
153
|
const { pool } = market.pool;
|
|
161
154
|
const oracle = market.priceOracle;
|
|
@@ -167,12 +160,10 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
167
160
|
chainId: this.chainId,
|
|
168
161
|
creditManager: cm.address,
|
|
169
162
|
targetCollateral: this.tokensMeta.mustGetToken(collateral),
|
|
170
|
-
|
|
163
|
+
name: `${this.tokensMeta.symbol(collateral)} / ${market.underlyingToken.symbol}`,
|
|
171
164
|
curator: market.curator,
|
|
172
165
|
underlyingToken: market.underlyingToken,
|
|
173
|
-
totalSupply,
|
|
174
166
|
totalBorrow: oracle.toAmount(pool.underlying, borrowed),
|
|
175
|
-
utilization: require_sdk_market_math.utilizationBps(borrowed, totalSupply.value),
|
|
176
167
|
collateralTokens: market.collateralTokens,
|
|
177
168
|
paused: this.isPaused,
|
|
178
169
|
rwa: market.rwa,
|
|
@@ -191,11 +182,10 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
191
182
|
* {@link strategyOpportunity} plus the data only its detail screen needs.
|
|
192
183
|
*
|
|
193
184
|
* @param collateral - Target collateral of the position.
|
|
194
|
-
* @param totalSupply - Summed worth of the credit accounts backing it.
|
|
195
185
|
*/
|
|
196
|
-
strategyOpportunityDetail(collateral
|
|
186
|
+
strategyOpportunityDetail(collateral) {
|
|
197
187
|
return {
|
|
198
|
-
...this.strategyOpportunity(collateral
|
|
188
|
+
...this.strategyOpportunity(collateral),
|
|
199
189
|
rateCurve: this.market.pool.rateCurve,
|
|
200
190
|
priceFeeds: this.market.priceFeedSummary(collateral)
|
|
201
191
|
};
|
|
@@ -1,41 +1,29 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_sdk_base_SDKConstruct = require("../base/SDKConstruct.js");
|
|
3
3
|
require("../base/index.js");
|
|
4
|
-
const require_sdk_market_math = require("../market/math.js");
|
|
5
4
|
//#region src/sdk/opportunities/OpportunitiesService.ts
|
|
6
5
|
/**
|
|
7
|
-
* A lookup that knows of no strategy, used when a filter rules strategies out
|
|
8
|
-
* and the credit-account query is skipped altogether.
|
|
9
|
-
**/
|
|
10
|
-
const NO_TOTALS = () => void 0;
|
|
11
|
-
/**
|
|
12
6
|
* Builds the `opportunities` read model from the chain.
|
|
13
7
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* the
|
|
8
|
+
* Every value in a row is market state the SDK already holds, so a list costs
|
|
9
|
+
* no RPC round-trip at all. Yield figures that fold in incentives, points or
|
|
10
|
+
* history are deliberately absent: they are the backend's job, and this service
|
|
11
|
+
* never guesses them. So is the size of a strategy — summing it takes a sweep
|
|
12
|
+
* over every credit account of the chain, which is too expensive for a list.
|
|
18
13
|
*
|
|
19
14
|
* The rows themselves are assembled by the market wrappers — see
|
|
20
15
|
* {@link MarketSuite.opportunities} — because every value in them is market
|
|
21
|
-
* state.
|
|
22
|
-
* much the credit accounts of a strategy are worth.
|
|
16
|
+
* state. This service only picks the markets and applies the filter.
|
|
23
17
|
**/
|
|
24
18
|
var OpportunitiesService = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
25
19
|
/**
|
|
26
20
|
* Every pool and strategy of every loaded market on this chain.
|
|
27
21
|
*
|
|
28
|
-
* Strategies are measured by the value locked in their credit accounts, so
|
|
29
|
-
* the list issues one credit-account query unless the filter rules strategies
|
|
30
|
-
* out entirely.
|
|
31
|
-
*
|
|
32
22
|
* @param filter - Optional narrowing, applied to the built rows.
|
|
33
23
|
**/
|
|
34
24
|
async list(filter) {
|
|
35
25
|
if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
|
|
36
|
-
|
|
37
|
-
const totals = filter?.kind === "pool" ? NO_TOTALS : await this.#strategyTotals(markets);
|
|
38
|
-
return markets.flatMap((market) => market.opportunities(totals, filter));
|
|
26
|
+
return this.sdk.marketRegister.markets.flatMap((market) => market.opportunities(filter));
|
|
39
27
|
}
|
|
40
28
|
/**
|
|
41
29
|
* A single pool opportunity plus its interest rate curve and quotas.
|
|
@@ -53,51 +41,8 @@ var OpportunitiesService = class extends require_sdk_base_SDKConstruct.SDKConstr
|
|
|
53
41
|
* collateral as a strategy.
|
|
54
42
|
**/
|
|
55
43
|
async getStrategy(key) {
|
|
56
|
-
|
|
57
|
-
const { suite } = market.mustFindStrategy(key.creditManager, key.targetCollateral);
|
|
58
|
-
const totals = await this.#strategyTotals([market]);
|
|
59
|
-
return suite.strategyOpportunityDetail(key.targetCollateral, totals(key.creditManager, key.targetCollateral));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Total value held by the credit accounts backing every strategy of the given
|
|
63
|
-
* markets.
|
|
64
|
-
*
|
|
65
|
-
* An account that holds several strategy collaterals counts in full towards
|
|
66
|
-
* each of them: the read model reports what a strategy's accounts are worth,
|
|
67
|
-
* not how that worth splits across the collaterals inside them.
|
|
68
|
-
**/
|
|
69
|
-
async #strategyTotals(markets) {
|
|
70
|
-
const wanted = /* @__PURE__ */ new Map();
|
|
71
|
-
for (const market of markets) for (const { suite, collateral } of market.strategies) {
|
|
72
|
-
const cm = suite.creditManager.address.toLowerCase();
|
|
73
|
-
const tokens = wanted.get(cm) ?? /* @__PURE__ */ new Set();
|
|
74
|
-
tokens.add(collateral.toLowerCase());
|
|
75
|
-
wanted.set(cm, tokens);
|
|
76
|
-
}
|
|
77
|
-
if (wanted.size === 0) return NO_TOTALS;
|
|
78
|
-
const accounts = await this.sdk.accounts.getCreditAccounts({ includeZeroDebt: true });
|
|
79
|
-
const totals = /* @__PURE__ */ new Map();
|
|
80
|
-
for (const account of accounts) {
|
|
81
|
-
const tokens = wanted.get(account.creditManager.toLowerCase());
|
|
82
|
-
if (!tokens) continue;
|
|
83
|
-
for (const token of account.tokens) {
|
|
84
|
-
if (token.balance <= 0n || !tokens.has(token.token.toLowerCase())) continue;
|
|
85
|
-
const key = strategyKey(account.creditManager, token.token);
|
|
86
|
-
const current = totals.get(key);
|
|
87
|
-
totals.set(key, {
|
|
88
|
-
value: (current?.value ?? 0n) + account.totalValue,
|
|
89
|
-
valueUsd: (current?.valueUsd ?? 0) + require_sdk_market_math.usdToNumber(account.totalValueUSD)
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return (creditManager, collateral) => totals.get(strategyKey(creditManager, collateral));
|
|
44
|
+
return this.sdk.marketRegister.findByCreditManager(key.creditManager).strategyOpportunityDetail(key.creditManager, key.targetCollateral);
|
|
94
45
|
}
|
|
95
46
|
};
|
|
96
|
-
/**
|
|
97
|
-
* Both halves of a strategy key folded into one map key.
|
|
98
|
-
**/
|
|
99
|
-
function strategyKey(creditManager, collateral) {
|
|
100
|
-
return `${creditManager.toLowerCase()}:${collateral.toLowerCase()}`;
|
|
101
|
-
}
|
|
102
47
|
//#endregion
|
|
103
48
|
exports.OpportunitiesService = OpportunitiesService;
|
|
@@ -58,6 +58,40 @@ var RouterV310Contract = class extends require_sdk_router_AbstractRouterContract
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
+
* {@inheritDoc IRouterContract.findManyToOnePath}
|
|
62
|
+
**/
|
|
63
|
+
async findManyToOnePath(props) {
|
|
64
|
+
const { creditAccount, creditManager, expectedBalances, leftoverBalances, target, slippage } = props;
|
|
65
|
+
const expectedMap = new require_sdk_utils_AssetsMap.AssetsMap(expectedBalances);
|
|
66
|
+
const leftoverMap = new require_sdk_utils_AssetsMap.AssetsMap(leftoverBalances);
|
|
67
|
+
const getNumSplits = this.#numSplitsGetter(creditManager, expectedBalances);
|
|
68
|
+
const tData = creditManager.collateralTokens.map((token) => ({
|
|
69
|
+
token,
|
|
70
|
+
balance: expectedMap.get(token) ?? 0n,
|
|
71
|
+
leftoverBalance: require_sdk_router_helpers.limitLeftover(leftoverMap.get(token), token) ?? 0n,
|
|
72
|
+
numSplits: getNumSplits(token),
|
|
73
|
+
claimRewards: false
|
|
74
|
+
}));
|
|
75
|
+
this.logger?.debug({
|
|
76
|
+
creditAccount: creditAccount.creditAccount,
|
|
77
|
+
creditManager: this.labelAddress(creditManager.address),
|
|
78
|
+
target: this.labelAddress(target),
|
|
79
|
+
slippage,
|
|
80
|
+
tData: this.#debugTokenData(tData)
|
|
81
|
+
}, "calling routeManyToOne");
|
|
82
|
+
const { result } = await this.contract.simulate.routeManyToOne([
|
|
83
|
+
creditAccount.creditAccount,
|
|
84
|
+
target,
|
|
85
|
+
BigInt(slippage),
|
|
86
|
+
tData
|
|
87
|
+
], { gas: this.sdk.gasLimit });
|
|
88
|
+
return {
|
|
89
|
+
amount: result.amount,
|
|
90
|
+
minAmount: result.minAmount,
|
|
91
|
+
calls: [...result.calls]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
61
95
|
* {@inheritDoc IRouterContract.findOpenStrategyPath}
|
|
62
96
|
**/
|
|
63
97
|
async findOpenStrategyPath(props) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../sdk/utils/AddressMap.js";
|
|
4
3
|
import { AddressSet } from "../sdk/utils/AddressSet.js";
|
|
5
4
|
import { AssetsMap } from "../sdk/utils/AssetsMap.js";
|
|
6
5
|
import { childLogger } from "../sdk/utils/childLogger.js";
|
|
6
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
7
7
|
import "../sdk/constants/addresses.js";
|
|
8
8
|
import { MAX_UINT256, PERCENTAGE_FACTOR } from "../sdk/constants/math.js";
|
|
9
9
|
import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { getNetworkType } from "../sdk/chain/chains.js";
|
|
3
2
|
import { getWithdrawalCompressorAddress } from "../sdk/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../sdk/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
package/dist/esm/model/index.js
CHANGED
|
@@ -5,5 +5,7 @@ import { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, hi
|
|
|
5
5
|
import { matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
6
6
|
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
7
7
|
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";
|
|
8
10
|
import "./primitives.js";
|
|
9
|
-
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, pointRewardsSchema, pointsProgramSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, timestampSchema, tokenAmountSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
|
|
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 };
|
|
@@ -44,7 +44,7 @@ const instantReceivedAssetSchema = z.object({
|
|
|
44
44
|
const delayedReceivedAssetSchema = z.object({
|
|
45
45
|
...tokenAmountSchema.shape,
|
|
46
46
|
isDelayed: z.literal(true),
|
|
47
|
-
|
|
47
|
+
redeemer: ZodAddress().optional(),
|
|
48
48
|
claimableAt: timestampSchema.optional()
|
|
49
49
|
});
|
|
50
50
|
/**
|
|
@@ -59,6 +59,8 @@ const liquidationApprovalSchema = tokenAmountSchema.extend({ spender: ZodAddress
|
|
|
59
59
|
* {@link LiquidationPosition}
|
|
60
60
|
**/
|
|
61
61
|
const liquidationPositionSchema = z.object({
|
|
62
|
+
kind: z.literal("liquidation"),
|
|
63
|
+
name: z.string(),
|
|
62
64
|
chainId: chainIdSchema,
|
|
63
65
|
sourceToken: tokenSchema,
|
|
64
66
|
output: tokenAmountSchema,
|
|
@@ -42,22 +42,19 @@ const rewardsSchema = z.discriminatedUnion("kind", [tokenRewardsSchema, pointRew
|
|
|
42
42
|
* {@link ApyBreakdown}
|
|
43
43
|
**/
|
|
44
44
|
const apyBreakdownSchema = z.object({
|
|
45
|
-
totalApy: bpsSchema,
|
|
45
|
+
totalApy: bpsSchema.optional(),
|
|
46
46
|
organicApy: bpsSchema,
|
|
47
|
-
rewards: z.array(rewardsSchema)
|
|
47
|
+
rewards: z.array(rewardsSchema).optional()
|
|
48
48
|
});
|
|
49
49
|
/**
|
|
50
50
|
* {@link OpportunityBase}
|
|
51
51
|
**/
|
|
52
52
|
const opportunityBaseSchema = z.object({
|
|
53
53
|
chainId: chainIdSchema,
|
|
54
|
-
|
|
54
|
+
name: z.string(),
|
|
55
55
|
curator: curatorSchema,
|
|
56
56
|
underlyingToken: tokenSchema,
|
|
57
|
-
totalSupply: amountSchema,
|
|
58
57
|
totalBorrow: amountSchema,
|
|
59
|
-
utilization: bpsSchema,
|
|
60
|
-
supplyApy: apyBreakdownSchema.optional(),
|
|
61
58
|
collateralTokens: z.array(tokenSchema),
|
|
62
59
|
paused: z.boolean(),
|
|
63
60
|
rwa: z.boolean(),
|
|
@@ -69,7 +66,10 @@ const opportunityBaseSchema = z.object({
|
|
|
69
66
|
const poolOpportunitySchema = z.object({
|
|
70
67
|
...opportunityBaseSchema.shape,
|
|
71
68
|
kind: z.literal("pool"),
|
|
72
|
-
pool: ZodAddress()
|
|
69
|
+
pool: ZodAddress(),
|
|
70
|
+
totalSupply: amountSchema,
|
|
71
|
+
utilization: bpsSchema,
|
|
72
|
+
supplyApy: apyBreakdownSchema
|
|
73
73
|
});
|
|
74
74
|
/**
|
|
75
75
|
* {@link StrategyOpportunity}
|
|
@@ -84,8 +84,11 @@ const strategyOpportunitySchema = z.object({
|
|
|
84
84
|
liquidationFee: bpsSchema,
|
|
85
85
|
expirationDate: timestampSchema.nullable(),
|
|
86
86
|
collateralApy: apyBreakdownSchema.optional(),
|
|
87
|
+
maxLeverageApy: apyBreakdownSchema.optional(),
|
|
87
88
|
borrowApy: bpsSchema.optional(),
|
|
88
89
|
additionalBorrowApy: bpsSchema.optional(),
|
|
90
|
+
totalValue: amountSchema.optional(),
|
|
91
|
+
utilization: bpsSchema.optional(),
|
|
89
92
|
maxBorrowAmount: amountSchema,
|
|
90
93
|
maxLeverage: leverageSchema
|
|
91
94
|
});
|