@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.
package/dist/testing.js CHANGED
@@ -41,7 +41,7 @@ Read more: https://mswjs.io/docs/http/intercepting-requests`;function s(u){switc
41
41
  `).map(r=>r.split("|"))[0],o=[];for(let r=0;r<Math.floor(t.length/n.length);r++){let a={};for(let i=0;i<n.length;i++)a[n[i]]=t[r*n.length+i];o.push(a);}return o}function ol(e){let t=bg(),n=e.split(`
42
42
  `).slice(1);for(let o of n){let r=fi(o);if(r&&r.file===t)return {line:r.line,column:r.column}}}globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;globalThis.performance?globalThis.performance.now.bind(globalThis.performance):Date.now;da();var gi=new Map,rl=[],nr=[];function vl(e){if(gi.size){var t;let n=Array.from(gi).map(([r,a])=>[r,a[0],a[1]]),o=(t=e.onTaskUpdate)===null||t===void 0?void 0:t.call(e,n,rl);o&&(nr.push(o),o.then(()=>nr.splice(nr.indexOf(o),1),()=>{})),rl.length=0,gi.clear();}}async function Cg(e){vl(e),await Promise.all(nr);}var al=Date.now,ft={currentSuite:null};function Rg(e){var t;(t=ft.currentSuite)===null||t===void 0||t.tasks.push(e);}async function Ag(e,t){let n=ft.currentSuite;ft.currentSuite=e,await t(),ft.currentSuite=n;}function It(e,t,n=false,o,r){if(t<=0||t===Number.POSITIVE_INFINITY)return e;let{setTimeout:a,clearTimeout:i}=da();return function(...u){let c=al(),l=bl();return l._currentTaskStartTime=c,l._currentTaskTimeout=t,new Promise((p,y)=>{var h;let k=a(()=>{i(k),f();},t);(h=k.unref)===null||h===void 0||h.call(k);function f(){let q=Ig(n,t,o);r?.(u,q),y(q);}function v(q){if(l._currentTaskStartTime=void 0,l._currentTaskTimeout=void 0,i(k),al()-c>=t){f();return}p(q);}function R(q){l._currentTaskStartTime=void 0,l._currentTaskTimeout=void 0,i(k),y(q);}try{let q=e(...u);typeof q=="object"&&q!=null&&typeof q.then=="function"?q.then(v,R):v(q);}catch(q){R(q);}})}}var bi=new WeakMap;function wi([e],t){e&&Pg(e,t);}function Pg(e,t){let n=bi.get(e);n?.abort(t);}function _g(e,t){var n;let o=function(){throw new Error("done() callback is deprecated, use promise instead")},r=bi.get(o);r||(r=new AbortController,bi.set(o,r)),o.signal=r.signal,o.task=e,o.skip=(i,s)=>{if(i!==false)throw e.result??(e.result={state:"skip"}),e.result.pending=true,new yi("test is skipped; abort execution",e,typeof i=="string"?i:s)};async function a(i,s,u,c){let l={message:i,type:u||"notice"};if(c){if(!c.body&&!c.path)throw new TypeError("Test attachment requires body or path to be set. Both are missing.");if(c.body&&c.path)throw new TypeError('Test attachment requires only one of "body" or "path" to be set. Both are specified.');l.attachment=c,c.body instanceof Uint8Array&&(c.body=qg(c.body));}if(s&&(l.location=s),!t.onTestAnnotate)throw new Error("Test runner doesn't support test annotations.");await Cg(t);let p=await t.onTestAnnotate(e,l);return e.annotations.push(p),p}return o.annotate=(i,s,u)=>{if(e.result&&e.result.state!=="run")throw new Error(`Cannot annotate tests outside of the test run. The test "${e.name}" finished running with the "${e.result.state}" state already.`);let c,l=new Error("STACK_TRACE").stack,p=l.includes("STACK_TRACE")?2:1,y=l.split(`
43
43
  `)[p],h=fi(y);return h&&(c={file:h.file,line:h.line,column:h.column}),typeof s=="object"?il(e,a(i,c,void 0,s)):il(e,a(i,c,s,u))},o.onTestFailed=(i,s)=>{e.onFailed||(e.onFailed=[]),e.onFailed.push(It(i,s??t.config.hookTimeout,true,new Error("STACK_TRACE_ERROR"),(u,c)=>r.abort(c)));},o.onTestFinished=(i,s)=>{e.onFinished||(e.onFinished=[]),e.onFinished.push(It(i,s??t.config.hookTimeout,true,new Error("STACK_TRACE_ERROR"),(u,c)=>r.abort(c)));},((n=t.extendTaskContext)===null||n===void 0?void 0:n.call(t,o))||o}function Ig(e,t,n){let o=`${e?"Hook":"Test"} timed out in ${t}ms.
44
- If this is a long-running ${e?"hook":"test"}, pass a timeout value as the last argument or configure it globally with "${e?"hookTimeout":"testTimeout"}".`,r=new Error(o);return n?.stack&&(r.stack=n.stack.replace(r.message,n.message)),r}var Og=new WeakMap;function zg(e){let t=Og.get(e);if(!t)throw new Error(`Cannot find file context for ${e.name}`);return t}var De=[];for(let e=65;e<91;e++)De.push(String.fromCharCode(e));for(let e=97;e<123;e++)De.push(String.fromCharCode(e));for(let e=0;e<10;e++)De.push(e.toString(10));function qg(e){let t="",n=e.byteLength;for(let o=0;o<n;o+=3)if(n===o+1){let r=(e[o]&252)>>2,a=(e[o]&3)<<4;t+=De[r],t+=De[a],t+="==";}else if(n===o+2){let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2;t+=De[r],t+=De[a],t+=De[i],t+="=";}else {let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2|(e[o+2]&192)>>6,s=e[o+2]&63;t+=De[r],t+=De[a],t+=De[i],t+=De[s];}return t}function il(e,t){return t=t.finally(()=>{if(!e.promises)return;let n=e.promises.indexOf(t);n!==-1&&e.promises.splice(n,1);}),e.promises||(e.promises=[]),e.promises.push(t),t}function rr(){return bl().config.hookTimeout}var Dg=Symbol.for("VITEST_CLEANUP_TIMEOUT"),Ng=Symbol.for("VITEST_CLEANUP_STACK_TRACE");function ar(e,t=rr()){xn(e,'"beforeAll" callback',["function"]);let n=new Error("STACK_TRACE_ERROR");return Qt().on("beforeAll",Object.assign(It(e,t,true,n),{[Dg]:t,[Ng]:n}))}function ir(e,t){return xn(e,'"afterAll" callback',["function"]),Qt().on("afterAll",It(e,rr(),true,new Error("STACK_TRACE_ERROR")))}Ci(Il());var ur={currency:Currency.Usd,timeWindow:TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function Ol(e,t,{batch:n=ur.batch,requestPolicy:o=ur.requestPolicy}=ur){return e.query(ChainQuery,{request:t},{batch:n,requestPolicy:o})}function zl(e,t){return e.query(HasProcessedKnownTransactionQuery,{request:t},{requestPolicy:"network-only",batch:false})}var xi=(e,t,n,o)=>BigInt(e[o.fieldName]),dt=(e,t,n,o)=>BigDecimal.new(e[o.fieldName]),Ot=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:dt(e,t,n,o)},$=(e,t,n,o)=>new Date(e[o.fieldName]),cr=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:$(e,t,n,o)},ql=cacheExchange({schema:ny,resolvers:{PercentNumber:{onChainValue:xi,value:dt,normalized:dt},DecimalNumber:{onChainValue:xi,value:dt},ExchangeAmount:{value:dt},AssetPriceSample:{price:dt,date:$},Reserve:{borrowCap:dt,supplyCap:dt},HealthFactorError:{current:Ot,after:Ot},HealthFactorVariation:{current:Ot,after:Ot},HealthFactorWithChange:{current:Ot},UserSummary:{lowestHealthFactor:Ot},UserSummaryHistoryItem:{healthFactor:Ot,date:$},TransactionRequest:{value:xi},ApySample:{date:$},AssetBorrowSample:{date:$},AssetSupplySample:{date:$},HubSummarySample:{date:$},PreviewMerklBorrowReward:{startDate:$,endDate:$},PreviewMerklSupplyReward:{startDate:$,endDate:$},ProtocolHistorySample:{date:$},BorrowActivity:{timestamp:$},LiquidatedActivity:{timestamp:$},MerklBorrowReward:{startDate:$,endDate:$},MerklSupplyReward:{startDate:$,endDate:$},RepayActivity:{timestamp:$},SupplyActivity:{timestamp:$},WithdrawActivity:{timestamp:$},UsingAsCollateralActivity:{timestamp:$},UpdatedDynamicConfigActivity:{timestamp:$},UpdatedRiskPremiumActivity:{timestamp:$},TokenSwapActivity:{timestamp:$},SupplySwapActivity:{timestamp:$},BorrowSwapActivity:{timestamp:$},RepayWithSupplyActivity:{timestamp:$},WithdrawSwapActivity:{timestamp:$},UserMerklClaimableReward:{startDate:$,endDate:$,claimUntil:$},UserPosition:{createdAt:$},UserBorrowItem:{createdAt:cr},UserSupplyItem:{createdAt:cr},SpokeUserPositionManager:{approvedOn:$},SwapCancelled:{createdAt:$,cancelledAt:cr},SwapCancelledResult:{createdAt:$,cancelledAt:cr},SwapExpired:{createdAt:$,expiredAt:$},SwapFulfilled:{createdAt:$,fulfilledAt:$},SwapOpen:{createdAt:$,deadline:$},SwapPendingSignature:{createdAt:$,deadline:$},SwapReceipt:{createdAt:$},Query:{hub:(e,{request:t})=>isHubInputVariant(t.query)?{__typename:"Hub",id:encodeHubId(t.query.hubInput)}:{__typename:"Hub",id:t.query.hubId},reserve:(e,{request:t})=>isReserveInputVariant(t.query)?{__typename:"Reserve",id:encodeReserveId(t.query.reserveInput)}:{__typename:"Reserve",id:t.query.reserveId},userPosition:(e,{request:t})=>{if("userSpoke"in t&&t.userSpoke){let{chainId:n,address:o}=decodeSpokeId(t.userSpoke.spoke);return {__typename:"UserPosition",id:encodeUserPositionId({chainId:n,spoke:o,user:t.userSpoke.user})}}if("id"in t&&t.id)return {__typename:"UserPosition",id:t.id}},activities:(e,t,n)=>{if(!isTxHashInputVariant(t.request.query))return n.resolve("Query","activities",t);let{txHash:o,chainId:r}=t.request.query.txHash,a=n.inspectFields("Query").filter(i=>i.fieldName==="activities").reduce((i,s)=>{let u=n.resolve("Query",s.fieldKey);if(!u)return i;let c=n.resolve(u,"items");if(!c)return i;for(let l of c)i.add(l);return i},new Set).values().toArray().filter(i=>{if(n.resolve(i,"txHash")!==o)return false;let u=n.resolve(i,"spoke");if(u){let c=n.resolve(u,"chain"),l=c?n.resolve(c,"chainId"):void 0;if(typeof l=="number")return l===r}return true});if(a.length!==0)return {__typename:"PaginatedActivitiesResult",items:a,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,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 lr={name:"production",backend:"https://api.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Dl={name:"staging",backend:"https://api.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Nl={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function Ml({environment:e=lr,headers:t,cache:n=true,batch:o=true,debug:r=false,fragments:a=[]}){return {displayName:"AaveClient",environment:e,headers:t,cache:n?ql:null,batch:o,debug:r,fragments:a}}function Ll(e){return e.operations!==null&&e.operations.length>0}function Fl(e){return {__typename:"TransactionReceipt",txHash:e}}var pr=class e extends GqlClient{static create(t){return new e(Ml(t??{}))}waitForTransaction=t=>(invariant(Ll(t),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),ResultAsync.fromPromise(this.pollTransactionStatus(t),n=>n instanceof TimeoutError||n instanceof UnexpectedError?n:UnexpectedError.from(n)));async pollTransactionStatus(t){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await zl(this,t).match(r=>r,r=>{throw r}))return Fl(t.txHash);await delay(this.context.environment.pollingInterval);}throw TimeoutError.from(`Timeout waiting for transaction ${t.txHash} to be processed.`)}};function Vl(e){switch(e.chainId){case chainId(mainnet.id):return mainnet;case chainId(sepolia.id):return sepolia}return defineChain({id:e.chainId,name:e.name,nativeCurrency:{name:e.nativeInfo.name,symbol:e.nativeInfo.symbol,decimals:e.nativeInfo.decimals},rpcUrls:{default:{http:[e.rpcUrl]}},blockExplorers:{default:{name:`${e.name} Explorer`,url:e.explorerUrl}}})}var ky=import.meta.env.ENVIRONMENT==="local"?Nl:import.meta.env.ENVIRONMENT==="production"?lr:Dl,tn=chainId(Number.parseInt("123456789",10)),YE=evmAddress("0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f"),QE=evmAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),ZE=evmAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),eS=evmAddress("0xdC035D45d973E3EC169d2276DDab16f1e407384F"),tS=evmAddress("0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"),nS=evmAddress("0x111111111117dC0aa78b770fA6A738034120C302"),oS=evmAddress("0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"),rS=evmAddress("0xdac17f958d2ee523a2206206994597c13d831ec7"),aS=evmAddress("0x4c9EDD5852cd905f086C759E8383e09bff1E68B3"),vy=evmAddress("0x46539e9123A18c427e6b4DFF114c28CF405Cb023"),iS=encodeSpokeId({chainId:tn,address:vy}),jy=evmAddress("0xf3b207c235f6154120F41eB63D5ACCBAfD4086D1"),sS=encodeSpokeId({chainId:tn,address:jy}),wy=evmAddress("0x3Ed2C9829FBCab6015E331a0352F8ae148217D70"),uS=encodeHubId({chainId:tn,address:wy}),Zt="https://virtual.mainnet-aave.us-east.rpc.tenderly.co/38393fd3-0a79-4e60-b8cc-c6bb5903454a",mr=import.meta.env.ETHEREUM_TENDERLY_ADMIN_RPC,xy=pr.create({environment:ky}),zn=await Ol(xy,{chainId:tn}).map(nonNullable).map(Vl).match(e=>e,()=>never("No devnet chain found"));async function cS(){return createPublicClient({chain:zn,transport:http(Zt)})}async function lS(e){if(!e){let t=generatePrivateKey(),n=createWalletClient({account:privateKeyToAccount(t),chain:zn,transport:http()});return await Ey(evmAddress(n.account.address)),n}return createWalletClient({account:privateKeyToAccount(e),chain:zn,transport:http()})}function Ey(e,t=bigDecimal("1.0")){let n=createPublicClient({chain:{id:tn,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[mr]}}},transport:http(mr)}),r=`0x${parseEther(t.toString()).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setBalance",params:[[e],r]}),a=>UnexpectedError.from(a))}function pS(e,t){let n=createPublicClient({chain:{id:tn,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[mr]}}},transport:http(mr)}),r=`0x${parseUnits(t.amount.toString(),t.decimals??18).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setErc20Balance",params:[t.address,e,r]}),a=>UnexpectedError.from(a))}function mS(e){return new Promise(t=>setTimeout(t,e))}async function fS(e,t){let n=createPublicClient({chain:zn,transport:http(Zt)}),[o,r]=await Promise.all([n.readContract({address:t,abi:[{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"balanceOf",args:[e]}),n.readContract({address:t,abi:[{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"}],functionName:"decimals"})]);return bigDecimal(o).rescale(-r)}async function dS(e){let n=await createPublicClient({chain:zn,transport:http(Zt)}).getBalance({address:e});return bigDecimal(n).rescale(-18)}function Ql(e){return isObject(e)&&"jsonrpc"in e&&"method"in e}function Sy(e){return Array.isArray(e)&&e.every(Ql)}function hS(e){let t=ou(Gn.post(Zt,async({request:n})=>{let o=await n.clone().json();if(Ql(o)){let r=e(o);return r?cn.json(r):ln()}if(Sy(o)){let r=o.map(a=>e(a));return r.some(a=>a===void 0)?ln():cn.json(r)}invariant(false,"body is not a valid JSON-RPC request or batch");}),Gn.post(Zt,()=>ln()));return ar(()=>{t.listen();}),ir(()=>{t.close();}),t}function gS(e){let t=createPublicClient({transport:http(Zt)});async function n(o,r){return t.request({method:o,params:r??[]})}return {async request(o){let r=await e(o);if(r!==void 0){if("error"in r)throw r.error;return r.result}return n(o.method,o.params)}}}/*! Bundled license information:
44
+ If this is a long-running ${e?"hook":"test"}, pass a timeout value as the last argument or configure it globally with "${e?"hookTimeout":"testTimeout"}".`,r=new Error(o);return n?.stack&&(r.stack=n.stack.replace(r.message,n.message)),r}var Og=new WeakMap;function zg(e){let t=Og.get(e);if(!t)throw new Error(`Cannot find file context for ${e.name}`);return t}var De=[];for(let e=65;e<91;e++)De.push(String.fromCharCode(e));for(let e=97;e<123;e++)De.push(String.fromCharCode(e));for(let e=0;e<10;e++)De.push(e.toString(10));function qg(e){let t="",n=e.byteLength;for(let o=0;o<n;o+=3)if(n===o+1){let r=(e[o]&252)>>2,a=(e[o]&3)<<4;t+=De[r],t+=De[a],t+="==";}else if(n===o+2){let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2;t+=De[r],t+=De[a],t+=De[i],t+="=";}else {let r=(e[o]&252)>>2,a=(e[o]&3)<<4|(e[o+1]&240)>>4,i=(e[o+1]&15)<<2|(e[o+2]&192)>>6,s=e[o+2]&63;t+=De[r],t+=De[a],t+=De[i],t+=De[s];}return t}function il(e,t){return t=t.finally(()=>{if(!e.promises)return;let n=e.promises.indexOf(t);n!==-1&&e.promises.splice(n,1);}),e.promises||(e.promises=[]),e.promises.push(t),t}function rr(){return bl().config.hookTimeout}var Dg=Symbol.for("VITEST_CLEANUP_TIMEOUT"),Ng=Symbol.for("VITEST_CLEANUP_STACK_TRACE");function ar(e,t=rr()){xn(e,'"beforeAll" callback',["function"]);let n=new Error("STACK_TRACE_ERROR");return Qt().on("beforeAll",Object.assign(It(e,t,true,n),{[Dg]:t,[Ng]:n}))}function ir(e,t){return xn(e,'"afterAll" callback',["function"]),Qt().on("afterAll",It(e,rr(),true,new Error("STACK_TRACE_ERROR")))}Ci(Il());var ur={currency:Currency.Usd,timeWindow:TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function Ol(e,t,{batch:n=ur.batch,requestPolicy:o=ur.requestPolicy}=ur){return e.query(ChainQuery,{request:t},{batch:n,requestPolicy:o})}function zl(e,t){return e.query(HasProcessedKnownTransactionQuery,{request:t},{requestPolicy:"network-only",batch:false})}var xi=(e,t,n,o)=>BigInt(e[o.fieldName]),dt=(e,t,n,o)=>BigDecimal.new(e[o.fieldName]),Ot=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:dt(e,t,n,o)},$=(e,t,n,o)=>new Date(e[o.fieldName]),cr=(e,t,n,o)=>{let r=e[o.fieldName];return r==null?null:$(e,t,n,o)},ql=cacheExchange({schema:ny,resolvers:{PercentNumber:{onChainValue:xi,value:dt,normalized:dt},DecimalNumber:{onChainValue:xi,value:dt},ExchangeAmount:{value:dt},AssetPriceSample:{price:dt,date:$},Reserve:{borrowCap:dt,supplyCap:dt},HealthFactorError:{current:Ot,after:Ot},HealthFactorVariation:{current:Ot,after:Ot},HealthFactorWithChange:{current:Ot},UserSummary:{lowestHealthFactor:Ot},UserSummaryHistoryItem:{healthFactor:Ot,date:$},TransactionRequest:{value:xi},ApySample:{date:$},AssetBorrowSample:{date:$},AssetSupplySample:{date:$},HubSummarySample:{date:$},PreviewMerklBorrowReward:{startDate:$,endDate:$},PreviewMerklSupplyReward:{startDate:$,endDate:$},ProtocolHistorySample:{date:$},BorrowActivity:{timestamp:$},LiquidatedActivity:{timestamp:$},MerklBorrowReward:{startDate:$,endDate:$},MerklSupplyReward:{startDate:$,endDate:$},RepayActivity:{timestamp:$},SupplyActivity:{timestamp:$},WithdrawActivity:{timestamp:$},UsingAsCollateralActivity:{timestamp:$},UpdatedDynamicConfigActivity:{timestamp:$},UpdatedRiskPremiumActivity:{timestamp:$},TokenSwapActivity:{timestamp:$},SupplySwapActivity:{timestamp:$},BorrowSwapActivity:{timestamp:$},RepayWithSupplyActivity:{timestamp:$},WithdrawSwapActivity:{timestamp:$},UserMerklClaimableReward:{startDate:$,endDate:$,claimUntil:$},UserPosition:{createdAt:$},UserBorrowItem:{createdAt:cr},UserSupplyItem:{createdAt:cr},SpokeUserPositionManager:{approvedOn:$},SwapCancelled:{createdAt:$,cancelledAt:cr},SwapCancelledResult:{createdAt:$,cancelledAt:cr},SwapExpired:{createdAt:$,expiredAt:$},SwapFulfilled:{createdAt:$,fulfilledAt:$},SwapOpen:{createdAt:$,deadline:$},SwapPendingSignature:{createdAt:$,deadline:$},SwapReceipt:{createdAt:$},Query:{hub:(e,{request:t})=>isHubInputVariant(t.query)?{__typename:"Hub",id:encodeHubId(t.query.hubInput)}:{__typename:"Hub",id:t.query.hubId},reserve:(e,{request:t})=>isReserveInputVariant(t.query)?{__typename:"Reserve",id:encodeReserveId(t.query.reserveInput)}:{__typename:"Reserve",id:t.query.reserveId},userPosition:(e,{request:t})=>{if("userSpoke"in t&&t.userSpoke){let{chainId:n,address:o}=decodeSpokeId(t.userSpoke.spoke);return {__typename:"UserPosition",id:encodeUserPositionId({chainId:n,spoke:o,user:t.userSpoke.user})}}if("id"in t&&t.id)return {__typename:"UserPosition",id:t.id}},activities:(e,t,n)=>{if(!isTxHashInputVariant(t.request.query))return n.resolve("Query","activities",t);let{txHash:o,chainId:r}=t.request.query.txHash,a=n.inspectFields("Query").filter(i=>i.fieldName==="activities").reduce((i,s)=>{let u=n.resolve("Query",s.fieldKey);if(!u)return i;let c=n.resolve(u,"items");if(!c)return i;for(let l of c)i.add(l);return i},new Set).values().toArray().filter(i=>{if(n.resolve(i,"txHash")!==o)return false;let u=n.resolve(i,"spoke");if(u){let c=n.resolve(u,"chain"),l=c?n.resolve(c,"chainId"):void 0;if(typeof l=="number")return l===r}return true});if(a.length!==0)return {__typename:"PaginatedActivitiesResult",items:a,pageInfo:{__typename:"PaginatedResultInfo",prev:null,next:null}}}}},keys:{Asset:e=>e.id,BorrowActivity:e=>e.id,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 lr={name:"production",backend:"https://api.aave.com/graphql",indexingTimeout:6e4,pollingInterval:100,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Dl={name:"staging",backend:"https://api.staging.aave.com/graphql",indexingTimeout:6e4,pollingInterval:500,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3},Nl={name:"local",backend:"http://localhost:3007/graphql",indexingTimeout:6e4,pollingInterval:1e3,exchangeRateInterval:1e4,swapQuoteInterval:3e4,swapStatusInterval:5e3};function Ml({environment:e=lr,headers:t,cache:n=true,batch:o=true,debug:r=false}){return {displayName:"AaveClient",environment:e,headers:t,cache:n?ql:null,batch:o,debug:r}}function Ll(e){return e.operations!==null&&e.operations.length>0}function Fl(e){return {__typename:"TransactionReceipt",txHash:e}}var pr=class e extends GqlClient{static create(t){return new e(Ml(t??{}))}waitForTransaction=t=>(invariant(Ll(t),"AaveClient.waitForTransaction called with an non-tracked operation. See the documentation for correct tracking setup."),ResultAsync.fromPromise(this.pollTransactionStatus(t),n=>n instanceof TimeoutError||n instanceof UnexpectedError?n:UnexpectedError.from(n)));async pollTransactionStatus(t){let n=Date.now();for(;Date.now()-n<this.context.environment.indexingTimeout;){if(await zl(this,t).match(r=>r,r=>{throw r}))return Fl(t.txHash);await delay(this.context.environment.pollingInterval);}throw TimeoutError.from(`Timeout waiting for transaction ${t.txHash} to be processed.`)}};function Vl(e){switch(e.chainId){case chainId(mainnet.id):return mainnet;case chainId(sepolia.id):return sepolia}return defineChain({id:e.chainId,name:e.name,nativeCurrency:{name:e.nativeInfo.name,symbol:e.nativeInfo.symbol,decimals:e.nativeInfo.decimals},rpcUrls:{default:{http:[e.rpcUrl]}},blockExplorers:{default:{name:`${e.name} Explorer`,url:e.explorerUrl}}})}var ky=import.meta.env.ENVIRONMENT==="local"?Nl:import.meta.env.ENVIRONMENT==="production"?lr:Dl,tn=chainId(Number.parseInt(import.meta.env.ETHEREUM_TENDERLY_FORK_ID,10)),YE=evmAddress("0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f"),QE=evmAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),ZE=evmAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),eS=evmAddress("0xdC035D45d973E3EC169d2276DDab16f1e407384F"),tS=evmAddress("0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"),nS=evmAddress("0x111111111117dC0aa78b770fA6A738034120C302"),oS=evmAddress("0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"),rS=evmAddress("0xdac17f958d2ee523a2206206994597c13d831ec7"),aS=evmAddress("0x4c9EDD5852cd905f086C759E8383e09bff1E68B3"),vy=evmAddress("0x46539e9123A18c427e6b4DFF114c28CF405Cb023"),iS=encodeSpokeId({chainId:tn,address:vy}),jy=evmAddress("0xf3b207c235f6154120F41eB63D5ACCBAfD4086D1"),sS=encodeSpokeId({chainId:tn,address:jy}),wy=evmAddress("0x3Ed2C9829FBCab6015E331a0352F8ae148217D70"),uS=encodeHubId({chainId:tn,address:wy}),Zt=import.meta.env.ETHEREUM_TENDERLY_PUBLIC_RPC,mr=import.meta.env.ETHEREUM_TENDERLY_ADMIN_RPC,xy=pr.create({environment:ky}),zn=await Ol(xy,{chainId:tn}).map(nonNullable).map(Vl).match(e=>e,()=>never("No devnet chain found"));async function cS(){return createPublicClient({chain:zn,transport:http(Zt)})}async function lS(e){if(!e){let t=generatePrivateKey(),n=createWalletClient({account:privateKeyToAccount(t),chain:zn,transport:http()});return await Ey(evmAddress(n.account.address)),n}return createWalletClient({account:privateKeyToAccount(e),chain:zn,transport:http()})}function Ey(e,t=bigDecimal("1.0")){let n=createPublicClient({chain:{id:tn,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[mr]}}},transport:http(mr)}),r=`0x${parseEther(t.toString()).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setBalance",params:[[e],r]}),a=>UnexpectedError.from(a))}function pS(e,t){let n=createPublicClient({chain:{id:tn,name:"Tenderly Fork",network:"tenderly-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[mr]}}},transport:http(mr)}),r=`0x${parseUnits(t.amount.toString(),t.decimals??18).toString(16)}`;return ResultAsync.fromPromise(n.request({method:"tenderly_setErc20Balance",params:[t.address,e,r]}),a=>UnexpectedError.from(a))}function mS(e){return new Promise(t=>setTimeout(t,e))}async function fS(e,t){let n=createPublicClient({chain:zn,transport:http(Zt)}),[o,r]=await Promise.all([n.readContract({address:t,abi:[{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"balanceOf",args:[e]}),n.readContract({address:t,abi:[{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"pure",type:"function"}],functionName:"decimals"})]);return bigDecimal(o).rescale(-r)}async function dS(e){let n=await createPublicClient({chain:zn,transport:http(Zt)}).getBalance({address:e});return bigDecimal(n).rescale(-18)}function Ql(e){return isObject(e)&&"jsonrpc"in e&&"method"in e}function Sy(e){return Array.isArray(e)&&e.every(Ql)}function hS(e){let t=ou(Gn.post(Zt,async({request:n})=>{let o=await n.clone().json();if(Ql(o)){let r=e(o);return r?cn.json(r):ln()}if(Sy(o)){let r=o.map(a=>e(a));return r.some(a=>a===void 0)?ln():cn.json(r)}invariant(false,"body is not a valid JSON-RPC request or batch");}),Gn.post(Zt,()=>ln()));return ar(()=>{t.listen();}),ir(()=>{t.close();}),t}function gS(e){let t=createPublicClient({transport:http(Zt)});async function n(o,r){return t.request({method:o,params:r??[]})}return {async request(o){let r=await e(o);if(r!==void 0){if("error"in r)throw r.error;return r.result}return n(o.method,o.params)}}}/*! Bundled license information:
45
45
 
46
46
  @bundled-es-modules/statuses/index-esm.js:
47
47
  (*! Bundled license information: