@aave/react 4.0.0-next.50 → 4.0.0-next.51

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'),z=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 z__default=/*#__PURE__*/_interopDefault(z);var ne=z__default.default.createContext(null);function oe({children:e,client:r}){return z__default.default.createElement(ne.Provider,{value:r},z__default.default.createElement(urql.Provider,{value:r.urql},e))}function o(){let e=z.useContext(ne);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Ra({children:e,client:r}){return z__default.default.createElement(oe,{client:r},e)}function fr(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}=graphql.decodeUserPositionId(e.userPositionId);return r}function Rr(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}=graphql.decodeUserPositionId(e.userPositionId);return r}function x(e,r){return e.refreshQueryWhere(graphql.UserBalancesQuery,s=>s.request.user===r)}function H(e,r){return e.refreshQueryWhere(graphql.UserSuppliesQuery,s=>fr(s.request.query)===r)}function O(e,r){return e.refreshQueryWhere(graphql.UserBorrowsQuery,s=>Rr(s.request.query)===r)}function J(e,r,s){let t=a=>a.spoke.chain.chainId===s.chainId&&a.spoke.address===s.address&&a.user===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(a,n)=>n.some(t)),e.refreshQueryWhere(graphql.UserPositionQuery,(a,n)=>n!==null&&t(n))])}function X(e,r){let s=t=>r.includes(t.id);return types.ResultAsync.combine([e.refreshQueryWhere(graphql.ReserveQuery,(t,a)=>a!==null&&s(a)),e.refreshQueryWhere(graphql.ReservesQuery,(t,a)=>a.some(s))])}function Z(e,r,s){return e.refreshQueryWhere(graphql.UserSummaryQuery,t=>t.request.user===r&&(graphql.isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===s.chainId&&t.request.filter.spoke.address===s.address:graphql.isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(a=>a===s.chainId):false))}function ee(e,r){let s=t=>t.chain.chainId===r.chainId&&t.address===r.address;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.SpokeQuery,(t,a)=>a!==null&&s(a)),e.refreshQueryWhere(graphql.SpokesQuery,(t,a)=>a.some(s))])}function re(e,r){let s=t=>t.chain.chainId===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.HubQuery,(t,a)=>a!==null&&s(a)),e.refreshQueryWhere(graphql.HubsQuery,(t,a)=>a.some(s))])}function V(e,r){return e.refreshQueryWhere(graphql.SpokePositionManagersQuery,s=>s.request.spoke===r)}function le(e,r){return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(s,t)=>t.some(a=>a.id===r)),e.refreshQueryWhere(graphql.UserPositionQuery,(s,t)=>t?.id===r)])}function E(e,r){let{chainId:s,spoke:t}=graphql.decodeReserveId(r.reserve),a={chainId:s,address:t};return types.ResultAsync.combine([J(e,r.sender,a),Z(e,r.sender,a),X(e,[r.reserve]),ee(e,a),x(e,r.sender),H(e,r.sender),O(e,r.sender),re(e,s)])}function ce(e,r){return x(e,r)}function ye(e,r){return types.ResultAsync.combine([H(e,r),x(e,r)])}function de(e,r){return types.ResultAsync.combine([O(e,r),x(e,r)])}function Se(e,r){return types.ResultAsync.combine([H(e,r),O(e,r),x(e,r)])}function me(e,r){return types.ResultAsync.combine([H(e,r),x(e,r)])}var h={Loading:e=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false,metadata:e}),Success:(e,r,s=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:s,metadata:r}),Failure:(e,r,s=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:s,metadata:r}),Paused:(e,r,s)=>({data:e,error:r,loading:false,paused:true,reloading:false,metadata:s})};function i({document:e,variables:r,suspense:s,pause:t,selector:a=types.ok,pollInterval:n=0,batch:l=true}){let[c,m]=z.useState({operationKey:0,resultOperationKey:void 0}),[U,w]=z.useState(true),k=z.useMemo(()=>urql.createRequest(e,r).key,[e,r]),[{fetching:T,data:q,error:_,stale:j},ae]=urql.useQuery({query:e,variables:r,pause:t,context:z.useMemo(()=>({batch:l,suspense:s}),[l,s])});if(z.useEffect(()=>{m(A=>({...A,operationKey:k}));},[k]),z.useEffect(()=>{t||T||w(false);},[T,t]),z.useEffect(()=>{t||T||m(A=>({...A,resultOperationKey:q&&!j?A.operationKey:A.resultOperationKey}));},[t,T,q,j]),z.useEffect(()=>{if(n<=0||T||t)return;let A=setTimeout(()=>{ae({requestPolicy:"network-only",batch:false});},n);return ()=>clearTimeout(A)},[T,ae,n,t]),t){let A=_?client.UnexpectedError.from(_):void 0;if(!q)return h.Paused(void 0,A,c);let $=a(q.value);return $.isErr()?h.Paused(void 0,$.error,c):h.Paused($.value,A,c)}if(!s&&U)return h.Loading(c);let G=j||!U&&T;if(_){let A=client.UnexpectedError.from(_);if(s)throw A;return h.Failure(A,c,G)}types.invariant(q!==void 0,`Unexpected empty response from the API for '${core.extractDocumentName(e)??"unknown"}' query`);let Je=q===null?null:q.value,F=a(Je);if(F.isErr()){if(s)throw F.error;return h.Failure(F.error,c,G)}return h.Success(F.value,c,G)}var se={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 u(e,r){let[s,t]=z.useState(se.Idle()),a=z.useRef(false),n=z.useRef(true);z.useEffect(()=>()=>{n.current=false;},[]);let l=z.useCallback(e,r);return [z.useCallback(m=>{types.invariant(n.current,"Cannot execute a task on an unmounted component."),types.invariant(!a.current,"Cannot execute a task while another is in progress."),a.current=true;let U;t(w=>(U=w,{called:true,loading:true,data:w.data,error:void 0}));try{let w=l(m);return w.match(k=>{a.current=!1,t(se.Success(k));},k=>{a.current=!1,t(se.Failed(k));}),w}catch(w){throw a.current=false,U&&t(U),w}},[l]),s]}var p=e=>core.CancelError.from(e).asResultAsync(),d=class e{constructor(r){this.wait=r;}static isInstanceOf(r){return r instanceof e}static tryFrom(r){return e.isInstanceOf(r)?types.okAsync(r):core.UnexpectedError.from(r).asResultAsync()}};function R(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}function Fa({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.HubQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Va({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.HubsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Ma({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.HubAssetsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function La({suspense:e=false,pause:r=false,...s}){return i({document:graphql.HubSummaryHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Ka(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.hubs(r,s,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function Xa({suspense:e=false,pause:r=false,...s}){return i({document:graphql.ChainQuery,variables:{request:s},suspense:e,pause:r})}function Za(){let e=o();return u(r=>actions.chain(e,r,{batch:false,requestPolicy:"cache-first"}),[e])}function en({suspense:e=false,pause:r=false,...s}={query:{filter:graphql.ChainsFilter.ALL}}){return i({document:graphql.ChainsQuery,variables:{request:s},suspense:e,pause:r})}function rn(){let e=o();return u(r=>actions.exchangeRate(e,r,{requestPolicy:"network-only"}),[e])}function sn({suspense:e=false,pause:r=false,...s}){let t=o();return i({document:graphql.ExchangeRateQuery,variables:{request:s},suspense:e,pause:r,pollInterval:s.at?0:t.context.environment.exchangeRateInterval})}function un({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.AssetQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function pn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.AssetPriceHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function ln({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.AssetSupplyHistoryQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r,batch:false})}function cn({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.AssetBorrowHistoryQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r,batch:false})}function yn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.ProtocolHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Un({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.ReserveQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function wn(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.reserve(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Pn({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.ReservesQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function gn(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.reserves(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function bn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.BorrowApyHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Tn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SupplyApyHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function kn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.UserClaimableRewardsQuery,variables:{request:s},suspense:e,pause:r})}function qn(){let e=o();return u(r=>actions.userClaimableRewards(e,r,{requestPolicy:"cache-first"}),[e])}function Bn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokeQuery,variables:{request:s},suspense:e,pause:r})}function Wn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokesQuery,variables:{request:s},suspense:e,pause:r})}function On({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokePositionManagersQuery,variables:{request:s},suspense:e,pause:r})}function Dn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokeUserPositionManagersQuery,variables:{request:s},suspense:e,pause:r})}function f(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 K(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function v(e){return {with:r=>e.approvals.reduce((s,t)=>s.andThen(a=>r(t,{cancel:p}).map(n=>{switch(t.__typename){case "PositionSwapAdapterContractApproval":a.adapterContractSignature=types.isSignature(n)?n:null;break;case "PositionSwapPositionManagerApproval":a.positionManagerSignature=types.isSignature(n)?n:null;break}return a})),types.okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function Q(e,r){return actions.swap(e,{intent:r}).andThen(s=>{switch(s.__typename){case "SwapReceipt":return types.okAsync(s);default:return core.UnexpectedError.from(s).asResultAsync()}})}function os(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>Q(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function ve(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function is({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.BorrowSwapQuoteQuery,variables:{request:ve(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.BorrowSwapQuoteQuery,variables:{request:ve(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function ps(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.borrowSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function qe(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}var D=class extends types.ResultAwareError{name="CannotCancelSwapError"};function ds(e){let r=o();return u(s=>actions.swapStatus(r,{id:s.id}).andThen(t=>{if(t===null)return core.UnexpectedError.from("Swap not found").asResultAsync();switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(r,s).andThen(a=>e(a.data,{cancel:p})).andThen(R).andThen(a=>actions.cancelSwap(r,{intent:{id:s.id,signature:a}})).andThen(a=>a.__typename==="SwapCancelledResult"?types.okAsync(a):e(a,{cancel:p}).andThen(d.tryFrom).andThen(n=>n.wait()).andThen(()=>actions.swapStatus(r,{id:s.id})).andThen(n=>n?.__typename==="SwapCancelled"?types.okAsync(qe(n)):new D("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(qe(t));case "SwapExpired":return new D("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[r,e])}function fs(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>Q(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ie(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function As({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function Us(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.repayWithSupplyQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function gs(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>Q(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Oe(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Ts({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.SupplySwapQuoteQuery,variables:{request:Oe(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.SupplySwapQuoteQuery,variables:{request:Oe(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function xs(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.supplySwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function hs({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SwappableTokensQuery,variables:{request:s},suspense:e,pause:r})}function qs({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=i({document:graphql.SwapStatusQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval});return z.useEffect(()=>{m.data&&K(m.data)&&c(true);},[m.data]),m}function Ds(e){let r=o(),s=z.useCallback(t=>actions.swap(r,t).andThen(a=>{switch(a.__typename){case "SwapTransactionRequest":return e(a,{cancel:p}).andThen(d.tryFrom).andThen(n=>n.wait()).andThen(()=>types.okAsync(a.orderReceipt));case "SwapReceipt":return types.okAsync(a)}}),[r,e]);return u(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...a})=>actions.tokenSwapQuote(r,a,{currency:t}).andThen(n=>{switch(n.__typename){case "SwapByTransaction":return s({transaction:{quoteId:n.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId}).andThen(l=>e(l.data,{cancel:p}).andThen(R).andThen(c=>s({intent:{quoteId:l.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(n)){let l=n.approvals[0];return e(l,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId,permitSig:{deadline:l.bySignature.message.deadline,value:c}}):d.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(R).andThen(m=>s({intent:{quoteId:c.newQuoteId,signature:m}})))}return n.approvals.reduce((l,c)=>l.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(d.tryFrom).andThen(m=>m.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})).andThen(l=>e(l.data,{cancel:p})).andThen(R).andThen(l=>s({intent:{quoteId:n.quote.quoteId,signature:l}}));default:types.never(`Unsupported swap quote result: ${n.__typename}. To be removed from API soon.`);}}),[r,e,s])}function te(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 Ve(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Ms({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.TokenSwapQuoteQuery,variables:{request:Ve(t,graphql.QuoteAccuracy.Fast),currency:s},selector:te,suspense:e,pause:r,batch:false}),l=i({document:graphql.TokenSwapQuoteQuery,variables:{request:Ve(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:te,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function Ls(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.tokenSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(te),[r,e.currency])}function $s(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 zs({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=i({document:graphql.UserSwapsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval}),U=m.data?.items??[],w=z.useDeferredValue(U);return z.useEffect(()=>{if(U.length===0)return;U.every(K)&&c(true);for(let T of $s(U,w))switch(T.operation.__typename){case "TokenSwap":a.user&&ce(n,a.user);break;case "BorrowSwap":a.user&&de(n,a.user);break;case "RepayWithSupply":a.user&&Se(n,a.user);break;case "SupplySwap":a.user&&ye(n,a.user);break;case "WithdrawSwap":a.user&&me(n,a.user);break}},[U,w,n,a.user]),m}function Zs(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>Q(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ye(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function rt({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function st(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.withdrawSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function nt({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.ActivitiesQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function ot(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.activities(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function ct(e){let r=o();return u(s=>actions.borrow(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(a=>a.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(r.waitForTransaction).andThrough(()=>E(r,s)),[r,e])}function St(e){let r=o();return u(s=>actions.claimRewards(r,s).andThen(t=>e(t,{cancel:p})).andThen(d.tryFrom).andThen(t=>t.wait()).map(t=>client.transactionReceipt(t.txHash)),[r,e])}function At(e,r){return {deadline:r.message.deadline,value:e}}function B(e,r){return e.approvals.reduce((s,t)=>s.andThen(()=>r({...t,bySignature:null},{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function W(e,r,s){let t=e.approvals[0];return r(t,{cancel:p}).andThen(a=>types.isSignature(a)?s(At(a,t.bySignature)).map(types.expectTypename("TransactionRequest")):a.wait().map(()=>e.originalTransaction))}function gt(e,r){return "exact"in e.amount&&e.amount.exact?{...e,amount:{exact:{...e.amount.exact,permitSig:r}}}:e}function bt(e){let r=o();return u(s=>actions.liquidatePosition(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?W(t,e,a=>actions.liquidatePosition(r,gt(s,a))).andThen(a=>e(a,{cancel:p})):B(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(d.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>x(r,s.liquidator)),[r,e])}function Et(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.preview(r,s,{currency:e.currency,requestPolicy:"network-only"}),[r,e.currency])}function ht({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return i({document:graphql.PreviewQuery,variables:{request:t,currency:s},suspense:e,pause:r})}function Qt(e){let r=o();return u(s=>actions.renounceSpokeUserPositionManager(r,s).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>V(r,s.spoke)),[r,e])}function Ht(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function It(e){let r=o();return u(s=>actions.repay(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?W(t,e,a=>actions.repay(r,Ht(s,a))).andThen(a=>e(a,{cancel:p})):B(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(d.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>E(r,s)),[r,e])}function Wt(e){let r=o();return u(s=>actions.setSpokeUserPositionManager(r,s).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>V(r,s.spoke)),[r,e])}function _t(e){let r=o();return u(s=>{let t=s.changes.map(n=>n.reserve),a=t.map(n=>graphql.decodeReserveId(n));return actions.setUserSuppliesAsCollateral(r,s).andThen(n=>e(n,{cancel:p})).andThen(n=>n.wait()).andThen(r.waitForTransaction).andThrough(()=>types.ResultAsync.combine([H(r,s.sender),O(r,s.sender),...a.flatMap(({chainId:n,spoke:l})=>[J(r,s.sender,{chainId:n,address:l}),Z(r,s.sender,{chainId:n,address:l}),ee(r,{chainId:n,address:l})]),X(r,t),...a.map(({chainId:n})=>re(r,n))]))},[r,e])}function Lt(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function Kt(e){let r=o();return u(s=>actions.supply(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?W(t,e,a=>actions.supply(r,Lt(s,a))).andThen(a=>e(a,{cancel:p})):B(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(d.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>E(r,s)),[r,e])}function jt(e){let r=o();return u(s=>actions.updateUserPositionConditions(r,s).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>le(r,s.userPositionId)),[r,e])}function Xt(e){let r=o();return u(s=>actions.withdraw(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(a=>a.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(r.waitForTransaction).andThrough(()=>E(r,s)),[r,e])}function Ep({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserSuppliesQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function hp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userSupplies(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function vp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserBorrowsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Qp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userBorrows(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function kp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserSummaryQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function qp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserPositionsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Cp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userPositions(r,s,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Hp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserPositionQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Ip({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return i({document:graphql.UserBalancesQuery,variables:{request:t,currency:s},suspense:e,pause:r})}function Bp({suspense:e=false,pause:r=false,...s}){return i({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Wp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userBalances(r,s,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function Op({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return i({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:s},suspense:e,pause:r,batch:false})}exports.AaveProvider=Ra;exports.CannotCancelSwapError=D;exports.useAaveClient=o;exports.useActivities=nt;exports.useActivitiesAction=ot;exports.useAsset=un;exports.useAssetBorrowHistory=cn;exports.useAssetPriceHistory=pn;exports.useAssetSupplyHistory=ln;exports.useBorrow=ct;exports.useBorrowApyHistory=bn;exports.useBorrowSwap=os;exports.useBorrowSwapQuote=is;exports.useBorrowSwapQuoteAction=ps;exports.useCancelSwap=ds;exports.useChain=Xa;exports.useChainAction=Za;exports.useChains=en;exports.useClaimRewards=St;exports.useExchangeRate=sn;exports.useExchangeRateAction=rn;exports.useHub=Fa;exports.useHubAssets=Ma;exports.useHubSummaryHistory=La;exports.useHubs=Va;exports.useHubsAction=Ka;exports.useLiquidatePosition=bt;exports.usePreview=ht;exports.usePreviewAction=Et;exports.useProtocolHistory=yn;exports.useRenounceSpokeUserPositionManager=Qt;exports.useRepay=It;exports.useRepayWithSupply=fs;exports.useRepayWithSupplyQuote=As;exports.useRepayWithSupplyQuoteAction=Us;exports.useReserve=Un;exports.useReserveAction=wn;exports.useReserves=Pn;exports.useReservesAction=gn;exports.useSetSpokeUserPositionManager=Wt;exports.useSetUserSuppliesAsCollateral=_t;exports.useSpoke=Bn;exports.useSpokePositionManagers=On;exports.useSpokeUserPositionManagers=Dn;exports.useSpokes=Wn;exports.useSupply=Kt;exports.useSupplyApyHistory=Tn;exports.useSupplySwap=gs;exports.useSupplySwapQuote=Ts;exports.useSupplySwapQuoteAction=xs;exports.useSwapStatus=qs;exports.useSwappableTokens=hs;exports.useTokenSwap=Ds;exports.useTokenSwapQuote=Ms;exports.useTokenSwapQuoteAction=Ls;exports.useUpdateUserPositionConditions=jt;exports.useUserBalances=Ip;exports.useUserBalancesAction=Wp;exports.useUserBorrows=vp;exports.useUserBorrowsAction=Qp;exports.useUserClaimableRewards=kn;exports.useUserClaimableRewardsAction=qn;exports.useUserPosition=Hp;exports.useUserPositions=qp;exports.useUserPositionsAction=Cp;exports.useUserRiskPremiumBreakdown=Bp;exports.useUserSummary=kp;exports.useUserSummaryHistory=Op;exports.useUserSupplies=Ep;exports.useUserSuppliesAction=hp;exports.useUserSwaps=zs;exports.useWithdraw=Xt;exports.useWithdrawSwap=Zs;exports.useWithdrawSwapQuote=rt;exports.useWithdrawSwapQuoteAction=st;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'),z=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 z__default=/*#__PURE__*/_interopDefault(z);var ne=z__default.default.createContext(null);function oe({children:e,client:r}){return z__default.default.createElement(ne.Provider,{value:r},z__default.default.createElement(urql.Provider,{value:r.urql},e))}function o(){let e=z.useContext(ne);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function wa({children:e,client:r}){return z__default.default.createElement(oe,{client:r},e)}function fr(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}=graphql.decodeUserPositionId(e.userPositionId);return r}function Rr(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}=graphql.decodeUserPositionId(e.userPositionId);return r}function E(e,r){return e.refreshQueryWhere(graphql.UserBalancesQuery,s=>s.request.user===r)}function H(e,r){return e.refreshQueryWhere(graphql.UserSuppliesQuery,s=>fr(s.request.query)===r)}function O(e,r){return e.refreshQueryWhere(graphql.UserBorrowsQuery,s=>Rr(s.request.query)===r)}function J(e,r,s){let t=a=>a.spoke.chain.chainId===s.chainId&&a.spoke.address===s.address&&a.user===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(a,n)=>n.some(t)),e.refreshQueryWhere(graphql.UserPositionQuery,(a,n)=>n!==null&&t(n))])}function X(e,r){let s=t=>r.includes(t.id);return types.ResultAsync.combine([e.refreshQueryWhere(graphql.ReserveQuery,(t,a)=>a!==null&&s(a)),e.refreshQueryWhere(graphql.ReservesQuery,(t,a)=>a.some(s))])}function Z(e,r,s){return e.refreshQueryWhere(graphql.UserSummaryQuery,t=>t.request.user===r&&(graphql.isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===s.chainId&&t.request.filter.spoke.address===s.address:graphql.isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(a=>a===s.chainId):false))}function ee(e,r){let s=t=>t.chain.chainId===r.chainId&&t.address===r.address;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.SpokeQuery,(t,a)=>a!==null&&s(a)),e.refreshQueryWhere(graphql.SpokesQuery,(t,a)=>a.some(s))])}function re(e,r){let s=t=>t.chain.chainId===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.HubQuery,(t,a)=>a!==null&&s(a)),e.refreshQueryWhere(graphql.HubsQuery,(t,a)=>a.some(s))])}function F(e,r){return e.refreshQueryWhere(graphql.SpokePositionManagersQuery,s=>s.request.spoke===r)}function le(e,r){return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(s,t)=>t.some(a=>a.id===r)),e.refreshQueryWhere(graphql.UserPositionQuery,(s,t)=>t?.id===r)])}function h(e,r){let{chainId:s,spoke:t}=graphql.decodeReserveId(r.reserve),a={chainId:s,address:t};return types.ResultAsync.combine([J(e,r.sender,a),Z(e,r.sender,a),X(e,[r.reserve]),ee(e,a),E(e,r.sender),H(e,r.sender),O(e,r.sender),re(e,s)])}function ce(e,r){return E(e,r)}function ye(e,r){return types.ResultAsync.combine([H(e,r),E(e,r)])}function de(e,r){return types.ResultAsync.combine([O(e,r),E(e,r)])}function Se(e,r){return types.ResultAsync.combine([H(e,r),O(e,r),E(e,r)])}function me(e,r){return types.ResultAsync.combine([H(e,r),E(e,r)])}var Q={Loading:e=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false,metadata:e}),Success:(e,r,s=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:s,metadata:r}),Failure:(e,r,s=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:s,metadata:r}),Paused:(e,r,s)=>({data:e,error:r,loading:false,paused:true,reloading:false,metadata:s})};function i({document:e,variables:r,suspense:s,pause:t,selector:a=types.ok,pollInterval:n=0,batch:l=true}){let[c,m]=z.useState({operationKey:0,resultOperationKey:void 0}),[U,w]=z.useState(true),q=z.useMemo(()=>urql.createRequest(e,r).key,[e,r]),[{fetching:T,data:C,error:M,stale:j},ae]=urql.useQuery({query:e,variables:r,pause:t,context:z.useMemo(()=>({batch:l,suspense:s}),[l,s])});if(z.useEffect(()=>{m(A=>({...A,operationKey:q}));},[q]),z.useEffect(()=>{t||T||w(false);},[T,t]),z.useEffect(()=>{t||T||m(A=>({...A,resultOperationKey:C&&!j?A.operationKey:A.resultOperationKey}));},[t,T,C,j]),z.useEffect(()=>{if(n<=0||T||t)return;let A=setTimeout(()=>{ae({requestPolicy:"network-only",batch:false});},n);return ()=>clearTimeout(A)},[T,ae,n,t]),t){let A=M?client.UnexpectedError.from(M):void 0;if(!C)return Q.Paused(void 0,A,c);let $=a(C.value);return $.isErr()?Q.Paused(void 0,$.error,c):Q.Paused($.value,A,c)}if(!s&&U)return Q.Loading(c);let G=j||!U&&T;if(M){let A=client.UnexpectedError.from(M);if(s)throw A;return Q.Failure(A,c,G)}types.invariant(C!==void 0,`Unexpected empty response from the API for '${core.extractDocumentName(e)??"unknown"}' query`);let Je=C===null?null:C.value,_=a(Je);if(_.isErr()){if(s)throw _.error;return Q.Failure(_.error,c,G)}return Q.Success(_.value,c,G)}var se={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 u(e,r){let[s,t]=z.useState(se.Idle()),a=z.useRef(false),n=z.useRef(true);z.useEffect(()=>()=>{n.current=false;},[]);let l=z.useCallback(e,r);return [z.useCallback(m=>{types.invariant(n.current,"Cannot execute a task on an unmounted component."),types.invariant(!a.current,"Cannot execute a task while another is in progress."),a.current=true;let U;t(w=>(U=w,{called:true,loading:true,data:w.data,error:void 0}));try{let w=l(m);return w.match(q=>{a.current=!1,t(se.Success(q));},q=>{a.current=!1,t(se.Failed(q));}),w}catch(w){throw a.current=false,U&&t(U),w}},[l]),s]}var p=e=>core.CancelError.from(e).asResultAsync(),d=class e{constructor(r){this.wait=r;}static isInstanceOf(r){return r instanceof e}static tryFrom(r){return e.isInstanceOf(r)?types.okAsync(r):core.UnexpectedError.from(r).asResultAsync()}};function R(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}function Ka({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.HubQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Ya({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.HubsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function ja({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.HubAssetsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Ga({suspense:e=false,pause:r=false,...s}){return i({document:graphql.HubSummaryHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function $a({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return i({document:graphql.HubAssetInterestRateModelQuery,variables:{request:t,currency:s},suspense:e,pause:r,selector:a=>types.ok(a.points)})}function za(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.hubAssetInterestRateModel(r,s,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function Ja(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.hubs(r,s,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function an({suspense:e=false,pause:r=false,...s}){return i({document:graphql.ChainQuery,variables:{request:s},suspense:e,pause:r})}function nn(){let e=o();return u(r=>actions.chain(e,r,{batch:false,requestPolicy:"cache-first"}),[e])}function on({suspense:e=false,pause:r=false,...s}={query:{filter:graphql.ChainsFilter.ALL}}){return i({document:graphql.ChainsQuery,variables:{request:s},suspense:e,pause:r})}function un(){let e=o();return u(r=>actions.exchangeRate(e,r,{requestPolicy:"network-only"}),[e])}function pn({suspense:e=false,pause:r=false,...s}){let t=o();return i({document:graphql.ExchangeRateQuery,variables:{request:s},suspense:e,pause:r,pollInterval:s.at?0:t.context.environment.exchangeRateInterval})}function Sn({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.AssetQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function mn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.AssetPriceHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function fn({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.AssetSupplyHistoryQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r,batch:false})}function Rn({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.AssetBorrowHistoryQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r,batch:false})}function An({suspense:e=false,pause:r=false,...s}){return i({document:graphql.ProtocolHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function xn({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.ReserveQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function En(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.reserve(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function hn({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.ReservesQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Qn(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.reserves(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function vn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.BorrowApyHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function kn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SupplyApyHistoryQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Wn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.UserClaimableRewardsQuery,variables:{request:s},suspense:e,pause:r})}function On(){let e=o();return u(r=>actions.userClaimableRewards(e,r,{requestPolicy:"cache-first"}),[e])}function _n({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokeQuery,variables:{request:s},suspense:e,pause:r})}function Fn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokesQuery,variables:{request:s},suspense:e,pause:r})}function Vn({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokePositionManagersQuery,variables:{request:s},suspense:e,pause:r})}function Ln({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SpokeUserPositionManagersQuery,variables:{request:s},suspense:e,pause:r})}function f(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 K(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function v(e){return {with:r=>e.approvals.reduce((s,t)=>s.andThen(a=>r(t,{cancel:p}).map(n=>{switch(t.__typename){case "PositionSwapAdapterContractApproval":a.adapterContractSignature=types.isSignature(n)?n:null;break;case "PositionSwapPositionManagerApproval":a.positionManagerSignature=types.isSignature(n)?n:null;break}return a})),types.okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function k(e,r){return actions.swap(e,{intent:r}).andThen(s=>{switch(s.__typename){case "SwapReceipt":return types.okAsync(s);default:return core.UnexpectedError.from(s).asResultAsync()}})}function ps(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Qe(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function cs({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.BorrowSwapQuoteQuery,variables:{request:Qe(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.BorrowSwapQuoteQuery,variables:{request:Qe(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function ys(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.borrowSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function qe(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}var D=class extends types.ResultAwareError{name="CannotCancelSwapError"};function fs(e){let r=o();return u(s=>actions.swapStatus(r,{id:s.id}).andThen(t=>{if(t===null)return core.UnexpectedError.from("Swap not found").asResultAsync();switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(r,s).andThen(a=>e(a.data,{cancel:p})).andThen(R).andThen(a=>actions.cancelSwap(r,{intent:{id:s.id,signature:a}})).andThen(a=>a.__typename==="SwapCancelledResult"?types.okAsync(a):e(a,{cancel:p}).andThen(d.tryFrom).andThen(n=>n.wait()).andThen(()=>actions.swapStatus(r,{id:s.id})).andThen(n=>n?.__typename==="SwapCancelled"?types.okAsync(qe(n)):new D("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(qe(t));case "SwapExpired":return new D("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[r,e])}function Us(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ie(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Ps({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function gs(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.repayWithSupplyQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function xs(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Oe(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function hs({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.SupplySwapQuoteQuery,variables:{request:Oe(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.SupplySwapQuoteQuery,variables:{request:Oe(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function Qs(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.supplySwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function ks({suspense:e=false,pause:r=false,...s}){return i({document:graphql.SwappableTokensQuery,variables:{request:s},suspense:e,pause:r})}function Is({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=i({document:graphql.SwapStatusQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval});return z.useEffect(()=>{m.data&&K(m.data)&&c(true);},[m.data]),m}function _s(e){let r=o(),s=z.useCallback(t=>actions.swap(r,t).andThen(a=>{switch(a.__typename){case "SwapTransactionRequest":return e(a,{cancel:p}).andThen(d.tryFrom).andThen(n=>n.wait()).andThen(()=>types.okAsync(a.orderReceipt));case "SwapReceipt":return types.okAsync(a)}}),[r,e]);return u(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...a})=>actions.tokenSwapQuote(r,a,{currency:t}).andThen(n=>{switch(n.__typename){case "SwapByTransaction":return s({transaction:{quoteId:n.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId}).andThen(l=>e(l.data,{cancel:p}).andThen(R).andThen(c=>s({intent:{quoteId:l.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(n)){let l=n.approvals[0];return e(l,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId,permitSig:{deadline:l.bySignature.message.deadline,value:c}}):d.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(R).andThen(m=>s({intent:{quoteId:c.newQuoteId,signature:m}})))}return n.approvals.reduce((l,c)=>l.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(d.tryFrom).andThen(m=>m.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})).andThen(l=>e(l.data,{cancel:p})).andThen(R).andThen(l=>s({intent:{quoteId:n.quote.quoteId,signature:l}}));default:types.never(`Unsupported swap quote result: ${n.__typename}. To be removed from API soon.`);}}),[r,e,s])}function te(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 Fe(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Ys({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.TokenSwapQuoteQuery,variables:{request:Fe(t,graphql.QuoteAccuracy.Fast),currency:s},selector:te,suspense:e,pause:r,batch:false}),l=i({document:graphql.TokenSwapQuoteQuery,variables:{request:Fe(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:te,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function js(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.tokenSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(te),[r,e.currency])}function Xs(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 Zs({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=i({document:graphql.UserSwapsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval}),U=m.data?.items??[],w=z.useDeferredValue(U);return z.useEffect(()=>{if(U.length===0)return;U.every(K)&&c(true);for(let T of Xs(U,w))switch(T.operation.__typename){case "TokenSwap":a.user&&ce(n,a.user);break;case "BorrowSwap":a.user&&de(n,a.user);break;case "RepayWithSupply":a.user&&Se(n,a.user);break;case "SupplySwap":a.user&&ye(n,a.user);break;case "WithdrawSwap":a.user&&me(n,a.user);break}},[U,w,n,a.user]),m}function st(e){let r=o();return u(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(r,t,{currency:s}).andThen(a=>v(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(R).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ye(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function at({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=i({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(t,graphql.QuoteAccuracy.Fast),currency:s},selector:f,suspense:e,pause:r,batch:false}),l=i({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(t,graphql.QuoteAccuracy.Accurate),currency:s},selector:f,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function nt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.withdrawSwapQuote(r,s,{currency:e.currency,requestPolicy:"network-only"}).andThen(f),[r,e.currency])}function it({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.ActivitiesQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function pt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.activities(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function St(e){let r=o();return u(s=>actions.borrow(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(a=>a.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(r.waitForTransaction).andThrough(()=>h(r,s)),[r,e])}function Rt(e){let r=o();return u(s=>actions.claimRewards(r,s).andThen(t=>e(t,{cancel:p})).andThen(d.tryFrom).andThen(t=>t.wait()).map(t=>client.transactionReceipt(t.txHash)),[r,e])}function Pt(e,r){return {deadline:r.message.deadline,value:e}}function B(e,r){return e.approvals.reduce((s,t)=>s.andThen(()=>r({...t,bySignature:null},{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function W(e,r,s){let t=e.approvals[0];return r(t,{cancel:p}).andThen(a=>types.isSignature(a)?s(Pt(a,t.bySignature)).map(types.expectTypename("TransactionRequest")):a.wait().map(()=>e.originalTransaction))}function xt(e,r){return "exact"in e.amount&&e.amount.exact?{...e,amount:{exact:{...e.amount.exact,permitSig:r}}}:e}function Et(e){let r=o();return u(s=>actions.liquidatePosition(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?W(t,e,a=>actions.liquidatePosition(r,xt(s,a))).andThen(a=>e(a,{cancel:p})):B(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(d.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>E(r,s.liquidator)),[r,e])}function vt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.preview(r,s,{currency:e.currency,requestPolicy:"network-only"}),[r,e.currency])}function kt({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return i({document:graphql.PreviewQuery,variables:{request:t,currency:s},suspense:e,pause:r})}function Ct(e){let r=o();return u(s=>actions.renounceSpokeUserPositionManager(r,s).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>F(r,s.spoke)),[r,e])}function Wt(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function Ot(e){let r=o();return u(s=>actions.repay(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?W(t,e,a=>actions.repay(r,Wt(s,a))).andThen(a=>e(a,{cancel:p})):B(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(d.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,s)),[r,e])}function Nt(e){let r=o();return u(s=>actions.setSpokeUserPositionManager(r,s).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>F(r,s.spoke)),[r,e])}function Vt(e){let r=o();return u(s=>{let t=s.changes.map(n=>n.reserve),a=t.map(n=>graphql.decodeReserveId(n));return actions.setUserSuppliesAsCollateral(r,s).andThen(n=>e(n,{cancel:p})).andThen(n=>n.wait()).andThen(r.waitForTransaction).andThrough(()=>types.ResultAsync.combine([H(r,s.sender),O(r,s.sender),...a.flatMap(({chainId:n,spoke:l})=>[J(r,s.sender,{chainId:n,address:l}),Z(r,s.sender,{chainId:n,address:l}),ee(r,{chainId:n,address:l})]),X(r,t),...a.map(({chainId:n})=>re(r,n))]))},[r,e])}function jt(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function Gt(e){let r=o();return u(s=>actions.supply(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?W(t,e,a=>actions.supply(r,jt(s,a))).andThen(a=>e(a,{cancel:p})):B(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(d.tryFrom).andThen(a=>a.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(d.tryFrom).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,s)),[r,e])}function zt(e){let r=o();return u(s=>actions.updateUserPositionConditions(r,s).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(r.waitForTransaction).andThrough(()=>le(r,s.userPositionId)),[r,e])}function ra(e){let r=o();return u(s=>actions.withdraw(r,s).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(a=>a.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(r.waitForTransaction).andThrough(()=>h(r,s)),[r,e])}function Cp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserSuppliesQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Hp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userSupplies(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Ip({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserBorrowsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Bp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userBorrows(r,s,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Wp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserSummaryQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Op({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserPositionsQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Dp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userPositions(r,s,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Np({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return i({document:graphql.UserPositionQuery,variables:{request:a,currency:s,timeWindow:t},suspense:e,pause:r})}function Mp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return i({document:graphql.UserBalancesQuery,variables:{request:t,currency:s},suspense:e,pause:r})}function _p({suspense:e=false,pause:r=false,...s}){return i({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:s},suspense:e,pause:r,batch:false})}function Fp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return u(s=>actions.userBalances(r,s,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function Vp({suspense:e=false,pause:r=false,currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return i({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:s},suspense:e,pause:r,batch:false})}exports.AaveProvider=wa;exports.CannotCancelSwapError=D;exports.useAaveClient=o;exports.useActivities=it;exports.useActivitiesAction=pt;exports.useAsset=Sn;exports.useAssetBorrowHistory=Rn;exports.useAssetPriceHistory=mn;exports.useAssetSupplyHistory=fn;exports.useBorrow=St;exports.useBorrowApyHistory=vn;exports.useBorrowSwap=ps;exports.useBorrowSwapQuote=cs;exports.useBorrowSwapQuoteAction=ys;exports.useCancelSwap=fs;exports.useChain=an;exports.useChainAction=nn;exports.useChains=on;exports.useClaimRewards=Rt;exports.useExchangeRate=pn;exports.useExchangeRateAction=un;exports.useHub=Ka;exports.useHubAssetInterestRateModel=$a;exports.useHubAssetInterestRateModelAction=za;exports.useHubAssets=ja;exports.useHubSummaryHistory=Ga;exports.useHubs=Ya;exports.useHubsAction=Ja;exports.useLiquidatePosition=Et;exports.usePreview=kt;exports.usePreviewAction=vt;exports.useProtocolHistory=An;exports.useRenounceSpokeUserPositionManager=Ct;exports.useRepay=Ot;exports.useRepayWithSupply=Us;exports.useRepayWithSupplyQuote=Ps;exports.useRepayWithSupplyQuoteAction=gs;exports.useReserve=xn;exports.useReserveAction=En;exports.useReserves=hn;exports.useReservesAction=Qn;exports.useSetSpokeUserPositionManager=Nt;exports.useSetUserSuppliesAsCollateral=Vt;exports.useSpoke=_n;exports.useSpokePositionManagers=Vn;exports.useSpokeUserPositionManagers=Ln;exports.useSpokes=Fn;exports.useSupply=Gt;exports.useSupplyApyHistory=kn;exports.useSupplySwap=xs;exports.useSupplySwapQuote=hs;exports.useSupplySwapQuoteAction=Qs;exports.useSwapStatus=Is;exports.useSwappableTokens=ks;exports.useTokenSwap=_s;exports.useTokenSwapQuote=Ys;exports.useTokenSwapQuoteAction=js;exports.useUpdateUserPositionConditions=zt;exports.useUserBalances=Mp;exports.useUserBalancesAction=Fp;exports.useUserBorrows=Ip;exports.useUserBorrowsAction=Bp;exports.useUserClaimableRewards=Wn;exports.useUserClaimableRewardsAction=On;exports.useUserPosition=Np;exports.useUserPositions=Op;exports.useUserPositionsAction=Dp;exports.useUserRiskPremiumBreakdown=_p;exports.useUserSummary=Wp;exports.useUserSummaryHistory=Vp;exports.useUserSupplies=Cp;exports.useUserSuppliesAction=Hp;exports.useUserSwaps=Zs;exports.useWithdraw=ra;exports.useWithdrawSwap=st;exports.useWithdrawSwapQuote=at;exports.useWithdrawSwapQuoteAction=nt;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