@gearbox-protocol/sdk 14.12.0-next.78 → 14.12.0-next.79
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/filters.js +20 -0
- package/dist/cjs/model/filters.schema.js +21 -0
- package/dist/cjs/model/index.js +6 -0
- package/dist/cjs/model/liquidations.js +10 -8
- package/dist/cjs/model/liquidations.schema.js +6 -5
- package/dist/cjs/model/opportunities.js +11 -9
- package/dist/cjs/model/opportunities.schema.js +7 -6
- package/dist/cjs/model/positions.js +10 -8
- package/dist/cjs/model/positions.schema.js +5 -4
- package/dist/cjs/sdk/market/MarketSuite.js +5 -3
- package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +5 -2
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +4 -1
- package/dist/cjs/sdk/positions/MultichainPositionsService.js +5 -2
- package/dist/cjs/sdk/positions/PositionsService.js +8 -4
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/filters.js +18 -0
- package/dist/esm/model/filters.schema.js +19 -0
- package/dist/esm/model/index.js +3 -1
- package/dist/esm/model/liquidations.js +10 -8
- package/dist/esm/model/liquidations.schema.js +6 -5
- package/dist/esm/model/opportunities.js +11 -9
- package/dist/esm/model/opportunities.schema.js +7 -6
- package/dist/esm/model/positions.js +10 -8
- package/dist/esm/model/positions.schema.js +5 -4
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
- 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 +1 -1
- 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 +5 -3
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- 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/MultichainOpportunitiesService.js +5 -2
- package/dist/esm/sdk/opportunities/OpportunitiesService.js +4 -1
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/positions/MultichainPositionsService.js +5 -2
- package/dist/esm/sdk/positions/PositionsService.js +8 -4
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/model/filters.d.ts +30 -0
- package/dist/types/model/filters.schema.d.ts +16 -0
- package/dist/types/model/index.d.ts +3 -1
- package/dist/types/model/liquidations.d.ts +14 -10
- package/dist/types/model/liquidations.schema.d.ts +5 -5
- package/dist/types/model/opportunities.d.ts +15 -11
- package/dist/types/model/opportunities.schema.d.ts +6 -6
- package/dist/types/model/positions.d.ts +14 -10
- package/dist/types/model/positions.schema.d.ts +4 -4
- package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/types.d.ts +1 -1
- package/dist/types/sdk/base/types.d.ts +1 -1
- package/dist/types/sdk/market/MarketSuite.d.ts +1 -1
- package/dist/types/sdk/positions/PositionsService.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/model/filters.ts
|
|
3
|
+
/**
|
|
4
|
+
* The vocabulary every read-model filter is written in: how a single condition
|
|
5
|
+
* says "do not narrow", and how a predicate asks whether it narrows at all.
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Sentinel a filter condition can be set to instead of being omitted.
|
|
9
|
+
**/
|
|
10
|
+
const FILTER_ALL = "all";
|
|
11
|
+
/**
|
|
12
|
+
* Whether a condition narrows anything. An omitted condition and one set to
|
|
13
|
+
* {@link FILTER_ALL} both do not, so this is the only check a predicate needs.
|
|
14
|
+
**/
|
|
15
|
+
function isFilterSet(condition) {
|
|
16
|
+
return condition !== void 0 && condition !== "all";
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.FILTER_ALL = FILTER_ALL;
|
|
20
|
+
exports.isFilterSet = isFilterSet;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./filters.js");
|
|
3
|
+
let zod_v4 = require("zod/v4");
|
|
4
|
+
//#region src/model/filters.schema.ts
|
|
5
|
+
/**
|
|
6
|
+
* Runtime schemas for {@link ./filters.js}, see the note in
|
|
7
|
+
* `primitives.schema.ts` on why they are written by hand.
|
|
8
|
+
**/
|
|
9
|
+
/**
|
|
10
|
+
* {@link FilterAll}
|
|
11
|
+
**/
|
|
12
|
+
const filterAllSchema = zod_v4.z.literal("all");
|
|
13
|
+
/**
|
|
14
|
+
* {@link Filterable}
|
|
15
|
+
**/
|
|
16
|
+
function filterable(schema) {
|
|
17
|
+
return zod_v4.z.union([schema, filterAllSchema]);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.filterAllSchema = filterAllSchema;
|
|
21
|
+
exports.filterable = filterable;
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./curators.js");
|
|
3
3
|
const require_model_curators_schema = require("./curators.schema.js");
|
|
4
|
+
const require_model_filters = require("./filters.js");
|
|
5
|
+
const require_model_filters_schema = require("./filters.schema.js");
|
|
4
6
|
const require_model_history = require("./history.js");
|
|
5
7
|
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
6
8
|
const require_model_opportunities_schema = require("./opportunities.schema.js");
|
|
@@ -11,6 +13,7 @@ const require_model_liquidations = require("./liquidations.js");
|
|
|
11
13
|
const require_model_opportunities = require("./opportunities.js");
|
|
12
14
|
const require_model_positions = require("./positions.js");
|
|
13
15
|
require("./primitives.js");
|
|
16
|
+
exports.FILTER_ALL = require_model_filters.FILTER_ALL;
|
|
14
17
|
exports.POOL_HISTORY_METRICS = require_model_history.POOL_HISTORY_METRICS;
|
|
15
18
|
exports.POOL_POSITION_HISTORY_METRICS = require_model_history.POOL_POSITION_HISTORY_METRICS;
|
|
16
19
|
exports.STRATEGY_HISTORY_METRICS = require_model_history.STRATEGY_HISTORY_METRICS;
|
|
@@ -23,12 +26,15 @@ exports.chainIdSchema = require_model_primitives_schema.chainIdSchema;
|
|
|
23
26
|
exports.curatorNameSchema = require_model_curators_schema.curatorNameSchema;
|
|
24
27
|
exports.curatorSchema = require_model_curators_schema.curatorSchema;
|
|
25
28
|
exports.delayedReceivedAssetSchema = require_model_liquidations_schema.delayedReceivedAssetSchema;
|
|
29
|
+
exports.filterAllSchema = require_model_filters_schema.filterAllSchema;
|
|
30
|
+
exports.filterable = require_model_filters_schema.filterable;
|
|
26
31
|
exports.historyChartMetadataSchema = require_model_history_schema.historyChartMetadataSchema;
|
|
27
32
|
exports.historyMetricSchema = require_model_history_schema.historyMetricSchema;
|
|
28
33
|
exports.historyPointSchema = require_model_history_schema.historyPointSchema;
|
|
29
34
|
exports.historyRangeSchema = require_model_history_schema.historyRangeSchema;
|
|
30
35
|
exports.historySeriesSchema = require_model_history_schema.historySeriesSchema;
|
|
31
36
|
exports.instantReceivedAssetSchema = require_model_liquidations_schema.instantReceivedAssetSchema;
|
|
37
|
+
exports.isFilterSet = require_model_filters.isFilterSet;
|
|
32
38
|
exports.leverageSchema = require_model_primitives_schema.leverageSchema;
|
|
33
39
|
exports.liquidatableAccountFilterSchema = require_model_liquidations_schema.liquidatableAccountFilterSchema;
|
|
34
40
|
exports.liquidatableAccountSchema = require_model_liquidations_schema.liquidatableAccountSchema;
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_filters = require("./filters.js");
|
|
2
3
|
//#region src/model/liquidations.ts
|
|
3
4
|
/**
|
|
4
|
-
* Whether a liquidatable account satisfies every
|
|
5
|
+
* Whether a liquidatable account satisfies every condition of a filter.
|
|
5
6
|
*
|
|
6
|
-
* This is the single definition of what each
|
|
7
|
+
* This is the single definition of what each condition means: every source
|
|
7
8
|
* builds its rows first and runs them through here, so the chain and the
|
|
8
9
|
* backend cannot disagree on what a filter selects.
|
|
9
10
|
*
|
|
10
11
|
* @param account - Row to test.
|
|
11
|
-
* @param filter -
|
|
12
|
+
* @param filter - Conditions to test against. An absent filter matches
|
|
13
|
+
* anything.
|
|
12
14
|
**/
|
|
13
15
|
function matchesLiquidatableAccountFilter(account, filter) {
|
|
14
16
|
if (!filter) return true;
|
|
15
|
-
if (filter.chainIds && !filter.chainIds.includes(account.chainId)) return false;
|
|
16
|
-
if (filter.underlyingType && account.totalValue.token.assetType !== filter.underlyingType) return false;
|
|
17
|
-
if (filter.paused
|
|
18
|
-
if (filter.rwa
|
|
19
|
-
if (filter.delayed
|
|
17
|
+
if (require_model_filters.isFilterSet(filter.chainIds) && !filter.chainIds.includes(account.chainId)) return false;
|
|
18
|
+
if (require_model_filters.isFilterSet(filter.underlyingType) && account.totalValue.token.assetType !== filter.underlyingType) return false;
|
|
19
|
+
if (require_model_filters.isFilterSet(filter.paused) && account.paused !== filter.paused) return false;
|
|
20
|
+
if (require_model_filters.isFilterSet(filter.rwa) && account.rwa !== filter.rwa) return false;
|
|
21
|
+
if (require_model_filters.isFilterSet(filter.delayed) && account.isDelayed !== filter.delayed) return false;
|
|
20
22
|
return true;
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_sdk_utils_zod = require("../sdk/utils/zod.js");
|
|
3
|
+
const require_model_filters_schema = require("./filters.schema.js");
|
|
3
4
|
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
4
5
|
let zod_v4 = require("zod/v4");
|
|
5
6
|
//#region src/model/liquidations.schema.ts
|
|
@@ -11,11 +12,11 @@ let zod_v4 = require("zod/v4");
|
|
|
11
12
|
* {@link LiquidatableAccountFilter}
|
|
12
13
|
**/
|
|
13
14
|
const liquidatableAccountFilterSchema = zod_v4.z.object({
|
|
14
|
-
chainIds: zod_v4.z.array(require_model_primitives_schema.chainIdSchema).optional(),
|
|
15
|
-
underlyingType: require_model_primitives_schema.assetTypeSchema.optional(),
|
|
16
|
-
paused: zod_v4.z.boolean().optional(),
|
|
17
|
-
rwa: zod_v4.z.boolean().optional(),
|
|
18
|
-
delayed: zod_v4.z.boolean().optional()
|
|
15
|
+
chainIds: require_model_filters_schema.filterable(zod_v4.z.array(require_model_primitives_schema.chainIdSchema)).optional(),
|
|
16
|
+
underlyingType: require_model_filters_schema.filterable(require_model_primitives_schema.assetTypeSchema).optional(),
|
|
17
|
+
paused: require_model_filters_schema.filterable(zod_v4.z.boolean()).optional(),
|
|
18
|
+
rwa: require_model_filters_schema.filterable(zod_v4.z.boolean()).optional(),
|
|
19
|
+
delayed: require_model_filters_schema.filterable(zod_v4.z.boolean()).optional()
|
|
19
20
|
});
|
|
20
21
|
/**
|
|
21
22
|
* {@link LiquidatableAccount}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_filters = require("./filters.js");
|
|
2
3
|
//#region src/model/opportunities.ts
|
|
3
4
|
/**
|
|
4
5
|
* Builds the canonical id of a pool opportunity.
|
|
@@ -29,23 +30,24 @@ function opportunityId(opportunity) {
|
|
|
29
30
|
return opportunity.kind === "pool" ? poolOpportunityId(opportunity.chainId, opportunity.pool) : strategyOpportunityId(opportunity.chainId, opportunity.creditManager, opportunity.targetCollateral.address);
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
|
-
* Whether an opportunity satisfies every
|
|
33
|
+
* Whether an opportunity satisfies every condition of a filter.
|
|
33
34
|
*
|
|
34
|
-
* This is the single definition of what each
|
|
35
|
+
* This is the single definition of what each condition means: every source
|
|
35
36
|
* builds its rows first and runs them through here, so the chain and the
|
|
36
37
|
* backend cannot disagree on what a filter selects.
|
|
37
38
|
*
|
|
38
39
|
* @param opportunity - Row to test.
|
|
39
|
-
* @param filter -
|
|
40
|
+
* @param filter - Conditions to test against. An absent filter matches
|
|
41
|
+
* anything.
|
|
40
42
|
**/
|
|
41
43
|
function matchesOpportunityFilter(opportunity, filter) {
|
|
42
44
|
if (!filter) return true;
|
|
43
|
-
if (filter.kind && opportunity.kind !== filter.kind) return false;
|
|
44
|
-
if (filter.chainIds && !filter.chainIds.includes(opportunity.chainId)) return false;
|
|
45
|
-
if (filter.underlyingType && opportunity.underlyingToken.assetType !== filter.underlyingType) return false;
|
|
46
|
-
if (filter.paused
|
|
47
|
-
if (filter.sunset
|
|
48
|
-
if (filter.rwa
|
|
45
|
+
if (require_model_filters.isFilterSet(filter.kind) && opportunity.kind !== filter.kind) return false;
|
|
46
|
+
if (require_model_filters.isFilterSet(filter.chainIds) && !filter.chainIds.includes(opportunity.chainId)) return false;
|
|
47
|
+
if (require_model_filters.isFilterSet(filter.underlyingType) && opportunity.underlyingToken.assetType !== filter.underlyingType) return false;
|
|
48
|
+
if (require_model_filters.isFilterSet(filter.paused) && opportunity.paused !== filter.paused) return false;
|
|
49
|
+
if (require_model_filters.isFilterSet(filter.sunset) && opportunity.sunset !== filter.sunset) return false;
|
|
50
|
+
if (require_model_filters.isFilterSet(filter.rwa) && opportunity.rwa !== filter.rwa) return false;
|
|
49
51
|
return true;
|
|
50
52
|
}
|
|
51
53
|
//#endregion
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_sdk_utils_zod = require("../sdk/utils/zod.js");
|
|
3
3
|
const require_model_curators_schema = require("./curators.schema.js");
|
|
4
|
+
const require_model_filters_schema = require("./filters.schema.js");
|
|
4
5
|
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
5
6
|
let zod_v4 = require("zod/v4");
|
|
6
7
|
//#region src/model/opportunities.schema.ts
|
|
@@ -103,12 +104,12 @@ const opportunitySchema = zod_v4.z.discriminatedUnion("kind", [poolOpportunitySc
|
|
|
103
104
|
* {@link OpportunityFilter}
|
|
104
105
|
**/
|
|
105
106
|
const opportunityFilterSchema = zod_v4.z.object({
|
|
106
|
-
kind: opportunityKindSchema.optional(),
|
|
107
|
-
chainIds: zod_v4.z.array(require_model_primitives_schema.chainIdSchema).optional(),
|
|
108
|
-
underlyingType: require_model_primitives_schema.assetTypeSchema.optional(),
|
|
109
|
-
paused: zod_v4.z.boolean().optional(),
|
|
110
|
-
sunset: zod_v4.z.boolean().optional(),
|
|
111
|
-
rwa: zod_v4.z.boolean().optional()
|
|
107
|
+
kind: require_model_filters_schema.filterable(opportunityKindSchema).optional(),
|
|
108
|
+
chainIds: require_model_filters_schema.filterable(zod_v4.z.array(require_model_primitives_schema.chainIdSchema)).optional(),
|
|
109
|
+
underlyingType: require_model_filters_schema.filterable(require_model_primitives_schema.assetTypeSchema).optional(),
|
|
110
|
+
paused: require_model_filters_schema.filterable(zod_v4.z.boolean()).optional(),
|
|
111
|
+
sunset: require_model_filters_schema.filterable(zod_v4.z.boolean()).optional(),
|
|
112
|
+
rwa: require_model_filters_schema.filterable(zod_v4.z.boolean()).optional()
|
|
112
113
|
});
|
|
113
114
|
/**
|
|
114
115
|
* {@link RateCurvePoint}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_filters = require("./filters.js");
|
|
2
3
|
//#region src/model/positions.ts
|
|
3
4
|
/**
|
|
4
5
|
* Builds the canonical id of a pool position.
|
|
@@ -46,26 +47,27 @@ function positionId(position) {
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
|
-
* Whether a position satisfies every
|
|
50
|
+
* Whether a position satisfies every condition of a filter.
|
|
50
51
|
*
|
|
51
|
-
* This is the single definition of what each
|
|
52
|
+
* This is the single definition of what each condition means: every source
|
|
52
53
|
* builds its rows first and runs them through here, so the chain and the
|
|
53
54
|
* backend cannot disagree on what a filter selects.
|
|
54
55
|
*
|
|
55
|
-
* A
|
|
56
|
+
* A condition that does not apply to a position's kind keeps the row rather
|
|
56
57
|
* than dropping it: `isZeroDebt` says nothing about a pool position, and
|
|
57
58
|
* `underlyingType` says nothing about a liquidation position, which is
|
|
58
59
|
* denominated in whatever its withdrawal pays out.
|
|
59
60
|
*
|
|
60
61
|
* @param position - Row to test.
|
|
61
|
-
* @param filter -
|
|
62
|
+
* @param filter - Conditions to test against. An absent filter matches
|
|
63
|
+
* anything.
|
|
62
64
|
**/
|
|
63
65
|
function matchesPositionFilter(position, filter) {
|
|
64
66
|
if (!filter) return true;
|
|
65
|
-
if (filter.kind && position.kind !== filter.kind) return false;
|
|
66
|
-
if (filter.chainIds && !filter.chainIds.includes(position.chainId)) return false;
|
|
67
|
-
if (filter.isZeroDebt
|
|
68
|
-
if (filter.underlyingType) {
|
|
67
|
+
if (require_model_filters.isFilterSet(filter.kind) && position.kind !== filter.kind) return false;
|
|
68
|
+
if (require_model_filters.isFilterSet(filter.chainIds) && !filter.chainIds.includes(position.chainId)) return false;
|
|
69
|
+
if (require_model_filters.isFilterSet(filter.isZeroDebt) && position.kind === "strategy" && position.totalDebt.value === 0n !== filter.isZeroDebt) return false;
|
|
70
|
+
if (require_model_filters.isFilterSet(filter.underlyingType)) {
|
|
69
71
|
const underlying = positionUnderlying(position);
|
|
70
72
|
if (underlying && underlying.assetType !== filter.underlyingType) return false;
|
|
71
73
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_sdk_utils_zod = require("../sdk/utils/zod.js");
|
|
3
|
+
const require_model_filters_schema = require("./filters.schema.js");
|
|
3
4
|
const require_model_primitives_schema = require("./primitives.schema.js");
|
|
4
5
|
const require_model_opportunities_schema = require("./opportunities.schema.js");
|
|
5
6
|
const require_model_liquidations_schema = require("./liquidations.schema.js");
|
|
@@ -101,10 +102,10 @@ const positionSchema = zod_v4.z.discriminatedUnion("kind", [
|
|
|
101
102
|
* {@link PositionFilter}
|
|
102
103
|
**/
|
|
103
104
|
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()
|
|
105
|
+
kind: require_model_filters_schema.filterable(positionKindSchema).optional(),
|
|
106
|
+
isZeroDebt: require_model_filters_schema.filterable(zod_v4.z.boolean()).optional(),
|
|
107
|
+
chainIds: require_model_filters_schema.filterable(zod_v4.z.array(require_model_primitives_schema.chainIdSchema)).optional(),
|
|
108
|
+
underlyingType: require_model_filters_schema.filterable(require_model_primitives_schema.assetTypeSchema).optional()
|
|
108
109
|
});
|
|
109
110
|
/**
|
|
110
111
|
* {@link PoolPositionKey}
|
|
@@ -8,6 +8,7 @@ const require_sdk_market_math = require("./math.js");
|
|
|
8
8
|
const require_sdk_market_credit_CreditSuite = require("./credit/CreditSuite.js");
|
|
9
9
|
require("./credit/index.js");
|
|
10
10
|
const require_sdk_market_MarketConfiguratorContract = require("./MarketConfiguratorContract.js");
|
|
11
|
+
const require_model_filters = require("../../model/filters.js");
|
|
11
12
|
const require_model_opportunities = require("../../model/opportunities.js");
|
|
12
13
|
require("../../model/index.js");
|
|
13
14
|
const require_sdk_market_loss_policy_createLossPolicy = require("./loss-policy/createLossPolicy.js");
|
|
@@ -200,12 +201,13 @@ var MarketSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
200
201
|
* @param filter - Optional narrowing. A filter naming a kind skips building
|
|
201
202
|
* the other kind entirely; every built row is then checked in full by
|
|
202
203
|
* {@link matchesOpportunityFilter}, so there is one definition of what each
|
|
203
|
-
*
|
|
204
|
+
* condition means.
|
|
204
205
|
*/
|
|
205
206
|
opportunities(filter) {
|
|
206
207
|
const rows = [];
|
|
207
|
-
|
|
208
|
-
if (
|
|
208
|
+
const kind = filter?.kind;
|
|
209
|
+
if (!require_model_filters.isFilterSet(kind) || kind === "pool") rows.push(this.poolOpportunity());
|
|
210
|
+
if (!require_model_filters.isFilterSet(kind) || kind === "strategy") for (const { suite, collateral } of this.strategies) rows.push(suite.strategyOpportunity(collateral));
|
|
209
211
|
return rows.filter((row) => require_model_opportunities.matchesOpportunityFilter(row, filter));
|
|
210
212
|
}
|
|
211
213
|
/**
|
|
@@ -2,6 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_sdk_chain_chains = require("../chain/chains.js");
|
|
3
3
|
const require_sdk_base_MultichainConstruct = require("../base/MultichainConstruct.js");
|
|
4
4
|
require("../base/index.js");
|
|
5
|
+
const require_model_filters = require("../../model/filters.js");
|
|
6
|
+
require("../../model/index.js");
|
|
5
7
|
//#region src/sdk/opportunities/MultichainOpportunitiesService.ts
|
|
6
8
|
/**
|
|
7
9
|
* Cross-chain counterpart of {@link OpportunitiesService}.
|
|
@@ -46,9 +48,10 @@ var MultichainOpportunitiesService = class extends require_sdk_base_MultichainCo
|
|
|
46
48
|
* a filter naming them is a narrowing, not a request.
|
|
47
49
|
**/
|
|
48
50
|
#networksOf(filter) {
|
|
49
|
-
|
|
51
|
+
const chainIds = filter?.chainIds;
|
|
52
|
+
if (!require_model_filters.isFilterSet(chainIds)) return;
|
|
50
53
|
const networks = [];
|
|
51
|
-
for (const chainId of
|
|
54
|
+
for (const chainId of chainIds) try {
|
|
52
55
|
networks.push(require_sdk_chain_chains.getNetworkType(chainId));
|
|
53
56
|
} catch {
|
|
54
57
|
this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in opportunities filter`);
|
|
@@ -1,6 +1,8 @@
|
|
|
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_model_filters = require("../../model/filters.js");
|
|
5
|
+
require("../../model/index.js");
|
|
4
6
|
//#region src/sdk/opportunities/OpportunitiesService.ts
|
|
5
7
|
/**
|
|
6
8
|
* Builds the `opportunities` read model from the chain.
|
|
@@ -22,7 +24,8 @@ var OpportunitiesService = class extends require_sdk_base_SDKConstruct.SDKConstr
|
|
|
22
24
|
* @param filter - Optional narrowing, applied to the built rows.
|
|
23
25
|
**/
|
|
24
26
|
async list(filter) {
|
|
25
|
-
|
|
27
|
+
const chainIds = filter?.chainIds;
|
|
28
|
+
if (require_model_filters.isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
|
|
26
29
|
return this.sdk.marketRegister.markets.flatMap((market) => market.opportunities(filter));
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
@@ -2,6 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_sdk_chain_chains = require("../chain/chains.js");
|
|
3
3
|
const require_sdk_base_MultichainConstruct = require("../base/MultichainConstruct.js");
|
|
4
4
|
require("../base/index.js");
|
|
5
|
+
const require_model_filters = require("../../model/filters.js");
|
|
6
|
+
require("../../model/index.js");
|
|
5
7
|
//#region src/sdk/positions/MultichainPositionsService.ts
|
|
6
8
|
/**
|
|
7
9
|
* Cross-chain counterpart of {@link PositionsService}.
|
|
@@ -34,9 +36,10 @@ var MultichainPositionsService = class extends require_sdk_base_MultichainConstr
|
|
|
34
36
|
* a filter naming them is a narrowing, not a request.
|
|
35
37
|
**/
|
|
36
38
|
#networksOf(filter) {
|
|
37
|
-
|
|
39
|
+
const chainIds = filter?.chainIds;
|
|
40
|
+
if (!require_model_filters.isFilterSet(chainIds)) return;
|
|
38
41
|
const networks = [];
|
|
39
|
-
for (const chainId of
|
|
42
|
+
for (const chainId of chainIds) try {
|
|
40
43
|
networks.push(require_sdk_chain_chains.getNetworkType(chainId));
|
|
41
44
|
} catch {
|
|
42
45
|
this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in positions filter`);
|
|
@@ -1,6 +1,7 @@
|
|
|
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_model_filters = require("../../model/filters.js");
|
|
4
5
|
const require_model_positions = require("../../model/positions.js");
|
|
5
6
|
require("../../model/index.js");
|
|
6
7
|
//#region src/sdk/positions/PositionsService.ts
|
|
@@ -13,18 +14,21 @@ var PositionsService = class extends require_sdk_base_SDKConstruct.SDKConstruct
|
|
|
13
14
|
/**
|
|
14
15
|
* Every position of a wallet on this chain, optionally narrowed by
|
|
15
16
|
* {@link PositionFilter} (see {@link matchesPositionFilter} for what each
|
|
16
|
-
*
|
|
17
|
+
* condition selects). Reads live chain state, so rows reflect the moment of
|
|
17
18
|
* the call rather than the SDK's loaded snapshot.
|
|
18
19
|
**/
|
|
19
20
|
async list(props) {
|
|
20
21
|
const { wallet, filter } = props;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const chainIds = filter?.chainIds;
|
|
23
|
+
if (require_model_filters.isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
|
|
24
|
+
const wantedKind = filter?.kind;
|
|
25
|
+
const wanted = (kind) => !require_model_filters.isFilterSet(wantedKind) || wantedKind === kind;
|
|
26
|
+
const isZeroDebt = filter?.isZeroDebt;
|
|
23
27
|
const [pool, strategy, liquidation] = await Promise.all([
|
|
24
28
|
wanted("pool") ? this.sdk.pools.listPositions({ wallet }) : Promise.resolve([]),
|
|
25
29
|
wanted("strategy") ? this.sdk.accounts.listPositions({
|
|
26
30
|
owner: wallet,
|
|
27
|
-
includeZeroDebt:
|
|
31
|
+
includeZeroDebt: !require_model_filters.isFilterSet(isZeroDebt) || isZeroDebt
|
|
28
32
|
}) : Promise.resolve([]),
|
|
29
33
|
wanted("liquidation") ? this.sdk.liquidations.getLiquidationPositions({ liquidator: wallet }) : Promise.resolve([])
|
|
30
34
|
]);
|
|
@@ -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";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/model/filters.ts
|
|
2
|
+
/**
|
|
3
|
+
* The vocabulary every read-model filter is written in: how a single condition
|
|
4
|
+
* says "do not narrow", and how a predicate asks whether it narrows at all.
|
|
5
|
+
**/
|
|
6
|
+
/**
|
|
7
|
+
* Sentinel a filter condition can be set to instead of being omitted.
|
|
8
|
+
**/
|
|
9
|
+
const FILTER_ALL = "all";
|
|
10
|
+
/**
|
|
11
|
+
* Whether a condition narrows anything. An omitted condition and one set to
|
|
12
|
+
* {@link FILTER_ALL} both do not, so this is the only check a predicate needs.
|
|
13
|
+
**/
|
|
14
|
+
function isFilterSet(condition) {
|
|
15
|
+
return condition !== void 0 && condition !== "all";
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { FILTER_ALL, isFilterSet };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "./filters.js";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
//#region src/model/filters.schema.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runtime schemas for {@link ./filters.js}, see the note in
|
|
6
|
+
* `primitives.schema.ts` on why they are written by hand.
|
|
7
|
+
**/
|
|
8
|
+
/**
|
|
9
|
+
* {@link FilterAll}
|
|
10
|
+
**/
|
|
11
|
+
const filterAllSchema = z.literal("all");
|
|
12
|
+
/**
|
|
13
|
+
* {@link Filterable}
|
|
14
|
+
**/
|
|
15
|
+
function filterable(schema) {
|
|
16
|
+
return z.union([schema, filterAllSchema]);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { filterAllSchema, filterable };
|
package/dist/esm/model/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "./curators.js";
|
|
2
2
|
import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
|
|
3
|
+
import { FILTER_ALL, isFilterSet } from "./filters.js";
|
|
4
|
+
import { filterAllSchema, filterable } from "./filters.schema.js";
|
|
3
5
|
import { POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS } from "./history.js";
|
|
4
6
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
|
|
5
7
|
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";
|
|
@@ -10,4 +12,4 @@ import { matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
|
10
12
|
import { matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
|
|
11
13
|
import { liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
|
|
12
14
|
import "./primitives.js";
|
|
13
|
-
export { POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorNameSchema, 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 };
|
|
15
|
+
export { FILTER_ALL, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorNameSchema, curatorSchema, delayedReceivedAssetSchema, filterAllSchema, filterable, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, isFilterSet, 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,21 +1,23 @@
|
|
|
1
|
+
import { isFilterSet } from "./filters.js";
|
|
1
2
|
//#region src/model/liquidations.ts
|
|
2
3
|
/**
|
|
3
|
-
* Whether a liquidatable account satisfies every
|
|
4
|
+
* Whether a liquidatable account satisfies every condition of a filter.
|
|
4
5
|
*
|
|
5
|
-
* This is the single definition of what each
|
|
6
|
+
* This is the single definition of what each condition means: every source
|
|
6
7
|
* builds its rows first and runs them through here, so the chain and the
|
|
7
8
|
* backend cannot disagree on what a filter selects.
|
|
8
9
|
*
|
|
9
10
|
* @param account - Row to test.
|
|
10
|
-
* @param filter -
|
|
11
|
+
* @param filter - Conditions to test against. An absent filter matches
|
|
12
|
+
* anything.
|
|
11
13
|
**/
|
|
12
14
|
function matchesLiquidatableAccountFilter(account, filter) {
|
|
13
15
|
if (!filter) return true;
|
|
14
|
-
if (filter.chainIds && !filter.chainIds.includes(account.chainId)) return false;
|
|
15
|
-
if (filter.underlyingType && account.totalValue.token.assetType !== filter.underlyingType) return false;
|
|
16
|
-
if (filter.paused
|
|
17
|
-
if (filter.rwa
|
|
18
|
-
if (filter.delayed
|
|
16
|
+
if (isFilterSet(filter.chainIds) && !filter.chainIds.includes(account.chainId)) return false;
|
|
17
|
+
if (isFilterSet(filter.underlyingType) && account.totalValue.token.assetType !== filter.underlyingType) return false;
|
|
18
|
+
if (isFilterSet(filter.paused) && account.paused !== filter.paused) return false;
|
|
19
|
+
if (isFilterSet(filter.rwa) && account.rwa !== filter.rwa) return false;
|
|
20
|
+
if (isFilterSet(filter.delayed) && account.isDelayed !== filter.delayed) return false;
|
|
19
21
|
return true;
|
|
20
22
|
}
|
|
21
23
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ZodAddress } from "../sdk/utils/zod.js";
|
|
2
|
+
import { filterable } from "./filters.schema.js";
|
|
2
3
|
import { assetTypeSchema, chainIdSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
|
|
3
4
|
import { z } from "zod/v4";
|
|
4
5
|
//#region src/model/liquidations.schema.ts
|
|
@@ -10,11 +11,11 @@ import { z } from "zod/v4";
|
|
|
10
11
|
* {@link LiquidatableAccountFilter}
|
|
11
12
|
**/
|
|
12
13
|
const liquidatableAccountFilterSchema = z.object({
|
|
13
|
-
chainIds: z.array(chainIdSchema).optional(),
|
|
14
|
-
underlyingType: assetTypeSchema.optional(),
|
|
15
|
-
paused: z.boolean().optional(),
|
|
16
|
-
rwa: z.boolean().optional(),
|
|
17
|
-
delayed: z.boolean().optional()
|
|
14
|
+
chainIds: filterable(z.array(chainIdSchema)).optional(),
|
|
15
|
+
underlyingType: filterable(assetTypeSchema).optional(),
|
|
16
|
+
paused: filterable(z.boolean()).optional(),
|
|
17
|
+
rwa: filterable(z.boolean()).optional(),
|
|
18
|
+
delayed: filterable(z.boolean()).optional()
|
|
18
19
|
});
|
|
19
20
|
/**
|
|
20
21
|
* {@link LiquidatableAccount}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isFilterSet } from "./filters.js";
|
|
1
2
|
//#region src/model/opportunities.ts
|
|
2
3
|
/**
|
|
3
4
|
* Builds the canonical id of a pool opportunity.
|
|
@@ -28,23 +29,24 @@ function opportunityId(opportunity) {
|
|
|
28
29
|
return opportunity.kind === "pool" ? poolOpportunityId(opportunity.chainId, opportunity.pool) : strategyOpportunityId(opportunity.chainId, opportunity.creditManager, opportunity.targetCollateral.address);
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
|
-
* Whether an opportunity satisfies every
|
|
32
|
+
* Whether an opportunity satisfies every condition of a filter.
|
|
32
33
|
*
|
|
33
|
-
* This is the single definition of what each
|
|
34
|
+
* This is the single definition of what each condition means: every source
|
|
34
35
|
* builds its rows first and runs them through here, so the chain and the
|
|
35
36
|
* backend cannot disagree on what a filter selects.
|
|
36
37
|
*
|
|
37
38
|
* @param opportunity - Row to test.
|
|
38
|
-
* @param filter -
|
|
39
|
+
* @param filter - Conditions to test against. An absent filter matches
|
|
40
|
+
* anything.
|
|
39
41
|
**/
|
|
40
42
|
function matchesOpportunityFilter(opportunity, filter) {
|
|
41
43
|
if (!filter) return true;
|
|
42
|
-
if (filter.kind && opportunity.kind !== filter.kind) return false;
|
|
43
|
-
if (filter.chainIds && !filter.chainIds.includes(opportunity.chainId)) return false;
|
|
44
|
-
if (filter.underlyingType && opportunity.underlyingToken.assetType !== filter.underlyingType) return false;
|
|
45
|
-
if (filter.paused
|
|
46
|
-
if (filter.sunset
|
|
47
|
-
if (filter.rwa
|
|
44
|
+
if (isFilterSet(filter.kind) && opportunity.kind !== filter.kind) return false;
|
|
45
|
+
if (isFilterSet(filter.chainIds) && !filter.chainIds.includes(opportunity.chainId)) return false;
|
|
46
|
+
if (isFilterSet(filter.underlyingType) && opportunity.underlyingToken.assetType !== filter.underlyingType) return false;
|
|
47
|
+
if (isFilterSet(filter.paused) && opportunity.paused !== filter.paused) return false;
|
|
48
|
+
if (isFilterSet(filter.sunset) && opportunity.sunset !== filter.sunset) return false;
|
|
49
|
+
if (isFilterSet(filter.rwa) && opportunity.rwa !== filter.rwa) return false;
|
|
48
50
|
return true;
|
|
49
51
|
}
|
|
50
52
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ZodAddress } from "../sdk/utils/zod.js";
|
|
2
2
|
import { curatorSchema } from "./curators.schema.js";
|
|
3
|
+
import { filterable } from "./filters.schema.js";
|
|
3
4
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenSchema } from "./primitives.schema.js";
|
|
4
5
|
import { z } from "zod/v4";
|
|
5
6
|
//#region src/model/opportunities.schema.ts
|
|
@@ -102,12 +103,12 @@ const opportunitySchema = z.discriminatedUnion("kind", [poolOpportunitySchema, s
|
|
|
102
103
|
* {@link OpportunityFilter}
|
|
103
104
|
**/
|
|
104
105
|
const opportunityFilterSchema = z.object({
|
|
105
|
-
kind: opportunityKindSchema.optional(),
|
|
106
|
-
chainIds: z.array(chainIdSchema).optional(),
|
|
107
|
-
underlyingType: assetTypeSchema.optional(),
|
|
108
|
-
paused: z.boolean().optional(),
|
|
109
|
-
sunset: z.boolean().optional(),
|
|
110
|
-
rwa: z.boolean().optional()
|
|
106
|
+
kind: filterable(opportunityKindSchema).optional(),
|
|
107
|
+
chainIds: filterable(z.array(chainIdSchema)).optional(),
|
|
108
|
+
underlyingType: filterable(assetTypeSchema).optional(),
|
|
109
|
+
paused: filterable(z.boolean()).optional(),
|
|
110
|
+
sunset: filterable(z.boolean()).optional(),
|
|
111
|
+
rwa: filterable(z.boolean()).optional()
|
|
111
112
|
});
|
|
112
113
|
/**
|
|
113
114
|
* {@link RateCurvePoint}
|