@aave/react 4.0.0-next.32 → 4.0.0-next.34

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'),W=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 W__default=/*#__PURE__*/_interopDefault(W);var L=W__default.default.createContext(null);function Y({children:e,client:s}){return W__default.default.createElement(L.Provider,{value:s},W__default.default.createElement(urql.Provider,{value:s.urql},e))}function i(){let e=W.useContext(L);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Cr({children:e,client:s}){return W__default.default.createElement(Y,{client:s},e)}function Ye(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:s}=graphql.decodeUserPositionId(e.userPositionId);return s}function Ge(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 $(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function K(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>Ye(r.request.query)===s)}function z(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>Ge(r.request.query)===s)}function J(e,s,r){return Promise.all([e.refreshQueryWhere(graphql.UserPositionsQuery,(t,n)=>n.some(a=>a.spoke.chain.chainId===r.chainId&&a.spoke.address===r.address&&a.user===s)),e.refreshQueryWhere(graphql.UserPositionQuery,(t,n)=>n?.spoke.chain.chainId===r.chainId&&n?.spoke.address===r.address&&n.user===s)])}function X(e,s){return Promise.all([e.refreshQueryWhere(graphql.ReserveQuery,(r,t)=>t?.id===s),e.refreshQueryWhere(graphql.ReservesQuery,(r,t)=>t.some(n=>n.id===s))])}function Z(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 ee(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(n=>n.chain.chainId===s.chainId&&n.address===s.address))])}function se(e,s){return e.refreshQueryWhere(graphql.HubsQuery,r=>graphql.isChainIdsVariant(r.request)&&r.request.chainIds.some(t=>t===s))}var T={Loading:()=>({data:void 0,error:void 0,loading:true,paused:false}),Success:e=>({data:e,error:void 0,loading:false,paused:false}),Failure:e=>({data:void 0,error:e,loading:false,paused:false}),Paused:(e,s)=>({data:e,error:s,loading:false,paused:true})};function o({document:e,variables:s,suspense:r,pause:t,selector:n=types.identity,pollInterval:a=0,batch:u=true}){let[l,y]=W.useState(true),[{fetching:S,data:g,error:Q},F]=urql.useQuery({query:e,variables:s,pause:t,context:W.useMemo(()=>({batch:u,suspense:r}),[u,r])});if(W.useEffect(()=>{t||S||y(false);},[S,t]),W.useEffect(()=>{if(a<=0||S||t)return;let E=setTimeout(()=>{F({requestPolicy:"network-only",batch:false});},a);return ()=>clearTimeout(E)},[S,F,a,t]),t)return T.Paused(g?n(g.value):void 0,Q?client.UnexpectedError.from(Q):void 0);if(!r&&l)return T.Loading();if(Q){let E=client.UnexpectedError.from(Q);if(r)throw E;return T.Failure(E)}return types.invariant(g,"No data returned"),T.Success(n(g.value))}var O={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 c(e,s){let[r,t]=W.useState(O.Idle()),n=W.useRef(false),a=W.useCallback(e,s);return [W.useCallback(l=>{types.invariant(!n.current,"Cannot execute a task while another is in progress."),n.current=true;let y;t(S=>(y=S,{called:true,loading:true,data:S.data,error:void 0}));try{let S=a(l);return S.match(g=>{n.current=!1,t(O.Success(g));},g=>{n.current=!1,t(O.Failed(g));}),S}catch(S){throw n.current=false,t(types.nonNullable(y)),S}},[a]),r]}var p=e=>core.CancelError.from(e).asResultAsync(),f=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 m(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}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.HubQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function rt({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 tt({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 nt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function at(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.hubs(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function yt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function dt(){let e=i();return c(s=>actions.chain(e,s,{batch:false,requestPolicy:"cache-first"}),[e])}function St({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 Rt(){let e=i();return c(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function ft({suspense:e=false,pause:s=false,...r}){let t=i();return o({document:graphql.ExchangeRateQuery,variables:{request:r},suspense:e,pause:s,pollInterval:r.at?0:t.context.environment.exchangeRateInterval})}function Pt({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 bt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.AssetPriceHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function wt({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 Tt({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 xt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ProtocolHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}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.ReserveQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Ct(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 Bt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,selector:n,...a}){return o({document:graphql.ReservesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s,selector:n||void 0})}function It(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 Wt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ot({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function _t({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function Mt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function Ft({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function Lt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function N(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return e.quote;default:throw core.UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`)}}function le(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:"limit"in e&&e.limit?{limit:{...e.limit,accuracy:s}}:e}function sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=o({document:graphql.TokenSwapQuoteQuery,variables:{request:le(t,graphql.QuoteAccuracy.Fast),currency:r},selector:N,suspense:e,pause:s,batch:false}),u=o({document:graphql.TokenSwapQuoteQuery,variables:{request:le(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:N,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function rn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(N),[s,e.currency])}function tn({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function nn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=i(),[u,l]=W.useState(false),y=o({document:graphql.UserSwapsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return W.useEffect(()=>{y.data&&y.data.items.length>0&&y.data.items.every(ge)&&l(true);},[y.data]),y}function ge(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function an({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=i(),[u,l]=W.useState(false),y=o({document:graphql.SwapStatusQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return W.useEffect(()=>{y.data&&ge(y.data)&&l(true);},[y.data]),y}function un({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.SupplySwapQuoteQuery,variables:{request:t,currency:r},selector:n=>n.quote,suspense:e,pause:s})}function on(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(t=>t.quote),[s,e.currency])}function pn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.BorrowSwapQuoteQuery,variables:{request:t,currency:r},selector:n=>n.quote,suspense:e,pause:s})}function ln(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(t=>t.quote),[s,e.currency])}function C(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 B(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 cn(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(n=>C(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(m).andThen(u=>B(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function yn(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(n=>C(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(m).andThen(u=>B(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function dn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:t,currency:r},selector:n=>n.quote,suspense:e,pause:s})}function Sn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(t=>t.quote),[s,e.currency])}function Rn(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(n=>C(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(m).andThen(u=>B(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function fn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){return o({document:graphql.WithdrawSwapQuoteQuery,variables:{request:t,currency:r},selector:n=>n.quote,suspense:e,pause:s})}function Un(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(t=>t.quote),[s,e.currency])}function mn(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(n=>C(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(m).andThen(u=>B(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function gn(e){let s=i(),r=W.useCallback(t=>actions.swap(s,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:p}).andThen(f.tryFrom).andThen(a=>a.wait()).andThen(()=>types.okAsync(n.orderReceipt));case "SwapReceipt":return types.okAsync(n)}}),[s,e]);return c(({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(u=>e(u.data,{cancel:p}).andThen(m).andThen(l=>r({intent:{quoteId:u.newQuoteId,signature:l}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(a)){let u=a.approvals[0];return e(u,{cancel:p}).andThen(l=>types.isSignature(l)?actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:{deadline:u.bySignature.message.deadline,value:l}}):f.isInstanceOf(l)?l.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})):core.UnexpectedError.from(l).asResultAsync()).andThen(l=>e(l.data,{cancel:p}).andThen(m).andThen(y=>r({intent:{quoteId:l.newQuoteId,signature:y}})))}return a.approvals.reduce((u,l)=>u.andThen(()=>e({...l,bySignature:null},{cancel:p}).andThen(f.tryFrom).andThen(y=>y.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})).andThen(u=>e(u.data,{cancel:p})).andThen(m).andThen(u=>r({intent:{quoteId:a.quote.quoteId,signature:u}}));default:types.never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var q=class extends types.ResultAwareError{name="CannotCancelSwapError"};function An(e){let s=i();return c(r=>actions.swapStatus(s,{id:r.id}).andThen(t=>{switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(s,r).andThen(n=>e(n.data,{cancel:p})).andThen(m).andThen(n=>actions.cancelSwap(s,{intent:{id:r.id,signature:n}})).andThen(n=>n.__typename==="SwapCancelled"?types.okAsync(n):e(n,{cancel:p}).andThen(f.tryFrom).andThen(a=>a.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(a=>a.__typename==="SwapCancelled"?types.okAsync(a):new q("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(t);case "SwapExpired":return new q("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function I(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),n={chainId:r,address:t};return async()=>Promise.all([J(e,s.sender,n),Z(e,s.sender,n),X(e,s.reserve),ee(e,n),$(e,s.sender),K(e,s.sender),z(e,s.sender),se(e,r)])}function cr(e,s){return {deadline:s.message.deadline,value:e}}function _(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function M(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(n=>types.isSignature(n)?r(cr(n,t.bySignature)).map(types.expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function kn(e){let s=i();return c(r=>actions.supply(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?M(t,e,n=>actions.supply(s,yr(r,n))).andThen(n=>e(n,{cancel:p})):_(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(f.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(I(s,r)),[s,e])}function yr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function qn(e){let s=i();return c(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).andTee(I(s,r)),[s,e])}function vn(e){let s=i();return c(r=>actions.repay(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?M(t,e,n=>actions.repay(s,dr(r,n))).andThen(n=>e(n,{cancel:p})):_(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(f.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(I(s,r)),[s,e])}function dr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Hn(e){let s=i();return c(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).andTee(I(s,r)),[s,e])}function Cn(e){let s=i();return c(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 Bn(e){let s=i();return c(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,(n,a)=>a.some(u=>u.id===t)),s.refreshQueryWhere(graphql.UserPositionQuery,(n,a)=>a?.id===t)])}),[s,e])}function In(e){let s=i();return c(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).andTee(()=>Promise.all([...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.UserPositionsQuery,(l,y)=>l.request.user===r.sender&&y.some(S=>S.spoke.chain.chainId===a&&S.spoke.address===u))),...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.UserPositionQuery,(l,y)=>y?.spoke.chain.chainId===a&&y?.spoke.address===u&&y.user===r.sender)),...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.UserSummaryQuery,l=>l.request.user===r.sender&&graphql.isSpokeInputVariant(l.request.filter)?l.request.filter.spoke.chainId===a&&l.request.filter.spoke.address===u:graphql.isChainIdsVariant(l.request.filter)?l.request.filter.chainIds.some(y=>y===a):false)),s.refreshQueryWhere(graphql.ReservesQuery,(a,u)=>u.some(l=>t.includes(l.id))),...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.SpokesQuery,(l,y)=>y.some(S=>S.chain.chainId===a&&S.address===u))),...n.map(({chainId:a})=>s.refreshQueryWhere(graphql.HubsQuery,u=>graphql.isChainIdsVariant(u.request.query)?u.request.query.chainIds.some(l=>l===a):graphql.isTokensVariant(u.request.query)?u.request.query.tokens.some(l=>l.chainId===a):true)),...n.map(({chainId:a})=>s.refreshQueryWhere(graphql.HubQuery,u=>graphql.isHubInputVariant(u.request.query)?u.request.query.hubInput.chainId===a:graphql.decodeHubId(u.request.query.hubId).chainId===a))]))},[s,e])}function Wn(e){let s=i();return c(r=>actions.liquidatePosition(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?M(t,e,n=>actions.liquidatePosition(s,Sr(r))).andThen(n=>e(n,{cancel:p})):_(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(f.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction),[s,e])}function Sr(e,s){return e}function On(e){let s=i();return c(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 Dn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.preview(s,r,{currency:e.currency,requestPolicy:"network-only"}),[s,e.currency])}function Nn({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 Vn({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 _n(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 $n({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 Kn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 zn({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 Jn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 Xn({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 Zn({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 ea(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function sa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserPositionQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ra({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 ta({suspense:e=false,pause:s=false,...r}){return o({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function na(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.userBalances(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function aa({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=Cr;exports.CannotCancelSwapError=q;exports.useAaveClient=i;exports.useActivities=Vn;exports.useActivitiesAction=_n;exports.useAsset=Pt;exports.useAssetBorrowHistory=Tt;exports.useAssetPriceHistory=bt;exports.useAssetSupplyHistory=wt;exports.useBorrow=qn;exports.useBorrowApyHistory=Wt;exports.useBorrowSwap=yn;exports.useBorrowSwapQuote=pn;exports.useBorrowSwapQuoteAction=ln;exports.useCancelSwap=An;exports.useChain=yt;exports.useChainAction=dt;exports.useChains=St;exports.useExchangeRate=ft;exports.useExchangeRateAction=Rt;exports.useHub=st;exports.useHubAssets=tt;exports.useHubSummaryHistory=nt;exports.useHubs=rt;exports.useHubsAction=at;exports.useLiquidatePosition=Wn;exports.usePreview=Nn;exports.usePreviewAction=Dn;exports.useProtocolHistory=xt;exports.useRenounceSpokeUserPositionManager=Cn;exports.useRepay=vn;exports.useRepayWithSupply=Rn;exports.useRepayWithSupplyQuote=dn;exports.useRepayWithSupplyQuoteAction=Sn;exports.useReserve=Ht;exports.useReserveAction=Ct;exports.useReserves=Bt;exports.useReservesAction=It;exports.useSetSpokeUserPositionManager=On;exports.useSetUserSuppliesAsCollateral=In;exports.useSpoke=_t;exports.useSpokePositionManagers=Ft;exports.useSpokeUserPositionManagers=Lt;exports.useSpokes=Mt;exports.useSupply=kn;exports.useSupplyApyHistory=Ot;exports.useSupplySwap=cn;exports.useSupplySwapQuote=un;exports.useSupplySwapQuoteAction=on;exports.useSwapStatus=an;exports.useSwappableTokens=tn;exports.useTokenSwap=gn;exports.useTokenSwapQuote=sn;exports.useTokenSwapQuoteAction=rn;exports.useUpdateUserPositionConditions=Bn;exports.useUserBalances=ra;exports.useUserBalancesAction=na;exports.useUserBorrows=zn;exports.useUserBorrowsAction=Jn;exports.useUserPosition=sa;exports.useUserPositions=Zn;exports.useUserPositionsAction=ea;exports.useUserRiskPremiumBreakdown=ta;exports.useUserSummary=Xn;exports.useUserSummaryHistory=aa;exports.useUserSupplies=$n;exports.useUserSuppliesAction=Kn;exports.useUserSwaps=nn;exports.useWithdraw=Hn;exports.useWithdrawSwap=mn;exports.useWithdrawSwapQuote=fn;exports.useWithdrawSwapQuoteAction=Un;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'),D=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 D__default=/*#__PURE__*/_interopDefault(D);var G=D__default.default.createContext(null);function Y({children:e,client:s}){return D__default.default.createElement(G.Provider,{value:s},D__default.default.createElement(urql.Provider,{value:s.urql},e))}function i(){let e=D.useContext(G);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function _r({children:e,client:s}){return D__default.default.createElement(Y,{client:s},e)}function rs(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 ts(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 z(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function J(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>rs(r.request.query)===s)}function X(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>ts(r.request.query)===s)}function Z(e,s,r){return Promise.all([e.refreshQueryWhere(graphql.UserPositionsQuery,(t,n)=>n.some(a=>a.spoke.chain.chainId===r.chainId&&a.spoke.address===r.address&&a.user===s)),e.refreshQueryWhere(graphql.UserPositionQuery,(t,n)=>n?.spoke.chain.chainId===r.chainId&&n?.spoke.address===r.address&&n.user===s)])}function ee(e,s){return Promise.all([e.refreshQueryWhere(graphql.ReserveQuery,(r,t)=>t?.id===s),e.refreshQueryWhere(graphql.ReservesQuery,(r,t)=>t.some(n=>n.id===s))])}function se(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 re(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(n=>n.chain.chainId===s.chainId&&n.address===s.address))])}function te(e,s){return e.refreshQueryWhere(graphql.HubsQuery,r=>graphql.isChainIdsVariant(r.request)&&r.request.chainIds.some(t=>t===s))}var h={Loading:()=>({data:void 0,error:void 0,loading:true,paused:false}),Success:e=>({data:e,error:void 0,loading:false,paused:false}),Failure:e=>({data:void 0,error:e,loading:false,paused:false}),Paused:(e,s)=>({data:e,error:s,loading:false,paused:true})};function o({document:e,variables:s,suspense:r,pause:t,selector:n=types.identity,pollInterval:a=0,batch:u=true}){let[l,y]=D.useState(true),[{fetching:S,data:P,error:v},j]=urql.useQuery({query:e,variables:s,pause:t,context:D.useMemo(()=>({batch:u,suspense:r}),[u,r])});if(D.useEffect(()=>{t||S||y(false);},[S,t]),D.useEffect(()=>{if(a<=0||S||t)return;let q=setTimeout(()=>{j({requestPolicy:"network-only",batch:false});},a);return ()=>clearTimeout(q)},[S,j,a,t]),t)return h.Paused(P?n(P.value):void 0,v?client.UnexpectedError.from(v):void 0);if(!r&&l)return h.Loading();if(v){let q=client.UnexpectedError.from(v);if(r)throw q;return h.Failure(q)}return types.invariant(P,"No data returned"),h.Success(n(P.value))}var N={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 c(e,s){let[r,t]=D.useState(N.Idle()),n=D.useRef(false),a=D.useCallback(e,s);return [D.useCallback(l=>{types.invariant(!n.current,"Cannot execute a task while another is in progress."),n.current=true;let y;t(S=>(y=S,{called:true,loading:true,data:S.data,error:void 0}));try{let S=a(l);return S.match(P=>{n.current=!1,t(N.Success(P));},P=>{n.current=!1,t(N.Failed(P));}),S}catch(S){throw n.current=false,t(types.nonNullable(y)),S}},[a]),r]}var p=e=>core.CancelError.from(e).asResultAsync(),f=class e{constructor(s){this.wait=s;}static isInstanceOf(s){return s instanceof e}static tryFrom(s){return e.isInstanceOf(s)?types.okAsync(s):core.UnexpectedError.from(s).asResultAsync()}};function g(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}function 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.HubQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function pt({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 lt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.HubAssetsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ct({suspense:e=false,pause:s=false,...r}){return o({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function yt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.hubs(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function At({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function gt(){let e=i();return c(s=>actions.chain(e,s,{batch:false,requestPolicy:"cache-first"}),[e])}function Pt({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 bt(){let e=i();return c(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function wt({suspense:e=false,pause:s=false,...r}){let t=i();return o({document:graphql.ExchangeRateQuery,variables:{request:r},suspense:e,pause:s,pollInterval:r.at?0:t.context.environment.exchangeRateInterval})}function Et({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 kt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.AssetPriceHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function vt({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 qt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.AssetBorrowHistoryQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s,batch:false})}function Ht({suspense:e=false,pause:s=false,...r}){return o({document:graphql.ProtocolHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Nt({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 _t(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 Vt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,selector:n,...a}){return o({document:graphql.ReservesQuery,variables:{request:a,currency:r,timeWindow:t},suspense:e,pause:s,selector:n||void 0})}function Mt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 Ft({suspense:e=false,pause:s=false,...r}){return o({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Lt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function $t({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function Kt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function zt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function Jt({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function V(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return e.quote;case "InsufficientLiquidityError":throw core.ValidationError.fromGqlNode(e);default:throw core.UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`)}}function Re(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 e.quote;case "InsufficientLiquidityError":throw core.ValidationError.fromGqlNode(e);default:throw core.UnexpectedError.upgradeRequired(`Unsupported position swap quote result: ${e.__typename}`)}}function fe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function me(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Ue(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}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 pn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=o({document:graphql.TokenSwapQuoteQuery,variables:{request:fe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:V,suspense:e,pause:s,batch:false}),u=o({document:graphql.TokenSwapQuoteQuery,variables:{request:fe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:V,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function ln(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(V),[s,e.currency])}function cn({suspense:e=false,pause:s=false,...r}){return o({document:graphql.SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function yn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=i(),[u,l]=D.useState(false),y=o({document:graphql.UserSwapsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return D.useEffect(()=>{y.data&&y.data.items.length>0&&y.data.items.every(ve)&&l(true);},[y.data]),y}function ve(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function dn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){let a=i(),[u,l]=D.useState(false),y=o({document:graphql.SwapStatusQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return D.useEffect(()=>{y.data&&ve(y.data)&&l(true);},[y.data]),y}function Sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=o({document:graphql.SupplySwapQuoteQuery,variables:{request:me(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),u=o({document:graphql.SupplySwapQuoteQuery,variables:{request:me(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function Rn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(m),[s,e.currency])}function fn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=o({document:graphql.BorrowSwapQuoteQuery,variables:{request:Ue(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),u=o({document:graphql.BorrowSwapQuoteQuery,variables:{request:Ue(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function mn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(m),[s,e.currency])}function B(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 W(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 Un(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(n=>B(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(u=>W(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function An(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(n=>B(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(u=>W(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function gn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=o({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ae(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),u=o({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ae(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function Pn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(m),[s,e.currency])}function bn(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(n=>B(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(u=>W(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function wn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=o({document:graphql.WithdrawSwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Fast),currency:r},selector:m,suspense:e,pause:s,batch:false}),u=o({document:graphql.WithdrawSwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:m,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function Tn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).map(m),[s,e.currency])}function xn(e){let s=i();return c(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(n=>B(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(u=>W(s,{quoteId:a.newQuoteId,signature:u})))),[s,e])}function hn(e){let s=i(),r=D.useCallback(t=>actions.swap(s,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:p}).andThen(f.tryFrom).andThen(a=>a.wait()).andThen(()=>types.okAsync(n.orderReceipt));case "SwapReceipt":return types.okAsync(n)}}),[s,e]);return c(({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(u=>e(u.data,{cancel:p}).andThen(g).andThen(l=>r({intent:{quoteId:u.newQuoteId,signature:l}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(a)){let u=a.approvals[0];return e(u,{cancel:p}).andThen(l=>types.isSignature(l)?actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:{deadline:u.bySignature.message.deadline,value:l}}):f.isInstanceOf(l)?l.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})):core.UnexpectedError.from(l).asResultAsync()).andThen(l=>e(l.data,{cancel:p}).andThen(g).andThen(y=>r({intent:{quoteId:l.newQuoteId,signature:y}})))}return a.approvals.reduce((u,l)=>u.andThen(()=>e({...l,bySignature:null},{cancel:p}).andThen(f.tryFrom).andThen(y=>y.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})).andThen(u=>e(u.data,{cancel:p})).andThen(g).andThen(u=>r({intent:{quoteId:a.quote.quoteId,signature:u}}));default:types.never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var C=class extends types.ResultAwareError{name="CannotCancelSwapError"};function Qn(e){let s=i();return c(r=>actions.swapStatus(s,{id:r.id}).andThen(t=>{switch(t.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(s,r).andThen(n=>e(n.data,{cancel:p})).andThen(g).andThen(n=>actions.cancelSwap(s,{intent:{id:r.id,signature:n}})).andThen(n=>n.__typename==="SwapCancelledResult"?types.okAsync(n):e(n,{cancel:p}).andThen(f.tryFrom).andThen(a=>a.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(a=>a.__typename==="SwapCancelled"?types.okAsync(Re(a)):new C("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(Re(t));case "SwapExpired":return new C("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function O(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),n={chainId:r,address:t};return async()=>Promise.all([Z(e,s.sender,n),se(e,s.sender,n),ee(e,s.reserve),re(e,n),z(e,s.sender),J(e,s.sender),X(e,s.sender),te(e,r)])}function Ur(e,s){return {deadline:s.message.deadline,value:e}}function F(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function L(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(n=>types.isSignature(n)?r(Ur(n,t.bySignature)).map(types.expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function Wn(e){let s=i();return c(r=>actions.supply(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?L(t,e,n=>actions.supply(s,Ar(r,n))).andThen(n=>e(n,{cancel:p})):F(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(f.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(O(s,r)),[s,e])}function Ar(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function On(e){let s=i();return c(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).andTee(O(s,r)),[s,e])}function Dn(e){let s=i();return c(r=>actions.repay(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?L(t,e,n=>actions.repay(s,gr(r,n))).andThen(n=>e(n,{cancel:p})):F(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(f.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(O(s,r)),[s,e])}function gr(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Nn(e){let s=i();return c(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).andTee(O(s,r)),[s,e])}function _n(e){let s=i();return c(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 Vn(e){let s=i();return c(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,(n,a)=>a.some(u=>u.id===t)),s.refreshQueryWhere(graphql.UserPositionQuery,(n,a)=>a?.id===t)])}),[s,e])}function Mn(e){let s=i();return c(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).andTee(()=>Promise.all([...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.UserPositionsQuery,(l,y)=>l.request.user===r.sender&&y.some(S=>S.spoke.chain.chainId===a&&S.spoke.address===u))),...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.UserPositionQuery,(l,y)=>y?.spoke.chain.chainId===a&&y?.spoke.address===u&&y.user===r.sender)),...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.UserSummaryQuery,l=>l.request.user===r.sender&&graphql.isSpokeInputVariant(l.request.filter)?l.request.filter.spoke.chainId===a&&l.request.filter.spoke.address===u:graphql.isChainIdsVariant(l.request.filter)?l.request.filter.chainIds.some(y=>y===a):false)),s.refreshQueryWhere(graphql.ReservesQuery,(a,u)=>u.some(l=>t.includes(l.id))),...n.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(graphql.SpokesQuery,(l,y)=>y.some(S=>S.chain.chainId===a&&S.address===u))),...n.map(({chainId:a})=>s.refreshQueryWhere(graphql.HubsQuery,u=>graphql.isChainIdsVariant(u.request.query)?u.request.query.chainIds.some(l=>l===a):graphql.isTokensVariant(u.request.query)?u.request.query.tokens.some(l=>l.chainId===a):true)),...n.map(({chainId:a})=>s.refreshQueryWhere(graphql.HubQuery,u=>graphql.isHubInputVariant(u.request.query)?u.request.query.hubInput.chainId===a:graphql.decodeHubId(u.request.query.hubId).chainId===a))]))},[s,e])}function Fn(e){let s=i();return c(r=>actions.liquidatePosition(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?L(t,e,n=>actions.liquidatePosition(s,Pr(r))).andThen(n=>e(n,{cancel:p})):F(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(f.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(f.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction),[s,e])}function Pr(e,s){return e}function Ln(e){let s=i();return c(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 jn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.preview(s,r,{currency:e.currency,requestPolicy:"network-only"}),[s,e.currency])}function Gn({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 Yn({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 $n(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 sa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserSuppliesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ra(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 ta({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return o({document:graphql.UserBorrowsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function na(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(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 aa({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 oa(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function ia({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 pa({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 la({suspense:e=false,pause:s=false,...r}){return o({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function ca(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return c(r=>actions.userBalances(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function ya({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=_r;exports.CannotCancelSwapError=C;exports.useAaveClient=i;exports.useActivities=Yn;exports.useActivitiesAction=$n;exports.useAsset=Et;exports.useAssetBorrowHistory=qt;exports.useAssetPriceHistory=kt;exports.useAssetSupplyHistory=vt;exports.useBorrow=On;exports.useBorrowApyHistory=Ft;exports.useBorrowSwap=An;exports.useBorrowSwapQuote=fn;exports.useBorrowSwapQuoteAction=mn;exports.useCancelSwap=Qn;exports.useChain=At;exports.useChainAction=gt;exports.useChains=Pt;exports.useExchangeRate=wt;exports.useExchangeRateAction=bt;exports.useHub=it;exports.useHubAssets=lt;exports.useHubSummaryHistory=ct;exports.useHubs=pt;exports.useHubsAction=yt;exports.useLiquidatePosition=Fn;exports.usePreview=Gn;exports.usePreviewAction=jn;exports.useProtocolHistory=Ht;exports.useRenounceSpokeUserPositionManager=_n;exports.useRepay=Dn;exports.useRepayWithSupply=bn;exports.useRepayWithSupplyQuote=gn;exports.useRepayWithSupplyQuoteAction=Pn;exports.useReserve=Nt;exports.useReserveAction=_t;exports.useReserves=Vt;exports.useReservesAction=Mt;exports.useSetSpokeUserPositionManager=Ln;exports.useSetUserSuppliesAsCollateral=Mn;exports.useSpoke=$t;exports.useSpokePositionManagers=zt;exports.useSpokeUserPositionManagers=Jt;exports.useSpokes=Kt;exports.useSupply=Wn;exports.useSupplyApyHistory=Lt;exports.useSupplySwap=Un;exports.useSupplySwapQuote=Sn;exports.useSupplySwapQuoteAction=Rn;exports.useSwapStatus=dn;exports.useSwappableTokens=cn;exports.useTokenSwap=hn;exports.useTokenSwapQuote=pn;exports.useTokenSwapQuoteAction=ln;exports.useUpdateUserPositionConditions=Vn;exports.useUserBalances=pa;exports.useUserBalancesAction=ca;exports.useUserBorrows=ta;exports.useUserBorrowsAction=na;exports.useUserPosition=ia;exports.useUserPositions=ua;exports.useUserPositionsAction=oa;exports.useUserRiskPremiumBreakdown=la;exports.useUserSummary=aa;exports.useUserSummaryHistory=ya;exports.useUserSupplies=sa;exports.useUserSuppliesAction=ra;exports.useUserSwaps=yn;exports.useWithdraw=Nn;exports.useWithdrawSwap=xn;exports.useWithdrawSwapQuote=wn;exports.useWithdrawSwapQuoteAction=Tn;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