Skip to content

Commit 4dbe9ad

Browse files
committed
fix: useUserSummaryHistory hook, userSummaryHistory action, UserBalance fragment
1 parent f8c6ffa commit 4dbe9ad

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

packages/client/src/actions/user.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,14 @@ export function userHistory(
232232
*
233233
* @param client - Aave client.
234234
* @param request - The user summary history request parameters.
235+
* @param options - The query options.
235236
* @returns The user summary history items.
236237
*/
237238
export function userSummaryHistory(
238239
client: AaveClient,
239240
request: UserSummaryHistoryRequest,
241+
_options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,
240242
): ResultAsync<UserSummaryHistoryItem[], UnexpectedError> {
243+
// TODO: wire up _options once AAVE-1982 is implemented
241244
return client.query(UserSummaryHistoryQuery, { request });
242245
}

packages/client/src/ethers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function waitForTransactionResult(
6767
}
6868
return okAsync({
6969
txHash: hash,
70-
operations: request.operations, // TODO: check if this is correct
70+
operations: request.operations,
7171
});
7272
});
7373
}

packages/graphql/src/fragments/user.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import type { FragmentOf } from 'gql.tada';
2-
import { graphql } from '../graphql';
2+
import { type FragmentDocumentFor, graphql } from '../graphql';
33
import {
4+
type DecimalValue,
45
DecimalValueFragment,
56
Erc20AmountFragment,
7+
type FiatAmount,
68
FiatAmountFragment,
79
FiatAmountWithChangeFragment,
810
HealthFactorChangeFragment,
911
PaginatedResultInfoFragment,
12+
type PercentValue,
1013
PercentValueFragment,
1114
PercentValueWithChangeFragment,
15+
type TokenAmount,
1216
TokenAmountFragment,
17+
type TokenInfo,
1318
TokenInfoFragment,
1419
} from './common';
1520
import { ReserveFragment, ReserveInfoFragment } from './reserve';
@@ -133,7 +138,30 @@ export const UserPositionFragment = graphql(
133138
);
134139
export type UserPosition = FragmentOf<typeof UserPositionFragment>;
135140

136-
export const UserBalanceFragment = graphql(
141+
export interface UserBalance {
142+
__typename: 'UserBalance';
143+
info: TokenInfo;
144+
totalAmount: DecimalValue;
145+
balances: TokenAmount[];
146+
fiatAmount: FiatAmount;
147+
/**
148+
* @deprecated Use `highestSupplyApy` instead. Removal slated for week commencing 6th October 2025.
149+
*/
150+
supplyApy: PercentValue;
151+
/**
152+
* @deprecated Use `highestBorrowApy` instead. Removal slated for week commencing 6th October 2025.
153+
*/
154+
borrowApy: PercentValue;
155+
highestSupplyApy: PercentValue;
156+
highestBorrowApy: PercentValue;
157+
lowestSupplyApy: PercentValue;
158+
lowestBorrowApy: PercentValue;
159+
}
160+
161+
export const UserBalanceFragment: FragmentDocumentFor<
162+
UserBalance,
163+
'UserBalance'
164+
> = graphql(
137165
`fragment UserBalance on UserBalance {
138166
__typename
139167
info {
@@ -154,6 +182,18 @@ export const UserBalanceFragment = graphql(
154182
borrowApy(metric: HIGHEST) {
155183
...PercentValue
156184
}
185+
highestSupplyApy: supplyApy(metric: HIGHEST) {
186+
...PercentValue
187+
}
188+
highestBorrowApy: borrowApy(metric: HIGHEST) {
189+
...PercentValue
190+
}
191+
lowestSupplyApy: supplyApy(metric: LOWEST) {
192+
...PercentValue
193+
}
194+
lowestBorrowApy: borrowApy(metric: LOWEST) {
195+
...PercentValue
196+
}
157197
}`,
158198
[
159199
TokenInfoFragment,
@@ -163,7 +203,6 @@ export const UserBalanceFragment = graphql(
163203
PercentValueFragment,
164204
],
165205
);
166-
export type UserBalance = FragmentOf<typeof UserBalanceFragment>;
167206

168207
// Activity Fragments
169208
export const BorrowActivityFragment = graphql(

packages/react/src/user.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ export function useUserHistory({
436436
});
437437
}
438438

439-
export type UseUserSummaryHistoryArgs = UserSummaryHistoryRequest;
439+
export type UseUserSummaryHistoryArgs = Prettify<
440+
UserSummaryHistoryRequest & CurrencyQueryOptions
441+
>;
440442

441443
/**
442444
* Fetch user summary history over time.
@@ -473,10 +475,12 @@ export function useUserSummaryHistory(
473475

474476
export function useUserSummaryHistory({
475477
suspense = false,
478+
currency: _currency = DEFAULT_QUERY_OPTIONS.currency,
476479
...request
477480
}: UseUserSummaryHistoryArgs & {
478481
suspense?: boolean;
479482
}): SuspendableResult<UserSummaryHistoryItem[]> {
483+
// TODO: wire up currency once AAVE-1982 is implemented
480484
return useSuspendableQuery({
481485
document: UserSummaryHistoryQuery,
482486
variables: {

0 commit comments

Comments
 (0)