@aave/client 4.0.0-next.26 → 4.0.0-next.28

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/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var core=require('@aave/core'),graphql=require('@aave/graphql'),types=require('@aave/types'),H=require('@aave/graphql/schema'),exchangeGraphcache=require('@urql/exchange-graphcache');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var H__default=/*#__PURE__*/_interopDefault(H);var B={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function f(e,t){return e.query(graphql.HasProcessedKnownTransactionQuery,{request:t},{requestPolicy:"network-only",batch:false})}var y=(e,t,r,a)=>BigInt(e[a.fieldName]),l=(e,t,r,a)=>types.BigDecimal.new(e[a.fieldName]),s=(e,t,r,a)=>{let i=e[a.fieldName];return i==null?null:l(e,t,r,a)},n=(e,t,r,a)=>new Date(e[a.fieldName]),I=(e,t,r,a)=>{let i=e[a.fieldName];return i==null?null:n(e,t,r,a)},h=exchangeGraphcache.cacheExchange({schema:H__default.default,resolvers:{PercentNumber:{onChainValue:y,value:l,normalized:l},DecimalNumber:{onChainValue:y,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:n},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:n},TransactionRequest:{value:y},ApySample:{date:n},AssetBorrowSample:{date:n},AssetSupplySample:{date:n},HubSummarySample:{date:n},ProtocolHistorySample:{date:n},BorrowActivity:{timestamp:n},LiquidatedActivity:{timestamp:n},RepayActivity:{timestamp:n},SupplyActivity:{timestamp:n},WithdrawActivity:{timestamp:n},UsingAsCollateralActivity:{timestamp:n},UpdatedDynamicConfigActivity:{timestamp:n},UpdatedRiskPremiumActivity:{timestamp:n},SpokeUserPositionManager:{approvedOn:n},SwapCancelled:{createdAt:n,cancelledAt:I},SwapExpired:{createdAt:n,expiredAt:n},SwapFulfilled:{createdAt:n,fulfilledAt:n},SwapOpen:{createdAt:n,deadline:n},SwapPendingSignature:{createdAt:n,deadline:n},SwapReceipt:{createdAt:n},Query:{hub:(e,{request:t})=>graphql.isHubInputVariant(t.query)?{__typename:"Hub",id:graphql.encodeHubId(t.query.hubInput)}:{__typename:"Hub",id:t.query.hubId},activities:(e,t,r)=>{if(!graphql.isTxHashInputVariant(t.request.query))return r.resolve("Query","activities",t);let{txHash:a,chainId:i}=t.request.query.txHash,m=r.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,d)=>{let u=r.resolve("Query",d.fieldKey);if(!u)return o;let p=r.resolve(u,"items");if(!p)return o;for(let c of p)o.add(c);return o},new Set).values().toArray().filter(o=>{if(r.resolve(o,"txHash")!==a)return false;let u=r.resolve(o,"spoke");if(u){let p=r.resolve(u,"chain"),c=p?r.resolve(p,"chainId"):void 0;if(typeof c=="number")return c===i}return true});if(m.length!==0)return {__typename:"PaginatedActivitiesResult",items:m,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,RepayActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,TokenInfo:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,DecimalNumberWithChange:()=>null,DomainData:()=>null,Erc20Amount:()=>null,Erc20Approval:()=>null,Erc20ApprovalRequired:()=>null,ExchangeAmount:()=>null,ExchangeAmountVariation:()=>null,ExchangeAmountWithChange:()=>null,ForkTopUpResponse:()=>null,HealthFactorError:()=>null,HealthFactorVariation:()=>null,HealthFactorWithChange:()=>null,HubAssetSettings:()=>null,HubAssetSummary:()=>null,HubAssetUserState:()=>null,HubSummary:()=>null,HubSummarySample:()=>null,InsufficientBalanceError:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitMessageData:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewUserPosition:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManger:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,TypeDefinition:()=>null,TypeField:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var v={name:"production",backend:"https://api.v4.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},j={name:"staging",backend:"https://api.v4.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},J={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function g({environment:e=v,headers:t,cache:r=true,debug:a=false,fragments:i=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:r?h:null,debug:a,fragments:i}}function A(e){return e.operations!==null&&e.operations.length>0}var x=class e extends core.GqlClient{static create(t){return new e(g(t??{}))}waitForTransaction=t=>(types.invariant(A(t),"Received a transaction result for an untracked operation. Make sure you're following the instructions in the docs."),types.ResultAsync.fromPromise(this.pollTransactionStatus(t),r=>r instanceof core.TimeoutError||r instanceof core.UnexpectedError?r:core.UnexpectedError.from(r)));async refreshQueryWhere(t,r){await this.refreshWhere(async a=>{if(a.query===t){let i=await this.query(t,a.variables,{requestPolicy:"cache-only"});return i.isErr()?false:r(a.variables,i.value)}return false});}async pollTransactionStatus(t){let r=Date.now();for(;Date.now()-r<this.context.environment.indexingTimeout;){if(await f(this,t).match(i=>i,i=>{throw i}))return t.txHash;await core.delay(this.context.environment.pollingInterval);}throw core.TimeoutError.from(`Timeout waiting for transaction ${t.txHash} to be processed.`)}};
1
+ 'use strict';var core=require('@aave/core'),graphql=require('@aave/graphql'),types=require('@aave/types'),H=require('@aave/graphql/schema'),exchangeGraphcache=require('@urql/exchange-graphcache');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var H__default=/*#__PURE__*/_interopDefault(H);var B={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function f(e,t){return e.query(graphql.HasProcessedKnownTransactionQuery,{request:t},{requestPolicy:"network-only",batch:false})}var y=(e,t,r,a)=>BigInt(e[a.fieldName]),l=(e,t,r,a)=>types.BigDecimal.new(e[a.fieldName]),s=(e,t,r,a)=>{let i=e[a.fieldName];return i==null?null:l(e,t,r,a)},n=(e,t,r,a)=>new Date(e[a.fieldName]),I=(e,t,r,a)=>{let i=e[a.fieldName];return i==null?null:n(e,t,r,a)},h=exchangeGraphcache.cacheExchange({schema:H__default.default,resolvers:{PercentNumber:{onChainValue:y,value:l,normalized:l},DecimalNumber:{onChainValue:y,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:n},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:n},TransactionRequest:{value:y},ApySample:{date:n},AssetBorrowSample:{date:n},AssetSupplySample:{date:n},HubSummarySample:{date:n},ProtocolHistorySample:{date:n},BorrowActivity:{timestamp:n},LiquidatedActivity:{timestamp:n},RepayActivity:{timestamp:n},SupplyActivity:{timestamp:n},WithdrawActivity:{timestamp:n},UsingAsCollateralActivity:{timestamp:n},UpdatedDynamicConfigActivity:{timestamp:n},UpdatedRiskPremiumActivity:{timestamp:n},SpokeUserPositionManager:{approvedOn:n},SwapCancelled:{createdAt:n,cancelledAt:I},SwapExpired:{createdAt:n,expiredAt:n},SwapFulfilled:{createdAt:n,fulfilledAt:n},SwapOpen:{createdAt:n,deadline:n},SwapPendingSignature:{createdAt:n,deadline:n},SwapReceipt:{createdAt:n},Query:{hub:(e,{request:t})=>graphql.isHubInputVariant(t.query)?{__typename:"Hub",id:graphql.encodeHubId(t.query.hubInput)}:{__typename:"Hub",id:t.query.hubId},activities:(e,t,r)=>{if(!graphql.isTxHashInputVariant(t.request.query))return r.resolve("Query","activities",t);let{txHash:a,chainId:i}=t.request.query.txHash,m=r.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,d)=>{let u=r.resolve("Query",d.fieldKey);if(!u)return o;let p=r.resolve(u,"items");if(!p)return o;for(let c of p)o.add(c);return o},new Set).values().toArray().filter(o=>{if(r.resolve(o,"txHash")!==a)return false;let u=r.resolve(o,"spoke");if(u){let p=r.resolve(u,"chain"),c=p?r.resolve(p,"chainId"):void 0;if(typeof c=="number")return c===i}return true});if(m.length!==0)return {__typename:"PaginatedActivitiesResult",items:m,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,RepayActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,TokenInfo:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,DecimalNumberWithChange:()=>null,DomainData:()=>null,Erc20Amount:()=>null,Erc20Approval:()=>null,Erc20ApprovalRequired:()=>null,ExchangeAmount:()=>null,ExchangeAmountVariation:()=>null,ExchangeAmountWithChange:()=>null,ForkTopUpResponse:()=>null,HealthFactorError:()=>null,HealthFactorVariation:()=>null,HealthFactorWithChange:()=>null,HubAssetSettings:()=>null,HubAssetSummary:()=>null,HubAssetUserState:()=>null,HubSummary:()=>null,HubSummarySample:()=>null,InsufficientBalanceError:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitMessageData:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewUserPosition:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManger:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,TypeDefinition:()=>null,TypeField:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var v={name:"production",backend:"https://api.v4.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},j={name:"staging",backend:"https://api.v4.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},J={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function g({environment:e=v,headers:t,cache:r=true,debug:a=false,fragments:i=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:r?h:null,debug:a,fragments:i}}function A(e){return e.operations!==null&&e.operations.length>0}var x=class e extends core.GqlClient{static create(t){return new e(g(t??{}))}waitForTransaction=t=>(types.invariant(A(t),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),types.ResultAsync.fromPromise(this.pollTransactionStatus(t),r=>r instanceof core.TimeoutError||r instanceof core.UnexpectedError?r:core.UnexpectedError.from(r)));async refreshQueryWhere(t,r){await this.refreshWhere(async a=>{if(a.query===t){let i=await this.query(t,a.variables,{requestPolicy:"cache-only"});return i.isErr()?false:r(a.variables,i.value)}return false});}async pollTransactionStatus(t){let r=Date.now();for(;Date.now()-r<this.context.environment.indexingTimeout;){if(await f(this,t).match(i=>i,i=>{throw i}))return t.txHash;await core.delay(this.context.environment.pollingInterval);}throw core.TimeoutError.from(`Timeout waiting for transaction ${t.txHash} to be processed.`)}};
2
2
  exports.AaveClient=x;exports.DEFAULT_QUERY_OPTIONS=B;exports.local=J;exports.production=v;exports.staging=j;Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(graphql).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return graphql[k]}})});Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});//# sourceMappingURL=index.cjs.map
3
3
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/options.ts","../src/actions/misc.ts","../src/cache.ts","../src/environments.ts","../src/config.ts","../src/types.ts","../src/AaveClient.ts"],"names":["DEFAULT_QUERY_OPTIONS","Currency","TimeWindow","hasProcessedKnownTransaction","client","request","HasProcessedKnownTransactionQuery","transformToBigInt","parent","_args","_cache","info","transformToBigDecimal","BigDecimal","transformToNullableBigDecimal","value","transformToDate","transformToNullableDate","exchange","cacheExchange","introspectedSchema","_","isHubInputVariant","encodeHubId","_parent","args","cache","isTxHashInputVariant","txHash","chainId","matches","f","set","pageRef","itemRefs","ref","spokeRef","chainRef","itemChainId","data","production","staging","local","configureContext","environment","headers","debug","fragments","isHasProcessedKnownTransactionRequest","result","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","document","predicate","op","startedAt","ok","delay"],"mappings":"oTA+CO,IAAMA,CAAAA,CAAwB,CACnC,SAAUC,gBAAAA,CAAS,GAAA,CACnB,UAAA,CAAYC,kBAAAA,CAAW,OAAA,CACvB,aAAA,CAAe,mBAAA,CACf,KAAA,CAAO,IACT,ECgCO,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACuC,CACvC,OAAOD,CAAAA,CAAO,KAAA,CACZE,yCAAAA,CACA,CAAE,OAAA,CAAAD,CAAQ,CAAA,CACV,CACE,cAAe,cAAA,CACf,KAAA,CAAO,KACT,CACF,CACF,CC7DA,IAAME,CAAAA,CAA8B,CAACC,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACnD,MAAA,CAAOH,CAAAA,CAAOG,EAAK,SAAS,CAAW,CAAA,CAG1CC,CAAAA,CAAkC,CAACJ,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,IACvDE,gBAAAA,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,EAAK,SAAS,CAAA,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CACrE,CACA,OAAO,MACT,CAAC,EACH,CAEA,MAAgB,qBAAA,CACd5C,CAAAA,CACiB,CACjB,IAAMyD,CAAAA,CAAY,IAAA,CAAK,KAAI,CAE3B,KAAO,IAAA,CAAK,GAAA,EAAI,CAAIA,CAAAA,CAAY,IAAA,CAAK,OAAA,CAAQ,YAAY,eAAA,EAAiB,CAQxE,GAPkB,MAAM3D,CAAAA,CAA6B,IAAA,CAAME,CAAO,CAAA,CAAE,MACjE0D,CAAAA,EAAOA,CAAAA,CACPP,CAAAA,EAAQ,CACP,MAAMA,CACR,CACF,CAAA,CAGE,OAAOnD,CAAAA,CAAQ,MAAA,CAGjB,MAAM2D,UAAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,eAAe,EACtD,CACA,MAAMP,iBAAAA,CAAa,IAAA,CACjB,CAAA,gCAAA,EAAmCpD,CAAAA,CAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF","file":"index.cjs","sourcesContent":["import { Currency, TimeWindow } from '@aave/graphql';\nimport type { RequestPolicy } from '@urql/core';\n\nexport type CurrencyQueryOptions = {\n /**\n * The currency for fiat amounts.\n *\n * @defaultValue {@link Currency.Usd}\n */\n currency?: Currency;\n};\n\nexport type TimeWindowQueryOptions = {\n /**\n * The time window for historical data changes.\n *\n * @defaultValue {@link TimeWindow.LastDay}\n */\n timeWindow?: TimeWindow;\n};\n\n/**\n * @internal\n */\nexport type RequestPolicyOptions = {\n /**\n * The request policy to use.\n *\n * @internal This is used for testing purposes and could be changed without notice.\n * @defaultValue `cache-and-network`\n */\n requestPolicy?: RequestPolicy;\n};\n\n/**\n * @internal\n */\nexport type BatchOptions = {\n /**\n * Whether to batch the query or not.\n *\n * @internal This is used to turn off batching for a single query.\n * @defaultValue `true`\n */\n batch?: boolean;\n};\n\nexport const DEFAULT_QUERY_OPTIONS = {\n currency: Currency.Usd,\n timeWindow: TimeWindow.LastDay,\n requestPolicy: 'cache-and-network',\n batch: true,\n} as const;\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Chain,\n ChainQuery,\n type ChainRequest,\n ChainsQuery,\n type ChainsRequest,\n type ExchangeAmount,\n ExchangeRateQuery,\n type ExchangeRateRequest,\n HasProcessedKnownTransactionQuery,\n type HasProcessedKnownTransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type BatchOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @returns The chain data, or null if not found.\n */\n\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n): ResultAsync<Chain | null, UnexpectedError>;\n/**\n * @internal\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n options: BatchOptions,\n): ResultAsync<Chain | null, UnexpectedError>;\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n { batch }: BatchOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { filter: ChainsFilter.ALL }\n * });\n * ```\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { chainIds: [chainId(1), chainId(137)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chains request parameters.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n request: ChainsRequest,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { request });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n): ResultAsync<ExchangeAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request });\n}\n","import {\n type ActivitiesQuery,\n type Asset,\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 TokenInfo,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\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 ExchangeAmount: {\n value: transformToBigDecimal,\n },\n AssetPriceSample: {\n price: transformToBigDecimal,\n date: transformToDate,\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 HubSummarySample: {\n date: transformToDate,\n },\n ProtocolHistorySample: {\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 UpdatedDynamicConfigActivity: {\n timestamp: transformToDate,\n },\n UpdatedRiskPremiumActivity: {\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 // Entities with id field as key\n Asset: (data: Asset) => data.id,\n BorrowActivity: (data: BorrowActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n Reserve: (data: Reserve) => data.id,\n ReserveInfo: (data: ReserveInfo) => data.id,\n Spoke: (data: Spoke) => data.id,\n SupplyActivity: (data: SupplyActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => 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 // Value objects and result types\n ApySample: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n DecimalNumberWithChange: () => null,\n DomainData: () => null,\n Erc20Amount: () => null,\n Erc20Approval: () => null,\n Erc20ApprovalRequired: () => null,\n ExchangeAmount: () => null,\n ExchangeAmountVariation: () => null,\n ExchangeAmountWithChange: () => 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 HubSummarySample: () => null,\n InsufficientBalanceError: () => null,\n NativeAmount: () => null,\n PaginatedActivitiesResult: () => null,\n PaginatedResultInfo: () => null,\n PaginatedSpokePositionManagerResult: () => null,\n PaginatedSpokeUserPositionManagerResult: () => null,\n PaginatedUserSwapsResult: () => null,\n PercentNumber: () => null,\n PercentNumberVariation: () => null,\n PercentNumberWithChange: () => null,\n PermitMessageData: () => null,\n PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManger: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapExpired: () => null,\n SwapFulfilled: () => null,\n SwapOpen: () => null,\n SwapPendingSignature: () => null,\n SwapQuote: () => null,\n SwapQuoteCosts: () => null,\n SwapReceipt: () => null,\n SwapTransactionRequest: () => null,\n SwapTypedData: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => null,\n TypeDefinition: () => null,\n TypeField: () => null,\n UserBalance: () => null,\n UserBorrowItem: () => null,\n UserPositionRiskPremium: () => null,\n UserRiskPremiumBreakdownItem: () => null,\n UserSummary: () => null,\n UserSummaryHistoryItem: () => null,\n UserSupplyItem: () => null,\n },\n});\n","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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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 ExecutionPlan,\n HasProcessedKnownTransactionRequest,\n InsufficientBalanceError,\n OperationType,\n PermitTypedData,\n SwapTypedData,\n} from '@aave/graphql';\nimport type { ResultAsync, Signature, 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 SignTypedDataError = CancelError | SigningError;\n\n/**\n * Union type for all EIP-712 typed data structures used in the SDK.\n */\nexport type TypedData = PermitTypedData | SwapTypedData;\n\nexport type TypedDataHandler = (\n data: TypedData,\n) => ResultAsync<Signature, SignTypedDataError>;\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"]}
1
+ {"version":3,"sources":["../src/options.ts","../src/actions/misc.ts","../src/cache.ts","../src/environments.ts","../src/config.ts","../src/types.ts","../src/AaveClient.ts"],"names":["DEFAULT_QUERY_OPTIONS","Currency","TimeWindow","hasProcessedKnownTransaction","client","request","HasProcessedKnownTransactionQuery","transformToBigInt","parent","_args","_cache","info","transformToBigDecimal","BigDecimal","transformToNullableBigDecimal","value","transformToDate","transformToNullableDate","exchange","cacheExchange","introspectedSchema","_","isHubInputVariant","encodeHubId","_parent","args","cache","isTxHashInputVariant","txHash","chainId","matches","f","set","pageRef","itemRefs","ref","spokeRef","chainRef","itemChainId","data","production","staging","local","configureContext","environment","headers","debug","fragments","isHasProcessedKnownTransactionRequest","result","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","document","predicate","op","startedAt","ok","delay"],"mappings":"oTA+CO,IAAMA,CAAAA,CAAwB,CACnC,SAAUC,gBAAAA,CAAS,GAAA,CACnB,UAAA,CAAYC,kBAAAA,CAAW,OAAA,CACvB,aAAA,CAAe,mBAAA,CACf,KAAA,CAAO,IACT,ECgCO,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACuC,CACvC,OAAOD,CAAAA,CAAO,KAAA,CACZE,yCAAAA,CACA,CAAE,OAAA,CAAAD,CAAQ,CAAA,CACV,CACE,cAAe,cAAA,CACf,KAAA,CAAO,KACT,CACF,CACF,CC7DA,IAAME,CAAAA,CAA8B,CAACC,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACnD,MAAA,CAAOH,CAAAA,CAAOG,EAAK,SAAS,CAAW,CAAA,CAG1CC,CAAAA,CAAkC,CAACJ,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,IACvDE,gBAAAA,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,EAAK,SAAS,CAAA,CACnC,OAAII,CAAAA,EAAU,IAAA,CACL,IAAA,CAEFH,CAAAA,CAAsBJ,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAI,CAC1D,CAAA,CAEMK,CAAAA,CAA4B,CAACR,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACjD,IAAI,IAAA,CAAKH,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CA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AA,CAAME,CAAO,CAAA,CAAE,MACjE0D,CAAAA,EAAOA,CAAAA,CACPP,CAAAA,EAAQ,CACP,MAAMA,CACR,CACF,CAAA,CAGE,OAAOnD,CAAAA,CAAQ,MAAA,CAGjB,MAAM2D,UAAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,eAAe,EACtD,CACA,MAAMP,iBAAAA,CAAa,IAAA,CACjB,CAAA,gCAAA,EAAmCpD,CAAAA,CAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF","file":"index.cjs","sourcesContent":["import { Currency, TimeWindow } from '@aave/graphql';\nimport type { RequestPolicy } from '@urql/core';\n\nexport type CurrencyQueryOptions = {\n /**\n * The currency for fiat amounts.\n *\n * @defaultValue {@link Currency.Usd}\n */\n currency?: Currency;\n};\n\nexport type TimeWindowQueryOptions = {\n /**\n * The time window for historical data changes.\n *\n * @defaultValue {@link TimeWindow.LastDay}\n */\n timeWindow?: TimeWindow;\n};\n\n/**\n * @internal\n */\nexport type RequestPolicyOptions = {\n /**\n * The request policy to use.\n *\n * @internal This is used for testing purposes and could be changed without notice.\n * @defaultValue `cache-and-network`\n */\n requestPolicy?: RequestPolicy;\n};\n\n/**\n * @internal\n */\nexport type BatchOptions = {\n /**\n * Whether to batch the query or not.\n *\n * @internal This is used to turn off batching for a single query.\n * @defaultValue `true`\n */\n batch?: boolean;\n};\n\nexport const DEFAULT_QUERY_OPTIONS = {\n currency: Currency.Usd,\n timeWindow: TimeWindow.LastDay,\n requestPolicy: 'cache-and-network',\n batch: true,\n} as const;\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Chain,\n ChainQuery,\n type ChainRequest,\n ChainsQuery,\n type ChainsRequest,\n type ExchangeAmount,\n ExchangeRateQuery,\n type ExchangeRateRequest,\n HasProcessedKnownTransactionQuery,\n type HasProcessedKnownTransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type BatchOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @returns The chain data, or null if not found.\n */\n\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n): ResultAsync<Chain | null, UnexpectedError>;\n/**\n * @internal\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n options: BatchOptions,\n): ResultAsync<Chain | null, UnexpectedError>;\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n { batch }: BatchOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { filter: ChainsFilter.ALL }\n * });\n * ```\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { chainIds: [chainId(1), chainId(137)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chains request parameters.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n request: ChainsRequest,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { request });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n): ResultAsync<ExchangeAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request });\n}\n","import {\n type ActivitiesQuery,\n type Asset,\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 TokenInfo,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\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 ExchangeAmount: {\n value: transformToBigDecimal,\n },\n AssetPriceSample: {\n price: transformToBigDecimal,\n date: transformToDate,\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 HubSummarySample: {\n date: transformToDate,\n },\n ProtocolHistorySample: {\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 UpdatedDynamicConfigActivity: {\n timestamp: transformToDate,\n },\n UpdatedRiskPremiumActivity: {\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 // Entities with id field as key\n Asset: (data: Asset) => data.id,\n BorrowActivity: (data: BorrowActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n Reserve: (data: Reserve) => data.id,\n ReserveInfo: (data: ReserveInfo) => data.id,\n Spoke: (data: Spoke) => data.id,\n SupplyActivity: (data: SupplyActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => 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 // Value objects and result types\n ApySample: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n DecimalNumberWithChange: () => null,\n DomainData: () => null,\n Erc20Amount: () => null,\n Erc20Approval: () => null,\n Erc20ApprovalRequired: () => null,\n ExchangeAmount: () => null,\n ExchangeAmountVariation: () => null,\n ExchangeAmountWithChange: () => 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 HubSummarySample: () => null,\n InsufficientBalanceError: () => null,\n NativeAmount: () => null,\n PaginatedActivitiesResult: () => null,\n PaginatedResultInfo: () => null,\n PaginatedSpokePositionManagerResult: () => null,\n PaginatedSpokeUserPositionManagerResult: () => null,\n PaginatedUserSwapsResult: () => null,\n PercentNumber: () => null,\n PercentNumberVariation: () => null,\n PercentNumberWithChange: () => null,\n PermitMessageData: () => null,\n PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManger: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapExpired: () => null,\n SwapFulfilled: () => null,\n SwapOpen: () => null,\n SwapPendingSignature: () => null,\n SwapQuote: () => null,\n SwapQuoteCosts: () => null,\n SwapReceipt: () => null,\n SwapTransactionRequest: () => null,\n SwapTypedData: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => null,\n TypeDefinition: () => null,\n TypeField: () => null,\n UserBalance: () => null,\n UserBorrowItem: () => null,\n UserPositionRiskPremium: () => null,\n UserRiskPremiumBreakdownItem: () => null,\n UserSummary: () => null,\n UserSummaryHistoryItem: () => null,\n UserSupplyItem: () => null,\n },\n});\n","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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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 ExecutionPlan,\n HasProcessedKnownTransactionRequest,\n InsufficientBalanceError,\n OperationType,\n PermitTypedData,\n SwapTypedData,\n} from '@aave/graphql';\nimport type { ResultAsync, Signature, 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 SignTypedDataError = CancelError | SigningError;\n\n/**\n * Union type for all EIP-712 typed data structures used in the SDK.\n */\nexport type TypedData = PermitTypedData | SwapTypedData;\n\nexport type TypedDataHandler = (\n data: TypedData,\n) => ResultAsync<Signature, SignTypedDataError>;\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 'AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup.',\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"]}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import {h as h$1}from'./chunk-IDO2PFSI.js';export{a as DEFAULT_QUERY_OPTIONS}from'./chunk-IDO2PFSI.js';import {GqlClient,UnexpectedError,TimeoutError,delay}from'@aave/core';export*from'@aave/core';import {encodeHubId,isTxHashInputVariant,isHubInputVariant}from'@aave/graphql';export*from'@aave/graphql';import {BigDecimal,ResultAsync,invariant}from'@aave/types';export*from'@aave/types';import b from'@aave/graphql/schema';import {cacheExchange}from'@urql/exchange-graphcache';var m=(e,t,r,a)=>BigInt(e[a.fieldName]),l=(e,t,r,a)=>BigDecimal.new(e[a.fieldName]),s=(e,t,r,a)=>{let i=e[a.fieldName];return i==null?null:l(e,t,r,a)},n=(e,t,r,a)=>new Date(e[a.fieldName]),E=(e,t,r,a)=>{let i=e[a.fieldName];return i==null?null:n(e,t,r,a)},v=cacheExchange({schema:b,resolvers:{PercentNumber:{onChainValue:m,value:l,normalized:l},DecimalNumber:{onChainValue:m,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:n},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:n},TransactionRequest:{value:m},ApySample:{date:n},AssetBorrowSample:{date:n},AssetSupplySample:{date:n},HubSummarySample:{date:n},ProtocolHistorySample:{date:n},BorrowActivity:{timestamp:n},LiquidatedActivity:{timestamp:n},RepayActivity:{timestamp:n},SupplyActivity:{timestamp:n},WithdrawActivity:{timestamp:n},UsingAsCollateralActivity:{timestamp:n},UpdatedDynamicConfigActivity:{timestamp:n},UpdatedRiskPremiumActivity:{timestamp:n},SpokeUserPositionManager:{approvedOn:n},SwapCancelled:{createdAt:n,cancelledAt:E},SwapExpired:{createdAt:n,expiredAt:n},SwapFulfilled:{createdAt:n,fulfilledAt:n},SwapOpen:{createdAt:n,deadline:n},SwapPendingSignature:{createdAt:n,deadline:n},SwapReceipt:{createdAt:n},Query:{hub:(e,{request:t})=>isHubInputVariant(t.query)?{__typename:"Hub",id:encodeHubId(t.query.hubInput)}:{__typename:"Hub",id:t.query.hubId},activities:(e,t,r)=>{if(!isTxHashInputVariant(t.request.query))return r.resolve("Query","activities",t);let{txHash:a,chainId:i}=t.request.query.txHash,d=r.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,y)=>{let u=r.resolve("Query",y.fieldKey);if(!u)return o;let p=r.resolve(u,"items");if(!p)return o;for(let c of p)o.add(c);return o},new Set).values().toArray().filter(o=>{if(r.resolve(o,"txHash")!==a)return false;let u=r.resolve(o,"spoke");if(u){let p=r.resolve(u,"chain"),c=p?r.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:{Asset:e=>e.id,BorrowActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,RepayActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,TokenInfo:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,DecimalNumberWithChange:()=>null,DomainData:()=>null,Erc20Amount:()=>null,Erc20Approval:()=>null,Erc20ApprovalRequired:()=>null,ExchangeAmount:()=>null,ExchangeAmountVariation:()=>null,ExchangeAmountWithChange:()=>null,ForkTopUpResponse:()=>null,HealthFactorError:()=>null,HealthFactorVariation:()=>null,HealthFactorWithChange:()=>null,HubAssetSettings:()=>null,HubAssetSummary:()=>null,HubAssetUserState:()=>null,HubSummary:()=>null,HubSummarySample:()=>null,InsufficientBalanceError:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitMessageData:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewUserPosition:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManger:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,TypeDefinition:()=>null,TypeField:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var g={name:"production",backend:"https://api.v4.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},W={name:"staging",backend:"https://api.v4.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},F={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function h({environment:e=g,headers:t,cache:r=true,debug:a=false,fragments:i=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:r?v:null,debug:a,fragments:i}}function S(e){return e.operations!==null&&e.operations.length>0}var w=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),r=>r instanceof TimeoutError||r instanceof UnexpectedError?r:UnexpectedError.from(r)));async refreshQueryWhere(t,r){await this.refreshWhere(async a=>{if(a.query===t){let i=await this.query(t,a.variables,{requestPolicy:"cache-only"});return i.isErr()?false:r(a.variables,i.value)}return false});}async pollTransactionStatus(t){let r=Date.now();for(;Date.now()-r<this.context.environment.indexingTimeout;){if(await h$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.`)}};
1
+ import {h as h$1}from'./chunk-IDO2PFSI.js';export{a as DEFAULT_QUERY_OPTIONS}from'./chunk-IDO2PFSI.js';import {GqlClient,UnexpectedError,TimeoutError,delay}from'@aave/core';export*from'@aave/core';import {encodeHubId,isTxHashInputVariant,isHubInputVariant}from'@aave/graphql';export*from'@aave/graphql';import {BigDecimal,ResultAsync,invariant}from'@aave/types';export*from'@aave/types';import b from'@aave/graphql/schema';import {cacheExchange}from'@urql/exchange-graphcache';var m=(e,t,a,r)=>BigInt(e[r.fieldName]),l=(e,t,a,r)=>BigDecimal.new(e[r.fieldName]),s=(e,t,a,r)=>{let i=e[r.fieldName];return i==null?null:l(e,t,a,r)},n=(e,t,a,r)=>new Date(e[r.fieldName]),E=(e,t,a,r)=>{let i=e[r.fieldName];return i==null?null:n(e,t,a,r)},v=cacheExchange({schema:b,resolvers:{PercentNumber:{onChainValue:m,value:l,normalized:l},DecimalNumber:{onChainValue:m,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:n},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:n},TransactionRequest:{value:m},ApySample:{date:n},AssetBorrowSample:{date:n},AssetSupplySample:{date:n},HubSummarySample:{date:n},ProtocolHistorySample:{date:n},BorrowActivity:{timestamp:n},LiquidatedActivity:{timestamp:n},RepayActivity:{timestamp:n},SupplyActivity:{timestamp:n},WithdrawActivity:{timestamp:n},UsingAsCollateralActivity:{timestamp:n},UpdatedDynamicConfigActivity:{timestamp:n},UpdatedRiskPremiumActivity:{timestamp:n},SpokeUserPositionManager:{approvedOn:n},SwapCancelled:{createdAt:n,cancelledAt:E},SwapExpired:{createdAt:n,expiredAt:n},SwapFulfilled:{createdAt:n,fulfilledAt:n},SwapOpen:{createdAt:n,deadline:n},SwapPendingSignature:{createdAt:n,deadline:n},SwapReceipt:{createdAt:n},Query:{hub:(e,{request:t})=>isHubInputVariant(t.query)?{__typename:"Hub",id:encodeHubId(t.query.hubInput)}:{__typename:"Hub",id:t.query.hubId},activities:(e,t,a)=>{if(!isTxHashInputVariant(t.request.query))return a.resolve("Query","activities",t);let{txHash:r,chainId:i}=t.request.query.txHash,d=a.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,y)=>{let u=a.resolve("Query",y.fieldKey);if(!u)return o;let p=a.resolve(u,"items");if(!p)return o;for(let c of p)o.add(c);return o},new Set).values().toArray().filter(o=>{if(a.resolve(o,"txHash")!==r)return false;let u=a.resolve(o,"spoke");if(u){let p=a.resolve(u,"chain"),c=p?a.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:{Asset:e=>e.id,BorrowActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,RepayActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,TokenInfo:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,DecimalNumberWithChange:()=>null,DomainData:()=>null,Erc20Amount:()=>null,Erc20Approval:()=>null,Erc20ApprovalRequired:()=>null,ExchangeAmount:()=>null,ExchangeAmountVariation:()=>null,ExchangeAmountWithChange:()=>null,ForkTopUpResponse:()=>null,HealthFactorError:()=>null,HealthFactorVariation:()=>null,HealthFactorWithChange:()=>null,HubAssetSettings:()=>null,HubAssetSummary:()=>null,HubAssetUserState:()=>null,HubSummary:()=>null,HubSummarySample:()=>null,InsufficientBalanceError:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitMessageData:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewUserPosition:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManger:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,TypeDefinition:()=>null,TypeField:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var g={name:"production",backend:"https://api.v4.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},W={name:"staging",backend:"https://api.v4.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},F={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function h({environment:e=g,headers:t,cache:a=true,debug:r=false,fragments:i=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:a?v:null,debug:r,fragments:i}}function S(e){return e.operations!==null&&e.operations.length>0}var w=class e extends GqlClient{static create(t){return new e(h(t??{}))}waitForTransaction=t=>(invariant(S(t),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),ResultAsync.fromPromise(this.pollTransactionStatus(t),a=>a instanceof TimeoutError||a instanceof UnexpectedError?a:UnexpectedError.from(a)));async refreshQueryWhere(t,a){await this.refreshWhere(async r=>{if(r.query===t){let i=await this.query(t,r.variables,{requestPolicy:"cache-only"});return i.isErr()?false:a(r.variables,i.value)}return false});}async pollTransactionStatus(t){let a=Date.now();for(;Date.now()-a<this.context.environment.indexingTimeout;){if(await h$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
2
  export{w as AaveClient,F as local,g as production,W as staging};//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cache.ts","../src/environments.ts","../src/config.ts","../src/types.ts","../src/AaveClient.ts"],"names":["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","production","staging","local","configureContext","environment","headers","debug","fragments","isHasProcessedKnownTransactionRequest","result","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","document","predicate","op","startedAt","hasProcessedKnownTransaction","ok","delay"],"mappings":"6dAmCA,IAAMA,CAAAA,CAA8B,CAACC,CAAAA,CAAQC,CAAAA,CAAOC,EAAQC,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,EAAK,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,CAEMK,CAAAA,CAA4B,CAACR,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACjD,IAAI,IAAA,CAAKH,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAW,CAAA,CAG5CM,CAAAA,CAAoC,CAACT,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GAAS,CACzE,IAA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EAAiB,CAQxE,GAPkB,MAAMC,GAAAA,CAA6B,IAAA,CAAM1C,CAAO,CAAA,CAAE,KAAA,CACjE2C,CAAAA,EAAOA,CAAAA,CACPR,CAAAA,EAAQ,CACP,MAAMA,CACR,CACF,CAAA,CAGE,OAAOnC,EAAQ,MAAA,CAGjB,MAAM4C,KAAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,eAAe,EACtD,CACA,MAAMR,YAAAA,CAAa,IAAA,CACjB,CAAA,gCAAA,EAAmCpC,CAAAA,CAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF","file":"index.js","sourcesContent":["import {\n type ActivitiesQuery,\n type Asset,\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 TokenInfo,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\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 ExchangeAmount: {\n value: transformToBigDecimal,\n },\n AssetPriceSample: {\n price: transformToBigDecimal,\n date: transformToDate,\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 HubSummarySample: {\n date: transformToDate,\n },\n ProtocolHistorySample: {\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 UpdatedDynamicConfigActivity: {\n timestamp: transformToDate,\n },\n UpdatedRiskPremiumActivity: {\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 // Entities with id field as key\n Asset: (data: Asset) => data.id,\n BorrowActivity: (data: BorrowActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n Reserve: (data: Reserve) => data.id,\n ReserveInfo: (data: ReserveInfo) => data.id,\n Spoke: (data: Spoke) => data.id,\n SupplyActivity: (data: SupplyActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => 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 // Value objects and result types\n ApySample: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n DecimalNumberWithChange: () => null,\n DomainData: () => null,\n Erc20Amount: () => null,\n Erc20Approval: () => null,\n Erc20ApprovalRequired: () => null,\n ExchangeAmount: () => null,\n ExchangeAmountVariation: () => null,\n ExchangeAmountWithChange: () => 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 HubSummarySample: () => null,\n InsufficientBalanceError: () => null,\n NativeAmount: () => null,\n PaginatedActivitiesResult: () => null,\n PaginatedResultInfo: () => null,\n PaginatedSpokePositionManagerResult: () => null,\n PaginatedSpokeUserPositionManagerResult: () => null,\n PaginatedUserSwapsResult: () => null,\n PercentNumber: () => null,\n PercentNumberVariation: () => null,\n PercentNumberWithChange: () => null,\n PermitMessageData: () => null,\n PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManger: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapExpired: () => null,\n SwapFulfilled: () => null,\n SwapOpen: () => null,\n SwapPendingSignature: () => null,\n SwapQuote: () => null,\n SwapQuoteCosts: () => null,\n SwapReceipt: () => null,\n SwapTransactionRequest: () => null,\n SwapTypedData: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => null,\n TypeDefinition: () => null,\n TypeField: () => null,\n UserBalance: () => null,\n UserBorrowItem: () => null,\n UserPositionRiskPremium: () => null,\n UserRiskPremiumBreakdownItem: () => null,\n UserSummary: () => null,\n UserSummaryHistoryItem: () => null,\n UserSupplyItem: () => null,\n },\n});\n","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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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 ExecutionPlan,\n HasProcessedKnownTransactionRequest,\n InsufficientBalanceError,\n OperationType,\n PermitTypedData,\n SwapTypedData,\n} from '@aave/graphql';\nimport type { ResultAsync, Signature, 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 SignTypedDataError = CancelError | SigningError;\n\n/**\n * Union type for all EIP-712 typed data structures used in the SDK.\n */\nexport type TypedData = PermitTypedData | SwapTypedData;\n\nexport type TypedDataHandler = (\n data: TypedData,\n) => ResultAsync<Signature, SignTypedDataError>;\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"]}
1
+ {"version":3,"sources":["../src/cache.ts","../src/environments.ts","../src/config.ts","../src/types.ts","../src/AaveClient.ts"],"names":["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","production","staging","local","configureContext","environment","headers","debug","fragments","isHasProcessedKnownTransactionRequest","result","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","document","predicate","op","startedAt","hasProcessedKnownTransaction","ok","delay"],"mappings":"6dAmCA,IAAMA,CAAAA,CAA8B,CAACC,CAAAA,CAAQC,CAAAA,CAAOC,EAAQC,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,EAAK,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,CAEMK,CAAAA,CAA4B,CAACR,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACjD,IAAI,IAAA,CAAKH,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAW,CAAA,CAG5CM,CAAAA,CAAoC,CAACT,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GAAS,CACzE,IAAMI,CAAAA,CAAQP,CAAAA,CAAOG,EAAK,SAAS,CAAA,CACnC,OAAII,CAAAA,EAAU,IAAA,CACL,IAAA,CAEFC,CAAAA,CAAgBR,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAI,CACpD,CAAA,CAEaO,CAAAA,CAAWC,aAAAA,CAAc,CACpC,OAAQC,CAAAA,CACR,SAAA,CAAW,CACT,aAAA,CAAe,CACb,YAAA,CAAcb,CAAAA,CACd,KAAA,CAAOK,CAAAA,CACP,UAAA,CAAYA,CAC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Q,MAAM,CAAA,iBAAA,CACnD,CACF,CACF","file":"index.js","sourcesContent":["import {\n type ActivitiesQuery,\n type Asset,\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 TokenInfo,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\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 ExchangeAmount: {\n value: transformToBigDecimal,\n },\n AssetPriceSample: {\n price: transformToBigDecimal,\n date: transformToDate,\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 HubSummarySample: {\n date: transformToDate,\n },\n ProtocolHistorySample: {\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 UpdatedDynamicConfigActivity: {\n timestamp: transformToDate,\n },\n UpdatedRiskPremiumActivity: {\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 // Entities with id field as key\n Asset: (data: Asset) => data.id,\n BorrowActivity: (data: BorrowActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n Reserve: (data: Reserve) => data.id,\n ReserveInfo: (data: ReserveInfo) => data.id,\n Spoke: (data: Spoke) => data.id,\n SupplyActivity: (data: SupplyActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => 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 // Value objects and result types\n ApySample: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n DecimalNumberWithChange: () => null,\n DomainData: () => null,\n Erc20Amount: () => null,\n Erc20Approval: () => null,\n Erc20ApprovalRequired: () => null,\n ExchangeAmount: () => null,\n ExchangeAmountVariation: () => null,\n ExchangeAmountWithChange: () => 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 HubSummarySample: () => null,\n InsufficientBalanceError: () => null,\n NativeAmount: () => null,\n PaginatedActivitiesResult: () => null,\n PaginatedResultInfo: () => null,\n PaginatedSpokePositionManagerResult: () => null,\n PaginatedSpokeUserPositionManagerResult: () => null,\n PaginatedUserSwapsResult: () => null,\n PercentNumber: () => null,\n PercentNumberVariation: () => null,\n PercentNumberWithChange: () => null,\n PermitMessageData: () => null,\n PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManger: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapExpired: () => null,\n SwapFulfilled: () => null,\n SwapOpen: () => null,\n SwapPendingSignature: () => null,\n SwapQuote: () => null,\n SwapQuoteCosts: () => null,\n SwapReceipt: () => null,\n SwapTransactionRequest: () => null,\n SwapTypedData: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => null,\n TypeDefinition: () => null,\n TypeField: () => null,\n UserBalance: () => null,\n UserBorrowItem: () => null,\n UserPositionRiskPremium: () => null,\n UserRiskPremiumBreakdownItem: () => null,\n UserSummary: () => null,\n UserSummaryHistoryItem: () => null,\n UserSupplyItem: () => null,\n },\n});\n","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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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: 10_000,\n swapQuoteInterval: 30_000,\n swapStatusInterval: 5_000,\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 ExecutionPlan,\n HasProcessedKnownTransactionRequest,\n InsufficientBalanceError,\n OperationType,\n PermitTypedData,\n SwapTypedData,\n} from '@aave/graphql';\nimport type { ResultAsync, Signature, 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 SignTypedDataError = CancelError | SigningError;\n\n/**\n * Union type for all EIP-712 typed data structures used in the SDK.\n */\nexport type TypedData = PermitTypedData | SwapTypedData;\n\nexport type TypedDataHandler = (\n data: TypedData,\n) => ResultAsync<Signature, SignTypedDataError>;\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 'AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup.',\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"]}
package/dist/testing.js CHANGED
@@ -41,7 +41,7 @@ Read more: https://mswjs.io/docs/http/intercepting-requests`;function s(u){switc
41
41
  `).map(r=>r.split("|"))[0],o=[];for(let r=0;r<Math.floor(t.length/n.length);r++){let a={};for(let i=0;i<n.length;i++)a[n[i]]=t[r*n.length+i];o.push(a);}return o}function ol(e){let t=kg(),n=e.split(`
42
42
  `).slice(1);for(let o of n){let r=pi(o);if(r&&r.file===t)return {line:r.line,column:r.column}}}globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;ma();var di=new Map,rl=[],nr=[];function vl(e){if(di.size){var t;let n=Array.from(di).map(([r,a])=>[r,a[0],a[1]]),o=(t=e.onTaskUpdate)===null||t===void 0?void 0:t.call(e,n,rl);o&&(nr.push(o),o.then(()=>nr.splice(nr.indexOf(o),1),()=>{})),rl.length=0,di.clear();}}async function Tg(e){vl(e),await Promise.all(nr);}var al=Date.now,ft={currentSuite:null};function Ag(e){var t;(t=ft.currentSuite)===null||t===void 0||t.tasks.push(e);}async function Pg(e,t){let n=ft.currentSuite;ft.currentSuite=e,await t(),ft.currentSuite=n;}function It(e,t,n=false,o,r){if(t<=0||t===Number.POSITIVE_INFINITY)return e;let{setTimeout:a,clearTimeout:i}=ma();return function(...u){let c=al(),l=bl();return l._currentTaskStartTime=c,l._currentTaskTimeout=t,new Promise((p,y)=>{var h;let k=a(()=>{i(k),f();},t);(h=k.unref)===null||h===void 0||h.call(k);function f(){let q=Og(n,t,o);r?.(u,q),y(q);}function v(q){if(l._currentTaskStartTime=void 0,l._currentTaskTimeout=void 0,i(k),al()-c>=t){f();return}p(q);}function R(q){l._currentTaskStartTime=void 0,l._currentTaskTimeout=void 0,i(k),y(q);}try{let q=e(...u);typeof q=="object"&&q!=null&&typeof q.then=="function"?q.then(v,R):v(q);}catch(q){R(q);}})}}var gi=new WeakMap;function vi([e],t){e&&_g(e,t);}function _g(e,t){let n=gi.get(e);n?.abort(t);}function Ig(e,t){var n;let o=function(){throw new Error("done() callback is deprecated, use promise instead")},r=gi.get(o);r||(r=new AbortController,gi.set(o,r)),o.signal=r.signal,o.task=e,o.skip=(i,s)=>{if(i!==false)throw e.result??(e.result={state:"skip"}),e.result.pending=true,new hi("test is skipped; abort execution",e,typeof i=="string"?i:s)};async function a(i,s,u,c){let l={message:i,type:u||"notice"};if(c){if(!c.body&&!c.path)throw new TypeError("Test attachment requires body or path to be set. Both are missing.");if(c.body&&c.path)throw new TypeError('Test attachment requires only one of "body" or "path" to be set. Both are specified.');l.attachment=c,c.body instanceof Uint8Array&&(c.body=Dg(c.body));}if(s&&(l.location=s),!t.onTestAnnotate)throw new Error("Test runner doesn't support test annotations.");await Tg(t);let p=await t.onTestAnnotate(e,l);return e.annotations.push(p),p}return o.annotate=(i,s,u)=>{if(e.result&&e.result.state!=="run")throw new Error(`Cannot annotate tests outside of the test run. The test "${e.name}" finished running with the "${e.result.state}" state already.`);let c,l=new Error("STACK_TRACE").stack,p=l.includes("STACK_TRACE")?2:1,y=l.split(`
43
43
  `)[p],h=pi(y);return h&&(c={file:h.file,line:h.line,column:h.column}),typeof s=="object"?il(e,a(i,c,void 0,s)):il(e,a(i,c,s,u))},o.onTestFailed=(i,s)=>{e.onFailed||(e.onFailed=[]),e.onFailed.push(It(i,s??t.config.hookTimeout,true,new Error("STACK_TRACE_ERROR"),(u,c)=>r.abort(c)));},o.onTestFinished=(i,s)=>{e.onFinished||(e.onFinished=[]),e.onFinished.push(It(i,s??t.config.hookTimeout,true,new Error("STACK_TRACE_ERROR"),(u,c)=>r.abort(c)));},((n=t.extendTaskContext)===null||n===void 0?void 0:n.call(t,o))||o}function Og(e,t,n){let o=`${e?"Hook":"Test"} timed out in ${t}ms.
44
- If this is a long-running ${e?"hook":"test"}, pass a timeout value as the last argument or configure it globally with "${e?"hookTimeout":"testTimeout"}".`,r=new Error(o);return n?.stack&&(r.stack=n.stack.replace(r.message,n.message)),r}var zg=new WeakMap;function qg(e){let t=zg.get(e);if(!t)throw new Error(`Cannot find file context for ${e.name}`);return t}var De=[];for(let e=65;e<91;e++)De.push(String.fromCharCode(e));for(let e=97;e<123;e++)De.push(String.fromCharCode(e));for(let e=0;e<10;e++)De.push(e.toString(10));function Dg(e){let t="",n=e.byteLength;for(let o=0;o<n;o+=3)if(n===o+1){let r=(e[o]&252)>>2,a=(e[o]&3)<<4;t+=De[r],t+=De[a],t+="==";}else if(n===o+2){let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2;t+=De[r],t+=De[a],t+=De[i],t+="=";}else {let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2|(e[o+2]&192)>>6,s=e[o+2]&63;t+=De[r],t+=De[a],t+=De[i],t+=De[s];}return t}function il(e,t){return t=t.finally(()=>{if(!e.promises)return;let n=e.promises.indexOf(t);n!==-1&&e.promises.splice(n,1);}),e.promises||(e.promises=[]),e.promises.push(t),t}function rr(){return bl().config.hookTimeout}var Ng=Symbol.for("VITEST_CLEANUP_TIMEOUT"),Lg=Symbol.for("VITEST_CLEANUP_STACK_TRACE");function ar(e,t=rr()){xn(e,'"beforeAll" callback',["function"]);let n=new Error("STACK_TRACE_ERROR");return Zt().on("beforeAll",Object.assign(It(e,t,true,n),{[Ng]:t,[Lg]:n}))}function ir(e,t){return xn(e,'"afterAll" callback',["function"]),Zt().on("afterAll",It(e,rr(),true,new Error("STACK_TRACE_ERROR")))}Ci(Il());var Ol={currency:Currency.Usd,timeWindow:TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function zl(e,t,{batch:n}=Ol){return e.query(ChainQuery,{request:t},{batch:n})}function ql(e,t){return e.query(HasProcessedKnownTransactionQuery,{request:t},{requestPolicy:"network-only",batch:false})}var ji=(e,t,n,o)=>BigInt(e[o.fieldName]),dt=(e,t,n,o)=>BigDecimal.new(e[o.fieldName]),Ot=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:dt(e,t,n,o)},ne=(e,t,n,o)=>new Date(e[o.fieldName]),ny=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:ne(e,t,n,o)},Dl=cacheExchange({schema:Zg,resolvers:{PercentNumber:{onChainValue:ji,value:dt,normalized:dt},DecimalNumber:{onChainValue:ji,value:dt},ExchangeAmount:{value:dt},AssetPriceSample:{price:dt,date:ne},Reserve:{borrowCap:dt,supplyCap:dt},HealthFactorError:{current:Ot,after:Ot},HealthFactorVariation:{current:Ot,after:Ot},HealthFactorWithChange:{current:Ot},UserSummary:{lowestHealthFactor:Ot},UserSummaryHistoryItem:{healthFactor:Ot,date:ne},TransactionRequest:{value:ji},ApySample:{date:ne},AssetBorrowSample:{date:ne},AssetSupplySample:{date:ne},HubSummarySample:{date:ne},ProtocolHistorySample:{date:ne},BorrowActivity:{timestamp:ne},LiquidatedActivity:{timestamp:ne},RepayActivity:{timestamp:ne},SupplyActivity:{timestamp:ne},WithdrawActivity:{timestamp:ne},UsingAsCollateralActivity:{timestamp:ne},UpdatedDynamicConfigActivity:{timestamp:ne},UpdatedRiskPremiumActivity:{timestamp:ne},SpokeUserPositionManager:{approvedOn:ne},SwapCancelled:{createdAt:ne,cancelledAt:ny},SwapExpired:{createdAt:ne,expiredAt:ne},SwapFulfilled:{createdAt:ne,fulfilledAt:ne},SwapOpen:{createdAt:ne,deadline:ne},SwapPendingSignature:{createdAt:ne,deadline:ne},SwapReceipt:{createdAt:ne},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:o,chainId:r}=t.request.query.txHash,a=n.inspectFields("Query").filter(i=>i.fieldName==="activities").reduce((i,s)=>{let u=n.resolve("Query",s.fieldKey);if(!u)return i;let c=n.resolve(u,"items");if(!c)return i;for(let l of c)i.add(l);return i},new Set).values().toArray().filter(i=>{if(n.resolve(i,"txHash")!==o)return false;let u=n.resolve(i,"spoke");if(u){let c=n.resolve(u,"chain"),l=c?n.resolve(c,"chainId"):void 0;if(typeof l=="number")return l===r}return true});if(a.length!==0)return {__typename:"PaginatedActivitiesResult",items:a,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,RepayActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,TokenInfo:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,DecimalNumberWithChange:()=>null,DomainData:()=>null,Erc20Amount:()=>null,Erc20Approval:()=>null,Erc20ApprovalRequired:()=>null,ExchangeAmount:()=>null,ExchangeAmountVariation:()=>null,ExchangeAmountWithChange:()=>null,ForkTopUpResponse:()=>null,HealthFactorError:()=>null,HealthFactorVariation:()=>null,HealthFactorWithChange:()=>null,HubAssetSettings:()=>null,HubAssetSummary:()=>null,HubAssetUserState:()=>null,HubSummary:()=>null,HubSummarySample:()=>null,InsufficientBalanceError:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitMessageData:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewUserPosition:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManger:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,TypeDefinition:()=>null,TypeField:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var ur={name:"production",backend:"https://api.v4.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Nl={name:"staging",backend:"https://api.v4.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Ll={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function Ml({environment:e=ur,headers:t,cache:n=true,debug:o=false,fragments:r=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:n?Dl:null,debug:o,fragments:r}}function Fl(e){return e.operations!==null&&e.operations.length>0}var cr=class e extends GqlClient{static create(t){return new e(Ml(t??{}))}waitForTransaction=t=>(invariant(Fl(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 o=>{if(o.query===t){let r=await this.query(t,o.variables,{requestPolicy:"cache-only"});return r.isErr()?false:n(o.variables,r.value)}return false});}async pollTransactionStatus(t){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await ql(this,t).match(r=>r,r=>{throw r}))return t.txHash;await delay(this.context.environment.pollingInterval);}throw TimeoutError.from(`Timeout waiting for transaction ${t.txHash} to be processed.`)}};var Wl=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://dashboard.tenderly.co/explorer/vnet/dbaa58ab-597b-4bcd-ae6a-b8e50f716146/"}}});({[chainId(Wl.id)]:Wl});function Jl(e){switch(e.chainId){case chainId(mainnet.id):return mainnet;case chainId(sepolia.id):return sepolia}return defineChain({id:e.chainId,name:e.name,nativeCurrency:{name:e.nativeInfo.name,symbol:e.nativeInfo.symbol,decimals:e.nativeInfo.decimals},rpcUrls:{default:{http:[e.rpcUrl]}},blockExplorers:{default:{name:`${e.name} Explorer`,url:e.explorerUrl}}})}var gy=import.meta.env.ENVIRONMENT==="local"?Ll:import.meta.env.ENVIRONMENT==="production"?ur:Nl,zt=chainId(Number.parseInt("123456789",10)),KE=evmAddress("0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f"),YE=evmAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),QE=evmAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),ZE=evmAddress("0xdC035D45d973E3EC169d2276DDab16f1e407384F"),eS=evmAddress("0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"),tS=evmAddress("0x111111111117dC0aa78b770fA6A738034120C302"),nS=evmAddress("0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"),yy=evmAddress("0xBa97c5E52cd5BC3D7950Ae70779F8FfE92d40CdC"),oS=encodeSpokeId({chainId:zt,address:yy}),by=evmAddress("0x2559E4E04F2cA7180e5f20C2872d22EC89601b56"),rS=encodeSpokeId({chainId:zt,address:by}),aS=evmAddress("0x5738d9cB82d6a1617973C257D05A387bF5568F47"),ky=evmAddress("0x4D4a7b3Ce709b4362D7095a4A0105bDFDb5dA2a7"),iS=encodeSpokeId({chainId:zt,address:ky}),vy=evmAddress("0xaD905aD5EA5B98cD50AE40Cfe368344686a21366"),sS=encodeHubId({chainId:zt,address:vy}),en="https://virtual.mainnet-aave.us-east.rpc.tenderly.co/dbaa58ab-597b-4bcd-ae6a-b8e50f716146",lr=import.meta.env.ETHEREUM_TENDERLY_ADMIN_RPC,jy=cr.create({environment:gy}),zn=await zl(jy,{chainId:zt}).map(nonNullable).map(Jl).match(e=>e,()=>never("No devnet chain found"));async function uS(){return createPublicClient({chain:zn,transport:http(en)})}async function cS(e){if(!e){let t=generatePrivateKey(),n=createWalletClient({account:privateKeyToAccount(t),chain:zn,transport:http()});return await wy(evmAddress(n.account.address)),n}return createWalletClient({account:privateKeyToAccount(e),chain:zn,transport:http()})}function wy(e,t=bigDecimal("1.0")){let n=createPublicClient({chain:{id:zt,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[lr]}}},transport:http(lr)}),r=`0x${parseEther(t.toString()).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setBalance",params:[[e],r]}).then(async a=>(await Ql(500),a)),a=>UnexpectedError.from(a))}function lS(e,t){let n=createPublicClient({chain:{id:zt,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[lr]}}},transport:http(lr)}),r=`0x${parseUnits(t.amount.toString(),t.decimals??18).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setErc20Balance",params:[t.address,e,r]}).then(async a=>(await Ql(500),a)),a=>UnexpectedError.from(a))}function Ql(e){return new Promise(t=>setTimeout(t,e))}async function pS(e,t){let n=createPublicClient({chain:zn,transport:http(en)}),[o,r]=await Promise.all([n.readContract({address:t,abi:[{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"balanceOf",args:[e]}),n.readContract({address:t,abi:[{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"}],functionName:"decimals"})]);return bigDecimal(o).rescale(-r)}async function mS(e){let n=await createPublicClient({chain:zn,transport:http(en)}).getBalance({address:e});return bigDecimal(n).rescale(-18)}function Zl(e){return isObject(e)&&"jsonrpc"in e&&"method"in e}function xy(e){return Array.isArray(e)&&e.every(Zl)}function fS(e){let t=ou(Gn.post(en,async({request:n})=>{let o=await n.clone().json();if(Zl(o)){let r=e(o);return r?cn.json(r):ln()}if(xy(o)){let r=o.map(a=>e(a));return r.some(a=>a===void 0)?ln():cn.json(r)}invariant(false,"body is not a valid JSON-RPC request or batch");}),Gn.post(en,()=>ln()));return ar(()=>{t.listen();}),ir(()=>{t.close();}),t}function dS(e){let t=createPublicClient({transport:http(en)});async function n(o,r){return t.request({method:o,params:r??[]})}return {async request(o){let r=await e(o);if(r!==void 0){if("error"in r)throw r.error;return r.result}return n(o.method,o.params)}}}/*! Bundled license information:
44
+ If this is a long-running ${e?"hook":"test"}, pass a timeout value as the last argument or configure it globally with "${e?"hookTimeout":"testTimeout"}".`,r=new Error(o);return n?.stack&&(r.stack=n.stack.replace(r.message,n.message)),r}var zg=new WeakMap;function qg(e){let t=zg.get(e);if(!t)throw new Error(`Cannot find file context for ${e.name}`);return t}var De=[];for(let e=65;e<91;e++)De.push(String.fromCharCode(e));for(let e=97;e<123;e++)De.push(String.fromCharCode(e));for(let e=0;e<10;e++)De.push(e.toString(10));function Dg(e){let t="",n=e.byteLength;for(let o=0;o<n;o+=3)if(n===o+1){let r=(e[o]&252)>>2,a=(e[o]&3)<<4;t+=De[r],t+=De[a],t+="==";}else if(n===o+2){let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2;t+=De[r],t+=De[a],t+=De[i],t+="=";}else {let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2|(e[o+2]&192)>>6,s=e[o+2]&63;t+=De[r],t+=De[a],t+=De[i],t+=De[s];}return t}function il(e,t){return t=t.finally(()=>{if(!e.promises)return;let n=e.promises.indexOf(t);n!==-1&&e.promises.splice(n,1);}),e.promises||(e.promises=[]),e.promises.push(t),t}function rr(){return bl().config.hookTimeout}var Ng=Symbol.for("VITEST_CLEANUP_TIMEOUT"),Lg=Symbol.for("VITEST_CLEANUP_STACK_TRACE");function ar(e,t=rr()){xn(e,'"beforeAll" callback',["function"]);let n=new Error("STACK_TRACE_ERROR");return Zt().on("beforeAll",Object.assign(It(e,t,true,n),{[Ng]:t,[Lg]:n}))}function ir(e,t){return xn(e,'"afterAll" callback',["function"]),Zt().on("afterAll",It(e,rr(),true,new Error("STACK_TRACE_ERROR")))}Ci(Il());var Ol={currency:Currency.Usd,timeWindow:TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function zl(e,t,{batch:n}=Ol){return e.query(ChainQuery,{request:t},{batch:n})}function ql(e,t){return e.query(HasProcessedKnownTransactionQuery,{request:t},{requestPolicy:"network-only",batch:false})}var ji=(e,t,n,o)=>BigInt(e[o.fieldName]),dt=(e,t,n,o)=>BigDecimal.new(e[o.fieldName]),Ot=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:dt(e,t,n,o)},ne=(e,t,n,o)=>new Date(e[o.fieldName]),ny=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:ne(e,t,n,o)},Dl=cacheExchange({schema:Zg,resolvers:{PercentNumber:{onChainValue:ji,value:dt,normalized:dt},DecimalNumber:{onChainValue:ji,value:dt},ExchangeAmount:{value:dt},AssetPriceSample:{price:dt,date:ne},Reserve:{borrowCap:dt,supplyCap:dt},HealthFactorError:{current:Ot,after:Ot},HealthFactorVariation:{current:Ot,after:Ot},HealthFactorWithChange:{current:Ot},UserSummary:{lowestHealthFactor:Ot},UserSummaryHistoryItem:{healthFactor:Ot,date:ne},TransactionRequest:{value:ji},ApySample:{date:ne},AssetBorrowSample:{date:ne},AssetSupplySample:{date:ne},HubSummarySample:{date:ne},ProtocolHistorySample:{date:ne},BorrowActivity:{timestamp:ne},LiquidatedActivity:{timestamp:ne},RepayActivity:{timestamp:ne},SupplyActivity:{timestamp:ne},WithdrawActivity:{timestamp:ne},UsingAsCollateralActivity:{timestamp:ne},UpdatedDynamicConfigActivity:{timestamp:ne},UpdatedRiskPremiumActivity:{timestamp:ne},SpokeUserPositionManager:{approvedOn:ne},SwapCancelled:{createdAt:ne,cancelledAt:ny},SwapExpired:{createdAt:ne,expiredAt:ne},SwapFulfilled:{createdAt:ne,fulfilledAt:ne},SwapOpen:{createdAt:ne,deadline:ne},SwapPendingSignature:{createdAt:ne,deadline:ne},SwapReceipt:{createdAt:ne},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:o,chainId:r}=t.request.query.txHash,a=n.inspectFields("Query").filter(i=>i.fieldName==="activities").reduce((i,s)=>{let u=n.resolve("Query",s.fieldKey);if(!u)return i;let c=n.resolve(u,"items");if(!c)return i;for(let l of c)i.add(l);return i},new Set).values().toArray().filter(i=>{if(n.resolve(i,"txHash")!==o)return false;let u=n.resolve(i,"spoke");if(u){let c=n.resolve(u,"chain"),l=c?n.resolve(c,"chainId"):void 0;if(typeof l=="number")return l===r}return true});if(a.length!==0)return {__typename:"PaginatedActivitiesResult",items:a,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,RepayActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,TokenInfo:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,DecimalNumberWithChange:()=>null,DomainData:()=>null,Erc20Amount:()=>null,Erc20Approval:()=>null,Erc20ApprovalRequired:()=>null,ExchangeAmount:()=>null,ExchangeAmountVariation:()=>null,ExchangeAmountWithChange:()=>null,ForkTopUpResponse:()=>null,HealthFactorError:()=>null,HealthFactorVariation:()=>null,HealthFactorWithChange:()=>null,HubAssetSettings:()=>null,HubAssetSummary:()=>null,HubAssetUserState:()=>null,HubSummary:()=>null,HubSummarySample:()=>null,InsufficientBalanceError:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitMessageData:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewUserPosition:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManger:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,TypeDefinition:()=>null,TypeField:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var ur={name:"production",backend:"https://api.v4.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Nl={name:"staging",backend:"https://api.v4.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Ll={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function Ml({environment:e=ur,headers:t,cache:n=true,debug:o=false,fragments:r=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:n?Dl:null,debug:o,fragments:r}}function Fl(e){return e.operations!==null&&e.operations.length>0}var cr=class e extends GqlClient{static create(t){return new e(Ml(t??{}))}waitForTransaction=t=>(invariant(Fl(t),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),ResultAsync.fromPromise(this.pollTransactionStatus(t),n=>n instanceof TimeoutError||n instanceof UnexpectedError?n:UnexpectedError.from(n)));async refreshQueryWhere(t,n){await this.refreshWhere(async o=>{if(o.query===t){let r=await this.query(t,o.variables,{requestPolicy:"cache-only"});return r.isErr()?false:n(o.variables,r.value)}return false});}async pollTransactionStatus(t){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await ql(this,t).match(r=>r,r=>{throw r}))return t.txHash;await delay(this.context.environment.pollingInterval);}throw TimeoutError.from(`Timeout waiting for transaction ${t.txHash} to be processed.`)}};var Wl=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://dashboard.tenderly.co/explorer/vnet/dbaa58ab-597b-4bcd-ae6a-b8e50f716146/"}}});({[chainId(Wl.id)]:Wl});function Jl(e){switch(e.chainId){case chainId(mainnet.id):return mainnet;case chainId(sepolia.id):return sepolia}return defineChain({id:e.chainId,name:e.name,nativeCurrency:{name:e.nativeInfo.name,symbol:e.nativeInfo.symbol,decimals:e.nativeInfo.decimals},rpcUrls:{default:{http:[e.rpcUrl]}},blockExplorers:{default:{name:`${e.name} Explorer`,url:e.explorerUrl}}})}var gy=import.meta.env.ENVIRONMENT==="local"?Ll:import.meta.env.ENVIRONMENT==="production"?ur:Nl,zt=chainId(Number.parseInt("123456789",10)),KE=evmAddress("0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f"),YE=evmAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),QE=evmAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),ZE=evmAddress("0xdC035D45d973E3EC169d2276DDab16f1e407384F"),eS=evmAddress("0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"),tS=evmAddress("0x111111111117dC0aa78b770fA6A738034120C302"),nS=evmAddress("0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"),yy=evmAddress("0xBa97c5E52cd5BC3D7950Ae70779F8FfE92d40CdC"),oS=encodeSpokeId({chainId:zt,address:yy}),by=evmAddress("0x2559E4E04F2cA7180e5f20C2872d22EC89601b56"),rS=encodeSpokeId({chainId:zt,address:by}),aS=evmAddress("0x5738d9cB82d6a1617973C257D05A387bF5568F47"),ky=evmAddress("0x4D4a7b3Ce709b4362D7095a4A0105bDFDb5dA2a7"),iS=encodeSpokeId({chainId:zt,address:ky}),vy=evmAddress("0xaD905aD5EA5B98cD50AE40Cfe368344686a21366"),sS=encodeHubId({chainId:zt,address:vy}),en="https://virtual.mainnet-aave.us-east.rpc.tenderly.co/dbaa58ab-597b-4bcd-ae6a-b8e50f716146",lr=import.meta.env.ETHEREUM_TENDERLY_ADMIN_RPC,jy=cr.create({environment:gy}),zn=await zl(jy,{chainId:zt}).map(nonNullable).map(Jl).match(e=>e,()=>never("No devnet chain found"));async function uS(){return createPublicClient({chain:zn,transport:http(en)})}async function cS(e){if(!e){let t=generatePrivateKey(),n=createWalletClient({account:privateKeyToAccount(t),chain:zn,transport:http()});return await wy(evmAddress(n.account.address)),n}return createWalletClient({account:privateKeyToAccount(e),chain:zn,transport:http()})}function wy(e,t=bigDecimal("1.0")){let n=createPublicClient({chain:{id:zt,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[lr]}}},transport:http(lr)}),r=`0x${parseEther(t.toString()).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setBalance",params:[[e],r]}).then(async a=>(await Ql(500),a)),a=>UnexpectedError.from(a))}function lS(e,t){let n=createPublicClient({chain:{id:zt,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[lr]}}},transport:http(lr)}),r=`0x${parseUnits(t.amount.toString(),t.decimals??18).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setErc20Balance",params:[t.address,e,r]}).then(async a=>(await Ql(500),a)),a=>UnexpectedError.from(a))}function Ql(e){return new Promise(t=>setTimeout(t,e))}async function pS(e,t){let n=createPublicClient({chain:zn,transport:http(en)}),[o,r]=await Promise.all([n.readContract({address:t,abi:[{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"balanceOf",args:[e]}),n.readContract({address:t,abi:[{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"}],functionName:"decimals"})]);return bigDecimal(o).rescale(-r)}async function mS(e){let n=await createPublicClient({chain:zn,transport:http(en)}).getBalance({address:e});return bigDecimal(n).rescale(-18)}function Zl(e){return isObject(e)&&"jsonrpc"in e&&"method"in e}function xy(e){return Array.isArray(e)&&e.every(Zl)}function fS(e){let t=ou(Gn.post(en,async({request:n})=>{let o=await n.clone().json();if(Zl(o)){let r=e(o);return r?cn.json(r):ln()}if(xy(o)){let r=o.map(a=>e(a));return r.some(a=>a===void 0)?ln():cn.json(r)}invariant(false,"body is not a valid JSON-RPC request or batch");}),Gn.post(en,()=>ln()));return ar(()=>{t.listen();}),ir(()=>{t.close();}),t}function dS(e){let t=createPublicClient({transport:http(en)});async function n(o,r){return t.request({method:o,params:r??[]})}return {async request(o){let r=await e(o);if(r!==void 0){if("error"in r)throw r.error;return r.result}return n(o.method,o.params)}}}/*! Bundled license information:
45
45
 
46
46
  @bundled-es-modules/statuses/index-esm.js:
47
47
  (*! Bundled license information: