@aave/client 4.0.0-next.45 → 4.0.0-next.47

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.
@@ -1,7 +1,6 @@
1
1
  import { GqlClient, TimeoutError, UnexpectedError } from '@aave/core';
2
2
  import { HasProcessedKnownTransactionRequest } from '@aave/graphql';
3
3
  import { ResultAsync } from '@aave/types';
4
- import { TypedDocumentNode } from '@urql/core';
5
4
  import { T as TransactionResult, c as TransactionReceipt } from './types-BzGr7R2Y.cjs';
6
5
 
7
6
  /**
@@ -48,12 +47,6 @@ type ClientConfig = {
48
47
  * @defaultValue `false`
49
48
  */
50
49
  debug?: boolean;
51
- /**
52
- * The custom fragments to use.
53
- *
54
- * @experimental This is an experimental API and may be subject to breaking changes.
55
- */
56
- fragments?: TypedDocumentNode[];
57
50
  };
58
51
 
59
52
  declare class AaveClient extends GqlClient {
@@ -1,7 +1,6 @@
1
1
  import { GqlClient, TimeoutError, UnexpectedError } from '@aave/core';
2
2
  import { HasProcessedKnownTransactionRequest } from '@aave/graphql';
3
3
  import { ResultAsync } from '@aave/types';
4
- import { TypedDocumentNode } from '@urql/core';
5
4
  import { T as TransactionResult, c as TransactionReceipt } from './types-BzGr7R2Y.js';
6
5
 
7
6
  /**
@@ -48,12 +47,6 @@ type ClientConfig = {
48
47
  * @defaultValue `false`
49
48
  */
50
49
  debug?: boolean;
51
- /**
52
- * The custom fragments to use.
53
- *
54
- * @experimental This is an experimental API and may be subject to breaking changes.
55
- */
56
- fragments?: TypedDocumentNode[];
57
50
  };
58
51
 
59
52
  declare class AaveClient extends GqlClient {
@@ -1,10 +1,10 @@
1
1
  import { UnexpectedError, ValidationError, TimeoutError } from '@aave/core';
2
2
  import { HubRequest, Hub, HubsRequest, HubAssetsRequest, HubAsset, HubSummaryHistoryRequest, HubSummarySample, ChainRequest, Chain, ChainsRequest, HasProcessedKnownTransactionRequest, ExchangeRateRequest, ExchangeAmount, AssetRequest, Asset, AssetPriceHistoryRequest, AssetPriceSample, AssetSupplyHistoryRequest, AssetSupplySample, AssetBorrowHistoryRequest, AssetBorrowSample, ProtocolHistoryRequest, ProtocolHistorySample, ReserveRequest, Reserve, ReservesRequest, BorrowApyHistoryRequest, ApySample, SupplyApyHistoryRequest, UserClaimableRewardsRequest, UserClaimableReward, SpokeRequest, Spoke, SpokesRequest, SpokePositionManagersRequest, PaginatedSpokePositionManagerResult, SpokeUserPositionManagersRequest, PaginatedSpokeUserPositionManagerResult, TokenSwapQuoteRequest, TokenSwapQuoteResult, InsufficientLiquidityError, SwappableTokensRequest, Token, PrepareTokenSwapRequest, PrepareSwapOrder, InsufficientBalanceError, SupplySwapQuoteRequest, PositionSwapByIntentApprovalsRequired, BorrowSwapQuoteRequest, RepayWithSupplyQuoteRequest, WithdrawSwapQuoteRequest, PreparePositionSwapRequest, SwapStatusRequest, SwapStatus, SwapCancelled, SwapExpired, SwapFulfilled, SwapReceipt, SwapRequest, SwapTransactionRequest, PrepareSwapCancelRequest, PrepareSwapCancelResult, CancelSwapRequest, CancelSwapExecutionPlan, UserSwapsRequest, PaginatedUserSwapsResult, BorrowRequest, ExecutionPlan, SupplyRequest, RepayRequest, WithdrawRequest, RenounceSpokeUserPositionManagerRequest, TransactionRequest, UpdateUserPositionConditionsRequest, LiquidatePositionRequest, SetSpokeUserPositionManagerRequest, PreviewRequest, PreviewUserPosition, SetUserSuppliesAsCollateralRequest, ClaimRewardsRequest, ActivitiesRequest, PaginatedActivitiesResult, UserSuppliesRequest, UserSupplyItem, UserBorrowsRequest, UserBorrowItem, UserSummaryRequest, UserSummary, UserPositionsRequest, UserPosition, UserPositionRequest, UserBalancesRequest, UserBalance, UserSummaryHistoryRequest, UserSummaryHistoryItem, UserRiskPremiumBreakdownRequest, UserRiskPremiumBreakdownItem } from '@aave/graphql';
3
3
  import { ResultAsync, Prettify } from '@aave/types';
4
- import { A as AaveClient } from '../AaveClient-DaBi3jFp.cjs';
4
+ import { A as AaveClient } from '../AaveClient-CGksa0-v.cjs';
5
5
  import { C as CurrencyQueryOptions, T as TimeWindowQueryOptions, R as RequestPolicyOptions, B as BatchOptions } from '../options-BX6n3sbh.cjs';
6
- import '@urql/core';
7
6
  import '../types-BzGr7R2Y.cjs';
7
+ import '@urql/core';
8
8
 
9
9
  /**
10
10
  * Fetches a specific hub by ID or by address and chain ID.
@@ -1,10 +1,10 @@
1
1
  import { UnexpectedError, ValidationError, TimeoutError } from '@aave/core';
2
2
  import { HubRequest, Hub, HubsRequest, HubAssetsRequest, HubAsset, HubSummaryHistoryRequest, HubSummarySample, ChainRequest, Chain, ChainsRequest, HasProcessedKnownTransactionRequest, ExchangeRateRequest, ExchangeAmount, AssetRequest, Asset, AssetPriceHistoryRequest, AssetPriceSample, AssetSupplyHistoryRequest, AssetSupplySample, AssetBorrowHistoryRequest, AssetBorrowSample, ProtocolHistoryRequest, ProtocolHistorySample, ReserveRequest, Reserve, ReservesRequest, BorrowApyHistoryRequest, ApySample, SupplyApyHistoryRequest, UserClaimableRewardsRequest, UserClaimableReward, SpokeRequest, Spoke, SpokesRequest, SpokePositionManagersRequest, PaginatedSpokePositionManagerResult, SpokeUserPositionManagersRequest, PaginatedSpokeUserPositionManagerResult, TokenSwapQuoteRequest, TokenSwapQuoteResult, InsufficientLiquidityError, SwappableTokensRequest, Token, PrepareTokenSwapRequest, PrepareSwapOrder, InsufficientBalanceError, SupplySwapQuoteRequest, PositionSwapByIntentApprovalsRequired, BorrowSwapQuoteRequest, RepayWithSupplyQuoteRequest, WithdrawSwapQuoteRequest, PreparePositionSwapRequest, SwapStatusRequest, SwapStatus, SwapCancelled, SwapExpired, SwapFulfilled, SwapReceipt, SwapRequest, SwapTransactionRequest, PrepareSwapCancelRequest, PrepareSwapCancelResult, CancelSwapRequest, CancelSwapExecutionPlan, UserSwapsRequest, PaginatedUserSwapsResult, BorrowRequest, ExecutionPlan, SupplyRequest, RepayRequest, WithdrawRequest, RenounceSpokeUserPositionManagerRequest, TransactionRequest, UpdateUserPositionConditionsRequest, LiquidatePositionRequest, SetSpokeUserPositionManagerRequest, PreviewRequest, PreviewUserPosition, SetUserSuppliesAsCollateralRequest, ClaimRewardsRequest, ActivitiesRequest, PaginatedActivitiesResult, UserSuppliesRequest, UserSupplyItem, UserBorrowsRequest, UserBorrowItem, UserSummaryRequest, UserSummary, UserPositionsRequest, UserPosition, UserPositionRequest, UserBalancesRequest, UserBalance, UserSummaryHistoryRequest, UserSummaryHistoryItem, UserRiskPremiumBreakdownRequest, UserRiskPremiumBreakdownItem } from '@aave/graphql';
3
3
  import { ResultAsync, Prettify } from '@aave/types';
4
- import { A as AaveClient } from '../AaveClient-DfMDhl-T.js';
4
+ import { A as AaveClient } from '../AaveClient-DpWiYPGY.js';
5
5
  import { C as CurrencyQueryOptions, T as TimeWindowQueryOptions, R as RequestPolicyOptions, B as BatchOptions } from '../options-BX6n3sbh.js';
6
- import '@urql/core';
7
6
  import '../types-BzGr7R2Y.js';
7
+ import '@urql/core';
8
8
 
9
9
  /**
10
10
  * Fetches a specific hub by ID or by address and chain ID.
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'),_=require('@aave/graphql/schema'),exchangeGraphcache=require('@urql/exchange-graphcache');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ___default=/*#__PURE__*/_interopDefault(_);var L={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function f(e,r){return e.query(graphql.HasProcessedKnownTransactionQuery,{request:r},{requestPolicy:"network-only",batch:false})}var m=(e,r,n,a)=>BigInt(e[a.fieldName]),l=(e,r,n,a)=>types.BigDecimal.new(e[a.fieldName]),s=(e,r,n,a)=>{let i=e[a.fieldName];return i==null?null:l(e,r,n,a)},t=(e,r,n,a)=>new Date(e[a.fieldName]),d=(e,r,n,a)=>{let i=e[a.fieldName];return i==null?null:t(e,r,n,a)},S=exchangeGraphcache.cacheExchange({schema:___default.default,resolvers:{PercentNumber:{onChainValue:m,value:l,normalized:l},DecimalNumber:{onChainValue:m,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:t},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:t},TransactionRequest:{value:m},ApySample:{date:t},AssetBorrowSample:{date:t},AssetSupplySample:{date:t},HubSummarySample:{date:t},PreviewMerklBorrowReward:{startDate:t,endDate:t},PreviewMerklSupplyReward:{startDate:t,endDate:t},ProtocolHistorySample:{date:t},BorrowActivity:{timestamp:t},LiquidatedActivity:{timestamp:t},MerklBorrowReward:{startDate:t,endDate:t},MerklSupplyReward:{startDate:t,endDate:t},RepayActivity:{timestamp:t},SupplyActivity:{timestamp:t},WithdrawActivity:{timestamp:t},UsingAsCollateralActivity:{timestamp:t},UpdatedDynamicConfigActivity:{timestamp:t},UpdatedRiskPremiumActivity:{timestamp:t},TokenSwapActivity:{timestamp:t},SupplySwapActivity:{timestamp:t},BorrowSwapActivity:{timestamp:t},RepayWithSupplyActivity:{timestamp:t},WithdrawSwapActivity:{timestamp:t},UserMerklClaimableReward:{startDate:t,endDate:t,claimUntil:t},UserPosition:{createdAt:t},UserBorrowItem:{createdAt:d},UserSupplyItem:{createdAt:d},SpokeUserPositionManager:{approvedOn:t},SwapCancelled:{createdAt:t,cancelledAt:d},SwapCancelledResult:{createdAt:t,cancelledAt:d},SwapExpired:{createdAt:t,expiredAt:t},SwapFulfilled:{createdAt:t,fulfilledAt:t},SwapOpen:{createdAt:t,deadline:t},SwapPendingSignature:{createdAt:t,deadline:t},SwapReceipt:{createdAt:t},Query:{hub:(e,{request:r})=>graphql.isHubInputVariant(r.query)?{__typename:"Hub",id:graphql.encodeHubId(r.query.hubInput)}:{__typename:"Hub",id:r.query.hubId},reserve:(e,{request:r})=>graphql.isReserveInputVariant(r.query)?{__typename:"Reserve",id:graphql.encodeReserveId(r.query.reserveInput)}:{__typename:"Reserve",id:r.query.reserveId},userPosition:(e,{request:r})=>{if("userSpoke"in r&&r.userSpoke){let{chainId:n,address:a}=graphql.decodeSpokeId(r.userSpoke.spoke);return {__typename:"UserPosition",id:graphql.encodeUserPositionId({chainId:n,spoke:a,user:r.userSpoke.user})}}if("id"in r&&r.id)return {__typename:"UserPosition",id:r.id}},activities:(e,r,n)=>{if(!graphql.isTxHashInputVariant(r.request.query))return n.resolve("Query","activities",r);let{txHash:a,chainId:i}=r.request.query.txHash,c=n.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,w)=>{let p=n.resolve("Query",w.fieldKey);if(!p)return o;let u=n.resolve(p,"items");if(!u)return o;for(let y of u)o.add(y);return o},new Set).values().toArray().filter(o=>{if(n.resolve(o,"txHash")!==a)return false;let p=n.resolve(o,"spoke");if(p){let u=n.resolve(p,"chain"),y=u?n.resolve(u,"chainId"):void 0;if(typeof y=="number")return y===i}return true});if(c.length!==0)return {__typename:"PaginatedActivitiesResult",items:c,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,BorrowSwapActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,MerklBorrowReward:e=>e.id,MerklGenericCriteria:e=>e.id,MerklSupplyReward:e=>e.id,RepayActivity:e=>e.id,RepayWithSupplyActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,SupplySwapActivity:e=>e.id,TokenInfo:e=>e.id,TokenSwapActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,UserMerklClaimableReward:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,WithdrawSwapActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,BorrowSwap:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSampleBreakdown:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,CollateralFactorVariation:()=>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,InsufficientLiquidityError:()=>null,LiquidationFeeVariation:()=>null,MaxLiquidationBonusVariation:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionAmount:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewMerklBorrowReward:()=>null,PreviewMerklSupplyReward:()=>null,PreviewRewardOutcome:()=>null,PreviewUserPosition:()=>null,RepayWithSupply:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManager:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwap:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapCancelledResult:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwap:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwap:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var A={name:"production",backend:"https://api.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},ne={name:"staging",backend:"https://api.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},ae={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function h({environment:e=A,headers:r,cache:n=true,batch:a=true,debug:i=false,fragments:c=[]}){return {displayName:"AaveClient",environment:e,headers:r,cache:n?S:null,batch:a,debug:i,fragments:c}}function R(e){return e.operations!==null&&e.operations.length>0}function v(e){return {__typename:"TransactionReceipt",txHash:e}}var x=class e extends core.GqlClient{static create(r){return new e(h(r??{}))}waitForTransaction=r=>(types.invariant(R(r),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),types.ResultAsync.fromPromise(this.pollTransactionStatus(r),n=>n instanceof core.TimeoutError||n instanceof core.UnexpectedError?n:core.UnexpectedError.from(n)));async pollTransactionStatus(r){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await f(this,r).match(i=>i,i=>{throw i}))return v(r.txHash);await core.delay(this.context.environment.pollingInterval);}throw core.TimeoutError.from(`Timeout waiting for transaction ${r.txHash} to be processed.`)}};function F(e){return typeof e=="object"&&e!==null&&"approvals"in e&&Array.isArray(e.approvals)}function fe(e){return F(e)&&types.isOneEntryArray(e.approvals)&&!!e.approvals[0].bySignature}
2
- exports.AaveClient=x;exports.DEFAULT_QUERY_OPTIONS=L;exports.local=ae;exports.production=A;exports.staging=ne;exports.supportsPermit=fe;exports.transactionReceipt=v;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
1
+ 'use strict';var core=require('@aave/core'),graphql=require('@aave/graphql'),types=require('@aave/types'),D=require('@aave/graphql/schema'),exchangeGraphcache=require('@urql/exchange-graphcache');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var D__default=/*#__PURE__*/_interopDefault(D);var L={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function S(e,r){return e.query(graphql.HasProcessedKnownTransactionQuery,{request:r},{requestPolicy:"network-only",batch:false})}var d=(e,r,n,a)=>BigInt(e[a.fieldName]),l=(e,r,n,a)=>types.BigDecimal.new(e[a.fieldName]),s=(e,r,n,a)=>{let i=e[a.fieldName];return i==null?null:l(e,r,n,a)},t=(e,r,n,a)=>new Date(e[a.fieldName]),y=(e,r,n,a)=>{let i=e[a.fieldName];return i==null?null:t(e,r,n,a)},f=exchangeGraphcache.cacheExchange({schema:D__default.default,resolvers:{PercentNumber:{onChainValue:d,value:l,normalized:l},DecimalNumber:{onChainValue:d,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:t},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:t},TransactionRequest:{value:d},ApySample:{date:t},AssetBorrowSample:{date:t},AssetSupplySample:{date:t},HubSummarySample:{date:t},PreviewMerklBorrowReward:{startDate:t,endDate:t},PreviewMerklSupplyReward:{startDate:t,endDate:t},ProtocolHistorySample:{date:t},BorrowActivity:{timestamp:t},LiquidatedActivity:{timestamp:t},MerklBorrowReward:{startDate:t,endDate:t},MerklSupplyReward:{startDate:t,endDate:t},RepayActivity:{timestamp:t},SupplyActivity:{timestamp:t},WithdrawActivity:{timestamp:t},UsingAsCollateralActivity:{timestamp:t},UpdatedDynamicConfigActivity:{timestamp:t},UpdatedRiskPremiumActivity:{timestamp:t},TokenSwapActivity:{timestamp:t},SupplySwapActivity:{timestamp:t},BorrowSwapActivity:{timestamp:t},RepayWithSupplyActivity:{timestamp:t},WithdrawSwapActivity:{timestamp:t},UserMerklClaimableReward:{startDate:t,endDate:t,claimUntil:t},UserPosition:{createdAt:t},UserBorrowItem:{createdAt:y},UserSupplyItem:{createdAt:y},SpokeUserPositionManager:{approvedOn:t},SwapCancelled:{createdAt:t,cancelledAt:y},SwapCancelledResult:{createdAt:t,cancelledAt:y},SwapExpired:{createdAt:t,expiredAt:t},SwapFulfilled:{createdAt:t,fulfilledAt:t},SwapOpen:{createdAt:t,deadline:t},SwapPendingSignature:{createdAt:t,deadline:t},SwapReceipt:{createdAt:t},Query:{hub:(e,{request:r})=>graphql.isHubInputVariant(r.query)?{__typename:"Hub",id:graphql.encodeHubId(r.query.hubInput)}:{__typename:"Hub",id:r.query.hubId},reserve:(e,{request:r})=>graphql.isReserveInputVariant(r.query)?{__typename:"Reserve",id:graphql.encodeReserveId(r.query.reserveInput)}:{__typename:"Reserve",id:r.query.reserveId},userPosition:(e,{request:r})=>{if("userSpoke"in r&&r.userSpoke){let{chainId:n,address:a}=graphql.decodeSpokeId(r.userSpoke.spoke);return {__typename:"UserPosition",id:graphql.encodeUserPositionId({chainId:n,spoke:a,user:r.userSpoke.user})}}if("id"in r&&r.id)return {__typename:"UserPosition",id:r.id}},activities:(e,r,n)=>{if(!graphql.isTxHashInputVariant(r.request.query))return n.resolve("Query","activities",r);let{txHash:a,chainId:i}=r.request.query.txHash,v=n.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,w)=>{let p=n.resolve("Query",w.fieldKey);if(!p)return o;let u=n.resolve(p,"items");if(!u)return o;for(let c of u)o.add(c);return o},new Set).values().toArray().filter(o=>{if(n.resolve(o,"txHash")!==a)return false;let p=n.resolve(o,"spoke");if(p){let u=n.resolve(p,"chain"),c=u?n.resolve(u,"chainId"):void 0;if(typeof c=="number")return c===i}return true});if(v.length!==0)return {__typename:"PaginatedActivitiesResult",items:v,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,BorrowSwapActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,MerklBorrowReward:e=>e.id,MerklGenericCriteria:e=>e.id,MerklSupplyReward:e=>e.id,RepayActivity:e=>e.id,RepayWithSupplyActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,SupplySwapActivity:e=>e.id,TokenInfo:e=>e.id,TokenSwapActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,UserMerklClaimableReward:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,WithdrawSwapActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,BorrowSwap:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSampleBreakdown:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,CollateralFactorVariation:()=>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,InsufficientLiquidityError:()=>null,LiquidationFeeVariation:()=>null,MaxLiquidationBonusVariation:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionAmount:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewMerklBorrowReward:()=>null,PreviewMerklSupplyReward:()=>null,PreviewRewardOutcome:()=>null,PreviewUserPosition:()=>null,RepayWithSupply:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManager:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwap:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapCancelledResult:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwap:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwap:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var A={name:"production",backend:"https://api.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},ne={name:"staging",backend:"https://api.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},ae={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function h({environment:e=A,headers:r,cache:n=true,batch:a=true,debug:i=false}){return {displayName:"AaveClient",environment:e,headers:r,cache:n?f:null,batch:a,debug:i}}function R(e){return e.operations!==null&&e.operations.length>0}function m(e){return {__typename:"TransactionReceipt",txHash:e}}var T=class e extends core.GqlClient{static create(r){return new e(h(r??{}))}waitForTransaction=r=>(types.invariant(R(r),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),types.ResultAsync.fromPromise(this.pollTransactionStatus(r),n=>n instanceof core.TimeoutError||n instanceof core.UnexpectedError?n:core.UnexpectedError.from(n)));async pollTransactionStatus(r){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await S(this,r).match(i=>i,i=>{throw i}))return m(r.txHash);await core.delay(this.context.environment.pollingInterval);}throw core.TimeoutError.from(`Timeout waiting for transaction ${r.txHash} to be processed.`)}};function F(e){return typeof e=="object"&&e!==null&&"approvals"in e&&Array.isArray(e.approvals)}function Se(e){return F(e)&&types.isOneEntryArray(e.approvals)&&!!e.approvals[0].bySignature}
2
+ exports.AaveClient=T;exports.DEFAULT_QUERY_OPTIONS=L;exports.local=ae;exports.production=A;exports.staging=ne;exports.supportsPermit=Se;exports.transactionReceipt=m;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","../src/adapters.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","isReserveInputVariant","encodeReserveId","chainId","address","decodeSpokeId","encodeUserPositionId","_parent","args","cache","isTxHashInputVariant","txHash","matches","f","set","pageRef","itemRefs","ref","spokeRef","chainRef","itemChainId","data","production","staging","local","configureContext","environment","headers","batch","debug","fragments","isHasProcessedKnownTransactionRequest","result","transactionReceipt","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","startedAt","ok","delay","hasApprovals","plan","supportsPermit","isOneEntryArray"],"mappings":"wTA+CaA,CAAAA,CAAwB,CACnC,QAAA,CAAUC,gBAAAA,CAAS,IACnB,UAAA,CAAYC,kBAAAA,CAAW,QACvB,aAAA,CAAe,mBAAA,CACf,MAAO,IACT,EC2BO,SAASC,CAAAA,CACdC,CAAAA,CACAC,EACuC,CACvC,OAAOD,EAAO,KAAA,CACZE,yCAAAA,CACA,CAAE,OAAA,CAAAD,CAAQ,CAAA,CACV,CACE,cAAe,cAAA,CACf,KAAA,CAAO,KACT,CACF,CACF,CCzCA,IAAME,EAA8B,CAACC,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAAA,GACnD,MAAA,CAAOH,CAAAA,CAAOG,EAAK,SAAS,CAAW,EAG1CC,CAAAA,CAAkC,CAACJ,EAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACvDE,gBAAAA,CAAW,IAAIL,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAW,CAAA,CAGlDG,EAA0C,CAC9CN,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,IACG,CACH,IAAMI,EAAQP,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAA,CACnC,OAAII,CAAAA,EAAU,IAAA,CACL,KAEFH,CAAAA,CAAsBJ,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAI,CAC1D,CAAA,CAEMK,CAAAA,CAA4B,CAACR,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAAA,GACjD,IAAI,IAAA,CAAKH,CAAAA,CAAOG,EAAK,SAAS,CAAW,CAAA,CAG5CM,CAAAA,CAAoC,CAACT,CAAAA,CAAQC,CAAAA,CAAOC,EAAQC,CAAAA,GAAS,CACzE,IAAMI,CAAAA,CAAQP,CAAAA,CAAOG,CAAAA,CA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AAiB,CAQxE,GAPkB,MAAM/D,CAAAA,CAA6B,IAAA,CAAME,CAAO,EAAE,KAAA,CACjE8D,CAAAA,EAAOA,EACPJ,CAAAA,EAAQ,CACP,MAAMA,CACR,CACF,CAAA,CAGE,OAAOP,EAAmBnD,CAAAA,CAAQ,MAAM,EAG1C,MAAM+D,UAAAA,CAAM,KAAK,OAAA,CAAQ,WAAA,CAAY,eAAe,EACtD,CACA,MAAMJ,iBAAAA,CAAa,KACjB,CAAA,gCAAA,EAAmC3D,CAAAA,CAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF,EC3EA,SAASgE,CAAAA,CAAaC,EAAsC,CAC1D,OACE,OAAOA,CAAAA,EAAS,UAChBA,CAAAA,GAAS,IAAA,EACT,cAAeA,CAAAA,EACf,KAAA,CAAM,QAAQA,CAAAA,CAAK,SAAS,CAEhC,CASO,SAASC,EAAAA,CAAkBD,CAAAA,CAG9B,CACF,OACED,CAAAA,CAAaC,CAAI,CAAA,EACjBE,qBAAAA,CAAgBF,CAAAA,CAAK,SAAS,GAC9B,CAAC,CAACA,EAAK,SAAA,CAAU,CAAC,EAAE,WAExB","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 {\n type BatchOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n} from '../options';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @param options - The query options.\n * @returns The chain data, or null if not found.\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n {\n batch = DEFAULT_QUERY_OPTIONS.batch,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: BatchOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch, requestPolicy });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { filter: ChainsFilter.ALL }\n * });\n * ```\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { chainIds: [chainId(1), chainId(137)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chains request parameters.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n request: ChainsRequest,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { request });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @param options - The query options.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<ExchangeAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request }, { requestPolicy });\n}\n","import {\n type ActivitiesQuery,\n type Asset,\n type BorrowActivity,\n type BorrowSwapActivity,\n type Chain,\n decodeSpokeId,\n type Erc20Token,\n encodeHubId,\n encodeReserveId,\n encodeUserPositionId,\n type Hub,\n type HubAsset,\n type HubQuery,\n isHubInputVariant,\n isReserveInputVariant,\n isTxHashInputVariant,\n type LiquidatedActivity,\n type MerklBorrowReward,\n type MerklGenericCriteria,\n type MerklSupplyReward,\n type NativeToken,\n type RepayActivity,\n type RepayWithSupplyActivity,\n type Reserve,\n type ReserveInfo,\n type ReserveQuery,\n type Spoke,\n type SupplyActivity,\n type SupplySwapActivity,\n type TokenInfo,\n type TokenSwapActivity,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\n type UserMerklClaimableReward,\n type UserPosition,\n type UserPositionQuery,\n type UsingAsCollateralActivity,\n type VariablesOf,\n type WithdrawActivity,\n type WithdrawSwapActivity,\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 PreviewMerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n PreviewMerklSupplyReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n ProtocolHistorySample: {\n date: transformToDate,\n },\n BorrowActivity: {\n timestamp: transformToDate,\n },\n LiquidatedActivity: {\n timestamp: transformToDate,\n },\n MerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n MerklSupplyReward: {\n startDate: transformToDate,\n endDate: 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 TokenSwapActivity: {\n timestamp: transformToDate,\n },\n SupplySwapActivity: {\n timestamp: transformToDate,\n },\n BorrowSwapActivity: {\n timestamp: transformToDate,\n },\n RepayWithSupplyActivity: {\n timestamp: transformToDate,\n },\n WithdrawSwapActivity: {\n timestamp: transformToDate,\n },\n UserMerklClaimableReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n claimUntil: transformToDate,\n },\n UserPosition: {\n createdAt: transformToDate,\n },\n UserBorrowItem: {\n createdAt: transformToNullableDate,\n },\n UserSupplyItem: {\n createdAt: transformToNullableDate,\n },\n SpokeUserPositionManager: {\n approvedOn: transformToDate,\n },\n SwapCancelled: {\n createdAt: transformToDate,\n cancelledAt: transformToNullableDate,\n },\n SwapCancelledResult: {\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 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 reserve: (_, { request }: VariablesOf<typeof ReserveQuery>) => {\n if (isReserveInputVariant(request.query)) {\n return {\n __typename: 'Reserve',\n id: encodeReserveId(request.query.reserveInput),\n };\n }\n return {\n __typename: 'Reserve',\n id: request.query.reserveId,\n };\n },\n\n userPosition: (_, { request }: VariablesOf<typeof UserPositionQuery>) => {\n if ('userSpoke' in request && request.userSpoke) {\n const { chainId, address } = decodeSpokeId(request.userSpoke.spoke);\n return {\n __typename: 'UserPosition',\n id: encodeUserPositionId({\n chainId,\n spoke: address,\n user: request.userSpoke.user,\n }),\n };\n }\n if ('id' in request && request.id) {\n return {\n __typename: 'UserPosition',\n id: request.id,\n };\n }\n return undefined;\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 BorrowSwapActivity: (data: BorrowSwapActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n MerklBorrowReward: (data: MerklBorrowReward) => data.id,\n MerklGenericCriteria: (data: MerklGenericCriteria) => data.id,\n MerklSupplyReward: (data: MerklSupplyReward) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n RepayWithSupplyActivity: (data: RepayWithSupplyActivity) => 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 SupplySwapActivity: (data: SupplySwapActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n TokenSwapActivity: (data: TokenSwapActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => data.id,\n UserMerklClaimableReward: (data: UserMerklClaimableReward) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n WithdrawSwapActivity: (data: WithdrawSwapActivity) => 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 BorrowSwap: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSampleBreakdown: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n CollateralFactorVariation: () => 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 InsufficientLiquidityError: () => null,\n LiquidationFeeVariation: () => null,\n MaxLiquidationBonusVariation: () => 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 PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionAmount: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewMerklBorrowReward: () => null,\n PreviewMerklSupplyReward: () => null,\n PreviewRewardOutcome: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupply: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManager: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwap: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapCancelledResult: () => 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 TokenSwap: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwap: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => 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.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.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 query batching.\n *\n * @defaultValue `true`\n */\n batch?: 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 batch = true,\n debug = false,\n fragments = [],\n}: ClientConfig): Context {\n return {\n displayName: 'AaveClient',\n environment,\n headers,\n cache: cache ? exchange : null,\n batch,\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 TransactionReceipt = {\n __typename: 'TransactionReceipt';\n txHash: TxHash;\n};\n\n/**\n * @internal\n */\nexport function transactionReceipt(txHash: TxHash): TransactionReceipt {\n return { __typename: 'TransactionReceipt', txHash };\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 { delay, GqlClient, TimeoutError, UnexpectedError } from '@aave/core';\nimport type { HasProcessedKnownTransactionRequest } from '@aave/graphql';\nimport { invariant, ResultAsync } from '@aave/types';\nimport { hasProcessedKnownTransaction } from './actions';\nimport { type ClientConfig, configureContext } from './config';\nimport {\n isHasProcessedKnownTransactionRequest,\n type TransactionReceipt,\n type TransactionResult,\n transactionReceipt,\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 {@link TransactionReceipt} or a error\n */\n readonly waitForTransaction = (\n result: TransactionResult,\n ): ResultAsync<TransactionReceipt, 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 protected async pollTransactionStatus(\n request: HasProcessedKnownTransactionRequest,\n ): Promise<TransactionReceipt> {\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 transactionReceipt(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","import type { Erc20Approval, PermitTypedData } from '@aave/graphql';\nimport { isOneEntryArray } from '@aave/types';\n\ntype WithApprovals = { approvals: Erc20Approval[] };\n\nfunction hasApprovals(plan: unknown): plan is WithApprovals {\n return (\n typeof plan === 'object' &&\n plan !== null &&\n 'approvals' in plan &&\n Array.isArray(plan.approvals)\n );\n}\n\n/**\n * Checks if a plan supports permit (single approval with bySignature).\n * Works with union types - picks any member that has an `approvals` array\n * with a single entry containing `bySignature`.\n *\n * @internal\n */\nexport function supportsPermit<T>(plan: T): plan is T &\n Extract<T, WithApprovals> & {\n approvals: [Erc20Approval & { bySignature: PermitTypedData }];\n } {\n return (\n hasApprovals(plan) &&\n isOneEntryArray(plan.approvals) &&\n !!plan.approvals[0].bySignature\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","../src/adapters.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","isReserveInputVariant","encodeReserveId","chainId","address","decodeSpokeId","encodeUserPositionId","_parent","args","cache","isTxHashInputVariant","txHash","matches","f","set","pageRef","itemRefs","ref","spokeRef","chainRef","itemChainId","data","production","staging","local","configureContext","environment","headers","batch","debug","isHasProcessedKnownTransactionRequest","result","transactionReceipt","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","startedAt","ok","delay","hasApprovals","plan","supportsPermit","isOneEntryArray"],"mappings":"wTA+CaA,CAAAA,CAAwB,CACnC,QAAA,CAAUC,gBAAAA,CAAS,IACnB,UAAA,CAAYC,kBAAAA,CAAW,QACvB,aAAA,CAAe,mBAAA,CACf,MAAO,IACT,EC2BO,SAASC,CAAAA,CACdC,CAAAA,CACAC,EACuC,CACvC,OAAOD,EAAO,KAAA,CACZE,yCAAAA,CACA,CAAE,OAAA,CAAAD,CAAQ,CAAA,CACV,CACE,cAAe,cAAA,CACf,KAAA,CAAO,KACT,CACF,CACF,CCzCA,IAAME,EAA8B,CAACC,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAAA,GACnD,MAAA,CAAOH,CAAAA,CAAOG,EAAK,SAAS,CAAW,EAG1CC,CAAAA,CAAkC,CAACJ,EAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACvDE,gBAAAA,CAAW,IAAIL,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAW,CAAA,CAGlDG,EAA0C,CAC9CN,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,IACG,CACH,IAAMI,EAAQP,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAA,CACnC,OAAII,CAAAA,EAAU,IAAA,CACL,KAEFH,CAAAA,CAAsBJ,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAI,CAC1D,CAAA,CAEMK,CAAAA,CAA4B,CAACR,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAAA,GACjD,IAAI,IAAA,CAAKH,CAAAA,CAAOG,EAAK,SAAS,CAAW,CAAA,CAG5CM,CAAAA,CAAoC,CAACT,CAAAA,CAAQC,CAAAA,CAAOC,EAAQC,CAAAA,GAAS,CACzE,IAAMI,CAAAA,CAAQP,CAAAA,CAAOG,CAAAA,C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AiB,CAQxE,GAPkB,MAAM9D,CAAAA,CAA6B,IAAA,CAAME,CAAO,EAAE,KAAA,CACjE6D,CAAAA,EAAOA,EACPJ,CAAAA,EAAQ,CACP,MAAMA,CACR,CACF,CAAA,CAGE,OAAOP,EAAmBlD,CAAAA,CAAQ,MAAM,EAG1C,MAAM8D,UAAAA,CAAM,KAAK,OAAA,CAAQ,WAAA,CAAY,eAAe,EACtD,CACA,MAAMJ,iBAAAA,CAAa,KACjB,CAAA,gCAAA,EAAmC1D,CAAAA,CAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF,EC3EA,SAAS+D,CAAAA,CAAaC,EAAsC,CAC1D,OACE,OAAOA,CAAAA,EAAS,UAChBA,CAAAA,GAAS,IAAA,EACT,cAAeA,CAAAA,EACf,KAAA,CAAM,QAAQA,CAAAA,CAAK,SAAS,CAEhC,CASO,SAASC,EAAAA,CAAkBD,CAAAA,CAG9B,CACF,OACED,CAAAA,CAAaC,CAAI,CAAA,EACjBE,qBAAAA,CAAgBF,CAAAA,CAAK,SAAS,GAC9B,CAAC,CAACA,EAAK,SAAA,CAAU,CAAC,EAAE,WAExB","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 {\n type BatchOptions,\n DEFAULT_QUERY_OPTIONS,\n type RequestPolicyOptions,\n} from '../options';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @param options - The query options.\n * @returns The chain data, or null if not found.\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n {\n batch = DEFAULT_QUERY_OPTIONS.batch,\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: BatchOptions & RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch, requestPolicy });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { filter: ChainsFilter.ALL }\n * });\n * ```\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { chainIds: [chainId(1), chainId(137)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chains request parameters.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n request: ChainsRequest,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { request });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @param options - The query options.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n {\n requestPolicy = DEFAULT_QUERY_OPTIONS.requestPolicy,\n }: RequestPolicyOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<ExchangeAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request }, { requestPolicy });\n}\n","import {\n type ActivitiesQuery,\n type Asset,\n type BorrowActivity,\n type BorrowSwapActivity,\n type Chain,\n decodeSpokeId,\n type Erc20Token,\n encodeHubId,\n encodeReserveId,\n encodeUserPositionId,\n type Hub,\n type HubAsset,\n type HubQuery,\n isHubInputVariant,\n isReserveInputVariant,\n isTxHashInputVariant,\n type LiquidatedActivity,\n type MerklBorrowReward,\n type MerklGenericCriteria,\n type MerklSupplyReward,\n type NativeToken,\n type RepayActivity,\n type RepayWithSupplyActivity,\n type Reserve,\n type ReserveInfo,\n type ReserveQuery,\n type Spoke,\n type SupplyActivity,\n type SupplySwapActivity,\n type TokenInfo,\n type TokenSwapActivity,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\n type UserMerklClaimableReward,\n type UserPosition,\n type UserPositionQuery,\n type UsingAsCollateralActivity,\n type VariablesOf,\n type WithdrawActivity,\n type WithdrawSwapActivity,\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 PreviewMerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n PreviewMerklSupplyReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n ProtocolHistorySample: {\n date: transformToDate,\n },\n BorrowActivity: {\n timestamp: transformToDate,\n },\n LiquidatedActivity: {\n timestamp: transformToDate,\n },\n MerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n MerklSupplyReward: {\n startDate: transformToDate,\n endDate: 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 TokenSwapActivity: {\n timestamp: transformToDate,\n },\n SupplySwapActivity: {\n timestamp: transformToDate,\n },\n BorrowSwapActivity: {\n timestamp: transformToDate,\n },\n RepayWithSupplyActivity: {\n timestamp: transformToDate,\n },\n WithdrawSwapActivity: {\n timestamp: transformToDate,\n },\n UserMerklClaimableReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n claimUntil: transformToDate,\n },\n UserPosition: {\n createdAt: transformToDate,\n },\n UserBorrowItem: {\n createdAt: transformToNullableDate,\n },\n UserSupplyItem: {\n createdAt: transformToNullableDate,\n },\n SpokeUserPositionManager: {\n approvedOn: transformToDate,\n },\n SwapCancelled: {\n createdAt: transformToDate,\n cancelledAt: transformToNullableDate,\n },\n SwapCancelledResult: {\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 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 reserve: (_, { request }: VariablesOf<typeof ReserveQuery>) => {\n if (isReserveInputVariant(request.query)) {\n return {\n __typename: 'Reserve',\n id: encodeReserveId(request.query.reserveInput),\n };\n }\n return {\n __typename: 'Reserve',\n id: request.query.reserveId,\n };\n },\n\n userPosition: (_, { request }: VariablesOf<typeof UserPositionQuery>) => {\n if ('userSpoke' in request && request.userSpoke) {\n const { chainId, address } = decodeSpokeId(request.userSpoke.spoke);\n return {\n __typename: 'UserPosition',\n id: encodeUserPositionId({\n chainId,\n spoke: address,\n user: request.userSpoke.user,\n }),\n };\n }\n if ('id' in request && request.id) {\n return {\n __typename: 'UserPosition',\n id: request.id,\n };\n }\n return undefined;\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 BorrowSwapActivity: (data: BorrowSwapActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n MerklBorrowReward: (data: MerklBorrowReward) => data.id,\n MerklGenericCriteria: (data: MerklGenericCriteria) => data.id,\n MerklSupplyReward: (data: MerklSupplyReward) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n RepayWithSupplyActivity: (data: RepayWithSupplyActivity) => 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 SupplySwapActivity: (data: SupplySwapActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n TokenSwapActivity: (data: TokenSwapActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => data.id,\n UserMerklClaimableReward: (data: UserMerklClaimableReward) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n WithdrawSwapActivity: (data: WithdrawSwapActivity) => 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 BorrowSwap: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSampleBreakdown: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n CollateralFactorVariation: () => 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 InsufficientLiquidityError: () => null,\n LiquidationFeeVariation: () => null,\n MaxLiquidationBonusVariation: () => 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 PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionAmount: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewMerklBorrowReward: () => null,\n PreviewMerklSupplyReward: () => null,\n PreviewRewardOutcome: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupply: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManager: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwap: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapCancelledResult: () => 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 TokenSwap: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwap: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => 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.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.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 { 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 query batching.\n *\n * @defaultValue `true`\n */\n batch?: boolean;\n /**\n * Whether to enable debug mode.\n *\n * @defaultValue `false`\n */\n debug?: boolean;\n};\n\n/**\n * @internal\n */\nexport function configureContext({\n environment = production,\n headers,\n cache = true,\n batch = true,\n debug = false,\n}: ClientConfig): Context {\n return {\n displayName: 'AaveClient',\n environment,\n headers,\n cache: cache ? exchange : null,\n batch,\n debug,\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 TransactionReceipt = {\n __typename: 'TransactionReceipt';\n txHash: TxHash;\n};\n\n/**\n * @internal\n */\nexport function transactionReceipt(txHash: TxHash): TransactionReceipt {\n return { __typename: 'TransactionReceipt', txHash };\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 { delay, GqlClient, TimeoutError, UnexpectedError } from '@aave/core';\nimport type { HasProcessedKnownTransactionRequest } from '@aave/graphql';\nimport { invariant, ResultAsync } from '@aave/types';\nimport { hasProcessedKnownTransaction } from './actions';\nimport { type ClientConfig, configureContext } from './config';\nimport {\n isHasProcessedKnownTransactionRequest,\n type TransactionReceipt,\n type TransactionResult,\n transactionReceipt,\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 {@link TransactionReceipt} or a error\n */\n readonly waitForTransaction = (\n result: TransactionResult,\n ): ResultAsync<TransactionReceipt, 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 protected async pollTransactionStatus(\n request: HasProcessedKnownTransactionRequest,\n ): Promise<TransactionReceipt> {\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 transactionReceipt(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","import type { Erc20Approval, PermitTypedData } from '@aave/graphql';\nimport { isOneEntryArray } from '@aave/types';\n\ntype WithApprovals = { approvals: Erc20Approval[] };\n\nfunction hasApprovals(plan: unknown): plan is WithApprovals {\n return (\n typeof plan === 'object' &&\n plan !== null &&\n 'approvals' in plan &&\n Array.isArray(plan.approvals)\n );\n}\n\n/**\n * Checks if a plan supports permit (single approval with bySignature).\n * Works with union types - picks any member that has an `approvals` array\n * with a single entry containing `bySignature`.\n *\n * @internal\n */\nexport function supportsPermit<T>(plan: T): plan is T &\n Extract<T, WithApprovals> & {\n approvals: [Erc20Approval & { bySignature: PermitTypedData }];\n } {\n return (\n hasApprovals(plan) &&\n isOneEntryArray(plan.approvals) &&\n !!plan.approvals[0].bySignature\n );\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ export * from '@aave/core';
3
3
  import { Erc20Approval, PermitTypedData } from '@aave/graphql';
4
4
  export * from '@aave/graphql';
5
5
  export * from '@aave/types';
6
- export { A as AaveClient, C as ClientConfig } from './AaveClient-DaBi3jFp.cjs';
6
+ export { A as AaveClient, C as ClientConfig } from './AaveClient-CGksa0-v.cjs';
7
7
  export { B as BatchOptions, C as CurrencyQueryOptions, D as DEFAULT_QUERY_OPTIONS, R as RequestPolicyOptions, T as TimeWindowQueryOptions } from './options-BX6n3sbh.cjs';
8
8
  export { E as ExecutionPlanHandler, d as SendWithError, S as SignTypedDataError, c as TransactionReceipt, T as TransactionResult, b as TypedData, a as TypedDataHandler, i as isHasProcessedKnownTransactionRequest, t as transactionReceipt } from './types-BzGr7R2Y.cjs';
9
9
  import '@urql/core';
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from '@aave/core';
3
3
  import { Erc20Approval, PermitTypedData } from '@aave/graphql';
4
4
  export * from '@aave/graphql';
5
5
  export * from '@aave/types';
6
- export { A as AaveClient, C as ClientConfig } from './AaveClient-DfMDhl-T.js';
6
+ export { A as AaveClient, C as ClientConfig } from './AaveClient-DpWiYPGY.js';
7
7
  export { B as BatchOptions, C as CurrencyQueryOptions, D as DEFAULT_QUERY_OPTIONS, R as RequestPolicyOptions, T as TimeWindowQueryOptions } from './options-BX6n3sbh.js';
8
8
  export { E as ExecutionPlanHandler, d as SendWithError, S as SignTypedDataError, c as TransactionReceipt, T as TransactionResult, b as TypedData, a as TypedDataHandler, i as isHasProcessedKnownTransactionRequest, t as transactionReceipt } from './types-BzGr7R2Y.js';
9
9
  import '@urql/core';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export{a as supportsPermit}from'./chunk-N4LXBTGY.js';import {h}from'./chunk-O65KFH4O.js';export{a as DEFAULT_QUERY_OPTIONS}from'./chunk-O65KFH4O.js';import {GqlClient,UnexpectedError,TimeoutError,delay}from'@aave/core';export*from'@aave/core';import {encodeReserveId,encodeHubId,isTxHashInputVariant,decodeSpokeId,encodeUserPositionId,isReserveInputVariant,isHubInputVariant}from'@aave/graphql';export*from'@aave/graphql';import {BigDecimal,ResultAsync,invariant}from'@aave/types';export*from'@aave/types';import U from'@aave/graphql/schema';import {cacheExchange}from'@urql/exchange-graphcache';var m=(e,r,n,a)=>BigInt(e[a.fieldName]),l=(e,r,n,a)=>BigDecimal.new(e[a.fieldName]),s=(e,r,n,a)=>{let i=e[a.fieldName];return i==null?null:l(e,r,n,a)},t=(e,r,n,a)=>new Date(e[a.fieldName]),y=(e,r,n,a)=>{let i=e[a.fieldName];return i==null?null:t(e,r,n,a)},f=cacheExchange({schema:U,resolvers:{PercentNumber:{onChainValue:m,value:l,normalized:l},DecimalNumber:{onChainValue:m,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:t},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:t},TransactionRequest:{value:m},ApySample:{date:t},AssetBorrowSample:{date:t},AssetSupplySample:{date:t},HubSummarySample:{date:t},PreviewMerklBorrowReward:{startDate:t,endDate:t},PreviewMerklSupplyReward:{startDate:t,endDate:t},ProtocolHistorySample:{date:t},BorrowActivity:{timestamp:t},LiquidatedActivity:{timestamp:t},MerklBorrowReward:{startDate:t,endDate:t},MerklSupplyReward:{startDate:t,endDate:t},RepayActivity:{timestamp:t},SupplyActivity:{timestamp:t},WithdrawActivity:{timestamp:t},UsingAsCollateralActivity:{timestamp:t},UpdatedDynamicConfigActivity:{timestamp:t},UpdatedRiskPremiumActivity:{timestamp:t},TokenSwapActivity:{timestamp:t},SupplySwapActivity:{timestamp:t},BorrowSwapActivity:{timestamp:t},RepayWithSupplyActivity:{timestamp:t},WithdrawSwapActivity:{timestamp:t},UserMerklClaimableReward:{startDate:t,endDate:t,claimUntil:t},UserPosition:{createdAt:t},UserBorrowItem:{createdAt:y},UserSupplyItem:{createdAt:y},SpokeUserPositionManager:{approvedOn:t},SwapCancelled:{createdAt:t,cancelledAt:y},SwapCancelledResult:{createdAt:t,cancelledAt:y},SwapExpired:{createdAt:t,expiredAt:t},SwapFulfilled:{createdAt:t,fulfilledAt:t},SwapOpen:{createdAt:t,deadline:t},SwapPendingSignature:{createdAt:t,deadline:t},SwapReceipt:{createdAt:t},Query:{hub:(e,{request:r})=>isHubInputVariant(r.query)?{__typename:"Hub",id:encodeHubId(r.query.hubInput)}:{__typename:"Hub",id:r.query.hubId},reserve:(e,{request:r})=>isReserveInputVariant(r.query)?{__typename:"Reserve",id:encodeReserveId(r.query.reserveInput)}:{__typename:"Reserve",id:r.query.reserveId},userPosition:(e,{request:r})=>{if("userSpoke"in r&&r.userSpoke){let{chainId:n,address:a}=decodeSpokeId(r.userSpoke.spoke);return {__typename:"UserPosition",id:encodeUserPositionId({chainId:n,spoke:a,user:r.userSpoke.user})}}if("id"in r&&r.id)return {__typename:"UserPosition",id:r.id}},activities:(e,r,n)=>{if(!isTxHashInputVariant(r.request.query))return n.resolve("Query","activities",r);let{txHash:a,chainId:i}=r.request.query.txHash,c=n.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,S)=>{let p=n.resolve("Query",S.fieldKey);if(!p)return o;let u=n.resolve(p,"items");if(!u)return o;for(let d of u)o.add(d);return o},new Set).values().toArray().filter(o=>{if(n.resolve(o,"txHash")!==a)return false;let p=n.resolve(o,"spoke");if(p){let u=n.resolve(p,"chain"),d=u?n.resolve(u,"chainId"):void 0;if(typeof d=="number")return d===i}return true});if(c.length!==0)return {__typename:"PaginatedActivitiesResult",items:c,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,BorrowSwapActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,MerklBorrowReward:e=>e.id,MerklGenericCriteria:e=>e.id,MerklSupplyReward:e=>e.id,RepayActivity:e=>e.id,RepayWithSupplyActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,SupplySwapActivity:e=>e.id,TokenInfo:e=>e.id,TokenSwapActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,UserMerklClaimableReward:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,WithdrawSwapActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,BorrowSwap:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSampleBreakdown:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,CollateralFactorVariation:()=>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,InsufficientLiquidityError:()=>null,LiquidationFeeVariation:()=>null,MaxLiquidationBonusVariation:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionAmount:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewMerklBorrowReward:()=>null,PreviewMerklSupplyReward:()=>null,PreviewRewardOutcome:()=>null,PreviewUserPosition:()=>null,RepayWithSupply:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManager:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwap:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapCancelledResult:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwap:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwap:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var A={name:"production",backend:"https://api.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},G={name:"staging",backend:"https://api.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},z={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function R({environment:e=A,headers:r,cache:n=true,batch:a=true,debug:i=false,fragments:c=[]}){return {displayName:"AaveClient",environment:e,headers:r,cache:n?f:null,batch:a,debug:i,fragments:c}}function g(e){return e.operations!==null&&e.operations.length>0}function v(e){return {__typename:"TransactionReceipt",txHash:e}}var x=class e extends GqlClient{static create(r){return new e(R(r??{}))}waitForTransaction=r=>(invariant(g(r),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),ResultAsync.fromPromise(this.pollTransactionStatus(r),n=>n instanceof TimeoutError||n instanceof UnexpectedError?n:UnexpectedError.from(n)));async pollTransactionStatus(r){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await h(this,r).match(i=>i,i=>{throw i}))return v(r.txHash);await delay(this.context.environment.pollingInterval);}throw TimeoutError.from(`Timeout waiting for transaction ${r.txHash} to be processed.`)}};
2
- export{x as AaveClient,z as local,A as production,G as staging,v as transactionReceipt};//# sourceMappingURL=index.js.map
1
+ export{a as supportsPermit}from'./chunk-N4LXBTGY.js';import {h}from'./chunk-O65KFH4O.js';export{a as DEFAULT_QUERY_OPTIONS}from'./chunk-O65KFH4O.js';import {GqlClient,UnexpectedError,TimeoutError,delay}from'@aave/core';export*from'@aave/core';import {encodeReserveId,encodeHubId,isTxHashInputVariant,decodeSpokeId,encodeUserPositionId,isReserveInputVariant,isHubInputVariant}from'@aave/graphql';export*from'@aave/graphql';import {BigDecimal,ResultAsync,invariant}from'@aave/types';export*from'@aave/types';import U from'@aave/graphql/schema';import {cacheExchange}from'@urql/exchange-graphcache';var y=(e,r,a,n)=>BigInt(e[n.fieldName]),l=(e,r,a,n)=>BigDecimal.new(e[n.fieldName]),s=(e,r,a,n)=>{let i=e[n.fieldName];return i==null?null:l(e,r,a,n)},t=(e,r,a,n)=>new Date(e[n.fieldName]),d=(e,r,a,n)=>{let i=e[n.fieldName];return i==null?null:t(e,r,a,n)},f=cacheExchange({schema:U,resolvers:{PercentNumber:{onChainValue:y,value:l,normalized:l},DecimalNumber:{onChainValue:y,value:l},ExchangeAmount:{value:l},AssetPriceSample:{price:l,date:t},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:t},TransactionRequest:{value:y},ApySample:{date:t},AssetBorrowSample:{date:t},AssetSupplySample:{date:t},HubSummarySample:{date:t},PreviewMerklBorrowReward:{startDate:t,endDate:t},PreviewMerklSupplyReward:{startDate:t,endDate:t},ProtocolHistorySample:{date:t},BorrowActivity:{timestamp:t},LiquidatedActivity:{timestamp:t},MerklBorrowReward:{startDate:t,endDate:t},MerklSupplyReward:{startDate:t,endDate:t},RepayActivity:{timestamp:t},SupplyActivity:{timestamp:t},WithdrawActivity:{timestamp:t},UsingAsCollateralActivity:{timestamp:t},UpdatedDynamicConfigActivity:{timestamp:t},UpdatedRiskPremiumActivity:{timestamp:t},TokenSwapActivity:{timestamp:t},SupplySwapActivity:{timestamp:t},BorrowSwapActivity:{timestamp:t},RepayWithSupplyActivity:{timestamp:t},WithdrawSwapActivity:{timestamp:t},UserMerklClaimableReward:{startDate:t,endDate:t,claimUntil:t},UserPosition:{createdAt:t},UserBorrowItem:{createdAt:d},UserSupplyItem:{createdAt:d},SpokeUserPositionManager:{approvedOn:t},SwapCancelled:{createdAt:t,cancelledAt:d},SwapCancelledResult:{createdAt:t,cancelledAt:d},SwapExpired:{createdAt:t,expiredAt:t},SwapFulfilled:{createdAt:t,fulfilledAt:t},SwapOpen:{createdAt:t,deadline:t},SwapPendingSignature:{createdAt:t,deadline:t},SwapReceipt:{createdAt:t},Query:{hub:(e,{request:r})=>isHubInputVariant(r.query)?{__typename:"Hub",id:encodeHubId(r.query.hubInput)}:{__typename:"Hub",id:r.query.hubId},reserve:(e,{request:r})=>isReserveInputVariant(r.query)?{__typename:"Reserve",id:encodeReserveId(r.query.reserveInput)}:{__typename:"Reserve",id:r.query.reserveId},userPosition:(e,{request:r})=>{if("userSpoke"in r&&r.userSpoke){let{chainId:a,address:n}=decodeSpokeId(r.userSpoke.spoke);return {__typename:"UserPosition",id:encodeUserPositionId({chainId:a,spoke:n,user:r.userSpoke.user})}}if("id"in r&&r.id)return {__typename:"UserPosition",id:r.id}},activities:(e,r,a)=>{if(!isTxHashInputVariant(r.request.query))return a.resolve("Query","activities",r);let{txHash:n,chainId:i}=r.request.query.txHash,v=a.inspectFields("Query").filter(o=>o.fieldName==="activities").reduce((o,S)=>{let p=a.resolve("Query",S.fieldKey);if(!p)return o;let u=a.resolve(p,"items");if(!u)return o;for(let c of u)o.add(c);return o},new Set).values().toArray().filter(o=>{if(a.resolve(o,"txHash")!==n)return false;let p=a.resolve(o,"spoke");if(p){let u=a.resolve(p,"chain"),c=u?a.resolve(u,"chainId"):void 0;if(typeof c=="number")return c===i}return true});if(v.length!==0)return {__typename:"PaginatedActivitiesResult",items:v,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,BorrowSwapActivity:e=>e.id,Hub:e=>e.id,HubAsset:e=>e.id,LiquidatedActivity:e=>e.id,MerklBorrowReward:e=>e.id,MerklGenericCriteria:e=>e.id,MerklSupplyReward:e=>e.id,RepayActivity:e=>e.id,RepayWithSupplyActivity:e=>e.id,Reserve:e=>e.id,ReserveInfo:e=>e.id,Spoke:e=>e.id,SupplyActivity:e=>e.id,SupplySwapActivity:e=>e.id,TokenInfo:e=>e.id,TokenSwapActivity:e=>e.id,UpdatedDynamicConfigActivity:e=>e.id,UpdatedRiskPremiumActivity:e=>e.id,UserMerklClaimableReward:e=>e.id,UserPosition:e=>e.id,UsingAsCollateralActivity:e=>e.id,WithdrawActivity:e=>e.id,WithdrawSwapActivity:e=>e.id,Erc20Token:e=>e.address,Chain:e=>e.chainId.toString(),NativeToken:e=>e.chain.chainId.toString(),ApySample:()=>null,BorrowSwap:()=>null,AssetAmountWithChange:()=>null,AssetBorrowSample:()=>null,AssetPriceSample:()=>null,AssetSampleBreakdown:()=>null,AssetSummary:()=>null,AssetSupplySample:()=>null,DecimalNumber:()=>null,CollateralFactorVariation:()=>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,InsufficientLiquidityError:()=>null,LiquidationFeeVariation:()=>null,MaxLiquidationBonusVariation:()=>null,NativeAmount:()=>null,PaginatedActivitiesResult:()=>null,PaginatedResultInfo:()=>null,PaginatedSpokePositionManagerResult:()=>null,PaginatedSpokeUserPositionManagerResult:()=>null,PaginatedUserSwapsResult:()=>null,PercentNumber:()=>null,PercentNumberVariation:()=>null,PercentNumberWithChange:()=>null,PermitTypedData:()=>null,BorrowSwapQuoteResult:()=>null,PercentNumberChangeSnapshot:()=>null,PositionAmount:()=>null,PositionSwapAdapterContractApproval:()=>null,PositionSwapByIntentApprovalsRequired:()=>null,PositionSwapPositionManagerApproval:()=>null,PreContractActionRequired:()=>null,PrepareSwapCancelResult:()=>null,PrepareSwapOrder:()=>null,PreviewMerklBorrowReward:()=>null,PreviewMerklSupplyReward:()=>null,PreviewRewardOutcome:()=>null,PreviewUserPosition:()=>null,RepayWithSupply:()=>null,RepayWithSupplyQuoteResult:()=>null,ProtocolHistorySample:()=>null,ReserveSettings:()=>null,ReserveStatus:()=>null,ReserveSummary:()=>null,ReserveUserState:()=>null,SpokePositionManager:()=>null,SpokeUserPositionManager:()=>null,SwapByIntent:()=>null,SwapByIntentWithApprovalRequired:()=>null,SupplySwap:()=>null,SupplySwapQuoteResult:()=>null,SwapByTransaction:()=>null,SwapCancelled:()=>null,SwapCancelledResult:()=>null,SwapExpired:()=>null,SwapFulfilled:()=>null,SwapOpen:()=>null,SwapPendingSignature:()=>null,SwapQuote:()=>null,SwapQuoteCosts:()=>null,SwapReceipt:()=>null,SwapTransactionRequest:()=>null,SwapTypedData:()=>null,TokenSwap:()=>null,TokenSwapQuoteResult:()=>null,WithdrawSwap:()=>null,WithdrawSwapQuoteResult:()=>null,TransactionRequest:()=>null,UserBalance:()=>null,UserBorrowItem:()=>null,UserPositionRiskPremium:()=>null,UserRiskPremiumBreakdownItem:()=>null,UserSummary:()=>null,UserSummaryHistoryItem:()=>null,UserSupplyItem:()=>null}});var A={name:"production",backend:"https://api.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},G={name:"staging",backend:"https://api.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},z={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function R({environment:e=A,headers:r,cache:a=true,batch:n=true,debug:i=false}){return {displayName:"AaveClient",environment:e,headers:r,cache:a?f:null,batch:n,debug:i}}function g(e){return e.operations!==null&&e.operations.length>0}function m(e){return {__typename:"TransactionReceipt",txHash:e}}var x=class e extends GqlClient{static create(r){return new e(R(r??{}))}waitForTransaction=r=>(invariant(g(r),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),ResultAsync.fromPromise(this.pollTransactionStatus(r),a=>a instanceof TimeoutError||a instanceof UnexpectedError?a:UnexpectedError.from(a)));async pollTransactionStatus(r){let a=Date.now();for(;Date.now()-a<this.context.environment.indexingTimeout;){if(await h(this,r).match(i=>i,i=>{throw i}))return m(r.txHash);await delay(this.context.environment.pollingInterval);}throw TimeoutError.from(`Timeout waiting for transaction ${r.txHash} to be processed.`)}};
2
+ export{x as AaveClient,z as local,A as production,G as staging,m as transactionReceipt};//# 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","isReserveInputVariant","encodeReserveId","chainId","address","decodeSpokeId","encodeUserPositionId","_parent","args","cache","isTxHashInputVariant","txHash","matches","f","set","pageRef","itemRefs","ref","spokeRef","chainRef","itemChainId","data","production","staging","local","configureContext","environment","headers","batch","debug","fragments","isHasProcessedKnownTransactionRequest","result","transactionReceipt","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError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R,CACF,EAGE,OAAOP,CAAAA,CAAmBnC,CAAAA,CAAQ,MAAM,EAG1C,MAAMgD,KAAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,YAAY,eAAe,EACtD,CACA,MAAML,aAAa,IAAA,CACjB,CAAA,gCAAA,EAAmC3C,EAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF","file":"index.js","sourcesContent":["import {\n type ActivitiesQuery,\n type Asset,\n type BorrowActivity,\n type BorrowSwapActivity,\n type Chain,\n decodeSpokeId,\n type Erc20Token,\n encodeHubId,\n encodeReserveId,\n encodeUserPositionId,\n type Hub,\n type HubAsset,\n type HubQuery,\n isHubInputVariant,\n isReserveInputVariant,\n isTxHashInputVariant,\n type LiquidatedActivity,\n type MerklBorrowReward,\n type MerklGenericCriteria,\n type MerklSupplyReward,\n type NativeToken,\n type RepayActivity,\n type RepayWithSupplyActivity,\n type Reserve,\n type ReserveInfo,\n type ReserveQuery,\n type Spoke,\n type SupplyActivity,\n type SupplySwapActivity,\n type TokenInfo,\n type TokenSwapActivity,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\n type UserMerklClaimableReward,\n type UserPosition,\n type UserPositionQuery,\n type UsingAsCollateralActivity,\n type VariablesOf,\n type WithdrawActivity,\n type WithdrawSwapActivity,\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 PreviewMerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n PreviewMerklSupplyReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n ProtocolHistorySample: {\n date: transformToDate,\n },\n BorrowActivity: {\n timestamp: transformToDate,\n },\n LiquidatedActivity: {\n timestamp: transformToDate,\n },\n MerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n MerklSupplyReward: {\n startDate: transformToDate,\n endDate: 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 TokenSwapActivity: {\n timestamp: transformToDate,\n },\n SupplySwapActivity: {\n timestamp: transformToDate,\n },\n BorrowSwapActivity: {\n timestamp: transformToDate,\n },\n RepayWithSupplyActivity: {\n timestamp: transformToDate,\n },\n WithdrawSwapActivity: {\n timestamp: transformToDate,\n },\n UserMerklClaimableReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n claimUntil: transformToDate,\n },\n UserPosition: {\n createdAt: transformToDate,\n },\n UserBorrowItem: {\n createdAt: transformToNullableDate,\n },\n UserSupplyItem: {\n createdAt: transformToNullableDate,\n },\n SpokeUserPositionManager: {\n approvedOn: transformToDate,\n },\n SwapCancelled: {\n createdAt: transformToDate,\n cancelledAt: transformToNullableDate,\n },\n SwapCancelledResult: {\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 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 reserve: (_, { request }: VariablesOf<typeof ReserveQuery>) => {\n if (isReserveInputVariant(request.query)) {\n return {\n __typename: 'Reserve',\n id: encodeReserveId(request.query.reserveInput),\n };\n }\n return {\n __typename: 'Reserve',\n id: request.query.reserveId,\n };\n },\n\n userPosition: (_, { request }: VariablesOf<typeof UserPositionQuery>) => {\n if ('userSpoke' in request && request.userSpoke) {\n const { chainId, address } = decodeSpokeId(request.userSpoke.spoke);\n return {\n __typename: 'UserPosition',\n id: encodeUserPositionId({\n chainId,\n spoke: address,\n user: request.userSpoke.user,\n }),\n };\n }\n if ('id' in request && request.id) {\n return {\n __typename: 'UserPosition',\n id: request.id,\n };\n }\n return undefined;\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 BorrowSwapActivity: (data: BorrowSwapActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n MerklBorrowReward: (data: MerklBorrowReward) => data.id,\n MerklGenericCriteria: (data: MerklGenericCriteria) => data.id,\n MerklSupplyReward: (data: MerklSupplyReward) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n RepayWithSupplyActivity: (data: RepayWithSupplyActivity) => 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 SupplySwapActivity: (data: SupplySwapActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n TokenSwapActivity: (data: TokenSwapActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => data.id,\n UserMerklClaimableReward: (data: UserMerklClaimableReward) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n WithdrawSwapActivity: (data: WithdrawSwapActivity) => 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 BorrowSwap: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSampleBreakdown: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n CollateralFactorVariation: () => 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 InsufficientLiquidityError: () => null,\n LiquidationFeeVariation: () => null,\n MaxLiquidationBonusVariation: () => 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 PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionAmount: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewMerklBorrowReward: () => null,\n PreviewMerklSupplyReward: () => null,\n PreviewRewardOutcome: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupply: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManager: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwap: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapCancelledResult: () => 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 TokenSwap: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwap: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => 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.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.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 query batching.\n *\n * @defaultValue `true`\n */\n batch?: 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 batch = true,\n debug = false,\n fragments = [],\n}: ClientConfig): Context {\n return {\n displayName: 'AaveClient',\n environment,\n headers,\n cache: cache ? exchange : null,\n batch,\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 TransactionReceipt = {\n __typename: 'TransactionReceipt';\n txHash: TxHash;\n};\n\n/**\n * @internal\n */\nexport function transactionReceipt(txHash: TxHash): TransactionReceipt {\n return { __typename: 'TransactionReceipt', txHash };\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 { delay, GqlClient, TimeoutError, UnexpectedError } from '@aave/core';\nimport type { HasProcessedKnownTransactionRequest } from '@aave/graphql';\nimport { invariant, ResultAsync } from '@aave/types';\nimport { hasProcessedKnownTransaction } from './actions';\nimport { type ClientConfig, configureContext } from './config';\nimport {\n isHasProcessedKnownTransactionRequest,\n type TransactionReceipt,\n type TransactionResult,\n transactionReceipt,\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 {@link TransactionReceipt} or a error\n */\n readonly waitForTransaction = (\n result: TransactionResult,\n ): ResultAsync<TransactionReceipt, 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 protected async pollTransactionStatus(\n request: HasProcessedKnownTransactionRequest,\n ): Promise<TransactionReceipt> {\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 transactionReceipt(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","isReserveInputVariant","encodeReserveId","chainId","address","decodeSpokeId","encodeUserPositionId","_parent","args","cache","isTxHashInputVariant","txHash","matches","f","set","pageRef","itemRefs","ref","spokeRef","chainRef","itemChainId","data","production","staging","local","configureContext","environment","headers","batch","debug","isHasProcessedKnownTransactionRequest","result","transactionReceipt","AaveClient","_AaveClient","GqlClient","options","invariant","ResultAsync","err","TimeoutError","UnexpectedError","startedAt","hasProcessedKnownTransaction","ok","delay"],"mappings":"olBAkDA,IAAMA,CAAAA,CAA8B,CAACC,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAAA,GACnD,OAAOH,CAAAA,CAAOG,CAAAA,CAAK,SAAS,CAAW,EAG1CC,CAAAA,CAAkC,CAACJ,CAAAA,CAAQC,CAAAA,CAAOC,EAAQC,CAAAA,GACvDE,UAAAA,CAAW,GAAA,CAAIL,CAAAA,CAAOG,EAAK,SAAS,CAAW,EAGlDG,CAAAA,CAA0C,CAC9CN,EACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,GACG,CACH,IAAMI,CAAAA,CAAQP,CAAAA,CAAOG,CAAAA,CAAK,SAAS,EACnC,OAAII,CAAAA,EAAU,IAAA,CACL,IAAA,CAEFH,EAAsBJ,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,CAAI,CAC1D,CAAA,CAEMK,CAAAA,CAA4B,CAACR,CAAAA,CAAQC,EAAOC,CAAAA,CAAQC,CAAAA,GACjD,IAAI,IAAA,CAAKH,EAAOG,CAAAA,CAAK,SAAS,CAAW,CAAA,CAG5CM,EAAoC,CAACT,CAAAA,CAAQC,CAAAA,CAAOC,CAAAA,CAAQC,IAAS,CACzE,IAAMI,CAAAA,CAAQP,CAAAA,CAAOG,EAAK,SAAS,CAAA,CACnC,OAAII,CAAAA,EAAU,KACL,IAAA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C,CAAA,CAAA,CAGF,MAAgB,qBAAA,CACdzC,EAC6B,CAC7B,IAAM4C,CAAAA,CAAY,IAAA,CAAK,KAAI,CAE3B,KAAO,KAAK,GAAA,EAAI,CAAIA,EAAY,IAAA,CAAK,OAAA,CAAQ,WAAA,CAAY,eAAA,EAAiB,CAQxE,GAPkB,MAAMC,CAAAA,CAA6B,IAAA,CAAM7C,CAAO,CAAA,CAAE,KAAA,CACjE8C,CAAAA,EAAOA,CAAAA,CACPL,GAAQ,CACP,MAAMA,CACR,CACF,EAGE,OAAOP,CAAAA,CAAmBlC,CAAAA,CAAQ,MAAM,EAG1C,MAAM+C,KAAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,YAAY,eAAe,EACtD,CACA,MAAML,aAAa,IAAA,CACjB,CAAA,gCAAA,EAAmC1C,EAAQ,MAAM,CAAA,iBAAA,CACnD,CACF,CACF","file":"index.js","sourcesContent":["import {\n type ActivitiesQuery,\n type Asset,\n type BorrowActivity,\n type BorrowSwapActivity,\n type Chain,\n decodeSpokeId,\n type Erc20Token,\n encodeHubId,\n encodeReserveId,\n encodeUserPositionId,\n type Hub,\n type HubAsset,\n type HubQuery,\n isHubInputVariant,\n isReserveInputVariant,\n isTxHashInputVariant,\n type LiquidatedActivity,\n type MerklBorrowReward,\n type MerklGenericCriteria,\n type MerklSupplyReward,\n type NativeToken,\n type RepayActivity,\n type RepayWithSupplyActivity,\n type Reserve,\n type ReserveInfo,\n type ReserveQuery,\n type Spoke,\n type SupplyActivity,\n type SupplySwapActivity,\n type TokenInfo,\n type TokenSwapActivity,\n type UpdatedDynamicConfigActivity,\n type UpdatedRiskPremiumActivity,\n type UserMerklClaimableReward,\n type UserPosition,\n type UserPositionQuery,\n type UsingAsCollateralActivity,\n type VariablesOf,\n type WithdrawActivity,\n type WithdrawSwapActivity,\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 PreviewMerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n PreviewMerklSupplyReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n ProtocolHistorySample: {\n date: transformToDate,\n },\n BorrowActivity: {\n timestamp: transformToDate,\n },\n LiquidatedActivity: {\n timestamp: transformToDate,\n },\n MerklBorrowReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n },\n MerklSupplyReward: {\n startDate: transformToDate,\n endDate: 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 TokenSwapActivity: {\n timestamp: transformToDate,\n },\n SupplySwapActivity: {\n timestamp: transformToDate,\n },\n BorrowSwapActivity: {\n timestamp: transformToDate,\n },\n RepayWithSupplyActivity: {\n timestamp: transformToDate,\n },\n WithdrawSwapActivity: {\n timestamp: transformToDate,\n },\n UserMerklClaimableReward: {\n startDate: transformToDate,\n endDate: transformToDate,\n claimUntil: transformToDate,\n },\n UserPosition: {\n createdAt: transformToDate,\n },\n UserBorrowItem: {\n createdAt: transformToNullableDate,\n },\n UserSupplyItem: {\n createdAt: transformToNullableDate,\n },\n SpokeUserPositionManager: {\n approvedOn: transformToDate,\n },\n SwapCancelled: {\n createdAt: transformToDate,\n cancelledAt: transformToNullableDate,\n },\n SwapCancelledResult: {\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 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 reserve: (_, { request }: VariablesOf<typeof ReserveQuery>) => {\n if (isReserveInputVariant(request.query)) {\n return {\n __typename: 'Reserve',\n id: encodeReserveId(request.query.reserveInput),\n };\n }\n return {\n __typename: 'Reserve',\n id: request.query.reserveId,\n };\n },\n\n userPosition: (_, { request }: VariablesOf<typeof UserPositionQuery>) => {\n if ('userSpoke' in request && request.userSpoke) {\n const { chainId, address } = decodeSpokeId(request.userSpoke.spoke);\n return {\n __typename: 'UserPosition',\n id: encodeUserPositionId({\n chainId,\n spoke: address,\n user: request.userSpoke.user,\n }),\n };\n }\n if ('id' in request && request.id) {\n return {\n __typename: 'UserPosition',\n id: request.id,\n };\n }\n return undefined;\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 BorrowSwapActivity: (data: BorrowSwapActivity) => data.id,\n Hub: (data: Hub) => data.id,\n HubAsset: (data: HubAsset) => data.id,\n LiquidatedActivity: (data: LiquidatedActivity) => data.id,\n MerklBorrowReward: (data: MerklBorrowReward) => data.id,\n MerklGenericCriteria: (data: MerklGenericCriteria) => data.id,\n MerklSupplyReward: (data: MerklSupplyReward) => data.id,\n RepayActivity: (data: RepayActivity) => data.id,\n RepayWithSupplyActivity: (data: RepayWithSupplyActivity) => 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 SupplySwapActivity: (data: SupplySwapActivity) => data.id,\n TokenInfo: (data: TokenInfo) => data.id,\n TokenSwapActivity: (data: TokenSwapActivity) => data.id,\n UpdatedDynamicConfigActivity: (data: UpdatedDynamicConfigActivity) =>\n data.id,\n UpdatedRiskPremiumActivity: (data: UpdatedRiskPremiumActivity) => data.id,\n UserMerklClaimableReward: (data: UserMerklClaimableReward) => data.id,\n UserPosition: (data: UserPosition) => data.id,\n UsingAsCollateralActivity: (data: UsingAsCollateralActivity) => data.id,\n WithdrawActivity: (data: WithdrawActivity) => data.id,\n WithdrawSwapActivity: (data: WithdrawSwapActivity) => 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 BorrowSwap: () => null,\n AssetAmountWithChange: () => null,\n AssetBorrowSample: () => null,\n AssetPriceSample: () => null,\n AssetSampleBreakdown: () => null,\n AssetSummary: () => null,\n AssetSupplySample: () => null,\n DecimalNumber: () => null,\n CollateralFactorVariation: () => 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 InsufficientLiquidityError: () => null,\n LiquidationFeeVariation: () => null,\n MaxLiquidationBonusVariation: () => 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 PermitTypedData: () => null,\n BorrowSwapQuoteResult: () => null,\n PercentNumberChangeSnapshot: () => null,\n PositionAmount: () => null,\n PositionSwapAdapterContractApproval: () => null,\n PositionSwapByIntentApprovalsRequired: () => null,\n PositionSwapPositionManagerApproval: () => null,\n PreContractActionRequired: () => null,\n PrepareSwapCancelResult: () => null,\n PrepareSwapOrder: () => null,\n PreviewMerklBorrowReward: () => null,\n PreviewMerklSupplyReward: () => null,\n PreviewRewardOutcome: () => null,\n PreviewUserPosition: () => null,\n RepayWithSupply: () => null,\n RepayWithSupplyQuoteResult: () => null,\n ProtocolHistorySample: () => null,\n ReserveSettings: () => null,\n ReserveStatus: () => null,\n ReserveSummary: () => null,\n ReserveUserState: () => null,\n SpokePositionManager: () => null,\n SpokeUserPositionManager: () => null,\n SwapByIntent: () => null,\n SwapByIntentWithApprovalRequired: () => null,\n SupplySwap: () => null,\n SupplySwapQuoteResult: () => null,\n SwapByTransaction: () => null,\n SwapCancelled: () => null,\n SwapCancelledResult: () => 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 TokenSwap: () => null,\n TokenSwapQuoteResult: () => null,\n WithdrawSwap: () => null,\n WithdrawSwapQuoteResult: () => null,\n TransactionRequest: () => 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.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.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 { 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 query batching.\n *\n * @defaultValue `true`\n */\n batch?: boolean;\n /**\n * Whether to enable debug mode.\n *\n * @defaultValue `false`\n */\n debug?: boolean;\n};\n\n/**\n * @internal\n */\nexport function configureContext({\n environment = production,\n headers,\n cache = true,\n batch = true,\n debug = false,\n}: ClientConfig): Context {\n return {\n displayName: 'AaveClient',\n environment,\n headers,\n cache: cache ? exchange : null,\n batch,\n debug,\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 TransactionReceipt = {\n __typename: 'TransactionReceipt';\n txHash: TxHash;\n};\n\n/**\n * @internal\n */\nexport function transactionReceipt(txHash: TxHash): TransactionReceipt {\n return { __typename: 'TransactionReceipt', txHash };\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 { delay, GqlClient, TimeoutError, UnexpectedError } from '@aave/core';\nimport type { HasProcessedKnownTransactionRequest } from '@aave/graphql';\nimport { invariant, ResultAsync } from '@aave/types';\nimport { hasProcessedKnownTransaction } from './actions';\nimport { type ClientConfig, configureContext } from './config';\nimport {\n isHasProcessedKnownTransactionRequest,\n type TransactionReceipt,\n type TransactionResult,\n transactionReceipt,\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 {@link TransactionReceipt} or a error\n */\n readonly waitForTransaction = (\n result: TransactionResult,\n ): ResultAsync<TransactionReceipt, 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 protected async pollTransactionStatus(\n request: HasProcessedKnownTransactionRequest,\n ): Promise<TransactionReceipt> {\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 transactionReceipt(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.d.ts CHANGED
@@ -13,7 +13,6 @@ import { TxHash, ResultAsync, EvmAddress, BigDecimal, HexString } from '@aave/ty
13
13
  import * as _aave_core from '@aave/core';
14
14
  import { GqlClient, TimeoutError, UnexpectedError } from '@aave/core';
15
15
  import { Eip1193Provider } from 'ethers';
16
- import { TypedDocumentNode } from '@urql/core';
17
16
 
18
17
  type VerifySiweMessageParameters = Prettify<Pick<VerifyHashParameters, 'blockNumber' | 'blockTag'> & Pick<ValidateSiweMessageParameters, 'address' | 'domain' | 'nonce' | 'scheme' | 'time'> & {
19
18
  /**
@@ -73,12 +72,6 @@ type ClientConfig = {
73
72
  * @defaultValue `false`
74
73
  */
75
74
  debug?: boolean;
76
- /**
77
- * The custom fragments to use.
78
- *
79
- * @experimental This is an experimental API and may be subject to breaking changes.
80
- */
81
- fragments?: TypedDocumentNode[];
82
75
  };
83
76
 
84
77
  /**