@metamask-previews/earn-controller 0.14.0-preview-37f78da → 0.14.0-preview-d20538b

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.
@@ -1,336 +0,0 @@
1
- import type { LendingMarket } from "@metamask/stake-sdk";
2
- import { type Selector } from "reselect";
3
- import type { EarnControllerState, LendingMarketWithPosition, LendingPositionWithMarket } from "./EarnController.mjs";
4
- export declare const selectLendingMarkets: (state: EarnControllerState) => LendingMarket[];
5
- export declare const selectLendingPositions: (state: EarnControllerState) => import("./EarnController.mjs").LendingPositionWithMarketReference[];
6
- export declare const selectLendingMarketsByProtocolAndId: ((state: EarnControllerState) => Record<string, Record<string, LendingMarket>>) & {
7
- clearCache: () => void;
8
- resultsCount: () => number;
9
- resetResultsCount: () => void;
10
- } & {
11
- resultFunc: (resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>;
12
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>) & {
13
- clearCache: () => void;
14
- resultsCount: () => number;
15
- resetResultsCount: () => void;
16
- };
17
- lastResult: () => Record<string, Record<string, LendingMarket>>;
18
- dependencies: [(state: EarnControllerState) => LendingMarket[]];
19
- recomputations: () => number;
20
- resetRecomputations: () => void;
21
- dependencyRecomputations: () => number;
22
- resetDependencyRecomputations: () => void;
23
- } & {
24
- argsMemoize: typeof import("reselect").weakMapMemoize;
25
- memoize: typeof import("reselect").weakMapMemoize;
26
- };
27
- export declare const selectLendingMarketForProtocolAndId: ((state: EarnControllerState) => (protocol: string, id: string) => LendingMarket) & {
28
- clearCache: () => void;
29
- resultsCount: () => number;
30
- resetResultsCount: () => void;
31
- } & {
32
- resultFunc: (resultFuncArgs_0: Record<string, Record<string, LendingMarket>>) => (protocol: string, id: string) => LendingMarket;
33
- memoizedResultFunc: ((resultFuncArgs_0: Record<string, Record<string, LendingMarket>>) => (protocol: string, id: string) => LendingMarket) & {
34
- clearCache: () => void;
35
- resultsCount: () => number;
36
- resetResultsCount: () => void;
37
- };
38
- lastResult: () => (protocol: string, id: string) => LendingMarket;
39
- dependencies: [((state: EarnControllerState) => Record<string, Record<string, LendingMarket>>) & {
40
- clearCache: () => void;
41
- resultsCount: () => number;
42
- resetResultsCount: () => void;
43
- } & {
44
- resultFunc: (resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>;
45
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>) & {
46
- clearCache: () => void;
47
- resultsCount: () => number;
48
- resetResultsCount: () => void;
49
- };
50
- lastResult: () => Record<string, Record<string, LendingMarket>>;
51
- dependencies: [(state: EarnControllerState) => LendingMarket[]];
52
- recomputations: () => number;
53
- resetRecomputations: () => void;
54
- dependencyRecomputations: () => number;
55
- resetDependencyRecomputations: () => void;
56
- } & {
57
- argsMemoize: typeof import("reselect").weakMapMemoize;
58
- memoize: typeof import("reselect").weakMapMemoize;
59
- }];
60
- recomputations: () => number;
61
- resetRecomputations: () => void;
62
- dependencyRecomputations: () => number;
63
- resetDependencyRecomputations: () => void;
64
- } & {
65
- argsMemoize: typeof import("reselect").weakMapMemoize;
66
- memoize: typeof import("reselect").weakMapMemoize;
67
- };
68
- export declare const selectLendingMarketsForChainId: ((state: EarnControllerState) => (chainId: number) => LendingMarket[]) & {
69
- clearCache: () => void;
70
- resultsCount: () => number;
71
- resetResultsCount: () => void;
72
- } & {
73
- resultFunc: (resultFuncArgs_0: LendingMarket[]) => (chainId: number) => LendingMarket[];
74
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarket[]) => (chainId: number) => LendingMarket[]) & {
75
- clearCache: () => void;
76
- resultsCount: () => number;
77
- resetResultsCount: () => void;
78
- };
79
- lastResult: () => (chainId: number) => LendingMarket[];
80
- dependencies: [(state: EarnControllerState) => LendingMarket[]];
81
- recomputations: () => number;
82
- resetRecomputations: () => void;
83
- dependencyRecomputations: () => number;
84
- resetDependencyRecomputations: () => void;
85
- } & {
86
- argsMemoize: typeof import("reselect").weakMapMemoize;
87
- memoize: typeof import("reselect").weakMapMemoize;
88
- };
89
- export declare const selectLendingMarketsByChainId: ((state: EarnControllerState) => Record<number, LendingMarket[]>) & {
90
- clearCache: () => void;
91
- resultsCount: () => number;
92
- resetResultsCount: () => void;
93
- } & {
94
- resultFunc: (resultFuncArgs_0: LendingMarket[]) => Record<number, LendingMarket[]>;
95
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarket[]) => Record<number, LendingMarket[]>) & {
96
- clearCache: () => void;
97
- resultsCount: () => number;
98
- resetResultsCount: () => void;
99
- };
100
- lastResult: () => Record<number, LendingMarket[]>;
101
- dependencies: [(state: EarnControllerState) => LendingMarket[]];
102
- recomputations: () => number;
103
- resetRecomputations: () => void;
104
- dependencyRecomputations: () => number;
105
- resetDependencyRecomputations: () => void;
106
- } & {
107
- argsMemoize: typeof import("reselect").weakMapMemoize;
108
- memoize: typeof import("reselect").weakMapMemoize;
109
- };
110
- export declare const selectLendingPositionsWithMarket: ((state: EarnControllerState) => LendingPositionWithMarket[]) & {
111
- clearCache: () => void;
112
- resultsCount: () => number;
113
- resetResultsCount: () => void;
114
- } & {
115
- resultFunc: (resultFuncArgs_0: import("./EarnController.mjs").LendingPositionWithMarketReference[], resultFuncArgs_1: Record<string, Record<string, LendingMarket>>) => LendingPositionWithMarket[];
116
- memoizedResultFunc: ((resultFuncArgs_0: import("./EarnController.mjs").LendingPositionWithMarketReference[], resultFuncArgs_1: Record<string, Record<string, LendingMarket>>) => LendingPositionWithMarket[]) & {
117
- clearCache: () => void;
118
- resultsCount: () => number;
119
- resetResultsCount: () => void;
120
- };
121
- lastResult: () => LendingPositionWithMarket[];
122
- dependencies: [(state: EarnControllerState) => import("./EarnController.mjs").LendingPositionWithMarketReference[], ((state: EarnControllerState) => Record<string, Record<string, LendingMarket>>) & {
123
- clearCache: () => void;
124
- resultsCount: () => number;
125
- resetResultsCount: () => void;
126
- } & {
127
- resultFunc: (resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>;
128
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>) & {
129
- clearCache: () => void;
130
- resultsCount: () => number;
131
- resetResultsCount: () => void;
132
- };
133
- lastResult: () => Record<string, Record<string, LendingMarket>>;
134
- dependencies: [(state: EarnControllerState) => LendingMarket[]];
135
- recomputations: () => number;
136
- resetRecomputations: () => void;
137
- dependencyRecomputations: () => number;
138
- resetDependencyRecomputations: () => void;
139
- } & {
140
- argsMemoize: typeof import("reselect").weakMapMemoize;
141
- memoize: typeof import("reselect").weakMapMemoize;
142
- }];
143
- recomputations: () => number;
144
- resetRecomputations: () => void;
145
- dependencyRecomputations: () => number;
146
- resetDependencyRecomputations: () => void;
147
- } & {
148
- argsMemoize: typeof import("reselect").weakMapMemoize;
149
- memoize: typeof import("reselect").weakMapMemoize;
150
- };
151
- export declare const selectLendingPositionsByChainId: ((state: EarnControllerState) => Record<number, LendingPositionWithMarket[]>) & {
152
- clearCache: () => void;
153
- resultsCount: () => number;
154
- resetResultsCount: () => void;
155
- } & {
156
- resultFunc: (resultFuncArgs_0: LendingPositionWithMarket[]) => Record<number, LendingPositionWithMarket[]>;
157
- memoizedResultFunc: ((resultFuncArgs_0: LendingPositionWithMarket[]) => Record<number, LendingPositionWithMarket[]>) & {
158
- clearCache: () => void;
159
- resultsCount: () => number;
160
- resetResultsCount: () => void;
161
- };
162
- lastResult: () => Record<number, LendingPositionWithMarket[]>;
163
- dependencies: [((state: EarnControllerState) => LendingPositionWithMarket[]) & {
164
- clearCache: () => void;
165
- resultsCount: () => number;
166
- resetResultsCount: () => void;
167
- } & {
168
- resultFunc: (resultFuncArgs_0: import("./EarnController.mjs").LendingPositionWithMarketReference[], resultFuncArgs_1: Record<string, Record<string, LendingMarket>>) => LendingPositionWithMarket[];
169
- memoizedResultFunc: ((resultFuncArgs_0: import("./EarnController.mjs").LendingPositionWithMarketReference[], resultFuncArgs_1: Record<string, Record<string, LendingMarket>>) => LendingPositionWithMarket[]) & {
170
- clearCache: () => void;
171
- resultsCount: () => number;
172
- resetResultsCount: () => void;
173
- };
174
- lastResult: () => LendingPositionWithMarket[];
175
- dependencies: [(state: EarnControllerState) => import("./EarnController.mjs").LendingPositionWithMarketReference[], ((state: EarnControllerState) => Record<string, Record<string, LendingMarket>>) & {
176
- clearCache: () => void;
177
- resultsCount: () => number;
178
- resetResultsCount: () => void;
179
- } & {
180
- resultFunc: (resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>;
181
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>) & {
182
- clearCache: () => void;
183
- resultsCount: () => number;
184
- resetResultsCount: () => void;
185
- };
186
- lastResult: () => Record<string, Record<string, LendingMarket>>;
187
- dependencies: [(state: EarnControllerState) => LendingMarket[]];
188
- recomputations: () => number;
189
- resetRecomputations: () => void;
190
- dependencyRecomputations: () => number;
191
- resetDependencyRecomputations: () => void;
192
- } & {
193
- argsMemoize: typeof import("reselect").weakMapMemoize;
194
- memoize: typeof import("reselect").weakMapMemoize;
195
- }];
196
- recomputations: () => number;
197
- resetRecomputations: () => void;
198
- dependencyRecomputations: () => number;
199
- resetDependencyRecomputations: () => void;
200
- } & {
201
- argsMemoize: typeof import("reselect").weakMapMemoize;
202
- memoize: typeof import("reselect").weakMapMemoize;
203
- }];
204
- recomputations: () => number;
205
- resetRecomputations: () => void;
206
- dependencyRecomputations: () => number;
207
- resetDependencyRecomputations: () => void;
208
- } & {
209
- argsMemoize: typeof import("reselect").weakMapMemoize;
210
- memoize: typeof import("reselect").weakMapMemoize;
211
- };
212
- export declare const selectLendingMarketsWithPosition: Selector<EarnControllerState, LendingMarketWithPosition[]>;
213
- export declare const selectLendingPositionsByProtocol: ((state: EarnControllerState) => Record<string, LendingPositionWithMarket[]>) & {
214
- clearCache: () => void;
215
- resultsCount: () => number;
216
- resetResultsCount: () => void;
217
- } & {
218
- resultFunc: (resultFuncArgs_0: LendingPositionWithMarket[]) => Record<string, LendingPositionWithMarket[]>;
219
- memoizedResultFunc: ((resultFuncArgs_0: LendingPositionWithMarket[]) => Record<string, LendingPositionWithMarket[]>) & {
220
- clearCache: () => void;
221
- resultsCount: () => number;
222
- resetResultsCount: () => void;
223
- };
224
- lastResult: () => Record<string, LendingPositionWithMarket[]>;
225
- dependencies: [((state: EarnControllerState) => LendingPositionWithMarket[]) & {
226
- clearCache: () => void;
227
- resultsCount: () => number;
228
- resetResultsCount: () => void;
229
- } & {
230
- resultFunc: (resultFuncArgs_0: import("./EarnController.mjs").LendingPositionWithMarketReference[], resultFuncArgs_1: Record<string, Record<string, LendingMarket>>) => LendingPositionWithMarket[];
231
- memoizedResultFunc: ((resultFuncArgs_0: import("./EarnController.mjs").LendingPositionWithMarketReference[], resultFuncArgs_1: Record<string, Record<string, LendingMarket>>) => LendingPositionWithMarket[]) & {
232
- clearCache: () => void;
233
- resultsCount: () => number;
234
- resetResultsCount: () => void;
235
- };
236
- lastResult: () => LendingPositionWithMarket[];
237
- dependencies: [(state: EarnControllerState) => import("./EarnController.mjs").LendingPositionWithMarketReference[], ((state: EarnControllerState) => Record<string, Record<string, LendingMarket>>) & {
238
- clearCache: () => void;
239
- resultsCount: () => number;
240
- resetResultsCount: () => void;
241
- } & {
242
- resultFunc: (resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>;
243
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarket[]) => Record<string, Record<string, LendingMarket>>) & {
244
- clearCache: () => void;
245
- resultsCount: () => number;
246
- resetResultsCount: () => void;
247
- };
248
- lastResult: () => Record<string, Record<string, LendingMarket>>;
249
- dependencies: [(state: EarnControllerState) => LendingMarket[]];
250
- recomputations: () => number;
251
- resetRecomputations: () => void;
252
- dependencyRecomputations: () => number;
253
- resetDependencyRecomputations: () => void;
254
- } & {
255
- argsMemoize: typeof import("reselect").weakMapMemoize;
256
- memoize: typeof import("reselect").weakMapMemoize;
257
- }];
258
- recomputations: () => number;
259
- resetRecomputations: () => void;
260
- dependencyRecomputations: () => number;
261
- resetDependencyRecomputations: () => void;
262
- } & {
263
- argsMemoize: typeof import("reselect").weakMapMemoize;
264
- memoize: typeof import("reselect").weakMapMemoize;
265
- }];
266
- recomputations: () => number;
267
- resetRecomputations: () => void;
268
- dependencyRecomputations: () => number;
269
- resetDependencyRecomputations: () => void;
270
- } & {
271
- argsMemoize: typeof import("reselect").weakMapMemoize;
272
- memoize: typeof import("reselect").weakMapMemoize;
273
- };
274
- export declare const selectLendingMarketByProtocolAndTokenAddress: ((state: EarnControllerState, ...params: unknown[]) => Record<string, Record<string, LendingMarketWithPosition>>) & {
275
- clearCache: () => void;
276
- resultsCount: () => number;
277
- resetResultsCount: () => void;
278
- } & {
279
- resultFunc: (resultFuncArgs_0: LendingMarketWithPosition[]) => Record<string, Record<string, LendingMarketWithPosition>>;
280
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarketWithPosition[]) => Record<string, Record<string, LendingMarketWithPosition>>) & {
281
- clearCache: () => void;
282
- resultsCount: () => number;
283
- resetResultsCount: () => void;
284
- };
285
- lastResult: () => Record<string, Record<string, LendingMarketWithPosition>>;
286
- dependencies: [Selector<EarnControllerState, LendingMarketWithPosition[]>];
287
- recomputations: () => number;
288
- resetRecomputations: () => void;
289
- dependencyRecomputations: () => number;
290
- resetDependencyRecomputations: () => void;
291
- } & {
292
- argsMemoize: typeof import("reselect").weakMapMemoize;
293
- memoize: typeof import("reselect").weakMapMemoize;
294
- };
295
- export declare const selectLendingMarketForProtocolAndTokenAddress: ((state: EarnControllerState, ...params: unknown[]) => (protocol: string, tokenAddress: string) => LendingMarketWithPosition) & {
296
- clearCache: () => void;
297
- resultsCount: () => number;
298
- resetResultsCount: () => void;
299
- } & {
300
- resultFunc: (resultFuncArgs_0: Record<string, Record<string, LendingMarketWithPosition>>) => (protocol: string, tokenAddress: string) => LendingMarketWithPosition;
301
- memoizedResultFunc: ((resultFuncArgs_0: Record<string, Record<string, LendingMarketWithPosition>>) => (protocol: string, tokenAddress: string) => LendingMarketWithPosition) & {
302
- clearCache: () => void;
303
- resultsCount: () => number;
304
- resetResultsCount: () => void;
305
- };
306
- lastResult: () => (protocol: string, tokenAddress: string) => LendingMarketWithPosition;
307
- dependencies: [((state: EarnControllerState, ...params: unknown[]) => Record<string, Record<string, LendingMarketWithPosition>>) & {
308
- clearCache: () => void;
309
- resultsCount: () => number;
310
- resetResultsCount: () => void;
311
- } & {
312
- resultFunc: (resultFuncArgs_0: LendingMarketWithPosition[]) => Record<string, Record<string, LendingMarketWithPosition>>;
313
- memoizedResultFunc: ((resultFuncArgs_0: LendingMarketWithPosition[]) => Record<string, Record<string, LendingMarketWithPosition>>) & {
314
- clearCache: () => void;
315
- resultsCount: () => number;
316
- resetResultsCount: () => void;
317
- };
318
- lastResult: () => Record<string, Record<string, LendingMarketWithPosition>>;
319
- dependencies: [Selector<EarnControllerState, LendingMarketWithPosition[]>];
320
- recomputations: () => number;
321
- resetRecomputations: () => void;
322
- dependencyRecomputations: () => number;
323
- resetDependencyRecomputations: () => void;
324
- } & {
325
- argsMemoize: typeof import("reselect").weakMapMemoize;
326
- memoize: typeof import("reselect").weakMapMemoize;
327
- }];
328
- recomputations: () => number;
329
- resetRecomputations: () => void;
330
- dependencyRecomputations: () => number;
331
- resetDependencyRecomputations: () => void;
332
- } & {
333
- argsMemoize: typeof import("reselect").weakMapMemoize;
334
- memoize: typeof import("reselect").weakMapMemoize;
335
- };
336
- //# sourceMappingURL=selectors.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B;AACzD,OAAO,EAAkB,KAAK,QAAQ,EAAE,iBAAiB;AAEzD,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EAC1B,6BAAyB;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M,gBAAgB,MAAM;qHAA5B,MAAM,gBAAgB,MAAM;;;;;iCAA5B,MAAM,gBAAgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAE1C,CAAC"}
@@ -1,68 +0,0 @@
1
- import { createSelector } from "reselect";
2
- export const selectLendingMarkets = (state) => state.lending.markets;
3
- export const selectLendingPositions = (state) => state.lending.positions;
4
- export const selectLendingMarketsByProtocolAndId = createSelector(selectLendingMarkets, (markets) => {
5
- return markets.reduce((acc, market) => {
6
- acc[market.protocol] = acc[market.protocol] || {};
7
- acc[market.protocol][market.id] = market;
8
- return acc;
9
- }, {});
10
- });
11
- export const selectLendingMarketForProtocolAndId = createSelector(selectLendingMarketsByProtocolAndId, (marketsByProtocolAndId) => (protocol, id) => marketsByProtocolAndId?.[protocol]?.[id]);
12
- export const selectLendingMarketsForChainId = createSelector(selectLendingMarkets, (markets) => (chainId) => markets.filter((market) => market.chainId === chainId));
13
- export const selectLendingMarketsByChainId = createSelector(selectLendingMarkets, (markets) => {
14
- return markets.reduce((acc, market) => {
15
- acc[market.chainId] = acc[market.chainId] || [];
16
- acc[market.chainId].push(market);
17
- return acc;
18
- }, {});
19
- });
20
- export const selectLendingPositionsWithMarket = createSelector(selectLendingPositions, selectLendingMarketsByProtocolAndId, (positions, marketsByProtocolAndId) => {
21
- return positions.map((position) => {
22
- return {
23
- ...position,
24
- market: marketsByProtocolAndId?.[position.protocol]?.[position.marketId],
25
- };
26
- });
27
- });
28
- export const selectLendingPositionsByChainId = createSelector(selectLendingPositionsWithMarket, (positionsWithMarket) => {
29
- return positionsWithMarket.reduce((acc, position) => {
30
- const chainId = position.market?.chainId;
31
- if (chainId) {
32
- acc[chainId] = acc[chainId] || [];
33
- acc[chainId].push(position);
34
- }
35
- return acc;
36
- }, {});
37
- });
38
- export const selectLendingMarketsWithPosition = createSelector(selectLendingPositionsWithMarket, (positionsWithMarket) => {
39
- return positionsWithMarket
40
- .filter((position) => position.market !== undefined)
41
- .map((positionWithMarket) => {
42
- return {
43
- ...positionWithMarket.market,
44
- position: {
45
- ...positionWithMarket,
46
- market: undefined,
47
- },
48
- };
49
- });
50
- });
51
- export const selectLendingPositionsByProtocol = createSelector(selectLendingPositionsWithMarket, (positionsWithMarket) => {
52
- return positionsWithMarket.reduce((acc, position) => {
53
- acc[position.protocol] = acc[position.protocol] || [];
54
- acc[position.protocol].push(position);
55
- return acc;
56
- }, {});
57
- });
58
- export const selectLendingMarketByProtocolAndTokenAddress = createSelector(selectLendingMarketsWithPosition, (marketsWithPosition) => {
59
- return marketsWithPosition.reduce((acc, market) => {
60
- if (market.underlying?.address) {
61
- acc[market.protocol] = acc[market.protocol] || {};
62
- acc[market.protocol][market.underlying.address] = market;
63
- }
64
- return acc;
65
- }, {});
66
- });
67
- export const selectLendingMarketForProtocolAndTokenAddress = createSelector(selectLendingMarketByProtocolAndTokenAddress, (marketsByProtocolAndTokenAddress) => (protocol, tokenAddress) => marketsByProtocolAndTokenAddress?.[protocol]?.[tokenAddress]);
68
- //# sourceMappingURL=selectors.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAiB,iBAAiB;AAQzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAA0B,EAAE,EAAE,CACjE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAA0B,EAAE,EAAE,CACnE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;AAE1B,MAAM,CAAC,MAAM,mCAAmC,GAAG,cAAc,CAC/D,oBAAoB,EACpB,CAAC,OAAO,EAAE,EAAE;IACV,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACd,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAA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B,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE;QAChB,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtD,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAiD,CAClD,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,4CAA4C,GAAG,cAAc,CACxE,gCAAgC,EAChC,CAAC,mBAAmB,EAAE,EAAE;IACtB,OAAO,mBAAmB,CAAC,MAAM,CAC/B,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACd,IAAI,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE;YAC9B,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAClD,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;SAC1D;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAA+D,CAChE,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,6CAA6C,GAAG,cAAc,CACzE,4CAA4C,EAC5C,CAAC,gCAAgC,EAAE,EAAE,CACnC,CAAC,QAAgB,EAAE,YAAoB,EAAE,EAAE,CACzC,gCAAgC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,CACjE,CAAC","sourcesContent":["import type { LendingMarket } from '@metamask/stake-sdk';\nimport { createSelector, type Selector } from 'reselect';\n\nimport type {\n EarnControllerState,\n LendingMarketWithPosition,\n LendingPositionWithMarket,\n} from './EarnController';\n\nexport const selectLendingMarkets = (state: EarnControllerState) =>\n state.lending.markets;\n\nexport const selectLendingPositions = (state: EarnControllerState) =>\n state.lending.positions;\n\nexport const selectLendingMarketsByProtocolAndId = createSelector(\n selectLendingMarkets,\n (markets) => {\n return markets.reduce(\n (acc, market) => {\n acc[market.protocol] = acc[market.protocol] || {};\n acc[market.protocol][market.id] = market;\n return acc;\n },\n {} as Record<string, Record<string, LendingMarket>>,\n );\n },\n);\n\nexport const selectLendingMarketForProtocolAndId = createSelector(\n selectLendingMarketsByProtocolAndId,\n (marketsByProtocolAndId) => (protocol: string, id: string) =>\n marketsByProtocolAndId?.[protocol]?.[id],\n);\n\nexport const selectLendingMarketsForChainId = createSelector(\n selectLendingMarkets,\n (markets) => (chainId: number) =>\n markets.filter((market) => market.chainId === chainId),\n);\n\nexport const selectLendingMarketsByChainId = createSelector(\n selectLendingMarkets,\n (markets) => {\n return markets.reduce(\n (acc, market) => {\n acc[market.chainId] = acc[market.chainId] || [];\n acc[market.chainId].push(market);\n return acc;\n },\n {} as Record<number, LendingMarket[]>,\n );\n },\n);\n\nexport const selectLendingPositionsWithMarket = createSelector(\n selectLendingPositions,\n selectLendingMarketsByProtocolAndId,\n (positions, marketsByProtocolAndId): LendingPositionWithMarket[] => {\n return positions.map((position) => {\n return {\n ...position,\n market:\n marketsByProtocolAndId?.[position.protocol]?.[position.marketId],\n };\n });\n },\n);\n\nexport const selectLendingPositionsByChainId = createSelector(\n selectLendingPositionsWithMarket,\n (positionsWithMarket) => {\n return positionsWithMarket.reduce(\n (acc, position) => {\n const chainId = position.market?.chainId;\n if (chainId) {\n acc[chainId] = acc[chainId] || [];\n acc[chainId].push(position);\n }\n return acc;\n },\n {} as Record<number, LendingPositionWithMarket[]>,\n );\n },\n);\n\nexport const selectLendingMarketsWithPosition: Selector<\n EarnControllerState,\n LendingMarketWithPosition[]\n> = createSelector(selectLendingPositionsWithMarket, (positionsWithMarket) => {\n return positionsWithMarket\n .filter(\n (\n position,\n ): position is LendingPositionWithMarket & {\n market: NonNullable<LendingPositionWithMarket['market']>;\n } => position.market !== undefined,\n )\n .map((positionWithMarket) => {\n return {\n ...positionWithMarket.market,\n position: {\n ...positionWithMarket,\n market: undefined,\n },\n };\n });\n});\n\nexport const selectLendingPositionsByProtocol = createSelector(\n selectLendingPositionsWithMarket,\n (positionsWithMarket) => {\n return positionsWithMarket.reduce(\n (acc, position) => {\n acc[position.protocol] = acc[position.protocol] || [];\n acc[position.protocol].push(position);\n return acc;\n },\n {} as Record<string, LendingPositionWithMarket[]>,\n );\n },\n);\n\nexport const selectLendingMarketByProtocolAndTokenAddress = createSelector(\n selectLendingMarketsWithPosition,\n (marketsWithPosition) => {\n return marketsWithPosition.reduce(\n (acc, market) => {\n if (market.underlying?.address) {\n acc[market.protocol] = acc[market.protocol] || {};\n acc[market.protocol][market.underlying.address] = market;\n }\n return acc;\n },\n {} as Record<string, Record<string, LendingMarketWithPosition>>,\n );\n },\n);\n\nexport const selectLendingMarketForProtocolAndTokenAddress = createSelector(\n selectLendingMarketByProtocolAndTokenAddress,\n (marketsByProtocolAndTokenAddress) =>\n (protocol: string, tokenAddress: string) =>\n marketsByProtocolAndTokenAddress?.[protocol]?.[tokenAddress],\n);\n"]}