@aave/react 4.0.0-next.46 → 4.0.0-next.47

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