@aave/client 4.0.0-next.2 → 4.0.0-next.20
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-Cv6_HiWO.d.ts} +1 -1
- package/dist/{AaveClient-L3v8kWvn.d.cts → AaveClient-D1eyXM-a.d.cts} +1 -1
- package/dist/actions/index.cjs +1 -1
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +228 -135
- package/dist/actions/index.d.ts +228 -135
- package/dist/actions/index.js +1 -1
- package/dist/chunk-3HZQC3YV.js +3 -0
- package/dist/chunk-3HZQC3YV.js.map +1 -0
- package/dist/chunk-MKZBFAXA.js +2 -0
- package/dist/chunk-MKZBFAXA.js.map +1 -0
- package/dist/ethers.cjs +1 -1
- package/dist/ethers.cjs.map +1 -1
- package/dist/ethers.d.cts +5 -7
- package/dist/ethers.d.ts +5 -7
- 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 +3 -3
- package/dist/index.d.ts +3 -3
- 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 +2 -2
- package/dist/privy.cjs.map +1 -1
- package/dist/privy.d.cts +3 -5
- package/dist/privy.d.ts +3 -5
- package/dist/privy.js +1 -1
- package/dist/privy.js.map +1 -1
- package/dist/testing.d.ts +3839 -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 +15 -11
- package/dist/thirdweb.d.ts +15 -11
- package/dist/thirdweb.js +1 -2
- package/dist/thirdweb.js.map +1 -1
- package/dist/{types-Bu63z0x6.d.cts → types-CQvue0x0.d.cts} +4 -4
- package/dist/{types-Bu63z0x6.d.ts → types-CQvue0x0.d.ts} +4 -4
- package/dist/viem.cjs +2 -2
- package/dist/viem.cjs.map +1 -1
- package/dist/viem.d.cts +23 -10
- package/dist/viem.d.ts +23 -10
- package/dist/viem.js +1 -1
- package/package.json +11 -12
- package/dist/chunk-2TNQ52OQ.js +0 -3
- package/dist/chunk-2TNQ52OQ.js.map +0 -1
- package/dist/chunk-BQFM5RT3.js +0 -2
- package/dist/chunk-BQFM5RT3.js.map +0 -1
- package/dist/chunk-BQNVAUS6.js +0 -3
- package/dist/chunk-BQNVAUS6.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 -49
- package/dist/test-utils.d.ts +0 -49
- 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[]
|
|
@@ -2,7 +2,7 @@ import { GqlClient, TimeoutError, UnexpectedError, StandardData } from '@aave/co
|
|
|
2
2
|
import { HasProcessedKnownTransactionRequest } from '@aave/graphql';
|
|
3
3
|
import { ResultAsync, TxHash, AnyVariables } from '@aave/types';
|
|
4
4
|
import { TypedDocumentNode } from '@urql/core';
|
|
5
|
-
import { T as TransactionResult } from './types-
|
|
5
|
+
import { T as TransactionResult } from './types-CQvue0x0.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The environment configuration type.
|
|
@@ -2,7 +2,7 @@ import { GqlClient, TimeoutError, UnexpectedError, StandardData } from '@aave/co
|
|
|
2
2
|
import { HasProcessedKnownTransactionRequest } from '@aave/graphql';
|
|
3
3
|
import { ResultAsync, TxHash, AnyVariables } from '@aave/types';
|
|
4
4
|
import { TypedDocumentNode } from '@urql/core';
|
|
5
|
-
import { T as TransactionResult } from './types-
|
|
5
|
+
import { T as TransactionResult } from './types-CQvue0x0.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The environment configuration type.
|
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
|
|
1
|
+
'use strict';var graphql=require('@aave/graphql'),core=require('@aave/core'),types=require('@aave/types');var n={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function xe(e,t,r=n){return e.query(graphql.HubQuery,{request:t,currency:r.currency??n.currency,timeWindow:r.timeWindow??n.timeWindow},{requestPolicy:r.requestPolicy??n.requestPolicy})}function fe(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.HubsQuery,{request:t,currency:r,timeWindow:o})}function Ce(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.HubAssetsQuery,{request:t,currency:r,timeWindow:o})}function Qe(e,t){return e.query(graphql.HubSummaryHistoryQuery,{request:t})}function Te(e,t,{batch:r}=n){return e.query(graphql.ChainQuery,{request:t},{batch:r})}function he(e,t){return e.query(graphql.ChainsQuery,{request:t})}function ke(e,t){return e.query(graphql.HasProcessedKnownTransactionQuery,{request:t},{requestPolicy:"network-only",batch:false})}function He(e,t){return e.query(graphql.ExchangeRateQuery,{request:t})}function _e(e,t){return e.query(graphql.PermitTypedDataQuery,{request:t})}function Me(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow,requestPolicy:p=n.requestPolicy}=n){return e.query(graphql.AssetQuery,{request:t,currency:r,timeWindow:o},{requestPolicy:p})}function De(e,t,r=n){return e.query(graphql.AssetPriceHistoryQuery,{request:t},{requestPolicy:r.requestPolicy??n.requestPolicy})}function Fe(e,t,r=n){return e.query(graphql.AssetSupplyHistoryQuery,{request:t},{requestPolicy:r.requestPolicy??n.requestPolicy})}function Le(e,t,r=n){return e.query(graphql.AssetBorrowHistoryQuery,{request:t},{requestPolicy:r.requestPolicy??n.requestPolicy})}function Ne(e,t,r=n){return e.query(graphql.ProtocolHistoryQuery,{request:t},{requestPolicy:r.requestPolicy??n.requestPolicy})}function Ve(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.ReserveQuery,{request:t,currency:r,timeWindow:o})}function Ge(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.ReservesQuery,{request:t,currency:r,timeWindow:o})}function je(e,t){return e.query(graphql.BorrowApyHistoryQuery,{request:t})}function ze(e,t){return e.query(graphql.SupplyApyHistoryQuery,{request:t})}function Ze(e,t){return e.query(graphql.SpokeQuery,{request:t})}function et(e,t){return e.query(graphql.SpokesQuery,{request:t})}function tt(e,t){return e.query(graphql.SpokePositionManagersQuery,{request:t})}function rt(e,t){return e.query(graphql.SpokeUserPositionManagersQuery,{request:t})}function pt(e,t,r=n){return e.query(graphql.TokenSwapQuoteQuery,{request:t,currency:r.currency},{batch:false})}function at(e,t){return e.query(graphql.SwappableTokensQuery,{request:t})}function yt(e,t){return e.query(graphql.PrepareTokenSwapQuery,{request:t},{batch:false}).map(types.extendWithOpaqueType).andThen(r=>{switch(r.__typename){case "PrepareSwapOrder":return types.okAsync(r);case "InsufficientBalanceError":return core.ValidationError.fromGqlNode(r).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${r.__typename}`).asResultAsync()}})}function ct(e,t,r=n){return e.query(graphql.SupplySwapQuoteQuery,{request:t,currency:r.currency},{batch:false}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function lt(e,t,r=n){return e.query(graphql.BorrowSwapQuoteQuery,{request:t,currency:r.currency},{batch:false}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function Rt(e,t,r=n){return e.query(graphql.RepayWithSupplyQuoteQuery,{request:t,currency:r.currency},{batch:false}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function mt(e,t,r=n){return e.query(graphql.WithdrawSwapQuoteQuery,{request:t,currency:r.currency},{batch:false}).map(types.extendWithOpaqueType).andThen(o=>{switch(o.__typename){case "PositionSwapByIntentApprovalsRequired":return types.okAsync(o);default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${o.__typename}`).asResultAsync()}})}function qt(e,t){return e.query(graphql.PreparePositionSwapQuery,{request:t},{batch:false}).map(types.extendWithOpaqueType).andThen(r=>{switch(r.__typename){case "PrepareSwapOrder":return types.okAsync(r);case "InsufficientBalanceError":return core.ValidationError.fromGqlNode(r).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported result: ${r.__typename}`).asResultAsync()}})}function X(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.SwapStatusQuery,{request:t,currency:r,timeWindow:o})}function dt(e){return t=>{let r=async o=>{let p=Date.now();for(;Date.now()-p<e.context.environment.indexingTimeout;){let c=await X(e,o).match(a=>a,a=>{throw a});switch(c.__typename){case "SwapCancelled":case "SwapExpired":case "SwapFulfilled":return c;default:await core.delay(e.context.environment.pollingInterval);continue}}throw core.TimeoutError.from(`Timeout waiting for swap ${o.id} to reach final outcome.`)};return types.ResultAsync.fromPromise(r({id:t.id}),o=>o instanceof core.TimeoutError||o instanceof core.UnexpectedError?o:core.UnexpectedError.from(o))}}function At(e,t){return e.mutation(graphql.SwapMutation,{request:t}).map(types.extendWithOpaqueType).andThen(r=>{switch(r.__typename){case "SwapTransactionRequest":return types.okAsync(r);case "SwapReceipt":return types.okAsync(r);case "InsufficientBalanceError":return core.ValidationError.fromGqlNode(r).asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap plan: ${r.__typename}`).asResultAsync()}})}function wt(e,t){return e.query(graphql.PrepareSwapCancelQuery,{request:t},{batch:false})}function St(e,t){return e.mutation(graphql.CancelSwapMutation,{request:t})}function Ut(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.UserSwapsQuery,{request:t,currency:r,timeWindow:o})}function Ct(e,t){return e.query(graphql.BorrowQuery,{request:t})}function Qt(e,t){return e.query(graphql.SupplyQuery,{request:t})}function vt(e,t){return e.query(graphql.RepayQuery,{request:t})}function Et(e,t){return e.query(graphql.WithdrawQuery,{request:t})}function Ot(e,t){return e.query(graphql.RenounceSpokeUserPositionManagerQuery,{request:t})}function Tt(e,t){return e.query(graphql.UpdateUserPositionConditionsQuery,{request:t})}function ht(e,t){return e.query(graphql.LiquidatePositionQuery,{request:t})}function kt(e,t){return e.query(graphql.SetSpokeUserPositionManagerQuery,{request:t})}function Ht(e,t,r=n){return e.query(graphql.PreviewQuery,{request:t,...r})}function Bt(e,t){return e.query(graphql.SetUserSuppliesAsCollateralQuery,{request:t})}function Wt(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow,requestPolicy:p=n.requestPolicy}=n){return e.query(graphql.ActivitiesQuery,{request:t,currency:r,timeWindow:o},{requestPolicy:p})}function It(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.UserSuppliesQuery,{request:t,currency:r,timeWindow:o})}function Mt(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.UserBorrowsQuery,{request:t,currency:r,timeWindow:o})}function Dt(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.UserSummaryQuery,{request:t,currency:r,timeWindow:o})}function Ft(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.UserPositionsQuery,{request:t,currency:r,timeWindow:o})}function Lt(e,t,{currency:r=n.currency,timeWindow:o=n.timeWindow}=n){return e.query(graphql.UserPositionQuery,{request:t,currency:r,timeWindow:o})}function Nt(e,t,r=n){return e.query(graphql.UserBalancesQuery,{request:t,...r})}function Yt(e,t,r=n){return e.query(graphql.UserSummaryHistoryQuery,{request:t,...r})}function $t(e,t){return e.query(graphql.UserRiskPremiumBreakdownQuery,{request:t})}exports.activities=Wt;exports.asset=Me;exports.assetBorrowHistory=Le;exports.assetPriceHistory=De;exports.assetSupplyHistory=Fe;exports.borrow=Ct;exports.borrowApyHistory=je;exports.borrowSwapQuote=lt;exports.cancelSwap=St;exports.chain=Te;exports.chains=he;exports.exchangeRate=He;exports.hasProcessedKnownTransaction=ke;exports.hub=xe;exports.hubAssets=Ce;exports.hubSummaryHistory=Qe;exports.hubs=fe;exports.liquidatePosition=ht;exports.permitTypedData=_e;exports.preparePositionSwap=qt;exports.prepareSwapCancel=wt;exports.prepareTokenSwap=yt;exports.preview=Ht;exports.protocolHistory=Ne;exports.renounceSpokeUserPositionManager=Ot;exports.repay=vt;exports.repayWithSupplyQuote=Rt;exports.reserve=Ve;exports.reserves=Ge;exports.setSpokeUserPositionManager=kt;exports.setUserSuppliesAsCollateral=Bt;exports.spoke=Ze;exports.spokePositionManagers=tt;exports.spokeUserPositionManagers=rt;exports.spokes=et;exports.supply=Qt;exports.supplyApyHistory=ze;exports.supplySwapQuote=ct;exports.swap=At;exports.swapStatus=X;exports.swappableTokens=at;exports.tokenSwapQuote=pt;exports.updateUserPositionConditions=Tt;exports.userBalances=Nt;exports.userBorrows=Mt;exports.userPosition=Lt;exports.userPositions=Ft;exports.userRiskPremiumBreakdown=$t;exports.userSummary=Dt;exports.userSummaryHistory=Yt;exports.userSupplies=It;exports.userSwaps=Ut;exports.waitForSwapOutcome=dt;exports.withdraw=Et;exports.withdrawSwapQuote=mt;//# 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,OAAA,CACvB,aAAA,CAAe,mBACjB,CAAA,CCFO,SAASC,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,EAAuDN,CAAAA,CACb,CAC1C,OAAOI,CAAAA,CAAO,KAAA,CACZG,gBAAAA,CACA,CAAE,OAAA,CAAAF,CAAAA,CAAS,QAAA,CAAUC,CAAAA,CAAQ,QAAA,EAAYN,CAAAA,CAAsB,QAAS,CAAA,CACxEM,CAAAA,CAAQ,eAAiBN,CAAAA,CAAsB,aACjD,CACF,CAkBO,SAASQ,EAAAA,CACdJ,CAAAA,CACAC,CAAAA,CACAC,EAA0CN,CAAAA,CACL,CACrC,OAAOI,CAAAA,CAAO,KAAA,CAAMK,iBAAAA,CAAW,CAAE,OAAA,CAAAJ,EAAS,GAAGC,CAAQ,CAAC,CACxD,CAgBO,SAASI,EAAAA,CACdN,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0CN,CAAAA,CACA,CAC1C,OAAOI,CAAAA,CAAO,KAAA,CAAMO,sBAAAA,CAAgB,CAAE,OAAA,CA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,CAAWzG,CAAAA,CAAsB,QAAA,CACjC,UAAA,CAAA0G,CAAAA,CAAa1G,CAAAA,CAAsB,UACrC,EAA8BA,CAAAA,CACqB,CACnD,OAAOI,CAAAA,CAAO,KAAA,CAAM2G,yBAAAA,CAAmB,CAAE,OAAA,CAAA1G,CAAAA,CAAS,QAAA,CAAAoG,CAAAA,CAAU,UAAA,CAAAC,CAAW,CAAC,CAC1E,CAmBO,SAASM,EAAAA,CACd5G,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0CN,CAAAA,CACG,CAC7C,OAAOI,CAAAA,CAAO,KAAA,CAAM6G,yBAAAA,CAAmB,CAAE,OAAA,CAAA5G,CAAAA,CAAS,GAAGC,CAAQ,CAAC,CAChE,CAoBO,SAAS4G,EAAAA,CACd9G,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0CN,CAAAA,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 options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\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 'network-only',\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 options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\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 options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\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 options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\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 options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\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 options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.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 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/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","currency","timeWindow","HubsQuery","hubAssets","HubAssetsQuery","hubSummaryHistory","HubSummaryHistoryQuery","chain","batch","ChainQuery","chains","ChainsQuery","hasProcessedKnownTransaction","HasProcessedKnownTransactionQuery","exchangeRate","ExchangeRateQuery","permitTypedData","PermitTypedDataQuery","asset","requestPolicy","AssetQuery","assetPriceHistory","AssetPriceHistoryQuery","assetSupplyHistory","AssetSupplyHistoryQuery","assetBorrowHistory","AssetBorrowHistoryQuery","protocolHistory","ProtocolHistoryQuery","reserve","ReserveQuery","reserves","ReservesQuery","borrowApyHistory","BorrowApyHistoryQuery","supplyApyHistory","SupplyApyHistoryQuery","spoke","SpokeQuery","spokes","SpokesQuery","spokePositionManagers","SpokePositionManagersQuery","spokeUserPositionManagers","SpokeUserPositionManagersQuery","tokenSwapQuote","TokenSwapQuoteQuery","swappableTokens","SwappableTokensQuery","prepareTokenSwap","PrepareTokenSwapQuery","extendWithOpaqueType","result","okAsync","ValidationError","UnexpectedError","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","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,G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AAOI,CAAAA,CAAO,KAAA,CAAM0H,0BAAAA,CAAoB,CAAE,QAAAzH,CAAAA,CAAS,QAAA,CAAAI,EAAU,UAAA,CAAAC,CAAW,CAAC,CAC3E,CAgBO,SAASqH,EAAAA,CACd3H,CAAAA,CACAC,CAAAA,CACA,CACE,QAAA,CAAAI,CAAAA,CAAWT,EAAsB,QAAA,CACjC,UAAA,CAAAU,EAAaV,CAAAA,CAAsB,UACrC,CAAA,CAA8BA,CAAAA,CACqB,CACnD,OAAOI,EAAO,KAAA,CAAM4H,yBAAAA,CAAmB,CAAE,OAAA,CAAA3H,CAAAA,CAAS,SAAAI,CAAAA,CAAU,UAAA,CAAAC,CAAW,CAAC,CAC1E,CAmBO,SAASuH,EAAAA,CACd7H,CAAAA,CACAC,EACAC,CAAAA,CAA0CN,CAAAA,CACG,CAC7C,OAAOI,CAAAA,CAAO,KAAA,CAAM8H,yBAAAA,CAAmB,CAAE,OAAA,CAAA7H,EAAS,GAAGC,CAAQ,CAAC,CAChE,CAoBO,SAAS6H,EAAAA,CACd/H,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0CN,CAAAA,CACc,CACxD,OAAOI,CAAAA,CAAO,KAAA,CAAMgI,gCAAyB,CAAE,OAAA,CAAA/H,EAAS,GAAGC,CAAQ,CAAC,CACtE,CAkBO,SAAS+H,GACdjI,CAAAA,CACAC,CAAAA,CAC8D,CAC9D,OAAOD,CAAAA,CAAO,KAAA,CAAMkI,sCAA+B,CAAE,OAAA,CAAAjI,CAAQ,CAAC,CAChE","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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Hub[], UnexpectedError> {\n return client.query(HubsQuery, { request, currency, timeWindow });\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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<HubAsset[], UnexpectedError> {\n return client.query(HubAssetsQuery, { request, currency, timeWindow });\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 * @returns Array of hub summary samples over time.\n */\nexport function hubSummaryHistory(\n client: AaveClient,\n request: HubSummaryHistoryRequest,\n): ResultAsync<HubSummarySample[], UnexpectedError> {\n return client.query(HubSummaryHistoryQuery, { request });\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 { type BatchOptions, DEFAULT_QUERY_OPTIONS } 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 * @returns The chain data, or null if not found.\n */\n\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n): ResultAsync<Chain | null, UnexpectedError>;\n/**\n * @internal\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n options: BatchOptions,\n): ResultAsync<Chain | null, UnexpectedError>;\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n { batch }: BatchOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch });\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 * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n): ResultAsync<ExchangeAmount, 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 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.\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 * 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.\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\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 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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve | null, UnexpectedError> {\n return client.query(ReserveQuery, { request, currency, timeWindow });\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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve[], UnexpectedError> {\n return client.query(ReservesQuery, { request, currency, timeWindow });\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 {\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 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 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 options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<TokenSwapQuoteResult, UnexpectedError> {\n return client.query(\n TokenSwapQuoteQuery,\n {\n request,\n currency: options.currency,\n },\n { batch: false },\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 * @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 * 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 signSwapTypedDataWith(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 options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PositionSwapByIntentApprovalsRequired, UnexpectedError> {\n return client\n .query(\n SupplySwapQuoteQuery,\n { request, currency: options.currency },\n { batch: false },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\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 options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PositionSwapByIntentApprovalsRequired, UnexpectedError> {\n return client\n .query(\n BorrowSwapQuoteQuery,\n { request, currency: options.currency },\n { batch: false },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\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 options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PositionSwapByIntentApprovalsRequired, UnexpectedError> {\n return client\n .query(\n RepayWithSupplyQuoteQuery,\n { request, currency: options.currency },\n { batch: false },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\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 options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PositionSwapByIntentApprovalsRequired, UnexpectedError> {\n return client\n .query(\n WithdrawSwapQuoteQuery,\n { request, currency: options.currency },\n { batch: false },\n )\n .map(extendWithOpaqueType)\n .andThen((result) => {\n switch (result.__typename) {\n case 'PositionSwapByIntentApprovalsRequired':\n return okAsync(result);\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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<SwapStatus, UnexpectedError> {\n return client.query(SwapStatusQuery, { request, currency, timeWindow });\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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PaginatedUserSwapsResult, UnexpectedError> {\n return client.query(UserSwapsQuery, { request, currency, timeWindow });\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 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 options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PreviewUserPosition, UnexpectedError> {\n return client.query(PreviewQuery, { request, ...options });\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 * 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 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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSupplyItem[], UnexpectedError> {\n return client.query(UserSuppliesQuery, { request, currency, timeWindow });\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 }: CurrencyQueryOptions & TimeWindowQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserBorrowItem[], UnexpectedError> {\n return client.query(UserBorrowsQuery, { request, currency, timeWindow });\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\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 * @returns Array of risk premium breakdown items.\n */\nexport function userRiskPremiumBreakdown(\n client: AaveClient,\n request: UserRiskPremiumBreakdownRequest,\n): ResultAsync<UserRiskPremiumBreakdownItem[], UnexpectedError> {\n return client.query(UserRiskPremiumBreakdownQuery, { request });\n}\n"]}
|