@aave/react 4.0.0-next.26 → 4.0.0-next.28
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 +3 -3
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b}from'./chunk-3T44WW7A.js';export{c as useChain,d as useChains,f as useExchangeRate,e as useExchangeRateAction}from'./chunk-3T44WW7A.js';import {a,b as b$1}from'./chunk-4NA4FB6K.js';export{b as useAaveClient}from'./chunk-4NA4FB6K.js';import {a as a$1,b as b$2,c}from'./chunk-VGAHEW5B.js';import {DEFAULT_QUERY_OPTIONS,UnexpectedError as UnexpectedError$1}from'@aave/client';export*from'@aave/client';import le,{useState,useEffect,useCallback}from'react';import {hubs,reserve,reserves,tokenSwapQuote,supplySwapQuote,borrowSwapQuote,preparePositionSwap,repayWithSupplyQuote,withdrawSwapQuote,swap,prepareTokenSwap,swapStatus,prepareSwapCancel,cancelSwap,supply,borrow,repay,withdraw,renounceSpokeUserPositionManager,updateUserPositionConditions,setUserSuppliesAsCollateral,liquidatePosition,setSpokeUserPositionManager,preview,activities,userSupplies,userBorrows,userPositions,userBalances}from'@aave/client/actions';import {HubQuery,HubsQuery,HubAssetsQuery,HubSummaryHistoryQuery,AssetQuery,AssetPriceHistoryQuery,AssetSupplyHistoryQuery,AssetBorrowHistoryQuery,ProtocolHistoryQuery,ReserveQuery,ReservesQuery,BorrowApyHistoryQuery,SupplyApyHistoryQuery,SpokeQuery,SpokesQuery,SpokePositionManagersQuery,SpokeUserPositionManagersQuery,TokenSwapQuoteQuery,QuoteAccuracy,SwappableTokensQuery,UserSwapsQuery,SwapStatusQuery,SupplySwapQuoteQuery,BorrowSwapQuoteQuery,RepayWithSupplyQuoteQuery,WithdrawSwapQuoteQuery,UserPositionsQuery,UserPositionQuery,decodeReserveId,UserSummaryQuery,isSpokeInputVariant,isChainIdsVariant,isHubInputVariant,decodeHubId,PreviewQuery,ActivitiesQuery,UserSuppliesQuery,UserBorrowsQuery,UserBalancesQuery,UserRiskPremiumBreakdownQuery,UserSummaryHistoryQuery}from'@aave/graphql';import {UnexpectedError,ValidationError}from'@aave/core';import {invariant,isSignature,okAsync,never,ResultAwareError,errAsync,expectTypename}from'@aave/types';function Ts({children:e,client:s}){return le.createElement(a,{client:s},e)}function vs({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:HubQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Es({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:HubsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Bs({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:HubAssetsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Ws({suspense:e=false,pause:s=false,...r}){return b({document:HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Is(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>hubs(s,r,{currency:e.currency}),[s,e.currency])}function Ns({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:AssetQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Ms({suspense:e=false,pause:s=false,...r}){return b({document:AssetPriceHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Fs({suspense:e=false,pause:s=false,...r}){return b({document:AssetSupplyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Vs({suspense:e=false,pause:s=false,...r}){return b({document:AssetBorrowHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ls({suspense:e=false,pause:s=false,...r}){return b({document:ProtocolHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ks({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:ReserveQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Xs(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>reserve(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function Zs({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,selector:t,...a}){return b({document:ReservesQuery,variables:{request:a,currency:r,timeWindow:n},suspense:e,pause:s,selector:t||void 0})}function er(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>reserves(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function sr({suspense:e=false,pause:s=false,...r}){return b({document:BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function rr({suspense:e=false,pause:s=false,...r}){return b({document:SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function ur({suspense:e=false,pause:s=false,...r}){return b({document:SpokeQuery,variables:{request:r},suspense:e,pause:s})}function or({suspense:e=false,pause:s=false,...r}){return b({document:SpokesQuery,variables:{request:r},suspense:e,pause:s})}function pr({suspense:e=false,pause:s=false,...r}){return b({document:SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function ir({suspense:e=false,pause:s=false,...r}){return b({document:SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function W(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return e.quote;default:throw UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`)}}function F(e,s){return "market"in e&&e.market?{...e,market:{...e.market,accuracy:s}}:"limit"in e&&e.limit?{...e,limit:{...e.limit,accuracy:s}}:e}function Pr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){let t=b$1(),a=b({document:TokenSwapQuoteQuery,variables:{request:F(n,QuoteAccuracy.Fast),currency:r},selector:W,suspense:e,pause:s,batch:false}),u=b({document:TokenSwapQuoteQuery,variables:{request:F(n,QuoteAccuracy.Accurate),currency:r},selector:W,suspense:false,pause:s||e&&!a.data,pollInterval:t.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function Ar(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>tokenSwapQuote(s,r,{currency:e.currency}).map(W),[s,e.currency])}function br({suspense:e=false,pause:s=false,...r}){return b({document:SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function fr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){let a=b$1(),[u,i]=useState(false),y=b({document:UserSwapsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return useEffect(()=>{y.data&&y.data.items.length>0&&y.data.items.every(K)&&i(true);},[y.data]),y}function K(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function Tr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){let a=b$1(),[u,i]=useState(false),y=b({document:SwapStatusQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return useEffect(()=>{y.data&&K(y.data)&&i(true);},[y.data]),y}function xr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:SupplySwapQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function Qr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>supplySwapQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function qr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:BorrowSwapQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function kr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>borrowSwapQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function k(e){return {with:s=>e.approvals.reduce((r,n)=>r.andThen(t=>s(n,{cancel:b$2}).map(a=>{switch(n.__typename){case "PositionSwapAdapterContractApproval":t.adapterContractSignature=isSignature(a)?a:null;break;case "PositionSwapPositionManagerApproval":t.positionManagerSignature=isSignature(a)?a:null;break}return t})),okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function h(e,s){return swap(e,{intent:s}).andThen(r=>{switch(r.__typename){case "SwapReceipt":return okAsync(r);default:return UnexpectedError.from(r).asResultAsync()}})}function hr(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>supplySwapQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function Hr(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>borrowSwapQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function vr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:RepayWithSupplyQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function Er(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>repayWithSupplyQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function Br(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>repayWithSupplyQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function Wr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:WithdrawSwapQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function Ir(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>withdrawSwapQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function Cr(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>withdrawSwapQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function Or(e){let s=b$1(),r=useCallback(n=>swap(s,n).andThen(t=>{switch(t.__typename){case "SwapTransactionRequest":return e(t,{cancel:b$2}).map(c.ensure).andThen(a=>a.wait()).andThen(()=>okAsync(t.orderReceipt));case "SwapReceipt":return okAsync(t)}}),[s,e]);return a$1(({currency:n=DEFAULT_QUERY_OPTIONS.currency,...t})=>tokenSwapQuote(s,t,{currency:n}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return r({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return prepareTokenSwap(s,{quoteId:a.quote.quoteId}).andThen(u=>e(u.data,{cancel:b$2}).map(i=>(invariant(isSignature(i),"Invalid signature"),i)).andThen(i=>r({intent:{quoteId:u.newQuoteId,signature:i}})));case "SwapByIntentWithApprovalRequired":return e(a.approval,{cancel:b$2}).andThen(u=>{if(isSignature(u)){let i=a.approval.bySignature;if(!i)return UnexpectedError.from("Expected bySignature to be present in SwapByIntentWithApprovalRequired").asResultAsync();let y={deadline:i.message.deadline,value:u};return prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:y})}return c.isInstanceOf(u)?u.wait().andThen(()=>prepareTokenSwap(s,{quoteId:a.quote.quoteId})):UnexpectedError.from(u).asResultAsync()}).andThen(u=>e(u.data,{cancel:b$2}).map(i=>(invariant(isSignature(i),"Invalid signature"),i)).andThen(i=>r({intent:{quoteId:a.quote.quoteId,signature:i}})));default:never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var Q=class extends ResultAwareError{name="CannotCancelSwapError"};function _r(e){let s=b$1();return a$1(r=>swapStatus(s,{id:r.id}).andThen(n=>{switch(n.__typename){case "SwapOpen":case "SwapPendingSignature":return prepareSwapCancel(s,r).andThen(t=>e(t.data,{cancel:b$2})).map(t=>(invariant(isSignature(t),"Invalid signature"),t)).andThen(t=>cancelSwap(s,{intent:{id:r.id,signature:t}})).andThen(t=>t.__typename==="SwapCancelled"?okAsync(t):e(t,{cancel:b$2}).map(c.ensure).andThen(a=>a.wait()).andThen(()=>swapStatus(s,{id:r.id})).andThen(a=>a.__typename==="SwapCancelled"?okAsync(a):new Q("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return okAsync(n);case "SwapExpired":return new Q("Swap cannot longer be cancelled").asResultAsync();default:return UnexpectedError.upgradeRequired(`Unsupported swap status: ${n.__typename}`).asResultAsync()}}),[s,e])}function E(e,s){let{chainId:r,spoke:n}=decodeReserveId(s.reserve);return async()=>Promise.all([await e.refreshQueryWhere(UserPositionsQuery,(t,a)=>t.request.user===s.sender&&a.some(u=>u.spoke.chain.chainId===r&&u.spoke.address===n)),await e.refreshQueryWhere(UserPositionQuery,(t,a)=>a?.spoke.chain.chainId===r&&a?.spoke.address===n&&a.user===s.sender),await e.refreshQueryWhere(UserSummaryQuery,t=>t.request.user===s.sender&&isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===r&&t.request.filter.spoke.address===n:isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(a=>a===r):false),await e.refreshQueryWhere(ReservesQuery,(t,a)=>a.some(u=>u.id===s.reserve)),await e.refreshQueryWhere(SpokesQuery,(t,a)=>a.some(u=>u.chain.chainId===r&&u.address===n)),await e.refreshQueryWhere(UserBalancesQuery,t=>t.request.user===s.sender),await e.refreshQueryWhere(HubsQuery,t=>isChainIdsVariant(t.request)&&t.request.chainIds.some(a=>a===r))])}function Gr(e){let s=b$1();return a$1(r=>supply(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "Erc20ApprovalRequired":return e(n,{cancel:b$2}).andThen(t=>{if(isSignature(t)){let a=n.approval.bySignature;if(!a)return UnexpectedError$1.from("Expected bySignature to be present in Erc20ApprovalRequired").asResultAsync();let u={deadline:a.message.deadline,value:t};return supply(s,ns(r,u)).map(expectTypename("TransactionRequest")).andThen(i=>e(i,{cancel:b$2})).map(c.ensure)}return okAsync(t)}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n))}}).andTee(E(s,r)),[s,e])}function ns(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function $r(e){let s=b$1();return a$1(r=>borrow(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n));case "Erc20ApprovalRequired":return UnexpectedError$1.from(n).asResultAsync()}}).andTee(E(s,r)),[s,e])}function zr(e){let s=b$1();return a$1(r=>repay(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "Erc20ApprovalRequired":return e(n,{cancel:b$2}).andThen(t=>{if(isSignature(t)){let a=n.approval.bySignature;if(!a)return UnexpectedError$1.from("Expected bySignature to be present in Erc20ApprovalRequired").asResultAsync();let u={deadline:a.message.deadline,value:t};return repay(s,as(r,u)).map(expectTypename("TransactionRequest")).andThen(i=>e(i,{cancel:b$2})).map(c.ensure)}return okAsync(t)}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n))}}).andTee(E(s,r)),[s,e])}function as(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Jr(e){let s=b$1();return a$1(r=>withdraw(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n));case "Erc20ApprovalRequired":return UnexpectedError$1.from(n).asResultAsync()}}).andTee(E(s,r)),[s,e])}function Kr(e){let s=b$1();return a$1(r=>renounceSpokeUserPositionManager(s,r).andThen(n=>e(n,{cancel:b$2})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(SpokePositionManagersQuery,n=>n.request.spoke===r.spoke)),[s,e])}function Xr(e){let s=b$1();return a$1(r=>updateUserPositionConditions(s,r).andThen(n=>e(n,{cancel:b$2})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(async()=>{let{userPositionId:n}=r;return Promise.all([s.refreshQueryWhere(UserPositionsQuery,(t,a)=>a.some(u=>u.id===n)),s.refreshQueryWhere(UserPositionQuery,(t,a)=>a?.id===n)])}),[s,e])}function Zr(e){let s=b$1();return a$1(r=>{let n=r.changes.map(a=>a.reserve),t=n.map(a=>decodeReserveId(a));return setUserSuppliesAsCollateral(s,r).andThen(a=>e(a,{cancel:b$2})).andThen(a=>a.wait()).andThen(s.waitForTransaction).andTee(()=>Promise.all([...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(UserPositionsQuery,(i,y)=>i.request.user===r.sender&&y.some(b=>b.spoke.chain.chainId===a&&b.spoke.address===u))),...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(UserPositionQuery,(i,y)=>y?.spoke.chain.chainId===a&&y?.spoke.address===u&&y.user===r.sender)),...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(UserSummaryQuery,i=>i.request.user===r.sender&&isSpokeInputVariant(i.request.filter)?i.request.filter.spoke.chainId===a&&i.request.filter.spoke.address===u:isChainIdsVariant(i.request.filter)?i.request.filter.chainIds.some(y=>y===a):false)),s.refreshQueryWhere(ReservesQuery,(a,u)=>u.some(i=>n.includes(i.id))),...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(SpokesQuery,(i,y)=>y.some(b=>b.chain.chainId===a&&b.address===u))),...t.map(({chainId:a})=>s.refreshQueryWhere(HubsQuery,u=>isChainIdsVariant(u.request.query)?u.request.query.chainIds.some(i=>i===a):u.request.query.tokens.some(i=>i.chainId===a))),...t.map(({chainId:a})=>s.refreshQueryWhere(HubQuery,u=>isHubInputVariant(u.request.query)?u.request.query.hubInput.chainId===a:decodeHubId(u.request.query.hubId).chainId===a))]))},[s,e])}function et(e){let s=b$1();return a$1(r=>liquidatePosition(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "Erc20ApprovalRequired":case "PreContractActionRequired":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n))}}),[s,e])}function st(e){let s=b$1();return a$1(r=>setSpokeUserPositionManager(s,r).andThen(n=>e(n,{cancel:b$2})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(SpokePositionManagersQuery,n=>n.request.spoke===r.spoke)),[s,e])}function rt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>preview(s,r,{currency:e.currency}),[s,e.currency])}function tt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:PreviewQuery,variables:{request:n,currency:r},suspense:e,pause:s})}function nt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:ActivitiesQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function at(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>activities(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function yt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserSuppliesQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function St(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userSupplies(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function dt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserBorrowsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Rt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userBorrows(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function Ut({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserSummaryQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function wt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserPositionsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function mt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow}),[s,e.currency,e.timeWindow])}function gt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserPositionQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Pt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:UserBalancesQuery,variables:{request:n,currency:r},suspense:e,pause:s})}function At({suspense:e=false,pause:s=false,...r}){return b({document:UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function bt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userBalances(s,r,{currency:e.currency}),[s,e.currency])}function ft({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:UserSummaryHistoryQuery,variables:{request:n,currency:r},suspense:e,pause:s,batch:false})}export{Ts as AaveProvider,Q as CannotCancelSwapError,nt as useActivities,at as useActivitiesAction,Ns as useAsset,Vs as useAssetBorrowHistory,Ms as useAssetPriceHistory,Fs as useAssetSupplyHistory,$r as useBorrow,sr as useBorrowApyHistory,Hr as useBorrowSwap,qr as useBorrowSwapQuote,kr as useBorrowSwapQuoteAction,_r as useCancelSwap,vs as useHub,Bs as useHubAssets,Ws as useHubSummaryHistory,Es as useHubs,Is as useHubsAction,et as useLiquidatePosition,tt as usePreview,rt as usePreviewAction,Ls as useProtocolHistory,Kr as useRenounceSpokeUserPositionManager,zr as useRepay,Br as useRepayWithSupply,vr as useRepayWithSupplyQuote,Er as useRepayWithSupplyQuoteAction,Ks as useReserve,Xs as useReserveAction,Zs as useReserves,er as useReservesAction,st as useSetSpokeUserPositionManager,Zr as useSetUserSuppliesAsCollateral,ur as useSpoke,pr as useSpokePositionManagers,ir as useSpokeUserPositionManagers,or as useSpokes,Gr as useSupply,rr as useSupplyApyHistory,hr as useSupplySwap,xr as useSupplySwapQuote,Qr as useSupplySwapQuoteAction,Tr as useSwapStatus,br as useSwappableTokens,Or as useTokenSwap,Pr as useTokenSwapQuote,Ar as useTokenSwapQuoteAction,Xr as useUpdateUserPositionConditions,Pt as useUserBalances,bt as useUserBalancesAction,dt as useUserBorrows,Rt as useUserBorrowsAction,gt as useUserPosition,wt as useUserPositions,mt as useUserPositionsAction,At as useUserRiskPremiumBreakdown,Ut as useUserSummary,ft as useUserSummaryHistory,yt as useUserSupplies,St as useUserSuppliesAction,fr as useUserSwaps,Jr as useWithdraw,Cr as useWithdrawSwap,Wr as useWithdrawSwapQuote,Ir as useWithdrawSwapQuoteAction};//# sourceMappingURL=index.js.map
|
|
1
|
+
import {b}from'./chunk-3T44WW7A.js';export{c as useChain,d as useChains,f as useExchangeRate,e as useExchangeRateAction}from'./chunk-3T44WW7A.js';import {a,b as b$1}from'./chunk-4NA4FB6K.js';export{b as useAaveClient}from'./chunk-4NA4FB6K.js';import {a as a$1,b as b$2,c}from'./chunk-VGAHEW5B.js';import {DEFAULT_QUERY_OPTIONS,UnexpectedError as UnexpectedError$1}from'@aave/client';export*from'@aave/client';import ie,{useState,useEffect,useCallback}from'react';import {hubs,reserve,reserves,tokenSwapQuote,supplySwapQuote,borrowSwapQuote,preparePositionSwap,repayWithSupplyQuote,withdrawSwapQuote,swap,prepareTokenSwap,swapStatus,prepareSwapCancel,cancelSwap,supply,borrow,repay,withdraw,renounceSpokeUserPositionManager,updateUserPositionConditions,setUserSuppliesAsCollateral,liquidatePosition,setSpokeUserPositionManager,preview,activities,userSupplies,userBorrows,userPositions,userBalances}from'@aave/client/actions';import {HubQuery,HubsQuery,HubAssetsQuery,HubSummaryHistoryQuery,AssetQuery,AssetPriceHistoryQuery,AssetSupplyHistoryQuery,AssetBorrowHistoryQuery,ProtocolHistoryQuery,ReserveQuery,ReservesQuery,BorrowApyHistoryQuery,SupplyApyHistoryQuery,SpokeQuery,SpokesQuery,SpokePositionManagersQuery,SpokeUserPositionManagersQuery,TokenSwapQuoteQuery,QuoteAccuracy,SwappableTokensQuery,UserSwapsQuery,SwapStatusQuery,SupplySwapQuoteQuery,BorrowSwapQuoteQuery,RepayWithSupplyQuoteQuery,WithdrawSwapQuoteQuery,UserPositionsQuery,UserPositionQuery,decodeReserveId,UserSummaryQuery,isSpokeInputVariant,isChainIdsVariant,isHubInputVariant,decodeHubId,PreviewQuery,ActivitiesQuery,UserSuppliesQuery,UserBorrowsQuery,UserBalancesQuery,UserRiskPremiumBreakdownQuery,UserSummaryHistoryQuery}from'@aave/graphql';import {UnexpectedError,ValidationError}from'@aave/core';import {invariant,isSignature,okAsync,never,ResultAwareError,errAsync,expectTypename}from'@aave/types';function fs({children:e,client:s}){return ie.createElement(a,{client:s},e)}function Hs({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:HubQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function vs({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:HubsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Es({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:HubAssetsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Bs({suspense:e=false,pause:s=false,...r}){return b({document:HubSummaryHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ws(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>hubs(s,r,{currency:e.currency}),[s,e.currency])}function Ds({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:AssetQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Ns({suspense:e=false,pause:s=false,...r}){return b({document:AssetPriceHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Ms({suspense:e=false,pause:s=false,...r}){return b({document:AssetSupplyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Fs({suspense:e=false,pause:s=false,...r}){return b({document:AssetBorrowHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Vs({suspense:e=false,pause:s=false,...r}){return b({document:ProtocolHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function Js({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:ReserveQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Ks(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>reserve(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function Xs({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,selector:t,...a}){return b({document:ReservesQuery,variables:{request:a,currency:r,timeWindow:n},suspense:e,pause:s,selector:t||void 0})}function Zs(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>reserves(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function er({suspense:e=false,pause:s=false,...r}){return b({document:BorrowApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function sr({suspense:e=false,pause:s=false,...r}){return b({document:SupplyApyHistoryQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function ar({suspense:e=false,pause:s=false,...r}){return b({document:SpokeQuery,variables:{request:r},suspense:e,pause:s})}function ur({suspense:e=false,pause:s=false,...r}){return b({document:SpokesQuery,variables:{request:r},suspense:e,pause:s})}function or({suspense:e=false,pause:s=false,...r}){return b({document:SpokePositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function pr({suspense:e=false,pause:s=false,...r}){return b({document:SpokeUserPositionManagersQuery,variables:{request:r},suspense:e,pause:s})}function W(e){switch(e.__typename){case "SwapByIntent":case "SwapByIntentWithApprovalRequired":case "SwapByTransaction":return e.quote;default:throw UnexpectedError.upgradeRequired(`Unsupported swap quote result: ${e.__typename}`)}}function F(e,s){return "market"in e&&e.market?{...e,market:{...e.market,accuracy:s}}:"limit"in e&&e.limit?{...e,limit:{...e.limit,accuracy:s}}:e}function gr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){let t=b$1(),a=b({document:TokenSwapQuoteQuery,variables:{request:F(n,QuoteAccuracy.Fast),currency:r},selector:W,suspense:e,pause:s,batch:false}),u=b({document:TokenSwapQuoteQuery,variables:{request:F(n,QuoteAccuracy.Accurate),currency:r},selector:W,suspense:false,pause:s||e&&!a.data,pollInterval:t.context.environment.swapQuoteInterval,batch:false});return u.data?u:a}function Pr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>tokenSwapQuote(s,r,{currency:e.currency}).map(W),[s,e.currency])}function Ar({suspense:e=false,pause:s=false,...r}){return b({document:SwappableTokensQuery,variables:{request:r},suspense:e,pause:s})}function br({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){let a=b$1(),[u,l]=useState(false),y=b({document:UserSwapsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return useEffect(()=>{y.data&&y.data.items.length>0&&y.data.items.every(K)&&l(true);},[y.data]),y}function K(e){return e.__typename==="SwapFulfilled"||e.__typename==="SwapCancelled"||e.__typename==="SwapExpired"}function fr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){let a=b$1(),[u,l]=useState(false),y=b({document:SwapStatusQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s||u,pollInterval:a.context.environment.swapStatusInterval});return useEffect(()=>{y.data&&K(y.data)&&l(true);},[y.data]),y}function Tr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:SupplySwapQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function xr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>supplySwapQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function Qr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:BorrowSwapQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function qr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>borrowSwapQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function k(e){return {with:s=>e.approvals.reduce((r,n)=>r.andThen(t=>s(n,{cancel:b$2}).map(a=>{switch(n.__typename){case "PositionSwapAdapterContractApproval":t.adapterContractSignature=isSignature(a)?a:null;break;case "PositionSwapPositionManagerApproval":t.positionManagerSignature=isSignature(a)?a:null;break}return t})),okAsync({quoteId:e.quote.quoteId,adapterContractSignature:null,positionManagerSignature:null}))}}function h(e,s){return swap(e,{intent:s}).andThen(r=>{switch(r.__typename){case "SwapReceipt":return okAsync(r);default:return UnexpectedError.from(r).asResultAsync()}})}function kr(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>supplySwapQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function hr(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>borrowSwapQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function Hr({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:RepayWithSupplyQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function vr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>repayWithSupplyQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function Er(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>repayWithSupplyQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function Br({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:WithdrawSwapQuoteQuery,variables:{request:n,currency:r},selector:t=>t.quote,suspense:e,pause:s})}function Wr(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>withdrawSwapQuote(s,r,{currency:e.currency}).map(n=>n.quote),[s,e.currency])}function Ir(e){let s=b$1();return a$1(({currency:r=DEFAULT_QUERY_OPTIONS.currency,...n})=>withdrawSwapQuote(s,n,{currency:r}).andThen(t=>k(t).with(e).andThen(a=>preparePositionSwap(s,a)).andThen(a=>e(a.data,{cancel:b$2}).map(u=>(invariant(isSignature(u),"Expected signature, got an object instead."),u))).andThen(a=>h(s,{quoteId:t.quote.quoteId,signature:a}))),[s,e])}function Cr(e){let s=b$1(),r=useCallback(n=>swap(s,n).andThen(t=>{switch(t.__typename){case "SwapTransactionRequest":return e(t,{cancel:b$2}).map(c.ensure).andThen(a=>a.wait()).andThen(()=>okAsync(t.orderReceipt));case "SwapReceipt":return okAsync(t)}}),[s,e]);return a$1(({currency:n=DEFAULT_QUERY_OPTIONS.currency,...t})=>tokenSwapQuote(s,t,{currency:n}).andThen(a=>{switch(a.__typename){case "SwapByTransaction":return r({transaction:{quoteId:a.quote.quoteId}});case "SwapByIntent":return prepareTokenSwap(s,{quoteId:a.quote.quoteId}).andThen(u=>e(u.data,{cancel:b$2}).map(l=>(invariant(isSignature(l),"Invalid signature"),l)).andThen(l=>r({intent:{quoteId:u.newQuoteId,signature:l}})));case "SwapByIntentWithApprovalRequired":return e(a.approval,{cancel:b$2}).andThen(u=>{if(isSignature(u)){let l=a.approval.bySignature;if(!l)return UnexpectedError.from("Expected bySignature to be present in SwapByIntentWithApprovalRequired").asResultAsync();let y={deadline:l.message.deadline,value:u};return prepareTokenSwap(s,{quoteId:a.quote.quoteId,permitSig:y})}return c.isInstanceOf(u)?u.wait().andThen(()=>prepareTokenSwap(s,{quoteId:a.quote.quoteId})):UnexpectedError.from(u).asResultAsync()}).andThen(u=>e(u.data,{cancel:b$2}).map(l=>(invariant(isSignature(l),"Invalid signature"),l)).andThen(l=>r({intent:{quoteId:a.quote.quoteId,signature:l}})));default:never(`Unsupported swap quote result: ${a.__typename}. To be removed from API soon.`);}}),[s,e,r])}var Q=class extends ResultAwareError{name="CannotCancelSwapError"};function Or(e){let s=b$1();return a$1(r=>swapStatus(s,{id:r.id}).andThen(n=>{switch(n.__typename){case "SwapOpen":case "SwapPendingSignature":return prepareSwapCancel(s,r).andThen(t=>e(t.data,{cancel:b$2})).map(t=>(invariant(isSignature(t),"Invalid signature"),t)).andThen(t=>cancelSwap(s,{intent:{id:r.id,signature:t}})).andThen(t=>t.__typename==="SwapCancelled"?okAsync(t):e(t,{cancel:b$2}).map(c.ensure).andThen(a=>a.wait()).andThen(()=>swapStatus(s,{id:r.id})).andThen(a=>a.__typename==="SwapCancelled"?okAsync(a):new Q("Failed to cancel swap").asResultAsync()));case "SwapCancelled":return okAsync(n);case "SwapExpired":return new Q("Swap cannot longer be cancelled").asResultAsync();default:return UnexpectedError.upgradeRequired(`Unsupported swap status: ${n.__typename}`).asResultAsync()}}),[s,e])}function E(e,s){let{chainId:r,spoke:n}=decodeReserveId(s.reserve);return async()=>Promise.all([await e.refreshQueryWhere(UserPositionsQuery,(t,a)=>t.request.user===s.sender&&a.some(u=>u.spoke.chain.chainId===r&&u.spoke.address===n)),await e.refreshQueryWhere(UserPositionQuery,(t,a)=>a?.spoke.chain.chainId===r&&a?.spoke.address===n&&a.user===s.sender),await e.refreshQueryWhere(UserSummaryQuery,t=>t.request.user===s.sender&&isSpokeInputVariant(t.request.filter)?t.request.filter.spoke.chainId===r&&t.request.filter.spoke.address===n:isChainIdsVariant(t.request.filter)?t.request.filter.chainIds.some(a=>a===r):false),await e.refreshQueryWhere(ReservesQuery,(t,a)=>a.some(u=>u.id===s.reserve)),await e.refreshQueryWhere(SpokesQuery,(t,a)=>a.some(u=>u.chain.chainId===r&&u.address===n)),await e.refreshQueryWhere(UserBalancesQuery,t=>t.request.user===s.sender),await e.refreshQueryWhere(HubsQuery,t=>isChainIdsVariant(t.request)&&t.request.chainIds.some(a=>a===r))])}function Yr(e){let s=b$1();return a$1(r=>supply(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "Erc20ApprovalRequired":return e(n,{cancel:b$2}).andThen(t=>{if(isSignature(t)){let a=n.approval.bySignature;if(!a)return UnexpectedError$1.from("Expected bySignature to be present in Erc20ApprovalRequired").asResultAsync();let u={deadline:a.message.deadline,value:t};return supply(s,ts(r,u)).map(expectTypename("TransactionRequest")).andThen(l=>e(l,{cancel:b$2})).map(c.ensure)}return t.wait().andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure)}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n))}}).andTee(E(s,r)),[s,e])}function ts(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function Gr(e){let s=b$1();return a$1(r=>borrow(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n));case "Erc20ApprovalRequired":return UnexpectedError$1.from(n).asResultAsync()}}).andTee(E(s,r)),[s,e])}function $r(e){let s=b$1();return a$1(r=>repay(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "Erc20ApprovalRequired":return e(n,{cancel:b$2}).andThen(t=>{if(isSignature(t)){let a=n.approval.bySignature;if(!a)return UnexpectedError$1.from("Expected bySignature to be present in Erc20ApprovalRequired").asResultAsync();let u={deadline:a.message.deadline,value:t};return repay(s,ns(r,u)).map(expectTypename("TransactionRequest")).andThen(l=>e(l,{cancel:b$2})).map(c.ensure)}return t.wait().andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure)}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).map(c.ensure).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).map(c.ensure).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n))}}).andTee(E(s,r)),[s,e])}function ns(e,s){return "erc20"in e.amount?{...e,amount:{erc20:{...e.amount.erc20,permitSig:s}}}:e}function zr(e){let s=b$1();return a$1(r=>withdraw(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "PreContractActionRequired":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n));case "Erc20ApprovalRequired":return UnexpectedError$1.from(n).asResultAsync()}}).andTee(E(s,r)),[s,e])}function Jr(e){let s=b$1();return a$1(r=>renounceSpokeUserPositionManager(s,r).andThen(n=>e(n,{cancel:b$2})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(SpokePositionManagersQuery,n=>n.request.spoke===r.spoke)),[s,e])}function Kr(e){let s=b$1();return a$1(r=>updateUserPositionConditions(s,r).andThen(n=>e(n,{cancel:b$2})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(async()=>{let{userPositionId:n}=r;return Promise.all([s.refreshQueryWhere(UserPositionsQuery,(t,a)=>a.some(u=>u.id===n)),s.refreshQueryWhere(UserPositionQuery,(t,a)=>a?.id===n)])}),[s,e])}function Xr(e){let s=b$1();return a$1(r=>{let n=r.changes.map(a=>a.reserve),t=n.map(a=>decodeReserveId(a));return setUserSuppliesAsCollateral(s,r).andThen(a=>e(a,{cancel:b$2})).andThen(a=>a.wait()).andThen(s.waitForTransaction).andTee(()=>Promise.all([...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(UserPositionsQuery,(l,y)=>l.request.user===r.sender&&y.some(b=>b.spoke.chain.chainId===a&&b.spoke.address===u))),...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(UserPositionQuery,(l,y)=>y?.spoke.chain.chainId===a&&y?.spoke.address===u&&y.user===r.sender)),...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(UserSummaryQuery,l=>l.request.user===r.sender&&isSpokeInputVariant(l.request.filter)?l.request.filter.spoke.chainId===a&&l.request.filter.spoke.address===u:isChainIdsVariant(l.request.filter)?l.request.filter.chainIds.some(y=>y===a):false)),s.refreshQueryWhere(ReservesQuery,(a,u)=>u.some(l=>n.includes(l.id))),...t.map(({chainId:a,spoke:u})=>s.refreshQueryWhere(SpokesQuery,(l,y)=>y.some(b=>b.chain.chainId===a&&b.address===u))),...t.map(({chainId:a})=>s.refreshQueryWhere(HubsQuery,u=>isChainIdsVariant(u.request.query)?u.request.query.chainIds.some(l=>l===a):u.request.query.tokens.some(l=>l.chainId===a))),...t.map(({chainId:a})=>s.refreshQueryWhere(HubQuery,u=>isHubInputVariant(u.request.query)?u.request.query.hubInput.chainId===a:decodeHubId(u.request.query.hubId).chainId===a))]))},[s,e])}function Zr(e){let s=b$1();return a$1(r=>liquidatePosition(s,r).andThen(n=>{switch(n.__typename){case "TransactionRequest":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "Erc20ApprovalRequired":case "PreContractActionRequired":return e(n,{cancel:b$2}).andThen(t=>t.wait()).andThen(()=>e(n.originalTransaction,{cancel:b$2})).andThen(t=>t.wait()).andThen(s.waitForTransaction);case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n))}}),[s,e])}function et(e){let s=b$1();return a$1(r=>setSpokeUserPositionManager(s,r).andThen(n=>e(n,{cancel:b$2})).andThen(n=>n.wait()).andThen(s.waitForTransaction).andTee(()=>s.refreshQueryWhere(SpokePositionManagersQuery,n=>n.request.spoke===r.spoke)),[s,e])}function st(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>preview(s,r,{currency:e.currency}),[s,e.currency])}function rt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:PreviewQuery,variables:{request:n,currency:r},suspense:e,pause:s})}function tt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:ActivitiesQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function nt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>activities(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function ct({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserSuppliesQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function yt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userSupplies(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function St({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserBorrowsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function dt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userBorrows(s,r,{currency:e.currency??DEFAULT_QUERY_OPTIONS.currency,timeWindow:e.timeWindow??DEFAULT_QUERY_OPTIONS.timeWindow}),[s,e.currency,e.timeWindow])}function Rt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserSummaryQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function Ut({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserPositionsQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function wt(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userPositions(s,r,{currency:e.currency,timeWindow:e.timeWindow}),[s,e.currency,e.timeWindow])}function mt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,timeWindow:n=DEFAULT_QUERY_OPTIONS.timeWindow,...t}){return b({document:UserPositionQuery,variables:{request:t,currency:r,timeWindow:n},suspense:e,pause:s})}function gt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:UserBalancesQuery,variables:{request:n,currency:r},suspense:e,pause:s})}function Pt({suspense:e=false,pause:s=false,...r}){return b({document:UserRiskPremiumBreakdownQuery,variables:{request:r},suspense:e,pause:s,batch:false})}function At(e=DEFAULT_QUERY_OPTIONS){let s=b$1();return a$1(r=>userBalances(s,r,{currency:e.currency}),[s,e.currency])}function bt({suspense:e=false,pause:s=false,currency:r=DEFAULT_QUERY_OPTIONS.currency,...n}){return b({document:UserSummaryHistoryQuery,variables:{request:n,currency:r},suspense:e,pause:s,batch:false})}export{fs as AaveProvider,Q as CannotCancelSwapError,tt as useActivities,nt as useActivitiesAction,Ds as useAsset,Fs as useAssetBorrowHistory,Ns as useAssetPriceHistory,Ms as useAssetSupplyHistory,Gr as useBorrow,er as useBorrowApyHistory,hr as useBorrowSwap,Qr as useBorrowSwapQuote,qr as useBorrowSwapQuoteAction,Or as useCancelSwap,Hs as useHub,Es as useHubAssets,Bs as useHubSummaryHistory,vs as useHubs,Ws as useHubsAction,Zr as useLiquidatePosition,rt as usePreview,st as usePreviewAction,Vs as useProtocolHistory,Jr as useRenounceSpokeUserPositionManager,$r as useRepay,Er as useRepayWithSupply,Hr as useRepayWithSupplyQuote,vr as useRepayWithSupplyQuoteAction,Js as useReserve,Ks as useReserveAction,Xs as useReserves,Zs as useReservesAction,et as useSetSpokeUserPositionManager,Xr as useSetUserSuppliesAsCollateral,ar as useSpoke,or as useSpokePositionManagers,pr as useSpokeUserPositionManagers,ur as useSpokes,Yr as useSupply,sr as useSupplyApyHistory,kr as useSupplySwap,Tr as useSupplySwapQuote,xr as useSupplySwapQuoteAction,fr as useSwapStatus,Ar as useSwappableTokens,Cr as useTokenSwap,gr as useTokenSwapQuote,Pr as useTokenSwapQuoteAction,Kr as useUpdateUserPositionConditions,gt as useUserBalances,At as useUserBalancesAction,St as useUserBorrows,dt as useUserBorrowsAction,mt as useUserPosition,Ut as useUserPositions,wt as useUserPositionsAction,Pt as useUserRiskPremiumBreakdown,Rt as useUserSummary,bt as useUserSummaryHistory,ct as useUserSupplies,yt as useUserSuppliesAction,br as useUserSwaps,zr as useWithdraw,Ir as useWithdrawSwap,Br as useWithdrawSwapQuote,Wr as useWithdrawSwapQuoteAction};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|