@aave/react 4.0.0-next.36 → 4.0.0-next.37
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.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var client=require('@aave/client'),M=require('react'),types=require('@aave/types'),urql=require('urql'),actions=require('@aave/client/actions'),graphql=require('@aave/graphql'),core=require('@aave/core');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var M__default=/*#__PURE__*/_interopDefault(M);var re=M__default.default.createContext(null);function te({children:e,client:s}){return M__default.default.createElement(re.Provider,{value:s},M__default.default.createElement(urql.Provider,{value:s.urql},e))}function i(){let e=M.useContext(re);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Vr({children:e,client:s}){return M__default.default.createElement(te,{client:s},e)}function ps(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:s}=graphql.decodeUserPositionId(e.userPositionId);return s}function ls(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:s}=graphql.decodeUserPositionId(e.userPositionId);return s}function ue(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function F(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>ps(r.request.query)===s)}function oe(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>ls(r.request.query)===s)}function L(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 j(e,s){return Promise.all([e.refreshQueryWhere(graphql.ReserveQuery,(r,t)=>t!==null&&s.includes(t.id)),e.refreshQueryWhere(graphql.ReservesQuery,(r,t)=>t.some(n=>s.includes(n.id)))])}function G(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 Y(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 $(e,s){return Promise.all([e.refreshQueryWhere(graphql.HubQuery,r=>graphql.isHubInputVariant(r.request.query)?r.request.query.hubInput.chainId===s:graphql.decodeHubId(r.request.query.hubId).chainId===s),e.refreshQueryWhere(graphql.HubsQuery,r=>graphql.isChainIdsVariant(r.request)?r.request.chainIds.some(t=>t===s):graphql.isTokensVariant(r.request.query)?r.request.query.tokens.some(t=>t.chainId===s):true)])}var b={Loading:()=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false}),Success:(e,s=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:s}),Failure:(e,s=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:s}),Paused:(e,s)=>({data:e,error:s,loading:false,paused:true,reloading:false})};function u({document:e,variables:s,suspense:r,pause:t,selector:n=types.ok,pollInterval:a=0,batch:o=true}){let[c,d]=M.useState(true),[{fetching:f,data:P,error:q,stale:Me},se]=urql.useQuery({query:e,variables:s,pause:t,context:M.useMemo(()=>({batch:o,suspense:r}),[o,r])});if(M.useEffect(()=>{t||f||d(false);},[f,t]),M.useEffect(()=>{if(a<=0||f||t)return;let T=setTimeout(()=>{se({requestPolicy:"network-only",batch:false});},a);return ()=>clearTimeout(T)},[f,se,a,t]),t){let T=q?client.UnexpectedError.from(q):void 0;if(!P)return b.Paused(void 0,T);let _=n(P.value);return _.isErr()?b.Paused(void 0,_.error):b.Paused(_.value,T)}if(!r&&c)return b.Loading();let V=Me||!c&&f;if(q){let T=client.UnexpectedError.from(q);if(r)throw T;return b.Failure(T,V)}types.invariant(P,"No data returned");let H=n(P.value);if(H.isErr()){if(r)throw H.error;return b.Failure(H.error,V)}return b.Success(H.value,V)}var K={Idle:()=>({called:false,loading:false,data:void 0,error:void 0}),Loading:e=>({called:true,loading:true,data:e,error:void 0}),Success:e=>({called:true,loading:false,data:e,error:void 0}),Failed:e=>({called:true,loading:false,data:void 0,error:e})};function l(e,s){let[r,t]=M.useState(K.Idle()),n=M.useRef(false),a=M.useCallback(e,s);return [M.useCallback(c=>{types.invariant(!n.current,"Cannot execute a task while another is in progress."),n.current=true;let d;t(f=>(d=f,{called:true,loading:true,data:f.data,error:void 0}));try{let f=a(c);return f.match(P=>{n.current=!1,t(K.Success(P));},P=>{n.current=!1,t(K.Failed(P));}),f}catch(f){throw n.current=false,t(types.nonNullable(d)),f}},[a]),r]}var p=e=>core.CancelError.from(e).asResultAsync(),R=class e{constructor(s){this.wait=s;}static isInstanceOf(s){return s instanceof e}static tryFrom(s){return e.isInstanceOf(s)?types.okAsync(s):core.UnexpectedError.from(s).asResultAsync()}};function 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 u({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 u({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 u({document:graphql.HubAssetsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ct({suspense:e=false,pause:s=false,...r}){return u({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function yt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.hubs(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function At({suspense:e=false,pause:s=false,...r}){return u({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function gt(){let e=i();return l(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 u({document:graphql.ChainsQuery,variables:{request:r},suspense:e,pause:s})}function bt(){let e=i();return l(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function wt({suspense:e=false,pause:s=false,...r}){let t=i();return u({document:graphql.ExchangeRateQuery,variables:{request:r},suspense:e,pause:s,pollInterval:r.at?0:t.context.environment.exchangeRateInterval})}function Qt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({document:graphql.AssetQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function kt({suspense:e=false,pause:s=false,...r}){return u({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 u({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 u({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 u({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 u({document:graphql.ReserveQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Vt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.reserve(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function _t({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({document:graphql.ReservesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Mt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.reserves(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Ft({suspense:e=false,pause:s=false,...r}){return u({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Lt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function $t({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function Kt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function zt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function Jt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function J(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 Ae(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}function U(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 ge(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Pe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function be(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function we(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Te(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function pn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.TokenSwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Fast),currency:r},selector:J,suspense:e,pause:s,batch:false}),o=u({document:graphql.TokenSwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:J,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function ln(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(J),[s,e.currency])}function cn({suspense:e=false,pause:s=false,...r}){return u({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(),[o,c]=M.useState(false),d=u({document:graphql.UserSwapsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||o,pollInterval:a.context.environment.swapStatusInterval});return M.useEffect(()=>{d.data&&d.data.items.length>0&&d.data.items.every(Be)&&c(true);},[d.data]),d}function Be(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(),[o,c]=M.useState(false),d=u({document:graphql.SwapStatusQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||o,pollInterval:a.context.environment.swapStatusInterval});return M.useEffect(()=>{d.data&&Be(d.data)&&c(true);},[d.data]),d}function Sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.SupplySwapQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.SupplySwapQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Rn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function fn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:be(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:be(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Un(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function D(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 O(e,s){return actions.swap(e,{intent:s}).andThen(r=>{switch(r.__typename){case "SwapReceipt":return types.okAsync(r);default:return core.UnexpectedError.from(r).asResultAsync()}})}function mn(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function An(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function gn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Pn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function bn(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function wn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Tn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function xn(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function hn(e){let s=i(),r=M.useCallback(t=>actions.swap(s,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait()).andThen(()=>types.okAsync(n.orderReceipt));case "SwapReceipt":return types.okAsync(n)}}),[s,e]);return l(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...n})=>actions.tokenSwapQuote(s,n,{currency:t}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return r({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId}).andThen(o=>e(o.data,{cancel:p}).andThen(g).andThen(c=>r({intent:{quoteId:o.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(a)){let o=a.approvals[0];return e(o,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:{deadline:o.bySignature.message.deadline,value:c}}):R.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(g).andThen(d=>r({intent:{quoteId:c.newQuoteId,signature:d}})))}return a.approvals.reduce((o,c)=>o.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(d=>d.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})).andThen(o=>e(o.data,{cancel:p})).andThen(g).andThen(o=>r({intent:{quoteId:a.quote.quoteId,signature:o}}));default:types.never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var B=class extends types.ResultAwareError{name="CannotCancelSwapError"};function En(e){let s=i();return l(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(R.tryFrom).andThen(a=>a.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(a=>a.__typename==="SwapCancelled"?types.okAsync(Ae(a)):new B("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(Ae(t));case "SwapExpired":return new B("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function N(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),n={chainId:r,address:t};return async()=>Promise.all([L(e,s.sender,n),G(e,s.sender,n),j(e,[s.reserve]),Y(e,n),ue(e,s.sender),F(e,s.sender),oe(e,s.sender),$(e,r)])}function mr(e,s){return {deadline:s.message.deadline,value:e}}function Z(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function ee(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(n=>types.isSignature(n)?r(mr(n,t.bySignature)).map(types.expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function Wn(e){let s=i();return l(r=>actions.supply(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?ee(t,e,n=>actions.supply(s,Ar(r,n))).andThen(n=>e(n,{cancel:p})):Z(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Ar(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Dn(e){let s=i();return l(r=>actions.borrow(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(s,r)),[s,e])}function On(e){let s=i();return l(r=>actions.repay(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?ee(t,e,n=>actions.repay(s,gr(r,n))).andThen(n=>e(n,{cancel:p})):Z(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(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 l(r=>actions.withdraw(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Vn(e){let s=i();return l(r=>actions.renounceSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function _n(e){let s=i();return l(r=>actions.updateUserPositionConditions(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(async()=>{let{userPositionId:t}=r;return Promise.all([s.refreshQueryWhere(graphql.UserPositionsQuery,(n,a)=>a.some(o=>o.id===t)),s.refreshQueryWhere(graphql.UserPositionQuery,(n,a)=>a?.id===t)])}),[s,e])}function Mn(e){let s=i();return l(r=>{let t=r.changes.map(a=>a.reserve),n=t.map(a=>graphql.decodeReserveId(a));return actions.setUserSuppliesAsCollateral(s,r).andThen(a=>e(a,{cancel:p})).andThen(a=>a.wait()).andThen(s.waitForTransaction).andTee(()=>Promise.all([F(s,r.sender),...n.flatMap(({chainId:a,spoke:o})=>[L(s,r.sender,{chainId:a,address:o}),G(s,r.sender,{chainId:a,address:o}),Y(s,{chainId:a,address:o})]),j(s,t),...n.map(({chainId:a})=>$(s,a))]))},[s,e])}function Fn(e){let s=i();return l(r=>actions.liquidatePosition(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?ee(t,e,n=>actions.liquidatePosition(s,Pr(r))).andThen(n=>e(n,{cancel:p})):Z(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction),[s,e])}function Pr(e,s){return e}function Ln(e){let s=i();return l(r=>actions.setSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function jn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(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 u({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 u({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 l(r=>actions.activities(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function sa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({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 l(r=>actions.userSupplies(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function ta({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({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 l(r=>actions.userBorrows(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function aa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({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 u({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 l(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 u({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 u({document:graphql.UserBalancesQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function la({suspense:e=false,pause:s=false,...r}){return u({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function ca(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(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 u({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:r},suspense:e,pause:s,batch:false})}exports.AaveProvider=Vr;exports.CannotCancelSwapError=B;exports.useAaveClient=i;exports.useActivities=Yn;exports.useActivitiesAction=$n;exports.useAsset=Qt;exports.useAssetBorrowHistory=qt;exports.useAssetPriceHistory=kt;exports.useAssetSupplyHistory=vt;exports.useBorrow=Dn;exports.useBorrowApyHistory=Ft;exports.useBorrowSwap=An;exports.useBorrowSwapQuote=fn;exports.useBorrowSwapQuoteAction=Un;exports.useCancelSwap=En;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=Vn;exports.useRepay=On;exports.useRepayWithSupply=bn;exports.useRepayWithSupplyQuote=gn;exports.useRepayWithSupplyQuoteAction=Pn;exports.useReserve=Nt;exports.useReserveAction=Vt;exports.useReserves=_t;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=mn;exports.useSupplySwapQuote=Sn;exports.useSupplySwapQuoteAction=Rn;exports.useSwapStatus=dn;exports.useSwappableTokens=cn;exports.useTokenSwap=hn;exports.useTokenSwapQuote=pn;exports.useTokenSwapQuoteAction=ln;exports.useUpdateUserPositionConditions=_n;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
|
|
1
|
+
'use strict';var client=require('@aave/client'),M=require('react'),types=require('@aave/types'),urql=require('urql'),actions=require('@aave/client/actions'),graphql=require('@aave/graphql'),core=require('@aave/core');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var M__default=/*#__PURE__*/_interopDefault(M);var te=M__default.default.createContext(null);function ne({children:e,client:s}){return M__default.default.createElement(te.Provider,{value:s},M__default.default.createElement(urql.Provider,{value:s.urql},e))}function i(){let e=M.useContext(te);return types.invariant(e,"Could not find Aave SDK context, ensure your code is wrapped in a <AaveProvider>"),e}function Vr({children:e,client:s}){return M__default.default.createElement(ne,{client:s},e)}function ps(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:s}=graphql.decodeUserPositionId(e.userPositionId);return s}function ls(e){if("userSpoke"in e)return e.userSpoke.user;if("userToken"in e)return e.userToken.user;if("userChains"in e)return e.userChains.user;if("userHub"in e)return e.userHub.user;let{user:s}=graphql.decodeUserPositionId(e.userPositionId);return s}function oe(e,s){return e.refreshQueryWhere(graphql.UserBalancesQuery,r=>r.request.user===s)}function F(e,s){return e.refreshQueryWhere(graphql.UserSuppliesQuery,r=>ps(r.request.query)===s)}function L(e,s){return e.refreshQueryWhere(graphql.UserBorrowsQuery,r=>ls(r.request.query)===s)}function j(e,s,r){return Promise.all([e.refreshQueryWhere(graphql.UserPositionsQuery,(t,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 G(e,s){return Promise.all([e.refreshQueryWhere(graphql.ReserveQuery,(r,t)=>t!==null&&s.includes(t.id)),e.refreshQueryWhere(graphql.ReservesQuery,(r,t)=>t.some(n=>s.includes(n.id)))])}function Y(e,s,r){return e.refreshQueryWhere(graphql.UserSummaryQuery,t=>t.request.user===s&&graphql.isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===r.chainId&&t.request.filter.spoke.address===r.address:graphql.isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(n=>n===r.chainId):false)}function $(e,s){return Promise.all([e.refreshQueryWhere(graphql.SpokeQuery,(r,t)=>t?.chain.chainId===s.chainId&&t?.address===s.address),e.refreshQueryWhere(graphql.SpokesQuery,(r,t)=>t.some(n=>n.chain.chainId===s.chainId&&n.address===s.address))])}function K(e,s){return Promise.all([e.refreshQueryWhere(graphql.HubQuery,r=>graphql.isHubInputVariant(r.request.query)?r.request.query.hubInput.chainId===s:graphql.decodeHubId(r.request.query.hubId).chainId===s),e.refreshQueryWhere(graphql.HubsQuery,r=>graphql.isChainIdsVariant(r.request)?r.request.chainIds.some(t=>t===s):graphql.isTokensVariant(r.request.query)?r.request.query.tokens.some(t=>t.chainId===s):true)])}var b={Loading:()=>({data:void 0,error:void 0,loading:true,paused:false,reloading:false}),Success:(e,s=false)=>({data:e,error:void 0,loading:false,paused:false,reloading:s}),Failure:(e,s=false)=>({data:void 0,error:e,loading:false,paused:false,reloading:s}),Paused:(e,s)=>({data:e,error:s,loading:false,paused:true,reloading:false})};function u({document:e,variables:s,suspense:r,pause:t,selector:n=types.ok,pollInterval:a=0,batch:o=true}){let[c,d]=M.useState(true),[{fetching:f,data:P,error:q,stale:Me},re]=urql.useQuery({query:e,variables:s,pause:t,context:M.useMemo(()=>({batch:o,suspense:r}),[o,r])});if(M.useEffect(()=>{t||f||d(false);},[f,t]),M.useEffect(()=>{if(a<=0||f||t)return;let T=setTimeout(()=>{re({requestPolicy:"network-only",batch:false});},a);return ()=>clearTimeout(T)},[f,re,a,t]),t){let T=q?client.UnexpectedError.from(q):void 0;if(!P)return b.Paused(void 0,T);let _=n(P.value);return _.isErr()?b.Paused(void 0,_.error):b.Paused(_.value,T)}if(!r&&c)return b.Loading();let V=Me||!c&&f;if(q){let T=client.UnexpectedError.from(q);if(r)throw T;return b.Failure(T,V)}types.invariant(P,"No data returned");let H=n(P.value);if(H.isErr()){if(r)throw H.error;return b.Failure(H.error,V)}return b.Success(H.value,V)}var z={Idle:()=>({called:false,loading:false,data:void 0,error:void 0}),Loading:e=>({called:true,loading:true,data:e,error:void 0}),Success:e=>({called:true,loading:false,data:e,error:void 0}),Failed:e=>({called:true,loading:false,data:void 0,error:e})};function l(e,s){let[r,t]=M.useState(z.Idle()),n=M.useRef(false),a=M.useCallback(e,s);return [M.useCallback(c=>{types.invariant(!n.current,"Cannot execute a task while another is in progress."),n.current=true;let d;t(f=>(d=f,{called:true,loading:true,data:f.data,error:void 0}));try{let f=a(c);return f.match(P=>{n.current=!1,t(z.Success(P));},P=>{n.current=!1,t(z.Failed(P));}),f}catch(f){throw n.current=false,t(types.nonNullable(d)),f}},[a]),r]}var p=e=>core.CancelError.from(e).asResultAsync(),R=class e{constructor(s){this.wait=s;}static isInstanceOf(s){return s instanceof e}static tryFrom(s){return e.isInstanceOf(s)?types.okAsync(s):core.UnexpectedError.from(s).asResultAsync()}};function 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 u({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 u({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 u({document:graphql.HubAssetsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function ct({suspense:e=false,pause:s=false,...r}){return u({document:graphql.HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function yt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.hubs(s,r,{currency:e.currency,requestPolicy:"cache-first"}),[s,e.currency])}function At({suspense:e=false,pause:s=false,...r}){return u({document:graphql.ChainQuery,variables:{request:r},suspense:e,pause:s})}function gt(){let e=i();return l(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 u({document:graphql.ChainsQuery,variables:{request:r},suspense:e,pause:s})}function bt(){let e=i();return l(s=>actions.exchangeRate(e,s,{requestPolicy:"network-only"}),[e])}function wt({suspense:e=false,pause:s=false,...r}){let t=i();return u({document:graphql.ExchangeRateQuery,variables:{request:r},suspense:e,pause:s,pollInterval:r.at?0:t.context.environment.exchangeRateInterval})}function Qt({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({document:graphql.AssetQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function kt({suspense:e=false,pause:s=false,...r}){return u({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 u({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 u({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 u({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 u({document:graphql.ReserveQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Vt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.reserve(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function _t({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({document:graphql.ReservesQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s})}function Mt(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.reserves(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function Ft({suspense:e=false,pause:s=false,...r}){return u({document:graphql.BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Lt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function $t({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeQuery,variables:{request:r},suspense:e,pause:s})}function Kt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokesQuery,variables:{request:r},suspense:e,pause:s})}function zt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function Jt({suspense:e=false,pause:s=false,...r}){return u({document:graphql.SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function X(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return types.ok(e.quote);case "InsufficientLiquidityError":return types.err(core.ValidationError.fromGqlNode(e));default:return types.err(core.UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`))}}function Ae(e){return {__typename:"SwapCancelledResult",swapId:e.swapId,createdAt:e.createdAt,cancelledAt:e.cancelledAt,explorerUrl:e.explorerUrl}}function U(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 ge(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Pe(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function be(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function we(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function Te(e,s){return "market"in e&&e.market?{market:{...e.market,accuracy:s}}:e}function pn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.TokenSwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Fast),currency:r},selector:X,suspense:e,pause:s,batch:false}),o=u({document:graphql.TokenSwapQuoteQuery,variables:{request:ge(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:X,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function ln(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.tokenSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(X),[s,e.currency])}function cn({suspense:e=false,pause:s=false,...r}){return u({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(),[o,c]=M.useState(false),d=u({document:graphql.UserSwapsQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||o,pollInterval:a.context.environment.swapStatusInterval});return M.useEffect(()=>{d.data&&d.data.items.length>0&&d.data.items.every(Be)&&c(true);},[d.data]),d}function Be(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(),[o,c]=M.useState(false),d=u({document:graphql.SwapStatusQuery,variables:{request:n,currency:r,timeWindow:t},suspense:e,pause:s||o,pollInterval:a.context.environment.swapStatusInterval});return M.useEffect(()=>{d.data&&Be(d.data)&&c(true);},[d.data]),d}function Sn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.SupplySwapQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.SupplySwapQuoteQuery,variables:{request:Pe(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Rn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.supplySwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function fn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:be(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.BorrowSwapQuoteQuery,variables:{request:be(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Un(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.borrowSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function D(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 O(e,s){return actions.swap(e,{intent:s}).andThen(r=>{switch(r.__typename){case "SwapReceipt":return types.okAsync(r);default:return core.UnexpectedError.from(r).asResultAsync()}})}function mn(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.supplySwapQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function An(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.borrowSwapQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function gn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.RepayWithSupplyQuoteQuery,variables:{request:we(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Pn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.repayWithSupplyQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function bn(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.repayWithSupplyQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function wn({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t}){let n=i(),a=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Fast),currency:r},selector:U,suspense:e,pause:s,batch:false}),o=u({document:graphql.WithdrawSwapQuoteQuery,variables:{request:Te(t,graphql.QuoteAccuracy.Accurate),currency:r},selector:U,suspense:false,pause:s||e&&!a.data,pollInterval:n.context.environment.swapQuoteInterval,batch:false});return o.data?o:a}function Tn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(r=>actions.withdrawSwapQuote(s,r,{currency:e.currency,requestPolicy:"network-only"}).andThen(U),[s,e.currency])}function xn(e){let s=i();return l(({currency:r=client.DEFAULT_QUERY_OPTIONS.currency,...t})=>actions.withdrawSwapQuote(s,t,{currency:r}).andThen(n=>D(n).with(e).andThen(a=>actions.preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:p}).andThen(g).andThen(o=>O(s,{quoteId:a.newQuoteId,signature:o})))),[s,e])}function hn(e){let s=i(),r=M.useCallback(t=>actions.swap(s,t).andThen(n=>{switch(n.__typename){case "SwapTransactionRequest":return e(n,{cancel:p}).andThen(R.tryFrom).andThen(a=>a.wait()).andThen(()=>types.okAsync(n.orderReceipt));case "SwapReceipt":return types.okAsync(n)}}),[s,e]);return l(({currency:t=client.DEFAULT_QUERY_OPTIONS.currency,...n})=>actions.tokenSwapQuote(s,n,{currency:t}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return r({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId}).andThen(o=>e(o.data,{cancel:p}).andThen(g).andThen(c=>r({intent:{quoteId:o.newQuoteId,signature:c}})));case "SwapByIntentWithApprovalRequired":if(client.supportsPermit(a)){let o=a.approvals[0];return e(o,{cancel:p}).andThen(c=>types.isSignature(c)?actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:{deadline:o.bySignature.message.deadline,value:c}}):R.isInstanceOf(c)?c.wait().andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})):core.UnexpectedError.from(c).asResultAsync()).andThen(c=>e(c.data,{cancel:p}).andThen(g).andThen(d=>r({intent:{quoteId:c.newQuoteId,signature:d}})))}return a.approvals.reduce((o,c)=>o.andThen(()=>e({...c,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(d=>d.wait())),types.okAsync(void 0)).andThen(()=>actions.prepareTokenSwap(s,{quoteId:a.quote.quoteId})).andThen(o=>e(o.data,{cancel:p})).andThen(g).andThen(o=>r({intent:{quoteId:a.quote.quoteId,signature:o}}));default:types.never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var B=class extends types.ResultAwareError{name="CannotCancelSwapError"};function En(e){let s=i();return l(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(R.tryFrom).andThen(a=>a.wait()).andThen(()=>actions.swapStatus(s,{id:r.id})).andThen(a=>a.__typename==="SwapCancelled"?types.okAsync(Ae(a)):new B("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return types.okAsync(Ae(t));case "SwapExpired":return new B("Swap cannot longer be cancelled").asResultAsync();default:return core.UnexpectedError.upgradeRequired(`Unsupported swap status: ${t.__typename}`).asResultAsync()}}),[s,e])}function N(e,s){let{chainId:r,spoke:t}=graphql.decodeReserveId(s.reserve),n={chainId:r,address:t};return async()=>Promise.all([j(e,s.sender,n),Y(e,s.sender,n),G(e,[s.reserve]),$(e,n),oe(e,s.sender),F(e,s.sender),L(e,s.sender),K(e,r)])}function mr(e,s){return {deadline:s.message.deadline,value:e}}function ee(e,s){return e.approvals.reduce((r,t)=>r.andThen(()=>s({...t,bySignature:null},{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait())),types.okAsync(void 0)).map(()=>e.originalTransaction)}function se(e,s,r){let t=e.approvals[0];return s(t,{cancel:p}).andThen(n=>types.isSignature(n)?r(mr(n,t.bySignature)).map(types.expectTypename("TransactionRequest")):n.wait().map(()=>e.originalTransaction))}function Wn(e){let s=i();return l(r=>actions.supply(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?se(t,e,n=>actions.supply(s,Ar(r,n))).andThen(n=>e(n,{cancel:p})):ee(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Ar(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Dn(e){let s=i();return l(r=>actions.borrow(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(s,r)),[s,e])}function On(e){let s=i();return l(r=>actions.repay(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?se(t,e,n=>actions.repay(s,gr(r,n))).andThen(n=>e(n,{cancel:p})):ee(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(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 l(r=>actions.withdraw(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "PreContractActionRequired":return e(t,{cancel:p}).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t));case "Erc20ApprovalRequired":return client.UnexpectedError.from(t).asResultAsync()}}).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(N(s,r)),[s,e])}function Vn(e){let s=i();return l(r=>actions.renounceSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function _n(e){let s=i();return l(r=>actions.updateUserPositionConditions(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(async()=>{let{userPositionId:t}=r;return Promise.all([s.refreshQueryWhere(graphql.UserPositionsQuery,(n,a)=>a.some(o=>o.id===t)),s.refreshQueryWhere(graphql.UserPositionQuery,(n,a)=>a?.id===t)])}),[s,e])}function Mn(e){let s=i();return l(r=>{let t=r.changes.map(a=>a.reserve),n=t.map(a=>graphql.decodeReserveId(a));return actions.setUserSuppliesAsCollateral(s,r).andThen(a=>e(a,{cancel:p})).andThen(a=>a.wait()).andThen(s.waitForTransaction).andTee(()=>Promise.all([F(s,r.sender),L(s,r.sender),...n.flatMap(({chainId:a,spoke:o})=>[j(s,r.sender,{chainId:a,address:o}),Y(s,r.sender,{chainId:a,address:o}),$(s,{chainId:a,address:o})]),G(s,t),...n.map(({chainId:a})=>K(s,a))]))},[s,e])}function Fn(e){let s=i();return l(r=>actions.liquidatePosition(s,r).andThen(t=>{switch(t.__typename){case "TransactionRequest":return e(t,{cancel:p});case "Erc20ApprovalRequired":return client.supportsPermit(t)?se(t,e,n=>actions.liquidatePosition(s,Pr(r))).andThen(n=>e(n,{cancel:p})):ee(t,e).andThen(n=>e(n,{cancel:p}));case "PreContractActionRequired":return e(t,{cancel:p}).andThen(R.tryFrom).andThen(n=>n.wait()).andThen(()=>e(t.originalTransaction,{cancel:p}));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}).andThen(R.tryFrom).andThen(t=>t.wait()).andThen(s.waitForTransaction),[s,e])}function Pr(e,s){return e}function Ln(e){let s=i();return l(r=>actions.setSpokeUserPositionManager(s,r).andThen(t=>e(t,{cancel:p})).andThen(t=>t.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(graphql.SpokePositionManagersQuery,t=>t.request.spoke===r.spoke)),[s,e])}function jn(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(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 u({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 u({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 l(r=>actions.activities(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function sa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({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 l(r=>actions.userSupplies(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function ta({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({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 l(r=>actions.userBorrows(s,r,{currency:e.currency??client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??client.DEFAULT_QUERY_OPTIONS.timeWindow,requestPolicy:"cache-first"}),[s,e.currency,e.timeWindow])}function aa({suspense:e=false,pause:s=false,currency:r=client.DEFAULT_QUERY_OPTIONS.currency,timeWindow:t=client.DEFAULT_QUERY_OPTIONS.timeWindow,...n}){return u({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 u({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 l(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 u({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 u({document:graphql.UserBalancesQuery,variables:{request:t,currency:r},suspense:e,pause:s})}function la({suspense:e=false,pause:s=false,...r}){return u({document:graphql.UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function ca(e=client.DEFAULT_QUERY_OPTIONS){let s=i();return l(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 u({document:graphql.UserSummaryHistoryQuery,variables:{request:t,currency:r},suspense:e,pause:s,batch:false})}exports.AaveProvider=Vr;exports.CannotCancelSwapError=B;exports.useAaveClient=i;exports.useActivities=Yn;exports.useActivitiesAction=$n;exports.useAsset=Qt;exports.useAssetBorrowHistory=qt;exports.useAssetPriceHistory=kt;exports.useAssetSupplyHistory=vt;exports.useBorrow=Dn;exports.useBorrowApyHistory=Ft;exports.useBorrowSwap=An;exports.useBorrowSwapQuote=fn;exports.useBorrowSwapQuoteAction=Un;exports.useCancelSwap=En;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=Vn;exports.useRepay=On;exports.useRepayWithSupply=bn;exports.useRepayWithSupplyQuote=gn;exports.useRepayWithSupplyQuoteAction=Pn;exports.useReserve=Nt;exports.useReserveAction=Vt;exports.useReserves=_t;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=mn;exports.useSupplySwapQuote=Sn;exports.useSupplySwapQuoteAction=Rn;exports.useSwapStatus=dn;exports.useSwappableTokens=cn;exports.useTokenSwap=hn;exports.useTokenSwapQuote=pn;exports.useTokenSwapQuoteAction=ln;exports.useUpdateUserPositionConditions=_n;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
|