Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/client/src/actions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ export function userHistory(
*
* @param client - Aave client.
* @param request - The user summary history request parameters.
* @param options - The query options.
* @returns The user summary history items.
*/
export function userSummaryHistory(
client: AaveClient,
request: UserSummaryHistoryRequest,
_options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,
): ResultAsync<UserSummaryHistoryItem[], UnexpectedError> {
// TODO: wire up _options once AAVE-1982 is implemented
return client.query(UserSummaryHistoryQuery, { request });
}
2 changes: 1 addition & 1 deletion packages/client/src/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function waitForTransactionResult(
}
return okAsync({
txHash: hash,
operations: request.operations, // TODO: check if this is correct
operations: request.operations,
});
});
}
Expand Down
45 changes: 42 additions & 3 deletions packages/graphql/src/fragments/user.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import type { FragmentOf } from 'gql.tada';
import { graphql } from '../graphql';
import { type FragmentDocumentFor, graphql } from '../graphql';
import {
type DecimalValue,
DecimalValueFragment,
Erc20AmountFragment,
type FiatAmount,
FiatAmountFragment,
FiatAmountWithChangeFragment,
HealthFactorChangeFragment,
PaginatedResultInfoFragment,
type PercentValue,
PercentValueFragment,
PercentValueWithChangeFragment,
type TokenAmount,
TokenAmountFragment,
type TokenInfo,
TokenInfoFragment,
} from './common';
import { ReserveFragment, ReserveInfoFragment } from './reserve';
Expand Down Expand Up @@ -133,7 +138,30 @@ export const UserPositionFragment = graphql(
);
export type UserPosition = FragmentOf<typeof UserPositionFragment>;

export const UserBalanceFragment = graphql(
export interface UserBalance {
__typename: 'UserBalance';
info: TokenInfo;
totalAmount: DecimalValue;
balances: TokenAmount[];
fiatAmount: FiatAmount;
/**
* @deprecated Use `highestSupplyApy` instead. Removal slated for week commencing 6th October 2025.
*/
supplyApy: PercentValue;
/**
* @deprecated Use `highestBorrowApy` instead. Removal slated for week commencing 6th October 2025.
*/
borrowApy: PercentValue;
highestSupplyApy: PercentValue;
highestBorrowApy: PercentValue;
lowestSupplyApy: PercentValue;
lowestBorrowApy: PercentValue;
}

export const UserBalanceFragment: FragmentDocumentFor<
UserBalance,
'UserBalance'
> = graphql(
`fragment UserBalance on UserBalance {
__typename
info {
Expand All @@ -154,6 +182,18 @@ export const UserBalanceFragment = graphql(
borrowApy(metric: HIGHEST) {
...PercentValue
}
highestSupplyApy: supplyApy(metric: HIGHEST) {
...PercentValue
}
highestBorrowApy: borrowApy(metric: HIGHEST) {
...PercentValue
}
lowestSupplyApy: supplyApy(metric: LOWEST) {
...PercentValue
}
lowestBorrowApy: borrowApy(metric: LOWEST) {
...PercentValue
}
}`,
[
TokenInfoFragment,
Expand All @@ -163,7 +203,6 @@ export const UserBalanceFragment = graphql(
PercentValueFragment,
],
);
export type UserBalance = FragmentOf<typeof UserBalanceFragment>;

// Activity Fragments
export const BorrowActivityFragment = graphql(
Expand Down
6 changes: 5 additions & 1 deletion packages/react/src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ export function useUserHistory({
});
}

export type UseUserSummaryHistoryArgs = UserSummaryHistoryRequest;
export type UseUserSummaryHistoryArgs = Prettify<
UserSummaryHistoryRequest & CurrencyQueryOptions
>;

/**
* Fetch user summary history over time.
Expand Down Expand Up @@ -473,10 +475,12 @@ export function useUserSummaryHistory(

export function useUserSummaryHistory({
suspense = false,
currency: _currency = DEFAULT_QUERY_OPTIONS.currency,
...request
}: UseUserSummaryHistoryArgs & {
suspense?: boolean;
}): SuspendableResult<UserSummaryHistoryItem[]> {
// TODO: wire up currency once AAVE-1982 is implemented
return useSuspendableQuery({
document: UserSummaryHistoryQuery,
variables: {
Expand Down