@aave/react 4.0.0-next.52 → 4.0.0-next.53
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var client=require('@aave/client'),z=require('react'),types=require('@aave/types'),urql=require('urql'),actions=require('@aave/client/actions'),graphql=require('@aave/graphql'),core=require('@aave/core');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var z__default=/*#__PURE__*/_interopDefault(z);var ne=z__default.default.createContext(null);function oe({children:e,client:r}){return z__default.default.createElement(ne.Provider,{value:r},z__default.default.createElement(urql.Provider,{value:r.urql},e))}function o(){let e=z.useContext(ne);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Ha({children:e,client:r}){return z__default.default.createElement(oe,{client:r},e)}function Ar(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 Ur(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:r}=graphql.decodeUserPositionId(e.userPositionId);return r}function E(e,r){return e.refreshQueryWhere(graphql.UserBalancesQuery,t=>t.request.user===r)}function B(e,r){return e.refreshQueryWhere(graphql.UserSuppliesQuery,t=>Ar(t.request.query)===r)}function W(e,r){return e.refreshQueryWhere(graphql.UserBorrowsQuery,t=>Ur(t.request.query)===r)}function J(e,r,t){let s=a=>a.spoke.chain.chainId===t.chainId&&a.spoke.address===t.address&&a.user===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(a,n)=>n.some(s)),e.refreshQueryWhere(graphql.UserPositionQuery,(a,n)=>n!==null&&s(n))])}function X(e,r){let t=s=>r.includes(s.id);return types.ResultAsync.combine([e.refreshQueryWhere(graphql.ReserveQuery,(s,a)=>a!==null&&t(a)),e.refreshQueryWhere(graphql.ReservesQuery,(s,a)=>a.some(t))])}function Z(e,r,t){return e.refreshQueryWhere(graphql.UserSummaryQuery,s=>s.request.user===r&&(graphql.isSpokeInputVariant(s.request.filter)?s.request.filter.spoke.chainId===t.chainId&&s.request.filter.spoke.address===t.address:graphql.isChainIdsVariant(s.request.filter)?s.request.filter.chainIds.some(a=>a===t.chainId):false))}function ee(e,r){let t=s=>s.chain.chainId===r.chainId&&s.address===r.address;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.SpokeQuery,(s,a)=>a!==null&&t(a)),e.refreshQueryWhere(graphql.SpokesQuery,(s,a)=>a.some(t))])}function re(e,r){let t=s=>s.chain.chainId===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.HubQuery,(s,a)=>a!==null&&t(a)),e.refreshQueryWhere(graphql.HubsQuery,(s,a)=>a.some(t))])}function _(e,r){return e.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r)}function le(e,r){return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(t,s)=>s.some(a=>a.id===r)),e.refreshQueryWhere(graphql.UserPositionQuery,(t,s)=>s?.id===r)])}function h(e,r){let{chainId:t,spoke:s}=graphql.decodeReserveId(r.reserve),a={chainId:t,address:s};return types.ResultAsync.combine([J(e,r.sender,a),Z(e,r.sender,a),X(e,[r.reserve]),ee(e,a),E(e,r.sender),B(e,r.sender),W(e,r.sender),re(e,t)])}function ce(e,r){return E(e,r)}function ye(e,r){return types.ResultAsync.combine([B(e,r),E(e,r)])}function de(e,r){return types.ResultAsync.combine([W(e,r),E(e,r)])}function Se(e,r){return types.ResultAsync.combine([B(e,r),W(e,r),E(e,r)])}function me(e,r){return types.ResultAsync.combine([B(e,r),E(e,r)])}var v={Loading:e=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false,metadata:e}),Success:(e,r,t=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:t,metadata:r}),Failure:(e,r,t=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:t,metadata:r}),Paused:(e,r,t)=>({data:e,error:r,loading:false,paused:true,reloading:false,metadata:t})};function u({document:e,variables:r,suspense:t,pause:s,selector:a=types.ok,pollInterval:n=0,batch:l=true}){let[c,m]=z.useState({operationKey:0,resultOperationKey:void 0}),[A,U]=z.useState(true),H=z.useMemo(()=>urql.createRequest(e,r).key,[e,r]),[{fetching:T,data:I,error:N,stale:j},ae]=urql.useQuery({query:e,variables:r,pause:s,context:z.useMemo(()=>({batch:l,suspense:t}),[l,t])});if(z.useEffect(()=>{m(b=>({...b,operationKey:H}));},[H]),z.useEffect(()=>{s||T||U(false);},[T,s]),z.useEffect(()=>{s||T||m(b=>({...b,resultOperationKey:I&&!j?b.operationKey:b.resultOperationKey}));},[s,T,I,j]),z.useEffect(()=>{if(n<=0||T||s)return;let b=setTimeout(()=>{ae({requestPolicy:"network-only",batch:false});},n);return ()=>clearTimeout(b)},[T,ae,n,s]),s){let b=N?client.UnexpectedError.from(N):void 0;if(!I)return v.Paused(void 0,b,c);let $=a(I.value);return $.isErr()?v.Paused(void 0,$.error,c):v.Paused($.value,b,c)}if(!t&&A)return v.Loading(c);let G=j||!A&&T;if(N){let b=client.UnexpectedError.from(N);if(t)throw b;return v.Failure(b,c,G)}types.invariant(I!==void 0,`Unexpected empty response from the API for '${core.extractDocumentName(e)??"unknown"}' query`);let er=I===null?null:I.value,M=a(er);if(M.isErr()){if(t)throw M.error;return v.Failure(M.error,c,G)}return v.Success(M.value,c,G)}var te={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 i(e,r){let[t,s]=z.useState(te.Idle()),a=z.useRef(false),n=z.useRef(true);z.useEffect(()=>()=>{n.current=false;},[]);let l=z.useCallback(e,r);return [z.useCallback(m=>{types.invariant(n.current,"Cannot execute a task on an unmounted component."),types.invariant(!a.current,"Cannot execute a task while another is in progress."),a.current=true;let A;s(U=>(A=U,{called:true,loading:true,data:U.data,error:void 0}));try{let U=l(m);return U.match(H=>{a.current=!1,s(te.Success(H));},H=>{a.current=!1,s(te.Failed(H));}),U}catch(U){throw a.current=false,A&&s(A),U}},[l]),t]}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 f(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}function an({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.HubQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function nn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.HubsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function on({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.HubAssetsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function un({suspense:e=false,pause:r=false,...t}){return u({document:graphql.HubSummaryHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function pn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.HubAssetInterestRateModelQuery,variables:{request:s,currency:t},suspense:e,pause:r,selector:a=>types.ok(a.points)})}function ln(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.hubAssetInterestRateModel(r,t,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function cn(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.hubs(r,t,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function bn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.ChainQuery,variables:{request:t},suspense:e,pause:r})}function An(){let e=o();return i(r=>actions.chain(e,r,{batch:false,requestPolicy:"cache-first"}),[e])}function Un({suspense:e=false,pause:r=false,...t}={query:{filter:graphql.ChainsFilter.ALL}}){return u({document:graphql.ChainsQuery,variables:{request:t},suspense:e,pause:r})}function Pn(){let e=o();return i(r=>actions.exchangeRate(e,r,{requestPolicy:"network-only"}),[e])}function gn({suspense:e=false,pause:r=false,...t}){let s=o();return u({document:graphql.ExchangeRateQuery,variables:{request:t},suspense:e,pause:r,pollInterval:t.at?0:s.context.environment.exchangeRateInterval})}function hn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.AssetQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function vn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.AssetPriceHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function Qn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.AssetSupplyHistoryQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r,batch:false})}function kn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.AssetBorrowHistoryQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r,batch:false})}function qn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.ProtocolHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function Dn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ReserveQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function On(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.reserve(r,t,{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 Nn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ReservesQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Mn(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.reserves(r,t,{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 _n({suspense:e=false,pause:r=false,...t}){return u({document:graphql.BorrowApyHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function Fn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SupplyApyHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function $n({suspense:e=false,pause:r=false,...t}){return u({document:graphql.UserClaimableRewardsQuery,variables:{request:t},suspense:e,pause:r})}function zn(){let e=o();return i(r=>actions.userClaimableRewards(e,r,{requestPolicy:"cache-first"}),[e])}function eo({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokeQuery,variables:{request:t},suspense:e,pause:r})}function ro({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokesQuery,variables:{request:t},suspense:e,pause:r})}function to({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokePositionManagersQuery,variables:{request:t},suspense:e,pause:r})}function so({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokeUserPositionManagersQuery,variables:{request:t},suspense:e,pause:r})}function R(e){switch(e.__typename){case "PositionSwapByIntentApprovalsRequired":return types.ok(e.quote);case "InsufficientLiquidityError":return types.err(core.ValidationError.fromGqlNode(e));default:return types.err(core.UnexpectedError.upgradeRequired(`Unsupported position swap quote result: ${e.__typename}`))}}function K(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function Q(e){return {with:r=>e.approvals.reduce((t,s)=>t.andThen(a=>r(s,{cancel:p}).map(n=>{switch(s.__typename){case "PositionSwapAdapterContractApproval":a.adapterContractSignature=types.isSignature(n)?n:null;break;case "PositionSwapPositionManagerApproval":a.positionManagerSignature=types.isSignature(n)?n:null;break}return a})),types.okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function k(e,r){return actions.swap(e,{intent:r}).andThen(t=>{switch(t.__typename){case "SwapReceipt":return types.okAsync(t);default:return core.UnexpectedError.from(t).asResultAsync()}})}function yt(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.borrowSwapQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(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 St({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:ve(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:ve(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function mt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.borrowSwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function qe(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}var D=class extends types.ResultAwareError{name="CannotCancelSwapError"};function At(e){let r=o();return i(t=>actions.swapStatus(r,{id:t.id}).andThen(s=>{if(s===null)return core.UnexpectedError.from("Swap not found").asResultAsync();switch(s.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(r,t).andThen(a=>e(a.data,{cancel:p})).andThen(f).andThen(a=>actions.cancelSwap(r,{intent:{id:t.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:t.id})).andThen(n=>n?.__typename==="SwapCancelled"?types.okAsync(qe(n)):new D("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(qe(s));case "SwapExpired":return new D("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${s.__typename}`).asResultAsync()}}),[r,e])}function gt(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.repayWithSupplyQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ie(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Tt({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function xt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.repayWithSupplyQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function vt(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.supplySwapQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function We(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function kt({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.SupplySwapQuoteQuery,variables:{request:We(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.SupplySwapQuoteQuery,variables:{request:We(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function qt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.supplySwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function Ht({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SwappableTokensQuery,variables:{request:t},suspense:e,pause:r})}function Wt({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=u({document:graphql.SwapStatusQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval});return z.useEffect(()=>{m.data&&K(m.data)&&c(true);},[m.data]),m}function Lt(e){let r=o(),t=z.useCallback(s=>actions.swap(r,s).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 i(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...a})=>actions.tokenSwapQuote(r,a,{currency:s}).andThen(n=>{switch(n.__typename){case "SwapByTransaction":return t({transaction:{quoteId:n.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId}).andThen(l=>e(l.data,{cancel:p}).andThen(f).andThen(c=>t({intent:{quoteId:l.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(n)){let l=n.approvals[0];return e(l,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId,permitSig:{deadline:l.bySignature.message.deadline,value:c}}):y.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(f).andThen(m=>t({intent:{quoteId:c.newQuoteId,signature:m}})))}return n.approvals.reduce((l,c)=>l.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(y.tryFrom).andThen(m=>m.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})).andThen(l=>e(l.data,{cancel:p})).andThen(f).andThen(l=>t({intent:{quoteId:n.quote.quoteId,signature:l}}));default:types.never(`Unsupported swap quote result: ${n.__typename}. To be removed from API soon.`);}}),[r,e,t])}function se(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 _e(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function $t({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.TokenSwapQuoteQuery,variables:{request:_e(s,graphql.QuoteAccuracy.Fast),currency:t},selector:se,suspense:e,pause:r,batch:false}),l=u({document:graphql.TokenSwapQuoteQuery,variables:{request:_e(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:se,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function zt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.tokenSwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(se),[r,e.currency])}function rs(e,r){let t=new Map(r.map(s=>[s.swapId,s.__typename]));return e.filter(s=>s.__typename==="SwapFulfilled"&&t.get(s.swapId)!=="SwapFulfilled")}function ts({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=u({document:graphql.UserSwapsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval}),A=m.data?.items??[],U=z.useDeferredValue(A);return z.useEffect(()=>{if(A.length===0)return;A.every(K)&&c(true);for(let T of rs(A,U))switch(T.operation.__typename){case "TokenSwap":a.user&&ce(n,a.user);break;case "BorrowSwap":a.user&&de(n,a.user);break;case "RepayWithSupply":a.user&&Se(n,a.user);break;case "SupplySwap":a.user&&ye(n,a.user);break;case "WithdrawSwap":a.user&&me(n,a.user);break}},[A,U,n,a.user]),m}function ns(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.withdrawSwapQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ye(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function us({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function is(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.withdrawSwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function cs({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ActivitiesQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function ys(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.activities(r,t,{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 fs(e){let r=o();return i(t=>actions.borrow(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "PreContractActionRequired":return e(s,{cancel:p}).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s));case "Erc20ApprovalRequired":return client.UnexpectedError.from(s).asResultAsync()}}).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function Us(e){let r=o();return i(t=>actions.claimRewards(r,t).andThen(s=>e(s,{cancel:p})).andThen(y.tryFrom).andThen(s=>s.wait()).map(s=>client.transactionReceipt(s.txHash)),[r,e])}function Ts(e,r){return {deadline:r.message.deadline,value:e}}function q(e,r){return e.approvals.reduce((t,s)=>t.andThen(()=>r({...s,bySignature:null},{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function C(e,r,t){let s=e.approvals[0];return r(s,{cancel:p}).andThen(a=>types.isSignature(a)?t(Ts(a,s.bySignature)).map(types.expectTypename("TransactionRequest")):a.wait().map(()=>e.originalTransaction))}function vs(e,r){return "exact"in e.amount&&e.amount.exact?{...e,amount:{exact:{...e.amount.exact,permitSig:r}}}:e}function Qs(e){let r=o();return i(t=>actions.liquidatePosition(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.liquidatePosition(r,vs(t,a))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>E(r,t.liquidator)),[r,e])}function Cs(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.preview(r,t,{currency:e.currency,requestPolicy:"network-only"}),[r,e.currency])}function Hs({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.PreviewQuery,variables:{request:s,currency:t},suspense:e,pause:r})}function Bs(e){let r=o();return i(t=>actions.renounceSpokeUserPositionManager(r,t).andThen(s=>e(s,{cancel:p})).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>_(r,t.spoke)),[r,e])}function Os(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function Ns(e){let r=o();return i(t=>actions.repay(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.repay(r,Os(t,a))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function _s(e){let r=o();return i(t=>actions.setSpokeUserPositionManager(r,t).andThen(s=>e(s,{cancel:p})).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>_(r,t.spoke)),[r,e])}function Ys(e){let r=o();return i(t=>{let s=t.changes.map(n=>n.reserve),a=s.map(n=>graphql.decodeReserveId(n));return actions.setUserSuppliesAsCollateral(r,t).andThen(n=>e(n,{cancel:p})).andThen(n=>n.wait()).andThen(r.waitForTransaction).andThrough(()=>types.ResultAsync.combine([B(r,t.sender),W(r,t.sender),...a.flatMap(({chainId:n,spoke:l})=>[J(r,t.sender,{chainId:n,address:l}),Z(r,t.sender,{chainId:n,address:l}),ee(r,{chainId:n,address:l})]),X(r,s),...a.map(({chainId:n})=>re(r,n))]))},[r,e])}function zs(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function Js(e){let r=o();return i(t=>actions.supply(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.supply(r,zs(t,a))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function Zs(e){let r=o();return i(t=>actions.updateUserPositionConditions(r,t).andThen(s=>e(s,{cancel:p})).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>le(r,t.userPositionId)),[r,e])}function aa(e){let r=o();return i(t=>actions.withdraw(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "PreContractActionRequired":return e(s,{cancel:p}).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s));case "Erc20ApprovalRequired":return client.UnexpectedError.from(s).asResultAsync()}}).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function Kp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSuppliesQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Yp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userSupplies(r,t,{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 jp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserBorrowsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Gp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userBorrows(r,t,{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 $p({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSummaryQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function zp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Jp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userPositions(r,t,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Xp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Zp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.UserBalancesQuery,variables:{request:s,currency:t},suspense:e,pause:r})}function el({suspense:e=false,pause:r=false,...t}){return u({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function rl(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userBalances(r,t,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function tl({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.UserSummaryHistoryQuery,variables:{request:s,currency:t},suspense:e,pause:r,batch:false})}function Ea(e,r){return {...e,amount:{...e.amount,permitSig:r}}}function yl(e){let r=o();return i(t=>actions.stableVaultDeposit(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.stableVaultDeposit(r,Ea(t,a))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>Ze(r,t.user)),[r,e])}function dl(e){let r=o();return i(t=>actions.stableVaultWithdraw(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(r.waitForTransaction).andThrough(()=>Ze(r,t.user));case "StableVaultWithdrawClaim":return e(s.transaction,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(r.waitForTransaction).map(()=>s)}}),[r,e])}function Sl(e){let r=o();return i(t=>actions.stableVaultWithdrawRedeem(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "StableVaultPendingAvailability":return core.UnexpectedError.from(`Funds not yet available. Please retry after ${s.executableAfter.toLocaleString()}`).asResultAsync()}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction),[r,e])}function ml({suspense:e=false,pause:r=false,...t}){let s=o();return u({document:graphql.StableVaultClaimStatusQuery,variables:{request:t},suspense:e,pause:r,pollInterval:s.context.environment.pollingInterval})}function Rl({suspense:e=false,pause:r=false,...t}){return u({document:graphql.StableVaultUserPositionsQuery,variables:{request:t},suspense:e,pause:r})}function fl({suspense:e=false,pause:r=false,...t}){return u({document:graphql.StableVaultQuery,variables:{request:t},suspense:e,pause:r})}function bl({suspense:e=false,pause:r=false,...t}){return u({document:graphql.StableVaultsQuery,variables:{request:t},suspense:e,pause:r})}function Ze(e,r){return e.refreshQueryWhere(graphql.StableVaultUserPositionsQuery,t=>t.request.user===r)}exports.AaveProvider=Ha;exports.CannotCancelSwapError=D;exports.useAaveClient=o;exports.useActivities=cs;exports.useActivitiesAction=ys;exports.useAsset=hn;exports.useAssetBorrowHistory=kn;exports.useAssetPriceHistory=vn;exports.useAssetSupplyHistory=Qn;exports.useBorrow=fs;exports.useBorrowApyHistory=_n;exports.useBorrowSwap=yt;exports.useBorrowSwapQuote=St;exports.useBorrowSwapQuoteAction=mt;exports.useCancelSwap=At;exports.useChain=bn;exports.useChainAction=An;exports.useChains=Un;exports.useClaimRewards=Us;exports.useExchangeRate=gn;exports.useExchangeRateAction=Pn;exports.useHub=an;exports.useHubAssetInterestRateModel=pn;exports.useHubAssetInterestRateModelAction=ln;exports.useHubAssets=on;exports.useHubSummaryHistory=un;exports.useHubs=nn;exports.useHubsAction=cn;exports.useLiquidatePosition=Qs;exports.usePreview=Hs;exports.usePreviewAction=Cs;exports.useProtocolHistory=qn;exports.useRenounceSpokeUserPositionManager=Bs;exports.useRepay=Ns;exports.useRepayWithSupply=gt;exports.useRepayWithSupplyQuote=Tt;exports.useRepayWithSupplyQuoteAction=xt;exports.useReserve=Dn;exports.useReserveAction=On;exports.useReserves=Nn;exports.useReservesAction=Mn;exports.useSetSpokeUserPositionManager=_s;exports.useSetUserSuppliesAsCollateral=Ys;exports.useSpoke=eo;exports.useSpokePositionManagers=to;exports.useSpokeUserPositionManagers=so;exports.useSpokes=ro;exports.useStableVault=fl;exports.useStableVaultClaimStatus=ml;exports.useStableVaultDeposit=yl;exports.useStableVaultUserPositions=Rl;exports.useStableVaultWithdraw=dl;exports.useStableVaultWithdrawRedeem=Sl;exports.useStableVaults=bl;exports.useSupply=Js;exports.useSupplyApyHistory=Fn;exports.useSupplySwap=vt;exports.useSupplySwapQuote=kt;exports.useSupplySwapQuoteAction=qt;exports.useSwapStatus=Wt;exports.useSwappableTokens=Ht;exports.useTokenSwap=Lt;exports.useTokenSwapQuote=$t;exports.useTokenSwapQuoteAction=zt;exports.useUpdateUserPositionConditions=Zs;exports.useUserBalances=Zp;exports.useUserBalancesAction=rl;exports.useUserBorrows=jp;exports.useUserBorrowsAction=Gp;exports.useUserClaimableRewards=$n;exports.useUserClaimableRewardsAction=zn;exports.useUserPosition=Xp;exports.useUserPositions=zp;exports.useUserPositionsAction=Jp;exports.useUserRiskPremiumBreakdown=el;exports.useUserSummary=$p;exports.useUserSummaryHistory=tl;exports.useUserSupplies=Kp;exports.useUserSuppliesAction=Yp;exports.useUserSwaps=ts;exports.useWithdraw=aa;exports.useWithdrawSwap=ns;exports.useWithdrawSwapQuote=us;exports.useWithdrawSwapQuoteAction=is;Object.keys(client).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return client[k]}})});//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var client=require('@aave/client'),z=require('react'),types=require('@aave/types'),urql=require('urql'),actions=require('@aave/client/actions'),graphql=require('@aave/graphql'),core=require('@aave/core');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var z__default=/*#__PURE__*/_interopDefault(z);var ne=z__default.default.createContext(null);function oe({children:e,client:r}){return z__default.default.createElement(ne.Provider,{value:r},z__default.default.createElement(urql.Provider,{value:r.urql},e))}function o(){let e=z.useContext(ne);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Ha({children:e,client:r}){return z__default.default.createElement(oe,{client:r},e)}function Ar(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 Ur(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:r}=graphql.decodeUserPositionId(e.userPositionId);return r}function E(e,r){return e.refreshQueryWhere(graphql.UserBalancesQuery,t=>t.request.user===r)}function B(e,r){return e.refreshQueryWhere(graphql.UserSuppliesQuery,t=>Ar(t.request.query)===r)}function W(e,r){return e.refreshQueryWhere(graphql.UserBorrowsQuery,t=>Ur(t.request.query)===r)}function J(e,r,t){let s=a=>a.spoke.chain.chainId===t.chainId&&a.spoke.address===t.address&&a.user===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(a,n)=>n.some(s)),e.refreshQueryWhere(graphql.UserPositionQuery,(a,n)=>n!==null&&s(n))])}function X(e,r){let t=s=>r.includes(s.id);return types.ResultAsync.combine([e.refreshQueryWhere(graphql.ReserveQuery,(s,a)=>a!==null&&t(a)),e.refreshQueryWhere(graphql.ReservesQuery,(s,a)=>a.some(t))])}function Z(e,r,t){return e.refreshQueryWhere(graphql.UserSummaryQuery,s=>s.request.user===r&&(graphql.isSpokeInputVariant(s.request.filter)?s.request.filter.spoke.chainId===t.chainId&&s.request.filter.spoke.address===t.address:graphql.isChainIdsVariant(s.request.filter)?s.request.filter.chainIds.some(a=>a===t.chainId):false))}function ee(e,r){let t=s=>s.chain.chainId===r.chainId&&s.address===r.address;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.SpokeQuery,(s,a)=>a!==null&&t(a)),e.refreshQueryWhere(graphql.SpokesQuery,(s,a)=>a.some(t))])}function re(e,r){let t=s=>s.chain.chainId===r;return types.ResultAsync.combine([e.refreshQueryWhere(graphql.HubQuery,(s,a)=>a!==null&&t(a)),e.refreshQueryWhere(graphql.HubsQuery,(s,a)=>a.some(t))])}function _(e,r){return e.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r)}function le(e,r){return types.ResultAsync.combine([e.refreshQueryWhere(graphql.UserPositionsQuery,(t,s)=>s.some(a=>a.id===r)),e.refreshQueryWhere(graphql.UserPositionQuery,(t,s)=>s?.id===r)])}function h(e,r){let{chainId:t,spoke:s}=graphql.decodeReserveId(r.reserve),a={chainId:t,address:s};return types.ResultAsync.combine([J(e,r.sender,a),Z(e,r.sender,a),X(e,[r.reserve]),ee(e,a),E(e,r.sender),B(e,r.sender),W(e,r.sender),re(e,t)])}function ce(e,r){return E(e,r)}function ye(e,r){return types.ResultAsync.combine([B(e,r),E(e,r)])}function de(e,r){return types.ResultAsync.combine([W(e,r),E(e,r)])}function Se(e,r){return types.ResultAsync.combine([B(e,r),W(e,r),E(e,r)])}function me(e,r){return types.ResultAsync.combine([B(e,r),E(e,r)])}var v={Loading:e=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false,metadata:e}),Success:(e,r,t=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:t,metadata:r}),Failure:(e,r,t=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:t,metadata:r}),Paused:(e,r,t)=>({data:e,error:r,loading:false,paused:true,reloading:false,metadata:t})};function u({document:e,variables:r,suspense:t,pause:s,selector:a=types.ok,pollInterval:n=0,batch:l=true}){let[c,m]=z.useState({operationKey:0,resultOperationKey:void 0}),[A,U]=z.useState(true),H=z.useMemo(()=>urql.createRequest(e,r).key,[e,r]),[{fetching:T,data:I,error:N,stale:j},ae]=urql.useQuery({query:e,variables:r,pause:s,context:z.useMemo(()=>({batch:l,suspense:t}),[l,t])});if(z.useEffect(()=>{m(b=>({...b,operationKey:H}));},[H]),z.useEffect(()=>{s||T||U(false);},[T,s]),z.useEffect(()=>{s||T||m(b=>({...b,resultOperationKey:I&&!j?b.operationKey:b.resultOperationKey}));},[s,T,I,j]),z.useEffect(()=>{if(n<=0||T||s)return;let b=setTimeout(()=>{ae({requestPolicy:"network-only",batch:false});},n);return ()=>clearTimeout(b)},[T,ae,n,s]),s){let b=N?client.UnexpectedError.from(N):void 0;if(!I)return v.Paused(void 0,b,c);let $=a(I.value);return $.isErr()?v.Paused(void 0,$.error,c):v.Paused($.value,b,c)}if(!t&&A)return v.Loading(c);let G=j||!A&&T;if(N){let b=client.UnexpectedError.from(N);if(t)throw b;return v.Failure(b,c,G)}types.invariant(I!==void 0,`Unexpected empty response from the API for '${core.extractDocumentName(e)??"unknown"}' query`);let er=I===null?null:I.value,M=a(er);if(M.isErr()){if(t)throw M.error;return v.Failure(M.error,c,G)}return v.Success(M.value,c,G)}var te={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 i(e,r){let[t,s]=z.useState(te.Idle()),a=z.useRef(false),n=z.useRef(true);z.useEffect(()=>()=>{n.current=false;},[]);let l=z.useCallback(e,r);return [z.useCallback(m=>{types.invariant(n.current,"Cannot execute a task on an unmounted component."),types.invariant(!a.current,"Cannot execute a task while another is in progress."),a.current=true;let A;s(U=>(A=U,{called:true,loading:true,data:U.data,error:void 0}));try{let U=l(m);return U.match(H=>{a.current=!1,s(te.Success(H));},H=>{a.current=!1,s(te.Failed(H));}),U}catch(U){throw a.current=false,A&&s(A),U}},[l]),t]}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 f(e){return types.isSignature(e)?types.okAsync(e):core.UnexpectedError.from(`Expected Signature, but got ${String(e)}`).asResultAsync()}function an({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.HubQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function nn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.HubsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function on({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.HubAssetsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function un({suspense:e=false,pause:r=false,...t}){return u({document:graphql.HubSummaryHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function pn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.HubAssetInterestRateModelQuery,variables:{request:s,currency:t},suspense:e,pause:r,selector:a=>types.ok(a.points)})}function ln(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.hubAssetInterestRateModel(r,t,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function cn(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.hubs(r,t,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function bn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.ChainQuery,variables:{request:t},suspense:e,pause:r})}function An(){let e=o();return i(r=>actions.chain(e,r,{batch:false,requestPolicy:"cache-first"}),[e])}function Un({suspense:e=false,pause:r=false,...t}={query:{filter:graphql.ChainsFilter.ALL}}){return u({document:graphql.ChainsQuery,variables:{request:t},suspense:e,pause:r})}function gn(){let e=o();return i(r=>actions.exchangeRate(e,r,{requestPolicy:"network-only"}),[e])}function Pn({suspense:e=false,pause:r=false,...t}){let s=o();return u({document:graphql.ExchangeRateQuery,variables:{request:t},suspense:e,pause:r,pollInterval:t.at?0:s.context.environment.exchangeRateInterval})}function hn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.AssetQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function vn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.AssetPriceHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function Qn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.AssetSupplyHistoryQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r,batch:false})}function kn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.AssetBorrowHistoryQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r,batch:false})}function qn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.ProtocolHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function Dn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ReserveQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function On(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.reserve(r,t,{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 Nn({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ReservesQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Mn(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.reserves(r,t,{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 _n({suspense:e=false,pause:r=false,...t}){return u({document:graphql.BorrowApyHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function Fn({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SupplyApyHistoryQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function $n({suspense:e=false,pause:r=false,...t}){return u({document:graphql.UserClaimableRewardsQuery,variables:{request:t},suspense:e,pause:r})}function zn(){let e=o();return i(r=>actions.userClaimableRewards(e,r,{requestPolicy:"cache-first"}),[e])}function eo({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokeQuery,variables:{request:t},suspense:e,pause:r})}function ro({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokesQuery,variables:{request:t},suspense:e,pause:r})}function to({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokePositionManagersQuery,variables:{request:t},suspense:e,pause:r})}function so({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SpokeUserPositionManagersQuery,variables:{request:t},suspense:e,pause:r})}function R(e){switch(e.__typename){case "PositionSwapByIntentApprovalsRequired":return types.ok(e.quote);case "InsufficientLiquidityError":return types.err(core.ValidationError.fromGqlNode(e));default:return types.err(core.UnexpectedError.upgradeRequired(`Unsupported position swap quote result: ${e.__typename}`))}}function K(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function Q(e){return {with:r=>e.approvals.reduce((t,s)=>t.andThen(a=>r(s,{cancel:p}).map(n=>{switch(s.__typename){case "PositionSwapAdapterContractApproval":a.adapterContractSignature=types.isSignature(n)?n:null;break;case "PositionSwapPositionManagerApproval":a.positionManagerSignature=types.isSignature(n)?n:null;break}return a})),types.okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function k(e,r){return actions.swap(e,{intent:r}).andThen(t=>{switch(t.__typename){case "SwapReceipt":return types.okAsync(t);default:return core.UnexpectedError.from(t).asResultAsync()}})}function yt(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.borrowSwapQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(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 St({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:ve(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:ve(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function mt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.borrowSwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function qe(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}var D=class extends types.ResultAwareError{name="CannotCancelSwapError"};function At(e){let r=o();return i(t=>actions.swapStatus(r,{id:t.id}).andThen(s=>{if(s===null)return core.UnexpectedError.from("Swap not found").asResultAsync();switch(s.__typename){case "SwapOpen":case "SwapPendingSignature":return actions.prepareSwapCancel(r,t).andThen(a=>e(a.data,{cancel:p})).andThen(f).andThen(a=>actions.cancelSwap(r,{intent:{id:t.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:t.id})).andThen(n=>n?.__typename==="SwapCancelled"?types.okAsync(qe(n)):new D("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(qe(s));case "SwapExpired":return new D("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${s.__typename}`).asResultAsync()}}),[r,e])}function Pt(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.repayWithSupplyQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ie(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function Tt({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:Ie(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function xt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.repayWithSupplyQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function vt(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.supplySwapQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function We(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function kt({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.SupplySwapQuoteQuery,variables:{request:We(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.SupplySwapQuoteQuery,variables:{request:We(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function qt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.supplySwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function Ht({suspense:e=false,pause:r=false,...t}){return u({document:graphql.SwappableTokensQuery,variables:{request:t},suspense:e,pause:r})}function Wt({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=u({document:graphql.SwapStatusQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval});return z.useEffect(()=>{m.data&&K(m.data)&&c(true);},[m.data]),m}function Lt(e){let r=o(),t=z.useCallback(s=>actions.swap(r,s).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 i(({currency:s=client.DEFAULT_QUERY_OPTIONS.currency,...a})=>actions.tokenSwapQuote(r,a,{currency:s}).andThen(n=>{switch(n.__typename){case "SwapByTransaction":return t({transaction:{quoteId:n.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId}).andThen(l=>e(l.data,{cancel:p}).andThen(f).andThen(c=>t({intent:{quoteId:l.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(n)){let l=n.approvals[0];return e(l,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId,permitSig:{deadline:l.bySignature.message.deadline,value:c}}):y.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(f).andThen(m=>t({intent:{quoteId:c.newQuoteId,signature:m}})))}return n.approvals.reduce((l,c)=>l.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(y.tryFrom).andThen(m=>m.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(r,{quoteId:n.quote.quoteId})).andThen(l=>e(l.data,{cancel:p})).andThen(f).andThen(l=>t({intent:{quoteId:n.quote.quoteId,signature:l}}));default:types.never(`Unsupported swap quote result: ${n.__typename}. To be removed from API soon.`);}}),[r,e,t])}function se(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 _e(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function $t({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.TokenSwapQuoteQuery,variables:{request:_e(s,graphql.QuoteAccuracy.Fast),currency:t},selector:se,suspense:e,pause:r,batch:false}),l=u({document:graphql.TokenSwapQuoteQuery,variables:{request:_e(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:se,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function zt(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.tokenSwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(se),[r,e.currency])}function rs(e,r){let t=new Map(r.map(s=>[s.swapId,s.__typename]));return e.filter(s=>s.__typename==="SwapFulfilled"&&t.get(s.swapId)!=="SwapFulfilled")}function ts({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){let n=o(),[l,c]=z.useState(false),m=u({document:graphql.UserSwapsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r||l,pollInterval:n.context.environment.swapStatusInterval}),A=m.data?.items??[],U=z.useDeferredValue(A);return z.useEffect(()=>{if(A.length===0)return;A.every(K)&&c(true);for(let T of rs(A,U))switch(T.operation.__typename){case "TokenSwap":a.user&&ce(n,a.user);break;case "BorrowSwap":a.user&&de(n,a.user);break;case "RepayWithSupply":a.user&&Se(n,a.user);break;case "SupplySwap":a.user&&ye(n,a.user);break;case "WithdrawSwap":a.user&&me(n,a.user);break}},[A,U,n,a.user]),m}function ns(e){let r=o();return i(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s})=>actions.withdrawSwapQuote(r,s,{currency:t}).andThen(a=>Q(a).with(e).andThen(n=>actions.preparePositionSwap(r,n)).andThen(n=>e(n.data,{cancel:p}).andThen(f).andThen(l=>k(r,{quoteId:n.newQuoteId,signature:l})))),[r,e])}function Ye(e,r){return "market"in e&&e.market?{market:{...e.market,accuracy:r}}:e}function us({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){let a=o(),n=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(s,graphql.QuoteAccuracy.Fast),currency:t},selector:R,suspense:e,pause:r,batch:false}),l=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Ye(s,graphql.QuoteAccuracy.Accurate),currency:t},selector:R,suspense:false,pause:r||e&&!n.data,pollInterval:a.context.environment.swapQuoteInterval,batch:false});return l.data&&l.metadata.resultOperationKey===l.metadata.operationKey?l:n}function is(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.withdrawSwapQuote(r,t,{currency:e.currency,requestPolicy:"network-only"}).andThen(R),[r,e.currency])}function cs({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.ActivitiesQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function ys(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.activities(r,t,{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 fs(e){let r=o();return i(t=>actions.borrow(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "PreContractActionRequired":return e(s,{cancel:p}).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s));case "Erc20ApprovalRequired":return client.UnexpectedError.from(s).asResultAsync()}}).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function Us(e){let r=o();return i(t=>actions.claimRewards(r,t).andThen(s=>e(s,{cancel:p})).andThen(y.tryFrom).andThen(s=>s.wait()).map(s=>client.transactionReceipt(s.txHash)),[r,e])}function Ts(e,r){return {deadline:r.message.deadline,value:e}}function q(e,r){return e.approvals.reduce((t,s)=>t.andThen(()=>r({...s,bySignature:null},{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function C(e,r,t){let s=e.approvals[0];return r(s,{cancel:p}).andThen(a=>types.isSignature(a)?t(Ts(a,s.bySignature)).map(types.expectTypename("TransactionRequest")):a.wait().map(()=>e.originalTransaction))}function vs(e,r){return "exact"in e.amount&&e.amount.exact?{...e,amount:{exact:{...e.amount.exact,permitSig:r}}}:e}function Qs(e){let r=o();return i(t=>actions.liquidatePosition(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.liquidatePosition(r,vs(t,a))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>E(r,t.liquidator)),[r,e])}function Cs(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.preview(r,t,{currency:e.currency,requestPolicy:"network-only"}),[r,e.currency])}function Hs({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.PreviewQuery,variables:{request:s,currency:t},suspense:e,pause:r})}function Bs(e){let r=o();return i(t=>actions.renounceSpokeUserPositionManager(r,t).andThen(s=>e(s,{cancel:p})).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>_(r,t.spoke)),[r,e])}function Os(e,r,t){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permit:{permitSig:r,signedAmount:t}}}}:e}function Ns(e){let r=o();return i(t=>actions.repay(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.repay(r,Os(t,a,s.approvals[0].bySignature.signedAmount))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function _s(e){let r=o();return i(t=>actions.setSpokeUserPositionManager(r,t).andThen(s=>e(s,{cancel:p})).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>_(r,t.spoke)),[r,e])}function Ys(e){let r=o();return i(t=>{let s=t.changes.map(n=>n.reserve),a=s.map(n=>graphql.decodeReserveId(n));return actions.setUserSuppliesAsCollateral(r,t).andThen(n=>e(n,{cancel:p})).andThen(n=>n.wait()).andThen(r.waitForTransaction).andThrough(()=>types.ResultAsync.combine([B(r,t.sender),W(r,t.sender),...a.flatMap(({chainId:n,spoke:l})=>[J(r,t.sender,{chainId:n,address:l}),Z(r,t.sender,{chainId:n,address:l}),ee(r,{chainId:n,address:l})]),X(r,s),...a.map(({chainId:n})=>re(r,n))]))},[r,e])}function zs(e,r){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:r}}}:e}function Js(e){let r=o();return i(t=>actions.supply(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.supply(r,zs(t,a))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "PreContractActionRequired":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function Zs(e){let r=o();return i(t=>actions.updateUserPositionConditions(r,t).andThen(s=>e(s,{cancel:p})).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>le(r,t.userPositionId)),[r,e])}function aa(e){let r=o();return i(t=>actions.withdraw(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "PreContractActionRequired":return e(s,{cancel:p}).andThen(a=>a.wait()).andThen(()=>e(s.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s));case "Erc20ApprovalRequired":return client.UnexpectedError.from(s).asResultAsync()}}).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>h(r,t)),[r,e])}function Kp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSuppliesQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Yp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userSupplies(r,t,{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 jp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserBorrowsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Gp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userBorrows(r,t,{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 $p({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserSummaryQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function zp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionsQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Jp(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userPositions(r,t,{currency:e.currency,timeWindow:e.timeWindow,requestPolicy:"cache-first"}),[r,e.currency,e.timeWindow])}function Xp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:s=client.DEFAULT_QUERY_OPTIONS.timeWindow,...a}){return u({document:graphql.UserPositionQuery,variables:{request:a,currency:t,timeWindow:s},suspense:e,pause:r})}function Zp({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.UserBalancesQuery,variables:{request:s,currency:t},suspense:e,pause:r})}function el({suspense:e=false,pause:r=false,...t}){return u({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:t},suspense:e,pause:r,batch:false})}function rl(e=client.DEFAULT_QUERY_OPTIONS){let r=o();return i(t=>actions.userBalances(r,t,{currency:e.currency,requestPolicy:"cache-first"}),[r,e.currency])}function tl({suspense:e=false,pause:r=false,currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...s}){return u({document:graphql.UserSummaryHistoryQuery,variables:{request:s,currency:t},suspense:e,pause:r,batch:false})}function Ea(e,r){return {...e,amount:{...e.amount,permitSig:r}}}function yl(e){let r=o();return i(t=>actions.stableVaultDeposit(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(s)?C(s,e,a=>actions.stableVaultDeposit(r,Ea(t,a))).andThen(a=>e(a,{cancel:p})):q(s,e).andThen(a=>e(a,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(s))}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction).andThrough(()=>Ze(r,t.user)),[r,e])}function dl(e){let r=o();return i(t=>actions.stableVaultWithdraw(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(r.waitForTransaction).andThrough(()=>Ze(r,t.user));case "StableVaultWithdrawClaim":return e(s.transaction,{cancel:p}).andThen(y.tryFrom).andThen(a=>a.wait()).andThen(r.waitForTransaction).map(()=>s)}}),[r,e])}function Sl(e){let r=o();return i(t=>actions.stableVaultWithdrawRedeem(r,t).andThen(s=>{switch(s.__typename){case "TransactionRequest":return e(s,{cancel:p});case "StableVaultPendingAvailability":return core.UnexpectedError.from(`Funds not yet available. Please retry after ${s.executableAfter.toLocaleString()}`).asResultAsync()}}).andThen(y.tryFrom).andThen(s=>s.wait()).andThen(r.waitForTransaction),[r,e])}function ml({suspense:e=false,pause:r=false,...t}){let s=o();return u({document:graphql.StableVaultClaimStatusQuery,variables:{request:t},suspense:e,pause:r,pollInterval:s.context.environment.pollingInterval})}function Rl({suspense:e=false,pause:r=false,...t}){return u({document:graphql.StableVaultUserPositionsQuery,variables:{request:t},suspense:e,pause:r})}function fl({suspense:e=false,pause:r=false,...t}){return u({document:graphql.StableVaultQuery,variables:{request:t},suspense:e,pause:r})}function bl({suspense:e=false,pause:r=false,...t}){return u({document:graphql.StableVaultsQuery,variables:{request:t},suspense:e,pause:r})}function Ze(e,r){return e.refreshQueryWhere(graphql.StableVaultUserPositionsQuery,t=>t.request.user===r)}exports.AaveProvider=Ha;exports.CannotCancelSwapError=D;exports.useAaveClient=o;exports.useActivities=cs;exports.useActivitiesAction=ys;exports.useAsset=hn;exports.useAssetBorrowHistory=kn;exports.useAssetPriceHistory=vn;exports.useAssetSupplyHistory=Qn;exports.useBorrow=fs;exports.useBorrowApyHistory=_n;exports.useBorrowSwap=yt;exports.useBorrowSwapQuote=St;exports.useBorrowSwapQuoteAction=mt;exports.useCancelSwap=At;exports.useChain=bn;exports.useChainAction=An;exports.useChains=Un;exports.useClaimRewards=Us;exports.useExchangeRate=Pn;exports.useExchangeRateAction=gn;exports.useHub=an;exports.useHubAssetInterestRateModel=pn;exports.useHubAssetInterestRateModelAction=ln;exports.useHubAssets=on;exports.useHubSummaryHistory=un;exports.useHubs=nn;exports.useHubsAction=cn;exports.useLiquidatePosition=Qs;exports.usePreview=Hs;exports.usePreviewAction=Cs;exports.useProtocolHistory=qn;exports.useRenounceSpokeUserPositionManager=Bs;exports.useRepay=Ns;exports.useRepayWithSupply=Pt;exports.useRepayWithSupplyQuote=Tt;exports.useRepayWithSupplyQuoteAction=xt;exports.useReserve=Dn;exports.useReserveAction=On;exports.useReserves=Nn;exports.useReservesAction=Mn;exports.useSetSpokeUserPositionManager=_s;exports.useSetUserSuppliesAsCollateral=Ys;exports.useSpoke=eo;exports.useSpokePositionManagers=to;exports.useSpokeUserPositionManagers=so;exports.useSpokes=ro;exports.useStableVault=fl;exports.useStableVaultClaimStatus=ml;exports.useStableVaultDeposit=yl;exports.useStableVaultUserPositions=Rl;exports.useStableVaultWithdraw=dl;exports.useStableVaultWithdrawRedeem=Sl;exports.useStableVaults=bl;exports.useSupply=Js;exports.useSupplyApyHistory=Fn;exports.useSupplySwap=vt;exports.useSupplySwapQuote=kt;exports.useSupplySwapQuoteAction=qt;exports.useSwapStatus=Wt;exports.useSwappableTokens=Ht;exports.useTokenSwap=Lt;exports.useTokenSwapQuote=$t;exports.useTokenSwapQuoteAction=zt;exports.useUpdateUserPositionConditions=Zs;exports.useUserBalances=Zp;exports.useUserBalancesAction=rl;exports.useUserBorrows=jp;exports.useUserBorrowsAction=Gp;exports.useUserClaimableRewards=$n;exports.useUserClaimableRewardsAction=zn;exports.useUserPosition=Xp;exports.useUserPositions=zp;exports.useUserPositionsAction=Jp;exports.useUserRiskPremiumBreakdown=el;exports.useUserSummary=$p;exports.useUserSummaryHistory=tl;exports.useUserSupplies=Kp;exports.useUserSuppliesAction=Yp;exports.useUserSwaps=ts;exports.useWithdraw=aa;exports.useWithdrawSwap=ns;exports.useWithdrawSwapQuote=us;exports.useWithdrawSwapQuoteAction=is;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
|