@aave/react 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/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {b}from'./chunk-QETO2FYE.js';export{c as useChain,d as useChainAction,e as useChains,g as useExchangeRate,f as useExchangeRateAction}from'./chunk-QETO2FYE.js';import {a,b as b$1}from'./chunk-4NA4FB6K.js';export{b as useAaveClient}from'./chunk-4NA4FB6K.js';import {a as a$1,b as b$2,d,c}from'./chunk-M23T3ICP.js';import {DEFAULT_QUERY_OPTIONS,supportsPermit,UnexpectedError as UnexpectedError$1,transactionReceipt}from'@aave/client';export*from'@aave/client';import qe,{useState,useEffect,useCallback}from'react';import {hubs,reserve,reserves,userClaimableRewards,tokenSwapQuote,supplySwapQuote,borrowSwapQuote,preparePositionSwap,repayWithSupplyQuote,withdrawSwapQuote,swap,prepareTokenSwap,swapStatus,prepareSwapCancel,cancelSwap,supply,borrow,repay,withdraw,renounceSpokeUserPositionManager,updateUserPositionConditions,setUserSuppliesAsCollateral,liquidatePosition,setSpokeUserPositionManager,preview,activities,claimRewards,userSupplies,userBorrows,userPositions,userBalances}from'@aave/client/actions';import {HubQuery,HubsQuery,HubAssetsQuery,HubSummaryHistoryQuery,AssetQuery,AssetPriceHistoryQuery,AssetSupplyHistoryQuery,AssetBorrowHistoryQuery,ProtocolHistoryQuery,ReserveQuery,ReservesQuery,BorrowApyHistoryQuery,SupplyApyHistoryQuery,UserClaimableRewardsQuery,SpokeQuery,SpokesQuery,SpokePositionManagersQuery,SpokeUserPositionManagersQuery,TokenSwapQuoteQuery,QuoteAccuracy,SwappableTokensQuery,UserSwapsQuery,SwapStatusQuery,SupplySwapQuoteQuery,BorrowSwapQuoteQuery,RepayWithSupplyQuoteQuery,WithdrawSwapQuoteQuery,decodeReserveId,PreviewQuery,ActivitiesQuery,UserSuppliesQuery,UserBorrowsQuery,UserSummaryQuery,UserPositionsQuery,UserPositionQuery,UserBalancesQuery,UserRiskPremiumBreakdownQuery,UserSummaryHistoryQuery,isSpokeInputVariant,isChainIdsVariant,decodeUserPositionId}from'@aave/graphql';import {okAsync,never,isSignature,ResultAwareError,errAsync,ResultAsync,err,ok,expectTypename}from'@aave/types';import {UnexpectedError,ValidationError}from'@aave/core';function or({children:e,client:s}){return qe.createElement(a,{client:s},e)}function Le(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:s}=decodeUserPositionId(e.userPositionId);return s}function Ve(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:s}=decodeUserPositionId(e.userPositionId);return s}function X(e,s){return e.refreshQueryWhere(UserBalancesQuery,r=>r.request.user===s)}function I(e,s){return e.refreshQueryWhere(UserSuppliesQuery,r=>Le(r.request.query)===s)}function W(e,s){return e.refreshQueryWhere(UserBorrowsQuery,r=>Ve(r.request.query)===s)}function O(e,s,r){let t=n=>n.spoke.chain.chainId===r.chainId&&n.spoke.address===r.address&&n.user===s;return ResultAsync.combine([e.refreshQueryWhere(UserPositionsQuery,(n,a)=>a.some(t)),e.refreshQueryWhere(UserPositionQuery,(n,a)=>a!==null&&t(a))])}function N(e,s){let r=t=>s.includes(t.id);return ResultAsync.combine([e.refreshQueryWhere(ReserveQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(ReservesQuery,(t,n)=>n.some(r))])}function _(e,s,r){return e.refreshQueryWhere(UserSummaryQuery,t=>t.request.user===s&&(isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===r.chainId&&t.request.filter.spoke.address===r.address:isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(n=>n===r.chainId):false))}function D(e,s){let r=t=>t.chain.chainId===s.chainId&&t.address===s.address;return ResultAsync.combine([e.refreshQueryWhere(SpokeQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(SpokesQuery,(t,n)=>n.some(r))])}function M(e,s){let r=t=>t.chain.chainId===s;return ResultAsync.combine([e.refreshQueryWhere(HubQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(HubsQuery,(t,n)=>n.some(r))])}function F(e,s){return e.refreshQueryWhere(SpokePositionManagersQuery,r=>r.request.spoke===s)}function Z(e,s){return ResultAsync.combine([e.refreshQueryWhere(UserPositionsQuery,(r,t)=>t.some(n=>n.id===s)),e.refreshQueryWhere(UserPositionQuery,(r,t)=>t?.id===s)])}function wr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:HubQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function fr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:HubsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function mr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:HubAssetsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Pr({suspense:e=false,pause:s=false,...r}){return b({document:HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ar(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>hubs(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function Qr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:AssetQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function hr({suspense:e=false,pause:s=false,...r}){return b({document:AssetPriceHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function kr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:AssetSupplyHistoryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function qr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:AssetBorrowHistoryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function vr({suspense:e=false,pause:s=false,...r}){return b({document:ProtocolHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Or({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:ReserveQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Nr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>reserve(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function _r({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:ReservesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Dr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>reserves(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Mr({suspense:e=false,pause:s=false,...r}){return b({document:BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Fr({suspense:e=false,pause:s=false,...r}){return b({document:SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function $r({suspense:e=false,pause:s=false,...r}){return b({document:UserClaimableRewardsQuery,variables:{request:r},suspense:e,pause:s})}function zr(){let e=b$1();return a$1(s=>userClaimableRewards(e,s,{requestPolicy:"cache-first"}),[e])}function Zr({suspense:e=false,pause:s=false,...r}){return b({document:SpokeQuery,variables:{request:r},suspense:e,pause:s})}function et({suspense:e=false,pause:s=false,...r}){return b({document:SpokesQuery,variables:{request:r},suspense:e,pause:s})}function st({suspense:e=false,pause:s=false,...r}){return b({document:SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function rt({suspense:e=false,pause:s=false,...r}){return b({document:SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function V(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return ok(e.quote);case "InsufficientLiquidityError":return err(ValidationError.fromGqlNode(e));default:return err(UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`))}}function ue(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}function U(e){switch(e.__typename){case "PositionSwapByIntentApprovalsRequired":return ok(e.quote);case "InsufficientLiquidityError":return err(ValidationError.fromGqlNode(e));default:return err(UnexpectedError.upgradeRequired(`Unsupported position swap quote result: ${e.__typename}`))}}function oe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function ie(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function pe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function le(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function ce(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function St({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$1(),a=b({document:TokenSwapQuoteQuery,variables:{request:oe(t,QuoteAccuracy.Fast),currency:r},selector:V,suspense:e,pause:s,batch:false}),p=b({document:TokenSwapQuoteQuery,variables:{request:oe(t,QuoteAccuracy.Accurate),currency:r},selector:V,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return p.data?p:a}function dt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(V),[s,e.currency])}function Rt({suspense:e=false,pause:s=false,...r}){return b({document:SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function Ut({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=b$1(),[p,S]=useState(false),d=b({document:UserSwapsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||p,pollInterval:a.context.environment.swapStatusInterval});return useEffect(()=>{d.data&&d.data.items.length>0&&d.data.items.every(be)&&S(true);},[d.data]),d}function be(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function wt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=b$1(),[p,S]=useState(false),d=b({document:SwapStatusQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||p,pollInterval:a.context.environment.swapStatusInterval});return useEffect(()=>{d.data&&be(d.data)&&S(true);},[d.data]),d}function ft({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$1(),a=b({document:SupplySwapQuoteQuery,variables:{request:ie(t,QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),p=b({document:SupplySwapQuoteQuery,variables:{request:ie(t,QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return p.data?p:a}function mt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function Pt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$1(),a=b({document:BorrowSwapQuoteQuery,variables:{request:pe(t,QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),p=b({document:BorrowSwapQuoteQuery,variables:{request:pe(t,QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return p.data?p:a}function At(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function H(e){return {with:s=>e.approvals.reduce((r,t)=>r.andThen(n=>s(t,{cancel:b$2}).map(a=>{switch(t.__typename){case "PositionSwapAdapterContractApproval":n.adapterContractSignature=isSignature(a)?a:null;break;case "PositionSwapPositionManagerApproval":n.positionManagerSignature=isSignature(a)?a:null;break}return n})),okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function B(e,s){return swap(e,{intent:s}).andThen(r=>{switch(r.__typename){case "SwapReceipt":return okAsync(r);default:return UnexpectedError.from(r).asResultAsync()}})}function bt(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...t})=>supplySwapQuote(s,t,{currency:r}).andThen(n=>H(n).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).andThen(d).andThen(p=>B(s,{quoteId:a.newQuoteId,signature:p})))),[s,e])}function gt(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...t})=>borrowSwapQuote(s,t,{currency:r}).andThen(n=>H(n).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).andThen(d).andThen(p=>B(s,{quoteId:a.newQuoteId,signature:p})))),[s,e])}function Tt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$1(),a=b({document:RepayWithSupplyQuoteQuery,variables:{request:le(t,QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),p=b({document:RepayWithSupplyQuoteQuery,variables:{request:le(t,QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return p.data?p:a}function xt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function Qt(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...t})=>repayWithSupplyQuote(s,t,{currency:r}).andThen(n=>H(n).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).andThen(d).andThen(p=>B(s,{quoteId:a.newQuoteId,signature:p})))),[s,e])}function ht({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$1(),a=b({document:WithdrawSwapQuoteQuery,variables:{request:ce(t,QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),p=b({document:WithdrawSwapQuoteQuery,variables:{request:ce(t,QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return p.data?p:a}function kt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function qt(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...t})=>withdrawSwapQuote(s,t,{currency:r}).andThen(n=>H(n).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).andThen(d).andThen(p=>B(s,{quoteId:a.newQuoteId,signature:p})))),[s,e])}function vt(e){let s=b$1(),r=useCallback(t=>swap(s,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:b$2}).andThen(c.tryFrom).andThen(a=>a.wait()).andThen(()=>okAsync(n.orderReceipt));case "SwapReceipt":return okAsync(n)}}),[s,e]);return a$1(({currency:t=DEFAULT_QUERY_OPTIONS.currency,...n})=>tokenSwapQuote(s,n,{currency:t}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return r({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return prepareTokenSwap(s,{quoteId:a.quote.quoteId}).andThen(p=>e(p.data,{cancel:b$2}).andThen(d).andThen(S=>r({intent:{quoteId:p.newQuoteId,signature:S}})));case "SwapByIntentWithApprovalRequired":if(supportsPermit(a)){let p=a.approvals[0];return e(p,{cancel:b$2}).andThen(S=>isSignature(S)?prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:{deadline:p.bySignature.message.deadline,value:S}}):c.isInstanceOf(S)?S.wait().andThen(()=>prepareTokenSwap(s,{quoteId:a.quote.quoteId})):UnexpectedError.from(S).asResultAsync()).andThen(S=>e(S.data,{cancel:b$2}).andThen(d).andThen(d=>r({intent:{quoteId:S.newQuoteId,signature:d}})))}return a.approvals.reduce((p,S)=>p.andThen(()=>e({...S,bySignature:null},{cancel:b$2}).andThen(c.tryFrom).andThen(d=>d.wait())),okAsync(void 0)).andThen(()=>prepareTokenSwap(s,{quoteId:a.quote.quoteId})).andThen(p=>e(p.data,{cancel:b$2})).andThen(d).andThen(p=>r({intent:{quoteId:a.quote.quoteId,signature:p}}));default:never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var v=class extends ResultAwareError{name="CannotCancelSwapError"};function Et(e){let s=b$1();return a$1(r=>swapStatus(s,{id:r.id}).andThen(t=>{if(t===null)return UnexpectedError.from("Swap not found").asResultAsync();switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return prepareSwapCancel(s,r).andThen(n=>e(n.data,{cancel:b$2})).andThen(d).andThen(n=>cancelSwap(s,{intent:{id:r.id,signature:n}})).andThen(n=>n.__typename==="SwapCancelledResult"?okAsync(n):e(n,{cancel:b$2}).andThen(c.tryFrom).andThen(a=>a.wait()).andThen(()=>swapStatus(s,{id:r.id})).andThen(a=>a?.__typename==="SwapCancelled"?okAsync(ue(a)):new v("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return okAsync(ue(t));case "SwapExpired":return new v("Swap cannot longer be cancelled").asResultAsync();default:return UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function C(e,s){let{chainId:r,spoke:t}=decodeReserveId(s.reserve),n={chainId:r,address:t};return ResultAsync.combine([O(e,s.sender,n),_(e,s.sender,n),N(e,[s.reserve]),D(e,n),X(e,s.sender),I(e,s.sender),W(e,s.sender),M(e,r)])}function Os(e,s){return {deadline:s.message.deadline,value:e}}function G(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:b$2}).andThen(c.tryFrom).andThen(n=>n.wait())),okAsync(void 0)).map(()=>e.originalTransaction)}function Y(e,s,r){let t=e.approvals[0];return s(t,{cancel:b$2}).andThen(n=>isSignature(n)?r(Os(n,t.bySignature)).map(expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function Dt(e){let s=b$1();return a$1(r=>supply(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$2});case "Erc20ApprovalRequired":return supportsPermit(t)?Y(t,e,n=>supply(s,Ns(r,n))).andThen(n=>e(n,{cancel:b$2})):G(t,e).andThen(n=>e(n,{cancel:b$2}));case "PreContractActionRequired":return e(t,{cancel:b$2}).andThen(c.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$2}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t))}}).andThen(c.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>C(s,r)),[s,e])}function Ns(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Mt(e){let s=b$1();return a$1(r=>borrow(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$2});case "PreContractActionRequired":return e(t,{cancel:b$2}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$2}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return UnexpectedError$1.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>C(s,r)),[s,e])}function Ft(e){let s=b$1();return a$1(r=>repay(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$2});case "Erc20ApprovalRequired":return supportsPermit(t)?Y(t,e,n=>repay(s,_s(r,n))).andThen(n=>e(n,{cancel:b$2})):G(t,e).andThen(n=>e(n,{cancel:b$2}));case "PreContractActionRequired":return e(t,{cancel:b$2}).andThen(c.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$2}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t))}}).andThen(c.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>C(s,r)),[s,e])}function _s(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Lt(e){let s=b$1();return a$1(r=>withdraw(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$2});case "PreContractActionRequired":return e(t,{cancel:b$2}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$2}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return UnexpectedError$1.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>C(s,r)),[s,e])}function Vt(e){let s=b$1();return a$1(r=>renounceSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:b$2})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>F(s,r.spoke)),[s,e])}function jt(e){let s=b$1();return a$1(r=>updateUserPositionConditions(s,r).andThen(t=>e(t,{cancel:b$2})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>Z(s,r.userPositionId)),[s,e])}function Gt(e){let s=b$1();return a$1(r=>{let t=r.changes.map(a=>a.reserve),n=t.map(a=>decodeReserveId(a));return setUserSuppliesAsCollateral(s,r).andThen(a=>e(a,{cancel:b$2})).andThen(a=>a.wait()).andThen(s.waitForTransaction).andThrough(()=>ResultAsync.combine([I(s,r.sender),W(s,r.sender),...n.flatMap(({chainId:a,spoke:p})=>[O(s,r.sender,{chainId:a,address:p}),_(s,r.sender,{chainId:a,address:p}),D(s,{chainId:a,address:p})]),N(s,t),...n.map(({chainId:a})=>M(s,a))]))},[s,e])}function Yt(e){let s=b$1();return a$1(r=>liquidatePosition(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$2});case "Erc20ApprovalRequired":return supportsPermit(t)?Y(t,e,n=>liquidatePosition(s,Ds(r))).andThen(n=>e(n,{cancel:b$2})):G(t,e).andThen(n=>e(n,{cancel:b$2}));case "PreContractActionRequired":return e(t,{cancel:b$2}).andThen(c.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$2}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t))}}).andThen(c.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction),[s,e])}function Ds(e,s){return e}function $t(e){let s=b$1();return a$1(r=>setSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:b$2})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>F(s,r.spoke)),[s,e])}function zt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>preview(s,r,{currency:e.currency,requestPolicy:"network-only"}),[s,e.currency])}function Jt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){return b({document:PreviewQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function Kt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:ActivitiesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Xt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>activities(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Zt(e){let s=b$1();return a$1(r=>claimRewards(s,r).andThen(t=>e(t,{cancel:b$2})).andThen(c.tryFrom).andThen(t=>t.wait()).map(t=>transactionReceipt(t.txHash)),[s,e])}function un({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:UserSuppliesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function on(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userSupplies(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function pn({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:UserBorrowsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ln(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userBorrows(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function cn({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:UserSummaryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function yn({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:UserPositionsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Sn(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function dn({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b({document:UserPositionQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Rn({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){return b({document:UserBalancesQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function Un({suspense:e=false,pause:s=false,...r}){return b({document:UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function wn(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userBalances(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function fn({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...t}){return b({document:UserSummaryHistoryQuery,variables:{request:t,currency:r},suspense:e,pause:s,batch:false})}export{or as AaveProvider,v as CannotCancelSwapError,Kt as useActivities,Xt as useActivitiesAction,Qr as useAsset,qr as useAssetBorrowHistory,hr as useAssetPriceHistory,kr as useAssetSupplyHistory,Mt as useBorrow,Mr as useBorrowApyHistory,gt as useBorrowSwap,Pt as useBorrowSwapQuote,At as useBorrowSwapQuoteAction,Et as useCancelSwap,Zt as useClaimRewards,wr as useHub,mr as useHubAssets,Pr as useHubSummaryHistory,fr as useHubs,Ar as useHubsAction,Yt as useLiquidatePosition,Jt as usePreview,zt as usePreviewAction,vr as useProtocolHistory,Vt as useRenounceSpokeUserPositionManager,Ft as useRepay,Qt as useRepayWithSupply,Tt as useRepayWithSupplyQuote,xt as useRepayWithSupplyQuoteAction,Or as useReserve,Nr as useReserveAction,_r as useReserves,Dr as useReservesAction,$t as useSetSpokeUserPositionManager,Gt as useSetUserSuppliesAsCollateral,Zr as useSpoke,st as useSpokePositionManagers,rt as useSpokeUserPositionManagers,et as useSpokes,Dt as useSupply,Fr as useSupplyApyHistory,bt as useSupplySwap,ft as useSupplySwapQuote,mt as useSupplySwapQuoteAction,wt as useSwapStatus,Rt as useSwappableTokens,vt as useTokenSwap,St as useTokenSwapQuote,dt as useTokenSwapQuoteAction,jt as useUpdateUserPositionConditions,Rn as useUserBalances,wn as useUserBalancesAction,pn as useUserBorrows,ln as useUserBorrowsAction,$r as useUserClaimableRewards,zr as useUserClaimableRewardsAction,dn as useUserPosition,yn as useUserPositions,Sn as useUserPositionsAction,Un as useUserRiskPremiumBreakdown,cn as useUserSummary,fn as useUserSummaryHistory,un as useUserSupplies,on as useUserSuppliesAction,Ut as useUserSwaps,Lt as useWithdraw,qt as useWithdrawSwap,ht as useWithdrawSwapQuote,kt as useWithdrawSwapQuoteAction};//# sourceMappingURL=index.js.map
1
+ import {b as b$1}from'./chunk-WQZMMTVR.js';export{c as useChain,d as useChainAction,e as useChains,g as useExchangeRate,f as useExchangeRateAction}from'./chunk-WQZMMTVR.js';import {a,b as b$2}from'./chunk-4NA4FB6K.js';export{b as useAaveClient}from'./chunk-4NA4FB6K.js';import {a as a$1,b as b$3,d,c}from'./chunk-4LHXPD6N.js';import {DEFAULT_QUERY_OPTIONS,supportsPermit,UnexpectedError as UnexpectedError$1,transactionReceipt}from'@aave/client';export*from'@aave/client';import ve,{useState,useEffect,useCallback,useDeferredValue}from'react';import {hubs,reserve,reserves,userClaimableRewards,borrowSwapQuote,preparePositionSwap,swapStatus,prepareSwapCancel,cancelSwap,repayWithSupplyQuote,supplySwapQuote,swap,tokenSwapQuote,prepareTokenSwap,withdrawSwapQuote,activities,borrow,claimRewards,liquidatePosition,preview,renounceSpokeUserPositionManager,repay,setSpokeUserPositionManager,setUserSuppliesAsCollateral,supply,updateUserPositionConditions,withdraw,userSupplies,userBorrows,userPositions,userBalances}from'@aave/client/actions';import {HubQuery,HubsQuery,HubAssetsQuery,HubSummaryHistoryQuery,AssetQuery,AssetPriceHistoryQuery,AssetSupplyHistoryQuery,AssetBorrowHistoryQuery,ProtocolHistoryQuery,ReserveQuery,ReservesQuery,BorrowApyHistoryQuery,SupplyApyHistoryQuery,UserClaimableRewardsQuery,SpokeQuery,SpokesQuery,SpokePositionManagersQuery,SpokeUserPositionManagersQuery,BorrowSwapQuoteQuery,QuoteAccuracy,RepayWithSupplyQuoteQuery,SupplySwapQuoteQuery,SwappableTokensQuery,SwapStatusQuery,TokenSwapQuoteQuery,UserSwapsQuery,WithdrawSwapQuoteQuery,ActivitiesQuery,PreviewQuery,decodeReserveId,UserSuppliesQuery,UserBorrowsQuery,UserSummaryQuery,UserPositionsQuery,UserPositionQuery,UserBalancesQuery,UserRiskPremiumBreakdownQuery,UserSummaryHistoryQuery,isSpokeInputVariant,isChainIdsVariant,decodeUserPositionId}from'@aave/graphql';import {ResultAwareError,okAsync,never,isSignature,errAsync,ResultAsync,err,ok,expectTypename}from'@aave/types';import {UnexpectedError,ValidationError}from'@aave/core';function Ht({children:e,client:r}){return ve.createElement(a,{client:r},e)}function Ve(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:r}=decodeUserPositionId(e.userPositionId);return r}function Ye(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:r}=decodeUserPositionId(e.userPositionId);return r}function x(e,r){return e.refreshQueryWhere(UserBalancesQuery,s=>s.request.user===r)}function Q(e,r){return e.refreshQueryWhere(UserSuppliesQuery,s=>Ve(s.request.query)===r)}function q(e,r){return e.refreshQueryWhere(UserBorrowsQuery,s=>Ye(s.request.query)===r)}function _(e,r,s){let t=n=>n.spoke.chain.chainId===s.chainId&&n.spoke.address===s.address&&n.user===r;return ResultAsync.combine([e.refreshQueryWhere(UserPositionsQuery,(n,a)=>a.some(t)),e.refreshQueryWhere(UserPositionQuery,(n,a)=>a!==null&&t(a))])}function D(e,r){let s=t=>r.includes(t.id);return ResultAsync.combine([e.refreshQueryWhere(ReserveQuery,(t,n)=>n!==null&&s(n)),e.refreshQueryWhere(ReservesQuery,(t,n)=>n.some(s))])}function N(e,r,s){return e.refreshQueryWhere(UserSummaryQuery,t=>t.request.user===r&&(isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===s.chainId&&t.request.filter.spoke.address===s.address:isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(n=>n===s.chainId):false))}function M(e,r){let s=t=>t.chain.chainId===r.chainId&&t.address===r.address;return ResultAsync.combine([e.refreshQueryWhere(SpokeQuery,(t,n)=>n!==null&&s(n)),e.refreshQueryWhere(SpokesQuery,(t,n)=>n.some(s))])}function F(e,r){let s=t=>t.chain.chainId===r;return ResultAsync.combine([e.refreshQueryWhere(HubQuery,(t,n)=>n!==null&&s(n)),e.refreshQueryWhere(HubsQuery,(t,n)=>n.some(s))])}function I(e,r){return e.refreshQueryWhere(SpokePositionManagersQuery,s=>s.request.spoke===r)}function z(e,r){return ResultAsync.combine([e.refreshQueryWhere(UserPositionsQuery,(s,t)=>t.some(n=>n.id===r)),e.refreshQueryWhere(UserPositionQuery,(s,t)=>t?.id===r)])}function P(e,r){let{chainId:s,spoke:t}=decodeReserveId(r.reserve),n={chainId:s,address:t};return ResultAsync.combine([_(e,r.sender,n),N(e,r.sender,n),D(e,[r.reserve]),M(e,n),x(e,r.sender),Q(e,r.sender),q(e,r.sender),F(e,s)])}function J(e,r){return x(e,r)}function K(e,r){return ResultAsync.combine([Q(e,r),x(e,r)])}function X(e,r){return ResultAsync.combine([q(e,r),x(e,r)])}function Z(e,r){return ResultAsync.combine([Q(e,r),q(e,r),x(e,r)])}function ee(e,r){return ResultAsync.combine([Q(e,r),x(e,r)])}function Ft({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:HubQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Lt({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:HubsQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Vt({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:HubAssetsQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Yt({suspense:e=false,pause:r=false,...s}){return b$1({document:HubSummaryHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function jt(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>hubs(r,s,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function Kt({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:AssetQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Xt({suspense:e=false,pause:r=false,...s}){return b$1({document:AssetPriceHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Zt({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:AssetSupplyHistoryQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r,batch:false})}function en({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:AssetBorrowHistoryQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r,batch:false})}function rn({suspense:e=false,pause:r=false,...s}){return b$1({document:ProtocolHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function pn({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:ReserveQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function ln(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>reserve(r,s,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function cn({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:ReservesQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function yn(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>reserves(r,s,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Sn({suspense:e=false,pause:r=false,...s}){return b$1({document:BorrowApyHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function dn({suspense:e=false,pause:r=false,...s}){return b$1({document:SupplyApyHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function An({suspense:e=false,pause:r=false,...s}){return b$1({document:UserClaimableRewardsQuery,variables:{request:s},suspense:e,pause:r})}function Pn(){let e=b$2();return a$1(r=>userClaimableRewards(e,r,{requestPolicy:"cache-first"}),[e])}function xn({suspense:e=false,pause:r=false,...s}){return b$1({document:SpokeQuery,variables:{request:s},suspense:e,pause:r})}function Qn({suspense:e=false,pause:r=false,...s}){return b$1({document:SpokesQuery,variables:{request:s},suspense:e,pause:r})}function En({suspense:e=false,pause:r=false,...s}){return b$1({document:SpokePositionManagersQuery,variables:{request:s},suspense:e,pause:r})}function hn({suspense:e=false,pause:r=false,...s}){return b$1({document:SpokeUserPositionManagersQuery,variables:{request:s},suspense:e,pause:r})}function m(e){switch(e.__typename){case "PositionSwapByIntentApprovalsRequired":return ok(e.quote);case "InsufficientLiquidityError":return err(ValidationError.fromGqlNode(e));default:return err(UnexpectedError.upgradeRequired(`Unsupported position swap quote result: ${e.__typename}`))}}function W(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function g(e){return {with:r=>e.approvals.reduce((s,t)=>s.andThen(n=>r(t,{cancel:b$3}).map(a=>{switch(t.__typename){case "PositionSwapAdapterContractApproval":n.adapterContractSignature=isSignature(a)?a:null;break;case "PositionSwapPositionManagerApproval":n.positionManagerSignature=isSignature(a)?a:null;break}return n})),okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function b(e,r){return swap(e,{intent:r}).andThen(s=>{switch(s.__typename){case "SwapReceipt":return okAsync(s);default:return UnexpectedError.from(s).asResultAsync()}})}function Ur(e){let r=b$2();return a$1(({currency:s=DEFAULT_QUERY_OPTIONS.currency,...t})=>borrowSwapQuote(r,t,{currency:s}).andThen(n=>g(n).with(e).andThen(a=>preparePositionSwap(r,a)).andThen(a=>e(a.data,{cancel:b$3}).andThen(d).andThen(l=>b(r,{quoteId:a.newQuoteId,signature:l})))),[r,e])}function ae(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Pr({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$2(),a=b$1({document:BorrowSwapQuoteQuery,variables:{request:ae(t,QuoteAccuracy.Fast),currency:s},selector:m,suspense:e,pause:r,batch:false}),l=b$1({document:BorrowSwapQuoteQuery,variables:{request:ae(t,QuoteAccuracy.Accurate),currency:s},selector:m,suspense:false,pause:r||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return l.data?l:a}function gr(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>borrowSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[r,e.currency])}function pe(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}var H=class extends ResultAwareError{name="CannotCancelSwapError"};function Qr(e){let r=b$2();return a$1(s=>swapStatus(r,{id:s.id}).andThen(t=>{if(t===null)return UnexpectedError.from("Swap not found").asResultAsync();switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return prepareSwapCancel(r,s).andThen(n=>e(n.data,{cancel:b$3})).andThen(d).andThen(n=>cancelSwap(r,{intent:{id:s.id,signature:n}})).andThen(n=>n.__typename==="SwapCancelledResult"?okAsync(n):e(n,{cancel:b$3}).andThen(c.tryFrom).andThen(a=>a.wait()).andThen(()=>swapStatus(r,{id:s.id})).andThen(a=>a?.__typename==="SwapCancelled"?okAsync(pe(a)):new H("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return okAsync(pe(t));case "SwapExpired":return new H("Swap cannot longer be cancelled").asResultAsync();default:return UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[r,e])}function vr(e){let r=b$2();return a$1(({currency:s=DEFAULT_QUERY_OPTIONS.currency,...t})=>repayWithSupplyQuote(r,t,{currency:s}).andThen(n=>g(n).with(e).andThen(a=>preparePositionSwap(r,a)).andThen(a=>e(a.data,{cancel:b$3}).andThen(d).andThen(l=>b(r,{quoteId:a.newQuoteId,signature:l})))),[r,e])}function ce(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function qr({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$2(),a=b$1({document:RepayWithSupplyQuoteQuery,variables:{request:ce(t,QuoteAccuracy.Fast),currency:s},selector:m,suspense:e,pause:r,batch:false}),l=b$1({document:RepayWithSupplyQuoteQuery,variables:{request:ce(t,QuoteAccuracy.Accurate),currency:s},selector:m,suspense:false,pause:r||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return l.data?l:a}function Hr(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>repayWithSupplyQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[r,e.currency])}function Br(e){let r=b$2();return a$1(({currency:s=DEFAULT_QUERY_OPTIONS.currency,...t})=>supplySwapQuote(r,t,{currency:s}).andThen(n=>g(n).with(e).andThen(a=>preparePositionSwap(r,a)).andThen(a=>e(a.data,{cancel:b$3}).andThen(d).andThen(l=>b(r,{quoteId:a.newQuoteId,signature:l})))),[r,e])}function de(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Or({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$2(),a=b$1({document:SupplySwapQuoteQuery,variables:{request:de(t,QuoteAccuracy.Fast),currency:s},selector:m,suspense:e,pause:r,batch:false}),l=b$1({document:SupplySwapQuoteQuery,variables:{request:de(t,QuoteAccuracy.Accurate),currency:s},selector:m,suspense:false,pause:r||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return l.data?l:a}function _r(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>supplySwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[r,e.currency])}function Nr({suspense:e=false,pause:r=false,...s}){return b$1({document:SwappableTokensQuery,variables:{request:s},suspense:e,pause:r})}function Vr({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=b$2(),[l,d]=useState(false),R=b$1({document:SwapStatusQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r||l,pollInterval:a.context.environment.swapStatusInterval});return useEffect(()=>{R.data&&W(R.data)&&d(true);},[R.data]),R}function Kr(e){let r=b$2(),s=useCallback(t=>swap(r,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:b$3}).andThen(c.tryFrom).andThen(a=>a.wait()).andThen(()=>okAsync(n.orderReceipt));case "SwapReceipt":return okAsync(n)}}),[r,e]);return a$1(({currency:t=DEFAULT_QUERY_OPTIONS.currency,...n})=>tokenSwapQuote(r,n,{currency:t}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return s({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return prepareTokenSwap(r,{quoteId:a.quote.quoteId}).andThen(l=>e(l.data,{cancel:b$3}).andThen(d).andThen(d=>s({intent:{quoteId:l.newQuoteId,signature:d}})));case "SwapByIntentWithApprovalRequired":if(supportsPermit(a)){let l=a.approvals[0];return e(l,{cancel:b$3}).andThen(d=>isSignature(d)?prepareTokenSwap(r,{quoteId:a.quote.quoteId,permitSig:{deadline:l.bySignature.message.deadline,value:d}}):c.isInstanceOf(d)?d.wait().andThen(()=>prepareTokenSwap(r,{quoteId:a.quote.quoteId})):UnexpectedError.from(d).asResultAsync()).andThen(d$1=>e(d$1.data,{cancel:b$3}).andThen(d).andThen(R=>s({intent:{quoteId:d$1.newQuoteId,signature:R}})))}return a.approvals.reduce((l,d)=>l.andThen(()=>e({...d,bySignature:null},{cancel:b$3}).andThen(c.tryFrom).andThen(R=>R.wait())),okAsync(void 0)).andThen(()=>prepareTokenSwap(r,{quoteId:a.quote.quoteId})).andThen(l=>e(l.data,{cancel:b$3})).andThen(d).andThen(l=>s({intent:{quoteId:a.quote.quoteId,signature:l}}));default:never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[r,e,s])}function L(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return ok(e.quote);case "InsufficientLiquidityError":return err(ValidationError.fromGqlNode(e));default:return err(UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`))}}function Ue(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function ss({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$2(),a=b$1({document:TokenSwapQuoteQuery,variables:{request:Ue(t,QuoteAccuracy.Fast),currency:s},selector:L,suspense:e,pause:r,batch:false}),l=b$1({document:TokenSwapQuoteQuery,variables:{request:Ue(t,QuoteAccuracy.Accurate),currency:s},selector:L,suspense:false,pause:r||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return l.data?l:a}function ts(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>tokenSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(L),[r,e.currency])}function ps(e,r){let s=new Map(r.map(t=>[t.swapId,t.__typename]));return e.filter(t=>t.__typename==="SwapFulfilled"&&s.get(t.swapId)!=="SwapFulfilled")}function is({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=b$2(),[l,d]=useState(false),R=b$1({document:UserSwapsQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r||l,pollInterval:a.context.environment.swapStatusInterval}),k=R.data?.items??[],V=useDeferredValue(k);return useEffect(()=>{if(k.length===0)return;k.every(W)&&d(true);for(let he of ps(k,V))switch(he.operation.__typename){case "TokenSwap":n.user&&J(a,n.user);break;case "BorrowSwap":n.user&&X(a,n.user);break;case "RepayWithSupply":n.user&&Z(a,n.user);break;case "SupplySwap":n.user&&K(a,n.user);break;case "WithdrawSwap":n.user&&ee(a,n.user);break}},[k,V,a,n.user]),R}function ys(e){let r=b$2();return a$1(({currency:s=DEFAULT_QUERY_OPTIONS.currency,...t})=>withdrawSwapQuote(r,t,{currency:s}).andThen(n=>g(n).with(e).andThen(a=>preparePositionSwap(r,a)).andThen(a=>e(a.data,{cancel:b$3}).andThen(d).andThen(l=>b(r,{quoteId:a.newQuoteId,signature:l})))),[r,e])}function be(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function ds({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){let n=b$2(),a=b$1({document:WithdrawSwapQuoteQuery,variables:{request:be(t,QuoteAccuracy.Fast),currency:s},selector:m,suspense:e,pause:r,batch:false}),l=b$1({document:WithdrawSwapQuoteQuery,variables:{request:be(t,QuoteAccuracy.Accurate),currency:s},selector:m,suspense:false,pause:r||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return l.data?l:a}function ms(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>withdrawSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[r,e.currency])}function ws({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:ActivitiesQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Us(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>activities(r,s,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Ts(e){let r=b$2();return a$1(s=>borrow(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$3});case "PreContractActionRequired":return e(t,{cancel:b$3}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$3}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return UnexpectedError$1.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>P(r,s)),[r,e])}function Es(e){let r=b$2();return a$1(s=>claimRewards(r,s).andThen(t=>e(t,{cancel:b$3})).andThen(c.tryFrom).andThen(t=>t.wait()).map(t=>transactionReceipt(t.txHash)),[r,e])}function qs(e,r){return {deadline:r.message.deadline,value:e}}function h(e,r){return e.approvals.reduce((s,t)=>s.andThen(()=>r({...t,bySignature:null},{cancel:b$3}).andThen(c.tryFrom).andThen(n=>n.wait())),okAsync(void 0)).map(()=>e.originalTransaction)}function v(e,r,s){let t=e.approvals[0];return r(t,{cancel:b$3}).andThen(n=>isSignature(n)?s(qs(n,t.bySignature)).map(expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function Bs(e,r){return e}function Ws(e){let r=b$2();return a$1(s=>liquidatePosition(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$3});case "Erc20ApprovalRequired":return supportsPermit(t)?v(t,e,n=>liquidatePosition(r,Bs(s))).andThen(n=>e(n,{cancel:b$3})):h(t,e).andThen(n=>e(n,{cancel:b$3}));case "PreContractActionRequired":return e(t,{cancel:b$3}).andThen(c.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$3}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t))}}).andThen(c.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction),[r,e])}function Ds(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>preview(r,s,{currency:e.currency,requestPolicy:"network-only"}),[r,e.currency])}function Ns({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){return b$1({document:PreviewQuery,variables:{request:t,currency:s},suspense:e,pause:r})}function Fs(e){let r=b$2();return a$1(s=>renounceSpokeUserPositionManager(r,s).andThen(t=>e(t,{cancel:b$3})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>I(r,s.spoke)),[r,e])}function js(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function Gs(e){let r=b$2();return a$1(s=>repay(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$3});case "Erc20ApprovalRequired":return supportsPermit(t)?v(t,e,n=>repay(r,js(s,n))).andThen(n=>e(n,{cancel:b$3})):h(t,e).andThen(n=>e(n,{cancel:b$3}));case "PreContractActionRequired":return e(t,{cancel:b$3}).andThen(c.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$3}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t))}}).andThen(c.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>P(r,s)),[r,e])}function zs(e){let r=b$2();return a$1(s=>setSpokeUserPositionManager(r,s).andThen(t=>e(t,{cancel:b$3})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>I(r,s.spoke)),[r,e])}function Zs(e){let r=b$2();return a$1(s=>{let t=s.changes.map(a=>a.reserve),n=t.map(a=>decodeReserveId(a));return setUserSuppliesAsCollateral(r,s).andThen(a=>e(a,{cancel:b$3})).andThen(a=>a.wait()).andThen(r.waitForTransaction).andThrough(()=>ResultAsync.combine([Q(r,s.sender),q(r,s.sender),...n.flatMap(({chainId:a,spoke:l})=>[_(r,s.sender,{chainId:a,address:l}),N(r,s.sender,{chainId:a,address:l}),M(r,{chainId:a,address:l})]),D(r,t),...n.map(({chainId:a})=>F(r,a))]))},[r,e])}function tt(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function nt(e){let r=b$2();return a$1(s=>supply(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$3});case "Erc20ApprovalRequired":return supportsPermit(t)?v(t,e,n=>supply(r,tt(s,n))).andThen(n=>e(n,{cancel:b$3})):h(t,e).andThen(n=>e(n,{cancel:b$3}));case "PreContractActionRequired":return e(t,{cancel:b$3}).andThen(c.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$3}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t))}}).andThen(c.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>P(r,s)),[r,e])}function ot(e){let r=b$2();return a$1(s=>updateUserPositionConditions(r,s).andThen(t=>e(t,{cancel:b$3})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>z(r,s.userPositionId)),[r,e])}function ct(e){let r=b$2();return a$1(s=>withdraw(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:b$3});case "PreContractActionRequired":return e(t,{cancel:b$3}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:b$3}));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return UnexpectedError$1.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>P(r,s)),[r,e])}function fp({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:UserSuppliesQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Rp(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>userSupplies(r,s,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function wp({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:UserBorrowsQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Up(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>userBorrows(r,s,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Ap({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:UserSummaryQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Pp({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:UserPositionsQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function gp(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>userPositions(r,s,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function bp({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return b$1({document:UserPositionQuery,variables:{request:n,currency:s,timeWindow:t},suspense:e,pause:r})}function Tp({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){return b$1({document:UserBalancesQuery,variables:{request:t,currency:s},suspense:e,pause:r})}function xp({suspense:e=false,pause:r=false,...s}){return b$1({document:UserRiskPremiumBreakdownQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Qp(e=DEFAULT_QUERY_OPTIONS){let r=b$2();return a$1(s=>userBalances(r,s,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function Ep({suspense:e=false,pause:r=false,currency:s=DEFAULT_QUERY_OPTIONS.currency,...t}){return b$1({document:UserSummaryHistoryQuery,variables:{request:t,currency:s},suspense:e,pause:r,batch:false})}export{Ht as AaveProvider,H as CannotCancelSwapError,ws as useActivities,Us as useActivitiesAction,Kt as useAsset,en as useAssetBorrowHistory,Xt as useAssetPriceHistory,Zt as useAssetSupplyHistory,Ts as useBorrow,Sn as useBorrowApyHistory,Ur as useBorrowSwap,Pr as useBorrowSwapQuote,gr as useBorrowSwapQuoteAction,Qr as useCancelSwap,Es as useClaimRewards,Ft as useHub,Vt as useHubAssets,Yt as useHubSummaryHistory,Lt as useHubs,jt as useHubsAction,Ws as useLiquidatePosition,Ns as usePreview,Ds as usePreviewAction,rn as useProtocolHistory,Fs as useRenounceSpokeUserPositionManager,Gs as useRepay,vr as useRepayWithSupply,qr as useRepayWithSupplyQuote,Hr as useRepayWithSupplyQuoteAction,pn as useReserve,ln as useReserveAction,cn as useReserves,yn as useReservesAction,zs as useSetSpokeUserPositionManager,Zs as useSetUserSuppliesAsCollateral,xn as useSpoke,En as useSpokePositionManagers,hn as useSpokeUserPositionManagers,Qn as useSpokes,nt as useSupply,dn as useSupplyApyHistory,Br as useSupplySwap,Or as useSupplySwapQuote,_r as useSupplySwapQuoteAction,Vr as useSwapStatus,Nr as useSwappableTokens,Kr as useTokenSwap,ss as useTokenSwapQuote,ts as useTokenSwapQuoteAction,ot as useUpdateUserPositionConditions,Tp as useUserBalances,Qp as useUserBalancesAction,wp as useUserBorrows,Up as useUserBorrowsAction,An as useUserClaimableRewards,Pn as useUserClaimableRewardsAction,bp as useUserPosition,Pp as useUserPositions,gp as useUserPositionsAction,xp as useUserRiskPremiumBreakdown,Ap as useUserSummary,Ep as useUserSummaryHistory,fp as useUserSupplies,Rp as useUserSuppliesAction,is as useUserSwaps,ct as useWithdraw,ys as useWithdrawSwap,ds as useWithdrawSwapQuote,ms as useWithdrawSwapQuoteAction};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map