PageSourceSearch

https://fe-v3.vercel.app/_next/static/chunks/1384.4412716326b76e85.js

js fe-v3.vercel.app collected 2026-10-03 06:57:59 UTC 34,582 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1384],{2443:(e,t,n)=>{n.d(t,{Ht:()=>a.H,ne:()=>i.ne,i5:()=>p,sb:()=>o.s});var a=n(17634),o=n(79180),i=n(18134),s=n(77407),l=n(56198),r=n(91804),d=n(6040),u=n(89567),c=n(15336);let m=(0,l.PF)("NFT_POSITION_MANAGER");function p(e){let t=(0,r.useMemo)(()=>(null==e?void 0:e.tokenId)?[{address:m.address,abi:m.abi,functionName:"positions",args:[(0,d.uU)(e.tokenId)]}]:[],[null==e?void 0:e.tokenId]),{data:n,isLoading:a,refetch:o}=(0,c.useReadContracts)({contracts:t,allowFailure:!0});return{data:(0,r.useMemo)(()=>{if(!n||!e)return;let t=e.token0Decimals,a=e.token1Decimals;if(!t||!a)return;let o=n[0];if(!o||"success"!==o.status)return;let i=o.result;try{let n={tokenId:e.tokenId,nonce:(0,u.cK)(i[0]),operator:i[1],token0:e.token0,token1:e.token1,fee:e.fee,tickLower:e.tickLower,tickUpper:e.tickUpper,liquidity:(0,u.cK)(i[7]),feeGrowthInside0LastX128:(0,u.cK)(i[8]),feeGrowthInside1LastX128:(0,u.cK)(i[9]),currentTick:e.currentTick,sqrtPriceX96:e.sqrtPriceX96,poolLiquidity:e.poolLiquidity},{amount0:o,amount1:l}=(0,s.x)(n,t,a);return{amount0:o.toExact(),amount1:l.toExact()}}catch(t){console.error("Error calculating amounts for position ".concat(e.tokenId,":"),t);return}},[n,e]),isLoading:a,error:null,refetch:o}}n(40946)},2939:(e,t,n)=>{n.d(t,{M:()=>o});let a={all:["portfolio"],positions:()=>[...a.all,"positions"],liquidityDataSubgraph:e=>["liquidityDataSubgraph",e],liquidityData:e=>["liquidityData",e],tokenIds:e=>["tokenIds",e],fees:()=>[...a.all,"fees"],pendingFees:(e,t)=>["pendingFees",e,t],positionPool:e=>["position-pool",e],positionPrices:e=>["positionPrices",...e]},o={afterAddLiquidity:(e,t)=>[a.liquidityDataSubgraph(e),["liquidityData"],a.tokenIds(e),["evmTokenBalances",e],a.pendingFees(t,e)],afterRemoveLiquidity:(e,t)=>[a.liquidityDataSubgraph(e),["liquidityData"],a.tokenIds(e),["evmTokenBalances",e],a.pendingFees(t,e)],afterCollectFees:(e,t)=>[a.liquidityDataSubgraph(e),a.pendingFees(t,e),["evmTokenBalances",e]],afterBatchCollect:(e,t)=>[a.liquidityDataSubgraph(e),...t.map(t=>a.pendingFees(t,e)),["evmTokenBalances",e]]}},17634:(e,t,n)=>{n.d(t,{H:()=>y});var a=n(20258),o=n(70205);async function i(e,t,n,a){try{return await (0,o.dr)(e,"ERC20","allowance",[n,a],{account:n,contractAddress:t})}catch(e){throw console.error("Error checking allowance:",e),e}}async function s(e,t,n,a,o){try{return await i(e,t,n,a)>=o}catch(e){throw console.error("Error checking if allowance is sufficient:",e),e}}async function l(e,t,n,a){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};try{return await (0,o.writeAndWaitForReceipt)(e,"ERC20","approve",[n,a],{account:i.account,contractAddress:t})}catch(e){throw console.error("Error setting and waiting for allowance:",e),e}}var r=n(62604),d=n(56198),u=n(8971),c=n(72310),m=n(70331),p=n(26283),x=n(2939),g=n(14515),f=n(21738),h=n(29798),k=n(1786),v=n(62289);let y=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"v3",t=arguments.length>1?arguments[1]:void 0,{address:n}=(0,k.useAccount)(),i=(0,v.useConfig)(),y=(0,m.jE)();return(0,p.n)({mutationFn:async m=>{if(!n)throw Error("Wallet not connected");let{onStatusChange:p}=t||{};if("v3"===e){null==p||p("preparing","Preparing to add liquidity");let e=await (0,o.dr)(i,"NFT_POSITION_MANAGER","positions",[m.tokenId]),t=e[2],v=e[3],y=(0,r.TH)(),b=(0,c.eU)(y),N=t.toLowerCase()===b.address.toLowerCase(),w=v.toLowerCase()===b.address.toLowerCase();N&&(t="0x0000000000000000000000000000000000000000"),w&&(v="0x0000000000000000000000000000000000000000");let I=0n;N&&m.amount0Desired&&(I+=BigInt(m.amount0Desired.toString())),w&&m.amount1Desired&&(I+=BigInt(m.amount1Desired.toString()));let A=(0,d.PF)("NFT_POSITION_MANAGER").address;!N&&m.amount0Desired&&(null==p||p("approving_token_a","Checking Token ".concat(m.token0Symbol," approval")),await s(i,e[2],n,A,m.amount0Desired||f.Ao)||(null==p||p("approving_token_a","Approving Token ".concat(m.token0Symbol)),await l(i,e[2],A,f.Ao,{account:n}))),!w&&m.amount1Desired&&(null==p||p("approving_token_b","Checking Token ".concat(m.token1Symbol," approval")),await s(i,e[3],n,A,m.amount1Desired||f.Ao)||(null==p||p("approving_token_b","Approving Token ".concat(m.token1Symbol)),await l(i,e[3],A,f.Ao,{account:n}))),null==p||p("minting","Adding liquidity");let C=[(0,h.p)({abi:a.xJ,functionName:"increaseLiquidity",args:[{...m}]})];(N||w)&&C.push((0,h.p)({abi:a.xJ,functionName:"refundETH",args:[]}));let T=(0,h.p)({abi:a.xJ,functionName:"multicall",args:[C]}),j=await (0,o.GX)(i,{to:A,data:T,value:I}),E=await (0,g.v)(i,{to:A,data:T,value:I,gas:j>2000000n?2000000n:j});try{var x,k;m.amount0Desired&&(0,u.S8)(m.amount0Desired.toString(),null!=(x=e[2]===t?m.decimals0:m.decimals1)?x:18),m.amount1Desired&&(0,u.S8)(m.amount1Desired.toString(),null!=(k=e[3]===v?m.decimals1:m.decimals0)?k:18),"".concat(m.token0Symbol,"/").concat(m.token1Symbol),m.tokenId.toString(),e[4]}catch(e){}return null==p||p("success","Liquidity added"),E}{let{token0:e,token1:t,amount0Desired:n,amount1Desired:a,amount0Min:o,amount1Min:i,deadline:s}=m;throw Error("V2 liquidity is no longer supported")}},onSuccess:(e,t)=>
1{n&&(x.M.afterAddLiquidity(n,t.tokenId.toString()).forEach(e=>{y.invalidateQueries({queryKey:e,exact:!1}),y.refetchQueries({queryKey:e,exact:!1})}),y.invalidateQueries({queryKey:["poolStats"],exact:!1}),y.refetchQueries({queryKey:["poolStats"],exact:!1}),y.invalidateQueries({queryKey:["liquidity-depth"],exact:!1}),y.refetchQueries({queryKey:["liquidity-depth"],exact:!1}))},onError:e=>{console.error("[useAddLiquidity] Transaction failed:",e);let{onStatusChange:n}=t||{};null==n||n("error",e.message||"Transaction failed",e)}})}},17873:(e,t,n)=>{n.d(t,{A:()=>v});var a=n(85520),o=n(93577),i=n(26897),s=n(26123),l=n(257),r=n(8971),d=n(30040),u=n(79038),c=n(72310),m=n(86222),p=n(91804),x=n(42447),g=n(32492),f=n(81868),h=n(25154);let k=(0,p.forwardRef)((e,t)=>{let{position:n,onReview:k,currentPrice:v,isInRange:y}=e,[b,N]=(0,p.useState)(!1);(0,p.useImperativeHandle)(t,()=>({openModal:()=>N(!0)}));let w=(0,d.TH)(),[I,A]=(0,p.useState)({}),[C,T]=(0,p.useState)(!1),[j,E]=(0,p.useState)(!1),[L,S]=(0,p.useState)(!1),{setStartingPrice:B,setDefaultPriceRange:F,reset:q}=(0,m.P)(),{data:D,isLoading:U}=(0,l.AX)(n.token0,{enabled:!!n.token0}),{data:M,isLoading:R}=(0,l.AX)(n.token1,{enabled:!!n.token1}),P=(null==D?void 0:D.address.toLowerCase())===(0,c.eU)(w).address.toLowerCase(),H=(null==M?void 0:M.address.toLowerCase())===(0,c.eU)(w).address.toLowerCase(),O=P?{...D,address:"0x0000000000000000000000000000000000000000",symbol:"ETH",logoURI:"https://assets.coingecko.com/coins/images/279/large/ethereum.png"}:D,_=H?{...M,address:"0x0000000000000000000000000000000000000000",symbol:"ETH",logoURI:"https://assets.coingecko.com/coins/images/279/large/ethereum.png"}:M;(0,p.useEffect)(()=>{b&&v&&(B(v),F(v))},[b,v,B,F]);let G=(0,p.useMemo)(()=>(0,a.jsx)(f.a,{className:"px-2",tokenA:O,tokenB:_,details:[{label:"Token A",value:"100"},{label:"Token B",value:"200"}],detailsFn:(e,t,o,i)=>{let s=[e,t],l=[n.amount0,n.amount1].map(e=>(0,r.cG)(e)),d=[I.amountA,I.amountB].map((e,t)=>l[t].plus((0,r.cG)(e)));return(0,a.jsx)(f.L,{tokenA:e,tokenB:t,labelFn:()=>"".concat(s[i].symbol," position"),valueFn:()=>(0,a.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,a.jsx)(h.A,{symbol:s[i].symbol,logoURI:s[i].logoURI,className:"size-4"}),(0,a.jsx)("span",{children:(0,g.Ki)(l[i].toNumber())}),(0,a.jsx)("span",{children:"→"}),(0,a.jsx)("span",{children:(0,g.Ki)(d[i].toNumber())})]})},i)}}),[O,_,n,I]);return(0,a.jsxs)("div",{className:"relative shrink-0",children:[(0,a.jsx)(i.A,{size:"sm",variant:"ghost",className:"bg-border hover:bg-border h-9 w-fit px-3 text-base font-medium",onClick:()=>N(!0),children:"Add"}),(0,a.jsxs)(s.A,{title:"Add Liquidity",isOpen:b,onClose:()=>{N(!1),q()},width:"w-full md:w-[420px]",modalClassName:"rounded-[20px]",titleClassName:"px-2",contentClassName:"px-3 md:px-3 pt-5 pb-3",children:[(0,a.jsx)(x.N,{tokenA:O,tokenB:_,fee:n.fee,isInRange:y,isLoading:U||R,className:"mx-2"}),(null==D?void 0:D.decimals)!==void 0&&(null==M?void 0:M.decimals)!==void 0&&(0,a.jsx)(o.A,{tokenA:O,tokenB:_,fee:n.fee,currentPrice:v,calculateAmounts:(e,t)=>{if(!D||!M||!v)return{amountA:"0",amountB:"0"};try{if("A"===e){let e=(0,u.quoteMintAmountsFromTokens)({tokenA:D,tokenB:M,fee:n.fee,tickLower:n.tickLower,tickUpper:n.tickUpper,amountA:t,currentPrice:v}),a=(0,r.S8)(e.isReversed?e.amount0Desired.toString():e.amount1Desired.toString(),M.decimals);return{amountA:t,amountB:a}}{let e=(0,u.quoteMintAmountsFromTokens)({tokenA:D,tokenB:M,fee:n.fee,tickLower:n.tickLower,tickUpper:n.tickUpper,amountB:t,currentPrice:v});return{amountA:(0,r.S8)(e.isReversed?e.amount1Desired.toString():e.amount0Desired.toString(),D.decimals),amountB:t}}}catch(e){return console.error("Error calculating amounts:",e),{amountA:"0",amountB:"0"}}},onDataUpdate:A,tickCurrent:n.currentTick,tickLower:n.tickLower,tickUpper:n.tickUpper,onTokenInvalidChange:T,onTokenAInvalidChange:E,onTokenBInvalidChange:S,isInPortfolio:!0,isInputOnly:!0}),G,(0,a.jsx)(i.A,{variant:"primary",className:"w-full !rounded-[20px]",label:"0"===I.amountA&&"0"===I.amountB?"Enter amount":j&&L?"Insufficient ".concat(null==O?void 0:O.symbol," & ").concat(null==_?void 0:_.symbol):j?"Insufficient ".concat(null==O?void 0:O.symbol):L?"Insufficient ".concat(null==_?void 0:_.symbol):"Review",onClick:()=>{O&&_&&(N(!1),k({tokenA:O,tokenB:_,amountA:I.amountA||"49.3",amountB:I.amountB||"13.2",additionalDetails:G,position:n,currentPrice:v}),q())},disabled:"0"===I.amountA&&"0"===I.amountB||C})]})]})});k.displayName="AddLiquidity";let v=k},18134:(e,t,n)=>{n.d(t,{Iq:()=>A,ne:()=>I});var a=n(34495),o=n(64348),i=n(8971),s=n(56198),l=n(70205),r=n(72310),d=n(70331),u=n(26283),c=n(92478),m=n(2939),p=n(83381),x=n(3365),g=n(66811),f=n(29798),h=n(6040),k=n(21738),v=n(89567),y=n(11604),b=n(1786),N=n(17784),w=n(62289);let I=e=>{let{address:t,chainId:n}=(0,b.useAccount)(),{writeContractAsync:i}=(0,N.useWriteContract)(),c=(0,s.PF)("NFT_POSITION_MANAGER"),g=(0,r.eU)(n||o.$E),h=(0,w.useConfig)(),k=(0,d.jE)(),v=e=>{var t,n;if(!e.token0Address||!e.token1Address)throw Error("Token addresses are required");let o=(null==(t=e.token0Address)?void 0:t.toLowerCase())===g.address.toLowerCase(),i=(null==(n=e.token1Address)?void 0:n.toLowerCase())===g.address.toLowerCase(),s=[];
1return s.push((0,f.p)({abi:a.xJ,functionName:"collect",args:[{tokenId:e.tokenId,recipient:p.Y4,amount0Max:e.amount0Max,amount1Max:e.amount1Max}]})),o?s.push((0,f.p)({abi:a.xJ,functionName:"unwrapWETH9",args:[e.expectedToken0Amount||0n,e.recipient]})):s.push((0,f.p)({abi:a.xJ,functionName:"sweepToken",args:[e.token0Address,e.expectedToken0Amount||0n,e.recipient]})),i?s.push((0,f.p)({abi:a.xJ,functionName:"unwrapWETH9",args:[e.expectedToken1Amount||0n,e.recipient]})):s.push((0,f.p)({abi:a.xJ,functionName:"sweepToken",args:[e.token1Address,e.expectedToken1Amount||0n,e.recipient]})),s};return(0,u.n)({mutationFn:async n=>{var o,s,r;if(!t)throw Error("Wallet not connected");let d=(null==(o=n.token0Address)?void 0:o.toLowerCase())===g.address.toLowerCase(),u=(null==(s=n.token1Address)?void 0:s.toLowerCase())===g.address.toLowerCase();if(null==e||null==(r=e.onStatusChange)||r.call(e,"pending","Claiming fees"),d||u){let e=await (0,l.GX)(h,{to:c.address,data:(0,f.p)({abi:a.xJ,functionName:"multicall",args:[v(n)]})}),t=await i({address:c.address,abi:a.xJ,functionName:"multicall",args:[v(n)],gas:e>2000000n?2000000n:e});return await (0,x.n)(h,{hash:t})}{let e=await (0,l.GX)(h,{to:c.address,data:(0,f.p)({abi:a.xJ,functionName:"collect",args:[{tokenId:n.tokenId,recipient:n.recipient,amount0Max:n.amount0Max,amount1Max:n.amount1Max}]})}),t=await i({address:c.address,abi:a.xJ,functionName:"collect",args:[{tokenId:n.tokenId,recipient:n.recipient,amount0Max:n.amount0Max,amount1Max:n.amount1Max}],gas:e>2000000n?2000000n:e});return await (0,x.n)(h,{hash:t})}},onSuccess:(n,a)=>{var o;t&&(null==e||null==(o=e.onStatusChange)||o.call(e,"success","Fees collected successfully"),m.M.afterCollectFees(t,a.tokenId.toString()).forEach(e=>{k.invalidateQueries({queryKey:e,exact:!1}),k.refetchQueries({queryKey:e,exact:!1})}),k.invalidateQueries({queryKey:["liquidity-depth"],exact:!1}),k.refetchQueries({queryKey:["liquidity-depth"],exact:!1}))},onError:t=>{var n;null==e||null==(n=e.onStatusChange)||n.call(e,"error",t.message||"Failed to collect fees",t)}})},A=(e,t,n)=>{let{address:a}=(0,b.useAccount)(),{data:o,isLoading:l,error:r,refetch:d}=((e,t)=>{let n=(0,w.useConfig)(),{address:a}=(0,b.useAccount)(),o=t||a||"0x0000000000000000000000000000000000000000";return(0,c.I)({queryKey:["pendingFees",e,o],queryFn:async()=>{if(!e)throw Error("Token ID is required");try{let t=(0,s.PF)("NFT_POSITION_MANAGER"),a=await (0,g.v)(n,{address:t.address,abi:t.abi,account:o,functionName:"collect",args:[{tokenId:(0,h.uU)(e),recipient:o,amount0Max:k.iB,amount1Max:k.iB}]});return{amount0:(0,v.cK)(a.result[0]),amount1:(0,v.cK)(a.result[1]),amount0BigInt:a.result[0],amount1BigInt:a.result[1]}}catch(e){throw console.error("Error simulating fee collection:",e),e}},enabled:!!e,refetchInterval:6e4,refetchIntervalInBackground:!1,staleTime:3e4,refetchOnWindowFocus:!1})})(e.tokenId,a),u=function(e,t,a){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=Number((0,y.J)(e,t||18)),l="".concat((0,i.cG)((0,i.cG)(s).toPrecision(6)).toString(10)," ").concat(a),r=s*o*n;return{formatted:l,value:s,usdValue:r,valueInBigInt:e}};if(!o||!t)return{token0:{formatted:"0",value:0,usdValue:0,valueInBigInt:0n},token1:{formatted:"0",value:0,usdValue:0,valueInBigInt:0n},totalUsdValue:0,hasActualFees:!1,isLoading:l,error:r,refetch:d};let m=u(o.amount0BigInt,t.tokenA.decimals||18,t.tokenA.symbol||"",e.token0DerivedETH),p=u(o.amount1BigInt,t.tokenB.decimals||18,t.tokenB.symbol||"",e.token1DerivedETH),x=m.usdValue+p.usdValue,f=m.value>0||p.value>0;return{token0:m,token1:p,totalUsdValue:x,hasActualFees:f,isLoading:l,error:r,refetch:d}}},18938:(e,t,n)=>{n.d(t,{A:()=>I});var a=n(85520),o=n(81868),i=n(98765),s=n(26897),l=n(26123),r=n(25154),d=n(91804),u=n(24404),c=n(32205),m=n(55249);let p=d.forwardRef((e,t)=>{var n;let{className:o,valueLabelFn:i,value:s,...l}=e,[r,p]=d.useState(!1),x=Array.isArray(s)&&null!=(n=s[0])?n:0,g=()=>p(!0),f=()=>p(!1),h=(0,a.jsx)(u.zi,{className:"block h-4 w-4 rounded-full border-2 border-secondary-foreground bg-background shadow-sm transition-transform focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-secondary-foreground disabled:pointer-events-none disabled:opacity-50",onPointerDown:g,onPointerUp:f,onPointerCancel:f,onMouseEnter:g,onMouseLeave:f}),k=i?(0,a.jsxs)(m.m_,{open:r,children:[(0,a.jsx)(m.k$,{asChild:!0,children:h}),(0,a.jsx)(m.ZI,{side:"top",className:"bg-muted text-muted-foreground px-3 h-[26px] flex items-center rounded-lg text-sm font-medium border",children:i(x)})]}
1):h,v=(0,a.jsxs)(u.bL,{ref:t,className:(0,c.cn)("relative flex w-full touch-none select-none items-center",o),value:s,...l,children:[(0,a.jsx)(u.CC,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:(0,a.jsx)(u.Q6,{className:"absolute h-full bg-secondary-foreground"})}),k]});return i?(0,a.jsx)(m.Bc,{children:v}):v});p.displayName=u.bL.displayName;var x=n(260),g=n(64348),f=n(8971),h=n(62604),k=n(44995),v=n(32492);let y=e=>{if(!e||isNaN(e))return 2;let t=Math.abs(e);return t>=1?2:Math.min(8,Math.ceil(-Math.log10(t))+2)};var b=n(42447);let N=e=>{let{value:t,onValueChange:n}=e,o=""===t?0:parseFloat(t);return(0,a.jsx)("div",{className:"flex w-full flex-col",children:(0,a.jsxs)("div",{className:"relative w-full px-2",children:[(0,a.jsx)(p,{min:0,max:100,step:5,value:[o],onValueChange:e=>{var t;return n((null==(t=e[0])?void 0:t.toString())||"")},valueLabelFn:e=>"".concat(e,"%"),className:"w-full"}),(0,a.jsx)("div",{className:"flex justify-between mt-2 px-0.5",children:[0,25,50,75,100].map(e=>(0,a.jsxs)("span",{className:"text-xs text-white/40 font-medium",children:[e,"%"]},e))})]})})},w=(0,d.forwardRef)((e,t)=>{var n;let{position:u,isInRange:c,onReview:m,unclaimedFeesUSD:p={amount0:{formatted:"",value:0,usdValue:0,valueInBigInt:0n},amount1:{formatted:"",value:0,usdValue:0,valueInBigInt:0n}}}=e,[w,I]=(0,d.useState)(!1);(0,d.useImperativeHandle)(t,()=>({openModal:()=>I(!0)}));let C=(0,h.TH)(),{data:T}=(0,x.u)(g.$E,"0x0000000000000000000000000000000000000000",{enabled:!0}),j=Array.isArray(T)?(null==(n=T[0])?void 0:n.price)||0:(null==T?void 0:T.price)||0,[E,L]=(0,d.useState)(""),{token0:S,token1:B,isLoading:F}=(0,i.DF)(u.token0,u.token1),q=(null==S?void 0:S.address)==="0x0000000000000000000000000000000000000000",D=(null==B?void 0:B.address)==="0x0000000000000000000000000000000000000000",U=q?S:(0,k.V)(S,C),M=D?B:(0,k.V)(B,C),R=(e,t)=>e&&t?(0,f.cG)(e).multipliedBy((0,f.cG)(t)).dividedBy(100):null,P=R(u.amount0,E),H=R(u.amount1,E),[O,_]=(0,d.useMemo)(()=>{var e,t;return[(null!=(e=null==u?void 0:u.token0DerivedETH)?e:0)*j,(null!=(t=null==u?void 0:u.token1DerivedETH)?t:0)*j]},[null==u?void 0:u.token0DerivedETH,null==u?void 0:u.token1DerivedETH,j]);return(0,a.jsxs)("div",{className:"relative flex shrink-0",children:[(0,a.jsx)(s.A,{size:"sm",variant:"ghost",className:"bg-border hover:bg-border px-3 w-fit h-9 text-base font-medium",onClick:()=>I(!0),children:"Remove"}),(0,a.jsxs)(l.A,{title:"Remove Liquidity",isOpen:w,onClose:()=>I(!1),width:"w-full md:w-[420px]",modalClassName:"rounded-[20px]",titleClassName:"px-2",contentClassName:"px-3 md:px-3 pt-5 pb-3",children:[(0,a.jsx)(b.N,{tokenA:U,tokenB:M,fee:u.fee,isInRange:c,isLoading:F,className:"mx-2"}),(0,a.jsx)(N,{value:E,onValueChange:L}),(0,a.jsx)(o.a,{className:"px-2",tokenA:U,tokenB:M,details:[{label:"Token A",value:"100"},{label:"Token B",value:"200"}],detailsFn:(e,t,n,i)=>{let s=[e,t],l=[u.amount0,u.amount1].map(e=>(0,f.cG)(null!=e?e:0n)),d=[P,H].map((e,t)=>l[t].minus(null!=e?e:0n));return(0,a.jsx)(o.L,{tokenA:e,tokenB:t,labelFn:()=>"".concat(s[i].symbol," position"),valueFn:()=>(0,a.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,a.jsx)(r.A,{symbol:s[i].symbol,logoURI:s[i].logoURI,className:"size-4"}),(0,a.jsx)("span",{children:l[i].toPrecision(6)}),(0,a.jsx)("span",{children:"→"}),(0,a.jsx)("span",{children:d[i].toPrecision(6)})]})},i)}}),(0,a.jsx)(s.A,{variant:"primary",disabled:!E||0>=parseFloat(E),className:"w-full !rounded-[20px]",label:"Review",onClick:()=>{if(!E||0>=parseFloat(E))return void console.warn("Withdrawal amount is required");if(!S||!B)return;I(!1);let e=O&&_?(0,v.Ki)(O/_):"--",t=(0,a.jsx)(o.a,{className:"px-2",tokenA:U,tokenB:M,details:[{label:"Fees",value:"0"},{label:"Rate",value:"0"},{label:"Token A",value:"100"},{label:"Token B",value:"200"}],detailsFn:(t,n,i,s)=>{let l=[t,n],d=[u.amount0,u.amount1].map(e=>(0,f.cG)(null!=e?e:0n)),c=[P,H].map((e,t)=>d[t].minus(null!=e?e:0n)),m=[O,_].map((e,t)=>c[t].multipliedBy(e).toNumber());return s>=2?(0,a.jsx)(o.L,{tokenA:t,tokenB:n,labelFn:()=>"New ".concat(l[s-2].symbol," position"),valueFn:()=>(0,a.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,a.jsx)(r.A,{symbol:l[
1s-2].symbol,logoURI:l[s-2].logoURI,className:"size-4"}),(0,a.jsxs)("span",{children:[function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"display";switch(t){case"display":default:if(!e||isNaN(e))return"0";let n=y(e);return e<.01?e.toExponential(2):e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:n});case"input":if(!e||isNaN(e))return 0;let a=y(e);return Number(e.toFixed(a));case"calculation":return e}}(c[s-2].toNumber(),"display")," ",l[s-2].symbol]}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,v.az)(m[s-2],!1),")"]})]})},s):0===s&&(p.amount0.value>0||p.amount1.value>0)?(0,a.jsx)(A,{token0:t,token1:n,amount0:p.amount0,amount1:p.amount1},s):1===s?(0,a.jsx)(o.L,{tokenA:t,tokenB:n,labelFn:()=>"Rate",valueFn:()=>"1 ".concat(t.symbol," = ").concat(e," ").concat(n.symbol)},s):null}});m({tokenA:U,tokenB:M,amountA:(null==P?void 0:P.toString())||"0",amountB:(null==H?void 0:H.toString())||"0",additionalDetails:t,position:u,withdrawalPercentage:E,currentPrice:j})}})]})]})});w.displayName="RemoveLiquidity";let I=w,A=e=>{let{token0:t,token1:n,amount0:o,amount1:i}=e;return(0,a.jsxs)("div",{className:"flex flex-col gap-3 p-4 mb-4 rounded-lg bg-muted",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Includes uncollected fees:"}),o.value>0&&(0,a.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,a.jsx)(r.A,{symbol:t.symbol,logoURI:t.logoURI,className:"size-6"}),(0,a.jsxs)("span",{className:"text-lg text-foreground font-medium flex-1",children:["$",o.usdValue.toFixed(2)]}),(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:o.formatted})]}),i.value>0&&(0,a.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,a.jsx)(r.A,{symbol:n.symbol,logoURI:n.logoURI,className:"size-6"}),(0,a.jsxs)("span",{className:"text-lg text-foreground font-medium flex-1",children:["$",i.usdValue.toFixed(2)]}),(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:i.formatted})]})]})}},24763:(e,t,n)=>{n.d(t,{I:()=>d});var a=n(42184),o=n(87707),i=n(18934),s=n(91804);let l=(e,t)=>null==e?void 0:e.find(e=>e.address.toLowerCase()===t.toLowerCase()),r=(e,t,n,a)=>{let o={decimals:((e,t,n)=>{var a;let o=l(e,t);return(null==o?void 0:o.decimals)===void 0||isNaN(Number(o.decimals))?(null==n||null==(a=n.formattedToken)?void 0:a.decimals)===void 0||isNaN(Number(n.formattedToken.decimals))?18:Number(n.formattedToken.decimals):Number(o.decimals)})(e,t,n),valueUSD:((e,t,n,a)=>{var o;if(null==n?void 0:n.valueUSD)return n.valueUSD;let i=l(e,t);return(null==i?void 0:i.priceUsd)?i.priceUsd:(null==a||null==(o=a.formattedToken)?void 0:o.valueUSD)?a.formattedToken.valueUSD:0})(e,t,a,n),logoURI:((e,t)=>{let n=l(e,t);return(null==n?void 0:n.logoURI)||""})(e,t)};return n.formattedToken?{...n.formattedToken,..."WETH"===n.formattedToken.symbol?{symbol:"ETH",name:"Ethereum"}:{},...o}:{address:t,symbol:"Unknown",name:"Unknown Token",balance:0,chainId:1,...o}},d=(e,t)=>{let[n,l]=(0,s.useState)(),{data:d}=(0,o.NO)(),u=(0,s.useMemo)(()=>d,[d]),{data:c,isLoading:m}=(0,a.s)({address:e||"",options:{enabled:!!e,staleTime:6e4}}),{data:p,isLoading:x}=(0,a.s)({address:t||"",options:{enabled:!!t,staleTime:6e4}}),{data:g}=(0,i.Y)(e,{enabled:!!e&&!(null==u?void 0:u.some(t=>t.address.toLowerCase()===e.toLowerCase()))}),{data:f}=(0,i.Y)(t,{enabled:!!t&&!(null==u?void 0:u.some(e=>e.address.toLowerCase()===t.toLowerCase()))});return(0,s.useEffect)(()=>{if(c&&p)l({tokenA:r(u,e,c,g),tokenB:r(u,t,p,f)})},[c,p,e,t,g,f,u]),{formattedTokens:n,isLoading:m||x}}},33259:(e,t,n)=>{n.d(t,{A:()=>p});var a=n(85520),o=n(91804),i=n(26897),s=n(26123),l=n(25154),r=n(98088),d=n(8971),u=n(260),c=n(1786),m=n(34495);let p=e=>{let{isOpen:t,onClose:n,title:p,actionLabel:x,tokenA:g,amountA:f,tokenB:h,amountB:k,position:v,details:y,onConfirm:b,isProcessing:N=!1,processingText:w="Processing...",disabled:I=!1,hideCloseOnProcessing:A=!0}=e,C=x||p,{token0DerivedETH:T,token1DerivedETH:j}=v||{},{chainId:E}=(0,c.useAccount)(),{data:L}=(0,u.u)(E||m.$E,"0x0000000000000000000000000000000000000000",{enabled:!0}),S=L&&!Array.isArray(L)?L.price:0,[B,F]=(0,o.useMemo)(()=>[(0,d.cG)(f).multipliedBy(T||0).multipliedBy(S).toFixed(2),(0,d.cG)(k).multipliedBy(j||0).multipliedBy(S).toFixed(2)],[f,k,T,j,L]);return(0,a.jsxs)(s.A,{isOpen:t,onClose:()=>{A&&N||n()},title:p,width:"w-full md:w-[420px]",modalClassName:"rounded-[20px]",titleClassName:"px-2",contentClassName:"px-3 md:px-3 pt-5 pb-3 gap-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 mx-2 mb-2",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-muted-foreground",children:C}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("span",{className:"text-lg font-bold text-foreground",children:[(0,r.NJ)(parseFloat(f)).display," ",g.symbol]}),(0,a.jsxs)("span",{className:"text-base text-muted-foreground",children:["$",B]})]}),(0,a.jsx)(l.A,{logoURI:g.logoURI,symbol:g.symbol,className:"h-12 w-12 rounded-full"})]}),h&&k&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("span",{className:"text-lg font-bold text-foreground",children:[(0,r.NJ)(parseFloat(k)).display," ",h.symbol]}),(0,a.jsxs)("span",{className:"text-base text-muted-foreground",children:["$",F]})]}),(0,a.jsx)(l.A,{logoURI:h.logoURI,symbol:h.symbol,className:"h-12 w-12 rounded-full"})]})]}),!!y&&y,(0,a.jsx)(i.A,{variant:"primary",label:N?w:"Confirm",onClick:b,disabled:N||I,loading:N,className:"w-full !rou
1nded-[20px] mt-2"})]})}},38158:(e,t,n)=>{n.d(t,{N:()=>a});function a(e,t,n){return Math.pow(1.0001,e)*Math.pow(10,t-n)}},40946:(e,t,n)=>{n.d(t,{T:()=>x});var a=n(91804),o=n(1786),i=n(17784),s=n(29798),l=n(21738),r=n(56198),d=n(70331),u=n(2939),c=n(34495),m=n(64348),p=n(72310);function x(){let{address:e,chainId:t}=(0,o.useAccount)(),{writeContractAsync:n}=(0,i.useWriteContract)(),x=(0,d.jE)(),[f,h]=(0,a.useState)({state:"idle",currentStep:0,totalSteps:0,stepDescription:""}),k=(0,r.PF)("NFT_POSITION_MANAGER"),v=(0,a.useCallback)((e,n)=>{let a=[],o=(0,p.eU)(t||m.$E);e.forEach(e=>{a.push((0,s.p)({abi:c.xJ,functionName:"collect",args:[{tokenId:BigInt(e.tokenId),recipient:"0x0000000000000000000000000000000000000000",amount0Max:l.iB,amount1Max:l.iB}]}))});let i=new Set;return e.forEach(e=>{i.add(e.token0.toLowerCase()),i.add(e.token1.toLowerCase())}),i.forEach(e=>{e.toLowerCase()===o.address.toLowerCase()?a.push((0,s.p)({abi:c.xJ,functionName:"unwrapWETH9",args:[BigInt(0),n]})):a.push((0,s.p)({abi:c.xJ,functionName:"sweepToken",args:[e,BigInt(0),n]}))}),i.has(o.address.toLowerCase())&&a.push((0,s.p)({abi:c.xJ,functionName:"refundETH",args:[]})),a},[t]),y=(0,a.useCallback)(e=>{if(!e.length)throw new g("No positions provided","INVALID_POSITIONS");if(0===e.filter(e=>e.unclaimedFees.hasActualFees).length)throw new g("No positions have claimable fees","NO_CLAIMABLE_FEES")},[]);return{executeCollection:(0,a.useCallback)(async t=>{if(console.log("\uD83D\uDE80 EXECUTE COLLECTION CALLED:",{positionCount:t.positions.length,recipient:t.recipient,timestamp:new Date().toISOString()}),!e)throw new g("Wallet not connected","WALLET_NOT_CONNECTED");try{h(e=>({...e,state:"preparing",currentStep:1,totalSteps:3,stepDescription:"Validating positions with fees..."})),y(t.positions),h(e=>({...e,currentStep:2,stepDescription:"Preparing multicall for ".concat(t.positions.length," positions...")}));let a=v(t.positions,t.recipient);console.log("\uD83D\uDD25 BATCH COLLECT DEBUG:",{positionCount:t.positions.length,multicallOperations:a.length,operations:a,contractAddress:k.address}),h(e=>({...e,state:"executing",currentStep:3,stepDescription:"Executing single multicall with ".concat(a.length," operations...")}));let o=await n({address:k.address,abi:c.xJ,functionName:"multicall",args:[a],gas:BigInt(2e6)}),i=function(e){let t=e.reduce((e,t)=>e+t.unclaimedFees.totalUsdValue,0);return{token0:{amount:BigInt(0),symbol:"",usdValue:0},token1:{amount:BigInt(0),symbol:"",usdValue:0},totalUsdValue:t}}(t.positions);if(e){let n=t.positions.map(e=>e.tokenId);u.M.afterBatchCollect(e,n).forEach(e=>{x.invalidateQueries({queryKey:e,exact:!1}),x.refetchQueries({queryKey:e,exact:!1})}),x.invalidateQueries({queryKey:["liquidity-depth"],exact:!1}),x.refetchQueries({queryKey:["liquidity-depth"],exact:!1})}return h(e=>({...e,state:"confirmed",stepDescription:"Batch collection completed successfully!",transactionHash:o})),{transactionHash:o,totalCollected:i,positionsProcessed:t.positions.length}}catch(t){let e=t instanceof g?t:new g(t.message,"BATCH_COLLECTION_FAILED",{originalError:t});throw h(t=>({...t,state:"failed",stepDescription:"Batch collection failed",error:e})),e}},[e,n,k.address,y,v,x]),state:f,reset:(0,a.useCallback)(()=>{h({state:"idle",currentStep:0,totalSteps:0,stepDescription:""})},[]),isLoading:["preparing","executing"].includes(f.state),hasError:"failed"===f.state}}class g extends Error{constructor(e,t,n){super(e),this.code=t,this.context=n,this.name="DeFiError"}}},43786:(e,t,n)=>{n.d(t,{K:()=>c});var a=n(85520),o=n(26897),i=n(26123),s=n(25154),l=n(42447),r=n(98088),d=n(8971),u=n(91804);let c=e=>{let{isOpen:t,onClose:n,position:c,tokenA:m,tokenB:p,unclaimedFeeA:x,unclaimedFeeB:g,currentPrice:f,isInRange:h,onConfirm:k,isProcessing:v=!1,processingText:y="Claiming fees..."}=e,[b,N]=(0,u.useMemo)(()=>[(0,d.cG)(x).multipliedBy((0,d.cG)(c.token0DerivedETH||0)).multipliedBy((0,d.cG)(f)),(0,d.cG)(g).multipliedBy((0,d.cG)(c.token1DerivedETH||0)).multipliedBy((0,d.cG)(f))],[x,g,c.token0DerivedETH,c.token1DerivedETH,f]),w=0n===BigInt(c.liquidity);return(0,a.jsx)(i.A,{isOpen:t,onClose:()=>{v||n()},width:"w-full md:w-[420px]",modalClassName:"rounded-[20px]",contentClassName:"px-3 md:px-3 pt-6 pb-3 gap-3",titleClassName:"px-2",title:"Claim Fees",children:(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,a.jsx)(l.N,{tokenA:m,tokenB:p,fee:c.fee,isInRange:h,isClosed:w,className:"mx-2"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 mx-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(s.A,{logoURI:m.logoURI,symbol:m.symbol,className:"size-6"}),(0,a.jsxs)("span",{className:"text-lg font-medium text-foreground flex-1",children:["$",b.toFixed(2)]}),(0,a.jsxs)("span",{className:"text-sm text-muted-foreground text-right",children:[(0,r.NJ)(parseFloat(x)).display," ",m.symbol]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(s.A,{logoURI:p.logoURI,symbol:p.symbol,className:"size-6"}),(0,a.jsxs)("span",{className:"text-lg font-medium text-foreground flex-1",children:["$",N.toFixed(2)]}),(0,a.jsxs)("span",{className:"text-sm text-muted-foreground text-right",children:[(0,r.NJ)(parseFloat(g)).display," ",p.symbol]})]})]}),(0,a.jsx)(o.A,{variant:"primary",label:v?y:"Confirm",onClick:k,disabled:v,loading:v,className:"w-full !rou
1nded-[20px]"})]})})}},79180:(e,t,n)=>{n.d(t,{s:()=>w});var a=n(56198),o=n(70205),i=n(8971),s=n(70331),l=n(26283),r=n(2939),d=n(14515),u=n(3365),c=n(6040),m=n(1786),p=n(62289),x=n(78436),g=n(72310),f=n(26214),h=n(83381),k=n(29798),v=n(21738),y=n(34495),b=n(62604);let N=async(e,t)=>{var n,a;let{position:o,percentageToRemove:i,slippageTolerance:s}=t,l=parseFloat(i);if(isNaN(l)||l<0||l>100)throw Error("Invalid percentage value");let r=(0,b.TH)(),d=new f.ou(r,o.token0,o.token0Decimals||18),u=new f.ou(r,o.token1,o.token1Decimals||18);if(void 0===o.sqrtPriceX96||void 0===o.liquidity||void 0===o.currentTick)throw Error("Invalid position data");let c=(0,x.vA)(d,u,o.fee,o.sqrtPriceX96,o.liquidity,o.currentTick),m=new h.yX({pool:c,liquidity:o.liquidity.toString(),tickLower:o.tickLower,tickUpper:o.tickUpper}),p=new f.QE(Math.floor(100*s),1e4),N=Math.floor(Date.now()/1e3)+1200,w=Math.pow(10,(l.toString().split(".")[1]||"").length),I=Math.round(l*w),A=BigInt(m.liquidity.toString())*BigInt(I)/BigInt(100*w),{amount0:C,amount1:T}=new h.yX({pool:c,liquidity:A.toString(),tickLower:o.tickLower,tickUpper:o.tickUpper}).burnAmountsWithSlippage(p),j=(0,g.eU)(r),E=(null==(n=o.token0)?void 0:n.toLowerCase())===j.address.toLowerCase(),L=(null==(a=o.token1)?void 0:a.toLowerCase())===j.address.toLowerCase(),S=E||L,B=[];return B.push((0,k.p)({abi:y.xJ,functionName:"decreaseLiquidity",args:[{tokenId:BigInt(o.tokenId.toString()),liquidity:A,amount0Min:BigInt(C.toString()),amount1Min:BigInt(T.toString()),deadline:BigInt(N)}]})),B.push((0,k.p)({abi:y.xJ,functionName:"collect",args:[{tokenId:BigInt(o.tokenId.toString()),recipient:S?h.Y4:e,amount0Max:v.iB,amount1Max:v.iB}]})),S&&((E||L)&&B.push((0,k.p)({abi:y.xJ,functionName:"unwrapWETH9",args:[0n,e]})),E||B.push((0,k.p)({abi:y.xJ,functionName:"sweepToken",args:[o.token0,0n,e]})),L||B.push((0,k.p)({abi:y.xJ,functionName:"sweepToken",args:[o.token1,0n,e]}))),{calldata:(0,k.p)({abi:y.xJ,functionName:"multicall",args:[B]}),value:"0x0"}},w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"v3",t=arguments.length>1?arguments[1]:void 0,{address:n}=(0,m.useAccount)(),x=(0,p.useConfig)(),g=(0,s.jE)();return(0,l.n)({mutationFn:async s=>{if(!n)throw Error("Wallet not connected");let{onStatusChange:l}=t||{};if("v3"===e){null==l||l("preparing","Preparing to remove liquidity");let e=await N(n,s),{address:t}=(0,a.PF)("NFT_POSITION_MANAGER"),r=await (0,o.GX)(x,{to:t,data:e.calldata,value:(0,c.uU)(e.value)},50);null==l||l("removing","Removing liquidity");let m=await (0,d.v)(x,{to:t,data:e.calldata,value:(0,c.uU)(e.value),gas:r>2000000n?2000000n:r}),p=await (0,u.n)(x,{hash:m});try{s.position&&(s.position.amount0&&(0,i.S8)(s.position.amount0,s.position.token0Decimals||18),s.position.amount1&&(0,i.S8)(s.position.amount1,s.position.token1Decimals||18),"".concat(s.position.token0Symbol,"/").concat(s.position.token1Symbol),parseFloat(s.percentageToRemove||"0"),s.position.tokenId,s.position.fee)}catch(e){}return null==l||l("success","Liquidity removed"),p.transactionHash}{let{token0:e,token1:t,liquidity:n,amount0Min:a,amount1Min:o,deadline:i,to:l}=s;throw Error("V2 liquidity removal is no longer supported")}},onSuccess:(e,t)=>{n&&(r.M.afterRemoveLiquidity(n,t.position.tokenId.toString()).forEach(e=>{g.invalidateQueries({queryKey:e,exact:!1}),g.refetchQueries({queryKey:e,exact:!1})}),g.invalidateQueries({queryKey:["poolStats"],exact:!1}),g.refetchQueries({queryKey:["poolStats"],exact:!1}),g.invalidateQueries({queryKey:["liquidity-depth"],exact:!1}),g.refetchQueries({queryKey:["liquidity-depth"],exact:!1}))},onError:e=>{let{onStatusChange:n}=t||{};null==n||n("error",e.message||"Transaction failed",e)}})}},81868:(e,t,n)=>{n.d(t,{L:()=>i,a:()=>s});var a=n(85520),o=n(32205);let i=e=>{let{tokenA:t,tokenB:n,labelFn:o,valueFn:i}=e;return(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-muted-foreground shrink-0",children:o(t,n)}),(0,a.jsx)("span",{className:"text-foreground",children:i(t,n)})]})},s=e=>{let{tokenA:t,tokenB:n,details:s,detailsFn:l,className:r}=e;return(0,a.jsx)("div",{className:(0,o.cn)("flex flex-col gap-2 text-sm",r),children:l?s&&s.map((e,a)=>l(t,n,e,a)):s&&s.map((e,o)=>(0,a.jsx)(i,{tokenA:t,tokenB:n,labelFn:(t,n)=>e.label,valueFn:(t,n)=>e.value},o))})}},93519:(e,t,n)=>{n.d(t,{Ey:()=>i});var a=n(62604),o=n(26214);n(26419);let i=(e,t,n,i)=>{let s=(0,a.TH)();return new o.ou(s,e,t,n||"TOKEN",i||"Unknown Token")}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.