@aave/client 4.0.0-next.4 → 4.0.0-next.40
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.
- package/README.md +6 -3
- package/dist/{AaveClient-CgHY2iS9.d.ts → AaveClient-BPNG2Fua.d.ts} +5 -7
- package/dist/{AaveClient-L3v8kWvn.d.cts → AaveClient-CYavo882.d.cts} +5 -7
- package/dist/actions/index.cjs +1 -1
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +289 -171
- package/dist/actions/index.d.ts +289 -171
- package/dist/actions/index.js +1 -1
- package/dist/chunk-N4LXBTGY.js +2 -0
- package/dist/chunk-N4LXBTGY.js.map +1 -0
- package/dist/chunk-TO3PPVNH.js +2 -0
- package/dist/chunk-TO3PPVNH.js.map +1 -0
- package/dist/chunk-XT6Q6AZR.js +2 -0
- package/dist/chunk-XT6Q6AZR.js.map +1 -0
- package/dist/ethers.cjs +1 -1
- package/dist/ethers.cjs.map +1 -1
- package/dist/ethers.d.cts +45 -11
- package/dist/ethers.d.ts +45 -11
- package/dist/ethers.js +1 -1
- package/dist/ethers.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -4
- package/dist/index.d.ts +21 -4
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{options-vB2peXdE.d.cts → options-BX6n3sbh.d.cts} +17 -1
- package/dist/{options-vB2peXdE.d.ts → options-BX6n3sbh.d.ts} +17 -1
- package/dist/privy.cjs +1 -2
- package/dist/privy.cjs.map +1 -1
- package/dist/privy.d.cts +49 -12
- package/dist/privy.d.ts +49 -12
- package/dist/privy.js +1 -1
- package/dist/privy.js.map +1 -1
- package/dist/testing.d.ts +3838 -0
- package/dist/testing.js +546 -0
- package/dist/testing.js.map +1 -0
- package/dist/thirdweb.cjs +1 -2
- package/dist/thirdweb.cjs.map +1 -1
- package/dist/thirdweb.d.cts +52 -16
- package/dist/thirdweb.d.ts +52 -16
- package/dist/thirdweb.js +1 -2
- package/dist/thirdweb.js.map +1 -1
- package/dist/{types-Bu63z0x6.d.cts → types-4gDcMKeo.d.cts} +9 -5
- package/dist/{types-Bu63z0x6.d.ts → types-4gDcMKeo.d.ts} +9 -5
- package/dist/viem.cjs +1 -2
- package/dist/viem.cjs.map +1 -1
- package/dist/viem.d.cts +57 -17
- package/dist/viem.d.ts +57 -17
- package/dist/viem.js +1 -1
- package/package.json +10 -11
- package/dist/chunk-2URLJFKP.js +0 -3
- package/dist/chunk-2URLJFKP.js.map +0 -1
- package/dist/chunk-IFRZEVIE.js +0 -3
- package/dist/chunk-IFRZEVIE.js.map +0 -1
- package/dist/chunk-UXJVSHNC.js +0 -2
- package/dist/chunk-UXJVSHNC.js.map +0 -1
- package/dist/test-utils.cjs +0 -3
- package/dist/test-utils.cjs.map +0 -1
- package/dist/test-utils.d.cts +0 -50
- package/dist/test-utils.d.ts +0 -50
- package/dist/test-utils.js +0 -3
- package/dist/test-utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -35,11 +35,14 @@ export const client = AaveClient.create();
|
|
|
35
35
|
## Usage
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
import { chains
|
|
38
|
+
import { chains } from '@aave/client/actions';
|
|
39
|
+
import { ChainsFilter } from '@aave/client';
|
|
39
40
|
import { client } from './client';
|
|
40
41
|
|
|
41
|
-
// Query
|
|
42
|
-
const
|
|
42
|
+
// Query chains by filter
|
|
43
|
+
const result = await chains(client, {
|
|
44
|
+
query: { filter: ChainsFilter.ALL },
|
|
45
|
+
});
|
|
43
46
|
|
|
44
47
|
if (result.isOk()) {
|
|
45
48
|
console.log("Chains:", result.value); // Chain[]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { GqlClient, TimeoutError, UnexpectedError
|
|
1
|
+
import { GqlClient, TimeoutError, UnexpectedError } from '@aave/core';
|
|
2
2
|
import { HasProcessedKnownTransactionRequest } from '@aave/graphql';
|
|
3
|
-
import { ResultAsync, TxHash
|
|
3
|
+
import { ResultAsync, TxHash } from '@aave/types';
|
|
4
4
|
import { TypedDocumentNode } from '@urql/core';
|
|
5
|
-
import { T as TransactionResult } from './types-
|
|
5
|
+
import { T as TransactionResult } from './types-4gDcMKeo.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The environment configuration type.
|
|
@@ -13,6 +13,8 @@ type EnvironmentConfig = {
|
|
|
13
13
|
indexingTimeout: number;
|
|
14
14
|
pollingInterval: number;
|
|
15
15
|
exchangeRateInterval?: number;
|
|
16
|
+
swapQuoteInterval: number;
|
|
17
|
+
swapStatusInterval: number;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -72,10 +74,6 @@ declare class AaveClient extends GqlClient {
|
|
|
72
74
|
* @returns The transaction hash or a TimeoutError
|
|
73
75
|
*/
|
|
74
76
|
readonly waitForTransaction: (result: TransactionResult) => ResultAsync<TxHash, TimeoutError | UnexpectedError>;
|
|
75
|
-
/**
|
|
76
|
-
* @internal
|
|
77
|
-
*/
|
|
78
|
-
refreshQueryWhere<TValue, TVariables extends AnyVariables>(document: TypedDocumentNode<StandardData<TValue>, TVariables>, predicate: (variables: TVariables, data: TValue) => boolean | Promise<boolean>): Promise<void>;
|
|
79
77
|
protected pollTransactionStatus(request: HasProcessedKnownTransactionRequest): Promise<TxHash>;
|
|
80
78
|
}
|
|
81
79
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { GqlClient, TimeoutError, UnexpectedError
|
|
1
|
+
import { GqlClient, TimeoutError, UnexpectedError } from '@aave/core';
|
|
2
2
|
import { HasProcessedKnownTransactionRequest } from '@aave/graphql';
|
|
3
|
-
import { ResultAsync, TxHash
|
|
3
|
+
import { ResultAsync, TxHash } from '@aave/types';
|
|
4
4
|
import { TypedDocumentNode } from '@urql/core';
|
|
5
|
-
import { T as TransactionResult } from './types-
|
|
5
|
+
import { T as TransactionResult } from './types-4gDcMKeo.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The environment configuration type.
|
|
@@ -13,6 +13,8 @@ type EnvironmentConfig = {
|
|
|
13
13
|
indexingTimeout: number;
|
|
14
14
|
pollingInterval: number;
|
|
15
15
|
exchangeRateInterval?: number;
|
|
16
|
+
swapQuoteInterval: number;
|
|
17
|
+
swapStatusInterval: number;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -72,10 +74,6 @@ declare class AaveClient extends GqlClient {
|
|
|
72
74
|
* @returns The transaction hash or a TimeoutError
|
|
73
75
|
*/
|
|
74
76
|
readonly waitForTransaction: (result: TransactionResult) => ResultAsync<TxHash, TimeoutError | UnexpectedError>;
|
|
75
|
-
/**
|
|
76
|
-
* @internal
|
|
77
|
-
*/
|
|
78
|
-
refreshQueryWhere<TValue, TVariables extends AnyVariables>(document: TypedDocumentNode<StandardData<TValue>, TVariables>, predicate: (variables: TVariables, data: TValue) => boolean | Promise<boolean>): Promise<void>;
|
|
79
77
|
protected pollTransactionStatus(request: HasProcessedKnownTransactionRequest): Promise<TxHash>;
|
|
80
78
|
}
|
|
81
79
|
|
package/dist/actions/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var graphql=require('@aave/graphql'),core=require('@aave/core'),types=require('@aave/types');var s={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network"};function Re(e,r,t=s){return e.query(graphql.HubQuery,{request:r,currency:t.currency??s.currency},{requestPolicy:t.requestPolicy??s.requestPolicy})}function qe(e,r,t=s){return e.query(graphql.HubsQuery,{request:r,...t})}function me(e,r,t=s){return e.query(graphql.HubAssetsQuery,{request:r,...t})}function Ue(e,r){return e.query(graphql.ChainQuery,{request:r})}function Pe(e,r=graphql.ChainsFilter.ALL){return e.query(graphql.ChainsQuery,{filter:r})}function xe(e,r){return e.query(graphql.HasProcessedKnownTransactionQuery,{request:r},{requestPolicy:"network-only",batch:false})}function de(e,r){return e.query(graphql.ExchangeRateQuery,{request:r})}function fe(e,r){return e.query(graphql.PermitTypedDataQuery,{request:r})}function Oe(e,r,t=s){return e.query(graphql.AssetQuery,{request:r,currency:t.currency??s.currency,timeWindow:t.timeWindow??s.timeWindow},{requestPolicy:t.requestPolicy??s.requestPolicy})}function Te(e,r,t=s){return e.query(graphql.AssetPriceHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function ke(e,r,t=s){return e.query(graphql.AssetSupplyHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function He(e,r,t=s){return e.query(graphql.AssetBorrowHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function Be(e,r,t=s){return e.query(graphql.ReserveQuery,{request:r,...t})}function Me(e,r,t=s){return e.query(graphql.ReservesQuery,{request:r,...t})}function We(e,r){return e.query(graphql.BorrowApyHistoryQuery,{request:r})}function De(e,r){return e.query(graphql.SupplyApyHistoryQuery,{request:r})}function Ie(e,r){return e.query(graphql.SpokeQuery,{request:r})}function Ye(e,r){return e.query(graphql.SpokesQuery,{request:r})}function Le(e,r){return e.query(graphql.SpokePositionManagersQuery,{request:r})}function Ne(e,r){return e.query(graphql.SpokeUserPositionManagersQuery,{request:r})}function Je(e,r,t=s){return e.query(graphql.SwapQuoteQuery,{request:r,...t})}function Ve(e,r){return e.query(graphql.SwappableTokensQuery,{request:r})}function Xe(e,r,t=s){return e.query(graphql.PrepareSwapQuery,{request:r,...t})}function L(e,r,t=s){return e.query(graphql.SwapStatusQuery,{request:r,...t})}function Ze(e){return r=>{let t=async n=>{let y=Date.now();for(;Date.now()-y<e.context.environment.indexingTimeout;){let u=await L(e,n).match(o=>o,o=>{throw o});switch(u.__typename){case "SwapCancelled":case "SwapExpired":case "SwapFulfilled":return u;default:await core.delay(e.context.environment.pollingInterval);continue}}throw core.TimeoutError.from(`Timeout waiting for swap ${n.id} to reach final outcome.`)};return types.ResultAsync.fromPromise(t({id:r.id}),n=>n instanceof core.TimeoutError||n instanceof core.UnexpectedError?n:core.UnexpectedError.from(n))}}function er(e,r){return e.query(graphql.SwapQuery,{request:r})}function rr(e,r){return e.query(graphql.PrepareSwapCancelQuery,{request:r})}function tr(e,r){return e.query(graphql.CancelSwapQuery,{request:r})}function sr(e,r,t=s){return e.query(graphql.UserSwapsQuery,{request:r,...t})}function ir(e,r){return e.query(graphql.BorrowQuery,{request:r})}function pr(e,r){return e.query(graphql.SupplyQuery,{request:r})}function yr(e,r){return e.query(graphql.RepayQuery,{request:r})}function ar(e,r){return e.query(graphql.WithdrawQuery,{request:r})}function cr(e,r){return e.query(graphql.RenounceSpokeUserPositionManagerQuery,{request:r})}function lr(e,r){return e.query(graphql.UpdateUserDynamicConfigQuery,{request:r})}function Rr(e,r){return e.query(graphql.UpdateUserRiskPremiumQuery,{request:r})}function qr(e,r){return e.query(graphql.LiquidatePositionQuery,{request:r})}function mr(e,r){return e.query(graphql.SetSpokeUserPositionManagerQuery,{request:r})}function Ar(e,r,t=s){return e.query(graphql.PreviewQuery,{request:r,...t})}function Sr(e,r){return e.query(graphql.SetUserSupplyAsCollateralQuery,{request:r})}function Ur(e,r,t=s){return e.query(graphql.ActivitiesQuery,{request:r,currency:t.currency??s.currency},{requestPolicy:t.requestPolicy??s.requestPolicy})}function wr(e,r,t=s){return e.query(graphql.UserSuppliesQuery,{request:r,...t})}function Cr(e,r,t=s){return e.query(graphql.UserBorrowsQuery,{request:r,...t})}function fr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(graphql.UserSummaryQuery,{request:r,currency:t,timeWindow:n})}function vr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(graphql.UserPositionsQuery,{request:r,currency:t,timeWindow:n})}function Qr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(graphql.UserPositionQuery,{request:r,currency:t,timeWindow:n})}function Er(e,r,t=s){return e.query(graphql.UserBalancesQuery,{request:r,...t})}function Or(e,r,t=s){return e.query(graphql.UserSummaryHistoryQuery,{request:r,...t})}exports.activities=Ur;exports.asset=Oe;exports.assetBorrowHistory=He;exports.assetPriceHistory=Te;exports.assetSupplyHistory=ke;exports.borrow=ir;exports.borrowApyHistory=We;exports.cancelSwap=tr;exports.chain=Ue;exports.chains=Pe;exports.exchangeRate=de;exports.hasProcessedKnownTransaction=xe;exports.hub=Re;exports.hubAssets=me;exports.hubs=qe;exports.liquidatePosition=qr;exports.permitTypedData=fe;exports.prepareSwap=Xe;exports.prepareSwapCancel=rr;exports.preview=Ar;exports.renounceSpokeUserPositionManager=cr;exports.repay=yr;exports.reserve=Be;exports.reserves=Me;exports.setSpokeUserPositionManager=mr;exports.setUserSupplyAsCollateral=Sr;exports.spoke=Ie;exports.spokePositionManagers=Le;exports.spokeUserPositionManagers=Ne;exports.spokes=Ye;exports.supply=pr;exports.supplyApyHistory=De;exports.swap=er;exports.swapQuote=Je;exports.swapStatus=L;exports.swappableTokens=Ve;exports.updateUserDynamicConfig=lr;exports.updateUserRiskPremium=Rr;exports.userBalances=Er;exports.userBorrows=Cr;exports.userPosition=Qr;exports.userPositions=vr;exports.userSummary=fr;exports.userSummaryHistory=Or;exports.userSupplies=wr;exports.userSwaps=sr;exports.waitForSwapOutcome=Ze;exports.withdraw=ar;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var graphql=require('@aave/graphql'),core=require('@aave/core'),types=require('@aave/types');var e={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function xe(t,r,n=e){return t.query(graphql.HubQuery,{request:r,currency:n.currency??e.currency,timeWindow:n.timeWindow??e.timeWindow},{requestPolicy:n.requestPolicy??e.requestPolicy})}function Ce(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.HubsQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Qe(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.HubAssetsQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Oe(t,r,{requestPolicy:n=e.requestPolicy}=e){return t.query(graphql.HubSummaryHistoryQuery,{request:r},{requestPolicy:n})}function he(t,r,{batch:n=e.batch,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.ChainQuery,{request:r},{batch:n,requestPolicy:s})}function ke(t,r){return t.query(graphql.ChainsQuery,{request:r})}function He(t,r){return t.query(graphql.HasProcessedKnownTransactionQuery,{request:r},{requestPolicy:"network-only",batch:false})}function We(t,r,{requestPolicy:n=e.requestPolicy}=e){return t.query(graphql.ExchangeRateQuery,{request:r},{requestPolicy:n})}function Ie(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.AssetQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function ge(t,r,n=e){return t.query(graphql.AssetPriceHistoryQuery,{request:r},{requestPolicy:n.requestPolicy??e.requestPolicy})}function Le(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.AssetSupplyHistoryQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Me(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.AssetBorrowHistoryQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Ne(t,r,n=e){return t.query(graphql.ProtocolHistoryQuery,{request:r},{requestPolicy:n.requestPolicy??e.requestPolicy})}function Ye(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.ReserveQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function $e(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.ReservesQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Ge(t,r,{requestPolicy:n=e.requestPolicy}=e){return t.query(graphql.BorrowApyHistoryQuery,{request:r},{requestPolicy:n})}function Ke(t,r,{requestPolicy:n=e.requestPolicy}=e){return t.query(graphql.SupplyApyHistoryQuery,{request:r},{requestPolicy:n})}function Xe(t,r,{requestPolicy:n=e.requestPolicy}=e){return t.query(graphql.UserClaimableRewardsQuery,{request:r},{requestPolicy:n})}function tt(t,r){return t.query(graphql.SpokeQuery,{request:r})}function rt(t,r){return t.query(graphql.SpokesQuery,{request:r})}function nt(t,r){return t.query(graphql.SpokePositionManagersQuery,{request:r})}function ot(t,r){return t.query(graphql.SpokeUserPositionManagersQuery,{request:r})}function at(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.TokenSwapQuoteQuery,{request:r,currency:n},{batch:false,requestPolicy:s}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return types.okAsync(o);case "InsufficientLiquidityError":return core.ValidationError.fromGqlNode(o).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function ct(t,r,{requestPolicy:n=e.requestPolicy}=e){return t.query(graphql.SwappableTokensQuery,{request:r},{requestPolicy:n})}function lt(t,r){return t.query(graphql.PrepareTokenSwapQuery,{request:r},{batch:false}).map(types.extendWithOpaqueType).andThen(n=>{switch(n.__typename){case "PrepareSwapOrder":return types.okAsync(n);case "InsufficientBalanceError":return core.ValidationError.fromGqlNode(n).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${n.__typename}`).asResultAsync()}})}function Rt(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.SupplySwapQuoteQuery,{request:r,currency:n},{batch:false,requestPolicy:s}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);case "InsufficientLiquidityError":return core.ValidationError.fromGqlNode(o).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function qt(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.BorrowSwapQuoteQuery,{request:r,currency:n},{batch:false,requestPolicy:s}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);case "InsufficientLiquidityError":return core.ValidationError.fromGqlNode(o).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function mt(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.RepayWithSupplyQuoteQuery,{request:r,currency:n},{batch:false,requestPolicy:s}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);case "InsufficientLiquidityError":return core.ValidationError.fromGqlNode(o).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function dt(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.WithdrawSwapQuoteQuery,{request:r,currency:n},{batch:false,requestPolicy:s}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);case "InsufficientLiquidityError":return core.ValidationError.fromGqlNode(o).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function wt(t,r){return t.query(graphql.PreparePositionSwapQuery,{request:r},{batch:false}).map(types.extendWithOpaqueType).andThen(n=>{switch(n.__typename){case "PrepareSwapOrder":return types.okAsync(n);case "InsufficientBalanceError":return core.ValidationError.fromGqlNode(n).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${n.__typename}`).asResultAsync()}})}function X(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.SwapStatusQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function At(t){return r=>{let n=async s=>{let o=Date.now();for(;Date.now()-o<t.context.environment.indexingTimeout;){let c=await X(t,s).match(a=>a,a=>{throw a});switch(c.__typename){case "SwapCancelled":case "SwapExpired":case "SwapFulfilled":return c;default:await core.delay(t.context.environment.pollingInterval);continue}}throw core.TimeoutError.from(`Timeout waiting for swap ${s.id} to reach final outcome.`)};return types.ResultAsync.fromPromise(n({id:r.id}),s=>s instanceof core.TimeoutError||s instanceof core.UnexpectedError?s:core.UnexpectedError.from(s))}}function Pt(t,r){return t.mutation(graphql.SwapMutation,{request:r}).map(types.extendWithOpaqueType).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return types.okAsync(n);case "SwapReceipt":return types.okAsync(n);case "InsufficientBalanceError":return core.ValidationError.fromGqlNode(n).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap plan: ${n.__typename}`).asResultAsync()}})}function St(t,r){return t.query(graphql.PrepareSwapCancelQuery,{request:r},{batch:false})}function ft(t,r){return t.mutation(graphql.CancelSwapMutation,{request:r})}function Ut(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.UserSwapsQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Ot(t,r){return t.query(graphql.BorrowQuery,{request:r})}function Et(t,r){return t.query(graphql.SupplyQuery,{request:r})}function vt(t,r){return t.query(graphql.RepayQuery,{request:r})}function Tt(t,r){return t.query(graphql.WithdrawQuery,{request:r})}function ht(t,r){return t.query(graphql.RenounceSpokeUserPositionManagerQuery,{request:r})}function kt(t,r){return t.query(graphql.UpdateUserPositionConditionsQuery,{request:r})}function Ht(t,r){return t.query(graphql.LiquidatePositionQuery,{request:r})}function Wt(t,r){return t.query(graphql.SetSpokeUserPositionManagerQuery,{request:r})}function Bt(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.PreviewQuery,{request:r,currency:n},{requestPolicy:s})}function _t(t,r){return t.query(graphql.SetUserSuppliesAsCollateralQuery,{request:r})}function bt(t,r){return t.query(graphql.ClaimRewardsQuery,{request:r})}function It(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.ActivitiesQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Nt(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.UserSuppliesQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Ft(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.UserBorrowsQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Dt(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.UserSummaryQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Vt(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.UserPositionsQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function Yt(t,r,{currency:n=e.currency,timeWindow:s=e.timeWindow,requestPolicy:o=e.requestPolicy}=e){return t.query(graphql.UserPositionQuery,{request:r,currency:n,timeWindow:s},{requestPolicy:o})}function $t(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.UserBalancesQuery,{request:r,currency:n},{requestPolicy:s})}function Gt(t,r,{currency:n=e.currency,requestPolicy:s=e.requestPolicy}=e){return t.query(graphql.UserSummaryHistoryQuery,{request:r,currency:n},{requestPolicy:s})}function Kt(t,r,{requestPolicy:n=e.requestPolicy}=e){return t.query(graphql.UserRiskPremiumBreakdownQuery,{request:r},{requestPolicy:n})}exports.activities=It;exports.asset=Ie;exports.assetBorrowHistory=Me;exports.assetPriceHistory=ge;exports.assetSupplyHistory=Le;exports.borrow=Ot;exports.borrowApyHistory=Ge;exports.borrowSwapQuote=qt;exports.cancelSwap=ft;exports.chain=he;exports.chains=ke;exports.claimRewards=bt;exports.exchangeRate=We;exports.hasProcessedKnownTransaction=He;exports.hub=xe;exports.hubAssets=Qe;exports.hubSummaryHistory=Oe;exports.hubs=Ce;exports.liquidatePosition=Ht;exports.preparePositionSwap=wt;exports.prepareSwapCancel=St;exports.prepareTokenSwap=lt;exports.preview=Bt;exports.protocolHistory=Ne;exports.renounceSpokeUserPositionManager=ht;exports.repay=vt;exports.repayWithSupplyQuote=mt;exports.reserve=Ye;exports.reserves=$e;exports.setSpokeUserPositionManager=Wt;exports.setUserSuppliesAsCollateral=_t;exports.spoke=tt;exports.spokePositionManagers=nt;exports.spokeUserPositionManagers=ot;exports.spokes=rt;exports.supply=Et;exports.supplyApyHistory=Ke;exports.supplySwapQuote=Rt;exports.swap=Pt;exports.swapStatus=X;exports.swappableTokens=ct;exports.tokenSwapQuote=at;exports.updateUserPositionConditions=kt;exports.userBalances=$t;exports.userBorrows=Ft;exports.userClaimableRewards=Xe;exports.userPosition=Yt;exports.userPositions=Vt;exports.userRiskPremiumBreakdown=Kt;exports.userSummary=Dt;exports.userSummaryHistory=Gt;exports.userSupplies=Nt;exports.userSwaps=Ut;exports.waitForSwapOutcome=At;exports.withdraw=Tt;exports.withdrawSwapQuote=dt;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/options.ts","../../src/actions/hubs.ts","../../src/actions/misc.ts","../../src/actions/permits.ts","../../src/actions/protocol.ts","../../src/actions/reserves.ts","../../src/actions/spokes.ts","../../src/actions/swap.ts","../../src/actions/transactions.ts","../../src/actions/user.ts"],"names":["DEFAULT_QUERY_OPTIONS","Currency","TimeWindow","hub","client","request","options","HubQuery","hubs","HubsQuery","hubAssets","HubAssetsQuery","chain","ChainQuery","chains","filter","ChainsFilter","ChainsQuery","hasProcessedKnownTransaction","HasProcessedKnownTransactionQuery","exchangeRate","ExchangeRateQuery","permitTypedData","PermitTypedDataQuery","asset","AssetQuery","assetPriceHistory","AssetPriceHistoryQuery","assetSupplyHistory","AssetSupplyHistoryQuery","assetBorrowHistory","AssetBorrowHistoryQuery","reserve","ReserveQuery","reserves","ReservesQuery","borrowApyHistory","BorrowApyHistoryQuery","supplyApyHistory","SupplyApyHistoryQuery","spoke","SpokeQuery","spokes","SpokesQuery","spokePositionManagers","SpokePositionManagersQuery","spokeUserPositionManagers","SpokeUserPositionManagersQuery","swapQuote","SwapQuoteQuery","swappableTokens","SwappableTokensQuery","prepareSwap","PrepareSwapQuery","swapStatus","SwapStatusQuery","waitForSwapOutcome","receipt","pollForSwapOutcome","startedAt","status","ok","err","delay","TimeoutError","ResultAsync","error","UnexpectedError","swap","SwapQuery","prepareSwapCancel","PrepareSwapCancelQuery","cancelSwap","CancelSwapQuery","userSwaps","UserSwapsQuery","borrow","BorrowQuery","supply","SupplyQuery","repay","RepayQuery","withdraw","WithdrawQuery","renounceSpokeUserPositionManager","RenounceSpokeUserPositionManagerQuery","updateUserDynamicConfig","UpdateUserDynamicConfigQuery","updateUserRiskPremium","UpdateUserRiskPremiumQuery","liquidatePosition","LiquidatePositionQuery","setSpokeUserPositionManager","SetSpokeUserPositionManagerQuery","preview","PreviewQuery","setUserSupplyAsCollateral","SetUserSupplyAsCollateralQuery","activities","ActivitiesQuery","userSupplies","UserSuppliesQuery","userBorrows","UserBorrowsQuery","userSummary","currency","timeWindow","UserSummaryQuery","userPositions","UserPositionsQuery","userPosition","UserPositionQuery","userBalances","UserBalancesQuery","userSummaryHistory","UserSummaryHistoryQuery"],"mappings":"0GA+BO,IAAMA,CAAAA,CAAwB,CACnC,QAAA,CAAUC,gBAAAA,CAAS,GAAA,CACnB,UAAA,CAAYC,kBAAAA,CAAW,QACvB,a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AA,CACc,CACxD,OAAOI,CAAAA,CAAO,KAAA,CAAM+G,+BAAAA,CAAyB,CAAE,OAAA,CAAA9G,CAAAA,CAAS,GAAGC,CAAQ,CAAC,CACtE","file":"index.cjs","sourcesContent":["import { Currency, TimeWindow } from '@aave/graphql';\nimport type { RequestPolicy } from '@urql/core';\n\nexport type CurrencyQueryOptions = {\n /**\n * The currency for fiat amounts.\n *\n * @defaultValue {@link Currency.Usd}\n */\n currency?: Currency;\n};\n\nexport type TimeWindowQueryOptions = {\n /**\n * The time window for historical data changes.\n *\n * @defaultValue {@link TimeWindow.LastDay}\n */\n timeWindow?: TimeWindow;\n};\n\nexport type RequestPolicyOptions = {\n /**\n * The request policy to use.\n *\n * @internal This is used for testing purposes and could be changed without notice.\n * @defaultValue `cache-and-network`\n */\n requestPolicy?: RequestPolicy;\n};\n\nexport const DEFAULT_QUERY_OPTIONS = {\n currency: Currency.Usd,\n timeWindow: TimeWindow.LastDay,\n requestPolicy: 'cache-and-network',\n} as const;\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Hub,\n type HubAsset,\n HubAssetsQuery,\n type HubAssetsRequest,\n HubQuery,\n type HubRequest,\n HubsQuery,\n type HubsRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n} from '../options';\n\n/**\n * Fetches a specific hub by ID or by address and chain ID.\n *\n * ```ts\n * const result = await hub(client, {\n * query: { hubId: hubId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hub request parameters.\n * @param options - The query options.\n * @returns The hub data, or null if not found.\n */\nexport function hub(\n client: AaveClient,\n request: HubRequest,\n options: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Hub | null, UnexpectedError> {\n return client.query(\n HubQuery,\n { request, currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches multiple hubs based on specified criteria.\n *\n * ```ts\n * const result = await hubs(client, {\n * query: {\n * chainIds: [chainId(1)]\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hubs request parameters (either tokens or chainIds).\n * @param options - The query options.\n * @returns Array of hub data.\n */\nexport function hubs(\n client: AaveClient,\n request: HubsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Hub[], UnexpectedError> {\n return client.query(HubsQuery, { request, ...options });\n}\n\n/**\n * Fetches hub assets for a specific hub by ID or by address and chain ID.\n *\n * ```ts\n * const result = await hubAssets(client, {\n * query: { hubId: hubId('SGVsbG8h') },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hub assets request parameters.\n * @param options - The query options.\n * @returns The hub assets array.\n */\nexport function hubAssets(\n client: AaveClient,\n request: HubAssetsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<HubAsset[], UnexpectedError> {\n return client.query(HubAssetsQuery, { request, ...options });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Chain,\n ChainQuery,\n type ChainRequest,\n ChainsFilter,\n ChainsQuery,\n ExchangeRateQuery,\n type ExchangeRateRequest,\n type FiatAmount,\n HasProcessedKnownTransactionQuery,\n type HasProcessedKnownTransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @returns The chain data, or null if not found.\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, { filter: ChainsFilter.ALL });\n * ```\n *\n * @param client - Aave client.\n * @param filter - The filter for chains.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n filter: ChainsFilter = ChainsFilter.ALL,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { filter });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n): ResultAsync<FiatAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type PermitRequest,\n PermitTypedDataQuery,\n type PermitTypedDataResponse,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\n\nimport type { AaveClient } from '../AaveClient';\n\n/**\n * Generates EIP-712 typed data for permit signatures.\n *\n * ```ts\n * const result = await permitTypedData(client, {\n * spender: evmAddress('0x87870bca…'),\n * currency: evmAddress('0xa0b86991c431c924b2047c7094daf21b77e…'),\n * amount: '1000.5',\n * });\n *\n * if (result.isOk()) {\n * // Use the typed data to create a signature\n * const signature = await wallet.signTypedData(result.value);\n * }\n * ```\n *\n * @param client - Aave client.\n * @param request - The permit request parameters.\n * @returns The EIP-712 typed data for permit signature.\n */\nexport function permitTypedData(\n client: AaveClient,\n request: PermitRequest,\n): ResultAsync<PermitTypedDataResponse, UnexpectedError> {\n return client.query(PermitTypedDataQuery, { request });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Asset,\n AssetBorrowHistoryQuery,\n type AssetBorrowHistoryRequest,\n type AssetBorrowSample,\n AssetPriceHistoryQuery,\n type AssetPriceHistoryRequest,\n type AssetPriceSample,\n AssetQuery,\n type AssetRequest,\n AssetSupplyHistoryQuery,\n type AssetSupplyHistoryRequest,\n type AssetSupplySample,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * ```ts\n * const result = await asset(client, {\n * query: { assetId: assetId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset request parameters.\n * @param options - The query options including currency and time window.\n * @returns The asset data, or null if not found.\n */\nexport function asset(\n client: AaveClient,\n request: AssetRequest,\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Asset | null, UnexpectedError> {\n return client.query(\n AssetQuery,\n {\n request,\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches historical price data for a specific asset.\n *\n * ```ts\n * const result = await assetPriceHistory(client, {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset price history request parameters.\n * @param options - The query options.\n * @returns Array of asset price samples over time.\n */\nexport function assetPriceHistory(\n client: AaveClient,\n request: AssetPriceHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetPriceSample[], UnexpectedError> {\n return client.query(\n AssetPriceHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches historical supply data for a specific asset.\n *\n * ```ts\n * const result = await assetSupplyHistory(client, {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset supply history request parameters.\n * @param options - The query options.\n * @returns Array of asset supply samples over time.\n */\nexport function assetSupplyHistory(\n client: AaveClient,\n request: AssetSupplyHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetSupplySample[], UnexpectedError> {\n return client.query(\n AssetSupplyHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches historical borrow data for a specific asset.\n *\n * ```ts\n * const result = await assetBorrowHistory(client, {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset borrow history request parameters.\n * @param options - The query options.\n * @returns Array of asset borrow samples over time.\n */\nexport function assetBorrowHistory(\n client: AaveClient,\n request: AssetBorrowHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetBorrowSample[], UnexpectedError> {\n return client.query(\n AssetBorrowHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type APYSample,\n type BorrowAPYHistoryRequest,\n BorrowApyHistoryQuery,\n type Reserve,\n ReserveQuery,\n type ReserveRequest,\n ReservesQuery,\n type ReservesRequest,\n type SupplyAPYHistoryRequest,\n SupplyApyHistoryQuery,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * Fetches a specific reserve by reserve ID, spoke, and chain.\n *\n * ```ts\n * const result = await reserve(client, {\n * reserve: reserveId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The reserve request parameters.\n * @param options - The query options.\n * @returns The reserve data, or null if not found.\n */\nexport function reserve(\n client: AaveClient,\n request: ReserveRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve | null, UnexpectedError> {\n return client.query(ReserveQuery, { request, ...options });\n}\n\n/**\n * Fetches reserves based on specified criteria.\n *\n * ```ts\n * const result = await reserves(client, {\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * filter: ReservesRequestFilter.All,\n * orderBy: { name: 'ASC' }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The reserves request parameters.\n * @param options - The query options.\n * @returns Array of reserves matching the criteria.\n */\nexport function reserves(\n client: AaveClient,\n request: ReservesRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve[], UnexpectedError> {\n return client.query(ReservesQuery, { request, ...options });\n}\n\n/**\n * Fetches borrow APY history for a specific reserve over time.\n *\n * ```ts\n * const result = await borrowApyHistory(client, {\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The borrow APY history request parameters.\n * @returns The borrow APY history samples.\n */\nexport function borrowApyHistory(\n client: AaveClient,\n request: BorrowAPYHistoryRequest,\n): ResultAsync<APYSample[], UnexpectedError> {\n return client.query(BorrowApyHistoryQuery, { request });\n}\n\n/**\n * Fetches supply APY history for a specific reserve over time.\n *\n * ```ts\n * const result = await supplyApyHistory(client, {\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The supply APY history request parameters.\n * @returns The supply APY history samples.\n */\nexport function supplyApyHistory(\n client: AaveClient,\n request: SupplyAPYHistoryRequest,\n): ResultAsync<APYSample[], UnexpectedError> {\n return client.query(SupplyApyHistoryQuery, { request });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type PaginatedSpokePositionManagerResult,\n type PaginatedSpokeUserPositionManagerResult,\n type Spoke,\n SpokePositionManagersQuery,\n type SpokePositionManagersRequest,\n SpokeQuery,\n type SpokeRequest,\n SpokesQuery,\n type SpokesRequest,\n SpokeUserPositionManagersQuery,\n type SpokeUserPositionManagersRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\n\n/**\n * Fetches a specific spoke.\n *\n * ```ts\n * const result = await spoke(client, {\n * query: { spokeId: spokeId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spoke request parameters.\n * @returns The spoke data, or null if not found.\n */\nexport function spoke(\n client: AaveClient,\n request: SpokeRequest,\n): ResultAsync<Spoke | null, UnexpectedError> {\n return client.query(SpokeQuery, { request });\n}\n\n/**\n * Fetches spokes based on specified criteria.\n *\n * ```ts\n * const result = await spokes(client, {\n * query: { chainIds: [chainId(1)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes request parameters.\n * @returns Array of spokes matching the criteria.\n */\nexport function spokes(\n client: AaveClient,\n request: SpokesRequest,\n): ResultAsync<Spoke[], UnexpectedError> {\n return client.query(SpokesQuery, { request });\n}\n\n/**\n * Fetches all positions manager for a specific spoke.\n *\n * ```ts\n * const result = await spokePositionManagers(client, {\n * spoke: spokeId('SGVsbG8h'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes request parameters.\n * @returns Array of spokes matching the criteria.\n */\nexport function spokePositionManagers(\n client: AaveClient,\n request: SpokePositionManagersRequest,\n): ResultAsync<PaginatedSpokePositionManagerResult, UnexpectedError> {\n return client.query(SpokePositionManagersQuery, { request });\n}\n\n/**\n * Fetches all the positions managers of a user for a specific spoke.\n *\n * ```ts\n * const result = await spokeUserPositionManagers(client, {\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes and pagination request parameters.\n * @returns Array of position managers of a user for a specific spoke.\n */\nexport function spokeUserPositionManagers(\n client: AaveClient,\n request: SpokeUserPositionManagersRequest,\n): ResultAsync<PaginatedSpokeUserPositionManagerResult, UnexpectedError> {\n return client.query(SpokeUserPositionManagersQuery, { request });\n}\n","import { delay, TimeoutError, UnexpectedError } from '@aave/core';\nimport type {\n CancelSwapExecutionPlan,\n CancelSwapRequest,\n PaginatedUserSwapsResult,\n PrepareSwapCancelRequest,\n PrepareSwapCancelResult,\n PrepareSwapRequest,\n PrepareSwapResult,\n SwapCancelled,\n SwapExecutionPlan,\n SwapExpired,\n SwapFulfilled,\n SwappableTokensRequest,\n SwapQuote,\n SwapQuoteRequest,\n SwapReceipt,\n SwapRequest,\n SwapStatus,\n SwapStatusRequest,\n Token,\n UserSwapsRequest,\n} from '@aave/graphql';\nimport {\n CancelSwapQuery,\n PrepareSwapCancelQuery,\n PrepareSwapQuery,\n SwappableTokensQuery,\n SwapQuery,\n SwapQuoteQuery,\n SwapStatusQuery,\n UserSwapsQuery,\n} from '@aave/graphql';\nimport { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * @internal\n * Fetches a swap quote for the specified trade parameters.\n *\n * ```ts\n * const result = await swapQuote(client, {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6...') },\n * sell: { erc20: evmAddress('0x6B175474E...') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.SELL,\n * from: evmAddress('0x742d35cc...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap quote request parameters.\n * @param options - The query options.\n * @returns The swap quote including pricing and cost information.\n */\nexport function swapQuote(\n client: AaveClient,\n request: SwapQuoteRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<SwapQuote, UnexpectedError> {\n return client.query(SwapQuoteQuery, { request, ...options });\n}\n\n/**\n * @internal\n * Fetches the list of tokens available for swapping on a specific chain.\n *\n * ```ts\n * const result = await swappableTokens(client, {\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swappable tokens request parameters.\n * @returns The list of tokens available for swapping.\n */\nexport function swappableTokens(\n client: AaveClient,\n request: SwappableTokensRequest,\n): ResultAsync<Token[], UnexpectedError> {\n return client.query(SwappableTokensQuery, { request });\n}\n\n/**\n * @internal\n * Prepares a swap for the specified trade parameters.\n *\n * ```ts\n * const result = await prepareSwap(client, {\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6...') },\n * sell: { erc20: evmAddress('0x6B175474E...') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.SELL,\n * user: evmAddress('0x742d35cc...'),\n * },\n * }).andThen(plan => {\n * switch (plan.__typename) {\n * case 'SwapByIntent':\n * return signSwapByIntentWith(plan.data)\n * .andThen((signature) => swap({ intent: { quoteId: quote.quoteId, signature } }))\n * .andThen((plan) => {\n * // …\n * });\n * );\n *\n * case 'SwapByIntentWithApprovalRequired':\n * return sendTransaction(plan.transaction)\n * .andThen(signSwapByIntentWith(plan.data))\n * .andThen((signature) => swap({ intent: { quoteId: quote.quoteId, signature } }))\n * .andThen((plan) => {\n * // …\n * });\n * );\n *\n * case 'SwapByTransaction':\n * return swap({ transaction: { quoteId: quote.quoteId } })\n * .andThen((plan) => {\n * // …\n * });\n * );\n *\n * case 'InsufficientBalanceError':\n * return errAsync(new Error(`Insufficient balance: ${plan.required.value} required.`));\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The prepare swap request parameters.\n * @param options - The query options.\n * @returns The prepared swap result containing details of the swap.\n */\nexport function prepareSwap(\n client: AaveClient,\n request: PrepareSwapRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PrepareSwapResult, UnexpectedError> {\n return client.query(PrepareSwapQuery, { request, ...options });\n}\n\n/**\n * @internal\n * Fetches the status of a specific swap.\n *\n * ```ts\n * const result = await swapStatus(client, {\n * id: swapId('swap_123'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap status request parameters.\n * @param options - The query options.\n * @returns The current status of the swap.\n */\nexport function swapStatus(\n client: AaveClient,\n request: SwapStatusRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<SwapStatus, UnexpectedError> {\n return client.query(SwapStatusQuery, { request, ...options });\n}\n\nexport type SwapOutcome = SwapCancelled | SwapExpired | SwapFulfilled;\n\n/**\n * @internal\n * Waits for a swap to reach a final outcome (cancelled, expired, or fulfilled).\n *\n * ```ts\n * const result = waitForSwapOutcome(client)(swapReceipt);\n *\n * if (result.isOk()) {\n * const outcome = result.value;\n * switch (outcome.__typename) {\n * case 'SwapFulfilled':\n * console.log('Swap completed successfully:', outcome.txHash);\n * break;\n * case 'SwapCancelled':\n * console.log('Swap was cancelled:', outcome.cancelledAt);\n * break;\n * case 'SwapExpired':\n * console.log('Swap expired:', outcome.expiredAt);\n * break;\n * }\n * }\n * ```\n *\n * @param client - Aave client configured with polling settings.\n * @returns A function that takes a SwapReceipt and returns a ResultAsync with the final outcome.\n */\nexport function waitForSwapOutcome(\n client: AaveClient,\n): (\n receipt: SwapReceipt,\n) => ResultAsync<SwapOutcome, TimeoutError | UnexpectedError> {\n return (receipt: SwapReceipt) => {\n const pollForSwapOutcome = async (\n request: SwapStatusRequest,\n ): Promise<SwapOutcome> => {\n const startedAt = Date.now();\n\n while (\n Date.now() - startedAt <\n client.context.environment.indexingTimeout\n ) {\n const status = await swapStatus(client, request).match(\n (ok) => ok,\n (err) => {\n throw err;\n },\n );\n\n switch (status.__typename) {\n case 'SwapCancelled':\n case 'SwapExpired':\n case 'SwapFulfilled':\n return status;\n\n default:\n await delay(client.context.environment.pollingInterval);\n continue;\n }\n }\n\n throw TimeoutError.from(\n `Timeout waiting for swap ${request.id} to reach final outcome.`,\n );\n };\n\n return ResultAsync.fromPromise(\n pollForSwapOutcome({ id: receipt.id }),\n (error) => {\n if (error instanceof TimeoutError || error instanceof UnexpectedError) {\n return error;\n }\n return UnexpectedError.from(error);\n },\n );\n };\n}\n\n/**\n * @internal\n * Executes a swap for the specified request parameters.\n *\n * ```ts\n * const result = await swap(client, {\n * intent: {\n * quoteId: swapQuoteId('123...'),\n * signature: {\n * value: signature('0x456...'),\n * deadline: 1234567890,\n * },\n * },\n * }).andThen((plan) => {\n * switch (plan.__typename) {\n * case 'SwapTransactionRequest':\n * return sendTransaction(plan.transaction)\n * .map(() => plan.orderReceipt);\n *\n * case 'SwapApprovalRequired':\n * return sendTransaction(plan.transaction)\n * .andThen(() => sendTransaction(plan.originalTransaction))\n * .map(() => plan.originalTransaction.orderReceipt);\n *\n * case 'SwapReceipt':\n * return okAsync(plan.orderReceipt);\n *\n * case 'InsufficientBalanceError':\n * return errAsync(new Error(`Insufficient balance: ${plan.required.value} required.`));\n * }\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * console.log('Order receipt:', result.value);\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap request parameters.\n * @returns The swap execution plan containing transaction details or receipt.\n */\nexport function swap(\n client: AaveClient,\n request: SwapRequest,\n): ResultAsync<SwapExecutionPlan, UnexpectedError> {\n return client.query(SwapQuery, { request });\n}\n\n/**\n * @internal\n * Prepares a swap cancellation for the specified swap ID.\n *\n * ```ts\n * const result = await prepareSwapCancel(client, {\n * id: swapId('123...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The prepare swap cancel request parameters.\n * @returns The prepared swap cancel result containing typed data for signing.\n */\nexport function prepareSwapCancel(\n client: AaveClient,\n request: PrepareSwapCancelRequest,\n): ResultAsync<PrepareSwapCancelResult, UnexpectedError> {\n return client.query(PrepareSwapCancelQuery, { request });\n}\n\n/**\n * @internal\n * Executes a swap cancellation for the specified request parameters.\n *\n * ```ts\n * const result = await cancelSwap(client, {\n * intent: {\n * id: swapId('123...'),\n * signature: {\n * value: signature('0x456...'),\n * deadline: 1234567890,\n * },\n * },\n * }).andThen((plan) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan)\n * .map(() => ({ success: true }));\n *\n * case 'SwapCancelled':\n * return okAsync(plan);\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The cancel swap request parameters.\n * @returns The cancel swap execution plan containing transaction details or cancellation receipt.\n */\nexport function cancelSwap(\n client: AaveClient,\n request: CancelSwapRequest,\n): ResultAsync<CancelSwapExecutionPlan, UnexpectedError> {\n return client.query(CancelSwapQuery, { request });\n}\n\n/**\n * @internal\n * Fetches the user's swap history for a specific chain.\n *\n * ```ts\n * const result = await userSwaps(client, {\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc...'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user swaps request parameters.\n * @param options - The query options.\n * @returns The paginated list of user swaps with their status information.\n */\nexport function userSwaps(\n client: AaveClient,\n request: UserSwapsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PaginatedUserSwapsResult, UnexpectedError> {\n return client.query(UserSwapsQuery, { request, ...options });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n ActivitiesQuery,\n type ActivitiesRequest,\n BorrowQuery,\n type BorrowRequest,\n type ExecutionPlan,\n LiquidatePositionQuery,\n type LiquidatePositionRequest,\n type PaginatedActivitiesResult,\n PreviewQuery,\n type PreviewRequest,\n type PreviewUserPosition,\n RenounceSpokeUserPositionManagerQuery,\n type RenounceSpokeUserPositionManagerRequest,\n RepayQuery,\n type RepayRequest,\n SetSpokeUserPositionManagerQuery,\n type SetSpokeUserPositionManagerRequest,\n SetUserSupplyAsCollateralQuery,\n type SetUserSupplyAsCollateralRequest,\n SupplyQuery,\n type SupplyRequest,\n type TransactionRequest,\n UpdateUserDynamicConfigQuery,\n type UpdateUserDynamicConfigRequest,\n UpdateUserRiskPremiumQuery,\n type UpdateUserRiskPremiumRequest,\n WithdrawQuery,\n type WithdrawRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n} from '../options';\n\n/**\n * Creates a transaction to borrow from a market.\n *\n * ```ts\n * const result = await borrow(client, {\n * amount: {\n * erc20: {\n * value: bigDecimal('1000'),\n * },\n * },\n * reserve: reserveId('SGVsbG8h'),\n * sender: evmAddress('0x9abc…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The borrow request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function borrow(\n client: AaveClient,\n request: BorrowRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(BorrowQuery, { request });\n}\n\n/**\n * Creates a transaction to supply to a market.\n *\n * ```ts\n * const result = await supply(client, {\n * reserve: {\n * reserveId: \"1234567890\",\n * spoke: evmAddress('0x8787…'),\n * chainId: chainId(1),\n * },\n * amount: {\n * erc20: {\n * value: bigDecimal('1000'),\n * },\n * },\n * enableCollateral: true, // Optional, defaults to true\n * sender: evmAddress('0x9abc…'),\n * });\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The supply request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function supply(\n client: AaveClient,\n request: SupplyRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(SupplyQuery, { request });\n}\n\n/**\n * Creates a transaction to repay to a market.\n *\n * ```ts\n * const result = await repay(client, {\n * amount: {\n * erc20: {\n * value: {\n * exact: bigDecimal('500'),\n * },\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * reserve: reserveId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The repay request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function repay(\n client: AaveClient,\n request: RepayRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(RepayQuery, { request });\n}\n\n/**\n * Creates a transaction to withdraw from a reserve.\n *\n * ```ts\n * const result = await withdraw(client, {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * exact: bigDecimal('750.5'),\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * **Withdraw specific amount:**\n * ```ts\n * amount: {\n * erc20: {\n * exact: bigDecimal('100.5'), // Exact amount to withdraw\n * }\n * }\n * ```\n *\n * **Withdraw all available:**\n * ```ts\n * amount: {\n * erc20: {\n * max: true, // Withdraw the full position\n * }\n * }\n * ```\n *\n * **Withdraw native token:**\n * ```ts\n * amount: {\n * native: bigDecimal('0.5'), // For ETH on Ethereum\n * }\n * ```\n *\n * @param client - Aave client.\n * @param request - The withdraw request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function withdraw(\n client: AaveClient,\n request: WithdrawRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(WithdrawQuery, { request });\n}\n\n/**\n * Creates a transaction to renounce a position manager of a user in a specific spoke.\n *\n * ```ts\n * const result = await renounceSpokeUserPositionManager(client, {\n * manager: evmAddress('0x9abc…'),\n * managing: evmAddress('0xdef0…'),\n * spoke: spokeId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The renounce spoke user position manager request parameters.\n * @returns The transaction data.\n */\nexport function renounceSpokeUserPositionManager(\n client: AaveClient,\n request: RenounceSpokeUserPositionManagerRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(RenounceSpokeUserPositionManagerQuery, { request });\n}\n\n/**\n * Creates a transaction to update user dynamic config for a specific spoke.\n *\n * ```ts\n * const result = await updateUserDynamicConfig(client, {\n * sender: evmAddress('0x9abc…'),\n * spoke: spokeId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The update user dynamic config request parameters.\n * @returns The transaction data.\n */\n\nexport function updateUserDynamicConfig(\n client: AaveClient,\n request: UpdateUserDynamicConfigRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(UpdateUserDynamicConfigQuery, { request });\n}\n\n/**\n * Creates a transaction to update user risk premium for a specific spoke.\n *\n * ```ts\n * const result = await updateUserRiskPremium(client, {\n * sender: evmAddress('0x9abc…'),\n * spoke: spokeId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The update user risk premium request parameters.\n * @returns The transaction data.\n */\nexport function updateUserRiskPremium(\n client: AaveClient,\n request: UpdateUserRiskPremiumRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(UpdateUserRiskPremiumQuery, { request });\n}\n\n/**\n * Creates a transaction to liquidate a user's position.\n *\n * ```ts\n * const result = await liquidatePosition(client, {\n * collateral: reserveId('SGVsbG8h'),\n * debt: reserveId('Q2lhbyE= '),\n * amount: {\n * exact: bigDecimal('1000'),\n * },\n * liquidator: evmAddress('0x9abc…'),\n * user: evmAddress('0xdef0…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The liquidate position request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function liquidatePosition(\n client: AaveClient,\n request: LiquidatePositionRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(LiquidatePositionQuery, { request });\n}\n\n/**\n * Sets or removes a position manager for a user on a specific spoke.\n *\n * **Position managers** can perform transactions on behalf of other users, including:\n * - Supply assets\n * - Borrow assets\n * - Withdraw assets\n * - Enable/disable collateral\n *\n * The `signature` parameter is an **ERC712 signature** that must be signed by the **user**\n * (the account granting permissions) to authorize the position manager. The signature contains:\n * - `value`: The actual cryptographic signature\n * - `deadline`: Unix timestamp when the authorization expires\n *\n * ```ts\n * const result = await setSpokeUserPositionManager(client, {\n * spoke: spokeId('SGVsbG8h'),\n * manager: evmAddress('0x9abc…'), // Address that will become the position manager\n * approve: true, // true to approve, false to remove the manager\n * user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)\n * signature: {\n * value: '0x1234...', // ERC712 signature signed by the user\n * deadline: 1735689600, // Unix timestamp when signature expires\n * },\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The spoke set for the position manager request parameters.\n * @returns The transaction request data to set position manager.\n */\nexport function setSpokeUserPositionManager(\n client: AaveClient,\n request: SetSpokeUserPositionManagerRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(SetSpokeUserPositionManagerQuery, { request });\n}\n\n/**\n * Previews the impact of a potential action on a user's position.\n *\n * ```ts\n * const result = await preview(client, {\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * value: '1000',\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * },\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The preview request parameters containing the action to preview.\n * @param options - The query options.\n * @returns The preview result showing position changes.\n */\nexport function preview(\n client: AaveClient,\n request: PreviewRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PreviewUserPosition, UnexpectedError> {\n return client.query(PreviewQuery, { request, ...options });\n}\n\n/**\n * Sets whether a user's supply should be used as collateral.\n *\n * ```ts\n * const result = await setUserSupplyAsCollateral(client, {\n * reserve: reserveId('SGVsbG8h'),\n * sender: evmAddress('0x456...'),\n * enableCollateral: true\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The set user supply as collateral request parameters.\n * @returns The transaction request to set collateral status.\n */\nexport function setUserSupplyAsCollateral(\n client: AaveClient,\n request: SetUserSupplyAsCollateralRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(SetUserSupplyAsCollateralQuery, { request });\n}\n\n/**\n * Fetches paginated list of activities.\n *\n * ```ts\n * const result = await activities(client, {\n * query: {\n * chainIds: [chainId(1)],\n * },\n * user: evmAddress('0x742d35cc…'), // Optional\n * types: [ActivityType.Supply, ActivityType.Borrow, ActivityType.Withdraw, ActivityType.Repay],\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The activities request parameters.\n * @param options - The query options.\n * @returns The paginated list of activities.\n */\nexport function activities(\n client: AaveClient,\n request: ActivitiesRequest,\n options: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PaginatedActivitiesResult, UnexpectedError> {\n return client.query(\n ActivitiesQuery,\n { request, currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type UserBalance,\n UserBalancesQuery,\n type UserBalancesRequest,\n type UserBorrowItem,\n UserBorrowsQuery,\n type UserBorrowsRequest,\n type UserPosition,\n UserPositionQuery,\n type UserPositionRequest,\n UserPositionsQuery,\n type UserPositionsRequest,\n type UserSummary,\n type UserSummaryHistoryItem,\n UserSummaryHistoryQuery,\n type UserSummaryHistoryRequest,\n UserSummaryQuery,\n type UserSummaryRequest,\n UserSuppliesQuery,\n type UserSuppliesRequest,\n type UserSupplyItem,\n} from '@aave/graphql';\nimport type { Prettify, ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches all user supply positions across the specified spoke.\n *\n * ```ts\n * const result = await userSupplies(client, {\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user supplies request parameters.\n * @param options - The query options.\n * @returns The user's supply positions.\n */\nexport function userSupplies(\n client: AaveClient,\n request: UserSuppliesRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSupplyItem[], UnexpectedError> {\n return client.query(UserSuppliesQuery, { request, ...options });\n}\n\n/**\n * Fetches all user borrow positions across the specified spoke.\n *\n * ```ts\n * const result = await userBorrows(client, {\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user borrows request parameters.\n * @param options - The query options.\n * @returns The user's borrow positions.\n */\nexport function userBorrows(\n client: AaveClient,\n request: UserBorrowsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserBorrowItem[], UnexpectedError> {\n return client.query(UserBorrowsQuery, { request, ...options });\n}\n\nexport type UserSummaryQueryOptions = Prettify<\n CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetches a user's summary across all positions.\n *\n * ```ts\n * const result = await userSummary(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user summary request parameters.\n * @param options - The query options.\n * @returns The user's financial summary.\n */\nexport function userSummary(\n client: AaveClient,\n request: UserSummaryRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n }: UserSummaryQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSummary, UnexpectedError> {\n return client.query(UserSummaryQuery, {\n request,\n currency,\n timeWindow,\n });\n}\n\nexport type UserPositionQueryOptions = CurrencyQueryOptions &\n TimeWindowQueryOptions;\n\n/**\n * Fetches all user positions across specified chains.\n *\n * ```ts\n * const result = await userPositions(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)],\n * },\n * orderBy: { balance: 'DESC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user positions request parameters.\n * @param options - The query options.\n * @returns The user's positions across all specified chains.\n */\nexport function userPositions(\n client: AaveClient,\n request: UserPositionsRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n }: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserPosition[], UnexpectedError> {\n return client.query(UserPositionsQuery, { request, currency, timeWindow });\n}\n\n/**\n * Fetches a specific user position by ID.\n *\n * ```ts\n * const result = await userPosition(client, {\n * id: userPositionId('SGVsbG8h'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user position request parameters.\n * @param options - The query options.\n * @returns The specific user position or null if not found.\n */\nexport function userPosition(\n client: AaveClient,\n request: UserPositionRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n }: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserPosition | null, UnexpectedError> {\n return client.query(UserPositionQuery, { request, currency, timeWindow });\n}\n\n/**\n * Fetches all user balances across specified chains.\n *\n * ```ts\n * const result = await userBalances(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)],\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user balances request parameters.\n * @param options - The query options.\n * @returns The user's balances across all specified chains.\n **/\nexport function userBalances(\n client: AaveClient,\n request: UserBalancesRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserBalance[], UnexpectedError> {\n return client.query(UserBalancesQuery, { request, ...options });\n}\n\n/**\n * Fetches user summary history over time.\n *\n * ```ts\n * const result = await userSummaryHistory(client, {\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: {\n * chainIds: [chainId(1)]\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user summary history request parameters.\n * @param options - The query options.\n * @returns The user summary history items.\n */\nexport function userSummaryHistory(\n client: AaveClient,\n request: UserSummaryHistoryRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSummaryHistoryItem[], UnexpectedError> {\n return client.query(UserSummaryHistoryQuery, { request, ...options });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/options.ts","../../src/actions/hubs.ts","../../src/actions/misc.ts","../../src/actions/protocol.ts","../../src/actions/reserves.ts","../../src/actions/rewards.ts","../../src/actions/spokes.ts","../../src/actions/swap.ts","../../src/actions/transactions.ts","../../src/actions/user.ts"],"names":["DEFAULT_QUERY_OPTIONS","Currency","TimeWindow","hub","client","request","options","HubQuery","hubs","currency","timeWindow","requestPolicy","HubsQuery","hubAssets","HubAssetsQuery","hubSummaryHistory","HubSummaryHistoryQuery","chain","batch","ChainQuery","chains","ChainsQuery","hasProcessedKnownTransaction","HasProcessedKnownTransactionQuery","exchangeRate","ExchangeRateQuery","asset","AssetQuery","assetPriceHistory","AssetPriceHistoryQuery","assetSupplyHistory","AssetSupplyHistoryQuery","assetBorrowHistory","AssetBorrowHistoryQuery","protocolHistory","ProtocolHistoryQuery","reserve","ReserveQuery","reserves","ReservesQuery","borrowApyHistory","BorrowApyHistoryQuery","supplyApyHistory","SupplyApyHistoryQuery","userClaimableRewards","UserClaimableRewardsQuery","spoke","SpokeQuery","spokes","SpokesQuery","spokePositionManagers","SpokePositionManagersQuery","spokeUserPositionManagers","SpokeUserPositionManagersQuery","tokenSwapQuote","TokenSwapQuoteQuery","extendWithOpaqueType","result","okAsync","ValidationError","UnexpectedError","swappableTokens","SwappableTokensQuery","prepareTokenSwap","PrepareTokenSwapQuery","supplySwapQuote","SupplySwapQuoteQuery","borrowSwapQuote","BorrowSwapQuoteQuery","repayWithSupplyQuote","RepayWithSupplyQuoteQuery","withdrawSwapQuote","WithdrawSwapQuoteQuery","preparePositionSwap","PreparePositionSwapQuery","swapStatus","SwapStatusQuery","waitForSwapOutcome","receipt","pollForSwapOutcome","startedAt","status","ok","err","delay","TimeoutError","ResultAsync","error","swap","SwapMutation","plan","prepareSwapCancel","PrepareSwapCancelQuery","cancelSwap","CancelSwapMutation","userSwaps","UserSwapsQuery","borrow","BorrowQuery","supply","SupplyQuery","repay","RepayQuery","withdraw","WithdrawQuery","renounceSpokeUserPositionManager","RenounceSpokeUserPositionManagerQuery","updateUserPositionConditions","UpdateUserPositionConditionsQuery","liquidatePosition","LiquidatePositionQuery","setSpokeUserPositionManager","SetSpokeUserPositionManagerQuery","preview","PreviewQuery","setUserSuppliesAsCollateral","SetUserSuppliesAsCollateralQuery","claimRewards","ClaimRewardsQuery","activities","ActivitiesQuery","userSupplies","UserSuppliesQuery","userBorrows","UserBorrowsQuery","userSummary","UserSummaryQuery","userPositions","UserPositionsQuery","userPosition","UserPositionQuery","userBalances","UserBalancesQuery","userSummaryHistory","UserSummaryHistoryQuery","userRiskPremiumBreakdown","UserRiskPremiumBreakdownQuery"],"mappings":"0GA+CO,IAAMA,CAAAA,CAAwB,CACnC,QAAA,CAAUC,gBAAAA,CAAS,GAAA,CACnB,UAAA,CAAYC,kBAAAA,CAAW,OAAA,CACvB,aAAA,CAAe,mBAAA,CACf,KAAA,CAAO,IACT,CAAA,CCfO,SAASC,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAEyBN,CAAAA,CACiB,CAC1C,OAAOI,CAAAA,CAAO,KAAA,CACZG,gBAAAA,CACA,CACE,OAAA,CAAAF,CAAAA,CACA,QAAA,CAAUC,CAAAA,CAAQ,QAAA,EAAYN,CAAAA,CAAsB,QAAA,CACpD,UAAA,CAAYM,CAAAA,CA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xC,CAAA,CAA8BA,CAAAA,CACqB,CACnD,OAAOI,CAAAA,CAAO,KAAA,CACZ8H,yBAAAA,CACA,CAAE,OAAA,CAAA7H,CAAAA,CAAS,QAAA,CAAAI,CAAAA,CAAU,UAAA,CAAAC,CAAW,CAAA,CAChC,CAAE,aAAA,CAAAC,CAAc,CAClB,CACF,CAmBO,SAASwH,EAAAA,CACd/H,CAAAA,CACAC,CAAAA,CACA,CACE,QAAA,CAAAI,CAAAA,CAAWT,CAAAA,CAAsB,QAAA,CACjC,aAAA,CAAAW,CAAAA,CAAgBX,CAAAA,CAAsB,aACxC,CAAA,CAAiDA,CAAAA,CACJ,CAC7C,OAAOI,CAAAA,CAAO,KAAA,CACZgI,yBAAAA,CACA,CAAE,OAAA,CAAA/H,CAAAA,CAAS,QAAA,CAAAI,CAAS,CAAA,CACpB,CAAE,aAAA,CAAAE,CAAc,CAClB,CACF,CAoBO,SAAS0H,EAAAA,CACdjI,CAAAA,CACAC,CAAAA,CACA,CACE,QAAA,CAAAI,CAAAA,CAAWT,CAAAA,CAAsB,QAAA,CACjC,aAAA,CAAAW,CAAAA,CAAgBX,CAAAA,CAAsB,aACxC,CAAA,CAAiDA,CAAAA,CACO,CACxD,OAAOI,CAAAA,CAAO,KAAA,CACZkI,+BAAAA,CACA,CAAE,OAAA,CAAAjI,CAAAA,CAAS,QAAA,CAAAI,CAAS,CAAA,CACpB,CAAE,aAAA,CAAAE,CAAc,CAClB,CACF,CAmBO,SAAS4H,EAAAA,CACdnI,CAAAA,CACAC,CAAAA,CACA,CACE,aAAA,CAAAM,CAAAA,CAAgBX,CAAAA,CAAsB,aACxC,CAAA,CAA0BA,CAAAA,CACoC,CAC9D,OAAOI,CAAAA,CAAO,KAAA,CACZoI,qCAAAA,CACA,CAAE,OAAA,CAAAnI,CAAQ,CAAA,CACV,CAAE,aAAA,CAAAM,CAAc,CAClB,CACF","file":"index.cjs","sourcesContent":["import { Currency, TimeWindow } from '@aave/graphql';\nimport type { RequestPolicy } from '@urql/core';\n\nexport type CurrencyQueryOptions = {\n /**\n * The currency for fiat amounts.\n *\n * @defaultValue {@link Currency.Usd}\n */\n currency?: Currency;\n};\n\nexport type TimeWindowQueryOptions = {\n /**\n * The time window for historical data changes.\n *\n * @defaultValue {@link TimeWindow.LastDay}\n */\n timeWindow?: TimeWindow;\n};\n\n/**\n * @internal\n */\nexport type RequestPolicyOptions = {\n /**\n * The request policy to use.\n *\n * @internal This is used for testing purposes and could be changed without notice.\n * @defaultValue `cache-and-network`\n */\n requestPolicy?: RequestPolicy;\n};\n\n/**\n * @internal\n */\nexport type BatchOptions = {\n /**\n * Whether to batch the query or not.\n *\n * @internal This is used to turn off batching for a single query.\n * @defaultValue `true`\n */\n batch?: boolean;\n};\n\nexport const DEFAULT_QUERY_OPTIONS = {\n currency: Currency.Usd,\n timeWindow: TimeWindow.LastDay,\n requestPolicy: 'cache-and-network',\n batch: true,\n} as const;\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Hub,\n type HubAsset,\n HubAssetsQuery,\n type HubAssetsRequest,\n HubQuery,\n type HubRequest,\n HubSummaryHistoryQuery,\n type HubSummaryHistoryRequest,\n type HubSummarySample,\n HubsQuery,\n type HubsRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches a specific hub by ID or by address and chain ID.\n *\n * ```ts\n * const result = await hub(client, {\n * query: { hubId: hubId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hub request parameters.\n * @param options - The query options.\n * @returns The hub data, or null if not found.\n */\nexport function hub(\n client: AaveClient,\n request: HubRequest,\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Hub | null, UnexpectedError> {\n return client.query(\n HubQuery,\n {\n request,\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches multiple hubs based on specified criteria.\n *\n * ```ts\n * const result = await hubs(client, {\n * query: {\n * chainIds: [chainId(1)]\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hubs request parameters (either tokens or chainIds).\n * @param options - The query options.\n * @returns Array of hub data.\n */\nexport function hubs(\n client: AaveClient,\n request: HubsRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Hub[], UnexpectedError> {\n return client.query(\n HubsQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches hub assets for a specific hub by ID or by address and chain ID.\n *\n * ```ts\n * const result = await hubAssets(client, {\n * query: { hubId: hubId('SGVsbG8h') },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hub assets request parameters.\n * @param options - The query options.\n * @returns The hub assets array.\n */\nexport function hubAssets(\n client: AaveClient,\n request: HubAssetsRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<HubAsset[], UnexpectedError> {\n return client.query(\n HubAssetsQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches historical summary data for a specific hub.\n *\n * ```ts\n * const result = await hubSummaryHistory(client, {\n * query: { hubId: hubId('SGVsbG8h') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hub summary history request parameters.\n * @param options - The query options.\n * @returns Array of hub summary samples over time.\n */\nexport function hubSummaryHistory(\n client: AaveClient,\n request: HubSummaryHistoryRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<HubSummarySample[], UnexpectedError> {\n return client.query(HubSummaryHistoryQuery, { request }, { requestPolicy });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Chain,\n ChainQuery,\n type ChainRequest,\n ChainsQuery,\n type ChainsRequest,\n type ExchangeAmount,\n ExchangeRateQuery,\n type ExchangeRateRequest,\n HasProcessedKnownTransactionQuery,\n type HasProcessedKnownTransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type BatchOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n} from '../options';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @param options - The query options.\n * @returns The chain data, or null if not found.\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n {\n batch = DEFAULT_QUERY_OPTIONS.batch,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: BatchOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch, requestPolicy });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { filter: ChainsFilter.ALL }\n * });\n * ```\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { chainIds: [chainId(1), chainId(137)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chains request parameters.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n request: ChainsRequest,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { request });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @param options - The query options.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<ExchangeAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request }, { requestPolicy });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Asset,\n AssetBorrowHistoryQuery,\n type AssetBorrowHistoryRequest,\n type AssetBorrowSample,\n AssetPriceHistoryQuery,\n type AssetPriceHistoryRequest,\n type AssetPriceSample,\n AssetQuery,\n type AssetRequest,\n AssetSupplyHistoryQuery,\n type AssetSupplyHistoryRequest,\n type AssetSupplySample,\n ProtocolHistoryQuery,\n type ProtocolHistoryRequest,\n type ProtocolHistorySample,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * ```ts\n * const result = await asset(client, {\n * query: { assetId: assetId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset request parameters.\n * @param options - The query options including currency and time window.\n * @returns The asset data, or null if not found.\n */\nexport function asset(\n client: AaveClient,\n request: AssetRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Asset | null, UnexpectedError> {\n return client.query(\n AssetQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches historical price data for a specific asset.\n *\n * ```ts\n * const result = await assetPriceHistory(client, {\n * query: {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset price history request parameters.\n * @param options - The query options.\n * @returns Array of asset price samples over time.\n */\nexport function assetPriceHistory(\n client: AaveClient,\n request: AssetPriceHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetPriceSample[], UnexpectedError> {\n return client.query(\n AssetPriceHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches historical supply data for a specific asset.\n *\n * ```ts\n * const result = await assetSupplyHistory(client, {\n * query: {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset supply history request parameters.\n * @param options - The query options including currency and time window.\n * @returns Array of asset supply samples over time.\n */\nexport function assetSupplyHistory(\n client: AaveClient,\n request: AssetSupplyHistoryRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetSupplySample[], UnexpectedError> {\n return client.query(\n AssetSupplyHistoryQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches historical borrow data for a specific asset.\n *\n * ```ts\n * const result = await assetBorrowHistory(client, {\n * query: {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset borrow history request parameters.\n * @param options - The query options including currency and time window.\n * @returns Array of asset borrow samples over time.\n */\nexport function assetBorrowHistory(\n client: AaveClient,\n request: AssetBorrowHistoryRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetBorrowSample[], UnexpectedError> {\n return client.query(\n AssetBorrowHistoryQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches historical protocol-wide data (deposits, borrows, earnings).\n *\n * ```ts\n * const result = await protocolHistory(client, {\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The protocol history request parameters.\n * @param options - The query options.\n * @returns Array of protocol history samples over time.\n */\nexport function protocolHistory(\n client: AaveClient,\n request: ProtocolHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<ProtocolHistorySample[], UnexpectedError> {\n return client.query(\n ProtocolHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type ApySample,\n BorrowApyHistoryQuery,\n type BorrowApyHistoryRequest,\n type Reserve,\n ReserveQuery,\n type ReserveRequest,\n ReservesQuery,\n type ReservesRequest,\n SupplyApyHistoryQuery,\n type SupplyApyHistoryRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches a specific reserve by reserve ID, spoke, and chain.\n *\n * ```ts\n * const result = await reserve(client, {\n * reserve: reserveId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The reserve request parameters.\n * @param options - The query options.\n * @returns The reserve data, or null if not found.\n */\nexport function reserve(\n client: AaveClient,\n request: ReserveRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve | null, UnexpectedError> {\n return client.query(\n ReserveQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches reserves based on specified criteria.\n *\n * ```ts\n * const result = await reserves(client, {\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * filter: ReservesRequestFilter.All,\n * orderBy: { name: 'ASC' }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The reserves request parameters.\n * @param options - The query options.\n * @returns Array of reserves matching the criteria.\n */\nexport function reserves(\n client: AaveClient,\n request: ReservesRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve[], UnexpectedError> {\n return client.query(\n ReservesQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches borrow APY history for a specific reserve over time.\n *\n * ```ts\n * const result = await borrowApyHistory(client, {\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The borrow APY history request parameters.\n * @param options - The query options.\n * @returns The borrow APY history samples.\n */\nexport function borrowApyHistory(\n client: AaveClient,\n request: BorrowApyHistoryRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<ApySample[], UnexpectedError> {\n return client.query(BorrowApyHistoryQuery, { request }, { requestPolicy });\n}\n\n/**\n * Fetches supply APY history for a specific reserve over time.\n *\n * ```ts\n * const result = await supplyApyHistory(client, {\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The supply APY history request parameters.\n * @param options - The query options.\n * @returns The supply APY history samples.\n */\nexport function supplyApyHistory(\n client: AaveClient,\n request: SupplyApyHistoryRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<ApySample[], UnexpectedError> {\n return client.query(SupplyApyHistoryQuery, { request }, { requestPolicy });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type UserClaimableReward,\n UserClaimableRewardsQuery,\n type UserClaimableRewardsRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { DEFAULT_QUERY_OPTIONS, type RequestPolicyOptions } from '../options';\n\n/**\n * Fetches all claimable rewards for a user.\n *\n * ```ts\n * const result = await userClaimableRewards(client, {\n * user: evmAddress('0x742d35cc…'),\n * });\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: UserClaimableReward[]\n * ```\n *\n * @param client - Aave client.\n * @param request - The user claimable rewards request parameters.\n * @param options - The query options.\n * @returns Array of claimable rewards.\n */\nexport function userClaimableRewards(\n client: AaveClient,\n request: UserClaimableRewardsRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserClaimableReward[], UnexpectedError> {\n return client.query(\n UserClaimableRewardsQuery,\n { request },\n { requestPolicy },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type PaginatedSpokePositionManagerResult,\n type PaginatedSpokeUserPositionManagerResult,\n type Spoke,\n SpokePositionManagersQuery,\n type SpokePositionManagersRequest,\n SpokeQuery,\n type SpokeRequest,\n SpokesQuery,\n type SpokesRequest,\n SpokeUserPositionManagersQuery,\n type SpokeUserPositionManagersRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\n\n/**\n * Fetches a specific spoke.\n *\n * ```ts\n * const result = await spoke(client, {\n * query: { spokeId: spokeId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spoke request parameters.\n * @returns The spoke data, or null if not found.\n */\nexport function spoke(\n client: AaveClient,\n request: SpokeRequest,\n): ResultAsync<Spoke | null, UnexpectedError> {\n return client.query(SpokeQuery, { request });\n}\n\n/**\n * Fetches spokes based on specified criteria.\n *\n * ```ts\n * const result = await spokes(client, {\n * query: { chainIds: [chainId(1)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes request parameters.\n * @returns Array of spokes matching the criteria.\n */\nexport function spokes(\n client: AaveClient,\n request: SpokesRequest,\n): ResultAsync<Spoke[], UnexpectedError> {\n return client.query(SpokesQuery, { request });\n}\n\n/**\n * Fetches all positions manager for a specific spoke.\n *\n * ```ts\n * const result = await spokePositionManagers(client, {\n * spoke: spokeId('SGVsbG8h'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes request parameters.\n * @returns Array of spokes matching the criteria.\n */\nexport function spokePositionManagers(\n client: AaveClient,\n request: SpokePositionManagersRequest,\n): ResultAsync<PaginatedSpokePositionManagerResult, UnexpectedError> {\n return client.query(SpokePositionManagersQuery, { request });\n}\n\n/**\n * Fetches all the positions managers of a user for a specific spoke.\n *\n * ```ts\n * const result = await spokeUserPositionManagers(client, {\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes and pagination request parameters.\n * @returns Array of position managers of a user for a specific spoke.\n */\nexport function spokeUserPositionManagers(\n client: AaveClient,\n request: SpokeUserPositionManagersRequest,\n): ResultAsync<PaginatedSpokeUserPositionManagerResult, UnexpectedError> {\n return client.query(SpokeUserPositionManagersQuery, { request });\n}\n","import {\n delay,\n TimeoutError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport {\n BorrowSwapQuoteQuery,\n type BorrowSwapQuoteRequest,\n type CancelSwapExecutionPlan,\n CancelSwapMutation,\n type CancelSwapRequest,\n type InsufficientBalanceError,\n type InsufficientLiquidityError,\n type PaginatedUserSwapsResult,\n type PositionSwapByIntentApprovalsRequired,\n PreparePositionSwapQuery,\n type PreparePositionSwapRequest,\n PrepareSwapCancelQuery,\n type PrepareSwapCancelRequest,\n type PrepareSwapCancelResult,\n type PrepareSwapOrder,\n PrepareTokenSwapQuery,\n type PrepareTokenSwapRequest,\n RepayWithSupplyQuoteQuery,\n type RepayWithSupplyQuoteRequest,\n SupplySwapQuoteQuery,\n type SupplySwapQuoteRequest,\n type SwapCancelled,\n type SwapExpired,\n type SwapFulfilled,\n SwapMutation,\n SwappableTokensQuery,\n type SwappableTokensRequest,\n type SwapReceipt,\n type SwapRequest,\n type SwapStatus,\n SwapStatusQuery,\n type SwapStatusRequest,\n type SwapTransactionRequest,\n type Token,\n TokenSwapQuoteQuery,\n type TokenSwapQuoteRequest,\n type TokenSwapQuoteResult,\n UserSwapsQuery,\n type UserSwapsRequest,\n WithdrawSwapQuoteQuery,\n type WithdrawSwapQuoteRequest,\n} from '@aave/graphql';\nimport { extendWithOpaqueType, okAsync, ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches a swap quote for the specified trade parameters.\n *\n * ```ts\n * const result = await tokenSwapQuote(client, {\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6...') },\n * sell: { erc20: evmAddress('0x6B175474E...') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.Sell,\n * user: evmAddress('0x742d35cc...'),\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap quote request parameters.\n * @param options - The query options.\n * @returns The swap quote including pricing and cost information and plan to start executing the swap.\n */\nexport function tokenSwapQuote(\n client: AaveClient,\n request: TokenSwapQuoteRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<\n TokenSwapQuoteResult,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n return client\n .query(\n TokenSwapQuoteQuery,\n { request, currency },\n { batch: false, requestPolicy },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'SwapByIntent':\n case 'SwapByIntentWithApprovalRequired':\n case 'SwapByTransaction':\n return okAsync(result);\n\n case 'InsufficientLiquidityError':\n return ValidationError.fromGqlNode(result).asResultAsync();\n\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported result: ${result.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Fetches the list of tokens available for swapping on a specific chain.\n *\n * ```ts\n * const result = await swappableTokens(client, {\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swappable tokens request parameters.\n * @param options - The query options.\n * @returns The list of tokens available for swapping.\n */\nexport function swappableTokens(\n client: AaveClient,\n request: SwappableTokensRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Token[], UnexpectedError> {\n return client.query(SwappableTokensQuery, { request }, { requestPolicy });\n}\n\n/**\n * Prepares a swap for the specified trade parameters.\n *\n * ```ts\n * const result = await prepareTokenSwap(client, {\n * quoteId: quote.quoteId,\n * }).andThen(order => {\n * return signTypedDataWith(wallet, order.data)\n * .andThen((signature) =>\n * swap({ intent: { quoteId: order.newQuoteId, signature } }),\n * );\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The prepare swap request parameters.\n * @returns The prepared swap result containing details of the swap.\n */\nexport function prepareTokenSwap(\n client: AaveClient,\n request: PrepareTokenSwapRequest,\n): ResultAsync<\n PrepareSwapOrder,\n ValidationError<InsufficientBalanceError> | UnexpectedError\n> {\n return client\n .query(PrepareTokenSwapQuery, { request }, { batch: false })\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PrepareSwapOrder':\n return okAsync(result);\n case 'InsufficientBalanceError':\n return ValidationError.fromGqlNode(result).asResultAsync();\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported result: ${result.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Fetches a supply swap quote for swapping deposited funds.\n *\n * ```ts\n * const result = await supplySwapQuote(client, {\n * market: {\n * sellPosition: userSupplyItemId('position_123'),\n * buyReserve: reserveId('reserve_456'),\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc...'),\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The supply swap request parameters.\n * @param options - The query options.\n * @returns The supply swap result with quote, approvals, and preview.\n */\nexport function supplySwapQuote(\n client: AaveClient,\n request: SupplySwapQuoteRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<\n PositionSwapByIntentApprovalsRequired,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n return client\n .query(\n SupplySwapQuoteQuery,\n { request, currency },\n { batch: false, requestPolicy },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\n\n case 'InsufficientLiquidityError':\n return ValidationError.fromGqlNode(result).asResultAsync();\n\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported result: ${result.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Fetches a borrow swap quote for swapping debt positions.\n *\n * ```ts\n * const result = await borrowSwapQuote(client, {\n * market: {\n * sellPosition: userBorrowItemId('position_123'),\n * buyReserve: reserveId('reserve_456'),\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc...'),\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The borrow swap request parameters.\n * @param options - The query options.\n * @returns The borrow swap result with quote, approvals, and preview.\n */\nexport function borrowSwapQuote(\n client: AaveClient,\n request: BorrowSwapQuoteRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<\n PositionSwapByIntentApprovalsRequired,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n return client\n .query(\n BorrowSwapQuoteQuery,\n { request, currency },\n { batch: false, requestPolicy },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\n\n case 'InsufficientLiquidityError':\n return ValidationError.fromGqlNode(result).asResultAsync();\n\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported result: ${result.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Fetches a repay with supply quote for repaying debt using collateral.\n *\n * ```ts\n * const result = await repayWithSupplyQuote(client, {\n * market: {\n * sellPosition: userSupplyItemId('collateral_123'),\n * buyPosition: userBorrowItemId('debt_456'),\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc...'),\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The repay with supply request parameters.\n * @param options - The query options.\n * @returns The repay with supply result with quote, approvals, and preview.\n */\nexport function repayWithSupplyQuote(\n client: AaveClient,\n request: RepayWithSupplyQuoteRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<\n PositionSwapByIntentApprovalsRequired,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n return client\n .query(\n RepayWithSupplyQuoteQuery,\n { request, currency },\n { batch: false, requestPolicy },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\n\n case 'InsufficientLiquidityError':\n return ValidationError.fromGqlNode(result).asResultAsync();\n\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported result: ${result.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Fetches a withdraw swap quote for withdrawing deposits and swapping on the fly.\n *\n * ```ts\n * const result = await withdrawSwapQuote(client, {\n * market: {\n * position: userSupplyItemId('position_123'),\n * buyReserve: reserveId('reserve_456'),\n * amount: bigDecimal('1000'),\n * user: evmAddress('0x742d35cc...'),\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The withdraw swap request parameters.\n * @param options - The query options.\n * @returns The withdraw swap result with quote, approvals, and preview.\n */\nexport function withdrawSwapQuote(\n client: AaveClient,\n request: WithdrawSwapQuoteRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<\n PositionSwapByIntentApprovalsRequired,\n UnexpectedError | ValidationError<InsufficientLiquidityError>\n> {\n return client\n .query(\n WithdrawSwapQuoteQuery,\n { request, currency },\n { batch: false, requestPolicy },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\n\n case 'InsufficientLiquidityError':\n return ValidationError.fromGqlNode(result).asResultAsync();\n\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported result: ${result.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Prepares a position swap by obtaining the typed data for signing.\n *\n * ```ts\n * const result = await preparePositionSwap(client, {\n * quoteId: quote.quoteId,\n * adapterContractSignature: signature('0x456...'),\n * positionManagerSignature: signature('0x789...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The position swap request with quote ID and signatures.\n * @returns The position swap result with intent data for execution.\n */\nexport function preparePositionSwap(\n client: AaveClient,\n request: PreparePositionSwapRequest,\n): ResultAsync<\n PrepareSwapOrder,\n ValidationError<InsufficientBalanceError> | UnexpectedError\n> {\n return client\n .query(PreparePositionSwapQuery, { request }, { batch: false })\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PrepareSwapOrder':\n return okAsync(result);\n case 'InsufficientBalanceError':\n return ValidationError.fromGqlNode(result).asResultAsync();\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported result: ${result.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Fetches the status of a specific swap.\n *\n * ```ts\n * const result = await swapStatus(client, {\n * id: swapId('swap_123'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap status request parameters.\n * @param options - The query options.\n * @returns The current status of the swap.\n */\nexport function swapStatus(\n client: AaveClient,\n request: SwapStatusRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<SwapStatus, UnexpectedError> {\n return client.query(\n SwapStatusQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\nexport type SwapOutcome = SwapCancelled | SwapExpired | SwapFulfilled;\n\n/**\n * Waits for a swap to reach a final outcome (cancelled, expired, or fulfilled).\n *\n * ```ts\n * const result = waitForSwapOutcome(client)(swapReceipt);\n *\n * if (result.isOk()) {\n * const outcome = result.value;\n * switch (outcome.__typename) {\n * case 'SwapFulfilled':\n * console.log('Swap completed successfully:', outcome.txHash);\n * break;\n * case 'SwapCancelled':\n * console.log('Swap was cancelled:', outcome.cancelledAt);\n * break;\n * case 'SwapExpired':\n * console.log('Swap expired:', outcome.expiredAt);\n * break;\n * }\n * }\n * ```\n *\n * @param client - Aave client configured with polling settings.\n * @returns A function that takes a SwapReceipt and returns a ResultAsync with the final outcome.\n */\nexport function waitForSwapOutcome(\n client: AaveClient,\n): (\n receipt: SwapReceipt,\n) => ResultAsync<SwapOutcome, TimeoutError | UnexpectedError> {\n return (receipt: SwapReceipt) => {\n const pollForSwapOutcome = async (\n request: SwapStatusRequest,\n ): Promise<SwapOutcome> => {\n const startedAt = Date.now();\n\n while (\n Date.now() - startedAt <\n client.context.environment.indexingTimeout\n ) {\n const status = await swapStatus(client, request).match(\n (ok) => ok,\n (err) => {\n throw err;\n },\n );\n\n switch (status.__typename) {\n case 'SwapCancelled':\n case 'SwapExpired':\n case 'SwapFulfilled':\n return status;\n\n default:\n await delay(client.context.environment.pollingInterval);\n continue;\n }\n }\n\n throw TimeoutError.from(\n `Timeout waiting for swap ${request.id} to reach final outcome.`,\n );\n };\n\n return ResultAsync.fromPromise(\n pollForSwapOutcome({ id: receipt.id }),\n (error) => {\n if (error instanceof TimeoutError || error instanceof UnexpectedError) {\n return error;\n }\n return UnexpectedError.from(error);\n },\n );\n };\n}\n\n/**\n * Executes a swap for the specified request parameters.\n *\n * ```ts\n * const result = await swap(client, {\n * intent: {\n * quoteId: quote.quoteId,\n * signature: signature('0x456...'),\n * },\n * }).andThen((plan) => {\n * switch (plan.__typename) {\n * case 'SwapTransactionRequest':\n * return sendTransaction(plan.transaction)\n * .map(() => plan.orderReceipt);\n *\n * case 'SwapReceipt':\n * return okAsync(plan);\n * }\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * console.log('Order receipt:', result.value);\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap request parameters.\n * @returns The swap execution plan containing transaction details or receipt.\n */\nexport function swap(\n client: AaveClient,\n request: SwapRequest,\n): ResultAsync<\n SwapTransactionRequest | SwapReceipt,\n ValidationError<InsufficientBalanceError> | UnexpectedError\n> {\n return client\n .mutation(SwapMutation, { request })\n .map(extendWithOpaqueType)\n .andThen((plan) => {\n switch (plan.__typename) {\n case 'SwapTransactionRequest':\n return okAsync(plan);\n case 'SwapReceipt':\n return okAsync(plan);\n case 'InsufficientBalanceError':\n return ValidationError.fromGqlNode(plan).asResultAsync();\n default:\n return UnexpectedError.upgradeRequired(\n `Unsupported swap plan: ${plan.__typename}`,\n ).asResultAsync();\n }\n });\n}\n\n/**\n * Prepares a swap cancellation for the specified swap ID.\n *\n * ```ts\n * const result = await prepareSwapCancel(client, {\n * id: swapId('123...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The prepare swap cancel request parameters.\n * @returns The prepared swap cancel result containing typed data for signing.\n */\nexport function prepareSwapCancel(\n client: AaveClient,\n request: PrepareSwapCancelRequest,\n): ResultAsync<PrepareSwapCancelResult, UnexpectedError> {\n return client.query(PrepareSwapCancelQuery, { request }, { batch: false });\n}\n\n/**\n * Executes a swap cancellation for the specified request parameters.\n *\n * ```ts\n * const result = await cancelSwap(client, {\n * intent: {\n * id: swapId('123...'),\n * signature: {\n * value: signature('0x456...'),\n * deadline: 1234567890,\n * },\n * },\n * }).andThen((plan) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan);\n *\n * case 'SwapCancelled':\n * return okAsync(plan);\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The cancel swap request parameters.\n * @returns The cancel swap execution plan containing transaction details or cancellation receipt.\n */\nexport function cancelSwap(\n client: AaveClient,\n request: CancelSwapRequest,\n): ResultAsync<CancelSwapExecutionPlan, UnexpectedError> {\n return client.mutation(CancelSwapMutation, { request });\n}\n\n/**\n * Fetches the user's swap history for a specific chain.\n *\n * ```ts\n * const result = await userSwaps(client, {\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc...'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user swaps request parameters.\n * @param options - The query options.\n * @returns The paginated list of user swaps with their status information.\n */\nexport function userSwaps(\n client: AaveClient,\n request: UserSwapsRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PaginatedUserSwapsResult, UnexpectedError> {\n return client.query(\n UserSwapsQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n ActivitiesQuery,\n type ActivitiesRequest,\n BorrowQuery,\n type BorrowRequest,\n ClaimRewardsQuery,\n type ClaimRewardsRequest,\n type ExecutionPlan,\n LiquidatePositionQuery,\n type LiquidatePositionRequest,\n type PaginatedActivitiesResult,\n PreviewQuery,\n type PreviewRequest,\n type PreviewUserPosition,\n RenounceSpokeUserPositionManagerQuery,\n type RenounceSpokeUserPositionManagerRequest,\n RepayQuery,\n type RepayRequest,\n SetSpokeUserPositionManagerQuery,\n type SetSpokeUserPositionManagerRequest,\n SetUserSuppliesAsCollateralQuery,\n type SetUserSuppliesAsCollateralRequest,\n SupplyQuery,\n type SupplyRequest,\n type TransactionRequest,\n UpdateUserPositionConditionsQuery,\n type UpdateUserPositionConditionsRequest,\n WithdrawQuery,\n type WithdrawRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Creates a transaction to borrow from a market.\n *\n * ```ts\n * const result = await borrow(client, {\n * amount: {\n * erc20: {\n * value: bigDecimal('1000'),\n * },\n * },\n * reserve: reserveId('SGVsbG8h'),\n * sender: evmAddress('0x9abc…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The borrow request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function borrow(\n client: AaveClient,\n request: BorrowRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(BorrowQuery, { request });\n}\n\n/**\n * Creates a transaction to supply to a market.\n *\n * ```ts\n * const result = await supply(client, {\n * reserve: {\n * reserveId: \"1234567890\",\n * spoke: evmAddress('0x8787…'),\n * chainId: chainId(1),\n * },\n * amount: {\n * erc20: {\n * value: bigDecimal('1000'),\n * },\n * },\n * enableCollateral: true, // Optional, defaults to true\n * sender: evmAddress('0x9abc…'),\n * });\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The supply request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function supply(\n client: AaveClient,\n request: SupplyRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(SupplyQuery, { request });\n}\n\n/**\n * Creates a transaction to repay to a market.\n *\n * ```ts\n * const result = await repay(client, {\n * amount: {\n * erc20: {\n * value: {\n * exact: bigDecimal('500'),\n * },\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * reserve: reserveId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The repay request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function repay(\n client: AaveClient,\n request: RepayRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(RepayQuery, { request });\n}\n\n/**\n * Creates a transaction to withdraw from a reserve.\n *\n * ```ts\n * const result = await withdraw(client, {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * exact: bigDecimal('750.5'),\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * **Withdraw specific amount:**\n * ```ts\n * amount: {\n * erc20: {\n * exact: bigDecimal('100.5'), // Exact amount to withdraw\n * }\n * }\n * ```\n *\n * **Withdraw all available:**\n * ```ts\n * amount: {\n * erc20: {\n * max: true, // Withdraw the full position\n * }\n * }\n * ```\n *\n * **Withdraw native token:**\n * ```ts\n * amount: {\n * native: bigDecimal('0.5'), // For ETH on Ethereum\n * }\n * ```\n *\n * @param client - Aave client.\n * @param request - The withdraw request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function withdraw(\n client: AaveClient,\n request: WithdrawRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(WithdrawQuery, { request });\n}\n\n/**\n * Creates a transaction to renounce a position manager of a user in a specific spoke.\n *\n * ```ts\n * const result = await renounceSpokeUserPositionManager(client, {\n * manager: evmAddress('0x9abc…'),\n * managing: evmAddress('0xdef0…'),\n * spoke: spokeId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The renounce spoke user position manager request parameters.\n * @returns The transaction data.\n */\nexport function renounceSpokeUserPositionManager(\n client: AaveClient,\n request: RenounceSpokeUserPositionManagerRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(RenounceSpokeUserPositionManagerQuery, { request });\n}\n\n/**\n * Creates a transaction to update user position conditions (dynamic config and/or risk premium).\n *\n * ```ts\n * const result = await updateUserPositionConditions(client, {\n * userPositionId: userPositionId('SGVsbG8h'),\n * update: UserPositionConditionsUpdate.AllDynamicConfig,\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The update user position conditions request parameters.\n * @returns The transaction data.\n */\nexport function updateUserPositionConditions(\n client: AaveClient,\n request: UpdateUserPositionConditionsRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(UpdateUserPositionConditionsQuery, { request });\n}\n\n/**\n * Creates a transaction to liquidate a user's position.\n *\n * ```ts\n * const result = await liquidatePosition(client, {\n * collateral: reserveId('SGVsbG8h'),\n * debt: reserveId('Q2lhbyE= '),\n * amount: {\n * exact: bigDecimal('1000'),\n * },\n * liquidator: evmAddress('0x9abc…'),\n * user: evmAddress('0xdef0…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The liquidate position request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function liquidatePosition(\n client: AaveClient,\n request: LiquidatePositionRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(LiquidatePositionQuery, { request });\n}\n\n/**\n * Sets or removes a position manager for a user on a specific spoke.\n *\n * **Position managers** can perform transactions on behalf of other users, including:\n * - Supply assets\n * - Borrow assets\n * - Withdraw assets\n * - Enable/disable collateral\n *\n * The `signature` parameter is an **ERC712 signature** that must be signed by the **user**\n * (the account granting permissions) to authorize the position manager. The signature contains:\n * - `value`: The actual cryptographic signature\n * - `deadline`: Unix timestamp when the authorization expires\n *\n * ```ts\n * const result = await setSpokeUserPositionManager(client, {\n * spoke: spokeId('SGVsbG8h'),\n * manager: evmAddress('0x9abc…'), // Address that will become the position manager\n * approve: true, // true to approve, false to remove the manager\n * user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)\n * signature: {\n * value: '0x1234...', // ERC712 signature signed by the user\n * deadline: 1735689600, // Unix timestamp when signature expires\n * },\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The spoke set for the position manager request parameters.\n * @returns The transaction request data to set position manager.\n */\nexport function setSpokeUserPositionManager(\n client: AaveClient,\n request: SetSpokeUserPositionManagerRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(SetSpokeUserPositionManagerQuery, { request });\n}\n\n/**\n * Previews the impact of a potential action on a user's position.\n *\n * ```ts\n * const result = await preview(client, {\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * value: '1000',\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * },\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The preview request parameters containing the action to preview.\n * @param options - The query options.\n * @returns The preview result showing position changes.\n */\nexport function preview(\n client: AaveClient,\n request: PreviewRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PreviewUserPosition, UnexpectedError> {\n return client.query(PreviewQuery, { request, currency }, { requestPolicy });\n}\n\n/**\n * Updates the collateral status of user's supplies.\n *\n * ```ts\n * const result = await setUserSuppliesAsCollateral(client, {\n * changes: [\n * {\n * reserve: reserveId('SGVsbG8h'),\n * enableCollateral: true\n * }\n * ],\n * sender: evmAddress('0x456...')\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The request parameters.\n * @returns The transaction request to update collateral status.\n */\nexport function setUserSuppliesAsCollateral(\n client: AaveClient,\n request: SetUserSuppliesAsCollateralRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(SetUserSuppliesAsCollateralQuery, { request });\n}\n\n/**\n * Creates a transaction to claim rewards.\n *\n * ```ts\n * const result = await claimRewards(client, {\n * ids: [rewardId('abc123')],\n * });\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TransactionRequest\n * ```\n *\n * @param client - Aave client.\n * @param request - The claim rewards request parameters.\n * @returns The transaction request to claim rewards.\n */\nexport function claimRewards(\n client: AaveClient,\n request: ClaimRewardsRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(ClaimRewardsQuery, { request });\n}\n\n/**\n * Fetches paginated list of activities.\n *\n * ```ts\n * const result = await activities(client, {\n * query: {\n * chainIds: [chainId(1)],\n * },\n * user: evmAddress('0x742d35cc…'), // Optional\n * types: [ActivityType.Supply, ActivityType.Borrow, ActivityType.Withdraw, ActivityType.Repay],\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The activities request parameters.\n * @param options - The query options.\n * @returns The paginated list of activities.\n */\nexport function activities(\n client: AaveClient,\n request: ActivitiesRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PaginatedActivitiesResult, UnexpectedError> {\n return client.query(\n ActivitiesQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type UserBalance,\n UserBalancesQuery,\n type UserBalancesRequest,\n type UserBorrowItem,\n UserBorrowsQuery,\n type UserBorrowsRequest,\n type UserPosition,\n UserPositionQuery,\n type UserPositionRequest,\n UserPositionsQuery,\n type UserPositionsRequest,\n type UserRiskPremiumBreakdownItem,\n UserRiskPremiumBreakdownQuery,\n type UserRiskPremiumBreakdownRequest,\n type UserSummary,\n type UserSummaryHistoryItem,\n UserSummaryHistoryQuery,\n type UserSummaryHistoryRequest,\n UserSummaryQuery,\n type UserSummaryRequest,\n UserSuppliesQuery,\n type UserSuppliesRequest,\n type UserSupplyItem,\n} from '@aave/graphql';\nimport type { Prettify, ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches all user supply positions across the specified spoke.\n *\n * ```ts\n * const result = await userSupplies(client, {\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user supplies request parameters.\n * @param options - The query options.\n * @returns The user's supply positions.\n */\nexport function userSupplies(\n client: AaveClient,\n request: UserSuppliesRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSupplyItem[], UnexpectedError> {\n return client.query(\n UserSuppliesQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches all user borrow positions across the specified spoke.\n *\n * ```ts\n * const result = await userBorrows(client, {\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user borrows request parameters.\n * @param options - The query options.\n * @returns The user's borrow positions.\n */\nexport function userBorrows(\n client: AaveClient,\n request: UserBorrowsRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserBorrowItem[], UnexpectedError> {\n return client.query(\n UserBorrowsQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\nexport type UserSummaryQueryOptions = Prettify<\n CurrencyQueryOptions & TimeWindowQueryOptions & RequestPolicyOptions\n>;\n\n/**\n * Fetches a user's summary across all positions.\n *\n * ```ts\n * const result = await userSummary(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user summary request parameters.\n * @param options - The query options.\n * @returns The user's financial summary.\n */\nexport function userSummary(\n client: AaveClient,\n request: UserSummaryRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: UserSummaryQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSummary, UnexpectedError> {\n return client.query(\n UserSummaryQuery,\n {\n request,\n currency,\n timeWindow,\n },\n { requestPolicy },\n );\n}\n\nexport type UserPositionQueryOptions = CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions;\n\n/**\n * Fetches all user positions across specified chains.\n *\n * ```ts\n * const result = await userPositions(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)],\n * },\n * orderBy: { balance: 'DESC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user positions request parameters.\n * @param options - The query options.\n * @returns The user's positions across all specified chains.\n */\nexport function userPositions(\n client: AaveClient,\n request: UserPositionsRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserPosition[], UnexpectedError> {\n return client.query(\n UserPositionsQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches a specific user position by ID.\n *\n * ```ts\n * const result = await userPosition(client, {\n * id: userPositionId('SGVsbG8h'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user position request parameters.\n * @param options - The query options.\n * @returns The specific user position or null if not found.\n */\nexport function userPosition(\n client: AaveClient,\n request: UserPositionRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserPosition | null, UnexpectedError> {\n return client.query(\n UserPositionQuery,\n { request, currency, timeWindow },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches all user balances across specified chains.\n *\n * ```ts\n * const result = await userBalances(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)],\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user balances request parameters.\n * @param options - The query options.\n * @returns The user's balances across all specified chains.\n **/\nexport function userBalances(\n client: AaveClient,\n request: UserBalancesRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserBalance[], UnexpectedError> {\n return client.query(\n UserBalancesQuery,\n { request, currency },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches user summary history over time.\n *\n * ```ts\n * const result = await userSummaryHistory(client, {\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: {\n * chainIds: [chainId(1)]\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user summary history request parameters.\n * @param options - The query options.\n * @returns The user summary history items.\n */\nexport function userSummaryHistory(\n client: AaveClient,\n request: UserSummaryHistoryRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSummaryHistoryItem[], UnexpectedError> {\n return client.query(\n UserSummaryHistoryQuery,\n { request, currency },\n { requestPolicy },\n );\n}\n\n/**\n * Fetches the risk premium breakdown for a user position or spoke.\n *\n * ```ts\n * const result = await userRiskPremiumBreakdown(client, {\n * query: {\n * userPositionId: userPositionId('SGVsbG8h'),\n * },\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user risk premium breakdown request parameters.\n * @param options - The query options.\n * @returns Array of risk premium breakdown items.\n */\nexport function userRiskPremiumBreakdown(\n client: AaveClient,\n request: UserRiskPremiumBreakdownRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserRiskPremiumBreakdownItem[], UnexpectedError> {\n return client.query(\n UserRiskPremiumBreakdownQuery,\n { request },\n { requestPolicy },\n );\n}\n"]}
|