@aave/react 4.0.0-next.41 → 4.0.0-next.42

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'),M=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 M__default=/*#__PURE__*/_interopDefault(M);var te=M__default.default.createContext(null);function ae({children:e,client:s}){return M__default.default.createElement(te.Provider,{value:s},M__default.default.createElement(urql.Provider,{value:s.urql},e))}function o(){let e=M.useContext(te);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 M__default.default.createElement(ae,{client:s},e)}function ps(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 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 oe(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function F(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>ps(r.request.query)===s)}function L(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>ls(r.request.query)===s)}function j(e,s,r){return Promise.all([e.refreshQueryWhere(graphql.UserPositionsQuery,(t,a)=>a.some(n=>n.spoke.chain.chainId===r.chainId&&n.spoke.address===r.address&&n.user===s)),e.refreshQueryWhere(graphql.UserPositionQuery,(t,a)=>a?.spoke.chain.chainId===r.chainId&&a?.spoke.address===r.address&&a.user===s)])}function G(e,s){return Promise.all([e.refreshQueryWhere(graphql.ReserveQuery,(r,t)=>t!==null&&s.includes(t.id)),e.refreshQueryWhere(graphql.ReservesQuery,(r,t)=>t.some(a=>s.includes(a.id)))])}function Y(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(a=>a===r.chainId):false)}function $(e,s){return Promise.all([e.refreshQueryWhere(graphql.SpokeQuery,(r,t)=>t?.chain.chainId===s.chainId&&t?.address===s.address),e.refreshQueryWhere(graphql.SpokesQuery,(r,t)=>t.some(a=>a.chain.chainId===s.chainId&&a.address===s.address))])}function K(e,s){return Promise.all([e.refreshQueryWhere(graphql.HubQuery,r=>graphql.isHubInputVariant(r.request.query)?r.request.query.hubInput.chainId===s:graphql.decodeHubId(r.request.query.hubId).chainId===s),e.refreshQueryWhere(graphql.HubsQuery,r=>graphql.isChainIdsVariant(r.request)?r.request.chainIds.some(t=>t===s):graphql.isTokensVariant(r.request.query)?r.request.query.tokens.some(t=>t.chainId===s):true)])}var P={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 u({document:e,variables:s,suspense:r,pause:t,selector:a=types.ok,pollInterval:n=0,batch:i=true}){let[c,y]=M.useState(true),[{fetching:f,data:g,error:q,stale:Me},re]=urql.useQuery({query:e,variables:s,pause:t,context:M.useMemo(()=>({batch:i,suspense:r}),[i,r])});if(M.useEffect(()=>{t||f||y(false);},[f,t]),M.useEffect(()=>{if(n<=0||f||t)return;let T=setTimeout(()=>{re({requestPolicy:"network-only",batch:false});},n);return ()=>clearTimeout(T)},[f,re,n,t]),t){let T=q?client.UnexpectedError.from(q):void 0;if(!g)return P.Paused(void 0,T);let _=a(g.value);return _.isErr()?P.Paused(void 0,_.error):P.Paused(_.value,T)}if(!r&&c)return P.Loading();let V=Me||!c&&f;if(q){let T=client.UnexpectedError.from(q);if(r)throw T;return P.Failure(T,V)}types.invariant(g,"No data returned");let H=a(g.value);if(H.isErr()){if(r)throw H.error;return P.Failure(H.error,V)}return P.Success(H.value,V)}var z={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]=M.useState(z.Idle()),a=M.useRef(false),n=M.useCallback(e,s);return [M.useCallback(c=>{types.invariant(!a.current,"Cannot execute a task while another is in progress."),a.current=true;let y;t(f=>(y=f,{called:true,loading:true,data:f.data,error:void 0}));try{let f=n(c);return f.match(g=>{a.current=!1,t(z.Success(g));},g=>{a.current=!1,t(z.Failed(g));}),f}catch(f){throw a.current=false,t(types.nonNullable(y)),f}},[n]),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 A(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,...a}){return u({document:graphql.HubQuery,variables:{request:a,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,...a}){return u({document:graphql.HubsQuery,variables:{request:a,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,...a}){return u({document:graphql.HubAssetsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function St({suspense:e=false,pause:s=false,...r}){return u({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Rt(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 u({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function wt(){let e=o();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 u({document:graphql.ChainsQuery,variables:{request:r},suspense:e,pause:s})}function xt(){let e=o();return l(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function ht({suspense:e=false,pause:s=false,...r}){let t=o();return u({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,...a}){return u({document:graphql.AssetQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Ht({suspense:e=false,pause:s=false,...r}){return u({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,...a}){return u({document:graphql.AssetSupplyHistoryQuery,variables:{request:a,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,...a}){return u({document:graphql.AssetBorrowHistoryQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function Bt({suspense:e=false,pause:s=false,...r}){return u({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,...a}){return u({document:graphql.ReserveQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Ft(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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,...a}){return u({document:graphql.ReservesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function jt(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 u({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Yt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Zt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.UserClaimableRewardsQuery,variables:{request:r},suspense:e,pause:s})}function ea(){let e=o();return l(s=>actions.userClaimableRewards(e,s,{requestPolicy:"cache-first"}),[e])}function aa({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function na({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function ua({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function oa({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function X(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 be(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 Ae(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function ge(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Pe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function we(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Te(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Ua({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.TokenSwapQuoteQuery,variables:{request:Ae(t,graphql.QuoteAccuracy.Fast),currency:r},selector:X,suspense:e,pause:s,batch:false}),i=u({document:graphql.TokenSwapQuoteQuery,variables:{request:Ae(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:X,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function ba(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(X),[s,e.currency])}function Aa({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function ga({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[i,c]=M.useState(false),y=u({document:graphql.UserSwapsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:n.context.environment.swapStatusInterval});return M.useEffect(()=>{y.data&&y.data.items.length>0&&y.data.items.every(Be)&&c(true);},[y.data]),y}function Be(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function Pa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[i,c]=M.useState(false),y=u({document:graphql.SwapStatusQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:n.context.environment.swapStatusInterval});return M.useEffect(()=>{y.data&&Be(y.data)&&c(true);},[y.data]),y}function wa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.SupplySwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.SupplySwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function Ta(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function xa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function ha(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function D(e){return {with:s=>e.approvals.reduce((r,t)=>r.andThen(a=>s(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 O(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 Ea(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function Qa(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function ka({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function va(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function qa(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function Ha({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function Ca(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function Ia(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function Ba(e){let s=o(),r=M.useCallback(t=>actions.swap(s,t).andThen(a=>{switch(a.__typename){case "SwapTransactionRequest":return e(a,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>types.okAsync(a.orderReceipt));case "SwapReceipt":return types.okAsync(a)}}),[s,e]);return l(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...a})=>actions.tokenSwapQuote(s,a,{currency:t}).andThen(n=>{switch(n.__typename){case "SwapByTransaction":return r({transaction:{quoteId:n.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId}).andThen(i=>e(i.data,{cancel:p}).andThen(A).andThen(c=>r({intent:{quoteId:i.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(n)){let i=n.approvals[0];return e(i,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId,permitSig:{deadline:i.bySignature.message.deadline,value:c}}):R.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(A).andThen(y=>r({intent:{quoteId:c.newQuoteId,signature:y}})))}return n.approvals.reduce((i,c)=>i.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(y=>y.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId})).andThen(i=>e(i.data,{cancel:p})).andThen(A).andThen(i=>r({intent:{quoteId:n.quote.quoteId,signature:i}}));default:types.never(`Unsupported swap quote result: ${n.__typename}. To be removed from API soon.`);}}),[s,e,r])}var B=class extends types.ResultAwareError{name="CannotCancelSwapError"};function Wa(e){let s=o();return l(r=>actions.swapStatus(s,{id:r.id}).andThen(t=>{switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(s,r).andThen(a=>e(a.data,{cancel:p})).andThen(A).andThen(a=>actions.cancelSwap(s,{intent:{id:r.id,signature:a}})).andThen(a=>a.__typename==="SwapCancelledResult"?types.okAsync(a):e(a,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(n=>n.__typename==="SwapCancelled"?types.okAsync(be(n)):new B("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(be(t));case "SwapExpired":return new B("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function N(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),a={chainId:r,address:t};return async()=>Promise.all([j(e,s.sender,a),Y(e,s.sender,a),G(e,[s.reserve]),$(e,a),oe(e,s.sender),F(e,s.sender),L(e,s.sender),K(e,r)])}function gr(e,s){return {deadline:s.message.deadline,value:e}}function ee(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function se(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(a=>types.isSignature(a)?r(gr(a,t.bySignature)).map(types.expectTypename("TransactionRequest")):a.wait().map(()=>e.originalTransaction))}function ja(e){let s=o();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)?se(t,e,a=>actions.supply(s,Pr(r,a))).andThen(a=>e(a,{cancel:p})):ee(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.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).andTee(N(s,r)),[s,e])}function Pr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Ga(e){let s=o();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(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(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Ya(e){let s=o();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)?se(t,e,a=>actions.repay(s,wr(r,a))).andThen(a=>e(a,{cancel:p})):ee(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.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).andTee(N(s,r)),[s,e])}function wr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function $a(e){let s=o();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(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(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Ka(e){let s=o();return l(r=>actions.renounceSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function za(e){let s=o();return l(r=>actions.updateUserPositionConditions(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(async()=>{let{userPositionId:t}=r;return Promise.all([s.refreshQueryWhere(graphql.UserPositionsQuery,(a,n)=>n.some(i=>i.id===t)),s.refreshQueryWhere(graphql.UserPositionQuery,(a,n)=>n?.id===t)])}),[s,e])}function Ja(e){let s=o();return l(r=>{let t=r.changes.map(n=>n.reserve),a=t.map(n=>graphql.decodeReserveId(n));return actions.setUserSuppliesAsCollateral(s,r).andThen(n=>e(n,{cancel:p})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(()=>Promise.all([F(s,r.sender),L(s,r.sender),...a.flatMap(({chainId:n,spoke:i})=>[j(s,r.sender,{chainId:n,address:i}),Y(s,r.sender,{chainId:n,address:i}),$(s,{chainId:n,address:i})]),G(s,t),...a.map(({chainId:n})=>K(s,n))]))},[s,e])}function Xa(e){let s=o();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)?se(t,e,a=>actions.liquidatePosition(s,Tr(r))).andThen(a=>e(a,{cancel:p})):ee(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.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 Za(e){let s=o();return l(r=>actions.setSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function en(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.preview(s,r,{currency:e.currency,requestPolicy:"network-only"}),[s,e.currency])}function sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return u({document:graphql.PreviewQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function rn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ActivitiesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function tn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 an(e){let s=o();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 dn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSuppliesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function yn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 Sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserBorrowsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Rn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 fn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSummaryQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function mn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Un(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function bn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function An({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return u({document:graphql.UserBalancesQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function gn({suspense:e=false,pause:s=false,...r}){return u({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Pn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.userBalances(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function wn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return u({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:r},suspense:e,pause:s,batch:false})}exports.AaveProvider=Fr;exports.CannotCancelSwapError=B;exports.useAaveClient=o;exports.useActivities=rn;exports.useActivitiesAction=tn;exports.useAsset=qt;exports.useAssetBorrowHistory=It;exports.useAssetPriceHistory=Ht;exports.useAssetSupplyHistory=Ct;exports.useBorrow=Ga;exports.useBorrowApyHistory=Gt;exports.useBorrowSwap=Qa;exports.useBorrowSwapQuote=xa;exports.useBorrowSwapQuoteAction=ha;exports.useCancelSwap=Wa;exports.useChain=Pt;exports.useChainAction=wt;exports.useChains=Tt;exports.useClaimRewards=an;exports.useExchangeRate=ht;exports.useExchangeRateAction=xt;exports.useHub=ct;exports.useHubAssets=yt;exports.useHubSummaryHistory=St;exports.useHubs=dt;exports.useHubsAction=Rt;exports.useLiquidatePosition=Xa;exports.usePreview=sn;exports.usePreviewAction=en;exports.useProtocolHistory=Bt;exports.useRenounceSpokeUserPositionManager=Ka;exports.useRepay=Ya;exports.useRepayWithSupply=qa;exports.useRepayWithSupplyQuote=ka;exports.useRepayWithSupplyQuoteAction=va;exports.useReserve=Mt;exports.useReserveAction=Ft;exports.useReserves=Lt;exports.useReservesAction=jt;exports.useSetSpokeUserPositionManager=Za;exports.useSetUserSuppliesAsCollateral=Ja;exports.useSpoke=aa;exports.useSpokePositionManagers=ua;exports.useSpokeUserPositionManagers=oa;exports.useSpokes=na;exports.useSupply=ja;exports.useSupplyApyHistory=Yt;exports.useSupplySwap=Ea;exports.useSupplySwapQuote=wa;exports.useSupplySwapQuoteAction=Ta;exports.useSwapStatus=Pa;exports.useSwappableTokens=Aa;exports.useTokenSwap=Ba;exports.useTokenSwapQuote=Ua;exports.useTokenSwapQuoteAction=ba;exports.useUpdateUserPositionConditions=za;exports.useUserBalances=An;exports.useUserBalancesAction=Pn;exports.useUserBorrows=Sn;exports.useUserBorrowsAction=Rn;exports.useUserClaimableRewards=Zt;exports.useUserClaimableRewardsAction=ea;exports.useUserPosition=bn;exports.useUserPositions=mn;exports.useUserPositionsAction=Un;exports.useUserRiskPremiumBreakdown=gn;exports.useUserSummary=fn;exports.useUserSummaryHistory=wn;exports.useUserSupplies=dn;exports.useUserSuppliesAction=yn;exports.useUserSwaps=ga;exports.useWithdraw=$a;exports.useWithdrawSwap=Ia;exports.useWithdrawSwapQuote=Ha;exports.useWithdrawSwapQuoteAction=Ca;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'),M=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 M__default=/*#__PURE__*/_interopDefault(M);var te=M__default.default.createContext(null);function ae({children:e,client:s}){return M__default.default.createElement(te.Provider,{value:s},M__default.default.createElement(urql.Provider,{value:s.urql},e))}function o(){let e=M.useContext(te);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 M__default.default.createElement(ae,{client:s},e)}function ps(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 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 oe(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function F(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>ps(r.request.query)===s)}function L(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>ls(r.request.query)===s)}function j(e,s,r){return Promise.all([e.refreshQueryWhere(graphql.UserPositionsQuery,(t,a)=>a.some(n=>n.spoke.chain.chainId===r.chainId&&n.spoke.address===r.address&&n.user===s)),e.refreshQueryWhere(graphql.UserPositionQuery,(t,a)=>a?.spoke.chain.chainId===r.chainId&&a?.spoke.address===r.address&&a.user===s)])}function G(e,s){return Promise.all([e.refreshQueryWhere(graphql.ReserveQuery,(r,t)=>t!==null&&s.includes(t.id)),e.refreshQueryWhere(graphql.ReservesQuery,(r,t)=>t.some(a=>s.includes(a.id)))])}function Y(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(a=>a===r.chainId):false)}function $(e,s){return Promise.all([e.refreshQueryWhere(graphql.SpokeQuery,(r,t)=>t?.chain.chainId===s.chainId&&t?.address===s.address),e.refreshQueryWhere(graphql.SpokesQuery,(r,t)=>t.some(a=>a.chain.chainId===s.chainId&&a.address===s.address))])}function K(e,s){return Promise.all([e.refreshQueryWhere(graphql.HubQuery,r=>graphql.isHubInputVariant(r.request.query)?r.request.query.hubInput.chainId===s:graphql.decodeHubId(r.request.query.hubId).chainId===s),e.refreshQueryWhere(graphql.HubsQuery,r=>graphql.isChainIdsVariant(r.request)?r.request.chainIds.some(t=>t===s):graphql.isTokensVariant(r.request.query)?r.request.query.tokens.some(t=>t.chainId===s):true)])}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 u({document:e,variables:s,suspense:r,pause:t,selector:a=types.ok,pollInterval:n=0,batch:i=true}){let[c,y]=M.useState(true),[{fetching:f,data:g,error:q,stale:Me},re]=urql.useQuery({query:e,variables:s,pause:t,context:M.useMemo(()=>({batch:i,suspense:r}),[i,r])});if(M.useEffect(()=>{t||f||y(false);},[f,t]),M.useEffect(()=>{if(n<=0||f||t)return;let T=setTimeout(()=>{re({requestPolicy:"network-only",batch:false});},n);return ()=>clearTimeout(T)},[f,re,n,t]),t){let T=q?client.UnexpectedError.from(q):void 0;if(!g)return w.Paused(void 0,T);let _=a(g.value);return _.isErr()?w.Paused(void 0,_.error):w.Paused(_.value,T)}if(!r&&c)return w.Loading();let V=Me||!c&&f;if(q){let T=client.UnexpectedError.from(q);if(r)throw T;return w.Failure(T,V)}types.invariant(g,"No data returned");let H=a(g.value);if(H.isErr()){if(r)throw H.error;return w.Failure(H.error,V)}return w.Success(H.value,V)}var z={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]=M.useState(z.Idle()),a=M.useRef(false),n=M.useCallback(e,s);return [M.useCallback(c=>{types.invariant(!a.current,"Cannot execute a task while another is in progress."),a.current=true;let y;t(f=>(y=f,{called:true,loading:true,data:f.data,error:void 0}));try{let f=n(c);return f.match(g=>{a.current=!1,t(z.Success(g));},g=>{a.current=!1,t(z.Failed(g));}),f}catch(f){throw a.current=false,t(types.nonNullable(y)),f}},[n]),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 A(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,...a}){return u({document:graphql.HubQuery,variables:{request:a,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,...a}){return u({document:graphql.HubsQuery,variables:{request:a,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,...a}){return u({document:graphql.HubAssetsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function St({suspense:e=false,pause:s=false,...r}){return u({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Rt(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 u({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function Pt(){let e=o();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 u({document:graphql.ChainsQuery,variables:{request:r},suspense:e,pause:s})}function xt(){let e=o();return l(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function ht({suspense:e=false,pause:s=false,...r}){let t=o();return u({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,...a}){return u({document:graphql.AssetQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Ht({suspense:e=false,pause:s=false,...r}){return u({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,...a}){return u({document:graphql.AssetSupplyHistoryQuery,variables:{request:a,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,...a}){return u({document:graphql.AssetBorrowHistoryQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function Bt({suspense:e=false,pause:s=false,...r}){return u({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,...a}){return u({document:graphql.ReserveQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Ft(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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,...a}){return u({document:graphql.ReservesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function jt(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 u({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Yt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Zt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.UserClaimableRewardsQuery,variables:{request:r},suspense:e,pause:s})}function ea(){let e=o();return l(s=>actions.userClaimableRewards(e,s,{requestPolicy:"cache-first"}),[e])}function aa({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function na({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function ua({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function oa({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function X(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 be(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 Ae(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function ge(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function we(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Pe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Te(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Ua({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.TokenSwapQuoteQuery,variables:{request:Ae(t,graphql.QuoteAccuracy.Fast),currency:r},selector:X,suspense:e,pause:s,batch:false}),i=u({document:graphql.TokenSwapQuoteQuery,variables:{request:Ae(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:X,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function ba(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(X),[s,e.currency])}function Aa({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function ga({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[i,c]=M.useState(false),y=u({document:graphql.UserSwapsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:n.context.environment.swapStatusInterval});return M.useEffect(()=>{y.data&&y.data.items.length>0&&y.data.items.every(Be)&&c(true);},[y.data]),y}function Be(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function wa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[i,c]=M.useState(false),y=u({document:graphql.SwapStatusQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s||i,pollInterval:n.context.environment.swapStatusInterval});return M.useEffect(()=>{y.data&&Be(y.data)&&c(true);},[y.data]),y}function Pa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.SupplySwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.SupplySwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function Ta(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function xa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function ha(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function D(e){return {with:s=>e.approvals.reduce((r,t)=>r.andThen(a=>s(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 O(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 Ea(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function Qa(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function ka({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function va(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function qa(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function Ha({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let a=o(),n=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),i=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return i.data?i:n}function Ca(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(m),[s,e.currency])}function Ia(e){let s=o();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(a=>D(a).with(e).andThen(n=>actions.preparePositionSwap(s,n)).andThen(n=>e(n.data,{cancel:p}).andThen(A).andThen(i=>O(s,{quoteId:n.newQuoteId,signature:i})))),[s,e])}function Ba(e){let s=o(),r=M.useCallback(t=>actions.swap(s,t).andThen(a=>{switch(a.__typename){case "SwapTransactionRequest":return e(a,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>types.okAsync(a.orderReceipt));case "SwapReceipt":return types.okAsync(a)}}),[s,e]);return l(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...a})=>actions.tokenSwapQuote(s,a,{currency:t}).andThen(n=>{switch(n.__typename){case "SwapByTransaction":return r({transaction:{quoteId:n.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId}).andThen(i=>e(i.data,{cancel:p}).andThen(A).andThen(c=>r({intent:{quoteId:i.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(n)){let i=n.approvals[0];return e(i,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId,permitSig:{deadline:i.bySignature.message.deadline,value:c}}):R.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(A).andThen(y=>r({intent:{quoteId:c.newQuoteId,signature:y}})))}return n.approvals.reduce((i,c)=>i.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(y=>y.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:n.quote.quoteId})).andThen(i=>e(i.data,{cancel:p})).andThen(A).andThen(i=>r({intent:{quoteId:n.quote.quoteId,signature:i}}));default:types.never(`Unsupported swap quote result: ${n.__typename}. To be removed from API soon.`);}}),[s,e,r])}var B=class extends types.ResultAwareError{name="CannotCancelSwapError"};function Wa(e){let s=o();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(a=>e(a.data,{cancel:p})).andThen(A).andThen(a=>actions.cancelSwap(s,{intent:{id:r.id,signature:a}})).andThen(a=>a.__typename==="SwapCancelledResult"?types.okAsync(a):e(a,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(n=>n?.__typename==="SwapCancelled"?types.okAsync(be(n)):new B("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(be(t));case "SwapExpired":return new B("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function N(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),a={chainId:r,address:t};return async()=>Promise.all([j(e,s.sender,a),Y(e,s.sender,a),G(e,[s.reserve]),$(e,a),oe(e,s.sender),F(e,s.sender),L(e,s.sender),K(e,r)])}function gr(e,s){return {deadline:s.message.deadline,value:e}}function ee(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function se(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(a=>types.isSignature(a)?r(gr(a,t.bySignature)).map(types.expectTypename("TransactionRequest")):a.wait().map(()=>e.originalTransaction))}function ja(e){let s=o();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)?se(t,e,a=>actions.supply(s,wr(r,a))).andThen(a=>e(a,{cancel:p})):ee(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.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).andTee(N(s,r)),[s,e])}function wr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Ga(e){let s=o();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(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(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Ya(e){let s=o();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)?se(t,e,a=>actions.repay(s,Pr(r,a))).andThen(a=>e(a,{cancel:p})):ee(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.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).andTee(N(s,r)),[s,e])}function Pr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function $a(e){let s=o();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(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(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Ka(e){let s=o();return l(r=>actions.renounceSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function za(e){let s=o();return l(r=>actions.updateUserPositionConditions(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(async()=>{let{userPositionId:t}=r;return Promise.all([s.refreshQueryWhere(graphql.UserPositionsQuery,(a,n)=>n.some(i=>i.id===t)),s.refreshQueryWhere(graphql.UserPositionQuery,(a,n)=>n?.id===t)])}),[s,e])}function Ja(e){let s=o();return l(r=>{let t=r.changes.map(n=>n.reserve),a=t.map(n=>graphql.decodeReserveId(n));return actions.setUserSuppliesAsCollateral(s,r).andThen(n=>e(n,{cancel:p})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(()=>Promise.all([F(s,r.sender),L(s,r.sender),...a.flatMap(({chainId:n,spoke:i})=>[j(s,r.sender,{chainId:n,address:i}),Y(s,r.sender,{chainId:n,address:i}),$(s,{chainId:n,address:i})]),G(s,t),...a.map(({chainId:n})=>K(s,n))]))},[s,e])}function Xa(e){let s=o();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)?se(t,e,a=>actions.liquidatePosition(s,Tr(r))).andThen(a=>e(a,{cancel:p})):ee(t,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.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 Za(e){let s=o();return l(r=>actions.setSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function en(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.preview(s,r,{currency:e.currency,requestPolicy:"network-only"}),[s,e.currency])}function sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return u({document:graphql.PreviewQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function rn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ActivitiesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function tn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 an(e){let s=o();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 dn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSuppliesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function yn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 Sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserBorrowsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Rn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();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 fn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSummaryQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function mn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionsQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function Un(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function bn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s})}function An({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return u({document:graphql.UserBalancesQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function gn({suspense:e=false,pause:s=false,...r}){return u({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function wn(e=client.DEFAULT_QUERY_OPTIONS){let s=o();return l(r=>actions.userBalances(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function Pn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return u({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:r},suspense:e,pause:s,batch:false})}exports.AaveProvider=Fr;exports.CannotCancelSwapError=B;exports.useAaveClient=o;exports.useActivities=rn;exports.useActivitiesAction=tn;exports.useAsset=qt;exports.useAssetBorrowHistory=It;exports.useAssetPriceHistory=Ht;exports.useAssetSupplyHistory=Ct;exports.useBorrow=Ga;exports.useBorrowApyHistory=Gt;exports.useBorrowSwap=Qa;exports.useBorrowSwapQuote=xa;exports.useBorrowSwapQuoteAction=ha;exports.useCancelSwap=Wa;exports.useChain=wt;exports.useChainAction=Pt;exports.useChains=Tt;exports.useClaimRewards=an;exports.useExchangeRate=ht;exports.useExchangeRateAction=xt;exports.useHub=ct;exports.useHubAssets=yt;exports.useHubSummaryHistory=St;exports.useHubs=dt;exports.useHubsAction=Rt;exports.useLiquidatePosition=Xa;exports.usePreview=sn;exports.usePreviewAction=en;exports.useProtocolHistory=Bt;exports.useRenounceSpokeUserPositionManager=Ka;exports.useRepay=Ya;exports.useRepayWithSupply=qa;exports.useRepayWithSupplyQuote=ka;exports.useRepayWithSupplyQuoteAction=va;exports.useReserve=Mt;exports.useReserveAction=Ft;exports.useReserves=Lt;exports.useReservesAction=jt;exports.useSetSpokeUserPositionManager=Za;exports.useSetUserSuppliesAsCollateral=Ja;exports.useSpoke=aa;exports.useSpokePositionManagers=ua;exports.useSpokeUserPositionManagers=oa;exports.useSpokes=na;exports.useSupply=ja;exports.useSupplyApyHistory=Yt;exports.useSupplySwap=Ea;exports.useSupplySwapQuote=Pa;exports.useSupplySwapQuoteAction=Ta;exports.useSwapStatus=wa;exports.useSwappableTokens=Aa;exports.useTokenSwap=Ba;exports.useTokenSwapQuote=Ua;exports.useTokenSwapQuoteAction=ba;exports.useUpdateUserPositionConditions=za;exports.useUserBalances=An;exports.useUserBalancesAction=wn;exports.useUserBorrows=Sn;exports.useUserBorrowsAction=Rn;exports.useUserClaimableRewards=Zt;exports.useUserClaimableRewardsAction=ea;exports.useUserPosition=bn;exports.useUserPositions=mn;exports.useUserPositionsAction=Un;exports.useUserRiskPremiumBreakdown=gn;exports.useUserSummary=fn;exports.useUserSummaryHistory=Pn;exports.useUserSupplies=dn;exports.useUserSuppliesAction=yn;exports.useUserSwaps=ga;exports.useWithdraw=$a;exports.useWithdrawSwap=Ia;exports.useWithdrawSwapQuote=Ha;exports.useWithdrawSwapQuoteAction=Ca;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