@aave/react 4.0.0-next.43 → 4.0.0-next.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var client=require('@aave/client'),F=require('react'),types=require('@aave/types'),urql=require('urql'),actions=require('@aave/client/actions'),graphql=require('@aave/graphql'),core=require('@aave/core');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var F__default=/*#__PURE__*/_interopDefault(F);var ae=F__default.default.createContext(null);function oe({children:e,client:s}){return F__default.default.createElement(ae.Provider,{value:s},F__default.default.createElement(urql.Provider,{value:s.urql},e))}function u(){let e=F.useContext(ae);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Mr({children:e,client:s}){return F__default.default.createElement(oe,{client:s},e)}function ls(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}=graphql.decodeUserPositionId(e.userPositionId);return s}function cs(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}=graphql.decodeUserPositionId(e.userPositionId);return s}function le(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function L(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>ls(r.request.query)===s)}function j(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>cs(r.request.query)===s)}function G(e,s,r){let t=n=>n.spoke.chain.chainId===r.chainId&&n.spoke.address===r.address&&n.user===s;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(n,a)=>a.some(t)),e.refreshQueryWhere(graphql.UserPositionQuery,(n,a)=>a!==null&&t(a))])}function Y(e,s){let r=t=>s.includes(t.id);return types.ResultAsync.combine([e.refreshQueryWhere(graphql.ReserveQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(graphql.ReservesQuery,(t,n)=>n.some(r))])}function $(e,s,r){return e.refreshQueryWhere(graphql.UserSummaryQuery,t=>t.request.user===s&&(graphql.isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===r.chainId&&t.request.filter.spoke.address===r.address:graphql.isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(n=>n===r.chainId):false))}function K(e,s){let r=t=>t.chain.chainId===s.chainId&&t.address===s.address;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.SpokeQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(graphql.SpokesQuery,(t,n)=>n.some(r))])}function z(e,s){let r=t=>t.chain.chainId===s;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.HubQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(graphql.HubsQuery,(t,n)=>n.some(r))])}function J(e,s){return e.refreshQueryWhere(graphql.SpokePositionManagersQuery,r=>r.request.spoke===s)}function ce(e,s){return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(r,t)=>t.some(n=>n.id===s)),e.refreshQueryWhere(graphql.UserPositionQuery,(r,t)=>t?.id===s)])}var w={Loading:()=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false}),Success:(e,s=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:s}),Failure:(e,s=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:s}),Paused:(e,s)=>({data:e,error:s,loading:false,paused:true,reloading:false})};function o({document:e,variables:s,suspense:r,pause:t,selector:n=types.ok,pollInterval:a=0,batch:i=true}){let[c,d]=F.useState(true),[{fetching:f,data:A,error:H,stale:Ge},ne]=urql.useQuery({query:e,variables:s,pause:t,context:F.useMemo(()=>({batch:i,suspense:r}),[i,r])});if(F.useEffect(()=>{t||f||d(false);},[f,t]),F.useEffect(()=>{if(a<=0||f||t)return;let T=setTimeout(()=>{ne({requestPolicy:"network-only",batch:false});},a);return ()=>clearTimeout(T)},[f,ne,a,t]),t){let T=H?client.UnexpectedError.from(H):void 0;if(!A)return w.Paused(void 0,T);let M=n(A.value);return M.isErr()?w.Paused(void 0,M.error):w.Paused(M.value,T)}if(!r&&c)return w.Loading();let _=Ge||!c&&f;if(H){let T=client.UnexpectedError.from(H);if(r)throw T;return w.Failure(T,_)}types.invariant(A,"No data returned");let C=n(A.value);if(C.isErr()){if(r)throw C.error;return w.Failure(C.error,_)}return w.Success(C.value,_)}var X={Idle:()=>({called:false,loading:false,data:void 0,error:void 0}),Loading:e=>({called:true,loading:true,data:e,error:void 0}),Success:e=>({called:true,loading:false,data:e,error:void 0}),Failed:e=>({called:true,loading:false,data:void 0,error:e})};function l(e,s){let[r,t]=F.useState(X.Idle()),n=F.useRef(false),a=F.useCallback(e,s);return [F.useCallback(c=>{types.invariant(!n.current,"Cannot execute a task while another is in progress."),n.current=true;let d;t(f=>(d=f,{called:true,loading:true,data:f.data,error:void 0}));try{let f=a(c);return f.match(A=>{n.current=!1,t(X.Success(A));},A=>{n.current=!1,t(X.Failed(A));}),f}catch(f){throw n.current=false,t(types.nonNullable(d)),f}},[a]),r]}var p=e=>core.CancelError.from(e).asResultAsync(),R=class e{constructor(s){this.wait=s;}static isInstanceOf(s){return s instanceof e}static tryFrom(s){return e.isInstanceOf(s)?types.okAsync(s):core.UnexpectedError.from(s).asResultAsync()}};function g(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}function ct({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.HubQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function yt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.HubsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function dt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.HubAssetsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function St({suspense:e=false,pause:s=false,...r}){return o({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Rt(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.hubs(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function wt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function Pt(){let e=u();return l(s=>actions.chain(e,s,{batch:false,requestPolicy:"cache-first"}),[e])}function Tt({suspense:e=false,pause:s=false,...r}={query:{filter:graphql.ChainsFilter.ALL}}){return o({document:graphql.ChainsQuery,variables:{request:r},suspense:e,pause:s})}function xt(){let e=u();return l(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function ht({suspense:e=false,pause:s=false,...r}){let t=u();return o({document:graphql.ExchangeRateQuery,variables:{request:r},suspense:e,pause:s,pollInterval:r.at?0:t.context.environment.exchangeRateInterval})}function qt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.AssetQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Ht({suspense:e=false,pause:s=false,...r}){return o({document:graphql.AssetPriceHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ct({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.AssetSupplyHistoryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function It({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.AssetBorrowHistoryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function Bt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ProtocolHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Mt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.ReserveQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Ft(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.reserve(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Lt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.ReservesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function jt(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.reserves(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Gt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Yt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Zt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.UserClaimableRewardsQuery,variables:{request:r},suspense:e,pause:s})}function en(){let e=u();return l(s=>actions.userClaimableRewards(e,s,{requestPolicy:"cache-first"}),[e])}function nn({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function an({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function on({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function un({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function ee(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return types.ok(e.quote);case "InsufficientLiquidityError":return types.err(core.ValidationError.fromGqlNode(e));default:return types.err(core.UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`))}}function Pe(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}function m(e){switch(e.__typename){case "PositionSwapByIntentApprovalsRequired":return types.ok(e.quote);case "InsufficientLiquidityError":return types.err(core.ValidationError.fromGqlNode(e));default:return types.err(core.UnexpectedError.upgradeRequired(`Unsupported position swap quote result: ${e.__typename}`))}}function Te(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function xe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function he(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Ee(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Qe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function bn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.TokenSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Fast),currency:r},selector:ee,suspense:e,pause:s,batch:false}),i=o({document:graphql.TokenSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:ee,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function gn(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(ee),[s,e.currency])}function An({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function wn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=u(),[i,c]=F.useState(false),d=o({document:graphql.UserSwapsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:a.context.environment.swapStatusInterval});return F.useEffect(()=>{d.data&&d.data.items.length>0&&d.data.items.every(Ne)&&c(true);},[d.data]),d}function Ne(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function Pn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=u(),[i,c]=F.useState(false),d=o({document:graphql.SwapStatusQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:a.context.environment.swapStatusInterval});return F.useEffect(()=>{d.data&&Ne(d.data)&&c(true);},[d.data]),d}function Tn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.SupplySwapQuoteQuery,variables:{request:xe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.SupplySwapQuoteQuery,variables:{request:xe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function xn(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function hn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.BorrowSwapQuoteQuery,variables:{request:he(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.BorrowSwapQuoteQuery,variables:{request:he(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function En(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function O(e){return {with:s=>e.approvals.reduce((r,t)=>r.andThen(n=>s(t,{cancel:p}).map(a=>{switch(t.__typename){case "PositionSwapAdapterContractApproval":n.adapterContractSignature=types.isSignature(a)?a:null;break;case "PositionSwapPositionManagerApproval":n.positionManagerSignature=types.isSignature(a)?a:null;break}return n})),types.okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function N(e,s){return actions.swap(e,{intent:s}).andThen(r=>{switch(r.__typename){case "SwapReceipt":return types.okAsync(r);default:return core.UnexpectedError.from(r).asResultAsync()}})}function Qn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function kn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function vn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ee(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ee(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function qn(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function Hn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function Cn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Qe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Qe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function In(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function Bn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function Wn(e){let s=u(),r=F.useCallback(t=>actions.swap(s,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait()).andThen(()=>types.okAsync(n.orderReceipt));case "SwapReceipt":return types.okAsync(n)}}),[s,e]);return l(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...n})=>actions.tokenSwapQuote(s,n,{currency:t}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return r({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId}).andThen(i=>e(i.data,{cancel:p}).andThen(g).andThen(c=>r({intent:{quoteId:i.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(a)){let i=a.approvals[0];return e(i,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:{deadline:i.bySignature.message.deadline,value:c}}):R.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(g).andThen(d=>r({intent:{quoteId:c.newQuoteId,signature:d}})))}return a.approvals.reduce((i,c)=>i.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(d=>d.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})).andThen(i=>e(i.data,{cancel:p})).andThen(g).andThen(i=>r({intent:{quoteId:a.quote.quoteId,signature:i}}));default:types.never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var W=class extends types.ResultAwareError{name="CannotCancelSwapError"};function Dn(e){let s=u();return l(r=>actions.swapStatus(s,{id:r.id}).andThen(t=>{if(t===null)return core.UnexpectedError.from("Swap not found").asResultAsync();switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(s,r).andThen(n=>e(n.data,{cancel:p})).andThen(g).andThen(n=>actions.cancelSwap(s,{intent:{id:r.id,signature:n}})).andThen(n=>n.__typename==="SwapCancelledResult"?types.okAsync(n):e(n,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(a=>a?.__typename==="SwapCancelled"?types.okAsync(Pe(a)):new W("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(Pe(t));case "SwapExpired":return new W("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function V(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),n={chainId:r,address:t};return types.ResultAsync.combine([G(e,s.sender,n),$(e,s.sender,n),Y(e,[s.reserve]),K(e,n),le(e,s.sender),L(e,s.sender),j(e,s.sender),z(e,r)])}function gr(e,s){return {deadline:s.message.deadline,value:e}}function re(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function te(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(n=>types.isSignature(n)?r(gr(n,t.bySignature)).map(types.expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function Gn(e){let s=u();return l(r=>actions.supply(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?te(t,e,n=>actions.supply(s,Ar(r,n))).andThen(n=>e(n,{cancel:p})):re(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function Ar(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Yn(e){let s=u();return l(r=>actions.borrow(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function $n(e){let s=u();return l(r=>actions.repay(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?te(t,e,n=>actions.repay(s,wr(r,n))).andThen(n=>e(n,{cancel:p})):re(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function wr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Kn(e){let s=u();return l(r=>actions.withdraw(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function zn(e){let s=u();return l(r=>actions.renounceSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>J(s,r.spoke)),[s,e])}function Jn(e){let s=u();return l(r=>actions.updateUserPositionConditions(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>ce(s,r.userPositionId)),[s,e])}function Xn(e){let s=u();return l(r=>{let t=r.changes.map(a=>a.reserve),n=t.map(a=>graphql.decodeReserveId(a));return actions.setUserSuppliesAsCollateral(s,r).andThen(a=>e(a,{cancel:p})).andThen(a=>a.wait()).andThen(s.waitForTransaction).andThrough(()=>types.ResultAsync.combine([L(s,r.sender),j(s,r.sender),...n.flatMap(({chainId:a,spoke:i})=>[G(s,r.sender,{chainId:a,address:i}),$(s,r.sender,{chainId:a,address:i}),K(s,{chainId:a,address:i})]),Y(s,t),...n.map(({chainId:a})=>z(s,a))]))},[s,e])}function Zn(e){let s=u();return l(r=>actions.liquidatePosition(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?te(t,e,n=>actions.liquidatePosition(s,Pr(r))).andThen(n=>e(n,{cancel:p})):re(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction),[s,e])}function Pr(e,s){return e}function ea(e){let s=u();return l(r=>actions.setSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>J(s,r.spoke)),[s,e])}function sa(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.preview(s,r,{currency:e.currency,requestPolicy:"network-only"}),[s,e.currency])}function ra({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.PreviewQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function ta({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.ActivitiesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function na(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.activities(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function aa(e){let s=u();return l(r=>actions.claimRewards(s,r).andThen(t=>e(t,{cancel:p})).andThen(R.tryFrom).andThen(t=>t.wait()).map(t=>t.txHash),[s,e])}function ya({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserSuppliesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function da(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userSupplies(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Sa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserBorrowsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Ra(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userBorrows(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function fa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserSummaryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ma({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserPositionsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Ua(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function ba({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserPositionQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ga({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.UserBalancesQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function Aa({suspense:e=false,pause:s=false,...r}){return o({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function wa(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userBalances(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function Pa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:r},suspense:e,pause:s,batch:false})}exports.AaveProvider=Mr;exports.CannotCancelSwapError=W;exports.useAaveClient=u;exports.useActivities=ta;exports.useActivitiesAction=na;exports.useAsset=qt;exports.useAssetBorrowHistory=It;exports.useAssetPriceHistory=Ht;exports.useAssetSupplyHistory=Ct;exports.useBorrow=Yn;exports.useBorrowApyHistory=Gt;exports.useBorrowSwap=kn;exports.useBorrowSwapQuote=hn;exports.useBorrowSwapQuoteAction=En;exports.useCancelSwap=Dn;exports.useChain=wt;exports.useChainAction=Pt;exports.useChains=Tt;exports.useClaimRewards=aa;exports.useExchangeRate=ht;exports.useExchangeRateAction=xt;exports.useHub=ct;exports.useHubAssets=dt;exports.useHubSummaryHistory=St;exports.useHubs=yt;exports.useHubsAction=Rt;exports.useLiquidatePosition=Zn;exports.usePreview=ra;exports.usePreviewAction=sa;exports.useProtocolHistory=Bt;exports.useRenounceSpokeUserPositionManager=zn;exports.useRepay=$n;exports.useRepayWithSupply=Hn;exports.useRepayWithSupplyQuote=vn;exports.useRepayWithSupplyQuoteAction=qn;exports.useReserve=Mt;exports.useReserveAction=Ft;exports.useReserves=Lt;exports.useReservesAction=jt;exports.useSetSpokeUserPositionManager=ea;exports.useSetUserSuppliesAsCollateral=Xn;exports.useSpoke=nn;exports.useSpokePositionManagers=on;exports.useSpokeUserPositionManagers=un;exports.useSpokes=an;exports.useSupply=Gn;exports.useSupplyApyHistory=Yt;exports.useSupplySwap=Qn;exports.useSupplySwapQuote=Tn;exports.useSupplySwapQuoteAction=xn;exports.useSwapStatus=Pn;exports.useSwappableTokens=An;exports.useTokenSwap=Wn;exports.useTokenSwapQuote=bn;exports.useTokenSwapQuoteAction=gn;exports.useUpdateUserPositionConditions=Jn;exports.useUserBalances=ga;exports.useUserBalancesAction=wa;exports.useUserBorrows=Sa;exports.useUserBorrowsAction=Ra;exports.useUserClaimableRewards=Zt;exports.useUserClaimableRewardsAction=en;exports.useUserPosition=ba;exports.useUserPositions=ma;exports.useUserPositionsAction=Ua;exports.useUserRiskPremiumBreakdown=Aa;exports.useUserSummary=fa;exports.useUserSummaryHistory=Pa;exports.useUserSupplies=ya;exports.useUserSuppliesAction=da;exports.useUserSwaps=wn;exports.useWithdraw=Kn;exports.useWithdrawSwap=Bn;exports.useWithdrawSwapQuote=Cn;exports.useWithdrawSwapQuoteAction=In;Object.keys(client).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return client[k]}})});//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var client=require('@aave/client'),F=require('react'),types=require('@aave/types'),urql=require('urql'),actions=require('@aave/client/actions'),graphql=require('@aave/graphql'),core=require('@aave/core');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var F__default=/*#__PURE__*/_interopDefault(F);var ae=F__default.default.createContext(null);function oe({children:e,client:s}){return F__default.default.createElement(ae.Provider,{value:s},F__default.default.createElement(urql.Provider,{value:s.urql},e))}function u(){let e=F.useContext(ae);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Fr({children:e,client:s}){return F__default.default.createElement(oe,{client:s},e)}function ls(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}=graphql.decodeUserPositionId(e.userPositionId);return s}function cs(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}=graphql.decodeUserPositionId(e.userPositionId);return s}function le(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function L(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>ls(r.request.query)===s)}function j(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>cs(r.request.query)===s)}function G(e,s,r){let t=n=>n.spoke.chain.chainId===r.chainId&&n.spoke.address===r.address&&n.user===s;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(n,a)=>a.some(t)),e.refreshQueryWhere(graphql.UserPositionQuery,(n,a)=>a!==null&&t(a))])}function Y(e,s){let r=t=>s.includes(t.id);return types.ResultAsync.combine([e.refreshQueryWhere(graphql.ReserveQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(graphql.ReservesQuery,(t,n)=>n.some(r))])}function $(e,s,r){return e.refreshQueryWhere(graphql.UserSummaryQuery,t=>t.request.user===s&&(graphql.isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===r.chainId&&t.request.filter.spoke.address===r.address:graphql.isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(n=>n===r.chainId):false))}function K(e,s){let r=t=>t.chain.chainId===s.chainId&&t.address===s.address;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.SpokeQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(graphql.SpokesQuery,(t,n)=>n.some(r))])}function z(e,s){let r=t=>t.chain.chainId===s;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.HubQuery,(t,n)=>n!==null&&r(n)),e.refreshQueryWhere(graphql.HubsQuery,(t,n)=>n.some(r))])}function J(e,s){return e.refreshQueryWhere(graphql.SpokePositionManagersQuery,r=>r.request.spoke===s)}function ce(e,s){return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(r,t)=>t.some(n=>n.id===s)),e.refreshQueryWhere(graphql.UserPositionQuery,(r,t)=>t?.id===s)])}var w={Loading:()=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false}),Success:(e,s=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:s}),Failure:(e,s=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:s}),Paused:(e,s)=>({data:e,error:s,loading:false,paused:true,reloading:false})};function o({document:e,variables:s,suspense:r,pause:t,selector:n=types.ok,pollInterval:a=0,batch:i=true}){let[c,d]=F.useState(true),[{fetching:f,data:A,error:H,stale:Ge},ne]=urql.useQuery({query:e,variables:s,pause:t,context:F.useMemo(()=>({batch:i,suspense:r}),[i,r])});if(F.useEffect(()=>{t||f||d(false);},[f,t]),F.useEffect(()=>{if(a<=0||f||t)return;let T=setTimeout(()=>{ne({requestPolicy:"network-only",batch:false});},a);return ()=>clearTimeout(T)},[f,ne,a,t]),t){let T=H?client.UnexpectedError.from(H):void 0;if(!A)return w.Paused(void 0,T);let M=n(A.value);return M.isErr()?w.Paused(void 0,M.error):w.Paused(M.value,T)}if(!r&&c)return w.Loading();let _=Ge||!c&&f;if(H){let T=client.UnexpectedError.from(H);if(r)throw T;return w.Failure(T,_)}types.invariant(A,"No data returned");let C=n(A.value);if(C.isErr()){if(r)throw C.error;return w.Failure(C.error,_)}return w.Success(C.value,_)}var X={Idle:()=>({called:false,loading:false,data:void 0,error:void 0}),Loading:e=>({called:true,loading:true,data:e,error:void 0}),Success:e=>({called:true,loading:false,data:e,error:void 0}),Failed:e=>({called:true,loading:false,data:void 0,error:e})};function l(e,s){let[r,t]=F.useState(X.Idle()),n=F.useRef(false),a=F.useCallback(e,s);return [F.useCallback(c=>{types.invariant(!n.current,"Cannot execute a task while another is in progress."),n.current=true;let d;t(f=>(d=f,{called:true,loading:true,data:f.data,error:void 0}));try{let f=a(c);return f.match(A=>{n.current=!1,t(X.Success(A));},A=>{n.current=!1,t(X.Failed(A));}),f}catch(f){throw n.current=false,t(types.nonNullable(d)),f}},[a]),r]}var p=e=>core.CancelError.from(e).asResultAsync(),R=class e{constructor(s){this.wait=s;}static isInstanceOf(s){return s instanceof e}static tryFrom(s){return e.isInstanceOf(s)?types.okAsync(s):core.UnexpectedError.from(s).asResultAsync()}};function g(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}function yt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.HubQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function dt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.HubsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function St({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.HubAssetsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Rt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function ft(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.hubs(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function Pt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function Tt(){let e=u();return l(s=>actions.chain(e,s,{batch:false,requestPolicy:"cache-first"}),[e])}function xt({suspense:e=false,pause:s=false,...r}={query:{filter:graphql.ChainsFilter.ALL}}){return o({document:graphql.ChainsQuery,variables:{request:r},suspense:e,pause:s})}function ht(){let e=u();return l(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function Et({suspense:e=false,pause:s=false,...r}){let t=u();return o({document:graphql.ExchangeRateQuery,variables:{request:r},suspense:e,pause:s,pollInterval:r.at?0:t.context.environment.exchangeRateInterval})}function Ht({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.AssetQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Ct({suspense:e=false,pause:s=false,...r}){return o({document:graphql.AssetPriceHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function It({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.AssetSupplyHistoryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function Bt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.AssetBorrowHistoryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function Wt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ProtocolHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ft({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.ReserveQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Lt(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.reserve(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function jt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.ReservesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Gt(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.reserves(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Yt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function $t({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function en({suspense:e=false,pause:s=false,...r}){return o({document:graphql.UserClaimableRewardsQuery,variables:{request:r},suspense:e,pause:s})}function sn(){let e=u();return l(s=>actions.userClaimableRewards(e,s,{requestPolicy:"cache-first"}),[e])}function an({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function on({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function un({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function pn({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function ee(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return types.ok(e.quote);case "InsufficientLiquidityError":return types.err(core.ValidationError.fromGqlNode(e));default:return types.err(core.UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`))}}function Pe(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}function m(e){switch(e.__typename){case "PositionSwapByIntentApprovalsRequired":return types.ok(e.quote);case "InsufficientLiquidityError":return types.err(core.ValidationError.fromGqlNode(e));default:return types.err(core.UnexpectedError.upgradeRequired(`Unsupported position swap quote result: ${e.__typename}`))}}function Te(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function xe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function he(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Ee(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Qe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function gn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.TokenSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Fast),currency:r},selector:ee,suspense:e,pause:s,batch:false}),i=o({document:graphql.TokenSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:ee,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function An(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(ee),[s,e.currency])}function wn({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function Pn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=u(),[i,c]=F.useState(false),d=o({document:graphql.UserSwapsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:a.context.environment.swapStatusInterval});return F.useEffect(()=>{d.data&&d.data.items.length>0&&d.data.items.every(Ne)&&c(true);},[d.data]),d}function Ne(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function Tn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=u(),[i,c]=F.useState(false),d=o({document:graphql.SwapStatusQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:a.context.environment.swapStatusInterval});return F.useEffect(()=>{d.data&&Ne(d.data)&&c(true);},[d.data]),d}function xn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.SupplySwapQuoteQuery,variables:{request:xe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.SupplySwapQuoteQuery,variables:{request:xe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function hn(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function En({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.BorrowSwapQuoteQuery,variables:{request:he(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.BorrowSwapQuoteQuery,variables:{request:he(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function Qn(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function O(e){return {with:s=>e.approvals.reduce((r,t)=>r.andThen(n=>s(t,{cancel:p}).map(a=>{switch(t.__typename){case "PositionSwapAdapterContractApproval":n.adapterContractSignature=types.isSignature(a)?a:null;break;case "PositionSwapPositionManagerApproval":n.positionManagerSignature=types.isSignature(a)?a:null;break}return n})),types.okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function N(e,s){return actions.swap(e,{intent:s}).andThen(r=>{switch(r.__typename){case "SwapReceipt":return types.okAsync(r);default:return core.UnexpectedError.from(r).asResultAsync()}})}function kn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function vn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function qn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ee(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ee(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function Hn(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function Cn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function In({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=u(),a=o({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Qe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=o({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Qe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return i.data?i:a}function Bn(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function Wn(e){let s=u();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(n=>O(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(i=>N(s,{quoteId:a.newQuoteId,signature:i})))),[s,e])}function Dn(e){let s=u(),r=F.useCallback(t=>actions.swap(s,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait()).andThen(()=>types.okAsync(n.orderReceipt));case "SwapReceipt":return types.okAsync(n)}}),[s,e]);return l(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...n})=>actions.tokenSwapQuote(s,n,{currency:t}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return r({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId}).andThen(i=>e(i.data,{cancel:p}).andThen(g).andThen(c=>r({intent:{quoteId:i.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(a)){let i=a.approvals[0];return e(i,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:{deadline:i.bySignature.message.deadline,value:c}}):R.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(g).andThen(d=>r({intent:{quoteId:c.newQuoteId,signature:d}})))}return a.approvals.reduce((i,c)=>i.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(d=>d.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})).andThen(i=>e(i.data,{cancel:p})).andThen(g).andThen(i=>r({intent:{quoteId:a.quote.quoteId,signature:i}}));default:types.never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var W=class extends types.ResultAwareError{name="CannotCancelSwapError"};function On(e){let s=u();return l(r=>actions.swapStatus(s,{id:r.id}).andThen(t=>{if(t===null)return core.UnexpectedError.from("Swap not found").asResultAsync();switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(s,r).andThen(n=>e(n.data,{cancel:p})).andThen(g).andThen(n=>actions.cancelSwap(s,{intent:{id:r.id,signature:n}})).andThen(n=>n.__typename==="SwapCancelledResult"?types.okAsync(n):e(n,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(a=>a?.__typename==="SwapCancelled"?types.okAsync(Pe(a)):new W("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(Pe(t));case "SwapExpired":return new W("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function V(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),n={chainId:r,address:t};return types.ResultAsync.combine([G(e,s.sender,n),$(e,s.sender,n),Y(e,[s.reserve]),K(e,n),le(e,s.sender),L(e,s.sender),j(e,s.sender),z(e,r)])}function Ar(e,s){return {deadline:s.message.deadline,value:e}}function re(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function te(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(n=>types.isSignature(n)?r(Ar(n,t.bySignature)).map(types.expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function Yn(e){let s=u();return l(r=>actions.supply(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?te(t,e,n=>actions.supply(s,wr(r,n))).andThen(n=>e(n,{cancel:p})):re(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function wr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function $n(e){let s=u();return l(r=>actions.borrow(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function Kn(e){let s=u();return l(r=>actions.repay(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?te(t,e,n=>actions.repay(s,Pr(r,n))).andThen(n=>e(n,{cancel:p})):re(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function Pr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function zn(e){let s=u();return l(r=>actions.withdraw(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>V(s,r)),[s,e])}function Jn(e){let s=u();return l(r=>actions.renounceSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>J(s,r.spoke)),[s,e])}function Xn(e){let s=u();return l(r=>actions.updateUserPositionConditions(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>ce(s,r.userPositionId)),[s,e])}function Zn(e){let s=u();return l(r=>{let t=r.changes.map(a=>a.reserve),n=t.map(a=>graphql.decodeReserveId(a));return actions.setUserSuppliesAsCollateral(s,r).andThen(a=>e(a,{cancel:p})).andThen(a=>a.wait()).andThen(s.waitForTransaction).andThrough(()=>types.ResultAsync.combine([L(s,r.sender),j(s,r.sender),...n.flatMap(({chainId:a,spoke:i})=>[G(s,r.sender,{chainId:a,address:i}),$(s,r.sender,{chainId:a,address:i}),K(s,{chainId:a,address:i})]),Y(s,t),...n.map(({chainId:a})=>z(s,a))]))},[s,e])}function ea(e){let s=u();return l(r=>actions.liquidatePosition(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?te(t,e,n=>actions.liquidatePosition(s,Tr(r))).andThen(n=>e(n,{cancel:p})):re(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction),[s,e])}function Tr(e,s){return e}function sa(e){let s=u();return l(r=>actions.setSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andThrough(()=>J(s,r.spoke)),[s,e])}function ra(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.preview(s,r,{currency:e.currency,requestPolicy:"network-only"}),[s,e.currency])}function ta({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.PreviewQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function na({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.ActivitiesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function aa(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.activities(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function oa(e){let s=u();return l(r=>actions.claimRewards(s,r).andThen(t=>e(t,{cancel:p})).andThen(R.tryFrom).andThen(t=>t.wait()).map(t=>client.transactionReceipt(t.txHash)),[s,e])}function da({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserSuppliesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Sa(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userSupplies(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Ra({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserBorrowsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function fa(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userBorrows(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function ma({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserSummaryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Ua({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserPositionsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ba(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function ga({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserPositionQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Aa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.UserBalancesQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function wa({suspense:e=false,pause:s=false,...r}){return o({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Pa(e=client.DEFAULT_QUERY_OPTIONS){let s=u();return l(r=>actions.userBalances(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function Ta({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:r},suspense:e,pause:s,batch:false})}exports.AaveProvider=Fr;exports.CannotCancelSwapError=W;exports.useAaveClient=u;exports.useActivities=na;exports.useActivitiesAction=aa;exports.useAsset=Ht;exports.useAssetBorrowHistory=Bt;exports.useAssetPriceHistory=Ct;exports.useAssetSupplyHistory=It;exports.useBorrow=$n;exports.useBorrowApyHistory=Yt;exports.useBorrowSwap=vn;exports.useBorrowSwapQuote=En;exports.useBorrowSwapQuoteAction=Qn;exports.useCancelSwap=On;exports.useChain=Pt;exports.useChainAction=Tt;exports.useChains=xt;exports.useClaimRewards=oa;exports.useExchangeRate=Et;exports.useExchangeRateAction=ht;exports.useHub=yt;exports.useHubAssets=St;exports.useHubSummaryHistory=Rt;exports.useHubs=dt;exports.useHubsAction=ft;exports.useLiquidatePosition=ea;exports.usePreview=ta;exports.usePreviewAction=ra;exports.useProtocolHistory=Wt;exports.useRenounceSpokeUserPositionManager=Jn;exports.useRepay=Kn;exports.useRepayWithSupply=Cn;exports.useRepayWithSupplyQuote=qn;exports.useRepayWithSupplyQuoteAction=Hn;exports.useReserve=Ft;exports.useReserveAction=Lt;exports.useReserves=jt;exports.useReservesAction=Gt;exports.useSetSpokeUserPositionManager=sa;exports.useSetUserSuppliesAsCollateral=Zn;exports.useSpoke=an;exports.useSpokePositionManagers=un;exports.useSpokeUserPositionManagers=pn;exports.useSpokes=on;exports.useSupply=Yn;exports.useSupplyApyHistory=$t;exports.useSupplySwap=kn;exports.useSupplySwapQuote=xn;exports.useSupplySwapQuoteAction=hn;exports.useSwapStatus=Tn;exports.useSwappableTokens=wn;exports.useTokenSwap=Dn;exports.useTokenSwapQuote=gn;exports.useTokenSwapQuoteAction=An;exports.useUpdateUserPositionConditions=Xn;exports.useUserBalances=Aa;exports.useUserBalancesAction=Pa;exports.useUserBorrows=Ra;exports.useUserBorrowsAction=fa;exports.useUserClaimableRewards=en;exports.useUserClaimableRewardsAction=sn;exports.useUserPosition=ga;exports.useUserPositions=Ua;exports.useUserPositionsAction=ba;exports.useUserRiskPremiumBreakdown=wa;exports.useUserSummary=ma;exports.useUserSummaryHistory=Ta;exports.useUserSupplies=da;exports.useUserSuppliesAction=Sa;exports.useUserSwaps=Pn;exports.useWithdraw=zn;exports.useWithdrawSwap=Wn;exports.useWithdrawSwapQuote=In;exports.useWithdrawSwapQuoteAction=Bn;Object.keys(client).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return client[k]}})});//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map