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
4 changes: 2 additions & 2 deletions packages/client/src/actions/hubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from '../options';
*
* @param client - Aave client.
* @param request - The hub request parameters.
* @param options - The query options (currency only).
* @param options - The query options.
* @returns The hub data, or null if not found.
*/
export function hub(
Expand All @@ -49,7 +49,7 @@ export function hub(
*
* @param client - Aave client.
* @param request - The hubs request parameters (either tokens or chainIds).
* @param options - The query options (currency only).
* @param options - The query options.
* @returns Array of hub data.
*/
export function hubs(
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from '../options';
*
* @param client - Aave client.
* @param request - The swap quote request parameters.
* @param options - The query options.
* @returns The swap quote including pricing and cost information.
*/
export function swapQuote(
Expand Down Expand Up @@ -128,6 +129,7 @@ export function swappableTokens(
*
* @param client - Aave client.
* @param request - The prepare swap request parameters.
* @param options - The query options.
* @returns The prepared swap result containing details of the swap.
*/
export function prepareSwap(
Expand All @@ -149,6 +151,7 @@ export function prepareSwap(
*
* @param client - Aave client.
* @param request - The swap status request parameters.
* @param options - The query options.
* @returns The current status of the swap.
*/
export function swapStatus(
Expand Down Expand Up @@ -355,6 +358,7 @@ export function cancelSwap(
*
* @param client - Aave client.
* @param request - The user swaps request parameters.
* @param options - The query options.
* @returns The paginated list of user swaps with their status information.
*/
export function userSwaps(
Expand Down
5 changes: 4 additions & 1 deletion packages/client/src/actions/transactions.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs updating tsdoc

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from '@aave/graphql-next';
import type { ResultAsync } from '@aave/types-next';
import type { AaveClient } from '../AaveClient';
import { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from '../options';

/**
* Creates a transaction to borrow from a market.
Expand Down Expand Up @@ -423,13 +424,15 @@ export function setSpokeUserPositionManager(
*
* @param client - Aave client.
* @param request - The preview request parameters containing the action to preview.
* @param options - The query options.
* @returns The preview result showing position changes.
*/
export function preview(
client: AaveClient,
request: PreviewRequest,
options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,
): ResultAsync<PreviewUserPosition, UnexpectedError> {
return client.query(PreviewQuery, { request });
return client.query(PreviewQuery, { request, ...options });
}

/**
Expand Down
7 changes: 5 additions & 2 deletions packages/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,8 @@ type PreviewUserPosition {
riskPremium: PercentValueVariation!
positionApy: PercentValueVariation!
netApy: PercentValueVariation!
netCollateral: FiatAmountValueVariation!
netBalance: FiatAmountValueVariation!
netCollateral(currency: Currency! = USD): FiatAmountValueVariation!
netBalance(currency: Currency! = USD): FiatAmountValueVariation!
}

type Query {
Expand Down Expand Up @@ -1410,6 +1410,9 @@ input UserBalancesRequestFilter @oneOf {

"""The balances for the underlying attached to a spoke"""
spoke: SpokeInput

"""The balances for the swappable tokens"""
swappable: SwappableTokensRequestQuery
}

input UserBalancesRequestOrderBy @oneOf {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/graphql-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export type introspection_types = {
'UpdateUserRiskPremiumRequest': { kind: 'INPUT_OBJECT'; name: 'UpdateUserRiskPremiumRequest'; isOneOf: false; inputFields: [{ name: 'spoke'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'INPUT_OBJECT'; name: 'SpokeInput'; ofType: null; }; }; defaultValue: null }, { name: 'sender'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'EvmAddress'; ofType: null; }; }; defaultValue: null }, { name: 'onBehalfOf'; type: { kind: 'SCALAR'; name: 'EvmAddress'; ofType: null; }; defaultValue: null }]; };
'UserBalance': { kind: 'OBJECT'; name: 'UserBalance'; fields: { 'balances': { name: 'balances'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'TokenAmount'; ofType: null; }; }; }; } }; 'borrowApy': { name: 'borrowApy'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'PercentValue'; ofType: null; }; } }; 'fiatAmount': { name: 'fiatAmount'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'FiatAmount'; ofType: null; }; } }; 'info': { name: 'info'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'TokenInfo'; ofType: null; }; } }; 'supplyApy': { name: 'supplyApy'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'PercentValue'; ofType: null; }; } }; 'totalAmount': { name: 'totalAmount'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'DecimalValue'; ofType: null; }; } }; }; };
'UserBalancesRequest': { kind: 'INPUT_OBJECT'; name: 'UserBalancesRequest'; isOneOf: false; inputFields: [{ name: 'user'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'EvmAddress'; ofType: null; }; }; defaultValue: null }, { name: 'orderBy'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'INPUT_OBJECT'; name: 'UserBalancesRequestOrderBy'; ofType: null; }; }; defaultValue: "{balance: DESC}" }, { name: 'filter'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'INPUT_OBJECT'; name: 'UserBalancesRequestFilter'; ofType: null; }; }; defaultValue: null }, { name: 'includeZeroBalances'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; }; defaultValue: "false" }]; };
'UserBalancesRequestFilter': { kind: 'INPUT_OBJECT'; name: 'UserBalancesRequestFilter'; isOneOf: true; inputFields: [{ name: 'chainIds'; type: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'ChainId'; ofType: null; }; }; }; defaultValue: null }, { name: 'hub'; type: { kind: 'INPUT_OBJECT'; name: 'HubInput'; ofType: null; }; defaultValue: null }, { name: 'spoke'; type: { kind: 'INPUT_OBJECT'; name: 'SpokeInput'; ofType: null; }; defaultValue: null }]; };
'UserBalancesRequestFilter': { kind: 'INPUT_OBJECT'; name: 'UserBalancesRequestFilter'; isOneOf: true; inputFields: [{ name: 'chainIds'; type: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'ChainId'; ofType: null; }; }; }; defaultValue: null }, { name: 'hub'; type: { kind: 'INPUT_OBJECT'; name: 'HubInput'; ofType: null; }; defaultValue: null }, { name: 'spoke'; type: { kind: 'INPUT_OBJECT'; name: 'SpokeInput'; ofType: null; }; defaultValue: null }, { name: 'swappable'; type: { kind: 'INPUT_OBJECT'; name: 'SwappableTokensRequestQuery'; ofType: null; }; defaultValue: null }]; };
'UserBalancesRequestOrderBy': { kind: 'INPUT_OBJECT'; name: 'UserBalancesRequestOrderBy'; isOneOf: true; inputFields: [{ name: 'name'; type: { kind: 'ENUM'; name: 'OrderDirection'; ofType: null; }; defaultValue: null }, { name: 'balance'; type: { kind: 'ENUM'; name: 'OrderDirection'; ofType: null; }; defaultValue: null }]; };
'UserBorrowItem': { kind: 'OBJECT'; name: 'UserBorrowItem'; fields: { 'amount': { name: 'amount'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'Erc20Amount'; ofType: null; }; } }; 'paid': { name: 'paid'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'Erc20Amount'; ofType: null; }; } }; 'reserve': { name: 'reserve'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'Reserve'; ofType: null; }; } }; }; };
'UserBorrowsQueryRequest': { kind: 'INPUT_OBJECT'; name: 'UserBorrowsQueryRequest'; isOneOf: true; inputFields: [{ name: 'userSpoke'; type: { kind: 'INPUT_OBJECT'; name: 'UserSpokeInput'; ofType: null; }; defaultValue: null }, { name: 'userPositionId'; type: { kind: 'SCALAR'; name: 'UserPositionId'; ofType: null; }; defaultValue: null }]; };
Expand Down
26 changes: 24 additions & 2 deletions packages/graphql/src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,18 @@
"ofType": null
}
},
"args": []
"args": [
{
"name": "currency",
"type": {
"kind": "NON_NULL",
"ofType": {
"kind": "SCALAR",
"name": "Any"
}
}
}
]
},
{
"name": "netBalance",
Expand All @@ -1969,7 +1980,18 @@
"ofType": null
}
},
"args": []
"args": [
{
"name": "currency",
"type": {
"kind": "NON_NULL",
"ofType": {
"kind": "SCALAR",
"name": "Any"
}
}
}
]
}
],
"interfaces": []
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ export const PreviewUserPositionFragment = graphql(
riskPremium {
...PercentValueVariation
}
netCollateral {
netCollateral(currency: $currency) {
...FiatAmountValueVariation
}
netBalance {
netBalance(currency: $currency) {
...FiatAmountValueVariation
}
}`,
Expand All @@ -169,7 +169,7 @@ export type PreviewUserPosition = FragmentOf<
* @internal
*/
export const PreviewQuery = graphql(
`query Preview($request: PreviewRequest!) {
`query Preview($request: PreviewRequest!, $currency: Currency! = USD) {
value: preview(request: $request) {
...PreviewUserPosition
}
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1231,12 +1231,13 @@ export function useSetSpokeUserPositionManagerAction(): UseAsyncTask<
* ```
*/
export function usePreviewAction(
_options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,
options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,
): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError> {
// TODO: wire up _options once AAVE-1916 is implemented
const client = useAaveClient();

return useAsyncTask((request: PreviewRequest) => preview(client, request));
return useAsyncTask((request: PreviewRequest) =>
preview(client, request, options),
);
}

export type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;
Expand Down