Skip to content

Commit 6d3effc

Browse files
authored
Merge pull request #83 from aave/fix/missing-currency-and-timeWindow
fix: adds missing currency and timeWindow params
2 parents a756b15 + ff7781b commit 6d3effc

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

packages/client/src/actions/user.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
type UserSuppliesRequest,
2525
type UserSupplyItem,
2626
} from '@aave/graphql-next';
27-
import type { ResultAsync } from '@aave/types-next';
27+
import type { Prettify, ResultAsync } from '@aave/types-next';
2828
import type { AaveClient } from '../AaveClient';
2929
import {
3030
type CurrencyQueryOptions,
@@ -88,6 +88,10 @@ export function userBorrows(
8888
return client.query(UserBorrowsQuery, { request, ...options });
8989
}
9090

91+
export type UserSummaryQueryOptions = Prettify<
92+
CurrencyQueryOptions & TimeWindowQueryOptions
93+
>;
94+
9195
/**
9296
* Fetches a user's summary across all positions.
9397
*
@@ -108,11 +112,15 @@ export function userBorrows(
108112
export function userSummary(
109113
client: AaveClient,
110114
request: UserSummaryRequest,
111-
options: Required<TimeWindowQueryOptions> = DEFAULT_QUERY_OPTIONS,
115+
{
116+
currency = DEFAULT_QUERY_OPTIONS.currency,
117+
timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,
118+
}: UserSummaryQueryOptions = DEFAULT_QUERY_OPTIONS,
112119
): ResultAsync<UserSummary, UnexpectedError> {
113120
return client.query(UserSummaryQuery, {
114121
request,
115-
timeWindow: options.timeWindow,
122+
currency,
123+
timeWindow,
116124
});
117125
}
118126

@@ -138,9 +146,12 @@ export type UserPositionQueryOptions = CurrencyQueryOptions &
138146
export function userPositions(
139147
client: AaveClient,
140148
request: UserPositionsRequest,
141-
options: Required<UserPositionQueryOptions> = DEFAULT_QUERY_OPTIONS,
149+
{
150+
currency = DEFAULT_QUERY_OPTIONS.currency,
151+
timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,
152+
}: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,
142153
): ResultAsync<UserPosition[], UnexpectedError> {
143-
return client.query(UserPositionsQuery, { request, ...options });
154+
return client.query(UserPositionsQuery, { request, currency, timeWindow });
144155
}
145156

146157
/**
@@ -160,9 +171,12 @@ export function userPositions(
160171
export function userPosition(
161172
client: AaveClient,
162173
request: UserPositionRequest,
163-
options: Required<UserPositionQueryOptions> = DEFAULT_QUERY_OPTIONS,
174+
{
175+
currency = DEFAULT_QUERY_OPTIONS.currency,
176+
timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,
177+
}: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,
164178
): ResultAsync<UserPosition | null, UnexpectedError> {
165-
return client.query(UserPositionQuery, { request, ...options });
179+
return client.query(UserPositionQuery, { request, currency, timeWindow });
166180
}
167181

168182
/**

packages/graphql/src/fragments/user.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ export const UserSummaryFragment = graphql(
5959
`fragment UserSummary on UserSummary {
6060
__typename
6161
totalPositions
62-
netBalance {
62+
netBalance(currency: $currency) {
6363
...FiatAmountWithChange
6464
}
65-
totalCollateral {
65+
totalCollateral(currency: $currency) {
6666
...FiatAmount
6767
}
68-
totalSupplied {
68+
totalSupplied(currency: $currency) {
6969
...FiatAmount
7070
}
71-
totalDebt {
71+
totalDebt(currency: $currency) {
7272
...FiatAmount
7373
}
7474
netApy {

packages/graphql/src/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type UserBorrowsRequest = RequestOf<typeof UserBorrowsQuery>;
3939
* @internal
4040
*/
4141
export const UserSummaryQuery = graphql(
42-
`query UserSummary($request: UserSummaryRequest!, $timeWindow: TimeWindow!) {
42+
`query UserSummary($request: UserSummaryRequest!, $currency: Currency!, $timeWindow: TimeWindow!) {
4343
value: userSummary(request: $request) {
4444
...UserSummary
4545
}

packages/react/src/user.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function useUserBorrows({
163163
}
164164

165165
export type UseUserSummaryArgs = Prettify<
166-
UserSummaryRequest & TimeWindowQueryOptions
166+
UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions
167167
>;
168168

169169
/**
@@ -203,6 +203,7 @@ export function useUserSummary(
203203

204204
export function useUserSummary({
205205
suspense = false,
206+
currency = DEFAULT_QUERY_OPTIONS.currency,
206207
timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,
207208
...request
208209
}: UseUserSummaryArgs & {
@@ -212,6 +213,7 @@ export function useUserSummary({
212213
document: UserSummaryQuery,
213214
variables: {
214215
request,
216+
currency,
215217
timeWindow,
216218
},
217219
suspense,

0 commit comments

Comments
 (0)