@aave/client 4.0.0-next.2 → 4.0.0-next.4
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/dist/actions/index.cjs +1 -1
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.js +1 -1
- package/dist/chunk-2URLJFKP.js +3 -0
- package/dist/{chunk-2TNQ52OQ.js.map → chunk-2URLJFKP.js.map} +1 -1
- package/dist/chunk-IFRZEVIE.js +3 -0
- package/dist/chunk-IFRZEVIE.js.map +1 -0
- package/dist/chunk-UXJVSHNC.js +2 -0
- package/dist/chunk-UXJVSHNC.js.map +1 -0
- package/dist/ethers.cjs +1 -1
- package/dist/ethers.cjs.map +1 -1
- package/dist/ethers.d.cts +2 -2
- package/dist/ethers.d.ts +2 -2
- package/dist/ethers.js +1 -1
- package/dist/ethers.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/privy.cjs +1 -1
- package/dist/privy.cjs.map +1 -1
- package/dist/privy.js +1 -1
- package/dist/test-utils.cjs +2 -2
- package/dist/test-utils.cjs.map +1 -1
- package/dist/test-utils.d.cts +2 -1
- package/dist/test-utils.d.ts +2 -1
- package/dist/test-utils.js +2 -2
- package/dist/test-utils.js.map +1 -1
- package/dist/thirdweb.cjs +2 -2
- package/dist/thirdweb.cjs.map +1 -1
- package/dist/thirdweb.d.cts +7 -3
- package/dist/thirdweb.d.ts +7 -3
- package/dist/thirdweb.js +2 -2
- package/dist/thirdweb.js.map +1 -1
- package/dist/viem.cjs +1 -1
- package/dist/viem.cjs.map +1 -1
- package/dist/viem.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-2TNQ52OQ.js +0 -3
- 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/actions/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var graphql=require('@aave/graphql'),core=require('@aave/core'),types=require('@aave/types');var s={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network"};function Re(e,r,t=s){return e.query(graphql.HubQuery,{request:r,currency:t.currency??s.currency},t.requestPolicy??s.requestPolicy)}function
|
|
1
|
+
'use strict';var graphql=require('@aave/graphql'),core=require('@aave/core'),types=require('@aave/types');var s={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network"};function Re(e,r,t=s){return e.query(graphql.HubQuery,{request:r,currency:t.currency??s.currency},{requestPolicy:t.requestPolicy??s.requestPolicy})}function qe(e,r,t=s){return e.query(graphql.HubsQuery,{request:r,...t})}function me(e,r,t=s){return e.query(graphql.HubAssetsQuery,{request:r,...t})}function Ue(e,r){return e.query(graphql.ChainQuery,{request:r})}function Pe(e,r=graphql.ChainsFilter.ALL){return e.query(graphql.ChainsQuery,{filter:r})}function xe(e,r){return e.query(graphql.HasProcessedKnownTransactionQuery,{request:r},{requestPolicy:"network-only",batch:false})}function de(e,r){return e.query(graphql.ExchangeRateQuery,{request:r})}function fe(e,r){return e.query(graphql.PermitTypedDataQuery,{request:r})}function Oe(e,r,t=s){return e.query(graphql.AssetQuery,{request:r,currency:t.currency??s.currency,timeWindow:t.timeWindow??s.timeWindow},{requestPolicy:t.requestPolicy??s.requestPolicy})}function Te(e,r,t=s){return e.query(graphql.AssetPriceHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function ke(e,r,t=s){return e.query(graphql.AssetSupplyHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function He(e,r,t=s){return e.query(graphql.AssetBorrowHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function Be(e,r,t=s){return e.query(graphql.ReserveQuery,{request:r,...t})}function Me(e,r,t=s){return e.query(graphql.ReservesQuery,{request:r,...t})}function We(e,r){return e.query(graphql.BorrowApyHistoryQuery,{request:r})}function De(e,r){return e.query(graphql.SupplyApyHistoryQuery,{request:r})}function Ie(e,r){return e.query(graphql.SpokeQuery,{request:r})}function Ye(e,r){return e.query(graphql.SpokesQuery,{request:r})}function Le(e,r){return e.query(graphql.SpokePositionManagersQuery,{request:r})}function Ne(e,r){return e.query(graphql.SpokeUserPositionManagersQuery,{request:r})}function Je(e,r,t=s){return e.query(graphql.SwapQuoteQuery,{request:r,...t})}function Ve(e,r){return e.query(graphql.SwappableTokensQuery,{request:r})}function Xe(e,r,t=s){return e.query(graphql.PrepareSwapQuery,{request:r,...t})}function L(e,r,t=s){return e.query(graphql.SwapStatusQuery,{request:r,...t})}function Ze(e){return r=>{let t=async n=>{let y=Date.now();for(;Date.now()-y<e.context.environment.indexingTimeout;){let u=await L(e,n).match(o=>o,o=>{throw o});switch(u.__typename){case "SwapCancelled":case "SwapExpired":case "SwapFulfilled":return u;default:await core.delay(e.context.environment.pollingInterval);continue}}throw core.TimeoutError.from(`Timeout waiting for swap ${n.id} to reach final outcome.`)};return types.ResultAsync.fromPromise(t({id:r.id}),n=>n instanceof core.TimeoutError||n instanceof core.UnexpectedError?n:core.UnexpectedError.from(n))}}function er(e,r){return e.query(graphql.SwapQuery,{request:r})}function rr(e,r){return e.query(graphql.PrepareSwapCancelQuery,{request:r})}function tr(e,r){return e.query(graphql.CancelSwapQuery,{request:r})}function sr(e,r,t=s){return e.query(graphql.UserSwapsQuery,{request:r,...t})}function ir(e,r){return e.query(graphql.BorrowQuery,{request:r})}function pr(e,r){return e.query(graphql.SupplyQuery,{request:r})}function yr(e,r){return e.query(graphql.RepayQuery,{request:r})}function ar(e,r){return e.query(graphql.WithdrawQuery,{request:r})}function cr(e,r){return e.query(graphql.RenounceSpokeUserPositionManagerQuery,{request:r})}function lr(e,r){return e.query(graphql.UpdateUserDynamicConfigQuery,{request:r})}function Rr(e,r){return e.query(graphql.UpdateUserRiskPremiumQuery,{request:r})}function qr(e,r){return e.query(graphql.LiquidatePositionQuery,{request:r})}function mr(e,r){return e.query(graphql.SetSpokeUserPositionManagerQuery,{request:r})}function Ar(e,r,t=s){return e.query(graphql.PreviewQuery,{request:r,...t})}function Sr(e,r){return e.query(graphql.SetUserSupplyAsCollateralQuery,{request:r})}function Ur(e,r,t=s){return e.query(graphql.ActivitiesQuery,{request:r,currency:t.currency??s.currency},{requestPolicy:t.requestPolicy??s.requestPolicy})}function wr(e,r,t=s){return e.query(graphql.UserSuppliesQuery,{request:r,...t})}function Cr(e,r,t=s){return e.query(graphql.UserBorrowsQuery,{request:r,...t})}function fr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(graphql.UserSummaryQuery,{request:r,currency:t,timeWindow:n})}function vr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(graphql.UserPositionsQuery,{request:r,currency:t,timeWindow:n})}function Qr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(graphql.UserPositionQuery,{request:r,currency:t,timeWindow:n})}function Er(e,r,t=s){return e.query(graphql.UserBalancesQuery,{request:r,...t})}function Or(e,r,t=s){return e.query(graphql.UserSummaryHistoryQuery,{request:r,...t})}exports.activities=Ur;exports.asset=Oe;exports.assetBorrowHistory=He;exports.assetPriceHistory=Te;exports.assetSupplyHistory=ke;exports.borrow=ir;exports.borrowApyHistory=We;exports.cancelSwap=tr;exports.chain=Ue;exports.chains=Pe;exports.exchangeRate=de;exports.hasProcessedKnownTransaction=xe;exports.hub=Re;exports.hubAssets=me;exports.hubs=qe;exports.liquidatePosition=qr;exports.permitTypedData=fe;exports.prepareSwap=Xe;exports.prepareSwapCancel=rr;exports.preview=Ar;exports.renounceSpokeUserPositionManager=cr;exports.repay=yr;exports.reserve=Be;exports.reserves=Me;exports.setSpokeUserPositionManager=mr;exports.setUserSupplyAsCollateral=Sr;exports.spoke=Ie;exports.spokePositionManagers=Le;exports.spokeUserPositionManagers=Ne;exports.spokes=Ye;exports.supply=pr;exports.supplyApyHistory=De;exports.swap=er;exports.swapQuote=Je;exports.swapStatus=L;exports.swappableTokens=Ve;exports.updateUserDynamicConfig=lr;exports.updateUserRiskPremium=Rr;exports.userBalances=Er;exports.userBorrows=Cr;exports.userPosition=Qr;exports.userPositions=vr;exports.userSummary=fr;exports.userSummaryHistory=Or;exports.userSupplies=wr;exports.userSwaps=sr;exports.waitForSwapOutcome=Ze;exports.withdraw=ar;//# sourceMappingURL=index.cjs.map
|
|
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,sBAAA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ACE,QAAA,CAAAoG,CAAAA,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","HubsQuery","hubAssets","HubAssetsQuery","chain","ChainQuery","chains","filter","ChainsFilter","ChainsQuery","hasProcessedKnownTransaction","HasProcessedKnownTransactionQuery","exchangeRate","ExchangeRateQuery","permitTypedData","PermitTypedDataQuery","asset","AssetQuery","assetPriceHistory","AssetPriceHistoryQuery","assetSupplyHistory","AssetSupplyHistoryQuery","assetBorrowHistory","AssetBorrowHistoryQuery","reserve","ReserveQuery","reserves","ReservesQuery","borrowApyHistory","BorrowApyHistoryQuery","supplyApyHistory","SupplyApyHistoryQuery","spoke","SpokeQuery","spokes","SpokesQuery","spokePositionManagers","SpokePositionManagersQuery","spokeUserPositionManagers","SpokeUserPositionManagersQuery","swapQuote","SwapQuoteQuery","swappableTokens","SwappableTokensQuery","prepareSwap","PrepareSwapQuery","swapStatus","SwapStatusQuery","waitForSwapOutcome","receipt","pollForSwapOutcome","startedAt","status","ok","err","delay","TimeoutError","ResultAsync","error","UnexpectedError","swap","SwapQuery","prepareSwapCancel","PrepareSwapCancelQuery","cancelSwap","CancelSwapQuery","userSwaps","UserSwapsQuery","borrow","BorrowQuery","supply","SupplyQuery","repay","RepayQuery","withdraw","WithdrawQuery","renounceSpokeUserPositionManager","RenounceSpokeUserPositionManagerQuery","updateUserDynamicConfig","UpdateUserDynamicConfigQuery","updateUserRiskPremium","UpdateUserRiskPremiumQuery","liquidatePosition","LiquidatePositionQuery","setSpokeUserPositionManager","SetSpokeUserPositionManagerQuery","preview","PreviewQuery","setUserSupplyAsCollateral","SetUserSupplyAsCollateralQuery","activities","ActivitiesQuery","userSupplies","UserSuppliesQuery","userBorrows","UserBorrowsQuery","userSummary","currency","timeWindow","UserSummaryQuery","userPositions","UserPositionsQuery","userPosition","UserPositionQuery","userBalances","UserBalancesQuery","userSummaryHistory","UserSummaryHistoryQuery"],"mappings":"0GA+BO,IAAMA,CAAAA,CAAwB,CACnC,QAAA,CAAUC,gBAAAA,CAAS,GAAA,CACnB,UAAA,CAAYC,kBAAAA,CAAW,QACvB,aAAA,CAAe,mBACjB,CAAA,CCFO,SAASC,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAAuDN,EACb,CAC1C,OAAOI,CAAAA,CAAO,KAAA,CACZG,gBAAAA,CACA,CAAE,OAAA,CAAAF,CAAAA,CAAS,QAAA,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y } from '@urql/core';\n\nexport type CurrencyQueryOptions = {\n /**\n * The currency for fiat amounts.\n *\n * @defaultValue {@link Currency.Usd}\n */\n currency?: Currency;\n};\n\nexport type TimeWindowQueryOptions = {\n /**\n * The time window for historical data changes.\n *\n * @defaultValue {@link TimeWindow.LastDay}\n */\n timeWindow?: TimeWindow;\n};\n\nexport type RequestPolicyOptions = {\n /**\n * The request policy to use.\n *\n * @internal This is used for testing purposes and could be changed without notice.\n * @defaultValue `cache-and-network`\n */\n requestPolicy?: RequestPolicy;\n};\n\nexport const DEFAULT_QUERY_OPTIONS = {\n currency: Currency.Usd,\n timeWindow: TimeWindow.LastDay,\n requestPolicy: 'cache-and-network',\n} as const;\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Hub,\n type HubAsset,\n HubAssetsQuery,\n type HubAssetsRequest,\n HubQuery,\n type HubRequest,\n HubsQuery,\n type HubsRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n} from '../options';\n\n/**\n * Fetches a specific hub by ID or by address and chain ID.\n *\n * ```ts\n * const result = await hub(client, {\n * query: { hubId: hubId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hub request parameters.\n * @param options - The query options.\n * @returns The hub data, or null if not found.\n */\nexport function hub(\n client: AaveClient,\n request: HubRequest,\n options: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Hub | null, UnexpectedError> {\n return client.query(\n HubQuery,\n { request, currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches multiple hubs based on specified criteria.\n *\n * ```ts\n * const result = await hubs(client, {\n * query: {\n * chainIds: [chainId(1)]\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hubs request parameters (either tokens or chainIds).\n * @param options - The query options.\n * @returns Array of hub data.\n */\nexport function hubs(\n client: AaveClient,\n request: HubsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Hub[], UnexpectedError> {\n return client.query(HubsQuery, { request, ...options });\n}\n\n/**\n * Fetches hub assets for a specific hub by ID or by address and chain ID.\n *\n * ```ts\n * const result = await hubAssets(client, {\n * query: { hubId: hubId('SGVsbG8h') },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The hub assets request parameters.\n * @param options - The query options.\n * @returns The hub assets array.\n */\nexport function hubAssets(\n client: AaveClient,\n request: HubAssetsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<HubAsset[], UnexpectedError> {\n return client.query(HubAssetsQuery, { request, ...options });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Chain,\n ChainQuery,\n type ChainRequest,\n ChainsFilter,\n ChainsQuery,\n ExchangeRateQuery,\n type ExchangeRateRequest,\n type FiatAmount,\n HasProcessedKnownTransactionQuery,\n type HasProcessedKnownTransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @returns The chain data, or null if not found.\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, { filter: ChainsFilter.ALL });\n * ```\n *\n * @param client - Aave client.\n * @param filter - The filter for chains.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n filter: ChainsFilter = ChainsFilter.ALL,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { filter });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n): ResultAsync<FiatAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type PermitRequest,\n PermitTypedDataQuery,\n type PermitTypedDataResponse,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\n\nimport type { AaveClient } from '../AaveClient';\n\n/**\n * Generates EIP-712 typed data for permit signatures.\n *\n * ```ts\n * const result = await permitTypedData(client, {\n * spender: evmAddress('0x87870bca…'),\n * currency: evmAddress('0xa0b86991c431c924b2047c7094daf21b77e…'),\n * amount: '1000.5',\n * });\n *\n * if (result.isOk()) {\n * // Use the typed data to create a signature\n * const signature = await wallet.signTypedData(result.value);\n * }\n * ```\n *\n * @param client - Aave client.\n * @param request - The permit request parameters.\n * @returns The EIP-712 typed data for permit signature.\n */\nexport function permitTypedData(\n client: AaveClient,\n request: PermitRequest,\n): ResultAsync<PermitTypedDataResponse, UnexpectedError> {\n return client.query(PermitTypedDataQuery, { request });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Asset,\n AssetBorrowHistoryQuery,\n type AssetBorrowHistoryRequest,\n type AssetBorrowSample,\n AssetPriceHistoryQuery,\n type AssetPriceHistoryRequest,\n type AssetPriceSample,\n AssetQuery,\n type AssetRequest,\n AssetSupplyHistoryQuery,\n type AssetSupplyHistoryRequest,\n type AssetSupplySample,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches information about a specific asset (ERC20 token) in the protocol by ID or by token.\n *\n * ```ts\n * const result = await asset(client, {\n * query: { assetId: assetId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset request parameters.\n * @param options - The query options including currency and time window.\n * @returns The asset data, or null if not found.\n */\nexport function asset(\n client: AaveClient,\n request: AssetRequest,\n options: CurrencyQueryOptions &\n TimeWindowQueryOptions &\n RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Asset | null, UnexpectedError> {\n return client.query(\n AssetQuery,\n {\n request,\n currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency,\n timeWindow: options.timeWindow ?? DEFAULT_QUERY_OPTIONS.timeWindow,\n },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches historical price data for a specific asset.\n *\n * ```ts\n * const result = await assetPriceHistory(client, {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * currency: Currency.Usd,\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset price history request parameters.\n * @param options - The query options.\n * @returns Array of asset price samples over time.\n */\nexport function assetPriceHistory(\n client: AaveClient,\n request: AssetPriceHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetPriceSample[], UnexpectedError> {\n return client.query(\n AssetPriceHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches historical supply data for a specific asset.\n *\n * ```ts\n * const result = await assetSupplyHistory(client, {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset supply history request parameters.\n * @param options - The query options.\n * @returns Array of asset supply samples over time.\n */\nexport function assetSupplyHistory(\n client: AaveClient,\n request: AssetSupplyHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetSupplySample[], UnexpectedError> {\n return client.query(\n AssetSupplyHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n\n/**\n * Fetches historical borrow data for a specific asset.\n *\n * ```ts\n * const result = await assetBorrowHistory(client, {\n * token: { chainId: chainId(1), address: evmAddress('0x123…') },\n * window: TimeWindow.LastWeek,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The asset borrow history request parameters.\n * @param options - The query options.\n * @returns Array of asset borrow samples over time.\n */\nexport function assetBorrowHistory(\n client: AaveClient,\n request: AssetBorrowHistoryRequest,\n options: Required<RequestPolicyOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<AssetBorrowSample[], UnexpectedError> {\n return client.query(\n AssetBorrowHistoryQuery,\n { request },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type APYSample,\n type BorrowAPYHistoryRequest,\n BorrowApyHistoryQuery,\n type Reserve,\n ReserveQuery,\n type ReserveRequest,\n ReservesQuery,\n type ReservesRequest,\n type SupplyAPYHistoryRequest,\n SupplyApyHistoryQuery,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * Fetches a specific reserve by reserve ID, spoke, and chain.\n *\n * ```ts\n * const result = await reserve(client, {\n * reserve: reserveId('SGVsbG8h'),\n * user: evmAddress('0x742d35cc…'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The reserve request parameters.\n * @param options - The query options.\n * @returns The reserve data, or null if not found.\n */\nexport function reserve(\n client: AaveClient,\n request: ReserveRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve | null, UnexpectedError> {\n return client.query(ReserveQuery, { request, ...options });\n}\n\n/**\n * Fetches reserves based on specified criteria.\n *\n * ```ts\n * const result = await reserves(client, {\n * query: {\n * spoke: {\n * address: evmAddress('0x123...'),\n * chainId: chainId(1)\n * }\n * },\n * filter: ReservesRequestFilter.All,\n * orderBy: { name: 'ASC' }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The reserves request parameters.\n * @param options - The query options.\n * @returns Array of reserves matching the criteria.\n */\nexport function reserves(\n client: AaveClient,\n request: ReservesRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Reserve[], UnexpectedError> {\n return client.query(ReservesQuery, { request, ...options });\n}\n\n/**\n * Fetches borrow APY history for a specific reserve over time.\n *\n * ```ts\n * const result = await borrowApyHistory(client, {\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The borrow APY history request parameters.\n * @returns The borrow APY history samples.\n */\nexport function borrowApyHistory(\n client: AaveClient,\n request: BorrowAPYHistoryRequest,\n): ResultAsync<APYSample[], UnexpectedError> {\n return client.query(BorrowApyHistoryQuery, { request });\n}\n\n/**\n * Fetches supply APY history for a specific reserve over time.\n *\n * ```ts\n * const result = await supplyApyHistory(client, {\n * reserve: reserveId('SGVsbG8h'),\n * window: TimeWindow.LastWeek\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The supply APY history request parameters.\n * @returns The supply APY history samples.\n */\nexport function supplyApyHistory(\n client: AaveClient,\n request: SupplyAPYHistoryRequest,\n): ResultAsync<APYSample[], UnexpectedError> {\n return client.query(SupplyApyHistoryQuery, { request });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type PaginatedSpokePositionManagerResult,\n type PaginatedSpokeUserPositionManagerResult,\n type Spoke,\n SpokePositionManagersQuery,\n type SpokePositionManagersRequest,\n SpokeQuery,\n type SpokeRequest,\n SpokesQuery,\n type SpokesRequest,\n SpokeUserPositionManagersQuery,\n type SpokeUserPositionManagersRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\n\n/**\n * Fetches a specific spoke.\n *\n * ```ts\n * const result = await spoke(client, {\n * query: { spokeId: spokeId('SGVsbG8h') }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spoke request parameters.\n * @returns The spoke data, or null if not found.\n */\nexport function spoke(\n client: AaveClient,\n request: SpokeRequest,\n): ResultAsync<Spoke | null, UnexpectedError> {\n return client.query(SpokeQuery, { request });\n}\n\n/**\n * Fetches spokes based on specified criteria.\n *\n * ```ts\n * const result = await spokes(client, {\n * query: { chainIds: [chainId(1)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes request parameters.\n * @returns Array of spokes matching the criteria.\n */\nexport function spokes(\n client: AaveClient,\n request: SpokesRequest,\n): ResultAsync<Spoke[], UnexpectedError> {\n return client.query(SpokesQuery, { request });\n}\n\n/**\n * Fetches all positions manager for a specific spoke.\n *\n * ```ts\n * const result = await spokePositionManagers(client, {\n * spoke: spokeId('SGVsbG8h'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes request parameters.\n * @returns Array of spokes matching the criteria.\n */\nexport function spokePositionManagers(\n client: AaveClient,\n request: SpokePositionManagersRequest,\n): ResultAsync<PaginatedSpokePositionManagerResult, UnexpectedError> {\n return client.query(SpokePositionManagersQuery, { request });\n}\n\n/**\n * Fetches all the positions managers of a user for a specific spoke.\n *\n * ```ts\n * const result = await spokeUserPositionManagers(client, {\n * spoke: spokeId('SGVsbG8h'),\n * user: evmAddress('0x123...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The spokes and pagination request parameters.\n * @returns Array of position managers of a user for a specific spoke.\n */\nexport function spokeUserPositionManagers(\n client: AaveClient,\n request: SpokeUserPositionManagersRequest,\n): ResultAsync<PaginatedSpokeUserPositionManagerResult, UnexpectedError> {\n return client.query(SpokeUserPositionManagersQuery, { request });\n}\n","import { delay, TimeoutError, UnexpectedError } from '@aave/core';\nimport type {\n CancelSwapExecutionPlan,\n CancelSwapRequest,\n PaginatedUserSwapsResult,\n PrepareSwapCancelRequest,\n PrepareSwapCancelResult,\n PrepareSwapRequest,\n PrepareSwapResult,\n SwapCancelled,\n SwapExecutionPlan,\n SwapExpired,\n SwapFulfilled,\n SwappableTokensRequest,\n SwapQuote,\n SwapQuoteRequest,\n SwapReceipt,\n SwapRequest,\n SwapStatus,\n SwapStatusRequest,\n Token,\n UserSwapsRequest,\n} from '@aave/graphql';\nimport {\n CancelSwapQuery,\n PrepareSwapCancelQuery,\n PrepareSwapQuery,\n SwappableTokensQuery,\n SwapQuery,\n SwapQuoteQuery,\n SwapStatusQuery,\n UserSwapsQuery,\n} from '@aave/graphql';\nimport { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type CurrencyQueryOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * @internal\n * Fetches a swap quote for the specified trade parameters.\n *\n * ```ts\n * const result = await swapQuote(client, {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6...') },\n * sell: { erc20: evmAddress('0x6B175474E...') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.SELL,\n * from: evmAddress('0x742d35cc...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap quote request parameters.\n * @param options - The query options.\n * @returns The swap quote including pricing and cost information.\n */\nexport function swapQuote(\n client: AaveClient,\n request: SwapQuoteRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<SwapQuote, UnexpectedError> {\n return client.query(SwapQuoteQuery, { request, ...options });\n}\n\n/**\n * @internal\n * Fetches the list of tokens available for swapping on a specific chain.\n *\n * ```ts\n * const result = await swappableTokens(client, {\n * query: { chainIds: [chainId(1)] },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swappable tokens request parameters.\n * @returns The list of tokens available for swapping.\n */\nexport function swappableTokens(\n client: AaveClient,\n request: SwappableTokensRequest,\n): ResultAsync<Token[], UnexpectedError> {\n return client.query(SwappableTokensQuery, { request });\n}\n\n/**\n * @internal\n * Prepares a swap for the specified trade parameters.\n *\n * ```ts\n * const result = await prepareSwap(client, {\n * market: {\n * chainId: chainId(1),\n * buy: { erc20: evmAddress('0xA0b86a33E6...') },\n * sell: { erc20: evmAddress('0x6B175474E...') },\n * amount: bigDecimal('1000'),\n * kind: SwapKind.SELL,\n * user: evmAddress('0x742d35cc...'),\n * },\n * }).andThen(plan => {\n * switch (plan.__typename) {\n * case 'SwapByIntent':\n * return signSwapByIntentWith(plan.data)\n * .andThen((signature) => swap({ intent: { quoteId: quote.quoteId, signature } }))\n * .andThen((plan) => {\n * // …\n * });\n * );\n *\n * case 'SwapByIntentWithApprovalRequired':\n * return sendTransaction(plan.transaction)\n * .andThen(signSwapByIntentWith(plan.data))\n * .andThen((signature) => swap({ intent: { quoteId: quote.quoteId, signature } }))\n * .andThen((plan) => {\n * // …\n * });\n * );\n *\n * case 'SwapByTransaction':\n * return swap({ transaction: { quoteId: quote.quoteId } })\n * .andThen((plan) => {\n * // …\n * });\n * );\n *\n * case 'InsufficientBalanceError':\n * return errAsync(new Error(`Insufficient balance: ${plan.required.value} required.`));\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The prepare swap request parameters.\n * @param options - The query options.\n * @returns The prepared swap result containing details of the swap.\n */\nexport function prepareSwap(\n client: AaveClient,\n request: PrepareSwapRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PrepareSwapResult, UnexpectedError> {\n return client.query(PrepareSwapQuery, { request, ...options });\n}\n\n/**\n * @internal\n * Fetches the status of a specific swap.\n *\n * ```ts\n * const result = await swapStatus(client, {\n * id: swapId('swap_123'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap status request parameters.\n * @param options - The query options.\n * @returns The current status of the swap.\n */\nexport function swapStatus(\n client: AaveClient,\n request: SwapStatusRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<SwapStatus, UnexpectedError> {\n return client.query(SwapStatusQuery, { request, ...options });\n}\n\nexport type SwapOutcome = SwapCancelled | SwapExpired | SwapFulfilled;\n\n/**\n * @internal\n * Waits for a swap to reach a final outcome (cancelled, expired, or fulfilled).\n *\n * ```ts\n * const result = waitForSwapOutcome(client)(swapReceipt);\n *\n * if (result.isOk()) {\n * const outcome = result.value;\n * switch (outcome.__typename) {\n * case 'SwapFulfilled':\n * console.log('Swap completed successfully:', outcome.txHash);\n * break;\n * case 'SwapCancelled':\n * console.log('Swap was cancelled:', outcome.cancelledAt);\n * break;\n * case 'SwapExpired':\n * console.log('Swap expired:', outcome.expiredAt);\n * break;\n * }\n * }\n * ```\n *\n * @param client - Aave client configured with polling settings.\n * @returns A function that takes a SwapReceipt and returns a ResultAsync with the final outcome.\n */\nexport function waitForSwapOutcome(\n client: AaveClient,\n): (\n receipt: SwapReceipt,\n) => ResultAsync<SwapOutcome, TimeoutError | UnexpectedError> {\n return (receipt: SwapReceipt) => {\n const pollForSwapOutcome = async (\n request: SwapStatusRequest,\n ): Promise<SwapOutcome> => {\n const startedAt = Date.now();\n\n while (\n Date.now() - startedAt <\n client.context.environment.indexingTimeout\n ) {\n const status = await swapStatus(client, request).match(\n (ok) => ok,\n (err) => {\n throw err;\n },\n );\n\n switch (status.__typename) {\n case 'SwapCancelled':\n case 'SwapExpired':\n case 'SwapFulfilled':\n return status;\n\n default:\n await delay(client.context.environment.pollingInterval);\n continue;\n }\n }\n\n throw TimeoutError.from(\n `Timeout waiting for swap ${request.id} to reach final outcome.`,\n );\n };\n\n return ResultAsync.fromPromise(\n pollForSwapOutcome({ id: receipt.id }),\n (error) => {\n if (error instanceof TimeoutError || error instanceof UnexpectedError) {\n return error;\n }\n return UnexpectedError.from(error);\n },\n );\n };\n}\n\n/**\n * @internal\n * Executes a swap for the specified request parameters.\n *\n * ```ts\n * const result = await swap(client, {\n * intent: {\n * quoteId: swapQuoteId('123...'),\n * signature: {\n * value: signature('0x456...'),\n * deadline: 1234567890,\n * },\n * },\n * }).andThen((plan) => {\n * switch (plan.__typename) {\n * case 'SwapTransactionRequest':\n * return sendTransaction(plan.transaction)\n * .map(() => plan.orderReceipt);\n *\n * case 'SwapApprovalRequired':\n * return sendTransaction(plan.transaction)\n * .andThen(() => sendTransaction(plan.originalTransaction))\n * .map(() => plan.originalTransaction.orderReceipt);\n *\n * case 'SwapReceipt':\n * return okAsync(plan.orderReceipt);\n *\n * case 'InsufficientBalanceError':\n * return errAsync(new Error(`Insufficient balance: ${plan.required.value} required.`));\n * }\n * });\n *\n * if (result.isErr()) {\n * console.error(result.error);\n * return;\n * }\n *\n * console.log('Order receipt:', result.value);\n * ```\n *\n * @param client - Aave client.\n * @param request - The swap request parameters.\n * @returns The swap execution plan containing transaction details or receipt.\n */\nexport function swap(\n client: AaveClient,\n request: SwapRequest,\n): ResultAsync<SwapExecutionPlan, UnexpectedError> {\n return client.query(SwapQuery, { request });\n}\n\n/**\n * @internal\n * Prepares a swap cancellation for the specified swap ID.\n *\n * ```ts\n * const result = await prepareSwapCancel(client, {\n * id: swapId('123...'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The prepare swap cancel request parameters.\n * @returns The prepared swap cancel result containing typed data for signing.\n */\nexport function prepareSwapCancel(\n client: AaveClient,\n request: PrepareSwapCancelRequest,\n): ResultAsync<PrepareSwapCancelResult, UnexpectedError> {\n return client.query(PrepareSwapCancelQuery, { request });\n}\n\n/**\n * @internal\n * Executes a swap cancellation for the specified request parameters.\n *\n * ```ts\n * const result = await cancelSwap(client, {\n * intent: {\n * id: swapId('123...'),\n * signature: {\n * value: signature('0x456...'),\n * deadline: 1234567890,\n * },\n * },\n * }).andThen((plan) => {\n * switch (plan.__typename) {\n * case 'TransactionRequest':\n * return sendTransaction(plan)\n * .map(() => ({ success: true }));\n *\n * case 'SwapCancelled':\n * return okAsync(plan);\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The cancel swap request parameters.\n * @returns The cancel swap execution plan containing transaction details or cancellation receipt.\n */\nexport function cancelSwap(\n client: AaveClient,\n request: CancelSwapRequest,\n): ResultAsync<CancelSwapExecutionPlan, UnexpectedError> {\n return client.query(CancelSwapQuery, { request });\n}\n\n/**\n * @internal\n * Fetches the user's swap history for a specific chain.\n *\n * ```ts\n * const result = await userSwaps(client, {\n * chainId: chainId(1),\n * user: evmAddress('0x742d35cc...'),\n * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user swaps request parameters.\n * @param options - The query options.\n * @returns The paginated list of user swaps with their status information.\n */\nexport function userSwaps(\n client: AaveClient,\n request: UserSwapsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PaginatedUserSwapsResult, UnexpectedError> {\n return client.query(UserSwapsQuery, { request, ...options });\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n ActivitiesQuery,\n type ActivitiesRequest,\n BorrowQuery,\n type BorrowRequest,\n type ExecutionPlan,\n LiquidatePositionQuery,\n type LiquidatePositionRequest,\n type PaginatedActivitiesResult,\n PreviewQuery,\n type PreviewRequest,\n type PreviewUserPosition,\n RenounceSpokeUserPositionManagerQuery,\n type RenounceSpokeUserPositionManagerRequest,\n RepayQuery,\n type RepayRequest,\n SetSpokeUserPositionManagerQuery,\n type SetSpokeUserPositionManagerRequest,\n SetUserSupplyAsCollateralQuery,\n type SetUserSupplyAsCollateralRequest,\n SupplyQuery,\n type SupplyRequest,\n type TransactionRequest,\n UpdateUserDynamicConfigQuery,\n type UpdateUserDynamicConfigRequest,\n UpdateUserRiskPremiumQuery,\n type UpdateUserRiskPremiumRequest,\n WithdrawQuery,\n type WithdrawRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n} from '../options';\n\n/**\n * Creates a transaction to borrow from a market.\n *\n * ```ts\n * const result = await borrow(client, {\n * amount: {\n * erc20: {\n * value: bigDecimal('1000'),\n * },\n * },\n * reserve: reserveId('SGVsbG8h'),\n * sender: evmAddress('0x9abc…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The borrow request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function borrow(\n client: AaveClient,\n request: BorrowRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(BorrowQuery, { request });\n}\n\n/**\n * Creates a transaction to supply to a market.\n *\n * ```ts\n * const result = await supply(client, {\n * reserve: {\n * reserveId: \"1234567890\",\n * spoke: evmAddress('0x8787…'),\n * chainId: chainId(1),\n * },\n * amount: {\n * erc20: {\n * value: bigDecimal('1000'),\n * },\n * },\n * enableCollateral: true, // Optional, defaults to true\n * sender: evmAddress('0x9abc…'),\n * });\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The supply request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function supply(\n client: AaveClient,\n request: SupplyRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(SupplyQuery, { request });\n}\n\n/**\n * Creates a transaction to repay to a market.\n *\n * ```ts\n * const result = await repay(client, {\n * amount: {\n * erc20: {\n * value: {\n * exact: bigDecimal('500'),\n * },\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * reserve: reserveId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The repay request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function repay(\n client: AaveClient,\n request: RepayRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(RepayQuery, { request });\n}\n\n/**\n * Creates a transaction to withdraw from a reserve.\n *\n * ```ts\n * const result = await withdraw(client, {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * exact: bigDecimal('750.5'),\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. insufficient balance, signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * **Withdraw specific amount:**\n * ```ts\n * amount: {\n * erc20: {\n * exact: bigDecimal('100.5'), // Exact amount to withdraw\n * }\n * }\n * ```\n *\n * **Withdraw all available:**\n * ```ts\n * amount: {\n * erc20: {\n * max: true, // Withdraw the full position\n * }\n * }\n * ```\n *\n * **Withdraw native token:**\n * ```ts\n * amount: {\n * native: bigDecimal('0.5'), // For ETH on Ethereum\n * }\n * ```\n *\n * @param client - Aave client.\n * @param request - The withdraw request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function withdraw(\n client: AaveClient,\n request: WithdrawRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(WithdrawQuery, { request });\n}\n\n/**\n * Creates a transaction to renounce a position manager of a user in a specific spoke.\n *\n * ```ts\n * const result = await renounceSpokeUserPositionManager(client, {\n * manager: evmAddress('0x9abc…'),\n * managing: evmAddress('0xdef0…'),\n * spoke: spokeId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The renounce spoke user position manager request parameters.\n * @returns The transaction data.\n */\nexport function renounceSpokeUserPositionManager(\n client: AaveClient,\n request: RenounceSpokeUserPositionManagerRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(RenounceSpokeUserPositionManagerQuery, { request });\n}\n\n/**\n * Creates a transaction to update user dynamic config for a specific spoke.\n *\n * ```ts\n * const result = await updateUserDynamicConfig(client, {\n * sender: evmAddress('0x9abc…'),\n * spoke: spokeId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The update user dynamic config request parameters.\n * @returns The transaction data.\n */\n\nexport function updateUserDynamicConfig(\n client: AaveClient,\n request: UpdateUserDynamicConfigRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(UpdateUserDynamicConfigQuery, { request });\n}\n\n/**\n * Creates a transaction to update user risk premium for a specific spoke.\n *\n * ```ts\n * const result = await updateUserRiskPremium(client, {\n * sender: evmAddress('0x9abc…'),\n * spoke: spokeId('SGVsbG8h'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n *\n * @param client - Aave client.\n * @param request - The update user risk premium request parameters.\n * @returns The transaction data.\n */\nexport function updateUserRiskPremium(\n client: AaveClient,\n request: UpdateUserRiskPremiumRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(UpdateUserRiskPremiumQuery, { request });\n}\n\n/**\n * Creates a transaction to liquidate a user's position.\n *\n * ```ts\n * const result = await liquidatePosition(client, {\n * collateral: reserveId('SGVsbG8h'),\n * debt: reserveId('Q2lhbyE= '),\n * amount: {\n * exact: bigDecimal('1000'),\n * },\n * liquidator: evmAddress('0x9abc…'),\n * user: evmAddress('0xdef0…'),\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The liquidate position request parameters.\n * @returns The transaction data, approval requirements, or insufficient balance error.\n */\nexport function liquidatePosition(\n client: AaveClient,\n request: LiquidatePositionRequest,\n): ResultAsync<ExecutionPlan, UnexpectedError> {\n return client.query(LiquidatePositionQuery, { request });\n}\n\n/**\n * Sets or removes a position manager for a user on a specific spoke.\n *\n * **Position managers** can perform transactions on behalf of other users, including:\n * - Supply assets\n * - Borrow assets\n * - Withdraw assets\n * - Enable/disable collateral\n *\n * The `signature` parameter is an **ERC712 signature** that must be signed by the **user**\n * (the account granting permissions) to authorize the position manager. The signature contains:\n * - `value`: The actual cryptographic signature\n * - `deadline`: Unix timestamp when the authorization expires\n *\n * ```ts\n * const result = await setSpokeUserPositionManager(client, {\n * spoke: spokeId('SGVsbG8h'),\n * manager: evmAddress('0x9abc…'), // Address that will become the position manager\n * approve: true, // true to approve, false to remove the manager\n * user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)\n * signature: {\n * value: '0x1234...', // ERC712 signature signed by the user\n * deadline: 1735689600, // Unix timestamp when signature expires\n * },\n * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);\n *\n * if (result.isErr()) {\n * // Handle error, e.g. signing error, etc.\n * return;\n * }\n *\n * // result.value: TxHash\n * ```\n *\n * @param client - Aave client.\n * @param request - The spoke set for the position manager request parameters.\n * @returns The transaction request data to set position manager.\n */\nexport function setSpokeUserPositionManager(\n client: AaveClient,\n request: SetSpokeUserPositionManagerRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(SetSpokeUserPositionManagerQuery, { request });\n}\n\n/**\n * Previews the impact of a potential action on a user's position.\n *\n * ```ts\n * const result = await preview(client, {\n * action: {\n * supply: {\n * reserve: reserveId('SGVsbG8h'),\n * amount: {\n * erc20: {\n * value: '1000',\n * },\n * },\n * sender: evmAddress('0x9abc…'),\n * },\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The preview request parameters containing the action to preview.\n * @param options - The query options.\n * @returns The preview result showing position changes.\n */\nexport function preview(\n client: AaveClient,\n request: PreviewRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PreviewUserPosition, UnexpectedError> {\n return client.query(PreviewQuery, { request, ...options });\n}\n\n/**\n * Sets whether a user's supply should be used as collateral.\n *\n * ```ts\n * const result = await setUserSupplyAsCollateral(client, {\n * reserve: reserveId('SGVsbG8h'),\n * sender: evmAddress('0x456...'),\n * enableCollateral: true\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The set user supply as collateral request parameters.\n * @returns The transaction request to set collateral status.\n */\nexport function setUserSupplyAsCollateral(\n client: AaveClient,\n request: SetUserSupplyAsCollateralRequest,\n): ResultAsync<TransactionRequest, UnexpectedError> {\n return client.query(SetUserSupplyAsCollateralQuery, { request });\n}\n\n/**\n * Fetches paginated list of activities.\n *\n * ```ts\n * const result = await activities(client, {\n * query: {\n * chainIds: [chainId(1)],\n * },\n * user: evmAddress('0x742d35cc…'), // Optional\n * types: [ActivityType.Supply, ActivityType.Borrow, ActivityType.Withdraw, ActivityType.Repay],\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The activities request parameters.\n * @param options - The query options.\n * @returns The paginated list of activities.\n */\nexport function activities(\n client: AaveClient,\n request: ActivitiesRequest,\n options: CurrencyQueryOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<PaginatedActivitiesResult, UnexpectedError> {\n return client.query(\n ActivitiesQuery,\n { request, currency: options.currency ?? DEFAULT_QUERY_OPTIONS.currency },\n {\n requestPolicy:\n options.requestPolicy ?? DEFAULT_QUERY_OPTIONS.requestPolicy,\n },\n );\n}\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type UserBalance,\n UserBalancesQuery,\n type UserBalancesRequest,\n type UserBorrowItem,\n UserBorrowsQuery,\n type UserBorrowsRequest,\n type UserPosition,\n UserPositionQuery,\n type UserPositionRequest,\n UserPositionsQuery,\n type UserPositionsRequest,\n type UserSummary,\n type UserSummaryHistoryItem,\n UserSummaryHistoryQuery,\n type UserSummaryHistoryRequest,\n UserSummaryQuery,\n type UserSummaryRequest,\n UserSuppliesQuery,\n type UserSuppliesRequest,\n type UserSupplyItem,\n} from '@aave/graphql';\nimport type { Prettify, ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport {\n type CurrencyQueryOptions,\n DEFAULT_QUERY_OPTIONS,\n type TimeWindowQueryOptions,\n} from '../options';\n\n/**\n * Fetches all user supply positions across the specified spoke.\n *\n * ```ts\n * const result = await userSupplies(client, {\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user supplies request parameters.\n * @param options - The query options.\n * @returns The user's supply positions.\n */\nexport function userSupplies(\n client: AaveClient,\n request: UserSuppliesRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSupplyItem[], UnexpectedError> {\n return client.query(UserSuppliesQuery, { request, ...options });\n}\n\n/**\n * Fetches all user borrow positions across the specified spoke.\n *\n * ```ts\n * const result = await userBorrows(client, {\n * query: {\n * userSpoke: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * user: evmAddress('0x742d35cc…'),\n * },\n * },\n * orderBy: { name: 'ASC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user borrows request parameters.\n * @param options - The query options.\n * @returns The user's borrow positions.\n */\nexport function userBorrows(\n client: AaveClient,\n request: UserBorrowsRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserBorrowItem[], UnexpectedError> {\n return client.query(UserBorrowsQuery, { request, ...options });\n}\n\nexport type UserSummaryQueryOptions = Prettify<\n CurrencyQueryOptions & TimeWindowQueryOptions\n>;\n\n/**\n * Fetches a user's summary across all positions.\n *\n * ```ts\n * const result = await userSummary(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user summary request parameters.\n * @param options - The query options.\n * @returns The user's financial summary.\n */\nexport function userSummary(\n client: AaveClient,\n request: UserSummaryRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n }: UserSummaryQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSummary, UnexpectedError> {\n return client.query(UserSummaryQuery, {\n request,\n currency,\n timeWindow,\n });\n}\n\nexport type UserPositionQueryOptions = CurrencyQueryOptions &\n TimeWindowQueryOptions;\n\n/**\n * Fetches all user positions across specified chains.\n *\n * ```ts\n * const result = await userPositions(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)],\n * },\n * orderBy: { balance: 'DESC' },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user positions request parameters.\n * @param options - The query options.\n * @returns The user's positions across all specified chains.\n */\nexport function userPositions(\n client: AaveClient,\n request: UserPositionsRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n }: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserPosition[], UnexpectedError> {\n return client.query(UserPositionsQuery, { request, currency, timeWindow });\n}\n\n/**\n * Fetches a specific user position by ID.\n *\n * ```ts\n * const result = await userPosition(client, {\n * id: userPositionId('SGVsbG8h'),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user position request parameters.\n * @param options - The query options.\n * @returns The specific user position or null if not found.\n */\nexport function userPosition(\n client: AaveClient,\n request: UserPositionRequest,\n {\n currency = DEFAULT_QUERY_OPTIONS.currency,\n timeWindow = DEFAULT_QUERY_OPTIONS.timeWindow,\n }: UserPositionQueryOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserPosition | null, UnexpectedError> {\n return client.query(UserPositionQuery, { request, currency, timeWindow });\n}\n\n/**\n * Fetches all user balances across specified chains.\n *\n * ```ts\n * const result = await userBalances(client, {\n * user: evmAddress('0x742d35cc…'),\n * filter: {\n * chainIds: [chainId(1), chainId(137)],\n * },\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user balances request parameters.\n * @param options - The query options.\n * @returns The user's balances across all specified chains.\n **/\nexport function userBalances(\n client: AaveClient,\n request: UserBalancesRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserBalance[], UnexpectedError> {\n return client.query(UserBalancesQuery, { request, ...options });\n}\n\n/**\n * Fetches user summary history over time.\n *\n * ```ts\n * const result = await userSummaryHistory(client, {\n * user: evmAddress('0x742d35cc…'),\n * window: TimeWindow.LastWeek,\n * filter: {\n * chainIds: [chainId(1)]\n * }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The user summary history request parameters.\n * @param options - The query options.\n * @returns The user summary history items.\n */\nexport function userSummaryHistory(\n client: AaveClient,\n request: UserSummaryHistoryRequest,\n options: Required<CurrencyQueryOptions> = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<UserSummaryHistoryItem[], UnexpectedError> {\n return client.query(UserSummaryHistoryQuery, { request, ...options });\n}\n"]}
|
package/dist/actions/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{P as activities,j as asset,m as assetBorrowHistory,k as assetPriceHistory,l as assetSupplyHistory,E as borrow,p as borrowApyHistory,C as cancelSwap,e as chain,f as chains,h as exchangeRate,g as hasProcessedKnownTransaction,b as hub,d as hubAssets,c as hubs,L as liquidatePosition,i as permitTypedData,x as prepareSwap,B as prepareSwapCancel,N as preview,I as renounceSpokeUserPositionManager,G as repay,n as reserve,o as reserves,M as setSpokeUserPositionManager,O as setUserSupplyAsCollateral,r as spoke,t as spokePositionManagers,u as spokeUserPositionManagers,s as spokes,F as supply,q as supplyApyHistory,A as swap,v as swapQuote,y as swapStatus,w as swappableTokens,J as updateUserDynamicConfig,K as updateUserRiskPremium,V as userBalances,R as userBorrows,U as userPosition,T as userPositions,S as userSummary,W as userSummaryHistory,Q as userSupplies,D as userSwaps,z as waitForSwapOutcome,H as withdraw}from'../chunk-
|
|
1
|
+
export{P as activities,j as asset,m as assetBorrowHistory,k as assetPriceHistory,l as assetSupplyHistory,E as borrow,p as borrowApyHistory,C as cancelSwap,e as chain,f as chains,h as exchangeRate,g as hasProcessedKnownTransaction,b as hub,d as hubAssets,c as hubs,L as liquidatePosition,i as permitTypedData,x as prepareSwap,B as prepareSwapCancel,N as preview,I as renounceSpokeUserPositionManager,G as repay,n as reserve,o as reserves,M as setSpokeUserPositionManager,O as setUserSupplyAsCollateral,r as spoke,t as spokePositionManagers,u as spokeUserPositionManagers,s as spokes,F as supply,q as supplyApyHistory,A as swap,v as swapQuote,y as swapStatus,w as swappableTokens,J as updateUserDynamicConfig,K as updateUserRiskPremium,V as userBalances,R as userBorrows,U as userPosition,T as userPositions,S as userSummary,W as userSummaryHistory,Q as userSupplies,D as userSwaps,z as waitForSwapOutcome,H as withdraw}from'../chunk-UXJVSHNC.js';//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {TransactionError,UnexpectedError,CancelError,SigningError,ValidationError}from'@aave/core';import {chainId,invariant,ResultAsync,txHash,okAsync,errAsync,signatureFrom,isObject}from'@aave/types';import {defineChain,SwitchChainError,UserRejectedRequestError,TransactionExecutionError}from'viem';import {waitForTransactionReceipt,sendTransaction,signTypedData,estimateGas}from'viem/actions';function p(n){return isObject(n)&&"code"in n&&"message"in n}function U(n){return isObject(n)&&"name"in n&&"message"in n&&"originalError"in n?p(n.originalError)&&"code"in n.originalError:true}var m=defineChain({id:Number.parseInt("123456789",10),name:"Devnet",network:"ethereum-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://virtual.mainnet-aave.us-east.rpc.tenderly.co/dbaa58ab-597b-4bcd-ae6a-b8e50f716146"]}},blockExplorers:{default:{name:"Devnet Explorer",url:"https://virtual.mainnet-aave.us-east.rpc.tenderly.co/dbaa58ab-597b-4bcd-ae6a-b8e50f716146"}}}),T={[chainId(m.id)]:m};function _(n,e){return ResultAsync.fromPromise(n.getChainId(),a=>SigningError.from(a)).andThen(a=>a===e.chainId?okAsync():ResultAsync.fromPromise(n.switchChain({id:e.chainId}),r=>SigningError.from(r)).orElse(r=>(p(r.cause)?r.cause.code:U(r.cause)?r.cause.data?.originalError?.code:void 0)===SwitchChainError.code&&e.chainId in T?ResultAsync.fromPromise(n.addChain({chain:T[e.chainId]}),c=>p(c)&&c.code===UserRejectedRequestError.code?CancelError.from(c):SigningError.from(c)):r.asResultAsync()))}function k(n,e){return ResultAsync.fromPromise(estimateGas(n,{account:n.account,data:e.data,to:e.to,value:BigInt(e.value)}),a=>SigningError.from(a)).map(a=>a*115n/100n)}function B(n,e){return k(n,e).andThen(a=>ResultAsync.fromPromise(sendTransaction(n,{account:n.account,data:e.data,to:e.to,value:BigInt(e.value),chain:n.chain,gas:a}),r=>{if(r instanceof TransactionExecutionError){let t=r.walk(c=>c instanceof UserRejectedRequestError);if(t)return CancelError.from(t)}return SigningError.from(r)})).map(txHash)}function L(n){return n.account!==void 0}function N(n,e){return invariant(L(n),"Wallet client with account is required"),_(n,e).andThen(a=>B(n,e))}function q(n,e,a){let r=n?.blockExplorers?.default?.url,t=r&&new URL(`/tx/${e}`,r).toString();return TransactionError.new({txHash:e,request:a,link:t})}function O(n,e,a){return ResultAsync.fromPromise(waitForTransactionReceipt(n,{hash:a,pollingInterval:100,retryCount:20,retryDelay:50}),r=>UnexpectedError.from(r)).andThen(r=>{let t=txHash(r.transactionHash);switch(r.status){case "reverted":return a!==t?errAsync(CancelError.from(`Transaction replaced by ${t}`)):errAsync(q(n.chain,t,e));case "success":return okAsync({txHash:t,operations:e.operations})}})}function s(n,e){return N(n,e).andThen(a=>O(n,e,a))}function y(n,e){switch(e.__typename){case "TransactionRequest":return s(n,e);case "Erc20ApprovalRequired":case "PreContractActionRequired":return s(n,e.transaction).andThen(()=>s(n,e.originalTransaction));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(e))}}function Y(n,e){return e?y(n,e):y.bind(null,n)}function F(n,e){return invariant(n.account,"Wallet account is required"),ResultAsync.fromPromise(signTypedData(n,{account:n.account,domain:e.domain,types:e.types,primaryType:e.primaryType,message:e.message}),a=>SigningError.from(a)).map(a=>({deadline:e.message.deadline,value:signatureFrom(a)}))}function J(n){return F.bind(null,n)}function E(n,e){return invariant(n.account,"Wallet account is required"),ResultAsync.fromPromise(signTypedData(n,{account:n.account,domain:e.domain,types:e.types,primaryType:e.primaryType,message:JSON.parse(e.message)}),a=>SigningError.from(a)).map(a=>({deadline:JSON.parse(e.message).deadline,value:signatureFrom(a)}))}function K(n,e){return e?E(n,e):E.bind(null,n)}
|
|
2
|
+
export{m as a,T as b,N as c,q as d,O as e,Y as f,J as g,K as h};//# sourceMappingURL=chunk-2URLJFKP.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-2URLJFKP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/viem.ts"],"names":["isRpcError","err","isObject","isProviderRpcError","devnetChain","defineChain","supportedChains","chainId","ensureChain","walletClient","request","ResultAsync","SigningError","okAsync","SwitchChainError","UserRejectedRequestError","CancelError","estimateGas","estimateGasWithViem","gas","sendEip1559Transaction","sendTransactionWithViem","TransactionExecutionError","rejected","txHash","isWalletClientWithAccount","sendTransaction","invariant","_","transactionError","chain","baseUrl","link","TransactionError","waitForTransactionResult","initialTxHash","waitForTransactionReceipt","UnexpectedError","receipt","hash","errAsync","sendTransactionAndWait","executePlan","result","ValidationError","sendWith","signERC20Permit","signTypedData","hex","signatureFrom","signERC20PermitWith","signSwapTypedData","signSwapTypedDataWith"],"mappings":"4YAqDA,SAASA,CAAAA,CAAWC,EAA+B,CACjD,OAAOC,QAAAA,CAASD,CAAG,GAAK,MAAA,GAAUA,CAAAA,EAAO,YAAaA,CACxD,CAEA,SAASE,CAAAA,CACPF,CAAAA,CAC+D,CAC/D,OAAOC,SAASD,CAAG,CAAA,EACjB,SAAUA,CAAAA,EACV,SAAA,GAAaA,GACb,eAAA,GAAmBA,CAAAA,CACjBD,EAAWC,CAAAA,CAAI,aAAa,GAAK,MAAA,GAAUA,CAAAA,CAAI,cAC/C,IACN,KAKaG,CAAAA,CAAqBC,WAAAA,CAAY,CAC5C,EAAA,CAAI,OAAO,QAAA,CAAS,WAAA,CAA2C,EAAE,CAAA,CACjE,IAAA,CAAM,SACN,OAAA,CAAS,eAAA,CACT,cAAA,CAAgB,CAAE,KAAM,OAAA,CAAS,MAAA,CAAQ,MAAO,QAAA,CAAU,EAAG,EAC7D,OAAA,CAAS,CACP,OAAA,CAAS,CAAE,KAAM,CAAC,2FAA4C,CAAE,CAClE,CAAA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KO,SAASE,EACdzC,CAAAA,CACoB,CACpB,OAAOqC,CAAAA,CAAgB,IAAA,CAAK,IAAA,CAAMrC,CAAY,CAChD,CAEA,SAAS0C,EACP1C,CAAAA,CACAkC,CAAAA,CACkC,CAClC,OAAAhB,SAAAA,CAAUlB,CAAAA,CAAa,OAAA,CAAS,4BAA4B,CAAA,CAErDE,WAAAA,CAAY,YACjBoC,aAAAA,CAActC,CAAAA,CAAc,CAC1B,OAAA,CAASA,CAAAA,CAAa,QACtB,MAAA,CAAQkC,CAAAA,CAAO,OACf,KAAA,CAAOA,CAAAA,CAAO,MACd,WAAA,CAAaA,CAAAA,CAAO,YACpB,OAAA,CAAS,IAAA,CAAK,KAAA,CAAMA,CAAAA,CAAO,OAAO,CACpC,CAAC,EACA1C,CAAAA,EAAQW,YAAAA,CAAa,KAAKX,CAAG,CAChC,EAAE,GAAA,CAAK+C,CAAAA,GAAS,CACd,QAAA,CAAU,IAAA,CAAK,MAAML,CAAAA,CAAO,OAAO,EAAE,QAAA,CACrC,KAAA,CAAOM,aAAAA,CAAcD,CAAG,CAC1B,CAAA,CAAE,CACJ,CAiBO,SAASI,CAAAA,CACd3C,EACAkC,CAAAA,CACyD,CACzD,OAAOA,CAAAA,CACHQ,CAAAA,CAAkB1C,EAAckC,CAAM,CAAA,CACtCQ,EAAkB,IAAA,CAAK,IAAA,CAAM1C,CAAY,CAC/C","file":"chunk-2TNQ52OQ.js","sourcesContent":["import {\n CancelError,\n SigningError,\n TransactionError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n CancelSwapTypedData,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n type ChainId,\n chainId,\n errAsync,\n invariant,\n isObject,\n okAsync,\n ResultAsync,\n signatureFrom,\n type TxHash,\n txHash,\n} from '@aave/types';\nimport {\n type Account,\n type Chain,\n defineChain,\n type ProviderRpcError,\n type RpcError,\n SwitchChainError,\n TransactionExecutionError,\n type Transport,\n type TypedData,\n type TypedDataDomain,\n UserRejectedRequestError,\n type WalletClient,\n} from 'viem';\nimport {\n estimateGas as estimateGasWithViem,\n sendTransaction as sendTransactionWithViem,\n signTypedData,\n waitForTransactionReceipt,\n} from 'viem/actions';\nimport type {\n ERC20PermitHandler,\n ExecutionPlanHandler,\n SwapSignatureHandler,\n TransactionResult,\n} from './types';\n\nfunction isRpcError(err: unknown): err is RpcError {\n return isObject(err) && 'code' in err && 'message' in err;\n}\n\nfunction isProviderRpcError(\n err: unknown,\n): err is ProviderRpcError<{ originalError?: { code: number } }> {\n return isObject(err) &&\n 'name' in err &&\n 'message' in err &&\n 'originalError' in err\n ? isRpcError(err.originalError) && 'code' in err.originalError\n : true;\n}\n\n/**\n * @internal\n */\nexport const devnetChain: Chain = defineChain({\n id: Number.parseInt(import.meta.env.ETHEREUM_TENDERLY_FORK_ID, 10),\n name: 'Devnet',\n network: 'ethereum-fork',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: {\n default: { http: [import.meta.env.ETHEREUM_TENDERLY_PUBLIC_RPC] },\n },\n blockExplorers: {\n default: {\n name: 'Devnet Explorer',\n url: import.meta.env.ETHEREUM_TENDERLY_BLOCKEXPLORER,\n },\n },\n});\n\n/**\n * @internal\n */\nexport const supportedChains: Record<\n ChainId,\n ReturnType<typeof defineChain>\n> = {\n // TODO add them back when deployed on these chains\n // [chainId(mainnet.id)]: mainnet,\n // [chainId(sepolia.id)]: sepolia,\n [chainId(devnetChain.id)]: devnetChain,\n};\n\nfunction ensureChain(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<void, CancelError | SigningError> {\n return ResultAsync.fromPromise(walletClient.getChainId(), (err) =>\n SigningError.from(err),\n ).andThen((chainId) => {\n if (chainId === request.chainId) {\n return okAsync();\n }\n\n return ResultAsync.fromPromise(\n walletClient.switchChain({ id: request.chainId }),\n (err) => SigningError.from(err),\n ).orElse((err) => {\n const code = isRpcError(err.cause)\n ? err.cause.code\n : // Unwrapping for MetaMask Mobile\n // https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719\n isProviderRpcError(err.cause)\n ? err.cause.data?.originalError?.code\n : undefined;\n\n if (\n code === SwitchChainError.code &&\n request.chainId in supportedChains\n ) {\n return ResultAsync.fromPromise(\n walletClient.addChain({ chain: supportedChains[request.chainId] }),\n (err) => {\n if (isRpcError(err) && err.code === UserRejectedRequestError.code) {\n return CancelError.from(err);\n }\n return SigningError.from(err);\n },\n );\n }\n\n return err.asResultAsync();\n });\n });\n}\n\nfunction estimateGas(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<bigint, SigningError> {\n return ResultAsync.fromPromise(\n estimateGasWithViem(walletClient, {\n account: walletClient.account,\n data: request.data,\n to: request.to,\n value: BigInt(request.value),\n }),\n (err) => SigningError.from(err),\n ).map((gas) => (gas * 115n) / 100n); // 15% buffer\n}\n\nfunction sendEip1559Transaction(\n walletClient: WalletClient<Transport, Chain, Account>,\n request: TransactionRequest,\n): ResultAsync<TxHash, CancelError | SigningError> {\n return estimateGas(walletClient, request)\n .andThen((gas) =>\n ResultAsync.fromPromise(\n sendTransactionWithViem(walletClient, {\n account: walletClient.account,\n data: request.data,\n to: request.to,\n value: BigInt(request.value),\n chain: walletClient.chain,\n gas,\n }),\n (err) => {\n if (err instanceof TransactionExecutionError) {\n const rejected = err.walk(\n (err) => err instanceof UserRejectedRequestError,\n );\n\n if (rejected) {\n return CancelError.from(rejected);\n }\n }\n return SigningError.from(err);\n },\n ),\n )\n .map(txHash);\n}\n\nfunction isWalletClientWithAccount(\n walletClient: WalletClient,\n): walletClient is WalletClient<Transport, Chain, Account> {\n return walletClient.account !== undefined;\n}\n\n/**\n * @internal\n */\nexport function sendTransaction(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<TxHash, CancelError | SigningError> {\n invariant(\n isWalletClientWithAccount(walletClient),\n 'Wallet client with account is required',\n );\n\n return ensureChain(walletClient, request).andThen((_) =>\n sendEip1559Transaction(walletClient, request),\n );\n}\n\n/**\n * @internal\n */\nexport function transactionError(\n chain: Chain | undefined,\n txHash: TxHash,\n request: TransactionRequest,\n): TransactionError {\n const baseUrl = chain?.blockExplorers?.default?.url;\n const link = baseUrl && new URL(`/tx/${txHash}`, baseUrl).toString();\n\n return TransactionError.new({ txHash, request, link });\n}\n\n/**\n * @internal\n */\nexport function waitForTransactionResult(\n walletClient: WalletClient,\n request: TransactionRequest,\n initialTxHash: TxHash,\n): ResultAsync<\n TransactionResult,\n CancelError | TransactionError | UnexpectedError\n> {\n return ResultAsync.fromPromise(\n waitForTransactionReceipt(walletClient, {\n hash: initialTxHash,\n pollingInterval: 100,\n retryCount: 20,\n retryDelay: 50,\n }),\n (err) => UnexpectedError.from(err),\n ).andThen((receipt) => {\n const hash = txHash(receipt.transactionHash);\n\n switch (receipt.status) {\n case 'reverted':\n if (initialTxHash !== hash) {\n return errAsync(CancelError.from(`Transaction replaced by ${hash}`));\n }\n return errAsync(transactionError(walletClient.chain, hash, request));\n case 'success':\n return okAsync({\n // viem's waitForTransactionReceipt supports transaction replacement\n // so it's important to use the transaction hash from the receipt\n txHash: hash,\n operations: request.operations,\n });\n }\n });\n}\n\nfunction sendTransactionAndWait(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<\n TransactionResult,\n CancelError | SigningError | TransactionError | UnexpectedError\n> {\n return sendTransaction(walletClient, request).andThen((hash) =>\n waitForTransactionResult(walletClient, request, hash),\n );\n}\n\nfunction executePlan(\n walletClient: WalletClient,\n result: ExecutionPlan,\n): ReturnType<ExecutionPlanHandler> {\n switch (result.__typename) {\n case 'TransactionRequest':\n return sendTransactionAndWait(walletClient, result);\n\n case 'Erc20ApprovalRequired':\n case 'PreContractActionRequired':\n return sendTransactionAndWait(walletClient, result.transaction).andThen(\n () => sendTransactionAndWait(walletClient, result.originalTransaction),\n );\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(result));\n }\n}\n\n/**\n * Creates an execution plan handler that sends transactions using the provided wallet client.\n */\nexport function sendWith(walletClient: WalletClient): ExecutionPlanHandler;\n/**\n * Sends execution plan transactions using the provided wallet client.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n walletClient: WalletClient,\n result: T,\n): ReturnType<ExecutionPlanHandler<T>>;\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n walletClient: WalletClient,\n result?: T,\n): ExecutionPlanHandler<T> | ReturnType<ExecutionPlanHandler<T>> {\n return result\n ? executePlan(walletClient, result)\n : executePlan.bind(null, walletClient);\n}\n\nfunction signERC20Permit(\n walletClient: WalletClient,\n result: PermitTypedDataResponse,\n): ReturnType<ERC20PermitHandler> {\n invariant(walletClient.account, 'Wallet account is required');\n\n return ResultAsync.fromPromise(\n signTypedData(walletClient, {\n account: walletClient.account,\n domain: result.domain as TypedDataDomain,\n types: result.types as TypedData,\n primaryType: result.primaryType as keyof typeof result.types,\n message: result.message,\n }),\n (err) => SigningError.from(err),\n ).map((hex) => ({\n deadline: result.message.deadline,\n value: signatureFrom(hex),\n }));\n}\n\n/**\n * Creates an ERC20 permit handler that signs ERC20 permits using the provided wallet client.\n */\nexport function signERC20PermitWith(\n walletClient: WalletClient,\n): ERC20PermitHandler {\n return signERC20Permit.bind(null, walletClient);\n}\n\nfunction signSwapTypedData(\n walletClient: WalletClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler> {\n invariant(walletClient.account, 'Wallet account is required');\n\n return ResultAsync.fromPromise(\n signTypedData(walletClient, {\n account: walletClient.account,\n domain: result.domain as TypedDataDomain,\n types: result.types as TypedData,\n primaryType: result.primaryType,\n message: JSON.parse(result.message),\n }),\n (err) => SigningError.from(err),\n ).map((hex) => ({\n deadline: JSON.parse(result.message).deadline,\n value: signatureFrom(hex),\n }));\n}\n\n/**\n * @internal\n * Creates a swap signature handler that signs swap typed data using the provided wallet client.\n */\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n): SwapSignatureHandler;\n/**\n * @internal\n * Signs swap typed data using the provided wallet client.\n */\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result?: SwapByIntentTypedData | CancelSwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(walletClient, result)\n : signSwapTypedData.bind(null, walletClient);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/viem.ts"],"names":["isRpcError","err","isObject","isProviderRpcError","devnetChain","defineChain","supportedChains","chainId","ensureChain","walletClient","request","ResultAsync","SigningError","okAsync","SwitchChainError","UserRejectedRequestError","CancelError","estimateGas","estimateGasWithViem","gas","sendEip1559Transaction","sendTransactionWithViem","TransactionExecutionError","rejected","txHash","isWalletClientWithAccount","sendTransaction","invariant","_","transactionError","chain","baseUrl","link","TransactionError","waitForTransactionResult","initialTxHash","waitForTransactionReceipt","UnexpectedError","receipt","hash","errAsync","sendTransactionAndWait","executePlan","result","ValidationError","sendWith","signERC20Permit","signTypedData","hex","signatureFrom","signERC20PermitWith","signSwapTypedData","signSwapTypedDataWith"],"mappings":"4YAqDA,SAASA,CAAAA,CAAWC,EAA+B,CACjD,OAAOC,QAAAA,CAASD,CAAG,GAAK,MAAA,GAAUA,CAAAA,EAAO,YAAaA,CACxD,CAEA,SAASE,CAAAA,CACPF,CAAAA,CAC+D,CAC/D,OAAOC,SAASD,CAAG,CAAA,EACjB,SAAUA,CAAAA,EACV,SAAA,GAAaA,GACb,eAAA,GAAmBA,CAAAA,CACjBD,EAAWC,CAAAA,CAAI,aAAa,GAAK,MAAA,GAAUA,CAAAA,CAAI,cAC/C,IACN,KAKaG,CAAAA,CAAqBC,WAAAA,CAAY,CAC5C,EAAA,CAAI,OAAO,QAAA,CAAS,WAAA,CAA2C,EAAE,CAAA,CACjE,IAA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CACA1C,CAAAA,EAAQW,aAAa,IAAA,CAAKX,CAAG,CAChC,CAAA,CAAE,GAAA,CAAK+C,IAAS,CACd,QAAA,CAAUL,EAAO,OAAA,CAAQ,QAAA,CACzB,MAAOM,aAAAA,CAAcD,CAAG,CAC1B,CAAA,CAAE,CACJ,CAKO,SAASE,EACdzC,CAAAA,CACoB,CACpB,OAAOqC,CAAAA,CAAgB,IAAA,CAAK,IAAA,CAAMrC,CAAY,CAChD,CAEA,SAAS0C,EACP1C,CAAAA,CACAkC,CAAAA,CACkC,CAClC,OAAAhB,SAAAA,CAAUlB,CAAAA,CAAa,OAAA,CAAS,4BAA4B,CAAA,CAErDE,WAAAA,CAAY,YACjBoC,aAAAA,CAActC,CAAAA,CAAc,CAC1B,OAAA,CAASA,CAAAA,CAAa,QACtB,MAAA,CAAQkC,CAAAA,CAAO,OACf,KAAA,CAAOA,CAAAA,CAAO,MACd,WAAA,CAAaA,CAAAA,CAAO,YACpB,OAAA,CAAS,IAAA,CAAK,KAAA,CAAMA,CAAAA,CAAO,OAAO,CACpC,CAAC,EACA1C,CAAAA,EAAQW,YAAAA,CAAa,KAAKX,CAAG,CAChC,EAAE,GAAA,CAAK+C,CAAAA,GAAS,CACd,QAAA,CAAU,IAAA,CAAK,MAAML,CAAAA,CAAO,OAAO,EAAE,QAAA,CACrC,KAAA,CAAOM,aAAAA,CAAcD,CAAG,CAC1B,CAAA,CAAE,CACJ,CAiBO,SAASI,CAAAA,CACd3C,EACAkC,CAAAA,CACyD,CACzD,OAAOA,CAAAA,CACHQ,CAAAA,CAAkB1C,EAAckC,CAAM,CAAA,CACtCQ,EAAkB,IAAA,CAAK,IAAA,CAAM1C,CAAY,CAC/C","file":"chunk-2URLJFKP.js","sourcesContent":["import {\n CancelError,\n SigningError,\n TransactionError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n CancelSwapTypedData,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n type ChainId,\n chainId,\n errAsync,\n invariant,\n isObject,\n okAsync,\n ResultAsync,\n signatureFrom,\n type TxHash,\n txHash,\n} from '@aave/types';\nimport {\n type Account,\n type Chain,\n defineChain,\n type ProviderRpcError,\n type RpcError,\n SwitchChainError,\n TransactionExecutionError,\n type Transport,\n type TypedData,\n type TypedDataDomain,\n UserRejectedRequestError,\n type WalletClient,\n} from 'viem';\nimport {\n estimateGas as estimateGasWithViem,\n sendTransaction as sendTransactionWithViem,\n signTypedData,\n waitForTransactionReceipt,\n} from 'viem/actions';\nimport type {\n ERC20PermitHandler,\n ExecutionPlanHandler,\n SwapSignatureHandler,\n TransactionResult,\n} from './types';\n\nfunction isRpcError(err: unknown): err is RpcError {\n return isObject(err) && 'code' in err && 'message' in err;\n}\n\nfunction isProviderRpcError(\n err: unknown,\n): err is ProviderRpcError<{ originalError?: { code: number } }> {\n return isObject(err) &&\n 'name' in err &&\n 'message' in err &&\n 'originalError' in err\n ? isRpcError(err.originalError) && 'code' in err.originalError\n : true;\n}\n\n/**\n * @internal\n */\nexport const devnetChain: Chain = defineChain({\n id: Number.parseInt(import.meta.env.ETHEREUM_TENDERLY_FORK_ID, 10),\n name: 'Devnet',\n network: 'ethereum-fork',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: {\n default: { http: [import.meta.env.ETHEREUM_TENDERLY_PUBLIC_RPC] },\n },\n blockExplorers: {\n default: {\n name: 'Devnet Explorer',\n url: import.meta.env.ETHEREUM_TENDERLY_BLOCKEXPLORER,\n },\n },\n});\n\n/**\n * @internal\n */\nexport const supportedChains: Record<\n ChainId,\n ReturnType<typeof defineChain>\n> = {\n // TODO add them back when deployed on these chains\n // [chainId(mainnet.id)]: mainnet,\n // [chainId(sepolia.id)]: sepolia,\n [chainId(devnetChain.id)]: devnetChain,\n};\n\nfunction ensureChain(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<void, CancelError | SigningError> {\n return ResultAsync.fromPromise(walletClient.getChainId(), (err) =>\n SigningError.from(err),\n ).andThen((chainId) => {\n if (chainId === request.chainId) {\n return okAsync();\n }\n\n return ResultAsync.fromPromise(\n walletClient.switchChain({ id: request.chainId }),\n (err) => SigningError.from(err),\n ).orElse((err) => {\n const code = isRpcError(err.cause)\n ? err.cause.code\n : // Unwrapping for MetaMask Mobile\n // https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719\n isProviderRpcError(err.cause)\n ? err.cause.data?.originalError?.code\n : undefined;\n\n if (\n code === SwitchChainError.code &&\n request.chainId in supportedChains\n ) {\n return ResultAsync.fromPromise(\n walletClient.addChain({ chain: supportedChains[request.chainId] }),\n (err) => {\n if (isRpcError(err) && err.code === UserRejectedRequestError.code) {\n return CancelError.from(err);\n }\n return SigningError.from(err);\n },\n );\n }\n\n return err.asResultAsync();\n });\n });\n}\n\nfunction estimateGas(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<bigint, SigningError> {\n return ResultAsync.fromPromise(\n estimateGasWithViem(walletClient, {\n account: walletClient.account,\n data: request.data,\n to: request.to,\n value: BigInt(request.value),\n }),\n (err) => SigningError.from(err),\n ).map((gas) => (gas * 115n) / 100n); // 15% buffer\n}\n\nfunction sendEip1559Transaction(\n walletClient: WalletClient<Transport, Chain, Account>,\n request: TransactionRequest,\n): ResultAsync<TxHash, CancelError | SigningError> {\n return estimateGas(walletClient, request)\n .andThen((gas) =>\n ResultAsync.fromPromise(\n sendTransactionWithViem(walletClient, {\n account: walletClient.account,\n data: request.data,\n to: request.to,\n value: BigInt(request.value),\n chain: walletClient.chain,\n gas,\n }),\n (err) => {\n if (err instanceof TransactionExecutionError) {\n const rejected = err.walk(\n (err) => err instanceof UserRejectedRequestError,\n );\n\n if (rejected) {\n return CancelError.from(rejected);\n }\n }\n return SigningError.from(err);\n },\n ),\n )\n .map(txHash);\n}\n\nfunction isWalletClientWithAccount(\n walletClient: WalletClient,\n): walletClient is WalletClient<Transport, Chain, Account> {\n return walletClient.account !== undefined;\n}\n\n/**\n * @internal\n */\nexport function sendTransaction(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<TxHash, CancelError | SigningError> {\n invariant(\n isWalletClientWithAccount(walletClient),\n 'Wallet client with account is required',\n );\n\n return ensureChain(walletClient, request).andThen((_) =>\n sendEip1559Transaction(walletClient, request),\n );\n}\n\n/**\n * @internal\n */\nexport function transactionError(\n chain: Chain | undefined,\n txHash: TxHash,\n request: TransactionRequest,\n): TransactionError {\n const baseUrl = chain?.blockExplorers?.default?.url;\n const link = baseUrl && new URL(`/tx/${txHash}`, baseUrl).toString();\n\n return TransactionError.new({ txHash, request, link });\n}\n\n/**\n * @internal\n */\nexport function waitForTransactionResult(\n walletClient: WalletClient,\n request: TransactionRequest,\n initialTxHash: TxHash,\n): ResultAsync<\n TransactionResult,\n CancelError | TransactionError | UnexpectedError\n> {\n return ResultAsync.fromPromise(\n waitForTransactionReceipt(walletClient, {\n hash: initialTxHash,\n pollingInterval: 100,\n retryCount: 20,\n retryDelay: 50,\n }),\n (err) => UnexpectedError.from(err),\n ).andThen((receipt) => {\n const hash = txHash(receipt.transactionHash);\n\n switch (receipt.status) {\n case 'reverted':\n if (initialTxHash !== hash) {\n return errAsync(CancelError.from(`Transaction replaced by ${hash}`));\n }\n return errAsync(transactionError(walletClient.chain, hash, request));\n case 'success':\n return okAsync({\n // viem's waitForTransactionReceipt supports transaction replacement\n // so it's important to use the transaction hash from the receipt\n txHash: hash,\n operations: request.operations,\n });\n }\n });\n}\n\nfunction sendTransactionAndWait(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<\n TransactionResult,\n CancelError | SigningError | TransactionError | UnexpectedError\n> {\n return sendTransaction(walletClient, request).andThen((hash) =>\n waitForTransactionResult(walletClient, request, hash),\n );\n}\n\nfunction executePlan(\n walletClient: WalletClient,\n result: ExecutionPlan,\n): ReturnType<ExecutionPlanHandler> {\n switch (result.__typename) {\n case 'TransactionRequest':\n return sendTransactionAndWait(walletClient, result);\n\n case 'Erc20ApprovalRequired':\n case 'PreContractActionRequired':\n return sendTransactionAndWait(walletClient, result.transaction).andThen(\n () => sendTransactionAndWait(walletClient, result.originalTransaction),\n );\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(result));\n }\n}\n\n/**\n * Creates an execution plan handler that sends transactions using the provided wallet client.\n */\nexport function sendWith(walletClient: WalletClient): ExecutionPlanHandler;\n/**\n * Sends execution plan transactions using the provided wallet client.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n walletClient: WalletClient,\n result: T,\n): ReturnType<ExecutionPlanHandler<T>>;\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n walletClient: WalletClient,\n result?: T,\n): ExecutionPlanHandler<T> | ReturnType<ExecutionPlanHandler<T>> {\n return result\n ? executePlan(walletClient, result)\n : executePlan.bind(null, walletClient);\n}\n\nfunction signERC20Permit(\n walletClient: WalletClient,\n result: PermitTypedDataResponse,\n): ReturnType<ERC20PermitHandler> {\n invariant(walletClient.account, 'Wallet account is required');\n\n return ResultAsync.fromPromise(\n signTypedData(walletClient, {\n account: walletClient.account,\n domain: result.domain as TypedDataDomain,\n types: result.types as TypedData,\n primaryType: result.primaryType as keyof typeof result.types,\n message: result.message,\n }),\n (err) => SigningError.from(err),\n ).map((hex) => ({\n deadline: result.message.deadline,\n value: signatureFrom(hex),\n }));\n}\n\n/**\n * Creates an ERC20 permit handler that signs ERC20 permits using the provided wallet client.\n */\nexport function signERC20PermitWith(\n walletClient: WalletClient,\n): ERC20PermitHandler {\n return signERC20Permit.bind(null, walletClient);\n}\n\nfunction signSwapTypedData(\n walletClient: WalletClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler> {\n invariant(walletClient.account, 'Wallet account is required');\n\n return ResultAsync.fromPromise(\n signTypedData(walletClient, {\n account: walletClient.account,\n domain: result.domain as TypedDataDomain,\n types: result.types as TypedData,\n primaryType: result.primaryType,\n message: JSON.parse(result.message),\n }),\n (err) => SigningError.from(err),\n ).map((hex) => ({\n deadline: JSON.parse(result.message).deadline,\n value: signatureFrom(hex),\n }));\n}\n\n/**\n * @internal\n * Creates a swap signature handler that signs swap typed data using the provided wallet client.\n */\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n): SwapSignatureHandler;\n/**\n * @internal\n * Signs swap typed data using the provided wallet client.\n */\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result?: SwapByIntentTypedData | CancelSwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(walletClient, result)\n : signSwapTypedData.bind(null, walletClient);\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {g as g$1}from'./chunk-UXJVSHNC.js';import {GqlClient,UnexpectedError,TimeoutError,delay}from'@aave/core';import {BigDecimal,ResultAsync,invariant}from'@aave/types';import {encodeHubId,isTxHashInputVariant,isHubInputVariant}from'@aave/graphql';import P from'@aave/graphql/schema';import {cacheExchange}from'@urql/exchange-graphcache';var v={name:"production",backend:"https://api.v4.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4},U={name:"staging",backend:"https://api.v4.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4},k={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4};var m=(e,t,n,r)=>BigInt(e[r.fieldName]),l=(e,t,n,r)=>BigDecimal.new(e[r.fieldName]),s=(e,t,n,r)=>{let i=e[r.fieldName];return i==null?null:l(e,t,n,r)},a=(e,t,n,r)=>new Date(e[r.fieldName]),E=(e,t,n,r)=>{let i=e[r.fieldName];return i==null?null:a(e,t,n,r)},g=cacheExchange({schema:P,resolvers:{PercentNumber:{onChainValue:m,value:l,normalized:l},DecimalNumber:{onChainValue:m,value:l},FiatAmount:{value:l},AssetPriceSample:{price:l,date:a},HubSummary:{utilizationRate:l},Reserve:{borrowCap:l,supplyCap:l},HealthFactorError:{current:s,after:s},HealthFactorVariation:{current:s,after:s},HealthFactorWithChange:{current:s},UserSummary:{lowestHealthFactor:s},UserSummaryHistoryItem:{healthFactor:s,date:a},TransactionRequest:{value:m},APYSample:{date:a},AssetBorrowSample:{date:a},AssetSupplySample:{date:a},BorrowActivity:{timestamp:a},LiquidatedActivity:{timestamp:a},RepayActivity:{timestamp:a},SupplyActivity:{timestamp:a},WithdrawActivity:{timestamp:a},UsingAsCollateralActivity:{timestamp:a},SpokeUserPositionManager:{approvedOn:a},SwapCancelled:{createdAt:a,cancelledAt:E},SwapExpired:{createdAt:a,expiredAt:a},SwapFulfilled:{createdAt:a,fulfilledAt:a},SwapOpen:{createdAt:a,deadline:a},SwapPendingSignature:{createdAt:a,deadline:a},SwapReceipt:{createdAt:a},Query:{hub:(e,{request:t})=>isHubInputVariant(t.query)?{__typename:"Hub",id:encodeHubId(t.query.hubInput)}:{__typename:"Hub",id:t.query.hubId},activities:(e,t,n)=>{if(!isTxHashInputVariant(t.request.query))return n.resolve("Query","activities",t);let{txHash:r,chainId:i}=t.request.query.txHash,d=n.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,y)=>{let u=n.resolve("Query",y.fieldKey);if(!u)return o;let p=n.resolve(u,"items");if(!p)return o;for(let c of p)o.add(c);return o},new Set).values().toArray().filter(o=>{if(n.resolve(o,"txHash")!==r)return false;let u=n.resolve(o,"spoke");if(u){let p=n.resolve(u,"chain"),c=p?n.resolve(p,"chainId"):void 0;if(typeof c=="number")return c===i}return true});if(d.length!==0)return {__typename:"PaginatedActivitiesResult",items:d,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Hub:e=>e.id,HubAsset:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,BorrowActivity:e=>e.id,LiquidatedActivity:e=>e.id,SupplyActivity:e=>e.id,SwapByIntent:e=>e.quote.quoteId,SwapByIntentWithApprovalRequired:e=>e.quote.quoteId,SwapByTransaction:e=>e.quote.quoteId,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,RepayActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,SpokePositionManger:()=>null,SpokeUserPositionManager:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,APYSample:()=>null,Asset:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,CancelSwapTypedData:()=>null,CancelSwapTypeDefinition:()=>null,DecimalNumber:()=>null,DecimalNumberWithChange:()=>null,DomainData:()=>null,Erc20Amount:()=>null,Erc20ApprovalRequired:()=>null,FiatAmount:()=>null,FiatAmountValueVariation:()=>null,FiatAmountWithChange:()=>null,ForkTopUpResponse:()=>null,HealthFactorError:()=>null,HealthFactorVariation:()=>null,HealthFactorWithChange:()=>null,HubAssetSettings:()=>null,HubAssetSummary:()=>null,HubAssetUserState:()=>null,HubSummary:()=>null,InsufficientBalanceError:()=>null,NativeAmount:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitMessageData:()=>null,PermitTypedDataResponse:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PreviewUserPosition:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SwapApprovalRequired:()=>null,SwapByIntentTypedData:()=>null,SwapByIntentTypeDefinition:()=>null,SwapCancelled:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,TokenInfo:()=>null,TransactionRequest:()=>null,TypeDefinition:()=>null,TypeField:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});function h({environment:e=v,headers:t,cache:n=true,debug:r=false,fragments:i=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:n?g:null,debug:r,fragments:i}}function S(e){return e.operations!==null&&e.operations.length>0}var R=class e extends GqlClient{static create(t){return new e(h(t??{}))}waitForTransaction=t=>(invariant(S(t),"Received a transaction result for an untracked operation. Make sure you're following the instructions in the docs."),ResultAsync.fromPromise(this.pollTransactionStatus(t),n=>n instanceof TimeoutError||n instanceof UnexpectedError?n:UnexpectedError.from(n)));async refreshQueryWhere(t,n){await this.refreshWhere(async r=>{if(r.query===t){let i=await this.query(t,r.variables,{requestPolicy:"cache-only"});return i.isErr()?false:n(r.variables,i.value)}return false});}async pollTransactionStatus(t){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await g$1(this,t).match(i=>i,i=>{throw i}))return t.txHash;await delay(this.context.environment.pollingInterval);}throw TimeoutError.from(`Timeout waiting for transaction ${t.txHash} to be processed.`)}};
|
|
2
|
+
export{v as a,U as b,k as c,R as d};//# sourceMappingURL=chunk-IFRZEVIE.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-IFRZEVIE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/environments.ts","../src/cache.ts","../src/config.ts","../src/types.ts","../src/AaveClient.ts"],"names":["production","staging","local","transformToBigInt","parent","_args","_cache","info","transformToBigDecimal","BigDecimal","transformToNullableBigDecimal","value","transformToDate","transformToNullableDate","exchange","cacheExchange","introspectedSchema","_","request","isHubInputVariant","encodeHubId","_parent","args","cache","isTxHashInputVariant","txHash","chainId","matches","f","set","pageRef","itemRefs","ref","spokeRef","chainRef","itemChainId","data","configureContext","environment","headers","debug","fragments","isHasProcessedKnownTransactionRequest","result","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","document","predicate","op","startedAt","hasProcessedKnownTransaction","ok","delay"],"mappings":"qVAKO,IAAMA,CAAAA,CAAgC,CAC3C,IAAA,CAAM,YAAA,CACN,OAAA,CAAS,iCAAA,CACT,eAAA,CAAiB,GAAA,CACjB,eAAA,CAAiB,GAAA,CACjB,oBAAA,CAAsB,GACxB,CAAA,CAKaC,CAAAA,CAA6B,CACxC,IAAA,CAAM,SAAA,CACN,OAAA,CAAS,yCAAA,CACT,eAAA,CAAiB,GAAA,CACjB,eAAA,CAAiB,GAAA,CACjB,oBAAA,CAAsB,GACxB,CAAA,CAKaC,CAAAA,CAA2B,CACtC,IAAA,CAAM,OAAA,CACN,OAAA,CAAS,+BAAA,CACT,eAAA,CAAiB,GAAA,CACjB,eAAA,CAAiB,GAAA,CACjB,oBAAA,CAAsB,GACxB,ECCA,IAAMC,CAAAA,CAA8B,CAACC,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACnD,MAAA,CAAOH,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAW,CAAA,CAG1CC,CAAAA,CAAkC,CAACJ,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACvDE,UAAAA,CAAW,GAAA,CAAIL,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAW,CAAA,CAGlDG,CAAAA,CAA0C,CAC9CN,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,GACG,CACH,IAAMI,CAAAA,CAAQP,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAA,CACnC,OAAII,CAAAA,EAAU,IAAA,CACL,IAAA,CAEFH,CAAAA,CAAsBJ,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAI,CAC1D,CAAA,CAEM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AAA,CAAMU,CAAAA,CAAUE,CAAAA,CAAG,SAAA,CAAyB,CACpE,aAAA,CAAe,YACjB,CAAC,CAAA,CAED,OAAIZ,CAAAA,CAAO,KAAA,EAAM,CACR,KAAA,CAGFW,CAAAA,CAAUC,CAAAA,CAAG,SAAA,CAAyBZ,CAAAA,CAAO,KAAe,CACrE,CACA,OAAO,MACT,CAAC,EACH,CAEA,MAAgB,qBAAA,CACdzB,CAAAA,CACiB,CACjB,IAAMsC,CAAAA,CAAY,IAAA,CAAK,GAAA,EAAI,CAE3B,KAAO,IAAA,CAAK,GAAA,EAAI,CAAIA,CAAAA,CAAY,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,eAAA,EAAiB,CAQxE,GAPkB,MAAMC,GAAAA,CAA6B,IAAA,CAAMvC,CAAO,CAAA,CAAE,KAAA,CACjEwC,CAAAA,EAAOA,CAAAA,CACPR,CAAAA,EAAQ,CACP,MAAMA,CACR,CACF,CAAA,CAGE,OAAOhC,CAAAA,CAAQ,MAAA,CAGjB,MAAMyC,KAAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,eAAe,EACtD,CACA,MAAMR,YAAAA,CAAa,IAAA,CACjB,CAAA,gCAAA,EAAmCjC,CAAAA,CAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF","file":"chunk-IFRZEVIE.js","sourcesContent":["import type { EnvironmentConfig } from '@aave/core';\n\n/**\n * The production environment configuration.\n */\nexport const production: EnvironmentConfig = {\n name: 'production',\n backend: 'https://api.v4.aave.com/graphql',\n indexingTimeout: 60_000,\n pollingInterval: 100,\n exchangeRateInterval: 10000,\n};\n\n/**\n * @internal\n */\nexport const staging: EnvironmentConfig = {\n name: 'staging',\n backend: 'https://api.v4.staging.aave.com/graphql',\n indexingTimeout: 60_000,\n pollingInterval: 500,\n exchangeRateInterval: 10000,\n};\n\n/**\n * @internal\n */\nexport const local: EnvironmentConfig = {\n name: 'local',\n backend: 'http://localhost:3007/graphql',\n indexingTimeout: 60_000,\n pollingInterval: 1000,\n exchangeRateInterval: 10000,\n};\n","import {\n type ActivitiesQuery,\n type BorrowActivity,\n type Chain,\n type Erc20Token,\n encodeHubId,\n type Hub,\n type HubAsset,\n type HubQuery,\n isHubInputVariant,\n isTxHashInputVariant,\n type LiquidatedActivity,\n type NativeToken,\n type RepayActivity,\n type Reserve,\n type ReserveInfo,\n type Spoke,\n type SupplyActivity,\n type SwapByIntent,\n type SwapByIntentWithApprovalRequired,\n type SwapByTransaction,\n type UserPosition,\n type UsingAsCollateralActivity,\n type VariablesOf,\n type WithdrawActivity,\n} from '@aave/graphql';\nimport introspectedSchema from '@aave/graphql/schema';\nimport { BigDecimal, type TxHash } from '@aave/types';\nimport {\n cacheExchange,\n type Resolver,\n type Scalar,\n} from '@urql/exchange-graphcache';\n\nconst transformToBigInt: Resolver = (parent, _args, _cache, info) => {\n return BigInt(parent[info.fieldName] as string) as unknown as Scalar;\n};\n\nconst transformToBigDecimal: Resolver = (parent, _args, _cache, info) => {\n return BigDecimal.new(parent[info.fieldName] as string);\n};\n\nconst transformToNullableBigDecimal: Resolver = (\n parent,\n _args,\n _cache,\n info,\n) => {\n const value = parent[info.fieldName];\n if (value === null || value === undefined) {\n return null;\n }\n return transformToBigDecimal(parent, _args, _cache, info);\n};\n\nconst transformToDate: Resolver = (parent, _args, _cache, info) => {\n return new Date(parent[info.fieldName] as string);\n};\n\nconst transformToNullableDate: Resolver = (parent, _args, _cache, info) => {\n const value = parent[info.fieldName];\n if (value === null || value === undefined) {\n return null;\n }\n return transformToDate(parent, _args, _cache, info);\n};\n\nexport const exchange = cacheExchange({\n schema: introspectedSchema,\n resolvers: {\n PercentNumber: {\n onChainValue: transformToBigInt,\n value: transformToBigDecimal,\n normalized: transformToBigDecimal,\n },\n DecimalNumber: {\n onChainValue: transformToBigInt,\n value: transformToBigDecimal,\n },\n FiatAmount: {\n value: transformToBigDecimal,\n },\n AssetPriceSample: {\n price: transformToBigDecimal,\n date: transformToDate,\n },\n HubSummary: {\n utilizationRate: transformToBigDecimal,\n },\n Reserve: {\n borrowCap: transformToBigDecimal,\n supplyCap: transformToBigDecimal,\n },\n HealthFactorError: {\n current: transformToNullableBigDecimal,\n after: transformToNullableBigDecimal,\n },\n HealthFactorVariation: {\n current: transformToNullableBigDecimal,\n after: transformToNullableBigDecimal,\n },\n HealthFactorWithChange: {\n current: transformToNullableBigDecimal,\n },\n UserSummary: {\n lowestHealthFactor: transformToNullableBigDecimal,\n },\n UserSummaryHistoryItem: {\n healthFactor: transformToNullableBigDecimal,\n date: transformToDate,\n },\n TransactionRequest: {\n value: transformToBigInt,\n },\n APYSample: {\n date: transformToDate,\n },\n AssetBorrowSample: {\n date: transformToDate,\n },\n AssetSupplySample: {\n date: transformToDate,\n },\n BorrowActivity: {\n timestamp: transformToDate,\n },\n LiquidatedActivity: {\n timestamp: transformToDate,\n },\n RepayActivity: {\n timestamp: transformToDate,\n },\n SupplyActivity: {\n timestamp: transformToDate,\n },\n WithdrawActivity: {\n timestamp: transformToDate,\n },\n UsingAsCollateralActivity: {\n timestamp: transformToDate,\n },\n SpokeUserPositionManager: {\n approvedOn: transformToDate,\n },\n SwapCancelled: {\n createdAt: transformToDate,\n cancelledAt: transformToNullableDate,\n },\n SwapExpired: {\n createdAt: transformToDate,\n expiredAt: transformToDate,\n },\n SwapFulfilled: {\n createdAt: transformToDate,\n fulfilledAt: transformToDate,\n },\n SwapOpen: {\n createdAt: transformToDate,\n deadline: transformToDate,\n },\n SwapPendingSignature: {\n createdAt: transformToDate,\n deadline: transformToDate,\n },\n SwapReceipt: {\n createdAt: transformToDate,\n },\n // Intentionally omitted to keep it as BigIntString\n // PermitMessageData: {\n // value: transformToBigInt,\n // nonce: transformToBigInt,\n // },\n\n Query: {\n hub: (_, { request }: VariablesOf<typeof HubQuery>) => {\n if (isHubInputVariant(request.query)) {\n return {\n __typename: 'Hub',\n id: encodeHubId(request.query.hubInput),\n };\n }\n return {\n __typename: 'Hub',\n id: request.query.hubId,\n };\n },\n\n activities: (\n _parent,\n args: VariablesOf<typeof ActivitiesQuery>,\n cache,\n ) => {\n // Bail out if not a txHash filter lookup\n if (!isTxHashInputVariant(args.request.query)) {\n return cache.resolve('Query', 'activities', args);\n }\n\n const { txHash, chainId } = args.request.query.txHash;\n\n // Collect all cached activities matching txHash\n const matches = cache\n .inspectFields('Query')\n .filter((f) => f.fieldName === 'activities')\n .reduce((set, f) => {\n const pageRef = cache.resolve('Query', f.fieldKey) as string | null;\n if (!pageRef) return set;\n\n const itemRefs = cache.resolve(pageRef, 'items') as string[] | null;\n if (!itemRefs) return set;\n\n for (const ref of itemRefs) {\n set.add(ref);\n }\n return set;\n }, new Set<string>())\n .values()\n .toArray()\n .filter((ref) => {\n const itemTxHash = cache.resolve(ref, 'txHash') as TxHash;\n if (itemTxHash !== txHash) return false;\n\n // Verify chainId via spoke.chain.chainId if present\n const spokeRef = cache.resolve(ref, 'spoke') as string | null;\n if (spokeRef) {\n const chainRef = cache.resolve(spokeRef, 'chain') as\n | string\n | null;\n const itemChainId = chainRef\n ? (cache.resolve(chainRef, 'chainId') as number | undefined)\n : undefined;\n if (typeof itemChainId === 'number') {\n return itemChainId === chainId;\n }\n }\n return true;\n });\n\n if (matches.length === 0) return undefined;\n\n return {\n __typename: 'PaginatedActivitiesResult',\n items: matches,\n pageInfo: {\n __typename: 'PaginatedResultInfo',\n prev: null,\n next: null,\n },\n };\n },\n },\n },\n keys: {\n // Entitied with composite key\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n Reserve: (data: Reserve) => data.id,\n ReserveInfo: (data: ReserveInfo) => data.id,\n Spoke: (data: Spoke) => data.id,\n\n // Entities with id field as key\n BorrowActivity: (data: BorrowActivity) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n SupplyActivity: (data: SupplyActivity) => data.id,\n SwapByIntent: (data: SwapByIntent) => data.quote.quoteId,\n SwapByIntentWithApprovalRequired: (\n data: SwapByIntentWithApprovalRequired,\n ) => data.quote.quoteId,\n SwapByTransaction: (data: SwapByTransaction) => data.quote.quoteId,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n\n // Entities with address field as key\n Erc20Token: (data: Erc20Token) => data.address,\n\n // Entities with other fields as key\n Chain: (data: Chain) => data.chainId.toString(),\n NativeToken: (data: NativeToken) => data.chain.chainId.toString(),\n\n // Entities without keys will be embedded directly on the parent entity\n PaginatedActivitiesResult: () => null,\n PaginatedResultInfo: () => null,\n PaginatedSpokePositionManagerResult: () => null,\n PaginatedSpokeUserPositionManagerResult: () => null,\n PaginatedUserSwapsResult: () => null,\n SpokePositionManger: () => null,\n SpokeUserPositionManager: () => null,\n SwapReceipt: () => null,\n SwapTransactionRequest: () => null,\n\n // Value objects and result types\n APYSample: () => null,\n Asset: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n CancelSwapTypedData: () => null,\n CancelSwapTypeDefinition: () => null,\n DecimalNumber: () => null,\n DecimalNumberWithChange: () => null,\n DomainData: () => null,\n Erc20Amount: () => null,\n Erc20ApprovalRequired: () => null,\n FiatAmount: () => null,\n FiatAmountValueVariation: () => null,\n FiatAmountWithChange: () => null,\n ForkTopUpResponse: () => null,\n HealthFactorError: () => null,\n HealthFactorVariation: () => null,\n HealthFactorWithChange: () => null,\n HubAssetSettings: () => null,\n HubAssetSummary: () => null,\n HubAssetUserState: () => null,\n HubSummary: () => null,\n InsufficientBalanceError: () => null,\n NativeAmount: () => null,\n PercentNumber: () => null,\n PercentNumberVariation: () => null,\n PercentNumberWithChange: () => null,\n PermitMessageData: () => null,\n PermitTypedDataResponse: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PreviewUserPosition: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SwapApprovalRequired: () => null,\n SwapByIntentTypedData: () => null,\n SwapByIntentTypeDefinition: () => null,\n SwapCancelled: () => null,\n SwapExpired: () => null,\n SwapFulfilled: () => null,\n SwapOpen: () => null,\n SwapPendingSignature: () => null,\n SwapQuote: () => null,\n SwapQuoteCosts: () => null,\n TokenInfo: () => null,\n TransactionRequest: () => null,\n TypeDefinition: () => null,\n TypeField: () => null,\n UserBalance: () => null,\n UserBorrowItem: () => null,\n UserSummary: () => null,\n UserSummaryHistoryItem: () => null,\n UserSupplyItem: () => null,\n },\n});\n","import type { Context } from '@aave/core';\nimport type { TypedDocumentNode } from '@urql/core';\nimport type { EnvironmentConfig } from '../../core/src/types';\nimport { exchange } from './cache';\nimport { production } from './environments';\n\n/**\n * The client configuration.\n */\nexport type ClientConfig = {\n /**\n * @internal\n * @defaultValue `production`\n */\n environment?: EnvironmentConfig;\n /**\n * @internal\n */\n headers?: Record<string, string>;\n /**\n * Whether to enable caching.\n *\n * @defaultValue `true`\n */\n cache?: boolean;\n /**\n * Whether to enable debug mode.\n *\n * @defaultValue `false`\n */\n debug?: boolean;\n /**\n * The custom fragments to use.\n *\n * @experimental This is an experimental API and may be subject to breaking changes.\n */\n fragments?: TypedDocumentNode[];\n};\n\n/**\n * @internal\n */\nexport function configureContext({\n environment = production,\n headers,\n cache = true,\n debug = false,\n fragments = [],\n}: ClientConfig): Context {\n return {\n displayName: 'AaveClient',\n environment,\n headers,\n cache: cache ? exchange : null,\n debug,\n fragments,\n };\n}\n","import type {\n CancelError,\n SigningError,\n TransactionError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n CancelSwapTypedData,\n ERC20PermitSignature,\n ExecutionPlan,\n HasProcessedKnownTransactionRequest,\n InsufficientBalanceError,\n OperationType,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n} from '@aave/graphql';\nimport type { ResultAsync, TxHash } from '@aave/types';\n\n/**\n * @internal\n */\nexport type TransactionResult = {\n txHash: TxHash;\n operations: OperationType[] | null;\n};\n\n/**\n * @internal\n */\nexport function isHasProcessedKnownTransactionRequest(\n result: TransactionResult,\n): result is HasProcessedKnownTransactionRequest {\n return result.operations !== null && result.operations.length > 0;\n}\n\nexport type SendWithError =\n | CancelError\n | SigningError\n | TransactionError\n | ValidationError<InsufficientBalanceError>\n | UnexpectedError;\n\nexport type ExecutionPlanHandler<T extends ExecutionPlan = ExecutionPlan> = (\n result: T,\n) => ResultAsync<TransactionResult, SendWithError>;\n\nexport type ERC20PermitHandler = (\n result: PermitTypedDataResponse,\n) => ResultAsync<ERC20PermitSignature, SigningError>;\n\nexport type SwapSignatureHandler = (\n result: CancelSwapTypedData | SwapByIntentTypedData,\n) => ResultAsync<ERC20PermitSignature, SigningError>;\n","import {\n delay,\n GqlClient,\n type StandardData,\n TimeoutError,\n UnexpectedError,\n} from '@aave/core';\nimport type { HasProcessedKnownTransactionRequest } from '@aave/graphql';\nimport {\n type AnyVariables,\n invariant,\n ResultAsync,\n type TxHash,\n} from '@aave/types';\nimport type { TypedDocumentNode } from '@urql/core';\nimport { hasProcessedKnownTransaction } from './actions';\nimport { type ClientConfig, configureContext } from './config';\nimport {\n isHasProcessedKnownTransactionRequest,\n type TransactionResult,\n} from './types';\n\nexport class AaveClient extends GqlClient {\n /**\n * Create a new instance of the {@link AaveClient}.\n *\n * ```ts\n * const client = AaveClient.create({\n * environment: production,\n * });\n * ```\n *\n * @param options - The options to configure the client.\n * @returns The new instance of the client.\n */\n static create(options?: ClientConfig): AaveClient {\n return new AaveClient(configureContext(options ?? {}));\n }\n\n /**\n * Given the transaction hash of an Aave protocol transaction, wait for the transaction to be\n * processed by the Aave v4 API.\n *\n * Returns a {@link TimeoutError} if the transaction is not processed within the expected timeout period.\n *\n * @param result - The transaction execution result to wait for.\n * @returns The transaction hash or a TimeoutError\n */\n readonly waitForTransaction = (\n result: TransactionResult,\n ): ResultAsync<TxHash, TimeoutError | UnexpectedError> => {\n invariant(\n isHasProcessedKnownTransactionRequest(result),\n `Received a transaction result for an untracked operation. Make sure you're following the instructions in the docs.`,\n );\n\n return ResultAsync.fromPromise(\n this.pollTransactionStatus(result),\n (err) => {\n if (err instanceof TimeoutError || err instanceof UnexpectedError) {\n return err;\n }\n return UnexpectedError.from(err);\n },\n );\n };\n\n /**\n * @internal\n */\n async refreshQueryWhere<TValue, TVariables extends AnyVariables>(\n document: TypedDocumentNode<StandardData<TValue>, TVariables>,\n predicate: (\n variables: TVariables,\n data: TValue,\n ) => boolean | Promise<boolean>,\n ): Promise<void> {\n await this.refreshWhere(async (op) => {\n if (op.query === document) {\n const result = await this.query(document, op.variables as TVariables, {\n requestPolicy: 'cache-only',\n });\n\n if (result.isErr()) {\n return false;\n }\n\n return predicate(op.variables as TVariables, result.value as TValue);\n }\n return false;\n });\n }\n\n protected async pollTransactionStatus(\n request: HasProcessedKnownTransactionRequest,\n ): Promise<TxHash> {\n const startedAt = Date.now();\n\n while (Date.now() - startedAt < this.context.environment.indexingTimeout) {\n const processed = await hasProcessedKnownTransaction(this, request).match(\n (ok) => ok,\n (err) => {\n throw err;\n },\n );\n\n if (processed) {\n return request.txHash;\n }\n\n await delay(this.context.environment.pollingInterval);\n }\n throw TimeoutError.from(\n `Timeout waiting for transaction ${request.txHash} to be processed.`,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {TimeWindow,Currency,ChainsFilter,HubQuery,HubsQuery,HubAssetsQuery,ChainQuery,ChainsQuery,HasProcessedKnownTransactionQuery,ExchangeRateQuery,PermitTypedDataQuery,AssetQuery,AssetPriceHistoryQuery,AssetSupplyHistoryQuery,AssetBorrowHistoryQuery,ReserveQuery,ReservesQuery,BorrowApyHistoryQuery,SupplyApyHistoryQuery,SpokeQuery,SpokesQuery,SpokePositionManagersQuery,SpokeUserPositionManagersQuery,SwapQuoteQuery,SwappableTokensQuery,PrepareSwapQuery,SwapStatusQuery,SwapQuery,PrepareSwapCancelQuery,CancelSwapQuery,UserSwapsQuery,BorrowQuery,SupplyQuery,RepayQuery,WithdrawQuery,RenounceSpokeUserPositionManagerQuery,UpdateUserDynamicConfigQuery,UpdateUserRiskPremiumQuery,LiquidatePositionQuery,SetSpokeUserPositionManagerQuery,PreviewQuery,SetUserSupplyAsCollateralQuery,ActivitiesQuery,UserSuppliesQuery,UserBorrowsQuery,UserSummaryQuery,UserPositionsQuery,UserPositionQuery,UserBalancesQuery,UserSummaryHistoryQuery}from'@aave/graphql';import {UnexpectedError,TimeoutError,delay}from'@aave/core';import {ResultAsync}from'@aave/types';var s={currency:Currency.Usd,timeWindow:TimeWindow.LastDay,requestPolicy:"cache-and-network"};function Re(e,r,t=s){return e.query(HubQuery,{request:r,currency:t.currency??s.currency},{requestPolicy:t.requestPolicy??s.requestPolicy})}function qe(e,r,t=s){return e.query(HubsQuery,{request:r,...t})}function me(e,r,t=s){return e.query(HubAssetsQuery,{request:r,...t})}function Ue(e,r){return e.query(ChainQuery,{request:r})}function Pe(e,r=ChainsFilter.ALL){return e.query(ChainsQuery,{filter:r})}function xe(e,r){return e.query(HasProcessedKnownTransactionQuery,{request:r},{requestPolicy:"network-only",batch:false})}function de(e,r){return e.query(ExchangeRateQuery,{request:r})}function fe(e,r){return e.query(PermitTypedDataQuery,{request:r})}function Oe(e,r,t=s){return e.query(AssetQuery,{request:r,currency:t.currency??s.currency,timeWindow:t.timeWindow??s.timeWindow},{requestPolicy:t.requestPolicy??s.requestPolicy})}function Te(e,r,t=s){return e.query(AssetPriceHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function ke(e,r,t=s){return e.query(AssetSupplyHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function He(e,r,t=s){return e.query(AssetBorrowHistoryQuery,{request:r},{requestPolicy:t.requestPolicy??s.requestPolicy})}function Be(e,r,t=s){return e.query(ReserveQuery,{request:r,...t})}function Me(e,r,t=s){return e.query(ReservesQuery,{request:r,...t})}function We(e,r){return e.query(BorrowApyHistoryQuery,{request:r})}function De(e,r){return e.query(SupplyApyHistoryQuery,{request:r})}function Ie(e,r){return e.query(SpokeQuery,{request:r})}function Ye(e,r){return e.query(SpokesQuery,{request:r})}function Le(e,r){return e.query(SpokePositionManagersQuery,{request:r})}function Ne(e,r){return e.query(SpokeUserPositionManagersQuery,{request:r})}function Je(e,r,t=s){return e.query(SwapQuoteQuery,{request:r,...t})}function Ve(e,r){return e.query(SwappableTokensQuery,{request:r})}function Xe(e,r,t=s){return e.query(PrepareSwapQuery,{request:r,...t})}function L(e,r,t=s){return e.query(SwapStatusQuery,{request:r,...t})}function Ze(e){return r=>{let t=async n=>{let y=Date.now();for(;Date.now()-y<e.context.environment.indexingTimeout;){let u=await L(e,n).match(o=>o,o=>{throw o});switch(u.__typename){case "SwapCancelled":case "SwapExpired":case "SwapFulfilled":return u;default:await delay(e.context.environment.pollingInterval);continue}}throw TimeoutError.from(`Timeout waiting for swap ${n.id} to reach final outcome.`)};return ResultAsync.fromPromise(t({id:r.id}),n=>n instanceof TimeoutError||n instanceof UnexpectedError?n:UnexpectedError.from(n))}}function er(e,r){return e.query(SwapQuery,{request:r})}function rr(e,r){return e.query(PrepareSwapCancelQuery,{request:r})}function tr(e,r){return e.query(CancelSwapQuery,{request:r})}function sr(e,r,t=s){return e.query(UserSwapsQuery,{request:r,...t})}function ir(e,r){return e.query(BorrowQuery,{request:r})}function pr(e,r){return e.query(SupplyQuery,{request:r})}function yr(e,r){return e.query(RepayQuery,{request:r})}function ar(e,r){return e.query(WithdrawQuery,{request:r})}function cr(e,r){return e.query(RenounceSpokeUserPositionManagerQuery,{request:r})}function lr(e,r){return e.query(UpdateUserDynamicConfigQuery,{request:r})}function Rr(e,r){return e.query(UpdateUserRiskPremiumQuery,{request:r})}function qr(e,r){return e.query(LiquidatePositionQuery,{request:r})}function mr(e,r){return e.query(SetSpokeUserPositionManagerQuery,{request:r})}function Ar(e,r,t=s){return e.query(PreviewQuery,{request:r,...t})}function Sr(e,r){return e.query(SetUserSupplyAsCollateralQuery,{request:r})}function Ur(e,r,t=s){return e.query(ActivitiesQuery,{request:r,currency:t.currency??s.currency},{requestPolicy:t.requestPolicy??s.requestPolicy})}function wr(e,r,t=s){return e.query(UserSuppliesQuery,{request:r,...t})}function Cr(e,r,t=s){return e.query(UserBorrowsQuery,{request:r,...t})}function fr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(UserSummaryQuery,{request:r,currency:t,timeWindow:n})}function vr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(UserPositionsQuery,{request:r,currency:t,timeWindow:n})}function Qr(e,r,{currency:t=s.currency,timeWindow:n=s.timeWindow}=s){return e.query(UserPositionQuery,{request:r,currency:t,timeWindow:n})}function Er(e,r,t=s){return e.query(UserBalancesQuery,{request:r,...t})}function Or(e,r,t=s){return e.query(UserSummaryHistoryQuery,{request:r,...t})}export{er as A,rr as B,tr as C,sr as D,ir as E,pr as F,yr as G,ar as H,cr as I,lr as J,Rr as K,qr as L,mr as M,Ar as N,Sr as O,Ur as P,wr as Q,Cr as R,fr as S,vr as T,Qr as U,Er as V,Or as W,s as a,Re as b,qe as c,me as d,Ue as e,Pe as f,xe as g,de as h,fe as i,Oe as j,Te as k,ke as l,He as m,Be as n,Me as o,We as p,De as q,Ie as r,Ye as s,Le as t,Ne as u,Je as v,Ve as w,Xe as x,L as y,Ze as z};//# sourceMappingURL=chunk-UXJVSHNC.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-UXJVSHNC.js.map
|