1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="df05e998-c444-4d9c-89f7-e4ef0799d5e6",e._sentryDebugIdIdentifier="sentry-dbid-df05e998-c444-4d9c-89f7-e4ef0799d5e6")}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2471,6330,7817,9252],{2812:(e,t,n)=>{"use strict";n.d(t,{I:()=>i.I0});var i=n(602845)},11080:(e,t,n)=>{"use strict";n.d(t,{E:()=>x,P:()=>m});var i=n(827666),r=n(25963),l=n(203907),o=n(440589),a=n(924627),s=n(623208),d=n(228876),u=n(290589),c=n(659197),p=n(619749);let m=(e,t)=>{if(e.liquidity.isZero())return l.$.CLOSED;if(t)try{if("number"==typeof t.tickCurrent){if(t.tickCurrent<e.tickLower||t.tickCurrent>=e.tickUpper)return l.$.INACTIVE;return l.$.ACTIVE}if(t.price>0){let{price:n}=t,i=Math.floor(Math.log(n)/Math.log(1.0001));if(i<e.tickLower||i>=e.tickUpper)return l.$.INACTIVE;return l.$.ACTIVE}let{amountA:n,amountB:r}=i.ZZh.getAmountsFromLiquidity({poolInfo:t,ownerPosition:e,liquidity:e.liquidity,slippage:0,add:!1,epochInfo:{epoch:0,slotIndex:0,slotsInEpoch:0,absoluteSlot:0}});if(n.amount.isZero()||r.amount.isZero())return l.$.INACTIVE;return l.$.ACTIVE}catch(e){console.warn("Error calculating Solana position status:",e)}return l.$.ACTIVE},x=e=>{let{selectedNetwork:t,selectedTokens:n,positionStatus:i,farmsOnly:x,accountOverride:h}=e,{publicKey:f}=(0,a.v)(),v=(0,r.useMemo)(()=>null!=h?h:null==f?void 0:f.toBase58(),[h,f]),{data:y,isLoading:g}=(0,o.o$)(v),A=(0,r.useMemo)(()=>(null==y?void 0:y.map(e=>e.poolId.toBase58()))||[],[y]),b=(0,s._L)(A),{loading:w}=(0,u.t)((0,r.useMemo)(()=>b.filter(e=>!!e),[b])),j=(0,r.useMemo)(()=>new Map(b.filter(e=>!!e).map(e=>[e.id,e])),[b]),k=(0,r.useMemo)(()=>null==y?void 0:y.map(e=>{let t=j.get(e.poolId.toBase58());return Object.assign(e,{status:m(e,t),protocol:c.Zs.V3,chainId:d.Cb.SOLANA,token0:t?(0,p.ph)(null==t?void 0:t.mintA):void 0,token1:t?(0,p.ph)(null==t?void 0:t.mintB):void 0})}),[y,j]),C=(0,r.useMemo)(()=>null==k?void 0:k.filter(e=>{let r=t.includes(d.Cb.SOLANA),o=j.get(e.poolId.toBase58());if(!o)return!1;let a=!(null==n?void 0:n.length)||n.some(e=>e===`${d.Cb.SOLANA}:${o.mintA.address}`||e===`${d.Cb.SOLANA}:${o.mintB.address}`),s=i===l.$.ALL||e.status===i,u=!x||o.isFarming&&e.status===l.$.ACTIVE;return r&&a&&s&&u}),[k,t,n,i,x,j]);return{solanaLoading:g||w,solanaPositions:(0,r.useMemo)(()=>C?[...C].sort((e,t)=>e.status-t.status):[],[C]),poolsLength:j.size}}},12563:(e,t,n)=>{"use strict";n.d(t,{Fq:()=>x,VB:()=>c,mO:()=>d,ot:()=>h,yn:()=>u});var i=n(350979),r=n(501823),l=n(605641),o=n(962478),a=n(796147),s=n(680797);let d=(0,s.I4)(r.A).withConfig({componentId:"sc-adb62600-0"})(["position:relative;flex-direction:column;justify-content:space-between;padding:1rem;"]);s.I4.div.withConfig({componentId:"sc-adb62600-1"})(["padding:2px;",""],e=>{let{clickable:t}=e;return t?(0,s.AH)(["&:hover{cursor:pointer;opacity:0.8;}"]):null});let u=(0,s.I4)(l.A).withConfig({componentId:"sc-adb62600-2"})(["color:",";"],e=>{let{theme:t,severity:n}=e;return 3===n||4===n?t.colors.failure:2===n?t.colors.warning:1===n?t.colors.text:t.colors.positive60}),c=s.I4.button.withConfig({componentId:"sc-adb62600-3"})(["height:22px;width:22px;background-color:",";border:none;border-radius:50%;padding:0.2rem;font-size:0.875rem;font-weight:400;margin-left:0.4rem;cursor:pointer;color:",";display:flex;justify-content:center;align-items:center;float:right;&:hover{background-color:",";}&:focus{background-color:",";outline:none;}"],e=>{let{theme:t}=e;return t.colors.background},e=>{let{theme:t}=e;return t.colors.text},e=>{let{theme:t}=e;return t.colors.dropdown},e=>{let{theme:t}=e;return t.colors.dropdown});(0,s.I4)(l.A).attrs({ellipsis:!0}).withConfig({componentId:"sc-adb62600-4"})(["width:220px;"]);let p=s.I4.div.withConfig({componentId:"sc-adb62600-5"})(["background-color:",";border-radius:1rem;display:flex;align-items:center;font-size:0.825rem;width:100%;padding:3rem 1.25rem 1rem 1rem;margin-top:-2rem;color:",";z-index:-1;p{padding:0;margin:0;font-weight:500;}"],e=>{let{theme:t}=e;return`${t.colors.failure33}`},e=>{let{theme:t}=e;return t.colors.failure}
1),m=s.I4.div.withConfig({componentId:"sc-adb62600-6"})(["background-color:",";display:flex;align-items:center;justify-content:center;margin-right:12px;border-radius:12px;min-width:48px;height:48px;"],e=>{let{theme:t}=e;return`${t.colors.failure33}`});function x(e){let{error:t}=e;return(0,i.jsxs)(p,{children:[(0,i.jsx)(m,{children:(0,i.jsx)(o.A,{width:"24px"})}),(0,i.jsx)("p",{children:t})]})}let h=(0,s.I4)(a.mm).withConfig({componentId:"sc-adb62600-7"})(["background-color:",";padding:0.5rem;border-radius:12px;margin-top:8px;"],e=>{let{theme:t}=e;return`${t.colors.warning33}`})},13978:(e,t,n)=>{"use strict";n.d(t,{O:()=>d});var i=n(25963),r=n(662928),l=n(126294),o=n(529208),a=n(91168);async function s(e){try{let t=await fetch(`https://sol-explorer.pancakeswap.com/api/cached/v1/pools/line/position?poolId=${e}`);if(!t.ok)throw Error(`API request failed: ${t.status}`);let n=await t.json(),i=[];return n.line?i=n.line:n.data&&n.data.line?i=n.data.line:Array.isArray(n)&&(i=n),i.map(e=>({liquidity:parseFloat(e.liquidity),price0:parseFloat(e.price),price1:parseFloat(new a.A(1).div(e.price).toString()),tick:e.tick}))}catch(e){return console.error("Error fetching pool chart data:",e),[]}}function d(e){let t=(0,i.useMemo)(()=>e,[e]),{data:n,isLoading:a,error:d}=(0,r.I)({queryKey:["solanaPoolChartData",t],queryFn:()=>s(e),enabled:!!e,placeholderData:l.rX,refetchInterval:o.IX});return(0,i.useMemo)(()=>n?{isLoading:a,error:d,formattedData:n}:{isLoading:a,error:d,formattedData:[]},[n,a,d])}},20664:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var i=n(350979);n(25963);var r=n(680797),l=n(428089),o=n(282304),a=n(312680),s=n(966983),d=n(118142);let u=r.I4.div.withConfig({componentId:"sc-10f99794-0"})(["position:absolute;top:16px;left:calc(50% - 18px);width:36px;height:4px;background-color:",";opacity:0.1;"],e=>{let{theme:t}=e;return t.colors.v2Inverse}),c=e=>{let{drawerContainerStyle:t={},content:n,isOpen:r,setIsOpen:c,hideCloseButton:p=!1}=e;return(0,i.jsx)(a.aF,{isOpen:r,onDismiss:()=>c(!1),closeOnOverlayClick:!0,children:(0,i.jsx)(o.FQ,{onDismiss:()=>c(!1),children:(0,i.jsxs)(d.x1,{style:t,children:[p?(0,i.jsx)(u,{}):(0,i.jsx)(l.Ay,{position:"absolute",right:"24px",top:"24px",children:(0,i.jsx)(s.s_,{onDismiss:()=>c(!1)})}),n]})})})}},21354:(e,t,n)=>{"use strict";n.d(t,{CT:()=>o,X3:()=>a,gI:()=>s,p9:()=>d});var i=n(680797),r=n(605641),l=n(995315);let o=i.Ay.div.withConfig({componentId:"sc-83e18422-0"})(["display:flex;gap:8px;font-size:16px;font-weight:600;flex-direction:",";"],e=>{let{$isMobile:t}=e;return t?"column":"row"}),a=i.Ay.div.withConfig({componentId:"sc-83e18422-1"})(["display:flex;flex-direction:column;gap:8px;font-size:12px;font-weight:400;"]),s=(0,i.Ay)(r.A).withConfig({componentId:"sc-83e18422-2"})(["color:",";font-weight:600;font-size:12px;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),d=(0,i.Ay)(l.A).withConfig({componentId:"sc-83e18422-3"})(["position:absolute;right:0;top:0;padding:16px;"])},23275:(e,t,n)=>{"use strict";n.d(t,{$:()=>o});var i=n(985148),r=n(118708);let l=(0,i.eU)(!1),o=()=>(0,r.fp)(l)},23940:(e,t,n)=>{e.exports=n(989601)()},34334:(e,t,n)=>{"use strict";n.d(t,{_:()=>d});var i=n(350979),r=n(311560),l=n(168927),o=n(970645),a=n(12563),s=n(852076);function d(e){let{slippage:t,loading:n=!1,...d}=e,u=t?t.lessThan(o.u4)||t.equalTo(0)?"<0.01%":`${t.toFixed(2,{groupSeparator:""},r.VS.ROUND_DOWN)}%`:"-",c=n?(0,i.jsx)(l.A,{}):u;return(0,i.jsx)(a.yn,{severity:t?(0,s.Y9)(t):0,...d,children:c})}},35075:(e,t,n)=>{"use strict";n.d(t,{$:()=>p});var i=n(350979),r=n(659197),l=n(796147),o=n(995315),a=n(575058),s=n(893001),d=n(660582),u=n(573271),c=n(203907);let p=e=>{let{poolInfo:t,currency0:n,currency1:p,position:m}=e;return(0,i.jsxs)(l.mm,{gap:"16px",mb:"16px",children:[(0,i.jsxs)(o.A,{gap:"16px",alignItems:"center",children:[(0,i.jsx)(d.g,{size:40,currency0:n,currency1:p,showChainLogoCurrency1:!0,margin:!1,innerMargin:"-8px"}),(0,i.jsxs)(o.A,{gap:"4px",alignItems:"center",children:[(0,i.jsx)(a.A,{as:"h2",children:t.mintA.symbol}),(0,i.jsx)(a.A,{as:"h2",color:"textSubtle",children:"/"}),(0,i.jsx)(a.A,{as:"h2",children:t.mintB.symbol})]}),(0,i.jsx)(s.T,{type:r.Zs.V3,fee:t.feeRate,denominator:1})]}),(0,i.jsx)(o.A,{gap:"16px",alignItems:"center",children:(0,i.jsx)(u.K,{scale:"sm",lowContrast:!0,removed:m.liquidity.isZero(),outOfRange:m.status===c.$.INACTIVE,protocol:r.Zs.V3})})]})}},38866:(e,t,n)=>{"use strict";n.d(t,{B:()=>nD});var i=n(350979),r=n(659197),l=n(769932),o=n(796259),a=n(312680),s=n(475690),d=n(995315),u=n(27313),c=n(810498),p=n(401368),m=n(25963),x=n(680797),h=n(
1501823),f=n(554945),v=n(428089),y=n(979332),g=n(228876),A=n(364327);function b(e,t){let n=(0,u.jE)(t),i=n.getQueryCache();return m.useSyncExternalStore(m.useCallback(e=>i.subscribe(A.j.batchCalls(e)),[i]),()=>n.isFetching(e),()=>n.isFetching(e))}var w=n(737982),j=n(573271),k=n(671449),C=n(762971),I=n(944715),S=n(42142),R=n(437862),E=n(670420),M=n(605641),N=n(660582);function P(e){var t,n;let{currency0:r,currency1:l,feeTierDisplay:o,rangeTags:a,aprDisplay:s}=e,u=r.isToken&&null!=(t=(0,E.U$)(r))?t:r,c=l.isToken&&null!=(n=(0,E.U$)(l))?n:l;return(0,i.jsxs)(v.Ay,{children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsx)(N.g,{currency0:u,currency1:c,showChainLogoCurrency1:!0,size:34,innerMargin:"-8px"}),(0,i.jsxs)(d.A,{gap:"2px",alignItems:"center",mb:"1px",style:{minWidth:0},children:[(0,i.jsx)(M.A,{fontSize:"20px",bold:!0,style:{wordBreak:"break-word"},children:u.symbol}),(0,i.jsx)(M.A,{fontSize:"20px",color:"textSubtle",bold:!0,children:"/"}),(0,i.jsx)(M.A,{fontSize:"20px",bold:!0,style:{wordBreak:"break-word"},children:c.symbol})]}),(0,i.jsx)(v.Ay,{children:o})]}),(0,i.jsxs)(d.A,{mt:"8px",gap:"4px",alignItems:"center",children:[a," ",s]})]})}var T=n(24153),U=n(28192),B=n(770773),D=n(557423),F=n(823585),q=n(862373),L=n(53847),O=n(494350),_=n(701150),$=n(261803),Y=n(687287),z=n(810286);let V="80px";function Z(e){var t,n,r,a;let{currency0:s,currency1:u,currency0Amount:c,currency0NewAmount:p,currency1Amount:m,currency1NewAmount:x,currency0AmountRaw:h,currency0NewAmountRaw:f,currency1AmountRaw:v,currency1NewAmountRaw:y,totalPositionUsd:g,totalPositionNewUsd:A,amountUsd:b,amountUsdLabel:w,feeValue0:j,feeValue1:k,feesEarnedUsd:C}=e,{t:I}=(0,l.A)(),S=(0,Y.tT)(j),R=(0,Y.tT)(k),E=S?(0,$.O)({currencyAmount:S}):"0",N=R?(0,$.O)({currencyAmount:R}):"0",P=!!((null==j?void 0:j.greaterThan(0))||(null==k?void 0:k.greaterThan(0)));return(0,i.jsxs)(_.k,{mt:"16px",padding:"16px",borderRadius:"24px",style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsxs)(T.JA,{children:[(0,i.jsx)(o.y,{children:I("Position")}),(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:I("Current")}),(0,i.jsx)(O.A,{color:"textSubtle",width:"16px",mt:"2px"}),(0,i.jsx)(M.A,{color:"textSubtle",minWidth:V,small:!0,children:I("New Balance")})]})]}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",children:[(0,i.jsx)(_.Z,{currency:s,size:"24px"}),(0,i.jsx)(M.A,{mt:"2px",color:"textSubtle",small:!0,children:null!=(t=s.symbol)?t:"UNKNOWN"})]}),(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(z.g3,{currency:s,rawDisplay:h,small:!0,children:c}),(0,i.jsx)(O.A,{color:"textSubtle",width:"16px",mt:"2px"}),(0,i.jsx)(z.g3,{currency:s,rawDisplay:0===Number(p)?void 0:f,minWidth:V,textAlign:"right",small:!0,children:0===Number(p)?"0":p})]})]}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",children:[(0,i.jsx)(_.Z,{currency:u,size:"24px"}),(0,i.jsx)(M.A,{mt:"2px",color:"textSubtle",small:!0,children:null!=(n=u.symbol)?n:"UNKNOWN"})]}),(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(z.g3,{currency:u,rawDisplay:v,small:!0,children:m}),(0,i.jsx)(O.A,{color:"textSubtle",width:"16px",mt:"2px"}),(0,i.jsx)(z.g3,{currency:u,rawDisplay:0===Number(x)?void 0:y,minWidth:V,textAlign:"right",small:!0,children:0===Number(x)?"0":x})]})]}),(0,i.jsxs)(T.JA,{mt:"8px",gap:"8px",children:[(0,i.jsx)(o.y,{children:I("Total Position Value (USD)")}),(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(M.A,{small:!0,children:g}),(0,i.jsx)(O.A,{color:"textSubtle",width:"16px",mt:"2px"}),(0,i.jsx)(M.A,{minWidth:V,textAlign:"right",small:!0,children:A})]})]}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:null!=w?w:I("Total removed value (USD)")}),(0,i.jsx)(M.A,{minWidth:V,textAlign:"right",small:!0,children:b})]}),P?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o.y,{mt:"8px",children:I("Fees Earned")}),(null==j?void 0:j.greaterThan(0))?(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",children:[(0,i.jsx)(_.Z,{currency:j.currency,size:"24px"}),(0,i.jsx)(M.A,{mt:"2px",color:"textSubtle",small:!0,children:null!=(r=j.currency.symbol)?r:"UNKNOWN"})]}),(0,i.jsx)(M.A,{minWidth:V,textAlign:"right",small:!0,children:E})]}):null,(null==k?void 0:k.greaterThan(0))?(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",children:[(0,i.jsx)(_.Z,{currency:k.currency,size:"24px"}),(0,i.jsx)(M.A,{mt:"2px",color:"textSubtle",small:!0,children:null!=(a=k.currency.symbol)?a:"UNKNOWN"})]}),(0,i.jsx)(M.A,{minWidth:V,textAlign:"right",small:!0,children:N})]}):null,(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:I("Total fees earned value (USD)")}),(0,i.jsx)(M.A,{minWidth:V,textAlign:"right",small:!0,children:null!=C?C:"$0.00"})]})]}):null]})}var W=n(18201),H=n(610564),Q=n(23644),G=n(54753),K=n(293765),X=n(968349),J=n(262453),ee=n(748520),et=n(52451),en=n(207014),ei=n(178852),er=n(241439),el=n(83549
10),eo=n(918279),ea=n(745332),es=n(512165),ed=n(655727),eu=n(645444),ec=n(265394),ep=n(732170),em=n(850611),ex=n(91168),eh=n(459587),ef=n(465840),ev=n(974134);let ey=e=>{var t,n,r,a,s;let{position:u,poolInfo:c}=e,{t:p}=(0,l.A)(),{account:x,chainId:h}=(0,X.W7)(),{switchNetworkIfNecessary:f,isLoading:y}=(0,ev.Hk)(),{token0:g,token1:A,token0Price:b,token1Price:w}=c,{pool:j}=(0,R.RI)(u);(0,Y.yx)(g),(0,Y.yx)(A);let k=(0,Y.wG)(g),C=(0,Y.wG)(A),I=(0,m.useMemo)(()=>({[el.O9.CURRENCY_A]:g,[el.O9.CURRENCY_B]:A}),[g,A]),S=u.chainId||c.chainId,[E,N]=(0,m.useState)(!1),P=(0,G.A)(u.tickLower,u.tickUpper,u.tickSpacing),O=(0,m.useMemo)(()=>(0,eu.lN)(u.tickLower,u.tickUpper,c.token0,c.token1,j||c,P,E),[u,j,c,P,E]),_=(0,m.useCallback)(()=>{N(!E)},[E,N]),$=(0,m.useMemo)(()=>!!j&&void 0!==u.tickLower&&void 0!==u.tickUpper&&(j.tickCurrent<u.tickLower||j.tickCurrent>u.tickUpper),[j,u.tickLower,u.tickUpper]),{amount0:z,amount1:V,deposit0Disabled:ey,deposit1Disabled:eg,invalidRange:eA}=(0,K.h)({token0:g,token1:A,tickCurrent:null==j?void 0:j.tickCurrent,tickLower:u.tickLower,tickUpper:u.tickUpper,sqrtRatioX96:null==j?void 0:j.sqrtRatioX96,liquidity:u.liquidity}),{inputAmountRaw:eb,outputAmountRaw:ew,inputBalance:ej,outputBalance:ek,onInputAmountChange:eC,onOutputAmountChange:eI,onInputPercentChange:eS,onOutputPercentChange:eR,inputAmount:eE,outputAmount:eM,lastEditCurrency:eN}=(0,es.o)({currency0:g,currency1:A,invalidRange:eA,tickLower:u.tickLower,tickUpper:u.tickUpper,outOfRange:$,poolKey:u.poolKey}),eP=(0,m.useMemo)(()=>({[el.O9.CURRENCY_A]:eE,[el.O9.CURRENCY_B]:eM}),[eE,eM]),eT=(0,m.useMemo)(()=>{let e=(0,er.r)(ej);return!!x&&!!eE&&!!e&&e.lessThan(eE)},[x,eE,ej]),eU=(0,m.useMemo)(()=>{let e=(0,er.r)(ek);return!!x&&!!eM&&!!e&&e.lessThan(eM)},[x,eM,ek]),{data:eB}=(0,eh.GB)(g,{enabled:!!g}),{data:eD}=(0,eh.GB)(A,{enabled:!!A}),eF=(0,m.useMemo)(()=>{if(!eB||!eD)return null;let e=(0,ex.g)(eB).multipliedBy((null==eE?void 0:eE.toExact())||0),t=(0,ex.g)(eD).multipliedBy((null==eM?void 0:eM.toExact())||0);return e.plus(t)},[eB,eD,eE,eM]),eq=null!=(t=k(z,6))?t:"0",eL=null!=(n=C(V,6))?n:"0",eO=(0,m.useMemo)(()=>{var e,t;return z?eE?null!=(t=k(z.wrapped.add(eE.wrapped),6))?t:"0":eq:null!=(e=k(eE,6))?e:"0"},[z,eE,eq,k]),e_=(0,m.useMemo)(()=>{var e,t;return V?eM?null!=(t=C(V.wrapped.add(eM.wrapped),6))?t:"0":eL:null!=(e=C(eM,6))?e:"0"},[V,eM,eL,C]),e$=null==z?void 0:z.toExact(),eY=null==V?void 0:V.toExact(),ez=(0,m.useMemo)(()=>z?eE?z.wrapped.add(eE.wrapped).toExact():z.toExact():null==eE?void 0:eE.toExact(),[z,eE]),eV=(0,m.useMemo)(()=>V?eM?V.wrapped.add(eM.wrapped).toExact():V.toExact():null==eM?void 0:eM.toExact(),[V,eM]),eZ=(0,m.useMemo)(()=>{if(!z||!V||!eB||!eD)return null;let e=(0,ex.g)(eB).multipliedBy(z.toExact()),t=(0,ex.g)(eD).multipliedBy(V.toExact());return e.plus(t)},[z,V,eB,eD]),eW=(0,m.useMemo)(()=>eZ?`$${eZ.toFormat(2)}`:"$0",[eZ]),eH=(0,m.useMemo)(()=>eZ?eF?`$${eZ.plus(eF).toFormat(2)}`:eW:"$0",[eZ,eF,eW]),eQ=!!((null==eE?void 0:eE.greaterThan(0))||(null==eM?void 0:eM.greaterThan(0))),eG=(0,et.PJ)(),{requirePermit:eK,requireApprove:eX,permit2Allowance:eJ,isApproving:e0,isPermitting:e1,permit:e2,revoke:e6,approve:e8}=(0,ee.$)((null==g?void 0:g.isNative)||null==eE?void 0:eE.wrapped,(null==j?void 0:j.poolType)?(0,en.B4)(j.poolType,S):void 0,{overrideChainId:S}),e3=(0,m.useMemo)(()=>e0?J.h$.PENDING:eX?J.h$.NOT_APPROVED:J.h$.APPROVED,[e0,eX]),{requirePermit:e9,requireApprove:e4,permit2Allowance:e5,isApproving:e7,isPermitting:te,permit:tt,revoke:tn,approve:ti}=(0,ee.$)((null==A?void 0:A.isNative)||null==eM?void 0:eM.wrapped,(null==j?void 0:j.poolType)?(0,en.B4)(j.poolType,S):void 0,{overrideChainId:S}),tr=(0,m.useMemo)(()=>e7?J.h$.PENDING:e4?J.h$.NOT_APPROVED:J.h$.APPROVED,[e7,e4]),tl=e3!==J.h$.APPROVED&&!!z,to=tr!==J.h$.APPROVED&&!!V,{errorMessage:ta}=(0,ea.P)({currencyA:g,currencyB:A,currencyAAmount:eE,currencyBAmount:eM,allowSingleSide:ey!==eg}),ts=!(eA||ta),[td]=(0,q.oA)()||[q.C0],tu=(null==g?void 0:g.isNative)?ep.Xd:null!=(r=null==g?void 0:g.address)?r:ep.Xd,tc=(null==A?void 0:A.isNative)?ep.Xd:null!=(a=null==A?void 0:A.address)?a:ep.Xd,{addCLLiquidity:tp,attemptingTx:tm}=(0,H.K)(null!=S?S:0,null!=x?x:ep.Xd,tu,tc),tx=(0,m.useCallback)(async()=>{var e,t;let n,i;if(!u||!u.tokenId||!j||!g||!A||!x||ey&&(null==eE?void 0:eE.greaterThan(0))||eg&&(null==eM?void 0:eM.greaterThan(0))||(null==eE?void 0:eE.equalTo(0))&&(null==eM?void 0:eM.equalTo(0)))return;try{(null==g?void 0:g.isNative)||!eK||(n=await e2()),(null==A?void 0:A.isNative)||!e9||(i=await tt())}catch(e){if(eG(e))return;throw e}let[,r]=eE?(0,ei.wQ)(eE,td):[0n,em.iB],[,l]=eM?(0,ei.wQ)(eM,td):[0n,em.iB];await tp({tokenId:BigInt(u.tokenId),currency0:g,currency1:A,lastEditCurrency:eN,pool
1Key:u.poolKey,tickLower:u.tickLower,tickUpper:u.tickUpper,sqrtPriceX96:j.sqrtRatioX96,amount0Desired:null!=(e=null==eE?void 0:eE.quotient)?e:0n,amount1Desired:null!=(t=null==eM?void 0:eM.quotient)?t:0n,recipient:x,amount0Max:r,amount1Max:l,deadline:BigInt(Math.floor(Date.now()/1e3)+1200),token0Permit2Signature:n,token1Permit2Signature:i})},[u,j,g,A,x,eE,eM,eK,e9,td,eN,tp,eG,e2,tt]);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(Q.S,{currency:g}),(0,i.jsx)(Q.S,{currency:A}),(0,i.jsxs)(L.k0,{borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(o.y,{mb:"8px",children:p("Price Range (Min-Max)")}),(0,i.jsx)(v.Ay,{px:$?"16px":"0",children:(0,i.jsx)(ed.F9,{minPrice:O.minPriceFormatted,maxPrice:O.maxPriceFormatted,currentPrice:O.currentPrice,minPriceRaw:O.minPrice,maxPriceRaw:O.maxPrice,currentPriceRaw:O.currentPriceValue,minPercentage:O.minPercentage,maxPercentage:O.maxPercentage,showPercentages:O.showPercentages,rangePosition:O.rangePosition,outOfRange:$,maxWidth:"unset"})}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Current Price")}),(0,i.jsxs)(d.A,{gap:"2px",children:[(0,i.jsx)(M.A,{small:!0,children:b&&w?(0,F.ZV)(E?b:w,{maximumDecimalTrailingZeroes:5,maximumSignificantDigits:8}):"-"}),(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("%symbol0% per %symbol1%",{symbol0:E?g.symbol:A.symbol,symbol1:E?A.symbol:g.symbol})}),(0,i.jsx)(U.A,{variant:"text",onClick:_,scale:"xs",children:(0,i.jsx)(B.A,{color:"primary60",width:"16px",mt:"2px"})})]})]})]}),(0,i.jsx)(o.y,{mt:"16px",children:p("Amount of liquidity to add")}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),(0,i.jsxs)(L.k0,{mt:"16px",borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(W.A,{id:"position-modal-clamm-increase-A",defaultValue:eb,currency:g,onUserInput:eC,maxAmount:ej,onMax:()=>{var e;return eC(ej&&null!=(e=k(ej))?e:"")},onPercentInput:eS,showUSDPrice:!0,showMaxButton:!0,disableCurrencySelect:!0,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},isUserInsufficientBalance:eT}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(W.A,{id:"position-modal-clamm-increase-B",defaultValue:ew,currency:A,onUserInput:eI,maxAmount:ek,onMax:()=>{var e;return eI(ek&&null!=(e=C(ek))?e:"")},onPercentInput:eR,showUSDPrice:!0,showMaxButton:!0,disableCurrencySelect:!0,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},isUserInsufficientBalance:eU})})]}),eQ&&(0,i.jsx)(Z,{currency0:g,currency1:A,currency0Amount:eq,currency0NewAmount:eO,currency1Amount:eL,currency1NewAmount:e_,currency0AmountRaw:e$,currency0NewAmountRaw:ez,currency1AmountRaw:eY,currency1NewAmountRaw:eV,totalPositionUsd:eW,totalPositionNewUsd:eH,amountUsd:`$${null!=(s=null==eF?void 0:eF.toFormat(2))?s:0}`,amountUsdLabel:p("Total deposit value (USD)")}),(0,i.jsx)(v.Ay,{mt:"16px",children:(0,i.jsx)(ef.u,{size:"sm"})}),(0,i.jsx)(v.Ay,{mt:"16px",children:h!==S?(0,i.jsx)(D.A,{width:"100%",onClick:()=>S?f(S):void 0,disabled:y,children:p("Switch Network")}):(0,i.jsx)(eo.E,{addIsUnsupported:!1,account:null!=x?x:void 0,isWrongNetwork:!1,approvalA:e3,approvalB:tr,isValid:ts,showApprovalA:tl,approveACallback:e8,currentAllowanceA:eJ,revokeACallback:e6,currencies:I,approveBCallback:ti,currentAllowanceB:e5,revokeBCallback:tn,showApprovalB:to,parsedAmounts:eP,onClick:tx,attemptingTxn:tm,errorMessage:ta,buttonText:p("Add"),depositADisabled:ey,depositBDisabled:eg})})]})};var eg=n(273523),eA=n(734658),eb=n(512977),ew=n(662949),ej=n(208103),ek=n(165073),eC=n(488907),eI=n(569019),eS=n(493803);let eR=e=>{var t,n,r,a,s,u,c,p,x;let{position:h,poolInfo:f}=e,{t:y}=(0,l.A)(),{account:g,chainId:A}=(0,X.W7)(),{switchNetworkIfNecessary:b,isLoading:w}=(0,ev.Hk)(),j=null!=(t=h.chainId)?t:f.chainId,[,k]=(0,ej.W)(h.poolId,j),C=(0,ek.L)(h.poolId,j,"Bin"),I=null!=(n=h.poolKey)?n:null==C?void 0:C.data,S=null==k?void 0:k.token0,R=null==k?void 0:k.token1;(0,Y.yx)(S),(0,Y.yx)(R);let E=(0,Y.wG)(S),N=(0,Y.wG)(R),P=(0,m.useMemo)(()=>({[el.O9.CURRENCY_A]:S,[el.O9.CURRENCY_B]:R}),[S,R]),[L,O]=(0,m.useState)(!1),$=(0,m.useCallback)(()=>O(e=>!e),[]),z=(0,m.useMemo)(()=>
1{if(k)return(0,eg.GQ)(k.activeId,k.binStep,k.token0,k.token1)},[k]),V=(0,m.useMemo)(()=>{if(k&&h.minBinId)return(0,eg.GQ)(h.minBinId,k.binStep,k.token0,k.token1)},[k,h.minBinId]),H=(0,m.useMemo)(()=>{if(k&&h.maxBinId)return(0,eg.GQ)(h.maxBinId,k.binStep,k.token0,k.token1)},[k,h.maxBinId]),G=(0,m.useMemo)(()=>{if(!z||!V||!H)return{minPrice:"-",maxPrice:"-",minPriceRaw:0,maxPriceRaw:0,currentPriceRaw:0,showPercentages:!1};let e=L?H.invert():V,t=L?V.invert():H,n=L?z.invert():z,i=parseFloat(e.toSignificant(8)),r=parseFloat(t.toSignificant(8)),l=parseFloat(n.toSignificant(8)),o=l>0?((i-l)/l*100).toFixed(2):"0",a=l>0?((r-l)/l*100).toFixed(2):"0";return{minPrice:(0,F.ZV)(i,{maximumDecimalTrailingZeroes:5,maximumSignificantDigits:8}),maxPrice:(0,F.ZV)(r,{maximumDecimalTrailingZeroes:5,maximumSignificantDigits:8}),minPriceRaw:i,maxPriceRaw:r,currentPriceRaw:l,minPercentage:`${Number(o)>=0?"+":""}${o}%`,maxPercentage:`${Number(a)>=0?"+":""}${a}%`,showPercentages:l>0}},[z,V,H,L]),K=(0,m.useMemo)(()=>{if(!z)return"-";let e=L?z.invert():z;return(0,F.ZV)(parseFloat(e.toSignificant(8)),{maximumDecimalTrailingZeroes:5,maximumSignificantDigits:8})},[z,L]),{data:es}=(0,eh.GB)(S),{data:eu}=(0,eh.GB)(R),ey=(0,m.useMemo)(()=>{if(!S||!h.reserveOfBins)return;let e=h.reserveOfBins.reduce((e,t)=>0n===t.userSharesOfBin||0n===t.totalShares?e:e+t.userSharesOfBin*t.reserveX/t.totalShares,0n);return eA.eF.fromRawAmount(S,e)},[h.reserveOfBins,S]),eR=(0,m.useMemo)(()=>{if(!R||!h.reserveOfBins)return;let e=h.reserveOfBins.reduce((e,t)=>0n===t.userSharesOfBin||0n===t.totalShares?e:e+t.userSharesOfBin*t.reserveY/t.totalShares,0n);return eA.eF.fromRawAmount(R,e)},[h.reserveOfBins,R]),eE=(0,m.useMemo)(()=>{if(!ey||!eR||!es||!eu)return 50;let e=(0,ex.g)(ey.toExact()).multipliedBy(es),t=(0,ex.g)(eR.toExact()).multipliedBy(eu),n=e.plus(t);return n.isZero()?50:e.dividedBy(n).multipliedBy(100).toNumber()},[ey,eR,es,eu]),[{lowerBinId:eM,upperBinId:eN},eP]=(0,eC.H4)(),[eT,eU]=(0,eC.oO)(),[eB]=(0,eC.cB)(),eD=null!=(r=h.minBinId)?r:null,eF=null!=(a=h.maxBinId)?a:null;(0,m.useEffect)(()=>{if(null===eD||null===eF)return;let e=null===eM||null===eN,t=null!==eM&&null!==eN&&eM>eN,n=null!==eM&&null!==eN&&(eM<eD||eN>eF||eN<eD||eM>eF);(e||t||n)&&eP({lowerBinId:eD,upperBinId:eF});let i=e||t||n?eD:eM,r=e||t||n?eF:eN;if(null!==i&&null!==r&&r>=i){let e=r-i+1;(null===eT||eT<=0)&&Number.isFinite(e)&&e>0&&eU(e)}},[eM,eF,eD,eT,eP,eU,eN]);let eq=(0,m.useMemo)(()=>!eM||!eN||!!(eM>eN)||null!==eD&&(!!(eM<eD)||!!(eN<eD))||null!==eF&&(!!(eM>eF)||!!(eN>eF)),[eM,eN,eD,eF]),eL=(0,m.useMemo)(()=>!!(eM&&eN&&k&&(k.activeId<eM||k.activeId>eN)),[eM,eN,k]),eO=(0,m.useMemo)(()=>!!k&&!!eM&&!!eN&&eM<=k.activeId&&k.activeId<=eN,[k,eM,eN]),e_=(0,m.useMemo)(()=>!!k&&!!eM&&(eM>=k.activeId||eO),[k,eM,eO]),e$=(0,m.useMemo)(()=>!!k&&!!eN&&(eN<=k.activeId||eO),[k,eN,eO]),[eY,ez]=(0,m.useState)(""),[eV,eZ]=(0,m.useState)(""),eW=(0,Y.dm)(eY,null!=S?S:void 0),eH=(0,Y.dm)(eV,null!=R?R:void 0),[eQ,eG]=(0,eI.pl)(null!=g?g:void 0,(0,m.useMemo)(()=>[S,R],[S,R]),j),eK=(0,m.useCallback)(e=>{var t;eQ&&ez(null!=(t=E(eQ.multiply(new eA.QE(e,100))))?t:"")},[eQ,E]),eX=(0,m.useCallback)(e=>{var t;eG&&eZ(null!=(t=N(eG.multiply(new eA.QE(e,100))))?t:"")},[eG,N]),eJ=(0,m.useMemo)(()=>({[el.O9.CURRENCY_A]:eW,[el.O9.CURRENCY_B]:eH}),[eW,eH]),e0=(0,m.useMemo)(()=>{let e=(0,er.r)(eQ);return!!g&&!!eW&&!!e&&e.lessThan(eW)},[g,eW,eQ]),e1=(0,m.useMemo)(()=>{let e=(0,er.r)(eG);return!!g&&!!eH&&!!e&&e.lessThan(eH)},[g,eH,eG]),e2=(0,m.useMemo)(()=>{if(!es||!eu)return null;let e=(0,ex.g)(es).multipliedBy((null==eW?void 0:eW.toExact())||0),t=(0,ex.g)(eu).multipliedBy((null==eH?void 0:eH.toExact())||0);return e.plus(t)},[es,eu,eW,eH]),e6=null!=(s=E(ey,6))?s:"0",e8=null!=(u=N(eR,6))?u:"0",e3=(0,m.useMemo)(()=>{var e,t;return ey?eW?null!=(t=E(ey.wrapped.add(eW.wrapped),6))?t:"0":e6:null!=(e=E(eW,6))?e:"0"},[ey,eW,e6,E]),e9=(0,m.useMemo)(()=>{var e,t;return eR?eH?null!=(t=N(eR.wrapped.add(eH.wrapped),6))?t:"0":e8:null!=(e=N(eH,6))?e:"0"},[eR,eH,e8,N]),e4=null==ey?void 0:ey.toExact(),e5=null==eR?void 0:eR.toExact(),e7=(0,m.useMemo)(()=>ey?eW?ey.wrapped.add(eW.wrapped).toExact():ey.toExact():null==eW?void 0:eW.toExact(),[ey,eW]),te=(0,m.useMemo)(()=>eR?eH?eR.wrapped.add(eH.wrapped).toExact():eR.toExact():null==eH?void 0:eH.toExact(),[eR,eH]),tt=(0,m.useMemo)(()=>
1{if(!ey||!eR||!es||!eu)return null;let e=(0,ex.g)(es).multipliedBy(ey.toExact()),t=(0,ex.g)(eu).multipliedBy(eR.toExact());return e.plus(t)},[ey,eR,es,eu]),tn=(0,m.useMemo)(()=>tt?`$${tt.toFormat(2)}`:"$0",[tt]),ti=(0,m.useMemo)(()=>tt?!e2||e2.isZero()?tn:`$${tt.plus(e2).toFormat(2)}`:"$0",[tt,e2,tn]),tr=!!((null==eW?void 0:eW.greaterThan(0))||(null==eH?void 0:eH.greaterThan(0))),{errorMessage:tl}=(0,ea.P)({currencyA:S,currencyB:R,currencyAAmount:e_?eW:void 0,currencyBAmount:e$?eH:void 0,allowSingleSide:!0}),[to]=(0,q.oA)()||[q.C0],[ta]=(0,q.Ts)(),ts=(0,m.useMemo)(()=>k?(0,eg.FP)(parseFloat(ta.toSignificant(2)),k.binStep,k.activeId):0,[ta,k]),td=(0,en.B4)("Bin",j),tu=(0,et.PJ)(),{requirePermit:tc,requireApprove:tp,permit2Allowance:tm,isApproving:tx,permit:th,revoke:tf,approve:tv}=(0,ee.$)((null==S?void 0:S.isNative)||null==eW?void 0:eW.wrapped,td,{overrideChainId:j}),ty=(0,m.useMemo)(()=>tx?J.h$.PENDING:tp?J.h$.NOT_APPROVED:J.h$.APPROVED,[tx,tp]),{requirePermit:tg,requireApprove:tA,permit2Allowance:tb,isApproving:tw,permit:tj,revoke:tk,approve:tC}=(0,ee.$)((null==R?void 0:R.isNative)||null==eH?void 0:eH.wrapped,td,{overrideChainId:j}),tI=(0,m.useMemo)(()=>tw?J.h$.PENDING:tA?J.h$.NOT_APPROVED:J.h$.APPROVED,[tw,tA]),tS=ty!==J.h$.APPROVED&&!!eW,tR=tI!==J.h$.APPROVED&&!!eH,tE=(null==S?void 0:S.isNative)?ep.Xd:null!=(c=null==S?void 0:S.address)?c:ep.Xd,tM=(null==R?void 0:R.isNative)?ep.Xd:null!=(p=null==R?void 0:R.address)?p:ep.Xd,{addBinLiquidity:tN,attemptingTx:tP}=(0,eS._)(null!=j?j:0,null!=g?g:ep.Xd,tE,tM),tT=(0,m.useCallback)(async()=>{var e,t;let n,i;if(!k||!g||!I||!S||!R||!(null==eW?void 0:eW.greaterThan(0))&&!(null==eH?void 0:eH.greaterThan(0))||null===eM||null===eN||null===eB||null===eT)return;try{!S.isNative&&tc&&eW&&eW.greaterThan(0)&&(n=await th()),!R.isNative&&tg&&eH&&eH.greaterThan(0)&&(i=await tj())}catch(e){if(tu(e))return;throw e}let[,r]=eW?(0,ei.wQ)(eW,to):[0n,em.iB],[,l]=eH?(0,ei.wQ)(eH,to):[0n,em.iB],o={poolKey:I,liquidityShape:eB,binNums:eT,activeIdDesired:k.activeId,idSlippage:BigInt(ts),amount0Desired:null!=(e=null==eW?void 0:eW.quotient)?e:0n,amount1Desired:null!=(t=null==eH?void 0:eH.quotient)?t:0n,amount0Max:r,amount1Max:l,recipient:g,deadline:BigInt(Math.floor(Date.now()/1e3)+1200),currency0:S,currency1:R,lowerBinId:eM,upperBinId:eN,token0Permit2Signature:n,token1Permit2Signature:i};await tN(o)},[k,g,I,S,R,eW,eH,eM,eN,eB,eT,tc,tg,tu,th,tj,to,ts,tN]);if(!k)return null;let tU=L?k.token1.symbol:k.token0.symbol,tB=L?k.token0.symbol:k.token1.symbol;return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(Q.S,{currency:S}),(0,i.jsx)(Q.S,{currency:R}),(0,i.jsxs)(_.k,{borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(o.y,{mb:"8px",children:y("Price Range (Min-Max)")}),(0,i.jsx)(ed.F9,{minPrice:G.minPrice,maxPrice:G.maxPrice,minPriceRaw:G.minPriceRaw,maxPriceRaw:G.maxPriceRaw,currentPriceRaw:G.currentPriceRaw,minPercentage:G.minPercentage,maxPercentage:G.maxPercentage,showPercentages:G.showPercentages,outOfRange:eL,maxWidth:"unset"}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:y("Current Price")}),(0,i.jsxs)(d.A,{gap:"2px",children:[(0,i.jsx)(M.A,{small:!0,children:K}),(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:y("%symbol0% per %symbol1%",{symbol0:tU,symbol1:tB})}),(0,i.jsx)(U.A,{variant:"text",onClick:$,scale:"xs",children:(0,i.jsx)(B.A,{color:"primary60",width:"16px",mt:"2px"})})]})]})]}),S&&R&&(0,i.jsxs)(_.k,{borderRadius:"24px",padding:"16px",mt:"16px",children:[(0,i.jsx)(T.JA,{children:(0,i.jsx)(o.y,{children:y("Distribution")})}),(0,i.jsxs)(T.JA,{mt:"12px",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(_.Z,{currency:S,size:"24px"}),(0,i.jsx)(M.A,{bold:!0,children:S.symbol})]}),(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(M.A,{bold:!0,children:R.symbol}),(0,i.jsx)(_.Z,{currency:R,size:"24px"})]})]}),(0,i.jsxs)(T.JA,{mt:"4px",children:[(0,i.jsx)(M.A,{small:!0,children:e6}),(0,i.jsx)(M.A,{small:!0,children:e8})]}),(0,i.jsx)(v.Ay,{mt:"8px",height:"5px",borderRadius:"4px",overflow:"hidden",backgroundColor:"primary",children:(0,i.jsx)(v.Ay,{height:"100%",borderRadius:"4px",width:`${eE}%`,backgroundColor:"textSubtle"})}),(0,i.jsxs)(T.JA,{mt:"4px",children:[(0,i.jsxs)(M.A,{small:!0,color:"textSubtle",children:[eE.toFixed(2),"%"]}),(0,i.jsxs)(M.A,{small:!0,color:"textSubtle",children:[(100-eE).toFixed(2),"%"]})]})]}),(0,i.jsx)(o.y,{mt:"16px",children:y("Set Price Range")}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(eb.W,{currency0:S,currency1:R,binStep:k.binStep,activeBinId:k.activeId,minBinId:eD,maxBinId:eF})}),(0,i.jsx)(ew.k,{mt:"16px"}),(0,i.jsx)(o.y,{mt:"16px",children:y("Amount of Liquidity to Add")}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:y("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),(0,i.jsxs)(_.k,{mt:"16px",borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(W.A,{id:"position-modal-bin-increase-A",defaultValue:eY,currency:S,onUserInput:ez,maxAmount:eQ,onMax:()=>{var e;return ez(eQ&&null!=(e=E(eQ))?e:"")},onPercentInput:eK,showUSDPrice:!0,showMaxButton:!0,disableCurrencySelect:!0,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},isUserInsufficientBalance:e0}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(W.A,{id:"position-modal-bin-increase-B",defaultValue:eV,currency:R,onUserInput:eZ,maxAmount:eG,onMax:()=>{var e;return eZ(eG&&null!=(e=N(eG))?e:"")},onPercentInput:eX,showUSDPrice:!0,showMaxButton:!0,disableCurrencySelect:!0,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},isUserInsufficientBalance:e1})})]}),S&&R&&tr&&(0,i.jsx)(Z,{currency0:S,currency1:R,currency0Amount:e6,currency0NewAmount:e3,currency1Amount:e8,currency1NewAmount:e9,currency0AmountRaw:e4,currency0NewAmountRaw:e7,currency1AmountRaw:e5,currency1NewAmountRaw:te,totalPositionUsd:tn,totalPositionNewUsd:ti,amountUsd:`$${null!=(x=null==e2?void 0:e2.toFormat(2))?x:"0.00"}`,amountUsdLabel:y("Total deposit value (USD)")}),(0,i.jsx)(v.Ay,{mt:"16px",children:(0,i.jsx)(ef.u,{size:"sm"})}),(0,i.jsx)(v.Ay,{mt:"16px",children:A!==j?(0,i.jsx)(D.A,{width:"100%",onClick:()=>j?b(j):void 0,disabled:w,children:y("Switch Network")}):(0,i.jsx)(eo.E,{addIsUnsupported:!1,account:null!=g?g:void 0,isWrongNetwork:!1,approvalA:ty,approvalB:tI,isValid:!tl&&!eq,showApprovalA:tS,approveACallback:tv,currentAllowanceA:tm,revokeACallback:tf,currencies:P,approveBCallback:tC,currentAllowanceB:tb,revokeBCallback:tk,showApprovalB:tR,parsedAmounts:eJ,onClick:tT,attemptingTxn:tP,errorMessage:tl,buttonText:y("Add"),depositADisabled:!e_,depositBDisabled:!e$})})]})};var eE=n(179087),eM=n(987212),eN=n(311560),eP=n(779243),eT=n(614325),eU=n(344730),eB=n(606771),eD=n(419041),eF=n(259145),eq=n(17581);let eL=e=>{var t,n,r;let{position:a,poolInfo:s}=e,{t:u}=(0,l.A)(),{address:c}=(0,eq.F)(),{chainId:p}=(0,X.W7)(),{switchNetworkIfNecessary:x,isLoading:f}=(0,ev.Hk)(),y=null!=(t=a.chainId)?t:s.chainId,g=s.token0,A=s.token1,{poolKey:b,liquidity:w,tickLower:j,tickUpper:k}=a,C=0n===a.liquidity,I=(0,m.useMemo)(()=>b?(0,eg.Qn)(b):void 0,[b]),[,S]=(0,ej.W)(I,y),R=(0,eD.Ay)(y),[E,N]=(0,m.useState)(50),[P,U]=(0,eE.Vv)(E,N),[B,F]=(0,m.useState)(!1),O
1=(0,m.useMemo)(()=>{if(!g||!y)return g;let e=eN.xQ[y];return e&&g.isNative?B?e:R:g},[g,y,B,R]),_=(0,m.useMemo)(()=>{if(!A||!y)return A;let e=eN.xQ[y];return e&&A.isNative?B?e:R:A},[A,y,B,R]),$=(0,m.useCallback)(e=>U(Math.ceil(e)),[U]),{amount0:z,amount1:V}=(0,K.h)({token0:g,token1:A,tickCurrent:null==S?void 0:S.tickCurrent,tickLower:j,tickUpper:k,sqrtRatioX96:null==S?void 0:S.sqrtRatioX96,liquidity:w}),[W,H]=(0,m.useMemo)(()=>[null==z?void 0:z.multiply(new eA.QE(P,100)),null==V?void 0:V.multiply(new eA.QE(P,100))],[z,V,P]),{data:Q}=(0,eh.GB)(g),{data:G}=(0,eh.GB)(A),J=(0,m.useMemo)(()=>{var e,t;return B?(null==g?void 0:g.isNative)?null!=(e=null==g?void 0:g.wrapped.address)?e:eM.Xd:(null==A?void 0:A.isNative)&&null!=(t=null==A?void 0:A.wrapped.address)?t:eM.Xd:eM.Xd},[B,g,A]),[ee]=(0,q.oA)()||[q.C0],{removeLiquidity:et,attemptingTx:en}=(0,eB.X)(y,c),er=(0,m.useCallback)(async()=>{if(!a||!a.tokenId)return;let[e]=W?(0,ei.wQ)(W,ee):[em.iB],[t]=H?(0,ei.wQ)(H,ee):[em.iB];await et({tokenId:a.tokenId,poolKey:a.poolKey,liquidity:a.liquidity*BigInt(P)/100n,amount0Min:e,amount1Min:t,wrapAddress:J,deadline:BigInt(Math.floor(Date.now()/1e3)+1200),amount0Desired:null==W?void 0:W.quotient,amount1Desired:null==H?void 0:H.quotient,currency0:g,currency1:A})},[a,W,ee,H,et,P,J,g,A]),el=(0,m.useMemo)(()=>c?0===E?u("Enter a percent"):void 0:u("Connect Wallet"),[u,c,E]),eo=(0,m.useMemo)(()=>!!(g&&A&&(g.isNative||A.isNative)),[g,A]),ea=(0,Y.wG)(g),es=(0,Y.wG)(A),ed=null!=(n=ea(z,6))?n:"0",eu=null!=(r=es(V,6))?r:"0",ep=(0,m.useMemo)(()=>{var e;if(!z||!W)return ed;let t=z.quotient-W.quotient;return t<0n?"0":null!=(e=ea(eA.eF.fromRawAmount(z.currency,t),6))?e:"0"},[z,W,ed,ea]),ef=(0,m.useMemo)(()=>{var e;if(!V||!H)return eu;let t=V.quotient-H.quotient;return t<0n?"0":null!=(e=es(eA.eF.fromRawAmount(V.currency,t),6))?e:"0"},[V,H,eu,es]),ey=null==z?void 0:z.toExact(),eb=null==V?void 0:V.toExact(),ew=(0,m.useMemo)(()=>{if(!z||!W)return ey;let e=z.quotient-W.quotient;return e<0n?"0":eA.eF.fromRawAmount(z.currency,e).toExact()},[z,W,ey]),ek=(0,m.useMemo)(()=>{if(!V||!H)return eb;let e=V.quotient-H.quotient;return e<0n?"0":eA.eF.fromRawAmount(V.currency,e).toExact()},[V,H,eb]),eC=(0,m.useMemo)(()=>{if(!z||!V||!Q||!G)return"$0";let e=(0,ex.g)(z.toExact()).multipliedBy(Q),t=(0,ex.g)(V.toExact()).multipliedBy(G);return`$${e.plus(t).toFormat(2)}`},[z,V,Q,G]),eI=(0,m.useMemo)(()=>{if(!W||!H||!Q||!G)return"0";let e=(0,ex.g)(W.toExact()).multipliedBy(Q),t=(0,ex.g)(H.toExact()).multipliedBy(G);return e.plus(t).toFormat(2)},[W,H,Q,G]),eS=(0,m.useMemo)(()=>{if("$0"===eC||"0"===eI)return eC;let e=(0,ex.g)(eC.replace(/[$,]/g,"")),t=(0,ex.g)(eI.replace(/,/g,"")),n=e.minus(t);return`$${n.isNegative()?"0":n.toFormat(2)}`},[eC,eI]),[eR,eL]=(0,eU.s)({currency0:g,currency1:A,tokenId:void 0!==a.tokenId?BigInt(a.tokenId):void 0,poolId:I,tickLower:a.tickLower,tickUpper:a.tickUpper}),eO=(0,m.useMemo)(()=>{if(!(null==eR?void 0:eR.greaterThan(0))&&!(null==eL?void 0:eL.greaterThan(0)))return;let e=(null==eR?void 0:eR.greaterThan(0))&&Q?(0,ex.g)(eR.toExact()).multipliedBy(Q):(0,ex.g)(0),t=(null==eL?void 0:eL.greaterThan(0))&&G?(0,ex.g)(eL.toExact()).multipliedBy(G):(0,ex.g)(0);return`$${e.plus(t).toFormat(2)}`},[eR,eL,Q,G]),e_=en||C||!!el||0===E;return(0,i.jsxs)(v.Ay,{children:[(0,i.jsxs)(T.JA,{mb:"4px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:u("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),eo&&(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:u("Collect as %symbol%",{symbol:R.wrapped.symbol})}),(0,i.jsx)(eP.A,{scale:"sm",checked:B,onChange:()=>F(e=>!e)})]}),(0,i.jsx)(o.y,{mt:"16px",children:u("Amount of liquidity to remove")}),(0,i.jsxs)(L.k0,{mt:"8px",padding:"16px",borderRadius:"24px",children:[(0,i.jsxs)(M.A,{fontSize:"40px",bold:!0,mb:"16px",style:{lineHeight:1},children:[P,"%"]}),(0,i.jsx)(eT.A,{name:"lp-amount",min:0,max:100,value:P,onValueChanged:$,mb:"16px"}),(0,i.jsxs)(d.A,{gap:"8px",justifyContent:"space-between",children:[(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>N(10),width:"100%",borderRadius:"12px",children:"10%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>N(20),width:"100%",borderRadius:"12px",children:"20%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>N(75),width:"100%",borderRadius:"12px",children:"75%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>N(100),width:"100%",borderRadius:"12px",children:u("Max.fill-max")})]})]}),(0,i.jsx)(Z,{currency0:null!=O?O:g,currency1:null!=_?_:A,currency0Amount:ed,currency0NewAmount:ep,currency1Amount:eu,currency1NewAmount:ef,currency0AmountRaw:ey,currency0NewAmountRaw:ew,currency1AmountRaw:eb,currency1NewAmountRaw:ek,totalPositionUsd:eC,totalPositionNewUsd:eS,amountUsd:`$${eI}`,feeValue0:eR,feeValue1:eL,feesEarnedUsd:eO}),p!==y?(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>y?x(y):void 0,disabled:f,children:u("Switch Network")}):(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:e_,onClick:()=>{er(),(0,eF.z_)()},children:C?u("Closed"):null!=el?el:u("Remove")})]})};var eO=n(226464),e_=n(727705),e$=n(772763),eY=n(981830),ez=n(59404);let eV=e=>{var t,n,r,a,s,d;let{position:u,poolInfo:c}=e,{t:p}=(0,l.A)(),{address:x}=(0,eq.F)(),{chainId:f}=(0,X.W7)(),{switchNetworkIfNecessary:y,isLoading:g}=(0,ev.Hk)(),A=null!=(t=u.chainId)?t:c.chainId,{poolId:b}=u,[,w]=(0,ej.W)(b,A),j=(0,ek.L)(b,A,"Bin"),k=null!=(n=u.poolKey)?n:null==j?void 0:j.data,C=null==w?void 0:w.token0,I=null==w?void 0:w.token1,S=(0,eD.Ay)(A),[R,E]=(0,m.useState)(!1),N=(0,m.useMemo)(()=>
1{if(!C||!A)return C;let e=eN.xQ[A];return e&&C.isNative?R?e:S:C},[C,A,R,S]),P=(0,m.useMemo)(()=>{if(!I||!A)return I;let e=eN.xQ[A];return e&&I.isNative?R?e:S:I},[I,A,R,S]),[,U]=(0,eC.H4)(),[B,F]=(0,m.useState)([null!=(r=u.minBinId)?r:0,null!=(a=u.maxBinId)?a:0]),{data:O}=(0,eY.C)(b,A,x),_=(0,m.useMemo)(()=>(null==O?void 0:O.reserveOfBins)?O.reserveOfBins:u.reserveOfBins?u.reserveOfBins.filter(e=>e.userSharesOfBin>0n).map(e=>({...e,reserveX:e.totalShares>0n?e.userSharesOfBin*e.reserveX/e.totalShares:0n,reserveY:e.totalShares>0n?e.userSharesOfBin*e.reserveY/e.totalShares:0n})):[],[null==O?void 0:O.reserveOfBins,u.reserveOfBins]),$=(0,m.useMemo)(()=>{if(!C||!_.length)return;let[e,t]=B,n=_.reduce((n,i)=>i.binId>=e&&i.binId<=t?n+i.reserveX:n,0n);return eA.eF.fromRawAmount(C,n)},[_,C,B]),z=(0,m.useMemo)(()=>{if(!I||!_.length)return;let[e,t]=B,n=_.reduce((n,i)=>i.binId>=e&&i.binId<=t?n+i.reserveY:n,0n);return eA.eF.fromRawAmount(I,n)},[_,I,B]),V=(0,m.useMemo)(()=>{if(!C||!_.length)return;let e=_.reduce((e,t)=>e+t.reserveX,0n);return eA.eF.fromRawAmount(C,e)},[_,C]),W=(0,m.useMemo)(()=>{if(!I||!_.length)return;let e=_.reduce((e,t)=>e+t.reserveY,0n);return eA.eF.fromRawAmount(I,e)},[_,I]),{data:H}=(0,eh.GB)(C),{data:Q}=(0,eh.GB)(I),G=(0,m.useMemo)(()=>0n===u.reserveX&&0n===u.reserveY,[u]),K=(0,m.useMemo)(()=>{if(!x)return p("Connect Wallet")},[p,x]);(0,m.useEffect)(()=>{u.minBinId&&u.maxBinId&&!B[0]&&!B[1]&&F([u.minBinId,u.maxBinId])},[u,B]);let J=(0,m.useCallback)(e=>{let[t,n]=Array.isArray(e)?e:[e,e];F([t,n]),U({lowerBinId:t,upperBinId:n})},[U]),{removeLiquidity:ee,attemptingTx:et}=(0,e_.p)(A,x),[en]=(0,e$.g)(),[er]=(0,q.oA)()||[q.C0],el=(0,m.useMemo)(()=>C&&I&&R?C.isNative?C.wrapped.address:I.isNative?I.wrapped.address:ep.Xd:ep.Xd,[R,C,I]),eo=(0,m.useCallback)(async()=>{if(!w||!x||!k||!_.length)return;let e=_.filter(e=>e.binId>=B[0]&&e.binId<=B[1]),t=e.map(e=>e.binId),n=e.map(e=>e.userSharesOfBin),i=eA.eF.fromRawAmount(w.token0,e.reduce((e,t)=>e+t.reserveX,0n)),r=eA.eF.fromRawAmount(w.token1,e.reduce((e,t)=>e+t.reserveY,0n)),l=(0,ei.wQ)(i,er)[0],o=(0,ei.wQ)(r,er)[0];await ee({poolKey:k,ids:t,amounts:n,amount0Min:l,amount1Min:o,wrapAddress:el,hookData:void 0,deadline:null!=en?en:BigInt(Math.floor(Date.now()/1e3)+1200),amount0Desired:null==$?void 0:$.quotient,amount1Desired:null==z?void 0:z.quotient,currency0:C,currency1:I})},[x,er,_,en,w,k,ee,B,el,$,z,C,I]),[{lowerBinId:ea,upperBinId:es}]=(0,eC.H4)(),ed=(0,m.useMemo)(()=>!ea||!es||ea>es||!!u.minBinId&&ea<u.minBinId||!!u.maxBinId&&ea>u.maxBinId||!!u.minBinId&&es<u.minBinId||!!u.maxBinId&&es>u.maxBinId||!1,[u.maxBinId,u.minBinId,ea,es]);(0,m.useEffect)(()=>{!ed&&ea&&es&&(B[0]!==ea||B[1]!==es)&&F([ea,es])},[ed,ea,B,es]);let eu=(0,eE.aq)();(0,m.useEffect)(()=>{eu&&u.minBinId&&u.maxBinId&&(null===ea||null===es||ea<u.minBinId||ea>u.maxBinId||es<u.minBinId||es>u.maxBinId)&&U({lowerBinId:u.minBinId,upperBinId:u.maxBinId})},[u.maxBinId,u.minBinId,eu,ea,U,es]);let em=(0,m.useMemo)(()=>!!(et||G||K||!$||!z||$.asFraction.add(z.asFraction).equalTo(0)),[et,G,K,$,z]),ef=(0,m.useMemo)(()=>!!(C&&I&&(C.isNative||I.isNative)),[C,I]),ey=(0,Y.wG)(C),eg=(0,Y.wG)(I),ew=null!=(s=ey(V,6))?s:"0",eI=null!=(d=eg(W,6))?d:"0",eS=(0,m.useMemo)(()=>{var e;if(!V||!$)return ew;let t=V.quotient-$.quotient;return t<0n?"0":null!=(e=ey(eA.eF.fromRawAmount(V.currency,t),6))?e:"0"},[V,$,ew,ey]),eR=(0,m.useMemo)(()=>{var e;if(!W||!z)return eI;let t=W.quotient-z.quotient;return t<0n?"0":null!=(e=eg(eA.eF.fromRawAmount(W.currency,t),6))?e:"0"},[W,z,eI,eg]),eM=null==V?void 0:V.toExact(),eT=null==W?void 0:W.toExact(),eU=(0,m.useMemo)(()=>{if(!V||!$)return null==V?void 0:V.toExact();let e=V.quotient-$.quotient;return e<0n?"0":eA.eF.fromRawAmount(V.currency,e).toExact()},[V,$]),eB=(0,m.useMemo)(()=>{if(!W||!z)return null==W?void 0:W.toExact();let e=W.quotient-z.quotient;return e<0n?"0":eA.eF.fromRawAmount(W.currency,e).toExact()},[W,z]),eL=(0,m.useMemo)(()=>{if(!V||!W||!H||!Q)return"$0";let e=(0,ex.g)(V.toExact()).multipliedBy(H),t=(0,ex.g)(W.toExact()).multipliedBy(Q);return`$${e.plus(t).toFormat(2)}`},[V,W,H,Q]),eV=(0,m.useMemo)(()=>
1{if(!$||!z||!H||!Q)return"0";let e=(0,ex.g)($.toExact()).multipliedBy(H),t=(0,ex.g)(z.toExact()).multipliedBy(Q);return e.plus(t).toFormat(2)},[$,z,H,Q]),eZ=(0,m.useMemo)(()=>{if("$0"===eL||"0"===eV)return eL;let e=(0,ex.g)(eL.replace(/[$,]/g,"")),t=(0,ex.g)(eV.replace(/,/g,"")),n=e.minus(t);return`$${n.isNegative()?"0":n.toFormat(2)}`},[eL,eV]);return w?(0,i.jsxs)(v.Ay,{children:[(0,i.jsxs)(T.JA,{mb:"4px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),ef&&(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Collect as %symbol%",{symbol:S.wrapped.symbol})}),(0,i.jsx)(eP.A,{scale:"sm",checked:R,onChange:()=>E(e=>!e)})]}),(0,i.jsx)(o.y,{mt:"16px",children:p("Amount of liquidity to remove")}),(0,i.jsxs)(L.k0,{mt:"8px",padding:"16px",borderRadius:"24px",children:[(0,i.jsx)(o.y,{textTransform:"uppercase",children:p("Price Range")}),null!=u.minBinId&&null!=u.maxBinId?(0,i.jsxs)(i.Fragment,{children:[u.maxBinId-u.minBinId>1?(0,i.jsx)(v.Ay,{height:"48px",my:"8px",children:(0,i.jsx)(ez.t,{defaultValue:[u.minBinId,u.maxBinId],min:u.minBinId,max:u.maxBinId,value:B,step:1,onChange:J})}):null,(0,i.jsx)(eb.W,{currency0:C,currency1:I,binStep:w.binStep,minBinId:u.minBinId,maxBinId:u.maxBinId})]}):null]}),(0,i.jsx)(eO.A,{variant:"primary",mt:"16px",children:(0,i.jsx)(M.A,{small:!0,children:p("Displayed amounts include fees. In LBAMM pools, accrued fees are added back to the pool reserves.")})}),C&&I&&(0,i.jsx)(Z,{currency0:null!=N?N:C,currency1:null!=P?P:I,currency0Amount:ew,currency0NewAmount:eS,currency1Amount:eI,currency1NewAmount:eR,currency0AmountRaw:eM,currency0NewAmountRaw:eU,currency1AmountRaw:eT,currency1NewAmountRaw:eB,totalPositionUsd:eL,totalPositionNewUsd:eZ,amountUsd:`$${eV}`}),f!==A?(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>A?y(A):void 0,disabled:g,children:p("Switch Network")}):(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:em,onClick:()=>{eo(),(0,eF.z_)()},children:G?p("Closed"):null!=K?K:p("Remove")})]}):null};var eZ=n(605360),eW=n(252146),eH=n(450253),eQ=n.n(eH),eG=n(402861),eK=n(642010);function eX(e){let{chainId:t,poolId:n,position:i,onDone:l}=e,{address:o}=(0,eq.F)(),a=(0,m.useMemo)(()=>eQ()().startOf("hour").unix(),[]),s=i.protocol===r.Zs.InfinityCLAMM,d=s?i.tokenId:void 0,{data:u,isLoading:c}=(0,eG.fG)({chainId:t,address:o,poolId:n,tokenId:d,timestamp:a}),{data:p,isLoading:x}=(0,eG.wA)({chainId:t,address:o,poolId:n,timestamp:a}),h=(0,m.useMemo)(()=>s?null==u?void 0:u.rewardsAmount:null==p?void 0:p.rewardsAmount,[s,u,p]),f=(0,m.useMemo)(()=>{let e=null==h?void 0:h.toExact();return new ex.A(e||0)},[h]),v=(0,m.useMemo)(()=>{var e,t;return s?null!=(e=null==u?void 0:u.rewardsUSD)?e:0:null!=(t=null==p?void 0:p.rewardsUSD)?t:0},[s,u,p]),y=f.isGreaterThan(0),{onHarvest:g,attemptingTx:A}=(0,eK.A)({chainId:t,onDone:l});return{rewardsCurrencyAmount:h,totalRewardsAmount:f,totalRewardsUSD:v,hasUnclaimedRewards:y,onHarvest:g,attemptingTx:A,isLoading:s?c:x}}var eJ=n(788501),e0=n(748853);function e1(e){var t,n;let{currency0:r,currency1:a,feeAmount0:s,feeAmount1:u,feeUsd0:c,feeUsd1:p,totalFeesUsd:m,onCollect:x,collecting:h,disabled:f,hideButton:v}=e,{t:y}=(0,l.A)(),g=(0,Y.wG)(r),A=(0,Y.wG)(a);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(_.k,{padding:"16px",borderRadius:"24px",style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsx)(o.y,{color:"secondary",mb:"8px",children:y("Unclaimed Fees")}),(0,i.jsx)(M.A,{fontSize:"32px",bold:!0,lineHeight:1.2,letterSpacing:"-0.32px",children:(0,e0.l)(null!=m?m:0)}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(_.Z,{currency:r,size:"24px"}),(0,i.jsx)(z.g3,{amount:s,small:!0,children:(0,F.ZV)(null!=(t=g(s,6))?t:"0")}),(0,i.jsx)(M.A,{small:!0,color:"textSubtle",children:r.symbol})]}),(0,i.jsx)(M.A,{small:!0,children:(0,e0.l)(null!=c?c:0)})]}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(_.Z,{currency:a,size:"24px"}),(0,i.jsx)(z.g3,{amount:u,small:!0,children:(0,F.ZV)(null!=(n=A(u,6))?n:"0")}),(0,i.jsx)(M.A,{small:!0,color:"textSubtle",children:a.symbol})]}),(0,i.jsx)(M.A,{small:!0,children:(0,e0.l)(null!=p?p:0)})]})]}),v?null:(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:f,onClick:x,children:y(h?"Collecting...":"Collect")})]})}function e2(e){let{rewardToken:t,rewardsAmount:n,rewardsUSD:r,onHarvest:a,harvesting:s,disabled:u,hideButton:c}=e,{t:p}=(0,l.A)();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(_.k,{padding:"16px",borderRadius:"24px",style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsx)(o.y,{color:"secondary",mb:"8px",children:p("Farming Rewards")}),(0,i.jsx)(M.A,{fontSize:"32px",bold:!0,lineHeight:1.2,letterSpacing:"-0.32px",children:(0,e0.l)(r)}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(_.Z,{currency:t,size:"24px"}),(0,i.jsx)(M.A,{small:!0,children:(0,F.ZV)(n)}),(0,i.jsx)(M.A,{small:!0,color:"textSubtle",children:t.symbol})]}),(0,i.jsx)(M.A,{small:!0,children:(0,e0.l)(r)})]})]}),c?null:(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:u,onClick:a,children:p(s?"Harvesting...":"Harvest")})]})}var e6=n(673115),e8=n(427548),e3=n(303728);function e9(e){let{tokenAmount:t}=e,n=(0,Y.Wu)(t,6);return(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(_.Z,{currency:t.currency,size:"24px"}),(0,i.jsx)(M.A,{small:!0,color:"textSubtle",children:t.currency.symbol})]}),(0,i.jsx)(z.g3,{amount:t,small:!0,children:n})]})}function e4(e){let{poolAddress:t,poolProtocol:n,chainId:r,disabled:a,outRange:s,notEnoughLiquidity:d,hideButton:u}=e,{t:c}=(0,l.A)(),{claimTokenReward:p,isClaiming:m,rewardsPerToken:x,hasMerkl:h}=(0,e8.Ay)(t,r),f=(0,e3.Y)({hasMerkl:h,chainId:r,lpAddress:t,poolProtocol:n});if(!x.length||!h&&x.every(e=>e.equalTo("0")))return null;let v=x.every(e=>e.equalTo("0"));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(_.k,{mt:"16px",padding:"16px",borderRadius:"24px",style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsx)(o.y,{color:"secondary",mb:"8px",children:c("Merkl Rewards")}),x.map(e=>(0,i.jsx)(e9,{tokenAmount:e},e.currency.wrapped.address))]}),s&&h?(0,i.jsx)(eO.A,{variant:"warning",mt:"8px",children:(0,i.jsx)(eO.J,{children:c("This Merkl campaign is NOT rewarding out-of-range liquidity.")})}):d&&h?(0,i.jsx)(eO.A,{variant:"warning",mt:"8px",children:(0,i.jsxs)(eO.J,{children:[c("Position value is less than $20 â not eligible for Merkl rewards.")," ",f&&(0,i.jsx)(e6.A,{fontSize:"inherit",color:"currentColor",external:!0,href:f,children:c("Details")})]})}):null,u?null:(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:a||m||v,onClick:p,children:c(m?"Claiming...":"Claim")})]})}var e5=n(32654),e7=n(170601),te=n(427575);function tt(e){let{poolAddress:t,chainId:n}=e,{t:r}=(0,l.A)(),{hasIncentra:a,incentraCampaignType:s}=(0,e7.uw)(t);if(!a)return null;let u=(0,te.n)({hasIncentra:a,chainId:n,lpAddress:t,campaignType:s});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(L.k0,{mt:"16px",padding:"16px",borderRadius:"24px",style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsx)(o.y,{color:"secondary",mb:"8px",children:r("Incentra Rewards")}),(0,i.jsx)(M.A,{small:!0,color:"textSubtle",children:r("This pool has active Incentra rewards. Claim on Incentra's website.")})]}),(0,i.jsx)(D.A,{as:"a",href:null!=u?u:te.G,target:"_blank",rel:"noopener noreferrer",mt:"16px",width:"100%",variant:"primary60Outline",children:(0,i.jsxs)(d.A,{gap:"4px",alignItems:"center",children:[r("Claim on Incentra"),(0,i.jsx)(e5.A,{width:"16px",color:"currentColor"})]})})]})}let tn=e=>{var t,n;let{position:r,poolInfo:o}
1=e,{t:a}=(0,l.A)(),{chainId:s}=(0,X.W7)(),{switchNetworkIfNecessary:d,isLoading:u}=(0,ev.Hk)(),[,c]=(0,eW.r)(),p=(0,eZ.se)(),x=null!=(t=r.chainId)?t:o.chainId,h=s!==x,f=o.token0,y=o.token1,{poolKey:g,tokenId:A,tickLower:b,tickUpper:w}=r,j=(0,m.useMemo)(()=>g?(0,eg.Qn)(g):void 0,[g]),{feeAmount0:k,feeAmount1:C,fiatValue0:I,fiatValue1:S}=(0,eU.O)({currency0:f,currency1:y,tokenId:A,poolId:j,tickLower:b,tickUpper:w}),R=(0,m.useMemo)(()=>I?Number(I.toExact()):void 0,[I]),N=(0,m.useMemo)(()=>S?Number(S.toExact()):void 0,[S]),P=(0,m.useMemo)(()=>{if(void 0!==R||void 0!==N)return(null!=R?R:0)+(null!=N?N:0)},[R,N]),{onCollect:T,attemptingTx:U}=(0,eJ.A)({chainId:x,onDone:e=>c({blockHash:e,status:"success"})}),B=async()=>{g&&await T({tokenId:A,poolKey:g,wrapAddress:ep.Xd,amount0Desired:null==k?void 0:k.quotient,amount1Desired:null==C?void 0:C.quotient,currency0:f,currency1:y})},F=U||!((null==k?void 0:k.greaterThan(0))||(null==C?void 0:C.greaterThan(0))),{rewardsCurrencyAmount:q,totalRewardsAmount:L,totalRewardsUSD:O,hasUnclaimedRewards:_}=eX({chainId:x,poolId:j,position:r}),$=_&&L.isGreaterThan(0);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(e1,{currency0:f,currency1:y,feeAmount0:k,feeAmount1:C,feeUsd0:R,feeUsd1:N,totalFeesUsd:P,onCollect:B,collecting:U,disabled:F,hideButton:h}),(0,i.jsxs)(v.Ay,{mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",fontSize:"14px",mb:"16px",lineHeight:"1.5",children:a("Open Harvest for farming rewards from your positions.")}),$?(0,i.jsx)(e2,{rewardToken:E.x_.cake,rewardsAmount:null!=(n=null==q?void 0:q.toSignificant(6))?n:L.toFixed(6),rewardsUSD:O,onHarvest:()=>null==p?void 0:p(),harvesting:!1,disabled:!p,hideButton:h}):h?null:(0,i.jsx)(D.A,{width:"100%",onClick:()=>null==p?void 0:p(),disabled:!p,children:a("Harvest")})]}),(0,i.jsx)(e4,{poolAddress:j,poolProtocol:o.protocol,chainId:x,disabled:h,hideButton:h}),(0,i.jsx)(tt,{poolAddress:j,chainId:x}),h&&(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>x?d(x):void 0,disabled:u,children:a("Switch Network")})]})},ti=e=>{var t,n;let{position:o,poolInfo:a}=e,{t:s}=(0,l.A)(),{chainId:d}=(0,X.W7)(),{switchNetworkIfNecessary:u,isLoading:c}=(0,ev.Hk)(),p=(0,eZ.se)(),m=null!=(t=o.chainId)?t:a.chainId,x=d!==m,h=o.poolKey?(0,eg.Qn)(o.poolKey):o.poolId,{rewardsCurrencyAmount:f,totalRewardsAmount:y,totalRewardsUSD:g,hasUnclaimedRewards:A}=eX({chainId:m,poolId:h,position:o}),b=A&&y.isGreaterThan(0);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(M.A,{color:"textSubtle",fontSize:"14px",mb:"16px",lineHeight:"1.5",children:s("Open Harvest for farming rewards from your positions.")}),b?(0,i.jsx)(e2,{rewardToken:E.x_.cake,rewardsAmount:null!=(n=null==f?void 0:f.toSignificant(6))?n:y.toFixed(6),rewardsUSD:g,onHarvest:()=>null==p?void 0:p(),harvesting:!1,disabled:!p,hideButton:x}):x?null:(0,i.jsx)(D.A,{width:"100%",onClick:()=>null==p?void 0:p(),disabled:!p,children:s("Harvest")}),(0,i.jsx)(e4,{poolAddress:h,poolProtocol:r.Zs.InfinityBIN,chainId:m,disabled:x,hideButton:x}),(0,i.jsx)(tt,{poolAddress:h,chainId:m}),x&&(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>m?u(m):void 0,disabled:c,children:s("Switch Network")})]})},tr=e=>{var t,n;let{poolId:o,chainId:a,position:s,tab:u="Add"}=e,{t:c}=(0,l.A)(),x=(0,R.qX)({poolAddress:o,chainId:a}),A=o&&(0,g.F8)(a)&&null!=(t=(0,p.QR)(o))?t:o,E=b({queryKey:["poolInfo",a,A]}),M=null!=(n=null==x?void 0:x.poolId)?n:o,N=(0,S.rB)({chainId:a,poolId:M?String(M):void 0}),T=(null==s?void 0:s.protocol)===r.Zs.InfinityCLAMM,U=T?s:void 0,B=T?void 0:s,{outOfRange:D,removed:F}=(0,R.RI)(U),q=(0,m.useMemo)(()=>!!B&&null!==B.minBinId&&null!==B.maxBinId&&(B.activeId<B.minBinId||B.activeId>B.maxBinId),[B]),L=(0,m.useMemo)(()=>!!B&&0n===B.liquidity,[B]);if(!x)return E?(0,i.jsx)(h.A,{justifyContent:"center",py:"48px",children:(0,i.jsx)(f.A,{})}):"Unable to fetch pool info, or pool does not exist";let O=!!(x.isFarming||N||s&&"isStaked"in s&&s.isStaked);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(P,{currency0:x.token0,currency1:x.token1,feeTierDisplay:(0,i.jsx)(w.Eu,{poolId:o,poolInfo:null!=x?x:void 0,chainId:a}),rangeTags:(0,i.jsxs)(d.A,{alignItems:"center",children:[(0,i.jsxs)(d.A,{gap:"4px",children:[(0,i.jsx)(j.K,{removed:T?F:L,outOfRange:T?D:q,protocol:x.protocol,lowContrast:!0}),O&&(0,i.jsx)(y.A,{variant:"primary60",children:c("Farming")})]}),(0,i.jsx)(k.cD,{poolAddress:x.lpAddress}),(0,i.jsx)(C.rW,{poolAddress:x.lpAddress})]}),aprDisplay:x&&s?x.protocol===r.Zs.InfinityBIN?(0,i.jsx)(I.IV,{pool:x,userPosition:s,textProps:{fontSize:"16px"}}):(0,i.jsx)(I.UB,{pool:x,userPosition:s,textProps:{fontSize:"16px"}}):null}),(0,i.jsx)(v.Ay,{mt:"16px",children:"Add"===u&&x.protocol===r.Zs.InfinityCLAMM?(0,i.jsx)(ey,{position:s,poolInfo:x}):"Add"===u&&x.protocol===r.Zs.InfinityBIN?(0,i.jsx)(eR,{position:s,poolInfo:x}):"Remove"===u&&x.protocol===r.Zs.InfinityCLAMM?(0,i.jsx)(eL,{position:s,poolInfo:x}):"Remove"===u&&x.protocol===r.Zs.InfinityBIN?(0,i.jsx)(eV,{position:s,poolInfo:x}):"Harvest"===u&&x.protocol===r.Zs.InfinityCLAMM?(0,i.jsx)(tn,{position:s,poolInfo:x}):"Harvest"===u&&x.protocol===r.Zs.InfinityBIN?(0,i.jsx)(ti,{position:s,poolInfo:x}):null})]})};var tl=n(854780),to=n(549333),ta=n(353540),ts=n(525033),td=n(183693),tu=n(157657),tc=n(97114),tp=n(306411),tm=n(909725),tx=n(189346),th=n(975644),tf=n(112616),tv=n(34334),ty=n(579670),tg=n(697115),tA=n(236088),tb=n(909114),tw=n(733775),tj=n(121480),tk=n(662928),tC=n(529208);let tI=e=>{let{poolAddress:t,chainId:n}=e,i=(0,tg.e)({chainId:n}),r=(0,m.useMemo)(()=>i&&t?new tj.Dp(t,i):null,[t,i]),l=!!r,{data:o}=(0,tk.I)({queryKey:["infinity-stable-total-supply",t,n],queryFn:async()=>r?r.totalSupply():null,enabled:l,...tC.MU});return l&&null!=o?o:null},tS=e=>{let{poolAddress:t,amounts:n,deposit:i=!0,enabled:r=!0,chainId:l}=e,o=(0,tg.e)({chainId:l}),a=(0,m.useMemo)(()=>o&&t?new tj.Dp(t,o):null,[t,o]),s=r&&!!a&&(n[0]>0n||n[1]>0n),{data:d,isLoading:u,error:c}=(0,tk.I)({queryKey:["infinity-stable-calc-token-amount",t,n[0].toString(),n[1].toString(),i,l],queryFn:async()=>a?a.calcTokenAmount(n,i):null,enabled:s,...tC.MU});return(0,m.useMemo)(()=>({tokenAmount:s&&null!=d?d:null,isLoading:!!s&&u,error:s&&null!=c?c:null}),[s,d,u,c])},tR=e=>{let{poolAddress:t,account:n,chainId:i}=e,r=(0,tg.e)({chainId:i}),l=(0,m.useMemo)(()=>r&&t?new tj.Dp(t,r):null,[t,r]),o=!!l&&!!n,{data:a}=(0,tk.I)({queryKey:["infinity-stable-user-lp-balance",t,n,i],queryFn:async()=>l&&n?l.balanceOf(n):null,enabled:o,...tC.MU});return o&&null!=a?a:null},tE=e=>{let{poolAddress:t,chainId:n}=e,i=(0,tg.e)({chainId:n}),r=(0,m.useMemo)(()=>i&&t?new tj.Dp(t,i):null,[t,i]),l=!!r,{data:o}=(0,tk.I)({queryKey:["infinity-stable-pool-balances",t,n],queryFn:async()=>
1{if(!r)return null;let[e,t]=await Promise.all([r.balances(0),r.balances(1)]);return[e,t]},enabled:l,...tC.MU});return l&&o?o:[null,null]},tM=e=>{var t,n;let{poolInfo:r}=e,{t:a}=(0,l.A)(),{currentLanguage:{locale:s}}=(0,l.A)(),{address:u}=(0,eq.F)(),{chainId:c}=(0,X.W7)(),p=r.token0,x=r.token1;(0,Y.yx)(p),(0,Y.yx)(x);let h=(0,Y.wG)(p),f=(0,Y.wG)(x),y=null==p?void 0:p.chainId,g=r.lpAddress,A=c!==y,{switchNetworkIfNecessary:b,isLoading:w}=(0,ev.Hk)(),[j]=(0,q.lB)(),[k]=(0,q.uZ)(),C=(0,tu.LU)(p,x),I=(0,tu.aS)(p,x),[S,R]=(0,m.useState)(""),[E,N]=(0,m.useState)(""),[{attemptingTxn:P,liquidityErrorMessage:U,txHash:B},F]=(0,m.useState)({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),[O,_]=(0,m.useState)(void 0),[$,z]=(0,m.useState)(!1),{addLiquidityInfinityStablePool:V,estimateAddLiquidityInfinityStablePool:H,isReady:G}=(e=>{let{poolAddress:t}=e,n=(0,tg.e)(),{chainId:i}=(0,X.ax)(),{sendTransactionAsync:r}=(0,tA.s)(),{maxFeePerGas:l,maxPriorityFeePerGas:o}=(0,tb.N)(i),{address:a}=(0,eq.F)(),s=(0,m.useMemo)(()=>n&&t?new tj.Dp(t,n):null,[t,n]),d=(0,m.useCallback)(async(e,t,i)=>{if(!n)throw Error("Public client not available");if(!a)throw Error("Account not connected");return n.estimateGas({account:a,to:e,data:t,value:i})},[n,a]),u=(0,m.useCallback)(async(e,t,i)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let d=s.getAddLiquidityCalldata(e,t,i),u=d.value?BigInt(d.value):void 0,c=await n.estimateGas({account:a,to:d.address,data:d.calldata,value:u});return await r({to:d.address,data:d.calldata,value:u,gas:(0,tw.KL)(c),maxFeePerGas:l,maxPriorityFeePerGas:o})},[s,a,n,r,l,o]),c=(0,m.useCallback)(async(e,t,n)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let i=s.getAddLiquidityCalldata(e,t,n);return d(i.address,i.calldata,i.value?BigInt(i.value):void 0)},[s,a,d]);return(0,m.useMemo)(()=>({addLiquidityInfinityStablePool:u,estimateAddLiquidityInfinityStablePool:c,isReady:!!s}),[u,c,s])})({poolAddress:g}),K=(0,tp.OQ)(),[ee,et]=(0,eI.pl)(u,[p,x],y),en=(0,Y.dm)(S,null!=p?p:void 0),eo=(0,Y.dm)(E,null!=x?x:void 0),ea=(0,m.useMemo)(()=>{var e,t;return[null!=(e=null==en?void 0:en.quotient)?e:0n,null!=(t=null==eo?void 0:eo.quotient)?t:0n]},[en,eo]),{tokenAmount:es,error:ed}=tS({poolAddress:g,amounts:ea,deposit:!0,enabled:G&&(ea[0]>0n||ea[1]>0n)}),eu=tI({poolAddress:g}),ep=tR({poolAddress:g,account:u,chainId:y}),[em,ex]=tE({poolAddress:g,chainId:y}),[eh,ey]=(0,m.useMemo)(()=>eu&&0n!==eu&&em&&ex&&ep?[ep*em/eu,ep*ex/eu]:[0n,0n],[ep,em,ex,eu]),eg=(0,m.useMemo)(()=>p&&eh>0n?eA.eF.fromRawAmount(p,eh):void 0,[p,eh]),eb=(0,m.useMemo)(()=>x&&ey>0n?eA.eF.fromRawAmount(x,ey):void 0,[x,ey]),ew=(0,m.useMemo)(()=>{var e;return p?eA.eF.fromRawAmount(p,eh+(null!=(e=null==en?void 0:en.quotient)?e:0n)):void 0},[p,eh,en]),ej=(0,m.useMemo)(()=>{var e;return x?eA.eF.fromRawAmount(x,ey+(null!=(e=null==eo?void 0:eo.quotient)?e:0n)):void 0},[x,ey,eo]),ek=null==eg?void 0:eg.toExact(),eC=null==ew?void 0:ew.toExact(),eS=null==eb?void 0:eb.toExact(),eR=null==ej?void 0:ej.toExact(),eE=(0,tc.Z)({currency0:p,currency1:x,amount0:eg,amount1:eb}),eM=(0,tc.Z)({currency0:p,currency1:x,amount0:ew,amount1:ej}),eN=(0,tc.Z)({currency0:p,currency1:x,amount0:en,amount1:eo}),eP=!!((null==en?void 0:en.greaterThan(0))||(null==eo?void 0:eo.greaterThan(0))),eT=(0,m.useMemo)(()=>({[el.O9.CURRENCY_A]:(0,er.r)(ee),[el.O9.CURRENCY_B]:(0,er.r)(et)}),[ee,et]),eU=(0,m.useMemo)(()=>{let e=eT[el.O9.CURRENCY_A];return!!u&&!!en&&!!e&&e.lessThan(en)},[u,en,eT]),eB=(0,m.useMemo)(()=>{let e=eT[el.O9.CURRENCY_B];return!!u&&!!eo&&!!e&&e.lessThan(eo)},[u,eo,eT]),eD=(0,m.useMemo)(()=>{var e,t;return en&&ee&&en.greaterThan(ee)?a("Insufficient %symbol% balance",{symbol:null!=(e=null==p?void 0:p.symbol)?e:""}):eo&&et&&eo.greaterThan(et)?a("Insufficient %symbol% balance",{symbol:null!=(t=null==x?void 0:x.symbol)?t:""}):void 0},[en,eo,ee,et,p,x,a]),eL=(0,m.useMemo)(()=>es&&eu&&eu>0n?new eA.QE(es,eu+es):new eA.QE(0n,1n),[es,eu]);(0,m.useEffect)(()=>{let e=!1,t=setTimeout(async()=>{let t=ea[0]>0n||ea[1]>0n;if(!G||!u||!t||!es||eD||ed){_(void 0),z(!1);return}let n=(0,ei.wQ)(eA.eF.fromRawAmount(p,es),k)[0];z(!0),_(void 0);try{await H(ea[0],ea[1],n),e||(_(void 0),z(!1))}catch(t){e||(t&&!(0,tx.U)(t)?_((0,th.w)(t,a)):_(void 0),z(!1))}},500);return()=>{e=!0,clearTimeout(t)}},[G,u,ea,es,p,k,eD,ed,H,a]);let{approvalState:eO,approveCallback:e_}=(0,J.CT)({token:(null==p?void 0:p.isToken)?p:void 0,minAmount:null==en?void 0:en.quotient,spender:g}),{approvalState:e$,approveCallback:eY}=(0,J.CT)({token:(null==x?void 0:x.isToken)?x:void 0,minAmount:null==eo?void 0:eo.quotient,spender:g}
1),ez=[J.h$.NOT_APPROVED,J.h$.PENDING].includes(eO)&&!!en,eV=[J.h$.NOT_APPROVED,J.h$.PENDING].includes(e$)&&!!eo,eZ=ez||eV,eW=(0,m.useCallback)(async()=>{var e,t;if(!p||!x||!en&&!eo||!es)return;let n=(0,ei.wQ)(eA.eF.fromRawAmount(p,es),k)[0],i=null!=(e=null==en?void 0:en.quotient)?e:0n,r=null!=(t=null==eo?void 0:eo.quotient)?t:0n;F({attemptingTxn:!0,liquidityErrorMessage:void 0,txHash:void 0});try{let e=await V(i,r,n);F({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:e});let t=null==p?void 0:p.symbol,l=(null==en?void 0:en.toSignificant(3))||"0",o=null==x?void 0:x.symbol,a=(null==eo?void 0:eo.toSignificant(3))||"0";K({hash:e},{summary:`Add ${l} ${t} and ${a} ${o}`,translatableSummary:{text:"Add %amountA% %symbolA% and %amountB% %symbolB%",data:{amountA:l,symbolA:t,amountB:a,symbolB:o}},type:"add-liquidity"})}catch(e){e&&!(0,tx.U)(e)&&((0,tx.v)(e),console.error("Add liquidity failed:",e)),F({attemptingTxn:!1,liquidityErrorMessage:e&&!(0,tx.U)(e)?a("Add liquidity failed: %message%",{message:(0,th.w)(e,a)}):void 0,txHash:void 0})}},[p,x,en,eo,es,V,k,K,a]),eH=a("Supplying %amountA% %symbolA% and %amountB% %symbolB%",{amountA:(0,tm.N)(en,4,s),symbolA:null!=(t=null==p?void 0:p.symbol)?t:"",amountB:(0,tm.N)(eo,4,s),symbolB:null!=(n=null==x?void 0:x.symbol)?n:""}),eQ=(0,m.useCallback)(()=>{B&&(R(""),N("")),F({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0})},[B]),eG=(0,m.useMemo)(()=>({[el.O9.CURRENCY_A]:p,[el.O9.CURRENCY_B]:x}),[p,x]),eK=(0,m.useMemo)(()=>({[el.O9.CURRENCY_A]:en,[el.O9.CURRENCY_B]:eo}),[en,eo]),eX=(0,m.useMemo)(()=>{if(es&&p&&g)return new eA.ou(p.chainId,g,18,"LP","LP Token")},[p,g,es]),eJ=(0,m.useMemo)(()=>{if(eX&&es)return eA.eF.fromRawAmount(eX,es)},[eX,es]),[e0]=(0,to.A)((0,i.jsx)(ty.A,{title:a("You will receive"),customOnDismiss:eQ,attemptingTxn:P,hash:B,pendingText:eH,currencyToAdd:void 0,allowedSlippage:k,onAdd:eW,parsedAmounts:eK,currencies:eG,liquidityErrorMessage:U,price:void 0,noLiquidity:!1,poolTokenPercentage:eL,liquidityMinted:eJ,isStable:!0}),!0,!0,"infinitySSAddLiquidityModal"),e1=!G||!S&&!E||!!eD||!es||!!ed||eO===J.h$.PENDING||e$===J.h$.PENDING||ez||eV||!!O||$,e2=G?S||E?eD||(ed?a("Cannot add liquidity with current amounts"):eO===J.h$.PENDING||e$===J.h$.PENDING?a("Waiting for approval..."):ez||eV?a("Approval required"):$?a("Checking..."):O?a("Cannot add liquidity with current amounts"):void 0):a("Please enter at least one amount"):a("Pool not ready"),e6=(0,m.useCallback)(()=>A?(0,i.jsx)(D.A,{width:"100%",onClick:()=>y?b(y):void 0,disabled:w,children:a("Switch Network")}):C||I?(0,i.jsx)(D.A,{disabled:!0,children:a("Unsupported Asset")}):(0,i.jsxs)(i.Fragment,{children:[eZ&&(0,i.jsxs)(T.JA,{style:{gap:"8px"},mb:"8px",children:[ez&&(0,i.jsx)(D.A,{onClick:e_,disabled:eO===J.h$.PENDING,width:"100%",children:eO===J.h$.PENDING?(0,i.jsx)(ta.n,{children:a("Enabling %asset%",{asset:null==p?void 0:p.symbol})}):a("Enable %asset%",{asset:null==p?void 0:p.symbol})}),eV&&(0,i.jsx)(D.A,{onClick:eY,disabled:e$===J.h$.PENDING,width:"100%",children:e$===J.h$.PENDING?(0,i.jsx)(ta.n,{children:a("Enabling %asset%",{asset:null==x?void 0:x.symbol})}):a("Enable %asset%",{asset:null==x?void 0:x.symbol})})]}),(0,i.jsx)(td.O,{variant:e1?"danger":"primary",onClick:()=>{j?eW():e0(),(0,eF.uL)()},disabled:e1,width:"100%",children:e2||a("Add")})]}),[A,e1,e2,y,w,b,C,I,eZ,ez,eV,e_,eY,eO,e$,p,x,j,eW,e0,a]);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(Q.S,{currency:p}),(0,i.jsx)(Q.S,{currency:x}),(0,i.jsx)(o.y,{children:a("Amount of Liquidity to Add")}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:a("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{gap:"4px",alignItems:"center",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:a("Slippage Bonus")}),(0,i.jsx)(ts.PT,{text:a("Extra LP tokens earned when depositing the low-balance coin in the pool, appearing as a bonus for helping rebalance."),placement:"top-start",mt:"1px"})]}),(0,i.jsx)(tv._,{slippage:new eA.QE(k,1e4),loading:$,small:!0})]}),(0,i.jsxs)(L.k0,{mt:"16px",borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(W.A,{id:"position-modal-increase-infinity-ss-A",defaultValue:S,currency:p,onUserInput:R,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},onPercentInput:e=>{var t,n;let i=null==(t=eT[el.O9.CURRENCY_A])?void 0:t.multiply(new eA.QE(e,100));i&&R(null!=(n=h(i))?n:"")},onMax:()=>{var e;let t=eT[el.O9.CURRENCY_A];R(t&&null!=(e=h(t))?e:"")},maxAmount:eT[el.O9.CURRENCY_A],showMaxButton:!0,disableCurrencySelect:!0,showUSDPrice:!0,isUserInsufficientBalance:eU}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(W.A,{id:"position-modal-increase-infinity-ss-B",defaultValue:E,currency:x,onUserInput:N,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},onPercentInput:e=>{var t,n;let i=null==(t=eT[el.O9.CURRENCY_B])?void 0:t.multiply(new eA.QE(e,100));i&&N(null!=(n=f(i))?n:"")},onMax:()=>{var e;let t=eT[el.O9.CURRENCY_B];N(t&&null!=(e=f(t))?e:"")},maxAmount:eT[el.O9.CURRENCY_B],showMaxButton:!0,disableCurrencySelect:!0,showUSDPrice:!0,isUserInsufficientBalance:eB})})]}),p&&x&&eP&&(0,i.jsx)(Z,{currency0:p,currency1:x,currency0Amount:h(eg,6)||"0",currency0NewAmount:h(ew,6)||"0",currency1Amount:f(eb,6)||"0",currency1NewAmount:f(ej,6)||"0",currency0AmountRaw:ek,currency0NewAmountRaw:eC,currency1AmountRaw:eS,currency1NewAmountRaw:eR,totalPositionUsd:(0,tf.o5)(eE,2,!1),totalPositionNewUsd:(0,tf.o5)(eM,2,!1),amountUsd:(0,tf.o5)(eN,2,!1),amountUsdLabel:a("Total deposit value (USD)")}),(0,i.jsx)(v.Ay,{mt:"16px",children:(0,i.jsx)(ef.u,{size:"sm"})}),(0,i.jsx)(v.Ay,{mt:"16px",children:e6()})]})};var tN=n(933752),tP=n(696368),tT=n(310085);function tU(e){let{label:t,checked:n,onChange:r}=e;return(0,i.jsxs)(h.A,{alignItems:"center",style:{cursor:"pointer"},onClick:r,children:[(0,i.jsx)(M.A,{bold:!0,small:!0,color:"textSubtle",mr:"4px",children:t}),(0,i.jsx)(tT.A,{scale:"sm",checked:n,onChange:r})]})}var tB=function(e){return e.BALANCE="balance",e.ONE_COIN="onecoin",e.CUSTOM="custom",e}({});let tD=e=>{var t,n,r,a,s,c;let{poolInfo:p}=e,{t:x}=(0,l.A)(),{account:f,chainId:y}=(0,X.W7)(),{switchNetworkIfNecessary:g,isLoading:A}=(0,ev.Hk)(),b=p.chainId,w=(0,u.jE)(),j=(0,tg.e)({chainId:b}),k=p.token0,C=p.token1;(0,Y.yx)(k),(0,Y.yx)(C);let I=(0,Y.wG)(k),S=(0,Y.wG)(C),R=(0,Y.fA)(k),E=(0,Y.fA)(C),N=p.lpAddress,[P,U]=(0,m.useState)(0),[B,F]=(0,m.useState)(tB.BALANCE),[L,O]=(0,m.useState)(0),[$,z]=(0,m.useState)(""),[V,H]=(0,m.useState)(""),[{attemptingTxn:G,liquidityErrorMessage:K,txHash:ee},et]=(0,m.useState)({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),[en,er]=(0,m.useState)(void 0),[el,eo]=(0,m.useState)(!1),{removeLiquidityInfinityStablePool:ea,removeLiquidityOneCoin:es,removeLiquidityImbalance:ed,estimateRemoveLiquidityInfinityStablePool:eu,estimateRemoveLiquidityOneCoin:ep,estimateRemoveLiquidityImbalance:em,isReady:ex}=(e=>{let{poolAddress:t,chainId:n}=e,i=(0,tg.e)({chainId:n}),{sendTransactionAsync:r}=(0,tA.s)(),{maxFeePerGas:l,maxPriorityFeePerGas:o}=(0,tb.N)(n),{address:a}=(0,eq.F)(),s=(0,m.useMemo)(()=>i&&t?new tj.Dp(t,i):null,[t,i]),d=(0,m.useCallback)(async(e,t,n)=>{if(!i)throw Error("Public client not available");if(!a)throw Error("Account not connected");return i.estimateGas({account:a,to:e,data:t,value:n})},[i,a]),u=(0,m.useCallback)(async(e,t,n)=>{if(!i)throw Error("Public client not available");if(!a)throw Error("Account not connected");return i.estimateGas({account:a,to:e,data:t,value:n}).then(i=>(console.log("success estimate gas: ",{to:e,data:t,value:n}),r({to:e,data:t,value:n,gas:(0,tw.KL)(i),maxFeePerGas:l,maxPriorityFeePerGas:o})))},[i,a,r,l,o]),c=(0,m.useCallback)(async(e,t,n)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let i=s.getRemoveLiquidityCalldata(e,t,n,a);return await u(i.address,i.calldata,i.value?BigInt(i.value):void 0)},[s,a,u]),p=(0,m.useCallback)(async(e,t,n)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let i=s.getRemoveLiquidityOneCoinCalldata(e,t,n);return await u(i.address,i.calldata,i.value?BigInt(i.value):void 0)},[s,a,u]),x=(0,m.useCallback)(async(e,t,n)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let i=s.getRemoveLiquidityImbalanceCalldata(e,t,n);return await u(i.address,i.calldata,i.value?BigInt(i.value):void 0)},[s,a,u]),h=(0,m.useCallback)(async(e,t,n)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let i=s.getRemoveLiquidityCalldata(e,t,n,a);return d(i.address,i.calldata,i.value?BigInt(i.value):void 0)},[s,a,d]),f=(0,m.useCallback)(async(e,t,n)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let i=s.getRemoveLiquidityOneCoinCalldata(e,t,n);return d(i.address,i.calldata,i.value?BigInt(i.value):void 0)},[s,a,d]),v=(0,m.useCallback)(async(e,t,n)=>{if(!s)throw Error("InfinityStableHook not initialized");if(!a)throw Error("Account not connected");let i=s.getRemoveLiquidityImbalanceCalldata(e,t,n);return d(i.address,i.calldata,i.value?BigInt(i.value):void 0)},[s,a,d]);return(0,m.useMemo)(()=>({removeLiquidityInfinityStablePool:c,removeLiquidityOneCoin:p,removeLiquidityImbalance:x,estimateRemoveLiquidityInfinityStablePool:h,estimateRemoveLiquidityOneCoin:f,estimateRemoveLiquidityImbalance:v,isReady:!!s}),[c,p,x,h,f,v,s])})({poolAddress:N,chainId:b}),ef=(0,tp.OQ)(),[ey]=(0,q.uZ)(),eg=tR({poolAddress:N,account:f,chainId:b}),eb=tI({poolAddress:N,chainId:b}),[ew,ej]=tE({poolAddress:N,chainId:b}),ek=(0,m.useMemo)(()=>eg&&0!==P?eg*BigInt(P)/100n:0n,[eg,P]),[eC,eI]=(0,m.useMemo)(()=>eb&&0n!==eb&&ew&&ej&&0n!==ek?[ek*ew/eb,ek*ej/eb]:[0n,0n],[ek,ew,ej,eb]),{tokenAmount:eS}=tS({poolAddress:N,amounts:(0,m.useMemo)(()=>[eC,eI],[eC,eI]),deposit:!1,enabled:ex&&ek>0n,chainId:b}),eR=(0,m.useMemo)(()=>
1{if(k&&0n!==eC)return eA.eF.fromRawAmount(k,eC)},[k,eC]),eM=(0,m.useMemo)(()=>{if(C&&0n!==eI)return eA.eF.fromRawAmount(C,eI)},[C,eI]),eN=(0,Y.Wu)(eR,6),eP=(0,Y.Wu)(eM,6),{amount:eU}=(e=>{let{poolAddress:t,burnAmount:n,index:i,enabled:r=!0,chainId:l}=e,o=(0,tg.e)({chainId:l}),a=(0,m.useMemo)(()=>o&&t?new tj.Dp(t,o):null,[t,o]),s=r&&!!a&&n>0n,{data:d,isLoading:u,error:c}=(0,tk.I)({queryKey:["infinity-stable-calc-withdraw-one-coin",t,n.toString(),i,l],queryFn:async()=>a?a.calcWithdrawOneCoin(n,i):null,enabled:s,...tC.MU});return(0,m.useMemo)(()=>({amount:s&&null!=d?d:null,isLoading:!!s&&u,error:s&&null!=c?c:null}),[s,d,u,c])})({poolAddress:N,burnAmount:ek,index:L,enabled:B===tB.ONE_COIN&&ek>0n&&ex,chainId:b}),eB=null!=eU?eU:0n;(0,m.useEffect)(()=>{var e,t;if(B===tB.CUSTOM){if(0===P){z(""),H("");return}k&&z(eC>0n&&null!=(e=I(eA.eF.fromRawAmount(k,eC)))?e:""),C&&H(eI>0n&&null!=(t=S(eA.eF.fromRawAmount(C,eI)))?t:"")}},[B,P]);let eD=(0,Y.dm)($,null!=k?k:void 0),eL=(0,Y.dm)(V,null!=C?C:void 0),eO=(0,m.useMemo)(()=>{var e;return null!=(e=null==eD?void 0:eD.quotient)?e:0n},[eD]),e_=(0,m.useMemo)(()=>{var e;return null!=(e=null==eL?void 0:eL.quotient)?e:0n},[eL]),{tokenAmount:e$}=tS({poolAddress:N,amounts:[eO,e_],deposit:!1,enabled:B===tB.CUSTOM&&eO>0n&&e_>0n,chainId:b}),eY=(0,m.useMemo)(()=>{if(k&&N)return new eA.ou(k.chainId,N,18,"LP","LP Token")},[k,N]),[ez,eV]=(0,m.useMemo)(()=>eb&&0n!==eb&&ew&&ej&&eg?[eg*ew/eb,eg*ej/eb]:[0n,0n],[eg,ew,ej,eb]),eZ=(0,m.useCallback)(async()=>{if(k&&C){et({attemptingTxn:!0,liquidityErrorMessage:void 0,txHash:void 0});try{var e,t,n,i,r;let l,o=null==k?void 0:k.symbol,a=null==C?void 0:C.symbol,s="0",d="0";if(B===tB.BALANCE){if(!ek||0n===ek)return;let n=eR?(0,ei.wQ)(eR,ey)[0]:0n,i=eM?(0,ei.wQ)(eM,ey)[0]:0n;l=await ea(ek,n,i),s=eR?null!=(e=R(eR.quotient,eR.currency.decimals))?e:"-":"0",d=eM?null!=(t=E(eM.quotient,eM.currency.decimals))?t:"-":"0"}else if(B===tB.ONE_COIN){if(!ek||0n===ek||0n===eB)return;let e=0===L?k:C,t=eA.eF.fromRawAmount(e,eB),i=(0,ei.wQ)(t,ey)[0];l=await es(ek,0===L,i);let r=null!=(n=(0===L?R:E)(t.quotient,t.currency.decimals))?n:"-";0===L?s=r:d=r}else{if(void 0===eD||void 0===eL||!e$||0n===e$||!eY)return;let e=(0,ei.wQ)(eA.eF.fromRawAmount(eY,e$),ey)[1];l=await ed(eO,e_,e),s=null!=(i=R(eD.quotient,eD.currency.decimals))?i:"-",d=null!=(r=E(eL.quotient,eL.currency.decimals))?r:"-"}et({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:l}),ef({hash:l},{summary:`Remove ${s} ${o} and ${d} ${a}`,translatableSummary:{text:"Remove %amountA% %symbolA% and %amountB% %symbolB%",data:{amountA:s,symbolA:o,amountB:d,symbolB:a}},type:"remove-liquidity"}),j&&j.waitForTransactionReceipt({hash:l}).then(()=>{w.invalidateQueries({queryKey:["infinity-stable-user-lp-balance",N,f]}),w.invalidateQueries({queryKey:["infinity-stable-total-supply",N]}),w.invalidateQueries({queryKey:["infinity-stable-pool-balances",N]}),w.invalidateQueries({queryKey:["infinity-stable-calc-token-amount",N]}),w.invalidateQueries({queryKey:["infinity-stable-calc-withdraw-one-coin",N]})}).catch(()=>{})}catch(e){e&&!(0,tx.U)(e)&&((0,tx.v)(e),console.error("Remove liquidity failed:",e)),et({attemptingTxn:!1,liquidityErrorMessage:e&&!(0,tx.U)(e)?x("Remove liquidity failed: %message%",{message:(0,th.w)(e,x)}):void 0,txHash:void 0})}}},[k,C,B,ek,eR,eM,eB,L,eD,eL,eO,e_,e$,eY,ea,es,ed,ey,ef,x,j,w,N,f,R,E]),eW=(0,m.useCallback)(()=>{ee&&U(0),et({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0})},[ee]),eH=(0,m.useCallback)(e=>U(e),[]),[eQ,eG]=(0,eE.Vv)(P,eH),eK=(0,m.useCallback)(e=>eG(Math.ceil(Number(e))),[eG]),eX=(0,m.useMemo)(()=>{let e,t;return B===tB.BALANCE?(e=eR,t=eM):B===tB.ONE_COIN?0===L&&k&&eB>0n?e=eA.eF.fromRawAmount(k,eB):1===L&&C&&eB>0n&&(t=eA.eF.fromRawAmount(C,eB)):B===tB.CUSTOM&&(e=k&&eO>0n?eA.eF.fromRawAmount(k,eO):void 0,t=C&&e_>0n?eA.eF.fromRawAmount(C,e_):void 0),{[tP.D.LIQUIDITY_PERCENT]:new eA.QE(P,100),CURRENCY_A:e,CURRENCY_B:t}},[B,eR,eM,L,k,C,eB,eO,e_,P]),eJ=(0,m.useMemo)(()=>{var e,t,n,i;let r=eX.CURRENCY_A&&null!=(e=R(eX.CURRENCY_A.quotient,eX.CURRENCY_A.currency.decimals))?e:"",l=eX.CURRENCY_B&&null!=(t=E(eX.CURRENCY_B.quotient,eX.CURRENCY_B.currency.decimals))?t:"";return x("Removing %amountA% %symbolA% and %amountB% %symbolB%",{amountA:r,symbolA:null!=(n=null==k?void 0:k.symbol)?n:"",amountB:l,symbolB:null!=(i=null==C?void 0:C.symbol)?i:""})},[eX,k,C,R,E,x]),[e0]=(0,to.A)((null==k?void 0:k.wrapped)&&(null==C?void 0:C.wrapped)?(0,i.jsx)(tN.A,{approval:J.h$.APPROVED,title:x("You will receive"),customOnDismiss:eW,attemptingTxn:G,hash:ee||"",allowedSlippage:ey,onRemove:eZ,pendingText:eJ,tokenA:k.wrapped,tokenB:C.wrapped,liquidityErrorMessage:K,parsedAmounts:eX,currencyA:k,currencyB:C}):(0,i.jsx)(i.Fragment,{}),!0,!0,"infinitySSRemoveLiquidityModal"),e1=(0,m.useCallback)(()=>{en||(et({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),e0())},[e0,en]);(0,m.useEffect)(()=>{let e=!1,t=setTimeout(async()=>
1{if(!ex||!f){er(void 0),eo(!1);return}try{let t=!1,n=null;if(B===tB.BALANCE){if((t=ek>0n)&&eR&&eM){let e=(0,ei.wQ)(eR,ey)[0],t=(0,ei.wQ)(eM,ey)[0];n=eu(ek,e,t)}}else if(B===tB.ONE_COIN){if(t=ek>0n&&eB>0n){let e=0===L?k:C;if(e){let t=eA.eF.fromRawAmount(e,eB),i=(0,ei.wQ)(t,ey)[0];n=ep(ek,0===L,i)}}}else if(B===tB.CUSTOM){let e=eO>0n||e_>0n,i=0n===eO||eO<=ez,r=0n===e_||e_<=eV,l=null!=e$&&e$>0n;if((t=e&&i&&r&&l)&&e$&&eY){let e=(0,ei.wQ)(eA.eF.fromRawAmount(eY,e$),ey)[1];n=em(eO,e_,e)}}if(!t||!n){er(void 0),eo(!1);return}eo(!0),er(void 0),await n,e||(er(void 0),eo(!1))}catch(t){e||(t&&!(0,tx.U)(t)?er((0,th.w)(t,x,[tB.ONE_COIN,tB.CUSTOM].includes(B)?x("Unknown error: might be due to low liquidity. Try to remove with Balance mode."):void 0)):er(void 0),eo(!1))}},500);return()=>{e=!0,clearTimeout(t)}},[B,ek,eR,eM,eB,L,eO,e_,e$,eY,ez,eV,ey,eu,ep,em,ex,f,k,C,x]);let e2=(0,m.useMemo)(()=>{if(!ex||en)return!1;if(B===tB.BALANCE)return ek>0n;if(B===tB.ONE_COIN)return ek>0n&&eB>0n;if(B===tB.CUSTOM){let e=eO>0n||e_>0n,t=0n===eO||eO<=ez,n=0n===e_||e_<=eV,i=null!=e$&&e$>0n;return e&&t&&n&&i}return!1},[B,ek,eB,eO,e_,e$,ex,ez,eV,en]),e6=(0,m.useMemo)(()=>{if(B!==tB.CUSTOM)return null;let e=[];return eO>0n&&eO>ez&&k&&e.push(k.symbol||"Token"),e_>0n&&e_>eV&&C&&e.push(C.symbol||"Token"),e.length>0?e.join(" and "):null},[B,eO,e_,ez,eV,k,C]),e8=e=>e<0n||e<100n?0n:e,[e3,e9]=(0,m.useMemo)(()=>{let e=e=>{if(!eb||0n===eb||!ew||!ej||!eg)return[ez,eV];let t=eg>e?eg-e:0n;return[e8(t*ew/eb),e8(t*ej/eb)]};return B===tB.BALANCE&&eS?e(eS):B===tB.ONE_COIN?e(ek):B===tB.CUSTOM?[e8(ez>eO?ez-eO:0n),e8(eV>e_?eV-e_:0n)]:[ez,eV]},[B,ez,eV,eS,ek,eO,e_,eg,eb,ew,ej]),e4=(0,m.useMemo)(()=>k&&ez>0n?eA.eF.fromRawAmount(k,ez):void 0,[k,ez]),e5=(0,m.useMemo)(()=>C&&eV>0n?eA.eF.fromRawAmount(C,eV):void 0,[C,eV]),e7=(0,m.useMemo)(()=>k?eA.eF.fromRawAmount(k,e3):void 0,[k,e3]),te=(0,m.useMemo)(()=>C?eA.eF.fromRawAmount(C,e9):void 0,[C,e9]),tt=null==e4?void 0:e4.toExact(),tn=null==e7?void 0:e7.toExact(),ti=null==e5?void 0:e5.toExact(),tr=null==te?void 0:te.toExact(),tl=(0,tc.Z)({currency0:k,currency1:C,amount0:e4,amount1:e5}),ta=(0,tc.Z)({currency0:k,currency1:C,amount0:e7,amount1:te}),[ts,td]=(0,m.useMemo)(()=>{if(B===tB.BALANCE)return[eR,eM];if(B===tB.ONE_COIN){if(0===L&&k&&eB>0n)return[eA.eF.fromRawAmount(k,eB),void 0];if(1===L&&C&&eB>0n)return[void 0,eA.eF.fromRawAmount(C,eB)]}return B===tB.CUSTOM?[k&&eO>0n?eA.eF.fromRawAmount(k,eO):void 0,C&&e_>0n?eA.eF.fromRawAmount(C,e_):void 0]:[void 0,void 0]},[B,eR,eM,L,k,C,eB,eO,e_]),tu=(0,tc.Z)({currency0:k,currency1:C,amount0:ts,amount1:td}),tm=Math.max(tl-tu-ta,0),tv=ta>0?tm/ta*100:0,{data:ty}=(0,eh.GB)(k,{enabled:!!k}),{data:tM}=(0,eh.GB)(C,{enabled:!!C}),tT=(0,m.useMemo)(()=>eR&&ty?parseFloat(eR.toExact())*ty:0,[eR,ty]),tD=(0,m.useMemo)(()=>eM&&tM?parseFloat(eM.toExact())*tM:0,[eM,tM]),tF=(0,m.useMemo)(()=>0===L&&k&&0n!==eB&&ty?parseFloat(eA.eF.fromRawAmount(k,eB).toExact())*ty:0,[L,k,eB,ty]),tq=(0,m.useMemo)(()=>1===L&&C&&0n!==eB&&tM?parseFloat(eA.eF.fromRawAmount(C,eB).toExact())*tM:0,[L,C,eB,tM]),tL=ex?el?x("Checking..."):en||(0n===ek&&B!==tB.CUSTOM||B===tB.CUSTOM&&0n===eO&&0n===e_?x("Enter an amount"):e6?x("Insufficient %symbol% balance",{symbol:e6}):x("Remove")):x("Pool not ready");return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(Q.S,{currency:k}),(0,i.jsx)(Q.S,{currency:C}),(0,i.jsxs)(T.JA,{mb:"4px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:x("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),(0,i.jsx)(o.y,{mt:"16px",children:x("Amount of liquidity to remove")}),(0,i.jsxs)(_.k,{mt:"8px",padding:"16px",borderRadius:"24px",children:[(0,i.jsxs)(M.A,{fontSize:"40px",bold:!0,mb:"16px",style:{lineHeight:1},children:[eQ,"%"]}),(0,i.jsx)(eT.A,{name:"lp-amount",min:0,max:100,value:eQ,onValueChanged:e=>eG(Math.ceil(e)),mb:"16px"}),(0,i.jsxs)(d.A,{gap:"8px",justifyContent:"space-between",children:[(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eK("10"),width:"100%",borderRadius:"12px",children:"10%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eK("20"),width:"100%",borderRadius:"12px",children:"20%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eK("75"),width:"100%",borderRadius:"12px",children:"75%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eK("100"),width:"100%",borderRadius:"12px",children:x("Max.fill-max")})]})]}),(0,i.jsx)(o.y,{mt:"16px",mb:"8px",children:x("Collect as")}),(0,i.jsxs)(_.k,{padding:"16px",borderRadius:"24px",children:[(0,i.jsxs)(T.eF,{gap:"16px",mb:"16px",children:[(0,i.jsx)(tU,{label:
1x("One coin"),checked:B===tB.ONE_COIN,onChange:()=>F(tB.ONE_COIN)}),(0,i.jsx)(tU,{label:x("Balance"),checked:B===tB.BALANCE,onChange:()=>F(tB.BALANCE)}),(0,i.jsx)(tU,{label:x("Custom"),checked:B===tB.CUSTOM,onChange:()=>F(tB.CUSTOM)})]}),B===tB.BALANCE&&(0,i.jsxs)(d.A,{flexDirection:"column",gap:"8px",children:[(0,i.jsx)(_.k,{padding:"8px 16px",children:(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(_.Z,{showChainLogo:!0,currency:k,size:"32px"}),(0,i.jsx)(M.A,{bold:!0,children:null==k?void 0:k.symbol})]}),(0,i.jsxs)(h.A,{flexDirection:"column",alignItems:"flex-end",style:{gap:"4px"},children:[(0,i.jsx)(M.A,{bold:!0,children:eN||"0"}),(0,i.jsxs)(M.A,{fontSize:"12px",color:"textSubtle",children:["~",(0,tf.o5)(tT,2,!0)]})]})]})}),(0,i.jsx)(_.k,{padding:"8px 16px",children:(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(_.Z,{showChainLogo:!0,currency:C,size:"32px"}),(0,i.jsx)(M.A,{bold:!0,children:null==C?void 0:C.symbol})]}),(0,i.jsxs)(h.A,{flexDirection:"column",alignItems:"flex-end",style:{gap:"4px"},children:[(0,i.jsx)(M.A,{bold:!0,children:eP||"0"}),(0,i.jsxs)(M.A,{fontSize:"12px",color:"textSubtle",children:["~",(0,tf.o5)(tD,2,!0)]})]})]})})]}),B===tB.ONE_COIN&&(0,i.jsxs)(d.A,{flexDirection:"column",gap:"8px",children:[(0,i.jsx)(_.k,{padding:"8px 16px",style:{cursor:"pointer",border:0===L?"1px solid #31D0AA":void 0},onClick:()=>O(0),children:(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",ml:"-8px",children:[(0,i.jsx)(tU,{label:"",checked:0===L,onChange:()=>O(0)}),(0,i.jsx)(_.Z,{showChainLogo:!0,currency:k,size:"32px"}),(0,i.jsx)(M.A,{bold:!0,children:null==k?void 0:k.symbol})]}),(0,i.jsxs)(h.A,{flexDirection:"column",alignItems:"flex-end",style:{gap:"4px"},children:[(0,i.jsx)(M.A,{bold:!0,children:0===L&&eB>0n?null!=(t=R(eB,k.decimals))?t:"-":"0"}),(0,i.jsxs)(M.A,{fontSize:"12px",color:"textSubtle",children:["~",(0,tf.o5)(tF,2,!0)]})]})]})}),(0,i.jsx)(_.k,{padding:"8px 16px",style:{cursor:"pointer",border:1===L?"1px solid #31D0AA":void 0},onClick:()=>O(1),children:(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",children:[(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",ml:"-8px",children:[(0,i.jsx)(tU,{label:"",checked:1===L,onChange:()=>O(1)}),(0,i.jsx)(_.Z,{showChainLogo:!0,currency:C,size:"32px"}),(0,i.jsx)(M.A,{bold:!0,children:null==C?void 0:C.symbol})]}),(0,i.jsxs)(h.A,{flexDirection:"column",alignItems:"flex-end",style:{gap:"4px"},children:[(0,i.jsx)(M.A,{bold:!0,children:1===L&&eB>0n?null!=(n=E(eB,C.decimals))?n:"-":"0"}),(0,i.jsxs)(M.A,{fontSize:"12px",color:"textSubtle",children:["~",(0,tf.o5)(tq,2,!0)]})]})]})})]}),B===tB.CUSTOM&&(0,i.jsxs)(d.A,{flexDirection:"column",gap:"8px",children:[(0,i.jsx)(W.A,{title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),id:"remove-liquidity-infinity-ss-custom-0",defaultValue:$,onUserInput:z,currency:k,overrideBalance:e4,maxAmount:e4,showMaxButton:!0,onMax:()=>{var e;return z(e4&&null!=(e=I(e4))?e:"")},onPercentInput:e=>{if(e4){var t;z(null!=(t=I(e4.multiply(new eA.QE(e,100))))?t:"")}},showUSDPrice:!0,disableCurrencySelect:!0}),(0,i.jsx)(W.A,{title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),id:"remove-liquidity-infinity-ss-custom-1",defaultValue:V,onUserInput:H,currency:C,overrideBalance:e5,maxAmount:e5,showMaxButton:!0,onMax:()=>{var e;return H(e5&&null!=(e=S(e5))?e:"")},onPercentInput:e=>{if(e5){var t;H(null!=(t=S(e5.multiply(new eA.QE(e,100))))?t:"")}},showUSDPrice:!0,disableCurrencySelect:!0})]})]}),(B!==tB.CUSTOM&&P>0||B===tB.CUSTOM&&(eO>0n||e_>0n))&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Z,{currency0:k,currency1:C,currency0Amount:e4?null!=(r=R(e4.quotient,k.decimals))?r:"-":"0",currency0NewAmount:e7?null!=(a=R(e7.quotient,k.decimals))?a:"-":"0",currency1Amount:e5?null!=(s=E(e5.quotient,C.decimals))?s:"-":"0",currency1NewAmount:te?null!=(c=E(te.quotient,C.decimals))?c:"-":"0",currency0AmountRaw:tt,currency0NewAmountRaw:tn,currency1AmountRaw:ti,currency1NewAmountRaw:tr,totalPositionUsd:(0,tf.o5)(tl,2,!1),totalPositionNewUsd:(0,tf.o5)(ta,2,!1),amountUsd:(0,tf.o5)(tu,2,!1)}),tm>0&&(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:x("Slippage loss")}),(0,i.jsxs)(M.A,{color:"failure",small:!0,children:[(0,tf.o5)(tm,2,!1),tv>=.001?` (${tv.toFixed(2)}%)`:""]})]})]}),y!==b?(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>b?g(b):void 0,disabled:A,children:x("Switch Network")}):(0,i.jsx)(D.A,{mt:"16px",width:"100%",variant:!e2&&ek>0n?"danger":"primary",onClick:()=>{e1(),(0,eF.z_)()},disabled:!e2||el,children:tL})]})},tF=e=>{var t,n;let{poolId:r,chainId:l,position:o,tab:a="Add"}=e,s=(0,R.qX)({poolAddress:r,chainId:l}),u=r&&(0,g.F8)(l)&&null!=(t=(0,p.QR)(r))?t:r,c=b({queryKey:["poolInfo",l,u]});return s?(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(P,{currency0:s.token0,currency1:s.token1,feeTierDisplay:(0,i.jsx)(tl.Q,{type:s.protocol,percent:new eN.QE(null!=(n=null==s?void 0:s.feeTier)?n:0n,null==s?void 0:s.feeTierBase)}),rangeTags:(0,i.jsxs)(d.A,{alignItems:"center",children:[(0,i.jsx)(d.A,{gap:"4px",children:(0,i.jsx)(j.K,{outOfRange:!1,lowContrast:!0})}),(0,i.jsx)(k.cD,{poolAddress:s.lpAddress}),(0,i.jsx)(C.rW,{poolAddress:s.lpAddress})]}),aprDisplay:o?(0,i.jsx)(I.xo,{pool:s,userPosition:o,textProps:{fontSize:"16px"}}):null}),(0,i.jsx)(v.Ay,{mt:"16px",children:"Add"===a?(0,i.jsx)(tM,{poolInfo:s}):"Remove"===a?(0,i.jsx)(tD,{position:o,poolInfo:s}):null})]}):c?(0,i.jsx)(h.A,{justifyContent:"center",py:"48px",children:(0,i.jsx)(f.A,{})}):"Unable to fetch pool info, or pool does not exist"};var tq=n(663257),tL=n(555967),tO=n(341050),t_=n(673384),t$=n(37735),tY=n(284178),tz=n(553301),tV=n(343954),tZ=n(792118),tW=n(782038),tH=n(270483),tQ=n(226207),tG=n(326848),tK=n(145142);let tX=e=>{var t,n,r,a,s;let{position:u,poolInfo:c}=e,{t:p}=(0,l.A)(),x=(0,tG.useRouter)(),{account:h,chainId:f}=(0,X.W7)(),{switchNetworkIfNecessary:y,isLoading:g}=(0,ev.Hk)(),[A]=(0,e$.g)(),b=(0,tp.OQ)(),{sendTransactionAsync:w}=(0,tA.s)(),[j,k]=(0,m.useState)(""),[C,I]=(0,m.useState)(!1),[S,R]=(0,m.useState)(),{token0:E,token1:N,token0Price:P,token1Price:O,feeTier:_}=c,$=(0,m.useMemo)(()=>_,[_]),{tokenId:z}=u,V=u.chainId||c.chainId,{maxFeePerGas:H,maxPriorityFeePerGas:G}=(0,tb.N)(V),{position:K}=(0,tz.w)(u,V),ee=(0,eD.Ay)(V),[et,en]=(0,m.useState)(!0),ea=(0,m.useMemo)(()=>{var e,t;return(null==E||null==(e=E.wrapped)?void 0:e.address)===ee.wrapped.address||(null==N||null==(t=N.wrapped)?void 0:t.address)===ee.wrapped.address},[E,N,ee]),es=(0,m.useCallback)(e=>{en(e.target.checked)},[en]),ep=(0,m.useMemo)(()=>{var e;return et&&ea&&(null==E||null==(e=E.wrapped)?void 0:e.address)===ee.wrapped.address?ee:E},[E,et,ea,ee]),em=(0,m.useMemo)(()=>{var e;return et&&ea&&(null==N||null==(e=N.wrapped)?void 0:e.address)===ee.wrapped.address?ee:N},[N,et,ea,ee]),ey=(0,tL.rZ)(),eg=(0,tL.TA)(),eb=(0,m.useMemo)(()=>!!((null==ey?void 0:ey.address)&&(null==ey?void 0:ey.address)!=="0x"),[ey]),{tokenIds:ew,loading:ej}=(0,tO.s2)(eb?null==ey?void 0:ey.address:void 0,h),ek=(0,m.useMemo)(()=>eb?ej?"loading":z&&ew.find(e=>e===BigInt(z))?"true":"false":"false",[eb,ej,z,ew]),eC="loading"!==ek?"true"===ek?ey:eg:void 0,eI="loading"!==ek?"true"===ek?t_.SG:t_.uy:void 0,eS=(0,tY.oU)(),{independentField:eR,typedValue:eE}=eS,{pool:eM,dependentField:eN,parsedAmounts:eT,position:eU,noLiquidity:eB,hasInsufficentBalance:eF,currencies:eq,errorMessage:eL,invalidRange:eO,outOfRange:e_,depositADisabled:eY,depositBDisabled:ez,ticksAtLimit:eV,currencyBalances:eZ}=(0,t$.A)(null!=ep?ep:void 0,null!=em?em:void 0,$,null!=ep?ep:void 0,K,eS),{onFieldAInput:eW,onFieldBInput:eH}=(0,tV.i)(eB),eQ=(0,Y.wG)(eq[el.O9.CURRENCY_A]),eG=(0,Y.wG)(eq[el.O9.CURRENCY_B]),eK=eN===el.O9.CURRENCY_A?eQ:eG,eX=(0,m.useMemo)(()=>{var e;return{[eR]:eE,[eN]:null!=(e=eK(eT[eN],6))?e:""}},[eT,eE,eR,eN,eK]),eJ=(0,m.useMemo)(()=>[el.O9.CURRENCY_A,el.O9.CURRENCY_B].reduce((e,t)=>
1({...e,[t]:(0,er.r)(eZ[t])}),{}),[eZ]),e0=(0,m.useMemo)(()=>{let e=eT[el.O9.CURRENCY_A],t=eJ[el.O9.CURRENCY_A];return!!h&&!!e&&!!t&&t.lessThan(e)},[h,eT,eJ]),e1=(0,m.useMemo)(()=>{let e=eT[el.O9.CURRENCY_B],t=eJ[el.O9.CURRENCY_B];return!!h&&!!e&&!!t&&t.lessThan(e)},[h,eT,eJ]),[e2,e6]=(0,m.useState)(!1),e8=(0,m.useMemo)(()=>(0,eu.lN)(u.tickLower,u.tickUpper,c.token0,c.token1,eM||c,eV,e2),[u,eM,c,eV,e2]),e3=(0,m.useCallback)(()=>{e6(!e2)},[e2,e6]),{data:e9}=(0,eh.GB)(ep,{enabled:!!ep}),{data:e4}=(0,eh.GB)(em,{enabled:!!em});(0,Y.yx)(ep),(0,Y.yx)(em);let e5=(0,Y.wG)(ep),e7=(0,Y.wG)(em),te=(0,m.useMemo)(()=>{var e,t;if(!e9||!e4)return null;let n=(0,ex.g)(e9).multipliedBy((null==(e=eT[el.O9.CURRENCY_A])?void 0:e.toExact())||0),i=(0,ex.g)(e4).multipliedBy((null==(t=eT[el.O9.CURRENCY_B])?void 0:t.toExact())||0);return n.plus(i)},[e9,e4,eT[el.O9.CURRENCY_A],eT[el.O9.CURRENCY_B]]),tt=null==K?void 0:K.amount0,tn=null==K?void 0:K.amount1,ti=null!=(t=e5(tt,6))?t:"0",tr=null!=(n=e7(tn,6))?n:"0",tl=(0,m.useMemo)(()=>{var e,t;let n=eT[el.O9.CURRENCY_A];return tt?n?null!=(t=e5(tt.wrapped.add(n.wrapped),6))?t:"0":ti:null!=(e=e5(n,6))?e:"0"},[tt,eT[el.O9.CURRENCY_A],ti,e5]),to=(0,m.useMemo)(()=>{var e,t;let n=eT[el.O9.CURRENCY_B];return tn?n?null!=(t=e7(tn.wrapped.add(n.wrapped),6))?t:"0":tr:null!=(e=e7(n,6))?e:"0"},[tn,eT[el.O9.CURRENCY_B],tr,e7]),ta=null==tt?void 0:tt.toExact(),ts=null==tn?void 0:tn.toExact(),td=(0,m.useMemo)(()=>{let e=eT[el.O9.CURRENCY_A];return tt?e?tt.wrapped.add(e.wrapped).toExact():tt.toExact():null==e?void 0:e.toExact()},[tt,eT[el.O9.CURRENCY_A]]),tu=(0,m.useMemo)(()=>{let e=eT[el.O9.CURRENCY_B];return tn?e?tn.wrapped.add(e.wrapped).toExact():tn.toExact():null==e?void 0:e.toExact()},[tn,eT[el.O9.CURRENCY_B]]),tc=(0,m.useMemo)(()=>{if(!tt||!tn||!e9||!e4)return null;let e=(0,ex.g)(e9).multipliedBy(tt.toExact()),t=(0,ex.g)(e4).multipliedBy(tn.toExact());return e.plus(t)},[tt,tn,e9,e4]),tf=(0,m.useMemo)(()=>tc?`$${tc.toFormat(2)}`:"$0",[tc]),tv=(0,m.useMemo)(()=>tc?te?`$${tc.plus(te).toFormat(2)}`:tf:"$0",[tc,te,tf]),ty=(0,m.useMemo)(()=>{var e,t;return!!((null==(e=eT[el.O9.CURRENCY_A])?void 0:e.greaterThan(0))||(null==(t=eT[el.O9.CURRENCY_B])?void 0:t.greaterThan(0)))},[eT[el.O9.CURRENCY_A],eT[el.O9.CURRENCY_B]]),{approvalState:tg,approveCallback:tj,revokeCallback:tk,currentAllowance:tC}=(0,J.en)(eT[el.O9.CURRENCY_A],null==eC?void 0:eC.address),{approvalState:tI,approveCallback:tS,revokeCallback:tR,currentAllowance:tE}=(0,J.en)(eT[el.O9.CURRENCY_B],null==eC?void 0:eC.address),tM=tg!==J.h$.APPROVED&&!!eT[el.O9.CURRENCY_A],tN=tI!==J.h$.APPROVED&&!!eT[el.O9.CURRENCY_B],tP=!eL&&!eO&&!ej,{shouldBlock:tT}=(0,tW.Wd)(null==eq?void 0:eq.CURRENCY_A,null==eq?void 0:eq.CURRENCY_B),[tU]=(0,q.oA)()||[q.C0],tB=(0,m.useCallback)(async()=>{var e;let t=null==ey?void 0:ey.address;if(t&&"0x"!==t&&ej||!V||!w||!h||!eI||!eC||!eg||!ep||!em||!A||!eU)return;let n=ep.isNative?ep:em.isNative?em:void 0,{calldata:i,value:r}=z?eI.addCallParameters(eU,{tokenId:z,slippageTolerance:(0,ei.aW)(tU),deadline:A.toString(),useNative:n}):eI.addCallParameters(eU,{slippageTolerance:(0,ei.aW)(tU),recipient:h,deadline:A.toString(),useNative:n,createPool:eB});I(!0),null==(e=(0,tZ.Qr)({chainId:V}))||e.estimateGas({account:h,to:eC.address,data:i,value:(0,tq.uU)(r)}).then(e=>w({account:h,to:eC.address,data:i,value:(0,tq.uU)(r),gas:(0,tw.KL)(e),chainId:V,maxFeePerGas:H,maxPriorityFeePerGas:G})).then(e=>{var t,n,i,r,l,o;let a=(0,tm.cf)(null!=(l=null==(n=eT[el.O9.CURRENCY_A])||null==(t=n.quotient)?void 0:t.toString())?l:"0",ep.decimals,4),s=(0,tm.cf)(null!=(o=null==(r=eT[el.O9.CURRENCY_B])||null==(i=r.quotient)?void 0:i.toString())?o:"0",em.decimals,4);I(!1),b({hash:e},{type:"increase-liquidity-v3",summary:`Increase ${a} ${null==ep?void 0:ep.symbol} and ${s} ${null==em?void 0:em.symbol}`}),k(e)}).catch(e=>{(0,tx.U)(e)||R((0,th.w)(e,p)),I(!1),console.error(e)})},[h,b,tU,ep,V,A,ey,eI,eC,eB,eT,eU,eg,em,w,z,ej,p,H,G]),tD=(0,m.useMemo)(()=>{if(eM){let e=tH.w[eM.chainId];if(e)return 0===e.length||e.includes(t_.bC.getAddress(eM.token0,eM.token1,eM.fee))}return!1},[eM]),tF=(0,m.useCallback)(()=>{x.push(`/liquidity/${z}`)},[x,z]);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(Q.S,{currency:ep}),(0,i.jsx)(Q.S,{currency:em}),(0,i.jsxs)(L.k0,{borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(o.y,{mb:"8px",children:p("Price Range (Min-Max)")}),e8&&(0,i.jsx)(v.Ay,{px:e_?"16px":"0",children:(0,i.jsx)(ed.F9,{minPrice:e8.minPriceFormatted,maxPrice:e8.maxPriceFormatted,currentPrice:e8.currentPrice,minPriceRaw:e8.minPrice,maxPriceRaw:e8.maxPrice,currentPriceRaw:e8.currentPriceValue,minPercentage:e8.minPercentage,maxPercentage:e8.maxPercentage,showPercentages:e8.showPercentages,rangePosition:e8.rangePosition,outOfRange:e_,maxWidth:"unset"})}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Current Price")}),(0,i.jsxs)(d.A,{gap:"2px",children:[(0,i.jsx)(M.A,{small:!0,children:P&&O?(0,F.ZV)(e2?P:O,{maximumDecimalTrailingZeroes:5,maximumSignificantDigits:8}):"-"}),(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("%symbol0% per %symbol1%",{symbol0:e2?E.symbol:N.symbol,symbol1:e2?N.symbol:E.symbol})}),(0,i.jsx)(U.A,{variant:"text",onClick:e3,scale:"xs",children:(0,i.jsx)(B.A,{color:"primary60",width:"16px",mt:"2px"})})]})]})]}
1),(0,i.jsx)(o.y,{mt:"16px",children:p("Amount of liquidity to add")}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),ea&&(0,i.jsxs)(T.JA,{mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Use %symbol% instead",{symbol:ee.symbol})}),(0,i.jsx)(eP.A,{scale:"sm",checked:et,onChange:es})]}),(0,i.jsxs)(L.k0,{mt:"16px",borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(tK.A,{locked:eY,children:(0,i.jsx)(W.A,{id:"position-modal-v3-increase-A",defaultValue:null!=(r=eX[el.O9.CURRENCY_A])?r:"0",currency:ep,onUserInput:eW,maxAmount:eJ[el.O9.CURRENCY_A],onMax:()=>{var e;let t=eJ[el.O9.CURRENCY_A];eW(t&&null!=(e=e5(t))?e:"")},onPercentInput:e=>{var t,n;let i=null==eJ||null==(t=eJ[el.O9.CURRENCY_A])?void 0:t.multiply(new eA.QE(e,100));eW(i&&null!=(n=e5(i))?n:"")},showUSDPrice:!0,showMaxButton:!0,disableCurrencySelect:!0,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},disabled:eY,isUserInsufficientBalance:e0})}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(tK.A,{locked:ez,children:(0,i.jsx)(W.A,{id:"position-modal-v3-increase-B",defaultValue:null!=(a=eX[el.O9.CURRENCY_B])?a:"0",currency:em,onUserInput:eH,maxAmount:eJ[el.O9.CURRENCY_B],onMax:()=>{var e;let t=eJ[el.O9.CURRENCY_B];eH(t&&null!=(e=e7(t))?e:"")},onPercentInput:e=>{var t,n;let i=null==eJ||null==(t=eJ[el.O9.CURRENCY_B])?void 0:t.multiply(new eA.QE(e,100));eH(i&&null!=(n=e7(i))?n:"")},showUSDPrice:!0,showMaxButton:!0,disableCurrencySelect:!0,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},disabled:ez,isUserInsufficientBalance:e1})})})]}),ty&&(0,i.jsx)(Z,{currency0:ep,currency1:em,currency0Amount:ti,currency0NewAmount:tl,currency1Amount:tr,currency1NewAmount:to,currency0AmountRaw:ta,currency0NewAmountRaw:td,currency1AmountRaw:ts,currency1NewAmountRaw:tu,totalPositionUsd:tf,totalPositionNewUsd:tv,amountUsd:`$${null!=(s=null==te?void 0:te.toFormat(2))?s:0}`,amountUsdLabel:p("Total deposit value (USD)")}),(0,i.jsx)(v.Ay,{mt:"16px",children:(0,i.jsx)(ef.u,{size:"sm"})}),(0,i.jsx)(v.Ay,{mt:"16px",children:f!==V?(0,i.jsx)(D.A,{width:"100%",onClick:()=>V?y(V):void 0,disabled:g,children:p("Switch Network")}):(0,i.jsx)(eo.E,{addIsUnsupported:tT,account:null!=h?h:void 0,approvalA:tg,approvalB:tI,isValid:tP,showApprovalA:tM,approveACallback:tj,currentAllowanceA:tC,revokeACallback:tk,currencies:eq,approveBCallback:tS,currentAllowanceB:tE,revokeBCallback:tR,showApprovalB:tN,parsedAmounts:eT,onClick:tB,attemptingTxn:C,errorMessage:eL,buttonText:p("Add"),depositADisabled:eY,depositBDisabled:ez,isWrongNetwork:!1})}),tD&&eF&&(0,i.jsx)(tQ.E,{wrapperProps:{mt:"16px",mx:"auto",maxWidth:["auto","auto","auto","370px"]},tokenId:z.toString(),pool:eM,baseCurrency:ep,baseCurrencyAmount:eX[el.O9.CURRENCY_A],quoteCurrency:em,quoteCurrencyAmount:eX[el.O9.CURRENCY_B],onSubmit:tF})]})};var tJ=n(871792);let t0=e=>{var t,n,r,a,s;let{position:u,poolInfo:c}=e,{t:p}=(0,l.A)(),{account:x,chainId:f}=(0,X.W7)(),{switchNetworkIfNecessary:y,isLoading:g}=(0,ev.Hk)(),A=c.token0,b=c.token1,w=null!=(r=u.chainId)?r:c.chainId,{tokenId:j}=u,k=0n===u.liquidity,[C]=(0,q.oA)()||[q.C0],[I]=(0,e$.g)(),[S,R]=(0,m.useState)(50),[E,N]=(0,eE.Vv)(S,R),P=(0,m.useCallback)(e=>N(Math.ceil(e)),[N]),U=(0,eD.Ay)(w),[B,F]=(0,m.useState)(!1),O=(0,m.useMemo)(()=>{if(!w)return A;let e=eN.xQ[w];return e&&e.equals(A.wrapped)?B?e:U:A},[A,w,B,U]),_=(0,m.useMemo)(()=>{if(!w)return b;let e=eN.xQ[w];return e&&e.equals(b.wrapped)?B?e:U:b},[b,w,B,U]),{position:$,liquidityPercentage:z,liquidityValue0:V,liquidityValue1:W,feeValue0:H,feeValue1:Q,error:G}=(0,tJ.t)(u,E,B,w),K=!!((null==V?void 0:V.currency)&&(null==W?void 0:W.currency)&&(V.currency.isNative||W.currency.isNative||(null==(t=eN.xQ[V.currency.chainId])?void 0:t.equals(V.currency.wrapped))||(null==(n=eN.xQ[W.currency.chainId])?void 0:n.equals(W.currency.wrapped)))),J=(0,tL.p6)(w),ee=(0,tL.TA)({chainId:w}),{maxFeePerGas:et,maxPriorityFeePerGas:en}=(0,tb.N)(w),er=!!((null==J?void 0:J.address)&&(null==J?void 0:J.address)!=="0x"),{tokenIds:el,loading:eo}=(0,tO.s2)(er?null==J?void 0:J.address:void 0,x,w),ea=(0,m.useMemo)(()=>!!(j&&el.find(e=>e===j)),[j,el]),es=ea?J:ee,ed=ea?t_.SG:t_.uy,{data:eu}=(0,eh.GB)(A),{data:ep}=(0,eh.GB)(b),em=null==$?void 0:$.amount0,ef=null==$?void 0:$.amount1,ey=(0,Y.wG)(A),eg=(0,Y.wG)(b),eA=null!=(a=ey(em,6))?a:"0",eb=null!=(s=eg(ef,6))?s:"0",ew=(0,m.useMemo)(()=>{var e;if(!em||!V)return eA;let t=em.quotient-V.quotient;return t<0n?"0":null!=(e=ey(eN.eF.fromRawAmount(em.currency,t),6))?e:"0"},[em,V,eA,ey]),ej=(0,m.useMemo)(()=>{var e;if(!ef||!W)return eb;let t=ef.quotient-W.quotient;return t<0n?"0":null!=(e=eg(eN.eF.fromRawAmount(ef.currency,t),6))?e:"0"},[ef,W,eb,eg]),ek=null==em?void 0:em.toExact(),eC=null==ef?void 0:ef.toExact(),eI=(0,m.useMemo)(()=>
1{if(!em||!V)return ek;let e=em.quotient-V.quotient;return e<0n?"0":eN.eF.fromRawAmount(em.currency,e).toExact()},[em,V,ek]),eS=(0,m.useMemo)(()=>{if(!ef||!W)return eC;let e=ef.quotient-W.quotient;return e<0n?"0":eN.eF.fromRawAmount(ef.currency,e).toExact()},[ef,W,eC]),eR=(0,m.useMemo)(()=>{if(!em||!ef||!eu||!ep)return"$0";let e=(0,ex.g)(em.toExact()).multipliedBy(eu),t=(0,ex.g)(ef.toExact()).multipliedBy(ep);return`$${e.plus(t).toFormat(2)}`},[em,ef,eu,ep]),eM=(0,m.useMemo)(()=>{if(!V||!W||!eu||!ep)return"0";let e=(0,ex.g)(V.toExact()).multipliedBy(eu),t=(0,ex.g)(W.toExact()).multipliedBy(ep);return e.plus(t).toFormat(2)},[V,W,eu,ep]),eU=(0,m.useMemo)(()=>{if("$0"===eR||"0"===eM)return eR;let e=(0,ex.g)(eR.replace(/[$,]/g,"")),t=(0,ex.g)(eM.replace(/,/g,"")),n=e.minus(t);return`$${n.isNegative()?"0":n.toFormat(2)}`},[eR,eM]),eB=(0,m.useMemo)(()=>{if(!(null==H?void 0:H.greaterThan(0))&&!(null==Q?void 0:Q.greaterThan(0)))return;let e=H&&H.greaterThan(0)&&eu?(0,ex.g)(H.toExact()).multipliedBy(eu):(0,ex.g)(0),t=Q&&Q.greaterThan(0)&&ep?(0,ex.g)(Q.toExact()).multipliedBy(ep):(0,ex.g)(0);return`$${e.plus(t).toFormat(2)}`},[H,Q,eu,ep]),eq=(0,tp.OQ)(),{sendTransactionAsync:eL}=(0,tA.s)(),[e_,eY]=(0,m.useState)(!1),[ez,eV]=(0,m.useState)(),eZ=(0,m.useCallback)(async()=>{var e;if(er&&eo||!ed||!es||!V||!W||!I||!x||!w||!$||!z||!j||!eL)return;eY(!0);let{calldata:t,value:n}=ed.removeCallParameters($,{tokenId:j.toString(),liquidityPercentage:z,slippageTolerance:(0,ei.aW)(C),deadline:I.toString(),collectOptions:{expectedCurrencyOwed0:null!=H?H:eN.eF.fromRawAmount(V.currency,0),expectedCurrencyOwed1:null!=Q?Q:eN.eF.fromRawAmount(W.currency,0),recipient:x}}),i={to:es.address,data:t,value:(0,tq.uU)(n),account:x};null==(e=(0,tZ.Qr)({chainId:w}))||e.estimateGas(i).then(e=>eL({...i,gas:(0,tw.KL)(e),chainId:w,maxFeePerGas:et,maxPriorityFeePerGas:en})).then(e=>{let t=(0,tm.cf)(V.quotient.toString(),V.currency.decimals,4),n=(0,tm.cf)(W.quotient.toString(),W.currency.decimals,4);eY(!1),eq({hash:e},{type:"remove-liquidity-v3",summary:`Remove ${t} ${V.currency.symbol} and ${n} ${W.currency.symbol}`})}).catch(e=>{(0,tx.U)(e)||eV((0,th.w)(e,p)),eY(!1),console.error(e)})},[er,eo,ed,es,V,W,I,x,w,$,z,j,eL,C,H,Q,eq,p,et,en]);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsxs)(T.JA,{mb:"4px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),K&&(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:p("Collect as %symbol%",{symbol:U.wrapped.symbol})}),(0,i.jsx)(eP.A,{id:"receive-as-wnative",scale:"sm",checked:B,onChange:()=>F(e=>!e)})]}),(0,i.jsx)(o.y,{mt:"16px",children:p("Amount of liquidity to remove")}),(0,i.jsxs)(L.k0,{mt:"8px",padding:"16px",borderRadius:"24px",children:[(0,i.jsxs)(M.A,{fontSize:"40px",bold:!0,mb:"16px",style:{lineHeight:1},children:[E,"%"]}),(0,i.jsx)(eT.A,{name:"lp-amount",min:0,max:100,value:E,onValueChanged:P,mb:"16px"}),(0,i.jsxs)(d.A,{gap:"8px",justifyContent:"space-between",children:[(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>R(10),width:"100%",borderRadius:"12px",children:"10%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>R(20),width:"100%",borderRadius:"12px",children:"20%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>R(75),width:"100%",borderRadius:"12px",children:"75%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>R(100),width:"100%",borderRadius:"12px",children:p("Max.fill-max")})]})]}),(0,i.jsx)(Z,{currency0:O,currency1:_,currency0Amount:eA,currency0NewAmount:ew,currency1Amount:eb,currency1NewAmount:ej,currency0AmountRaw:ek,currency0NewAmountRaw:eI,currency1AmountRaw:eC,currency1NewAmountRaw:eS,totalPositionUsd:eR,totalPositionNewUsd:eU,amountUsd:`$${eM}`,feeValue0:H,feeValue1:Q,feesEarnedUsd:eB}),ea?(0,i.jsx)(eO.A,{variant:"secondary60",mt:"16px",children:(0,i.jsx)(M.A,{small:!0,children:p("This liquidity position is currently staking in the Farm. Adding or removing liquidity will also harvest any unclaimed CAKE to your wallet.")})}):null,ez?(0,i.jsx)(eO.A,{variant:"danger",mt:"16px",children:(0,i.jsx)(M.A,{small:!0,children:ez})}):null,f!==w?(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>w?y(w):void 0,disabled:g,children:p("Switch Network")}):(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:e_||k||!!G||0===S,onClick:()=>{eZ(),(0,eF.z_)()},children:k?p("Closed"):null!=G?G:p("Remove")})]})};var t1=n(706172),t2=n(197504),t6=n(323641),t8=n(57654);let t3=e=>{var t,n;let{position:o,poolInfo:a}=e,{t:s}=(0,l.A)(),{address:d}=(0,eq.F)(),{chainId:u}=(0,X.W7)(),{switchNetworkIfNecessary:c,isLoading:p}=(0,ev.Hk)(),[,x]=(0,eW.r)(),h=null!=(t=o.chainId)?t:a.chainId,f=u!==h,y=a.token0,g=a.token1,{tokenId:A}=o,{pool:b}=(0,tz.w)(o,h),[w,j]=(0,t1.R)(b,A,!1),{data:k}=(0,eh.GB)(y),{data:C}=(0,eh.GB)(g),I=(0,m.useMemo)(()=>
1{if(k&&w)return Number(w.toExact())*k},[k,w]),S=(0,m.useMemo)(()=>{if(C&&j)return Number(j.toExact())*C},[C,j]),R=(0,m.useMemo)(()=>{if(void 0!==I||void 0!==S)return(null!=I?I:0)+(null!=S?S:0)},[I,S]),{onCollect:M,attemptingTx:N}=(0,t8.A)({chainId:h,onDone:e=>x({blockHash:e,status:"success"})}),P=(0,m.useCallback)(async()=>{b&&A&&await M({pool:b,tokenId:A,feeValue0:w,feeValue1:j,receiveWNATIVE:!1})},[b,A,M,w,j]),T=N||!b||!((null==w?void 0:w.greaterThan(0))||(null==j?void 0:j.greaterThan(0))),U=(0,tL.p6)(h),B=!!((null==U?void 0:U.address)&&(null==U?void 0:U.address)!=="0x"),{tokenIds:F}=(0,tO.s2)(B?null==U?void 0:U.address:void 0,d,h),q=(0,m.useMemo)(()=>!!(A&&F.find(e=>e===A)),[A,F]),{earningsAmount:L,earningsBusd:O,hasEarnings:_}=(0,t6.Ls)((0,m.useMemo)(()=>q&&A?[A]:[],[A,q]),h),{onHarvest:$,attemptingTxn:Y}=(0,t2.A)({tokenId:null!=(n=null==A?void 0:A.toString())?n:"",onDone:x,chainId:h}),z=q&&_;return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(e1,{currency0:y,currency1:g,feeAmount0:w,feeAmount1:j,feeUsd0:I,feeUsd1:S,totalFeesUsd:R,onCollect:P,collecting:N,disabled:T,hideButton:f}),z?(0,i.jsx)(v.Ay,{mt:"16px",children:(0,i.jsx)(e2,{rewardToken:E.vb[h],rewardsAmount:L,rewardsUSD:O,onHarvest:$,harvesting:Y,disabled:Y||!_,hideButton:f})}):null,(0,i.jsx)(e4,{poolAddress:a.lpAddress,poolProtocol:r.Zs.V3,chainId:h,disabled:f,hideButton:f}),(0,i.jsx)(tt,{poolAddress:a.lpAddress,chainId:h}),f&&(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>h?c(h):void 0,disabled:p,children:s("Switch Network")})]})},t9=e=>{var t,n;let{poolId:o,chainId:a,position:s,tab:u="Add"}=e,{t:c}=(0,l.A)(),x=o&&(0,g.F8)(a)&&null!=(t=(0,p.QR)(o))?t:o,A=(0,R.qX)({poolAddress:o,chainId:a}),w=b({queryKey:["poolInfo",a,x]}),S=null!=a?a:s&&"chainId"in s?s.chainId:void 0,E=(null==s?void 0:s.protocol)!==r.Zs.V3||void 0===S||(0,g.fT)(S)?void 0:s,{outOfRange:M,removed:N}=(0,R.ck)(E),T=(0,m.useMemo)(()=>!!S&&((0,g.fT)(S)?!!(null==A?void 0:A.isFarming):!!(null==E?void 0:E.isStaked)),[S,null==A?void 0:A.isFarming,null==E?void 0:E.isStaked]);return A?(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(P,{currency0:A.token0,currency1:A.token1,feeTierDisplay:(0,i.jsx)(tl.Q,{type:A.protocol,percent:new eN.QE(null!=(n=null==A?void 0:A.feeTier)?n:0n,null==A?void 0:A.feeTierBase),dynamic:null==A?void 0:A.isDynamicFee,showType:!1}),rangeTags:(0,i.jsxs)(d.A,{alignItems:"center",children:[(0,i.jsxs)(d.A,{gap:"4px",children:[(0,i.jsx)(j.K,{removed:N,outOfRange:M,protocol:r.Zs.V3,lowContrast:!0}),T&&(0,i.jsx)(y.A,{variant:"primary60",children:c("Farming")})]}),(0,i.jsx)(k.cD,{poolAddress:A.lpAddress}),(0,i.jsx)(C.rW,{poolAddress:A.lpAddress})]}),aprDisplay:E?(0,i.jsx)(I._o,{pool:A,userPosition:E,textProps:{fontSize:"16px"}}):(0,i.jsx)(I.uu,{pool:A,userPosition:s,textProps:{fontSize:"16px"}})}),(0,i.jsx)(v.Ay,{mt:"16px",children:"Add"===u?(0,i.jsx)(tX,{position:s,poolInfo:A}):"Remove"===u?(0,i.jsx)(t0,{position:s,poolInfo:A}):"Harvest"===u?(0,i.jsx)(t3,{position:s,poolInfo:A}):null})]}):w?(0,i.jsx)(h.A,{justifyContent:"center",py:"48px",children:(0,i.jsx)(f.A,{})}):"Unable to fetch pool info, or pool does not exist"};var t4=n(430586),t5=n(399832);function t7(e,t,n){if(!t||!n)return{override0:void 0,override1:void 0};let i=e.nativeDeposited0.add(e.farmingDeposited0),r=e.nativeDeposited1.add(e.farmingDeposited1),l=t.wrapped,o=n.wrapped;return i.currency.equals(l)&&r.currency.equals(o)?{override0:eA.eF.fromRawAmount(t,i.quotient),override1:eA.eF.fromRawAmount(n,r.quotient)}:i.currency.equals(o)&&r.currency.equals(l)?{override0:eA.eF.fromRawAmount(t,r.quotient),override1:eA.eF.fromRawAmount(n,i.quotient)}:{override0:void 0,override1:void 0}}var ne=n(364698),nt=n(899297),nn=n(856870);let ni=e=>{let{position:t,poolInfo:n}=e,{t:r}=(0,l.A)(),{token0:a,token1:s}=n,{chainId:d}=n,u=(0,eD.Ay)(d),[c,p]=(0,m.useState)(!0),x=(0,m.useMemo)(()=>{var e,t;return(null==a||null==(e=a.wrapped)?void 0:e.address)===u.wrapped.address||(null==s||null==(t=s.wrapped)?void 0:t.address)===u.wrapped.address},[a,s,u]),h=(0,m.useCallback)(e=>{p(e.target.checked)},[p]),f=(0,m.useMemo)(()=>{var e;return c&&x&&(null==a||null==(e=a.wrapped)?void 0:e.address)===u.wrapped.address?u:a},[a,c,x,u]),y=(0,m.useMemo)(()=>{var e;return c&&x&&(null==s||null==(e=s.wrapped)?void 0:e.address)===u.wrapped.address?u:s},[s,c,x,u]);return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(o.y,{children:r("Amount of Liquidity to Add")}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:r("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),x&&(0,i.jsxs)(T.JA,{mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:r("Use %symbol% instead",{symbol:u.symbol})}),(0,i.jsx)(eP.A,{scale:"sm",checked:c,onChange:h})]}),(0,i.jsx)(ne.A,{currencyA:f,currencyB:y,children:e=>(0,i.jsx)(nr,{...e,position:t})})]})},nr=e=>{var t,n,r,o,a;let{position:s,formattedAmounts:d,addIsUnsupported:u,shouldShowApprovalGroup:c,approveACallback:p,revokeACallback:x,currentAllowanceA:f,approvalA:y,approvalB:g,approveBCallback:A,revokeBCallback:b,currentAllowanceB:w,showFieldBApproval:j,show
1FieldAApproval:k,currencies:C,buttonDisabled:I,onAdd:S,onPresentAddLiquidityModal:R,errorText:E,onFieldAInput:M,onFieldBInput:N,maxAmounts:P,isOneWeiAttack:T,pair:U}=e,{t:B}=(0,l.A)(),F=null!=(n=null==U?void 0:U.chainId)?n:null==(t=C[el.O9.CURRENCY_A])?void 0:t.chainId,O=(0,m.useMemo)(()=>U&&(0,tw.Bz)(eN.Rm.getAddress(U.token0,U.token1),"address",F)||void 0,[U,F]),{chainId:_,account:$}=(0,X.W7)(),z=_!==F,{switchNetworkIfNecessary:V,isLoading:H}=(0,ev.Hk)(),[G]=(0,q.lB)(),K=C[el.O9.CURRENCY_A],J=C[el.O9.CURRENCY_B];(0,Y.yx)(K),(0,Y.yx)(J);let ee=(0,Y.wG)(K),et=(0,Y.wG)(J),en=d[el.O9.CURRENCY_A],ei=d[el.O9.CURRENCY_B],{data:er}=(0,eh.GB)(K,{enabled:!!K}),{data:eo}=(0,eh.GB)(J,{enabled:!!J}),ea=(0,m.useMemo)(()=>{if(!er||!eo)return null;let e=(0,ex.g)(er).multipliedBy(en||0),t=(0,ex.g)(eo).multipliedBy(ei||0);return e.plus(t)},[er,eo,en,ei]),{override0:es,override1:ed}=(0,m.useMemo)(()=>K&&J?t7(s,K,J):{override0:void 0,override1:void 0},[s,K,J]),eu=null!=(r=ee(es,6))?r:"0",ec=null!=(o=et(ed,6))?o:"0",ep=(0,Y.dm)(en,null!=K?K:void 0),em=(0,Y.dm)(ei,null!=J?J:void 0),ey=(0,m.useMemo)(()=>{var e,t;return es?ep?null!=(t=ee(es.wrapped.add(ep.wrapped),6))?t:"0":eu:null!=(e=ee(ep,6))?e:"0"},[es,ep,eu,ee]),eg=(0,m.useMemo)(()=>{var e,t;return ed?em?null!=(t=et(ed.wrapped.add(em.wrapped),6))?t:"0":ec:null!=(e=et(em,6))?e:"0"},[ed,em,ec,et]),eb=null==es?void 0:es.toExact(),ew=null==ed?void 0:ed.toExact(),ej=(0,m.useMemo)(()=>es?ep?es.wrapped.add(ep.wrapped).toExact():es.toExact():null==ep?void 0:ep.toExact(),[es,ep]),ek=(0,m.useMemo)(()=>ed?em?ed.wrapped.add(em.wrapped).toExact():ed.toExact():null==em?void 0:em.toExact(),[ed,em]),eC=(0,m.useMemo)(()=>{if(!es||!ed||!er||!eo)return null;let e=(0,ex.g)(er).multipliedBy(es.toExact()),t=(0,ex.g)(eo).multipliedBy(ed.toExact());return e.plus(t)},[es,ed,er,eo]),eI=(0,m.useMemo)(()=>eC?`$${eC.toFormat(2)}`:"$0",[eC]),eS=(0,m.useMemo)(()=>eC?ea?`$${eC.plus(ea).toFormat(2)}`:eI:"$0",[eC,ea,eI]),eR=!!((null==ep?void 0:ep.greaterThan(0))||(null==em?void 0:em.greaterThan(0))),eE=(0,m.useMemo)(()=>{let e=P[el.O9.CURRENCY_A];return!!$&&!!K&&!!e&&!!ep&&e.lessThan(ep)},[$,K,P,ep]),eM=(0,m.useMemo)(()=>{let e=P[el.O9.CURRENCY_B];return!!$&&!!J&&!!e&&!!em&&e.lessThan(em)},[$,J,P,em]),eP=(0,m.useCallback)(()=>z?(0,i.jsx)(D.A,{width:"100%",onClick:()=>F?V(F):void 0,disabled:H,children:B("Switch Network")}):u?(0,i.jsx)(D.A,{disabled:!0,children:B("Unsupported Asset")}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v.Ay,{mb:c?"8px":null,children:(0,i.jsx)(nt.A,{approvalA:y,approvalB:g,showFieldAApproval:k,showFieldBApproval:j,approveACallback:p,approveBCallback:A,revokeACallback:x,revokeBCallback:b,currencies:C,currentAllowanceA:f,currentAllowanceB:w,shouldShowApprovalGroup:c})}),T?(0,i.jsx)(eO.A,{variant:"warning",mb:"8px",children:(0,i.jsxs)(h.A,{flexDirection:"column",children:[(0,i.jsx)(eO.J,{children:B("Adding liquidity to this V2 pair is currently not available on PancakeSwap UI. Please follow the instructions to resolve it using blockchain explorer.")}),(0,i.jsx)(t4.A,{href:"https://docs.pancakeswap.finance/products/pancakeswap-exchange/faq#why-cant-i-add-liquidity-to-a-pair-i-just-created",mt:"0.25rem",children:B("Learn more how to fix")}),(0,i.jsx)(t5.A,{useBscCoinFallback:F?nn.jc.includes(F):void 0,href:O,mt:"0.25rem",children:B("View pool on explorer")})]})}):null,(0,i.jsx)(td.O,{variant:I?"danger":"primary",onClick:()=>{G?S():R(),(0,eF.uL)()},disabled:I,width:"100%",children:E||B("Add")})]}),[z,u,c,y,g,k,j,p,A,x,b,C,f,w,T,O,G,S,R,d,I,E,F,_,V,H,B]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Q.S,{currency:K}),(0,i.jsx)(Q.S,{currency:J}),(0,i.jsxs)(L.k0,{mt:"16px",borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(W.A,{id:"position-modal-increase-v2-A",defaultValue:d[el.O9.CURRENCY_A],currency:C[el.O9.CURRENCY_A],onUserInput:M,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},onPercentInput:e=>{var t,n;let i=null==(t=P[el.O9.CURRENCY_A])?void 0:t.multiply(new eA.QE(e,100));i&&M(null!=(n=ee(i))?n:"")},onMax:()=>{var e;let t=P[el.O9.CURRENCY_A];M(t&&null!=(e=ee(t))?e:"")},maxAmount:P[el.O9.CURRENCY_A],showMaxButton:!0,disableCurrencySelect:!0,showUSDPrice:!0,isUserInsufficientBalance:eE}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(W.A,{id:"position-modal-increase-v2-B",defaultValue:d[el.O9.CURRENCY_B],currency:C[el.O9.CURRENCY_B],onUserInput:N,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},onPercentInput:e=>{var t,n;let i=null==(t=P[el.O9.CURRENCY_B])?void 0:t.multiply(new eA.QE(e,100));i&&N(null!=(n=et(i))?n:"")},onMax:()=>{var e;let t=P[el.O9.CURRENCY_B];N(t&&null!=(e=et(t))?e:"")},maxAmount:P[el.O9.CURRENCY_B],showMaxButton:!0,disableCurrencySelect:!0,showUSDPrice:!0,isUserInsufficientBalance:eM})})]}),K&&J&&eR&&(0,i.jsx)(Z,{currency0:K,currency1:J,currency0Amount:eu,currency0NewAmount:ey,currency1Amount:ec,currency1NewAmount:eg,currency0AmountRaw:eb,currency0NewAmountRaw:ej,currency1AmountRaw:ew,currency1NewAmountRaw:ek,totalPositionUsd:eI,totalPositionNewUsd:eS,amountUsd:`$${null!=(a=null==ea?void 0:ea.toFormat(2))?a:0}`,amountUsdLabel:B("Total deposit value (USD)")}),(0,i.jsx)(v.Ay,{mt:"16px",children:(0,i.jsx)(ef.u,{size:"sm"})}),(0,i.jsx)(v.Ay,{mt:"16px",children:eP()})]})};var nl=n(636236),no=n(579014);let na=e=>{let{position:t,poolInfo:n}=e,{t:r}=(0,l.A)(),{token0:a,token1:s}=n,{chainId:d}=n,u=(0,eD.Ay)(d),[c,p]=(0,m.useState)(!0),x=(0,m.useMemo)(()=>{var e,t;return(null==a||null==(e=a.wrapped)?void 0:e.address)===u.wrapped.address||(null==s||null==(t=s.wrapped)?void 0:t.address)===u.wrapped.address},[a,s,u]),h=(0,m.useCallback)(e=>{p(e.target.checked)},[p]),f=(0,m.useMemo)(()=>{var e;return c&&x&&(null==a||null==(e=a.wrapped)?void 0:e.address)===u.wrapped.address?u:a},[a,c,x,u]),y=(0,m.useMemo)(()=>{var e;return c&&x&&(null==s||null==(e=s.wrapped)?void 0:e.address)===u.wrapped.address?u:s},[s,c,x,u]),g=(0,nl.Ay)({tokenA:f,tokenB:y});return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(o.y,{children:r("Amount of Liquidity to Add")}),(0,i.jsxs)(T.JA,{mt:"8px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:r("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),x&&(0,i.jsxs)(T.JA,{mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:r("Use %symbol% instead",{symbol:u.symbol})}),(0,i.jsx)(eP.A,{scale:"sm",checked:c,onChange:h})]}),(0,i.jsx)(nl.jq.Provider,{value:g,children:(0,i.jsx)(no.A,{currencyA:f,currencyB:y,children:e=>(0,i.jsx)(ns,{...e,position:t})})})]})},ns=e=>{var t,n;let{position:r,formattedAmounts:o,shouldShowApprovalGroup:a,approveACallback:s,approvalA:u,approvalB:c,approveBCallback:p,showFieldBApproval:x,showFieldAApproval:h,currencies:f,buttonDisabled:y,onAdd:g,onPresentAddLiquidityModal:A,errorText:b,onFieldAInput:w,onFieldBInput:j,executionSlippage:k,loading:C,maxAmounts:I,inputAmountsTotalUsdValue:S}=e,{t:R}=(0,l.A)(),E=f[el.O9.CURRENCY_A],N=f[el.O9.CURRENCY_B];(0,Y.yx)(E),(0,Y.yx)(N);let P=(0,Y.wG)(E),U=(0,Y.wG)(N),B=(0,Y.dm)(o[el.O9.CURRENCY_A],null!=E?E:void 0),F=(0,Y.dm)(o[el.O9.CURRENCY_B],null!=N?N:void 0),O=null==E?void 0:E.
1chainId,_=(0,tu.LU)(E,N),$=(0,tu.aS)(E,N),{chainId:z,account:V}=(0,X.W7)(),H=z!==O,{switchNetworkIfNecessary:G,isLoading:K}=(0,ev.Hk)(),[ee]=(0,q.lB)(),et=(0,m.useMemo)(()=>{let e=I[el.O9.CURRENCY_A];return!!V&&!!E&&!!e&&!!B&&e.lessThan(B)},[V,E,I,B]),en=(0,m.useMemo)(()=>{let e=I[el.O9.CURRENCY_B];return!!V&&!!N&&!!e&&!!F&&e.lessThan(F)},[V,N,I,F]),{data:ei}=(0,eh.GB)(E),{data:er}=(0,eh.GB)(N),{override0:eo,override1:ea}=(0,m.useMemo)(()=>E&&N?t7(r,E,N):{override0:void 0,override1:void 0},[r,E,N]),es=null!=(t=P(eo,6))?t:"0",ed=null!=(n=U(ea,6))?n:"0",eu=(0,m.useMemo)(()=>{var e,t;return eo?B?null!=(t=P(eo.wrapped.add(B.wrapped),6))?t:"0":es:null!=(e=P(B,6))?e:"0"},[eo,B,es,P]),ec=(0,m.useMemo)(()=>{var e,t;return ea?F?null!=(t=U(ea.wrapped.add(F.wrapped),6))?t:"0":ed:null!=(e=U(F,6))?e:"0"},[ea,F,ed,U]),ep=null==eo?void 0:eo.toExact(),em=null==ea?void 0:ea.toExact(),ey=(0,m.useMemo)(()=>eo?B?eo.wrapped.add(B.wrapped).toExact():eo.toExact():null==B?void 0:B.toExact(),[eo,B]),eg=(0,m.useMemo)(()=>ea?F?ea.wrapped.add(F.wrapped).toExact():ea.toExact():null==F?void 0:F.toExact(),[ea,F]),eb=(0,m.useMemo)(()=>{if(!eo||!ea||!ei||!er)return null;let e=(0,ex.g)(ei).multipliedBy(eo.toExact()),t=(0,ex.g)(er).multipliedBy(ea.toExact());return e.plus(t)},[eo,ea,ei,er]),ew=(0,m.useMemo)(()=>eb?`$${eb.toFormat(2)}`:"$0",[eb]),ej=(0,m.useMemo)(()=>eb?S?`$${eb.plus(S).toFormat(2)}`:ew:"$0",[eb,S,ew]),ek=!!((null==B?void 0:B.greaterThan(0))||(null==F?void 0:F.greaterThan(0))),eC=(0,m.useCallback)(()=>{var e,t,n,r;return H?(0,i.jsx)(D.A,{width:"100%",onClick:()=>O?G(O):void 0,disabled:K,children:R("Switch Network")}):_||$?(0,i.jsx)(D.A,{disabled:!0,children:R("Unsupported Asset")}):(0,i.jsxs)(i.Fragment,{children:[a&&(0,i.jsxs)(T.JA,{style:{gap:"8px"},mb:"8px",children:[h&&(0,i.jsx)(D.A,{onClick:s,disabled:u===J.h$.PENDING,width:"100%",children:u===J.h$.PENDING?(0,i.jsx)(ta.n,{children:R("Enabling %asset%",{asset:null==(e=f[el.O9.CURRENCY_A])?void 0:e.symbol})}):R("Enable %asset%",{asset:null==(t=f[el.O9.CURRENCY_A])?void 0:t.symbol})}),x&&(0,i.jsx)(D.A,{onClick:p,disabled:c===J.h$.PENDING,width:"100%",children:c===J.h$.PENDING?(0,i.jsx)(ta.n,{children:R("Enabling %asset%",{asset:null==(n=f[el.O9.CURRENCY_B])?void 0:n.symbol})}):R("Enable %asset%",{asset:null==(r=f[el.O9.CURRENCY_B])?void 0:r.symbol})})]}),(0,i.jsx)(td.O,{variant:y?"danger":"primary",onClick:()=>{ee?g():A(),(0,eF.uL)()},disabled:y,width:"100%",children:b||R("Add")})]})},[H,_,$,a,h,x,s,p,u,c,f,ee,g,A,o,y,b,O,z,K,G,R]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Q.S,{currency:E}),(0,i.jsx)(Q.S,{currency:N}),(0,i.jsxs)(L.k0,{mt:"16px",borderRadius:"24px",padding:"16px",children:[(0,i.jsx)(W.A,{id:"position-modal-increase-v2-A",defaultValue:o[el.O9.CURRENCY_A],currency:f[el.O9.CURRENCY_A],onUserInput:w,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},onPercentInput:e=>{var t,n;let i=null==(t=I[el.O9.CURRENCY_A])?void 0:t.multiply(new eA.QE(e,100));i&&w(null!=(n=P(i))?n:"")},onMax:()=>{var e;let t=I[el.O9.CURRENCY_A];w(t&&null!=(e=P(t))?e:"")},maxAmount:I[el.O9.CURRENCY_A],showMaxButton:!0,disableCurrencySelect:!0,showUSDPrice:!0,isUserInsufficientBalance:et}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(W.A,{id:"position-modal-increase-v2-B",defaultValue:o[el.O9.CURRENCY_B],currency:f[el.O9.CURRENCY_B],onUserInput:j,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{style:{backgroundColor:"transparent"}},onPercentInput:e=>{var t,n;let i=null==(t=I[el.O9.CURRENCY_B])?void 0:t.multiply(new eA.QE(e,100));i&&j(null!=(n=U(i))?n:"")},onMax:()=>{var e;let t=I[el.O9.CURRENCY_B];j(t&&null!=(e=U(t))?e:"")},maxAmount:I[el.O9.CURRENCY_B],showMaxButton:!0,disableCurrencySelect:!0,showUSDPrice:!0,isUserInsufficientBalance:en})})]}),(0,i.jsxs)(T.JA,{mt:"16px",children:[(0,i.jsxs)(d.A,{gap:"4px",alignItems:"center",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:R("Slippage")}),(0,i.jsx)(ts.PT,{text:R("Based on % contributed to stable pair, fees will vary. Deposits with fees >= 0.15% will be rejected"),placement:"top-start",mt:"1px"})]}),(0,i.jsx)(tv._,{slippage:k,loading:C,small:!0})]}
1),E&&N&&ek&&(0,i.jsx)(Z,{currency0:E,currency1:N,currency0Amount:es,currency0NewAmount:eu,currency1Amount:ed,currency1NewAmount:ec,currency0AmountRaw:ep,currency0NewAmountRaw:ey,currency1AmountRaw:em,currency1NewAmountRaw:eg,totalPositionUsd:ew,totalPositionNewUsd:ej,amountUsd:(0,tf.o5)(S,2,!1),amountUsdLabel:R("Total deposit value (USD)")}),(0,i.jsx)(v.Ay,{mt:"16px",children:(0,i.jsx)(ef.u,{size:"sm"})}),(0,i.jsx)(v.Ay,{mt:"16px",children:eC()})]})};var nd=n(890398),nu=n(970645),nc=n(608135),np=n(859886),nm=n(656302),nx=n(305791),nh=n(452301),nf=n(954219),nv=n(518400),ny=n(133018);function ng(e){if("<1"===e)return 1;let t=Number.parseInt(e,10);return Number.isNaN(t)?0:Math.min(100,Math.max(0,t))}let nA=(0,nf.AK)(),nb=e=>{let{position:t,poolInfo:n}=e;return(0,i.jsx)(nf.XK,{value:{formAtom:nA},children:(0,i.jsx)(nw,{position:t,poolInfo:n})})},nw=e=>{var t,n,r,a;let{position:s,poolInfo:u}=e,{t:c}=(0,l.A)(),{account:p,chainId:x}=(0,X.W7)(),{switchNetworkIfNecessary:f,isLoading:y}=(0,ev.Hk)(),g=u.chainId,A=(0,nv.YW)(),b=!!g&&x!==g,w=b?g:x,j=u.token0,k=u.token1,C=(0,eD.Ay)(null!=w?w:void 0),[I,S]=(0,m.useState)(!1),R=(0,m.useMemo)(()=>{if(!w)return j;let e=eN.xQ[w];return e&&e.equals(j.wrapped)?I?e:C:j},[j,w,I,C]),E=(0,m.useMemo)(()=>{if(!w)return k;let e=eN.xQ[w];return e&&e.equals(k.wrapped)?I?e:C:k},[k,w,I,C]);(0,Y.yx)(R),(0,Y.yx)(E);let N=(0,Y.wG)(R),P=(0,Y.wG)(E),U=!!(x&&w&&(j&&(null==(t=eN.xQ[w])?void 0:t.equals(j.wrapped))||k&&(null==(n=eN.xQ[w])?void 0:n.equals(k.wrapped))||(null==j?void 0:j.isNative)||(null==k?void 0:k.isNative))),[B,F]=(0,m.useMemo)(()=>[null==R?void 0:R.wrapped,null==E?void 0:E.wrapped],[R,E]),{independentField:O,typedValue:_}=(0,nf.lD)(),{pair:z,parsedAmounts:V,error:H}=function(e,t,n){let i,{account:r,chainId:o}=(0,X.W7)(),{independentField:a,typedValue:s}=(0,nf.lD)(),{t:d}=(0,l.A)(),[,u]=(0,np.ek)(e,t),c=!!((null==n?void 0:n.chainSnapshot)&&void 0!==n.targetChainId&&o!==n.targetChainId),p=(0,m.useMemo)(()=>c?n.chainSnapshot.pair:u,[c,n,u]),[x]=(0,eI.Tz)(null!=r?r:void 0,(0,m.useMemo)(()=>[null==u?void 0:u.liquidityToken],[null==u?void 0:u.liquidityToken])),h=(null==u?void 0:u.liquidityToken)?null==x?void 0:x[`${u.liquidityToken.chainId}-${u.liquidityToken.address}`]:void 0,f=(0,m.useMemo)(()=>c?n.chainSnapshot.userLiquidity:h,[c,n,h]),v=(0,nm.A)(null==u?void 0:u.liquidityToken),y=(0,m.useMemo)(()=>c?n.chainSnapshot.totalSupply:v,[c,n,v]),g=c?n.targetChainId:o,[A,b]=[(0,nh.dc)(e,g),(0,nh.dc)(t,g)],w={[tP.D.CURRENCY_A]:A,[tP.D.CURRENCY_B]:b,[tP.D.LIQUIDITY]:null==p?void 0:p.liquidityToken},j=p&&y&&f&&A&&y.quotient>=f.quotient?eN.eF.fromRawAmount(A,p.getLiquidityValue(A,y,f,!1).quotient):void 0,k=p&&y&&f&&b&&y.quotient>=f.quotient?eN.eF.fromRawAmount(b,p.getLiquidityValue(b,y,f,!1).quotient):void 0,C={[tP.D.CURRENCY_A]:j,[tP.D.CURRENCY_B]:k},I=a===tP.D.LIQUIDITY?void 0:w[a],S=(0,Y.dm)(s,I),R=new eN.QE("0","100");if(a===tP.D.LIQUIDITY_PERCENT)R=new eN.QE(s,"100");else if(a===tP.D.LIQUIDITY){if(null==p?void 0:p.liquidityToken){let e=(0,nc.A)(s,p.liquidityToken);e&&f&&!e.greaterThan(f)&&(R=new eN.QE(e.quotient,f.quotient))}}else if(w[a]){let e=C[a];S&&e&&!S.greaterThan(e)&&(R=new eN.QE(S.quotient,e.quotient))}let E=f&&R&&R.greaterThan("0")?eN.eF.fromRawAmount(f.currency,R.multiply(f.quotient).quotient):void 0,M=A&&R&&R.greaterThan("0")&&j?eN.eF.fromRawAmount(A,R.multiply(j.quotient).quotient):void 0,N=b&&R&&R.greaterThan("0")&&k?eN.eF.fromRawAmount(b,R.multiply(k.quotient).quotient):void 0,P={[tP.D.LIQUIDITY_PERCENT]:R,[tP.D.LIQUIDITY]:E,[tP.D.CURRENCY_A]:M,[tP.D.CURRENCY_B]:N};return r||(i=d("Connect Wallet")),P[tP.D.LIQUIDITY]&&P[tP.D.CURRENCY_A]&&P[tP.D.CURRENCY_B]||(i=null!=i?i:d("Enter an amount")),{pair:p,parsedAmounts:P,error:i}}(R,E,(0,m.useMemo)(()=>{if(g&&x!==g)return{targetChainId:g,chainSnapshot:{pair:s.pair,totalSupply:s.totalSupply,userLiquidity:s.nativeBalance}}},[g,x,s.pair,s.totalSupply,s.nativeBalance])),{onUserInput:G}=(0,nx.a)(),[,K]=(0,np.ek)(R,E),[ee]=(0,eI.Tz)(null!=p?p:void 0,(0,m.useMemo)(()=>[null==K?void 0:K.liquidityToken],[null==K?void 0:K.liquidityToken])),et=(null==K?void 0:K.liquidityToken)?null==ee?void 0:ee[`${K.liquidityToken.chainId}-${K.liquidityToken.address}`]:void 0,en=(0,m.useMemo)(()=>b?s.nativeBalance:et,[b,s.nativeBalance,et]),er=(0,nm.A)(null==K?void 0:K.liquidityToken),el=(0,m.useMemo)(()=>b?s.totalSupply:er,[b,s.totalSupply,er]),eo=(0,m.useMemo)(()=>(0,nh.dc)(R,w),[R,w]),ea=(0,m.useMemo)(()=>(0,nh.dc)(E,w),[E,w]),es=(0,Y.zW)(eo),ed=(0,Y.zW)(ea),eu=(0,m.useMemo)(()=>
1{if(z&&el&&en&&eo&&!(el.quotient<en.quotient))return eN.eF.fromRawAmount(eo,z.getLiquidityValue(eo,el,en,!1).quotient)},[z,el,en,eo]),ep=(0,m.useMemo)(()=>{if(z&&el&&en&&ea&&!(el.quotient<en.quotient))return eN.eF.fromRawAmount(ea,z.getLiquidityValue(ea,el,en,!1).quotient)},[z,el,en,ea]),em=(0,m.useMemo)(()=>{if(O===tP.D.LIQUIDITY_PERCENT)return!1;if(O===tP.D.LIQUIDITY){if(!(null==z?void 0:z.liquidityToken)||!en)return!1;let e=(0,nc.A)(_,z.liquidityToken);return!!(null==e?void 0:e.greaterThan(en))}if(O===tP.D.CURRENCY_A||O===tP.D.CURRENCY_B){let e=O===tP.D.CURRENCY_A?eo:ea,t=O===tP.D.CURRENCY_A?eu:ep,n=O===tP.D.CURRENCY_A?es:ed;if(!e||!t)return!1;let i=n(_);return!!(null==i?void 0:i.greaterThan(t))}return!1},[O,_,es,ed,z,en,eo,ea,eu,ep]),ef=em?c("Remove amount exceeds your LP balance"):H,[ey,eg]=(0,m.useState)(!1),[{attemptingTxn:eA,liquidityErrorMessage:eb},ew]=(0,m.useState)({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),[ej]=(0,e$.g)(),[ek]=(0,q.oA)()||[q.C0],eC={[tP.D.LIQUIDITY_PERCENT]:V[tP.D.LIQUIDITY_PERCENT].equalTo("0")?"0":V[tP.D.LIQUIDITY_PERCENT].lessThan(new eN.QE("1","100"))?"<1":V[tP.D.LIQUIDITY_PERCENT].toFixed(0),[tP.D.LIQUIDITY]:O===tP.D.LIQUIDITY?_:(0,$.O)({currencyAmount:V[tP.D.LIQUIDITY]}),[tP.D.CURRENCY_A]:O===tP.D.CURRENCY_A?_:null!=(r=N(V[tP.D.CURRENCY_A]))?r:"",[tP.D.CURRENCY_B]:O===tP.D.CURRENCY_B?_:null!=(a=P(V[tP.D.CURRENCY_B]))?a:""},{approvalState:eS,approveCallback:eR}=(0,J.en)(V[tP.D.LIQUIDITY],x?nu.U5[x]:void 0),eM=(0,m.useCallback)((e,t)=>G(e,t),[G]),eU=(0,m.useCallback)(e=>eM(tP.D.LIQUIDITY_PERCENT,e),[eM]),eB=(0,m.useCallback)(e=>eM(tP.D.CURRENCY_A,e),[eM]),eq=(0,m.useCallback)(e=>eM(tP.D.CURRENCY_B,e),[eM]),eL=(0,m.useCallback)(e=>eU(Math.ceil(e).toString()),[eU]),[eO,e_]=(0,eE.Vv)(ng(eC[tP.D.LIQUIDITY_PERCENT]),eL),eY=(0,ei.hj)(),ez=(0,tp.OQ)(),eV=(0,m.useCallback)(async()=>{let e,t,n;if(!x||!p||!ej||!eY)return;let{[tP.D.CURRENCY_A]:i,[tP.D.CURRENCY_B]:r}=V;if(!i||!r||!R||!E||!B||!F)return;let l={[tP.D.CURRENCY_A]:(0,ei.wQ)(i,ek)[0],[tP.D.CURRENCY_B]:(0,ei.wQ)(r,ek)[0]},o=V[tP.D.LIQUIDITY];if(!o)return;let a=null==E?void 0:E.isNative,s=(null==R?void 0:R.isNative)||a;if(eS!==J.h$.APPROVED)return;s?(e=["removeLiquidityETH","removeLiquidityETHSupportingFeeOnTransferTokens"],t=[a?B.address:F.address,o.quotient.toString(),l[a?tP.D.CURRENCY_A:tP.D.CURRENCY_B].toString(),l[a?tP.D.CURRENCY_B:tP.D.CURRENCY_A].toString(),p,ej]):(e=["removeLiquidity"],t=[B.address,F.address,o.quotient.toString(),l[tP.D.CURRENCY_A].toString(),l[tP.D.CURRENCY_B].toString(),p,ej]);for(let i=0;i<e.length;i++)try{let r=await eY.estimateGas[e[i]](t,{account:p});n={methodName:e[i],safeGasEstimate:(0,tw.KL)(r)};break}catch(n){console.error("estimateGas failed",e[i],t,n)}if(!n)return;let{methodName:d,safeGasEstimate:u}=n;ew({attemptingTxn:!0,liquidityErrorMessage:void 0,txHash:void 0}),await eY.write[d](t,{gas:u,gasPrice:A}).then(e=>{var t,n;ew({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:e});let i=null==(t=V[tP.D.CURRENCY_A])?void 0:t.toSignificant(3),r=null==(n=V[tP.D.CURRENCY_B])?void 0:n.toSignificant(3);ez({hash:e},{summary:`Remove ${i} ${null==R?void 0:R.symbol} and ${r} ${null==E?void 0:E.symbol}`,translatableSummary:{text:"Remove %amountA% %symbolA% and %amountB% %symbolB%",data:{amountA:i,symbolA:null==R?void 0:R.symbol,amountB:r,symbolB:null==E?void 0:E.symbol}},type:"remove-liquidity"})}).catch(e=>{e&&!(0,tx.U)(e)&&((0,tx.v)(e),console.error("Remove Liquidity failed",e,t)),ew({attemptingTxn:!1,liquidityErrorMessage:e&&!(0,tx.U)(e)?c("Remove liquidity failed: %message%",{message:(0,th.w)(e,c)}):void 0,txHash:void 0})})},[x,p,ej,eY,V,R,E,B,F,ek,eS,A,ez,c]),{data:eZ}=(0,eh.GB)(R),{data:eW}=(0,eh.GB)(E),{override0:eH,override1:eQ}=(0,m.useMemo)(()=>t7(s,R,E),[s,R,E]),eG=(0,m.useMemo)(()=>eu?eH?eH.wrapped.greaterThan(eu)?eN.eF.fromRawAmount(R,eu.quotient):eH:eN.eF.fromRawAmount(R,eu.quotient):eH,[eH,eu,R]),eK=(0,m.useMemo)(()=>ep?eQ?eQ.wrapped.greaterThan(ep)?eN.eF.fromRawAmount(E,ep.quotient):eQ:eN.eF.fromRawAmount(E,ep.quotient):eQ,[eQ,ep,E]),eX=(0,m.useMemo)(()=>!V[tP.D.LIQUIDITY_PERCENT].equalTo("0")&&!!(V[tP.D.CURRENCY_A]&&V[tP.D.CURRENCY_B]),[V]),eJ=(0,m.useMemo)(()=>
1{if(eX){let e=V[tP.D.LIQUIDITY_PERCENT],t=V[tP.D.CURRENCY_A];if(!t||e.equalTo("0"))return;return(0,ex.g)(t.toExact()).dividedBy((0,ex.g)(e.numerator.toString()).dividedBy(e.denominator.toString()))}if(eH)return(0,ex.g)(eH.toExact())},[eX,V,eH]),e0=(0,m.useMemo)(()=>{if(eX){let e=V[tP.D.LIQUIDITY_PERCENT],t=V[tP.D.CURRENCY_B];if(!t||e.equalTo("0"))return;return(0,ex.g)(t.toExact()).dividedBy((0,ex.g)(e.numerator.toString()).dividedBy(e.denominator.toString()))}if(eQ)return(0,ex.g)(eQ.toExact())},[eX,V,eQ]),e1=(0,m.useMemo)(()=>{var e,t;if(eX){let t=V[tP.D.CURRENCY_A],n=V[tP.D.LIQUIDITY_PERCENT];return!t||n.equalTo("0")?"0":null!=(e=N(t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())),6))?e:"0"}return null!=(t=N(eH,6))?t:"0"},[eX,V,eH,N]),e2=(0,m.useMemo)(()=>{var e,t;if(eX){let t=V[tP.D.CURRENCY_B],n=V[tP.D.LIQUIDITY_PERCENT];return!t||n.equalTo("0")?"0":null!=(e=P(t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())),6))?e:"0"}return null!=(t=P(eQ,6))?t:"0"},[eX,V,eQ,P]),e6=(0,m.useMemo)(()=>{var e,t;if(eX){let t=V[tP.D.CURRENCY_A],n=V[tP.D.LIQUIDITY_PERCENT];if(!t||n.equalTo("0"))return e1;let i=t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())).quotient-t.quotient;return i<0n?"0":null!=(e=N(eN.eF.fromRawAmount(t.currency,i),6))?e:"0"}return null!=(t=N(eH,6))?t:"0"},[eX,V,eH,e1,N]),e8=(0,m.useMemo)(()=>{var e,t;if(eX){let t=V[tP.D.CURRENCY_B],n=V[tP.D.LIQUIDITY_PERCENT];if(!t||n.equalTo("0"))return e2;let i=t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())).quotient-t.quotient;return i<0n?"0":null!=(e=P(eN.eF.fromRawAmount(t.currency,i),6))?e:"0"}return null!=(t=P(eQ,6))?t:"0"},[eX,V,eQ,e2,P]),e3=(0,m.useMemo)(()=>{if(eX){let e=V[tP.D.CURRENCY_A],t=V[tP.D.LIQUIDITY_PERCENT];if(!e||t.equalTo("0"))return;return e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).toExact()}return null==eH?void 0:eH.toExact()},[eX,V,eH]),e9=(0,m.useMemo)(()=>{if(eX){let e=V[tP.D.CURRENCY_B],t=V[tP.D.LIQUIDITY_PERCENT];if(!e||t.equalTo("0"))return;return e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).toExact()}return null==eQ?void 0:eQ.toExact()},[eX,V,eQ]),e4=(0,m.useMemo)(()=>{if(eX){let e=V[tP.D.CURRENCY_A],t=V[tP.D.LIQUIDITY_PERCENT];if(!e||t.equalTo("0"))return e3;let n=e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).quotient-e.quotient;return n<0n?"0":eN.eF.fromRawAmount(e.currency,n).toExact()}return null==eH?void 0:eH.toExact()},[eX,V,eH,e3]),e5=(0,m.useMemo)(()=>{if(eX){let e=V[tP.D.CURRENCY_B],t=V[tP.D.LIQUIDITY_PERCENT];if(!e||t.equalTo("0"))return e9;let n=e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).quotient-e.quotient;return n<0n?"0":eN.eF.fromRawAmount(e.currency,n).toExact()}return null==eQ?void 0:eQ.toExact()},[eX,V,eQ,e9]),e7=(0,m.useMemo)(()=>{if(!eJ||!e0||!eZ||!eW)return"$0";let e=eJ.multipliedBy(eZ),t=e0.multipliedBy(eW);return`$${e.plus(t).toFormat(2)}`},[eJ,e0,eZ,eW]),te=(0,m.useMemo)(()=>{if(!eZ||!eW)return"0";let e=V[tP.D.CURRENCY_A],t=V[tP.D.CURRENCY_B],n=e?(0,ex.g)(e.toExact()).multipliedBy(eZ):(0,ex.g)(0),i=t?(0,ex.g)(t.toExact()).multipliedBy(eW):(0,ex.g)(0);return n.plus(i).toFormat(2)},[V,eZ,eW]),tt=(0,m.useMemo)(()=>{if("$0"===e7||"0"===te||"0.00"===te)return e7;let e=(0,ex.g)(e7.replace(/[$,]/g,"")),t=(0,ex.g)(te.replace(/,/g,"")),n=e.minus(t);return`$${n.isNegative()?"0":n.toFormat(2)}`},[e7,te]),tn=(0,m.useMemo)(()=>(0,ny.C)(z,B),[z,B]),ti=(0,m.useMemo)(()=>(0,ny.C)(z,F),[z,F]),tr=!ef,tl=eS!==J.h$.APPROVED;return(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(Q.S,{currency:R}),(0,i.jsx)(Q.S,{currency:E}),(0,i.jsxs)(T.JA,{mb:"4px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:c("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),U&&(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:c("Collect as %symbol%",{symbol:C.wrapped.symbol})}),(0,i.jsx)(eP.A,{id:"receive-as-wnative-v2",scale:"sm",checked:I,onChange:()=>S(e=>!e)})]}),(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",mt:"16px",children:[(0,i.jsx)(o.y,{children:c("Amount of liquidity to remove")}),(0,i.jsxs)(h.A,{alignItems:"center",style:{gap:"8px"},children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:c("Detailed")}),(0,i.jsx)(eP.A,{scale:"sm",checked:ey,onChange:()=>{eg(e=>(e&&eU(String(eO>0?eO:50)),!e))}})]})]}),ey?(0,i.jsxs)(v.Ay,{mt:"8px",children:[(0,i.jsx)(W.A,{defaultValue:eC[tP.D.CURRENCY_A],onUserInput:eB,currency:R,overrideBalance:eG,onMax:()=>{var e;return eB(eG&&null!=(e=N(eG))?e:"")},onPercentInput:e=>{if(eG){var t;eB(null!=(t=N(eG.multiply(new eN.QE(e,100))))?t:"")}},maxAmount:eG,id:"remove-liquidity-tokena",title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),disableCurrencySelect:!0,showMaxButton:!0,showUSDPrice:!0,isUserInsufficientBalance:O===tP.D.CURRENCY_A&&em}),(0,i.jsx)(v.Ay,{mt:"8px",children:(0,i.jsx)(W.A,{defaultValue:eC[tP.D.CURRENCY_B],onUserInput:eq,currency:E,overrideBalance:eK,onMax:()=>{var e;return eq(eK&&null!=(e=P(eK))?e:"")},onPercentInput:e=>{if(eK){var t;eq(null!=(t=P(eK.multiply(new eN.QE(e,100))))?t:"")}},maxAmount:eK,id:"remove-liquidity-tokenb",title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),disableCurrencySelect:!0,showMaxButton:!0,showUSDPrice:!0,isUserInsufficientBalance:O===tP.D.CURRENCY_B&&em})})]}):(0,i.jsxs)(L.k0,{mt:"8px",padding:"16px",borderRadius:"24px",children:[(0,i.jsxs)(M.A,{fontSize:"40px",bold:!0,mb:"16px",style:{lineHeight:1},children:[eO,"%"]}),(0,i.jsx)(eT.A,{name:"lp-amount",min:0,max:100,value:eO,onValueChanged:e=>e_(Math.ceil(e)),mb:"16px"}),(0,i.jsxs)(d.A,{gap:"8px",justifyContent:"space-between",children:[(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eU("10"),width:"100%",borderRadius:"12px",children:"10%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eU("20"),width:"100%",borderRadius:"12px",children:"20%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eU("75"),width:"100%",borderRadius:"12px",children:"75%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eU("100"),width:"100%",borderRadius:"12px",children:c("Max.fill-max")})]})]}),z&&(0,i.jsxs)(L.k0,{mt:"16px",padding:"12px 16px",borderRadius:"24px",children:[(0,i.jsx)(o.y,{mb:"8px",children:c("Rates")}),(0,i.jsxs)(h.A,{justifyContent:"space-between",children:[(0,i.jsxs)(M.A,{small:!0,color:"textSubtle",children:["1 ",null==R?void 0:R.symbol]}),(0,i.jsxs)(M.A,{small:!0,children:[tn," ",null==E?void 0:E.symbol]})]}),(0,i.jsxs)(h.A,{justifyContent:"space-between",mt:"4px",children:[(0,i.jsxs)(M.A,{small:!0,color:"textSubtle",children:["1 ",null==E?void 0:E.symbol]}),(0,i.jsxs)(M.A,{small:!0,children:[ti," ",null==R?void 0:R.symbol]})]})]}),(0,i.jsx)(Z,{currency0:R,currency1:E,currency0Amount:e1,currency0NewAmount:e6,currency1Amount:e2,currency1NewAmount:e8,currency0AmountRaw:e3,currency0NewAmountRaw:e4,currency1AmountRaw:e9,currency1NewAmountRaw:e5,totalPositionUsd:e7,totalPositionNewUsd:tt,amountUsd:`$${te}`}),x!==g?(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>g?f(g):void 0,disabled:y,children:c("Switch Network")}):tl&&tr?(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:eS!==J.h$.NOT_APPROVED,onClick:eR,children:eS===J.h$.PENDING?(0,i.jsx)(nd.A,{children:c("Enabling")}):c("Enable.Approval")}):(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:eA||!tr,onClick:()=>{eV(),(0,eF.z_)()},children:null!=ef?ef:c("Remove")})]})};var nj=n(372133),nk=n(85642);let nC=(0,nf.AK)(),nI=e=>{let{position:t,poolInfo:n}=e,r=n.token0,l=n.token1,o=(0,nl.Ay)({tokenA:r,tokenB:l});return(0,i.jsx)(nl.jq.Provider,{value:o,children:(0,i.jsx)(nf.XK,{value:{formAtom:nC},children:(0,i.jsx)(nS,{position:t,poolInfo:n})})})},nS=e=>{var t,n;let{position:r,poolInfo:a}=e,{t:s}=(0,l.A)(),{account:u,chainId:c}
1=(0,X.W7)(),{switchNetworkIfNecessary:p,isLoading:x}=(0,ev.Hk)(),f=a.chainId,y=(0,nv.YW)(),g=f&&c!==f?f:c,A=a.token0,b=a.token1,w=(0,eD.Ay)(null!=g?g:void 0),[j,k]=(0,m.useState)(!1),C=(0,m.useMemo)(()=>{if(!g)return A;let e=eN.xQ[g];return e&&e.equals(A.wrapped)?j?e:w:A},[A,g,j,w]),I=(0,m.useMemo)(()=>{if(!g)return b;let e=eN.xQ[g];return e&&e.equals(b.wrapped)?j?e:w:b},[b,g,j,w]),S=(0,Y.wG)(C),R=(0,Y.wG)(I),E=!!(c&&g&&(A&&(null==(t=eN.xQ[g])?void 0:t.equals(A.wrapped))||b&&(null==(n=eN.xQ[g])?void 0:n.equals(b.wrapped))||(null==A?void 0:A.isNative)||(null==b?void 0:b.isNative))),[N,P]=(0,m.useMemo)(()=>[null==C?void 0:C.wrapped,null==I?void 0:I.wrapped],[C,I]),U=(0,tL.TH)(),B=(null==C?void 0:C.isNative)||(null==I?void 0:I.isNative),{independentField:F,typedValue:O}=(0,nf.lD)(),{pair:_,parsedAmounts:$,error:z}=function(e,t,n){var i,r,o,a,s;let d,{account:u,chainId:c}=(0,X.W7)(),{independentField:p,typedValue:x}=(0,nf.lD)(),{t:h}=(0,l.A)(),f=(0,m.useContext)(nl.jq),{pair:v}=(0,nk.v)(null==e?void 0:e.wrapped,null==t?void 0:t.wrapped),y=!!((null==n?void 0:n.chainSnapshot)&&void 0!==n.targetChainId&&c!==n.targetChainId),g=(0,m.useMemo)(()=>{var e;if(y&&(null==n||null==(e=n.chainSnapshot)?void 0:e.pair)){let e=n.chainSnapshot.pair,t=eN.eF.fromRawAmount(e.token0.wrapped,"0");return{liquidityToken:e.liquidityToken,tokenAmounts:[],token0:e.token0,token1:e.token1,priceOf:()=>t,token0Price:()=>t,token1Price:()=>t,reserve0:e.reserve0,reserve1:e.reserve1,getLiquidityValue:()=>t}}return v},[y,null==n||null==(i=n.chainSnapshot)?void 0:i.pair,v]),[A]=(0,eI.Tz)(null!=u?u:void 0,(0,m.useMemo)(()=>[(null==v?void 0:v.liquidityToken)||void 0],[null==v?void 0:v.liquidityToken])),b=(null==v?void 0:v.liquidityToken)?null==A?void 0:A[`${v.liquidityToken.chainId}-${v.liquidityToken.address}`]:void 0,w=(0,m.useMemo)(()=>y?n.chainSnapshot.nativeBalance:b,[y,n,b]),j=new eN.QE("0","100");p===tP.D.LIQUIDITY_PERCENT&&(j=new eN.QE(x,"100"));let k=w&&j&&j.greaterThan("0")?eN.eF.fromRawAmount(w.currency,j.multiply(w.quotient).quotient):void 0,[C,I]=function(e){let{lpAmount:t,stableSwapAddress:n,token0:i,token1:r,stableSwapInfoContract:l,crossChainRead:o}=e,{data:a}=(0,tk.I)({queryKey:["stableSwapInfoContract","calc_coins_amount",n,t,null==o?void 0:o.chainId,null==o?void 0:o.infoStableSwapAddress],queryFn:async()=>t?o?(0,tZ.Rt)({chainId:o.chainId}).readContract({address:o.infoStableSwapAddress,abi:nj.j,functionName:"calc_coins_amount",args:[o.stableSwapAddress,BigInt(t)]}):l&&n?l.read.calc_coins_amount([n,BigInt(t)]):void 0:void 0,enabled:!!t&&(!!o||!!(l&&n))});return Array.isArray(a)&&i&&r?[eN.eF.fromRawAmount(i,a[0].toString()),eN.eF.fromRawAmount(r,a[1].toString())]:[]}({lpAmount:null==k||null==(r=k.quotient)?void 0:r.toString(),stableSwapAddress:y?n.chainSnapshot.pair.stableSwapAddress:null==f||null==(o=f.stableSwapConfig)?void 0:o.stableSwapAddress,token0:y?n.chainSnapshot.pair.token0.wrapped:null==f||null==(a=f.stableSwapConfig)?void 0:a.token0.wrapped,token1:y?n.chainSnapshot.pair.token1.wrapped:null==f||null==(s=f.stableSwapConfig)?void 0:s.token1.wrapped,stableSwapInfoContract:y||null==f?void 0:f.stableSwapInfoContract,crossChainRead:y&&(null==n?void 0:n.targetChainId)&&n.chainSnapshot?{chainId:n.targetChainId,infoStableSwapAddress:n.chainSnapshot.pair.infoStableSwapAddress,stableSwapAddress:n.chainSnapshot.pair.stableSwapAddress}:void 0}),S={[tP.D.LIQUIDITY_PERCENT]:j,[tP.D.LIQUIDITY]:k,[tP.D.CURRENCY_A]:C,[tP.D.CURRENCY_B]:I};return u||(d=h("Connect Wallet")),S[tP.D.LIQUIDITY]||(d=null!=d?d:h("Enter an amount")),{pair:g,parsedAmounts:S,error:d}}(C,I,(0,m.useMemo)(()=>{if(f&&c!==f)return{targetChainId:f,chainSnapshot:{pair:r.pair,nativeBalance:r.nativeBalance}}},[f,c,r.pair,r.nativeBalance])),{onUserInput:V}=(0,nx.a)(),{stableSwapConfig:W,stableSwapContract:H}=(0,nl.ED)(),[{attemptingTxn:Q,liquidityErrorMessage:G},K]=(0,m.useState)({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),[ee]=(0,q.oA)()||[q.C0],et={[tP.D.LIQUIDITY_PERCENT]:$[tP.D.LIQUIDITY_PERCENT].equalTo("0")?"0":$[tP.D.LIQUIDITY_PERCENT].lessThan(new eN.QE("1","100"))?"<1":$[tP.D.LIQUIDITY_PERCENT].toFixed(0)},{approvalState:en,approveCallback:er}=(0,J.en)($[tP.D.LIQUIDITY],B?null==U?void 0:U.address:null==W?void 0:W.stableSwapAddress),el=(0,m.useCallback)((e,t)=>V(e,t),[V]),eo=(0,m.useCallback)(e=>el(tP.D.LIQUIDITY_PERCENT,e),[el]),ea=(0,m.useCallback)(e=>eo(Math.ceil(e).toString()),[eo]),[es,ed]=(0,eE.Vv)(ng(et[tP.D.LIQUIDITY_PERCENT]),ea),eu=(0,tp.OQ)(),ep=(0,m.useCallback)(async()=>{let e,t,n,i=B?U:H;if(!c||!u||!i)return;let{[tP.D.CURRENCY_A]:r,[tP.D.CURRENCY_B]:l}=$;if(!r||!l||!N||!P)return;let o={[tP.D.CURRENCY_A]:(0,ei.wQ)(r,ee)[0],[tP.D.CURRENCY_B]:(0,ei.wQ)(l,ee)[0]},a=$[tP.D.LIQUIDITY];if(!a||en!==J.h$.APPROVED)return;e=["remove_liquidity"],t=B&&H?[H.address,a.quotient.toString(),[o[tP.D.CURRENCY_A].toString(),o[tP.D.CURRENCY_B].toString()]]:[a.quotient.toString(),[o[tP.D.CURRENCY_A].toString(),o[tP.D.CURRENCY_B].toString()]];for(let r=0;r<e.length;r++)try{let l=await i.estimateGas[e[r]](t,{account:u});n={methodName:e[r],safeGasEstimate:(0,tw.KL)(l)};break}catch(n){console.error("estimateGas failed",e[r],t,n)}if(!n)return;let{methodName:d,safeGasEstimate:p}=n;K({attemptingTxn:!0,liquidityErrorMessage:void 0,txHash:void 0}),await i.write[d](t,{gas:p,gasPrice:y}).then(e=>{var t,n;K({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:e});let i=null==(t=$[tP.D.CURRENCY_A])?void 0:t.toSignificant(3),r=null==(n=$[tP.D.CURRENCY_B])?void 0:n.toSignificant(3);eu({hash:e},{summary:`Remove ${i} ${null==C?void 0:C.symbol} and ${r} ${null==I?void 0:I.symbol}`,translatableSummary:{text:"Remove %amountA% %symbolA% and %amountB% %symbolB%",data:{amountA:i,symbolA:null==C?void 0:C.symbol,amountB:r,symbolB:null==I?void 0:I.symbol}},type:"remove-liquidity"})}).catch(e=>{e&&!(0,tx.U)(e)&&((0,tx.v)(e),console.error("Remove Liquidity failed",e,t)),K({attemptingTxn:!1,liquidityErrorMessage:e&&!(0,tx.U)(e)?s("Remove liquidity failed: %message%",{message:(0,th.w)(e,s)}):void 0,txHash:void 0})})},[B,U,H,c,u,$,N,P,ee,en,y,eu,C,I,s]),{data:em}=(0,eh.GB)(C),{data:ef}=(0,eh.GB)(I),ey=(0,m.useMemo)(()=>
1{if(!$[tP.D.CURRENCY_A]||$[tP.D.LIQUIDITY_PERCENT].equalTo("0"))return;let e=$[tP.D.LIQUIDITY_PERCENT],t=$[tP.D.CURRENCY_A];return(0,ex.g)(t.toExact()).dividedBy((0,ex.g)(e.numerator.toString()).dividedBy(e.denominator.toString()))},[$]),eg=(0,m.useMemo)(()=>{if(!$[tP.D.CURRENCY_B]||$[tP.D.LIQUIDITY_PERCENT].equalTo("0"))return;let e=$[tP.D.LIQUIDITY_PERCENT],t=$[tP.D.CURRENCY_B];return(0,ex.g)(t.toExact()).dividedBy((0,ex.g)(e.numerator.toString()).dividedBy(e.denominator.toString()))},[$]),eA=(0,m.useMemo)(()=>{var e;let t=$[tP.D.CURRENCY_A],n=$[tP.D.LIQUIDITY_PERCENT];return!t||n.equalTo("0")?"0":null!=(e=S(t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())),6))?e:"0"},[$,S]),eb=(0,m.useMemo)(()=>{var e;let t=$[tP.D.CURRENCY_B],n=$[tP.D.LIQUIDITY_PERCENT];return!t||n.equalTo("0")?"0":null!=(e=R(t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())),6))?e:"0"},[$,R]),ew=(0,m.useMemo)(()=>{var e;let t=$[tP.D.CURRENCY_A],n=$[tP.D.LIQUIDITY_PERCENT];return!t||n.equalTo("0")?eA:es>=100?"0":null!=(e=S(t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())).multiply(new eN.QE(100-es,100)),6))?e:"0"},[$,eA,es,S]),ej=(0,m.useMemo)(()=>{var e;let t=$[tP.D.CURRENCY_B],n=$[tP.D.LIQUIDITY_PERCENT];return!t||n.equalTo("0")?eb:es>=100?"0":null!=(e=R(t.multiply(new eN.QE(n.denominator.toString(),n.numerator.toString())).multiply(new eN.QE(100-es,100)),6))?e:"0"},[$,eb,es,R]),ek=(0,m.useMemo)(()=>{let e=$[tP.D.CURRENCY_A],t=$[tP.D.LIQUIDITY_PERCENT];if(!(!e||t.equalTo("0")))return e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).toExact()},[$]),eC=(0,m.useMemo)(()=>{let e=$[tP.D.CURRENCY_B],t=$[tP.D.LIQUIDITY_PERCENT];if(!(!e||t.equalTo("0")))return e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).toExact()},[$]),eS=(0,m.useMemo)(()=>{let e=$[tP.D.CURRENCY_A],t=$[tP.D.LIQUIDITY_PERCENT];return!e||t.equalTo("0")?ek:es>=100?"0":e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).multiply(new eN.QE(100-es,100)).toExact()},[$,ek,es]),eR=(0,m.useMemo)(()=>{let e=$[tP.D.CURRENCY_B],t=$[tP.D.LIQUIDITY_PERCENT];return!e||t.equalTo("0")?eC:es>=100?"0":e.multiply(new eN.QE(t.denominator.toString(),t.numerator.toString())).multiply(new eN.QE(100-es,100)).toExact()},[$,eC,es]),eM=(0,m.useMemo)(()=>{if(!ey||!eg||!em||!ef)return"$0";let e=ey.multipliedBy(em),t=eg.multipliedBy(ef);return`$${e.plus(t).toFormat(2)}`},[ey,eg,em,ef]),eU=(0,m.useMemo)(()=>{if(!ey||!eg||!em||!ef)return"0";let e=ey.multipliedBy(em).multipliedBy(es/100),t=eg.multipliedBy(ef).multipliedBy(es/100);return e.plus(t).toFormat(2)},[ey,eg,em,ef,es]),eB=(0,m.useMemo)(()=>{if("$0"===eM||"0"===eU)return eM;let e=(0,ex.g)(eM.replace(/[$,]/g,"")),t=(0,ex.g)(eU.replace(/,/g,"")),n=e.minus(t);return`$${n.isNegative()?"0":n.toFormat(2)}`},[eM,eU]),eq=!z,eL=en!==J.h$.APPROVED;return(0,i.jsxs)(v.Ay,{children:[(0,i.jsxs)(T.JA,{mb:"4px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:s("Slippage Tolerance")}),(0,i.jsx)(ec.AK,{})]}),E&&(0,i.jsxs)(h.A,{justifyContent:"space-between",alignItems:"center",mt:"16px",children:[(0,i.jsx)(M.A,{color:"textSubtle",small:!0,children:s("Collect as %symbol%",{symbol:w.wrapped.symbol})}),(0,i.jsx)(eP.A,{id:"receive-as-wnative-ss",scale:"sm",checked:j,onChange:()=>k(e=>!e)})]}),(0,i.jsx)(o.y,{mt:"16px",children:s("Amount of liquidity to remove")}),(0,i.jsxs)(L.k0,{mt:"8px",padding:"16px",borderRadius:"24px",children:[(0,i.jsxs)(M.A,{fontSize:"40px",bold:!0,mb:"16px",style:{lineHeight:1},children:[es,"%"]}),(0,i.jsx)(eT.A,{name:"lp-amount",min:0,max:100,value:es,onValueChanged:e=>ed(Math.ceil(e)),mb:"16px"}),(0,i.jsxs)(d.A,{gap:"8px",justifyContent:"space-between",children:[(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eo("10"),width:"100%",borderRadius:"12px",children:"10%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eo("20"),width:"100%",borderRadius:"12px",children:"20%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eo("75"),width:"100%",borderRadius:"12px",children:"75%"}),(0,i.jsx)(D.A,{variant:"primary60Outline",scale:"sm",onClick:()=>eo("100"),width:"100%",borderRadius:"12px",children:s("Max.fill-max")})]})]}),(0,i.jsx)(Z,{currency0:C,currency1:I,currency0Amount:eA,currency0NewAmount:ew,currency1Amount:eb,currency1NewAmount:ej,currency0AmountRaw:ek,currency0NewAmountRaw:eS,currency1AmountRaw:eC,currency1NewAmountRaw:eR,totalPositionUsd:eM,totalPositionNewUsd:eB,amountUsd:`$${eU}`}),c!==f?(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>f?p(f):void 0,disabled:x,children:s("Switch Network")}):eL?(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:en!==J.h$.NOT_APPROVED,onClick:er,children:en===J.h$.PENDING?(0,i.jsx)(nd.A,{children:s("Enabling")}):s("Enable.Approval")}):(0,i.jsx)(D.A,{mt:"16px",width:"100%",disabled:Q||!eq,onClick:()=>{ep(),(0,eF.z_)()},children:null!=z?z:s("Remove")})]})};var nR=n(334404),nE=n(227883),nM=n(389512),nN=n(282692);let nP=e=>{let{position:t,poolInfo:n}=e,{t:r}=(0,l.A)(),{toastSuccess:o}=(0,nR.d)(),{chainId:a}=(0,X.W7)(),{switchNetworkIfNecessary:s,isLoading:d}=(0,ev.Hk)(),[,u]=(0,eW.r)(),{loading:c,fetchWithCatchTxError:p}=(0,nM.A)(),{chainId:x}=n,h=a!==x,f=n.lpAddress,{bCakeWrapperAddress:y}=n,{onHarvest:g}=(0,nN.F)(f,y),{earningsAmount:A,earningsBusd:b,hasEarnings:w,isLoading:j}=(0,t6._L)(n),k=(0,m.useCallback)(async()=>{let e=await p(()=>g());(null==e?void 0:e.status)&&(u(e),o(`${r("Harvested")}!`,(0,i.jsx)(nE.G,{txHash:e.transactionHash,children:r("Your %symbol% earnings have been sent to your wallet!",{symbol:"CAKE"})})))},[p,g,u,r,o]),C=(0,m.useMemo)(()=>n.stableSwapAddress||n.lpAddress,[n.stableSwapAddress,n.lpAddress]);return(0,i.jsxs)(v.Ay,{children:[w||j?(0,i.jsx)(e2,{rewardToken:E.vb[x],rewardsAmount:A,rewardsUSD:b,onHarvest:k,harvesting:c,disabled:c||j||!w,hideButton:h}):(0,i.jsx)(M.A,{color:"textSubtle",textAlign:"center",py:"24px",children:r("No farming rewards to harvest")}),(0,i.jsx)(e4,{poolAddress:C,poolProtocol:n.protocol,chainId:x,disabled:h,hideButton:h}),(0,i.jsx)(tt,{poolAddress:C,chainId:x}),h&&(0,i.jsx)(D.A,{mt:"16px",width:"100%",onClick:()=>x?s(x):void 0,disabled:d,children:r("Switch Network")})]})},nT=e=>{var t;let{poolId:n,chainId:o,position:a,protocol:s,tab:u="Add"}=e,{t:c}=(0,l.A)(),p=(0,R.qX)({poolAddress:n,chainId:o}),x=(0,m.useMemo)(()=>
1{if(p||!a||!o)return null;if(s===r.Zs.V2&&"pair"in a){let{pair:e}=a;return{chainId:o,protocol:r.Zs.V2,lpAddress:e.liquidityToken.address,token0:e.token0,token1:e.token1,feeTier:2500,feeTierBase:1e6,isFarming:!!a.isStaked}}if(s===r.Zs.STABLE&&"pair"in a){let{pair:e}=a;return{chainId:o,protocol:r.Zs.STABLE,lpAddress:e.lpAddress,token0:e.token0,token1:e.token1,feeTier:Math.round(1e6*e.stableTotalFee),feeTierBase:1e6,isFarming:!!a.isStaked}}return null},[p,a,o,s]),h=null!=p?p:x;return h?(0,i.jsxs)(v.Ay,{children:[(0,i.jsx)(P,{currency0:h.token0,currency1:h.token1,feeTierDisplay:(0,i.jsx)(tl.Q,{type:h.protocol,percent:new eN.QE(null!=(t=null==h?void 0:h.feeTier)?t:0n,null==h?void 0:h.feeTierBase)}),rangeTags:(0,i.jsxs)(d.A,{alignItems:"center",children:[(0,i.jsxs)(d.A,{gap:"4px",children:[(0,i.jsx)(j.K,{outOfRange:!1,lowContrast:!0}),(null==h?void 0:h.isFarming)&&(0,i.jsx)(y.A,{variant:"primary60",children:c("Farming")})]}),(0,i.jsx)(k.cD,{poolAddress:h.lpAddress}),(0,i.jsx)(C.rW,{poolAddress:h.lpAddress})]}),aprDisplay:a?(0,i.jsx)(I.xo,{pool:h,userPosition:a,textProps:{fontSize:"16px"}}):null}),(0,i.jsx)(v.Ay,{mt:"16px",children:"Harvest"===u?(0,i.jsx)(nP,{position:a,poolInfo:h}):s===r.Zs.V2?"Add"===u?(0,i.jsx)(ni,{position:a,poolInfo:h}):"Remove"===u?(0,i.jsx)(nb,{position:a,poolInfo:h}):null:s===r.Zs.STABLE?"Add"===u?(0,i.jsx)(na,{position:a,poolInfo:h}):"Remove"===u?(0,i.jsx)(nI,{position:a,poolInfo:h}):null:null})]}):"Unable to fetch pool info, or pool does not exist"},nU=(0,x.Ay)(o.y).withConfig({componentId:"sc-2c28f3e3-0"})(["cursor:pointer;transition:scale,opacity 0.15s;user-select:none;"," &:active{transform:translateY(1px);}"],e=>{let{$active:t}=e;return!t&&` 2 &:hover { 3 opacity: 0.7; 4 } 5 `}),nB={Add:"Add Liquidity",Remove:"Remove Liquidity",Harvest:"Harvest"};function nD(e){let{isOpen:t,onDismiss:n,protocol:o,poolId:x,chainId:h,position:f,presetTab:v}=e,{t:y}=(0,l.A)(),g=(0,u.jE)();(0,m.useEffect)(()=>{if(t&&h&&x){var e;g.refetchQueries({queryKey:["poolInfo",h,null!=(e=(0,p.QR)(x))?e:x]})}},[t,h,x,g]);let A=(0,m.useMemo)(()=>{let e=["Add","Remove"];return o&&o!==r.Zs.InfinitySTABLE&&(o===r.Zs.V3||(0,c.T)(o)?e.push("Harvest"):f&&"farmingBalance"in f&&f.farmingBalance.greaterThan(0)&&e.push("Harvest")),e},[o,f]),[b,w]=(0,m.useState)(null!=v?v:"Add");(0,m.useEffect)(()=>{t&&v&&w(v)},[t,v]),(0,m.useEffect)(()=>{A.includes(b)||w("Add")},[A,b]);let j=(0,m.useCallback)(e=>{w(e)},[w]);return x&&o?(0,i.jsx)(a.aF,{isOpen:t,onDismiss:n,closeOnOverlayClick:!0,children:(0,i.jsxs)(s.Ay,{title:y("Position Management"),headerBorderColor:"transparent",bodyPadding:"0 24px 16px",onDismiss:n,width:["100%",null,o===r.Zs.InfinityBIN?"520px":"452px"],children:[(0,i.jsx)(d.A,{gap:"16px",mb:"16px",children:A.map(e=>(0,i.jsx)(nU,{color:b===e?"secondary":"textSubtle",onClick:()=>j(e),$active:b===e,children:y(nB[e])},e))}),o===r.Zs.InfinitySTABLE?(0,i.jsx)(tF,{poolId:x,chainId:h,tab:b,position:f}):(0,c.T)(o)?(0,i.jsx)(tr,{poolId:x,chainId:h,tab:b,position:f}):o===r.Zs.V3?(0,i.jsx)(t9,{poolId:x,chainId:h,tab:b,position:f}):o===r.Zs.V2||o===r.Zs.STABLE?(0,i.jsx)(nT,{poolId:x,chainId:h,tab:b,position:f,protocol:o}):"protocol not supported (testing)"]})}):null}},43185:(e,t,n)=>{"use strict";n.d(t,{w:()=>r});var i=n(769621);function r(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&i._P in e?e[i._P](t):e instanceof Date?new e.constructor(t):new Date(t)}},50369:(e,t,n)=>{"use strict";n.d(t,{H:()=>a});var i=n(827666),r=n(242312),l=n.n(r),o=n(715599).Buffer;let a=async e=>{let{raydium:t,poolInfo:n,position:r,liquidity:a,amountMinA:s,amountMinB:d,simulateOnly:u}=e;if(!t)return;let{simulate:c}=await t.clmm.decreaseLiquidity({poolInfo:n.rawPool,poolKeys:t.clmm.getClmmKeysFromPoolInfo(n.rawPool),ownerPosition:r,ownerInfo:{useSOLBalance:!0,closePosition:!1},liquidity:new(l())(a),amountMinA:new(l())(s),amountMinB:new(l())(d),txVersion:i.HqF.V0});if(u)try{var p;let e=await c({accounts:{encoding:"base64",addresses:n.rawPool.rewardDefaultInfos.map(e=>e.mint.address)}});if(!e.value.logs||e.value.logs.length<3)return;let t=await crypto.subtle.digest("SHA-256",o.from("event:DecreaseLiquidityEvent","utf-8")),r=o.from(t).toString("base64").slice(0,8),l=null==(p=e.value.logs.find(e=>e.startsWith(`Program data: ${r}`)))?void 0:p.slice(14);if(!l)return;return i.vSc.decode(o.from(l,"base64"))}catch(e){console.error("Simulation error:",e)}}}
5,52093:(e,t,n)=>{"use strict";n.d(t,{u:()=>l});var i=n(448390),r=n(25963);function l(e){let{currencyA:t,currencyB:n,feeAmount:l,interval:o}=e,{isLoading:a,error:s,data:d}=(0,i.Ud)(t,n,l,o),u=(0,r.useCallback)(()=>{if(!(null==d?void 0:d.length))return;let e=[];for(let t=0;t<d.length;t++){let n=d[t],i={activeLiquidity:parseFloat(n.liquidityActive.toString()),price0:parseFloat(n.price0)};i.activeLiquidity>0&&e.push(i)}return e},[d]);return(0,r.useMemo)(()=>({isLoading:a,error:s,formattedData:a?void 0:u()}),[a,s,u])}},57654:(e,t,n)=>{"use strict";n.d(t,{A:()=>y});var i=n(311560),r=n(673384),l=n(909114),o=n(555967),a=n(341050),s=n(25963),d=n(306411),u=n(733775),c=n(792118),p=n(452301),m=n(663257),x=n(17581),h=n(495964),f=n(236088),v=n(514666);let y=e=>{let{chainId:t,onDone:n}=e,{address:y}=(0,x.F)(),{data:g}=(0,h.G)(),{sendTransactionAsync:A}=(0,f.s)(),{switchNetworkIfNecessary:b,isLoading:w}=(0,v.H)(),j=(0,d.OQ)(),{maxFeePerGas:k,maxPriorityFeePerGas:C}=(0,l.N)(t),[I,S]=(0,s.useState)(!1),R=(0,o.TA)({chainId:t}),E=(0,o.p6)(t),M=!!((null==E?void 0:E.address)&&(null==E?void 0:E.address)!=="0x"),{tokenIds:N,loading:P}=(0,a.s2)(M?null==E?void 0:E.address:void 0,y,t);return{attemptingTx:I||w,isLoadingStakedPositions:P,onCollect:(0,s.useCallback)(async e=>{let{pool:l,tokenId:o,feeValue0:a,feeValue1:s,receiveWNATIVE:d=!1}=e;if(!t||!y||!R||await b(t))return;let x=!!N.find(e=>e===o),h=x?E:R,f=x?r.SG:r.uy;if(h){S(!0);try{var v,w,I;let e=d?l.token0:(0,p.U$)(l.token0),r=d?l.token1:(0,p.U$)(l.token1),{calldata:x,value:b}=f.collectCallParameters({tokenId:o.toString(),expectedCurrencyOwed0:null!=a?a:i.eF.fromRawAmount(e,0),expectedCurrencyOwed1:null!=s?s:i.eF.fromRawAmount(r,0),recipient:y}),R={to:h.address,data:x,value:(0,m.uU)(b),account:y,chain:null==g?void 0:g.chain},E=await (null==(v=(0,c.Qr)({chainId:t}))?void 0:v.estimateGas(R));if(!E)throw Error("Failed to estimate gas");let M={...R,gas:(0,u.KL)(E),maxFeePerGas:k,maxPriorityFeePerGas:C},N=await A(M),P=null!=a?a:i.eF.fromRawAmount(e,0),T=null!=s?s:i.eF.fromRawAmount(r,0);return j({hash:N},{type:"collect-fee",summary:`Collect fee ${P.toExact()} ${null==e?void 0:e.symbol} and ${T.toExact()} ${null==r?void 0:r.symbol}`,translatableSummary:{text:"Collect fee %amountA% %symbolA% and %amountB% %symbolB%",data:{amountA:P.toExact(),symbolA:null!=(w=null==e?void 0:e.symbol)?w:"",amountB:T.toExact(),symbolB:null!=(I=null==r?void 0:r.symbol)?I:""}}}),null==n||n(N),S(!1),N}catch(e){throw console.error("[useV3CollectFeeAction] Error collecting fees:",e),S(!1),e}}},[t,y,R,b,N,E,g,A,j,n,k,C])}}}
5,59299:(e,t,n)=>{"use strict";n.d(t,{T:()=>a});var i=n(25963),r=n(91168),l=n(72912),o=n(98378);let a=e=>{var t,n,a,s;let{poolInfo:d,tickLower:u,tickUpper:c,liquidity:p}=e,{amount0:m,amount1:x}=(0,o.y)({poolInfo:d,tickLower:u,tickUpper:c,liquidity:p}),{data:h}=(0,l.wm)({mint:null==d||null==(t=d.mintA)?void 0:t.address,enabled:!!(null==d||null==(n=d.mintA)?void 0:n.address)}),{data:f}=(0,l.wm)({mint:null==d||null==(a=d.mintB)?void 0:a.address,enabled:!!(null==d||null==(s=d.mintB)?void 0:s.address)});return(0,i.useMemo)(()=>{var e,t,n,i;return m&&x&&h&&f?{usdValue0:new r.A(null!=(e=null==m?void 0:m.toExact())?e:0).multipliedBy(null!=h?h:0),usdValue1:new r.A(null!=(t=null==x?void 0:x.toExact())?t:0).multipliedBy(null!=f?f:0),totalUsdValue:new r.A(null!=(n=null==m?void 0:m.toExact())?n:0).multipliedBy(null!=h?h:0).plus(new r.A(null!=(i=null==x?void 0:x.toExact())?i:0).multipliedBy(null!=f?f:0))}:{usdValue0:void 0,usdValue1:void 0}},[m,x,h,f])}},59404:(e,t,n)=>{"use strict";n.d(t,{t:()=>a});var i=n(350979),r=n(461738),l=n(41898);n(190562);let o=(0,n(680797).Ay)(l.A).withConfig({componentId:"sc-fd298476-0"})([".rc-slider-rail{background-color:",";height:2px;position:absolute;top:18px;width:100%;}.rc-slider-track{background-color:",";filter:",";height:10px;position:absolute;top:18px;}.rc-slider-handle{-webkit-appearance:none;background-color:transparent;box-shadow:none;border:0;cursor:pointer;width:24px;height:32px;filter:none;transform:translate(-2px,-2px);transition:200ms transform;&:hover{transform:scale(1.1) translate(-3px,-3px);}}.rc-slider-handle-1{background-image:url(",");}.rc-slider-handle-2{background-image:url(",");}"],e=>{let{theme:t,disabled:n}=e;return t.colors[n?"textDisabled":"inputSecondary"]},e=>{let{theme:t}=e;return t.colors.primary},e=>{let{disabled:t}=e;return t?"grayscale(100%)":"none"},r.f5,r.mk),a=e=>(0,i.jsx)(o,{range:!0,...e})},59701:(e,t,n)=>{"use strict";n.d(t,{M:()=>i.M,g:()=>r.g});var i=n(841228),r=n(486556)},70619:(e,t,n)=>{"use strict";n.d(t,{cB:()=>i.c,Zp:()=>X,bw:()=>ee,aR:()=>J,IV:()=>r.IV,UB:()=>r.UB,uO:()=>A,rr:()=>r.rr,K5:()=>l.K,QO:()=>E.Q,sT:()=>M.s,M8:()=>P.M,n6:()=>W.n,X5:()=>Z.X5,pr:()=>T.p,uu:()=>r.uu,_o:()=>r._o,c1:()=>v.c1,k_:()=>M.k});var i=n(216625),r=n(944715),l=n(30899),o=n(350979),a=n(796147),s=n(557423),d=n(950171),u=n(20664),c=n(619005),p=n(326848),m=n(25963),x=n(796764),h=n(680797),f=n(721665),v=n(350375);let y=h.Ay.ul.withConfig({componentId:"sc-35ad9506-0"})([""]),g=h.Ay.li.withConfig({componentId:"sc-35ad9506-1"})(["display:flex;padding:12px 16px;align-items:center;gap:16px;justify-content:space-between;border-bottom:1px solid ",";background:1px solid ",";&:first-child{border-top:1px solid ",";}"],e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.card.background},e=>{let{theme:t}=e;return t.colors.cardBorder}),A=e=>{let{data:t,getItemKey:n,onRowClick:i}=e,[l,c]=(0,m.useState)(null),h=(0,m.useCallback)(e=>{e||c(null)},[]),A=(0,p.useRouter)(),b=(0,m.useCallback)(async e=>{let t=await (0,f.VZ)(e);A.push(t)},[A]),w=(0,m.useCallback)(e=>{var t,i;return n?n(e):e.farm?(0,x.sc)(e.farm):[e.chainId,e.protocol,null!=(i=null!=(t=e.lpAddress)?t:e.poolId)?i:""].join(":")},[n]);return(0,o.jsxs)(y,{children:[t.map(e=>{var t;return(0,o.jsxs)(g,{onClick:()=>null==i?void 0:i(e),children:[(0,o.jsxs)(a.VP,{gap:"12px",onClick:()=>b(e),children:[(0,o.jsx)(v.bS,{data:e}),(0,o.jsx)(r.rr,{pool:e,aprInfo:null==(t=(0,x.oP)(e.farm))?void 0:t.aprInfo})]}),(0,o.jsx)(a.VP,{children:(0,o.jsx)(s.A,{scale:"xs",variant:"text",onClick:t=>{t.stopPropagation(),c(e)},py:"2rem",pl:"1rem",children:(0,o.jsx)(d.A,{})})})]},w(e))}),(0,o.jsx)(u.A,{drawerContainerStyle:{height:"auto"},isOpen:null!==l,setIsOpen:h,content:(0,o.jsx)(R,{data:l})})]})},b=h.Ay.div.withConfig({componentId:"sc-35ad9506-2"})([""]),w=h.Ay.div.withConfig({componentId:"sc-35ad9506-3"})(["display:flex;padding:16px 0 8px;justify-content:center;"]),j=h.Ay.div.withConfig({componentId:"sc-35ad9506-4"})(["width:36px;height:4px;border-radius:9999px;opacity:0.1;background:",";"],e=>{let{theme:t}=e;return t.colors.contrast}),k=h.Ay.div.withConfig({componentId:"sc-35ad9506-5"})(["border-top:1px solid ",";&& button{display:flex;padding:12px 16px;justify-content:space-between;gap:8px;color:",";font-weight:400;line-height:24px;width:100%;}"],e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.text}),C=h.Ay.div.withConfig({componentId:"sc-35ad9506-6"})(["display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:8px;padding:16px;color:",";font-size:12px;font-weight:600;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),I=h.Ay.div.withConfig({componentId:"sc-35ad9506-7"})(["display:flex;width:100%;justify-content:space-between;align-items:flex-end;line-height:150%;"]),S=(0,h.Ay)(a.VP).withConfig({componentId:"sc-35ad9506-8"})(["text-transform:uppercase;"]),R=(0,m.memo)(e=>{let{data:t}=e,n=(0,v.IO)();return t?(0,o.jsxs)(b,{children:[(0,o.jsx)(w,{children:(0,o.jsx)(j,{})}),(0,o.jsxs)(C,{children:[(0,o.jsx)(v.bS,{data:t}),n.map(e=>(0,o.jsxs)(I,{children:[(0,o.jsx)(S,{children:"function"==typeof e.title?e.title():"string"==typeof e.title?e.title.toUpperCase():e.title}),(0,o.jsx)(a.VP,{children:e.render?e.render(e.dataIndex?t[e.dataIndex]:t,t,0):e.dataIndex?t[e.dataIndex]:null})]},e.key))]}),(0,o.jsx)(k,{children:(0,o.jsx)(l.L,{pool:t,icon:(0,o.jsx)(c.A,{})})})]}):null});var E=n(977973),M=n(779133);n(704784);var N=n(484562),P=n(451184),T=n(435619),U=n(228876),B=n(734658),D=n(659197),F=n(203907),q=n(489886),L=n(72912),O=n(619749),_=n(487430),$=n(542160),Y=n(98378),z=n(903878),V=n(200604);(0,m.memo)(e=>{var t,n;let{position:i,detailMode:r}
5=e,l=null!=(t=(0,q.xk)(i.poolId.toBase58()))?t:void 0,a=(0,m.useMemo)(()=>(0,O.ph)(null==l?void 0:l.mintA),[null==l?void 0:l.mintA]),s=(0,m.useMemo)(()=>(0,O.ph)(null==l?void 0:l.mintB),[null==l?void 0:l.mintB]),{priceUpper:d,priceLower:u}=(0,$.x)({tickLower:i.tickLower,tickUpper:i.tickUpper,baseIn:!0,poolInfo:l}),{amount0:c,amount1:p}=(0,Y.y)({poolInfo:l,tickLower:i.tickLower,tickUpper:i.tickUpper,liquidity:i.liquidity}),x=(0,m.useMemo)(()=>{let e=(0,_.iz)(null==l?void 0:l.config.tickSpacing);return(0,_.Kc)(i.tickLower,i.tickUpper,e)},[null==l?void 0:l.config.tickSpacing,i.tickLower,i.tickUpper]),h=(0,m.useMemo)(()=>{if(a&&s&&l)return{pid:0,nftMint:i.nftMint,lpAddress:B.cF,protocol:D.Zs.V3,token0:a,token1:s,feeTier:Math.round(l.feeRate*z.J),feeTierBase:z.J,isFarming:!1,poolId:i.poolId.toBase58(),liquidity:BigInt(i.liquidity.toString()),chainId:U.Cb.SOLANA,tvlUsd:l.tvl.toString(),rawPool:l}},[a,s,l,i.liquidity,i.poolId,i.nftMint]),{data:f}=(0,L.wm)({mint:null==a?void 0:a.wrapped.address,enabled:!!a}),{data:v}=(0,L.wm)({mint:null==s?void 0:s.wrapped.address,enabled:!!s}),y=(0,m.useMemo)(()=>{var e,t;return Number(null!=f?f:0)*Number(null!=(e=null==c?void 0:c.toExact())?e:0)+Number(null!=v?v:0)*Number(null!=(t=null==p?void 0:p.toExact())?t:0)},[f,v,c,p]),g=(0,m.useMemo)(()=>(0,o.jsx)(T.p,{base:null!=a?a:void 0,quote:null!=s?s:void 0,priceLower:u,priceUpper:d,tickAtLimit:x}),[a,s,u,d,x]);return(0,o.jsx)(N.l,{link:`/liquidity/position/v3/solana/${null==h?void 0:h.poolId}/${i.nftMint.toBase58()}`,chainId:U.Cb.SOLANA,pool:h,totalPriceUSD:y,amount0:c,amount1:p,desc:g,currency0:null!=a?a:void 0,currency1:null!=s?s:void 0,removed:i.liquidity.isZero(),outOfRange:i.status===F.$.INACTIVE,fee:null!=(n=null==l?void 0:l.feeRate)?n:0,feeTierBase:1,protocol:D.Zs.V3,isStaked:null==l?void 0:l.isFarming,detailMode:r,userPosition:i,children:a&&s&&h?(0,o.jsx)(V.u,{removed:i.liquidity.isZero(),outOfRange:i.status===F.$.INACTIVE,chainId:U.Cb.SOLANA,detailMode:r,poolInfo:h,position:i}):null})}).displayName="SolanaV3PositionItem",n(97114),n(437862),n(990056),n(782739),n(555849),n(660430),BigInt(1e10),new B.QE(25,1e4),n(366028),n(483547),n(524261),n(755407),n(959072),n(271780),n(851931);var Z=n(178629),W=n(293173),H=n(807543),Q=n(341936),G=n(150591),K=n(349142);let X=(0,h.Ay)(H.A).withConfig({componentId:"sc-6e262b19-0"})(["overflow:initial;min-height:600px;display:flex;flex-direction:column;"]),J=(0,h.Ay)(Q.A).withConfig({componentId:"sc-6e262b19-1"})(["padding:16px;background:",";","{padding:24px;}"],e=>{let{theme:t}=e;return t.card.background},e=>{let{theme:t}=e;return t.mediaQueries.sm}),ee=(0,h.Ay)(G.A).withConfig({componentId:"sc-6e262b19-2"})(["padding:0;"]);(0,h.Ay)(K.A).withConfig({componentId:"sc-6e262b19-3"})(["position:sticky;bottom:50px;z-index:50;border-bottom-right-radius:",";border-bottom-left-radius:",";background:",";text-align:center;font-size:12px;font-weight:400;color:",";display:flex;justify-content:center;align-items:center;gap:4px;line-height:18px;padding:12px 16px;","{bottom:0;}"],e=>{let{theme:t}=e;return t.radii.card},e=>{let{theme:t}=e;return t.radii.card},e=>{let{theme:t}=e;return t.card.background},e=>{let{theme:t}=e;return t.colors.textSubtle},e=>{let{theme:t}=e;return t.mediaQueries.lg})},88748:(e,t,n)=>{"use strict";n.d(t,{S$:()=>l,pG:()=>r});var i=n(25963);let r=e=>{let t=(0,i.useRef)(null),[n,r]=(0,i.useState)({left:!1,right:!1}),l=(0,i.useCallback)(()=>{let e=t.current;if(!e)return;let n=e.scrollWidth-e.clientWidth;r({left:e.scrollLeft>1,right:e.scrollLeft<n-1})},[]);return(0,i.useEffect)(()=>{let e=t.current;if(!e)return;if(l(),e.addEventListener("scroll",l,{passive:!0}),"undefined"==typeof ResizeObserver)return()=>e.removeEventListener("scroll",l);let n=new ResizeObserver(l);return n.observe(e),()=>{e.removeEventListener("scroll",l),n.disconnect()}},[l,e]),{ref:t,edges:n,measure:l}},l=e=>{let t=(0,i.useRef)({down:!1,startX:0,startLeft:0,moved:!1}),[n,r]=(0,i.useState)(!1),l=(0,i.useCallback)(n=>{let i=e.current;i&&"touch"!==n.pointerType&&0===n.button&&(t.current={down:!0,startX:n.clientX,startLeft:i.scrollLeft,moved:!1})},[e]),o=(0,i.useCallback)(n=>{let i=e.current;if(!i||!t.current.down)return;let l=n.clientX-t.current.startX;if(!(!t.current.moved&&4>Math.abs(l))){if(!t.current.moved){var o;t.current.moved=!0,r(!0),null==(o=i.setPointerCapture)||o.call(i,n.pointerId)}i.scrollLeft=t.current.startLeft-l}},[e]),a=(0,i.useCallback)(()=>{t.current.down&&(t.current.down=!1,r(!1))},[]);return{dragging:n,didDrag:()=>t.current.moved,handlers:{onPointerDown:l,onPointerMove:o,onPointerUp:a,onPointerCancel:a,onPointerLeave:a}}}},90634:(e,t,n)=>{"use strict";n.d(t,{A:()=>
5o});var i=n(350979),r=n(25963),l=n(286750);function o(e){let{children:t}=e,n=(0,r.useMemo)(()=>(0,l.AK)(),[]);return(0,i.jsx)(l.Ib,{value:{formAtom:n},children:t})}},97114:(e,t,n)=>{"use strict";n.d(t,{Z:()=>l});var i=n(459587),r=n(25963);let l=e=>{let{currency0:t,currency1:n,amount0:l,amount1:o}=e,{data:a}=(0,i.GB)(t,{enabled:l&&l.greaterThan(0)}),{data:s}=(0,i.GB)(n,{enabled:o&&o.greaterThan(0)});return(0,r.useMemo)(()=>Number(null!=a?a:0)*Number(l?l.toExact():0)+Number(null!=s?s:0)*Number(o?o.toExact():0),[l,o,a,s])}},98378:(e,t,n)=>{"use strict";n.d(t,{R:()=>c,y:()=>u});var i=n(827666),r=n(734658),l=n(91168),o=n(619749),a=n(25963),s=n(72912),d=n(644919);let u=e=>{let{poolInfo:t,tickLower:n,tickUpper:l,liquidity:s}=e,u=(0,a.useMemo)(()=>(null==t?void 0:t.mintA)?(0,o.ph)(t.mintA):void 0,[null==t?void 0:t.mintA]),c=(0,a.useMemo)(()=>(null==t?void 0:t.mintB)?(0,o.ph)(t.mintB):void 0,[null==t?void 0:t.mintB]),{data:p}=(0,d.H)(!!t),[m,x]=(0,a.useMemo)(()=>{if(!u||!c||!t||!p||!s||!t.price)return[void 0,void 0];let{amountA:e,amountB:o}=i.ZZh.getAmountsFromLiquidity({poolInfo:t,ownerPosition:{tickLower:n,tickUpper:l},liquidity:s,slippage:0,add:!1,epochInfo:p});return[r.C3.fromRawAmount(u,e.amount.toString()),r.C3.fromRawAmount(c,o.amount.toString())]},[t,s,n,l,u,c,p]),[h,f]=(0,a.useMemo)(()=>t&&"number"==typeof n&&"number"==typeof l&&"number"==typeof t.tickCurrent?[t.tickCurrent>l,t.tickCurrent<n]:[!1,!1],[n,l,t]);return{amount0:m,amount1:x,amount0Disabled:h,amount1Disabled:f}},c=e=>{var t,n,i,o;let{poolInfo:d,tickLower:c,tickUpper:p,liquidity:m}=e,{amount0:x,amount1:h}=u({poolInfo:d,tickLower:c,tickUpper:p,liquidity:m}),{data:f}=(0,s.wm)({mint:null==d||null==(t=d.mintA)?void 0:t.address,enabled:!!(null==d||null==(n=d.mintA)?void 0:n.address)}),{data:v}=(0,s.wm)({mint:null==d||null==(i=d.mintB)?void 0:i.address,enabled:!!(null==d||null==(o=d.mintB)?void 0:o.address)});return(0,a.useMemo)(()=>{var e,t,n,i;if(!x||!h||!f||!v)return{ratio0:void 0,ratio1:void 0};let o=new l.A(null!=(e=null==x?void 0:x.toExact())?e:0).multipliedBy(null!=f?f:0),a=new l.A(null!=(t=null==h?void 0:h.toExact())?t:0).multipliedBy(null!=v?v:0),s=o.plus(a),[d,u]=new l.A(null!=(n=o.toNumber())?n:0).dividedBy(s.toNumber()||1).toFraction(),[c,p]=new l.A(null!=(i=a.toNumber())?i:0).dividedBy(s.toNumber()||1).toFraction();return{ratio0:new r.QE(d.toString(),u.toString()),ratio1:new r.QE(c.toString(),p.toString())}},[x,h,f,v])}},99490:(e,t,n)=>{"use strict";n.d(t,{m:()=>r});var i=n(501823);let r=(0,n(680797).Ay)(i.A).withConfig({componentId:"sc-68f62443-0"})(["padding:12px;","{padding:16px;}align-items:flex-start;position:relative;gap:12px;border-radius:20px;border:1px solid ",";border-bottom-width:2px;background:",";margin:8px 0;cursor:pointer;transition:background 0.15s ease-in-out,transform 0s;"," transform:translateZ(0);&:first-of-type{margin-top:0;}"],e=>{let{theme:t}=e;return t.mediaQueries.sm},e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.card.background},e=>{let{theme:t,$withLink:n}=e;return n&&` 6 &:hover { 7 background: ${t.colors.backgroundHover}; 8 } 9 &:active { 10 background: ${t.colors.backgroundTapped}; 11 } 12 `})},106736:(e,t,n)=>{"use strict";n.d(t,{p:()=>c});var i=n(864737),r=n(282268),l=n(171341),o=n(466790),a=n(797041),s=n(660876),d=n(735868);async function u(e,t){let n=t.contracts.map(e=>{let{address:t,abi:n,functionName:i,args:r,value:l}=e;return{data:(0,s.p)({abi:n,functionName:i,args:r}),to:t,value:l}});return(0,d.T)(e,l.yM,"sendCalls")({...t,calls:n}
12)}function c(){return e=>({getCallsStatus:t=>(0,i.k)(e,t),getCapabilities:t=>(0,r.F)(e,t),sendCalls:t=>(0,l.yM)(e,t),showCallsStatus:t=>(0,o.J)(e,t),waitForCallsStatus:t=>(0,a.c)(e,t),writeContracts:t=>u(e,t)})}},112205:()=>{},125795:(e,t,n)=>{"use strict";n.d(t,{Gu:()=>y,Gy:()=>c,YS:()=>T});var i=n(350979),r=n(25963),l=n(680797),o=n(815148),a=n(253365),s=n(334337);let d=l.Ay.button.withConfig({componentId:"sc-3b20590c-0"})(["display:inline-flex;align-items:center;gap:8px;padding:4px 0;border:0;background:transparent;font-family:inherit;font-size:16px;font-weight:600;line-height:1.5;white-space:nowrap;cursor:pointer;color:var(--tooltip-inverse-link,#48d0db);font-feature-settings:'liga' off;"]),u=e=>{let{content:t}=e,{targetRef:n,tooltip:r,tooltipVisible:l}=(0,a.fS)(t,{placement:"bottom-start"});return(0,i.jsxs)("span",{ref:n,style:{display:"inline-flex"},children:[l&&r,(0,i.jsx)(f,{width:"24px"})]})},c=e=>{let{headingHelp:t,learnHowLabel:n="Learn How",onLearnHow:r}=e;return t||r?(0,i.jsx)(u,{content:null!=t?t:(0,i.jsxs)(d,{type:"button",onClick:r,children:[n,(0,i.jsx)(o.aO4,{width:"24px",color:"currentColor"})]})}):null},p=l.Ay.div.withConfig({componentId:"sc-3b20590c-1"})(["display:flex;justify-content:center;width:100%;height:197px;box-sizing:border-box;padding:24px;background:var(--pcs-colors-background-bubblegum,linear-gradient(139.73deg,#e5fdff 0%,#f3efff 100%));font-family:'Kanit',sans-serif;"]),m=l.Ay.div.withConfig({componentId:"sc-3b20590c-2"})(["display:flex;align-items:flex-start;justify-content:space-between;gap:24px;width:100%;max-width:1200px;height:149px;"]),x=l.Ay.div.withConfig({componentId:"sc-3b20590c-3"})(["display:flex;flex-direction:column;justify-content:center;gap:24px;flex:0 1 645px;min-width:0;height:100%;"]),h=l.Ay.div.withConfig({componentId:"sc-3b20590c-4"})(["display:flex;align-items:center;gap:8px;"]),f=(0,l.Ay)(o.NTw).withConfig({componentId:"sc-3b20590c-5"})(["flex:none;color:",";cursor:help;&:hover{opacity:0.7;}"],e=>{let{theme:t}=e;return t.colors.textSubtle}),v=l.Ay.h1.withConfig({componentId:"sc-3b20590c-6"})(["margin:0;font-size:32px;font-weight:600;line-height:1.2;letter-spacing:-0.32px;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.text}),y=l.Ay.span.withConfig({componentId:"sc-3b20590c-7"})(["color:",";"],e=>{let{theme:t}=e;return t.colors.secondary}),g=(0,i.jsxs)(i.Fragment,{children:["Earn from ",(0,i.jsx)(y,{children:"Liquidity Pools"})," & ",(0,i.jsx)(y,{children:"Farms"})]}),A=l.Ay.div.withConfig({componentId:"sc-3b20590c-8"})(["display:flex;align-items:center;justify-content:space-between;width:100%;height:54px;"]),b=l.Ay.span.withConfig({componentId:"sc-3b20590c-9"})(["flex:none;align-self:stretch;width:1px;background:",";"],e=>{let{theme:t}=e;return t.colors.cardBorder}),w=l.Ay.span.withConfig({componentId:"sc-3b20590c-10"})(["font-size:12px;font-weight:600;line-height:1.5;letter-spacing:0.24px;text-transform:uppercase;white-space:nowrap;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),j=l.Ay.div.withConfig({componentId:"sc-3b20590c-11"})(["display:flex;flex-direction:column;align-items:center;flex:none;width:85px;text-align:center;"]),k=l.Ay.span.withConfig({componentId:"sc-3b20590c-12"})(["font-size:24px;font-weight:600;line-height:1.5;letter-spacing:-0.24px;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.text}),C=l.Ay.div.withConfig({componentId:"sc-3b20590c-13"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;flex:none;"]),I=l.Ay.div.withConfig({componentId:"sc-3b20590c-14"})(["display:flex;align-items:center;justify-content:center;gap:4px;"]),S=l.Ay.span.withConfig({componentId:"sc-3b20590c-15"})(["display:inline-flex;align-items:center;justify-content:center;flex:none;padding:2px 8px 1px;border-radius:999px;background:",";font-size:12px;font-weight:600;line-height:1.5;letter-spacing:0.24px;text-transform:uppercase;white-space:nowrap;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.card},e=>{let{theme:t}=e;return t.colors.secondary}),R=l.Ay.div.withConfig({componentId:"sc-3b20590c-16"})(["display:flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap;"]),E=l.Ay.span.withConfig({componentId:"sc-3b20590c-17"})(["font-size:16px;font-weight:600;line-height:1.5;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.text}),M=(0,l.Ay)(E).withConfig({componentId:"sc-3b20590c-18"})(["font-weight:400;"]),N=l.Ay.span.withConfig({componentId:"sc-3b20590c-19"})(["font-size:12px;line-height:1.5;letter-spacing:0.24px;opacity:0.5;color:",";"],e=>{let{theme:t}=e;return t.colors.textSubtle}),P=l.Ay.div.withConfig({componentId:"sc-3b20590c-20"})(["display:flex;flex:none;width:466px;height:100%;"]),T=e=>{let{heading:t=g,headingHelp:n,learnHowLabel:l="Learn How",onLearnHow:o,totalTvlLabel:a="Total TVL",totalTvl:d="-",metrics:u=[],showStats:f=!0,volumeLabel:y="24H vol",picksLabel:T="Pancake picks \uD83D\uDD25",picks:U=[],feeLabel:B="Fee",aprLabel:D="APR",tvlLabel:F="TVL",className:q}=e;return(0,i.jsx)(p,{className:q,children:(0,i.jsxs)(m,{children:[(0,i.jsxs)(x,{children:[(0,i.jsxs)(h,{children:[(0,i.jsx)(v,{children:t}),(0,i.jsx)(c,{headingHelp:n,learnHowLabel:l,onLearnHow:o})]}),f&&(0,i.jsxs)(A,{children:[(0,i.jsxs)(j,{children:[(0,i.jsx)(w,{children:a}),(0,i.jsx)(k,{children:d})]}),u.map(e=>(0,i.jsxs)(r.Fragment,{children:[(0,i.jsx)(b,{"aria-hidden":!0}),(0,i.jsxs)(C,{children:[(0,i.jsxs)(I,{children:[(0,i.jsx)(S,{children:e.label}),(0,i.jsx)(w,{children:y})]}),(0,i.jsxs)(R,{children:[(0,i.jsx)(E,{children:e.value}
12),(0,i.jsx)(N,{"aria-hidden":!0,children:"|"}),(0,i.jsx)(M,{children:e.volume})]})]})]},e.label))]})]}),U.length>0&&(0,i.jsx)(P,{children:(0,i.jsx)(s.y,{picks:U,variant:"wide",label:T,feeLabel:B,aprLabel:D,tvlLabel:F})})]})})}},131117:(e,t,n)=>{"use strict";n.d(t,{a:()=>r});var i=n(43185);function r(e,t){return(0,i.w)(t||e,e)}},133018:(e,t,n)=>{"use strict";function i(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:6;try{if(!e||!t)return"-";let i=e.priceOf(t);if(!i)return"-";return i.toSignificant(n)}catch(e){return console.error("safeGetTokenPairPrice error:",e),"-"}}n.d(t,{C:()=>i})},146105:(e,t,n)=>{"use strict";n.d(t,{w:()=>l});var i=n(25963),r=n(306411);let l=e=>{let t=(0,r.OQ)(e);return(0,i.useCallback)((e,n)=>{e&&t({transactionHash:e},{type:"harvest",summary:"Harvested farm rewards",translatableSummary:{text:"Harvested farm rewards",...null!=n&&Number.isFinite(n)&&n>0?{data:{totalUsd:n}}:{}}})},[t])}},148388:(e,t,n)=>{e.exports=n(488511)(n(638280))},149160:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var i=n(350979),r=n(769932),l=n(557423),o=n(501823),a=n(605641),s=n(498938);let d=(0,n(680797).I4)(l.A).withConfig({componentId:"sc-bb7aac7a-0"})(["border-radius:8px;padding-left:4px;padding-right:4px;"]);function u(e){let{currencyA:t,handleRateToggle:n}=e,{t:l}=(0,r.A)();return t?(0,i.jsxs)(o.A,{justifyContent:"center",alignItems:"center",children:[(0,i.jsx)(a.A,{mr:"4px",color:"textSubtle",children:l("View prices in")}),(0,i.jsx)(d,{variant:"secondary",scale:"sm",onClick:n,startIcon:(0,i.jsx)(s.A,{color:"primary"}),children:null==t?void 0:t.symbol})]}):null}},149201:(e,t,n)=>{var i=n(19773),r=n(22363);e.exports=function(e){return!0===e||!1===e||r(e)&&"[object Boolean]"==i(e)}},152497:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var i=n(228876),r=n(769932),l=n(334404),o=n(924627),a=n(227883),s=n(196229),d=n(25963),u=n(306411),c=n(681941);function p(){let{t:e}=(0,r.A)(),{toastError:t,toastSuccess:n}=(0,l.d)(),[p,m]=(0,d.useState)(!1),x=(0,u.OQ)(i.Cb.SOLANA),{wallet:h}=(0,o.v)(),f=(0,c.I)(h),v=(0,d.useCallback)(n=>{console.error("Solana transaction error:",n);let i=e("Transaction failed");if(null==n?void 0:n.message){let t=n.message.toLowerCase();t.includes("insufficient funds")||t.includes("insufficient lamports")?i=e("Insufficient balance to complete transaction"):t.includes("blockhash not found")?i=e("Network congestion. Please try again"):t.includes("transaction was not confirmed")?i=e("Transaction failed to confirm. Please try again"):t.includes("user rejected")||t.includes("user denied")?i=e("Transaction rejected by user"):t.includes("invalid account data")?i=e("Invalid account data. Please check recipient address"):t.includes("program error")?i=e("Program execution error. Please try again"):t.includes("timeout")?i=e("Transaction timeout. Please try again"):(console.error("Solana transaction error:",n),i=e("Send didnât go through. Please try again."))}t(e("Transaction Failed"),i)},[e,t]);return{loading:p,executeSolanaTransaction:(0,d.useCallback)(async(t,i)=>{let r=null;try{if(m(!0),(r=await t())&&r.hash&&!f&&void 0===r.status&&x({hash:r.hash},{...null==i?void 0:i()}),!r)throw Error("Transaction failed to execute");return r.hash&&(f?n(e("Multisig transaction submitted"),d.createElement(s.A,null)):n(e("Transaction Submitted"),d.createElement(a.B,{txHash:r.hash},e("Your transaction has been submitted to the network")))),r}catch(e){var l,o;throw(null==(l=e.message)?void 0:l.toLowerCase().includes("user rejected"))||(null==(o=e.message)?void 0:o.toLowerCase().includes("user denied"))||v(e),e}finally{m(!1)}},[e,n,v,x,f]),handleSolanaError:v}}},157657:(e,t,n)=>{"use strict";n.d(t,{$C:()=>h,LU:()=>f,aS:()=>v,yB:()=>x});var i=n(311560),r=n(968182),l=n.n(r),o=n(25963),a=n(862373),s=n(970645),d=n(452301),u=n(859886),c=n(782038),p=n(968349);function m(e,t){let{chainId:n}=(0,p.ax)(),[i,r]=n?[(0,d.dc)(e,n),(0,d.dc)(t,n)]:[void 0,void 0],a=(0,o.useMemo)(()=>{var e,t,l,o,a;if(!n)return[];let d=null!=(l=s.mn[n])?l:[];return[...d,...i&&null!=(o=null==(e=s.L3[n])?void 0:e[i.address])?o:[],...r&&null!=(a=null==(t=s.L3[n])?void 0:t[r.address])?a:[]]},[n,i,r]),c=(0,o.useMemo)(()=>l()(a,e=>a.map(t=>
12[e,t])),[a]),m=(0,o.useMemo)(()=>i&&r?[[i,r],...a.map(e=>[i,e]),...a.map(e=>[r,e]),...c].filter(e=>!!(e[0]&&e[1])).filter(e=>{let[t,n]=e;return t.address!==n.address}).filter(e=>{let[t,i]=e;if(!n)return!0;let r=s.Jl[n],l=null==r?void 0:r[t.address],o=null==r?void 0:r[i.address];return!l&&!o||(!l||!!l.find(e=>i.equals(e)))&&(!o||!!o.find(e=>t.equals(e)))}):[],[i,r,a,c,n]),x=(0,u.hM)(m);return(0,o.useMemo)(()=>Object.values(x.filter(e=>!!(e[0]===u.CN.EXISTS&&e[1])).reduce((e,t)=>{var n;let[,i]=t;return e[i.liquidityToken.address]=null!=(n=e[i.liquidityToken.address])?n:i,e},{})),[x])}function x(e,t){let n=m(null==e?void 0:e.currency,t),[r]=(0,a.aw)();return(0,o.useMemo)(()=>{if(e&&t&&n.length>0){var l,o;if(r)return null!=(l=i.h2.bestTradeExactIn(n,e,t,{maxHops:1,maxNumResults:1})[0])?l:null;let a=null;for(let r=1;r<=3;r++){let l=null!=(o=i.h2.bestTradeExactIn(n,e,t,{maxHops:r,maxNumResults:1})[0])?o:null;(0,i.rS)(a,l,s.fE)&&(a=l)}return a}return null},[n,e,t,r])}function h(e,t){let n=m(e,null==t?void 0:t.currency),[r]=(0,a.aw)();return(0,o.useMemo)(()=>{if(e&&t&&n.length>0){var l,o;if(r)return null!=(l=i.h2.bestTradeExactOut(n,e,t,{maxHops:1,maxNumResults:1})[0])?l:null;let a=null;for(let r=1;r<=3;r++){let l=null!=(o=i.h2.bestTradeExactOut(n,e,t,{maxHops:r,maxNumResults:1})[0])?o:null;(0,i.rS)(a,l,s.fE)&&(a=l)}return a}return null},[e,t,n,r])}function f(e,t){let{shouldBlock:n}=(0,c.Wd)(e,t);return n}function v(e,t){let{shouldWarn:n}=(0,c.Wd)(e,t);return n}},171751:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/add/[[...currency]]",function(){return n(805995)}])},178629:(e,t,n)=>{"use strict";n.d(t,{X5:()=>no});var i=n(350979),r=n(501823),l=n(605641),o=n(659197),a=n(680797),s=n(769932),d=n(326848),u=n(25963),c=n(779133),p=n(228876),m=n(734658),x=n(91168),h=n(208103),f=n(981830),v=n(459587),y=n(687287),g=n(437862),A=n(402861),b=n(956586),w=n(17581),j=n(450253),k=n.n(j),C=n(273523),I=n(487430),S=n(112616),R=n(252146),E=n(312680),M=n(131619),N=n(642010),P=n(857019),T=n(179087),U=n(670420),B=n(796898),D=n(282304),F=n(995315),q=n(796147),L=n(24153),O=n(557423),_=n(294643),$=n(748853),Y=n(823585),z=n(38395),V=n(420248),Z=n(181471),W=n(53847),H=n(288429),Q=n(737982),G=n(20897),K=n(344730),X=n(885334),J=n(810286),ee=n(517024),et=n(876579),en=n(271780),ei=n(959072);let er=a.Ay.div.withConfig({componentId:"sc-d116fd6b-0"})(["display:",";padding:6px;border-top:1px solid ",";overflow:auto;min-height:",";max-height:calc(100vh - 600px);-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}","{padding:12px;}"],e=>{let{$visible:t}=e;return t?"block":"none"},e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{$num:t}=e;return 0===t?"auto":1===t?"190px":"300px"},e=>{let{theme:t}=e;return t.mediaQueries.sm}),el=e=>{var t,n,r;let{pos:a,positionList:d,currency0:c,currency1:m,isOpen:h,closeOnOverlayClick:f,showPositionFees:v=!0,onDismiss:b,onHarvest:j,onCollect:k,chainId:I}=e,S=null!=a?a:null==d?void 0:d[0],{protocol:R,chainId:M,poolKey:N}=null!=S?S:{},P=null!=I?I:M,{t:el}=(0,s.A)(),{theme:eo}=(0,T.DP)(),{address:ea}=(0,w.F)(),[es,ed]=(0,u.useState)(!1),[eu]=(0,ee.J)(),ec=(0,u.useMemo)(()=>null==d?void 0:d.filter(e=>{var t,n,i,r,l;return e.protocol===o.Zs.InfinityCLAMM?null==(r=null==eu||null==(n=eu[e.chainId])||null==(t=n[e.poolId])?void 0:t[e.tokenId.toString()])||r:null==(l=null==eu||null==(i=eu[e.chainId])?void 0:i[e.poolId])||l}),[d,eu]),{totalUnclaimedRewards:ep}=(0,A.LM)({chainId:P,user:ea}),em=ep.reduce((e,t)=>new x.A(t.totalReward).plus(e),new x.A(0)),ex=(0,X.T)(),eh=em.times(ex),ef=N?(0,C.Qn)(N):void 0,{feeAmount0:ev,feeAmount1:ey,totalFiatValue:eg}=(0,K.O)({currency0:c,currency1:m,tickLower:S&&("tickLower"in S?S.tickLower:void 0),tickUpper:S&&("tickUpper"in S?S.tickUpper:void 0),tokenId:S&&("tokenId"in S?S.tokenId:void 0),poolId:S?ef:void 0,enabled:v&&!!S}),eA=(0,y.Wu)(ev),eb=(0,y.Wu)(ey),{isMobile:ew}=(0,B.A)(),ej=(0,u.useMemo)(()=>ew?"0px 4px 8px":"0px 24px 24px",[ew]);return(0,i.jsx)(E.aF,{onDismiss:b,isOpen:h,closeOnOverlayClick:f,children:(0,i.jsx)(D.Ay,{width:["100%","100%","100%","480px"],title:el("Harvest Infinity Farms"),headerBorderColor:"transparent",bodyPadding:ej,children:(0,i.jsxs)(F.A,{gap:"24px",alignItems:"flex-start",flexDirection:"column",children:[(0,i.jsx)(H.T,{isReady:!0,token:c,quoteToken:m,iconWidth:"48px",title:(0,i.jsxs)(F.A,{gap:"4px",alignItems:"center",children:[(0,i.jsx)(l.A,{as:"span",bold:!0,fontSize:"20px",mr:"8px",children:`${c.symbol} / ${m.symbol}`}),(0,i.jsx)(Q.Eu,{poolId:ef,chainId:P})]}),getChainName:et.Y6,icon:(0,i.jsx)(G.hm,{width:44,height:44,variant:"inverted",primaryToken:c,secondaryToken:m.wrapped})}),(0,i.jsx)(Z.V,{primaryMsg:el("Harvesting earnings from all Infinity farming positions under %chainName%",{chainName:P?p.Qk[P]:""})}),(0,i.jsxs)(W.Al,{border:`1px solid ${eo.colors.cardBorder}`,padding:"0",children:[(0,i.jsxs)(q.mm,{padding:"12px",children:[(0,i.jsxs)(l.A,{textTransform:"uppercase",children:[(0,i.jsx)(l.A,{color:"textSubtle",as:"span",fontSize:"12px",fontWeight:600,children:el("Total earnings from ")}),(0,i.jsx)(l.A,{color:"secondary",as:"span",fontSize:"12px",fontWeight:600,children:el("%num% Positions",{num:null!=(t=null==ec?void 0:ec.length)?t:0})})]}),(0,i.jsxs)(L.eF,{justifyContent:"space-between",gap:"8px",children:[(0,i.jsxs)(q.mm,{justifyContent:"flex-start",children:[(0,i.jsx)(l.A,{mt:"8px",as:"h3",fontWeight:600,fontSize:24,children:(0,$.l)(eh.toFixed(18))}),(0,i.jsxs)(L.eF,{gap:"8px",children:[(0,i.jsx)(z.Z,{currency:U.x_.cake}),(0,i.jsxs)(l.A,{color:"textSubtle",fontSize:14,children:[(0,Y.ZV)(em.toFixed(18))," CAKE"]})]})]}),(0,i.jsx)(O.A,{width:["100%","100%","auto"],onClick:j,disabled:em.isLessThanOrEqualTo(0),children:el("Harvest All")})]}),(null==ec?void 0:ec.length)?(0,i.jsx)(Z.q,{style:{textAlign:"center"},children:(0,i.jsx)(_.d,{expanded:es,onClick:()=>ed(e=>!e),children:el(es?"Hide":"Details")})}):null]}),(0,i.jsx)(er,{$visible:es,$num:null!=(n=null==ec?void 0:ec.length)?n:0,children:null==ec?void 0:ec.map(e=>e.protocol===o.Zs.InfinityCLAMM?(0,i.jsx)(ei.q,{data:e,showAPR:!1,miniMode:!0},(0,g.S_)({chainId:e.chainId,poolAddress:e.poolId,tokenId:e.tokenId,protocol:e.protocol})):e.protocol===o.Zs.InfinityBIN?(0,i.jsx)(en.o,{miniMode:!0,showAPR:!1,data:e},(0,g.S_)({chainId:e.chainId,poolAddress:e.poolId,tokenId:e.activeId.toString(),protocol:e.protocol})):null)})]}),v&&R===o.Zs.InfinityCLAMM?(0,i.jsxs)(q.mm,{padding:"12px",width:"100%",children:[(0,i.jsx)(l.A,{color:"textSubtle",as:"span",fontSize:"12px",fontWeight:600,textTransform:"uppercase",children:el("Unclaimed Fees")}),(0,i.jsxs)(L.eF,{justifyContent:"space-between",gap:"8px",children:[(0,i.jsxs)(q.mm,{justifyContent:"flex-start",flex:1,children:[(0,i.jsx)(l.A,{as:"h3",fontWeight:600,fontSize:24,children:(0,$.l)(null!=(r=null==eg?void 0:eg.toExact())?r:0)}),(0,i.jsxs)(L.eF,{gap:"8px",children:[(0,i.jsx)(V.g,{currency0:c,
12currency1:m,innerMargin:"-4px"}),(0,i.jsxs)(l.A,{color:"textSubtle",fontSize:14,children:[(0,i.jsx)(J.g3,{amount:ev,color:"textSubtle",fontSize:14,style:{display:"inline-block"},children:null!=eA?eA:"0"})," ",c.symbol," +"," ",(0,i.jsx)(J.g3,{amount:ey,color:"textSubtle",fontSize:14,style:{display:"inline-block"},children:null!=eb?eb:"0"})," ",m.symbol]})]})]}),(0,i.jsx)(O.A,{width:["100%","100%","auto"],onClick:k,disabled:!((null==ev?void 0:ev.greaterThan(0))||(null==ey?void 0:ey.greaterThan(0))),children:el("Collect")})]})]}):null]})})})};var eo=n(944715),ea=n(893001),es=n(979332),ed=n(28192),eu=n(703082),ec=n(258213),ep=n(671449),em=n(762971),ex=n(898719),eh=n(538534),ef=n(732269),ev=n(562265),ey=n(810498),eg=n(573271),eA=n(605360),eb=n(978300),ew=n(428089),ej=n(599876),ek=n(990296),eC=n(32654),eI=n(795904),eS=n(892977),eR=n(919968),eE=n(150103),eM=n(905470),eN=n(721665),eP=n(650176),eT=n(662928),eU=n(38866),eB=n(623208),eD=n(60199),eF=n(54753);let eq=(0,a.Ay)(ew.Ay).withConfig({componentId:"sc-33f54cd4-0"})(["margin:8px 0;min-height:200px;width:100%;"]);var eL=n(888178),eO=n(456194),e_=n(218090),e$=n(632259),eY=n(393851),ez=n(227432),eV=n(382425),eZ=n(397261),eW=n(43838),eH=n(561767),eQ=n(453461);function eG(e){return Number.isFinite(e)&&(0===e||e>=1e-18&&e<=1e18)}let eK=[.5,1,2,4,8];function eX(e){let{x:t,y:n,width:r,height:l,fill:o}=e,a=Math.max(r,1),s=Math.max(l,1);return(0,i.jsx)("rect",{x:r<1?t-(a-r)/2:t,y:n,width:a,height:s,fill:o,rx:2,ry:2})}let eJ=e=>{let{chartData:t,tickLower:n,tickUpper:r,tickCurrent:o,priceLower:d,priceUpper:c,priceCurrent:p,baseIn:m=!0,token0Symbol:x,token1Symbol:h,compact:f=!1,height:v=200,isFullRange:y=!1}=e,{t:g}=(0,s.A)(),[A,b]=(0,u.useState)(!1),[w,j]=(0,u.useState)(1),k=eK[w],C=(0,u.useCallback)(()=>{j(e=>Math.max(0,e-1))},[]),I=(0,u.useCallback)(()=>{j(e=>Math.min(eK.length-1,e+1))},[]);(0,u.useEffect)(()=>{A&&b(!1)},[t,n,r,o,A]);let S=(0,a.DP)(),{isDark:R}=(0,eL.Ay)(),E=(0,u.useId)(),M=(0,u.useMemo)(()=>{try{if(!t||0===t.length)return[];let e=m?"price0":"price1",i=t.filter(t=>{let n=t[e];return eG(n)});if(0===i.length)return console.warn("[PositionChartV2] All chart data filtered out as insane"),[];if(y){let e=Math.round(500*k),t=o-e,n=o+e,r=i.filter(e=>e.tick>=t&&e.tick<=n);if(0===r.length){let e=Math.round(150*k);r=i.filter(t=>t.tick>=o-e&&t.tick<=o+e),0===r.length&&(r=i)}return r.sort((e,t)=>m?e.tick-t.tick:t.tick-e.tick)}let l=r-n,a=Math.max(.3*l,50)*k,s=n-a,d=r+a,u=i.filter(e=>e.tick>=s&&e.tick<=d);if(0===u.length){let e=Math.max(2*l,200)*k;u=i.filter(t=>t.tick>=n-e&&t.tick<=r+e),0===u.length&&(u=i)}return u.sort((e,t)=>m?e.tick-t.tick:t.tick-e.tick)}catch(e){return console.error("[PositionChartV2] Error filtering chart data:",e),b(!0),[]}},[t,n,r,m,y,o,k]),[N,P,T]=(0,u.useMemo)(()=>{let e,t=M.find(e=>e.tick===n),i=M.find(e=>e.tick===o),l=M.find(e=>e.tick===r);!t&&M.length&&(t=M.reduce((e,t)=>Math.abs(t.tick-n)<Math.abs(e.tick-n)?t:e,M[0])),!i&&M.length&&(e=M.reduce((e,t)=>t.tick<o?t.tick>e.tick?t:e:t.tick>o&&Math.abs(t.tick-o)<Math.abs(e.tick-o)?t:e,M[0])),!l&&M.length&&(l=M.reduce((e,t)=>Math.abs(t.tick-r)<Math.abs(e.tick-r)?t:e,M[0]));let a=m?d:c>0?1/c:d,s=m?c:d>0?1/d:c,u=null!=i?i:e,x=m?null==u?void 0:u.price0:null==u?void 0:u.price1;return[a,null!=p&&Number.isFinite(p)&&(m?p>=0:p>0)?m?p:1/p:null!=x?x:m?p:p>0?1/p:void 0,s]},[M,o,n,r,m,d,c,p]),U=(0,u.useMemo)(()=>{if(null==P||!Number.isFinite(Number(P)))return;let e=Number(P);if(eG(e))return 0===e?"0":e.toFixed(4)},[P]),B=(0,u.useMemo)(()=>o>=n&&o<=r?S.colors.success:S.colors.failure,[o,n,r,S.colors.success,S.colors.failure]),D=(0,u.useMemo)(()=>{let e=0;for(let t of M)t.liquidity>e&&(e=t.liquidity);return e},[M]),q=(0,u.useMemo)(()=>{let e=m?"price0":"price1",t=m?p:p>0?1/p:0,n=t>=0&&eG(t);if(y&&n){let n=.1*k*t,i=t-n,r=t+n;if(M.length>0){let n=M.map(t=>t[e]).filter(e=>e>0&&eG(e));if(n.length>0){let e=.15*t*k,l=n.filter(n=>n>=t-e&&n<=t+e);if(l.length>0){let e=Math.min(...l),t=Math.max(...l);i=Math.min(i,e),r=Math.max(r,t)}}}let l=.1*(r-i);return[Math.max(0,i-l),r+l]}if(!(d&&c&&d>0&&c>0)){if(0===M.length)return;let i=M.map(t=>t[e]).filter(e=>e>0&&eG(e));if(0===i.length)return;let r=Math.min(...i),l=Math.max(...i),o=l-r,a=o>0?.1*o:.1*r,s=Math.max(0,r-a),d=l+a;return n&&(t<s&&(s=Math.max(0,t-a)),t>d&&(d=t+a)),[s,d]}let i=m?d:c>0?1/c:d,r=m?c:d>0?1/d:c,l=Math.min(i,r),o=Math.max(i,r),a=l,s=o;if(M.length>0){let t=M.map(t=>t[e]).filter(e=>e>0&&eG(e));t.length>0&&(a=Math.min(a,...t),s=Math.max(s,...t))}let u=Math.min(a,l),x=Math.max(s,o),h=x-u,f=o-l<.1*l?.15:.05,v=h>0?h*f:u*f,g=Math.max(0,u-v),A=x+v;if(n){if(t<g){let e=(A-t)*.1;g=Math.max(0,t-e)}if(t>A){let e=(t-g)*.1;A=t+e}}return[g,A]},[M,d,c,m,y,p,k]),{xAxisTickPrecision:O,dynamicMinTickGap:_}=(0,u.useMemo)(()=>
12{if(!q||0===M.length)return{xAxisTickPrecision:2,dynamicMinTickGap:f?20:30};let e=m?"price0":"price1",t=M.map(t=>t[e]).filter(e=>e>0&&e>=q[0]&&e<=q[1]).sort((e,t)=>e-t);if(t.length<2)return{xAxisTickPrecision:2,dynamicMinTickGap:f?20:30};let n=1/0;for(let e=1;e<t.length;e++){let i=Math.abs(t[e]-t[e-1]);i>0&&i<n&&(n=i)}if(!Number.isFinite(n)||0===n)return{xAxisTickPrecision:2,dynamicMinTickGap:f?20:30};let i=2;for(;i<8;){let e=!0,n=new Set;for(let l of t){var r;let t=null!=(r=(0,eO.e)(l,{precision:i}))?r:String(l);if(n.has(t)){e=!1;break}n.add(t)}if(e)break;i++}let l=Math.max(1,i-2);return{xAxisTickPrecision:i,dynamicMinTickGap:(f?20:30)+8*l}},[q,M,m,f]),[$,Y]=(0,u.useState)(void 0),[z,V]=(0,u.useState)(void 0),[Z,W]=(0,u.useState)(void 0);return((0,u.useEffect)(()=>{W(void 0),Y(void 0),V(void 0)},[m]),A)?(0,i.jsx)(eQ.yn,{children:g("Chart display error")}):M.length?(0,i.jsxs)(ew.Ay,{width:"100%",position:"relative",children:[!f&&!y&&(0,i.jsx)(e1,{x0:Z,x1:$,x2:z,xLower:N,xUpper:T,rangeColor:B,baseIn:m}),(0,i.jsx)(e_.u,{width:"100%",height:v,children:(0,i.jsxs)(e$.E,{data:M,barCategoryGap:0,barGap:0,margin:{top:f?20:30,right:0,left:0,bottom:f?4:8},children:[(0,i.jsx)("defs",{children:(0,i.jsxs)("linearGradient",{id:E,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,i.jsx)("stop",{offset:"5%",stopColor:R?"rgba(168, 129, 252, 0.95)":"rgba(118, 69, 217, 0.95)",stopOpacity:.95}),(0,i.jsx)("stop",{offset:"95%",stopColor:R?"rgba(168, 129, 252, 0.5)":"rgba(118, 69, 217, 0.5)",stopOpacity:.95})]})}),(0,i.jsx)(eY.W,{type:"number",dataKey:m?"price0":"price1",axisLine:!1,tickLine:!1,tick:{fontSize:f?10:12,fill:S.colors.textSubtle},tickFormatter:e=>{var t;return null!=(t=(0,eO.e)(e,{precision:O}))?t:""},minTickGap:_,interval:"preserveStartEnd",domain:q,allowDataOverflow:!0}),(0,i.jsx)(ez.h,{hide:!0,axisLine:!1,tickLine:!1,domain:[0,D]}),null!=P&&Number.isFinite(P)&&eG(P)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(eV.e,{x:P,stroke:S.colors.secondary,strokeWidth:2,strokeDasharray:"3 3",children:U&&(0,i.jsx)(eZ.J,{value:U,position:"top",offset:10,style:{fill:S.colors.secondary,fontSize:f?"11px":"12px",fontWeight:"bold",stroke:"white",strokeWidth:.5,paintOrder:"stroke"}})}),(0,i.jsx)(eV.e,{x:P,stroke:S.colors.secondary,strokeWidth:1,shape:e=>(0,i.jsx)(e0,{x:e.x1,onEffect:W,baseIn:m})})]}),y&&q?(0,i.jsx)(eW.T,{x1:q[0],x2:q[1],fill:S.colors.success,fillOpacity:.1}):N&&T&&(0,i.jsx)(eW.T,{x1:N,x2:T,fill:B,fillOpacity:.1}),N&&T&&!f&&!y&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(eV.e,{segment:[{x:N,y:D},{x:T,y:D}],stroke:B,position:"start",strokeWidth:0,shape:e=>(0,i.jsx)(e0,{x:e.x1,onEffect:Y,baseIn:m})}),(0,i.jsx)(eV.e,{segment:[{x:N,y:D},{x:T,y:D}],stroke:B,position:"end",strokeWidth:0,shape:e=>(0,i.jsx)(e0,{x:e.x2,onEffect:V,baseIn:m})})]}),!y&&N&&(0,i.jsx)(eV.e,{position:"start",x:N,stroke:B,strokeWidth:2}),!y&&T&&(0,i.jsx)(eV.e,{position:"end",x:T,stroke:B,strokeWidth:2}),(0,i.jsx)(eH.y,{dataKey:"liquidity",fill:`url(#${E})`,isAnimationActive:!1,minPointSize:1,shape:e=>{var t,n,r,l,o;return(0,i.jsx)(eX,{x:null!=(t=e.x)?t:0,y:null!=(n=e.y)?n:0,width:null!=(r=e.width)?r:0,height:null!=(l=e.height)?l:0,fill:null!=(o=e.fill)?o:`url(#${E})`})}})]})}),(0,i.jsxs)(e6,{children:[(0,i.jsx)(e8,{onClick:I,disabled:w>=eK.length-1,children:"â"}),(0,i.jsx)(e8,{onClick:C,disabled:w<=0,children:"+"})]}),!f&&x&&h&&(0,i.jsxs)(L.eF,{justifyContent:"space-between",mt:"8px",children:[(0,i.jsxs)(F.A,{alignItems:"center",gap:"4px",children:[(0,i.jsx)(ew.Ay,{style:{width:"7px",height:"7px",background:S.colors.secondary,borderRadius:"10px"}}),(0,i.jsx)(l.A,{fontSize:"12px",lineHeight:1.5,children:g("Current Price")})]}),(0,i.jsxs)(F.A,{alignItems:"center",gap:"4px",children:[(0,i.jsx)(l.A,{fontSize:"12px",lineHeight:1.5,fontWeight:600,children:U}),(0,i.jsx)(l.A,{fontSize:"12px",lineHeight:1.5,color:"textSubtle",children:g("%subA% per %subB%",{subA:m?x:h,subB:m?h:x})})]})]})]}):null},e0=e=>{let{x:t,onEffect:n,baseIn:i}=e;return(0,u.useEffect)(()=>{n(t)},[t,i,n]),null},e1=e=>{let{x0:t,x1:n,x2:r,xLower:l,xUpper:o,rangeColor:a,baseIn:s}=e;return(0,i.jsxs)(q.mm,{width:"100%",py:"8px",gap:"4px",children:[(0,i.jsx)(e2,{x1:n,x2:r,xLower:l,xUpper:o,baseIn:s}),(0,i.jsxs)(ew.Ay,{width:"100%",position:"relative",children:[(0,i.jsx)(e3,{}
12),void 0!==n&&void 0!==r?(0,i.jsx)(e4,{left:n,right:r,rangeColor:a}):null,void 0!==t?(0,i.jsx)(e9,{left:t}):null]})]})},e2=e=>{let{x1:t,x2:n,xLower:r,xUpper:o,baseIn:a}=e,s=(0,u.useRef)(null),d=(0,u.useRef)(null),[c,p]=(0,u.useState)(void 0),[m,x]=(0,u.useState)(void 0),h=(0,u.useMemo)(()=>{if(!r||!o||r===o||0===Math.abs(Number(o)-Number(r)))return 4;let e=2;for(;e<8&&(0,Y.ZV)(Number(r),{maxDecimalDisplayDigits:e})===(0,Y.ZV)(Number(o),{maxDecimalDisplayDigits:e});){;e++}return Math.max(e,4)},[r,o]),f=(0,u.useMemo)(()=>r?1>Number(r)?(0,Y.ZV)(r,{maximumDecimalTrailingZeroes:h}):(0,Y.ZV)(r,{maxDecimalDisplayDigits:h}):"0",[r,h]),v=(0,u.useMemo)(()=>o?1>Number(o)?(0,Y.ZV)(o,{maximumDecimalTrailingZeroes:h}):(0,Y.ZV)(o,{maxDecimalDisplayDigits:h}):"â",[o,h]),y=(0,u.useMemo)(()=>!!c&&!!m&&!!t&&!!n&&m+c>n-t,[c,m,t,n]);return((0,u.useEffect)(()=>{if(s.current&&d.current){var e,t;p(null==(e=s.current)?void 0:e.clientWidth),x(null==(t=d.current)?void 0:t.clientWidth)}},[t,n]),t&&n)?(0,i.jsx)(ew.Ay,{width:"100%",position:"relative",height:"30px",children:(0,i.jsx)(e5,{left:t,right:n,children:(0,i.jsxs)(L.eF,{justifyContent:"space-between",flexWrap:"nowrap",children:[(0,i.jsx)(q.mm,{alignItems:"flex-start",children:(0,i.jsx)(e7,{distance:-(null!=c?c:0)/2,enabled:y,children:(0,i.jsx)(l.A,{fontSize:"12px",lineHeight:1.5,fontWeight:600,ref:s,children:f})})}),(0,i.jsx)(q.mm,{alignItems:"flex-end",children:(0,i.jsx)(e7,{distance:(null!=m?m:0)/2,enabled:y,children:(0,i.jsx)(l.A,{fontSize:"12px",lineHeight:1.5,fontWeight:600,ref:d,children:v})})})]})})}):null},e6=a.Ay.div.withConfig({componentId:"sc-67c15e39-0"})(["position:absolute;right:8px;bottom:-12px;display:flex;gap:4px;z-index:1;"]),e8=a.Ay.button.withConfig({componentId:"sc-67c15e39-1"})(["width:24px;height:24px;border-radius:4px;border:1px solid ",";display:flex;justify-content:center;align-items:center;font-size:14px;font-weight:600;line-height:1;cursor:",";opacity:",";background-color:",";color:",";user-select:none;padding:0;&:hover{opacity:",";}"],e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{disabled:t}=e;return t?"not-allowed":"pointer"},e=>{let{disabled:t}=e;return t?.4:.9},e=>{let{theme:t}=e;return t.colors.backgroundAlt},e=>{let{theme:t}=e;return t.colors.text},e=>{let{disabled:t}=e;return t?.4:.6}),e3=a.Ay.div.withConfig({componentId:"sc-67c15e39-2"})(["position:absolute;top:0;left:0;width:100%;height:5px;border-radius:8px;background:",";border:0.5px solid ",";"],e=>{let{theme:t}=e;return t.colors.disabled},e=>{let{theme:t}=e;return t.colors.inputSecondary}),e9=a.Ay.div.withConfig({componentId:"sc-67c15e39-3"})(["position:absolute;top:-2px;left:","px;width:5px;height:12px;border-radius:16px;background:",";&:before{background-image:url(data:image/svg+xml,%3Csvg%20width%3D%227%22%20height%3D%227%22%20viewBox%3D%220%200%207%207%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M1.14844%202.4598C0.803786%201.79417%201.28689%201%202.03646%201H4.96209C5.71165%201%206.19476%201.79417%205.85011%202.4598L4.38729%205.28495C4.01435%206.00522%202.98419%206.00522%202.61125%205.28495L1.14844%202.4598Z%22%20fill%3D%22%237645D9%22%20stroke%3D%22white%22%2F%3E%3C%2Fsvg%3E);background-size:cover;background-repeat:no-repeat;content:'';position:absolute;top:-5px;left:-1px;width:7px;height:6px;}"],e=>{let{left:t}=e;return t-2.5},e=>{let{theme:t}=e;return t.colors.secondary}),e4=a.Ay.div.withConfig({componentId:"sc-67c15e39-4"})(["position:absolute;top:0;left:","px;width:","px;height:5px;border-radius:8px;background:",";"],e=>{let{left:t}=e;return t},e=>{let{right:t,left:n}=e;return t-n},e=>{let{rangeColor:t}=e;return t}),e5=a.Ay.div.withConfig({componentId:"sc-67c15e39-5"})(["position:absolute;height:30px;top:0;left:","px;width:","px;"],e=>{let{left:t}=e;return t},e=>{let{right:t,left:n}=e;return t-n}),e7=a.Ay.div.withConfig({componentId:"sc-67c15e39-6"})(["",""],e=>{let{distance:t,enabled:n}=e;return n&&` 13 transform: translateX(${t}px); 14 `});function te(e){let{reason:t}=e,{t:n}=(0,s.A)();return"unsupportedChain"===t?(0,i.jsx)(eQ.yn,{children:n("Position chart is not available on this network yet")}):(0,i.jsx)(eQ.yn,{children:n("Unable to load chart data. Please try again later.")})}function tt(e){let{poolId:t,chainId:n,baseCurrency:r,quoteCurrency:l,tickLower:o,tickUpper:a,tickCurrent:s,tickSpacing:d,inverted:c=!1,priceLower:p,priceUpper:m}=e,x=null!=o?o:0,h=null!=a?a:0,{isLoading:f,formattedData:v,activeBinId:y}=(0,eD.n)({poolId:t,chainId:n,baseCurrency:r,quoteCurrency:l}),g=(0,eF.A)(x,h,d),A=(null==g?void 0:g.LOWER)&&(null==g?void 0:g.UPPER),{priceLowerNum:b,priceUpperNum:w,priceCurrentNum:j}=(0,u.useMemo)(()=>{let e=null==v?void 0:v.find(e=>e.binId===y),t=null==e?void 0:e.price0;return{priceLowerNum:null!=p?p:0,priceUpperNum:null!=m?m:0,priceCurrentNum:null!=t?t:0}},[v,y,p,m]),k=(0,u.useMemo)(()=>
14{if(null==v?void 0:v.length)return v.map(e=>({liquidity:e.activeLiquidity,price0:e.price0,price1:e.price1,tick:e.binId}))},[v]);return k&&k.length>0?(0,i.jsx)(eq,{children:(0,i.jsx)(eJ,{chartData:k,tickLower:x,tickUpper:h,tickCurrent:null!=y?y:null!=s?s:0,priceLower:b,priceUpper:w,priceCurrent:j,baseIn:!c,token0Symbol:null==r?void 0:r.symbol,token1Symbol:null==l?void 0:l.symbol,compact:!0,height:200,isFullRange:A})}):(0,i.jsx)(eq,{children:f?(0,i.jsx)(ek.Ay,{height:200}):(0,i.jsx)(te,{reason:"dataUnavailable"})})}var tn=n(998292),ti=n(774900),tr=n(939565),tl=n(529208),to=n(673384);function ta(e){var t;let{poolId:n,chainId:r,baseCurrency:l,quoteCurrency:a,tickLower:s,tickUpper:d,tickCurrent:c,tickSpacing:p,inverted:m=!1,priceLower:x,priceUpper:f}=e,[v,y]=(0,u.useState)(!1),[,g]=(0,h.W)(n,r),A=(0,u.useMemo)(()=>{if(r)return(0,ti.uP)(r)},[r]),b=(0,u.useMemo)(()=>g?{token0:g.token0,token1:g.token1,tickCurrent:Math.abs(g.tickCurrent)<to.gy.MAX_TICK?g.tickCurrent:c,liquidity:g.liquidity,sqrtPriceX96:g.sqrtRatioX96,feeTier:g.fee}:l&&a?{token0:l,token1:a,tickCurrent:c}:void 0,[g,l,a,c]),{data:w,error:j}=(0,eT.I)({queryKey:["info/pool/poolTickData",r,n,o.Zs.InfinityCLAMM,p,"v2"],queryFn:async e=>{let{signal:t}=e;if(!A||!n||!p||!r)return void console.warn("[InfinityCLPositionChart] Missing required params:",{poolId:n,explorerChainName:A,chainId:r,tickSpacing:p});let i=await (0,tr.s)({poolAddress:n,chainName:A,chainId:r,signal:t,protocol:o.Zs.InfinityCLAMM,tickSpacing:p,poolMetaFallback:b});if(i.error||!i.data)throw Error(`Failed to load Infinity CL tick data for ${n} on ${A}`);return i},enabled:!!(A&&n&&p&&r),retry:2,retryDelay:1500,...tl.MU}),k=(0,u.useMemo)(()=>{var e;return(null==w||null==(e=w.data)?void 0:e.activeTickIdx)!==void 0?w.data.activeTickIdx:(null==g?void 0:g.tickCurrent)!==void 0&&Math.abs(g.tickCurrent)<to.gy.MAX_TICK?g.tickCurrent:c},[null==w||null==(t=w.data)?void 0:t.activeTickIdx,null==g?void 0:g.tickCurrent,c]),C=(0,u.useMemo)(()=>(0,et.Tz)(s),[s]),I=(0,u.useMemo)(()=>(0,et.Tz)(d),[d]),S=(0,u.useMemo)(()=>(0,et.Tz)(k),[k]),R=(0,eF.A)(C,I,p),E=(null==R?void 0:R.LOWER)&&(null==R?void 0:R.UPPER),{priceLower:M,priceUpper:N,priceCurrent:P}=(0,tn.Z)({currencyA:l,currencyB:a,tickLower:C,tickUpper:I,tickCurrent:S}),T=(0,u.useMemo)(()=>void 0===s&&void 0!==x?x:(null==M?void 0:M.toSignificant(8))?parseFloat(M.toSignificant(8)):0,[s,x,M]),U=(0,u.useMemo)(()=>void 0===d&&void 0!==f?f:(null==N?void 0:N.toSignificant(8))?parseFloat(N.toSignificant(8)):0,[d,f,N]),B=(0,u.useMemo)(()=>{try{var e,t;if(!(null==w||null==(t=w.data)||null==(e=t.ticksProcessed)?void 0:e.length)||!l||!a)return;return w.data.ticksProcessed.map(e=>{let t=(0,to.y1)(l,a,e.tickIdx),n=(0,to.y1)(a,l,e.tickIdx);return{liquidity:parseFloat(e.liquidityActive.toString()),price0:parseFloat(t.toSignificant(8)),price1:parseFloat(n.toSignificant(8)),tick:e.tickIdx}})}catch(e){console.error("[InfinityCLPositionChart] Error processing tick data:",e),y(!0);return}},[w,l,a]);(0,u.useEffect)(()=>{w&&v&&y(!1),j&&y(!0)},[w,v,j]);let D=!!r&&void 0===A,F=!D&&void 0===w&&!j;return D?(0,i.jsx)(eq,{children:(0,i.jsx)(te,{reason:"unsupportedChain"})}):v?(0,i.jsx)(eq,{children:(0,i.jsx)(te,{reason:"dataUnavailable"})}):B&&B.length>0&&void 0!==C&&void 0!==I&&void 0!==S?(0,i.jsx)(eq,{children:(0,i.jsx)(eJ,{chartData:B,tickLower:C,tickUpper:I,tickCurrent:S,priceLower:T,priceUpper:U,priceCurrent:(null==P?void 0:P.toSignificant(8))?parseFloat(P.toSignificant(8)):0,baseIn:!m,token0Symbol:null==l?void 0:l.symbol,token1Symbol:null==a?void 0:a.symbol,compact:!0,height:200,isFullRange:E})}):(0,i.jsx)(eq,{children:F?(0,i.jsx)(ek.Ay,{height:200}):(0,i.jsx)(te,{reason:"dataUnavailable"})})}var ts=n(538192);function td(e){var t,n,r;let{currency0:l,currency1:a,feeAmount:s,tickLower:d,tickUpper:c,tickCurrent:p,inverted:m=!1}=e,[x,h]=(0,u.useState)(!1),[,f]=(0,eP.f$)(null!=(t=null==l?void 0:l.wrapped)?t:void 0,null!=(n=null==a?void 0:a.wrapped)?n:void 0,s),v=(0,u.useMemo)(()=>(null==f?void 0:f.tickCurrent)!==void 0?f.tickCurrent:p,[null==f?void 0:f.tickCurrent,p]),y=(0,u.useMemo)(()=>(0,et.Tz)(d),[d]),g=(0,u.useMemo)(()=>(0,et.Tz)(c),[c]),A=(0,u.useMemo)(()=>(0,et.Tz)(v),[v]),b=(0,u.useMemo)(()=>l&&a&&s?to.bC.getAddress(l.wrapped,a.wrapped,s):void 0,[l,a,s]),w=null!=(r=null==f?void 0:f.chainId)?r:null==l?void 0:l.chainId,j=(0,u.useMemo)(()=>
14{if(w)return(0,ti.uP)(w)},[w]),k=(0,u.useMemo)(()=>s?to.D6[s]:void 0,[s]),C=(0,u.useMemo)(()=>f?{token0:f.token0,token1:f.token1,tickCurrent:f.tickCurrent,liquidity:f.liquidity,sqrtPriceX96:f.sqrtRatioX96,feeTier:f.fee}:l&&a?{token0:l.wrapped,token1:a.wrapped,tickCurrent:p,feeTier:s}:void 0,[f,l,a,p,s]),{data:I,error:S}=(0,eT.I)({queryKey:["v3/position/chart/tickData",w,b,k],queryFn:async e=>{let{signal:t}=e;if(!b||!j||!w||!k)return void console.warn("[V3PositionChart] Missing required params:",{poolAddress:b,explorerChainName:j,chainId:w,tickSpacing:k});let n=await (0,tr.s)({poolAddress:b,chainName:j,chainId:w,signal:t,protocol:o.Zs.V3,tickSpacing:k,poolMetaFallback:C});if(n.error||!n.data)throw Error(`Failed to load V3 tick data for ${b} on ${j}`);return n},enabled:!!(b&&j&&w&&k),retry:2,retryDelay:1500,...tl.MU}),R=(0,ts.A)(s,y,g),E=(null==R?void 0:R.LOWER)&&(null==R?void 0:R.UPPER),{priceLower:M,priceUpper:N,priceCurrent:P}=(0,tn.Z)({currencyA:null==l?void 0:l.wrapped,currencyB:null==a?void 0:a.wrapped,tickLower:y,tickUpper:g,tickCurrent:A}),T=(0,u.useMemo)(()=>{try{var e,t;if(!(null==I||null==(t=I.data)||null==(e=t.ticksProcessed)?void 0:e.length))return;return I.data.ticksProcessed.map(e=>({liquidity:parseFloat(e.liquidityActive.toString()),price0:parseFloat(e.price0),price1:parseFloat(e.price1),tick:e.tickIdx}))}catch(e){console.error("[V3PositionChart] Error processing tick data:",e),h(!0);return}},[I]);(0,u.useEffect)(()=>{I&&x&&h(!1),S&&h(!0)},[I,x,S]);let U=!!w&&void 0===j,B=!U&&void 0===I&&!S;return U?(0,i.jsx)(eq,{children:(0,i.jsx)(te,{reason:"unsupportedChain"})}):x?(0,i.jsx)(eq,{children:(0,i.jsx)(te,{reason:"dataUnavailable"})}):T&&T.length>0&&void 0!==y&&void 0!==g&&void 0!==A?(0,i.jsx)(eq,{children:(0,i.jsx)(eJ,{chartData:T,tickLower:y,tickUpper:g,tickCurrent:A,priceLower:(null==M?void 0:M.toSignificant(8))?parseFloat(M.toSignificant(8)):0,priceUpper:(null==N?void 0:N.toSignificant(8))?parseFloat(N.toSignificant(8)):0,priceCurrent:(null==P?void 0:P.toSignificant(8))?parseFloat(P.toSignificant(8)):0,baseIn:!m,token0Symbol:null==l?void 0:l.symbol,token1Symbol:null==a?void 0:a.symbol,compact:!0,height:200,isFullRange:E})}):(0,i.jsx)(eq,{children:B?(0,i.jsx)(ek.Ay,{height:200}):(0,i.jsx)(te,{reason:"dataUnavailable"})})}var tu=n(827666),tc=n(13978);function tp(e,t,n){try{if(e>=tu.ZlO)return 1/0;if(e<=tu.BMJ)return 0;let i=tu.P3F.getTickPrice({poolInfo:t,tick:e,baseIn:n});return parseFloat(i.price.toFixed(18))}catch(i){console.error("[SolanaV3PositionChart] Error calculating tick price:",i);let t=1.0001**e;return n?t:1/t}}function tm(e){var t,n;let{currency0:r,currency1:l,feeAmount:o,tickLower:a,tickUpper:s,poolInfo:d,inverted:c=!1}=e,p=null!=(n=null==d?void 0:d.tickCurrent)?n:0,m=(0,u.useMemo)(()=>(0,et.Tz)(a),[a]),x=(0,u.useMemo)(()=>(0,et.Tz)(s),[s]),h=(0,u.useMemo)(()=>(0,et.Tz)(p),[p]),f=null==d?void 0:d.id,{formattedData:v,isLoading:y,error:g}=(0,tc.O)(f),{tickAtLimit:A,isFullRange:b}=(0,u.useMemo)(()=>{var e;let t=void 0!==m&&void 0!==x&&m<=tu.BMJ&&x>=tu.ZlO;if(void 0===m||void 0===x||!(null==d||null==(e=d.config)?void 0:e.tickSpacing))return{tickAtLimit:{LOWER:t,UPPER:t},isFullRange:t};let n=(0,I.iz)(d.config.tickSpacing),i=(0,I.Kc)(m,x,n);return{tickAtLimit:i,isFullRange:i.LOWER&&i.UPPER}},[m,x,null==d||null==(t=d.config)?void 0:t.tickSpacing]),{priceLower:w,priceUpper:j,priceCurrent:k}=(0,u.useMemo)(()=>{if(!d||void 0===m||void 0===x)return{priceLower:0,priceUpper:0,priceCurrent:0};let e=tp(m,d,!0);return{priceLower:e,priceUpper:tp(x,d,!0),priceCurrent:tp(null!=h?h:0,d,!0)}},[d,m,x,h]);return g?(0,i.jsx)(eq,{children:(0,i.jsx)(te,{reason:"dataUnavailable"})}):v&&v.length>0&&void 0!==m&&void 0!==x?(0,i.jsx)(eq,{children:(0,i.jsx)(eJ,{chartData:v,tickLower:m,tickUpper:x,tickCurrent:h,priceLower:w,priceUpper:j,priceCurrent:k,baseIn:!c,token0Symbol:null==r?void 0:r.symbol,token1Symbol:null==l?void 0:l.symbol,compact:!0,height:200,isFullRange:b})}):(0,i.jsx)(eq,{children:y?(0,i.jsx)(ek.Ay,{height:200}):(0,i.jsx)(te,{reason:"dataUnavailable"})})}function tx(e){var t;let{position:n,currency0:r,currency1:l,inverted:o}
14=e,a=null!=(t=(0,eB.xk)(n.poolId.toBase58()))?t:void 0,s=(null==a?void 0:a.feeRate)?(0,et.$v)(a.feeRate):void 0;return(0,i.jsx)(tm,{currency0:r,currency1:l,feeAmount:s,tickLower:n.tickLower,tickUpper:n.tickUpper,poolInfo:a,inverted:o})}function th(e){let{protocol:t,position:n,currency0:r,currency1:l,chainId:a,poolId:s,inverted:d,priceLower:u,priceUpper:c}=e;return t===o.Zs.V3?(0,p.fT)(a)?(0,i.jsx)(tx,{position:n,currency0:r,currency1:l,inverted:d}):(0,i.jsx)(td,{currency0:r,currency1:l,feeAmount:"fee"in n?n.fee:void 0,tickLower:"tickLower"in n?n.tickLower:void 0,tickUpper:"tickUpper"in n?n.tickUpper:void 0,inverted:d}):t===o.Zs.InfinityCLAMM?(0,i.jsx)(ta,{poolId:s,chainId:a,baseCurrency:r,quoteCurrency:l,tickLower:"tickLower"in n?n.tickLower:void 0,tickUpper:"tickUpper"in n?n.tickUpper:void 0,tickSpacing:"tickSpacing"in n?n.tickSpacing:void 0,inverted:d,priceLower:u,priceUpper:c}):t===o.Zs.InfinityBIN?(0,i.jsx)(tt,{poolId:s,chainId:a,baseCurrency:r,quoteCurrency:l,tickLower:"tickLower"in n?n.tickLower:void 0,tickUpper:"tickUpper"in n?n.tickUpper:void 0,tickSpacing:"tickSpacing"in n?n.tickSpacing:void 0,inverted:d,priceLower:u,priceUpper:c}):null}var tf=n(291249);let tv=(0,a.Ay)(ew.Ay).withConfig({componentId:"sc-f79dab6-0"})(["padding:16px 24px;background:",";border-bottom:1px solid ",";"],e=>{let{theme:t}=e;return t.card.background},e=>{let{theme:t}=e;return t.colors.cardBorder}),ty=(0,a.Ay)(r.A).withConfig({componentId:"sc-f79dab6-1"})(["gap:6px;flex-wrap:wrap;"]),tg=(0,a.Ay)(ew.Ay).withConfig({componentId:"sc-f79dab6-2"})(["padding:16px;border-right:",";flex:",";min-width:",";"],e=>{let{$hasBorder:t,theme:n}=e;return t?`1px solid ${n.colors.cardBorder}`:"none"},e=>{let{$flex:t}=e;return t||"none"},e=>{let{$minWidth:t}=e;return t||"auto"}),tA=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-3"})(["font-size:16px;font-weight:600;color:",";margin-bottom:8px;"],e=>{let{theme:t}=e;return t.colors.text}),tb=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-4"})(["font-size:12px;color:",";letter-spacing:0.12px;margin-bottom:4px;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),tw=(0,a.Ay)(r.A).withConfig({componentId:"sc-f79dab6-5"})(["gap:8px;align-items:flex-start;"]),tj=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-6"})(["font-size:12px;color:",";letter-spacing:0.12px;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),tk=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-7"})(["font-size:12px;color:",";letter-spacing:0.12px;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),tC=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-8"})(["font-size:12px;font-weight:600;color:",";letter-spacing:0.12px;"],e=>{let{theme:t}=e;return t.colors.text}),tI=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-9"})(["font-size:12px;font-weight:600;color:",";letter-spacing:0.24px;text-transform:uppercase;"],e=>{let{theme:t}=e;return t.colors.secondary}),tS=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-10"})(["font-size:12px;font-weight:600;color:",";letter-spacing:0.12px;"],e=>{let{theme:t}=e;return t.colors.text}),tR=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-11"})(["font-size:12px;font-weight:600;color:",";letter-spacing:0.12px;margin-left:4px;"],e=>{let{theme:t}=e;return t.colors.primary60}),tE=(0,a.Ay)(r.A).withConfig({componentId:"sc-f79dab6-12"})(["gap:8px;justify-content:flex-end;margin-top:26px;"]),tM=(0,a.Ay)(ew.Ay).withConfig({componentId:"sc-f79dab6-13"})(["background:",";border:1px solid ",";border-radius:16px;padding:16px;display:flex;flex-direction:column;gap:4px;width:fit-content;margin-left:auto;"],e=>{let{theme:t}=e;return t.colors.secondary10},e=>{let{theme:t}=e;return t.colors.secondary}),tN=(0,a.Ay)(l.A).withConfig({componentId:"sc-f79dab6-14"})(["font-size:14px;font-weight:500;line-height:1.5;"]),tP=(0,u.memo)(e=>{var t,n,l,a,d,c,m,h,f,A,b,w,j,k,R,M;let{position:N,pool:P,currency0:T,currency1:U,amount0:B,amount1:D,earnings:q,earningsBreakdown:L,totalLiquidityUSD:_=0,lpApr:$=0,merklApr:z=0,incentraApr:V=0,farmApr:Z=0,totalApr:W=0,price0Usd:H,price1Usd:Q,currentPrice:G,onAddLiquidity:K,onRemoveLiquidity:X,onHarvest:ee,onViewDetails:en,inverted:ei,onToggleInverted:er,hasFarm:el,v3SdkPool:eo}=e,{t:ea}=(0,s.A)(),[es,ed]=(0,u.useState)(!1),eu=null!=ei?ei:es,ec=(0,u.useCallback)(()=>{er?er():ed(e=>!e)},[er]),{currency0:ep,currency1:em,currentPrice:ex,chainId:eh,poolId:ef,tokenId:ev,t
14ickLower:ey,tickUpper:eg,priceLower:eA,priceUpper:eb,v3Pool:eB,removed:eD,outOfRange:eF}=function(e){var t,n,i;let r=(0,et.g7)(e),l=(0,g.RI)(e.protocol===o.Zs.InfinityCLAMM?e:void 0),a=(0,g.ck)(e.protocol!==o.Zs.V3||(0,p.fT)(r)?void 0:e),s=e.protocol===o.Zs.V3&&!(0,p.fT)(r),d=s?e:void 0,[,c]=(0,eP.f$)(s?a.currency0:void 0,s?a.currency1:void 0,s?null==d?void 0:d.fee:void 0),m=(0,y.Ae)(null==(t=a.currency0)?void 0:t.wrapped,null==(n=a.currency1)?void 0:n.wrapped),x=(0,u.useMemo)(()=>{var e,t;if(!s||!d)return!1;let n=c||a.pool;if(!n)return!1;let{tickLower:i,tickUpper:r,fee:l}=d;if(void 0===i||void 0===r)return!1;let o=(0,I.jC)(n,l),u=(0,I.Mu)(o),p=(0,I.Kc)(i,r,u),x=a.currency0,h=a.currency1,f=!!((null==x||null==(e=x.wrapped)?void 0:e.address)&&(null==(t=n.token1)?void 0:t.address)&&x.wrapped.address.toLowerCase()===n.token1.address.toLowerCase()),v=(0,I.lN)(i,r,null==x?void 0:x.wrapped,null==h?void 0:h.wrapped,n,p,f,m);if(v.showPercentages&&v.minPercentage&&v.maxPercentage){let e=v.minPercentage.startsWith("-")&&"-%"!==v.minPercentage,t=v.minPercentage.startsWith("+"),n=v.maxPercentage.startsWith("-")&&"-%"!==v.maxPercentage,i=v.maxPercentage.startsWith("+");return!(e&&i||t&&n)&&(e||t)&&(n||i)}return!1},[s,d,c,a.pool,a.currency0,a.currency1,m]),h=(0,u.useMemo)(()=>{if(e.protocol===o.Zs.InfinityCLAMM||e.protocol===o.Zs.InfinityBIN){let{poolKey:t}=e;if(t)return(0,C.Qn)(t)}},[e]),f=(0,u.useMemo)(()=>{if("tokenId"in e)return e.tokenId},[e]),v=(0,u.useMemo)(()=>{if(e.protocol===o.Zs.InfinityCLAMM||e.protocol===o.Zs.V3)return e.tickLower},[e]),A=(0,u.useMemo)(()=>{if(e.protocol===o.Zs.InfinityCLAMM||e.protocol===o.Zs.V3)return e.tickUpper},[e]),b=l.currency0||a.currency0,w=l.currency1||a.currency1,j=(0,u.useMemo)(()=>{var e,t;return null!=(t=null==(e=(l.pool?l:a).pool)?void 0:e.token0Price)?t:null},[l,a]),k=(0,y.xm)(j),S=(0,u.useMemo)(()=>l.priceLower||a.priceLower,[l.priceLower,a.priceLower]),R=(0,u.useMemo)(()=>l.priceUpper||a.priceUpper,[l.priceUpper,a.priceUpper]),E=(0,y.xm)(S),M=(0,y.xm)(R),N=(0,u.useMemo)(()=>k?k.toSignificant(8):null,[k]),P=l.removed||a.removed,T=l.outOfRange||a.outOfRange||x;return{currency0:b,currency1:w,currentPrice:N,chainId:r,poolId:h,tokenId:f,tickLower:v,tickUpper:A,priceLower:(0,u.useMemo)(()=>{if(E)try{return parseFloat(E.toSignificant(8))}catch{return}},[E]),priceUpper:(0,u.useMemo)(()=>{if(M)try{return parseFloat(M.toSignificant(8))}catch{return}},[M]),v3Pool:null!=(i=a.pool)?i:void 0,removed:P,outOfRange:T}}(N),eq=null!=T?T:ep,eL=null!=U?U:em,eO=void 0!==G?String(G):ex,e_=!!(null==B?void 0:B.greaterThan(0)),e$=!!(null==D?void 0:D.greaterThan(0)),{data:eY}=(0,v.GB)(void 0!==H?void 0:eq,{enabled:void 0===H&&e_}),{data:ez}=(0,v.GB)(void 0!==Q?void 0:eL,{enabled:void 0===Q&&e$}),eV=null!=H?H:eY,eZ=null!=Q?Q:ez,eW=(0,y.Wu)(B,6),eH=(0,y.Wu)(D,6),eQ=(0,u.useMemo)(()=>B&&D&&eq&&eL?{amount0Str:null!=eW?eW:"0",amount1Str:null!=eH?eH:"0",amount0Usd:eV?(0,x.g)(B.toExact()).times(eV).toNumber():0,amount1Usd:eZ?(0,x.g)(D.toExact()).times(eZ).toNumber():0}:null,[B,D,eq,eL,eV,eZ,eW,eH]),eG=(0,u.useMemo)(()=>N.protocol===o.Zs.V3||N.protocol===o.Zs.InfinityCLAMM||N.protocol===o.Zs.InfinityBIN,[N.protocol]),eK=(0,u.useMemo)(()=>eq&&eL?eu?`${eq.symbol} per ${eL.symbol}`:`${eL.symbol} per ${eq.symbol}`:"",[eq,eL,eu]),eX=(0,u.useMemo)(()=>{if(!eO)return"-";try{let e=new x.g(eO);if(!e.isFinite()||e.isNaN())return console.warn("[ExpandedRowContent] Invalid current price:",eO),"-";let t=eu&&e.gt(0)?new x.g(1).div(e):e;if(!t.isFinite()||t.isNaN())return console.warn("[ExpandedRowContent] Invalid computed price:",t.toString()),"-";return(0,Y.ZV)(t.toNumber(),{maxDecimalDisplayDigits:6})}catch(e){return console.error("[ExpandedRowContent] Error computing display price:",e,eO),"-"}},[eO,eu]),eJ=void 0!==el?el:!!(null!=(l=null==P?void 0:P.isActiveFarm)?l:null==P?void 0:P.isFarming)||!P&&(null!=Z?Z:0)>0,e0=(0,u.useMemo)(()=>{if(L){var e,t,n,i,r,l,o,a,s,d;let u=(null!=(e=L.fee0USD)?e:0)+(null!=(t=L.fee1USD)?t:0)+(null!=(n=L.farmRewardsUSD)?n:0);return{header:null!=(i=null==q?void 0:q.display)?i:u>0?(0,S.dx)(u):"$0",fee0Amount:null!=(r=L.fee0Amount)?r:0,fee1Amount:null!=(l=L.fee1Amount)?l:0,fee0Raw:L.fee0Raw,fee1Raw:L.fee1Raw,fee0USD:null!=(o=L.fee0USD)?o:0,fee1USD:null!=(a=L.fee1USD)?a:0,farmRewardsAmount:null!=(s=L.farmRewardsAmount)?s:0,farmRewardsRaw:L.farmRewardsRaw,farmRewardsUSD:null!=(d=L.farmRewardsUSD)?d:0,rewardCurrency:L.rewardCurrency,farmRewards:L.farmRewards}}return null},[L,q]),e1=null!=(a=null==e0?void 0:e0.header)?a:"$0",{data:e2}=(0,eT.I)({queryKey:["poolDetailUrl",null==P?void 0:P.chainId,null!=(d=null==P?void 0:P.lpAddress)?d:null==P?void 0:P.poolId,null==P?void 0:P.protocol],queryFn:()=>
14{if(P)return(0,eN.VZ)(P)}}),e6=(0,u.useMemo)(()=>{if(P&&"token0"in P&&P.token0)try{return(0,eN.e6)(P)}catch{return}},[P]),e8=N.protocol!==o.Zs.V2&&N.protocol!==o.Zs.STABLE&&N.protocol!==o.Zs.InfinitySTABLE,e3=N.protocol===o.Zs.V3&&(0,p.fT)(eh),e9=null!=(c=null==P?void 0:P.protocol)?c:N.protocol;N.protocol===o.Zs.V2||N.protocol===o.Zs.STABLE||(N.protocol,o.Zs.InfinitySTABLE);let{isOpen:e4,setIsOpen:e5,onDismiss:e7}=(0,E.jN)(),[te,tt]=(0,u.useState)("Add"),tn=(0,u.useCallback)(e=>{tt(e),e5(!0)},[e5]);return(0,i.jsxs)(tv,{children:[(0,i.jsxs)(ty,{children:[(0,i.jsxs)(tg,{$flex:"1",$minWidth:"240px",$hasBorder:!0,children:[e8&&(0,i.jsxs)(i.Fragment,{children:[eG&&(0,i.jsx)(th,{protocol:N.protocol,position:N,currency0:eq,currency1:eL,chainId:eh,poolId:ef,inverted:eu,priceLower:eA,priceUpper:eb}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"0px",mt:"64px",children:[(0,i.jsx)(tI,{children:ea("Current Price")}),(0,i.jsxs)(r.A,{alignItems:"center",children:[(0,i.jsx)(tS,{children:eX}),(0,i.jsx)(tR,{children:eK}),(0,i.jsx)(ew.Ay,{as:"button",ml:"4px",onClick:ec,style:{background:"none",border:"none",cursor:"pointer",padding:0},children:(0,i.jsx)(ej.A,{color:"primary60",width:"18px"})})]})]})]}),!e8&&(0,i.jsxs)(tM,{children:[(0,i.jsx)(tN,{children:ea("No price range for this pool.")}),(0,i.jsx)(tN,{children:ea("Liquidity is spread evenly")})]})]}),(0,i.jsxs)(tg,{$hasBorder:!0,$minWidth:"150px",children:[(0,i.jsxs)(tA,{children:["$",_.toFixed(2)]}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"4px",children:[(0,i.jsx)(tb,{children:ea("Deposited Tokens:")}),eQ?(0,i.jsxs)(F.A,{flexDirection:"column",gap:"4px",children:[(0,i.jsxs)(tw,{children:[eq&&(0,i.jsx)(eE.Zm,{currency:eq,size:"16px"}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"0px",children:[(0,i.jsxs)(J.g3,{amount:B,fontSize:"12px",bold:!0,color:"text",style:{letterSpacing:"0.12px"},children:[(0,Y.ZV)((0,x.g)(eQ.amount0Str).toNumber(),{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})," ",null==eq?void 0:eq.symbol]}),(0,i.jsxs)(tj,{children:["~",(0,S.o5)(eQ.amount0Usd)]})]})]}),(0,i.jsxs)(tw,{children:[eL&&(0,i.jsx)(eE.Zm,{currency:eL,size:"16px"}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"0px",children:[(0,i.jsxs)(J.g3,{amount:D,fontSize:"12px",bold:!0,color:"text",style:{letterSpacing:"0.12px"},children:[(0,Y.ZV)((0,x.g)(eQ.amount1Str).toNumber(),{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})," ",null==eL?void 0:eL.symbol]}),(0,i.jsxs)(tj,{children:["~",(0,S.o5)(eQ.amount1Usd)]})]})]})]}):(0,i.jsx)(ek.Ay,{height:68})]})]}),(0,i.jsxs)(tg,{$hasBorder:!0,$minWidth:"130px",children:[(0,i.jsx)(tA,{children:e1}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"12px",children:[(0,i.jsxs)(F.A,{flexDirection:"column",gap:"4px",children:[(0,i.jsx)(tb,{children:ea("LP Fees")}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"4px",children:[(0,i.jsxs)(tw,{children:[eq&&(0,i.jsx)(eE.Zm,{currency:eq,size:"16px"}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"0px",children:[(0,i.jsxs)(J.g3,{currency:eq,rawDisplay:null==e0?void 0:e0.fee0Raw,fontSize:"12px",bold:!0,color:"text",style:{letterSpacing:"0.12px"},children:[(null==e0?void 0:e0.fee0Amount)?(0,Y.ZV)(e0.fee0Amount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3}):"0"," ",null==eq?void 0:eq.symbol]}),(0,i.jsxs)(tj,{children:["~",(0,S.o5)(null!=(m=null==e0?void 0:e0.fee0USD)?m:0)]})]})]}),(0,i.jsxs)(tw,{children:[eL&&(0,i.jsx)(eE.Zm,{currency:eL,size:"16px"}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"0px",children:[(0,i.jsxs)(J.g3,{currency:eL,rawDisplay:null==e0?void 0:e0.fee1Raw,fontSize:"12px",bold:!0,color:"text",style:{letterSpacing:"0.12px"},children:[(null==e0?void 0:e0.fee1Amount)?(0,Y.ZV)(e0.fee1Amount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3}):"0"," ",null==eL?void 0:eL.symbol]}),(0,i.jsxs)(tj,{children:["~",(0,S.o5)(null!=(h=null==e0?void 0:e0.fee1USD)?h:0)]})]})]})]})]}),e0&&((null==(t=e0.farmRewards)?void 0:t.length)||(null!=(f=e0.farmRewardsAmount)?f:0)>0)&&(0,i.jsxs)(F.A,{flexDirection:"column",gap:"4px",children:[(0,i.jsx)(tb,{children:ea("Farm Rewards")}),(0,i.jsx)(F.A,{flexDirection:"column",gap:"4px",children:(null==(n=e0.farmRewards)?void 0:n.length)?e0.farmRewards.map((e,t)=>(0,i.jsxs)(tw,{children:[(0,i.jsx)(eE.Zm,{currency:e.currency,size:"16px"}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"0px",children:[(0,i.jsxs)(J.g3,{currency:e.currency,rawDisplay:e.rawAmount,fontSize:"12px",bold:!0,color:"text",style:{letterSpacing:"0.12px"},children:[(0,Y.ZV)(e.amount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})," ",e.currency.symbol]}),(0,i.jsxs)(tj,{children:["~",(0,S.o5)(e.amountUSD)]})]})]},t)):(null!=(A=e0.farmRewardsAmount)?A:0)>0&&e0.rewardCurrency&&(0,i.jsxs)(tw,{children:[(0,i.jsx)(eE.Zm,{currency:e0.rewardCurrency,size:"16px"}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"0px",children:[(0,i.jsxs)(J.g3,{currency:e0.rewardCurrency,rawDisplay:e0.farmRewardsRaw,fontSize:"12px",bold:!0,color:"text",style:{letterSpacing:"0.12px"},children:[(0,Y.ZV)(e0.farmRewardsAmount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})," ",e0.rewardCurrency.symbol]}),(0,i.jsxs)(tj,{children:["~",(0,S.o5)(null!=(b=e0.farmRewardsUSD)?b:0)]})]})]})})]})]})]}),(0,i.jsxs)(tg,{$minWidth:"120px",children:[(0,i.jsxs)(tA,{children:[eJ&&"\uD83C\uDF3F ",W>0?(0,eR.U)(W):"0%"]}),(0,i.jsxs)(F.A,{flexDirection:"column",gap:"4px",children:[(0,i.jsxs)(ew.Ay,{children:[(0,i.jsx)(tk,{children:ea("LP Fee APR")}),(0,i.jsx)(tC,{children:$>0?(0,eR.U)($):"0%"})]}),z>0&&(0,i.jsxs)(ew.Ay,{children:[(0,i.jsx)(tk,{children:ea("Merkl APR")}),(0,i.jsx)(tC,{children:(0,eR.U)(z)})]}),V>0&&(0,i.jsxs)(ew.Ay,{children:[(0,i.jsx)(tk,{children:ea("Incentra APR")}),(0,i.jsx)(tC,{children:(0,eR.U)(V)})]}),Z>0&&(0,i.jsxs)(ew.Ay,{children:[(0,i.jsx)(tk,{children:ea("Farm APR")}),(0,i.jsx)(tC,{children:(0,eR.U)(Z)})]})]})]})]}),!e3&&(0,i.jsx)(eU.B,{isOpen:e4,onDismiss:e7,poolId:null!=(k=null!=(j=null!=(w=null==P?void 0:P.poolId)?w:null==P?void 0:P.stableSwapAddress)?j:null==P?void 0:P.lpAddress)?k:"pair"in N?
14N.pair.liquidityToken.address:void 0,protocol:null!=(R=null==P?void 0:P.protocol)?R:N.protocol,chainId:null!=(M=null==P?void 0:P.chainId)?M:eh,position:N,presetTab:te}),(0,i.jsxs)(tE,{children:[e2&&(0,i.jsx)(O.A,{variant:"primary60",scale:"md",as:eM.Y,to:e2,target:"_blank",rel:"noopener noreferrer",endIcon:(0,i.jsx)(eC.A,{width:"18px",color:"primary60"}),children:ea("Full Page")}),!e3&&e9&&(0,i.jsx)(O.A,{variant:"primary60",scale:"md",onClick:()=>tn("Remove"),width:"48px",p:"0",children:(0,i.jsx)(eI.A,{width:"24px",color:"primary60"})}),!e3&&e9&&(0,i.jsx)(O.A,{variant:"primary60",scale:"md",onClick:()=>tn("Add"),width:"48px",p:"0",children:(0,i.jsx)(eS.A,{width:"24px",color:"primary60"})}),(0,i.jsx)(tf.j,{position:N,pool:P,chainId:eh,isFarmLive:eJ,isStaked:"isStaked"in N&&N.isStaked,removed:eD,outOfRange:eF,totalLiquidityUSD:_,amount0:B,amount1:D,showCollectButton:!0,v3SdkPool:eo}),e6&&(0,i.jsx)(O.A,{variant:"primary60Outline",scale:"md",as:eM.Y,to:e6,children:ea("New position")})]})]})});var tT=n(807718),tU=n(612507);let tB=a.Ay.tr.withConfig({componentId:"sc-b45332fa-0"})(["border-bottom:1px solid ",";transition:background 0.2s ease;&:hover{background:",";}",""],e=>{let{theme:t,$expanded:n}=e;return n?"transparent":t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.backgroundHover},e=>{let{$expanded:t,theme:n}=e;return t&&` 15 background: ${n.colors.backgroundAlt}; 16 `}),tD=a.Ay.td.withConfig({componentId:"sc-b45332fa-1"})(["padding:8px;text-align:",";vertical-align:middle;&:first-child{padding-left:24px;}&:last-child{padding-right:24px;}"],e=>{let{align:t}=e;return t||"left"}),tF=a.Ay.div.withConfig({componentId:"sc-b45332fa-2"})(["min-height:70px;width:100%;display:flex;align-items:center;"]),tq=a.Ay.tr.withConfig({componentId:"sc-b45332fa-3"})(["background:",";"],e=>{let{theme:t}=e;return t.colors.backgroundAlt}),tL=a.Ay.td.withConfig({componentId:"sc-b45332fa-4"})(["padding:0;"]),tO=(0,a.Ay)(r.A).withConfig({componentId:"sc-b45332fa-5"})(["align-items:center;gap:12px;"]),t_=(0,a.Ay)(r.A).withConfig({componentId:"sc-b45332fa-6"})(["flex-wrap:wrap;gap:4px;"]),t$=(0,u.memo)(e=>{var t,n,a;let{position:d,data:c,expanded:m,onToggleExpand:h,hideEarningsColumn:f=!1,rowAction:v,priceRangeDecimalPlaces:g}=e,{t:A}=(0,s.A)(),{currency0:b,currency1:w,removed:j,outOfRange:k,pool:C,totalPriceUSD:I,aprButton:R,hookData:E,chainId:M,earnings:N,earningsBreakdown:P,amount0:T,amount1:U,price0Usd:B,price1Usd:D,priceRangeDisplay:q,lpApr:L,merklApr:_,incentraApr:$,farmApr:z,totalApr:V,hasFarm:Z,feeTier:W,feeTierBase:H,onViewDetails:K,onAddLiquidity:X,onRemoveLiquidity:ee,onHarvest:et,hasUnclaimedRewards:en,isMerkleRootMismatch:ei,v3SdkPool:er}=c,el=(0,eA.se)(),eo=null==v?void 0:v(d),ew=null!=eo&&!1!==eo,ej=(0,y.Wu)(T),ek=(0,y.Wu)(U),eC=(0,J.$Y)({currency:b,rawDisplay:null==P?void 0:P.fee0Raw}),eI=(0,J.$Y)({currency:w,rawDisplay:null==P?void 0:P.fee1Raw}),eS=(0,J.$Y)({currency:null==P?void 0:P.rewardCurrency,rawDisplay:null==P?void 0:P.farmRewardsRaw}),eR=!j&&!ew,eE=(0,ey.T)(d.protocol),eM=j&&eE&&en&&!ei&&!!el,eN=(0,u.useMemo)(()=>{if(d.protocol===o.Zs.V3&&M!==p.Cb.SOLANA)return!!("isStaked"in d&&d.isStaked);if((0,ey.T)(d.protocol)){let e="number"==typeof z?z:0,t=!!("isStaked"in d&&d.isStaked);return!!Z||e>0||t}return!!Z},[d,M,Z,z]),{base:eP,quote:eT,isFlipped:eU}=(0,u.useMemo)(()=>b&&w?(0,eb.SP)(b,w):{base:b,quote:w,isFlipped:!1},[b,w]),[eB,eD]=(0,u.useState)(!1),eF=(0,u.useCallback)(()=>eD(e=>!e),[]),eq=eB!==eU,eL=(0,u.useMemo)(()=>{if(!q)return null;if(!eq)return q;try{let{minPrice:e}=q,{maxPrice:t}=q,{currentPriceValue:n}=q;if(void 0===e||void 0===t||!Number.isFinite(e)||!Number.isFinite(t)||Number.isNaN(e)||Number.isNaN(t))return q;let i=new x.g(e),r=new x.g(t),l=n&&Number.isFinite(n)?new x.g(n):null,o=r.gt(0)?new x.g(1).div(r):new x.g(0),a=i.gt(0)?new x.g(1).div(i):new x.g(0),s=l&&l.gt(0)?new x.g(1).div(l):null;if(!o.isFinite()||!a.isFinite()||o.isNaN()||a.isNaN())return q;let d=e=>{if(!e.isFinite()||e.isNaN()||e.lte(0))return"0";let t=e.toNumber();return void 0!==g?(0,ev.Yr)(t,t,g).minFormatted:(0,Y.ZV)(t,{maxDecimalDisplayDigits:6})},u=q.maxPercentage.startsWith("-")?q.maxPercentage.replace("-","+"):q.maxPercentage.startsWith("+")?q.maxPercentage.replace("+","-"):`-${q.maxPercentage}`,c=q.minPercentage.startsWith("-")?q.minPercentage.replace("-","+"):q.minPercentage.startsWith("+")?q.minPercentage.replace("+","-"):`-${q.minPercentage}`,p=100-q.rangePosition;return{minPriceFormatted:d(o),maxPriceFormatted:d(a),currentPrice:s?d(s):void 0,minPercentage:u,maxPercentage:c,rangePosition:p,showPercentages:q.showPercentages,minPrice:o.toNumber(),maxPrice:a.toNumber(),currentPriceValue:s?s.toNumber():void 0}}catch(e){return q}},[q,eq,g]),eO=(0,u.useCallback)(e=>{if(!eR)return;let t=e.target;"BUTTON"!==t.tagName&&"A"!==t.tagName&&null===t.closest("button")&&null===t.closest("a")&&null===t.closest('[role="button"]')&&null===t.closest("[data-interactive]")&&h()},[eR,h]),e_=(0,u.useCallback)(e=>{e.stopPropagation(),h()}
16,[h]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(tB,{$expanded:m,onClick:eR?eO:void 0,style:{cursor:eR?"pointer":"default"},children:[(0,i.jsx)(tD,{children:(0,i.jsx)(tF,{children:(0,i.jsxs)(tO,{children:[eP&&eT?(0,i.jsx)(G.hm,{width:40,height:40,variant:"inverted",primaryToken:eP,secondaryToken:eT,withChainLogo:!0}):null,(0,i.jsxs)(t_,{children:[(0,i.jsx)(F.A,{alignItems:"center",gap:"8px",children:eP&&eT?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(tT.G,{json:c,children:(0,i.jsxs)(l.A,{bold:!0,children:[eP.symbol," / ",eT.symbol]})}),"tokenId"in d&&d.tokenId&&(0,i.jsxs)(l.A,{color:"textSubtle",fontSize:"12px",children:["(#",d.tokenId.toString(),")"]})]}):(0,i.jsxs)(l.A,{color:"textSubtle",fontSize:"14px",children:[A("Loading"),"..."]})}),(0,i.jsxs)(F.A,{alignItems:"center",gap:"4px",flexWrap:"wrap",children:[(0,ey.T)(d.protocol)?(0,i.jsx)(Q.Eu,{poolId:null==C?void 0:C.poolId,chainId:M,hookData:E,infoIconVisible:!1}):(0,i.jsx)(ea.T,{type:d.protocol,fee:null!=W?W:"fee"in d?d.fee:0,denominator:null!=H?H:"fee"in d?1e6:void 0}),(0,i.jsx)(ep.cD,{poolAddress:null==C?void 0:C.lpAddress}),(0,i.jsx)(em.rW,{poolAddress:null==C?void 0:C.lpAddress}),eN&&!j&&!k&&(0,i.jsx)(es.A,{variant:"primary60",scale:"sm",px:"6px",children:A("Farming")})]})]})]})})}),(0,i.jsx)(tD,{align:"left",children:j?(0,i.jsx)(eg.K,{lowContrast:!0,removed:j,outOfRange:k,protocol:d.protocol}):eL?(0,i.jsx)(ef.F,{minPrice:eL.minPriceFormatted,maxPrice:eL.maxPriceFormatted,currentPrice:eL.currentPrice,minPercentage:eL.minPercentage,maxPercentage:eL.maxPercentage,rangePosition:eL.rangePosition,outOfRange:k,removed:j,showPercentages:eL.showPercentages,maxWidth:"180px",minPriceRaw:eL.minPrice,maxPriceRaw:eL.maxPrice,currentPriceRaw:eL.currentPriceValue}):[o.Zs.V2,o.Zs.STABLE,o.Zs.InfinitySTABLE].includes(d.protocol)?(0,i.jsx)(l.A,{fontSize:"12px",color:"textSubtle",textTransform:"uppercase",textAlign:"center",children:A("Full Range")}):(0,i.jsx)(l.A,{fontSize:"12px",color:"textSubtle",children:"-"})}),(0,i.jsx)(tD,{align:"right",children:(0,i.jsx)(r.A,{flexDirection:"column",alignItems:"flex-end",children:(0,i.jsx)(eh.z,{content:(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",gap:"8px",children:[(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(F.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(F.A,{alignItems:"center",gap:"8px",children:[b&&(0,i.jsx)(ex.Z,{currency:b,size:"16px"}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:null!=(n=null==b?void 0:b.symbol)?n:"-"})]}),(0,i.jsx)(J.g3,{amount:T,fontSize:"14px",bold:!0,children:null!=ej?ej:"-"})]}),(0,i.jsx)(l.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:T&&"number"==typeof B?`~${(0,S.o5)((0,x.g)(T.toExact()).times(B).toNumber())}`:"$0.00"})]}),(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(F.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(F.A,{alignItems:"center",gap:"8px",children:[w&&(0,i.jsx)(ex.Z,{currency:w,size:"16px"}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:null!=(a=null==w?void 0:w.symbol)?a:"-"})]}),(0,i.jsx)(J.g3,{amount:U,fontSize:"14px",bold:!0,children:null!=ek?ek:"-"})]}),(0,i.jsx)(l.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:U&&"number"==typeof D?`~${(0,S.o5)((0,x.g)(U.toExact()).times(D).toNumber())}`:"$0.00"})]})]}),children:(0,i.jsxs)(l.A,{bold:!0,fontSize:"14px",children:["$",I.toFixed(2)]})})})}),!f&&(0,i.jsx)(tD,{align:"right",children:N&&function(e){return!!e&&(void 0!==e.fee0Amount&&e.fee0Amount>0||void 0!==e.fee1Amount&&e.fee1Amount>0||void 0!==e.farmRewardsAmount&&e.farmRewardsAmount>0)}(P)?(0,i.jsx)(eh.z,{content:(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",gap:"8px",children:[void 0!==P.fee0Amount&&P.fee0Amount>0&&b&&(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(F.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(F.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(ex.Z,{currency:b,size:"16px",mb:"-3px"}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:b.symbol})]}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:(0,Y.ZV)(P.fee0Amount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})})]}),void 0!==P.fee0USD&&(0,i.jsx)(l.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,S.o5)(P.fee0USD)}),eC]}),void 0!==P.fee1Amount&&P.fee1Amount>0&&w&&(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",ga
16p:"2px",width:"100%",children:[(0,i.jsxs)(F.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(F.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(ex.Z,{currency:w,size:"16px",mb:"-3px"}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:w.symbol})]}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:(0,Y.ZV)(P.fee1Amount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})})]}),void 0!==P.fee1USD&&(0,i.jsx)(l.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,S.o5)(P.fee1USD)}),eI]}),(null==(t=P.farmRewards)?void 0:t.length)?P.farmRewards.map((e,t)=>(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(F.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(F.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(ex.Z,{currency:e.currency,size:"16px",mb:"-3px"}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:e.currency.symbol})]}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:(0,Y.ZV)(e.amount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})})]}),(0,i.jsx)(l.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,S.o5)(e.amountUSD)})]},t)):void 0!==P.farmRewardsAmount&&P.farmRewardsAmount>0&&P.rewardCurrency&&(0,i.jsxs)(F.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(F.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(F.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(ex.Z,{currency:P.rewardCurrency,size:"16px",mb:"-3px"}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:P.rewardCurrency.symbol})]}),(0,i.jsx)(l.A,{fontSize:"14px",bold:!0,children:(0,Y.ZV)(P.farmRewardsAmount,{maxDecimalDisplayDigits:6,maximumDecimalTrailingZeroes:3})})]}),void 0!==P.farmRewardsUSD&&(0,i.jsx)(l.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,S.o5)(P.farmRewardsUSD)}),eS]})]}),children:(0,i.jsx)(l.A,{bold:!0,fontSize:"14px",children:N.display})}):N?(0,i.jsx)(l.A,{bold:!0,fontSize:"14px",children:N.display}):(0,i.jsx)(l.A,{bold:!0,fontSize:"14px",children:"-"})}),(0,i.jsx)(tD,{align:"right",children:(0,i.jsx)(r.A,{flexDirection:"column",alignItems:"flex-end","data-interactive":!0,children:R})}),(0,i.jsx)(tD,{align:"right",children:ew?(0,i.jsx)("div",{"data-interactive":!0,children:eo}):eM?(0,i.jsx)("div",{"data-interactive":!0,children:(0,i.jsx)(O.A,{scale:"md",onClick:()=>null==el?void 0:el("evm",M),children:A("Harvest")})}):eR?(0,i.jsx)("div",{"data-interactive":!0,children:(0,i.jsx)(ed.A,{variant:"light",onClick:e_,"aria-label":A(m?"Collapse row":"Expand row"),children:m?(0,i.jsx)(eu.A,{}):(0,i.jsx)(ec.A,{})})}):null})]}),m&&eR&&(0,i.jsx)(tq,{children:(0,i.jsx)(tL,{colSpan:6,children:(0,i.jsx)(tP,{position:d,pool:C,currency0:b,currency1:w,amount0:T,amount1:U,earnings:N,earningsBreakdown:P,totalLiquidityUSD:I,lpApr:null!=L?L:0,merklApr:null!=_?_:0,incentraApr:null!=$?$:0,farmApr:null!=z?z:0,totalApr:null!=V?V:0,price0Usd:B,price1Usd:D,currentPrice:null==q?void 0:q.currentPriceValue,onViewDetails:K,onAddLiquidity:X,onRemoveLiquidity:ee,v3SdkPool:er,onHarvest:et,inverted:eq,onToggleInverted:eF,hasFarm:Z})})})]})},(e,t)=>{var n,i,r,l,o,a,s,d,u,c,p,m,x,h,f,v,y,g,A,b,w,j;if((0,tU.V)(e.position)!==(0,tU.V)(t.position)||e.expanded!==t.expanded||e.hideEarningsColumn!==t.hideEarningsColumn||e.rowAction!==t.rowAction)return!1;let k=e.data,C=t.data;return k.totalPriceUSD===C.totalPriceUSD&&k.removed===C.removed&&k.outOfRange===C.outOfRange&&(null==(n=k.earnings)?void 0:n.display)===(null==(i=C.earnings)?void 0:i.display)&&k.totalApr===C.totalApr&&k.hasFarm===C.hasFarm&&k.farmApr===C.farmApr&&("isStaked"in e.position?e.position.isStaked:void 0)===("isStaked"in t.position?t.position.isStaked:void 0)&&(null==(l=k.currency0)||null==(r=l.wrapped)?void 0:r.address)===(null==(a=C.currency0)||null==(o=a.wrapped)?void 0:o.address)&&(null==(d=k.currency1)||null==(s=d.wrapped)?void 0:s.address)===(null==(c=C.currency1)||null==(u=c.wrapped)?void 0:u.address)&&(null==(p=k.priceRangeDisplay)?void 0:p.minPriceFormatted)===(null==(m=C.priceRangeDisplay)?void 0:m.minPriceFormatted)&&(null==(x=k.priceRangeDisplay)?void 0:x.maxPriceFormatted)===(null==(h=C.priceRangeDisplay)?void 0:h.maxPriceFormatted)&&(null==(f=k.priceRangeDisplay)?void 0:f.currentPrice)===(null==(v=C.priceRangeDisplay)?void 0:v.currentPrice)&&(null==(y=k.amount0)?void 0:y.toExact())===(null==(g=C.amount0)?void 0:g.toExact())&&
16(null==(A=k.amount1)?void 0:A.toExact())===(null==(b=C.amount1)?void 0:b.toExact())&&k.price0Usd===C.price0Usd&&k.price1Usd===C.price1Usd&&(null==(w=k.pool)?void 0:w.lpAddress)===(null==(j=C.pool)?void 0:j.lpAddress)&&!0});var tY=n(698163);let tz=(0,u.memo)(e=>{var t,n,r,l,a,s,d,c,p;let{position:j,chainId:T,hideEarningsColumn:U,rowAction:B,priceRangeDecimalPlaces:D}=e,[F,q]=(0,u.useState)(!1),{address:L}=(0,w.F)(),[,O]=(0,R.r)(),_=(0,E.jN)(),$=(0,u.useMemo)(()=>j.poolKey?(0,C.Qn)(j.poolKey):j.poolId?j.poolId:void 0,[j]),{onHarvest:Y,hasUnclaimedRewards:z,isMerkleRootMismatch:V,attemptingTx:Z}=(0,N.A)({chainId:T,onDone:O}),{data:W}=(0,P.I)(),H=(0,u.useMemo)(()=>{let e=W.filter(e=>e.chainId===T).filter(e=>!(e=>e.chainId===j.chainId&&e.protocol===j.protocol&&e.protocol===o.Zs.InfinityBIN&&j.protocol===o.Zs.InfinityBIN&&e.activeId===j.activeId)(e));return e.unshift(j),e},[W,j,T]),Q=null!=(s=(0,M.G5)(null==(t=j.poolKey)?void 0:t.currency0,T))?s:void 0,G=null!=(d=(0,M.G5)(null==(n=j.poolKey)?void 0:n.currency1,T))?d:void 0,K=(0,u.useCallback)(()=>{_.onOpen()},[_]),[,X]=(0,h.W)($,T),J=(0,g.qX)({poolAddress:$,chainId:T}),ee=(0,b.R4)(T,null==J?void 0:J.poolId),{data:et}=(0,f.C)($,T,L),en=(null==J?void 0:J.token0)||(null==X?void 0:X.token0),ei=(null==J?void 0:J.token1)||(null==X?void 0:X.token1),er=(0,y.Ae)(en,ei),ea=(0,u.useMemo)(()=>{var e,t;return(null==X?void 0:X.token0)?m.eF.fromRawAmount(X.token0,null!=(t=null!=(e=null==et?void 0:et.reserveX)?e:null==j?void 0:j.reserveX)?t:0n):void 0},[null==et?void 0:et.reserveX,null==j?void 0:j.reserveX,null==X?void 0:X.token0]),es=(0,u.useMemo)(()=>{var e,t;return(null==X?void 0:X.token1)?m.eF.fromRawAmount(X.token1,null!=(t=null!=(e=null==et?void 0:et.reserveY)?e:null==j?void 0:j.reserveY)?t:0n):void 0},[null==et?void 0:et.reserveY,null==j?void 0:j.reserveY,null==X?void 0:X.token1]),ed=!((null==ea?void 0:ea.greaterThan("0"))||(null==es?void 0:es.greaterThan("0"))),eu=(0,u.useMemo)(()=>{let e=null==X?void 0:X.binStep,t=null==X?void 0:X.activeId;if(null===j.minBinId||void 0===j.minBinId||null===j.maxBinId||void 0===j.maxBinId||!e||void 0===t)return!1;let n=(0,I.Hf)(j.minBinId,j.maxBinId,e,t,en,ei,void 0,er);if(n.showPercentages&&n.minPercentage&&n.maxPercentage){let e=n.minPercentage.startsWith("-")&&"-%"!==n.minPercentage,t=n.minPercentage.startsWith("+"),i=n.maxPercentage.startsWith("-")&&"-%"!==n.maxPercentage,r=n.maxPercentage.startsWith("+");return!(e&&r||t&&i)&&(e||t)&&(i||r)}return!1},[X,j,en,ei,er]),{data:ec}=(0,v.GB)(null!=(c=null==X?void 0:X.token0)?c:void 0,{enabled:!!((null==X?void 0:X.token0)&&(null==ea?void 0:ea.greaterThan("0")))}),{data:ep}=(0,v.GB)(null!=(p=null==X?void 0:X.token1)?p:void 0,{enabled:!!((null==X?void 0:X.token1)&&(null==es?void 0:es.greaterThan("0")))}),em=(0,u.useMemo)(()=>{var e,t;return new x.g(null!=(e=null==ea?void 0:ea.toExact())?e:0).times(null!=ec?ec:0).plus(new x.g(null!=(t=null==es?void 0:es.toExact())?t:0).times(null!=ep?ep:0)).toNumber()},[ea,es,ec,ep]),ex=(0,A.wA)({chainId:T,poolId:$,address:L,timestamp:k()().startOf("hour").unix()}),eh=(0,y.fA)(null==(l=ex.data)||null==(r=l.rewardsAmount)?void 0:r.currency),ef=(0,u.useMemo)(()=>{var e,t;let n=null==(e=ex.data)?void 0:e.rewardsAmount,i=n?Number(eh(n.quotient,n.currency.decimals)):0;return{farmRewardsAmount:i>0?i:void 0,farmRewardsRaw:i>0?null==n?void 0:n.toExact():void 0,farmRewardsUSD:(null==(t=ex.data)?void 0:t.rewardsUSD)&&ex.data.rewardsUSD>0?ex.data.rewardsUSD:void 0,rewardCurrency:null==n?void 0:n.currency}},[ex.data,eh]),ev=(0,u.useMemo)(()=>{var e;let t="number"==typeof(null==(e=ex.data)?void 0:e.rewardsUSD)&&ex.data.rewardsUSD>0?ex.data.rewardsUSD:null;return{display:t?(0,S.dx)(t):"$0"}},[ex.data]),ey=(0,u.useMemo)(()=>{let e=null==X?void 0:X.binStep,t=null==X?void 0:X.activeId;return null!==j.minBinId&&void 0!==j.minBinId&&null!==j.maxBinId&&void 0!==j.maxBinId&&e&&null!=t?(0,I.Hf)(j.minBinId,j.maxBinId,e,t,en,ei,void 0,er,D):null},[X,j,en,ei,er,D]),eg=(e=>null!=e&&"poolId"in e&&(e.protocol===o.Zs.InfinityBIN||e.protocol===o.Zs.InfinityCLAMM))(J)?J:null,eA=(0,tY.FX)(eg||{},j),eb=(0,u.useMemo)(()=>eg&&(0,x.g)(eA.lpApr).toNumber()||0,[eA.lpApr,eg]),ew=(0,u.useMemo)(()=>eg&&(0,x.g)(eA.merklApr).toNumber()||0,[eA.merklApr,eg]),ej=(0,u.useMemo)(()=>eg&&(0,x.g)(eA.incentraApr).toNumber()||0,[eA.incentraApr,eg]),ek=(0,u.useMemo)(()=>{var e,t;return eg&&(0,x.g)(null!=(t=null==(e=eA.cakeApr)?void 0:e.value)?t:"0").toNumber()||0},[null==(a=eA.cakeApr)?void 0:a.value,eg]),eC=(0,u.useMemo)(()=>eb+ew+ej+ek,[eb,ew,ej,ek]),eI=(0,u.useMemo)(()=>{var e;return!!(null!=(e=null==J?void 0:J.isActiveFarm)?e:null==J?void 0:J.isFarming)||!J&&ek>0},[null==J?void 0:J.isActiveFarm,null==J?void 0:J.isFarming,J,ek]),eS=(0,u.useCallback)(()=>q(e=>!e),[]),eR=(0,u.useMemo)(()=>eg?(0,i.jsx)(eo.IV,{pool:eg,userPosition:j,textProps:{bold:!0}}):null,[eg,j]),eE=(0,u.useMemo)(()=>({currency0:en,currency1:ei,removed:ed,outOfRange:eu,pool:J,totalPriceUSD:em,a
16prButton:eR,hookData:ee,chainId:T,earnings:ev,earningsBreakdown:ef,amount0:ea,amount1:es,price0Usd:ec,price1Usd:ep,priceRangeDisplay:ey,lpApr:eb,merklApr:ew,incentraApr:ej,farmApr:ek,totalApr:eC,hasFarm:eI,hasUnclaimedRewards:z,isMerkleRootMismatch:V,onHarvest:ed&&z?K:void 0}),[en,ei,ed,eu,J,em,eR,ee,T,ev,ef,ea,es,ec,ep,ey,eb,ew,ej,ek,eC,eI,z,V,K]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t$,{position:j,data:eE,expanded:F,onToggleExpand:eS,hideEarningsColumn:U,rowAction:B,priceRangeDecimalPlaces:D}),_.isOpen&&Q&&G&&(0,i.jsx)(el,{..._,positionList:H,currency0:Q,currency1:G,chainId:T,onHarvest:Y,pos:j,showPositionFees:!0,closeOnOverlayClick:!0})]})});var tV=n(97114),tZ=n(788501);let tW=(0,u.memo)(e=>{var t,n,r,l,a,s,d,c,p;let{position:m,chainId:f,hideEarningsColumn:j,rowAction:T,priceRangeDecimalPlaces:U}=e,[B,D]=(0,u.useState)(!1),{address:F}=(0,w.F)(),[,q]=(0,R.r)(),L=(0,E.jN)(),O=(0,u.useMemo)(()=>m.poolKey?(0,C.Qn)(m.poolKey):m.poolId?m.poolId:void 0,[m]),{onHarvest:_,hasUnclaimedRewards:$,isMerkleRootMismatch:Y,attemptingTx:z}=(0,N.A)({chainId:f,onDone:q}),{onCollect:V,attemptingTx:Z}=(0,tZ.A)({chainId:f}),{data:W}=(0,P.I)(),H=(0,u.useMemo)(()=>{let e=W.filter(e=>e.chainId===f).filter(e=>!(e=>e.chainId===m.chainId&&e.protocol===m.protocol&&e.protocol===o.Zs.InfinityCLAMM&&m.protocol===o.Zs.InfinityCLAMM&&e.tokenId===m.tokenId)(e));return e.unshift(m),e},[W,m,f]),Q=null!=(c=(0,M.G5)(null==(t=m.poolKey)?void 0:t.currency0,f))?c:void 0,G=null!=(p=(0,M.G5)(null==(n=m.poolKey)?void 0:n.currency1,f))?p:void 0,X=(0,u.useCallback)(()=>{V({tokenId:m.tokenId,poolKey:m.poolKey})},[m.poolKey,m.tokenId,V]),J=(0,u.useCallback)(()=>{L.onOpen()},[L]),[,ee]=(0,h.W)(O,f),et=(0,g.qX)({poolAddress:O,chainId:f}),en=(0,b.R4)(f,null==et?void 0:et.poolId),ei=(0,g.RI)(m),er=(et&&"token0"in et?et.token0:void 0)||ei.currency0,ea=(et&&"token1"in et?et.token1:void 0)||ei.currency1,es=(0,y.fA)(er),ed=(0,y.fA)(ea),eu=(0,y.Ae)(er,ea),{amount0:ec}=ei,{amount1:ep}=ei,em=ei.removed||!1,ex=(0,u.useMemo)(()=>{var e,t;let n=ee||ei.pool;if(!n)return!1;let{tickLower:i,tickUpper:r,tickSpacing:l}=m;if(void 0===i||void 0===r)return!1;let o=(0,I.Mu)(l),a=(0,I.Kc)(i,r,o),s=!!((null==er||null==(e=er.wrapped)?void 0:e.address)&&(null==(t=n.token1)?void 0:t.address)&&er.wrapped.address.toLowerCase()===n.token1.address.toLowerCase()),d=(0,I.lN)(i,r,er,ea,n,a,s,eu);if(d.showPercentages&&d.minPercentage&&d.maxPercentage){let e=d.minPercentage.startsWith("-")&&"-%"!==d.minPercentage,t=d.minPercentage.startsWith("+"),n=d.maxPercentage.startsWith("-")&&"-%"!==d.maxPercentage,i=d.maxPercentage.startsWith("+");return!(e&&i||t&&n)&&(e||t)&&(n||i)}return!1},[ee,ei.pool,m,er,ea,eu]),eh=ei.outOfRange||ex,ef=(0,K.O)({currency0:er,currency1:ea,tokenId:m.tokenId,poolId:O,tickLower:m.tickLower,tickUpper:m.tickUpper,enabled:!em}),{data:ev}=(0,v.GB)(er,{enabled:!!(null==(r=ef.feeAmount0)?void 0:r.greaterThan(0))}),{data:ey}=(0,v.GB)(ea,{enabled:!!(null==(l=ef.feeAmount1)?void 0:l.greaterThan(0))}),eg=(0,tV.Z)({currency0:er,currency1:ea,amount0:ec,amount1:ep}),eA=(0,A.fG)({chainId:f,tokenId:m.tokenId,poolId:O,address:F,timestamp:k()().startOf("hour").unix()}),eb=(0,y.fA)(null==(s=eA.data)||null==(a=s.rewardsAmount)?void 0:a.currency),ew=(0,u.useMemo)(()=>{var e,t;if(em)return;let n=ef.feeAmount0?Number(es(ef.feeAmount0.quotient,ef.feeAmount0.currency.decimals)):0,i=ef.feeAmount1?Number(ed(ef.feeAmount1.quotient,ef.feeAmount1.currency.decimals)):0,r=n>0&&null!=ev&&ef.feeAmount0?(0,x.g)(ef.feeAmount0.toExact()).times(ev).toNumber():0,l=i>0&&null!=ey&&ef.feeAmount1?(0,x.g)(ef.feeAmount1.toExact()).times(ey).toNumber():0,o=null==(e=eA.data)?void 0:e.rewardsAmount,a=o?Number(eb(o.quotient,o.currency.decimals)):0;return{fee0Amount:n>0?n:void 0,fee1Amount:i>0?i:void 0,fee0Raw:ef.feeAmount0&&n>0?ef.feeAmount0.toExact():void 0,fee1Raw:ef.feeAmount1&&i>0?ef.feeAmount1.toExact():void 0,fee0USD:r>0?r:void 0,fee1USD:l>0?l:void 0,farmRewardsAmount:a>0?a:void 0,farmRewardsRaw:a>0?null==o?void 0:o.toExact():void 0,farmRewardsUSD:(null==(t=eA.data)?void 0:t.rewardsUSD)&&eA.data.rewardsUSD>0?eA.data.rewardsUSD:void 0,rewardCurrency:null==o?void 0:o.currency}},[ef,eA.data,em,ev,ey,es,ed,eb]),ej=(0,u.useMemo)(()=>{var e;let t=ef.feeAmount0?(0,x.g)(ef.feeAmount0.toExact()).toNumber():0,n=ef.feeAmount1?(0,x.g)(ef.feeAmount1.toExact()).toNumber():0,i=(t>0&&null!=ev?(0,x.g)(t).times(ev):(0,x.g)(0)).plus(n>0&&null!=ey?(0,x.g)(n).times(ey):(0,x.g)(0)).toNumber(),r=(null==(e=eA.data)?void 0:e.rewardsUSD)||0,l=(0,x.g)(i).plus(r).toNumber();return{display:l>0?(0,S.dx)(l):"$0"}},[ef,eA.data,ev,ey]),ek=(0,u.useMemo)(()=>{var e,t;let n=ee||ei.pool;if(!n)return null;let{tickLower:i,tickUpper:r,tickSpacing:l}=m;if(void 0===i||void 0===r)return null;let o=(0,I.Mu)(l),a=(0,I.Kc)(i,r,o),s=!!((null==er||null==(e=er.wrapped)?void 0:e.address)&&(null==(t=n.token1)?void 0:t.address)&&er.wrapped.address.toLowerCase()===n.token1.address.toLowerCase());return(0,I.lN)(i,r,er,ea,n,a,s,eu,U)},[ee,ei.pool,m,er,ea,eu,U]),eC=(e=>null!=e&&"poolId"in e&&(e.protocol===o.Zs.InfinityBIN||e.protocol===o.Zs.InfinityCLAMM))(et)?et:null,eI=(0,tY.pe)(eC||{},m),eS=(0,u.useMemo)(()=>eC&&(0,x.g)(eI.lpApr).toNumber()||0,[eI.lpApr,eC]),eR=(0,u.useMemo)(()=>eC&&(0,x.g)(eI.merklApr).toNumber()||0,[eI.merklApr,eC]),eE=(0,u.useMemo)(()=>eC&&(0,x.g)(eI.incentraApr).toNumber()||0,[eI.incentraApr,eC]),eM=(0,u.useMemo)(()=>{var e,t;return eC&&(0,x.g)(null!=(t=null==(e=eI.cakeApr)?void 0:e.value)?t:"0").toNumber()||0},[null==(d=eI.cakeApr)?void 0:d.value,eC]),eN=(0,u.useMemo)(()=>eS+eR+eE+eM,[eS,eR,eE,eM]),eP=(0,u.useMemo)(()=>{var e;return!!(null!=(e=null==et?void 0:et.isActiveFarm)?e:null==et?void 0:et.isFarming)||!et&&eM>0},[null==et?void 0:et.isActiveFarm,null==et?void 0:et.isFarming,et,eM]),eT=(0,u.useCallback)(()=>D(e=>!e),[]),eU=(0,u.useMemo)(()=>eC?(0,i.jsx)(eo.UB,{pool:eC,userPosition:m,textProps:{bold:!0}}):null,[eC,m]),eB=(0,u.useMemo)(()=>({currency0:er,currency1:ea,removed:em,outOfRange:eh,pool:et,totalPriceUSD:eg,aprButton:eU,hookData:en,chainId:f,earnings:ej,earningsBreakdown:ew,amount0:ec,amount1:ep,price0Usd:ev,price1Usd:ey,priceRangeDisplay:ek,lpApr:eS,merklApr:eR,incentraApr:eE,farmApr:eM,totalApr:eN,hasFarm:eP,hasUnclaimedRewards:$,isMerkleRootMismatch:Y,onHarvest:em&&$?J:void 0}),[er,ea,em,eh,et,eg,eU,en,f,ej,ew,ec,ep,ev,ey,ek,eS,eR,eE,eM,eN,eP,$,Y,J]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t$,{position:m,data:eB,expanded:B,onToggleExpand:eT,hideEarningsColumn:j,rowAction:T,priceRangeDecimalPlaces:U}),L.isOpen&&Q&&G&&(0,i.jsx)(el,{...L,positionList:H,currency0:Q,currency1:G,chainId:f,onHarvest:_,onCollect:X,pos:m,showPositionFees:!0,closeOnOverlayClick:!0})]})});var tH=n(366028),tQ=n(706172),tG=n(323641);let tK=(0,u.memo)(e=>{var t,n,r;let{position:l,chainId:a,hideEarningsColumn:s,rowAction:d,priceRangeDecimalPlaces:c}=e,[p,h]=(0,u.useState)(!1),f=(0,g.ck)(l),{currency0:A}=f,{currency1:b}=f,w=(0,y.Ae)(null==A?void 0:A.wrapped,null==b?void 0:b.wrapped),[,j]=(0,eP.f$)(null==A?void 0:A.wrapped,null==b?void 0:b.wrapped,l.fee),k=null==(t=f.position)?void 0:t.amount0,C=null==(n=f.position)?void 0:n.amount1,R=f.removed||!1,E=(0,u.useMemo)(()=>{var e,t;let n=j||f.pool;if(!n)return!1;let{tickLower:i,tickUpper:r,fee:o}=l;if(void 0===i||void 0===r)return!1;let a=(0,I.jC)(n,o),s=(0,I.Mu)(a),d=(0,I.Kc)(i,r,s),u=!!((null==A||null==(e=A.wrapped)?void 0:e.address)&&(null==(t=n.token1)?void 0:t.address)&&A.wrapped.address.toLowerCase()===n.token1.address.toLowerCase()),c=(0,I.lN)(i,r,null==A?void 0:A.wrapped,null==b?void 0:b.wrapped,n,d,u,w);if(c.showPercentages&&c.minPercentage&&c.maxPercentage){let e=c.minPercentage.startsWith("-")&&"-%"!==c.minPercentage,t=c.minPercentage.startsWith("+"),n=c.maxPercentage.startsWith("-")&&"-%"!==c.maxPercentage,i=c.maxPercentage.startsWith("+");return!(e&&i||t&&n)&&(e||t)&&(n||i)}return!1},[j,f.pool,l,A,b,w]),M=f.outOfRange||E,N=j||f.pool,[P,T]=(0,tQ.R)(null!=N?N:void 0,l.tokenId,!1,!R),B=!!(k&&k.greaterThan(0)||P&&P.greaterThan(0)),D=!!(C&&C.greaterThan(0)||T&&T.greaterThan(0)),{data:F}=(0,v.GB)(A,{enabled:B}),{data:q}=(0,v.GB)(b,{enabled:D}),L=(0,tV.Z)({currency0:A,currency1:b,amount0:k,amount1:C}),O=(0,u.useMemo)(()=>l.tokenId?[l.tokenId]:[],[l.tokenId]),_=(0,tG.Ls)(O,a),$=(0,y.fA)(A),Y=(0,y.fA)(b),z=(0,u.useMemo)(()=>
16{if(R)return;let e=P?Number($(P.quotient,P.currency.decimals)):0,t=T?Number(Y(T.quotient,T.currency.decimals)):0,n=F&&P?(0,x.g)(P.toExact()).times(F).toNumber():0,i=q&&T?(0,x.g)(T.toExact()).times(q).toNumber():0;return{fee0Amount:e>0?e:void 0,fee1Amount:t>0?t:void 0,fee0Raw:P&&e>0?P.toExact():void 0,fee1Raw:T&&t>0?T.toExact():void 0,fee0USD:n>0?n:void 0,fee1USD:i>0?i:void 0,farmRewardsAmount:_.earningsAmount&&_.earningsAmount>0?_.earningsAmount:void 0,farmRewardsUSD:_.earningsBusd&&_.earningsBusd>0?_.earningsBusd:void 0,rewardCurrency:U.vb[a]}},[P,T,F,q,_,R,$,Y]),V=(0,u.useMemo)(()=>{let e=((null==z?void 0:z.fee0USD)||0)+((null==z?void 0:z.fee1USD)||0),t=(_.earningsBusd||0)+e;return{display:t>0?(0,S.dx)(t):"$0"}},[_,z]),Z=(0,u.useMemo)(()=>{var e,t;let n=j||f.pool;if(!n)return null;let{tickLower:i,tickUpper:r,fee:o}=l;if(void 0===i||void 0===r)return null;let a=(0,I.jC)(n,o),s=(0,I.Mu)(a),d=(0,I.Kc)(i,r,s),u=!!((null==A||null==(e=A.wrapped)?void 0:e.address)&&(null==(t=n.token1)?void 0:t.address)&&A.wrapped.address.toLowerCase()===n.token1.address.toLowerCase());return(0,I.lN)(i,r,null==A?void 0:A.wrapped,null==b?void 0:b.wrapped,n,d,u,w,c)},[j,f.pool,l,A,b,w,c]),W=(0,u.useMemo)(()=>(0,g.ji)(a,l.token0,l.token1,l.fee),[a,l.token0,l.token1,l.fee]),H=(0,g.qX)({poolAddress:W,chainId:a}),Q=(0,u.useMemo)(()=>{var e,t;if(H)return H;let n=a||l.chainId;if(n||console.warn("chainId is undefined for V3 position APR calculation"),A&&b&&W)return{chainId:n,lpAddress:W,token0:A,token1:b,protocol:o.Zs.V3};let i=A||(null==(e=f.pool)?void 0:e.token0),r=b||(null==(t=f.pool)?void 0:t.token1);return{chainId:n,lpAddress:W||m.cF,token0:i||void 0,token1:r||void 0,protocol:o.Zs.V3}},[H,a,l.chainId,W,A,b,f.pool]),G=(0,tY.jr)(Q,l),K=(0,u.useMemo)(()=>H?(0,x.g)(G.lpApr||0).toNumber():0,[G.lpApr,H]),X=(0,u.useMemo)(()=>{var e;return H?(0,x.g)(null!=(e=G.merklApr)?e:0).toNumber():0},[G.merklApr,H]),J=(0,u.useMemo)(()=>{var e;return H?(0,x.g)(null!=(e=G.incentraApr)?e:0).toNumber():0},[G.incentraApr,H]),ee=(0,u.useMemo)(()=>{var e,t;return H&&(0,x.g)(null!=(t=null==(e=G.cakeApr)?void 0:e.value)?t:"0").toNumber()||0},[null==(r=G.cakeApr)?void 0:r.value,H]),et=(0,u.useMemo)(()=>K+X+J+ee,[K,X,J,ee]),en=(null==H?void 0:H.pid)?H:null,[ei]=(0,g.nW)(en),er=(0,tH.o)(ei),{data:el}=(0,g.cO)([a]),ea=null==el?void 0:el[a],es=(0,u.useMemo)(()=>!!H&&!!H.pid&&"0X"!==er&&(!ea||H.pid<=ea),[H,null==H?void 0:H.pid,ea,er]),ed=(0,u.useCallback)(()=>h(e=>!e),[]),eu=(0,u.useMemo)(()=>H?(0,i.jsx)(eo._o,{pool:H,userPosition:l,textProps:{bold:!0}}):null,[H,l]),ec=(0,u.useMemo)(()=>({currency0:A,currency1:b,removed:R,outOfRange:M,pool:null!=H?H:Q,totalPriceUSD:L,aprButton:eu,hookData:void 0,chainId:a,earnings:V,earningsBreakdown:z,amount0:k,amount1:C,price0Usd:F,price1Usd:q,priceRangeDisplay:Z,lpApr:K,merklApr:X,incentraApr:J,farmApr:ee,totalApr:et,hasFarm:es,v3SdkPool:N}),[A,b,R,M,H,Q,L,eu,a,V,z,k,C,F,q,Z,K,X,J,ee,et,es,N]);return(0,i.jsx)(t$,{position:l,data:ec,expanded:p,onToggleExpand:ed,hideEarningsColumn:s,rowAction:d,priceRangeDecimalPlaces:c})});var tX=n(755407);let tJ=(0,u.memo)(e=>{var t;let{position:n,chainId:r,protocol:l,hideEarningsColumn:a,rowAction:s}=e,[d,c]=(0,u.useState)(!1),p=l===o.Zs.V2,m=n.pair,h=m.token0,f=m.token1,y=p?m.liquidityToken.address:n.pair.stableSwapAddress,A=(0,g.qX)({poolAddress:y,chainId:r}),b=n.nativeDeposited0.add(n.farmingDeposited0),w=n.nativeDeposited1.add(n.farmingDeposited1),{data:j}=(0,v.GB)(h,{enabled:b.greaterThan(0)}),{data:k}=(0,v.GB)(f,{enabled:w.greaterThan(0)}),C=(0,u.useMemo)(()=>{var e,t;return(0,x.g)(null!=j?j:0).times(null!=(e=null==b?void 0:b.toExact())?e:0).plus((0,x.g)(null!=k?k:0).times(null!=(t=null==w?void 0:w.toExact())?t:0)).toNumber()},[j,k,b,w]),I=(e=>null!=e&&(e.protocol===o.Zs.V2||e.protocol===o.Zs.STABLE||e.protocol===o.Zs.InfinitySTABLE))(A)?A:null,S=(0,u.useMemo)(()=>{var e;return p?tX.p5:Number(null!=(e=n.pair.stableTotalFee)?e:0)*tX.dg},[p,n.pair]),R=tX.dg,E=(0,tY.mi)(I||{},n),M=(0,u.useMemo)(()=>I?(0,x.g)(E.lpApr||0).toNumber():0,[E.lpApr,I]),N=(0,u.useMemo)(()=>{var e;return I?(0,x.g)(null!=(e=E.merklApr)?e:0).toNumber():0},[E.merklApr,I]),P=(0,u.useMemo)(()=>{var e;return I?(0,x.g)(null!=(e=E.incentraApr)?e:0).toNumber():0},[E.incentraApr,I]),T=(0,u.useMemo)(()=>{var e,t;return I&&(0,x.g)(null!=(t=null==(e=E.cakeApr)?void 0:e.value)?t:"0").toNumber()||0},[null==(t=E.cakeApr)?void 0:t.value,I]),U=(0,u.useMemo)(()=>M+N+P+T,[M,N,P,T]),B=(0,u.useMemo)(()=>{var e;return!!(null!=(e=null==A?void 0:A.isActiveFarm)?e:null==A?void 0:A.isFarming)||!A&&T>0},[null==A?void 0:A.isActiveFarm,null==A?void 0:A.isFarming,A,T]),D=(0,u.useCallback)(()=>c(e=>!e),[]),F=(0,u.useMemo)(()=>I?(0,i.jsx)(eo.xo,{pool:I,userPosition:n,textProps:{bold:!0}}):null,[I,p,n,n]),q=(0,u.useMemo)(()=>({currency0:h,currency1:f,removed:!1,outOfRange:!1,pool:A,totalPriceUSD:C,aprButton:F,hookData:void 0,chainId:r,earnings:null,amount0:b,amount1:w,price0Usd:j,price1Usd:k,priceRangeDisplay:null,lpApr:M,merklApr:N,incentraApr:P,farmApr:T,totalApr:U,hasFarm:B,feeTier:S,feeTierBase:R}),[h,f,A,C,F,r,b,w,j,k,M,N,P,T,U,B,S,R]);return(0,i.jsx)(t$,{position:n,data:q,expanded:d,onToggleExpand:D,hideEarningsColumn:a,rowAction:s})});var t0=n(203907),t1=n(489886),t2=n(72912),t6=n(619749),t8=n(542160),t3=n(98378),t9=n(903878),t4=n(188882);let t5=(0,u.memo)(e=>{var t;let{position:n,hideEarningsColumn:r,rowAction:l,priceRangeDecimalPlaces:a}=e,[s,d]=(0,u.useState)(!1),c=null!=(t=(0,t1.xk)(n.poolId.toBase58()
16))?t:void 0,m=(0,u.useMemo)(()=>(0,t6.ph)(null==c?void 0:c.mintA),[null==c?void 0:c.mintA]),h=(0,u.useMemo)(()=>(0,t6.ph)(null==c?void 0:c.mintB),[null==c?void 0:c.mintB]),{amount0:f,amount1:v}=(0,t3.y)({poolInfo:c,tickLower:n.tickLower,tickUpper:n.tickUpper,liquidity:n.liquidity}),{data:y}=(0,t2.wm)({mint:null==m?void 0:m.wrapped.address,enabled:!!m}),{data:g}=(0,t2.wm)({mint:null==h?void 0:h.wrapped.address,enabled:!!h}),A=(0,u.useMemo)(()=>{var e,t;return Number(null!=y?y:0)*Number(null!=(e=null==f?void 0:f.toExact())?e:0)+Number(null!=g?g:0)*Number(null!=(t=null==v?void 0:v.toExact())?t:0)},[y,g,f,v]),b=n.liquidity.isZero(),w=n.status===t0.$.INACTIVE,j=(0,u.useMemo)(()=>{var e;if(m&&h&&c)return{pid:0,nftMint:n.nftMint,lpAddress:void 0,protocol:o.Zs.V3,token0:m,token1:h,feeTier:Math.round(c.feeRate*t9.J),feeTierBase:t9.J,isFarming:null!=(e=c.isFarming)&&e,poolId:n.poolId.toBase58(),liquidity:BigInt(n.liquidity.toString()),chainId:p.Cb.SOLANA,tvlUsd:c.tvl.toString(),rawPool:c}},[m,h,c,n.liquidity,n.poolId,n.nftMint]),{breakdownRewardInfo:k,totalPendingYield:C}=(0,t4.n)({poolInfo:j,position:n}),I=(0,u.useMemo)(()=>{var e;if(b||!k)return;let t=k.fee.A?(0,x.g)(k.fee.A.amount).toNumber():0,n=k.fee.B?(0,x.g)(k.fee.B.amount).toNumber():0,i=k.fee.A?(0,x.g)(k.fee.A.amountUSD).toNumber():0,r=k.fee.B?(0,x.g)(k.fee.B.amountUSD).toNumber():0,l=k.rewards.filter(e=>(0,x.g)(e.amount).gt(0)).map(e=>({amount:(0,x.g)(e.amount).toNumber(),amountUSD:(0,x.g)(e.amountUSD).toNumber(),currency:(0,t6.ph)(e.mint)})).filter(e=>e.currency),o=l.reduce((e,t)=>e+t.amountUSD,0),a=l.reduce((e,t)=>e+t.amount,0);return{fee0Amount:t>0?t:void 0,fee1Amount:n>0?n:void 0,fee0USD:i>0?i:void 0,fee1USD:r>0?r:void 0,farmRewards:l.length>0?l:void 0,farmRewardsAmount:a>0?a:void 0,farmRewardsUSD:o>0?o:void 0,rewardCurrency:null==(e=l[0])?void 0:e.currency}},[k,b]),R=(0,u.useMemo)(()=>{let e=C?C.toNumber():0;return{display:e>0?(0,S.dx)(e):"-"}},[C]),E=n.poolId.toBase58(),M=m&&h?`${m.symbol}/${h.symbol}`:void 0,N=(0,t8.Q)({tickLower:n.tickLower,tickUpper:n.tickUpper,baseIn:!0,poolInfo:c,debugMeta:{poolId:E,pairSymbols:M}}),P=(0,u.useMemo)(()=>{if(!N)return null;let{minPriceFormatted:e,maxPriceFormatted:t}=N,{minPrice:n,maxPrice:i}=N;if(n&&i&&Number.isFinite(n)&&Number.isFinite(i)&&n>0&&i>0){let r=(0,ev.Yr)(n,i,a);e=r.minFormatted,t=r.maxFormatted}return{...N,minPriceFormatted:e,maxPriceFormatted:t}},[N,a]),{apr:T}=(0,tY.Ln)(null!=j?j:{},n),U=(0,u.useMemo)(()=>{var e,t;return null!=(t=null==T||null==(e=T.fee)?void 0:e.apr)?t:0},[T]),B=(0,u.useMemo)(()=>{var e,t;return null!=(t=null==T||null==(e=T.rewards)?void 0:e.reduce((e,t)=>e+t.apr,0))?t:0},[T]),D=(0,u.useMemo)(()=>{var e;return null!=(e=null==T?void 0:T.apr)?e:0},[T]),F=(0,u.useMemo)(()=>!!(null==j?void 0:j.isFarming)||!j&&B>0,[null==j?void 0:j.isFarming,j,B]),q=(0,u.useCallback)(()=>{d(e=>!e)},[]),L=(0,u.useMemo)(()=>j?(0,i.jsx)(eo.uu,{pool:j,userPosition:n,textProps:{bold:!0}}):null,[j,n]),O=(0,u.useMemo)(()=>({currency0:m,currency1:h,removed:b,outOfRange:w,pool:null!=j?j:null,totalPriceUSD:A,aprButton:L,hookData:void 0,chainId:p.Cb.SOLANA,earnings:R,earningsBreakdown:I,amount0:f,amount1:v,price0Usd:y,price1Usd:g,priceRangeDisplay:P,lpApr:U,farmApr:B,totalApr:D,hasFarm:F,feeTier:(null==c?void 0:c.feeRate)?Math.round(c.feeRate*t9.J):void 0,feeTierBase:t9.J}),[m,h,b,w,j,A,L,R,I,f,v,y,g,P,U,B,D,F,null==c?void 0:c.feeRate]);return(0,i.jsx)(t$,{position:n,data:O,expanded:s,onToggleExpand:q,hideEarningsColumn:r,rowAction:l,priceRangeDecimalPlaces:a})}),t7=(0,u.memo)(e=>{let{position:t,hideEarningsColumn:n,rowAction:r,priceRangeDecimalPlaces:l}=e,a=(0,et.g7)(t);switch(t.protocol){case o.Zs.InfinityBIN:return(0,i.jsx)(tz,{position:t,chainId:a,hideEarningsColumn:n,rowAction:r,priceRangeDecimalPlaces:l});case o.Zs.InfinityCLAMM:return(0,i.jsx)(tW,{position:t,chainId:a,hideEarningsColumn:n,rowAction:r,priceRangeDecimalPlaces:l});case o.Zs.V3:if((0,p.fT)(a))return(0,i.jsx)(t5,{position:t,chainId:a,hideEarningsColumn:n,rowAction:r,priceRangeDecimalPlaces:l});return(0,i.jsx)(tK,{position:t,chainId:a,hideEarningsColumn:n,rowAction:r,priceRangeDecimalPlaces:l});case o.Zs.V2:case o.Zs.STABLE:case o.Zs.InfinitySTABLE:return(0,i.jsx)(tJ,{position:t,chainId:a,protocol:t.protocol,hideEarningsColumn:n,rowAction:r});default:return null}}),ne=a.Ay.div.withConfig({componentId:"sc-29e41771-0"})(["width:100%;overflow-x:auto;background:",";border:1px solid ",";border-radius:20px;"],e=>{let{theme:t}=e;return t.card.background},e=>{let{theme:t}=e;return t.colors.cardBorder}),nt=a.Ay.table.withConfig({componentId:"sc-29e41771-1"})(["width:100%;border-collapse:collapse;background:",";"],e=>{let{theme:t}=e;return t.card.background}),nn=a.Ay.thead.withConfig({componentId:"sc-29e41771-2"})(["border-bottom:1px solid ",";"],e=>{let{theme:t}=e;return t.colors.cardBorder}),ni=a.Ay.tr.withConfig({componentId:"sc-29e41771-3"})([""]),nr=a.Ay.th.withConfig({componentId:"sc-29e41771-4"})(["padding:20px 16px;text-align:",";font-size:12px;font-weight:600;color:",";text-transform:uppercase;width:",";&:first-child{padding-left:24px;}&:last-child{padding-right:24px;}"],e=>{let{align:t}=e;return t||"left"},e=>{let{theme:t}=e;return t.colors.secondary},e=>{let{width:t}=e;return t||"auto"}),nl=a.Ay.tbody.withConfig({componentId:"sc-29e41771-5"})([""]),no=e=>{let{positions:t,poolLengthMap:n,typeIndex:a,rowAction:p,priceRangeDecimalPlaces:m}=e,{t:x}=(0,s.A)(),h=(0,d.useRouter)(),f=(0,u.useMemo)(()=>
16{if(void 0!==a)return a;let e=h.query.type;return e?Number(Array.isArray(e)?e[0]:e):0},[a,h.query.type]),v=(0,c.k)(f),y=(0,u.useMemo)(()=>1===v.length&&(v[0]===o.Zs.V2||v[0]===o.Zs.STABLE),[v]);return t.length?(0,i.jsx)(ne,{children:(0,i.jsxs)(nt,{children:[(0,i.jsx)(nn,{children:(0,i.jsxs)(ni,{children:[(0,i.jsxs)(nr,{children:[x("Position")," (",t.length,")"]}),(0,i.jsx)(nr,{align:"left",children:x("Price Range (Min/Max)")}),(0,i.jsx)(nr,{align:"right",children:x("Liquidity")}),!y&&(0,i.jsx)(nr,{align:"right",children:x("Earnings")}),(0,i.jsx)(nr,{align:"right",children:x("APR")}),(0,i.jsx)(nr,{align:"right"})]})}),(0,i.jsx)(nl,{children:t.map(e=>{let t=(0,et.g7)(e),r=(0,tU.V)(e);return(0,i.jsx)(t7,{position:e,poolLength:null==n?void 0:n[t],hideEarningsColumn:y,rowAction:p,priceRangeDecimalPlaces:m},`${t}-${e.protocol}-${r}`)})})]})}):(0,i.jsx)(r.A,{justifyContent:"center",p:"40px",children:(0,i.jsx)(l.A,{color:"textSubtle",children:x("No positions found")})})}},180255:e=>{var t="\ud800-\udfff",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",i="\ud83c[\udffb-\udfff]",r="[^"+t+"]",l="(?:\ud83c[\udde6-\uddff]){2}",o="[\ud800-\udbff][\udc00-\udfff]",a="(?:"+n+"|"+i+")?",s="[\\ufe0e\\ufe0f]?",d="(?:\\u200d(?:"+[r,l,o].join("|")+")"+s+a+")*",u=RegExp(i+"(?="+i+")|"+("(?:"+[r+n+"?",n,l,o,"["+t+"]"].join("|"))+")"+(s+a+d),"g");e.exports=function(e){return e.match(u)||[]}},188882:(e,t,n)=>{"use strict";n.d(t,{n:()=>h});var i=n(25963),r=n(638380),l=n(662928),o=n(529208),a=n(72912),s=n(252146),d=n(91168),u=n(142511),c=n(174722),p=n.n(c),m=n(659918),x=n(379324);let h=e=>{var t;let{poolInfo:n,position:c}=e,h=(0,r.W)(),f=(0,u.zl)(),v=(0,i.useCallback)(()=>(0,x.bh)({raydium:f,poolInfo:n,position:c,connection:h}),[h,n,c,f]),[y]=(0,s.r)(),{data:g}=(0,l.I)({queryKey:(0,x.nl)(null==n?void 0:n.poolId,null==c||null==(t=c.nftMint)?void 0:t.toBase58(),null==y?void 0:y.blockHash),queryFn:v,enabled:!!(n&&c&&f),...o.MU}),A=(0,i.useMemo)(()=>g?{tokenFeeAmountA:null==g?void 0:g.feeAmount0,tokenFeeAmountB:null==g?void 0:g.feeAmount1}:{},[g]),b=(0,i.useMemo)(()=>{var e;return null!=(e=null==g?void 0:g.rewardAmounts)?e:[]},[g]),w=(0,i.useMemo)(()=>{var e,t,i,r,l,o;return p()([null==n||null==(t=n.rawPool)||null==(e=t.mintA)?void 0:e.address,null==n||null==(r=n.rawPool)||null==(i=r.mintB)?void 0:i.address,...(null==n||null==(o=n.rawPool)||null==(l=o.rewardDefaultInfos)?void 0:l.map(e=>e.mint.address))||[]]).filter(Boolean)},[n]),{data:j}=(0,a.h3)({mints:w,enabled:w.length>0}),k=(0,i.useMemo)(()=>n?b.map((e,t)=>{var i;let r=null==(i=n.rawPool.rewardDefaultInfos[t])?void 0:i.mint;return r?new d.A(e.toString()).div(10**(r.decimals||0)).multipliedBy(j[r.address]||0).toString():"0"}).reduce((e,t)=>e.plus(t),m.AH):m.AH,[n,b,j]),C=(0,i.useMemo)(()=>{var e,t;return n&&j?new d.A((null==(e=A.tokenFeeAmountA)?void 0:e.toString())||0).div(10**n.rawPool.mintA.decimals).multipliedBy(j[n.rawPool.mintA.address]||0).plus(new d.A((null==(t=A.tokenFeeAmountB)?void 0:t.toString())||0).div(10**n.rawPool.mintB.decimals).multipliedBy(j[n.rawPool.mintB.address]||0)).plus(k):m.AH},[n,j,k,A.tokenFeeAmountA,A.tokenFeeAmountB]);return{breakdownRewardInfo:(0,i.useMemo)(()=>{var e,t,i,r,l,o;return n&&j?{fee:{A:{mint:n.rawPool.mintA,amount:new d.A(null!=(l=null==(e=A.tokenFeeAmountA)?void 0:e.toString())?l:0).div(new d.A(10**n.rawPool.mintA.decimals)).toString()||"0",amountUSD:new d.A((null==(t=A.tokenFeeAmountA)?void 0:t.toString())||0).div(10**n.rawPool.mintA.decimals).multipliedBy(j[n.rawPool.mintA.address]||0).toFixed(4)},B:{mint:n.rawPool.mintB,amount:new d.A(null!=(o=null==(i=A.tokenFeeAmountB)?void 0:i.toString())?o:0).div(new d.A(10**n.rawPool.mintB.decimals)).toString()||"0",amountUSD:new d.A((null==(r=A.tokenFeeAmountB)?void 0:r.toString())||0).div(10**n.rawPool.mintB.decimals).multipliedBy(j[n.rawPool.mintB.address]||0).toFixed(4)}},rewards:b.map((e,t)=>{var i;let r=null==(i=n.rawPool.rewardDefaultInfos[t])?void 0:i.mint;if(!r)return{mint:null,amount:"0",amountUSD:"0"};let l=new d.A(e.toString()).div(10**(r.decimals||0));return{mint:r,amount:l.toFixed(r.decimals||6),amountUSD:l.multipliedBy(j[r.address]||0).toFixed(4)}}).filter(e=>!!e.mint)}:{fee:{A:void 0,B:void 0},rewards:[]}},[b,A,n,j]),totalPendingYield:C}}}
16,191928:(e,t,n)=>{"use strict";n.d(t,{f:()=>l});var i=n(43185),r=n(131117);function l(e,t,n){let l=(0,r.a)(e,null==n?void 0:n.in);return isNaN(t)?(0,i.w)((null==n?void 0:n.in)||e,NaN):(t&&l.setDate(l.getDate()+t),l)}},196229:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(350979),r=n(605641),l=n(769932);let o=()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(r.A,{children:e("Transaction pending approvals. Execution will occur after multisig confirmation.")})}},196941:(e,t,n)=>{var i=n(418595),r=n(367475),l=n(180255);e.exports=function(e){return r(e)?l(e):i(e)}},197504:(e,t,n)=>{"use strict";n.d(t,{A:()=>I,V:()=>C});var i=n(350979),r=n(769932),l=n(311560),o=n(334404),a=n(673384),s=n(27313),d=n(227883),u=n(893130),c=n(968349),p=n(909114),m=n(389512),x=n(146105),h=n(555967),f=n(398892),v=n(25963),y=n(733775),g=n(259145),A=n(792118),b=n(663257),w=n(17581),j=n(495964),k=n(236088);function C(){var e,t,n;let{t:l}=(0,r.A)(),{data:u}=(0,j.G)(),{toastSuccess:c}=(0,o.d)(),{address:f}=(0,w.F)(),{sendTransactionAsync:g}=(0,k.s)(),{maxFeePerGas:C,maxPriorityFeePerGas:I}=(0,p.N)(null==u||null==(e=u.chain)?void 0:e.id),{loading:S,fetchWithCatchTxError:R}=(0,m.A)(),E=(0,s.jE)(),M=(0,x.w)(null==u||null==(t=u.chain)?void 0:t.id),N=null==(n=(0,h.rZ)())?void 0:n.address;return{onHarvestAll:(0,v.useCallback)(async e=>{var t;if(!f||!N)return;let{calldata:n,value:r}=a.SG.batchHarvestCallParameters(e.map(e=>({tokenId:e,to:f}))),o={to:N,data:n,value:(0,b.uU)(r),account:f},s=(0,A.Qr)({chainId:null==u||null==(t=u.chain)?void 0:t.id}),p=await R(()=>s.estimateGas(o).then(e=>g({...o,gas:(0,y.KL)(e),maxFeePerGas:C,maxPriorityFeePerGas:I})));(null==p?void 0:p.status)&&(M(p.transactionHash),c(`${l("Harvested")}!`,(0,i.jsx)(d.G,{txHash:p.transactionHash,children:l("Your %symbol% earnings have been sent to your wallet!",{symbol:"CAKE"})})),E.invalidateQueries({queryKey:["mcv3-harvest"]}))},[f,R,N,g,C,I,u,l,c,E,M]),harvesting:S}}let I=e=>{var t,n;let{tokenId:C,onDone:I,chainId:S}=e,{t:R}=(0,r.A)(),{toastSuccess:E}=(0,o.d)(),{address:M}=(0,w.F)(),{data:N}=(0,j.G)(),{chainId:P}=(0,c.ax)(),T=null!=S?S:P,U=(0,f.t)(M),{sendTransactionAsync:B}=(0,k.s)(),{maxFeePerGas:D,maxPriorityFeePerGas:F}=(0,p.N)(T),q=(0,s.jE)(),L=A.e7[T],{loading:O,fetchWithCatchTxError:_}=(0,m.A)(),$=(0,x.w)(T),Y=null==(t=(0,h.p6)(T))?void 0:t.address,z=null==(n=(0,h.TA)({chainId:T}))?void 0:n.address,V=(0,v.useCallback)(async()=>{if(!M)return;let{calldata:e,value:t}=a.SG.withdrawCallParameters({tokenId:C,to:M}),n={account:M,to:Y,data:e,value:(0,b.uU)(t),chain:null==N?void 0:N.chain},r=await _(()=>L.estimateGas(n).then(e=>B({...n,gas:(0,y.KL)(e),maxFeePerGas:D,maxPriorityFeePerGas:F})).catch(e=>{if(U&&T===l.nU.ZKSYNC&&e.shortMessage.includes("argent/forbidden-fallback"))return B({...n,gas:u.YU,maxFeePerGas:D,maxPriorityFeePerGas:F});throw e}));(null==r?void 0:r.status)&&(null==I||I(r),E(`${R("Unstaked.status")}!`,(0,i.jsx)(d.G,{txHash:r.transactionHash,children:R("Your earnings have also been harvested to your wallet")})))},[M,_,Y,U,T,L,B,D,F,N,R,E,C,I]);return{attemptingTxn:O,onStake:(0,v.useCallback)(async()=>{if((0,g.bw)(),!M||!z)return;let{calldata:e,value:t}=a.uy.safeTransferFromParameters({tokenId:C,recipient:Y,sender:M}),n={to:z,data:e,value:(0,b.uU)(t),account:M,chain:null==N?void 0:N.chain},r=await _(()=>L.estimateGas(n).then(e=>B({...n,gas:(0,y.KL)(e),maxFeePerGas:D,maxPriorityFeePerGas:F})));(null==r?void 0:r.status)&&((0,g.Bm)(),null==I||I(r),E(`${R("Staked")}!`,(0,i.jsx)(d.G,{txHash:r.transactionHash,children:R("Your funds have been staked in the farm")})))},[M,_,Y,z,L,B,D,F,N,R,E,C,I]),onUnstake:V,onHarvest:(0,v.useCallback)(async()=>{if(!M)return;let{calldata:e}=a.SG.harvestCallParameters({tokenId:C,to:M}),t={to:Y,data:e,value:0n},n=await _(()=>L.estimateGas({account:M,...t}).then(e=>B({...t,account:M,chain:null==N?void 0:N.chain,gas:(0,y.KL)(e),maxFeePerGas:D,maxPriorityFeePerGas:F})));(null==n?void 0:n.status)&&(null==I||I(n),$(n.transactionHash),E(`${R("Harvested")}!`,(0,i.jsx)(d.G,{txHash:n.transactionHash,children:R("Your %symbol% earnings have been sent to your wallet!",{symbol:"CAKE"})}
16)),q.invalidateQueries({queryKey:["mcv3-harvest"]}))},[I,M,_,Y,L,B,D,F,N,R,E,C,q,$])}}},200604:(e,t,n)=>{"use strict";n.d(t,{u:()=>v});var i=n(350979),r=n(312680),l=n(557423),o=n(28192),a=n(795904),s=n(892977),d=n(769932),u=n(25963),c=n(188882),p=n(605360),m=n(813405),x=n(427896),h=n(710102),f=n(453461);let v=(0,u.memo)(e=>{let{removed:t,poolInfo:n,position:v,detailMode:y,hideAddRemoveButtons:g=!1}=e,{t:A}=(0,d.A)(),b=(0,r.jN)(),w=(0,r.jN)(),j=(0,u.useCallback)(()=>{b.onOpen()},[b]),k=(0,p.se)(),C=(0,u.useCallback)(()=>{null==k||k("solana")},[k]),{breakdownRewardInfo:I}=(0,c.n)({poolInfo:n,position:v}),S=(0,u.useMemo)(()=>{if(!I)return!1;let e=I.rewards.some(e=>Number(e.amount)>0||Number(e.amountUSD)>0),t=I.fee.A&&(Number(I.fee.A.amount)>0||Number(I.fee.A.amountUSD)>0)||I.fee.B&&(Number(I.fee.B.amount)>0||Number(I.fee.B.amountUSD)>0);return e||t},[I]);return y&&n&&t?(0,i.jsxs)(x.L,{children:[(0,i.jsxs)(f.Cp,{children:[(0,i.jsx)(l.A,{variant:"primary",onClick:w.onOpen,children:A("Add")}),S&&(0,i.jsx)(l.A,{variant:"primary",id:"sol-v3-harvest-btn",disabled:!k,onClick:C,children:A("Harvest")})]}),(0,i.jsx)(h.P,{isOpen:w.isOpen,onClose:w.onDismiss,pool:n,position:v})]}):(0,i.jsxs)(x.L,{children:[(0,i.jsxs)(f.Cp,{$detailMode:y,children:[!g&&!t&&(null==n?void 0:n.rawPool)&&v&&(0,i.jsx)(o.A,{id:"sol-v3-remove-btn",variant:"secondary",onClick:j,children:(0,i.jsx)(a.A,{color:"primary",width:"24px"})}),!g&&(0,i.jsx)(o.A,{id:"sol-v3-add-btn",variant:"secondary",onClick:w.onOpen,children:(0,i.jsx)(s.A,{color:"primary",width:"24px"})}),S&&(0,i.jsx)(l.A,{variant:"primary",id:"sol-v3-harvest-btn",disabled:!k,onClick:C,children:A("Harvest")})]}),n&&!t&&(0,i.jsx)(m.A,{isOpen:b.isOpen,onClose:b.onDismiss,pool:n,position:v}),n&&(0,i.jsx)(h.P,{isOpen:w.isOpen,onClose:w.onDismiss,pool:n,position:v})]})})},213694:(e,t,n)=>{"use strict";n.d(t,{C:()=>z});var i=n(350979),r=n(25963),l=n(228876),o=n(995315),a=n(605641),s=n(979332),d=n(428089),u=n(968349),c=n(827666),p=n(76103),m=n(719186),x=n(456194),h=n(487430),f=n(645444),v=n(721745),y=n(27313),g=n(919968),A=n(769932),b=n(660430),w=n(538534),j=n(863984),k=n(337034),C=n(200604),I=n(203907),S=n(142511),R=n(735167),E=n(743295),M=n(11080),N=n(23275),P=n(978300),T=n(326848),U=n.n(T),B=n(899188),D=n(529208),F=n(659197),q=n(748469),L=n(606862),O=n(732269),_=n(894799),$=n(481711),Y=n(432680);let z=e=>{let{poolInfo:t}=e,{t:n}=(0,A.A)(),{solanaAccount:T}=(0,u.W7)(),z=(0,b.Vx)(),[V,Z]=(0,r.useState)(Y.E.All),W=null==t?void 0:t.poolId,{data:H}=(0,k.L)(null==t?void 0:t.poolId),[Q]=(0,N.$)(),{isFlipped:G}=(0,r.useMemo)(()=>t.token0&&t.token1?(0,P.SP)(t.token0,t.token1):{isFlipped:!1},[t.token0,t.token1]),K=Q!==G,{solanaPositions:X,solanaLoading:J}=(0,M.E)({selectedNetwork:[l.Cb.SOLANA],selectedTokens:[`${l.Cb.SOLANA}:${t.rawPool.mintA.address}`,`${l.Cb.SOLANA}:${t.rawPool.mintB.address}`],positionStatus:I.$.ALL,farmsOnly:!1}),ee=(0,r.useMemo)(()=>X.filter(e=>{var t,n;return(null==(t=(n=e.poolId).toBase58)?void 0:t.call(n))===W}),[X,W]),et=(0,S.zl)(),{computeBudgetConfig:en}=(0,R.a0)(),[ei,er]=(0,r.useState)(!1),el=(0,y.jE)(),eo=(0,r.useCallback)(async()=>{if(!ei&&et&&(null==t?void 0:t.poolId)&&T)try{er(!0);let{poolId:e}=t,n=p.Ak["mainnet-beta"],i=(await et.clmm.getOwnerPositionInfo({programId:n})).filter(t=>t.poolId.toBase58()===e).filter(e=>!e.liquidity.isZero());if(!i.length)return void er(!1);let r={[e]:t.rawPool},l=await et.clmm.harvestAllRewards({allPoolInfo:r,allPositions:{[e]:i},ownerInfo:{useSOLBalance:!0},programId:p.Ak["mainnet-beta"],computeBudgetConfig:en});await l.execute({sequentially:!0}),await Promise.all([el.invalidateQueries({queryKey:["solana-v3-positions"],exact:!1}),el.invalidateQueries({queryKey:["solana-v3-reward-info-from-simulation",t.poolId],exact:!1})]),ec({})}catch(e){console.error(e)}finally{er(!1)}},[T,t,ei,et,en,el]),ea=(0,r.useMemo)(()=>{var e,n,i;let r=null==t?void 0:t.rawPool,l=null==r||null==(e=r.mintA)?void 0:e.address;return[l,null==r||null==(n=r.mintB)?void 0:n.address,...((null==H||null==(i=H.computePoolInfo)?void 0:i.rewardInfos)||[]).map(e=>{var t,n;return null==e||null==(n=e.tokenMint)||null==(t=n.toBase58)?void 0:t.call(n)}
16).filter(Boolean)]},[t,null==H?void 0:H.computePoolInfo]),{data:es}=(0,m.E)({mintList:ea,enabled:z===l.Cb.SOLANA}),ed=(0,r.useMemo)(()=>({...t,rawPool:{...t.rawPool,price:t.rawPool.price?1/t.rawPool.price:0}}),[t]),[eu,ec]=(0,r.useState)({}),ep=(0,r.useCallback)((e,t)=>{ec(n=>n[e]===t?n:{...n,[e]:t})},[]),em=(0,r.useMemo)(()=>{var e,r,u,p;if(!(null==ee?void 0:ee.length)||!(null==H?void 0:H.computePoolInfo))return[];let m=H.computePoolInfo.sqrtPriceX64,h=null!=(p=null==H||null==(u=H.computePoolInfo)||null==(r=u.currentPrice)||null==(e=r.toNumber)?void 0:e.call(r))?p:void 0,y=K&&h&&Number.isFinite(h)&&h>0?1/h:h;return ee.map(e=>{var r,u,p,A,b,k,S,R;let M=e.nftMint.toBase58(),N=c.mb.getSqrtPriceX64FromTick(e.tickLower),P=c.mb.getSqrtPriceX64FromTick(e.tickUpper),{amountA:T,amountB:U}=c.Rwp.getAmountsFromLiquidity(m,N,P,e.liquidity,!1),B=Number(T.toString())/10**t.token0.decimals,D=Number(U.toString())/10**t.token1.decimals,F=(0,f.iz)(null==t||null==(u=t.rawPool)||null==(r=u.config)?void 0:r.tickSpacing),q=(0,f.Kc)(e.tickLower,e.tickUpper,F),L=(0,f.Rp)(e.tickLower,e.tickUpper,t.token0,t.token1,q,K,y),_=null==H||null==(p=H.computePoolInfo)?void 0:p.tickCurrent,Y="number"==typeof _?_<e.tickLower||_>=e.tickUpper:void 0!==h&&!!L.currentPrice&&(Number(L.currentPrice)<Number(L.minPriceFormatted.replace("â","Infinity"))||Number(L.currentPrice)>Number(L.maxPriceFormatted.replace("â","Infinity"))),{showPercentages:z}=L,V=t.isFarming||t.rawPool.rewardDefaultInfos.some(e=>{var t;return 1e3*Number(null!=(t=e.endTime)?t:0)>Date.now()&&e.perSecond>0}),Z=G?t.token1:t.token0,W=G?t.token0:t.token1,Q=(0,i.jsx)(o.A,{flexDirection:"column",gap:"4px",children:(0,i.jsxs)(o.A,{alignItems:"center",gap:"8px",children:[(0,i.jsxs)(a.A,{bold:!0,fontSize:"16px",children:[Z.symbol," / ",W.symbol," ",(0,i.jsxs)(a.A,{as:"span",color:"textSubtle",children:["#",(0,v.A)(M)]})]}),!V||e.liquidity.isZero()||Y?null:(0,i.jsx)(s.A,{variant:"primary60",scale:"sm",px:"6px",children:n("Farming")}),e.liquidity.isZero()&&(0,i.jsx)(s.A,{variant:"tertiary",scale:"sm",px:"6px",children:n("Closed")})]})}),X={},[J,ee]=[t.rawPool.mintA.address,t.rawPool.mintB.address],et=J&&null!=(S=null==es||null==(A=es[J])?void 0:A.value)?S:0,en=ee&&null!=(R=null==es||null==(b=es[ee])?void 0:b.value)?R:0;J&&(X[J]={value:et}),ee&&(X[ee]={value:en}),((null==H||null==(k=H.computePoolInfo)?void 0:k.rewardInfos)||[]).forEach(e=>{var t,n,i,r;let l=null==e||null==(n=e.tokenMint)||null==(t=n.toBase58)?void 0:t.call(n);l&&(X[l]={value:null!=(r=null==es||null==(i=es[l])?void 0:i.value)?r:0})});let ei={...e,token0:t.token0,token1:t.token1,protocol:t.protocol,chainId:t.chainId,status:Y?I.$.INACTIVE:e.liquidity.isZero()?I.$.CLOSED:I.$.ACTIVE},er=(0,E.q)({poolInfo:{...t.rawPool,liquidity:H?BigInt(H.computePoolInfo.liquidity.toString()):0n},positionAccount:ei,mintPrices:X,inRange:!Y});return{tokenId:M,amountADec:B,amountBDec:D,tableRow:{tokenInfo:Q,liquidity:(0,i.jsxs)(d.Ay,{children:[(0,i.jsxs)(a.A,{fontSize:"14px",children:[(0,x.e)(B)," ",t.token0.symbol]}),(0,i.jsxs)(a.A,{fontSize:"14px",children:[(0,x.e)(D)," ",t.token1.symbol]})]}),earnings:(0,i.jsx)(a.A,{bold:!0,fontSize:"16px",children:(0,i.jsx)($.lQ,{poolInfo:t,position:ei,positionClosed:e.liquidity.isZero(),tokenId:M,onReady:ep})}),apr:(0,i.jsx)(w.z,{content:(0,i.jsx)(j.S,{combinedApr:er.apr,lpFeeApr:er.fee.apr,cakeApr:{value:er.rewards.reduce((e,t)=>e+t.apr,0)},showDesc:!0}),children:(0,i.jsx)(a.A,{bold:!0,children:(0,g.U)(er.apr)})}),aprValue:er,priceRange:(0,i.jsx)(O.F,{minPrice:L.minPriceFormatted,maxPrice:L.maxPriceFormatted,currentPrice:L.currentPrice||(y?String(y):void 0),minPercentage:L.minPercentage,maxPercentage:L.maxPercentage,rangePosition:L.rangePosition,outOfRange:Y,removed:e.liquidity.isZero(),showPercentages:z,minPriceRaw:L.minPrice,maxPriceRaw:L.maxPrice,currentPriceRaw:L.currentPriceValue}),actions:(0,i.jsx)(C.u,{removed:e.liquidity.isZero(),outOfRange:Y,chainId:l.Cb.SOLANA,poolInfo:ed,position:ei}),tokenId:M}}})},[ep,ee,H,es,t,ed,K,G]),ex=(0,r.useMemo)(()=>{var e,n,r,l,o,s;if(!em.length)return{rows:[],totalLiq:0,totalEarn:0,totalApr:0};
16let d=t.rawPool,u=null==d||null==(e=d.mintA)?void 0:e.address,c=null==d||null==(n=d.mintB)?void 0:n.address,p=u&&null!=(o=null==es||null==(r=es[u])?void 0:r.value)?o:0,m=c&&null!=(s=null==es||null==(l=es[c])?void 0:l.value)?s:0,x=0,f=0,v=0,y=em.map(e=>{var t;let n=(e.amountADec||0)*p+(e.amountBDec||0)*m;x+=n;let r=null!=(t=eu[e.tokenId])?t:0;return f+=r,v+=e.tableRow.aprValue.apr*n,{...e,liquidityUSD:n,tableRow:{...e.tableRow,liquidity:(0,i.jsx)(a.A,{bold:!0,children:(0,h.Su)(n)})}}}),g=x>0?v/x:0;return{rows:y,totalLiq:x,totalEarn:f,totalApr:g}},[es,t,em,eu]),eh=(0,r.useMemo)(()=>V===Y.E.Inactive?ex.rows.filter(e=>e.liquidityUSD>0&&0===e.tableRow.aprValue.apr):ex.rows,[ex.rows,V]);return J?(0,i.jsx)(L.B,{}):ex.rows.length?(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(q.X,{poolInfo:t,totalLiquidityUSD:eh.reduce((e,t)=>e+t.liquidityUSD,0),totalApr:ex.totalApr,totalEarnings:(0,h.Su)(ex.totalEarn),data:eh.map(e=>e.tableRow),showInactiveOnly:V===Y.E.Inactive,toggleInactiveOnly:()=>Z(V===Y.E.Inactive?Y.E.All:Y.E.Inactive),onlyFarmHarvest:!1,harvestAllButton:(0,i.jsx)(_.v,{onClick:eo,disabled:ei||!ex.totalEarn,children:ei?n("Harvesting..."):n("Harvest All")}),onRowClick:e=>{U().push(`/liquidity/position/${F.Zs.V3}/solana/${t.lpAddress}/${e.tokenId}?chain=${B.RW[t.chainId]}&${D.hy}=1`)}})}):(0,i.jsx)(L.p,{})}},214885:(e,t,n)=>{"use strict";n.d(t,{A:()=>C,d:()=>k});var i=n(350979),r=n(228876),l=n(769932),o=n(3197),a=n(796147),s=n(633900),d=n(605641),u=n(673115),c=n(785459),p=n(557423),m=n(282304),x=n(59701),h=n(968349),f=n(25963),v=n(680797),y=n(733775),g=n(452301),A=n(48099);let b=v.I4.div.withConfig({componentId:"sc-14e30960-0"})(["width:100%;"]),w=(0,v.I4)(a.mm).withConfig({componentId:"sc-14e30960-1"})(["padding:24px;"]),j=(0,v.I4)(a.YA).withConfig({componentId:"sc-14e30960-2"})(["padding:24px 0;"]);function k(e){let{onDismiss:t,chainId:n,hash:m,currencyToAdd:x,isMultisig:h=!1}=e,{t:v}=(0,l.A)(),k=(0,y.$8)(n),C=(0,y.iM)(),I=(0,g.dc)(x,n),S=(0,f.useMemo)(()=>!!I&&!!x&&!x.isNative,[I,x]);return(0,i.jsx)(b,{children:(0,i.jsxs)(w,{children:[(0,i.jsx)(j,{children:(0,i.jsx)(s.A,{strokeWidth:.5,width:"90px",color:"primary"})}),(0,i.jsxs)(a.mm,{gap:"12px",justify:"center",children:[(0,i.jsx)(d.A,{fontSize:"20px",bold:!0,children:v(h?"Multisig transaction submitted":"Transaction Submitted")}),h?(0,i.jsx)(d.A,{textAlign:"center",children:v("Transaction pending approvals. Execution will occur after multisig confirmation.")}):n&&m&&(0,i.jsxs)(u.A,{external:!0,small:!0,href:C(m,"transaction",n),children:[v("View on %site%",{site:k}),n===r.nU.BSC&&(0,i.jsx)(c.A,{color:"primary",ml:"4px"})]}),S&&!h&&(0,i.jsx)(A.A,{variant:"tertiary",mt:"12px",width:"fit-content",marginTextBetweenLogo:"6px",textOptions:A.D.TEXT_WITH_ASSET,tokenAddress:null==I?void 0:I.address,tokenSymbol:x.symbol,tokenDecimals:null==I?void 0:I.decimals,tokenLogo:I instanceof o.Xs?I.logoURI:void 0}),(0,i.jsx)(p.A,{onClick:t,mt:"20px",children:v("Close")})]})]})})}let C=e=>{let{title:t,onDismiss:n,customOnDismiss:r,attemptingTxn:l,errorMessage:o,hash:a,pendingText:s,content:d,currencyToAdd:u,isMultisig:c,...p}=e,{chainId:v}=(0,h.ax)(),y=(0,f.useCallback)(()=>{r&&r(),null==n||n()},[r,n]);return v?(0,i.jsx)(m.Ay,{title:t,headerBackground:"gradientCardHeader",...p,onDismiss:y,children:l?(0,i.jsx)(x.M,{pendingText:s}):a?(0,i.jsx)(k,{chainId:v,hash:a,isMultisig:c,onDismiss:y,currencyToAdd:u}):o?(0,i.jsx)(x.g,{message:o,onDismiss:y}):d()}):null}},216625:(e,t,n)=>{"use strict";n.d(t,{c:()=>u});var i=n(350979),r=n(769932),l=n(428089),o=n(557423),a=n(892977),s=n(326848),d=n(25963);let u=e=>{let{wrapperProps:t,to:n="/liquidity/select",...u}=e,{t:c}=(0,r.A)(),p=(0,s.useRouter)(),m=(0,d.useCallback)(()=>{n.startsWith("http")?window.open(n,"_blank"):p.push(n)},[p,n]);return(0,i.jsx)(l.Ay,{width:"100%",minWidth:"max-content",...t,children:(0,i.jsx)(o.A,{onClick:m,endIcon:(0,i.jsx)(a.A,{color:"invertedContrast"}),...u,children:c("Add Liquidity")})})}},256592:(e,t,n)=>{"use strict";n.d(t,{p:()=>v});var i=n(968349),r=n(985148),l=n(118708),o=n(656862),a=n(484305),s=n.n(a),d=n(581513),u=n(633835),c=n(779623),p=n(106736),m=n(17581);let x=async e=>{let{address:t,connector:n}=e;if(!n||!t)return null;try{let e=await n.getProvider(),i=(0,u.F)({transport:(0,c.I)(e)}).extend((0,p.p)());return await i.getCapabilities({account:t})}catch(e){return console.error("Error checking EIP-5792 support:",e),null}},h=(0,o.Iz)(e=>(0,d.Q)(async()=>e.address&&e.connector?x(e):null),s());(0,o.Iz)(e=>(0,r.eU)(t=>!!e.address&&!!e.connector&&t(h(e)).map(t=>((e,t)=>{if(!e)return!1;let n=e=>{var t;return(null==e||null==(t=e.atomic)?void 0:t.status)==="ready"};return t?n(e[t]):Object.values(e).some(n)})(t,e.chainId)).unwrapOr(!1)),s());let f=(0,o.Iz)(e=>(0,r.eU)(t=>e.address&&e.connector?t(h(e)).map(t=>((e,t)=>{var n,i;if(!e)return"unsupported";let r=t?e[t]:void 0;return null!=(i=null==r||null==(n=r.atomic)?void 0:n.status)?i:"unsupported"})(t,e.chainId)).unwrapOr("unsupported"):"unsupported"),s()),v=()=>{let{chainId:e}=(0,i.ax)(),{connector:t,address:n}=(0,m.F)();return(0,l.md)(f({address:n,connector:t,chainId:e}))}},261803:(e,t,n)=>{"use strict";n.d(t,{A:()=>s,O:()=>a});var i=n(350979),r=n(311560),l=n(955647);let o=new r.fw(1n,1000000n);function a(e){let{currencyAmount:t,significantDigits:n=4}=e,i=(0,l.ej)(t,n);return!i||!t||t.equalTo(0n)?"0":t.greaterThan(o)?new Intl.NumberFormat(void 0,{maximumSignificantDigits:n}).format(Number(i)):`<${o.toSignificant(1)}`}function s(e){return(0,i.jsx)(i.Fragment,{children:a(e)})}},271780:(e,t,n)=>{"use strict";n.d(t,{o:()=>h});var i=n(350979),r=n(928768),l=n(97114),o=n(25963),a=n(437862),s=n(203907),d=n(273523),u=n(734658),c=n(850611),p=n(484562),m=n(435619),x=n(755407);let h=(0,o.memo)(e=>{var t,n;let{data:h,detailMode:f,action:v,showAPR:y,miniMode:g}=e,{chainId:A,poolId:b}=h,w=(0,a.qX)({poolAddress:b,chainId:A}),j=null==w?void 0:w.token0,k=null==w?void 0:w.token1,C=(0,o.useMemo)(()=>j?u.eF.fromRawAmount(j,h.reserveX):void 0,[j,h.reserveX]),I=(0,o.useMemo)(()=>k?u.eF.fromRawAmount(k,h.reserveY):void 0,[k,h.reserveY]),S=(0,l.Z)({currency0:null==w?void 0:w.token0,currency1:null==w?void 0:w.token1,amount0:C,amount1:I}),R=null==(t=h.poolKey)?void 0:t.parameters.binStep,E=(0,o.useMemo)(()=>j&&k&&null!==h.minBinId&&R?(0,d.GQ)(h.minBinId,R,j,k):void 0,[j,k,h.minBinId,R]),M=(0,o.useMemo)(()=>j&&k&&null!==h.maxBinId&&R?(0,d.GQ)(h.maxBinId,R,j,k):void 0,[j,k,h.maxBinId,R]),N=(0,o.useMemo)(()=>j&&k&&E&&M?(0,i.jsx)(m.p,{base:j,quote:k,priceLower:E,priceUpper:M,tickAtLimit:{LOWER:!!(h.minBinId&&1n===BigInt(h.minBinId)),UPPER:!!(h.maxBinId&&BigInt(h.maxBinId)===c.Jn-1n)}}):null,[j,k,E,M,h.minBinId,h.maxBinId]),P=(0,o.useMemo)(()=>(0,r.Pl)({chainId:A,poolId:b,protocol:h.protocol}),[A,h.protocol,b]);return(0,i.jsx)(p.l,{chainId:A,link:P,pool:w,poolId:b,totalPriceUSD:S,amount0:C,amount1:I,desc:N,currency0:j,currency1:k,outOfRange:h.status===s.$.INACTIVE,removed:h.status===s.$.CLOSED,fee:null!=(n=null==w?void 0:w.feeTier)?n:0,feeTierBase:x.KF,protocol:h.protocol,isStaked:h.isStaked,detailMode:f,userPosition:h,showAPR:y,miniMode:g,children:v})})},274696:(e,t,n)=>{"use strict";n.d(t,{L:()=>o});var i=n(43185),r=n(131117),l=n(769621);function o(e,t,n){var o;return o=t*l.s0,(0,i.w)((null==n?void 0:n.in)||e,+(0,r.a)(e)+o)}}
16,276348:(e,t,n)=>{"use strict";n.d(t,{U:()=>r});var i=n(378385);let r=e=>{let t=Number(e);return Number.isFinite(t)?t>0&&t<.001?"<0.001":t>0&&t<1?(0,i.ZV)(t,2,4):(0,i.ZV)(t):(0,i.ZV)(0)}},282692:(e,t,n)=>{"use strict";n.d(t,{F:()=>c});var i=n(893130),r=n(623895),l=n(555967),o=n(25963),a=n(518400),s=n(349111),d=n(732170),u=n(850611);let c=(e,t)=>{let{gasPrice:n}=(0,a.M6)(),c=(0,l.Lz)(null!=t?t:d.Xd),p=(0,o.useCallback)(async e=>(0,s.hU)(c,e,n,i.YU),[c,n]),m=(0,o.useCallback)(async e=>(0,s.A9)(c,e,n,i.YU),[c,n]),x=(0,o.useCallback)(async()=>(0,s.o4)(c,n),[c,n]),{callWithGasPrice:h}=(0,r.M)(),f=(0,l.OD)(e);return{onStake:p,onUnStake:m,onHarvest:x,onApprove:(0,o.useCallback)(async()=>t?h(f,"approve",[t,u.Ao]):Promise.resolve(),[t,h,f])}}},284087:(e,t,n)=>{"use strict";n.d(t,{x:()=>s});var i=n(112788),r=n(326848),l=n(25963),o=n(284178),a=n(343954);let s=(e,t)=>{let{query:n}=(0,r.useRouter)(),{onBothRangeInput:s}=(0,a.i)(void 0),{leftRangeTypedValue:d,rightRangeTypedValue:u}=(0,o.oU)(),[c,p]=(0,l.useMemo)(()=>{let{minPrice:e,maxPrice:t}=n;return[e,t].map(e=>{if("string"==typeof e&&!Number.isNaN(e))return e})},[n]);(0,l.useEffect)(()=>{!d&&!u&&c&&p&&e&&t&&s({leftTypedValue:(0,i.m)(e,t,c),rightTypedValue:(0,i.m)(e,t,p)})},[n,c,p,e,t,d,u,s])}},290589:(e,t,n)=>{"use strict";n.d(t,{t:()=>d});var i=n(118708),r=n(489886),l=n(25963),o=n(206284),a=n(827666),s=n(638380);let d=(e,t)=>{let n=(0,s.W)(),d=(0,i.Xr)(r.Rc),{initialFetch:u=!0,enabledSubscribe:c=!0}=t||{},[p,m]=(0,l.useState)(!1),[x,h]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!n||!e||0===e.length||!u||p||x)return;h(!0);let t=async e=>{try{let t=await n.getAccountInfo(new o.PublicKey(e.id));if(!(null==t?void 0:t.data))return;let i=a.Ltm.decode(t.data),r=a.mb.sqrtPriceX64ToPrice(i.sqrtPriceX64,e.mintA.decimals,e.mintB.decimals);d({...e,price:r.toDecimalPlaces(20).toNumber(),liquidity:BigInt(i.liquidity.toString()),tickCurrent:i.tickCurrent})}catch(e){console.error("fetchPoolInfoFromRpc error",e)}};Promise.all(e.map(t)).finally(()=>{h(!1),m(!0)})},[n,e,u,p,d,x]),(0,l.useEffect)(()=>{if(!n||!e||!c)return;let t=[];return e.forEach(e=>{let i=n.onProgramAccountChange(new o.PublicKey(e.programId),t=>{let n=a.Ltm.decode(t.accountInfo.data);if(t.accountId.toString()!==e.id)return;let i=a.mb.sqrtPriceX64ToPrice(n.sqrtPriceX64,e.mintA.decimals,e.mintB.decimals);d({...e,price:i.toDecimalPlaces(20).toNumber(),liquidity:BigInt(n.liquidity.toString()),tickCurrent:n.tickCurrent})},"confirmed",[{dataSize:a.Ltm.span},{memcmp:{offset:a.Ltm.offsetOf("ammConfig"),bytes:e.config.id}},{memcmp:{offset:a.Ltm.offsetOf("mintA"),bytes:e.mintA.address}},{memcmp:{offset:a.Ltm.offsetOf("mintB"),bytes:e.mintB.address}}]);t.push(i)}),()=>{t.forEach(e=>n.removeProgramAccountChangeListener(e))}},[n,e,d]),{loading:x}}},291249:(e,t,n)=>{"use strict";n.d(t,{j:()=>v});var i=n(350979),r=n(659197),l=n(25963),o=n(483547),a=n(990056),s=n(851931),d=n(200604),u=n(524261),c=n(437862),p=n(899188),m=n(529208),x=n(70619),h=n(228876),f=n(755407);let v=(0,l.memo)(function(e){var t,n,v,y,g,A,b;let{position:w,pool:j,chainId:k,isFarmLive:C,isStaked:I,removed:S,outOfRange:R,totalLiquidityUSD:E,amount0:M,amount1:N,showCollectButton:P=!1,hideStakeButtons:T=!1,v3SdkPool:U}=e,{protocol:B}=w,D=(0,c.ck)(B!==r.Zs.V3||(0,h.fT)(k)?void 0:w),F=null!=(t=null==D?void 0:D.pool)?t:U,q=null!=(n=null!=S?S:null==D?void 0:D.removed)&&n,L=null!=(v=null!=R?R:null==D?void 0:D.outOfRange)&&v,O=B!==r.Zs.V3||(0,h.fT)(k)?null:w,_=(null==O?void 0:O.tokenId)?BigInt(O.tokenId):void 0,{quote:$,base:Y,priceUpper:z,priceLower:V,tickAtLimit:Z}=D||{},W=(0,l.useMemo)(()=>{if(B!==r.Zs.V3||(0,h.fT)(k)||!j||!_||!O)return null;let e=Y&&$?(0,i.jsx)(x.pr,{base:Y,quote:$,priceLower:V,priceUpper:z,tickAtLimit:Z}):null;return(0,i.jsx)(u.B,{chainId:k,userPosition:O,link:`/liquidity/${_}?chain=${p.RW[k]}&${m.hy}=1`,pool:j,totalPriceUSD:null!=E?E:0,desc:e,amount0:M,amount1:N,currency0:j.token0,currency1:j.token1,removed:q,outOfRange:L,fee:O.fee,feeTierBase:f.KF,protocol:O.protocol,isStaked:null!=I&&I,tokenId:_})},[B,k,j,_,O,Y,$,z,V,Z,E,M,N,q,L,I]);if(B===r.Zs.V3&&(0,h.fT)(k))return(0,i.jsx)(d.u,{position:w,poolInfo:j,removed:q,hideAddRemoveButtons:T});if(B===r.Zs.V3)return(0,i.jsx)(o.A,{chainId:k,isStaked:I,isFarmLive:C,removed:q,outOfRange:L,tokenId:_,modalContent:W,pool:null!=F?F:void 0,showCollectButton:P,hideStakeButtons:T});if(B===r.Zs.V2||B===r.Zs.STABLE){let e=null!=(b=null==j?void 0:j.stableSwapAddress)?b:null==j?void 0:j.lpAddress,t=B===r.Zs.V2?null==(g=w.pair)||null==(y=g.liquidityToken)?void 0:y.address:null==(A=w.pair)?void 0:A.stableSwapAddress,n=null!=e?e:t,l=null==j?void 0:j.pid;return j&&n&&I?(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(a.L,{data:w,chainId:k,lpAddress:n,pid:l,isStaked:!0,tvlUsd:E,poolInfo:j,isFarmLive:C})}):null}return B===r.Zs.InfinityCLAMM||B===r.Zs.InfinityBIN?(0,i.jsx)(s.v,{pos:w,chainId:k,showPositionFees:!0,showCollectButton:P}):null})},293173:(e,t,n)=>{"use strict";n.d(t,{n:()=>ek});var i=n(350979),r=n(25963),l=n(501823),o=n(605641),a=n(769932),s=n(680797),d=n(659197),u=n(273523),c=n(428089),p=n(796898),m=n(312680),x=n(995315),h=n(893001),f=n(557423),v=n(769193),y=n(247153),g=n(20897),A=n(670420),b=n(737982),w=n(573271),j=n(671449),k=n(762971),C=n(956586),I=n(208103),S=n(981830),R=n(402861),E=n(344730),M=n(469079),N=n(687287),P=n(459587),T=n(706172),U=n(650176),B=n(323641),D=n(188882),F=n(450253),q=n.n(F),L=n(91168),O=n(734658),_=n(112616),$=n(17581),Y=n(928768),z=n(662928),V=n(721665),Z=n(978300),W=n(437862),H=n(732269),Q=n(487430),G=n(562265),K=n(542160),X=n(810498),J=n(38866),ee=n(228876),et=n(619749),en=n(489886),ei=n(903878),er=n(98378),el=n(710102),eo=n(876579),ea=n(944715),es=n(291249),ed=n(755407);let eu=(0,s.Ay)(c.Ay).withConfig({componentId:"sc-c365dd95-0"})(["padding:16px;border-radius:16px;border:1px solid ",";background:",";"],e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.card.background}),ec=(0,s.Ay)(l.A).withConfig({componentId:"sc-c365dd95-1"})(["justify-content:space-between;align-items:flex-start;margin-bottom:12px;"]),ep=(0,s.Ay)(l.A).withConfig({componentId:"sc-c365dd95-2"})(["flex-direction:column;gap:8px;flex:1;"]),em=(0,s.Ay)(l.A).withConfig({componentId:"sc-c365dd95-3"})(["flex-direction:column;gap:12px;"]),ex=(0,s.Ay)(l.A).withConfig({componentId:"sc-c365dd95-4"})(["justify-content:space-between;align-items:flex-start;flex-wrap:wrap;gap:8px;"]),eh=(0,s.Ay)(l.A).withConfig({componentId:"sc-c365dd95-5"})(["flex-direction:column;gap:2px;align-items:",";"],e=>{let{$align:t}=e;return"right"===t?"flex-end":"center"===t?"center":"flex-start"}),ef=(0,s.Ay)(o.A).withConfig({componentId:"sc-c365dd95-6"})(["font-size:12px;font-weight:600;color:",";text-transform:uppercase;letter-spacing:0.24px;"],e=>{let{theme:t}=e;return t.colors.secondary}),ev=(0,s.Ay)(o.A).withConfig({componentId:"sc-c365dd95-7"})(["font-size:14px;font-weight:600;color:",";"],e=>{let{theme:t}=e;return t.colors.text}),ey=(0,s.Ay)(l.A).withConfig({componentId:"sc-c365dd95-8"})(["flex-direction:column;padding-top:12px;width:100%;"]),eg=(0,s.Ay)(l.A).withConfig({componentId:"sc-c365dd95-9"})(["flex-direction:column;gap:8px;padding-top:12px;"]),eA=e=>{var t,n,l,s,F,K,eA;let{position:ew,poolLength:ej,rowAction:ek,priceRangeDecimalPlaces:eC}=e,{t:eI}=(0,a.A)(),{isMobile:eS,isMd:eR}
16=(0,p.A)(),eE=(0,eo.g7)(ew),eM=(0,ee.fT)(eE),eN=eM&&"poolId"in ew?ew.poolId.toBase58():void 0,eP=(0,en.xk)(eN),[eT,eU]=(0,r.useState)(null),eB=!!(eM&&ew.protocol===d.Zs.V3&&eP&&eP.mintA&&eP.mintB&&"tickLower"in ew&&"tickUpper"in ew),{currency0:eD,currency1:eF,removed:eq,outOfRange:eL,pool:eO,totalPriceUSD:e_,aprButton:e$,hookData:eY,feeTier:ez,feeTierBase:eV,amount0:eZ,amount1:eW,isStaked:eH,isFarmLive:eQ,priceRangeDisplay:eG,earnings:eK,displayBaseCurrency:eX,displayQuoteCurrency:eJ}=function(e){var t,n,l;let{position:o,poolLength:a,priceRangeDecimalPlaces:s}=e,c=(0,eo.g7)(o),p=(0,ee.fT)(c),{address:m}=(0,$.F)(),x=(0,r.useMemo)(()=>{if(o.protocol===d.Zs.InfinityCLAMM||o.protocol===d.Zs.InfinityBIN){if(o.poolKey)return(0,u.Qn)(o.poolKey);if("poolId"in o&&o.poolId)return o.poolId}},[o]),[,h]=(0,I.W)(o.protocol===d.Zs.InfinityCLAMM?x:void 0,c),[,f]=(0,I.W)(o.protocol===d.Zs.InfinityBIN?x:void 0,c),v=(0,W.qX)({poolAddress:o.protocol===d.Zs.InfinityBIN?x:void 0,chainId:o.protocol===d.Zs.InfinityBIN?c:void 0}),y=(0,W.qX)({poolAddress:o.protocol===d.Zs.InfinityCLAMM?x:void 0,chainId:o.protocol===d.Zs.InfinityCLAMM?c:void 0}),g=(0,W.RI)(o.protocol===d.Zs.InfinityCLAMM?o:void 0),b=(0,W.ck)(o.protocol!==d.Zs.V3||p?void 0:o),w=p&&"poolId"in o?o.poolId.toBase58():void 0,j=(0,en.xk)(w),k=(0,r.useMemo)(()=>o.protocol===d.Zs.InfinityCLAMM?(null==y?void 0:y.token0)||g.currency0||(null==h?void 0:h.token0):o.protocol===d.Zs.InfinityBIN?(null==v?void 0:v.token0)||(null==f?void 0:f.token0):b.currency0?b.currency0:p&&(null==j?void 0:j.mintA)?(0,et.ph)(j.mintA):o.protocol===d.Zs.V2&&"pair"in o?(0,A.U$)(o.pair.token0):(o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE)&&"pair"in o?o.pair.token0:void 0,[g.currency0,h,y,f,v,b.currency0,o,p,j]),U=(0,r.useMemo)(()=>o.protocol===d.Zs.InfinityCLAMM?(null==y?void 0:y.token1)||g.currency1||(null==h?void 0:h.token1):o.protocol===d.Zs.InfinityBIN?(null==v?void 0:v.token1)||(null==f?void 0:f.token1):b.currency1?b.currency1:p&&(null==j?void 0:j.mintB)?(0,et.ph)(j.mintB):o.protocol===d.Zs.V2&&"pair"in o?(0,A.U$)(o.pair.token1):(o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE)&&"pair"in o?o.pair.token1:void 0,[g.currency1,h,y,f,v,b.currency1,o,p,j]),F=(0,N.Ae)(k,U),{base:z,quote:V,isFlipped:H}=(0,r.useMemo)(()=>k&&U?(0,Z.SP)(k,U):{base:k,quote:U,isFlipped:!1},[k,U]),G=(0,r.useMemo)(()=>o.protocol===d.Zs.InfinityCLAMM&&!!g.removed||(o.protocol===d.Zs.InfinityBIN?!(o.reserveX&&BigInt(o.reserveX)>0n||o.reserveY&&BigInt(o.reserveY)>0n):!!b.removed||!!p&&"liquidity"in o&&o.liquidity.isZero()),[g.removed,b.removed,p,o]),K=g.outOfRange||b.outOfRange||!1,J=(0,r.useMemo)(()=>o.protocol===d.Zs.InfinityCLAMM||o.protocol===d.Zs.InfinityBIN?x:o.protocol===d.Zs.V3&&!p&&"token0"in o&&"token1"in o&&"fee"in o?(0,W.ji)(c,o.token0,o.token1,o.fee):o.protocol===d.Zs.V2&&"pair"in o?o.pair.liquidityToken.address:(o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE)&&"pair"in o?o.pair.stableSwapAddress:void 0,[o,p,c,x]),el=(0,W.qX)({poolAddress:p?void 0:J,chainId:p?void 0:c}),es=(0,r.useMemo)(()=>{var e;if(p&&k&&U&&j)return{pid:0,nftMint:o.nftMint,lpAddress:void 0,protocol:d.Zs.V3,token0:k,token1:U,feeTier:Math.round(j.feeRate*ei.J),feeTierBase:ei.J,isFarming:null!=(e=j.isFarming)&&e,poolId:o.poolId.toBase58(),liquidity:BigInt(o.liquidity.toString()),chainId:ee.Cb.SOLANA,tvlUsd:j.tvl.toString(),rawPool:j}},[p,k,U,j,o]),eu=(0,r.useMemo)(()=>!p&&o.protocol===d.Zs.V3&&k&&U&&J?el&&el.token0&&el.token1?el:{chainId:c,lpAddress:J,token0:k,token1:U,protocol:d.Zs.V3,feeTier:o.fee,pid:null==el?void 0:el.pid}:void 0,[p,o,k,U,J,c,el]),ec=(0,r.useMemo)(()=>p?es:o.protocol===d.Zs.V3?eu:el,[p,o.protocol,es,eu,el]),ep=(0,C.R4)(c,(0,X.T)(o.protocol)?null==ec?void 0:ec.poolId:void 0),{data:em}=(0,S.C)(o.protocol===d.Zs.InfinityBIN?x:void 0,c,m),ex=p&&o.protocol===d.Zs.V3&&"tickLower"in o&&"tickUpper"in o,{amount0:eh,amount1:ef}=(0,er.y)({poolInfo:ex&&j?j:void 0,tickLower:ex?o.tickLower:0,tickUpper:ex?o.tickUpper:0,liquidity:ex?o.liquidity:void 0}),ev=(0,r.useMemo)(()=>{var e,t,n;return o.protocol===d.Zs.InfinityCLAMM&&g.amount0?g.amount0:o.protocol===d.Zs.InfinityBIN&&(null==f?void 0:f.token0)?O.eF.fromRawAmount(f.token0,null!=(n=null!=(t=null==em?void 0:em.reserveX)?t:o.reserveX)?n:0n):ex&&eh?eh:(null==(e=b.position)?void 0:e.amount0)?b.position.amount0:o.protocol===d.Zs.V2&&"nativeDeposited0"in o||(o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE)&&"nativeDeposited0"in o?o.nativeDeposited0.add(o.farmingDeposited0):void 0},[g.amount0,f,em,ex,eh,null==(t=b.position)?void 0:t.amount0,o]),ey=(0,r.useMemo)(()=>{var e,t,n;return o.protocol===d.Zs.InfinityCLAMM&&g.amount1?g.amount1:o.protocol===d.Zs.InfinityBIN&&(null==f?void 0:f.token1)?O.eF.fromRawAmount(f.token1,null!=(n=null!=(t=null==em?void 0:em.reserveY)?t:o.reserveY)?n:0n):ex&&ef?ef:(null==(e=b.position)?void 0:e.amount1)?b.position.amount1:o.protocol===d.Zs.V2&&"nativeDeposited1"in o||(o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE)&&"nativeDeposited1"in o?o.nativeDeposited1.add(o.farmingDeposited1):void 0},[g.amount1,f,em,ex,ef,null==(n=b.position)?void 0:n.amount1,o]),{data:eg}=(0,M.y)(k,!!k),{data:eA}=(0,M.y)(U,!!U),eb=(0,r.useMemo)(()=>{var e,t;return(0,L.g)(null!=eg?eg:0).times(null!=(e=null==ev?void 0:ev.toExact())?e:0).plus((0,L.g)(null!=eA?eA:0).times(null!=(t=null==ey?void 0:ey.toExact())?t:0)).toNumber()},[eg,eA,ev,ey]),ew=(0,R.fG)({chainId:o.protocol===d.Zs.InfinityCLAMM?c:void 0,tokenId:o.protocol===d.Zs.InfinityCLAMM&&"tokenId"in o?o.tokenId:void 0,poolId:o.protocol===d.Zs.InfinityCLAMM?x:void 0,address:m,timestamp:q()().startOf("hour").unix()}),ej=(0,E.O)({currency0:o.protocol===d.Zs.InfinityCLAMM?k:void 0,currency1:o.protocol===d.Zs.InfinityCLAMM?U:void 0,tokenId:o.protocol===d.Zs.InfinityCLAMM&&"tokenId"in o?o.tokenId:void 0,poolId:o.protocol===d.Zs.InfinityCLAMM?x:void 0,tickLower:o.protocol===d.Zs.InfinityCLAMM&&"tickLower"in o?o.tickLower:void 0,tickUpper:o.protocol===d.Zs.InfinityCLAMM&&"tickUpper"in o?o.tickUpper:void 0,enabled:o.protocol===d.Zs.InfinityCLAMM&&!G}),ek=(0,R.wA)({chainId:o.protocol===d.Zs.InfinityBIN?c:void 0,poolId:o.protocol===d.Zs.InfinityBIN?x:void 0,address:m,timestamp:q()().startOf("hour").unix()}),eC=o.protocol===d.Zs.V3&&!p,eI=(0,r.useMemo)(()=>eC&&"tokenId"in o?[o.tokenId]:[],[eC,o]),eS=(0,B.Ls)(eI,c),eR=eC?null!=(l=b.pool)?l:eu:void 0,[eE,eM]=(0,T.R)(eR,eC&&"tokenId"in o?o.tokenId:void 0,!1,eC&&!G),{data:eN}=(0,P.GB)(k,{enabled:!!(k&&!p&&(o.protocol===d.Zs.V3||(0,X.T)(o.protocol)))}),{data:eP}=(0,P.GB)(U,{enabled:!!(U&&!p&&(o.protocol===d.Zs.V3||(0,X.T)(o.protocol)))}),eT=p&&o.protocol===d.Zs.V3&&"poolId"in o,eU=(0,D.n)({poolInfo:eT&&es?es:void 0,position:eT?o:{}}),eB=(0,r.useMemo)(()=>{var e,t;if(o.protocol===d.Zs.V2||o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE)return null;if(p&&o.protocol===d.Zs.V3){let e=eU.totalPendingYield?eU.totalPendingYield.toNumber():0;return{display:e>0?`~${(0,_.o5)(e)}`:"-"}}if(o.protocol===d.Zs.InfinityCLAMM){let t=ej.feeAmount0?(0,L.g)(ej.feeAmount0.toExact()).toNumber():0,n=ej.feeAmount1?(0,L.g)(ej.feeAmount1.toExact()).toNumber():0,i=t>0&&null!=eN?(0,L.g)(t).times(eN).toNumber():0,r=i+(n>0&&null!=eP?(0,L.g)(n).times(eP).toNumber():0)+((null==(e=ew.data)?void 0:e.rewardsUSD)&&ew.data.rewardsUSD>0?ew.data.rewardsUSD:0);return{display:r>0?`~${(0,_.o5)(r)}`:"$0"}}if(o.protocol===d.Zs.InfinityBIN){let e="number"==typeof(null==(t=ek.data)?void 0:t.rewardsUSD)&&ek.data.rewardsUSD>0?ek.data.rewardsUSD:null;return{display:e?`~${(0,_.o5)(e)}`:"$0"}}if(o.protocol===d.Zs.V3){let e=eE?(0,L.g)(eE.toExact()).toNumber():0,t=eM?(0,L.g)(eM.toExact()).toNumber():0,n=eN&&eE?(0,L.g)(e).times(eN).toNumber():0,i=eP&&eM?(0,L.g)(t).times(eP).toNumber():0,r=(eS.earningsBusd||0)+(n+i);return{display:r>0?`~${(0,_.o5)(r)}`:"$0"}}return null},[o.protocol,p,eU,ew,ej,ek,eS,eE,eM,eN,eP]),eD=(0,r.useMemo)(()=>
16{if(o.protocol===d.Zs.InfinityCLAMM||o.protocol===d.Zs.InfinityBIN)return(0,Y.Pl)({chainId:c,tokenId:"tokenId"in o?Number(o.tokenId):void 0,poolId:J,protocol:o.protocol});if(o.protocol===d.Zs.V3){if(p&&es)return`/liquidity/position/v3/solana/${es.poolId}/${o.nftMint.toBase58()}`;if("tokenId"in o)return`/liquidity/${o.tokenId}`}},[o,J,c,p,es]),eF=null!=ec&&"poolId"in ec&&(ec.protocol===d.Zs.InfinityBIN||ec.protocol===d.Zs.InfinityCLAMM)?ec:null,eq=null!=ec&&(ec.protocol===d.Zs.V2||ec.protocol===d.Zs.STABLE||ec.protocol===d.Zs.InfinitySTABLE)?ec:null,eL=(0,r.useMemo)(()=>ec?o.protocol===d.Zs.V3&&p?(0,i.jsx)(ea.uu,{pool:ec,userPosition:o,textProps:{bold:!0}}):o.protocol===d.Zs.V3?(0,i.jsx)(ea._o,{pool:ec,userPosition:o}):o.protocol===d.Zs.InfinityCLAMM&&eF?(0,i.jsx)(ea.UB,{pool:eF,userPosition:o}):o.protocol===d.Zs.InfinityBIN&&eF?(0,i.jsx)(ea.IV,{pool:eF,userPosition:o}):(o.protocol===d.Zs.V2||o.protocol===d.Zs.STABLE)&&eq?(0,i.jsx)(ea.xo,{pool:eq,userPosition:o}):(0,i.jsx)(ea.rr,{pool:ec}):null,[ec,o,p,eF,eq]),eO=(0,r.useMemo)(()=>"isStaked"in o?o.isStaked:!!p&&null!=j&&!!j.isFarming,[o,p,j]),e_=(0,r.useMemo)(()=>!!p&&null!=j&&!!j.isFarming||!!ec&&"pid"in ec&&void 0!==ec.pid&&(!a||ec.pid<=a),[p,j,ec,a]),e$=(0,r.useMemo)(()=>{if(o.protocol===d.Zs.V2)return ed.p5;if((o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE)&&"pair"in o){var e;return Number(null!=(e=o.pair.stableTotalFee)?e:0)*ed.dg}if(p&&(null==j?void 0:j.feeRate))return Math.round(j.feeRate*ei.J)},[o,p,j]),eY=(0,r.useMemo)(()=>o.protocol===d.Zs.V2||o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE?ed.dg:p?ei.J:void 0,[o.protocol,p]),ez=(0,r.useMemo)(()=>{var e,t,n,i;if(o.protocol===d.Zs.V2||o.protocol===d.Zs.STABLE||o.protocol===d.Zs.InfinitySTABLE||p&&o.protocol===d.Zs.V3)return null;if(o.protocol===d.Zs.InfinityCLAMM){let n=h||g.pool;if(!n||void 0===o.tickLower||void 0===o.tickUpper||!k||!U)return null;let i=(0,Q.Mu)(o.tickSpacing),r=(0,Q.Kc)(o.tickLower,o.tickUpper,i),l=!!((null==k||null==(e=k.wrapped)?void 0:e.address)&&(null==(t=n.token1)?void 0:t.address)&&k.wrapped.address.toLowerCase()===n.token1.address.toLowerCase())!==H;return(0,Q.lN)(o.tickLower,o.tickUpper,k,U,n,r,l,F,s)}if(o.protocol===d.Zs.InfinityBIN){let e=null==f?void 0:f.binStep,t=null==f?void 0:f.activeId;return null!=e&&null!=t&&null!==o.minBinId&&void 0!==o.minBinId&&null!==o.maxBinId&&void 0!==o.maxBinId&&k&&U?(0,Q.Hf)(o.minBinId,o.maxBinId,e,t,k,U,H,F,s):null}if(o.protocol===d.Zs.V3&&!p){let e=b.pool;if(!e||void 0===o.tickLower||void 0===o.tickUpper||!k||!U)return null;let t=(0,Q.jC)(e,o.fee),r=(0,Q.Mu)(t),l=(0,Q.Kc)(o.tickLower,o.tickUpper,r),a=!!((null==k||null==(n=k.wrapped)?void 0:n.address)&&(null==(i=e.token1)?void 0:i.address)&&k.wrapped.address.toLowerCase()===e.token1.address.toLowerCase())!==H;return(0,Q.lN)(o.tickLower,o.tickUpper,null==k?void 0:k.wrapped,null==U?void 0:U.wrapped,e,l,a,F,s)}return null},[o,p,h,g.pool,f,b.pool,k,U,F,H,s]);return{currency0:k,currency1:U,displayBaseCurrency:z,displayQuoteCurrency:V,removed:G,outOfRange:K,pool:ec,totalPriceUSD:eb,aprButton:eL,link:eD,hookData:ep,chainId:c,feeTier:e$,feeTierBase:eY,amount0:ev,amount1:ey,isStaked:eO,isFarmLive:e_,priceRangeDisplay:ez,earnings:eB}}({position:ew,poolLength:ej,priceRangeDecimalPlaces:eC}),e0=ew.protocol===d.Zs.V3&&!eM,e1=(0,W.ck)(e0?ew:void 0),e2=e0?eD:void 0,e6=e0?eF:void 0,[,e8]=(0,U.f$)(null==e2?void 0:e2.wrapped,null==e6?void 0:e6.wrapped,e0&&"fee"in ew?ew.fee:void 0),e3=e0?null!=(t=e1.pool)?t:e8:void 0,{isOpen:e9,setIsOpen:e4,onDismiss:e5}=(0,m.jN)(),[e7,te]=(0,r.useState)("Add"),tt=(0,r.useCallback)(e=>{te(e),e4(!0)},[e4]),tn=eM&&ew.protocol===d.Zs.V3,ti=tn&&eO&&"rawPool"in eO&&eO.rawPool?eO:void 0,{isOpen:tr,onOpen:tl,onDismiss:to}=(0,m.jN)(),ta=(0,r.useMemo)(()=>{if(eB&&eT){var e,t;let n,i,r,l=(null==(e=eT.minPriceFormatted)?void 0:e.includes("NaN"))||"NaN"===eT.minPriceFormatted||"0"!==eT.minPriceFormatted&&"â"!==eT.minPriceFormatted&&Number.isNaN(Number(eT.minPriceFormatted))?"-":eT.minPriceFormatted,o=(null==(t=eT.maxPriceFormatted)?void 0:t.includes("NaN"))||"NaN"===eT.maxPriceFormatted||"0"!==eT.maxPriceFormatted&&"â"!==eT.maxPriceFormatted&&Number.isNaN(Number(eT.maxPriceFormatted))?"-":eT.maxPriceFormatted;if("-"!==l&&"0"!==l){let e=parseFloat(l);Number.isFinite(e)&&!Number.isNaN(e)&&(n=e)}else"0"===l&&(n=0);if("-"!==o&&"â"!==o){let e=parseFloat(o);Number.isFinite(e)&&!Number.isNaN(e)&&(i=e)}if(eT.currentPrice){let e=parseFloat(eT.currentPrice);Number.isFinite(e)&&!Number.isNaN(e)&&(r=e)}if(void 0!==n&&void 0!==i&&"-"!==l&&"0"!==l&&"-"!==o&&"â"!==o&&Number.isFinite(n)&&Number.isFinite(i)&&n>0&&i>0){let e=(0,G.Yr)(n,i,eC);l=e.minFormatted,o=e.maxFormatted}return{...eT,minPriceFormatted:l,maxPriceFormatted:o,minPrice:n,maxPrice:i,currentPriceValue:r}}return eG},[eB,eT,eG,eC]),{data:ts}=(0,z.I)({queryKey:["poolDetailUrl",null==eO?void 0:eO.chainId,null!=(n=null==eO?void 0:eO.lpAddress)?n:null==eO?void 0:eO.poolId,null==eO?void 0:eO.protocol],queryFn:()=>
16{if(eO)return(0,V.VZ)(eO)}});return(0,i.jsxs)(i.Fragment,{children:[eB&&eP&&(0,i.jsx)(eb,{tickLower:ew.tickLower,tickUpper:ew.tickUpper,poolInfo:eP,onDataReady:eU,poolId:eN,pairSymbols:eX&&eJ?`${eX.symbol}/${eJ.symbol}`:void 0}),(0,i.jsxs)(eu,{children:[(0,i.jsx)(ec,{children:(0,i.jsxs)(x.A,{alignItems:"center",gap:"12px",flex:"1",children:[eX&&eJ?(0,i.jsx)(g.hm,{width:40,height:40,variant:"inverted",primaryToken:eX,secondaryToken:eJ,withChainLogo:!0}):null,(0,i.jsxs)(ep,{children:[(0,i.jsx)(x.A,{alignItems:"center",gap:"8px",flexWrap:"wrap",children:eX&&eJ?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(o.A,{bold:!0,fontSize:"16px",children:[eX.symbol," / ",eJ.symbol]}),"tokenId"in ew&&ew.tokenId&&(0,i.jsxs)(o.A,{color:"textSubtle",fontSize:"12px",children:["#",ew.tokenId.toString()]})]}):(0,i.jsxs)(o.A,{color:"textSubtle",fontSize:"16px",children:[eI("Loading"),"..."]})}),(0,i.jsxs)(x.A,{alignItems:"center",gap:"4px",flexWrap:"wrap",children:[(0,X.T)(ew.protocol)?(0,i.jsx)(b.Eu,{poolId:null==eO?void 0:eO.poolId,chainId:eE,hookData:eY,infoIconVisible:!1}):(0,i.jsx)(h.T,{type:ew.protocol,fee:null!=ez?ez:"fee"in ew?ew.fee:0,denominator:null!=eV?eV:"fee"in ew?ed.KF:void 0}),(0,i.jsx)(j.yK,{poolAddress:null==eO?void 0:eO.lpAddress}),(0,i.jsx)(k.f0,{poolAddress:null==eO?void 0:eO.lpAddress}),![d.Zs.V2,d.Zs.STABLE,d.Zs.InfinitySTABLE].includes(ew.protocol)&&(0,i.jsx)(w.K,{lowContrast:!0,removed:eq,outOfRange:eL,protocol:ew.protocol})]})]})]})}),(0,i.jsxs)(em,{mt:"24px",px:"8px",children:[(0,i.jsxs)(ex,{children:[(0,i.jsxs)(eh,{children:[(0,i.jsx)(ef,{children:eI("Liquidity")}),(0,i.jsx)(ev,{children:(0,i.jsx)(v.u,{value:e_,style:{fontSize:"14px",fontWeight:600},showFullDigitsTooltip:!1})})]}),ew.protocol!==d.Zs.V2&&ew.protocol!==d.Zs.STABLE&&ew.protocol!==d.Zs.InfinitySTABLE&&(0,i.jsxs)(eh,{$align:"center",children:[(0,i.jsx)(ef,{children:eI("Earnings")}),(0,i.jsx)(ev,{children:null!=(l=null==eK?void 0:eK.display)?l:"-"})]}),(0,i.jsxs)(eh,{$align:"right",children:[(0,i.jsx)(ef,{children:eI("APR")}),e$]})]}),![d.Zs.V2,d.Zs.STABLE,d.Zs.InfinitySTABLE].includes(ew.protocol)&&!eq&&(0,i.jsxs)(ey,{children:[(0,i.jsx)(ef,{style:{marginBottom:"8px"},children:eI("Price Range")}),ta?(0,i.jsx)(c.Ay,{px:"16px",children:(0,i.jsx)(H.F,{minPrice:ta.minPriceFormatted,maxPrice:ta.maxPriceFormatted,currentPrice:ta.currentPrice,minPercentage:ta.minPercentage,maxPercentage:ta.maxPercentage,rangePosition:ta.rangePosition,outOfRange:eL,removed:eq,showPercentages:ta.showPercentages,maxWidth:"100%",minPriceRaw:ta.minPrice,maxPriceRaw:ta.maxPrice,currentPriceRaw:ta.currentPriceValue})}):(0,i.jsx)(o.A,{fontSize:"12px",color:"textSubtle",children:"-"})]}),(0,i.jsx)(eg,{children:null!=(s=null==ek?void 0:ek(ew))?s:(0,i.jsxs)(i.Fragment,{children:[!eq&&(null==eO?void 0:eO.protocol)&&(!tn||ti)&&(0,i.jsx)(f.A,{width:"100%",onClick:()=>{tn&&ti?tl():tt("Add")},children:eI("Add Liquidity")}),(0,i.jsx)(es.j,{position:ew,pool:eO,chainId:eE,isFarmLive:eQ,isStaked:eH,removed:eq,outOfRange:eL,totalLiquidityUSD:e_,amount0:eZ,amount1:eW,showCollectButton:!0,hideStakeButtons:!0,v3SdkPool:e3}),ts&&(0,i.jsx)(f.A,{variant:"primary60",scale:"md",width:"100%",as:y.Y,to:ts,...!eS&&!eR&&{target:"_blank",rel:"noopener noreferrer"},children:eI("Details")})]})})]})]}),ti&&(0,i.jsx)(el.P,{isOpen:tr,onClose:to,pool:ti,position:ew}),!tn&&(0,i.jsx)(J.B,{isOpen:e9,onDismiss:e5,poolId:null!=(K=null!=(F=null==eO?void 0:eO.poolId)?F:null==eO?void 0:eO.stableSwapAddress)?K:null==eO?void 0:eO.lpAddress,protocol:null==eO?void 0:eO.protocol,chainId:null!=(eA=null==eO?void 0:eO.chainId)?eA:eE,position:ew,presetTab:e7},e7)]})},eb=e=>{let{tickLower:t,tickUpper:n,poolInfo:i,onDataReady:l,poolId:o,pairSymbols:a}=e,s=(0,r.useMemo)(()=>({poolId:o,pairSymbols:a}),[o,a]),d=(0,K.Q)({tickLower:t,tickUpper:n,baseIn:!0,poolInfo:i,debugMeta:s});return(0,r.useEffect)(()=>
16{l(d)},[d,l]),null};var ew=n(612507);let ej=s.Ay.div.withConfig({componentId:"sc-a39f7787-0"})(["display:flex;flex-direction:column;gap:8px;"]),ek=e=>{let{positions:t,poolLengthMap:n,rowAction:r,priceRangeDecimalPlaces:s}=e,{t:d}=(0,a.A)();return t.length?(0,i.jsx)(ej,{children:t.map(e=>{let t=(0,eo.g7)(e),l=(0,ew.V)(e);return(0,i.jsx)(eA,{position:e,poolLength:null==n?void 0:n[t],rowAction:r,priceRangeDecimalPlaces:s},`${t}-${e.protocol}-${l}`)})}):(0,i.jsx)(l.A,{justifyContent:"center",p:"40px",children:(0,i.jsx)(o.A,{color:"textSubtle",children:d("No positions found")})})}},294373:(e,t,n)=>{"use strict";n.d(t,{r:()=>x});var i=n(862373),r=n(25963),l=n(242312),o=n.n(l),a=n(91168),s=n(827666),d=n(735167),u=n(276348),c=n(152497),p=n(644919),m=n(142511);let x=()=>{let e=(0,m.zl)(),{data:t}=(0,p.H)(),{computeBudgetConfig:n}=(0,d.a0)(),[l]=(0,i.at)(),{executeSolanaTransaction:x,handleSolanaError:h}=(0,c.A)();return(0,r.useCallback)(async i=>{var r,d;let{params:c,harvest:p,onSent:m,onError:f,onFinally:v,onConfirmed:y}=i,{poolInfo:g,position:A,liquidity:b,amountA:w,amountB:j,summaryAmountA:k,summaryAmountB:C,closePosition:I}=c;if(!e||!A)return;let[S,R]=[new(o())(new a.A(w).multipliedBy(1e4-l).dividedBy(1e4).multipliedBy(10**g.mintA.decimals).toFixed(0)),new(o())(new a.A(j).multipliedBy(1e4-l).dividedBy(1e4).multipliedBy(10**g.mintB.decimals).toFixed(0))],E="boolean"==typeof I?I:A.liquidity.eq(b),{fee:M=new(o())(0)}=(0,s._6H)(S,null==(r=g.mintA.extensions)?void 0:r.feeConfig,t,!1),{fee:N=new(o())(0)}=(0,s._6H)(R,null==(d=g.mintB.extensions)?void 0:d.feeConfig,t,!1),{execute:P}=await e.clmm.decreaseLiquidity({poolInfo:g,poolKeys:e.clmm.getClmmKeysFromPoolInfo(g),ownerPosition:A,ownerInfo:{useSOLBalance:!0,closePosition:!(p||!E)},liquidity:b,amountMinA:S.sub(M),amountMinB:R.sub(N),computeBudgetConfig:n,txVersion:s.HqF.V0});return x(async()=>{try{let{txId:e,signedTx:t}=await P();return null==m||m(e),{hash:e}}catch(e){return h(e),null==f||f(e),{hash:""}}finally{null==v||v()}},()=>{let e=String(null!=k?k:w),t=String(null!=C?C:j),n=(0,u.U)(e),i=(0,u.U)(t);return{summary:`${p?"Harvest":E?"Remove and close":"Remove"} ${n} ${g.mintA.symbol} and ${i} ${g.mintB.symbol}`,type:p?"harvest":"remove-liquidity-v3",translatableSummary:{text:p?"Harvest %amountA% %tokenASymbol% and %amountB% %tokenBSymbol%":E?"Remove %amountA% %tokenASymbol% and %amountB% %tokenBSymbol% and close position":"Remove %amountA% %tokenASymbol% and %amountB% %tokenBSymbol%",data:{amountA:n,tokenASymbol:g.mintA.symbol,amountB:i,tokenBSymbol:g.mintB.symbol,amountARaw:e,amountBRaw:t}}}})},[e,n,x,h,l,t])}},298491:(e,t,n)=>{var i=n(496546),r=n(491978),l=n(184837);e.exports=function(e){return e&&e.length?i(e,l,r):void 0}},302075:(e,t,n)=>{"use strict";n.d(t,{Io:()=>Q,Rz:()=>X,nh:()=>et,Cu:()=>ee});var i=n(228876),r=n(466020),l=n(543337),o=n(659197),a=n(421479),s=n(495659),d=n(740523),u=n(408447),c=n(988998),p=n(3197),m=n(673384),x=n(662928),h=n(126294),f=n(91168),v=n(529208),y=n(833438),g=n(968349),A=n(885334),b=n(555967),w=n(341050),j=n(362140),k=n.n(j),C=n(477979),I=n.n(C),S=n(25963),R=n(733775),E=n(736134),M=n(792118),N=n(18468),P=n(17581),T=n(555242),U=n(660876),B=n(851374),D=n(300107),F=n.n(D),q=n(207014);let L=(e,t,n)=>`${e}:${t}:${n}`,O=[i.nU.ZKSYNC_TESTNET,i.nU.ZKSYNC],_=[{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}],$=async(e,t,n)=>{let i,r=e.map(e=>({address:e.positionManagerAddress,abi:_,functionName:"ownerOf",args:[e.tokenId]}));try{i=await t.multicall({contracts:r,allowFailure:!0,multicallAddress:n})}catch{return null}let l=new Set;return e.forEach((e,t)=>{let n=i[t];if("success"!==n.status)return;let r=n.result;(0,R.ho)(r,e.masterchefAddress)&&l.add(e.tokenId.toString())}),l},Y=async(e,t,n,i)=>{let r=e.map(e=>({address:e.masterchefAddress,abi:e.abi,functionName:"pendingCake",args:[e.tokenId]})),l=await n.multicall({contracts:r,allowFailure:!0,multicallAddress:i});return e.reduce((e,n,i)=>{let r=l[i],o="success"===r.status,a=o?r.result:0n;return e[L(t,n.account,n.tokenId)]={success:o,amount:a},e},{})},z=async(e,t,n)=>{if(!e.length)return{};let{account:i,abi:r,masterchefAddress:l}=e[0],o=e.map(e=>(0,U.p)({abi:e.abi,functionName:"harvest",args:[e.tokenId,e.account]})),a={};try{let{result:s}=await n.simulateContract({address:l,abi:r,functionName:"multicall",args:[o],account:i});
16s.forEach((n,i)=>{let r=e[i],l=L(t,r.account,r.tokenId);try{let e=(0,B.e)({abi:r.abi,functionName:"harvest",data:n});a[l]={success:!0,amount:e}}catch{a[l]={success:!1,amount:0n}}})}catch{e.forEach(e=>{a[L(t,e.account,e.tokenId)]={success:!1,amount:0n}})}return a},V=async(e,t,n)=>{let i=O.includes(t);return(await Promise.all(e.map(async e=>{let r=(0,U.p)({abi:e.abi,functionName:i?"pendingCake":"harvest",args:i?[e.tokenId]:[e.tokenId,e.account]});try{let{result:l}=await n.simulateContract({address:e.masterchefAddress,abi:e.abi,functionName:"multicall",args:[[r]],account:e.account}),o=(0,B.e)({abi:e.abi,functionName:i?"pendingCake":"harvest",data:l[0]});return{key:L(t,e.account,e.tokenId),value:{success:!0,amount:o}}}catch{return{key:L(t,e.account,e.tokenId),value:{success:!1,amount:0n}}}}))).reduce((e,t)=>(e[t.key]=t.value,e),{})},Z=async(e,t)=>{let n=(0,N.Rt)({chainId:t}),i=(0,q.kb)(t);if(!n||!e.length)return{};if(!i)return V(e,t,n);let r=await $(e,n,i);if(!r)return V(e,t,n);let l=e.filter(e=>r.has(e.tokenId.toString())),o=e.filter(e=>!r.has(e.tokenId.toString())).reduce((e,n)=>(e[L(t,n.account,n.tokenId)]={success:!1,amount:0n},e),{});if(!l.length)return o;let a=O.includes(t)?await Y(l,t,n,i):await z(l,t,n);return{...o,...a}},W=async e=>{let t=F()(e,e=>`${e.chainId}:${e.masterchefAddress}:${e.account}:${e.positionManagerAddress}`);return(await Promise.all(Object.values(t).map(e=>Z(e,e[0].chainId)))).reduce((e,t)=>Object.assign(e,t),{})},H=(0,T.vt)({fetcher:W,resolver:(e,t)=>e[L(t.chainId,t.account,t.tokenId)],scheduler:(0,T.On)({windowMs:60,maxBatchSize:25})}),Q=e=>fetch(`/api/v3/${e}/farms`).then(e=>e.json()).then(t=>{let n=t.farmsWithPrice.map(e=>({...e,token:(0,p.t6)(e.token),quoteToken:(0,p.t6)(e.quoteToken)}));return{chainId:e,...t,farmsWithPrice:n}}),G={chainId:i.nU.BSC,farmsWithPrice:[],poolLength:0,cakePerSecond:"0",totalAllocPoint:"0"},K=(0,r.VD)(M.Qr),X=function(){var e;let t=!(arguments.length>0)||void 0===arguments[0]||arguments[0],{chainId:n}=(0,g.ax)(),i=(0,x.I)({queryKey:[n,"farmV3ApiFetch"],queryFn:async()=>{try{let e=await (0,l.v)(n,o.Zs.V3),t=(0,a.b)(e),i=await (0,c.ej)(d.Ij[null!=n?n:-1]),r=await K.fetchFarms({chainId:null!=n?n:-1,farms:t,commonPrice:i});return{...r,farmsWithPrice:r.farmsWithPrice.map(e=>{let t=(0,R.QR)(e.lpAddress);return t?{...e,lpAddress:t}:void 0}).filter(e=>!!e)}}catch(e){return console.error(e),G}},refetchInterval:6e5,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,enabled:t&&!!K.isChainSupported(null!=n?n:-1)});return{...i,data:null!=(e=null==i?void 0:i.data)?e:G}},J=function(){var e,t,n;let{mockApr:i=!1,boosterLiquidityX:r={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{chainId:l}=(0,g.ax)(),o=X(),a=(0,A.T)(),{data:d}=(0,x.I)({queryKey:[l,"cake-apr-tvl",r],queryFn:async e=>{var t;let{signal:n}=e;if(l!==(null==o||null==(t=o.data)?void 0:t.chainId))throw Error("ChainId mismatch");let d={};if(s.GO.includes(l)){let e=o.data.farmsWithPrice.filter(e=>"0"!==e.poolWeight),t=k()(e.map(e=>e.lpAddress),10);(await Promise.allSettled(t.map((e,t)=>(0,E.A)(`${y.Ch}/v3/${l}/liquidity?page=${t+1}&size=10`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({farmAddresses:e}),signal:n}).then(e=>e.json()).catch(e=>{throw console.error(e),e})))).forEach(e=>{"fulfilled"===e.status&&e.value.data.forEach(e=>{let t=(0,R.QR)(e.farmAddress);t&&(d[t]={...e.formatted,updatedAt:new Date})})})}let u=o.data.farmsWithPrice.map(e=>{var t,n,l;if(!d[e.lpAddress])return e;let s=d[e.lpAddress];if(i&&(null==s?void 0:s.token0)==="0"&&(null==s?void 0:s.token1)==="0"){let[t,n]=e.token.sortsBefore(e.quoteToken)?[e.tokenPriceBusd,e.quoteTokenPriceBusd]:[e.quoteTokenPriceBusd,e.tokenPriceBusd];s.token0=t?String(1/Number(t)):"1",s.token1=n?String(1/Number(n)):"1"}let{activeTvlUSD:u,activeTvlUSDUpdatedAt:c,cakeApr:p}=K.getCakeAprAndTVL(e,s,a.toString(),null!=(n=null==(t=o.data)?void 0:t.cakePerSecond)?n:"1",null!=(l=null==r?void 0:r[e.pid])?l:1);return{...e,cakeApr:p,activeTvlUSD:u,activeTvlUSDUpdatedAt:c}});return{...o.data,farmsWithPrice:u}},enabled:!!((null==o||null==(e=o.data)?void 0:e.farmsWithPrice)&&(null==o||null==(n=o.data)||null==(t=n.farmsWithPrice)?void 0:t.length)>0),placeholderData:(e,t)=>{let n=null==t?void 0:t.queryKey;if(n&&n[0]===l)return e},refetchInterval:3*v.fr,staleTime:3*v.fr});return{data:(0,S.useMemo)(()=>{var e;return o.isLoading||(null==(e=o.data)?void 0:e.chainId)!==l||(null==d?void 0:d.chainId)!==l?o.data:null!=d?d:o.data},[l,d,o.data,o.isLoading]),isLoading:o.isLoading,error:o.error}},ee=(e,t)=>
16{let{address:n}=(0,P.F)(),{chainId:i}=(0,g.ax)(),r=null!=t?t:i,l=(0,b.p6)(r),o=(0,b.TA)({chainId:r}),a=(0,S.useMemo)(()=>e.map(e=>e.toString()).join(","),[e]),{data:d}=(0,x.I)({queryKey:["mcv3-harvest",r,n,a],queryFn:async()=>(null==l?void 0:l.abi)&&n&&r&&s.GO.includes(r)&&o?(await Promise.all(e.map(e=>H.fetch({tokenId:e,account:n,chainId:r,masterchefAddress:l.address,positionManagerAddress:o.address,abi:l.abi})))).map(e=>null!=e?e:{success:!1,amount:0n}):[],enabled:!!(n&&r&&e.length),placeholderData:h.rX});return{tokenIdResults:(0,S.useMemo)(()=>{var e;return null!=(e=null==d?void 0:d.map(e=>e.amount))?e:[]},[d]),isLoading:e.length>0&&!d}};function et(){var e,t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{data:i}=ei(),{data:r,isLoading:l}=J({...n,boosterLiquidityX:i}),{data:o}=en(null==r||null==(e=r.farmsWithPrice)?void 0:e.map(e=>e.pid));return{...(e=>{let{address:t}=(0,P.F)(),n=(0,b.TA)(),i=(0,b.rZ)(),r=!!((null==i?void 0:i.address)&&(null==i?void 0:i.address)!=="0x"),{tokenIds:l}=(0,w.s2)(r?null==i?void 0:i.address:void 0,t),o=(0,S.useMemo)(()=>l||[],[l]),{tokenIds:a}=(0,w.s2)(null==n?void 0:n.address,t),s=(0,S.useMemo)(()=>[...o,...a],[o,a]),{positions:d}=(0,w.Gg)(s),{tokenIdResults:u,isLoading:c}=ee(o),[p,m]=(0,S.useMemo)(()=>d?[a.filter(e=>!o.find(t=>t===e)).map(e=>d.find(t=>t.tokenId===e)).filter(e=>{var t;return(null!=(t=null==e?void 0:e.liquidity)?t:0n)>0n}),o.map(e=>d.find(t=>t.tokenId===e)).filter(e=>{var t;return(null!=(t=null==e?void 0:e.liquidity)?t:0n)>0n})]:[[],[]],[d,o,a]),x=(0,S.useMemo)(()=>{var e;return null!=(e=null==u?void 0:u.reduce((e,t,n)=>{let i=m[n];return t&&(null==i?void 0:i.tokenId)?{...e,[i.tokenId.toString()]:t}:e},{}))?e:{}},[m,u]);return{farmsWithPositions:(0,S.useMemo)(()=>e.map(e=>{let{feeAmount:t,token0:n,token1:i}=e,r=p.filter(e=>I()(null==e?void 0:e.token0)===I()(n.address)&&I()(null==e?void 0:e.token1)===I()(i.address)&&t===(null==e?void 0:e.fee)),l=m.filter(e=>I()(null==e?void 0:e.token0)===I()(n.address)&&I()(null==e?void 0:e.token1)===I()(i.address)&&t===(null==e?void 0:e.fee));return{...e,unstakedPositions:r,stakedPositions:l,pendingCakeByTokenIds:Object.entries(x).reduce((e,t)=>{let[n,i]=t;return l.find(e=>(null==e?void 0:e.tokenId)===BigInt(n))?{...e,[n]:i}:e},{})}}),[e,x,m,p]),userDataLoaded:!c}})(null==(t=r.farmsWithPrice)?void 0:t.map((e,t)=>{var n;return{...e,boosted:null==o||null==(n=o[t])?void 0:n.boosted}})),poolLength:r.poolLength,cakePerSecond:r.cakePerSecond,isLoading:l}}let en=e=>{let{chainId:t}=(0,g.ax)(),n=(0,b.HN)(),{data:i}=(0,x.I)({queryKey:["v3/boostedFarm",t,null==e?void 0:e.join("-")],queryFn:()=>er({farmBoosterContract:n,chainId:null!=t?t:-1,pids:null!=e?e:[]}),enabled:!!(t&&e&&e.length>0&&s.Ts.includes(t)),retry:3,retryDelay:3e3});return{data:i}},ei=()=>{var e;let t=X(),n=(0,S.useMemo)(()=>{var e,n;return null==t||null==(n=t.data)||null==(e=n.farmsWithPrice)?void 0:e.map(e=>e.pid)},[null==t||null==(e=t.data)?void 0:e.farmsWithPrice]),{chainId:i}=(0,g.ax)(),r=(0,b.rZ)(),{data:l}=(0,x.I)({queryKey:["v3/getV3BoosterAPRLiquidityX",i,null==n?void 0:n.join("-")],queryFn:()=>el({masterChefV3Contract:r,chainId:null!=i?i:-1,pids:null!=n?n:[]}),enabled:!!(i&&n&&n.length>0&&s.Ts.includes(i))});return(0,S.useMemo)(()=>{let e=null==l?void 0:l.reduce((e,t)=>(e[t.pid]=Number.isNaN(t.boosterliquidityX)?1:t.boosterliquidityX,e),{});return{data:null!=e?e:{}}},[l])};async function er(e){let{farmBoosterContract:t,chainId:n,pids:i}=e,r=null==i?void 0:i.map(e=>({address:t.address,functionName:"whiteList",abi:u.C,args:[BigInt(e)]})),l=await (0,N.Rt)({chainId:n}).multicall({contracts:r});return l&&(null==l?void 0:l.length)===(null==i?void 0:i.length)?null==i?void 0:i.map((e,t)=>{var n;return{pid:e,boosted:null!=(n=l[t].result)&&n}}):[]}async function el(e){let{masterChefV3Contract:t,chainId:n,pids:i}=e,r=null==i?void 0:i.map(e=>{var n;return{address:null!=(n=null==t?void 0:t.address)?n:"0x",functionName:"poolInfo",abi:m.aT,args:[BigInt(e)]}}),l=await (0,N.Rt)({chainId:n}).multicall({contracts:r});return l&&(null==l?void 0:l.length)===(null==i?void 0:i.length)?null==i?void 0:i.map((e,t)=>{var n,i,r,o,a,s,d,u,c;return{pid:e,boosterliquidityX:null!=(c=new f.A(null!=(d=null==l||null==(r=l[t])||null==(i=r.result)||null==(n=i[6])?void 0:n.toString())?d:1).div(null!=(u=null==l||null==(s=l[t])||null==(a=s.result)||null==(o=a[5])?void 0:o.toString())?u:1).toNumber())?c:1}}):[]}},305791:(e,t,n)=>{"use strict";n.d(t,{a:()=>f,s:()=>h});var i=n(311560),r=n(859886),l=n(687287),o=n(656302),a=n(25963),s=n(452301),d=n(769932),u=n(608135),c=n(968349),p=n(954219),m=n(569019),x=n(696368);function h(e,t){let n,{account:h,chainId:f}=(0,c.W7)(),{independentField:v,typedValue:y}
16=(0,p.lD)(),{t:g}=(0,d.A)(),[,A]=(0,r.ek)(e,t),[b]=(0,m.Tz)(null!=h?h:void 0,(0,a.useMemo)(()=>[null==A?void 0:A.liquidityToken],[null==A?void 0:A.liquidityToken])),w=(null==A?void 0:A.liquidityToken)?null==b?void 0:b[`${A.liquidityToken.chainId}-${A.liquidityToken.address}`]:void 0,j=(0,o.A)(null==A?void 0:A.liquidityToken),[k,C]=[(0,s.dc)(e,f),(0,s.dc)(t,f)],I={[x.D.CURRENCY_A]:k,[x.D.CURRENCY_B]:C,[x.D.LIQUIDITY]:null==A?void 0:A.liquidityToken},S=A&&j&&w&&k&&j.quotient>=w.quotient?i.eF.fromRawAmount(k,A.getLiquidityValue(k,j,w,!1).quotient):void 0,R=A&&j&&w&&C&&j.quotient>=w.quotient?i.eF.fromRawAmount(C,A.getLiquidityValue(C,j,w,!1).quotient):void 0,E={[x.D.CURRENCY_A]:S,[x.D.CURRENCY_B]:R},M=v===x.D.LIQUIDITY?void 0:I[v],N=(0,l.dm)(y,M),P=new i.QE("0","100");if(v===x.D.LIQUIDITY_PERCENT)P=new i.QE(y,"100");else if(v===x.D.LIQUIDITY){if(null==A?void 0:A.liquidityToken){let e=(0,u.A)(y,A.liquidityToken);e&&w&&!e.greaterThan(w)&&(P=new i.QE(e.quotient,w.quotient))}}else if(I[v]){let e=E[v];N&&e&&!N.greaterThan(e)&&(P=new i.QE(N.quotient,e.quotient))}let T=w&&P&&P.greaterThan("0")?i.eF.fromRawAmount(w.currency,P.multiply(w.quotient).quotient):void 0,U=k&&P&&P.greaterThan("0")&&S?i.eF.fromRawAmount(k,P.multiply(S.quotient).quotient):void 0,B=C&&P&&P.greaterThan("0")&&R?i.eF.fromRawAmount(C,P.multiply(R.quotient).quotient):void 0,D={[x.D.LIQUIDITY_PERCENT]:P,[x.D.LIQUIDITY]:T,[x.D.CURRENCY_A]:U,[x.D.CURRENCY_B]:B};return h||(n=g("Connect Wallet")),D[x.D.LIQUIDITY]&&D[x.D.CURRENCY_A]&&D[x.D.CURRENCY_B]||(n=null!=n?n:g("Enter an amount")),{pair:A,parsedAmounts:D,error:n}}function f(){let e=(0,p.qK)();return{onUserInput:(0,a.useCallback)((t,n)=>{e((0,x.$)({field:t,typedValue:n}))},[e])}}},312531:(e,t,n)=>{var i=n(224813);e.exports=function(e,t,n){var r=e.length;return n=void 0===n?r:n,!t&&n>=r?e:i(e,t,n)}},323641:(e,t,n)=>{"use strict";n.d(t,{Ls:()=>m,_L:()=>p,p$:()=>x});var i=n(378385),r=n(91168),l=n(885334),o=n(25963),a=n(302075),s=n(437862),d=n(776808),u=n(660430),c=n(17581);let p=e=>{let{address:t}=(0,c.F)(),n=(0,l.T)(),{chainId:a,lpAddress:s}=e||{},{data:u,isLoading:p}=(0,d.f)(t,{chainId:a,lpAddress:s,bCakeWrapperAddress:null==e?void 0:e.bCakeWrapperAddress}),m=(0,o.useMemo)(()=>BigInt(null!=u?u:0),[u]),x=(0,o.useMemo)(()=>+(0,i.x4)(m,5),[m]),h=(0,o.useMemo)(()=>new r.A(null!=x?x:0).times(n.toString()).toNumber(),[n,x]);return{earningsAmount:x,earningsBusd:h,hasEarnings:m>0n,isLoading:p}},m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,n=(0,l.T)({enabled:e.length>0}),{tokenIdResults:s,isLoading:d}=(0,a.Cu)(e,t),u=(0,o.useMemo)(()=>s.reduce(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0n;return e+t},0n),[s]),c=(0,o.useMemo)(()=>new r.A(u.toString()).times(n.toString()).div(1e18).toNumber(),[n,u]);return(0,o.useMemo)(()=>({earningsAmount:+(0,i.x4)(u,5),earningsBusd:c,hasEarnings:u>0n,isLoading:d}),[u,c,d])},x=e=>{var t,n;let i=(0,u.Vx)(),{address:r}=(0,c.F)(),{data:l,isLoading:a}=(0,s.mP)(null!=(t=null==e?void 0:e.chainId)?t:i,r,null!=e?e:void 0),{earningsBusd:d,earningsAmount:p,hasEarnings:x}=m((0,o.useMemo)(()=>(null==l?void 0:l.length)?l.filter(e=>e.isStaked).map(e=>e.tokenId).filter(Boolean):[],[l]),null!=(n=null==e?void 0:e.chainId)?n:i);return{earningsBusd:d,earningsAmount:p,hasEarnings:x,isLoading:a}}},334337:(e,t,n)=>{"use strict";n.d(t,{y:()=>M});var i=n(350979),r=n(769932);n(25963);var l=n(680797),o=n(88748),a=n(253365),s=n(36195),d=n(205357);let u={wide:{height:123,gap:8,cardGap:0,showFee:!1,padding:"12px 16px",fade:69,hug:!1},compact:{height:91,gap:8,cardGap:4,showFee:!1,padding:"11px 11px 10px",fade:109,hug:!0}},c=l.Ay.div.withConfig({componentId:"sc-8708f254-0"})(["display:flex;flex-direction:column;align-items:flex-start;gap:8px;width:100%;font-family:'Kanit',sans-serif;"]),p=l.Ay.span.withConfig({componentId:"sc-8708f254-1"})(["position:relative;display:inline-flex;align-items:center;font-size:12px;font-weight:600;line-height:1.5;letter-spacing:0.24px;text-transform:uppercase;white-space:nowrap;cursor:help;color:",";font-feature-settings:'liga' off;&::after{content:'';position:absolute;right:0;bottom:0;left:0;border-bottom:1px dashed ",";opacity:0.6;}"],e=>{let{theme:t}=e;return t.colors.secondary},e=>{let{theme:t}=e;return t.colors.textSubtle}),m=l.Ay.div.withConfig({componentId:"sc-8708f254-2"})(["display:flex;flex-direction:column;gap:4px;"]),x=l.Ay.div.withConfig({componentId:"sc-8708f254-3"})(["position:relative;width:100%;height:","px;"],e=>{let{$height:t}=e;return t}),h=l.Ay.div.withConfig({componentId:"sc-8708f254-4"})(["width:100%;height:100%;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;-ms-overflow-style:none;cursor:",";-webkit-mask-image:",";mask-image:",";&::-webkit-scrollbar{display:none;}"],e=>{let{$dragging:t}=e;return t?"grabbing":"grab"},e=>{let{$mask:t}=e;return t},e=>{let{$mask:t}=e;return t}),f=l.Ay.div.withConfig({componentId:"sc-8708f254-5"}
16)(["height:100%;gap:","px;",""],e=>{let{$gap:t}=e;return t},e=>{let{$equal:t}=e;return t?` 17 display: grid; 18 grid-auto-flow: column; 19 grid-auto-columns: 1fr; 20 width: max-content; 21 `:` 22 display: flex; 23 align-items: stretch; 24 `}),v=l.Ay.button.withConfig({componentId:"sc-8708f254-6"})(["display:flex;flex-direction:column;align-items:flex-start;gap:","px;flex:none;width:",";min-width:150px;height:100%;box-sizing:border-box;padding:",";overflow:hidden;border:1px solid ",";border-bottom-width:2px;border-radius:24px;background:",";font-family:inherit;text-align:left;cursor:",";"],e=>{let{$gap:t}=e;return t},e=>{let{$hug:t}=e;return t?"auto":"150px"},e=>{let{$padding:t}=e;return t},e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.card},e=>{let{onClick:t}=e;return t?"pointer":"default"}),y=l.Ay.div.withConfig({componentId:"sc-8708f254-7"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:4px;"]),g=l.Ay.div.withConfig({componentId:"sc-8708f254-8"})(["display:flex;align-items:center;gap:8px;"]),A=l.Ay.span.withConfig({componentId:"sc-8708f254-9"})(["display:inline-flex;align-items:center;> span{position:relative;display:inline-flex;flex:none;border-radius:50%;&::after{content:'';position:absolute;inset:0;border:0.6px solid ",";border-radius:50%;opacity:0.1;pointer-events:none;}}> span:first-child{z-index:1;margin-right:-8px;}"],e=>{let{theme:t}=e;return t.colors.contrast}),b=l.Ay.span.withConfig({componentId:"sc-8708f254-10"})(["display:inline-flex;align-items:center;flex:none;> span{position:relative;display:inline-flex;flex:none;border-radius:50%;&::after{content:'';position:absolute;inset:0;border:0.6px solid ",";border-radius:50%;opacity:0.1;pointer-events:none;}}> span:first-child{z-index:1;margin-right:-8px;}"],e=>{let{theme:t}=e;return t.colors.contrast}),w=l.Ay.span.withConfig({componentId:"sc-8708f254-11"})(["font-size:16px;font-weight:600;line-height:1.5;white-space:nowrap;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.text}),j=l.Ay.span.withConfig({componentId:"sc-8708f254-12"})(["display:inline-flex;align-items:center;justify-content:center;gap:4px;flex:none;padding:2px 8px 1px;border-radius:999px;background:",";font-size:14px;font-weight:400;line-height:1.5;white-space:nowrap;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.tertiary},e=>{let{theme:t}=e;return t.colors.textSubtle}),k=l.Ay.span.withConfig({componentId:"sc-8708f254-13"})(["opacity:0.5;font-weight:200;"]),C=l.Ay.div.withConfig({componentId:"sc-8708f254-14"})(["display:flex;align-items:center;white-space:nowrap;",""],e=>{let{$hug:t}=e;return t?` 25 gap: 28px; 26 `:` 27 justify-content: space-between; 28 width: 100%; 29 `}),I=l.Ay.div.withConfig({componentId:"sc-8708f254-15"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:center;"]),S=l.Ay.span.withConfig({componentId:"sc-8708f254-16"})(["font-size:12px;font-weight:400;line-height:1.5;letter-spacing:0.12px;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),R=l.Ay.span.withConfig({componentId:"sc-8708f254-17"})(["margin-top:-3px;font-size:16px;font-weight:600;line-height:1.5;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.positive60}),E=l.Ay.span.withConfig({componentId:"sc-8708f254-18"})(["font-size:14px;font-weight:600;line-height:1.5;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.text}),M=e=>{let{picks:t,variant:n="wide",label:l,feeLabel:M="Fee",aprLabel:N="APR",tvlLabel:P="TVL",className:T}=e,{t:U}=(0,r.A)(),B=u[n],{ref:D,edges:F}=(0,o.pG)(t),{dragging:q,didDrag:L,handlers:O}=(0,o.S$)(D),{targetRef:_,tooltip:$}=(0,a.fS)((0,i.jsxs)(m,{children:[(0,i.jsx)("span",{children:U("Pancake Picks are trending tokens from selected categories, filtered by meaningful metrics, and refreshed every weekday.")}),(0,i.jsx)(s.e9,{href:"https://docs.pancakeswap.finance/products/pancake-picks",children:U("More Information")})]}),{placement:"bottom-start",hideTimeout:300});return 0===t.length?null:(0,i.jsxs)(c,{className:T,children:[l&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(p,{ref:_,children:l}),$]}),(0,i.jsx)(x,{$height:B.height,children:(0,i.jsx)(h,{ref:D,$dragging:q,$mask:((e,t,n)=>{if(!e&&!t)return"none";let i=e?`transparent 0, #000 ${n}px`:"#000 0",r=t?`#000 calc(100% - ${n}px), transparent 100%`:"#000 100%";return`linear-gradient(to right, ${i}, ${r})`})(F.left,F.right,B.fade),...O,children:(0,i.jsx)(f,{$gap:B.gap,$equal:B.hug,children:t.map(e=>{var t,r,l,o;return(0,i.jsxs)(v,{type:"button",$padding:B.padding,$hug:B.hug,$gap:B.cardGap,onClick:e.onClick&&(()=>{var t;L()||null==(t=e.onClick)||t.call(e)}),children:[(0,i.jsxs)(y,{children:["wide"===n?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(A,{"aria-hidden":!0,
29children:[(0,i.jsx)("span",{children:(0,i.jsx)(d.xz,{symbol:e.symbols[0],src:null==(t=e.logoUrls)?void 0:t[0],size:32})}),(0,i.jsx)("span",{children:(0,i.jsx)(d.xz,{symbol:e.symbols[1],src:null==(r=e.logoUrls)?void 0:r[1],size:32})})]}),(0,i.jsx)(w,{children:e.pair})]}):(0,i.jsxs)(g,{children:[(0,i.jsxs)(b,{"aria-hidden":!0,children:[(0,i.jsx)("span",{children:(0,i.jsx)(d.xz,{symbol:e.symbols[0],src:null==(l=e.logoUrls)?void 0:l[0],size:24})}),(0,i.jsx)("span",{children:(0,i.jsx)(d.xz,{symbol:e.symbols[1],src:null==(o=e.logoUrls)?void 0:o[1],size:24})})]}),(0,i.jsx)(w,{children:e.pair})]}),B.showFee?(0,i.jsxs)(j,{children:[M,(0,i.jsx)(k,{"aria-hidden":!0,children:"|"}),e.fee]}):null]}),(0,i.jsxs)(C,{$hug:B.hug,children:[(0,i.jsxs)(I,{children:[(0,i.jsx)(S,{children:N}),(0,i.jsx)(R,{children:e.apr})]}),(0,i.jsxs)(I,{children:[(0,i.jsx)(S,{children:P}),(0,i.jsx)(E,{children:e.tvl})]})]})]},e.id)})})})})]})}},337049:(e,t,n)=>{"use strict";n.d(t,{t:()=>o});var i=n(25963),r=n(630806),l=n(955647);let o=e=>{let{parsedAmountA:t,parsedAmountB:n}=e,o=null==t?void 0:t.currency,a=null==n?void 0:n.currency,s=(0,r.h1)(o,Number((0,l.ej)(t,18)),{enabled:!!o}),d=(0,r.h1)(a,Number((0,l.ej)(n,18)),{enabled:!!a});return{totalUsdValue:(0,i.useMemo)(()=>{let e=(null!=s?s:0)+(null!=d?d:0);return Number.isNaN(e)?0:e},[s,d])}}},341050:(e,t,n)=>{"use strict";n.d(t,{Cq:()=>c,Gg:()=>u,J2:()=>m,s2:()=>p});var i=n(659197),r=n(673384),l=n(968349),o=n(555967),a=n(782739),s=n(530957),d=n(25963);function u(e){let t=(0,o.TA)(),{chainId:n}=(0,l.ax)(),i=(0,d.useMemo)(()=>void 0===e?[]:Array.isArray(e)?e:[e],[e]),r=(0,d.useMemo)(()=>i.length>0&&t?i.map(e=>({abi:t.abi,address:t.address,functionName:"positions",args:[e],chainId:n})):[],[n,t,i]),{isLoading:u,data:c}=(0,a.XO)({contracts:r,allowFailure:!0,query:{enabled:!!r.length},watch:!0});return{loading:u,positions:(0,d.useMemo)(()=>c&&r?r.map((e,t)=>{let n=c[t];if(!n||"success"!==n.status||!n.result)return;let i=n.result;return{nonce:i[0],operator:i[1],token0:i[2],token1:i[3],fee:i[4],tickLower:i[5],tickUpper:i[6],liquidity:i[7],feeGrowthInside0LastX128:i[8],feeGrowthInside1LastX128:i[9],tokensOwed0:i[10],tokensOwed1:i[11],tokenId:e.args[0]}}).filter(e=>!!e&&!Object.values(e).some(s.A)):[],[r,c])}}function c(e){let t=u(e);return(0,d.useMemo)(()=>{var e;return{loading:t.loading,position:null==(e=t.positions)?void 0:e[0]}},[t.loading,t.positions])}function p(e,t,n){let{chainId:i}=(0,l.ax)(),o=null!=n?n:i,{isLoading:s,data:u,refetch:c}=(0,a.Qo)({abi:r.aT,address:e,query:{enabled:!!t&&!!e},args:[t],functionName:"balanceOf",chainId:o,watch:!0}),p=(0,d.useMemo)(()=>{if(u&&t){let n=[];for(let i=0;i<u;i++)n.push({abi:r.aT,address:e,functionName:"tokenOfOwnerByIndex",args:[t,i],chainId:o});return n}return[]},[t,u,o,e]),{isLoading:m,data:x,refetch:h}=(0,a.XO)({contracts:p,allowFailure:!0,query:{enabled:!!p.length}});return(0,d.useEffect)(()=>{t&&(c({cancelRefetch:!1}),h({cancelRefetch:!1}))},[t,c,h]),{tokenIds:(0,d.useMemo)(()=>{var e;return null!=(e=null==x?void 0:x.map(e=>"success"===e.status?e.result:null).filter(Boolean))?e:[]},[x]),loading:m||s}}function m(e){let t=(0,o.TA)(),n=(0,o.rZ)(),r=!!((null==n?void 0:n.address)&&(null==n?void 0:n.address)!=="0x"),{tokenIds:l,loading:a}=p(null==t?void 0:t.address,e),{tokenIds:s}=p(r?null==n?void 0:n.address:void 0,e),{positions:c,loading:m}=u((0,d.useMemo)(()=>[...s,...l],[s,l]));return(0,d.useMemo)(()=>({loading:a||m,positions:null==c?void 0:c.map(e=>({...e,isStaked:!!(null==s?void 0:s.find(t=>t===e.tokenId)),protocol:i.Zs.V3}))}),[c,m,s,a])}},343517:e=>{"use strict";e.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,i){return n({key:t,value:e[t]},{key:i,value:e[i]})}}),l=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t)){for(n=0,o="[";n<t.length;n++)n&&(o+=","),o+=e(t[n])||"null";return o+"]"}if(null===t)return"null";if(-1!==l.indexOf(t)){if(i)return JSON.stringify("__cycle__");throw TypeError("Converting circular structure to JSON")}var n,o,a=l.push(t)-1,s=Object.keys(t).sort(r&&r(t));for(n=0,o="";n<s.length;n++){var d=s[n],u=e(t[d]);u&&(o&&(o+=","),o+=JSON.stringify(d)+":"+u)}return l.splice(a,1),"{"+o+"}"}}(e)}},344730:(e,t,n)=>{"use strict";n.d(t,{O:()=>x,s:()=>m});var i=n(273523),r=n(734658),l=n(662928),o=n(630806),a=n(811021),s=n.n(a),d=n(25963),u=n(792118),c=n(878314),p=n(165073);let m=e=>{let{poolId:t,tokenId:n,tickLower:o,tickUpper:a,currency0:m,currency1:x,enabled:h}=e,f=null==m?void 0:m.chainId,{data:v}=(0,p.L)(t,f),{poolManager:y}=null!=v?v:{},g=f?i.e1[f]:void 0,A=(void 0===h||!0===h)&&!!(g&&y&&t&&f&&n&&!s()(a)&&!s()(o)),{data:b}=(0,l.I)({queryKey:["useFeesEarned",t,f,Number(n),o,a],queryFn:()=>A?(e=>{let{chainId:t,lpFeesHelper:n,poolManager:r,poolId:l,owner:o,tickLower:a,tickUpper:s,tokenId:d}=e;return(0,u.Qr)({chainId:t}).readContract({abi:i.mo,address:n,functionName:"getLPFees",args:[r,l,o,a,s,(0,c.nj)(d,{size:32})]})})({chainId:f,lpFeesHelper:g,poolManager:y,poolId:t,owner:i.qI[f],tickLower:o,tickUpper:a,tokenId:n}):[0n,0n],enabled:A,retry:!1});return(0,d.useMemo)(()=>m&&x&&b?[r.eF.fromRawAmount(m,b[0]),r.eF.fromRawAmount(x,b[1])]:[void 0,void 0],[m,x,b])},x=e=>{let{currency0:t,currency1:n}=e,[i,l]=m(e),a=(0,o.r0)(t,{enabled:!!(null==i?void 0:i.greaterThan(0))}),s=(0,o.r0)(n,{enabled:!!(null==l?void 0:l.greaterThan(0))}
29),u=(e,t,n)=>{try{if(e&&t){if(e.baseCurrency.equals(t.currency))return e.quote(t);if(e.baseCurrency.wrapped.address===t.currency.wrapped.address){let n=r.eF.fromRawAmount(e.baseCurrency,t.quotient);return e.quote(n)}}}catch(e){console.warn(`Error calculating fiat value for ${n}:`,e)}},{totalFiatValue:c,fiatValue0:p,fiatValue1:x}=(0,d.useMemo)(()=>{let e=u(a,i,"currency0"),t=u(s,l,"currency1");return{fiatValue0:e,fiatValue1:t,totalFiatValue:e&&t?e.add(t):void 0}},[a,s,i,l]);return(0,d.useMemo)(()=>({feeAmount0:i,feeAmount1:l,fiatValue0:p,fiatValue1:x,totalFiatValue:c}),[i,l,p,x,c])}},353761:(e,t,n)=>{var i=n(20564);e.exports=function(e,t){var n;return i(e,function(e,i,r){return!(n=t(e,i,r))}),!!n}},359777:(e,t,n)=>{var i=n(496546),r=n(895557),l=n(184837);e.exports=function(e){return e&&e.length?i(e,l,r):void 0}},361325:(e,t,n)=>{"use strict";n.d(t,{i:()=>j});var i=n(350979),r=n(25963),l=n(680797),o=n(125795),a=n(334337);let s=l.Ay.div.withConfig({componentId:"sc-72069bcc-0"})(["display:flex;flex-direction:column;width:100%;box-sizing:border-box;font-family:'Kanit',sans-serif;"]),d=l.Ay.div.withConfig({componentId:"sc-72069bcc-1"})(["display:flex;flex-direction:column;gap:16px;width:100%;box-sizing:border-box;padding:16px;background:var(--pcs-colors-background-bubblegum,linear-gradient(139.73deg,#e5fdff 0%,#f3efff 100%));"]),u=l.Ay.div.withConfig({componentId:"sc-72069bcc-2"})(["display:flex;align-items:stretch;width:100%;height:59px;box-sizing:border-box;background:",";border-bottom:1px solid ",";"],e=>{let{theme:t}=e;return t.colors.card},e=>{let{theme:t}=e;return t.colors.cardBorder}),c=l.Ay.div.withConfig({componentId:"sc-72069bcc-3"})(["display:flex;flex:1 1 0;min-width:0;flex-direction:column;align-items:center;justify-content:center;box-sizing:border-box;padding:8px;& + &{border-left:1px solid ",";}"],e=>{let{theme:t}=e;return t.colors.cardBorder}),p=l.Ay.span.withConfig({componentId:"sc-72069bcc-4"})(["font-size:12px;font-weight:600;line-height:1.5;letter-spacing:0.24px;text-transform:uppercase;white-space:nowrap;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),m=l.Ay.span.withConfig({componentId:"sc-72069bcc-5"})(["font-size:16px;font-weight:600;line-height:1.5;white-space:nowrap;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.text}),x=(0,l.Ay)(c).withConfig({componentId:"sc-72069bcc-6"})(["padding:8px 6px;"]),h=(0,l.i7)(["from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:translateY(0);}"]),f=l.Ay.div.withConfig({componentId:"sc-72069bcc-7"})(["display:flex;flex-direction:column;align-items:center;width:100%;min-width:0;animation:"," 0.42s ease;@media (prefers-reduced-motion:reduce){animation:none;}"],h),v=l.Ay.span.withConfig({componentId:"sc-72069bcc-8"})(["display:flex;align-items:center;justify-content:center;gap:4px;width:100%;min-width:0;"]),y=(0,l.Ay)(p).withConfig({componentId:"sc-72069bcc-9"})(["color:",";"],e=>{let{theme:t}=e;return t.colors.secondary}),g=l.Ay.span.withConfig({componentId:"sc-72069bcc-10"})(["display:inline-flex;vertical-align:middle;margin-left:8px;"]),A=l.Ay.div.withConfig({componentId:"sc-72069bcc-11"})(["display:flex;flex-direction:column;align-items:flex-start;gap:8px;width:100%;"]),b=l.Ay.h1.withConfig({componentId:"sc-72069bcc-12"})(["margin:0;font-size:24px;font-weight:600;line-height:1.5;letter-spacing:-0.24px;color:",";font-feature-settings:'liga' off;"],e=>{let{theme:t}=e;return t.colors.text}),w=(0,i.jsxs)(i.Fragment,{children:["Earn from ",(0,i.jsx)(o.Gu,{children:"Liquidity Pools"})," & ",(0,i.jsx)(o.Gu,{children:"Farms"})]}),j=e=>{let{heading:t=w,headingHelp:n,learnHowLabel:l="Learn How",onLearnHow:h,totalTvlLabel:j="Total TVL",totalTvl:k="-",volume24hLabel:C="24h Volume",volume24h:I="-",fees24hLabel:S="24h Fees",fees24h:R="-",protocolTvls:E,protocolTvlLabel:M="TVL",protocolTvlIntervalMs:N=8e3,showStats:P=!0,picks:T=[],feeLabel:U="Fee",aprLabel:B="APR",tvlLabel:D="TVL",className:F}=e,q=null!=E?E:[],[L,O]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(q.length<2)return;let e=setInterval(()=>O(e=>(e+1)%q.length),N);return()=>clearInterval(e)},[q.length,N]);let _=q[L%(q.length||1)];return(0,i.jsxs)(s,{className:F,children:[P&&(0,i.jsxs)(u,{children:[(0,i.jsxs)(c,{children:[(0,i.jsx)(p,{children:j}),(0,i.jsx)(m,{children:k})]}),(0,i.jsxs)(c,{children:[(0,i.jsx)(p,{children:C}),(0,i.jsx)(m,{children:I})]}),_?(0,i.jsx)(x,{children:(0,i.jsxs)(f,{children:[(0,i.jsxs)(v,{children:[(0,i.jsx)(y,{children:_.protocol}),(0,i.jsx)(p,{children:M})]}),(0,i.jsx)(m,{children:_.value})]},_.protocol)}):(0,i.jsxs)(c,{children:[(0,i.jsx)(p,{children:S}),(0,i.jsx)(m,{children:R})]})]}),(0,i.jsxs)(d,{children:[(0,i.jsx)(A,{children:(0,i.jsxs)(b,{children:[t,(0,i.jsx)(g,{children:(0,i.jsx)(o.Gy,{headingHelp:n,learnHowLabel:l,onLearnHow:h})})]})}),T.length>0&&(0,i.jsx)(a.y,{picks:T,variant:"compact",feeLabel:U,aprLabel:B,tvlLabel:D})]})]})}}
29,364698:(e,t,n)=>{"use strict";n.d(t,{A:()=>D});var i=n(350979),r=n(769932),l=n(549333),o=n(862373),a=n(25963),s=n(970645),d=n(782038),u=n(336627),c=n(259145),p=n(189346),m=n(975644),x=n(495964),h=n(412867),f=n(687287),v=n(968349),y=n(743818),g=n(262453),A=n(835490),b=n(443634),w=n(286750),j=n(306411),k=n(518400),C=n(733775),I=n(178852),S=n(241439),R=n(459247),E=n(182063),M=n(772763),N=n(579670),P=n(670420),T=n(419041),U=n(326848),B=n(463532);function D(e){var t,n,D,F;let{currencyA:q,currencyB:L,children:O}=e,{data:_}=(0,x.G)(),{account:$,chainId:Y}=(0,v.W7)(),z=(0,y.j6)(),V=(0,k.Ep)(),{t:Z,currentLanguage:{locale:W}}=(0,r.A)(),H=(0,k.YW)(),{independentField:Q,typedValue:G,otherTypedValue:K}=(0,w.uE)(),{dependentField:X,currencies:J,pair:ee,pairState:et,currencyBalances:en,parsedAmounts:ei,price:er,noLiquidity:el,liquidityMinted:eo,poolTokenPercentage:ea,error:es,addError:ed,isOneWeiAttack:eu}=(0,b.L)(null!=q?q:void 0,null!=L?L:void 0),ec=(0,u.f)("v2",ee),{onFieldAInput:ep,onFieldBInput:em}=(0,b.B)(el),ex=(0,h.m)();(0,a.useEffect)(()=>{if(ex){let{currencyIdA:n,currencyIdB:i}=ex;if(n&&i&&n!==(0,E.A)(null!=q?q:void 0)&&i!==(0,E.A)(null!=L?L:void 0)){var e,t;ep(null!=(e=eM[A.O9.CURRENCY_B])?e:""),em(null!=(t=eM[A.O9.CURRENCY_A])?t:"")}}},[ex]);let[{attemptingTxn:eh,liquidityErrorMessage:ef,txHash:ev},ey]=(0,a.useState)({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),[eg]=(0,M.g)(),[eA]=(0,o.uZ)(),eb=[A.O9.CURRENCY_A,A.O9.CURRENCY_B].reduce((e,t)=>({...e,[t]:(0,S.r)(en[t])}),{}),{handleCurrencyASelect:ew,handleCurrencyBSelect:ej}=(()=>{var e,t,n;let i=(0,T.Ay)(),r=(0,U.useRouter)(),{chainId:l}=(0,v.ax)(),[o,s]=r.query.currency||(l?[i.symbol,null!=(n=null==(e=P.vb[l])?void 0:e.address)?n:null==(t=P.is[l])?void 0:t.address]:[]);return{handleCurrencyASelect:(0,a.useCallback)(e=>{let t=(0,E.A)(e);t===s?r.replace(`/add/${s}/${o}`,void 0,{shallow:!0}):s?r.replace(`/add/${t}/${s}`,void 0,{shallow:!0}):r.replace(`/add/${t}`,void 0,{shallow:!0})},[s,r,o]),handleCurrencyBSelect:(0,a.useCallback)(e=>{let t=(0,E.A)(e);o===t?s?r.replace(`/add/${s}/${t}`,void 0,{shallow:!0}):r.replace(`/add/${t}`,void 0,{shallow:!0}):r.replace(`/add/${o||i.symbol}/${t}`,void 0,{shallow:!0})},[o,r,s,i])}})(),ek=(0,B.A)(q?(0,E.A)(q):void 0,L?(0,E.A)(L):void 0),eC=(0,a.useCallback)(e=>{ek(e),ew(e)},[ek,ew]),eI=(0,a.useCallback)(e=>{ek(e),ej(e)},[ek,ej]),eS=(0,f.wG)(J[A.O9.CURRENCY_A]),eR=(0,f.wG)(J[A.O9.CURRENCY_B]),eE=X===A.O9.CURRENCY_A?eS:eR,eM=(0,a.useMemo)(()=>{var e;return{[Q]:G,[X]:el?K:null!=(e=eE(ei[X],6))?e:""}},[X,Q,el,K,ei,G,eE]),{approvalState:eN,approveCallback:eP,revokeCallback:eT,currentAllowance:eU}=(0,g.en)(ei[A.O9.CURRENCY_A],Y?s.U5[Y]:void 0),{approvalState:eB,approveCallback:eD,revokeCallback:eF,currentAllowance:eq}=(0,g.en)(ei[A.O9.CURRENCY_B],Y&&s.U5[Y]),eL=(0,j.OQ)(),eO=(0,I.hj)();async function e_(){var e,t,n,i,r,l,o,a,s,d,u,x,h,f;let v,y,g,b;if((0,c.aF)(),!Y||!$||!eO||!_)return;let{[A.O9.CURRENCY_A]:w,[A.O9.CURRENCY_B]:j}=ei;if(!w||!j||!q||!L||!eg)return;let k={[A.O9.CURRENCY_A]:(0,I.wQ)(w,el?0:eA)[0],[A.O9.CURRENCY_B]:(0,I.wQ)(j,el?0:eA)[0]},S=null==(e=J[A.O9.CURRENCY_A])?void 0:e.symbol,E=null==(t=ei[A.O9.CURRENCY_A])?void 0:t.toSignificant(3),M=null==(n=J[A.O9.CURRENCY_B])?void 0:n.symbol,N=null==(i=ei[A.O9.CURRENCY_B])?void 0:i.toSignificant(3),P=null!=(l=eS(ei[A.O9.CURRENCY_A],3))?l:E,T=null!=(o=eR(ei[A.O9.CURRENCY_B],3))?o:N,U=(0,R.bD)({account:$,chainId:Y,runtime:z});if((null==q?void 0:q.isNative)||(null==L?void 0:L.isNative)){let e=null==L?void 0:L.isNative;v=eO.estimateGas.addLiquidityETH,y=eO.write.addLiquidityETH,g=[null!=(d=null==(s=e?q:L)||null==(a=s.wrapped)?void 0:a.address)?d:"",(e?w:j).quotient.toString(),k[e?A.O9.CURRENCY_A:A.O9.CURRENCY_B].toString(),k[e?A.O9.CURRENCY_B:A.O9.CURRENCY_A].toString(),$,eg],b=(e?j:w).quotient}else v=eO.estimateGas.addLiquidity,y=eO.write.addLiquidity,g=[null!=(h=null==q||null==(u=q.wrapped)?void 0:u.address)?h:"",null!=(f=null==L||null==(x=L.wrapped)?void 0:x.address)?f:"",w.quotient.toString(),j.quotient.toString(),k[A.O9.CURRENCY_A].toString(),k[A.O9.CURRENCY_B].toString(),$,eg],b=null;ey({attemptingTxn:!0,liquidityErrorMessage:void 0,txHash:void 0}),(0,R.Dt)("liquidity_add_started",{...U,pool_type:"v2",token_a_symbol:null!=S?S:null,token_a_amount:null!=E?E:null,token_b_symbol:null!=M?M:null,token_b_amount:null!=N?N:null,no_liquidity:el}),await (null==(r=v(g,b?{value:b,account:eO.account,chain:eO.chain}:{account:eO.account,chain:eO.chain}).then(e=>y(g,{...b?{value:b}:{},gas:(0,C.KL)(e),gasPrice:H}).then(e=>{ey({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:e}),(0,c.Mg)(),eL({hash:e},{summary:`Add ${P} ${S} and ${T} ${M}`,translatableSummary:{text:"Add %amountA% %symbolA% and %amountB% %symbolB%",data:{amountA:P,symbolA:S,amountB:T,symbolB:M}},type:"add-liquidity"}),ee&&V(ee),(0,R.Dt)("liquidity_add_succeeded",{...U,pool_type:"v2",token_a_symbol:null!=S?S:null,token_a_amount:null!=E?E:null,token_b_symbol:null!=M?M:null,token_b_amount:null!=N?N:null,tx_hash:e,no_liquidity:el})})))?void 0:r.catch(e=>{e&&!(0,p.U)(e)&&((0,p.v)(e),console.error("Add Liquidity failed",e,g,b)),(0,R.Dt)("liquidity_add_failed",{...U,pool_type:"v2",token_a_symbol:null!=S?S:null,token_a_amount:null!=E?E:null,token_b_symbol:null!=M?M:null,token_b_amount:null!=N?N:null,rejected_by_user:!!(e&&(0,p.U)(e)),no_liquidity:el,...(0,R.fx)(e,e&&(0,p.U)(e)?"Transaction rejected.":void 0)}),ey({attemptingTxn:!1,liquidityErrorMessage:e&&!(0,p.U)(e)?Z("Add liquidity failed: %message%",{message:(0,m.w)(e,Z)}):void 0,txHash:void 0})}))}let e$=e=>
29e?Number(e).toLocaleString(W,{maximumSignificantDigits:4}):"",eY=Z("Supplying %amountA% %symbolA% and %amountB% %symbolB%",{amountA:e$(eS(ei[A.O9.CURRENCY_A],4)),symbolA:null!=(D=null==(t=J[A.O9.CURRENCY_A])?void 0:t.symbol)?D:"",amountB:e$(eR(ei[A.O9.CURRENCY_B],4)),symbolB:null!=(F=null==(n=J[A.O9.CURRENCY_B])?void 0:n.symbol)?F:""}),ez=(0,a.useCallback)(()=>{ev&&ep("")},[ep,ev]),{shouldBlock:eV}=(0,d.Wd)(null==J?void 0:J.CURRENCY_A,null==J?void 0:J.CURRENCY_B),[eZ]=(0,l.A)((0,i.jsx)(N.A,{title:el?Z("You are creating a trading pair"):Z("You will receive"),customOnDismiss:ez,attemptingTxn:eh,hash:ev,pendingText:eY,currencyToAdd:null==ee?void 0:ee.liquidityToken,allowedSlippage:eA,onAdd:e_,parsedAmounts:ei,currencies:J,liquidityErrorMessage:ef,price:er,noLiquidity:el,poolTokenPercentage:ea,liquidityMinted:eo}),!0,!0,"addLiquidityModal"),eW=(0,a.useCallback)(()=>{ey({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),eZ()},[eZ]),eH=!es&&!ed,eQ=null!=es?es:ed,eG=!eH||eN!==g.h$.APPROVED||eB!==g.h$.APPROVED,eK=eN===g.h$.NOT_APPROVED||eN===g.h$.PENDING,eX=eB===g.h$.NOT_APPROVED||eB===g.h$.PENDING;return O({isOneWeiAttack:eu,error:es,currencies:J,noLiquidity:el,handleCurrencyASelect:eC,formattedAmounts:eM,onFieldAInput:ep,maxAmounts:eb,handleCurrencyBSelect:eI,onFieldBInput:em,pairState:et,poolTokenPercentage:ea,price:er,allowedSlippage:eA,pair:ee,poolData:ec,shouldShowApprovalGroup:(eK||eX)&&eH,showFieldAApproval:eK,approveACallback:eP,approvalA:eN,revokeACallback:eT,currentAllowanceA:eU,showFieldBApproval:eX,approveBCallback:eD,approvalB:eB,revokeBCallback:eF,currentAllowanceB:eq,onAdd:e_,onPresentAddLiquidityModal:eW,buttonDisabled:eG,errorText:eQ,addIsUnsupported:eV,pendingText:eY})}},367475:e=>{var t=RegExp("[\\u200d\ud800-\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");e.exports=function(e){return t.test(e)}},368177:(e,t,n)=>{"use strict";n.d(t,{A:()=>I});var i=n(350979),r=n(769932),l=n(796147),o=n(995315),a=n(605641),s=n(805017),d=n(67002),u=n(557423),c=n(608135),p=n(673384),m=n(968349),x=n(859886),h=n(961862),f=n(314811),v=n(920820),y=n(650176),g=n(25963),A=n(800939),b=n(206016),w=n(510110),j=n(960755),k=n(456937);let C=[p.dl.LOWEST,p.dl.LOW,p.dl.MEDIUM,p.dl.HIGH];function I(e){let{feeAmount:t,handleFeePoolSelect:n,currencyA:I,currencyB:S,handleSelectV2:R}=e,{t:E}=(0,r.A)(),{chainId:M}=(0,m.ax)(),{farms:N}=(0,h.N)(M),P=(0,g.useMemo)(()=>{if(I&&S){let[e,t]=[I.wrapped,S.wrapped],[n,i]=e.sortsBefore(t)?[e,t]:[t,e];return null==N?void 0:N.find(e=>e.token.equals(n)&&e.quoteToken.equals(i))}return null},[I,S,N]),{isPending:T,isError:U,largestUsageFeeTier:B,distributions:D,largestUsageFeeTierTvl:F}=(0,v.g)(I,S),[q,L]=(0,x.ek)(I,S),[O,_]=(0,g.useState)(!1),$=(0,y.Tw)((0,g.useMemo)(()=>[[I,S,p.dl.LOWEST],[I,S,p.dl.LOW],[I,S,p.dl.MEDIUM],[I,S,p.dl.HIGH]],[I,S])),Y=(0,g.useMemo)(()=>$.reduce((e,t)=>{let[n,i]=t;return i?{...e,...{[i.fee]:n}}:e},{[p.dl.LOWEST]:f.S.NOT_EXISTS,[p.dl.LOW]:f.S.NOT_EXISTS,[p.dl.MEDIUM]:f.S.NOT_EXISTS,[p.dl.HIGH]:f.S.NOT_EXISTS}),[$]),z=(0,g.useMemo)(()=>{if(!R||T||U||!I||!S||[x.CN.LOADING,x.CN.INVALID].includes(q))return!1;if(!T&&!B||q===x.CN.NOT_EXISTS||C.every(e=>Y[e]===f.S.NOT_EXISTS))return!0;if(F){if(!Array.isArray(F)||!(F[0]&&!(null==B?void 0:B[1])))return!0;let e=(0,c.A)(String(F[0]),null==L?void 0:L.token0),t=(0,c.A)(String(F[1]),null==L?void 0:L.token1);return e&&(null==L?void 0:L.reserve0.greaterThan(e))||t&&(null==L?void 0:L.reserve1.greaterThan(t))}return!0},[Y,I,S,R,U,T,B,F,L,q]);return(0,g.useEffect)(()=>{if(!t){if(P)return void n({type:b.b.V3,feeAmount:P.feeAmount});T||U||(!B||z?_(!0):(_(!1),n({type:b.b.V3,feeAmount:B})))}},[t,T,U,B,n,z,P]),(0,i.jsx)(A.A,{showOptions:O||!z&&U,noHideButton:!t||!z&&U,setShowOptions:_,heading:t?(0,i.jsx)(l.mm,{gap:"8px",children:(0,i.jsxs)(o.A,{gap:"4px",alignItems:"center",children:[(0,i.jsxs)(a.A,{fontSize:["12px","16px"],children:[k.A[t].label,"% ",E("fee tier")]}),D&&(0,i.jsx)(j.m,{distributions:D,feeAmount:t,poolState:Y[t]})]})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.A,{children:"V3 LP"}),T&&(0,i.jsx)(s.m,{})]}),content:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(k.K,{children:C.map(e=>{let{supportedChains:r}=k.A[e];return M&&r.includes(M)?(0,i.jsx)(w.o,{isLoading:T,largestUsageFeeTier:B,feeAmount:e,active:t===e,onClick:()=>n({type:b.b.V3,feeAmount:e}),distributions:D,poolState:Y[e]},e):null})}),I&&S&&R&&(0,i.jsx)(d.R,{textAlign:"center",children:(0,i.jsx)(u.A,{variant:"text",onClick:R,children:(0,i.jsx)(a.A,{color:"textSubtle",bold:!0,children:E("Add V2 Liquidity")})})})]})})}},369067:(e,t,n)=>{"use strict";n.d(t,{B:()=>o});var i=n(273523),r=n(662928),l=n(792118);let o=e=>{let{data:t}=(0,r.I)({queryKey:["use-merkletree-root",e],queryFn:async()=>
29{if(e)return(0,l.Rt)({chainId:e}).readContract({abi:i.fS,address:i.BI[e],functionName:"getMerkleTreeRoot"})},enabled:!!e,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1});return t}},379324:(e,t,n)=>{"use strict";n.d(t,{nl:()=>x,bh:()=>v});var i=n(827666),r=n(206284),l=n(393569);class o extends Error{constructor(e){super(e),this.name="TimeoutError"}}class a extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}let s=e=>void 0===globalThis.DOMException?new a(e):new DOMException(e),d=e=>{let t=void 0===e.reason?s("This operation was aborted."):e.reason;return t instanceof Error?t:s(t)};class u{#e=[];enqueue(e,t){let n={priority:(t={priority:0,...t}).priority,id:t.id,run:e};if(0===this.size||this.#e[this.size-1].priority>=t.priority)return void this.#e.push(n);let i=function(e,t,n){let i=0,r=e.length;for(;r>0;){let l=Math.trunc(r/2),o=i+l;0>=n(e[o],t)?(i=++o,r-=l+1):r=l}return i}(this.#e,n,(e,t)=>t.priority-e.priority);this.#e.splice(i,0,n)}setPriority(e,t){let n=this.#e.findIndex(t=>t.id===e);if(-1===n)throw ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[i]=this.#e.splice(n,1);this.enqueue(i.run,{priority:t,id:e})}dequeue(){let e=this.#e.shift();return e?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(e=>e.run)}get size(){return this.#e.length}}class c extends l.b{#t;#n;#i=0;#r;#l;#o=0;#a;#s;#e;#d;#u=0;#c;#p;#m;#x=1n;timeout;constructor(e){if(super(),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:u,...e}).intervalCap&&e.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#t=e.carryoverConcurrencyCount,this.#n=e.intervalCap===1/0||0===e.interval,this.#r=e.intervalCap,this.#l=e.interval,this.#e=new e.queueClass,this.#d=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#m=!0===e.throwOnTimeout,this.#p=!1===e.autoStart}get #h(){return this.#n||this.#i<this.#r}get #f(){return this.#u<this.#c}#v(){this.#u--,this.#y(),this.emit("next")}#g(){this.#A(),this.#b(),this.#s=void 0}get #w(){let e=Date.now();if(void 0===this.#a){let t=this.#o-e;if(!(t<0))return void 0===this.#s&&(this.#s=setTimeout(()=>{this.#g()},t)),!0;this.#i=this.#t?this.#u:0}return!1}#y(){if(0===this.#e.size)return this.#a&&clearInterval(this.#a),this.#a=void 0,this.emit("empty"),0===this.#u&&this.emit("idle"),!1;if(!this.#p){let e=!this.#w;if(this.#h&&this.#f){let t=this.#e.dequeue();
29return!!t&&(this.emit("active"),t(),e&&this.#b(),!0)}}return!1}#b(){this.#n||void 0!==this.#a||(this.#a=setInterval(()=>{this.#A()},this.#l),this.#o=Date.now()+this.#l)}#A(){0===this.#i&&0===this.#u&&this.#a&&(clearInterval(this.#a),this.#a=void 0),this.#i=this.#t?this.#u:0,this.#j()}#j(){for(;this.#y(););}get concurrency(){return this.#c}set concurrency(e){if(!("number"==typeof e&&e>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#c=e,this.#j()}async #k(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}setPriority(e,t){this.#e.setPriority(e,t)}async add(e,t={}){return t.id??=(this.#x++).toString(),t={timeout:this.timeout,throwOnTimeout:this.#m,...t},new Promise((n,i)=>{this.#e.enqueue(async()=>{this.#u++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=function(e,t){let n,i,{milliseconds:r,fallback:l,message:a,customTimers:s={setTimeout,clearTimeout}}=t,u=new Promise((u,c)=>{if("number"!=typeof r||1!==Math.sign(r))throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:e}=t;e.aborted&&c(d(e)),i=()=>{c(d(e))},e.addEventListener("abort",i,{once:!0})}if(r===1/0)return void e.then(u,c);let p=new o;n=s.setTimeout.call(void 0,()=>{if(l){try{u(l())}catch(e){c(e)}return}"function"==typeof e.cancel&&e.cancel(),!1===a?u():a instanceof Error?c(a):(p.message=a??`Promise timed out after ${r} milliseconds`,c(p))},r),(async()=>{try{u(await e)}catch(e){c(e)}})()}).finally(()=>{u.clear(),i&&t.signal&&t.signal.removeEventListener("abort",i)});return u.clear=()=>{s.clearTimeout.call(void 0,n),n=void 0},u}(Promise.resolve(i),{milliseconds:t.timeout}
29)),t.signal&&(i=Promise.race([i,this.#k(t.signal)]));let r=await i;n(r),this.emit("completed",r)}catch(e){if(e instanceof o&&!t.throwOnTimeout)return void n();i(e),this.emit("error",e)}finally{this.#v()}},t),this.emit("add"),this.#y()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#p&&(this.#p=!1,this.#j()),this}pause(){this.#p=!0}clear(){this.#e=new this.#d}async onEmpty(){0!==this.#e.size&&await this.#C("empty")}async onSizeLessThan(e){this.#e.size<e||await this.#C("next",()=>this.#e.size<e)}async onIdle(){(0!==this.#u||0!==this.#e.size)&&await this.#C("idle")}async #C(e,t){return new Promise(n=>{let i=()=>{(!t||t())&&(this.off(e,i),n())};this.on(e,i)})}get size(){return this.#e.size}sizeBy(e){return this.#e.filter(e).length}get pending(){return this.#u}get isPaused(){return this.#p}}var p=n(50369);let m=new c({interval:1e3,intervalCap:1}),x=(e,t,n)=>["solana-v3-reward-info-from-simulation",e,t,n],h={feeAmount0:0n,feeAmount1:0n,rewardAmounts:[]},f=e=>i.P3F.getTickArrayAddressByTick(new r.PublicKey(e.pool.programId),new r.PublicKey(e.pool.id),e.tickNumber,e.pool.config.tickSpacing),v=e=>{let{raydium:t,poolInfo:n,position:r,connection:l}=e;return m.add(async()=>{if(!t||!n||!r)return h;let e=await (0,p.H)({simulateOnly:!0,poolInfo:n,raydium:t,position:r,liquidity:0n,amountMinA:0n,amountMinB:0n});if(!e){console.info("Simulation failed, trying on-chain fetch");try{let e=await t.clmm.getPoolInfoFromRpc(n.poolId),o=f({pool:e.poolInfo,tickNumber:r.tickLower}),a=f({pool:e.poolInfo,tickNumber:r.tickUpper}),s=await l.getAccountInfo(o),d=await l.getAccountInfo(a);if(!s||!d)throw Error("Tick array account not found");let u=i.$Ex.decode(s.data),c=i.$Ex.decode(d.data),p=u.ticks[i.P3F.getTickOffsetInArray(r.tickLower,e.computePoolInfo.tickSpacing)],m=c.ticks[i.P3F.getTickOffsetInArray(r.tickUpper,e.computePoolInfo.tickSpacing)],x=i.ZZh.GetPositionFeesV2(e.computePoolInfo,r,p,m),h=i.ZZh.GetPositionRewardsV2(e.computePoolInfo,r,p,m);return{feeAmount0:x.tokenFeeAmountA,feeAmount1:x.tokenFeeAmountB,rewardAmounts:h}}catch(e){return console.error("On-chain fetch failed, returning default result",e),h}}return e})}},393783:(e,t,n)=>{"use strict";n.d(t,{Q:()=>s});var i=n(638791),r=n(252299),l=n(393851),o=n(227432),a=n(106829),s=(0,i.g)({chartName:"AreaChart",GraphicalChild:r.G,axisComponents:[{axisType:"xAxis",AxisComp:l.W},{axisType:"yAxis",AxisComp:o.h}],formatAxisMap:a.pr})},412867:(e,t,n)=>{"use strict";n.d(t,{C:()=>s,m:()=>d});var i=n(25963),r=n(326848),l=n(985148),o=n(118708);let a=(0,l.eU)(null),s=e=>{let{currencyIdA:t,currencyIdB:n,feeAmount:l}=e,s=(0,r.useRouter)(),d=(0,o.Xr)(a),u=(0,i.useCallback)(()=>{t&&n&&d({currencyIdA:n,currencyIdB:t}),s.events.off("routeChangeComplete",u)},[s.events,d,n,t]);return{handleInvertCurrencies:(0,i.useCallback)(()=>{t&&n&&(s.push({pathname:s.pathname,query:{...s.query,currency:l?[n,t,null==l?void 0:l.toString()]:[n,t]}}),s.isReady?u():s.events.on("routeChangeComplete",u))},[u,t,n,l,s])}},d=()=>(0,o.md)(a)},414506:(e,t,n)=>{var i=n(940293),r=n(498198),l=n(592479),o=n(486821);e.exports=l(function(e,t){if(null==e)return[];var n=t.length;return n>1&&o(e,t[0],t[1])?t=[]:n>2&&o(t[0],t[1],t[2])&&(t=[t[0]]),r(e,i(t,1),[])})},418595:e=>{e.exports=function(e){return e.split("")}},426593:(e,t,n)=>{"use strict";n.d(t,{e:()=>k});var i=n(350979),r=n(769932),l=n(796147),o=n(24153),a=n(575058),s=n(605641),d=n(266283),u=n(747292),c=n(150103),p=n(432594),m=n(687287),x=n(810286),h=n(504304),f=n(114041),v=n(630806),y=n(829715),g=n(25963),A=n(909725),b=n(452301),w=n(573271),j=n(149160);let k=e=>{var t,n,k,C,I,S,R,E,M;let{position:N,title:P,inRange:T,baseCurrencyDefault:U,ticksAtLimit:B}=e,{t:D,currentLanguage:{locale:F}}=(0,r.A)(),q=(0,b.U$)(N.pool.token0),L=(0,b.U$)(N.pool.token1),O=(0,m.wG)(N.pool.token0),_=(0,m.wG)(N.pool.token1),[$,Y]=(0,g.useState)(U?U===q?q:U===L?L:q:q),z=$===q,V=z?L:q,Z=z?N.pool.priceOf(N.pool.token0):N.pool.priceOf(N.pool.token1),W=z?N.token0PriceLower:N.token0PriceUpper.invert(),H=z?N.token0PriceUpper:N.token0PriceLower.invert(),Q=(0,m.xm)(Z),G=(0,m.xm)(W),K=(0,m.xm)(H),X=(0,v.r0)(null!=(S=N.pool.token0)?S:void 0,{enabled:!!(null==N||null==(t=N.amount0)?void 0:t.greaterThan(0))}),J=(0,v.r0)(null!=(R=N.pool.token1)?R:void 0,{enabled:!!(null==N||null==(n=N.amount1)?void 0:n.greaterThan(0))}),ee=(0,g.useCallback)(()=>{Y(V)},[V]),et="bigint"==typeof(null==N?void 0:N.liquidity)&&(null==N?void 0:N.liquidity)===0n;return(0,i.jsxs)(l.mm,{gap:"md",style:{marginTop:"0.5rem"},children:[(0,i.jsxs)(o.JA,{style:{marginBottom:"0.5rem"},children:[(0,i.jsxs)(o.Bp,{children:[(0,i.jsx)(c.gz,{currency0:null!=q?q:void 0,currency1:null!=L?L:void 0,size:24}),(0,i.jsxs)(a.A,{as:"h2",ml:"4px",children:[null==q?void 0:q.symbol,"-",null==L?void 0:L.symbol]})]}),(0,i.jsx)(w.K,{removed:et,outOfRange:!T})]}),(0,i.jsx)(d.k0,{children:(0,i.jsxs)(l.mm,{gap:"sm",children:[(0,i.jsxs)(o.JA,{children:[(0,i.jsxs)(o.Bp,{children:[(0,i.jsx)(p.Ay,{currency:q}),(0,i.jsx)(s.A,{ml:"4px",children:null==q?void 0:q.symbol})]}),(0,i.jsx)(o.Bp,{children:(0,i.jsx)(x.g3,{amount:N.amount0,mr:"8px",children:null!=(E=O(N.amount0,4))?E:"-"})}),(0,i.jsx)(o.JA,{justifyContent:"flex-end",children:(0,i.jsx)(s.A,{fontSize:"10px",color:"textSubtle",ml:"4px",mr:"8px",children:N.amount0&&X?`~$${X.quote(null==(k=N.amount0)?void 0:k.wrapped).toFixed(2,{groupSeparator:","})}`:""})})]}),(0,i.jsxs)(o.JA,{children:[(0,i.jsxs)(o.Bp,{children:[(0,i.jsx)(p.Ay,{currency:L}),(0,i.jsx)(s.A,{ml:"4px",children:null==L?void 0:L.symbol})]}),(0,i.jsx)(o.Bp,{children:(0,i.jsx)(x.g3,{amount:N.amount1,mr:"8px",children:null!=(M=_(N.amount1,4))?M:"-"})}),(0,i.jsx)(o.JA,{justifyContent:"flex-end",children:(0,i.jsx)(s.A,{fontSize:"10px",color:"textSubtle",ml:"4px",mr:"8px",children:N.amount1&&J?`~$${J.quote(null==(C=N.amount1)?void 0:C.wrapped).toFixed(2,{groupSeparator:","})}`:""})})]}),(0,i.jsx)(u.A,{}),(0,i.jsxs)(o.JA,{children:[(0,i.jsx)(s.A,{color:"textSubtle",children:D("Fee Tier")}),(0,i.jsxs)(s.A,{children:[(null==N||null==(I=N.pool)?void 0:I.fee)/1e4,"%"]})]})]})}),(0,i.jsxs)(l.mm,{gap:"md",children:[(0,i.jsxs)(o.JA,{children:[P?(0,i.jsx)(s.A,{color:"secondary",bold:!0,fontSize:"12px",textTransform:"uppercase",children:P}):(0,i.jsx)("div",{}),(0,i.jsx)(j.A,{currencyA:z?q:L,handleRateToggle:ee})]}
29),(0,i.jsxs)(o.JA,{children:[(0,i.jsx)(h.E,{width:"48%",title:D("Min Price"),currency0:V,currency1:$,price:(0,y.I)(G,B,f.zm.LOWER,F),rawPrice:W}),(0,i.jsx)(h.E,{width:"48%",title:D("Max Price"),currency0:V,currency1:$,price:(0,y.I)(K,B,f.zm.UPPER,F),rawPrice:H})]}),(0,i.jsx)(h.E,{title:D("Current Price"),currency0:V,currency1:$,price:(0,A.$g)(Q,6,F),rawPrice:Z})]})]})}},427548:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>E,VB:()=>R});var i=n(350979),r=n(769932),l=n(311560),o=n(334404),a=n(662928),s=n(227883);let d=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidDispute",type:"error"},{inputs:[],name:"InvalidLengths",type:"error"},{inputs:[],name:"InvalidProof",type:"error"},{inputs:[],name:"InvalidUninitializedRoot",type:"error"},{inputs:[],name:"NoDispute",type:"error"},{inputs:[],name:"NotGovernorOrGuardian",type:"error"},{inputs:[],name:"NotTrusted",type:"error"},{inputs:[],name:"NotWhitelisted",type:"error"},{inputs:[],name:"UnresolvedDispute",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"previousAdmin",type:"address"},{indexed:!1,internalType:"address",name:"newAdmin",type:"address"}],name:"AdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"beacon",type:"address"}],name:"BeaconUpgraded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"user",type:"address"},{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Claimed",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"_disputeAmount",type:"uint256"}],name:"DisputeAmountUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint48",name:"_disputePeriod",type:"uint48"}],name:"DisputePeriodUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"valid",type:"bool"}],name:"DisputeResolved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"_disputeToken",type:"address"}],name:"DisputeTokenUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"reason",type:"string"}],name:"Disputed",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"user",type:"address"},{indexed:!1,internalType:"bool",name:"isEnabled",type:"bool"}],name:"OperatorClaimingToggled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"user",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"isWhitelisted",type:"bool"}],name:"OperatorToggled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Recovered",type:"event"},{anonymous:!1,inputs:[],name:"Revoked",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bytes32",name:"merkleRoot",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"ipfsHash",type:"bytes32"},{indexed:!1,internalType:"uint48",name:"endOfDisputePeriod",type:"uint48"}],name:"TreeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"eoa",type:"address"},{indexed:!1,internalType:"bool",name:"trust",type:"bool"}],name:"TrustedToggled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"canUpdateMerkleRoot",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address[]",name:"users",type:"address[]"},{internalType:"address[]",name:"tokens",type:"address[]"},{internalType:"uint256[]",name:"amounts",type:"uint256[]"},{internalType:"bytes32[][]",name:"proofs",type:"bytes32[][]"}],name:"claim",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"claimed",outputs:[{internalType:"uint208",name:"amount",type:"uint208"},{internalType:"uint48",name:"timestamp",type:"uint48"},{internalType:"bytes32",name:"merkleRoot",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"core",outputs:[{internalType:"contract ICore",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"disputeAmount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"disputePeriod",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"disputeToken",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"string",name:"reason",type:"string"}],name:"disputeTree",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"disputer",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"endOfDisputePeriod",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMerkleRoot",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract ICore",name:"_core",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"lastTree",outputs:[{internalType:"bytes32",name:"merkleRoot",type:"bytes32"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}
29],name:"onlyOperatorCanClaim",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"operators",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"tokenAddress",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountToRecover",type:"uint256"}],name:"recoverERC20",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bool",name:"valid",type:"bool"}],name:"resolveDispute",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"revokeTree",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"_disputeAmount",type:"uint256"}],name:"setDisputeAmount",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"_disputePeriod",type:"uint48"}],name:"setDisputePeriod",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20",name:"_disputeToken",type:"address"}],name:"setDisputeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"user",type:"address"}],name:"toggleOnlyOperatorCanClaim",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"user",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"toggleOperator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"eoa",type:"address"}],name:"toggleTrusted",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"tree",outputs:[{internalType:"bytes32",name:"merkleRoot",type:"bytes32"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bytes32",name:"merkleRoot",type:"bytes32"},{internalType:"bytes32",name:"ipfsHash",type:"bytes32"}],internalType:"struct MerkleTree",name:"_tree",type:"tuple"}],name:"updateTree",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"}],name:"upgradeTo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"}];var u=n(529208),c=n(228876);let p="0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae",m={[c.nU.ETHEREUM]:p,[c.nU.BSC]:p,[c.nU.LINEA]:p,[c.nU.BASE]:p,[c.nU.ARBITRUM_ONE]:p,[c.nU.MONAD_MAINNET]:p,[c.nU.ZKSYNC]:"0xe117ed7Ef16d3c28fCBA7eC49AFAD77f451a6a21"};var x=n(968349),h=n(623895),f=n(389512),v=n(174722),y=n.n(v),g=n(25963),A=n(735872),b=n(703258),w=n(495964),j=n(555967),k=n(733775),C=n(45705),I=n(407786);let S="/api/merkl/v4";function R(e,t){var n;let{account:i,chainId:r}=(0,x.W7)(),o=null!=t?t:r,s=(0,C.ky)(o),d=null==(n=(0,j.p6)(o))?void 0:n.address,c=(0,A.mC)(),{data:p,isPending:m,refetch:h}=(0,a.I)({queryKey:["fetchMerklPools"],queryFn:async e=>{let{signal:t}=e,n=await (0,I.Vw)(t);if(!n||!n.length)return;let i=n.reduce((e,t)=>{var n;return e+(null!=(n=t.liveCampaigns)?n:0)},0),r=async e=>{let i=new URLSearchParams({items:String(100),page:String(e),status:"LIVE"});n.forEach(e=>i.append("opportunityIds",e.id));let r=await fetch(`${S}/campaigns?${i}`,{signal:t});if(!r.ok)throw r;return await r.json()},l=await r(0);if(i>100){let e=1;for(;;){let t=await r(e);if(!t.length||(l=l.concat(t),t.length<100))break;e+=1}}let o=new Map;for(let e of l){let t=e.opportunityId;o.has(t)||o.set(t,[]),o.get(t).push(e)}return{pools:n.map(e=>{var t;return{...e,campaigns:null!=(t=o.get(e.id))?t:[]}})}},enabled:!!e,staleTime:u.fr,retryDelay:e=>Math.min(2e3*2**e,3e4)}),{data:f}=(0,a.I)({queryKey:[`fetchMerkl-user-${o}-${i}`],queryFn:async()=>
29{if(!o)return;let e=await fetch(`${S}/users/${i}/rewards?chainId=${o}`);if(!e.ok)throw e;let t=await e.json();if(t)return t},enabled:!!(p&&o&&i&&e),staleTime:u.fr,retryDelay:e=>Math.min(2e3*2**e,3e4)});return(0,g.useMemo)(()=>{var t,n,r,a,u,x,v;let g=null==p||null==(n=p.pools)||null==(t=n.filter(t=>(0,k.ho)(t.identifier,e)))?void 0:t[0];if(!g||!s)return{rewardsPerToken:[],rewardTokenAddresses:[],transactionData:null,refreshData:h,hasMerkl:!1,isPending:m};let A="LIVE"===g.status&&g.apr>0&&!!(null==(r=g.campaigns)?void 0:r.some(e=>{let{startTimestamp:t,endTimestamp:n,whitelist:r,blacklist:l}=e,o=Number(t),a=Number(n);if(!(o<=s&&s<=a))return!1;let u=!r||0===r.length||r.includes(i)||r.includes(d),c=!l||0===l.length||!l.includes(i)||!l.includes(d);return u&&c})),b=((null==(u=g.rewardsRecord)||null==(a=u.breakdowns)?void 0:a.flatMap(e=>e.token.address))||[]).filter((e,t,n)=>n.indexOf(e)===t),w=null==f||null==(x=f.filter(e=>{var t;return(null==e||null==(t=e.chain)?void 0:t.id)===g.chainId}))?void 0:x[0],j=null==w||null==(v=w.rewards)?void 0:v.filter(e=>b.some(t=>(0,k.ho)(e.token.address,t))).filter(e=>{let{amount:t,claimed:n}=e||{};return BigInt(t||0)-BigInt(n||0)>0}),C=null==j?void 0:j.reduce((e,t)=>{var n;return e[null==t||null==(n=t.token)?void 0:n.address]={proof:null==t?void 0:t.proofs,claim:null==t?void 0:t.amount},e},{}),{rewardsPerToken:I=[],rewardTokenAddresses:S=[],...R}={hasMerkl:!!A,rewardsPerToken:j?j.map(e=>{let{amount:t,claimed:n,token:{address:i,decimals:r,symbol:a}}=e,s=new l.ou(o,i,r,a),d=BigInt(t||0)-BigInt(n||0);return l.eF.fromRawAmount(s,d)}).filter(Boolean):[],rewardTokenAddresses:y()(null==j?void 0:j.map(e=>{var t;return null==e||null==(t=e.token)?void 0:t.address})),transactionData:C,isPending:m},E=I.length?I:S.reduce((e,t)=>(Object.values(c).find(n=>{var i;let r=null==n||null==(i=n.current)?void 0:i.tokens.find(e=>(0,k.ho)(e.address,t));return!!r&&e.push(r)}),e),[]).map(e=>{let t=new l.ou(o,e.address,e.decimals,e.symbol);return l.eF.fromRawAmount(t,"0")}),M=null==g?void 0:g.apr;return{...R,rewardsPerToken:E,refreshData:h,merklApr:M}},[o,p,c,h,m,e,i,d,s,f])}function E(e,t){let{account:n,chainId:l}=(0,x.W7)(),a=null!=t?t:l,{data:u}=(0,w.G)(),{transactionData:c,rewardsPerToken:p,refreshData:v,hasMerkl:y}=R(e,t),{callWithGasPrice:A}=(0,h.M)(),{fetchWithCatchTxError:j,loading:k}=(0,f.A)(),{toastSuccess:C}=(0,o.d)(),{t:I}=(0,r.A)(),S=(0,g.useCallback)(async()=>{let e=a?m[a]:void 0;if(!n||!e||!u)return;let t=(0,b.PF)({abi:d,address:e,signer:u});if(!c||!t)return;let r=p.map(e=>{let t=e.currency.wrapped.address,n=c[t];if(n&&n.proof&&"0"!==n.claim)return t}).filter(Boolean),l=r.map(e=>c[e].claim),o=r.map(e=>c[e].proof),x=await j(()=>A(t,"claim",[r.map(e=>n),r,l,o]));(null==x?void 0:x.status)&&(C(I("Success!"),(0,i.jsx)(s.G,{txHash:x.transactionHash,children:I("Merkl Rewards are claimed")})),v())},[a,n,u,c,j,p,A,C,I,v]);return(0,g.useMemo)(()=>({hasMerkl:y,rewardsPerToken:p,claimTokenReward:S,isClaiming:k}),[S,y,k,p])}},432680:(e,t,n)=>{"use strict";n.d(t,{E:()=>i});var i=function(e){return e[e.All=0]="All",e[e.Active=1]="Active",e[e.Inactive=2]="Inactive",e[e.Closed=3]="Closed",e}({})},435619:(e,t,n)=>{"use strict";n.d(t,{p:()=>x});var i=n(350979),r=n(769932),l=n(796898),o=n(995315),a=n(501823),s=n(28192),d=n(770773),u=n(805939),c=n(829715),p=n(687287),m=n(25963);let x=(0,m.memo)(e=>{let{base:t,quote:n,priceLower:x,priceUpper:h,tickAtLimit:f}=e,[v,y]=(0,m.useState)(!1),{t:g,currentLanguage:{locale:A}}=(0,r.A)(),b=(0,m.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),y(!v)},[v]),[w,j,k,C]=(0,m.useMemo)(()=>v?[null==n?void 0:n.symbol,null==t?void 0:t.symbol,null==h?void 0:h.invert(),null==x?void 0:x.invert()]:[null==t?void 0:t.symbol,null==n?void 0:n.symbol,x,h],[null==t?void 0:t.symbol,null==n?void 0:n.symbol,x,h,v]),I=(0,p.xm)(k),S=(0,p.xm)(C),{isMobile:R}=(0,l.A)();return h&&x?(0,i.jsxs)(o.A,{flexDirection:R?"column":"row","aria-hidden":!0,onClick:b,alignItems:R?"flex-start":"center",children:[g("Min %minAmount%",{minAmount:(0,c.I)(I,f,u.z.LOWER,A)})," ","/"," ",g("Max %maxAmount%",{maxAmount:(0,c.I)(S,f,u.z.UPPER,A)})," ",R?(0,i.jsx)("br",{}):(0,i.jsx)(i.Fragment,{children:"\xa0"}),(0,i.jsxs)(a.A,{alignItems:"center",children:[g("of %quote% per %base%",{quote:j,base:w}),(0,i.jsx)(s.A,{variant:"text",scale:"xs",children:(0,i.jsx)(d.A,{color:"textSubtle",ml:"2px"})})]})]}):null})},435662:e=>{e.exports=function(e){return null==e}}
29,440589:(e,t,n)=>{"use strict";n.d(t,{dy:()=>g,o$:()=>A});var i=n(118708),r=n(954335),l=n(25963),o=n(827666),a=n(242312),s=n.n(a),d=n(662928),u=n(206284),c=n(862373),p=n(381033),m=n(529208),x=n(252146),h=n(429484);let f=async(e,t)=>{let n=new u.Connection(e);try{return(await (0,o.FtI)(n,t)).flat().map(e=>e?o.iY2.decode(e.data):null).filter(e=>!!e)}catch(e){return console.error("error fetching solana position info",e),[]}},v=new Map,y=(0,p.A)(e=>e.map(e=>{let t=`${e.mint.toBase58()}-${e.programId.toBase58()}`;if(v.get(t))return v.get(t);let n=(0,o.XAG)(m.nH,e.mint);return v.set(t,n.publicKey),n.publicKey})),g="solana-position-info",A=e=>{let t=(e=>{let{data:t,isLoading:n}=(0,i.md)((0,h.Ww)(e)),{tokenList:o}=(0,r.F)(!!e);return(0,l.useMemo)(()=>n||!t?[]:Array.from(t.values()).flat().filter(e=>e.amount.eq(new(s())(1))&&!o.some(t=>t.address===e.mint.toBase58())),[t,n,o])})(e),n=(0,i.md)(c._A),[o]=(0,x.r)();return(0,d.I)({queryKey:[g,e,null==o?void 0:o.blockHash],queryFn:()=>f(n,y(t)),enabled:!!e&&t.length>0,staleTime:0,refetchInterval:m.IX,refetchOnWindowFocus:!0})}},441706:()=>{},451184:(e,t,n)=>{"use strict";n.d(t,{M:()=>o});var i=n(350979),r=n(990296),l=n(99490);let o=()=>(0,i.jsxs)(l.m,{children:[(0,i.jsx)(r.Ay,{width:48,height:48,variant:"circle"}),(0,i.jsxs)("div",{children:[(0,i.jsx)(r.Ay,{width:40,height:10,mb:"4px"}),(0,i.jsx)(r.Ay,{width:60,height:24})]})]})},456937:(e,t,n)=>{"use strict";n.d(t,{A:()=>o,K:()=>a});var i=n(673384),r=n(680797),l=n(18468);let o={[i.dl.LOWEST]:{label:"0.01",description:"Best for very stable pairs.",supportedChains:l.uz},[i.dl.LOW]:{label:"0.05",description:"Best for stable pairs.",supportedChains:l.uz},[i.dl.MEDIUM]:{label:"0.25",description:"Best for most pairs.",supportedChains:l.uz},[i.dl.HIGH]:{label:"1",description:"Best for exotic pairs.",supportedChains:l.uz}},a=r.I4.div.withConfig({componentId:"sc-ccc2a2ff-0"})(["align-items:flex-start;display:grid;grid-auto-flow:column;grid-gap:4px;@media (max-width:410px){grid-auto-flow:row;grid-template-columns:repeat(2,1fr);}"])},462864:(e,t,n)=>{"use strict";n.d(t,{RC:()=>ee,W3:()=>nl,DC:()=>no});var i=n(350979),r=n(25963),l=n(228876),o=n(968349),a=n(662928),s=n(680797),d=n(605641),u=n(796898),c=n(561213),p=n(428089),m=n(245009),x=n(995315),h=n(905470),f=n(769932),v=n(131619),y=n(279760),g=n(338685),A=n(242312),b=n.n(A),w=n(579518),j=n(337034),k=n(719186),C=n(827666),I=function(e){return e.Day="day",e.Week="week",e.Month="month",e}({}),S=n(284178),R=n(445603),E=n(863984),M=n(142845);let N=e=>{var t,n,l,o,a,s,u;let{pool:c,fontSize:p="24px"}=e,{data:m}=(0,j.L)(c.poolId),x=(0,S.oU)(),{ticks:h}=(0,R.r)(c.token0,c.token1,c.feeTier,c.token0,void 0,x),f=(0,r.useMemo)(()=>{var e;return((null==m||null==(e=m.computePoolInfo)?void 0:e.rewardInfos)||[]).map(e=>{var t,n;return null==e||null==(n=e.tokenMint)||null==(t=n.toBase58)?void 0:t.call(n)}).filter(Boolean)},[null==m||null==(t=m.computePoolInfo)?void 0:t.rewardInfos]),v=null==c||null==(l=c.rawPool)||null==(n=l.mintA)?void 0:n.address,y=null==c||null==(a=c.rawPool)||null==(o=a.mintB)?void 0:o.address,g=(0,r.useMemo)(()=>[v,y,...f],[v,y,f]),{data:A}=(0,k.E)({mintList:g}),N=(0,r.useMemo)(()=>{var e,t;let n={};return v&&(null==A||null==(e=A[v])?void 0:e.value)!==void 0&&(n[v]={value:A[v].value}),y&&(null==A||null==(t=A[y])?void 0:t.value)!==void 0&&(n[y]={value:A[y].value}),null==f||f.forEach(e=>{var t;e&&(null==A||null==(t=A[e])?void 0:t.value)!==void 0&&(n[e]={value:A[e].value})}),n},[A,v,y,f]),P=(e=>{var t,n;let{poolInfo:i,poolLiquidity:l,positionInfo:o,timeBasis:a,planType:s="M",chainTimeOffsetMs:d=0,tokenPrices:u={}}=e,c=null!=(t=null==o?void 0:o.tickLower)?t:0,p=null!=(n=null==o?void 0:o.tickUpper)?n:0;return(0,r.useMemo)(()=>{if(i&&null!=c&&null!=p)try{var e;return function(e){var t,n;let{poolInfo:i,poolLiquidity:r,tickLower:l,tickUpper:o,planType:a,tokenPrices:s,timeBasis:d,chainTimeOffsetMs:u=0,liquidity:c}=e;if(c.isZero())return{fee:{apr:0,percentInTotal:0},rewards:(i.rewardDefaultInfos||[]).map((e,t)=>{var n,r;return{apr:0,percentInTotal:0,mint:null==(r=i.rewardDefaultInfos)||null==(n=r[t])?void 0:n.mint}}),apr:0};if("D"===a){let e=C.QNe.estimateAprsForPriceRangeDelta({poolInfo:i,poolLiquidity:r,aprType:d,mintPrice:s,positionTickLowerIndex:Math.min(l,o),positionTickUpperIndex:Math.max(l,o),chainTime:(Date.now()+u)/1e3,liquidity:c}),t=(e.rewardsApr||[]).slice(0,(null==(n=i.rewardDefaultInfos)?void 0:n.length)||0),a=[e.feeApr,...t].reduce((e,t)=>
29e+t,0);return{fee:{apr:e.feeApr,percentInTotal:a?e.feeApr/a*100:0},rewards:t.map((e,t)=>{var n,r;return{apr:e,percentInTotal:a?e/a*100:0,mint:null==(r=i.rewardDefaultInfos)||null==(n=r[t])?void 0:n.mint}}),apr:Number.isNaN(e.apr)?0:e.apr}}let p=C.QNe.estimateAprsForPriceRangeMultiplier({poolInfo:i,aprType:d,positionTickLowerIndex:Math.min(l,o),positionTickUpperIndex:Math.max(l,o)}),m=(p.rewardsApr||[]).slice(0,(null==(t=i.rewardDefaultInfos)?void 0:t.length)||0),x=[p.feeApr,...m].reduce((e,t)=>e+t,0);return{fee:{apr:p.feeApr,percentInTotal:x?p.feeApr/x*100:0},rewards:m.map((e,t)=>{var n,r;return{apr:e,percentInTotal:x?e/x*100:0,mint:null==(r=i.rewardDefaultInfos)||null==(n=r[t])?void 0:n.mint}}),apr:Number.isNaN(p.apr)?0:p.apr}}({poolInfo:i,poolLiquidity:l,tickLower:c,tickUpper:p,planType:s,tokenPrices:u,timeBasis:a,chainTimeOffsetMs:d,liquidity:null!=(e=o.liquidity)?e:new(b())(1)})}catch(e){return}},[i,null==o?void 0:o.liquidity,c,p,s,u,a,d,l])})({poolInfo:c.rawPool,poolLiquidity:null!=(u=null==m||null==(s=m.computePoolInfo)?void 0:s.liquidity)?u:new(b())(0),positionInfo:{tickLower:null==h?void 0:h.LOWER,tickUpper:null==h?void 0:h.UPPER,liquidity:new(b())(1)},timeBasis:I.Day,planType:"D",tokenPrices:N}),{combinedApr:T,feeApr:U,rewardApr:B}=(0,r.useMemo)(()=>{var e,t;return{combinedApr:Number((null==P?void 0:P.apr)||0)/100,feeApr:Number((null==P||null==(e=P.fee)?void 0:e.apr)||0)/100,rewardApr:{value:null!=(t=null==P?void 0:P.rewards.reduce((e,t)=>e+Number(t.apr)/100,0))?t:0}}},[P]),{tooltip:D,targetRef:F,tooltipVisible:q}=(0,w.A)((0,i.jsx)(E.S,{cakeApr:B,combinedApr:T,lpFeeApr:U,showDesc:!0}));return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d.A,{ref:F,children:(0,i.jsx)(M.A,{showApyButton:!1,hasFarm:B.value>0,baseApr:T,textProps:{fontSize:p,fontWeight:"600"}})}),q&&D]})};var P=n(721665),T=n(942272),U=n(412867);let B=(0,s.Ay)(d.A).withConfig({componentId:"sc-d31ba27d-0"})(["color:",";transition:opacity 0.2s ease;&:hover{opacity:0.8;}"],e=>{let{theme:t}=e;return t.colors.primary60});function D(e){var t,n,l,s;let{children:A}=e,{t:b}=(0,f.A)(),{chainId:w}=(0,o.ax)(),{isMobile:k}=(0,u.A)(),{currencyIdA:C,currencyIdB:I,feeAmount:S}=(0,T.J)(),R=(0,v.Jg)(C),E=(0,v.Jg)(I),{data:M}=(0,y.t)(null==R?void 0:R.wrapped.address,null==E?void 0:E.wrapped.address,S),{data:D}=(0,j.L)(null==M?void 0:M.poolId),F=(0,r.useMemo)(()=>!!((null==M?void 0:M.token0)&&(null==M?void 0:M.token1)&&(null==M?void 0:M.token0.wrapped.address)!==(null==M?void 0:M.token1.wrapped.address)&&R&&!M.token0.wrapped.equals(R)),[M,R]),{handleInvertCurrencies:q}=(0,U.C)({currencyIdA:C,currencyIdB:I,feeAmount:S}),L=null!=(n=null!=(t=null==M?void 0:M.token0)?t:R)?n:void 0,O=null!=(s=null!=(l=null==M?void 0:M.token1)?l:E)?s:void 0,{data:_}=(0,a.I)({queryKey:["poolDetailLink",w,M],queryFn:()=>w&&M?(0,P.VZ)(M):null,enabled:!!w&&!!M});return(0,i.jsxs)(c.A,{mx:"auto",my:"24px",maxWidth:"1200px",children:[(0,i.jsx)(p.Ay,{mb:"24px",children:(0,i.jsxs)(m.A,{children:[(0,i.jsx)(h.Y,{to:"/liquidity/pools",children:(0,i.jsx)(B,{children:b("Farms")})}),w&&M&&_&&(0,i.jsx)(h.Y,{to:_,children:(0,i.jsx)(B,{children:b("Pool Detail")})}),(0,i.jsx)(x.A,{alignItems:"center",gap:"4px",children:(0,i.jsx)(d.A,{children:b("Add Liquidity")})})]})}),(0,i.jsx)(g.I,{linkType:"addLiquidity",poolInfo:M,chainId:w,currency0:L,currency1:O,isInverted:F,onInvertPrices:q,poolId:null==M?void 0:M.poolId,price:null==D?void 0:D.computePoolInfo.currentPrice,overrideAprDisplay:{aprDisplay:M?(0,i.jsx)(N,{pool:M,fontSize:k?"20px":"24px"}):(0,i.jsx)(i.Fragment,{}),roiCalculator:(0,i.jsx)(i.Fragment,{})}}),A]})}var F=n(311560),q=n(673384),L=n(961862),O=n(985148),_=n(118708),$=n(920820),Y=n(636236),z=n(37735),V=n(687287),Z=n(642984),W=n(859886),H=n(85642),Q=n(206016),G=n(776484);let K=(0,s.I4)(d.A).withConfig({componentId:"sc-5011af1a-0"})(["color:",";transition:opacity 0.2s ease;&:hover{opacity:0.8;}"],e=>{let{theme:t}=e;return t.colors.primary60}),X=(0,O.eU)(Q.b.V3);function J(e){var t,n,l,s;let{children:y}=e,{t:A}=(0,f.A)(),{chainId:b}=(0,o.ax)(),{isMobile:w}=(0,u.A)(),[j]=(0,_.fp)(X),{currencyIdA:k,currencyIdB:C,feeAmount:I}=(0,T.J)(),S=(0,v.H2)(k),R=(0,v.H2)(C),E=(0,Y.Ay)({tokenA:S,tokenB:R}),{farms:M}=(0,L.N)(b),N=(0,r.useMemo)(()=>
29{if(S&&R){let[e,t]=[S.wrapped,R.wrapped],[n,i]=e.sortsBefore(t)?[e,t]:[t,e];return null==M?void 0:M.find(e=>e.token.equals(n)&&e.quoteToken.equals(i))}return null},[S,R,M]),{largestUsageFeeTier:B}=(0,$.g)(S,R),D=(0,r.useMemo)(()=>{var e;return(null==S?void 0:S.wrapped)&&(null==R?void 0:R.wrapped)?j===Q.b.V3?I?q.bC.getAddress(S.wrapped,R.wrapped,I):N?q.bC.getAddress(S.wrapped,R.wrapped,N.feeAmount):B?q.bC.getAddress(S.wrapped,R.wrapped,B):void 0:j===Q.b.V2?F.Rm.getAddress(S.wrapped,R.wrapped):j===Q.b.STABLE?null==(e=E.stableSwapConfig)?void 0:e.stableSwapAddress:void 0:void 0},[null==S?void 0:S.wrapped,I,null==R?void 0:R.wrapped,j,E.stableSwapConfig,B,N]),O=(0,Z.qX)({poolAddress:D,chainId:b}),J=(0,r.useMemo)(()=>{var e,t,n;return!!((null==O?void 0:O.token0)&&(null==O?void 0:O.token1)&&(null==O||null==(e=O.token0)?void 0:e.wrapped.address)!==(null==O||null==(t=O.token1)?void 0:t.wrapped.address)&&(null==O||null==(n=O.token0)?void 0:n.wrapped.address)!==(null==S?void 0:S.wrapped.address))},[O,S]),{handleInvertCurrencies:ee}=(0,U.C)({currencyIdA:k,currencyIdB:C,feeAmount:I}),{data:et}=(0,a.I)({queryKey:["poolDetailLink",b,O],queryFn:()=>b&&O?(0,P.VZ)(O):null,enabled:!!b&&!!O}),en=null!=(n=null!=(t=null==O?void 0:O.token0)?t:S)?n:void 0,ei=null!=(s=null!=(l=null==O?void 0:O.token1)?l:R)?s:void 0,{price:er}=(0,z.A)(j===Q.b.V3?en:void 0,j===Q.b.V3?ei:void 0,I,null!=S?S:void 0),[,el]=(0,W.ek)(j===Q.b.V2?en:void 0,j===Q.b.V2?ei:void 0),{pair:eo}=(0,H.v)(j===Q.b.STABLE?en:void 0,j===Q.b.STABLE?ei:void 0),ea=(0,r.useMemo)(()=>{try{if(j===Q.b.V3&&er)return er;if(j===Q.b.V2&&el&&S)return el.priceOf(S.wrapped);if(j===Q.b.STABLE&&eo&&S)return eo.priceOf(S)}catch(e){console.error("Error computing on-chain price:",e)}},[j,er,el,eo,S]),es=(0,V.xm)(ea),ed=(0,r.useMemo)(()=>{let e,t;if(!O)return null;try{j===Q.b.V2||j===Q.b.STABLE?(e=J?null==es?void 0:es.toFixed(18):null==es?void 0:es.invert().toFixed(18),t=J?null==es?void 0:es.invert().toFixed(18):null==es?void 0:es.toFixed(18)):(e=null==es?void 0:es.invert().toFixed(18),t=null==es?void 0:es.toFixed(18))}catch(e){console.error("Error formatting on-chain price:",e)}return{...O,token0Price:null!=e?e:O.token0Price,token1Price:null!=t?t:O.token1Price}},[O,es,J,j]);return(0,i.jsxs)(c.A,{mx:"auto",my:"24px",maxWidth:"1200px",children:[(0,i.jsx)(p.Ay,{mb:"24px",children:(0,i.jsxs)(m.A,{children:[(0,i.jsx)(h.Y,{to:"/liquidity/pools",children:(0,i.jsx)(K,{children:A("Farms")})}),b&&O&&et&&(0,i.jsx)(h.Y,{to:et,children:(0,i.jsx)(K,{children:A("Pool Detail")})}),(0,i.jsx)(x.A,{alignItems:"center",gap:"4px",children:(0,i.jsx)(d.A,{children:A("Add Liquidity")})})]})}),(0,i.jsx)(g.I,{linkType:"addLiquidity",poolInfo:ed,chainId:b,currency0:en,currency1:ei,isInverted:J,onInvertPrices:ee,poolId:D,overrideAprDisplay:j===Q.b.V3?{aprDisplay:(0,i.jsx)(G.C,{pool:O,inverted:J,showTitle:!1,derived:!0,showApyButton:!1,fontSize:w?"20px":"24px"}),roiCalculator:(0,i.jsx)(G.C,{pool:O,inverted:J,showTitle:!1,derived:!0,showApyText:!1,fontSize:w?"20px":"24px"})}:void 0}),y]})}function ee(e){let{children:t}=e,{chainId:n}=(0,o.ax)();return(0,l.fT)(n)?(0,i.jsx)(D,{children:t}):(0,i.jsx)(J,{children:t})}var et=n(179087),en=n(364698),ei=n(579014),er=n(463532),el=n(902609),eo=n(286750),ea=n(796147),es=n(807543),ed=n(150591),eu=n(24153),ec=n(525033),ep=n(862373),em=n(157657),ex=n(835490),eh=n(465840),ef=n(389213),ev=n(659197),ey=n(437862),eg=n(511820);let eA=e=>{let{poolInfo:t,totalUsdValue:n}=e,{lpApr:l,cakeAprValue:o,merklApr:a,incentraApr:s}=(e=>{let t=e?`${e.chainId}:${e.lpAddress}`:null,n=(null==e?void 0:e.protocol)!==ev.Zs.STABLE,{lpApr:i,cakeApr:l,merklApr:o,incentraApr:a}=(0,ey.nY)(t,null!=e?e:null,n);return(0,r.useMemo)(()=>{var e;return{lpApr:parseFloat(null!=i?i:"0")||0,cakeAprValue:parseFloat(null!=(e=null==l?void 0:l.value)?e:"0")||0,merklApr:parseFloat(null!=o?o:"0")||0,incentraApr:parseFloat(null!=a?a:"0")||0}},[i,null==l?void 0:l.value,o,a])})(t);return(0,i.jsx)(eg.E,{lpApr:l,cakeAprValue:o,merklApr:a,incentraApr:s,totalUsdValue:n})};var eb=n(133843),ew=n(265394),ej=n(34334),ek=n(557423),eC=n(353540),eI=n(183693),eS=n(296123),eR=n(262453),eE=n(259145);function eM(e){var t,n,r,l;let{account:o,isWrongNetwork:a,addIsUnsupported:s,addIsWarning:d,shouldShowApprovalGroup:u,showFieldAApproval:c,showFieldBApproval:p,approvalA:m,approvalB:x,approveACallback:h,approveBCallback:v,currencies:y,buttonDisabled:g,errorText:A,expertMode:b,onAdd:w,onPresentAddLiquidityModal:j}=e,{t:k}=(0,f.A)();return s||d?(0,i.jsx)(ek.A,{disabled:!0,mb:"4px",children:k("Unsupported Asset")}):o?a?(0,i.jsx)(eI.O,{}):(0,i.jsxs)(ea.mm,{gap:"md",children:[u&&(0,i.jsxs)(eu.JA,{style:{gap:"8px"},children:[c&&(0,i.jsx)(ek.A,{onClick:h,disabled:m===eR.h$.PENDING,width:"100%",children:m===eR.h$.PENDING?(0,i.jsx)(eC.n,{children:k("Enabling %asset%",{asset:null==(t=y[ex.O9.CURRENCY_A])?void 0:t.symbol})}):k("Enable %asset%",{asset:null==(n=y[ex.O9.CURRENCY_A])?void 0:n.symbol})}),p&&(0,i.jsx)(ek.A,{onClick:v,disabled:x===eR.h$.PENDING,width:"100%",children:x===eR.h$.PENDING?(0,i.jsx)(eC.n,{children:k("Enabling %asset%",{asset:null==(r=y[ex.O9.CURRENCY_B])?void 0:r.symbol})}):k("Enable %asset%",{asset:null==(l=y[ex.O9.CURRENCY_B])?void 0:l.symbol})})]}),(0,i.jsx)(eI.O,{variant:g?"danger":"primary",onClick:()=>{b?w():j(),(0,eE.uL)()},disabled:g,children:A||k("Add")})]}):(0,i.jsx)(eS.A,{width:"100%"})}function eN(e){var t,n,l,a,s;let{formattedAmounts:u,shouldShowApprovalGroup:c,approveACallback:m,approvalA:h,approvalB:v,approveBCallback:y,showFieldBApproval:g,showFieldAApproval:A,currencies:b,buttonDisabled:w,onAdd:j,onPresentAddLiquidityModal:k,errorText:C,onFieldAInput:I,onFieldBInput:S,poolTokenPercentage:R,executionSlippage:E,loading:M,maxAmounts:N,inputAmountsTotalUsdValue:P}=e,{t:T}=(0,f.A)(),{account:U,isWrongNetwork:B}=(0,o.W7)(),D=(0,em.LU)(null==b?void 0:b.CURRENCY_A,null==b?void 0:b.CURRENCY_B),F=(0,em.aS)(null==b?void 0:b.CURRENCY_A,null==b?void 0:b.CURRENCY_B),q=(0,ep.xf)(),L=(0,eb.S)({baseCurrency:b[ex.O9.CURRENCY_A],quoteCurrency:b[ex.O9.CURRENCY_B],baseInputValue:null!=(n=u[ex.O9.CURRENCY_A])?n:"",quoteInputValue:null!=(l=u[ex.O9.CURRENCY_B])?l:"",onBaseInput:I,onQuoteInput:S,baseTokenRatio:.5,independentQuote:!0}),{stableSwapConfig:O}=(0,r.useContext)(Y.jq)||{},_=(0,ey.qX)({poolAddress:null==O?void 0:O.stableSwapAddress,chainId:null==O||null==(t=O.liquidityToken)?void 0:t.chainId});return(0,i.jsx)(p.Ay,{mx:"auto",pb:"16px",width:"100%",maxWidth:[null,null,null,null,"480px"],children:(0,i.jsxs)(ea.VP,{gap:"16px",children:[(0,i.jsx)(eA,{poolInfo:_,totalUsdValue:L.totalUsdValue}),(0,i.jsx)(es.A,{children:(0,i.jsx)(ed.A,{children:(0,i.jsxs)(ea.mm,{children:[(0,i.jsx)(ef.N,{baseCurrency:b[ex.O9.CURRENCY_A],quoteCurrency:b[ex.O9.CURRENCY_B],baseInputValue:null!=(a=u[ex.O9.CURRENCY_A])?a:"",quoteInputValue:null!=(s=u[ex.O9.CURRENCY_B])?s:"",onBaseInput:L.onBaseInputWrapped,onQuoteInput:L.onQuoteInputWrapped,usdDisplayValue:L.usdDisplayValue,onUsdInput:L.onUsdInput,canUseUsdMode:L.canUseUsdMode,totalUsdValue:L.totalUsdValue,isDepositEnabled:!0,isBaseDepositEnabled:!0,isQuoteDepositEnabled:!0,baseBalance:N[ex.O9.CURRENCY_A],quoteBalance:N[ex.O9.CURRENCY_B],maxBaseAmount:N[ex.O9.CURRENCY_A],maxQuoteAmount:N[ex.O9.CURRENCY_B],basePriceUsd:L.basePriceUsd,quotePriceUsd:L.quotePriceUsd,showSettings:!1}),(0,i.jsxs)(ea.VP,{mt:"16px",gap:"16px",children:[(0,i.jsxs)(eu.JA,{children:[(0,i.jsxs)(x.A,{gap:"4px",alignItems:"center",children:[(0,i.jsx)(d.A,{color:"textSubtle",children:T("Slippage bonus")}),(0,i.jsx)(ec.PT,{text:T("Extra LP tokens earned when depositing the low-balance coin in the pool, appearing as a bonus for helping rebalance."),placement:"top-start",mt:"1px"})]}),(0,i.jsx)(ej._,{slippage:E,loading:M})]}),(0,i.jsxs)(eu.JA,{children:[(0,i.jsx)(d.A,{color:"textSubtle",children:T("Slippage Tolerance")}),(0,i.jsx)(ew.AK,{})]}),(0,i.jsxs)(eu.JA,{children:[(0,i.jsx)(d.A,{color:"textSubtle",children:T("Your share in pool")}),(0,i.jsx)(d.A,{children:R?`${null==R?void 0:R.toSignificant(4)}
29%`:"-"})]})]}),(0,i.jsx)(p.Ay,{mt:"8px",children:(0,i.jsx)(eh.u,{size:"sm"})}),(0,i.jsx)(p.Ay,{mt:"16px",children:(0,i.jsx)(eM,{account:U,isWrongNetwork:B,addIsUnsupported:D,addIsWarning:F,shouldShowApprovalGroup:c,showFieldAApproval:A,showFieldBApproval:g,approvalA:h,approvalB:v,approveACallback:m,approveBCallback:y,currencies:b,buttonDisabled:w,errorText:C,expertMode:q,onAdd:j,onPresentAddLiquidityModal:k})})]})})})]})})}var eP=n(226464),eT=n(501823),eU=n(430586),eB=n(399832),eD=n(779243),eF=n(856870),eq=n(419041),eL=n(733775),eO=n(899297),e_=n(326848),e$=n(182063);let eY=e=>{let{baseCurrency:t,quoteCurrency:n,feeAmount:i}=e,l=(0,e_.useRouter)(),o=(0,eq.Ay)(),a=(0,r.useMemo)(()=>{var e,t;return!!l.isReady&&((null==(e=l.query.currency)?void 0:e.includes(o.symbol))||(null==(t=l.query.currency)?void 0:t.includes(o.symbol.toLowerCase()))||!1)},[l.query.currency,o.symbol,l.isReady]);return{canUseNativeCurrency:(0,r.useMemo)(()=>(null==t?void 0:t.wrapped.address)===o.wrapped.address||(null==n?void 0:n.wrapped.address)===o.wrapped.address,[t,o,n]),handleUseNative:(0,r.useCallback)(e=>{let{checked:r}=e.target;if(t&&n)if(r){let e=(null==t?void 0:t.wrapped.address)===o.wrapped.address?[o.symbol,(0,e$.A)(n)]:[(0,e$.A)(t),o.symbol];i&&e.push(i.toString()),l.replace({query:{...l.query,currency:e}})}else{var a,s;let e=[null!=(a=null==t?void 0:t.wrapped.address)?a:"",null!=(s=null==n?void 0:n.wrapped.address)?s:""];i&&e.push(i.toString()),l.replace({query:{...l.query,currency:e}})}},[t,i,o,n,l]),useNativeInstead:a}};function ez(e){var t,n,l,a;let{formattedAmounts:s,addIsUnsupported:u,shouldShowApprovalGroup:c,approveACallback:m,revokeACallback:x,currentAllowanceA:h,approvalA:v,approvalB:y,approveBCallback:g,revokeBCallback:A,currentAllowanceB:b,showFieldBApproval:w,showFieldAApproval:j,currencies:k,buttonDisabled:C,onAdd:I,onPresentAddLiquidityModal:S,errorText:R,onFieldAInput:E,onFieldBInput:M,maxAmounts:N,isOneWeiAttack:P,pair:T}=e,{t:U}=(0,f.A)(),{account:B,chainId:D,isWrongNetwork:q}=(0,o.W7)(),L=(0,ep.xf)(),O=(0,eq.Ay)(),_=null,{canUseNativeCurrency:$,handleUseNative:Y,useNativeInstead:z}=eY({baseCurrency:k[ex.O9.CURRENCY_A],quoteCurrency:k[ex.O9.CURRENCY_B],feeAmount:0}),V=(0,eb.S)({baseCurrency:k[ex.O9.CURRENCY_A],quoteCurrency:k[ex.O9.CURRENCY_B],baseInputValue:null!=(t=s[ex.O9.CURRENCY_A])?t:"",quoteInputValue:null!=(n=s[ex.O9.CURRENCY_B])?n:"",onBaseInput:E,onQuoteInput:M,baseTokenRatio:.5}),Z=(0,ey.qX)({poolAddress:null==T?void 0:T.liquidityToken.address,chainId:null==T?void 0:T.liquidityToken.chainId}),W=(0,r.useMemo)(()=>T&&(0,eL.Bz)(F.Rm.getAddress(T.token0,T.token1),"address",D)||void 0,[T,D]);return _=u?(0,i.jsx)(ek.A,{disabled:!0,mb:"4px",children:U("Unsupported Asset")}):B?q?(0,i.jsx)(eI.O,{}):(0,i.jsxs)(ea.mm,{gap:"md",children:[(0,i.jsx)(eO.A,{approvalA:v,approvalB:y,showFieldAApproval:j,showFieldBApproval:w,approveACallback:m,approveBCallback:g,revokeACallback:x,revokeBCallback:A,currencies:k,currentAllowanceA:h,currentAllowanceB:b,shouldShowApprovalGroup:c}),P?(0,i.jsx)(eP.A,{variant:"warning",children:(0,i.jsxs)(eT.A,{flexDirection:"column",children:[(0,i.jsx)(eP.J,{children:U("Adding liquidity to this V2 pair is currently not available on PancakeSwap UI. Please follow the instructions to resolve it using blockchain explorer.")}),(0,i.jsx)(eU.A,{href:"https://docs.pancakeswap.finance/products/pancakeswap-exchange/faq#why-cant-i-add-liquidity-to-a-pair-i-just-created",mt:"0.25rem",children:U("Learn more how to fix")}),(0,i.jsx)(eB.A,{useBscCoinFallback:D?eF.jc.includes(D):void 0,href:W,mt:"0.25rem",children:U("View pool on explorer")})]})}):null,(0,i.jsx)(eI.O,{variant:C?"danger":"primary",onClick:()=>{L?I():S(),(0,eE.uL)()},disabled:C,children:R||U("Add")})]}):(0,i.jsx)(eS.A,{width:"100%"}),(0,i.jsx)(p.Ay,{mx:"auto",pb:"16px",width:"100%",maxWidth:[null,null,null,null,"480px"],children:(0,i.jsxs)(ea.VP,{gap:"16px",children:[(0,i.jsx)(eA,{poolInfo:Z,totalUsdValue:V.totalUsdValue}),(0,i.jsx)(es.A,{children:(0,i.jsx)(ed.A,{children:(0,i.jsxs)(ea.mm,{children:[(0,i.jsx)(ef.N,{baseCurrency:k[ex.O9.CURRENCY_A],quoteCurrency:k[ex.O9.CURRENCY_B],baseInputValue:null!=(l=s[ex.O9.CURRENCY_A])?l:"",quoteInputValue:null!=(a=s[ex.O9.CURRENCY_B])?a:"",onBaseInput:V.onBaseInputWrapped,onQuoteInput:V.onQuoteInputWrapped,usdDisplayValue:V.usdDisplayValue,onUsdInput:V.onUsdInput,canUseUsdMode:V.canUseUsdMode,totalUsdValue:V.totalUsdValue,isDepositEnabled:!0,isBaseDepositEnabled:!0,isQuoteDepositEnabled:!0,baseBalance:N[ex.O9.CURRENCY_A],quoteBalance:N[ex.O9.CURRENCY_B],maxBaseAmount:N[ex.O9.CURRENCY_A],maxQuoteAmount:N[ex.O9.CURRENCY_B],basePriceUsd:V.basePriceUsd,quotePriceUsd:V.quotePriceUsd,showSettings:!0}),$&&(0,i.jsxs)(eu.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{color:"textSubtle",children:["Use ",O.symbol," instead"]}),(0,i.jsx)(eD.A,{scale:"sm",checked:z,onChange:Y})]}),(0,i.jsx)(p.Ay,{mt:"16px",children:_})]})})})]})})}var eV=n(734658),eZ=n(549333),eW=n(796259),eH=n(92292),eQ=n(770773),eG=n(559307),eK=n(955647),eX=n(550062),eJ=n(82029),e0=n(265349),e1=n(698409),e2=n(375634),e6=n(91168),e8=n(698163);let e3=e=>{var t;let{poolInfo:n,outOfRange:r,totalUsdValue:l,invertPrice:o}=e,{lpApr:a,cakeApr:s,merklApr:d,incentraApr:u}=(0,e8.L4)(n,o);return r?null:(0,i.jsx)(eg.E,{lpApr:null!=a?a:0,cakeAprValue:parseFloat(null!=(t=null==s?void 0:s.value)?t:"0")||0,merklApr:null!=d?d:0,incentraApr:null!=u?u:0,totalUsdValue:l})},e9=e=>{let{poolInfo:t,outOfRange:n,totalUsdValue:r,invertPrice:l}=e;return t?(0,i.jsx)(e3,{poolInfo:t,outOfRange:n,totalUsdValue:r,invertPrice:l}):null};var e4=n(332083),e5=n(810286),e7=n(290387),te=n(469079),tt=n(214885),tn=n(226207),ti=n(114041),tr=n(270483),tl=n(782038),to=n(743818),ta=n(555967),ts=n(519901),td=n(909114),tu=n(772763),tc=n(112788),tp=n(306411),tm=n(178852),tx=n(909725),th=n(241439),tf=n(459247),tv=n(189346),ty=n(975644),tg=n(792118),tA=n(663257),tb=n(395153),tw=n(495815),tj=n(918279),tk=n(52093),tC=n(796416),tI=n(495964),tS=n(236088),tR=n(337049),tE=n(368177),tM=n(426593),tN=n(64523),tP=n(284087),tT=n(427866),t
29U=n(343954);let tB=(0,s.I4)(e0.p).withConfig({componentId:"sc-3f9e75d6-0"})(["background-color:",";box-shadow:",";border-radius:16px;padding:8px 16px;font-size:16px;width:100%;margin-bottom:16px;"],e=>{let{theme:t}=e;return t.colors.input},e=>{let{theme:t,error:n}=e;return t.shadows[n?"warning":"inset"]}),tD=s.I4.span.withConfig({componentId:"sc-3f9e75d6-1"})(["display:inline-flex;width:8px;height:8px;border-radius:50%;background-color:",";"],e=>{let{theme:t,$color:n}=e;return t.colors[n]}),tF=(0,s.I4)(ea.mm).withConfig({componentId:"sc-3f9e75d6-2"})(["height:fit-content;grid-column:1;"]),tq=(0,s.I4)(ek.A).attrs({scale:"xs",variant:"text"}).withConfig({componentId:"sc-3f9e75d6-3"})(["height:24px;padding:4px 8px;font-size:12px;font-weight:600;border-radius:8px;display:flex;align-items:center;gap:4px;background:transparent;border:2px solid ",";color:",";"],e=>{let{theme:t}=e;return t.colors.primary},e=>{let{theme:t}=e;return t.colors.primary60});function tL(e){var t,n,l,a,s,c,m,h;let{feeAmount:v,baseCurrency:y,quoteCurrency:g,currencyIdA:A,currencyIdB:b}=e,j=(0,e_.useRouter)(),{isMobile:k}=(0,u.A)(),{data:C}=(0,tI.G)(),{sendTransactionAsync:I}=(0,tS.s)(),R=(0,eq.Ay)(),[E,M]=(0,r.useState)(!1),[N,P]=(0,r.useState)(),{t:T,currentLanguage:{locale:B}}=(0,f.A)(),D=(0,ep.xf)(),{canUseNativeCurrency:F,handleUseNative:L,useNativeInstead:O}=eY({baseCurrency:y,quoteCurrency:g,feeAmount:v}),_=(0,r.useMemo)(()=>(null==y?void 0:y.isNative)?y.wrapped:y,[y]),$=(0,r.useMemo)(()=>(null==g?void 0:g.isNative)?g.wrapped:g,[g]),Y=(0,ta.TA)(),{account:Z,chainId:W,isWrongNetwork:H}=(0,o.W7)(),{maxFeePerGas:G,maxPriorityFeePerGas:K}=(0,td.N)(W),X=(0,to.j6)(),J=(0,tp.OQ)(),[ee,et]=(0,r.useState)(eJ.PRESET_RANGE_ITEMS[0]),en=(0,r.useMemo)(()=>(0,tw.x)(ee.value,k),[ee.value,k]),ei=(0,S.oU)(),{independentField:er,typedValue:el,startPriceTypedValue:eo,leftRangeTypedValue:ec,rightRangeTypedValue:em}=ei,{pool:eh,ticks:eg,dependentField:eA,price:ew,pricesAtTicks:ej,parsedAmounts:eC,currencyBalances:eI,position:eS,noLiquidity:eM,currencies:eN,errorMessage:eT,hasInsufficentBalance:eU,invalidPool:eB,invalidRange:eF,outOfRange:eO,depositADisabled:e$,depositBDisabled:ez,invertPrice:e0,ticksAtLimit:e8,tickSpaceLimits:e3}=(0,z.A)(null!=y?y:void 0,null!=g?g:void 0,v,null!=y?y:void 0,void 0,ei),tL=(0,r.useMemo)(()=>{if(eh){let e=tr.w[eh.chainId];if(e)return 0===e.length||e.includes(q.bC.getAddress(eh.token0,eh.token1,eh.fee))}return!1},[eh]),{onFieldAInput:tO,onFieldBInput:t_,onLeftRangeInput:t$,onRightRangeInput:tY,onStartPriceInput:tz,onBothRangeInput:tV}=(0,tU.i)(eM),tZ=(0,V.hx)(null==y?void 0:y.wrapped,null==g?void 0:g.wrapped),tW=(0,r.useCallback)((e,t)=>{tV({leftTypedValue:tZ(e),rightTypedValue:tZ(t)})},[tZ,tV]),tH=(0,r.useCallback)(e=>{t$(tZ(e))},[tZ,t$]),tQ=(0,r.useCallback)(e=>{tY(tZ(e))},[tZ,tY]),[tG,tK]=(0,r.useState)(!1);(0,r.useEffect)(()=>{tK(!1)},[y,g,v]),(0,r.useEffect)(()=>{v&&(nL(void 0),tV({leftTypedValue:void 0,rightTypedValue:void 0}))},[v]);let tX=(0,S.VF)(),[,,tJ]=(0,ts.r)(null!=y?y:void 0,null!=g?g:void 0),t0=(0,V.xm)(tJ),[t1]=(0,tu.g)(),[t2,t6]=(0,r.useState)(""),t8=(0,V.wG)(eN[ex.O9.CURRENCY_A]),t3=(0,V.wG)(eN[ex.O9.CURRENCY_B]),t9=(0,r.useMemo)(()=>({[ex.O9.CURRENCY_A]:t8,[ex.O9.CURRENCY_B]:t3}),[t8,t3]),t4=(0,r.useMemo)(()=>{var e;return{[er]:el,[eA]:null!=(e=t9[eA](eC[eA],6))?e:""}},[eA,er,el,eC,t9]),{totalUsdValue:t5}=(0,tR.t)({parsedAmountA:eC[ex.O9.CURRENCY_A],parsedAmountB:eC[ex.O9.CURRENCY_B]}),t7=(0,r.useMemo)(()=>{if(eh)try{return q.bC.getAddress(eh.token0,eh.token1,eh.fee)}catch{return}},[eh]),ne=(0,ey.qX)({poolAddress:t7,chainId:null==eh?void 0:eh.chainId}),nt=(0,r.useMemo)(()=>[ex.O9.CURRENCY_A,ex.O9.CURRENCY_B].reduce((e,t)=>({...e,[t]:(0,th.r)(eI[t])}),{}),[eI]),nn=null==(t=(0,ta.TA)())?void 0:t.address,{approvalState:ni,approveCallback:nr,revokeCallback:nl,currentAllowance:no}=(0,eR.en)(eC[ex.O9.CURRENCY_A],nn),{approvalState:na,approveCallback:ns,revokeCallback:nd,currentAllowance:nu}=(0,eR.en)(eC[ex.O9.CURRENCY_B],nn),[nc]=(0,ep.uZ)(),np=(0,r.useCallback)(e=>{let{feeAmount:t}=e;!t||j.pathname.includes("stable")||j.pathname.includes("v2")||j.replace({query:{...j.query,currency:t?[A,b,t.toString()]:[A,b]}},void 0,{shallow:!0})},[A,b,j]),nm=(0,r.useCallback)(async()=>{var e,t,n,i,r,l,o,a,s,d,u,c,p,m;if((0,eE.aF)(),!W||!C||!Z||!nn||!Y||!y||!g||!eS||!t1)return;if((null==eS?void 0:eS.liquidity)===0n)return void P(T("The liquidity of this position is 0. Please try increasing the amount."));let x=y.isNative?y:g.isNative?g:void 0,{calldata:h,value:f}=q.uy.addCallParameters(eS,{slippageTolerance:(0,tm.aW)(nc),recipient:Z,deadline:t1.toString(),useNative:x,createPool:eM}),A=(0,tx.cf)(null!=(r=null==(t=eC[ex.O9.CURRENCY_A])||null==(e=t.quotient)?void 0:e.toString())?r:"0",y.decimals,4),b=(0,tx.cf)(null!=(l=null==(i=eC[ex.O9.CURRENCY_B])||null==(n=i.quotient)?void 0:n.toString())?l:"0",g.decimals,4),w=null!=(o=t8(eC[ex.O9.CURRENCY_A],4))?o:A,j=null!=(a=t3(eC[ex.O9.CURRENCY_B],4))?a:b,k=(0,tf.bD)({account:Z,chainId:W,runtime:X});M(!0),(0,tf.Dt)("liquidity_add_started",{...k,pool_type:"v3",token_a_symbol:null!=(s=y.symbol)?s:null,token_a_amount:A,token_b_symbol:null!=(d=g.symbol)?d:null,token_b_amount:b,no_liquidity:eM,fee_tier:null!=v?v:null});let S={data:h,to:nn,value:(0,tA.uU)(f),account:Z};try{let e=(0,tg.Qr)({chainId:W});if(!e)throw Error("Public client unavailable");let t=await e.estimateGas(S),n=await I({...S,gas:(0,eL.KL)(t),maxFeePerGas:G,maxPriorityFeePerGas:K});(0,eE.Mg)(),J({hash:n},{type:"add-liquidity-v3",summary:`Add ${w} ${null==y?void 0:y.symbol} and ${j} ${null==g?void 0:g.symbol}`}),t6(n),tX(n),(0,tf.Dt)("liquidity_add_succeeded",{...k,pool_type:"v3",token_a_symbol:null!=(u=y.symbol)?u:null,token_a_amount:A,token_b_symbol:null!=(c=g.symbol)?c:null,token_b_amount:b,tx_hash:n,no_liquidity:eM,fee_tier:null!=v?v:null})}catch(e){console.error("Failed to send transaction",e),(0,tf.Dt)("liquidity_add_failed",{...k,pool_type:"v3",token_a_symbol:null!=(p=y.symbol)?p:null,token_a_amount:A,token_b_symbol:null!=(m=g.symbol)?m:null,token_b_amount:b,rejected_by_user:(0,tv.U)(e),no_liquidity:eM,fee_tier:null!=v?v:null,...(0,tf.fx)(e,(0,tv.U)(e)?"Transaction rejected.":void 0)}),(0,tv.U)(e)||P((0,ty.w)(e,T))}finally{M(!1)}},[Z,J,nc,y,W,t1,nn,eM,tX,eC,eS,Y,g,I,C,T,t8,t3,G,K]),nx=(0,r.useCallback)(()=>{t2&&tO(""),t6(""),P(void 0)},[tO,t2]),{shouldBlock:nh}=(0,tl.Wd)(null==eN?void 0:eN.CURRENCY_A,null==eN?void 0:eN.CURRENCY_B),{[ti.zm.LOWER]:nf,[t
29i.zm.UPPER]:nv}=eg,{[ti.zm.LOWER]:ny,[ti.zm.UPPER]:ng}=ej,{data:nA}=(0,te.y)(null!=y?y:void 0,!!y),{data:nb}=(0,te.y)(null!=g?g:void 0,!!g),nw=null!=(l=null==eh?void 0:eh.token0)?l:null==ew?void 0:ew.baseCurrency,nj=null!=(a=null==eh?void 0:eh.token1)?a:null==ew?void 0:ew.quoteCurrency,nk=(0,r.useMemo)(()=>{if(null==eh?void 0:eh.sqrtRatioX96)return eh.sqrtRatioX96;if(ew)try{return(0,q.r_)(ew.numerator,ew.denominator)}catch{return}},[null==eh?void 0:eh.sqrtRatioX96,ew]),nC=(0,r.useMemo)(()=>!y||!nw||y.wrapped.address.toLowerCase()===nw.address.toLowerCase(),[y,nw]),nI=(0,e7.y)(nk,nf,nv,null==nw?void 0:nw.decimals,null==nj?void 0:nj.decimals,nC?null!=nA?nA:0:null!=nb?nb:0,nC?null!=nb?nb:0:null!=nA?nA:0),nS=(0,r.useMemo)(()=>nC?nI:1-nI,[nC,nI]),nR=(0,eb.S)({baseCurrency:null!=y?y:void 0,quoteCurrency:null!=g?g:void 0,baseInputValue:null!=(s=t4[ex.O9.CURRENCY_A])?s:"",quoteInputValue:null!=(c=t4[ex.O9.CURRENCY_B])?c:"",onBaseInput:tO,onQuoteInput:t_,baseTokenRatio:nS,isBaseDepositEnabled:!e$,isQuoteDepositEnabled:!ez});(0,tP.x)(null==y?void 0:y.wrapped,null==g?void 0:g.wrapped);let{getDecrementLower:nE,getIncrementLower:nM,getDecrementUpper:nN,getIncrementUpper:nP,getSetFullRange:nT}=(0,tT.U)(null!=y?y:void 0,null!=g?g:void 0,v,nf,nv,eh),nU=ni!==eR.h$.APPROVED&&!!eC[ex.O9.CURRENCY_A],nB=na!==eR.h$.APPROVED&&!!eC[ex.O9.CURRENCY_B],nD=(0,r.useMemo)(()=>{var e,t,n,i;let r=e=>e?Number(e).toLocaleString(B,{maximumSignificantDigits:4}):"";return e$?{amount:r(t3(eC[ex.O9.CURRENCY_B],4)),symbol:(null==(n=eN[ex.O9.CURRENCY_B])?void 0:n.symbol)?eN[ex.O9.CURRENCY_B].symbol:""}:ez?{amount:r(t8(eC[ex.O9.CURRENCY_A],4)),symbol:(null==(i=eN[ex.O9.CURRENCY_A])?void 0:i.symbol)?eN[ex.O9.CURRENCY_A].symbol:""}:{amountA:r(t8(eC[ex.O9.CURRENCY_A],4)),symbolA:(null==(e=eN[ex.O9.CURRENCY_A])?void 0:e.symbol)?eN[ex.O9.CURRENCY_A].symbol:"",amountB:r(t3(eC[ex.O9.CURRENCY_B],4)),symbolB:(null==(t=eN[ex.O9.CURRENCY_B])?void 0:t.symbol)?eN[ex.O9.CURRENCY_B].symbol:""}},[e$,ez,eC,eN,t8,t3,B]),nF=(0,r.useMemo)(()=>eO?T("Supplying %amount% %symbol%",nD):T("Supplying %amountA% %symbolA% and %amountB% %symbolB%",nD),[T,eO,nD]),[nq,nL]=(0,r.useState)(),nO=(0,r.useRef)(!1),[n_,n$]=(0,r.useState)(null),[nY,nz]=(0,r.useState)(void 0),[nV]=(0,eZ.A)((0,i.jsx)(tt.A,{minWidth:["100%",null,"420px"],title:T("Add Liquidity"),customOnDismiss:nx,attemptingTxn:E,hash:t2,errorMessage:N,content:()=>(0,i.jsx)(eX.Y,{topContent:()=>eS?(0,i.jsx)(tM.e,{position:eS,inRange:!eO,ticksAtLimit:e8,baseCurrencyDefault:y}):null,bottomContent:()=>(0,i.jsx)(ek.A,{width:"100%",mt:"16px",onClick:nm,children:T("Add")})}),pendingText:nF}),!0,!0,"TransactionConfirmationModal"),nZ=(0,r.useCallback)(()=>{D?nm():nV(),(0,eE.uL)()},[D,nm,nV]),nW=(0,r.useMemo)(()=>{if(eh)return new eV.gm(eh.token0,eh.token1,2n**192n,eh.sqrtRatioX96*eh.sqrtRatioX96)},[eh]),[,nH]=(0,ts.e)(null==eh?void 0:eh.token0,null==eh?void 0:eh.token1,nW),nQ=(0,r.useMemo)(()=>void 0!==nH&&new e6.A(nH.toFixed(0)).abs().gt(5),[nH]),nG=(0,i.jsx)(tj.E,{addIsUnsupported:nh,account:null!=Z?Z:void 0,isWrongNetwork:!!H,approvalA:ni,approvalB:na,isValid:!eT&&!eF,showApprovalA:nU,approveACallback:nr,currentAllowanceA:no,revokeACallback:nl,currencies:eN,showApprovalB:nB,approveBCallback:ns,currentAllowanceB:nu,revokeBCallback:nd,parsedAmounts:eC,onClick:nZ,attemptingTxn:E,errorMessage:eT,buttonText:T("Add"),depositADisabled:e$,depositBDisabled:ez});(0,r.useEffect)(()=>{!nO.current&&nq?(nL(void 0),n$(null),nz(void 0)):nO.current&&(nO.current=!1)},[nO,nq,ec,em]);let nK=(0,r.useCallback)(e=>{nL(void 0),e||nz(void 0);let t=ew?parseFloat((e0?ew.invert():ew).toSignificant(8)):void 0;if(t){var n,i;tV({leftTypedValue:(0,tc.m)(null==y?void 0:y.wrapped,null==g?void 0:g.wrapped,(t*(null!=(n=null==e?void 0:e.initialMin)?n:e2.W[null!=v?v:q.dl.MEDIUM].initialMin)).toString()),rightTypedValue:(0,tc.m)(null==y?void 0:y.wrapped,null==g?void 0:g.wrapped,(t*(null!=(i=null==e?void 0:e.initialMax)?i:e2.W[null!=v?v:q.dl.MEDIUM].initialMax)).toString())})}},[ew,v,e0,tV,y,g]),nX=(0,r.useCallback)((e,t)=>{if(n$(e),null!==e)if(100===e)nz(void 0),tK(!0),nL(100),nO.current=!0;else{var n;v&&(null==(n=Q.T[v])?void 0:n[e])?(nz(void 0),nK(Q.T[v][e])):(nz(t),nK(t)),nL(e),nO.current=!0}},[nq,v,nK,tK]),nJ=(0,r.useCallback)(()=>{j.push("/liquidity/positions")},[j]),n0=(0,r.useCallback)(()=>
29{if(!e8[ti.zm.LOWER]&&!e8[ti.zm.UPPER]){var e,t,n;t$(null!=(e=e0?ny:null==ng?void 0:ng.invert())?e:void 0),tY(null!=(t=e0?ng:null==ny?void 0:ny.invert())?t:void 0),tO(null!=(n=t4[ex.O9.CURRENCY_B])?n:"")}},[e8,t$,tY,tO,e0,ny,ng,t4]),n1=(0,U.m)(),{handleInvertCurrencies:n2}=(0,U.C)({currencyIdA:A,currencyIdB:b,feeAmount:v});(0,r.useEffect)(()=>{if(n1){let{currencyIdA:e,currencyIdB:t}=n1;e&&t&&e!==A&&t!==b&&n0()}},[n1]);let n6=(0,r.useCallback)(()=>{var e,t;n2(),tz(null!=(t=null==ew||null==(e=ew.invert())?void 0:e.toSignificant(18))?t:"")},[ew,tz,n2]),{isLoading:n8,error:n3,formattedData:n9}=(0,tk.u)({currencyA:null!=y?y:void 0,currencyB:null!=g?g:void 0,feeAmount:v,interval:3e5}),{data:n4}=(0,tb.F)({period:ee.value,baseCurrency:null!=_?_:void 0,quoteCurrency:null!=$?$:void 0,chainId:null==y?void 0:y.chainId,protocol:ev.Zs.V3,poolId:eh?q.bC.getAddress(eh.token0,eh.token1,eh.fee):void 0}),n5=(0,r.useMemo)(()=>ew?e0?ew.invert():ew:void 0,[ew,e0]),n7=(0,V.xm)(n5),ie=(0,V.xm)(ny),it=(0,V.xm)(ng),ii=(0,V.jN)(n5),ir=(0,r.useMemo)(()=>(0,e4.X)(n9,ii),[n9,ii]),il=(0,r.useMemo)(()=>(0,e4.B)(n4,ii),[n4,ii]),io=(0,r.useCallback)(()=>{if(t0){let e=(0,eK.$g)(t0);e&&tz(e)}},[t0,tz]),{tooltip:ia,tooltipVisible:is,targetRef:id}=(0,w.A)(T("The price is an estimation of the current market price. Please verify before using it."),{avoidToStopPropagation:!0});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(tF,{children:(0,i.jsx)(es.A,{children:(0,i.jsx)(ed.A,{children:(0,i.jsxs)(ea.mm,{gap:"16px",children:[eM&&(0,i.jsxs)(p.Ay,{children:[(0,i.jsxs)(x.A,{gap:"8px",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsx)(eW.y,{mb:"8px",children:T("Set Starting Price")}),tJ?(0,i.jsxs)(x.A,{mb:"8px",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsx)("div",{}),(0,i.jsxs)(x.A,{gap:"4px",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsxs)("div",{ref:id,children:[(0,i.jsxs)(tq,{onClick:io,children:[(0,i.jsx)("span",{children:T("Use Market Price")}),(0,i.jsx)(eH.A,{color:"primary60",width:"18px"})]}),is&&ia]}),(0,i.jsxs)(e5.g3,{mode:"price",price:tJ,as:"span",color:"textSubtle",small:!0,children:[null==t0?void 0:t0.toSignificant(8)," ",null==g?void 0:g.symbol," per ",null==y?void 0:y.symbol]}),(0,i.jsx)(eQ.A,{role:"button",color:"primary60",onClick:n6,style:{cursor:"pointer"}})]})]}):(0,i.jsx)(eJ.RateToggle,{currencyA:y,handleRateToggle:n6})]}),(0,i.jsx)(eP.A,{variant:"warning",my:"8px",children:(0,i.jsxs)(eP.J,{children:[T("This pool must be initialized before you can add liquidity. To initialize, select a starting price for the pool. Then, enter your liquidity price range and deposit amount. Gas fees will be higher than usual due to the initialization transaction."),(0,i.jsx)("br",{}),(0,i.jsx)("br",{}),(0,i.jsx)("span",{style:{fontWeight:600},children:T("Fee-on transfer tokens and rebasing tokens are NOT compatible with V3.")})]})}),(0,i.jsxs)(x.A,{gap:"8px",alignItems:"baseline",justifyContent:"space-between",children:[(0,i.jsx)(tB,{className:"start-price-input",value:eo,onUserInput:tz}),(0,i.jsx)(d.A,{color:"textSubtle",children:null==g?void 0:g.symbol})]})]}),(0,i.jsxs)(eG.x,{disabled:!v||eB,children:[(0,i.jsxs)(x.A,{gap:"8px",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsx)(eW.y,{children:T("Set position range")}),!eM&&(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(tD,{$color:"primary"}),(0,i.jsx)(d.A,{color:"textSubtle",small:!0,children:T("Current Price")})]}),(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(tD,{$color:"secondary"}),(0,i.jsx)(d.A,{color:"textSubtle",small:!0,children:T("Position Range")})]}),(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(tD,{$color:"input"}),(0,i.jsx)(d.A,{color:"textSubtle",small:!0,children:T("Liquidity Depth")})]})]})]}),!eM&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(p.Ay,{mt:"22px",border:"1px solid",borderColor:"cardBorder",borderRadius:"24px",p:"8px",children:[(0,i.jsx)(x.A,{flexDirection:k?"column":"row",justifyContent:k?"flex-start":"space-between",gap:"16px",mb:"24px",children:(0,i.jsx)(eJ.PriceRangeDatePicker,{onChange:et,value:ee})}),(0,i.jsx)(e1.k,{isLoading:n8,zoomLevel:nY||(nq&&v?null===Q.T||void 0===Q.T||null==(n=Q.T[v])?void 0:n[nq]:void 0),baseCurrency:_,quoteCurrency:$,ticksAtLimit:e8,price:n7?parseFloat(n7.toSignificant(8)):void 0,priceLower:ie,priceUpper:it,onBothRangeInput:tW,onMinPriceInput:tH,onMaxPriceInput:tQ,formattedData:ir,priceHistoryData:il,axisTicks:en,error:n3,interactive:!0},null==y?void 0:y.wrapped.address)]})})]}),(0,i.jsxs)(eG.x,{disabled:!v||eB||eM&&!eo,gap:"16px",children:[!tG&&(0,i.jsx)(tN.A,{priceLower:ny,priceUpper:ng,getDecrementLower:nE,getIncrementLower:nM,getDecrementUpper:nN,getIncrementUpper:nP,onLeftRangeInput:t$,onRightRangeInput:tY,currencyA:y,currencyB:g,feeAmount:v,ticksAtLimit:e8,tickSpaceLimits:e3,quickAction:n_,handleQuickAction:nX}),tG&&(0,i.jsx)(eP.A,{variant:"warning",children:(0,i.jsxs)(p.Ay,{children:[(0,i.jsx)(d.A,{fontSize:"16px",children:T("Efficiency Comparison")}),(0,i.jsx)(d.A,{color:"textSubtle",children:T("Full range positions may earn less fees than concentrated positions.")}),(0,i.jsx)(ek.A,{mt:"16px",onClick:()=>{tK(!1),nT()},scale:"md",variant:"danger",children:T("I understand")})]})}),nQ?(0,i.jsx)(tC.Zw,{slippage:`${null==nH?void 0:nH.toFixed(0)} %`}):null,eO?(0,i.jsx)(eP.A,{variant:"warning",children:(0,i.jsx)(eu.JA,{children:(0,i.jsx)(d.A,{ml:"12px",fontSize:"12px",children:T("Your position will not earn fees or be used in trades until the market price moves into your range.")})})}):null,eF?(0,i.jsx)(eP.A,{variant:"warning",children:(0,i.jsx)(eP.J,{children:T("Invalid range selected. The min price must be lower than the max price.")})}):null]})]})})})}),(0,i.jsxs)(ea.VP,{gap:"16px",style:{height:"fit-content"},children:[eB||eM&&!eo?null:(0,i.jsx)(e9,{poolInfo:ne,outOfRange:eO,totalUsdValue:t5,invertPrice:e0}),(0,i.jsx)(es.A,{style:{height:"fit-content"},children:(0,i.jsxs)(ed.A,{children:[(0,i.jsx)(eG.x,{disabled:!y||!g,children:(0,i.jsx)(tE.A,{currencyA:null!=y?y:void 0,currencyB:null!=g?g:void 0,handleFeePoolSelect:np,feeAmount:v})}),(0,i.jsxs)(eG.x,{mt:"16px",style:{gridAutoRows:"max-content",gridAutoColumns:"100%"},gap:"8px",disabled:!v||eB||eM&&!eo||!ny&&!ng,children:[tL&&eU&&(0,i.jsx)(tn.E,{wrapperProps:{mb:"8px"},tickLower:nf,tickUpper:nv,pool:eh,baseCurrency:y,baseCurrencyAmount:t4[ex.O9.CURRENCY_A],quoteCurrency:g,quoteCurrencyAmount:t4[ex.O9.CURRENCY_B],onSubmit:nJ}),eB||eM&&!eo?null:(0,i.jsx)(ef.N,{baseCurrency:eN[ex.O9.CURRENCY_A],quoteCurrency:eN[ex.O9.CURRENCY_B],baseInputValue:null!=(m=t4[ex.O9.CURRENCY_A])?m:"",quoteInputValue:null!=(h=t4[ex.O9.CURRENCY_B])?h:"",onBaseInput:nR.onBaseInputWrapped,onQuoteInput:nR.onQuoteInputWrapped,usdDisplayValue:nR.usdDisplayValue,onUsdInput:nR.onUsdInput,canUseUsdMode:nR.canUseUsdMode,totalUsdValue:nR.totalUsdValue,isDepositEnabled:!eB&&!eF,isBaseDepositEnabled:!e$,isQuoteDepositEnabled:!ez,baseBalance:eI[ex.O9.CURRENCY_A],quoteBalance:eI[ex.O9.CURRENCY_B],maxBaseAmount:nt[ex.O9.CURRENCY_A],maxQuoteAmount:nt[ex.O9.CURRENCY_B],basePriceUsd:nR.basePriceUsd,quotePriceUsd:nR.quotePriceUsd,disabledMessage:eM?T("Set starting price and price range first"):T("Set price range first"),baseDisabledMessage:e$?eB?T("Set price range first"):T("The price range is outside current pool price"):void 0,quoteDisabledMessage:ez?eB?T("Set price range first"):T("The price range is outside current pool price"):void 0,showSettings:!0}),F&&(0,i.jsxs)(eu.JA,{mt:"8px",children:[(0,i.jsxs)(d.A,{color:"textSubtle",children:["Use ",R.symbol," instead"]}),(0,i.jsx)(eD.A,{scale:"sm",checked:O,onChange:L})]}),(0,i.jsx)(p.Ay,{mt:"8px",children:nG})]})]})})]})]})}var tO=n(697300),t_=n(630806),t$=n(420248),tY=n(18201),tz=n(266283),tV=n(747292),tZ=n(432594),tW=n(504304),tH=n(573271),tQ=n(767365),tG=n(992842),tK=n(448390),tX=n(112616),tJ=n(68317),t0=n(570295),t1=n(829715),t2=n(142511),t6=n(354117),t8=n(72181),t3=n(520457),t9=n(924627),t4=n(681941),t5=n(145142),t7=n(586348);let ne=(0,s.I4)(e0.p).withConfig({componentId:"sc-5d9a35e1-0"})(["background-color:",";box-shadow:",";border-radius:16px;padding:8px 16px;font-size:16px;width:100%;margin-bottom:16px;"],e=>{let{theme:t}=e;return t.colors.input},e=>{let{theme:t,error:n}=e;return t.shadows[n?"warning":"inset"]}),nt=s.I4.span.withConfig({componentId:"sc-5d9a35e1-1"})(["display:inline-flex;width:8px;height:8px;border-radius:50%;background-color:",";"],e=>{let{theme:t,$color:n}=e;return t.colors[n]}),nn=(0,s.I4)(ea.mm).withConfig({componentId:"sc-5d9a35e1-2"})(["height:fit-content;grid-column:1;"]),ni=(0,s.I4)(ek.A).attrs({scale:"xs",variant:"text"}).withConfig({componentId:"sc-5d9a35e1-3"})(["height:24px;padding:4px 8px;font-size:12px;font-weight:600;border-radius:8px;display:flex;align-items:center;gap:4px;background:transparent;border:2px solid ",";color:",";"],e=>{let{theme:t}=e;return t.colors.primary},e=>{let{theme:t}=e;return t.colors.primary60});function nr(e){var t,n,a,s,c,m,h,v,g,A,b,k;let{feeAmount:C,baseCurrency:I,quoteCurrency:E,currencyIdA:M,currencyIdB:N}=e,P=(0,e_.useRouter)(),{isMobile:T}=(0,u.A)(),[B,D]=(0,r.useState)(!1),[F,L]=(0,r.useState)(),{t:O,currentLanguage:{locale:_}}=(0,f.A)(),$=(0,ep.xf)(),Y=(0,et.Sz)(C),{data:z}=(0,y.t)(null==I||null==(t=I.wrapped)?void 0:t.address,null==E||null==(n=E.wrapped)?void 0:n.address,C),{solanaAccount:V,isWrongNetwork:Z}=(0,o.W7)(),[W,H]=(0,r.useState)(eJ.PRESET_RANGE_ITEMS[0]),Q=(0,r.useMemo)(()=>(0,tw.x)(W.value,T),[W.value,T]),G=(0,S.oU)(),{independentField:K,typedValue:X,startPriceTypedValue:J,leftRangeTypedValue:ee,rightRangeTypedValue:en}=G,{pool:ei,ticks:er,dependentField:el,price:eo,pricesAtTicks:ec,parsedAmounts:em,currencyBalances:eh,noLiquidity:ef,currencies:ey,errorMessage:eg,invalidPool:eA,invali
29dRange:eb,outOfRange:ej,depositADisabled:eC,depositBDisabled:eI,invertPrice:eS,ticksAtLimit:eR,tickSpaceLimits:eM}=(0,R.r)(I,E,C,I,void 0,G),{onFieldAInput:eN,onFieldBInput:eT,onLeftRangeInput:eU,onRightRangeInput:eB,onStartPriceInput:eD,onBothRangeInput:eF}=(0,tU.i)(ef),eq=(0,r.useCallback)((e,t)=>{eF({leftTypedValue:(0,tc.m)(null==I?void 0:I.wrapped,null==E?void 0:E.wrapped,e),rightTypedValue:(0,tc.m)(null==I?void 0:I.wrapped,null==E?void 0:E.wrapped,t)})},[I,E,eF]),eL=(0,r.useCallback)(e=>{eU((0,tc.m)(null==I?void 0:I.wrapped,null==E?void 0:E.wrapped,e))},[I,E,eU]),eO=(0,r.useCallback)(e=>{eB((0,tc.m)(null==I?void 0:I.wrapped,null==E?void 0:E.wrapped,e))},[I,E,eB]),[e$,eY]=(0,r.useState)(!1);(0,r.useEffect)(()=>{eY(!1)},[I,E,C]),(0,r.useEffect)(()=>{C&&Y!==C&&(tS(void 0),eF({leftTypedValue:void 0,rightTypedValue:void 0}))},[C]),(0,tP.x)(null==I?void 0:I.wrapped,null==E?void 0:E.wrapped);let ez=(0,S.VF)(),[eK,e0]=(0,r.useState)(""),e8=(0,r.useMemo)(()=>{var e,t;return{[K]:X,[el]:null!=(t=null==(e=em[el])?void 0:e.toSignificant(6))?t:""}},[el,K,em,X]),e3=(0,t_.HW)(null==(a=em[ex.O9.CURRENCY_A])?void 0:a.currency,em[ex.O9.CURRENCY_A]?Number(null==(s=em[ex.O9.CURRENCY_A])?void 0:s.toExact()):void 0,{enabled:!!em[ex.O9.CURRENCY_A]}),e9=(0,t_.HW)(null==(c=em[ex.O9.CURRENCY_B])?void 0:c.currency,em[ex.O9.CURRENCY_B]?Number(null==(m=em[ex.O9.CURRENCY_B])?void 0:m.toExact()):void 0,{enabled:!!em[ex.O9.CURRENCY_B]}),e4=(null!=e3?e3:0)+(null!=e9?e9:0),e5=(0,r.useMemo)(()=>[ex.O9.CURRENCY_A,ex.O9.CURRENCY_B].reduce((e,t)=>({...e,[t]:(0,th.Z)(eh[t])}),{}),[eh]),e7=(0,r.useCallback)((e,t)=>{t&&P.isReady&&P.replace({query:{...P.query,currency:t?[M,N,t.toString()]:[M,N]}},void 0,{shallow:!0})},[M,N,P]),tn=(0,t2.zl)(),tr=(0,r.useCallback)(()=>{eK&&eN(""),e0(""),L(void 0)},[eN,eK]),{[ti.zm.LOWER]:tl,[ti.zm.UPPER]:to}=ec,{[ti.zm.LOWER]:ta,[ti.zm.UPPER]:td}=er,{getDecrementLower:tu,getIncrementLower:tm,getDecrementUpper:tf,getIncrementUpper:tv,getSetFullRange:ty}=(0,t0.i)(I,E,C,ta,td,ei),tg=(0,r.useMemo)(()=>{var e,t,n,i,r,l,o,a,s,d,u,c;return eC?{amount:null!=(o=null==(r=em[ex.O9.CURRENCY_B])?void 0:r.toSignificant(4))?o:"-",symbol:(null==(l=ey[ex.O9.CURRENCY_B])?void 0:l.symbol)?ey[ex.O9.CURRENCY_B].symbol:""}:eI?{amount:null!=(d=null==(a=em[ex.O9.CURRENCY_A])?void 0:a.toSignificant(4))?d:"-",symbol:(null==(s=ey[ex.O9.CURRENCY_A])?void 0:s.symbol)?ey[ex.O9.CURRENCY_A].symbol:""}:{amountA:null!=(u=null==(e=em[ex.O9.CURRENCY_A])?void 0:e.toSignificant(4))?u:"-",symbolA:(null==(t=ey[ex.O9.CURRENCY_A])?void 0:t.symbol)?ey[ex.O9.CURRENCY_A].symbol:"",amountB:null!=(c=null==(n=em[ex.O9.CURRENCY_B])?void 0:n.toSignificant(4))?c:"-",symbolB:(null==(i=ey[ex.O9.CURRENCY_B])?void 0:i.symbol)?ey[ex.O9.CURRENCY_B].symbol:""}},[eC,eI,em,ey]),tA=(0,r.useMemo)(()=>ej?O("Supplying %amount% %symbol%",tg):O("Supplying %amountA% %symbolA% and %amountB% %symbolB%",tg),[O,ej,tg]),tj=(0,r.useMemo)(()=>!!I&&!!E&&(0,eV.DW)(I,E),[I,E]),tk=(0,r.useMemo)(()=>tj?eo:null==eo?void 0:eo.invert(),[tj,eo]),[tI,tS]=(0,r.useState)(),tR=(0,r.useRef)(!1),[tE,tM]=(0,r.useState)(null),[tN,tT]=(0,r.useState)(void 0),tB=(0,tp.OQ)(),tD=(0,t8.h)(),tF=(0,t6.$)(),{wallet:tq}=(0,t9.v)(),tL=(0,t4.I)(tq),nr=(0,r.useCallback)(async()=>{var e,t,n,i,r,l,o,a;(0,eE.aF)();try{let a;if(!I||!E||!tn||!(null==er?void 0:er[ti.zm.LOWER])||!(null==er?void 0:er[ti.zm.UPPER]))return;if(D(!0),ef&&C&&eo){let{buildData:e}=await tD({mintA:I.wrapped,mintB:E.wrapped,tradeFeeRate:C,initialPrice:parseFloat(eo.toSignificant(18)),position:"number"==typeof ta&&"number"==typeof td?{tickLower:ta,tickUpper:td,amountA:em[tj?ex.O9.CURRENCY_A:ex.O9.CURRENCY_B],amountB:em[tj?ex.O9.CURRENCY_B:ex.O9.CURRENCY_A]}:void 0});a=e}let s=await tF({createBuildData:a,independentField:K,dependentField:el,parsedAmounts:em,ticks:er,poolInfo:null!=(e=null==z?void 0:z.rawPool)?e:null==a?void 0:a.extInfo.mockPoolInfo});D(!1),(0,eE.Mg)();let d=s?"txId"in s?s.txId:"txIds"in s?s.txIds[0]:"":"";e0(d),tL||tB({hash:d},{type:"add-liquidity-v3",summary:`Add ${null==(t=em[K])?void 0:t.toExact()} ${null==(i=em[K])||null==(n=i.currency)?void 0:n.symbol} and ${null==(r=em[el])?void 0:r.toExact()} ${null==(o=em[el])||null==(l=o.currency)?void 0:l.symbol}`}),ez(d)}catch(e){D(!1),L(null!=(a=null==e?void 0:e.message)?a:"Failed to add liquidity")}},[tB,el,K,null==z?void 0:z.rawPool,tF,tD,C,tj,ef,eo,ta,td,I,E,em,er,ez,tn,tL]),nl=(0,r.useCallback)(()=>{let[e,t]=z?[null==z?void 0:z.token0,null==z?void 0:z.token1]:I&&E?(0,eV.oS)([I,E]):[];return(0,i.jsx)(eX.Y,{topContent:()=>{var n,r,l;return(0,i.jsxs)(ea.mm,{gap:"md",style:{marginTop:"0.5rem"},children:[(0,i.jsxs)(eu.JA,{style:{marginBottom:"0.5rem"},children:[(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(t$.g,{currency0:e,currency1:t,size:24}),(0,i.jsxs)(d.A,{bold:!0,children:[null==e?void 0:e.symbol,"-",null==t?void 0:t.symbol]})]}),(0,i.jsx)(tH.K,{removed:!1,outOfRange:!!ej})]}),(0,i.jsx)(tz.k0,{children:(0,i.jsxs)(ea.mm,{gap:"sm",children:[(0,i.jsxs)(eu.JA,{children:[(0,i.jsxs)(x.A,{gap:"4px",alignItems:"center",children:[(0,i.jsx)(tZ.Ay,{currency:e}),(0,i.jsx)(d.A,{children:null==e?void 0:e.symbol})]}),(0,i.jsxs)(p.Ay,{children:[(0,i.jsx)(d.A,{children:(null==(n=em[t
29j?ex.O9.CURRENCY_A:ex.O9.CURRENCY_B])?void 0:n.toSignificant(6))||"-"}),(0,i.jsxs)(d.A,{fontSize:"10px",color:"textSubtle",textAlign:"right",children:["~",(0,tX.o5)(tj?e3:e9)]})]})]}),(0,i.jsxs)(eu.JA,{children:[(0,i.jsxs)(x.A,{gap:"4px",alignItems:"center",children:[(0,i.jsx)(tZ.Ay,{currency:t}),(0,i.jsx)(d.A,{children:null==t?void 0:t.symbol})]}),(0,i.jsxs)(p.Ay,{children:[(0,i.jsx)(d.A,{children:(null==(r=em[tj?ex.O9.CURRENCY_B:ex.O9.CURRENCY_A])?void 0:r.toSignificant(6))||"-"}),(0,i.jsxs)(d.A,{fontSize:"10px",color:"textSubtle",textAlign:"right",children:["~",(0,tX.o5)(tj?e9:e3)]})]})]}),(0,i.jsx)(tV.A,{}),(0,i.jsxs)(eu.JA,{children:[(0,i.jsx)(d.A,{color:"textSubtle",children:O("Fee Tier")}),(0,i.jsxs)(d.A,{children:[((null!=(l=null!=C?C:null==z?void 0:z.feeTier)?l:0)/1e4).toString(),"%"]})]})]})}),(0,i.jsxs)(ea.mm,{gap:"md",children:[(0,i.jsx)(eu.JA,{children:(0,i.jsx)("div",{})}),(0,i.jsxs)(eu.JA,{children:[(0,i.jsx)(tW.E,{width:"48%",title:O("Min Price"),currency0:E,currency1:I,price:(0,t1.I)(ec[ti.zm.LOWER],eR,ti.zm.LOWER,_)}),(0,i.jsx)(tW.E,{width:"48%",title:O("Max Price"),currency0:E,currency1:I,price:(0,t1.I)(ec[ti.zm.UPPER],eR,ti.zm.UPPER,_)})]}),(0,i.jsx)(tW.E,{title:O("Current Price"),currency0:E,currency1:I,price:(0,tx.$g)(tk,6,_)})]}),(0,i.jsx)(tz.k0,{children:(0,i.jsxs)(eu.JA,{children:[(0,i.jsx)(d.A,{color:"textSubtle",children:O("Total Deposit")}),(0,i.jsxs)(d.A,{children:["~",(0,tX.o5)(e4,2,!1)]})]})})]})},bottomContent:()=>(0,i.jsx)(ek.A,{width:"100%",mt:"16px",onClick:nr,children:O("Add")})})},[z,I,tk,C,tj,_,nr,ej,em,E,O,eR,e4,e3,e9,ec]),[no]=(0,eZ.A)((0,i.jsx)(tt.A,{minWidth:["100%",null,"420px"],title:O("Add Liquidity"),customOnDismiss:tr,attemptingTxn:B,hash:eK,isMultisig:tL,errorMessage:F,content:nl,pendingText:tA}),!0,!0,"TransactionConfirmationModal"),na=(0,r.useCallback)(()=>{$?nr():no(),(0,eE.uL)()},[$,nr,no]),ns=(0,r.useMemo)(()=>{if(ei)return new eV.gm(ei.token0,ei.token1,2n**192n,ei.sqrtRatioX96*ei.sqrtRatioX96)},[ei]),{data:nd}=(0,te.y)(I),{data:nu}=(0,te.y)(E),nc=(0,r.useMemo)(()=>{if(nd&&nu)return new tO.A(nd).dividedBy(nu)},[nd,nu]),[,np]=(0,ts.e)(I,E,ns),nm=(0,r.useMemo)(()=>void 0!==np&&new e6.A(np.toFixed(0)).abs().gt(5),[np]),nx=(0,i.jsx)(tQ.N,{addIsUnsupported:!1,addIsWarning:!1,account:null!=V?V:void 0,isWrongNetwork:!!Z,isValid:!eg&&!eb,parsedAmounts:em,onClick:na,attemptingTxn:B,errorMessage:eg,buttonText:O("Add"),depositADisabled:eC,depositBDisabled:eI});(0,r.useEffect)(()=>{!tR.current&&tI?(tS(void 0),tM(null),tT(void 0)):tR.current&&(tR.current=!1)},[tR,tI,ee,en]);let nh=(0,r.useCallback)(e=>{tS(void 0),e||tT(void 0);let t=eo?parseFloat((eS?eo.invert():eo).toSignificant(8)):void 0;if(t){var n,i;eF({leftTypedValue:(0,tc.m)(null==I?void 0:I.wrapped,null==E?void 0:E.wrapped,(t*(null!=(n=null==e?void 0:e.initialMin)?n:e2.W[null!=C?C:q.dl.MEDIUM].initialMin)).toString()),rightTypedValue:(0,tc.m)(null==I?void 0:I.wrapped,null==E?void 0:E.wrapped,(t*(null!=(i=null==e?void 0:e.initialMax)?i:e2.W[null!=C?C:q.dl.MEDIUM].initialMax)).toString())})}},[eo,C,eS,eF,I,E]),nf=(0,r.useCallback)(()=>{if(!eR[ti.zm.LOWER]&&!eR[ti.zm.UPPER]){var e,t,n,i;eF({leftTypedValue:null!=(e=null==to?void 0:to.invert())?e:void 0,rightTypedValue:null!=(t=null==tl?void 0:tl.invert())?t:void 0}),eS?eN(null!=(n=e8[ex.O9.CURRENCY_B])?n:""):eT(null!=(i=e8[ex.O9.CURRENCY_A])?i:"")}},[eF,eR,eN,eT,eS,tl,to,e8]),nv=(0,U.m)(),{handleInvertCurrencies:ny}=(0,U.C)({currencyIdA:M,currencyIdB:N,feeAmount:C});(0,r.useEffect)(()=>{nv&&nf()},[nv]);let ng=(0,r.useCallback)(()=>{var e,t;ny(),eD(null!=(t=null==eo||null==(e=eo.invert())?void 0:e.toSignificant(18))?t:"")},[eo,eD,ny]),{isLoading:nA,error:nb,formattedData:nw}=function(e){var t,n;let{currencyA:i,currencyB:o,feeAmount:a}=e,s=(null==i?void 0:i.chainId)===l.Cb.SOLANA||(null==o?void 0:o.chainId)===l.Cb.SOLANA,d=null==i||null==(t=i.wrapped)?void 0:t.address,u=null==o||null==(n=o.wrapped)?void 0:n.address,{data:c}=(0,y.t)(d,u,a),{data:p,isLoading:m,error:x}=(0,j.L)(null==c?void 0:c.poolId),{data:h}=(0,tG.Ay)({chainId:null==c?void 0:c.chainId,poolAddress:null==c?void 0:c.poolId,interval:3e4,enabled:s,protocol:ev.Zs.V3,activeTick:null==p?void 0:p.computePoolInfo.tickCurrent}),{data:f}=(0,tK.Hn)({currencyA:i,currencyB:o,ticks:h,pool:{tickSpacing:null==p?void 0:p.computePoolInfo.tickSpacing,tickCurrent:null==p?void 0:p.computePoolInfo.tickCurrent,liquidity:(null==p?void 0:p.computePoolInfo.liquidity)?BigInt(null==p?void 0:p.computePoolInfo.liquidity.toString()):void 0}}),v=(0,r.useCallback)(()=>
29{if(!(null==f?void 0:f.length))return;let e=[];for(let a=0;a<f.length;a++){var t,n,i,r,l,o;let s=f[a],d=null!=(i=null!=(n=s.liquidityActive)?n:s.liquidity_active)?i:0,u=null!=(l=null!=(r=s.price0)?r:s.price)?l:s.price_0,c={activeLiquidity:parseFloat(d.toString()),price0:parseFloat(null!=(o=null==u||null==(t=u.toString)?void 0:t.call(u))?o:"0")};c.activeLiquidity>0&&e.push(c)}return e},[f]);return(0,r.useMemo)(()=>({isLoading:m,error:null!=x?x:void 0,formattedData:m?void 0:v()}),[m,x,v])}({currencyA:null!=I?I:void 0,currencyB:null!=E?E:void 0,feeAmount:C}),nj=(0,r.useMemo)(()=>eo?parseFloat((eS?eo.invert():eo).toSignificant(8)):void 0,[eo,eS]),{data:nk}=(0,tb.F)({period:W.value,baseCurrency:null!=I?I:void 0,quoteCurrency:null!=E?E:void 0,chainId:null==I?void 0:I.chainId,protocol:ev.Zs.V3,poolId:null==z?void 0:z.poolId}),nC=(0,r.useCallback)(()=>{var e;eD(null!=(e=null==nc?void 0:nc.toSignificantDigits(18).toString())?e:"")},[nc,eD]),{tooltip:nI,tooltipVisible:nS,targetRef:nR}=(0,w.A)(O("The price is an estimation of the current market price. Please verify before using it."),{placement:"bottom",avoidToStopPropagation:!0}),nE=(0,r.useMemo)(()=>{var e,t;return null==z||null==(t=z.rawPool)||null==(e=t.config)?void 0:e.defaultRangePoint.map(e=>100*Number(e))},[null==z||null==(v=z.rawPool)||null==(h=v.config)?void 0:h.defaultRangePoint]),nM=(0,t3._)({defaultRangePoints:nE,feeAmount:C}),nN=(0,r.useCallback)((e,t)=>{if(tM(e),null!==e)if(100===e)tT(void 0),eY(!0),tS(100),tR.current=!0;else{let n=null==nM?void 0:nM[e];n?(tT(void 0),nh(n)):(tT(t),nh(t)),tS(e),tR.current=!0}},[nM,nh,eY]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nn,{children:(0,i.jsx)(es.A,{children:(0,i.jsx)(ed.A,{children:(0,i.jsxs)(ea.mm,{gap:"16px",children:[ef&&(0,i.jsxs)(p.Ay,{children:[(0,i.jsxs)(x.A,{gap:"8px",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsx)(eW.y,{mb:"8px",children:O("Set Starting Price")}),nc?(0,i.jsxs)(x.A,{mb:"8px",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsx)("div",{}),(0,i.jsxs)(x.A,{gap:"4px",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsxs)("div",{ref:nR,children:[(0,i.jsxs)(ni,{onClick:nC,children:[(0,i.jsx)("span",{children:O("Use Market Price")}),(0,i.jsx)(eH.A,{color:"primary60",width:"18px"})]}),nS&&nI]}),(0,i.jsxs)(d.A,{color:"textSubtle",small:!0,children:[nc.toNumber()," ",null==E?void 0:E.symbol," per ",null==I?void 0:I.symbol]}),(0,i.jsx)(eQ.A,{role:"button",color:"primary60",onClick:ng,style:{cursor:"pointer"}})]})]}):null]}),(0,i.jsx)(eP.A,{variant:"warning",my:"8px",children:(0,i.jsxs)(eP.J,{children:[O("This pool needs to be initialized before you can add liquidity."),(0,i.jsx)("br",{}),O("First, set the poolâs starting price. Then, choose your liquidity price range and enter the amount you want to deposit. Please note that creating a pool has higher fees compared to normal SOL transactions, since ticks must be initialized during setup.")]})}),(0,i.jsxs)(x.A,{gap:"8px",alignItems:"baseline",justifyContent:"space-between",children:[(0,i.jsx)(ne,{className:"start-price-input",value:J,onUserInput:eD}),(0,i.jsx)(d.A,{color:"textSubtle",children:null==E?void 0:E.symbol})]})]}),(0,i.jsxs)(eG.x,{disabled:!C||eA,children:[(0,i.jsxs)(x.A,{gap:"8px",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsx)(eW.y,{children:O("Set position range")}),!ef&&(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",flexWrap:"wrap",children:[(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(nt,{$color:"primary"}),(0,i.jsx)(d.A,{color:"textSubtle",small:!0,children:O("Current Price")})]}),(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(nt,{$color:"secondary"}),(0,i.jsx)(d.A,{color:"textSubtle",small:!0,children:O("Position Range")})]}),(0,i.jsxs)(x.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(nt,{$color:"input"}),(0,i.jsx)(d.A,{color:"textSubtle",small:!0,children:O("Liquidity Depth")})]})]})]}),!ef&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(p.Ay,{mt:"22px",border:"1px solid",borderColor:"cardBorder",borderRadius:"24px",p:"8px",children:[(0,i.jsx)(x.A,{flexDirection:T?"column":"row",justifyContent:T?"flex-start":"space-between",gap:"16px",mb:"24px",children:(0,i.jsx)(eJ.PriceRangeDatePicker,{onChange:H,value:W})}),(0,i.jsx)(e1.k,{isLoading:nA,zoomLevel:tN||(tI?null==nM?void 0:nM[tI]:void 0),baseCurrency:I,quoteCurrency:E,ticksAtLimit:eR,price:nj,priceLower:tl,priceUpper:to,onBothRangeInput:eq,onMinPriceInput:eL,onMaxPriceInput:eO,formattedData:nw,priceHistoryData:nk,axisTicks:Q,error:nb,interactive:!0},null==I?void 0:I.wrapped.address)]})})]}),(0,i.jsxs)(eG.x,{disabled:!C||eA||ef&&!J,gap:"16px",children:[!e$&&(0,i.jsx)(t7.L,{priceLower:tl,priceUpper:to,getDecrementLower:tu,getIncrementLower:tm,getDecrementUpper:tf,getIncrementUpper:tv,onLeftRangeInput:eU,onRightRangeInput:eB,currencyA:I,currencyB:E,feeAmount:C,ticksAtLimit:eR,tickSpaceLimits:eM,quickAction:tE,handleQuickAction:nN,defaultRangePoints:nE}),e$&&(0,i.jsx)(eP.A,{variant:"warning",children:(0,i.jsxs)(p.Ay,{children:[(0,i.jsx)(d.A,{fontSize:"16px",children:O("Efficiency Comparison")}),(0,i.jsx)(d.A,{color:"textSubtle",children:O("Full range positions may earn less fees than concentrated positions.")}),(0,i.jsx)(ek.A,{mt:"16px",onClick:()=>{eY(!1),ty()},scale:"md",variant:"danger",children:O("I understand")})]})}),nm?(0,i.jsx)(tC.Zw,{slippage:`${null==np?void 0:np.toFixed(0)} %`}):null,ej?(0,i.jsx)(eP.A,{variant:"warning",children:(0,i.jsx)(eu.JA,{children:(0,i.jsx)(d.A,{ml:"12px",fontSize:"12px",children:O("Your position will not earn fees or be used in trades until the market price moves into your range.")})})}):null,eb?(0,i.jsx)(eP.A,{variant:"warning",children:(0,i.jsx)(eP.J,{children:O("Invalid range selected. The min price must be lower than the max price.")})}):null]})]})})})}),(0,i.jsx)(es.A,{style:{height:"fit-content"},children:(0,i.jsxs)(ed.A,{children:[(0,i.jsx)(eG.x,{disabled:!I||!E,children:(0,i.jsx)(tJ.L,{baseCurrency:null!=I?I:void 0,quoteCurrency:null!=E?E:void 0,onSelect:e7,feeAmount:C})}),(0,i.jsxs)(eG.x,{mt:"16px",style:{gridAutoRows:"max-content",gridAutoColumns:"100%"},gap:"8px",disabled:!C||eA||ef&&!J||!tl&&!to,children:[(0,i.jsx)(t5.A,{locked:eC,children:(0,i.jsx)(p.Ay,{mb:"8px",children:(0,i.jsx)(tY.A,{showUSDPrice:!0,maxDecimals:null==(g=ey[ex.O9.CURRENCY_A])?void 0:g.decimals,maxAmount:e5[ex.O9.CURRENCY_A],onMax:()=>{var e,t;return eN(null!=(t=null==(e=e5[ex.O9.CURRENCY_A])?void 0:e.toExact())?t:"")},onPercentInput:e=>{var t,n,i;return eN(null!=(i=null==(n=e5[ex.O9.CURRENCY_A])||null==(t=n.multiply(new eV.QE(e,100)))?void 0:t.toExact())?i:"")},disableCurrencySelect:!0,defaultValue:null!=(b=e8[ex.O9.CURRENCY_A])?b:"0",onUserInput:eN,showQuickInputButton:!0,showMaxButton:!0,currency:ey[ex.O9.CURRENCY_A],id:"add-liquidity-input-tokena",title:(0,i.jsx)(eW.y,{children:O("Deposit Amount")})})})}),(0,i.jsx)(t5.A,{locked:eI,children:(0,i.jsx)(tY.A,{showUSDPrice:!0,maxDecimals:null==(A=ey[ex.O9.CURRENCY_B])?void 0:A.decimals,maxAmount:e5[ex.O9.CURRENCY_B],onMax:()=>{var e,t;return eT(null!=(t=null==(e=e5[ex.O9.CURRENCY_B])?void 0:e.toExact())?t:"")},onPercentInput:e=>{var t,n,i;return eT(null!=(i=null==(n=e5[ex.O9.CURRENCY_B])||null==(t=n.multiply(new eV.QE(e,100)))?void 0:t.toExact())?i:"")},disableCurrencySelect:!0,defaultValue:null!=(k=e8[ex.O9.CURRENCY_B])?k:"0",onUserInput:eT,showQuickInputButton:!0,showMaxButton:!0,currency:ey[ex.O9.CURRENCY_B],id:"add-liquidity-input-tokenb",title:(0,i.jsx)(i.Fragment,{children:"\xa0"})})}),(0,i.jsxs)(ea.VP,{mt:"16px",gap:"16px",children:[(0,i.jsxs)(eu.JA,{children:[(0,i.jsx)(d.A,{color:"textSubtle",children:O("Total")}),(0,i.jsxs)(d.A,{children:["~",(0,tX.o5)(e4,2,!1)]})]}),(0,i.jsxs)(eu.JA,{children:[(0,i.jsx)(d.A,{color:"textSubtle",children:O("Slippage Tolerance")}),(0,i.jsx)(ew.AK,{})]})]}),(0,i.jsx)(p.Ay,{mt:"8px",children:nx})]})]})})]})}let nl=s.I4.div.withConfig({componentId:"sc-23f6fbcd-0"})(["display:grid;grid-column-gap:32px;grid-row-gap:16px;grid-template-columns:1fr;grid-template-rows:max-content;grid-auto-flow:row;","{grid-template-columns:",";}"],e=>{let{theme:t}=e;return t.mediaQueries.md},e=>{let{$singleColumn:t}=e;return t?"1fr":"3fr 2fr"});function no(e){let{currencyIdA:t,currencyIdB:n,preferredSelectType:a,preferredFeeAmount:s}=e,d=(0,eo.Zg)(),{chainId:u}=(0,o.W7)();(0,r.useEffect)(()=>{d((0,el.J)())},[d,t,n]);let c=(0,v.Jg)(t),m=(0,v.Jg)(n),x=c&&!(0,l.fT)(c.chainId)?c:void 0,h=m&&!(0,l.fT)(m.chainId)?m:void 0;(0,er.A)(t,n);let f=(0,Y.Ay)({tokenA:x,tokenB:h}),y=c&&m&&c.wrapped.equals(m.wrapped)?void 0:m,g=(0,T.U)(),A=(0,r.useMemo)(()=>s||g,[s,g]),[b,w]=(0,_.fp)(X),j=(0,et.Sz)(a);return(0,r.useEffect)(()=>{t&&n&&(b!==Q.b.V3||a!==Q.b.V3)&&(a===Q.b.STABLE&&f.stableSwapConfig?w(Q.b.STABLE):w(a||Q.b.V3))},[t,n,a,j,w,f.stableSwapConfig]),(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(p.Ay,{mt:"24px",children:(0,i.jsxs)(nl,{$singleColumn:b===Q.b.V2||b===Q.b.STABLE,children:[b===Q.b.V3&&((0,l.fT)(u)?(0,i.jsx)(nr,{feeAmount:A,baseCurrency:c,quoteCurrency:y,currencyIdA:t,currencyIdB:n}):(0,i.jsx)(tL,{feeAmount:A,baseCurrency:x,quoteCurrency:h,currencyIdA:t,currencyIdB:n})),b===Q.b.V2&&(0,i.jsx)(en.A,{currencyA:x,currencyB:h,children:e=>(0,i.jsx)(ez,{...e})}),b===Q.b.STABLE&&(0,i.jsx)(Y.jq.Provider,{value:f,children:(0,i.jsx)(ei.A,{currencyA:x,currencyB:h,children:e=>{var t;return(0,i.jsx)(eN,{...e,stableTotalFee:null==f||null==(t=f.stableSwapConfig)?void 0:t.stableTotalFee})}})})]})})})}},463532:(e,t,n)=>{"use strict";n.d(t,{A:()=>d});var i=n(350979),r=n(549333),l=n(25963),o=n(131619),a=n(782038),s=n(668637);function d(e,t){var n,d;let u=(0,o.Jg)(e),c=(0,o.Jg)(t),[p,m]=(0,l.useState)(null),[x,h]=(0,l.useState)(void 0),[f,v]=(0,l.useState)(void 0),{data:y=a.PK}=(0,a.i2)(),{tokenRiskA:g,tokenRiskB:A}=(0,a.Wd)(u,c),[b]=(0,r.A)((0,i.jsx)(s.A,{swapCurrency:p,title:x,reason:f}),!1);(0,l.useEffect)(()=>{p&&b()},[p,b]);let w=null==u||null==(n=u.wrapped)?void 0:n.address,j=null==c||null==(d=c.wrapped)?void 0:d.address,k=null==g?void 0:g.severity,C=null==A?void 0:A.severity;return(0,l.useEffect)(()=>{u&&"warn"===k?(m(u),h(null==g?void 0:g.title),v(null==g?void 0:g.reason)):c&&"warn"===C?(m(c),h(null==A?void 0:A.title),v(null==A?void 0:A.reason)):(m(null),h(void 0),v(void 0))},[w,j,k,C]),(0,l.useCallback)(e=>{let t=(0,a.tm)(y,e);(null==t?void 0:t.severity)==="warn"?(m(e||null),h(t.title),v(t.reason)):(m(null),h(void 0),v(void 0))},[y])}},477979:(e,t,n)=>{var i=n(115743);e.exports=function(e){return i(e).toLowerCase()}},481711:(e,t,n)=>{"use strict";n.d(t,{Fm:()=>N,Hp:()=>P,di:()=>E,lQ:()=>M});var i=n(350979),r=n(25963),l=n(17581),o=n(670420),a=n(995315),s=n(605641),d=n(378385),u=n(955647),c=n(898719),p=n(450253),m=n.n(p),x=n(402861),h=n(344730),f=n(459587),v=n(687287),y=n(810286),g=n(706172),A=n(456194),b=n(538534),w=n(323641),j=n(517024),k=n(112616),C=n(188882),I=n(619749);let S=e=>{if(null==e)return 0;let t="string"==typeof e?parseFloat(e):e;return Number.isNaN(t)?0:t},R=e=>{let{earningsBusd:t}=e;return(0,i.jsxs)("div",{children:["~$",(0,d.ZV)(t)]})},E=e=>{let{tokenId:t,chainId:n,pool:l,currency0:d,currency1:p,positionClosed:m=!1}=e,{earningsAmount:x,earningsBusd:h}=(0,w.Ls)((0,r.useMemo)(()=>t?[t]:[],[t]),n),[j,C]=(0,g.R)(null!=l?l:void 0,t,!1,!m),{data:I}=(0,f.GB)(null!=d?d:void 0,{enabled:!!(d&&(null==j?void 0:j.greaterThan(0)))}),{data:E}=(0,f.GB)(null!=p?p:void 0,{enabled:!!(p&&(null==C?void 0:C.greaterThan(0)))}),M=(0,v.HH)(j),N=(0,v.HH)(C),P=(0,r.useMemo)(()=>I&&j?S((0,u.ej)(j))*I:void 0,[I,j]),T=(0,r.useMemo)(()=>E&&C?S((0,u.ej)(C))*E:void 0,[E,C]),U=(0,r.useMemo)(()=>P&&T?P+T:void 0,[I,E,j,C]),B=h+(null!=U?U:0);return m?(0,i.jsx)(R,{earningsBusd:B}):(0,i.jsx)(b.z,{content:(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",ga
29p:"8px",children:[(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:d,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==d?void 0:d.symbol})]}),(0,i.jsx)(y.g3,{amount:j,fontSize:"14px",bold:!0,children:(0,A.e)(M)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:P&&I?(0,k.o5)(P):"$0.00"})]}),(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:p,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==p?void 0:p.symbol})]}),(0,i.jsx)(y.g3,{amount:C,fontSize:"14px",bold:!0,children:(0,A.e)(N)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:T&&E?(0,k.o5)(T):"$0.00"})]}),x>0&&(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:o.vb[n],size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:"CAKE"})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,A.e)(null!=x?x:0)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:h?(0,k.o5)(h):"$0.00"})]})]}),children:(0,i.jsx)(R,{earningsBusd:B})})},M=e=>{var t,n,l,o;let{poolInfo:d,position:u,positionClosed:p=!1,tokenId:m,onReady:x}=e,{breakdownRewardInfo:h,totalPendingYield:f}=(0,C.n)({poolInfo:d,position:u}),v=Number(null!=(o=null==f||null==(t=f.toString)?void 0:t.call(f))?o:0);if((0,r.useEffect)(()=>{x&&m&&x(m,v)},[x,m,v]),p)return(0,i.jsx)(R,{earningsBusd:v});let y=h.fee.A,g=h.fee.B,{rewards:w}=h;return(0,i.jsx)(b.z,{content:(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"8px",children:[(Number((null==y?void 0:y.amount)||0)>0||Number((null==g?void 0:g.amount)||0)>0)&&(0,i.jsxs)(i.Fragment,{children:[(null==y?void 0:y.mint)&&(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:(0,I.ph)(y.mint),size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(n=(0,I.ph)(y.mint))?void 0:n.symbol})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,A.e)(Number(y.amount)||0)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,k.o5)(Number(y.amountUSD)||0)})]}),(null==g?void 0:g.mint)&&(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:(0,I.ph)(g.mint),size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(l=(0,I.ph)(g.mint))?void 0:l.symbol})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,A.e)(Number(g.amount)||0)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,k.o5)(Number(g.amountUSD)||0)})]})]}),w&&w.length>0&&(0,i.jsx)(i.Fragment,{children:w.map((e,t)=>{var n;return e.mint?(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:(0,I.ph)(e.mint),size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(n=(0,I.ph)(e.mint))?void 0:n.symbol})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,A.e)(Number(e.amount)||0)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,k.o5)(Number(e.amountUSD)||0)})]},t):null})})]}),children:(0,i.jsx)(R,{earningsBusd:v})})},N=e=>{let{chainId:t,poolId:n}=e,{address:o}=(0,l.F)(),{data:{rewardsAmount:d,rewardsUSD:u},isLoading:p}=(0,x.wA)({chainId:t,poolId:n,address:o,timestamp:m()().startOf("hour").unix()}),h=(0,r.useMemo)(()=>{var e;if(!d)return 0;let t=Math.min(null!=(e=d.currency.decimals)?e:18,18);return S(d.toFixed(t))},[d]),[,f]=(0,j.J)();return(0,r.useEffect)(()=>{t&&n&&!p&&f(t,n,h)},[h,t,n,p,f]),(0,i.jsx)(b.z,{content:(0,i.jsx)(a.A,{flexDirection:"column",alignItems:"flex-start",ga
29p:"8px",children:d&&d.greaterThan(0)&&(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:d.currency,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:d.currency.symbol})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,A.e)(h)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:u?(0,k.o5)(u):"$0.00"})]})}),children:(0,i.jsx)(R,{earningsBusd:u})})},P=e=>{let{tokenId:t,chainId:n,poolId:o,currency0:d,currency1:u,tickLower:p,tickUpper:f,positionClosed:g=!1}=e,{address:w}=(0,l.F)(),{data:{rewardsAmount:C,rewardsUSD:I},isLoading:E}=(0,x.fG)({chainId:n,tokenId:t,poolId:o,address:w,timestamp:m()().startOf("hour").unix()}),{totalFiatValue:M,feeAmount0:N,feeAmount1:P,fiatValue0:T,fiatValue1:U}=(0,h.O)({currency0:d,currency1:u,tokenId:t,poolId:o,tickLower:p,tickUpper:f,enabled:!g}),B=(0,v.HH)(N),D=(0,v.HH)(P),F=(0,r.useMemo)(()=>{var e;if(!C)return 0;let t=Math.min(null!=(e=C.currency.decimals)?e:18,18);return S(C.toFixed(t))},[C]),[,q]=(0,j.J)();(0,r.useEffect)(()=>{n&&o&&t&&!E&&q(n,o,t,F)},[F,n,o,t,E,q]);let L=I+(0,r.useMemo)(()=>M?S(M.toExact()):0,[M]);return g?(0,i.jsx)(R,{earningsBusd:L}):(0,i.jsx)(b.z,{content:(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"8px",children:[N&&N.greaterThan(0)&&(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:d,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==d?void 0:d.symbol})]}),(0,i.jsx)(y.g3,{amount:N,fontSize:"14px",bold:!0,children:(0,A.e)(B)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:T?(0,k.o5)(S(T.toExact())):"$0.00"})]}),P&&P.greaterThan(0)&&(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:u,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==u?void 0:u.symbol})]}),(0,i.jsx)(y.g3,{amount:P,fontSize:"14px",bold:!0,children:(0,A.e)(D)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:U?(0,k.o5)(S(U.toExact())):"$0.00"})]}),C&&C.greaterThan(0)&&(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(c.Z,{currency:C.currency,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:C.currency.symbol})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,A.e)(F)})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:I?(0,k.o5)(I):"$0.00"})]})]}),children:(0,i.jsx)(R,{earningsBusd:L})})}},483547:(e,t,n)=>{"use strict";n.d(t,{A:()=>_});var i=n(350979),r=n(769932),l=n(557423),o=n(312680),a=n(24153),s=n(501823),d=n(605641),u=n(549333),c=n(28192),p=n(795904),m=n(698612),x=n(266283),h=n(150103),f=n(214885),v=n(706172),y=n(687287),g=n(810286),A=n(25963),b=n(252146),w=n(680797),j=n(909725),k=n(259145),C=n(197504),I=n(974134),S=n(323641),R=n(57654),E=n(179087),M=n(282304),N=n(796147),P=n(67002),T=n(649571),U=n(485909),B=n(833438);let D=w.Ay.div.withConfig({componentId:"sc-8a98580a-0"})(["position:absolute;top:0px;transform:translate3d(0px,62px,0px);right:4px;&::before{content:'';transform:rotate(45deg);background:var(--colors-backgroundAlt);position:absolute;width:10px;height:10px;border-radius:2px;z-index:-1;}"]),F=e=>{let{disabled:t,staking:n,onStake:a,onUnStake:s,isOpen:u,onDismiss:c,children:p}=e,{t:m}=(0,r.A)(),{isDark:h}=(0,E.DP)();return(0,i.jsx)(o.aF,{isOpen:u,onDismiss:c,closeOnOverlayClick:!0,children:(0,i.jsx)(M.Ay,{title:m(n?"Staking":"Unstaking"),width:["100%","100%","450px"],maxWidth:["100%",null,"450px"],children:(0,i.jsxs)(N.mm,{gap:"16px",children:[(0,i.jsx)(P.R,{position:"relative",style:{minHeight:"68px"},children:(0,i.jsxs)(P.R,{style:{width:"100%",position:"absolute",right:0,bottom:"-23px",display:"flex",justifyContent:"flex-end",alignItems:"flex-end",zIndex:1},children:[(0,i.jsxs)(T.F,{"data-theme":h?"light":"dark",style:{maxWidth:"240px",position:"relative"},children:[n?(0,i.jsxs)(i.Fragment,{children:[m("Inactive positions will"),(0,i.jsxs)("b",{children:[" ",m("NOT")," "]}),m("earn CAKE rewards from farm.")]}):m("You may add or remove liquidity on the position detail page without unstake"),(0,i.jsx)(D,{})]}),(0,i.jsx)(U.A,{src:`${B.HI}/web/universalFarms/bulb-bunny.png`,width:135,height:120,alt:"bulb bunny reminds unstaking"})]})}),(0,i.jsx)(x.R4,{style:{position:"relative"},children:p}),(0,i.jsx)(l.A,{variant:n?"subtle":"primary",onClick:n?a:s,width:"100%",disabled:t,children:m(n?"Continue Staking":"Unstake")}),n?null:(0,i.jsx)(d.A,{color:"textSubtle",children:m("Unstake will also automatically harvest any earnings that you havenât collected yet, and send them to your wallet.")})]})})})};var q=n(427896),L=n(453461);let O=(0,w.Ay)(l.A).withConfig({componentId:"sc-748eae3b-0"})(["color:",";"],e=>{let{theme:t}=e;return t.colors.primary60}),_=(0,A.memo)(e=>{var t,n;
29let{isFarmLive:w,chainId:E,isStaked:M,removed:N,outOfRange:P,tokenId:T,modalContent:U,detailMode:B=!1,pool:D,showCollectButton:_=!1,hideStakeButtons:$=!1}=e,{t:Y,currentLanguage:{locale:z}}=(0,r.A)(),[,V]=(0,b.r)(),{onStake:Z,onUnstake:W,onHarvest:H,attemptingTxn:Q}=(0,C.A)({tokenId:null!=(t=null==T?void 0:T.toString())?t:"",onDone:V,chainId:E}),G=(0,o.jN)(),{switchNetworkIfNecessary:K,isLoading:X}=(0,I.Hk)(),[J,ee]=(0,v.R)(D,T,!1),et=(0,y.Wu)(J,4),en=(0,y.Wu)(ee,4),{onCollect:ei,attemptingTx:er,isLoadingStakedPositions:el}=(0,R.A)({chainId:E}),[eo,ea]=(0,A.useState)(null),[es,ed]=(0,A.useState)(),eu=(0,A.useMemo)(()=>J&&J.greaterThan(0)||ee&&ee.greaterThan(0),[J,ee]),ec=(0,A.useCallback)(async()=>{(0,k.PJ)(),P&&!M?G.onOpen():await K(E)||await Z()},[M,Z,P,G,K,E]),ep=(0,A.useCallback)(async()=>{(0,k.PJ)(),await K(E)||await Z()},[Z,K,E]),em=(0,A.useCallback)(async()=>{await K(E)||(await W(),G.onDismiss())},[W,K,E,G]),[ex,eh]=(0,A.useState)(!1),ef=(0,A.useCallback)(async()=>{if(!await K(E))try{eh(!0),await H()}finally{eh(!1)}},[H,K,E]),ev=(0,A.useCallback)(async()=>{if(D&&T&&!await K(E))try{ed(void 0),ea(null);let e=await ei({pool:D,tokenId:T,feeValue0:J,feeValue1:ee,receiveWNATIVE:!1});e&&ea(e)}catch(e){console.error("[V3PositionActions] Collect error:",e),ed((null==e?void 0:e.message)||Y("Transaction failed")),ea(null)}},[D,T,ei,J,ee,Y,K,E]),ey=(0,A.useCallback)(()=>{ed(void 0),ea(null)},[]),eg=(0,A.useCallback)(()=>{var e,t;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(x.k0,{mb:"16px",children:[(0,i.jsxs)(a.eF,{justifyContent:"space-between",mb:"8px",children:[(0,i.jsxs)(s.A,{children:[(0,i.jsx)(h.Zm,{currency:null==J?void 0:J.currency,size:"24px"}),(0,i.jsx)(d.A,{color:"textSubtle",ml:"4px",children:null==J||null==(e=J.currency)?void 0:e.symbol})]}),(0,i.jsx)(g.g3,{amount:J,children:J?null!=et?et:(0,j.N)(J,4,z):"-"})]}),(0,i.jsxs)(a.eF,{justifyContent:"space-between",children:[(0,i.jsxs)(s.A,{children:[(0,i.jsx)(h.Zm,{currency:null==ee?void 0:ee.currency,size:"24px"}),(0,i.jsx)(d.A,{color:"textSubtle",ml:"4px",children:null==ee||null==(t=ee.currency)?void 0:t.symbol})]}),(0,i.jsx)(g.g3,{amount:ee,children:ee?null!=en?en:(0,j.N)(ee,4,z):"-"})]})]}),(0,i.jsx)(d.A,{mb:"16px",px:"16px",children:Y("Collecting fees will withdraw currently available fees for you")})]})},[J,ee,Y]),eA=(0,A.useCallback)(()=>(0,i.jsx)(m.Y,{topContent:eg,bottomContent:()=>(0,i.jsx)(l.A,{width:"100%",onClick:ev,disabled:er,children:er?Y("Collecting"):Y("Collect")})}),[eg,ev,er,Y]),eb=er&&!eo,[ew]=(0,u.A)((0,i.jsx)(f.A,{title:Y("Claim fees"),attemptingTxn:eb,customOnDismiss:ey,hash:null!=eo?eo:"",errorMessage:es,content:eA,pendingText:Y("Collecting fees")}),!0,null!=T,`V3TransactionConfirmationModalCollectFees_${E}_${null!=(n=null==T?void 0:T.toString())?n:"unknown"}`),ej=(0,A.useMemo)(()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l.A,{scale:"md",width:["100px"],style:{alignSelf:"center"},onClick:ec,disabled:Q||X,children:Y("Stake")}),(0,i.jsx)(F,{isOpen:G.isOpen,staking:P&&!M,onStake:ep,onDismiss:G.onDismiss,children:U})]}),[X,ep,ec,M,U,Y,P,G,Q]),ek=(0,A.useMemo)(()=>(0,i.jsxs)(i.Fragment,{children:[B?(0,i.jsx)(c.A,{variant:"secondary",disabled:Q||X,onClick:G.onOpen,children:(0,i.jsx)(p.A,{color:"primary",width:"24px"})}):(0,i.jsx)(O,{scale:"md",width:["100px"],style:{alignSelf:"center"},variant:"secondary",onClick:G.onOpen,disabled:Q||X,children:Y("Unstake")}),(0,i.jsx)(F,{disabled:Q||X,isOpen:G.isOpen,staking:P&&!M,onUnStake:em,onDismiss:G.onDismiss,children:U})]}),[B,X,em,M,U,Y,P,G,Q]),{hasEarnings:eC,isLoading:eI}=(0,S.Ls)((0,A.useMemo)(()=>M&&T?[T]:[],[T,M]),E);return(0,i.jsx)(q.L,{children:(0,i.jsxs)(L.Cp,{children:[!$&&(M?ek:!N&&w?ej:null),_&&!N&&eu?(0,i.jsx)(l.A,{width:["100px"],scale:"md",disabled:er||X||el||!D,onClick:ew,children:er?Y("Collecting"):Y("Collect")}):null,M&&!N?(0,i.jsx)(l.A,{width:["100px"],scale:"md",disabled:Q||X||eI||!eC,onClick:ef,children:ex?Y("Harvesting"):Y("Harvest")}):null]})})})},484562:(e,t,n)=>{"use strict";n.d(t,{l:()=>R});var i=n(350979),r=n(428089),l=n(371309),o=n(796898),a=n(579518),s=n(796147),d=n(501823),u=n(20897),c=n(899188),p=n(529208),m=n(326848),x=n(25963),h=n(680797),f=n(327834),v=n(769932),y=n(228876),g=n(995315),A=n(605641),b=n(490233),w=n(721745);let j=e=>{let{address:t,label:n,textProps:r,truncateNumber:l=6,...o}=e,a=l?(0,w.A)(t,l):t,{t:s}=(0,v.A)();return(0,i.jsxs)(g.A,{alignItems:"center",gap:"2px",...o,children:[n,(0,i.jsx)(A.A,{...r,children:a}),(0,i.jsx)(b.i,{width:"16px",color:"textSubtle",text:t,tooltipMessage:s("Copied"),style:{marginBottom:"-2px"}})]})};var k=n(99490),C=n(451184),I=n(704784);let S=e=>{let{chainId:t,currency0:n,currency1:o,poolId:a}=e,{t:s}=(0,v.A)();return n&&o&&t===y.Cb.SOLANA&&a?(0,i.jsxs)(r.Ay,{children:[(0,i.jsx)(j,{address:a,label:`${s("Pool id")}:`,mb:"2",textProps:{fontSize:"xs",ml:"2px"}}),(0,i.jsx)(j,{address:n.wrapped.address,label:(0,i.jsx)(l.A,{srcs:(0,u.ig)(n),sizes:"xs",width:16,height:16,style:{borderRadius:"50%"}}),textProps:{fontSize:"xs"}}
29),(0,i.jsx)(j,{address:o.wrapped.address,label:(0,i.jsx)(l.A,{srcs:(0,u.ig)(o),sizes:"xs",width:16,height:16,style:{borderRadius:"50%"}}),textProps:{fontSize:"xs"}})]}):null},R=e=>{var t,n;let{isDesktop:r}=(0,o.A)(),{link:l,currency0:d,currency1:h,chainId:v,children:g,miniMode:A=!r}=e,b=!!(d&&h&&v===y.Cb.SOLANA&&(null==(t=e.pool)?void 0:t.poolId)),{targetRef:w,tooltip:j,tooltipVisible:R}=(0,a.A)(b?(0,i.jsx)(S,{chainId:v,currency0:d,currency1:h,poolId:null==(n=e.pool)?void 0:n.poolId}):null),M=(0,m.useRouter)(),N=(0,x.useMemo)(()=>!l||l.startsWith("http")&&l.startsWith("//")?l:(0,f.e)(l,{chain:c.RW[v],[p.hy]:"1"}),[l,v]),P=(0,x.useCallback)(()=>{if(N){if(N.startsWith("http")||N.startsWith("//"))return void window.open(N,"_blank","noreferrer");M.push(N)}},[M,N]);if(!(d&&h))return(0,i.jsx)(C.M,{});let T=(0,i.jsxs)(k.m,{$withLink:!!N,children:[!A&&(0,i.jsx)(u.hm,{ref:w,width:48,height:48,variant:"inverted",primaryToken:d,secondaryToken:h,withChainLogo:!0}),b&&R&&j,(0,i.jsxs)(E,{children:[(0,i.jsx)(s.VP,{gap:"8px",children:(0,i.jsx)(I.U,{...e})}),(0,i.jsx)(s.VP,{justifyContent:"flex-end",children:g})]})]});return N?(0,i.jsx)("div",{onClick:P,tabIndex:0,role:"button",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),P())},children:T}):T},E=(0,h.Ay)(d.A).withConfig({componentId:"sc-9409253a-0"})(["flex-direction:column;justify-content:space-between;flex:1;gap:8px;color:",";","{flex-direction:row;}"],e=>{let{theme:t}=e;return t.colors.textSubtle},e=>{let{theme:t}=e;return t.mediaQueries.md})},487430:(e,t,n)=>{"use strict";n.d(t,{Hf:()=>p.Hf,iz:()=>p.iz,lN:()=>p.lN,Mu:()=>p.Mu,Uz:()=>l,T0:()=>a,mf:()=>r,Ee:()=>o.Ee,Su:()=>o.Su,V2:()=>c,Kc:()=>p.Kc,jC:()=>p.jC,MU:()=>d,Ss:()=>u});var i=n(659918);let r=e=>({lpApr:parseFloat((e.lpApr||"0").toString()),cakeApr:e.cakeApr?{value:parseFloat((e.cakeApr.value||"0").toString())}:null,merklApr:e.merklApr||0,incentraApr:e.incentraApr||0,numerator:e.numerator||i.AH,denominator:e.denominator||i.AH}),l=e=>{let t="string"==typeof e.lpApr?parseFloat(e.lpApr):e.lpApr,n=e.cakeApr?"string"==typeof e.cakeApr.value?parseFloat(e.cakeApr.value):e.cakeApr.value:0,i=e.merklApr||0,r=e.incentraApr||0;return Number(t||0)+Number(n||0)+Number(i||0)+Number(r||0)};var o=n(562265);let a=(e,t,n,i,r,l)=>{let o=e.add(n),a=t.add(i);return Number(o.toExact())*(null!=r?r:0)+Number(a.toExact())*(null!=l?l:0)};var s=n(203907);let d=(e,t,n)=>!!(e&&(e.tickCurrent<t||e.tickCurrent>=n)),u=e=>0n===e,c=e=>({removed:e===s.$.CLOSED,outOfRange:e===s.$.INACTIVE});var p=n(645444)},488511:(e,t,n)=>{var i=n(685892),r=n(189527),l=n(424967);e.exports=function(e){return function(t,n,o){var a=Object(t);if(!r(t)){var s=i(n,3);t=l(t),n=function(e){return s(a[e],e,a)}}var d=e(t,n,o);return d>-1?a[s?t[d]:d]:void 0}}},489886:(e,t,n)=>{"use strict";n.d(t,{Rc:()=>d,iA:()=>s,jQ:()=>o,n2:()=>u,xk:()=>c});var i=n(985148),r=n(118708),l=n(656862);let o=(0,i.eU)([]),a=(0,l.Iz)(e=>(0,i.eU)(null)),s=(0,i.eU)(null,(e,t,n)=>{if(!n)return;let i=e(o);i.includes(n.id)||(t(o,[...i,n.id]),t(a(n.id),n))}),d=(0,i.eU)(null,(e,t,n)=>{e(o).includes(n.id)&&t(a(n.id),{...e(a(n.id)),...n})});(0,i.eU)(null,(e,t,n)=>{let i=e(o);i.includes(n.id)&&(t(o,i.filter(e=>e!==n.id)),t(a(n.id),null))});let u=(0,i.eU)(e=>e(o).map(t=>e(a(t)))),c=e=>(0,r.md)(a(null!=e?e:""))},491978:e=>{e.exports=function(e,t){return e>t}},494570:(e,t,n)=>{"use strict";n.d(t,{A:()=>y});var i=n(350979),r=n(132435),l=n.n(r),o=n(156035),a=n.n(o),s=n(680797),d=n(605641),u=n(575058);let c=s.I4.table.withConfig({componentId:"sc-2c054c01-0"})(["margin-bottom:32px;margin-top:32px;width:100%;td,th{color:",";padding:8px;}"],e=>{let{theme:t}=e;return t.colors.text}),p=s.I4.div.withConfig({componentId:"sc-2c054c01-1"})(["width:100%;overflow:auto;-webkit-overflow-scrolling:touch;"]),m=s.I4.div.withConfig({componentId:"sc-2c054c01-2"})(["color:",";margin-bottom:16px;margin-top:16px;li{margin-bottom:8px;}"],e=>{let{theme:t}=e;return t.colors.text}),x=s.I4.pre.withConfig({componentId:"sc-2c054c01-3"})(["color:",";margin-bottom:16px;margin-top:16px;max-width:100%;overflow-x:auto;"],e=>{let{theme:t}=e;return t.colors.text}),h=s.I4.a.withConfig({componentId:"sc-2c054c01-4"})(["word-break:break-all;"]),f=e=>(0,i.jsx)(u.A,{as:"h4",scale:"lg",my:"16px",...e}),v={h1:f,h2:f,h3:f,h4:f,h5:f,h6:f,p:e=>(0,i.jsx)(d.A,{as:"p",my:"16px",...e}),table:e=>{let{...t}=e;return(0,i.jsx)(p,{children:(0,i.jsx)(c,{children:t.children})})},ol:e=>(0,i.jsx)(m,{as:"ol",...e}),ul:e=>(0,i.jsx)(m,{as:"ul",...e}),pre:x,a:h},y=e=>(0,i.jsx)(l(),{remarkPlugins:[a()],components:v,...e})},496546:(e,t,n)=>{var i=n(589723);e.exports=function(e,t,n){for(var r=-1,l=e.length;++r<l;){var o=e[r],a=t(o);if(null!=a&&(void 0===s?a==a&&!i(a):n(a,s)))var s=a,d=o}return d}}
29,504304:(e,t,n)=>{"use strict";n.d(t,{E:()=>c});var i=n(350979),r=n(769932),l=n(579518),o=n(605641),a=n(575058),s=n(266283),d=n(810286);let u={textDecoration:"underline dotted",textUnderlineOffset:"0.1em",cursor:"help"},c=e=>{var t,n;let{title:c,currency0:p,currency1:m,price:x,rawPrice:h,...f}=e,{t:v}=(0,r.A)(),y=(0,d.$Y)({mode:"price",price:h}),{targetRef:g,tooltip:A,tooltipVisible:b}=(0,l.A)(y,{placement:"top"});return(0,i.jsxs)(s.k0,{...f,style:{paddingTop:"8px",paddingBottom:"8px",textAlign:"center"},children:[(0,i.jsx)(o.A,{fontSize:"12px",color:"secondary",bold:!0,textTransform:"uppercase",mb:"4px",children:c}),y?(0,i.jsxs)(i.Fragment,{children:[b&&A,(0,i.jsx)(a.A,{mb:"4px",ref:g,style:u,children:x})]}):(0,i.jsx)(a.A,{mb:"4px",children:x}),(0,i.jsx)(o.A,{fontSize:"12px",color:"textSubtle",children:v("%assetA% per %assetB%",{assetA:null!=(t=null==p?void 0:p.symbol)?t:"",assetB:null!=(n=null==m?void 0:m.symbol)?n:""})})]})}},505566:(e,t,n)=>{"use strict";n.d(t,{z:()=>d,K:()=>s});var i=n(659197),r=n(991947),l=n(906296),o=n(25963),a=n(974134);let s=()=>{let e=(0,a.RP)(),[t,n]=(0,l.l)("poolType"),i=(0,o.useMemo)(()=>t===r.y4?(0,r.a5)(e,(0,r.H3)(e,[r.y4])).map(e=>e.data):t===r.FX?[]:Array.isArray(t)?t:t?[t]:[],[e,t]);return{poolType:(0,o.useMemo)(()=>{let n=void 0===t&&i&&Array.isArray(i)&&0===i.length?[r.y4]:i;return(0,r.H3)(e,n)},[e,t,i]),setPoolType:(0,o.useCallback)(t=>{let i=null==t?void 0:t["0"];t&&0!==Object.keys(t).length?i&&i.checked&&!1===i.partialChecked?n(r.y4):n((0,r.a5)(e,t).map(e=>e.data)):n(r.FX)},[n,e]),poolTypeQuery:i}},d=()=>{let{poolTypeQuery:e}=s();return(0,o.useMemo)(()=>e.length?e.reduce((e,t)=>(i.yJ.includes(t)?e.protocols.push(t):[a.Z4.all,a.Z4.poolType,a.Z4.poolFeature].includes(t)||e.features.push(t),t===a.Z4.poolType&&(e.isSelectAllProtocols=!0),t===a.Z4.poolFeature&&(e.isSelectAllFeatures=!0),e),{features:[],protocols:[],isSelectAllProtocols:!1,isSelectAllFeatures:!1}):{features:[],protocols:[],isSelectAllProtocols:!0,isSelectAllFeatures:!0},[e])}},510110:(e,t,n)=>{"use strict";n.d(t,{o:()=>m});var i=n(350979),r=n(769932),l=n(796147),o=n(605641),a=n(990296),s=n(314811),d=n(680797),u=n(53847),c=n(456937);let p=d.I4.div.withConfig({componentId:"sc-c53ebad3-0"})(["cursor:pointer;height:100%;border-radius:16px;padding:2px 2px 4px 2px;&:hover{opacity:0.7;}"]);function m(e){var t;let{feeAmount:n,active:d,poolState:m,distributions:x,onClick:h,largestUsageFeeTier:f,isLoading:v}=e,{t:y}=(0,r.A)();return(0,i.jsx)(p,{active:d,onClick:h,children:(0,i.jsx)(u.N4,{$active:d,padding:"10px 8px",height:"100%",children:(0,i.jsxs)(l.mm,{gap:"sm",justify:"flex-start",height:"100%",justifyItems:"center",children:[(0,i.jsxs)(o.A,{textAlign:"center",color:d?"invertedContrast":"textSubtle",bold:!0,children:[c.A[n].label,"% ",n===f&&"\uD83D\uDD25"]}),v?(0,i.jsx)(a.Ay,{width:"100%",height:16}):x?(0,i.jsx)(o.A,{fontSize:"12px",color:d?"invertedContrast":"textSubtle",children:x&&m!==s.S.NOT_EXISTS&&m!==s.S.INVALID?void 0!==x[n]?`${null==(t=x[n])?void 0:t.toFixed(0)}% ${y("Pick")}`:y("No Data"):y("Not Created")}):null]})})})}},512165:(e,t,n)=>{"use strict";n.d(t,{o:()=>m});var i=n(273523),r=n(734658),l=n(673384),o=n(208103),a=n(687287),s=n(811021),d=n.n(s),u=n(25963),c=n(569019),p=n(17581);let m=e=>{let{currency0:t,currency1:n,poolKey:s,tickLower:m,tickUpper:x,outOfRange:h,invalidRange:f}=e,v=(0,u.useMemo)(()=>s?(0,i.Qn)(s):void 0,[s]),[y,g]=(0,u.useState)(0),[,A]=(0,o.W)(v),[b,w]=(0,u.useState)(""),[j,k]=(0,u.useState)(""),{address:C}=(0,p.F)(),[I,S]=(0,c.ed)(C,(0,u.useMemo)(()=>[t,n],[t,n])),R=(0,a.zW)(t),E=(0,a.zW)(n),M=(0,a.wG)(t),N=(0,a.wG)(n),P=(0,a.dm)(b,t),T=(0,a.dm)(j,n),U=(0,u.useCallback)(e=>{var t,n,i;if(!A||d()(m)||d()(x))return;let r=null!=(i=N(l.yX.fromAmount0({pool:A,tickLower:m,tickUpper:x,amount0:null!=(n=null==(t=R(e))?void 0:t.quotient)?n:0n,useFullPrecision:!0}).amount1,6))?i:"";r!==j&&(g(1),h?k(""):k(r))},[R,N,j,A,x,m,h]),B=(0,u.useCallback)(e=>{var t,n,i;if(!A||d()(m)||d()(x))return;let r=null!=(i=M(l.yX.fromAmount1({pool:A,tickLower:m,tickUpper:x,amount1:null!=(n=null==(t=E(e))?void 0:t.quotient)?n:0n}).amount0,6))?i:"";r!==b&&(g(0),h?w(""):w(r))},[E,M,b,A,x,m,h]),D=(0,u.useCallback)(e=>{w(e),U(e)},[U]),F=(0,u.useCallback)(e=>{k(e),B(e)},[B]),q=(0,u.useCallback)(e=>{var t;let n=null==I?void 0:I.multiply(new r.QE(e,100));D(n&&null!=(t=M(n))?t:"")},[I,D,M]),L=(0,u.useCallback)(e=>{var t;let n=null==S?void 0:S.multiply(new r.QE(e,100));F(n&&null!=(t=N(n))?t:"")},[S,F,N]);return{inputBalance:I,outputBalance:S,inputAmountRaw:b,outputAmountRaw:j,inputAmount:P,outputAmount:T,onInputAmountChange:D,onOutputAmountChange:F,onInputPercentChange:q,onOutputPercentChange:L,lastEditCurrency:y}}},515324:(e,t,n)=>{"use strict";n.d(t,{IV:()=>s,Jc:()=>a,ee:()=>o});var i=n(807543),r=n(266283),l=n(680797);let o=(0,l.Ay)(i.A).withConfig({componentId:"sc-4652d3dc-0"})(["width:100%;max-width:440px;"]),a=(0,l.Ay)(i.A).withConfig({componentId:"sc-4652d3dc-1"})(["width:100%;max-width:580px;"]),s=(0,l.Ay)(r.Ay).withConfig({componentId:"sc-4652d3dc-2"})(["border:1px solid ",";background:",";padding:12px 18px;"],e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.background})},517024:(e,t,n)=>{"use strict";n.d(t,{B:()=>o,J:()=>a});var i=n(985148),r=n(118708),l=n(25963);let o=(0,i.eU)({}),a=()=>{let[e,t]=(0,r.fp)(o);return[e,(0,l.useCallback)((e,n,i,r)=>{let l=null!=r?r:Number(i);void 0!==l&&t(t=>{let o={...t};return o[e]||(o[e]={}),void 0===r?o[e][n]=l:("object"!=typeof o[e][n]&&(o[e][n]={}),o[e][n][i.toString()]=l),o})},[t])]}},522787:function(e){e.exports=function(e,t){var n=t.prototype,i=n.format;n.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return i.bind(this)(e);var r=this.$utils(),l=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return n.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return n.ordinal(t.week(),"W");case"w":case"ww":return r.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return r.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return r.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return"["+t.offsetName()+"]";case"zzz":return"["+t.offsetName("long")+"]";default:return e}});return i.bind(this)(l)}}},524261:(e,t,n)=>{"use strict";n.d(t,{B:()=>m});var i=n(350979),r=n(228876),l=n(769932),o=n(428089),a=n(557423),s=n(764289),d=n.n(s),u=n(25963),c=n(327834),p=n(704784);let m=e=>{let{chainId:t,link:n,outOfRange:s,isStaked:m}=e,{t:x}=(0,l.A)(),h=(0,u.useMemo)(()=>n?(0,c.e)(n,{chain:r.Qk[t]}):n,[n,t]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(p.U,{disableFixedTags:!0,...e}),h?(0,i.jsx)(o.Ay,{mt:"8px",children:(0,i.jsx)(d(),{href:h,children:s&&!m?(0,i.jsx)(a.A,{external:!0,variant:"primary",width:"100%",as:"a",href:h,style:{whiteSpace:"nowrap"},children:x("View Position")}):(0,i.jsx)(a.A,{variant:"tertiary",width:"100%",as:"a",style:{boxShadow:"0px -2px 0px 0px rgba(0, 0, 0, 0.10) inset"},children:x("Manage Position")})})}):null]})}},542160:(e,t,n)=>{"use strict";n.d(t,{Q:()=>m,x:()=>p});var i=n(827666),r=n(734658),l=n(619749),o=n(25963),a=n(91168),s=n(487430),d=n(805939),u=n(562265);let c=(e,t,n,r)=>{try{if(e>=i.ZlO)return 1/0;if(e<=i.BMJ)return 0;let r=i.P3F.getTickPrice({poolInfo:t,tick:e,baseIn:n});return parseFloat(r.price.toFixed(18))}catch(i){console.error("Error calculating tick price:",i);let t=1.0001**e;return n?t:1/t}},p=e=>
29{let{tickLower:t,tickUpper:n,baseIn:u,poolInfo:c}=e,p=(0,o.useMemo)(()=>(0,l.ph)(null==c?void 0:c.mintA),[null==c?void 0:c.mintA]),m=(0,o.useMemo)(()=>(0,l.ph)(null==c?void 0:c.mintB),[null==c?void 0:c.mintB]),x=(0,o.useMemo)(()=>{let e=(0,s.iz)(null==c?void 0:c.config.tickSpacing);return(0,s.Kc)(t,n,e)},[null==c?void 0:c.config.tickSpacing,t,n]),h=(0,o.useMemo)(()=>{if(!p||!m||!c)return;let e=r.gm.fromDecimal(p,m,new a.A(c.price.toString()).toFixed());return u?e:null==e?void 0:e.invert()},[p,m,c,u]),[f,v]=(0,o.useMemo)(()=>{if(!p||!m||!c)return[void 0,void 0];let[e,l]=[i.P3F.getTickPrice({poolInfo:c,tick:n,baseIn:u}),i.P3F.getTickPrice({poolInfo:c,tick:t,baseIn:u})];return[r.gm.fromDecimal(p,m,new a.A(e.price.toString()).toFixed()),r.gm.fromDecimal(p,m,new a.A(l.price.toString()).toFixed())]},[c,n,t,p,m,u,x]),y=(0,o.useMemo)(()=>{if(!f||!h||h.equalTo(0))return;if(u?x[d.z.UPPER]:x[d.z.LOWER])return new r.QE(1,1);let e=f.subtract(h).divide(h);return new r.QE(e.numerator,e.denominator)},[f,h,x,u]),g=(0,o.useMemo)(()=>{if(!v||!h)return;let e=v.subtract(h).divide(h);return new r.QE(e.numerator,e.denominator)},[v,h]);return{currentPrice:h,priceUpper:f,priceLower:v,priceUpperDiffPercent:y,priceLowerDiffPercent:g}},m=e=>{let{tickLower:t,tickUpper:n,baseIn:r,poolInfo:a,debugMeta:p}=e,m=(0,o.useMemo)(()=>(0,l.ph)(null==a?void 0:a.mintA),[null==a?void 0:a.mintA]),x=(0,o.useMemo)(()=>(0,l.ph)(null==a?void 0:a.mintB),[null==a?void 0:a.mintB]),h=(0,o.useMemo)(()=>{let e=(0,s.iz)(null==a?void 0:a.config.tickSpacing);return(0,s.Kc)(t,n,e)},[null==a?void 0:a.config.tickSpacing,t,n]);return(0,o.useMemo)(()=>{let e,l="-",o="-",s="",p="",f=50,v=!1;if(!a||!m||!x)return{minPriceFormatted:l,maxPriceFormatted:o,minPercentage:s,maxPercentage:p,rangePosition:f,showPercentages:v,currentPrice:e};let y=r?t:n,g=r?n:t,A=r?h:{[d.z.LOWER]:h[d.z.UPPER],[d.z.UPPER]:h[d.z.LOWER]},b=c(y,a,r),w=c(g,a,r);if(l=A[d.z.LOWER]?"0":b.toString()||"-",o=A[d.z.UPPER]?"â":w.toString()||"-",a.price)try{let t=parseFloat(a.price.toString());r||(t=1/t),t>0&&Number.isFinite(t)&&(e=t.toFixed(18))}catch(e){console.warn("Current price calculation error:",e)}if(A[d.z.LOWER]&&A[d.z.UPPER])f=50,v=!0,s="0%",p="100%",l="0",o="â";else if(e&&y>i.BMJ&&g<i.ZlO)try{let t=parseFloat(e);if(t>0&&w>b&&Number.isFinite(b)&&Number.isFinite(w)&&Number.isFinite(t)){let e=(b-t)/t*100,n=(w-t)/t*100;Number.isFinite(e)&&Number.isFinite(n)&&1e4>Math.abs(e)&&1e4>Math.abs(n)&&(s=(0,u.Ee)(e),p=(0,u.Ee)(n),f=Math.max(0,Math.min(100,(t-b)/(w-b)*100)),v=!0)}}catch(e){console.warn("Price percentage calculation error:",e)}return{minPriceFormatted:l,maxPriceFormatted:o,minPercentage:s,maxPercentage:p,rangePosition:f,showPercentages:v,currentPrice:e,minPrice:Number.isFinite(b)?b:void 0,maxPrice:Number.isFinite(w)?w:void 0,currentPriceValue:e&&Number.isFinite(parseFloat(e))?parseFloat(e):void 0}},[t,n,r,a,m,x,h])}},553301:(e,t,n)=>{"use strict";n.d(t,{w:()=>o});var i=n(673384),r=n(131619),l=n(650176);function o(e,t){let n,o=(0,r.H2)(null==e?void 0:e.token0,t),a=(0,r.H2)(null==e?void 0:e.token1,t),[,s]=(0,l.Q2)(null!=o?o:void 0,null!=a?a:void 0,null==e?void 0:e.fee);return s&&e&&(n=new i.yX({pool:s,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})),{position:n,pool:null!=s?s:void 0}}},562038:(e,t,n)=>{var i=n(312531),r=n(367475),l=n(196941),o=n(115743);e.exports=function(e){return function(t){var n=r(t=o(t))?l(t):void 0,a=n?n[0]:t.charAt(0),s=n?i(n,1).join(""):t.slice(1);return a[e]()+s}}},562265:(e,t,n)=>{"use strict";n.d(t,{Ee:()=>a,Su:()=>o,Yr:()=>s});var i=n(748853),r=n(91168),l=n(823585);let o=e=>(0,i.l)(e,"$").replace(" ",""),a=e=>{if(.01>Math.abs(e))return"0%";if(!Number.isFinite(e))return"-%";let t=e>=0?"+":"";return`${t}${e.toFixed(1)}%`},s=(e,t,n)=>{let i=String(e),o=String(t);if("0"===i||"-"===i||"NaN"===i||!Number.isFinite(Number(e)))return{minFormatted:"0"===i?"0":i,maxFormatted:"â"===o||"Infinity"===o?"â":o};if("â"===o||"Infinity"===o||"-"===o||"NaN"===o||!Number.isFinite(Number(t)))return{minFormatted:i,maxFormatted:"â"===o||"Infinity"===o?"â":o};let a=Number(e),s=Number(t);if(Number.isFinite(a)&&Number.isFinite(s)&&a>s){let e=a;a=s,s=e}if(void 0!==n){let e={decimalSeparator:".",groupSeparator:",",groupSize:3},t={minFormatted:new r.g(a).toFormat(n,r.g.ROUND_HALF_UP,e),maxFormatted:new r.g(s).toFormat(n,r.g.ROUND_HALF_UP,e)},i=(e,t)=>e>0&&new r.g(t.replace(/,/g,"")).isZero();if(!i(a,t.minFormatted)&&!i(s,t.maxFormatted))return t}let d=new r.g(a).toFixed(18),u=new r.g(s).toFixed(18),[c,p=""]=d.split("."),[m,x=""]=u.split("."),h=2;if(c!==m)h=1>Math.abs(a)?4:2;else{let e=Math.max(p.length,x.length),t=-1;for(let n=0;n<e;n++)if((p[n]||"0")!==(x[n]||"0")){t=n;break}h=t>=0?Math.min(t+2,8):2,.01>Math.abs(a)&&(h=Math.max(h,4))}let f=(e,t)=>e>0&&e<.001?(0,l.ZV)(e,{maxDecimalDisplayDigits:Math.max(6,t),maximumDecimalTrailingZeroes:3}):(0,l.ZV)(e,{maxDecimalDisplayDigits:Math.max(2,t)}).replace(/\.00$/,"");return{minFormatted:f(a,h),maxFormatted:f(s,h)}}},568137:(e,t,n)=>{"use strict";n.d(t,{h:()=>i});let i=[{value:"major",label:"Verified",children:[{value:"major",label:"Majors"},{value:"stocks",label:"Stocks"},{value:"stablecoin",label:"Stables"}]},{value:"unverified",label:"Unverified"}]},568618:e=>{var t=Math.ceil,n=Math.max;e.exports=function(e,i,r,l){for(var o=-1,a=n(t((i-e)/(r||1)),0),s=Array(a);a--;)s[l?a:++o]=e,e+=r;return s}},573271:(e,t,n)=>{"use strict";n.d(t,{K:()=>u});var i=n(350979),r=n(659197),l=n(769932),o=n(979332),a=n(501823),s=n(525033),d=n(581076);function u(e){var t;let{removed:n,outOfRange:u,protocol:c,children:p,lowContrast:m=!1,...x}=e,{t:h}=(0,l.A)();return n?(0,i.jsx)(o.A,{variant:m?"tertiary":"textSubtle",...x,children:p||h("Closed")}):u?(0,i.jsx)(o.A,{variant:m?"failureLowContrast":"failure",...x,children:p||(0,i.jsxs)(a.A,{alignItems:"center",children:[h("Inactive")," ",(0,i.jsx)(s.PT,{position:"relative",top:"1px",ml:"4px",text:h(c===r.Zs.InfinityBIN?"The position is inactive and not generating fees because there is no liquidity in the active bin.":"The position is inactive and not earning trading fees due to the current price being out of the set price range."),size:"20px",color:null!=(t=d.c[m?"failureLowContrast":"failure"].color)?t:"white",placement:"bottom"})]})}):(0,i.jsx)(o.A,{variant:m?"successLowContrast":"success",...x,children:p||h("Active")}
29)}},579014:(e,t,n)=>{"use strict";n.d(t,{A:()=>L});var i=n(350979),r=n(769932),l=n(311560),o=n(549333),a=n(412867),s=n(182063),d=n(862373),u=n(970645),c=n(555967),p=n(611262),m=n(25963),x=n(259145),h=n(189346),f=n(975644),v=n(636236),y=n(262453),g=n(835490),A=n(443634),b=n(687287),w=n(968349),j=n(743818),k=n(286750),C=n(306411),I=n(518400),S=n(733775),R=n(178852),E=n(241439),M=n(459247),N=n(579670),P=n(310899),T=n(614740),U=n(555849),B=n(782739),D=n(85642),F=n(852076),q=n(337049);function L(e){var t,n,L,O;let{currencyA:_,currencyB:$,children:Y}=e,{account:z,chainId:V}=(0,w.W7)(),Z=(0,j.j6)(),W=(0,d.xf)(),{t:H,currentLanguage:{locale:Q}}=(0,r.A)(),G=(0,I.YW)(),{independentField:K,typedValue:X,otherTypedValue:J}=(0,k.uE)(),{dependentField:ee,currencies:et,pair:en,pairState:ei,currencyBalances:er,parsedAmounts:el,noLiquidity:eo,liquidityMinted:ea,poolTokenPercentage:es,error:ed,addError:eu,loading:ec,reserves:ep}=(0,D.K)(null!=_?_:void 0,null!=$?$:void 0),{onFieldAInput:em,onFieldBInput:ex}=(0,A.B)(!0),eh=(0,a.m)();(0,m.useEffect)(()=>{if(eh){let{currencyIdA:n,currencyIdB:i}=eh;if(n&&i&&n!==(0,s.V)(null!=_?_:void 0)&&i!==(0,s.V)(null!=$?$:void 0)){var e,t;em(null!=(e=eE[g.O9.CURRENCY_B])?e:""),ex(null!=(t=eE[g.O9.CURRENCY_A])?t:"")}}},[eh]);let ef=(0,c.TH)(),[{attemptingTxn:ev,liquidityErrorMessage:ey,txHash:eg},eA]=(0,m.useState)({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0}),[eb]=(0,d.uZ)(),{lpOutputWithoutFee:ew,loading:ej,price:ek}=function(e,t){let{stableSwapConfig:n}=(0,m.useContext)(v.jq)||{},{totalSupply:i,balances:r,amplifier:o,loading:a}=function(e,t){var n,i;let{chainId:r}=(0,w.ax)(),{data:o,isLoading:a}=(0,B.XO)({query:{enabled:!!(e&&t)},contracts:[{chainId:r,abi:U.R,address:e,functionName:"balances",args:[0n]},{chainId:r,abi:U.R,address:e,functionName:"balances",args:[1n]},{chainId:r,abi:U.R,address:e,functionName:"A"},{chainId:r,abi:T.M,address:t,functionName:"totalSupply"},{chainId:r,abi:U.R,address:e,functionName:"fee"},{chainId:r,abi:U.R,address:e,functionName:"FEE_DENOMINATOR"}],watch:!0}),s=null==o||null==(n=o[4])?void 0:n.result,d=null==o||null==(i=o[5])?void 0:i.result;return{balances:[null==o?void 0:o[0].result,null==o?void 0:o[1].result],amplifier:null==o?void 0:o[2].result,totalSupply:null==o?void 0:o[3].result,fee:s&&d&&new l.QE(s,d),loading:a}}(null==n?void 0:n.stableSwapAddress,null==n?void 0:n.liquidityToken.address),s=(0,b.dm)("1",null==e?void 0:e.currency),d=null==e?void 0:e.currency.wrapped,c=null==t?void 0:t.currency.wrapped,[p,x]=d&&c&&(null==d?void 0:d.sortsBefore(c))?[d,c]:[c,d],[h,f]=d&&p&&p.equals(d)?[e,t]:[t,e],y=(0,m.useMemo)(()=>p&&x&&r[0]&&r[1]?[l.eF.fromRawAmount(p,r[0]),l.eF.fromRawAmount(x,r[1])]:void 0,[r,p,x]),g=(0,m.useMemo)(()=>i&&(null==n?void 0:n.liquidityToken)&&l.eF.fromRawAmount(n.liquidityToken,i),[i,null==n?void 0:n.liquidityToken]);return(0,m.useMemo)(()=>{let n={loading:a,lpOutputWithoutFee:null,price:null};if(!g||!y||!h||!f||!o||!e||!t||y[0].quotient+y[1].quotient===u.CL)return n;let i=null,r=null;try{if(i=(0,P.Iq)({amplifier:o,balances:y,totalSupply:g,amounts:[h,f]}),!s)return n;let e=(0,P.hg)({amplifier:o,balances:y,amount:s,outputCurrency:t.currency});r=new l.gm({baseAmount:s,quoteAmount:e})}catch(e){console.error(e)}return{loading:a,lpOutputWithoutFee:i,price:r}},[g,y,o,a,h,f,e,t,s])}(el[g.O9.CURRENCY_A],el[g.O9.CURRENCY_B]),eC=(0,m.useMemo)(()=>ew&&(0,R.wQ)(ew,eb)[0],[ew,eb]),eI=(0,m.useMemo)(()=>{if(ea&&ew)return u.cK.subtract(new l.QE(ea.quotient,ew.quotient))},[ea,ew]),eS=eI&&(0,F.Y9)(eI),eR=[g.O9.CURRENCY_A,g.O9.CURRENCY_B].reduce((e,t)=>({...e,[t]:(0,E.r)(er[t])}),{}),eE=(0,m.useMemo)(()=>({[K]:X,[ee]:J}),[ee,K,J,X]),{stableSwapContract:eM,stableSwapConfig:eN}=(0,m.useContext)(v.jq)||{};(0,p.L)(null==eN?void 0:eN.liquidityToken.address);let eP=(null==_?void 0:_.isNative)||(null==$?void 0:$.isNative),{approvalState:eT,approveCallback:eU}=(0,y.en)(el[g.O9.CURRENCY_A],eP?null==ef?void 0:ef.address:null==eM?void 0:eM.address),{approvalState:eB,approveCallback:eD}=(0,y.en)(el[g.O9.CURRENCY_B],eP?null==ef?void 0:ef.address:null==eM?void 0:eM.address),eF=(0,C.OQ)(),eq=(0,b.wG)(et[g.O9.CURRENCY_A]),eL=(0,b.wG)(et[g.O9.CURRENCY_B]);async function eO(){var e,t,n,i,r,l,o,a,s,d;let u,c,p;(0,x.aF)();let m=eP?ef:eM;if(!V||!z||!m)return;let{[g.O9.CURRENCY_A]:v,[g.O9.CURRENCY_B]:y}=el,A=(null==v?void 0:v.greaterThan(0))||(null==y?void 0:y.greaterThan(0)),b=(null==v?void 0:v.greaterThan(0))&&(null==y?void 0:y.greaterThan(0));if(eo?!b:!A)return;let w=ea&&(0,R.wQ)(ea,eo?0:eb)[0],j=null==(e=et[g.O9.CURRENCY_A])?void 0:e.symbol,k=(null==(t=el[g.O9.CURRENCY_A])?void 0:t.toSignificant(3))||"0",C=null==(n=et[g.O9.CURRENCY_B])?void 0:n.symbol,I=(null==(i=el[g.O9.CURRENCY_B])?void 0:i.toSignificant(3))||"0",E=null!=(a=eq(el[g.O9.CURRENCY_A],3))?a:k,N=null!=(s=eL(el[g.O9.CURRENCY_B],3))?s:I,P=(0,M.bD)({account:z,chainId:V,runtime:Z}),T=(null==v?void 0:v.quotient)||0n,U=(null==y?void 0:y.quotient)||0n,B=(0,S.ho)(null==eN||null==(r=eN.token0)?void 0:r.wrapped.address,null==v||null==(o=v.currency)||null==(l=o.wrapped)?void 0:l.address)?[T,U]:[U,T];if(eP){if(!eM)return;let e=[eM.address,B,eC||w];u=e;let t=null==(d=(null==$?void 0:$.isNative)?y:v)?void 0:d.quotient;c=t,p=ef.estimateGas.add_liquidity(e,{value:t,account:m.account}).then(n=>ef.write.add_liquidity(e,{gas:(0,S.KL)(n),gasPrice:G,value:t,account:m.account,chain:m.chain}))}else{let e=[B,eC||w];if(u=e,!eM||!m.account)return;let t=m.account;p=eM.estimateGas.add_liquidity(e,{account:t}).then(n=>eM.write.add_liquidity(e,{gas:(0,S.KL)(n),gasPrice:G,account:t,chain:m.chain}))}eA({attemptingTxn:!0,liquidityErrorMessage:void 0,txHash:void 0}),(0,M.Dt)("liquidity_add_started",{...P,pool_type:"stable",token_a_symbol:null!=j?j:null,token_a_amount:k,token_b_symbol:null!=C?C:null,token_b_amount:I,no_liquidity:eo}),await p.then(e=>{eA({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:e}),(0,x.Mg)(),eF({hash:e},{summary:`Add ${E} ${j} and ${N} ${C}`,translatableSummary:{text:"Add %amountA% %symbolA% and %amountB% %symbolB%",data:{amountA:E,symbolA:j,amountB:N,symbolB:C}},type:"add-liquidity"}),(0,M.Dt)("liquidity_add_succeeded",{...P,pool_type:"stable",token_a_symbol:null!=j?j:null,token_a_amount:k,token_b_symbol:null!=C?C:null,token_b_amount:I,tx_hash:e,no_liquidity:eo})}).catch(e=>{e&&!(0,h.U)(e)&&((0,h.v)(e),console.error("Add Liquidity failed",e,u,c)),(0,M.Dt)("liquidity_add_failed",{...P,pool_type:"stable",token_a_symbol:null!=j?j:null,token_a_amount:k,token_b_symbol:null!=C?C:null,token_b_amount:I,rejected_by_user:!!(e&&(0,h.U)(e)),no_liquidity:eo,...(0,M.fx)(e,e&&(0,h.U)(e)?"Transaction rejected.":void 0)}),eA({attemptingTxn:!1,liquidityErrorMessage:e&&!(0,h.U)(ed)?H("Add liquidity failed: %message%",{message:(0,f.w)(e,H)}):void 0,txHash:void 0})})}let e_=e=>
29e?Number(e).toLocaleString(Q,{maximumSignificantDigits:4}):"",e$=H("Supplying %amountA% %symbolA% and %amountB% %symbolB%",{amountA:e_(eq(el[g.O9.CURRENCY_A],4)),symbolA:null!=(L=null==(t=et[g.O9.CURRENCY_A])?void 0:t.symbol)?L:"",amountB:e_(eL(el[g.O9.CURRENCY_B],4)),symbolB:null!=(O=null==(n=et[g.O9.CURRENCY_B])?void 0:n.symbol)?O:""}),eY=(0,m.useCallback)(()=>{eg&&(em(""),ex("")),eA({attemptingTxn:!1,liquidityErrorMessage:void 0,txHash:void 0})},[em,ex,eg]),[ez]=(0,o.A)((0,i.jsx)(N.A,{title:eo?H("You are creating a trading pair"):H("You will receive"),customOnDismiss:eY,attemptingTxn:ev,hash:eg,pendingText:e$,currencyToAdd:null==en?void 0:en.liquidityToken,allowedSlippage:eb,onAdd:eO,parsedAmounts:el,currencies:et,liquidityErrorMessage:ey,price:ek,noLiquidity:eo,poolTokenPercentage:es,liquidityMinted:ea,isStable:!0}),!0,!0,"addLiquidityModal"),eV=!ed,eZ=ed;eV=!ed&&!eu,eZ=null!=ed?ed:eu;let{[g.O9.CURRENCY_A]:eW,[g.O9.CURRENCY_B]:eH}=el,eQ=(null==eW?void 0:eW.greaterThan(0))&&eT!==y.h$.APPROVED||(null==eH?void 0:eH.greaterThan(0))&&eB!==y.h$.APPROVED,eG=!eV||eQ||!!eS&&eS>2&&!W,eK=eT===y.h$.NOT_APPROVED||eT===y.h$.PENDING,eX=eB===y.h$.NOT_APPROVED||eB===y.h$.PENDING,eJ=(eK||eX)&&eV,{totalUsdValue:e0}=(0,q.t)({parsedAmountA:eW,parsedAmountB:eH});return Y({formattedAmounts:eE,onFieldAInput:em,onFieldBInput:ex,maxAmounts:eR,currencies:et,poolTokenPercentage:es,executionSlippage:eI,loading:ej,shouldShowApprovalGroup:eJ,showFieldAApproval:eK,approveACallback:eU,approvalA:eT,showFieldBApproval:eX,approvalB:eB,approveBCallback:eD,onAdd:eO,onPresentAddLiquidityModal:ez,buttonDisabled:eG,errorText:eZ,inputAmountsTotalUsdValue:e0})}},579670:(e,t,n)=>{"use strict";n.d(t,{A:()=>N});var i=n(350979),r=n(769932),l=n(557423),o=n(698612),a=n(214885),s=n(687287),d=n(567223),u=n.n(d),c=n(25963),p=n(696368),m=n(428089),x=n(257057),h=n(605641),f=n(796147),v=n(501823),y=n(579518),g=n(889948),A=n(266283),b=n(320669),w=n(150103),j=n(810286),k=n(680797),C=n(311560);let I=(0,k.I4)(m.Ay).withConfig({componentId:"sc-ec35c45e-0"})(["width:12px;height:12px;border-radius:50%;"]),S=e=>{let{percent:t=1,stroke:n="#1FC7D4",...r}=e;return(0,i.jsxs)(x.A,{width:"60px",height:"60px",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[(0,i.jsxs)("g",{filter:"url(#filter0_i_1147_113741)",children:[(0,i.jsx)("circle",{r:"10",cx:"10",cy:"10",fill:"#7645D9"}),(0,i.jsx)("circle",{r:"5",cx:"10",cy:"10",fill:"transparent",stroke:n,strokeWidth:"10",strokeDasharray:`calc(${100*t}px * 31.4 / 100) 31.4`,transform:"rotate(-90) translate(-20)"})]}),(0,i.jsx)("defs",{children:(0,i.jsxs)("filter",{id:"filter0_i_1147_113741",x:0,y:0,width:60,height:60,filterUnits:"userSpaceOnUse",colorInterpolationFilters:"sRGB",children:[(0,i.jsx)("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),(0,i.jsx)("feBlend",{in:"SourceGraphic",in2:"BackgroundImageFix",result:"shape"}),(0,i.jsx)("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),(0,i.jsx)("feOffset",{dy:-2}),(0,i.jsx)("feComposite",{in2:"hardAlpha",operator:"arithmetic",k2:-1,k3:1}),(0,i.jsx)("feColorMatrix",{values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"}),(0,i.jsx)("feBlend",{in2:"shape",result:"effect1_innerShadow_1147_113741"})]})})]})},R=e=>{let{children:t}=e;return(0,i.jsx)(h.A,{fontSize:"12px",textTransform:"uppercase",bold:!0,color:"secondary",children:t})},E=e=>{let t,{title:n,percent:r,currencyA:l,currencyB:o,currencyAValue:a,currencyBValue:s,tooltipTargetRef
29:d}=e;return 100===r&&(t=a?"primary":"secondary"),(0,i.jsxs)(f.mm,{gap:"8px",children:[(0,i.jsx)(R,{children:n}),(0,i.jsxs)(v.A,{children:[void 0!==r&&(0,i.jsx)("div",{ref:d,children:(0,i.jsx)(S,{stroke:t,percent:r,mr:"34px"})}),(0,i.jsxs)(f.mm,{style:{width:"100%"},children:[l&&(0,i.jsxs)(b.JA,{children:[(0,i.jsxs)(b.eF,{gap:"4px",children:[(0,i.jsx)(I,{bg:"primary"}),(0,i.jsx)(w.Zm,{currency:l}),(0,i.jsx)(h.A,{children:null==l?void 0:l.symbol})]}),(0,i.jsx)(h.A,{children:a||"0"})]}),o&&(0,i.jsxs)(b.JA,{children:[(0,i.jsxs)(b.eF,{gap:"4px",children:[(0,i.jsx)(I,{bg:"secondary"}),(0,i.jsx)(w.Zm,{currency:o}),(0,i.jsx)(h.A,{children:null==o?void 0:o.symbol})]}),(0,i.jsx)(h.A,{children:s||"0"})]})]})]})]})},M=e=>{var t,n,l,o,a,d,u,c,m,x;let{currencies:v,poolTokenPercentage:k,liquidityMinted:I,price:S,allowedSlippage:E,noLiquidity:M,children:N}=e,{t:P}=(0,r.A)(),T=(0,s.xm)(S),{tooltip:U,tooltipVisible:B,targetRef:D}=(0,y.A)(P("Output is estimated. If the price changes by more than %slippage%% your transaction will revert.",{slippage:E/100}));return(0,i.jsxs)(f.mm,{gap:"24px",children:[(0,i.jsxs)(f.mm,{gap:"8px",children:[(0,i.jsx)(R,{children:P("You will receive")}),(0,i.jsx)(A.Al,{children:(0,i.jsxs)(b.JA,{children:[(0,i.jsxs)(b.eF,{gap:"4px",children:[(0,i.jsx)(w.gz,{currency0:v[p.D.CURRENCY_A],currency1:v[p.D.CURRENCY_B],size:24}),(0,i.jsx)(h.A,{color:"textSubtle",children:(null==(t=v[p.D.CURRENCY_A])?void 0:t.symbol)&&(null==(n=v[p.D.CURRENCY_B])?void 0:n.symbol)&&((e,t,n)=>e===C.xQ[n].symbol?`${C.s6[n].symbol}-${t} LP`:t===C.xQ[n].symbol?`${e}-${C.s6[n].symbol} LP`:`${e}-${t} LP`)(null==(l=v[p.D.CURRENCY_A])?void 0:l.symbol,null==(o=v[p.D.CURRENCY_B])?void 0:o.symbol,null==(a=v[p.D.CURRENCY_A])?void 0:a.chainId)})]}),(0,i.jsx)(h.A,{ml:"8px",children:null==I?void 0:I.toSignificant(6)})]})})]}),(0,i.jsxs)(b.JA,{children:[(0,i.jsx)(R,{children:P("Your share in the pair")}),(0,i.jsxs)(h.A,{children:[M?"100":null==k?void 0:k.toSignificant(4),"%"]})]}),(0,i.jsx)(f.mm,{gap:"8px",children:N}),!!S&&(0,i.jsxs)(f.mm,{children:[(0,i.jsxs)(b.JA,{children:[(0,i.jsx)(R,{children:P("Rates")}),(0,i.jsx)(j.g3,{mode:"price",price:S,children:`1 ${null==(d=v[p.D.CURRENCY_A])?void 0:d.symbol} = ${null==T?void 0:T.toSignificant(4)} ${null==(u=v[p.D.CURRENCY_B])?void 0:u.symbol}`})]}),(0,i.jsx)(b.JA,{style:{justifyContent:"flex-end"},children:(0,i.jsx)(j.g3,{mode:"price",price:null==S?void 0:S.invert(),children:`1 ${null==(c=v[p.D.CURRENCY_B])?void 0:c.symbol} = ${null==T||null==(m=T.invert())?void 0:m.toSignificant(4)} ${null==(x=v[p.D.CURRENCY_A])?void 0:x.symbol}`})})]}),!M&&(0,i.jsxs)(b.JA,{children:[(0,i.jsx)(R,{children:P("Slippage Tolerance")}),(0,i.jsxs)(g.A,{ref:D,children:[E/100,"%"]}),B&&U]})]})},N=e=>{let{title:t,onDismiss:n,customOnDismiss:d,attemptingTxn:m,hash:x,pendingText:h,price:f,currencies:v,noLiquidity:y,allowedSlippage:g,parsedAmounts:A,liquidityErrorMessage:b,onAdd:w,poolTokenPercentage:j,liquidityMinted:k,currencyToAdd:C,isStable:I}=e,{t:S}=(0,r.A)(),R=(0,s.wG)(v[p.D.CURRENCY_A]),N=(0,s.wG)(v[p.D.CURRENCY_B]),P=R(A[p.D.CURRENCY_A],6),T=N(A[p.D.CURRENCY_B],6),U=(0,s.xm)(f),B=.5;if(I&&A[p.D.CURRENCY_A]||A[p.D.CURRENCY_B]){let e=P?u()(P):0,t=(U&&parseFloat(null==U?void 0:U.toSignificant(4))||1)*e;B=t/(t+(T?u()(T):0))}let D=(0,c.useCallback)(()=>(0,i.jsx)(M,{allowedSlippage:g,currencies:v,liquidityMinted:k,poolTokenPercentage:j,price:f,noLiquidity:y,children:(0,i.jsx)(E,{title:S("Input"),percent:B,currencyA:v[p.D.CURRENCY_A],currencyAValue:P,currencyB:v[p.D.CURRENCY_B],currencyBValue:T})}),[g,B,v,k,y,P,T,j,f,S]),F=(0,c.useCallback)(()=>(0,i.jsx)(l.A,{width:"100%",onClick:w,mt:"20px",children:y?S("Create Pair & Supply"):S("Confirm Supply")}),[y,w,S]),q=(0,c.useCallback)(()=>(0,i.jsx)(o.Y,{topContent:D,bottomContent:F}),[D,F]);return(0,i.jsx)(a.A,{minWidth:["100%","","420px"],title:t,onDismiss:n,customOnDismiss:d,attemptingTxn:m,currencyToAdd:C,errorMessage:b,hash:x,content:q,pendingText:h})}},580213:(e,t,n)=>{"use strict";n.d(t,{YS:()=>W.YS,Gu:()=>W.Gu,iC:()=>H.i,yw:()=>N,c5:()=>Z});var i=n(350979),r=n(25963),l=n(218090),o=n(393783),a=n(227432),s=n(393851),d=n(43838),u=n(252299),c=n(382425),p=n(
29580771),m=n(680797),x=n(35217),h=n(941660),f=n(608449);let v=e=>e,y="#31D0AA",g="#ED4B9E",A="#7645D9",b=m.I4.div.withConfig({componentId:"sc-f47caf97-0"})(["position:relative;width:100%;"]),w=m.I4.div.withConfig({componentId:"sc-f47caf97-1"})(["display:flex;align-items:center;gap:8px;margin-bottom:24px;"]),j=m.I4.div.withConfig({componentId:"sc-f47caf97-2"})(["color:",";font-size:24px;font-weight:600;font-variant-numeric:tabular-nums;"],e=>{let{theme:t}=e;return t.colors.text}),k=m.I4.div.withConfig({componentId:"sc-f47caf97-3"})(["display:flex;align-items:center;gap:5px;padding:2px 8px;border-radius:999px;color:",";background:",";font-size:16px;font-weight:600;white-space:nowrap;"],e=>{let{theme:t,$negative:n}=e;return n?t.colors.destructive60:t.colors.positive60},e=>{let{theme:t,$negative:n}=e;return n?t.colors.destructive10:t.colors.positive10}),C=m.I4.span.withConfig({componentId:"sc-f47caf97-4"})(["width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;",""],e=>{let{theme:t,$negative:n}=e;return n?`border-top: 7px solid ${t.colors.destructive60};`:`border-bottom: 7px solid ${t.colors.positive60};`}),I=m.I4.div.withConfig({componentId:"sc-f47caf97-5"})(["position:absolute;z-index:2;width:","px;box-sizing:border-box;padding:16px;display:flex;flex-direction:column;gap:8px;border:1px solid ",";border-radius:16px;background:",";box-shadow:0 4px 12px rgba(0,0,0,0.08);pointer-events:none;"],220,e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.card}),S=m.I4.div.withConfig({componentId:"sc-f47caf97-6"})(["display:flex;align-items:center;justify-content:space-between;gap:12px;white-space:nowrap;"]),R=m.I4.span.withConfig({componentId:"sc-f47caf97-7"})(["color:",";font-size:14px;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),E=m.I4.span.withConfig({componentId:"sc-f47caf97-8"})(["color:",";font-size:14px;font-weight:600;"],e=>{let{theme:t,$tone:n}=e;return"bid"===n?"#129E7D":"ask"===n?g:t.colors.text}),M=(e,t)=>{if(e.length)return e.reduce((e,n)=>Math.abs(n.price-t)<Math.abs(e.price-t)?n:e)},N=e=>{let{data:t,currentPrice:n,baseAsset:N,quoteAsset:P,priceChangePercent:T=0,rangePercent:U=.04,height:B=340,t:D=v}=e,F=(0,m.DP)(),{isMobile:q}=(0,x.ZV)(),L=(0,r.useRef)(null),[O,_]=(0,r.useState)(0),[$,Y]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=L.current;if(!e)return;let t=()=>_(e.clientWidth);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,r.useEffect)(()=>{q&&Y(null)},[q]);let z=Math.max(Math.abs(n)*U,Number.EPSILON),V=n-z,Z=n+z,W=Z-V,H=O<520?3:O<900?5:7,Q=(0,r.useMemo)(()=>{let e=H-1;return Array.from({length:H},(t,n)=>V+W*n/e)},[H,V,W]),G=(0,r.useMemo)(()=>t.filter(e=>e.price>=V&&e.price<=Z).sort((e,t)=>e.price-t.price),[t,Z,V]),K=(0,r.useMemo)(()=>G.filter(e=>null!=e.bid),[G]),X=(0,r.useMemo)(()=>G.filter(e=>null!=e.ask),[G]),J=(0,r.useMemo)(()=>Math.max(1,...G.flatMap(e=>{var t,n;return[null!=(t=e.bid)?t:0,null!=(n=e.ask)?n:0]})),[G]),ee=(0,r.useMemo)(()=>{if(q||null==$||0===O)return null;let e=Math.min(Math.abs($-n),z);if(e<=0)return null;let t=n-e,i=n+e,r=M(K,t),l=M(X,i),o=Math.max(0,O-48),a=e=>24+(e-V)/W*o,s=e=>Math.max(4,Math.min(e,O-220-4));return{leftPrice:t,rightPrice:i,leftPoint:r,rightPoint:l,rangePercent:e/n*100,leftCardLeft:s(a(t)-8-220),rightCardLeft:s(a(i)+8)}},[X,K,n,z,$,q,V,W,O]),et=(e,t,n,r)=>{var l;let o="bid"===t?null==r?void 0:r.bidAmount:null==r?void 0:r.askAmount,a="bid"===t?null==r?void 0:r.bidAmountUsd:null==r?void 0:r.askAmountUsd,s="bid"===t?N:P;return(0,i.jsxs)(I,{style:{left:e,top:"34%"},children:[(0,i.jsxs)(S,{children:[(0,i.jsx)(R,{children:D("Range")}),(0,i.jsx)(E,{$tone:t,children:`+${null!=(l=null==ee?void 0:ee.rangePercent.toFixed(1))?l:"0.0"}%`})]}),(0,i.jsxs)(S,{children:[(0,i.jsx)(R,{children:D("Price")}),(0,i.jsx)(E,{children:`${(0,f.oD)(n)} ${P}`})]}),(0,i.jsxs)(S,{children:[(0,i.jsx)(R,{children:D("Amount")}),(0,i.jsx)(E,{children:null==o?"â":`${(0,f.f0)(o)} ${s}`})]}),(0,i.jsxs)(S,{children:[(0,i.jsx)(R,{children:D("Amount (USD)")}),(0,i.jsx)(E,{children:(e=>null!=e&&Number.isFinite(e)?`$${(0,f.K5)(e)}`:"â")(a)})]})]})},en=T<0;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(w,{children:[(0,i.jsxs)(j,{children:["1 ",N," = ",(0,i.jsx)(h.s,{value:n})," ",P]}),(0,i.jsxs)(k,{$negative:en,children:[(0,i.jsx)(C,{$negative:en}),Math.abs(T).toFixed(2),"%"]})]}),(0,i.jsxs)(b,{ref:L,children:[(0,i.jsx)(l.u,{width:"100%",height:B,children:(0,i.jsxs)(o.Q,{data:G,margin:{top:10,right:24,left:24,bottom:0},onMouseMove:e=>{q||((null==e?void 0:e.activeLabel)!=null?Y(Number(e.activeLabel)):Y(null))},onMouseLeave:()=>Y(null),children:[(0,i.jsxs)("defs",{children:[(0,i.jsxs)("linearGradient",{id:"liquidityDepthBidFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,i.jsx)("stop",{offset:"0%",stopColor:y,stopOpacity:.6}),(0,i.jsx)("stop",{offset:"100%",stopColor:y,stopOpacity:0})]}),(0,i.jsxs)("linearGradient",{id:"liquidityDepthAskFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,i.jsx)("stop",{offset:"0%",stopColor:g,stopOpacity:.5}),(0,i.jsx)("stop",{offset:"100%",stopColor:g,stopOpacity:0})]})]}),(0,i.jsx)(a.h,{hide:!0,domain:[0,J]}),(0,i.jsx)(s.W,{type:"number",dataKey:"price",domain:[V,Z],ticks:Q,interval:0,axisLine
29:!1,tickLine:!1,tick:{fontSize:16,fill:F.colors.textSubtle,fontFamily:"Kanit"},tickFormatter:e=>(0,f.oD)(Number(e))}),ee?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(d.T,{x1:V,x2:ee.leftPrice,fill:A,fillOpacity:.06}),(0,i.jsx)(d.T,{x1:ee.rightPrice,x2:Z,fill:A,fillOpacity:.06})]}):null,(0,i.jsx)(u.G,{type:"stepAfter",dataKey:"bid",stroke:y,strokeWidth:2,fill:"url(#liquidityDepthBidFill)",connectNulls:!1,isAnimationActive:!1,baseValue:0,dot:!1,activeDot:!1}),(0,i.jsx)(u.G,{type:"stepAfter",dataKey:"ask",stroke:g,strokeWidth:2,fill:"url(#liquidityDepthAskFill)",connectNulls:!1,isAnimationActive:!1,baseValue:0,dot:!1,activeDot:!1}),(0,i.jsx)(c.e,{x:n,stroke:F.colors.cardBorder,strokeWidth:1}),ee?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c.e,{x:ee.leftPrice,stroke:A,strokeWidth:1,strokeDasharray:"2 3"}),(0,i.jsx)(c.e,{x:ee.rightPrice,stroke:A,strokeWidth:1,strokeDasharray:"2 3"})]}):null,(0,i.jsx)(p.m,{content:()=>null,cursor:!1})]})}),ee?(0,i.jsxs)(i.Fragment,{children:[et(ee.leftCardLeft,"bid",ee.leftPrice,ee.leftPoint),et(ee.rightCardLeft,"ask",ee.rightPrice,ee.rightPoint)]}):null]})]})},P=e=>e,T=(0,m.AH)(["padding-left:16px;padding-right:16px;"]),U=m.I4.div.withConfig({componentId:"sc-c5fa05c5-0"})(["display:flex;flex-direction:column;height:100%;box-sizing:border-box;padding-bottom:","px;"],88),B=m.I4.div.withConfig({componentId:"sc-c5fa05c5-1"})(["flex-shrink:0;display:grid;grid-template-columns:1fr 1fr 1fr;align-items:center;padding-top:8px;padding-bottom:8px;"," background:",";"],T,e=>{let{theme:t}=e;return t.colors.card}),D=m.I4.span.withConfig({componentId:"sc-c5fa05c5-2"})(["color:",";font-size:12px;text-align:",";"],e=>{let{theme:t}=e;return t.colors.textSubtle},e=>{let{$align:t}=e;return null!=t?t:"right"}),F=m.I4.div.withConfig({componentId:"sc-c5fa05c5-3"})(["position:relative;flex:1 1 0;min-height:0;"]),q=m.I4.div.withConfig({componentId:"sc-c5fa05c5-4"})(["height:100%;overflow-x:hidden;overflow-y:auto;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),L=m.I4.div.withConfig({componentId:"sc-c5fa05c5-5"})(["position:absolute;"," left:0;right:0;height:24px;pointer-events:none;background:",";"],e=>{let{$edge:t}=e;return`${t}: 0;`},e=>{let{theme:t,$edge:n}=e;return`linear-gradient(${"top"===n?"180deg":"0deg"}, ${t.colors.card} 0%, rgba(255,255,255,0) 100%)`}),O=m.I4.div.withConfig({componentId:"sc-c5fa05c5-6"})(["position:relative;display:grid;grid-template-columns:1fr 1fr 1fr;align-items:center;padding-top:3px;padding-bottom:3px;"," &::before{content:'';position:absolute;inset:0 auto 0 0;width:",";background:",";}"],T,e=>{let{$depth:t}=e;return`${Math.round(100*Math.max(0,Math.min(1,t)))}%`},e=>{let{$side:t,theme:n}=e;return"ask"===t?n.colors.destructive10:n.colors.positive10}),_=m.I4.span.withConfig({componentId:"sc-c5fa05c5-7"})(["position:relative;color:",";font-size:14px;font-feature-settings:'liga' off;font-variant-numeric:tabular-nums;line-height:1.5;text-align:",";white-space:nowrap;"],e=>{let{theme:t,$tone:n}=e;return"ask"===n?"#ED4B9E":"bid"===n?t.colors.positive60:t.colors.text},e=>{let{$align:t}=e;return null!=t?t:"right"}),$=m.I4.div.withConfig({componentId:"sc-c5fa05c5-8"})(["flex-shrink:0;display:flex;align-items:center;justify-content:center;gap:12px;padding-top:6px;padding-bottom:6px;"," border-top:1px solid ",";border-bottom:1px solid ",";background:",";font-size:12px;font-variant-numeric:tabular-nums;"],T,e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.cardSecondary}),Y=m.I4.span.withConfig({componentId:"sc-c5fa05c5-9"})(["color:",";"],e=>{let{theme:t}=e;return t.colors.textSubtle}),z=m.I4.span.withConfig({componentId:"sc-c5fa05c5-10"})(["color:",";font-weight:600;"],e=>{let{theme:t}=e;return t.colors.text}),V=e=>{let t=0;return e.map(e=>(t+=e.amount,{...e,sum:t}))},Z=e=>{let{asks:t,bids:n,feeTierPercent:l,dynamicFee:o=!1,t:a=P}=e,s=(0,r.useMemo)(()=>V(t).reverse(),[t]),d=(0,r.useMemo)(()=>V(n),[n]),u=(0,r.useMemo)(()=>{var e,t,n,i;return Math.max(null!=(n=null==(e=s[0])?void 0:e.sum)?n:0,null!=(i=null==(t=d[d.length-1])?void 0:t.sum)?i:0,1)},[s,d]),c=(0,r.useRef)(null);(0,r.useEffect)(()=>
29{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[t]);let p=(e,t,n)=>(0,i.jsxs)(O,{$side:t,$depth:e.sum/u,children:[(0,i.jsx)(_,{$align:"left",$tone:t,children:(0,i.jsx)(h.s,{value:e.price})}),(0,i.jsx)(_,{children:(0,f.f0)(e.amount)}),(0,i.jsx)(_,{children:(0,f.K5)(e.sum)})]},`${t}-${n}`);return(0,i.jsxs)(U,{children:[(0,i.jsxs)(B,{children:[(0,i.jsx)(D,{$align:"left",children:a("Price")}),(0,i.jsx)(D,{children:a("Amount")}),(0,i.jsx)(D,{children:a("SUM")})]}),(0,i.jsxs)(F,{children:[(0,i.jsx)(q,{ref:c,children:s.map((e,t)=>p(e,"ask",t))}),(0,i.jsx)(L,{$edge:"top"})]}),(0,i.jsxs)($,{children:[(0,i.jsxs)(Y,{children:[a("Spread")," ",(0,i.jsx)(z,{children:void 0===l?"â":(0,f.IJ)(l)})]}),(0,i.jsx)(Y,{children:o&&void 0===l?(0,i.jsx)(z,{children:a("Dynamic Fee")}):(0,i.jsxs)(i.Fragment,{children:[a("Fee Tier")," ",(0,i.jsx)(z,{children:void 0===l?"â":(0,f.Kt)(l)})]})})]}),(0,i.jsxs)(F,{children:[(0,i.jsx)(q,{children:d.map((e,t)=>p(e,"bid",t))}),(0,i.jsx)(L,{$edge:"bottom"})]})]})};var W=n(125795),H=n(361325);n(334337),n(568137)},590429:(e,t,n)=>{"use strict";n.d(t,{A:()=>d});var i=n(350979),r=n(769932),l=n(421770),o=n(428089),a=n(605641),s=n(673115);let d=()=>{let{t:e}=(0,r.A)();return(0,i.jsxs)(o.Ay,{maxWidth:"380px",children:[(0,i.jsx)(a.A,{as:"span",children:e("Overnight has temporarily paused USD+ operations on zkSync due to the recent Velocore exploit.Swap, approve, and add / remove liquidity functions are currently unavailable. More information can be found on Overnight's")}),(0,i.jsx)(l.x,{i18nKey:"Overnight has temporarily paused USD+ operations on zkSync due to the recent Velocore exploit.Swap, approve, and add / remove liquidity functions are currently unavailable. More information can be found on Overnight's <0>twitter page</0>.",components:[(0,i.jsx)(s.A,{external:!0,m:"0 4px",style:{display:"inline"},href:"https://twitter.com/overnight_fi/status/1797552748789195237"})]})]})}},605360:(e,t,n)=>{"use strict";n.d(t,{g6:()=>tl,S3:()=>ti,se:()=>tr});var i=n(350979),r=n(769932),l=n(312680),o=n(475690),a=n(995315),s=n(812297),d=n(819324),u=n(118708),c=n(25963),p=n(924627),m=n(747921),x=n(985148),h=function(e){return e.Idle="idle",e.Pending="pending",e.Success="success",e.Failed="failed",e}({});let f="sol-",v=(0,x.eU)({}),y=(0,x.eU)(!1),g=(0,x.eU)(new Set),A=(0,x.eU)(null,(e,t,n)=>{let i=e(g);i.has(n)||t(g,new Set(i).add(n))});(0,x.eU)(null,(e,t)=>{t(g,new Set)});let b=(0,x.eU)(null,(e,t,n)=>{var i,r;let l=e(v);t(v,{...l,[n.key]:{status:n.status,hash:null!=(r=n.hash)?r:null==(i=l[n.key])?void 0:i.hash,error:n.error}})}),w=(0,x.eU)(null,(e,t)=>{t(v,{}),t(g,new Set)}),j=(0,x.eU)(null,(e,t)=>{let n=e(v),i={};for(let[e,t]of Object.entries(n))e.startsWith(f)&&(i[e]=t);t(v,i)}),k=(0,x.eU)(e=>{let t=e(v),n={};for(let[e,i]of Object.entries(t))e.startsWith(f)||(n[e]=i);return n});var C=n(659197),I=n(228876),S=n(670420),R=n(796259),E=n(605641),M=n(805017),N=n(353540),P=n(428089),T=n(557423),U=n(226464),B=n(748853),D=n(181471),F=n(131619),q=n(402861),L=n(885334),O=n(450253),_=n.n(O),$=n(17581),Y=n(968349),z=n(344628),V=n(663936),Z=n(733775),W=n(273523),H=n(673384),Q=n(27313),G=n(663257),K=n(660876),X=n(633835),J=n(779623),ee=n(106736),et=n(495964),en=n(236088),ei=n(909114),er=n(256592),el=n(555967),eo=n(369067),ea=n(389512),es=n(146105),ed=n(252146),eu=n(695055),ec=n(792118),ep=n(823585),em=n(660582),ex=n(680797),eh=n(29545),ef=n(980450),ev=n(553588),ey=n(81949);let eg=(0,ex.Ay)(P.Ay).withConfig({componentId:"sc-f0bad52e-0"})(["padding:2px;background-color:",";border-radius:50%;"],e=>{let{theme:t}=e;return t.colors.secondary}),eA=(0,ex.Ay)(ef.A).withConfig({componentId:"sc-f0bad52e-1"})(["filter:grayscale(1) brightness(2);"]);function eb(e){let{status:t}=e;return t===h.Success?(0,i.jsx)(ev.A,{width:"24px",color:"positive60"}):t===h.Failed?(0,i.jsx)(ey.A,{width:"24px",color:"failure"}):t===h.Pending?(0,i.jsx)(eg,{children:(0,i.jsx)(eA,{size:16})}):null}let ew=(0,ex.Ay)(a.A).withConfig({componentId:"sc-3294056b-0"})(["border-bottom:1px solid ",";&:last-child{border-bottom:none;}"],e=>{let{theme:t}=e;return t.colors.cardBorder});function ej(e){let{currency0:t,currency1:n,tokenId:r,earningsUSD:l,rewards:o,protocol:s,status:d,children:u}=e,c=d&&d!==h.Idle;return(0,i.jsxs)(ew,{flexDirection:"column",py:"8px",width:"100%",children:[(0,i.jsxs)(a.A,{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",ga
29p:"8px",width:"100%",children:[(0,i.jsxs)(a.A,{gap:"8px",alignItems:"center",flex:"1",minWidth:"0",children:[c?(0,i.jsx)(eb,{status:d}):null,(0,i.jsx)(em.g,{currency0:t,currency1:n,size:24,innerMargin:"-4px",showChainLogoCurrency1:!0}),(0,i.jsxs)(a.A,{gap:"4px",alignItems:"center",flex:"1",minWidth:"0",flexWrap:"wrap",children:[(0,i.jsx)(E.A,{fontSize:"14px",bold:!0,ellipsis:!0,minWidth:"0",title:`${t.symbol} / ${n.symbol}`,children:`${t.symbol} / ${n.symbol}`}),r?(0,i.jsxs)(E.A,{fontSize:"14px",color:"textSubtle",style:{flexShrink:0},children:["#",String(r)]}):null,s?(0,i.jsx)(eh.RI,{$withBorder:!0,style:{padding:"0 8px"},children:(0,i.jsx)(E.A,{color:"textSubtle",fontSize:"12px",style:{display:"inline-flex",alignItems:"center",gap:"4px"},children:s===C.Zs.V3?"V3":s===C.Zs.V2?"V2":s===C.Zs.STABLE?"StableSwap":s===C.Zs.InfinityCLAMM?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{children:"Infinity"}),(0,i.jsx)("span",{style:{opacity:.5},children:"|"}),(0,i.jsx)("span",{children:"CLAMM"})]}):s===C.Zs.InfinityBIN?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{children:"Infinity"}),(0,i.jsx)("span",{style:{opacity:.5},children:"|"}),(0,i.jsx)("span",{children:"LBAMM"})]}):s===C.Zs.InfinitySTABLE?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{children:"Infinity"}),(0,i.jsx)("span",{style:{opacity:.5},children:"|"}),(0,i.jsx)("span",{children:"SS"})]}):s})}):null]})]}),(0,i.jsx)(E.A,{fontSize:"14px",bold:!0,style:{flexShrink:0},textAlign:"right",children:(0,B.l)(l,void 0,{maximumSignificantDigits:6})})]}),o.length>0?(0,i.jsx)(a.A,{justifyContent:"flex-end",flexWrap:"wrap",gap:"4px",width:"100%",children:(0,i.jsx)(E.A,{fontSize:"12px",textAlign:"right",children:o.map((e,t)=>{var n;return(0,i.jsxs)("span",{children:[t>0&&" + ",(0,ep.ZV)(e.amount,{maximumSignificantDigits:8})," ",(0,i.jsx)(E.A,{as:"span",fontSize:"12px",color:"textSubtle",children:e.currency.symbol})]},null!=(n=e.currency.symbol)?n:t)})})}):null,u]})}let ek=(0,ex.Ay)(a.A).withConfig({componentId:"sc-9dd6e7cd-0"})(["flex-direction:column;max-height:",";overflow-y:auto;padding-right:8px;"],e=>{let{$maxHeight:t}=e;return null!=t?t:"200px"}),eC=I.nU.BSC,eI=(0,c.memo)(function(e){var t;let{item:n,txMap:r}=e,{position:l,pendingCakeAmount:o,earningsUSD:a}=n,s=(0,F.G5)(l.token0,l.chainId),d=(0,F.G5)(l.token1,l.chainId),u=S.vb[l.chainId],c=`v3-${l.chainId}`;return null!==s&&null!==d&&s&&d?(0,i.jsx)(ej,{currency0:s,currency1:d,tokenId:String(l.tokenId),earningsUSD:a,rewards:u?[{currency:u,amount:o}]:[],protocol:C.Zs.V3,status:null==(t=r[c])?void 0:t.status}):null}),eS=(0,c.memo)(function(e){var t,n,r,l,o,a,s,d;let{item:u,txMap:p}=e,{position:m}=u,{chainId:x}=m,h=null!=(o=(0,F.G5)(null==(t=m.poolKey)?void 0:t.currency0,x))?o:void 0,f=null!=(a=(0,F.G5)(null==(n=m.poolKey)?void 0:n.currency1,x))?a:void 0,v=S.vb[x],{address:y}=(0,$.F)(),g=(0,c.useMemo)(()=>_()().startOf("hour").unix(),[]),A=m.protocol===C.Zs.InfinityCLAMM?m.tokenId:void 0,{data:b}=(0,q.fG)({chainId:x,poolId:m.poolId,tokenId:A,address:y,timestamp:g}),w=Number(null!=(s=null==b||null==(r=b.rewardsAmount)?void 0:r.toExact())?s:0),j=null!=(d=null==b?void 0:b.rewardsUSD)?d:0,k=`infinity-${x}`;return h&&f&&!(w<=0)?(0,i.jsx)(ej,{currency0:h,currency1:f,tokenId:m.protocol===C.Zs.InfinityCLAMM?String(m.tokenId):void 0,earningsUSD:j,rewards:v?[{currency:v,amount:w}]:[],protocol:m.protocol,status:null==(l=p[k])?void 0:l.status}):null}),eR=(0,c.memo)(function(e){var t,n,r,l,o,a;let{position:s,txMap:d,v2StableEarningsByKey:u}=e,{chainId:c}=s.pair,p=S.vb[c],m=`v2-${null==(n=s.pair)||null==(t=n.liquidityToken)?void 0:t.address}`,{earningsUSD:x,pendingCakeAmount:h}=null!=(a=u[m])?a:{earningsUSD:0,pendingCakeAmount:0};return(null==(r=s.pair)?void 0:r.token0)&&(null==(l=s.pair)?void 0:l.token1)?(0,i.jsx)(ej,{currency0:s.pair.token0,currency1:s.pair.token1,earningsUSD:x,rewards:p?[{currency:p,amount:h}]:[],protocol:C.Zs.V2,status:null==(o=d[m])?void 0:o.status}):null}),eE=(0,c.memo)(function(e){var t,n,r,l,o,a,s,d;let{position:u,txMap:c,v2StableEarningsByKey:p}=e,{chainId:m}=u.pair.liquidityToken,x=S.vb[m],h=null!=(s=null==(t=u.pair)?void 0:t.stableSwapAddress)?s:null==(r=u.pair)||null==(n=r.liquidityToken)?void 0:n.address,f=`ss-${h}`,{earningsUSD:v,pendingCakeAmount:y}=null!=(d=p[f])?d:{earningsUSD:0,pendingCakeAmount:0};return(null==(l=u.pair)?void 0:l.token0)&&(null==(o=u.pair)?void 0:o.token1)?(0,i.jsx)(ej,{currency0:u.pair.token0,currency1:u.pair.token1,earningsUSD:v,rewards:x?[{currency:x,amount:y}]:[],protocol:C.Zs.STABLE,status:null==(a=c[f])?void 0:a.status}):null});function eM(e){var t,n;let{v3HarvestPositions:l,infinityHarvestPositions:o,v2Positions:s,stablePositions:d,v3StakedTokenIds:p,v2Targets:x,v2StableEarningsByKey:f,harvestModalChainId:v,otherChainsWithRewards:g=[],otherChainsLoading:A=!1,positionsLoading:w=!1,onSwitchChain:O,focusedChainId:_,totalEarningsUsd:ep}=e,{t:em}=(0,r.A)(),{chainId:ex,account:eh}=(0,Y.W7)(),ef=ex&&(0,I.F8)(ex)?ex:eC,ev=!ex||!(0,I.F8)(ex),{switchNetwork:ey,isLoading:eg}=(0,m.Y)(),eA=(0,u.md)(k),eb=(0,u.md)(y),{harvestAll:ew,retryFailed:ej,txCount:eM,totalUnclaimedRewards:eN,infinityHasRewards:eP,infinityMerkleRootMismatch:eT,hasInfinityRewards:eU}=function(e){var t;let{v3StakedTokenIds:n,v2Targets:i,harvestModalChainId:r,totalEarningsUsd:l}=e,o=(0,Q.jE)(),{address:a,connector:s}=(0,$.F)(),{data:d}=(0,et.G)({chainId:r}),{sendTransactionAsync:p}=(0,en.s)(),{maxFeePerGas:m,maxPriorityFeePerGas:x}=(0,ei.N)(r),f=(0,er.p)(),v=null==(t=(0,el.p6)(r))?void 0:t.address,[,g]=(0,ed.r)(),{fetchWithCatchTxError:A}=(0,ea.A)(),w=(0,es.w)(r),C=(0,u.Xr)(b),S=(0,u.Xr)(y),R=(0,u.Xr)(j),[E,M]=(0,c.useState)(),{allRewards:N,totalUnclaimedRewards:P}
29=(0,q.LM)({chainId:r,user:a,timestamp:E}),T=(0,eo.B)(null!=r?r:void 0),U=(0,c.useMemo)(()=>T?null==N?void 0:N.find(e=>e.merkleRoot!==T):void 0,[N,T]);(0,c.useEffect)(()=>{!E&&T&&U&&M(Number(U.epochEndTimestamp)-1)},[T,E,U]);let B=(0,c.useMemo)(()=>null==P?void 0:P.some(e=>Number(e.totalReward)>0),[P]),D=B&&!U,F=n.length>0,L=i.length>0,O=(0,c.useMemo)(()=>"ready"===f&&r!==I.nU.BASE,[f,r]),_=(0,c.useMemo)(()=>{if(!r)return 0;if(O)return 1;let e=0;return D&&(e+=1),F&&(e+=1),e+=i.length},[r,O,D,F,i.length]),Y=(0,c.useCallback)(()=>{if(!a||!N||!r||!B)return null;let e=N.map(e=>{let{totalRewardAmount:t,rewardTokenAddress:n,proofs:i}=e;return{proof:i,amount:BigInt(t),token:n}}),t=(0,W.Rc)(e);return{to:W.BI[r],data:t,value:0n}},[a,N,r,B]),z=(0,c.useCallback)(()=>{if(!a||!v||!F)return null;let{calldata:e,value:t}=H.SG.batchHarvestCallParameters(n.map(e=>({tokenId:e,to:a})));return{to:v,data:e,value:(0,G.uU)(t)}},[a,v,F,n]),V=(0,c.useCallback)(async()=>{await Promise.all([o.invalidateQueries({queryKey:["poolFarmRewards"]}),o.invalidateQueries({queryKey:["userAllFarmRewards"]}),o.invalidateQueries({queryKey:["userAllClaimedRewards"]}),o.invalidateQueries({queryKey:["mcv3-harvest"]}),o.invalidateQueries({queryKey:["harvestModalV2StablePendingCake"]})])},[o]),ep=(0,c.useCallback)(()=>i.map(e=>({to:e.bCakeWrapperAddress,data:(0,K.p)({abi:[{name:"deposit",type:"function",stateMutability:"nonpayable",inputs:[{name:"_amount",type:"uint256"},{name:"_lock",type:"bool"}],outputs:[]}],functionName:"deposit",args:[0n,!1]}),value:0n})),[i]),em=(0,c.useCallback)(async()=>{if(!d||!s||!r||!a)return;let e=[],t=[];if(D){let n=Y();n&&(e.push(n),t.push(`infinity-${r}`))}let n=z();if(n&&(e.push(n),t.push(`v3-${r}`)),ep().forEach((n,r)=>{e.push(n),t.push(i[r].key)}),0!==e.length){t.forEach(e=>C({key:e,status:h.Pending}));try{var o,u;let n=await s.getProvider(),i=(0,X.F)({transport:(0,J.I)(n),account:d.account,chain:d.chain}).extend((0,ee.p)()),r=await i.sendCalls({calls:e,forceAtomic:!0});if(!r.id)return void t.forEach(e=>C({key:e,status:h.Failed,error:"No transaction ID returned"}));let{promise:a}=(0,eu.L5)(async()=>{let e=await i.getCallsStatus({id:r.id});if("failure"===e.status)throw Error("Transaction failed");if("success"!==e.status)throw new eu.dw;return e},{n:20,minWait:2e3,maxWait:4e3}),c=await a,p=null==(u=c.receipts)||null==(o=u[0])?void 0:o.transactionHash;"success"===c.status&&(t.forEach(e=>C({key:e,status:h.Success,hash:p})),p&&(g({blockHash:p,status:"success"}),w(p,l)),await V())}catch(e){t.forEach(t=>{var n;return C({key:t,status:h.Failed,error:null!=(n=null==e?void 0:e.message)?n:"Unknown error"})})}}},[d,s,r,a,D,Y,z,ep,i,C,g,V,w,l]),ex=(0,c.useCallback)(async e=>{if(!a||!r)return null;let t=(0,ec.Rt)({chainId:r}),n=await A(()=>t.estimateGas({account:a,...e}).then(t=>p({...e,account:a,chainId:r,gas:(0,Z.KL)(t),maxFeePerGas:m,maxPriorityFeePerGas:x})));return(null==n?void 0:n.status)&&w(n.transactionHash),n},[a,r,A,p,m,x,w]),eh=(0,c.useCallback)(async()=>{if(!a||!r)return;let e=!1;if(D){let t=`infinity-${r}`;C({key:t,status:h.Pending});try{let n=Y();if(n){let i=await ex(n);(null==i?void 0:i.status)?(C({key:t,status:h.Success,hash:i.transactionHash}),g({blockHash:i.blockHash,status:i.status}),e=!0):C({key:t,status:h.Failed})}}catch(e){C({key:t,status:h.Failed,error:null==e?void 0:e.message})}}if(F&&v){let t=`v3-${r}`;C({key:t,status:h.Pending});try{let n=z();if(n){let i=await ex(n);(null==i?void 0:i.status)?(C({key:t,status:h.Success,hash:i.transactionHash}),g({blockHash:i.blockHash,status:i.status}),e=!0):C({key:t,status:h.Failed})}}catch(e){C({key:t,status:h.Failed,error:null==e?void 0:e.message})}}let t=ep();for(let n=0;n<i.length;n++){let r=i[n],l=t[n];C({key:r.key,status:h.Pending});try{let t=await ex(l);(null==t?void 0:t.status)?(C({key:r.key,status:h.Success,hash:t.transactionHash}),g({blockHash:t.blockHash,status:t.status}),e=!0):C({key:r.key,status:h.Failed})}catch(e){C({key:r.key,status:h.Failed,error:null==e?void 0:e.message})}}e&&await V()},[a,r,D,F,v,i,Y,z,ep,ex,C,g,V]),ef=(0,c.useCallback)(async()=>{if(r){R(),S(!0);try{O?await em():await eh()}finally{S(!1)}}},[r,O,em,eh,S,R]),ev=(0,u.md)(k),ey=(0,c.useCallback)(async()=>
29{if(r&&a){S(!0);try{var e,t,n;let l=!1;if(D){let t=`infinity-${r}`;if((null==(e=ev[t])?void 0:e.status)===h.Failed){C({key:t,status:h.Pending});try{let e=Y();if(e){let n=await ex(e);(null==n?void 0:n.status)?(C({key:t,status:h.Success,hash:n.transactionHash}),g({blockHash:n.blockHash,status:n.status}),l=!0):C({key:t,status:h.Failed})}}catch(e){C({key:t,status:h.Failed,error:null==e?void 0:e.message})}}}if(F&&v){let e=`v3-${r}`;if((null==(t=ev[e])?void 0:t.status)===h.Failed){C({key:e,status:h.Pending});try{let t=z();if(t){let n=await ex(t);(null==n?void 0:n.status)?(C({key:e,status:h.Success,hash:n.transactionHash}),g({blockHash:n.blockHash,status:n.status}),l=!0):C({key:e,status:h.Failed})}}catch(t){C({key:e,status:h.Failed,error:null==t?void 0:t.message})}}}let o=ep();for(let e=0;e<i.length;e++){let t=i[e],r=o[e];if((null==(n=ev[t.key])?void 0:n.status)===h.Failed){C({key:t.key,status:h.Pending});try{let e=await ex(r);(null==e?void 0:e.status)?(C({key:t.key,status:h.Success,hash:e.transactionHash}),g({blockHash:e.blockHash,status:e.status}),l=!0):C({key:t.key,status:h.Failed})}catch(e){C({key:t.key,status:h.Failed,error:null==e?void 0:e.message})}}}l&&await V()}finally{S(!1)}}},[r,a,ev,D,F,v,i,Y,z,ep,ex,C,S,g,V]);return{harvestAll:ef,retryFailed:ey,txCount:_,hasInfinityRewards:B,infinityHasRewards:!!(null==N?void 0:N.length),infinityMerkleRootMismatch:!!U,hasV3Rewards:F,hasV2Rewards:L,isEip5792Ready:O,totalUnclaimedRewards:P}}({v3StakedTokenIds:p,v2Targets:(0,c.useMemo)(()=>x.filter(e=>{var t,n;return(null!=(n=null==(t=f[e.key])?void 0:t.pendingCakeAmount)?n:0)>0}),[x,f]),harvestModalChainId:v,totalEarningsUsd:ep}),eB=eP&&eU&&!eT,eD=(0,c.useMemo)(()=>Object.keys(eA).length>0,[eA]),eF=(0,c.useMemo)(()=>eD&&Object.values(eA).every(e=>e.status===h.Success),[eA,eD]),eq=(0,c.useMemo)(()=>Object.values(eA).filter(e=>e.status===h.Failed).length,[eA]),eL=!ev&&void 0!==_&&ef!==_,eO=null!=_?_:ef,e_=null!=(n=I.Qk[eO])?n:"",e$=!!(e_&&eh),eY=(0,L.T)(),ez=(0,c.useMemo)(()=>eB&&(null==eN?void 0:eN.length)&&eY.gt(0)?eN.reduce((e,t)=>e+Number(t.totalReward),0)*Number(eY.toString()):0,[eB,eN,eY]),eV=(0,c.useMemo)(()=>{let e=new Set;for(let{position:t}of l)t.token0&&e.add(t.token0),t.token1&&e.add(t.token1);return[...e]},[l]),eZ=null==(t=l[0])?void 0:t.position.chainId,eW=(0,F.Lr)(eV,eZ),eH=(0,c.useMemo)(()=>{var e,t,n,i,r,o,a,u,c,p,m,x,h,v;let y=(e,t)=>{let n=(0,Z.QR)(t);if(!n)return;let i=eW[n];return null===i?null:i||(0,S.vy)(e.chainId,t)},g=l.reduce((e,t)=>{let{position:n}=t,i=y(n,n.token0),r=y(n,n.token1);return null!==i&&null!==r&&i&&r?e+t.earningsUSD:e},0),A=0;for(let l of s)(null==(e=l.pair)?void 0:e.token0)&&(null==(t=l.pair)?void 0:t.token1)&&(A+=null!=(o=null==(r=f[`v2-${null==(i=l.pair)||null==(n=i.liquidityToken)?void 0:n.address}`])?void 0:r.earningsUSD)?o:0);for(let e of d){if(!(null==(a=e.pair)?void 0:a.token0)||!(null==(u=e.pair)?void 0:u.token1))continue;let t=null!=(h=null==(c=e.pair)?void 0:c.stableSwapAddress)?h:null==(m=e.pair)||null==(p=m.liquidityToken)?void 0:p.address;A+=null!=(v=null==(x=f[`ss-${t}`])?void 0:x.earningsUSD)?v:0}return ez+g+A},[ez,l,eW,s,d,f]),eQ=(0,c.useMemo)(()=>[...eB?o.map(e=>({type:"infinity",item:e})):[],...l.map(e=>({type:"v3",item:e})),...s.filter(e=>{var t,n,i,r;return(null!=(r=null==(i=f[`v2-${null==(n=e.pair)||null==(t=n.liquidityToken)?void 0:t.address}`])?void 0:i.pendingCakeAmount)?r:0)>0}).map(e=>({type:"v2",pos:e})),...d.filter(e=>{var t,n,i,r,l,o;let a=null!=(l=null==(t=e.pair)?void 0:t.stableSwapAddress)?l:null==(i=e.pair)||null==(n=i.liquidityToken)?void 0:n.address;return(null!=(o=null==(r=f[`ss-${a}`])?void 0:r.pendingCakeAmount)?o:0)>0}).map(e=>({type:"stable",pos:e}))],[eB,o,l,s,d,f]),eG=0===eQ.length,eK=eQ.length>0;return(0,i.jsxs)("div",{style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsxs)(a.A,{justifyContent:"space-between",alignItems:"center",mb:"12px",children:[(0,i.jsxs)(R.y,{color:"secondary",children:[em("EVM POSITIONS"),e$?` (${e_.toUpperCase()})`:""]}),(0,i.jsx)(E.A,{bold:!0,fontSize:"16px",children:(0,B.l)(eH)})]}),eG&&!w?(0,i.jsx)(E.A,{color:"textSubtle",textAlign:"center",py:"16px",fontSize:"14px",children:em("No farm rewards to harvest on this chain")}):(0,i.jsxs)(i.Fragment,{children:[eK&&(0,i.jsx)(ek,{children:eQ.map(e=>{var t,n,r,l,o,a;if("infinity"===e.type){let{position:t}=e.item,n=t.protocol===C.Zs.InfinityCLAMM?`infinity-${t.chainId}-${t.poolId}-${t.tokenId}`:`infinity-${t.chainId}-${t.poolId}`;return(0,i.jsx)(eS,{item:e.item,txMap:eA},n)}return"v3"===e.type?(0,i.jsx)(eI,{item:e.item,txMap:eA},`v3-${e.item.position.chainId}-${e.item.position.tokenId}`):"v2"===e.type?(0,i.jsx)(eR,{position:e.pos,txMap:eA,v2StableEarningsByKey:f},`v2-${null==(o=e.pos.pair)||null==(l=o.liquidityToken)?void 0:l.address}`):(0,i.jsx)(eE,{position:e.pos,txMap:eA,v2StableEarningsByKey:f},`ss-${null!=(a=null==(t=e.pos.pair)?void 0:t.stableSwapAddress)?a:null==(r=e.pos.pair)||null==(n=r.liquidityToken)?void 0:n.address}`)})}),w&&(0,i.jsxs)(a.A,{alignItems:"center",gap:"12px",justifyContent:"center",py:eK?"12px":"32px",children:[(0,i.jsx)(M.m,{size:"20px"}),(0,i.jsx)(E.A,{color:"textSubtle",fontSize:"14px",children:(0,i.jsx)(N.n,{children:em("Loading positions")})})]}),!w&&!eD&&!ev&&!eL&&eM>1&&(0,i.jsx)(P.Ay,{mt:"8px",children:(0,i.jsx)(D.V,{primaryMsg:em("You will need to confirm %count% transactions in your wallet",{count:eM})})}),ev?(0,i.jsx)(T.A,{mt:"12px",width:"100%",variant:"primary60Outline",disabled:eg,onClick:()=>ey(eC),children:em("Switch to %network%",{network:(0,V.I)(eC)})}):eL?(0,i.jsx)(T.A,{mt:"12px",width:"100%",variant:"primary60Outline",disabled:eg,onClick:()=>null==O?void 0:O(_),children:em("Switch to %network%",{network:(0,V.I)(_)})}):(0,i.jsxs)(i.Fragment,{children:[!eD&&(0,i.jsx)(T.A,{mt:"12px",width:"100%",variant:"primary60Outline",disabled:eb||eG||w,onClick:ew,children:em("Harvest all")}),eb&&!eF&&(0,i.jsx)(T.A,{mt:"12px",width:"100%",variant:"primary60Outline",disabled:!0,children:em("Harvesting")}),eF&&(0,i.jsx)(T.A,{mt:"12px",width:"100%",variant:"primary60Outline",disabled:!0,children:em("Harvested")})]}),eq>0&&!eb&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(T.A,{mt:"12px",width:"100%",variant:"primary60Outline",onClick:ej,children:em("Retry")}),(0,i.jsx)(U.A,{variant:"warning60",mt:"12px",children:(0,i.jsx)(U.J,{children:1===eq?em("An error occurred during the harvest, please try again"):em("%count% harvests failed, please try again",{count:eq})})})]})]}),!A&&g.length>0&&(0,i.jsx)(U.A,{variant:"primary",mt:"12px",children:(0,i.jsxs)(U.J,{children:[em("You also have earnings on ")," ",g.map((e,t)=>{var n;return(0,i.jsxs)(z._,{as:"span",fontSize:"14px",bold:!0,color:"primary60",style:{cursor:"pointer"},onClick:()=>null==O?void 0:O(e),children:[null==(n=I.Qk[e])?void 0:n.toUpperCase(),t<g.length-1?", ":""]},e)}),". ",em("Switch network to harvest.")]})})]})}var eN=n(770779),eP=n(440589);function eT(e){let{positions:t,totalEarningsUSD:n,harvestTargets:l,initialLoading:o=!1,refreshing:s=!1}=e,{t:d}=(0,r.A)(),u=(0,c.useMemo)(()=>new Map(l.map(e=>[e.key,e])),[l]),p=0===t.length;return o?(0,i.jsxs)("div",{style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsxs)(a.A,{justifyContent:"space-between",alignItems:"center",mb:"12px",children:[(0,i.jsxs)(R.y,{color:"secondary",children:[d("SOLANA POSITIONS"),s?(0,i.jsx)("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:6},children:(0,i.jsx)(M.m,{size:"12px"})}):null]}),(0,i.jsx)(E.A,{bold:!0,fontSize:"16px",color:"textDisabled",children:"â"})]}),(0,i.jsxs)(a.A,{alignItems:"center",gap:"12px",justifyContent:"center",py:"24px",children:[(0,i.jsx)(M.m,{size:"20px"}),(0,i.jsx)(E.A,{color:"textSubtle",fontSize:"14px",children:(0,i.jsx)(N.n,{children:d("Loading positions")})})]})]}):(0,i.jsxs)("div",{style:{fontVariantNumeric:"tabular-nums"},children:[(0,i.jsxs)(a.A,{justifyContent:"space-between",alignItems:"center",mb:"12px",children:[(0,i.jsx)(R.y,{color:"secondary",children:(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center"},children:[(0,i.jsxs)("span",{children:[d("SOLANA POSITIONS"),p?"":` (${t.length})`]}),s?(0,i.jsx)("span",{style:{display:"inline-flex",alignItems:"center",marginLeft:6},children:(0,i.jsx)(M.m,{size:"12px"})}):null]})}),(0,i.jsx)(E.A,{bold:!0,fontSize:"16px",children:(0,B.l)(n)})]}),p?(0,i.jsx)(E.A,{color:"textSubtle",textAlign:"center",py:"16px",fontSize:"14px",children:d("No farm rewards to harvest")}):(0,i.jsx)(ek,{$maxHeight:"400px",children:t.map(e=>(0,i.jsx)(eU,{position:e,target:u.get(e.key)},e.key))})]})}function eU(e){let{position:t,target:n}=e,{t:l}=(0,r.A)(),o=(0,u.md)(v),{harvest:a}=function(e){let t=(0,eN.f)(),n=(0,u.Xr)(b),i=(0,u.Xr)(A),r=(0,Q.jE)();return{harvest:(0,c.useCallback)(async()=>
29{if(!e)return;let{key:l,poolInfo:o,position:a,feeAmountA:s,feeAmountB:d}=e;n({key:l,status:h.Pending});let u={current:!1};try{await t({params:{poolInfo:o,position:a,rewardAmountA:s,rewardAmountB:d},onSent:e=>n({key:l,status:h.Pending,hash:e}),onError:e=>{var t;u.current=!0,n({key:l,status:h.Failed,error:null!=(t=null==e?void 0:e.message)?t:"Harvest failed"})}}),u.current||(n({key:l,status:h.Success}),i(l),Promise.all([r.invalidateQueries({queryKey:["solana-v3-positions"],exact:!1}),r.invalidateQueries({queryKey:["solana-harvest-modal-reward"],exact:!1}),r.invalidateQueries({queryKey:[eP.dy],exact:!1})]).catch(()=>void 0))}catch(e){u.current||n({key:l,status:h.Failed,error:e instanceof Error?e.message:"Harvest failed"})}},[e,t,n,i,r])}}(n),s=o[t.key],d=null==s?void 0:s.status,p=d===h.Pending,m=d===h.Success,x=d===h.Failed;return(0,i.jsxs)(ej,{currency0:t.currency0,currency1:t.currency1,tokenId:t.tokenId,earningsUSD:t.earningsUSD,rewards:t.rewards,status:d,children:[!d&&(0,i.jsx)(T.A,{width:"100%",scale:"sm",variant:"primary60Outline",onClick:a,children:l("Harvest")}),p&&(0,i.jsx)(T.A,{width:"100%",scale:"sm",variant:"primary60Outline",disabled:!0,children:(0,i.jsx)(N.n,{children:l("Harvesting")})}),m&&(0,i.jsx)(T.A,{width:"100%",scale:"sm",variant:"primary60Outline",disabled:!0,children:l("Harvested")}),x&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(T.A,{width:"100%",scale:"sm",variant:"primary60Outline",onClick:a,children:l("Retry")}),(0,i.jsx)(U.A,{variant:"warning",mt:"4px",children:(0,i.jsx)(U.J,{fontSize:"12px",children:t.tokenId?l("An error occurred during the harvest of pool #%id%, please try again",{id:t.tokenId}):l("An error occurred during the harvest, please try again")})})]})]})}var eB=n(135606),eD=n(91168),eF=n(662928),eq=n(302075),eL=n(710900),eO=n(529208),e_=n(668458),e$=n(378385),eY=n(342746),ez=n(314807),eV=n(275076),eZ=n(405213),eW=n(174722),eH=n.n(eW),eQ=n(623208),eG=n(290589),eK=n(72912),eX=n(638380),eJ=n(142511),e0=n(379324),e1=n(619749),e2=n(11080),e6=n(903878);let e8=eO.IX,e3={accountKey:null,chains:{}},e9=(0,x.eU)(e3);function e4(e){let t={};for(let n of e)t[n.chainId]||(t[n.chainId]=[]),t[n.chainId].push(n);return t}function e5(e,t){let n=e.chains[t];if(!(!n||Date.now()>n.expiresAt))return n}function e7(e,t,n,i,r,l){if(!i||!e||!n)return null!=r?r:[];let o=e.toLowerCase();if(t.accountKey!==o)return null!=r?r:[];let a=e5(t,n),s=null==a?void 0:a[l];return void 0!==s?s:null!=r?r:[]}function te(e,t,n,i,r,l){if(!i||!e)return null!=r?r:[];let o=e.toLowerCase();if(t.accountKey!==o)return null!=r?r:[];let a=null!=r?r:[],s=a.length?e4(a):void 0,d=Date.now();return n.flatMap(e=>{let n=null==s?void 0:s[e];if(null==n?void 0:n.length)return n;let i=t.chains[e];if(!i||d>i.expiresAt)return[];let r=i[l];return null!=r?r:[]})}let tt=["infinityCL","infinityBin","v3","v2","stable","infinityStable"];var tn=n(501823);(0,ex.Ay)(tn.A).withConfig({componentId:"sc-42de3452-0"})(["background:",";border:1px solid ",";border-radius:24px;padding:8px 16px;align-items:center;justify-content:space-between;width:100%;"],e=>{let{theme:t}=e;return t.card.background},e=>{let{theme:t}=e;return t.colors.cardBorder});let ti=(0,c.createContext)(null);function tr(){return(0,c.useContext)(ti)}function tl(e){let{isOpen:t,onDismiss:n,defaultTab:x="evm",focusedChainId:h}=e,{t:f}=(0,r.A)(),v=(0,u.Xr)(w),{publicKey:y}=(0,p.v)(),{switchNetwork:A}=(0,m.Y)(),b=!!y,[j,k]=(0,c.useState)(x),[R,E]=(0,c.useState)(h),{v3HarvestPositions:M,infinityHarvestPositions:N,v2Positions:P,stablePositions:T,v3StakedTokenIds:U,v2Targets:B,v2StableEarningsByKey:D,otherChainsWithRewards:F,evmTotalEarningsUSD:O,solanaPositions:z,solanaTotalEarningsUSD:V,solanaHarvestTargets:Z,solanaInitialLoading:W,solanaRefreshing:H,isCurrentChainEvmLoading:Q,isOtherChainsEvmLoading:G,effectiveEvmChainId:K}=function(e){let{chainId:t}=(0,Y.ax)(),{address:n}=(0,$.F)(),i=(0,L.T)(),r=(0,eV.Wp)(),l=(0,u.md)(e9),o=(0,u.Xr)(e9),a=null!=e?e:null==t||(0,I.fT)(t)?eC:t,s=(0,c.useMemo)(()=>[a],[a]),d=(0,c.useMemo)(()=>r.filter(e=>e!==a),[r,a]),{data:m,pending:x}=(0,eL.qQ)(s,n),{data:h,pending:f}=(0,eL.Ib)(n,s),{data:v,pending:y}=(0,eL.MP)(s,n),{data:A,pending:b}=(0,eL.dL)(s,n),{data:w,pending:j}=(0,eL.EU)(s,n),{data:k,pending:R}=((e,t)=>
29{let[n]=(0,ed.r)(),{data:i,isPending:r}=(0,eF.I)({queryKey:["accountInfinityStablePositions",t,e.join(","),null==n?void 0:n.blockHash],queryFn:async()=>t?(await Promise.all(e.map(async e=>{try{return(await (0,e_.sb)(e,t)).filter(e=>e.nativeBalance.greaterThan("0")||e.farmingBalance.greaterThan("0"))}catch(t){return console.error(`Error fetching Infinity Stable positions for chainId ${e}:`,t),[]}}))).flat():[],enabled:!!t,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:eO.IX,staleTime:eO.IX});return(0,c.useMemo)(()=>t?i?{data:i,pending:r}:{data:[],pending:r}:{data:[],pending:!1},[i,r,t])})(s,n),{data:E,pending:M}=(0,eL.qQ)(d,n),{data:N,pending:P}=(0,eL.Ib)(n,d),{data:T,pending:U}=(0,eL.MP)(d,n);(0,c.useEffect)(()=>{o(e=>(function(e,t){var n,i,r,l,o,a,s,d,u,c,p,m;if(!t.account)return null===e.accountKey&&0===Object.keys(e.chains).length?e:e3;let x=t.account.toLowerCase(),h=e.accountKey!==x,f=h?{}:e.chains,v=h,y=Date.now()+e8,g=(t,n)=>{var i;if(0===Object.keys(n).length)return;h||f!==e.chains||(f={...e.chains});let r=null!=(i=f[t])?i:{expiresAt:y};f[t]={...r,...n,expiresAt:y},v=!0},{chainId:A,current:b,otherChainIds:w,other:j}=t;if(void 0!==A&&!(0,I.fT)(A)){let e={};b.p1c||(e.infinityCL=null!=(n=b.infinityCL)?n:[]),b.p2c||(e.infinityBin=null!=(i=b.infinityBin)?i:[]),b.p3c||(e.v3=null!=(r=b.v3)?r:[]),b.p4c||(e.v2=null!=(l=b.v2)?l:[]),b.p5c||(e.stable=null!=(o=b.stable)?o:[]),b.p6c||(e.infinityStable=null!=(a=b.infinityStable)?a:[]),g(A,e)}if(w.length>0&&(!j.p1o||!j.p2o||!j.p3o)){let e={};for(let t of w)e[t]={};if(!j.p1o){let t=e4(null!=(s=j.infinityCL)?s:[]);for(let n of w)e[n].infinityCL=null!=(d=t[n])?d:[]}if(!j.p2o){let t=e4(null!=(u=j.infinityBin)?u:[]);for(let n of w)e[n].infinityBin=null!=(c=t[n])?c:[]}if(!j.p3o){let t=e4(null!=(p=j.v3)?p:[]);for(let n of w)e[n].v3=null!=(m=t[n])?m:[]}for(let t of w){let n=e[t];Object.keys(n).length>0&&g(t,n)}}return v?{accountKey:x,chains:f}:e})(e,{account:n,chainId:a,current:{p1c:x,p2c:f,p3c:y,p4c:b,p5c:j,p6c:R,infinityCL:m,infinityBin:h,v3:v,v2:A,stable:w,infinityStable:k},otherChainIds:d,other:{p1o:M,p2o:P,p3o:U,infinityCL:E,infinityBin:N,v3:T}}))},[n,a,x,f,y,b,j,R,m,h,v,A,w,k,M,P,U,E,N,T,d,o]);let{infinityCL:B,infinityBin:D,v3:F,v2:O,stable:z,infinityStable:V}=(0,c.useMemo)(()=>({infinityCL:e7(n,l,a,x,m,"infinityCL"),infinityBin:e7(n,l,a,f,h,"infinityBin"),v3:e7(n,l,a,y,v,"v3"),v2:e7(n,l,a,b,A,"v2"),stable:e7(n,l,a,j,w,"stable"),infinityStable:e7(n,l,a,R,k,"infinityStable")}),[n,l,a,x,f,y,b,j,R,m,h,v,A,w,k]),{v3:Z,infinityCL:W,infinityBin:H}=(0,c.useMemo)(()=>({v3:te(n,l,d,U,T,"v3"),infinityCL:te(n,l,d,M,E,"infinityCL"),infinityBin:te(n,l,d,P,N,"infinityBin")}),[n,l,d,M,P,U,E,N,T]),Q=(0,c.useMemo)(()=>{var e;return[(e={p1c:x,p2c:f,p3c:y,p4c:b,p5c:j,p6c:R}).p1c,e.p2c,e.p3c,e.p4c,e.p5c,e.p6c].some((e,t)=>e&&!function(e,t,n,i){if(!e||void 0===n||t.accountKey!==e.toLowerCase())return!1;let r=e5(t,n);return(null==r?void 0:r[i])!==void 0}(n,l,a,tt[t]))},[n,l,a,x,f,y,b,j,R]),G=(M||P||U)&&!function(e,t,n){if(!e)return!1;let i=e.toLowerCase();if(t.accountKey!==i)return!1;let r=Date.now();for(let e of n){let n=t.chains[e];if(!n||r>n.expiresAt||void 0===n.v3||void 0===n.infinityCL||void 0===n.infinityBin)return!1}return!0}(n,l,d),{data:K}=(0,eF.I)({queryKey:["fetchAllUniversalFarmsMap"],queryFn:eB.fetchAllUniversalFarmsMap,staleTime:6e4}),X=(0,c.useMemo)(()=>[...B,...D].filter(e=>e.chainId===a),[B,D,a]),J=(0,c.useMemo)(()=>_()().startOf("hour").unix(),[]),{data:ee}=(0,q._L)({chainId:a,address:n,timestamp:J}),et=(0,c.useMemo)(()=>{if(!ee)return{};let e={};for(let n of ee){var t;let{poolId:i,tokenIds:r,rewardAmounts:l,rewardTokenAddress:o}=n,s=(0,S.vy)(a,o),d=null!=(t=null==s?void 0:s.decimals)?t:18;e[i]||(e[i]={}),r.forEach((t,n)=>{var r;let o=(0,eD.g)(l[n]).div((0,eD.g)(10).pow(d)).toNumber();e[i][t]=(null!=(r=e[i][t])?r:0)+o})}return e},[ee,a]),en=(0,c.useMemo)(()=>X.map(e=>{let t=0,n=et[e.poolId];if(n)if(e.protocol===C.Zs.InfinityCLAMM){var r;t=null!=(r=n[e.tokenId.toString()])?r:0}else t=Object.values(n).reduce((e,t)=>e+t,0);return{position:e,earningsUSD:t>0&&i.gt(0)?(0,eD.g)(t).times(i.toString()).toNumber():0,cakeAmount:t}}).filter(e=>e.cakeAmount>0),[X,et,i]),ei=(0,c.useMemo)(()=>F.filter(e=>!(0,I.fT)(e.chainId)&&e.chainId===a&&!!e.isStaked&&void 0!==e.tokenId),[F,a]),er=(0,c.useMemo)(()=>ei.map(e=>BigInt(e.tokenId.toString())),[ei]),{tokenIdResults:el,isLoading:eo}=(0,eq.Cu)(er,a),ea=(0,c.useMemo)(()=>ei.map((e,t)=>{var n;let r=null!=(n=null==el?void 0:el[t])?n:0n,l=+(0,e$.x4)(r,18),o=(0,eD.g)(l).times(i.toString()).toNumber();return{position:e,pendingCakeAmount:l,earningsUSD:o}}).filter(e=>e.pendingCakeAmount>0),[ei,el,i]),es=(0,c.useMemo)(()=>ea.map(e=>e.position.tokenId.toString()),[ea]),eu=(0,c.useMemo)(()=>O.filter(e=>e.pair.chainId===a&&!!e.isStaked&&e.farmingBalance.greaterThan(0)),[O,a]),ec=(0,c.useMemo)(()=>[...z,...V].filter(e=>e.pair.liquidityToken.chainId===a&&!!e.isStaked&&e.farmingBalance.greaterThan(0)),[z,V,a]
29),ep=(0,c.useMemo)(()=>{var e,t,n,i,r,l;if(!K)return[];let o=[],s=(e,t)=>{let n=K[`${t.toLowerCase()}-${a}`];(null==n?void 0:n.bCakeWrapperAddress)&&o.push({key:e,lpAddress:t,bCakeWrapperAddress:n.bCakeWrapperAddress})};for(let n of eu){let i=null==(t=n.pair)||null==(e=t.liquidityToken)?void 0:e.address;i&&s(`v2-${i}`,i)}for(let e of ec){let t=null!=(l=null==(n=e.pair)?void 0:n.stableSwapAddress)?l:null==(r=e.pair)||null==(i=r.liquidityToken)?void 0:i.address;t&&s(`ss-${t}`,t)}return o},[eu,ec,K,a]),em=(0,c.useMemo)(()=>ep.map(e=>({chainId:a,lpAddress:e.lpAddress,bCakeWrapperAddress:e.bCakeWrapperAddress})),[a,ep]),ex=(0,c.useMemo)(()=>ep.map(e=>`${e.bCakeWrapperAddress}`).join(","),[ep]),{data:eh,isPending:ef}=(0,eF.I)({queryKey:["harvestModalV2StablePendingCake",a,n,ex],queryFn:()=>(0,eY.T)(a,n,em),enabled:!!(n&&em.length>0)}),ev=(0,c.useMemo)(()=>{let e={};return(null==eh?void 0:eh.length)&&i.gt(0)&&ep.forEach((t,n)=>{let r=eh[n];if(!r)return;let l=BigInt(r);if(0n===l)return;let o=+(0,e$.x4)(l,18),a=(0,eD.g)(o).times(i.toString()).toNumber();e[t.key]={earningsUSD:a,pendingCakeAmount:o}}),e},[ep,eh,i]),ey=Q||eo||ep.length>0&&ef,eg=(0,c.useMemo)(()=>{let e=new Set;for(let t of[...W,...H])(0,I.fT)(t.chainId)||e.add(t.chainId);return[...e]},[W,H]),eA=eg.join(","),{data:eb}=(0,eF.I)({queryKey:["otherChainsInfinityHasRewards",eA,n],queryFn:async e=>{let{signal:t}=e;if(!n||0===eg.length)return{};let i=Math.floor(Date.now()/1e3).toString();return Object.fromEntries((await Promise.all(eg.map(async e=>{try{var r,l;let o=null!=(l=null==(r=(await ez.x.GET("/farms/users/{chainId}/{address}/{timestamp}",{baseUrl:e===I.nU.BSC_TESTNET?"https://test.v4.pancakeswap.com/":"https://infinity.pancakeswap.com/",params:{path:{chainId:e,address:n,timestamp:i}},signal:t})).data)?void 0:r.rewards)?l:[];return{cId:e,hasRewards:o.some(e=>BigInt(e.totalRewardAmount)>0n)}}catch{return{cId:e,hasRewards:!1}}}))).map(e=>{let{cId:t,hasRewards:n}=e;return[t,n]}))},enabled:!!n&&eg.length>0,staleTime:6e4}),ew=(0,c.useMemo)(()=>{let e=new Set;for(let t of Z)!(0,I.fT)(t.chainId)&&t.isStaked&&e.add(t.chainId);for(let t of[...W,...H])!(0,I.fT)(t.chainId)&&(null==eb?void 0:eb[t.chainId])&&e.add(t.chainId);return Array.from(e)},[Z,W,H,eb]),ej=(0,c.useMemo)(()=>en.reduce((e,t)=>e+t.earningsUSD,0)+ea.reduce((e,t)=>e+t.earningsUSD,0)+Object.values(ev).reduce((e,t)=>e+t.earningsUSD,0),[en,ea,ev]),{solanaPositions:ek,solanaTotalEarningsUSD:eI,solanaHarvestTargets:eS,solanaInitialLoading:eR,solanaRefreshing:eE}=function(){let{publicKey:e}=(0,p.v)(),t=(0,c.useMemo)(()=>null==e?void 0:e.toBase58(),[e]),n=(0,eJ.zl)(),i=(0,eX.W)(),[r]=(0,ed.r)(),l=(0,u.md)(g),{data:o,isLoading:a,isFetching:s}=(0,eP.o$)(t),d=(0,c.useMemo)(()=>(null==o?void 0:o.map(e=>e.poolId.toBase58()))||[],[o]),m=(0,eQ._L)(d),{loading:x}=(0,eG.t)((0,c.useMemo)(()=>m.filter(e=>!!e),[m])),h=(0,c.useMemo)(()=>new Map(m.filter(e=>!!e).map(e=>[e.id,e])),[m]),f=(0,c.useMemo)(()=>o?o.map(e=>{var t;let n=h.get(e.poolId.toBase58());if(!n||e.liquidity.isZero())return null;let i=(0,e1.ph)(n.mintA),r=(0,e1.ph)(n.mintB);if(!i||!r)return null;let l={...e,status:(0,e2.P)(e,n),protocol:C.Zs.V3,chainId:I.Cb.SOLANA,token0:i,token1:r},o={pid:0,nftMint:e.nftMint,lpAddress:void 0,protocol:C.Zs.V3,token0:i,token1:r,feeTier:Math.round(n.feeRate*e6.J),feeTierBase:e6.J,isFarming:null!=(t=n.isFarming)&&t,poolId:e.poolId.toBase58(),liquidity:BigInt(e.liquidity.toString()),chainId:I.Cb.SOLANA,tvlUsd:n.tvl.toString(),rawPool:n};return{key:`sol-${e.nftMint.toBase58()}`,position:l,pool:n,poolInfo:o}}).filter(e=>null!==e):[],[o,h]),v=(0,c.useMemo)(()=>{let e=[];for(let{pool:n}of f){var t;for(let i of(e.push(n.mintA.address,n.mintB.address),null!=(t=n.rewardDefaultInfos)?t:[]))e.push(i.mint.address)}return eH()(e)},[f]),{data:y}=(0,eK.h3)({mints:v,enabled:v.length>0}),A=(0,eZ.E)({queries:f.map(e=>{let{position:t,poolInfo:l}=e;return{queryKey:(0,e0.nl)(l.poolId,t.nftMint.toBase58(),null==r?void 0:r.blockHash),queryFn:()=>(0,e0.bh)({raydium:n,poolInfo:l,position:t,connection:i}),enabled:!!(n&&l),...eO.MU}})}),b=A.some(e=>e.isPending),w=A.some(e=>e.isFetching),j=(0,c.useRef)({solanaPositions:[],solanaHarvestTargets:[],solanaTotalEarningsUSD:0}),k=(0,c.useMemo)(()=>{let e=[],t=[],n=0;if(A.some(e=>e.isPending))return{next:j.current,ready:!1};for(let b=0;b<f.length;b++){var i,r,l,o,a,s,d,u,c,p,m,x,h,v,g;let w,j,{key:k,position:C,pool:I}=f[b],S=null==(i=A[b])?void 0:i.data,R=null!=y?y:{},E=null!=(r=R[I.mintA.address])?r:0,M=null!=(l=R[I.mintB.address])?l:0,N=0,P=[];if(S){let e=new eD.A(null!=(u=null==(o=S.feeAmount0)?void 0:o.toString())?u:"0").div(10**I.mintA.decimals).times(E),t=new eD.A(null!=(c=null==(a=S.feeAmount1)?void 0:a.toString())?c:"0").div(10**I.mintB.decimals).times(M);N+=e.plus(t).toNumber();let n=new eD.A(null!=(p=null==(s=S.feeAmount0)?void 0:s.toString())?p:"0").div(10**I.mintA.decimals),i=new eD.A(null!=(m=null==(d=S.feeAmount1)?void 0:d.toString())?m:"0").div(10**I.mintB.decimals);w=n.toString(),j=i.toString();let r=(0,e1.ph)(I.mintA),l=(0,e1.ph)(I.mintB);n.gt(0)&&r&&P.push({currency:r,amount:n.toNumber()}),i.gt(0)&&l&&P.push({currency:l,amount:i.toNumber()});let f=null!=(x=S.rewardAmounts)?x:[];for(let e=0;e<f.length;e++){let t=null==(v=I.rewardDefaultInfos)||null==(h=v[e])?void 0:h.mint;if(!t)continue;let n=new eD.A(f[e].toString()).div(10**(t.decimals||0)),i=null!=(g=R[t.address])?g:0;if(N+=n.times(i).toNumber(),n.gt(0)){let e=(0,e1.ph)(t);e&&P.push({currency:e,amount:n.toNumber()})}}}if(N>0||P.length>0){let i=C.token0,r=C.token1;i&&r&&(e.push({key:k,currency0:i,currency1:r,earningsUSD:N,rewards:P}),t.push({key:k,position:C,poolInfo:I,feeAmountA:w,feeAmountB:j}),n+=N)}}return{next:{solanaPositions:e,solanaHarvestTargets:t,solanaTotalEarningsUSD:n},ready:!0}},[f,A,y]);k.ready&&(j.current=k.next);let S=(0,c.useMemo)(()=>{let e=k.ready?k.next:j.current;if(!l.size)return e;let t=e.solanaPositions.filter(e=>!l.has(e.key)),n=e.solanaHarvestTargets.filter(e=>!l.has(e.key)),i=e.solanaPositions.reduce((e,t)=>
29l.has(t.key)?e+t.earningsUSD:e,0);return{solanaPositions:t,solanaHarvestTargets:n,solanaTotalEarningsUSD:Math.max(0,e.solanaTotalEarningsUSD-i)}},[l,k]),R=(a||x||b)&&0===S.solanaPositions.length;return{solanaPositions:S.solanaPositions,solanaTotalEarningsUSD:S.solanaTotalEarningsUSD,solanaHarvestTargets:S.solanaHarvestTargets,solanaInitialLoading:R,solanaRefreshing:!R&&!!(s||x||w)}}();return{v3HarvestPositions:ea,infinityHarvestPositions:en,v2Positions:eu,stablePositions:ec,evmTotalEarningsUSD:ej,v3StakedTokenIds:es,v2Targets:ep,v2StableEarningsByKey:ev,otherChainsWithRewards:ew,solanaPositions:ek,solanaTotalEarningsUSD:eI,solanaHarvestTargets:eS,totalEarningsUSD:ej+eI,effectiveEvmChainId:a,isCurrentChainEvmLoading:ey,isOtherChainsEvmLoading:G,solanaInitialLoading:eR,solanaRefreshing:eE}}(R),X=(0,c.useCallback)(()=>{null==n||n()},[n]),J=(0,c.useCallback)(e=>{v(),E(e),A(e)},[v,A]),ee=(0,c.useCallback)(e=>{let t=0===e?"evm":"solana";("solana"!==t||b)&&k(t)},[b]);return(0,i.jsx)(l.aF,{isOpen:t,onDismiss:X,closeOnOverlayClick:!0,children:(0,i.jsx)(o.Ay,{title:f("Harvest Earnings"),headerBorderColor:"transparent",bodyPadding:"0 24px 16px",onDismiss:X,width:["100%",null,"480px"],children:(0,i.jsxs)(a.A,{flexDirection:"column",gap:"16px",py:"3px",children:[(0,i.jsxs)(s.A,{activeIndex:+("evm"!==j),onItemClick:ee,scale:"sm",variant:"subtle",fullWidth:!0,children:[(0,i.jsx)(d.A,{children:f("EVM")}),(0,i.jsx)(d.A,{disabled:!b,style:{opacity:b?1:.5},children:f("Solana")})]}),"evm"===j&&(0,i.jsx)(eM,{v3HarvestPositions:M,infinityHarvestPositions:N,v2Positions:P,stablePositions:T,v3StakedTokenIds:U,v2Targets:B,v2StableEarningsByKey:D,harvestModalChainId:K,totalEarningsUsd:O,otherChainsWithRewards:F,otherChainsLoading:G,positionsLoading:Q,onSwitchChain:J,focusedChainId:R}),"solana"===j&&(0,i.jsx)(eT,{initialLoading:W,refreshing:H,positions:z,totalEarningsUSD:V,harvestTargets:Z})]})})})}},606771:(e,t,n)=>{"use strict";n.d(t,{X:()=>b});var i=n(350979),r=n(273523),l=n(769932),o=n(549333),a=n(909114),s=n(728844),d=n(25963),u=n(252146),c=n(306411),p=n(733775),m=n(909725),x=n(207014),h=n(189346),f=n(975644),v=n(792118),y=n(522722),g=n(236088);let A=async(e,t,n,i,l,o,a,s,d,u)=>{var c;console.debug("debug removeLiquidity",t);let m=(0,r.s4)({tokenId:t.tokenId,poolKey:t.poolKey,liquidity:t.liquidity,amount0Min:t.amount0Min,amount1Min:t.amount1Min,wrapAddress:t.wrapAddress,recipient:l,hookData:t.hookData,deadline:t.deadline});null==(c=(0,v.Qr)({chainId:i}))||c.estimateGas({account:l,to:n,data:m}).then(t=>(null==s||s(!0),e({account:l,to:n,data:m,gas:(0,p.KL)(t),chainId:i,maxFeePerGas:d,maxPriorityFeePerGas:u}))).then(e=>{null==o||o(e)}).catch(e=>{null==a||a(e)})},b=(e,t,n,r)=>{let p=(0,c.OQ)(),[v,b]=(0,d.useState)(null),[w,j]=(0,d.useState)(!1),[k,C]=(0,d.useState)(),{t:I}=(0,l.A)(),S=(0,x.B4)("CL",e),{sendTransactionAsync:R}=(0,g.s)(),{maxFeePerGas:E,maxPriorityFeePerGas:M}=(0,a.N)(e),[,N]=(0,u.r)(),{waitForTransaction:P}=(0,s.x)(e),T=(0,d.useId)(),[U]=(0,o.A)((0,i.jsx)(y.A,{title:I("Remove Liquidity"),subTitle:k}),!0,!0,`infinity-cl-remove-liquidity-error-modal-${T}`);return{removeLiquidity:(0,d.useCallback)(async i=>{if(!e||!t)return;let l=async e=>{b(e);let t=0n===i.liquidity;p({hash:e},{type:t?"collect-fee":"remove-liquidity-infinity-cl",summary:(0,m.V$)(t?"Collect":"Remove",i.amount0Desired,i.currency0,i.amount1Desired,i.currency1,t?`Collect fees from ${i.tokenId}`:`Remove liquidity from ${i.tokenId}`)});let r=await P({hash:e});N({blockHash:r.blockHash,status:r.status}),null==j||j(!1),null==n||n(e)};await A(R,i,S,e,t,l,e=>{null==j||j(!1),console.error(e),(0,h.U)(e)||(C((0,f.w)(e,I)),U()),null==r||r(e)},j,E,M)},[S,R,e,t,n,p,r,I,P,N,E,M,U]),txHash:v,attemptingTx:w,txnErrorMessage:k}}}
29,606862:(e,t,n)=>{"use strict";n.d(t,{B:()=>c,p:()=>p});var i=n(350979),r=n(769932),l=n(150591),o=n(501823),a=n(428089),s=n(554945),d=n(605641),u=n(971733);let c=()=>{let{t:e}=(0,r.A)();return(0,i.jsx)(u.R,{padding:"0",borderRadius:"24px",children:(0,i.jsx)(l.A,{children:(0,i.jsxs)(o.A,{justifyContent:"center",alignItems:"center",flexDirection:"column",py:"40px",children:[(0,i.jsx)(a.Ay,{mb:"16px",children:(0,i.jsx)(s.A,{})}),(0,i.jsx)(d.A,{fontSize:"16px",color:"textSubtle",children:e("Loading...")})]})})})},p=()=>{let{t:e}=(0,r.A)();return(0,i.jsx)(u.R,{padding:"0",borderRadius:"24px",children:(0,i.jsx)(l.A,{children:(0,i.jsx)(o.A,{justifyContent:"center",alignItems:"center",flexDirection:"column",py:"40px",children:(0,i.jsx)(d.A,{color:"textSubtle",children:e("No positions found")})})})})}},609377:(e,t,n)=>{"use strict";n.d(t,{AU:()=>m,BL:()=>s,Er:()=>j,Hw:()=>k,Ip:()=>I,Iw:()=>c,Kk:()=>u,Kn:()=>p,Og:()=>b,PR:()=>d,Qq:()=>y,_i:()=>v,dZ:()=>f,fc:()=>x,iX:()=>C,s6:()=>T,xG:()=>g,y5:()=>h,yt:()=>A});var i=n(228876),r=n(985148),l=n(656862),o=n(608998),a=n(194755);let s=(0,r.eU)(null),d=(0,r.eU)(e=>{var t;return(null==(t=e(s))?void 0:t.complete)===!1}),u=(0,o.w)({asyncFn:async(e,t)=>a.qY.getRwaTokens(t,{throwOnError:!0}),shared:!0,maxRetries:2,fallbackValue:[],errorReportKey:"stocks-rwa-tokens"}),c=(0,r.eU)(e=>{var t,n;return null!=(n=null==(t=e(s))?void 0:t.assets)?n:e(u)},(e,t)=>{t(s,null),t(u)}),p=(0,l.Rq)(c),m=(0,r.eU)(!0),x=(0,r.eU)(void 0),h=(0,r.eU)(!1),f=(0,r.eU)(void 0),v=(0,r.eU)(void 0),y=(0,l.tG)("pcs:stocks:favorites",[],void 0,{getOnInit:!0}),g=(0,r.eU)("All"),A=(0,r.eU)(null),b=(0,r.eU)(0),w=(e,t)=>{var n,i;return e.address===t.address&&e.solanaAddress===t.solanaAddress&&e.chainId===t.chainId&&e.enabled===t.enabled&&(null!=(n=e.assetIds)?n:[]).join(",")===(null!=(i=t.assetIds)?i:[]).join(",")},j=(0,l.Iz)(e=>(0,r.eU)(async t=>{let{address:n,solanaAddress:i,assetIds:r,chainId:l,enabled:o}=e,[a,s,d,u]=await Promise.all([t(S({assetIds:r,chainId:l,enabled:o})),t(M({assetIds:r,chainId:l,enabled:o})),t(N({address:n,solanaAddress:i,assetIds:r,chainId:l,enabled:o})),t(P({assetIds:r,chainId:l,enabled:o}))]);return{prices:a,prices24h:s,balances:d,tradeStatuses:u}}),w),k=(0,l.Iz)(e=>(0,r.eU)(async t=>{let{assetIds:n,chainId:i,enabled:r}=e,[l,o]=await Promise.all([t(R({assetIds:n,chainId:i,enabled:r})),t(M({assetIds:n,chainId:i,enabled:r}))]);return{prices:l,prices24h:o}}),w),C=(0,l.Iz)(e=>(0,r.eU)(async t=>{let{assetIds:n,chainId:i,enabled:r}=e;return{prices:await t(E({assetIds:n,chainId:i,enabled:r}))}}),w),I=(0,l.Iz)(e=>(0,r.eU)(async t=>{let{address:n,solanaAddress:i,assetIds:r,chainId:l,enabled:o}=e,[a,s]=await Promise.all([t(N({address:n,solanaAddress:i,assetIds:r,chainId:l,enabled:o})),t(P({assetIds:r,chainId:l,enabled:o}))]);return{balances:a,tradeStatuses:s}}),w),S=(0,l.Iz)(e=>{let{assetIds:t,chainId:n,enabled:i=!0}=e;return(0,o.w)({asyncFn:async(e,r)=>{if(e(b),!i)return new Map;let l=await e(c),o=a.qY.getMarketAssets(l,t,n).map(e=>e.id);return a.qY.getPriceMap("prices",o,r,{throwOnError:!0})},fallbackValue:new Map,errorReportKey:"stocks-rwa-prices"})},(e,t)=>{var n,i;return e.chainId===t.chainId&&e.enabled===t.enabled&&(null!=(n=e.assetIds)?n:[]).join(",")===(null!=(i=t.assetIds)?i:[]).join(",")}),R=(0,l.Iz)(e=>{let{assetIds:t,chainId:n,enabled:r=!0}=e;return(0,o.w)({asyncFn:async(e,l)=>{if(!r)return new Map;e(b);let o=await e(c),s=a.qY.getMarketAssets(o,t,n).filter(e=>(0,i.F8)(e.chainId)).map(e=>e.id);return a.qY.getPriceMap("prices",s,l,{throwOnError:!0})},fallbackValue:new Map,errorReportKey:"stocks-rwa-prices-evm"})},(e,t)=>{var n,i;return e.chainId===t.chainId&&e.enabled===t.enabled&&(null!=(n=e.assetIds)?n:[]).join(",")===(null!=(i=t.assetIds)?i:[]).join(",")}),E=(0,l.Iz)(e=>{let{assetIds:t,chainId:n,enabled:r=!0}=e;return(0,o.w)({asyncFn:async(e,l)=>{if(!r)return new Map;e(b);let o=await e(c),s=a.qY.getMarketAssets(o,t,n).filter(e=>!(0,i.F8)(e.chainId)).map(e=>e.id);return a.qY.getPriceMap("prices",s,l,{throwOnError:!0})},fallbackValue:new Map,errorReportKey:"stocks-rwa-prices-solana"})},(e,t)=>{var n,i;return e.chainId===t.chainId&&e.enabled===t.enabled&&(null!=(n=e.assetIds)?n:[]).join(",")===(null!=(i=t.assetIds)?i:[]).join(",")}),M=(0,l.Iz)(e=>{let{assetIds:t,chainId:n,enabled:i=!0}=e;return(0,o.w)({asyncFn:async(e,r)=>{if(e(b),!i)return new Map;let l=await e(c),o=a.qY.getMarketAssets(l,t,n).map(e=>e.id);return a.qY.getPriceMap("prices24h",o,r,{throwOnError:!0})},fallbackValue:new Map,errorReportKey:"stocks-rwa-prices-24h"})},(e,t)=>{var n,i;return e.chainId===t.chainId&&e.enabled===t.enabled&&(null!=(n=e.assetIds)?n:[]).join(",")===(null!=(i=t.assetIds)?i:[]).join(",")}),N=(0,l.Iz)(e=>{let{address:t,solanaAddress:n,assetIds:i,chainId:r,enabled:l=!0}=e;return(0,o.w)({asyncFn:async(e,o)=>{if(!l||!t&&!n)return new Map;let s=await e(c),d=a.qY.getMarketAssets(s,i,r);return a.qY.getBalances(t,o,d,n)},fallbackValue:new Map,errorReportKey:"stocks-rwa-balances"})},(e,t)=>{var n,i;return e.address===t.address&&e.solanaAddress===t.solanaAddress&&e.chainId===t.chainId&&e.enabled===t.enabled&&(null!=(n=e.assetIds)?n:[]).join(",")===(null!=(i=t.assetIds)?i:[]).join(",")}),P=(0,l.Iz)(e=>{let{assetIds:t,chainId:n,enabled:i=!0}=e;return(0,o.w)({asyncFn:async(e,r)=>{if(!i)return new Map;let l=await e(c),o=a.qY.getMarketAssets(l,t,n);return a.qY.getTradeStatusMap(o,r)},fallbackValue:new Map,errorReportKey:"stocks-rwa-trade-statuses"})},(e,t)=>{var n,i;return e.chainId===t.chainId&&e.enabled===t.enabled&&(null!=(n=e.assetIds)?n:[]).join(",")===(null!=(i=t.assetIds)?i:[]).join(",")}),T=(0,l.Iz)(e=>(0,o.w)({asyncFn:async(t,n)=>{let i=new Map;if(!e)return i;t(b);let r=await fetch("/api/stocks/reference-prices",{signal:n});if(!r.ok)throw Error(`reference-prices request failed: ${r.status}`);return new Map(Object.entries((await r.json()).referencePrices))},fallbackValue:new Map,errorReportKey:"stocks-rwa-catalog-reference-prices"}))}
29,611262:(e,t,n)=>{"use strict";n.d(t,{L:()=>a});var i=n(662928),r=n(856870),l=n(660430),o=n(363459);let a=e=>{let t=(0,l.Rc)(),{data:n}=(0,i.I)({queryKey:[`info/pool/stableAPR/${e}/`,t],queryFn:()=>(0,o.V)(e,r._J[t]),enabled:!!e&&!!t,refetchInterval:15e3,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:3,retryDelay:3e3});return null==n?void 0:n.toNumber()}},612507:(e,t,n)=>{"use strict";function i(e){var t,n,i,r,l,o;return"tokenId"in e?e.tokenId.toString():"nftMint"in e&&e.nftMint?e.nftMint.toBase58():"poolId"in e&&e.poolId?"string"==typeof e.poolId?e.poolId:null!=(l=null==(i=(r=e.poolId).toBase58)?void 0:i.call(r))?l:e.poolId.toString():null!=(o=null==(n=e.pair)||null==(t=n.liquidityToken)?void 0:t.address)?o:"unknown"}n.d(t,{V:()=>i})},623208:(e,t,n)=>{"use strict";n.d(t,{_L:()=>u,xk:()=>c});var i=n(662928),r=n(529208),l=n(118708),o=n(25963),a=n(252146),s=n(489886);async function d(e){let t=Array.from(new Set(e.filter(Boolean))),n=Date.now();if(0===t.length)return e.map(()=>null);let i=new Map;return await Promise.all(((e,t)=>{let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n})(t,25).map(async e=>{try{let t=await fetch(`https://sol-explorer.pancakeswap.com/api/cached/v1/pools/info/ids?ids=${e.join(",")}`);if(!t.ok)throw Error(`API request failed: ${t.status}`);let r=await t.json();(r.data||r||[]).forEach(e=>{if(e&&e.id){let t=!1;e.rewardDefaultInfos&&e.rewardDefaultInfos.length>0&&(t=e.rewardDefaultInfos.some(e=>{var t;return 1e3*Number(null!=(t=e.endTime)?t:0)>n&&e.perSecond>0})),i.set(e.id,{...e,isFarming:t})}})}catch(e){console.error("Error fetching Solana pools data:",e)}})),e.map(e=>e&&i.get(e)||null)}function u(e){let t=(0,l.Xr)(s.iA),n=(0,l.md)(s.n2),u=(0,l.md)(s.jQ),c=(0,o.useMemo)(()=>e.filter(e=>void 0!==e&&!u.includes(e)),[e,u]),p=(0,o.useMemo)(()=>JSON.stringify(c),[c]),[m]=(0,a.r)();return(0,i.I)({queryKey:["solanaV3Pools",p,null==m?void 0:m.blockHash],queryFn:async()=>((await d(c)).forEach(t),!0),enabled:c.length>0,refetchInterval:r.IX}),n}function c(e){let t=u((0,o.useMemo)(()=>[e],[e]));return(0,o.useMemo)(()=>e&&t.find(t=>(null==t?void 0:t.id)===e)||null,[e,t])}},628838:(e,t,n)=>{"use strict";n.d(t,{g:()=>i});let i=[25,50,75,100]},630037:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(350979),r=n(25963),l=n(284178);function o(e){let{children:t,onAddLiquidityCallback:n}=e,o=(0,r.useMemo)(()=>(0,l.AK)(),[]);return(0,i.jsx)(l.N5,{value:{formAtom:o,onAddLiquidityCallback:(0,r.useCallback)(e=>{null==n||n(e)},[n])},children:t})}},633835:(e,t,n)=>{"use strict";n.d(t,{F:()=>l});var i=n(703730),r=n(16033);function l(e){let{key:t="wallet",name:n="Wallet Client",transport:l}=e;return(0,i.U)({...e,key:t,name:n,transport:l,type:"walletClient"}).extend(r.D)}},638280:(e,t,n)=>{var i=n(116182),r=n(685892),l=n(980544),o=Math.max;e.exports=function(e,t,n){var a=null==e?0:e.length;if(!a)return -1;var s=null==n?0:l(n);return s<0&&(s=o(a+s,0)),i(e,r(t,3),s)}},642010:(e,t,n)=>{"use strict";n.d(t,{A:()=>j});var i=n(350979),r=n(273523),l=n(769932),o=n(334404),a=n(27313),s=n(91168),d=n(227883),u=n(369067),c=n(402861),p=n(389512),m=n(146105),x=n(25963),h=n(252146),f=n(733775),v=n(792118),y=n(17581),g=n(495964),A=n(236088),b=n(909114),w=n(514666);let j=e=>{let{chainId:t,onDone:n}=e,{t:j}=(0,l.A)(),{toastSuccess:k}=(0,o.d)(),{address:C}=(0,y.F)(),{data:I}=(0,g.G)(),{sendTransactionAsync:S}=(0,A.s)(),{maxFeePerGas:R,maxPriorityFeePerGas:E}=(0,b.N)(t),M=(0,a.jE)(),N=(0,v.Rt)({chainId:t}),[P,T]=(0,x.useState)(),{loading:U,fetchWithCatchTxError:B}=(0,p.A)(),[,D]=(0,h.r)(),F=(0,m.w)(t),{switchNetworkIfNecessary:q,isLoading:L}=(0,w.H)(),{allRewards:O,totalUnclaimedRewards:_}=(0,c.LM)({chainId:t,user:C,timestamp:P}),$=(0,u.B)(t),Y=(0,x.useMemo)(()=>$?null==O?void 0:O.find(e=>e.merkleRoot!==$):void 0,[O,$]);(0,x.useEffect)(()=>{!P&&$&&Y&&T(Number(Y.epochEndTimestamp)-1)},[$,P,Y]);let z=(0,x.useCallback)(async()=>{if(!C||!O||!_.find(e=>new s.A(e.totalReward).isGreaterThan(0))||await q(t))return;let e=O.map(e=>{let{totalRewardAmount:t,rewardTokenAddress:n,proofs:i}=e;return{proof:i,amount:BigInt(t),token:n}}),l=(0,r.Rc)(e),o={to:r.BI[t],data:l,value:0n},a=await B(()=>N.estimateGas({account:C,...o}).then(e=>S({...o,account:C,chain:null==I?void 0:I.chain,gas:(0,f.KL)(e),maxFeePerGas:R,maxPriorityFeePerGas:E})));(null==a?void 0:a.status)==="success"&&(D({blockHash:a.blockHash,status:a.status}),null==n||n(a),F(a.transactionHash),k(`${j("Harvested")}!`,(0,i.jsx)(d.G,{txHash:a.transactionHash,children:j("Your %symbol% earnings have been sent to your wallet!",{symbol:"CAKE"})})),M.invalidateQueries({queryKey:["mcv4-harvest"]}))},[D,_,t,O,n,C,B,N,S,R,E,I,j,k,M,q,F]);return{hasRewards:!!(null==O?void 0:O.length),hasUnclaimedRewards:null==_?void 0:_.some(e=>Number(e.totalReward)>0),isMerkleRootMismatch:!!Y,attemptingTx:U||L,onHarvest:z}}},645444:(e,t,n)=>{"use strict";n.d(t,{Hf:()=>f,Kc:()=>m,Mu:()=>d,Rp:()=>p,iz:()=>u,jC:()=>x,lN:()=>h});var i=n(273523),r=n(673384),l=n(805939),o=n(827666),a=n(562265);let s=(e,t,n,i)=>{try{if(e>=r.gy.MAX_TICK)return 1/0;if(e<=r.gy.MIN_TICK)return 0;if(t&&n){let l=(0,r.y1)(t,n,e),o=parseFloat(l.toFixed(18));return i?1/o:o}let l=1.0001**e;return i?1/l:l}catch(n){console.error("Error calculating tick price:",n);let t=1.0001**e;return i?1/t:t}},d=e=>({[l.z.LOWER]:e?(0,r.Yp)(r.gy.MIN_TICK,e):void 0,[l.z.UPPER]:e?(0,r.Yp)(r.gy.MAX_TICK,e):void 0}),u=e=>({[l.z.LOWER]:e?o.P3F.nearestUsableTick(o.BMJ,e):void 0,[l.z.UPPER]:e?o.P3F.nearestUsableTick(o.ZlO,e):void 0}),c=(e,t,n,i)=>{try{if(e>=o.ZlO)return 1/0;if(e<=o.BMJ)return 0;if(t&&n){var r,l;let a=o.mb.getSqrtPriceX64FromTick(e),s=o.mb.sqrtPriceX64ToPrice(a,null!=(r=null==t?void 0:t.decimals)?r:0,null!=(l=null==n?void 0:n.decimals)?l:0),d=parseFloat(s.toString());return i?1/d:d}let a=1.0001**e;
29return i?1/a:a}catch(n){console.error("Error calculating Solana tick price:",n);let t=1.0001**e;return i?1/t:t}},p=(e,t,n,i,r,s,d,u)=>{let p,m="-",x="-",h="",f="",v=50,y=!1,g=s?t:e,A=s?e:t,b=s?{[l.z.LOWER]:r[l.z.UPPER],[l.z.UPPER]:r[l.z.LOWER]}:r,w=c(g,n,i,s),j=c(A,n,i,s),k=b[l.z.LOWER],C=b[l.z.UPPER],I=Number.isFinite(w)&&w>0,S=Number.isFinite(j)&&j>0;if(m=k?"0":I?w.toString():"-",x=C?"â":S?j.toString():"-",!k&&!C&&I&&S){let e=(0,a.Yr)(w,j,u);m=e.minFormatted,x=e.maxFormatted}if(b[l.z.LOWER]&&b[l.z.UPPER])v=50,y=!0,h="0%",f="100%",m="0",x="â";else if(I&&S&&void 0!==d&&g>o.BMJ&&A<o.ZlO)try{let e=Number(d);if(e>0&&j>w&&Number.isFinite(w)&&Number.isFinite(j)&&Number.isFinite(e)){let t=(w-e)/e*100,n=(j-e)/e*100;Number.isFinite(t)&&Number.isFinite(n)&&1e4>Math.abs(t)&&1e4>Math.abs(n)&&(h=(0,a.Ee)(t),f=(0,a.Ee)(n),v=Math.max(0,Math.min(100,(e-w)/(j-w)*100)),y=!0,p=e.toFixed(18))}}catch(e){console.warn("Solana price calculation error:",e)}return{minPriceFormatted:m,maxPriceFormatted:x,minPercentage:h,maxPercentage:f,rangePosition:v,showPercentages:y,currentPrice:p,minPrice:I?w:void 0,maxPrice:S?j:void 0,currentPriceValue:void 0!==d&&Number.isFinite(d)?d:void 0}},m=(e,t,n)=>({[l.z.LOWER]:!!e&&!!n.LOWER&&e<=n.LOWER,[l.z.UPPER]:!!t&&!!n.UPPER&&t>=n.UPPER}),x=(e,t)=>{var n;return null!=(n=null==e?void 0:e.tickSpacing)?n:t?r.D6[t]:void 0},h=function(e,t,n,i,o,d,u){let c,p,m,x=arguments.length>7&&void 0!==arguments[7]?arguments[7]:1,h=arguments.length>8?arguments[8]:void 0,f="-",v="-",y="",g="",A=50,b=!1,w=u?t:e,j=u?e:t,k=u?{[l.z.LOWER]:d[l.z.UPPER],[l.z.UPPER]:d[l.z.LOWER]}:d,C=s(w,n,i,u),I=s(j,n,i,u),S=u?1/x:x;if(1!==S&&(Number.isFinite(C)&&(C*=S),Number.isFinite(I)&&(I*=S)),"number"==typeof C&&"number"==typeof I&&Number.isFinite(C)&&Number.isFinite(I)&&C>I){let e=C;C=I,I=e}let R=k.LOWER,E=k.UPPER,M="number"!=typeof C||!Number.isFinite(C)||Number.isNaN(C),N="number"!=typeof I||!Number.isFinite(I)||Number.isNaN(I);if(f=R?"0":M?"-":C.toString(),v=E?"â":N?"-":I.toString(),!R&&!E&&!M&&!N){let e=(0,a.Yr)(C,I,h);f=e.minFormatted,v=e.maxFormatted}if(k.LOWER&&k.UPPER)A=50,b=!0,y="0%",g="100%",f="0",v="â";else if(!M&&!N&&(null==o?void 0:o.token0Price)&&w>r.gy.MIN_TICK&&j<r.gy.MAX_TICK)try{let e;if(u){var P,T;e=o.token1Price||(null==(T=o.token0Price)||null==(P=T.invert)?void 0:P.call(T))}else e=o.token0Price;if(!e){let e,t;return console.warn("No base price available for range calculation"),"0"===f?e=0:"-"!==f&&Number.isFinite(C)&&!Number.isNaN(C)&&(e=C),"â"===v?t=void 0:"-"!==v&&Number.isFinite(I)&&!Number.isNaN(I)&&(t=I),{minPriceFormatted:f,maxPriceFormatted:v,minPercentage:y,maxPercentage:g,rangePosition:A,showPercentages:b,currentPrice:c,minPrice:e,maxPrice:t,currentPriceValue:void 0}}let t="function"==typeof(null==e?void 0:e.toFixed)?e.toFixed(18):String(e),n=parseFloat(t)*S;if(c=1!==S?String(n):t,n>0&&I>C&&Number.isFinite(C)&&Number.isFinite(I)&&Number.isFinite(n)){let e=(C-n)/n*100,t=(I-n)/n*100;Number.isFinite(e)&&Number.isFinite(t)&&1e4>Math.abs(e)&&1e4>Math.abs(t)&&(y=(0,a.Ee)(e),g=(0,a.Ee)(t),A=Math.max(0,Math.min(100,(n-C)/(I-C)*100)),b=!0)}}catch(e){console.warn("Price calculation error:",e)}"0"===f?p=0:"-"!==f&&Number.isFinite(C)&&!Number.isNaN(C)&&(p=C),"â"===v?m=void 0:"-"!==v&&Number.isFinite(I)&&!Number.isNaN(I)&&(m=I);let U=c&&Number.isFinite(parseFloat(c))?parseFloat(c):void 0;return{minPriceFormatted:f,maxPriceFormatted:v,minPercentage:y,maxPercentage:g,rangePosition:A,showPercentages:b,currentPrice:c,minPrice:p,maxPrice:m,currentPriceValue:U}},f=function(e,t,n,r,l,o,s){let d,u,c,p=arguments.length>7&&void 0!==arguments[7]?arguments[7]:1,m=arguments.length>8?arguments[8]:void 0,x="-",h="-",f="",v="",y=50,g=!1,A=s?1/p:p;if(null!=e&&null!=t&&n&&l&&o){let p,b,w=(0,i.GQ)(e,n,l,o),j=(0,i.GQ)(t,n,l,o),k=null!=r?(0,i.GQ)(r,n,l,o):void 0;if(s?(p=j?j.invert():void 0,b=w?w.invert():void 0,d=k?k.invert():void 0):(p=w,b=j,d=k),p&&b){let e=parseFloat(p.toFixed(18)),t=parseFloat(b.toFixed(18));if(1!==A&&(Number.isFinite(e)&&(e*=A),Number.isFinite(t)&&(t*=A)),e>t&&Number.isFinite(e)&&Number.isFinite(t)){let n=e;e=t,t=n}u=Number.isFinite(e)&&!Number.isNaN(e)?e:void 0,c=Number.isFinite(t)&&!Number.isNaN(t)?t:void 0;let n=0===e||!Number.isFinite(e)||Number.isNaN(e),i=t===1/0||!Number.isFinite(t)||Number.isNaN(t);
29if(x=n?"0":e.toFixed(18),h=i?"â":t.toFixed(18),!n&&!i){let n=(0,a.Yr)(e,t,m);x=n.minFormatted,h=n.maxFormatted}if(d&&!n&&!i)try{let n=parseFloat(d.toFixed(18))*A;if(n>0&&t>e&&Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)){let i=(e-n)/n*100,r=(t-n)/n*100;Number.isFinite(i)&&Number.isFinite(r)&&1e4>Math.abs(i)&&1e4>Math.abs(r)&&(f=(0,a.Ee)(i),v=(0,a.Ee)(r),y=Math.max(0,Math.min(100,(n-e)/(t-e)*100)),g=!0)}}catch(e){console.warn("Price calculation error:",e)}}}let b=d&&Number.isFinite(parseFloat(d.toFixed(18)))?parseFloat(d.toFixed(18)):void 0,w=void 0!==b?b*A:void 0;return{minPriceFormatted:x,maxPriceFormatted:h,minPercentage:f,maxPercentage:v,rangePosition:y,showPercentages:g,currentPrice:1!==A&&void 0!==w?String(w):null==d?void 0:d.toFixed(18),minPrice:u,maxPrice:c,currentPriceValue:w}}},655727:(e,t,n)=>{"use strict";n.d(t,{Cv:()=>X,ml:()=>ei,F9:()=>W.F,AE:()=>em,KR:()=>eR});var i=n(350979),r=n(659197),l=n(769932),o=n(734658),a=n(995315),s=n(605641),d=n(979332),u=n(501823),c=n(795904),p=n(892977),m=n(659918),x=n(919968),h=n(898719),f=n(91168),v=n(450253),y=n.n(v),g=n(402861),A=n(208103),b=n(165073),w=n(687287),j=n(810286),k=n(459587),C=n(899188),I=n(529208),S=n(627817),R=n(326848),E=n.n(R),M=n(25963),N=n(437862),P=n(203907),T=n(660430),U=n(538534),B=n(23275),D=n(978300),F=n(487430),q=n(863984),L=n(851931),O=n(857019),_=n(698163),$=n(112616),Y=n(17581),z=n(894799),V=n(481711),Z=n(748469),W=n(732269),H=n(432680),Q=n(606862);let G=function(e,t,n,l,o,m,v,y,g,A,b,w){var k,R,E,M,N,T;let B=arguments.length>12&&void 0!==arguments[12]?arguments[12]:1,D=arguments.length>13&&void 0!==arguments[13]&&arguments[13],{removed:L,outOfRange:O}=(0,F.V2)(e.status),_=(null==o?void 0:o.greaterThan("0"))||(null==m?void 0:m.greaterThan("0")),Y=D?t.token1:t.token0,Z=D?t.token0:t.token1,H=(0,i.jsx)(a.A,{flexDirection:"column",gap:"4px",children:(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsxs)(s.A,{bold:!0,fontSize:"16px",children:[null==Y?void 0:Y.symbol," / ",null==Z?void 0:Z.symbol]}),e.isStaked&&!L&&!O&&(0,i.jsx)(d.A,{variant:"primary60",scale:"sm",children:g("Farming")}),L&&(0,i.jsx)(d.A,{variant:"tertiary",scale:"sm",px:"6px",children:g("Closed")})]})}),Q=new f.g(null!=(E=null==o?void 0:o.toExact())?E:0).times(null!=v?v:0).plus(new f.g(null!=(M=null==m?void 0:m.toExact())?M:0).times(null!=y?y:0)).toNumber(),G=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",children:(0,i.jsx)(U.z,{content:(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"8px",children:[(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:t.token0,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(k=t.token0)?void 0:k.symbol})]}),(0,i.jsx)(j.g3,{amount:o,fontSize:"14px",bold:!0,children:null!=(N=A(o,6))?N:"-"})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:o&&v?(0,$.o5)(new f.g(o.toExact()).times(v).toNumber()):"$0.00"})]}),(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:t.token1,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(R=t.token1)?void 0:R.symbol})]}),(0,i.jsx)(j.g3,{amount:m,fontSize:"14px",bold:!0,children:null!=(T=b(m,6))?T:"-"})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:m&&y?(0,$.o5)(new f.g(m.toExact()).times(y).toNumber()):"$0.00"})]})]}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",style:{cursor:"default"},children:(0,$.o5)(Q)})})}),K=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",style:{cursor:"default"},children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",children:(0,i.jsx)(V.Fm,{chainId:t.chainId,poolId:t.poolId})})}),X=(0,F.Uz)((0,F.mf)(l)),J=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",style:{cursor:"default"},children:(0,i.jsx)(U.z,{content:(0,i.jsx)(q.S,{combinedApr:X,lpFeeApr:Number(l.lpApr),cakeApr:l.cakeApr?{value:Number(l.cakeApr.value)}:void 0,merklApr:Number(l.merklApr)}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",color:X>0?"success":"text",children:(0,x.U)(X)})})}),ee=(0,F.Hf)(e.minBinId,e.maxBinId,null==n?void 0:n.binStep,null==n?void 0:n.activeId,t.token0,t.token1,w,B),et=(null==n?void 0:n.token0Price)!=null?String(parseFloat(n.token0Price.toSignificant(18))*B):void 0,en=(0,i.jsx)(W.F,{minPrice:ee.minPriceFormatted,maxPrice:ee.maxPriceFormatted,minPercentage:ee.minPercentage,maxPercentage:ee.maxPercentage,rangePosition:ee.rangePosition,outOfRange:O,removed:L,currentPrice:ee.currentPrice||et,showPercentages:ee.showPercentages,minPriceRaw:ee.minPrice,maxPriceRaw:ee.maxPrice,currentPriceRaw:ee.currentPriceValue}),ei=(0,i.jsxs)(a.A,{gap:"8px",alignItems:"center",justifyContent:"flex-end",children:[(0,i.jsx)(z.r,{as:"a",href:(0,S.g)({route:"/liquidity/position/[[...positionId]]",routeParam
29s:{positionId:[r.Zs.InfinityBIN,e.poolId.toString(),"decrease"]},searchParams:{chain:C.RW[t.chainId],[I.hy]:"1"}}),disabled:e.status===P.$.CLOSED,isIcon:!0,onClick:e=>e.stopPropagation(),children:(0,i.jsx)(c.A,{})}),(0,i.jsx)(z.r,{as:"a",href:(0,S.g)({route:"/liquidity/add/[[...poolId]]",routeParams:{poolId:[t.chainId,"infinity",t.poolId.toString()]},searchParams:{chain:C.RW[t.chainId],[I.hy]:"1"}}),disabled:e.status===P.$.CLOSED,isIcon:!0,onClick:e=>e.stopPropagation(),children:(0,i.jsx)(p.A,{})})]});return{positionId:`${e.chainId}-${e.poolId}`,tableRow:{tokenInfo:H,liquidity:G,earnings:K,apr:J,priceRange:en,actions:ei,protocol:r.Zs.InfinityBIN,poolId:e.poolId},liquidityUSD:Q,totalApr:X,hasLiquidity:_,aprData:l}},K=e=>{var t,n;let{position:i,poolInfo:r,pool:a,onRowDataReady:s,flipCurrentPrice:d,isClassificationFlipped:u}=e,{t:c}=(0,l.A)(),p=(0,_.FX)(r,i),m=(0,M.useMemo)(()=>{var e;return(null==a?void 0:a.token0)?o.eF.fromRawAmount(a.token0,null!=(e=null==i?void 0:i.reserveX)?e:0n):void 0},[null==i?void 0:i.reserveX,null==a?void 0:a.token0]),x=(0,M.useMemo)(()=>{var e;return(null==a?void 0:a.token1)?o.eF.fromRawAmount(a.token1,null!=(e=null==i?void 0:i.reserveY)?e:0n):void 0},[null==i?void 0:i.reserveY,null==a?void 0:a.token1]),{data:h}=(0,k.GB)(null!=(t=null==a?void 0:a.token0)?t:void 0,{enabled:!!((null==a?void 0:a.token0)&&(null==m?void 0:m.greaterThan("0")))}),{data:f}=(0,k.GB)(null!=(n=null==a?void 0:a.token1)?n:void 0,{enabled:!!((null==a?void 0:a.token1)&&(null==x?void 0:x.greaterThan("0")))}),v=(0,M.useMemo)(()=>(0,F.mf)(p),[p]),y=(0,w.wG)(r.token0),g=(0,w.wG)(r.token1),A=(0,w.Ae)(r.token0,r.token1),b=(0,M.useMemo)(()=>G(i,r,a,v,m,x,h,f,c,y,g,d,A,u),[i,r,a,v,m,x,c,h,f,d,u,y,g,A]);return(0,M.useEffect)(()=>{s(b)},[b,s]),null},X=e=>{let{poolInfo:t}=e,{address:n}=(0,Y.F)(),r=(0,T.Vx)(),[l]=(0,B.$)(),{isFlipped:o}=(0,M.useMemo)(()=>t.token0&&t.token1?(0,D.SP)(t.token0,t.token1):{isFlipped:!1},[t.token0,t.token1]),a=l!==o,[,s]=(0,A.W)(t.poolId,r),{data:d}=(0,b.L)(t.poolId,r),[u,c]=(0,M.useState)(H.E.All),[p,x]=(0,M.useState)([]),{data:h,isLoading:f}=(0,N.mP)(r,n,t),{data:v}=(0,O.I)(),{data:{rewardsAmount:w,rewardsUSD:j},isLoading:k}=(0,g.wA)({poolId:t.poolId,chainId:t.chainId,address:n,timestamp:y()().startOf("hour").unix()}),R=(0,M.useMemo)(()=>{var e;return{status:P.$.CLOSED,chainId:t.chainId,protocol:t.protocol,poolKey:d,poolId:t.poolId,activeId:null!=(e=null==s?void 0:s.activeId)?e:0,reserveX:0n,reserveY:0n,maxBinId:null,minBinId:null,reserveOfBins:[],liquidity:0n,activeLiquidity:0n,poolActiveLiquidity:0n}},[s,d,t]),U=(0,M.useMemo)(()=>{let e=h||[];return!f&&!k&&!e.length&&(null==w?void 0:w.greaterThan("0"))?[R]:e},[h,f,k,R,w]),q=(0,M.useCallback)(e=>{x(t=>t.find(t=>t.positionId===e.positionId)?t.map(t=>t.positionId===e.positionId?e:t):[...t,e])},[]);(0,M.useEffect)(()=>{x(e=>{let t=new Set(U.map(e=>`${e.chainId}-${e.poolId}`)),n=e.filter(e=>t.has(e.positionId));return n.length===U.length,n})},[U]);let _=(0,M.useMemo)(()=>U.length?U.map((e,n)=>(0,i.jsx)(K,{position:e,poolInfo:t,pool:s,onRowDataReady:q,flipCurrentPrice:a,isClassificationFlipped:o},`${e.chainId}-${e.poolId}-${n}`)):[],[U,t,s,q,a,o]),$=(0,M.useMemo)(()=>{if(!p.length)return[];let e=e=>{let{totalApr:t,liquidityUSD:n}=e,i=n>0;return i&&t>0?1:i&&0===t?2:i?4:3};return p.toSorted((t,n)=>{let i=e(t),r=e(n);if(i!==r)return i-r;let l=t.liquidityUSD;return n.liquidityUSD>l?1:-1}).filter(e=>{let{totalApr:t,liquidityUSD:n}=e,i=n>0;switch(u){case H.E.Active:return i&&t>0;case H.E.Inactive:return i&&0===t;case H.E.Closed:return!i;default:return!0}})},[p,u]),[z,V]=(0,M.useMemo)(()=>p.reduce((e,t)=>{let{numerator:n,denominator:i}=(0,F.mf)(t.aprData);return n.isZero()?e:[e[0].plus(n),e[1].plus(i)]},[m.AH,m.AH]),[p]),W=(0,M.useMemo)(()=>V.isZero()?0:z.div(V).toNumber(),[z,V]),G=(0,M.useMemo)(()=>v||[],[v]),X=(0,M.useMemo)(()=>(null==$?void 0:$.map(e=>e.tableRow))||[],[$]),J=(0,M.useMemo)(()=>(null==$?void 0:$.reduce((e,t)=>e+(t.liquidityUSD||0),0))||0,[$]);return f?(0,i.jsx)(Q.B,{}):(null==h?void 0:h.length)||w&&w.greaterThan("0")?(0,i.jsxs)(i.Fragment,{children:[_,(0,i.jsx)(Z.X,{poolInfo:t,totalLiquidityUSD:J,totalApr:W,totalEarnings:(0,F.Su)(j),data:X,showInactiveOnly:u===H.E.Inactive,toggleInactiveOnly:()=>c(u===H.E.Inactive?H.E.All:H.E.Inactive),harvestAllButton:(0,i.jsx)(L.v,{positionList:G,showPositionFees:!1,chainId:t.chainId}),onRowClick:e=>{E().push((0,S.g)({route:"/liquidity/position/[[...positionId]]",routeParam
29s:{positionId:[e.protocol,e.poolId]},searchParams:{chain:C.RW[t.chainId],[I.hy]:"1"}}))}})]}):(0,i.jsx)(Q.p,{})};var J=n(673384),ee=n(968349);let et=function(e,t,n,l,m,v,y,g,A,b){var w,k,R,E;let M=arguments.length>10&&void 0!==arguments[10]?arguments[10]:1,N=arguments.length>11&&void 0!==arguments[11]&&arguments[11],{tickLower:P,tickUpper:T,liquidity:B}=e,D=n?o.eF.fromRawAmount(n.token0,J.AH.getToken0Amount(n.tickCurrent,P,T,n.sqrtRatioX96,B)):void 0,L=n?o.eF.fromRawAmount(n.token1,J.AH.getToken1Amount(n.tickCurrent,P,T,n.sqrtRatioX96,B)):void 0,O=D&&L&&l&&m?new f.g(D.toExact()).times(l).plus(new f.g(L.toExact()).times(m)).toNumber():0,_=(0,F.Mu)(e.tickSpacing),Y=(0,F.Kc)(e.tickLower,e.tickUpper,_),Z=(0,F.MU)(n,e.tickLower,e.tickUpper),H=(0,F.Ss)(e.liquidity),Q=(0,F.lN)(e.tickLower,e.tickUpper,t.token0,t.token1,n,Y,b,M),G=N?t.token1:t.token0,K=N?t.token0:t.token1,X=(0,i.jsx)(a.A,{flexDirection:"column",gap:"4px",children:(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsxs)(s.A,{bold:!0,fontSize:"16px",children:[null==G?void 0:G.symbol," / ",null==K?void 0:K.symbol," ",(0,i.jsxs)(s.A,{as:"span",color:"textSubtle",children:["#",e.tokenId.toString()]})]}),e.isStaked&&!H&&!Z&&(0,i.jsx)(d.A,{variant:"primary60",scale:"sm",px:"6px",children:y("Farming")}),H&&(0,i.jsx)(d.A,{variant:"tertiary",scale:"sm",px:"6px",children:y("Closed")})]})}),ee=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",children:(0,i.jsx)(U.z,{content:(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"8px",children:[(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:t.token0,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(w=t.token0)?void 0:w.symbol})]}),(0,i.jsx)(j.g3,{amount:D,fontSize:"14px",bold:!0,children:null!=(R=g(D,6))?R:"-"})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:D&&l?(0,$.o5)(new f.g(D.toExact()).times(l).toNumber()):"$0.00"})]}),(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:t.token1,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(k=t.token1)?void 0:k.symbol})]}),(0,i.jsx)(j.g3,{amount:L,fontSize:"14px",bold:!0,children:null!=(E=A(L,6))?E:"-"})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:L&&m?(0,$.o5)(new f.g(L.toExact()).times(m).toNumber()):"$0.00"})]})]}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",style:{cursor:"default"},children:(0,$.o5)(O)})})}),et=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",style:{cursor:"default"},children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",children:(0,i.jsx)(V.Hp,{tokenId:e.tokenId,chainId:t.chainId,poolId:t.poolId,currency0:t.token0,currency1:t.token1,tickLower:e.tickLower,tickUpper:e.tickUpper,positionClosed:H})})}),en=(0,F.Uz)((0,F.mf)(v)),ei=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",style:{cursor:"default"},children:(0,i.jsx)(U.z,{content:(0,i.jsx)(q.S,{combinedApr:en,lpFeeApr:Number(v.lpApr),cakeApr:v.cakeApr?{value:Number(v.cakeApr.value)}:void 0,merklApr:Number(v.merklApr)}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",color:en>0?"success":"text",children:(0,x.U)(en)})})}),er=(null==n?void 0:n.token0Price)!=null?String(parseFloat(n.token0Price.toSignificant(18))*M):void 0,el=(0,i.jsx)(W.F,{minPrice:Q.minPriceFormatted,maxPrice:Q.maxPriceFormatted,minPercentage:Q.minPercentage,maxPercentage:Q.maxPercentage,rangePosition:Q.rangePosition,outOfRange:Z,removed:H,currentPrice:Q.currentPrice||er,showPercentages:Q.showPercentages,minPriceRaw:Q.minPrice,maxPriceRaw:Q.maxPrice,currentPriceRaw:Q.currentPriceValue}),eo=(0,i.jsxs)(a.A,{gap:"8px",alignItems:"center",justifyContent:"flex-end",children:[(0,i.jsx)(z.r,{as:"a",href:(0,S.g)({route:"/liquidity/position/[[...positionId]]",routeParam
29s:{positionId:[r.Zs.InfinityCLAMM,Number(e.tokenId),"decrease"]},searchParams:{chain:C.RW[t.chainId],[I.hy]:"1"}}),disabled:H,isIcon:!0,onClick:e=>e.stopPropagation(),children:(0,i.jsx)(c.A,{})}),(0,i.jsx)(z.r,{as:"a",href:(0,S.g)({route:"/liquidity/position/[[...positionId]]",routeParams:{positionId:[r.Zs.InfinityCLAMM,Number(e.tokenId),"increase"]},searchParams:{chain:C.RW[t.chainId],[I.hy]:"1"}}),disabled:H,isIcon:!0,onClick:e=>e.stopPropagation(),children:(0,i.jsx)(p.A,{})})]});return{tokenId:e.tokenId.toString(),tableRow:{tokenInfo:X,liquidity:ee,earnings:et,apr:ei,priceRange:el,actions:eo,protocol:r.Zs.InfinityCLAMM,tokenId:e.tokenId},liquidityUSD:O,totalApr:en,aprData:v}},en=e=>{let{position:t,poolInfo:n,pool:i,price0Usd:r,price1Usd:o,flipCurrentPrice:a,isClassificationFlipped:s,onRowDataReady:d}=e,{t:u}=(0,l.A)(),c=(0,_.pe)(n,t),p=(0,M.useMemo)(()=>(0,F.mf)(c),[c]),m=(0,w.wG)(n.token0),x=(0,w.wG)(n.token1),h=(0,w.Ae)(n.token0,n.token1),f=(0,M.useMemo)(()=>et(t,n,i,r,o,p,u,m,x,a,h,s),[t,n,i,r,o,p,u,a,s,m,x,h]);return(0,M.useEffect)(()=>{d(f)},[f,d]),null},ei=e=>{let{poolInfo:t}=e,{account:n}=(0,ee.W7)(),r=(0,T.Vx)(),[l]=(0,B.$)(),{isFlipped:o}=(0,M.useMemo)(()=>t.token0&&t.token1?(0,D.SP)(t.token0,t.token1):{isFlipped:!1},[t.token0,t.token1]),a=l!==o,[,s]=(0,A.W)(t.poolId,r),{data:d}=(0,k.GB)(t.token0,{enabled:!!t.token0}),{data:u}=(0,k.GB)(t.token1,{enabled:!!t.token1}),[c,p]=(0,M.useState)(H.E.All),[x,h]=(0,M.useState)([]),{data:v,isLoading:b}=(0,N.mP)(r,n,t),{data:w}=(0,O.I)(),j=(0,M.useCallback)(e=>{h(t=>t.find(t=>t.tokenId===e.tokenId)?t.map(t=>t.tokenId===e.tokenId?e:t):[...t,e])},[]);(0,M.useEffect)(()=>{h(e=>{if(!v)return e;let t=new Set(v.map(e=>e.tokenId.toString())),n=e.filter(e=>t.has(e.tokenId));return n.length===v.length,n})},[v]);let R=(0,M.useMemo)(()=>v?v.map(e=>(0,i.jsx)(en,{position:e,poolInfo:t,pool:s,price0Usd:d,price1Usd:u,flipCurrentPrice:a,isClassificationFlipped:o,onRowDataReady:j},e.tokenId.toString())):[],[v,t,s,d,u,a,o,j]),P=(0,M.useMemo)(()=>{if(!x)return[];let e=e=>{let{totalApr:t,liquidityUSD:n}=e,i=n>0;return i&&t>0?1:i&&0===t?2:i?4:3};return x.toSorted((t,n)=>{let i=e(t),r=e(n);if(i!==r)return i-r;let l=t.liquidityUSD;return n.liquidityUSD>l?1:-1}).filter(e=>{let{totalApr:t,liquidityUSD:n}=e,i=n>0;switch(c){case H.E.Active:return i&&t>0;case H.E.Inactive:return i&&0===t;case H.E.Closed:return!i;default:return!0}})},[x,c]),{data:{rewardsUSD:U}}=(0,g.wA)({poolId:t.poolId,chainId:t.chainId,address:n,timestamp:y()().startOf("hour").unix()}),[q,_]=(0,M.useMemo)(()=>x.reduce((e,t)=>{let{numerator:n,denominator:i}=(0,F.mf)(t.aprData);return n.isZero()?e:[e[0].plus(n),e[1].plus(i)]},[m.AH,m.AH]),[x]),$=(0,M.useMemo)(()=>_.isZero()?0:q.div(_).toNumber(),[q,_]),Y=(0,M.useMemo)(()=>w||[],[w]),z=(0,M.useMemo)(()=>(null==P?void 0:P.map(e=>e.tableRow))||[],[P]),V=(0,M.useMemo)(()=>(null==P?void 0:P.reduce((e,t)=>e+(t.liquidityUSD||0),0))||0,[P]);return b?(0,i.jsx)(Q.B,{}):v&&0!==v.length?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Z.X,{poolInfo:t,totalLiquidityUSD:V,totalEarnings:(0,F.Su)(U),totalApr:$,data:z,showInactiveOnly:c===H.E.Inactive,toggleInactiveOnly:()=>p(c===H.E.Inactive?H.E.All:H.E.Inactive),harvestAllButton:(0,i.jsx)(L.v,{positionList:Y,showPositionFees:!1,chainId:t.chainId}),onRowClick:e=>{E().push((0,S.g)({route:"/liquidity/position/[[...positionId]]",routeParams:{positionId:[e.protocol,new f.g(e.tokenId).toNumber()]},searchParams:{chain:C.RW[t.chainId],[I.hy]:"1"}}))}}),R]}):(0,i.jsx)(Q.p,{})};var er=n(334404),el=n(227883),eo=n(389512),ea=n(974134),es=n(323641),ed=n(282692),eu=n(930013),ec=n(427896);let ep=e=>{var t,n;let{poolInfo:o,v2OrStableData:d,harvestAllButton:m}=e,{t:f}=(0,l.A)(),v=(0,M.useMemo)(()=>d.nativeDeposited0.add(d.farmingDeposited0),[d.nativeDeposited0,d.farmingDeposited0]),y=(0,M.useMemo)(()=>d.nativeDeposited1.add(d.farmingDeposited1),[d.nativeDeposited1,d.farmingDeposited1]),{data:g}=(0,k.GB)(null==(t=o.token0)?void 0:t.wrapped,{enabled:v.greaterThan(0)}),{data:A}=(0,k.GB)(null==(n=o.token1)?void 0:n.wrapped,{enabled:y.greaterThan(0)}),b=(0,w.wG)(o.token0),S=(0,w.wG)(o.token1),R=(0,_.mi)(o,d),{earningsBusd:N}=(0,es._L)(o),P=(0,M.useMemo)(()=>{var e,t,n,l,m,w;let k=(0,F.T0)(d.nativeDeposited0,d.nativeDeposited1,d.farmingDeposited0,d.farmingDeposited1,g,A),M=Number(v.toExact())*(null!=g?g:0),N=Number(y.toExact())*(null!=A?A:0),{base:P,quote:T}=o.token0&&o.token1?(0,D.SP)(o.token0,o.token1):{base:o.token0,quote:o.token1},B=(0,i.jsx)(a.A,{flexDirection:"column",gap:"4px",children:(0,i.jsxs)(s.A,{bold:!0,fontSize:"16px",children:[null==P?void 0:P.symbol," / ",null==T?void 0:T.symbol]})}),L=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",children:(0,i.jsx)(U.z,{content:(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",ga
29p:"8px",children:[(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:o.token0,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(e=o.token0)?void 0:e.symbol})]}),(0,i.jsx)(j.g3,{amount:v,fontSize:"14px",bold:!0,children:null!=(m=b(v,6))?m:"-"})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,$.o5)(M)})]}),(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:o.token1,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(t=o.token1)?void 0:t.symbol})]}),(0,i.jsx)(j.g3,{amount:y,fontSize:"14px",bold:!0,children:null!=(w=S(y,6))?w:"-"})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:(0,$.o5)(N)})]})]}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",style:{cursor:"default"},children:(0,$.o5)(k)})})}),O=(0,F.Uz)((0,F.mf)(R)),_=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",style:{cursor:"default"},children:(0,i.jsx)(U.z,{content:(0,i.jsx)(q.S,{combinedApr:O,lpFeeApr:Number(R.lpApr),cakeApr:R.cakeApr?{value:Number(R.cakeApr.value)}:void 0,merklApr:Number(R.merklApr)}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",color:O>0?"success":"text",children:(0,x.U)(O)})})}),Y=null==(n=o.token0)?void 0:n.wrapped.address,V=null==(l=o.token1)?void 0:l.wrapped.address,Z="v2"===o.protocol?"/v2":"/stable",W=`chain=${C.RW[o.chainId]}&${[I.hy]}=1`,H=`${Z}/add/${Y}/${V}?increase=1&${W}`,Q=`${Z}/remove/${Y}/${V}?${W}`,G=`/v2/migrate/${o.lpAddress}?${W}`,K=`/infinityStable/add/${o.poolId}?${W}`,X=`/infinityStable/remove/${o.poolId}?${W}`;return{tableRow:{tokenInfo:B,liquidity:L,apr:_,actions:(0,i.jsx)(ec.L,{children:(0,i.jsxs)(a.A,{gap:"8px",alignItems:"center",justifyContent:"flex-end",children:[(0,i.jsx)(z.r,{isIcon:!0,onClick:()=>{o.protocol===r.Zs.InfinitySTABLE?E().push(X):E().push(Q)},children:(0,i.jsx)(c.A,{})}),(0,i.jsx)(z.r,{isIcon:!0,onClick:()=>{o.protocol===r.Zs.InfinitySTABLE?E().push(K):E().push(H)},children:(0,i.jsx)(p.A,{})}),"v2"===o.protocol&&eu.v1.includes(o.chainId)&&(0,i.jsx)(z.r,{onClick:()=>E().push(G),children:f("Migrate")})]})})},liquidityUSD:k,totalApr:O}},[d,o,R,f,g,A,b,S,v,y]);return(0,i.jsx)(Z.X,{poolInfo:o,totalLiquidityUSD:P.liquidityUSD,totalApr:P.totalApr,totalEarnings:(0,F.Su)(N),data:[P.tableRow],harvestAllButton:m,onRowClick:()=>{var e,t;let n=null==(e=o.token0)?void 0:e.wrapped.address,i=null==(t=o.token1)?void 0:t.wrapped.address,l="v2"===o.protocol?`/v2/pair/${n}/${i}`:`/${o.protocol===r.Zs.InfinitySTABLE?"infinityStable":"stable"}/${o.lpAddress}`,a=`${l}?chain=${C.RW[o.chainId]}&${[I.hy]}=1`;E().push(a)}})},em=e=>{let{poolInfo:t}=e,{t:n}=(0,l.A)(),{address:r}=(0,Y.F)(),o=(0,T.Vx)(),{toastSuccess:a}=(0,er.d)(),{fetchWithCatchTxError:s,loading:d}=(0,eo.A)(),{switchNetworkIfNecessary:u,isLoading:c}=(0,ea.Hk)(),{data:p,isLoading:m}=(0,N.mP)(o,r,t),{onHarvest:x}=(0,ed.F)(t.lpAddress,t.bCakeWrapperAddress),{earningsBusd:h,hasEarnings:f,isLoading:v}=(0,es._L)(t),y=(0,M.useCallback)(async()=>{if(!d&&x&&h&&!await u(o))try{let e=await s(()=>x());(null==e?void 0:e.status)&&a(`${n("Harvested")}!`,(0,i.jsx)(el.G,{txHash:e.transactionHash,children:n("Your %symbol% earnings have been sent to your wallet!",{symbol:"CAKE"})}))}catch(e){console.error(e)}},[d,x,h,u,o,s,a,n]);if(m)return(0,i.jsx)(Q.B,{});if(!p)return(0,i.jsx)(Q.p,{});let g=(0,i.jsx)(z.v,{onClick:y,disabled:d||v||c||!f,children:d?n("Harvesting..."):n("Harvest All")});return(0,i.jsx)(ep,{poolInfo:t,v2OrStableData:p,harvestAllButton:g})};var ex=n(428089),eh=n(456194),ef=n(650176),ev=n(366028),ey=n(182063),eg=n(197504),eA=n(670420),eb=n(131619),ew=n(70619),ej=n(483547),ek=n(524261),eC=n(207014);let eI=e=>{let{position:t,poolInfo:n,liquidityUSD:r}=e,{quote:l,base:o,priceUpper:s,priceLower:d,tickAtLimit:u,removed:m,outOfRange:x,position:h}=(0,N.ck)(t),f=null==h?void 0:h.amount0,v=null==h?void 0:h.amount1,{data:y}=(0,N.cO)([n.chainId]),[g]=(0,N.nW)(n),A=(0,ev.o)(g),b=(0,M.useMemo)(()=>null==y?void 0:y[n.chainId],[y,n.chainId]),w=(0,M.useMemo)(()=>null==n?void 0:n.pid,[n]),j=(0,M.useMemo)(()=>"0X"!==A&&(!b||!w||w<=b),[w,b,A]),k=(0,M.useMemo)(()=>o&&l?(0,i.jsx)(ex.Ay,{mt:"8px",children:(0,i.jsx)(ew.pr,{base:o,quote:l,priceLower:d,priceUpper:s,tickAtLimit:u})}):null,[o,l,d,s,u]);return(0,i.jsxs)(a.A,{gap:"8px",alignItems:"center",justifyContent:"flex-end",children:[(!j&&!t.isStaked||m)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(z.r,{as:"a",href:`/remove/${t.tokenId.toString()}?chain=${C.RW[n.chainId]}&${[I.hy]}=1`,disabled:m,isIcon:!0,onClick:e=>e.stopPropagation(),children:(0,i.jsx)(c.A,{})}),(0,i.jsx)(z.r,{as:"a",href:`/increase/${(0,ey.V)(n.token0.wrapped)}/${(0,ey.V)(n.token1.wrapped)}/${n.feeTier.toString()}/${t.tokenId.toString()}?chain=${C.RW[n.chainId]}&${[I.hy]}=1`,disabled:m,isIcon:!0,onClick:e=>e.stopPropagation(),children:(0,i.jsx)(p.A,{})})]}),(0,i.jsx)(ej.A,{chainId:n.chainId,isStaked:t.isStaked,isFarmLive:j,removed:m,outOfRange:x,tokenId:t.tokenId,detailMode:!0,modalContent:(0,i.jsx)(ek.B,{chainId:n.chainId,userPosition:t,link:`/liquidity/${t.tokenId}?chain=${C.RW[n.chainId]}&${[I.hy]}=1`,pool:n,totalPriceUSD:r,desc:k,amount0:f,amount1:v,currency0:n.token0,currency1:n.token1,removed:m,outOfRange:x,fee:t.fee,feeTierBase:1e6,protocol:t.protocol,isStaked:t.isStaked,tokenId:t.tokenId,detailMode:!1})})]})},eS=e=>{let{position:t,poolInfo:n,positionsData:r,price0Usd:o,price1Usd:c,pool:p,onRowDataReady:v,flipCurrentPrice:y,isClassificationFlipped:g}=e,{t:A}=(0,l.A)(),b=(0,_.jr)(n,t),j=(0,w.Li)(n.token0.wrapped),k=(0,w.Li)(n.token1.wrapped),C=(0,w.Ae)(n.token0.wrapped,n.token1.wrapped),I=(0,M.useMemo)(()=>(0,F.mf)(b),[b]),S=(0,M.useMemo)(()=>((e,t,n,r,l,o,c,p,v,y,g,A,b)=>{var w,j,k,C,I,S,R,E;let M=null==n?void 0:n.find(t=>Number(t.tokenId)===Number(e.tokenId)),N=0,P=m.AH,T=m.AH;if(e.liquidity>0n&&o)try{let{tickCurrent:n}=o,i=J.AH.getToken0Amount(n,e.tickLower,e.tickUpper,o.sqrtRatioX96,e.liquidity),a=J.AH.getToken1Amount(n,e.tickLower,e.tickUpper,o.sqrtRatioX96,e.liquidity);P=new f.g(i.toString()).div(10**((null==(I=t.token0.wrapped)?void 0:I.decimals)||18)),T=new f.g(a.toString()).div(10**((null==(S=t.token1.wrapped)?void 0:S.decimals)||18)),r&&l&&(N=P.times(r).plus(T.times(l)).toNumber())}catch(e){console.error("Manual liquidity calculation failed:",e)}let B=(0,F.MU)(o,e.tickLower,e.tickUpper),D=(0,F.Ss)(e.liquidity),L=!!e.isStaked,O=(0,F.jC)(o,t.feeTier),_=(0,F.Mu)(O),Y=(0,F.Kc)(e.tickLower,e.tickUpper,_),z=(0,F.lN)(e.tickLower,e.tickUpper,t.token0.wrapped,t.token1.wrapped,o,Y,v,b);if(M&&!z.showPercentages)try{let e=parseFloat(M.token0PriceLower.toFixed(18)),t=parseFloat(M.token0PriceUpper.toFixed(18));if(v){let n=1/t,i=1/e;e=n,t=i}let n=v?1/b:b;if(1!==n&&(Number.isFinite(e)&&(e*=n),Number.isFinite(t)&&(t*=n)),Number.isFinite(e)&&Number.isFinite(t)){let i=(0,eh.e)(e,{notation:"standard"})||"-",r=(0,eh.e)(t,{notation:"standard"})||"-",l="",a="",s=50,d=!1;if((null==o?void 0:o.token0Price)&&t>e){let i;if(i=v?o.token1Price||(null==(E=o.token0Price)||null==(R=E.invert)?void 0:R.call(E)):o.token0Price){let r=parseFloat(i.toFixed(18))*n;if(r>0&&Number.isFinite(r)){let n=(e-r)/r*100,i=(t-r)/r*100;Number.isFinite(n)&&Number.isFinite(i)&&1e4>Math.abs(n)&&1e4>Math.abs(i)&&(l=(0,F.Ee)(n),a=(0,F.Ee)(i),s=Math.max(0,Math.min(100,(r-e)/(t-e)*100)),d=!0)}}}z={minPriceFormatted:i,maxPriceFormatted:r,minPercentage:l,maxPercentage:a,rangePosition:s,showPercentages:d,currentPrice:z.currentPrice}}}catch(e){console.warn("Position data price calculation error:",e)}let Z=y?t.token1:t.token0,H=y?t.token0:t.token1,Q=(0,i.jsx)(a.A,{flexDirection:"column",gap:"4px",children:(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsxs)(s.A,{bold:!0,fontSize:"16px",children:[null==(w=Z.wrapped)?void 0:w.symbol," / ",null==(j=H.wrapped)?void 0:j.symbol," ",(0,i.jsxs)(s.A,{as:"span",color:"textSubtle",children:["#",e.tokenId.toString()]})]}),L&&!D&&!B&&(0,i.jsx)(d.A,{variant:"primary60",scale:"sm",px:"6px",children:p("Farming")}),D&&(0,i.jsx)(d.A,{variant:"tertiary",scale:"sm",px:"6px",children:p("Closed")})]})}),G=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",children:(0,i.jsx)(U.z,{content:(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",ga
29p:"8px",children:[(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:t.token0.wrapped,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(k=t.token0.wrapped)?void 0:k.symbol})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,eh.e)(P.times(g).toNumber())})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:P&&r?(0,$.o5)(P.times(r).toNumber()):"$0.00"})]}),(0,i.jsxs)(a.A,{flexDirection:"column",alignItems:"flex-start",gap:"2px",width:"100%",children:[(0,i.jsxs)(a.A,{alignItems:"center",justifyContent:"space-between",width:"100%",gap:"16px",children:[(0,i.jsxs)(a.A,{alignItems:"center",gap:"8px",children:[(0,i.jsx)(h.Z,{currency:t.token1.wrapped,size:"16px",mb:"-3px"}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:null==(C=t.token1.wrapped)?void 0:C.symbol})]}),(0,i.jsx)(s.A,{fontSize:"14px",bold:!0,children:(0,eh.e)(T.times(A).toNumber())})]}),(0,i.jsx)(s.A,{color:"textSubtle",fontSize:"12px",textAlign:"right",width:"100%",children:T&&l?(0,$.o5)(T.times(l).toNumber()):"$0.00"})]})]}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",style:{cursor:"default"},children:(0,$.o5)(N)})})}),K=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",style:{cursor:"default"},children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",children:(0,i.jsx)(V.di,{tokenId:e.tokenId,chainId:t.chainId,pool:o,currency0:t.token0,currency1:t.token1,positionClosed:D})})}),X=(0,F.Uz)((0,F.mf)(c)),ee=(0,i.jsx)(u.A,{flexDirection:"column",alignItems:"flex-start",style:{cursor:"default"},children:(0,i.jsx)(U.z,{content:(0,i.jsx)(q.S,{combinedApr:X,lpFeeApr:Number(c.lpApr),cakeApr:c.cakeApr?{value:Number(c.cakeApr.value)}:void 0,merklApr:Number(c.merklApr)}),children:(0,i.jsx)(s.A,{bold:!0,fontSize:"16px",color:X>0?"success":"text",children:(0,x.U)(X)})})}),et=(null==o?void 0:o.token0Price)!=null?String(parseFloat(o.token0Price.toFixed(18))*b):void 0,en=(0,i.jsx)(W.F,{minPrice:z.minPriceFormatted,maxPrice:z.maxPriceFormatted,minPercentage:z.minPercentage,maxPercentage:z.maxPercentage,rangePosition:z.rangePosition,outOfRange:B,removed:D,currentPrice:z.currentPrice||et,showPercentages:z.showPercentages,minPriceRaw:z.minPrice,maxPriceRaw:z.maxPrice,currentPriceRaw:z.currentPriceValue}),ei=(0,i.jsx)(eI,{position:e,poolInfo:t,liquidityUSD:N});return{tokenId:e.tokenId.toString(),tableRow:{tokenInfo:Q,liquidity:G,earnings:K,apr:ee,priceRange:en,actions:ei,protocol:e.protocol,tokenId:e.tokenId,liquidityUSD:N,isStaked:L},totalApr:X,liquidityUSD:N,aprData:c,isStaked:L}})(t,n,r,o,c,p,I,A,y,g,j,k,C),[t,n,r,o,c,p,I,A,y,g,j,k,C]);return(0,M.useEffect)(()=>{v(S)},[S,v]),null},eR=e=>{var t;let{poolInfo:n}=e,{t:r}=(0,l.A)(),{address:o}=(0,Y.F)(),a=(0,T.Vx)(),s=(0,eC.cC)(a),[d]=(0,B.$)(),{isFlipped:u}=(0,M.useMemo)(()=>n.token0&&n.token1?(0,D.SP)(n.token0,n.token1):{isFlipped:!1},[n.token0,n.token1]),c=d!==u,[,p]=(0,ef.f$)(n.token0.wrapped,n.token1.wrapped,n.feeTier),{data:x,isLoading:h}=(0,N.mP)(a,o,n),f=(0,M.useMemo)(()=>null==x?void 0:x.filter(e=>0n!==e.liquidity),[x]),v=(null!=(t=null==f?void 0:f.length)?t:0)>0,{data:y}=(0,k.GB)(n.token0.wrapped,{enabled:v}),{data:g}=(0,k.GB)(n.token1.wrapped,{enabled:v}),[A,b]=(0,M.useState)(H.E.All),[w,j]=(0,M.useState)([]),S=((e,t,n,i,r)=>{let l=(0,eb.G2)(t,e),o=(0,eb.G2)(n,e),a=l?(0,eA.U$)(l):void 0,s=o?(0,eA.U$)(o):void 0,[,d]=(0,ef.f$)(null!=a?a:void 0,null!=s?s:void 0,i);return(0,M.useMemo)(()=>d&&r&&r.length>0?r.map(e=>new J.yX({pool:d,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})):[],[d,r])})(a,n.token0.wrapped.address,n.token1.wrapped.address,n.feeTier,f),[R,P]=(0,M.useState)(!1),{earningsBusd:U,hasEarnings:q,isLoading:L}=(0,es.p$)(n),{switchNetworkIfNecessary:O,isLoading:_}=(0,ea.Hk)(),{onHarvestAll:$}=(0,eg.V)(),V=(0,M.useCallback)(async()=>{if(!R&&$&&x&&!await O(a))try{P(!0);let e=null==x?void 0:x.filter(e=>e.isStaked).map(e=>e.tokenId.toString());await $(e),P(!1)}catch(e){console.error(e),P(!1)}},[R,P,a,O,$,x]),W=(0,M.useCallback)(e=>{j(t=>t.find(t=>t.tokenId===e.tokenId)?t.map(t=>t.tokenId===e.tokenId?e:t):[...t,e])},[]);(0,M.useEffect)(()=>{j(e=>{if(!x)return e;let t=new Set(x.map(e=>e.tokenId.toString())),n=e.filter(e=>t.has(e.tokenId));return n.length===x.length,n})},[x]);let G=(0,M.useMemo)(()=>x&&S?x.map(e=>(0,i.jsx)(eS,{position:e,poolInfo:n,positionsData:S,price0Usd:y,price1Usd:g,pool:p,onRowDataReady:W,flipCurrentPrice:c,isClassificationFlipped:u},e.tokenId.toString())):[],[x,n,S,y,g,p,W,c,u]),K=(0,M.useMemo)(()=>
29{if(!w)return[];let e=e=>{let{totalApr:t,liquidityUSD:n,isStaked:i}=e,r=n>0;return r&&t>0&&i?1:r&&t>0?2:r&&0===t&&i?3:r&&0===t?4:r?6:5};return w.toSorted((t,n)=>{let i=e(t),r=e(n);if(i!==r)return i-r;let l=t.liquidityUSD;return n.liquidityUSD>l?1:-1}).filter(e=>{let{totalApr:t,liquidityUSD:n}=e,i=n>0;switch(A){case H.E.Active:return i&&t>0;case H.E.Inactive:return i&&0===t;case H.E.Closed:return!i;default:return!0}})},[w,A]),[X,ee]=(0,M.useMemo)(()=>w.reduce((e,t)=>{let{numerator:n,denominator:i}=(0,F.mf)(t.aprData);return n.isZero()?e:[e[0].plus(n),e[1].plus(i)]},[m.AH,m.AH]),[w]),et=(0,M.useMemo)(()=>ee.isZero()?0:X.div(ee).toNumber(),[X,ee]);return h?(0,i.jsx)(Q.B,{}):x&&0!==x.length?(0,i.jsxs)(i.Fragment,{children:[G,(0,i.jsx)(Z.X,{poolInfo:n,totalLiquidityUSD:K.reduce((e,t)=>e+t.liquidityUSD,0),totalApr:et,totalEarnings:(0,F.Su)(U),data:K.map(e=>e.tableRow),showInactiveOnly:A===H.E.Inactive,toggleInactiveOnly:()=>b(A===H.E.Inactive?H.E.All:H.E.Inactive),harvestAllButton:(0,i.jsx)(z.v,{onClick:V,disabled:R||L||_||!(s&&"0x"!==s)||!q,children:r(R?"Harvesting...":"Harvest All")}),onRowClick:e=>{E().push(`/liquidity/${e.tokenId}?chain=${C.RW[a]}&${I.hy}=1`)}})]}):(0,i.jsx)(Q.p,{})};n(213694)},660582:(e,t,n)=>{"use strict";n.d(t,{g:()=>i.g});var i=n(420248)},668637:(e,t,n)=>{"use strict";n.d(t,{A:()=>ef});var i=n(350979),r=n(228876),l=n(769932),o=n(966983),a=n(226464),s=n(575058),d=n(428089),u=n(605641),c=n(673115),p=n(494570),m=n(847085),x=n(888178),h=n(680797),f=n(670420),v=n(311560);let y={ath:new v.GH(r.nU.BASE,"0xd9DC8D2B0497C38999dd743A6aDdBe4e83DE8aF6",18,"ATH","Aethir Token","")},g={pokemoney:new v.GH(r.nU.BSC,"0x32ff5b4C3B1744F0344D96fA2f87799Ed2805749",18,"PMY","Pokemoney Coin",""),free:new v.GH(r.nU.BSC,"0x880BCe9321c79cAc1D290De6d31DDE722C606165",8,"FREE","Freedom Protocol Token",""),safemoon:new v.GH(r.nU.BSC,"0x8076C74C5e3F5852037F31Ff0093Eeb8c8ADd8D3",9,"SAFEMOON","Safemoon Token","https://safemoon.net/"),gala:new v.GH(r.nU.BSC,"0x7dDEE176F665cD201F93eEDE625770E2fD911990",18,"GALA","pTokens GALA","https://games.gala.com/"),xcad:new v.GH(r.nU.BSC,"0x431e0cD023a32532BF3969CddFc002c00E98429d",18,"XCAD","Chainport.io-Peg XCAD Token","https://xcadnetwork.com/"),lusd:new v.GH(r.nU.BSC,"0x23e8a70534308a4AAF76fb8C32ec13d17a3BD89e",18,"lUSD","lUSD","https://linear.finance/"),nfp:new v.GH(r.nU.BSC,"0x75E8ddB518bB757b4282cd5b83bb70d4101D12FB",18,"NFP","NFPrompt Token","https://nfprompt.io/"),pundiai:new v.GH(r.nU.BSC,"0x67AA700Ab0110Cc52bf7F308fe25068E87a0f581",18,"PUNDIAI","PundiAI Token","https://twitter.com/PundiAI"),town:new v.GH(r.nU.BSC,"0x973253D0C12366e0fA5AFb9F9E2e9486ECA69c01",18,"TOWN","Alt.town")},{alETH:A}=f.E8,{bondly:b,itam:w,ccar:j,bttold:k,abnbc:C,metis:I,gain:S}=f.x_,{pokemoney:R,free:E,safemoon:M,gala:N,xcad:P,lusd:T,nfp:U,pundiai:B,town:D}=g,{usdPlus:F}=f.ne,{ath:q}=y,L={[r.nU.ETHEREUM]:{alETH:A},[r.nU.BSC]:{safemoon:M,bondly:b,itam:w,ccar:j,bttold:k,pokemoney:R,free:E,gala:N,abnbc:C,xcad:P,metis:I,lusd:T,nfp:U,pundiai:B,gain:S,town:D},[r.nU.ZKSYNC]:{usdPlus:F},[r.nU.BASE]:{ath:q}},{ath:O}=L[r.nU.BASE],_={[O.address]:{symbol:O.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(d.Ay,{maxWidth:"380px",children:(0,i.jsx)(u.A,{children:e("Warning: The $ATH token pool is not a valid token trading pair - please stop buying")})})},{})}};var $=n(430586),Y=n(421770),z=n(25963);let{safemoon:V,bondly:Z,itam:W,ccar:H,bttold:Q,pokemoney:G,free:K,gala:X,abnbc:J,xcad:ee,metis:et,lusd:en,nfp:ei,pundiai:er,gain:el,town:eo}=L[r.nU.BSC],ea={[V.address]:{symbol:V.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(d.Ay,{maxWidth:"380px",children:(0,i.jsx)(u.A,{children:(0,i.jsx)(Y.x,{i18nKey:"SAFEMOON has been migrated to <0>a new contract address.</0> Trading on the old address may result in the complete loss of your assets. For more information please refer to <1>Safemoon's announcement</1>.",components:[(0,i.jsx)(c.A,{style:{display:"inline"},external:!0,href:"https://bscscan.com/address/0x42981d0bfbAf196529376EE702F2a9Eb9092fcB5"}),(0,i.jsx)(c.A,{style:{display:"inline"},external:!0,href:"https://twitter.com/safemoon/status/1477770592031887360"})]})})})},{})}
29,[Z.address]:{symbol:Z.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(u.A,{children:e("Warning: BONDLY has been compromised. Please remove liquidity until further notice.")})},{})},[W.address]:{symbol:W.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(d.Ay,{maxWidth:"380px",children:(0,i.jsx)(u.A,{children:(0,i.jsx)(Y.x,{i18nKey:"ITAM has been rebranded as ITAM CUBE. <0>Please proceed to ITAM bridge to conduct a one-way swap of your ITAM tokens.</0> All transfers of the old ITAM token will be disabled after the swap.",components:[(0,i.jsx)(c.A,{style:{display:"inline"},external:!0,href:"https://itam.network/swap"})]})})})},{})},[H.address]:{symbol:H.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(d.Ay,{maxWidth:"380px",children:(0,i.jsx)(u.A,{children:(0,i.jsx)(Y.x,{i18nKey:"Crypto Cars (CCAR) has been migrated to <0>a new contract address.</0> Trading on the old address may result in the complete loss of your assets. For more information please refer to <1>the announcement.</1>",components:[(0,i.jsx)(c.A,{style:{display:"inline"},external:!0,href:"https://bscscan.com/token/0x322e5015Cc464Ada7f99dE7131CE494dE1834396"}),(0,i.jsx)(c.A,{style:{display:"inline"},external:!0,href:"https://t.me/Crypto_Cars_Official/465037"})]})})})},{})},[Q.address]:{symbol:Q.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("Please note that this is the old BTT token, which has been swapped to the new BTT tokens in the following ratio:")}),(0,i.jsx)(u.A,{children:"1 BTT (OLD) = 1,000 BTT (NEW)"}),(0,i.jsx)(u.A,{mb:"8px",children:(0,i.jsx)(Y.x,{i18nKey:"Trade the new BTT token <0>here</0>",components:[(0,i.jsx)(c.A,{style:{display:"inline"},href:"/swap?outputCurrency=0x352Cb5E19b12FC216548a2677bD0fce83BaE434B"})]})}),(0,i.jsx)($.A,{href:"https://medium.com/@BitTorrent/tutorial-how-to-swap-bttold-to-btt-453264d7142",children:e("For more details on the swap, please refer here.")})]})},{})},[G.address]:{symbol:G.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(u.A,{children:e("Suspicious rugpull token")})})},{})},[K.address]:{symbol:K.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(d.Ay,{maxWidth:"380px",children:(0,i.jsx)(u.A,{children:e("Risk Warning: This token is subject to high price risk. Please do your own research before trading this token. Please also note that as of 24 June 2022 there is also a reflection fee for every transfer of FREE ranging from 2.5 to 5% per trade/transfer.")})})},{})},[X.address]:{symbol:X.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("Warning: The pGALA token pool is not a valid token trading pair - please stop buying.")}),(0,i.jsx)($.A,{href:"https://twitter.com/pNetworkDeFi/status/1588266897061031936",children:e("For more info, please see pGALAâs twitter.")})]})},{})},[J.address]:{symbol:J.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("Warning: aBNB token from Ankr has been exploited. Please proceed with caution. We do not recommend users to trade the token.")}),(0,i.jsx)($.A,{href:"https://twitter.com/ankr/status/1598503332477280256",children:e("Learn More")})]})},{})},[ee.address]:{symbol:ee.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(d.Ay,{maxWidth:"380px",children:(0,i.jsxs)(u.A,{children:[e("XCAD is now using a new bridge provider and has migrated to a new XCAD token on BSC."),(0,i.jsx)("br",{}),e("You can obtain the new token either by swapping your old tokens on PancakeSwap or bridging them to ETH and back to BSC using the new bridge provider."),(0,i.jsx)("br",{}),(0,i.jsx)(Y.x,{i18nKey:"For more info, click <0>here</0>",components:[(0,i.jsx)(c.A,{style:{display:"inline"},external:!0,href:"https://blog.xcadnetwork.com/xcad-network-bsc-token-migration-wormhole-partnership-3c73aaabe4ba"})]}),(0,i.jsx)("br",{}),(0,i.jsxs)(c.A,{external:!0,href:"https://bscscan.com/token/0xa026ad2ceda16ca5fc28fd3c72f99e2c332c8a26",children:[e("New token contract address"),"."]})]})})},{})}
29,[et.address]:{symbol:et.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("Caution - METIS Token")}),(0,i.jsx)(u.A,{children:(0,i.jsx)(Y.x,{i18nKey:"Please exercise due caution when trading / providing liquidity for the METIS token. The protocol was recently affected by the <0>PolyNetwork Exploit.</0> For more information, please refer to MetisDAOâs <1>Twitter</1>",components:[(0,i.jsx)(c.A,{external:!0,m:"0 4px",style:{display:"inline"},href:"https://twitter.com/MetisDAO/status/1676431481621676032"}),(0,i.jsx)(c.A,{external:!0,ml:"4px",style:{display:"inline"},href:"https://twitter.com/MetisDAO"})]})})]})},{})},[en.address]:{symbol:en.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("Caution - lUSD Token")}),(0,i.jsx)(u.A,{children:(0,i.jsx)(Y.x,{i18nKey:"Please exercise due caution when trading or providing liquidity for the lUSD token. The protocol was recently affected by an <0>exploit.</0> For more information, please refer to Linear Financeâs <1>Twitter</1>",components:[(0,i.jsx)(c.A,{external:!0,style:{display:"inline"},href:"https://twitter.com/LinearFinance/status/1704818417880936535"}),(0,i.jsx)(c.A,{external:!0,ml:"4px",style:{display:"inline"},href:"https://twitter.com/LinearFinance"})]})})]})},{})},[ei.address]:{symbol:ei.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("The NFP token has recently experienced an exploit. Please refrain from swapping NFP until further notice. More information can be found on the project's twitter page.")}),(0,i.jsx)($.A,{href:"https://twitter.com/nfprompt/status/1768558658697433464?s=20",children:e("twitter page")})]})},{})},[er.address]:{symbol:er.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("Caution - PUNDIAI Token")}),(0,i.jsxs)(u.A,{children:[e("Please exercise due caution when trading / providing liquidity for the PUNDIAI token. The protocol recently encountered a security compromise. For more information, please refer to PundiAIâs"),(0,i.jsx)(c.A,{external:!0,ml:"4px",style:{display:"inline"},href:"https://twitter.com/PundiAI",children:e("Twitter")})]})]})},{})},[el.address]:{symbol:el.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:e("Caution - GAIN Token")}),(0,i.jsx)(u.A,{children:(0,i.jsx)(Y.x,{i18nKey:"Please exercise due caution when trading / providing liquidity for the GAIN token. The protocol recently encountered a <0>security compromise.</0> For more information, please refer to <1>GriffinAI X</1>",components:[(0,i.jsx)(c.A,{external:!0,m:"0 4px",style:{display:"inline"},href:"https://x.com/Griffin_AI/status/1971049192245047677"}),(0,i.jsx)(c.A,{external:!0,ml:"4px",style:{display:"inline"},href:"https://x.com/Griffin_AI"})]})})]})},{})},[eo.address]:{symbol:eo.symbol,component:(0,i.jsx)(e=>{let{token:t,statusHref:n,profileHref:r}=e,{t:o}=(0,l.A)(),a=(0,z.useMemo)(()=>[(0,i.jsx)(c.A,{external:!0,m:"0 4px",style:{display:"inline"},href:n}),(0,i.jsx)(c.A,{external:!0,ml:"4px",style:{display:"inline"},href:r})],[n,r]);return(0,i.jsxs)(d.Ay,{maxWidth:"380px",children:[(0,i.jsx)(u.A,{children:o("Caution - %symbol% Token",{symbol:t.symbol})}),(0,i.jsx)(u.A,{children:(0,i.jsx)(Y.x,{i18nTemplate:"Please exercise due caution when trading / providing liquidity for the %symbol% token. The protocol recently encountered a <0>security compromise.</0> For more information, please refer to <1>%name% X</1>",values:{symbol:t.symbol,name:t.name},components:a})})]})},{token:eo,statusHref:"https://x.com/alttownofficial/status/1972853816652710317",profileHref:"https://x.com/AlttownOfficial"})}},{alETH:es}=L[r.nU.ETHEREUM],ed={[es.address]:{symbol:es.symbol,component:(0,i.jsx)(()=>{let{t:e}=(0,l.A)();return(0,i.jsx)(d.Ay,{maxWidth:"380px",children:(0,i.jsx)(Y.x,{i18nKey:"Please exercise due caution when trading / providing liquidity for the alETH token. The protocol was recently affected by the <0>Curve exploit.</0> For more information, please refer to Alchemixâs <1>Twitter</1> and await further updates from the team",components:[(0,i.jsx)(c.A,{external:!0,m:"0 4px",style:{display:"inline"},href:"https://twitter.com/CurveFinance/status/1685925429041917952"}),(0,i.jsx)(c.A,{external:!0,m:"0 4px",style:{display:"inline"},href:"https://twitter.com/AlchemixFi/status/1685737632133971968"})]})})},{})}};var eu=n(590429);let{usdPlus:ec}
29=L[r.nU.ZKSYNC],ep={[ec.address]:{symbol:ec.symbol,component:(0,i.jsx)(eu.A,{})}},em=(0,h.I4)(o.Bs).withConfig({componentId:"sc-dc6f1bcd-0"})(["max-width:440px;"]),ex=(0,h.I4)(a.A).withConfig({componentId:"sc-dc6f1bcd-1"})(["align-items:flex-start;justify-content:flex-start;"]),eh={[r.nU.ETHEREUM]:ed,[r.nU.BSC]:ea,[r.nU.ZKSYNC]:ep,[r.nU.BASE]:_,[r.nU.ARBITRUM_ONE]:{}},ef=e=>{var t,n;let{swapCurrency:a,title:h,reason:f,source:v,onDismiss:y,onAcknowledge:g}=e,{t:A}=(0,l.A)(),{theme:b}=(0,x.Ay)();if(!a)return null;let{chainId:w}=a,j=w?null==eh||null==(t=eh[w])?void 0:t[a.address]:void 0,k=(null==j?void 0:j.symbol)||(null==a?void 0:a.symbol)||A("this token"),C=h||A("Notice for trading %symbol%",{symbol:k});return(0,i.jsxs)(em,{minWidth:"280px",children:[(0,i.jsx)(o.rQ,{background:b.colors.gradientCardHeader,children:(0,i.jsx)(s.A,{p:"12px 24px",children:C})}),(0,i.jsxs)(o.cw,{p:"24px",children:[(0,i.jsx)(ex,{variant:"warning",mb:"24px",children:(0,i.jsx)(d.Ay,{children:null!=(n=null==j?void 0:j.component)?n:(0,i.jsx)(i.Fragment,{children:"thirdParty"===v?(0,i.jsxs)(d.Ay,{children:[(0,i.jsx)(u.A,{mb:"8px",children:A("This token has been flagged by a third-party risk scanner. Please do your own research and proceed with caution.")}),(0,i.jsxs)(u.A,{children:[A("Result provided by")," ",(0,i.jsx)(c.A,{external:!0,color:"primary60",style:{display:"inline"},href:"https://www.hashdit.io/",children:"HashDit"}),w===r.nU.BSC?(0,i.jsxs)(i.Fragment,{children:[" ","/"," ",(0,i.jsx)(c.A,{external:!0,color:"primary60",style:{display:"inline"},href:`https://dappbay.bnbchain.org/risk-scanner/${a.address}`,children:A("Get more details from RedAlarm")})]}):null]})]}):f?(0,i.jsx)(d.Ay,{children:(0,i.jsx)(p.A,{components:{p:e=>{let{children:t}=e;return(0,i.jsx)(u.A,{children:t})},a:e=>{let{href:t,children:n}=e;return(0,i.jsx)(c.A,{href:t,external:!0,color:"primary60",style:{display:"inline"},target:"_blank",rel:"noopener noreferrer",children:n})}},children:f})}):(0,i.jsx)(u.A,{children:A("This token has been flagged as high risk. Please do your own research and proceed with caution.")})})})}),(0,i.jsx)(m.z,{handleContinueClick:()=>{null==g||g(),null==y||y()}})]})]})}},671449:(e,t,n)=>{"use strict";n.d(t,{cD:()=>d,mi:()=>u,yK:()=>s});var i=n(350979),r=n(769932),l=n(979332),o=n(29545),a=n(427548);function s(e){let{poolAddress:t}=e,{t:n}=(0,r.A)(),{hasMerkl:o}=(0,a.VB)(t);return o?(0,i.jsx)(l.A,{ml:"8px",outline:!0,variant:"warning",children:n("Merkl")}):null}function d(e){let{poolAddress:t}=e,{t:n}=(0,r.A)(),{hasMerkl:l}=(0,a.VB)(t);return l?(0,i.jsx)(o.lh,{ml:"8px",variant:"warning",children:n("Merkl")}):null}function u(e){let{poolAddress:t}=e,{t:n}=(0,r.A)(),{hasMerkl:o}=(0,a.VB)(t);return o?(0,i.jsx)(l.A,{variant:"warning",mr:"8px",outline:!0,children:n("Merkl Rewards")}):null}},676334:(e,t,n)=>{var i=n(686740),r=n(888432),l=n(685892),o=n(233312),a=n(486821);e.exports=function(e,t,n){var s=o(e)?i:r;return n&&a(e,t,n)&&(t=void 0),s(e,l(t,3))}},681941:(e,t,n)=>{"use strict";n.d(t,{I:()=>i});let i=e=>{var t;return(null==e||null==(t=e.adapter)?void 0:t.name)==="SquadsX"}},686740:e=>{e.exports=function(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;
29)if(!t(e[n],n,e))return!1;return!0}},698612:(e,t,n)=>{"use strict";n.d(t,{Y:()=>i.Y});var i=n(550062)},701150:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i.Z,k:()=>r.k0});var i=n(38395),r=n(53847)},704784:(e,t,n)=>{"use strict";n.d(t,{U:()=>q});var i=n(350979),r=n(659197),l=n(179087),o=n(769932),a=n(796898),s=n(979332),d=n(24153),u=n(893001),c=n(605641),p=n(995315),m=n(990296),x=n(378385),h=n(823585),f=n(420248),v=n(769193),y=n(737982),g=n(671449),A=n(573271),b=n(450253),w=n.n(b),j=n(402861),k=n(956586),C=n(687287),I=n(810286),S=n(25963),R=n(810498),E=n(323641),M=n(517024),N=n(17581),P=n(762971),T=n(228876),U=n(807718),B=n(944715),D=n(21354),F=n(977418);let q=(0,S.memo)(e=>{var t,n;let{t:x}=(0,o.A)(),{theme:b}=(0,l.DP)(),{isMobile:w,isTablet:j}=(0,a.A)(),{currency0:E,currency1:M,removed:N,outOfRange:q,desc:L,tokenId:z,fee:V,feeTierBase:Z,isStaked:W,protocol:H,totalPriceUSD:Q,amount0:G,amount1:K,pool:X,poolId:J,userPosition:ee,detailMode:et,showAPR:en=!0,miniMode:ei=j||w,chainId:er,disableFixedTags:el}=e,eo=(0,k.R4)(er,(0,R.T)(H)?null==X?void 0:X.poolId:void 0),ea=(0,C.Wu)(G,6),es=(0,C.Wu)(K,6),ed=(0,S.useMemo)(()=>(0,i.jsxs)(i.Fragment,{children:[((0,R.T)(H)||(0,T.fT)(er)?W&&!q&&!N:W)&&(0,i.jsx)(s.A,{variant:"primary60",children:x("Farming")}),![r.Zs.STABLE,r.Zs.V2].includes(H)&&(0,i.jsx)(A.K,{lowContrast:!0,removed:N,outOfRange:q,protocol:H}),(0,i.jsx)(g.yK,{poolAddress:null==X?void 0:X.lpAddress}),(0,i.jsx)(P.f0,{poolAddress:null==X?void 0:X.lpAddress})]}),[x,er,H,W,q,N,null==X?void 0:X.lpAddress]),eu=(0,S.useMemo)(()=>ei?(0,i.jsxs)(D.CT,{$isMobile:!0,children:[(0,i.jsxs)(d.fI,{gap:"8px",flexWrap:"wrap",children:[(0,i.jsx)(f.g,{size:24,currency0:E,currency1:M,showChainLogoCurrency1:!0}),(0,R.T)(H)?(0,i.jsx)(y.Eu,{poolId:null==X?void 0:X.poolId,chainId:er,hookData:eo,infoIconVisible:!1}):(0,i.jsx)(u.T,{type:H,fee:V,dynamic:null==X?void 0:X.isDynamicFee,denominator:Z}),(0,i.jsxs)(d.fI,{children:[((0,R.T)(H)?W&&!q&&!N:W)&&(0,i.jsx)(s.A,{variant:"primary60",mr:"8px",children:x("Farming")}),![r.Zs.STABLE,r.Zs.V2].includes(H)&&(0,i.jsx)(A.K,{lowContrast:!0,removed:N,outOfRange:q,protocol:H}),(0,i.jsx)(g.yK,{poolAddress:null==X?void 0:X.lpAddress}),(0,i.jsx)(P.f0,{poolAddress:null==X?void 0:X.lpAddress})]})]}),(0,i.jsxs)(d.fI,{children:[(0,i.jsx)(c.A,{bold:!0,children:`${null==E?void 0:E.symbol} / ${null==M?void 0:M.symbol} LP`}),z?(0,i.jsxs)(c.A,{color:"textSubtle",children:["(#",z.toString(),")"]}):null]})]}):(0,i.jsx)(D.CT,{children:(0,i.jsxs)(p.A,{flexWrap:"wrap",gap:"8px",justifyContent:"space-between",width:"100%",children:[(0,i.jsxs)(p.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(U.G,{json:e,children:(0,i.jsx)(c.A,{bold:!0,children:`${null==E?void 0:E.symbol} / ${null==M?void 0:M.symbol} LP`})}),z?(0,i.jsxs)(c.A,{color:"textSubtle",children:["(#",z.toString(),")"]}):null,(0,R.T)(H)?(0,i.jsx)(y.Eu,{poolId:null==X?void 0:X.poolId,chainId:er,hookData:eo}):(0,i.jsx)(u.T,{type:H,fee:V,denominator:Z})]}),el?(0,i.jsx)(p.A,{gap:"8px",flexWrap:"wrap",children:ed}):(0,i.jsx)(D.p9,{gap:"8px",children:ed})]})}),[w,er,ei,Z,E,M,V,W,q,H,N,x,z,X,ed,el,eo]),ec=(0,S.useMemo)(()=>X?ee?X.protocol===r.Zs.V3?er===T.Cb.SOLANA?(0,i.jsx)(B.uu,{pool:X,userPosition:ee,textProps:{bold:!0}}):(0,i.jsx)(B._o,{pool:X,userPosition:ee}):X.protocol===r.Zs.InfinityCLAMM?(0,i.jsx)(B.UB,{pool:X,userPosition:ee}):X.protocol===r.Zs.InfinityBIN?(0,i.jsx)(B.IV,{pool:X,userPosition:ee}):(0,i.jsx)(B.xo,{pool:X,userPosition:ee}):(0,i.jsx)(B.rr,{pool:X,detailMode:et}):(0,i.jsx)(m.Ay,{width:60}),[er,et,X,ee]);return(0,i.jsxs)(i.Fragment,{children:[eu,(0,i.jsxs)(D.X3,{children:[L,(0,i.jsx)(d.fI,{gap:"sm",children:N||G&&K?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v.u,{prefix:"~",value:Q,style:{color:b.colors.textSubtle,fontSize:"12px"},showFullDigitsTooltip:!1}),(0,i.jsxs)(c.A,{as:"span",color:"textSubtle",fontSize:"12px",children:["(",(0,i.jsx)(I.g3,{amount:G,as:"span",children:(0,h.ZV)(null!=ea?ea:"0")})," ",null!=(t=null==G?void 0:G.currency.symbol)?t:"-"," /"," ",(0,i.jsx)(I.g3,{amount:K,as:"span",children:(0,h.ZV)(null!=es?es:"0")})," ",null!=(n=null==K?void 0:K.currency.symbol)?n:"-",")"]})]}):(0,i.jsx)(m.Ay,{width:80})}),en&&(0,i.jsxs)(d.fI,{gap:"8px",children:[(0,i.jsx)(D.gI,{children:"APR: "}),ec]}),W?[r.Zs.STABLE,r.Zs.V2].includes(H)?(0,i.jsx)(O,{pool:X}):r.Zs.V3===H&&er&&(0,T.F8)(er)?(0,i.jsx)(_,{tokenId:z,chainId:er}):null:null,r.Zs.InfinityCLAMM===H?(0,i.jsx)(Y,{tokenId:z,chainId:er,poolId:J}):r.Zs.InfinityBIN===H?(0,i.jsx)($,{chainId:er,poolId:J}):null,r.Zs.V3===H&&er&&(0,T.fT)(er)?(0,i.jsx)(F.n,{pool:X,position:ee}):null]})]})}),L=e=>{let{earningsAmount:t=0,earningsBusd:n=0}=e,{t:r}=(0,o.A)();return t>0&&(0,i.jsx)(d.fI,{gap:"8px",children:(0,i.jsxs)(D.gI,{children:[r("CAKE earned"),": ",t," (~$",(0,x.ZV)(n),")"]})})},O=e=>{let{pool:t}=e,{earningsAmount:n,earningsBusd:r}=(0,E._L)(t);return(0,i.jsx)(L,{earningsAmount:n,earningsBusd:r})},_=e=>{let{tokenId:t,chainId:n}=e,{earningsAmount:r,earningsBusd:l}=(0,E.Ls)((0,S.useMemo)(()=>t?[t]:[],[t]),n);return(0,i.jsx)(L,{earningsAmount:r,earningsBusd:l})},$=e=>{let{chainId:t,poolId:n}=e,{address:r}=(0,N.F)(),{data:{rewardsAmount:l,rewardsUSD:o},isLoading:a}=(0,j.wA)({chainId:t,poolId:n,address:r,timestamp:w()().startOf("hour").unix()}),s=(0,S.useMemo)(()=>{var e,t;let n=Math.min(null!=(e=null==l?void 0:l.currency.decimals)?e:18,18);return Number(null!=(t=null==l?void 0:l.toFixed(n))?t:0)},[l]),[,d]=(0,M.J)();return(0,S.useEffect)(()=>{t&&n&&!a&&d(t,n,s)},[s,t,n,a,d]),(0,i.jsx)(L,{earningsAmount:s,earningsBusd:o})},Y=e=>{let{tokenId:t,chainId:n,poolId:r}=e,{address:l}=(0,N.F)(),{data:{rewardsAmount:o,rewardsUSD:a},isLoading:s}=(0,j.fG)({chainId:n,tokenId:t,poolId:r,address:l,timestamp:w()().startOf("hour").unix()}),d=(0,S.useMemo)(()=>{var e,t;let n=Math.min(null!=(e=null==o?void 0:o.currency.decimals)?e:18,18);return Number(null!=(t=null==o?void 0:o.toFixed(n))?t:0)},[o]),[,u]=(0,M.J)();return(0,S.useEffect)(()=>{n&&r&&t&&!s&&u(n,r,t,d)},[d,n,r,t,s,u]),(0,i.jsx)(L,{earningsAmount:d,earningsBusd:a})}}
29,706172:(e,t,n)=>{"use strict";n.d(t,{R:()=>j});var i=n(311560),r=n(555967),l=n(25963),o=n(782739),a=n(662928),s=n(45705),d=n(452301),u=n(228876),c=n(555242),p=n(660876),m=n(851374),x=n(300107),h=n.n(x),f=n(18468);let v=2n**128n-1n,y=(e,t,n,i)=>`${e}:${t}:${n}:${i}`,g=async(e,t,n,i,r)=>(await Promise.all(e.map(async e=>{let l=y(t,n,i,e.tokenId);try{let{result:t}=await r.simulateContract({address:n,abi:e.abi,functionName:"collect",args:[{tokenId:e.tokenId,recipient:i,amount0Max:v,amount1Max:v}],account:i}),[o,a]=t;return{key:l,value:{success:!0,amount0:o,amount1:a}}}catch{return{key:l,value:{success:!1,amount0:0n,amount1:0n}}}}))).reduce((e,t)=>(e[t.key]=t.value,e),{}),A=async(e,t,n,i,r)=>{let{abi:l}=e[0],o=e.map(e=>{let t,n;return t=e.abi,n=e.tokenId,(0,p.p)({abi:t,functionName:"collect",args:[{tokenId:n,recipient:i,amount0Max:v,amount1Max:v}]})}),a={};try{let{result:s}=await r.simulateContract({address:n,abi:l,functionName:"multicall",args:[o],account:i});return s.forEach((r,l)=>{let o=e[l],s=y(t,n,i,o.tokenId);try{let e=(0,m.e)({abi:o.abi,functionName:"collect",data:r});a[s]={success:!0,amount0:e[0],amount1:e[1]}}catch{a[s]={success:!1,amount0:0n,amount1:0n}}}),a}catch{return g(e,t,n,i,r)}},b=async e=>{let t=h()(e,e=>`${e.chainId}:${e.positionManagerAddress}:${e.owner}`);return(await Promise.all(Object.values(t).map(e=>{let{chainId:t,positionManagerAddress:n,owner:i}=e[0],r=(0,f.Rt)({chainId:t});return r?A(e,t,n,i,r):{}}))).reduce((e,t)=>Object.assign(e,t),{})},w=(0,c.vt)({fetcher:b,resolver:(e,t)=>e[y(t.chainId,t.positionManagerAddress,t.owner,t.tokenId)],scheduler:(0,c.On)({windowMs:60,maxBatchSize:25})});function j(e,t){var n;let c=arguments.length>2&&void 0!==arguments[2]&&arguments[2],p=!(arguments.length>3)||void 0===arguments[3]||arguments[3],m=null!=(n=null==e?void 0:e.chainId)?n:null==e?void 0:e.token0.chainId,x=(0,r.TA)({chainId:m}),h=(0,l.useMemo)(()=>t?[t]:void 0,[t]),{data:f}=(0,o.Qo)({abi:null==x?void 0:x.abi,address:null==x?void 0:x.address,functionName:"ownerOf",args:h,chainId:m,query:{enabled:!!(p&&m&&x&&void 0!==t)}}),v=(0,s.KT)(m),y=(0,l.useMemo)(()=>{if(!m)return!1;let e=u.vf[m];return"number"==typeof e&&e>3},[m]),{data:g}=(0,a.I)({queryKey:["v3PositionFees",m,null==x?void 0:x.address,f,null==t?void 0:t.toString(),v],queryFn:async()=>{if(!x||void 0===t||!f||!m)return;let e=await w.fetch({tokenId:t,owner:f,chainId:m,positionManagerAddress:x.address,abi:x.abi});if(!(null==e?void 0:e.success))throw console.error(`useV3PositionFees: collect() simulation failed for tokenId ${t}`),Error(`useV3PositionFees: collect() simulation failed for tokenId ${t}`);return[e.amount0,e.amount1]},enabled:!!(p&&x&&void 0!==t&&f&&m&&v),retry:!!y&&3,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1,gcTime:0,placeholderData:(e,n)=>{let i=null==n?void 0:n.queryKey;if(!i)return;let[,r,l,o,a]=i;if(r===m&&l===(null==x?void 0:x.address)&&o===f&&a===(null==t?void 0:t.toString()))return e}});return e&&g?[i.eF.fromRawAmount(c?e.token0:(0,d.U$)(e.token0),g[0].toString()),i.eF.fromRawAmount(c?e.token1:(0,d.U$)(e.token1),g[1].toString())]:[void 0,void 0]}},710102:(e,t,n)=>{"use strict";n.d(t,{h:()=>X,P:()=>J});var i=n(350979),r=n(179087),l=n(769932),o=n(827666),a=n(734658),s=n(796147),d=n(796259),u=n(501823),c=n(605641),p=n(557423),m=n(796898),x=n(312680),h=n(475690),f=n(807543),v=n(150591),y=n(24153),g=n(995315),A=n(28192),b=n(770773),w=n(494350),j=n(371309),k=n(955647),C=n(823585),I=n(242312),S=n.n(I),R=n(91168),E=n(18201),M=n(20897),N=n(619749),P=n(862373),T=n(25963),U=n(644919),B=n(638380),D=n(735167),F=n(152497),q=n(276348),L=n(142511),O=n(98378),_=n(59299),$=n(542160),Y=n(968349),z=n(427554),V=n(203907),Z=n(680797),W=n(241439),H=n(265394),Q=n(228876),G=n(655727),K=n(35075);let X=e=>{var t,n;let{pool:r,position:m,onClose:x}=e,{t:h}=(0,l.A)(),{solanaAccount:f}=(0,Y.W7)(),[v,y]=(0,T.useState)(["",""]),[g,A]=(0,T.useState)(!1),b=r.rawPool,w=(()=>{let e=(0,L.zl)(),{t}=(0,l.A)(),{computeBudgetConfig:n}=(0,D.a0)(),{executeSolanaTransaction:i,handleSolanaError:r}=(0,F.A)();return(0,T.useCallback)(async t=>{let{params:l,onSent:a,onError:s,onFinally:d,onConfirmed:u}=t,{poolInfo:c,position:p,liquidity:m,amountMaxA:x,amountMaxB:h}=l;if(!e||!p)return;let[f,v]=[new(S())(new R.A(x).multipliedBy(10**c.mintA.decimals).toFixed(0)),new(S())(new R.A(h).multipliedBy(10**c.mintB.decimals).toFixed(0))],{execute:y}=await e.clmm.increasePositionFromLiquidity({poolInfo:c,poolKeys:e.clmm.getClmmKeysFromPoolInfo(c),ownerPosition:p,ownerInfo:{useSOLBalance:!0},liquidity:m,amountMaxA:f,amountMaxB:v,checkCreateATAOwner:!0,computeBudgetConfig:n,txVersion:o.HqF.V0});return i(async()=>{try{let{txId:e,signedTx:t}=await y();return null==a||a(e),{hash:e}}catch(e){return r(e),null==s||s(e),{hash:""}}finally{null==d||d()}},()=>{let e=(0,q.U)(x),t=(0,q.U)(h);return{summary:`Add ${e} ${c.mintA.symbol} and ${t} ${c.mintB.symbol}`,type:"increase-liquidity-v3",translatableSummary:{text:"Add %amountA% %tokenASymbol% and %amountB% %tokenBSymbol%",data:{amountA:e,tokenASymbol:c.mintA.symbol,amountB:t,tokenBSymbol:c.mintB.symbol}}}})},[e,n,i,r])})(),j=(0,T.useMemo)(()=>(0,N.ph)((0,o.c8D)(b.mintA)),[b.mintA]),k=(0,T.useMemo)(()=>(0,N.ph)((0,o.c8D)(b.mintB)),[b.mintB]),C=(0,z.V)(j),I=(0,z.V)(k),M=(0,T.useMemo)(()=>(0,W.Z)(C),[C]),_=(0,T.useMemo)(()=>(0,W.Z)(I),[I]),[$,V]=(0,T.useMemo)(()=>f?[!!v[0]&&Number(M.toExact())<Number(v[0]),!!v[1]&&Number(_.toExact())<Number(v[1])]:[!1,!1],[v[0],v[1],f,M,_]),{amount0:Z,amount1:G,amount0Disabled:X,amount1Disabled:J}=(0,O.y)({poolInfo:b,tickLower:m.tickLower,tickUpper:m.tickUpper,liquidity:m.liquidity}),[en,er]=(0,T.useState)(null),{amount0:el,amount1:eo,amountSlippage0:ea,amountSlippage1:es,liquidity:ed}=(e=>{let{poolInfo:t,tickLower:n,tickUpper:i,side:r,amount:l}=e,s=(0,B.W)(),{data:d}=(0,U.H)(),[u]=(0,P.at)(),c=(0,T.useMemo)(()=>(0,N.ph)(null==t?void 0:t.mintA),[null==t?void 0:t.mintA]),p=(0,T.useMemo)(()=>(0,N.ph)(null==t?void 0:t.mintB),[null==t?void 0:t.mintB]);return(0,T.useMemo)(()=>
29{if(!t||!s||!d||null===r||!l)return{amount0:void 0,amountSlippage0:void 0,amount1:void 0,amountSlippage1:void 0,liquidity:void 0};try{let{amountA:e,amountSlippageA:s,amountB:m,amountSlippageB:x,liquidity:h}=o.QNe.getLiquidityAmountOutFromAmountIn({poolInfo:t,slippage:0,inputA:0===r,tickUpper:Math.max(n,i),tickLower:Math.min(n,i),amount:new(S())(new R.A(l).multipliedBy(10**(0===r?c.decimals:p.decimals)).toFixed(0)),add:!0,amountHasFee:!0,epochInfo:d});return{amount0:a.C3.fromRawAmount(c,e.amount.toString()),amountSlippage0:a.C3.fromRawAmount(c,s.amount.toString()).multiply(1e4+u).divide(1e4),amount1:a.C3.fromRawAmount(p,m.amount.toString()),amountSlippage1:a.C3.fromRawAmount(p,x.amount.toString()).multiply(1e4+u).divide(1e4),liquidity:h}}catch(e){return console.error("Liquidity calc failed:",e),{amount0:void 0,amountSlippage0:void 0,amount1:void 0,amountSlippage1:void 0,liquidity:void 0}}},[t,n,i,r,l,u,c,p])})({poolInfo:b,tickLower:m.tickLower,tickUpper:m.tickUpper,side:en,amount:null!==en?v[en]:"0"});(0,T.useEffect)(()=>{y(["",""]),A(!1)},[]),(0,T.useEffect)(()=>{if(null===en)return;let[e,t]=v;1===en&&(null==ea?void 0:ea.toExact())!==e&&y(e=>{var t;return[null!=(t=null==ea?void 0:ea.toExact())?t:"",e[1]]}),0===en&&(null==es?void 0:es.toExact())!==t&&y(e=>{var t;return[e[0],null!=(t=null==es?void 0:es.toExact())?t:""]})},[ea,es,v[0],v[1],en]);let eu=(0,T.useCallback)(async()=>{if(ed&&ea&&es){A(!0);try{await w({params:{poolInfo:b,position:m,liquidity:ed,amountMaxA:ea.toExact(),amountMaxB:es.toExact()},onSent:()=>{A(!1),y(["",""]),x()},onError:e=>{console.error("Add liquidity error:",e),A(!1)},onFinally:()=>{A(!1)}})}catch(e){console.error(e),A(!1)}}},[w,b,m,ed,ea,es,x]),ec=(0,T.useCallback)(e=>{e!==v[0]&&(y(t=>[e,t[1]]),er(0))},[v[0]]),ep=(0,T.useCallback)(e=>{e!==v[1]&&(y(t=>[t[0],e]),er(1))},[v[1]]);return(0,i.jsxs)(s.mm,{gap:"16px",children:[(0,i.jsx)(K.$,{poolInfo:b,currency0:j,currency1:k,position:m}),(0,i.jsx)(et,{poolInfo:b,position:m}
29),(0,i.jsx)(d.y,{textTransform:"uppercase",children:h("Amount of liquidity to add")}),(0,i.jsxs)(u.A,{justifyContent:"space-between",alignItems:"center",children:[(0,i.jsx)(c.A,{children:h("Slippage Tolerance")}),(0,i.jsx)(H.AE,{})]}),(0,i.jsxs)(ee,{gap:"0px",children:[(0,i.jsx)(E.A,{customChainId:Q.Cb.SOLANA,showUSDPrice:!0,currency:j,title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),wrapperProps:{backgroundColor:"cardSecondary"},id:"add-liquidity-input-tokena",showMaxButton:!0,error:$,disabled:X,disableCurrencySelect:!0,defaultValue:!m.liquidity.isZero()&&(null==Z?void 0:Z.equalTo(0))?"":null!=(t=v[0])?t:"0",onUserInput:ec,onPercentInput:e=>{var t,n;er(0),100===e?M&&ec(null!=(t=M.toExact())?t:""):ec(null!=(n=null==C?void 0:C.multiply(new a.QE(e,100)).toExact())?n:"")},maxAmount:C,onMax:()=>{if(M){var e;ec(null!=(e=M.toExact())?e:"")}}}),(0,i.jsx)("hr",{}),(0,i.jsx)(E.A,{title:(0,i.jsx)(i.Fragment,{children:"\xa0"}),customChainId:Q.Cb.SOLANA,showUSDPrice:!0,currency:k,wrapperProps:{backgroundColor:"cardSecondary"},id:"add-liquidity-input-tokenb",showMaxButton:!0,error:V,disabled:J,disableCurrencySelect:!0,defaultValue:!m.liquidity.isZero()&&(null==G?void 0:G.equalTo(0))?"":null!=(n=v[1])?n:"0",onUserInput:ep,onPercentInput:e=>{var t,n;er(1),100===e?_&&ep(null!=(t=_.toExact())?t:""):ep(null!=(n=null==I?void 0:I.multiply(new a.QE(e,100)).toExact())?n:"")},maxAmount:I,onMax:()=>{if(_){var e;ep(null!=(e=_.toExact())?e:"")}}})]}),(0,i.jsx)(ei,{poolInfo:b,position:m,liquidityAdd:ed,amount0Add:0===en?el:ea,amount1Add:1===en?eo:es}),(0,i.jsx)(p.A,{width:"100%",disabled:!ed||ed.isZero()||$||V,isLoading:g,onClick:eu,children:h($||V?"Insufficient Balance":g?"Confirming...":"Add")})]})},J=e=>{let{isOpen:t,onClose:n,pool:r,position:o}=e,{t:a}=(0,l.A)(),{isMobile:s}=(0,m.A)();return(0,i.jsx)(x.aF,{isOpen:t,onDismiss:n,closeOnOverlayClick:!0,children:(0,i.jsx)(h.Ay,{title:a("Add Liquidity"),minWidth:[null,null,"500px"],headerPadding:"12px 24px",headerBorderColor:"transparent",bodyPadding:s?"0 16px 16px":"0 24px 24px",onDismiss:n,children:(0,i.jsx)(X,{pool:r,position:o,onClose:n})})})},ee=(0,Z.Ay)(s.mm).withConfig({componentId:"sc-65e40257-0"})(["background-color:",";border:1px solid ",";border-radius:24px;padding:16px;hr{height:1px;width:calc(100% + 32px);border:none;background-color:",";margin-left:-16px;margin-top:16px;margin-bottom:0;}"],e=>{let{theme:t}=e;return t.colors.cardSecondary},e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.cardBorder}),et=e=>{let{poolInfo:t,position:n}=e,{theme:o}=(0,r.DP)(),{t:p}=(0,l.A)(),[m,x]=(0,T.useState)(!0),h=(0,T.useMemo)(()=>(0,N.ph)(null==t?void 0:t.mintA),[null==t?void 0:t.mintA]),w=(0,T.useMemo)(()=>(0,N.ph)(null==t?void 0:t.mintB),[null==t?void 0:t.mintB]),j=(0,T.useMemo)(()=>{if(!h||!w||!t)return;let e=a.gm.fromDecimal(h,w,new R.A(t.price.toString()).toFixed());return m?e:null==e?void 0:e.invert()},[h,w,t,m]),{ratio0:I,ratio1:E}=(0,O.R)({poolInfo:t,tickLower:n.tickLower,tickUpper:n.tickUpper,liquidity:new(S())(1e4)}),M=(0,$.Q)({poolInfo:t,tickLower:n.tickLower,tickUpper:n.tickUpper,baseIn:m});return(0,i.jsx)(f.A,{background:o.colors.cardSecondary,children:(0,i.jsx)(v.A,{children:(0,i.jsxs)(s.mm,{gap:"8px",children:[(0,i.jsx)(d.y,{textTransform:"uppercase",children:`${p("price range")} (${p("Min")}-${p("Max")})`}),(0,i.jsx)(u.A,{alignItems:"center",justifyContent:"center",children:(0,i.jsx)(G.F9,{outOfRange:n.status===V.$.INACTIVE,currentPrice:M.currentPrice,minPrice:M.minPriceFormatted,maxPrice:M.maxPriceFormatted,minPercentage:M.minPercentage,maxPercentage:M.maxPercentage,rangePosition:M.rangePosition,showPercentages:M.showPercentages,maxWidth:n.status===V.$.INACTIVE?"80%":"100%",minPriceRaw:M.minPrice,maxPriceRaw:M.maxPrice,currentPriceRaw:M.currentPriceValue})}),(0,i.jsxs)(y.JA,{flexWrap:"wrap",style:{gap:"4px"},children:[(0,i.jsxs)(c.A,{fontSize:"14px",color:"textSubtle",children:[p("Current Price"),":"]}),(0,i.jsxs)(g.A,{gap:"8px",alignItems:"center",children:[(0,i.jsxs)(c.A,{fontSize:"14px",style:{wordBreak:"break-all"},children:[j?(0,C.ZV)(j.toSignificant(18),{maximumDecimalTrailingZeroes:4}):"-"," "]}),(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:(0,i.jsxs)(u.A,{alignItems:"center",children:[p("of %quote% per %base%",{quote:m?t.mintB.symbol:t.mintA.symbol,base:m?t.mintA.symbol:t.mintB.symbol}),(0,i.jsx)(A.A,{variant:"text",scale:"xs",children:(0,i.jsx)(b.A,{color:"textSubtle",ml:"2px",onClick:()=>x(!m)})})]})})]})]}),I&&E&&(0,i.jsxs)(y.JA,{flexWrap:"wrap",style:{gap:"4px"},children:[(0,i.jsxs)(c.A,{fontSize:"14px",color:"textSubtle",children:[p("Deposit Ratio"),":"]}),(0,i.jsx)(g.A,{gap:"8px",alignItems:"center",children:(0,i.jsxs)(c.A,{fontSize:"14px",children:[`${(0,k.l9)(I,2)}% ${t.mintA.symbol}`," /"," ",`${(0,k.l9)(E,2)}% ${t.mintB.symbol}`]})})]})]})})})},en=e=>{let{from:t,to:n}=e;return(0,i.jsxs)(g.A,{gap:"8px",children:[t,n&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(w.A,{color:"textSubtle"}),n]})]})},ei=e=>{var t,n,o,a,u,p;let{poolInfo:m,position:x,liquidityAdd:h,amount0Add:A,amount1Add:b}=e,{theme:w}=(0,r.DP)(),{t:k}=(0,l.A)(),I=(0,T.useMemo)(()=>(0,N.ph)(null==m?void 0:m.mintA),[null==m?void 0:m.mintA]),S=(0,T.useMemo)(()=>(0,N.ph)(null==m?void 0:m.mintB),[null==m?void 0:m.mintB]),{amount0:R,amount1:E}=(0,O.y)({poolInfo:m,tickLower:x.tickLower,tickUpper:x.tickUpper,liquidity:x.liquidity}),{totalUsdValue:P}=(0,_.T)({poolInfo:m,tickLower:x.tickLower,tickUpper:x.tickUpper,liquidity:x.liquidity}),{totalUsdValue:U}=(0,_.T)({poolInfo:m,tickLower:x.tickLower,tickUpper:x.tickUpper,liquidity:h});return(0,i.jsx)(f.A,{background:w.colors.cardSecondary,children:(0,i.jsx)(v.A,{children:(0,i.jsxs)(s.mm,{gap:"8px",children:[(0,i.jsxs)(y.JA,{children:[(0,i.jsx)(d.y,{textTransform:"uppercase",children:k("Position")}),(0,i.jsx)(en,{from:(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:k("Current")}),to:h?(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:k("New Balance")}):void 0})]}),(0,i.jsxs)(y.JA,{children:[(0,i.jsxs)(g.A,{gap:"8px",children:[(0,i.jsx)(j.A,{srcs:(0,M.ig)(I),sizes:"xs",width:24,height:24,style:{borderRadius:"50%"}}),(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:I.symbol})]}),(0,i.jsx)(en,{from:(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:(0,C.ZV)(null!=(t=null==R?void 0:R.toExact())?t:0)}),to:A&&R?(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:(0,C.ZV)(null!=(n=A.add(R).toExact())?n:0)}):void 0})]}),(0,i.jsxs)(y.JA,{children:[(0,i.jsxs)(g.A,{gap:"8px",children:[(0,i.jsx)(j.A,{srcs:(0,M.ig)(S),sizes:"xs",width:24,height:24,style:{borderRadius:"50%"}}),(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:S.symbol})]}),(0,i.jsx)(en,{from:(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:(0,C.ZV)(null!=(o=null==E?void 0:E.toExact())?o:0)}),to:b&&E?(0,i.jsx)(c.A,{fontSize:"14px",color:"textSubtle",children:(0,C.ZV)(null!=(a=b.add(E).toExact())?a:0)}):void 0})]}),(0,i.jsxs)(y.JA,{children:[(0,i.jsx)(d.y,{textTransform:"uppercase",children:k("total position value (USD)")}),(0,i.jsx)(en,{from:(0,i.jsxs)(c.A,{fontSize:"14px",color:"textSubtle",children:["~$",(0,C.ZV)(null!=(u=null==P?void 0:P.toNumber())?u:0)]}),to:U&&P?(0,i.jsxs)(c.A,{fontSize:"14px",color:"textSubtle",children:["~$",(0,C.ZV)(null!=(p=U.plus(P).toNumber())?p:0)]}):void 0})]})]})})})}},719186:(e,t,n)=>{"use strict";n.d(t,{E:()=>c});var i=n(25963),r=n(662928),l=n(827666),o=n(206284);let a=new Map;var s=n(311560);let d="https://sol-explorer.pancakeswap.com/api/cached/v1/tokens/birdeye/defi/multi_price",u=async e=>{let[t,n]=e,i=await fetch(`${t}?list_address=${n}`);if(!i.ok)throw Error("Failed to fetch Birdeye price");return i.json()},c=e=>{let{mintList:t,refreshInterval:n=12e4,enabled:c=!0}=e||{},p=(0,i.useMemo)(()=>Array.from(new Set(t.filter(e=>!!e&&(e=>{if(!e)return!1;let t=e.toString();if(a.has(t))return!0;try{return new o.PublicKey(t),!0}catch{return!1}})(e)).map(e=>(0,s.hY)(e).toString()))),[t]),m=p.length>0&&c,{data:x,isLoading:h,error:f,...v}=(0,r.I)({queryKey:[d,p.join(",")],queryFn:()=>u([d,p.join(",")]),enabled:m,refetchInterval:n,staleTime:n,refetchOnWindowFocus:!1}),y=!h&&!(x&&!f);return(null==x?void 0:x.data)&&(null==x?void 0:x.success)&&(x.data[o.PublicKey.default.toBase58()]=x.data[l.o9_.toBase58()]),{data:(null==x?void 0:x.success)?null==x?void 0:x.data:{},isLoading:h,error:f,isEmptyResult:y,...v}}},721407:(e,t,n)=>{"use strict";n.d(t,{Q:()=>r});var i=n(131117);function r(e,t){let n=(0,i.a)(e,null==t?void 0:t.in);return n.setMinutes(0,0,0),n}},726837:(e,t,n)=>{"use strict";n.d(t,{Q:()=>c});var i=n(27313),r=n(737358),l=n(74716),o=n(25963),a=n(975701),s=n(17581),d=n(318050),u=n(341305);function c(e={}){let{query:t={},...n}=e,p=(0,u.U)(n),m=(0,i.jE)(),{address:x,connector:h,status:f}=(0,s.F)({config:p}),v=(0,d.i)({config:p}),y=e.connector??h,{queryKey:g,...A}=function(e,t={}){return{gcTime:0,async queryFn({queryKey:n}){let{connector:i}=t,{connectorUid:l,scopeKey:o,...a}=n[1];return(0,r.r)(e,{...a,connector:i})},queryKey:function(e={}){let{connector:t,...n}=e;return["connectorClient",{...(0,l.xO)(n),connectorUid:t?.uid}]}(t)}}(p,{...e,chainId:e.chainId??v,connector:y}),b=!!(("connected"===f||"reconnecting"===f&&y?.getProvider)&&(t.enabled??!0)),w=(0,o.useRef)(x);return(0,o.useEffect)(()=>{let e=w.current;!x&&e?(m.removeQueries({queryKey:g}),w.current=void 0):x!==e&&(m.invalidateQueries({queryKey:g}),w.current=x)},[x,m]),(0,a.IT)({...t,...A,queryKey:g,enabled:b,staleTime:1/0})}},727705:(e,t,n)=>{"use strict";n.d(t,{p:()=>b});var i=n(350979),r=n(273523),l=n(769932),o=n(549333),a=n(909114),s=n(728844),d=n(25963),u=n(252146),c=n(306411),p=n(733775),m=n(909725),x=n(207014),h=n(189346),f=n(975644),v=n(792118),y=n(522722),g=n(236088);let A=async(e,t,n,i,l,o,a,s,d,u)=>{var c;console.debug("debug removeLiquidity",t);let m=(0,r.I4)({poolKey:t.poolKey,amount0Min:t.amount0Min,amount1Min:t.amount1Min,ids:t.ids,amounts:t.amounts,from:l,hookData:t.hookData,recipient:l,wrapAddress:t.wrapAddress},t.deadline);null==(c=(0,v.Qr)({chainId:i}))||c.estimateGas({account:l,to:n,data:m}).then(t=>(null==s||s(!0),e({account:l,to:n,data:m,gas:(0,p.KL)(t),chainId:i,maxFeePerGas:d,maxPriorityFeePerGas:u}))).then(e=>{null==o||o(e)}).catch(e=>{null==a||a(e)})},b=(e,t,n,p)=>{let v=(0,c.OQ)(),[b,w]=(0,d.useState)(null),[j,k]=(0,d.useState)(!1),[C,I]=(0,d.useState)(),{t:S}=(0,l.A)(),R=(0,x.B4)("Bin",e),{sendTransactionAsync:E}=(0,g.s)(),{maxFeePerGas:M,maxPriorityFeePerGas:N}=(0,a.N)(e),[,P]=(0,u.r)(),{waitForTransaction:T}=(0,s.x)(e),U=(0,d.useId)(),[B]=(0,o.A)((0,i.jsx)(y.A,{title:S("Remove Liquidity"),subTitle:C}),!0,!0,`infinity-bin-remove-liquidity-error-modal-${U}`);return{removeLiquidity:(0,d.useCallback)(async i=>{if(!e||!t)return;let l=async e=>{w(e),v({hash:e},{type:"remove-liquidity-infinity-bin",summary:(0,m.V$)("Remove",i.amount0Desired,i.currency0,i.amount1Desired,i.currency1,`Remove liquidity from ${(0,r.Qn)(i.poolKey)}`)});let t=await T({hash:e});P({blockHash:t.blockHash,status:t.status}),null==k||k(!1),null==n||n(e)};await A(E,i,R,e,t,l,e=>{null==k||k(!1),console.error(e),(0,h.U)(e)||(I((0,f.w)(e,S)),B()),null==p||p(e)},k,M,N)},[P,R,E,e,t,T,n,v,p,S,M,N,B]),txHash:b,attemptingTx:j,txnErrorMessage:C}}},732269:(e,t,n)=>{"use strict";n.d(t,{F:()=>y});var i=n(350979),r=n(605641),l=n(995315),o=n(501823),a=n(680797);let s=a.Ay.div.withConfig({componentId:"sc-ae4a403b-0"})(["position:relative;width:100%;height:20px;
29display:flex;align-items:center;"]),d=a.Ay.div.withConfig({componentId:"sc-ae4a403b-1"})(["width:100%;height:6px;background:",";border-radius:4px;position:relative;"],e=>{let{theme:t,outOfRange:n,disabled:i}=e;return i?t.colors.disabled:n?t.colors.failure:t.colors.success}),u=a.Ay.div.withConfig({componentId:"sc-ae4a403b-2"})(["width:100%;height:6px;border-radius:4px;position:relative;display:flex;"]),c=a.Ay.div.withConfig({componentId:"sc-ae4a403b-3"})(["height:100%;background:",";"," &:first-child{border-radius:4px 0 0 4px;}&:last-child{border-radius:0 4px 4px 0;}&:only-child{border-radius:4px;}"],e=>{let{theme:t,isGray:n,outOfRange:i,disabled:r}=e;return r?t.colors.disabled:n?t.colors.tertiary:i?t.colors.failure:t.colors.success},e=>{let{width:t}=e;return`width: ${t}%;`}),p=a.Ay.div.withConfig({componentId:"sc-ae4a403b-4"})(["position:absolute;left:","%;top:-5px;transform:translateX(-50%);width:4px;height:16px;background:",";border-radius:3px;z-index:2;"],e=>{let{position:t}=e;return Math.max(0,Math.min(100,t))},e=>{let{theme:t,outOfRange:n,disabled:i,isOverflow:r}=e;return i?t.colors.disabled:r?t.colors.tertiary:n?t.colors.failure:t.colors.success}),m=a.Ay.div.withConfig({componentId:"sc-ae4a403b-5"})(["position:absolute;left:","%;top:-5px;transform:translateX(-50%);width:4px;height:16px;background:",";border-radius:3px;z-index:2;"],e=>{let{position:t}=e;return Math.max(0,Math.min(100,t))},e=>{let{theme:t,disabled:n}=e;return n?t.colors.disabled:t.colors.failure}),x=(0,a.Ay)(r.A).withConfig({componentId:"sc-ae4a403b-6"})(["color:",";font-size:12px;font-weight:400;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),h=a.Ay.div.withConfig({componentId:"sc-ae4a403b-7"})(["position:relative;width:100%;max-width:",";height:16px;margin-bottom:4px;margin-left:auto;margin-right:auto;.left-percentage{position:absolute;left:","%;transform:translateX(-50%);}.right-percentage{position:absolute;left:","%;transform:translateX(-50%);}"],e=>{let{$maxWidth:t}=e;return t},e=>{let{leftPosition:t}=e;return t},e=>{let{rightPosition:t}=e;return t}),f=a.Ay.div.withConfig({componentId:"sc-ae4a403b-8"})(["position:relative;width:100%;max-width:",";height:24px;margin-bottom:2px;margin-left:auto;margin-right:auto;.left-price{position:absolute;left:","%;transform:translateX(-40%);}.right-price{position:absolute;left:","%;transform:translateX(-50%);}"],e=>{let{$maxWidth:t}=e;return t},e=>{let{leftPosition:t}=e;return t},e=>{let{rightPosition:t}=e;return t}),v=a.Ay.div.withConfig({componentId:"sc-ae4a403b-9"})(["width:100%;max-width:",";margin-bottom:4px;margin-left:auto;margin-right:auto;"],e=>{let{$maxWidth:t}=e;return t}),y=e=>{let{minPrice:t,maxPrice:n,currentPrice:a,minPercentage:y,maxPercentage:g,rangePosition:A=50,outOfRange:b=!1,removed:w=!1,showPercentages:j=!0,maxWidth:k="190px",minPriceRaw:C,maxPriceRaw:I,currentPriceRaw:S}=e,R=null!=S?S:null,E=null!=C?C:NaN,M=null!=I?I:NaN,N=t,P=n;if(!Number.isNaN(E)&&!Number.isNaN(M)&&E>M){let e=E;E=M,M=e,N=n,P=t}let T=null!==R&&!Number.isNaN(E)&&!Number.isNaN(M)&&R<E,U=null!==R&&!Number.isNaN(E)&&!Number.isNaN(M)&&R>M,B=b&&(T||U),D=N,F=P;"0"===N?D="0":("-"===N||"NaN"===N||N.includes("NaN")||Number.isNaN(E))&&(D="-"),"â"===P||"Infinity"===P?F="â":("-"===P||"NaN"===P||P.includes("NaN")||Number.isNaN(M))&&(F="-");let q=A,L=0,O=100,_="-"!==D&&"-"!==F&&!Number.isNaN(E)&&!Number.isNaN(M)&&Number.isFinite(E)&&Number.isFinite(M),$=Math.min(D.length+F.length>12?D.length+F.length:0,40),Y=35+$,z=35+$;if(B&&_&&null!==R){if(T){let e=M-R;q=0;let t=(E-R)/e*100,n=100,i=100-t;if(i<Y){let e=(Y-i)/2;t=Math.max(0,t-e),n=Math.min(100,n+e),0===t?n=Math.min(100,t+Y):100===n&&(t=Math.max(0,n-Y))}L=t,O=n}if(U){let e=R-E;q=100;let t=0,n=(M-E)/e*100,i=n-0;if(i<Y){let e=(Y-i)/2;t=Math.max(0,t-e),n=Math.min(100,n+e),0===t?n=Math.min(100,t+Y):100===n&&(t=Math.max(0,n-Y))}L=t,O=n}}return(0,i.jsxs)(o.A,{flexDirection:"column",alignItems:"flex-start",width:"100%",children:[B?(0,i.jsxs)(f,{leftPosition:L,rightPosition:O,$maxWidth:k,children:[(0,i.jsx)("div",{className:"left-price",children:(0,i.jsx)(r.A,{fontSize:"16px",bold:!0,children:D})}),(0,i.jsx)("div",{className:"right-price",children:(0,i.jsx)(r.A,{fontSize:"16px",bold:!0,children:F})})]}):(0,i.jsx)(v,{$maxWidth:k,style:{marginBottom:"2px"},children:(0,i.jsx)(l.A,{alignItems:"center",gap:"8px",width:"100%",children:(0,i.jsxs)(o.A,{alignItems:"center",justifyContent:"space-between",width:"100%",children:[(0,i.jsx)(r.A,{fontSize:"16px",bold:!0,children:D}),(0,i.jsx)(r.A,{fontSize:"16px",bold:!0,children:"-"}),(0,i.jsx)(r.A,{fontSize:"16px",bold:!0,children:F})]})})}),(0,i.jsx)(v,{$maxWidth:k,children:(0,i.jsx)(s,{children:(()=>
29{if(!B)return(0,i.jsx)(d,{outOfRange:b,disabled:w,children:(0,i.jsx)(p,{position:q,outOfRange:b,disabled:w})});if(T){let e=M-R,t=(E-R)/e*100,n=(M-E)/e*100;return n<z&&(t=100-(n=z)),(0,i.jsxs)(u,{children:[(0,i.jsx)(c,{width:t,isGray:!0,disabled:w}),(0,i.jsx)(c,{width:n,outOfRange:b,disabled:w}),(0,i.jsx)(p,{position:q,outOfRange:b,disabled:w,isOverflow:B}),(0,i.jsx)(m,{position:t,disabled:w}),(0,i.jsx)(m,{position:100,disabled:w})]})}if(U){let e=R-E,t=(M-E)/e*100,n=(R-M)/e*100;return t<z&&(n=100-(t=z)),(0,i.jsxs)(u,{children:[(0,i.jsx)(c,{width:t,outOfRange:b,disabled:w}),(0,i.jsx)(c,{width:n,isGray:!0,disabled:w}),(0,i.jsx)(p,{position:q,outOfRange:b,disabled:w,isOverflow:B}),(0,i.jsx)(m,{position:0,disabled:w}),(0,i.jsx)(m,{position:t,disabled:w})]})}return null})()})}),j?B?(0,i.jsxs)(h,{leftPosition:L,rightPosition:O,$maxWidth:k,children:[(0,i.jsx)("div",{className:"left-percentage",children:(0,i.jsx)(x,{children:y})}),(0,i.jsx)("div",{className:"right-percentage",children:(0,i.jsx)(x,{children:g})})]}):(0,i.jsx)(v,{$maxWidth:k,children:(0,i.jsxs)(l.A,{alignItems:"center",justifyContent:"space-between",width:"100%",children:[(0,i.jsx)(x,{children:y}),(0,i.jsx)(x,{children:g})]})}):null]})}},736134:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});let i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{timeout:n=1e4,...i}=t;return Promise.race([fetch(e,i),new Promise((t,i)=>{setTimeout(()=>{i(Error(`Request for ${e} timed out after ${n} milliseconds`))},n)})])}},748469:(e,t,n)=>{"use strict";n.d(t,{X:()=>j});var i=n(350979),r=n(659197),l=n(769932),o=n(150591),a=n(428089),s=n(796898),d=n(995315),u=n(605641),c=n(253286),p=n(779243),m=n(796147),x=n(919968),h=n(53847),f=n(25963),v=n(680797),y=n(810498),g=n(112616);let A=(0,v.Ay)(o.A).withConfig({componentId:"sc-5d157303-0"})(["border-bottom:1px solid ",";"],e=>{let{theme:t}=e;return t.colors.cardBorder}),b=(0,v.Ay)(a.Ay).withConfig({componentId:"sc-5d157303-1"})(["padding:16px;transition:background 0.2s ease-in-out;&:not(:last-child){border-bottom:1px solid ",";}&:hover{background:",";}&:active{background:",";}"],e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.isDark?t.colors.backgroundDisabled:t.colors.backgroundHover},e=>{let{theme:t}=e;return t.colors.backgroundTapped}),w=[],j=e=>{let{poolInfo:t,totalLiquidityUSD:n,totalApr:o,showInactiveOnly:v,toggleInactiveOnly:j,harvestAllButton:k,totalEarnings:C,data:I,onRowClick:S,onlyFarmHarvest:R=!0}=e,{t:E}=(0,l.A)(),{isMobile:M,isTablet:N}=(0,s.A)(),P=M||N,T=(0,f.useCallback)(e=>e.tokenId,[]);if(!t)return null;let{protocol:U}=null!=t?t:{};return(0,i.jsxs)(h.R4,{padding:"0",borderRadius:"24px",children:[(0,i.jsx)(A,{children:(0,i.jsxs)(d.A,{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"16px",children:[(0,i.jsxs)(d.A,{gap:"32px",justifyContent:"space-between",width:P?"100%":null,children:[(0,i.jsxs)(a.Ay,{children:[(0,i.jsx)(u.A,{color:"textSubtle",children:E("Total Liquidity")}),(0,i.jsx)(u.A,{fontSize:"24px",bold:!0,children:(0,g.o5)(n)})]}),(0,i.jsxs)(a.Ay,{children:[(0,i.jsx)(u.A,{color:"textSubtle",children:E("Total APR")}),(0,i.jsx)(u.A,{fontSize:"24px",bold:!0,children:o?(0,x.U)(o):"-"})]})]}),(0,i.jsx)(h.k0,{padding:"8px 16px",width:P?"100%":"max-content",borderRadius:"24px",children:(0,i.jsxs)(d.A,{gap:"16px",alignItems:"center",justifyContent:"space-between",children:[(0,i.jsxs)(a.Ay,{children:[(0,i.jsx)(u.A,{color:"textSubtle",children:R?E("Total Farm Earnings"):E("Total Earnings")}
29),(0,i.jsx)(u.A,{fontSize:"24px",bold:!0,children:C||"-"})]}),k]})})]})}),P?(0,i.jsxs)(m.mm,{children:[!!j&&(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",padding:"16px",borderBottom:"1px solid",borderColor:"cardBorder",children:[(0,i.jsx)(u.A,{color:"textSubtle",children:E("Inactive Only")}),(0,i.jsx)(p.A,{checked:v,onChange:j,scale:"sm"})]}),I.map(e=>(0,i.jsxs)(b,{onClick:()=>null==S?void 0:S(e),style:{display:"flex",flexDirection:"column",gap:"24px"},children:[e.tokenInfo,(0,i.jsxs)(d.A,{gap:"4px",justifyContent:"space-between",alignItems:"center",children:[(0,i.jsxs)(a.Ay,{children:[(0,i.jsx)(u.A,{color:"textSubtle",children:E("APR")}),e.apr]}),(0,i.jsxs)(a.Ay,{children:[(0,i.jsx)(u.A,{color:"textSubtle",children:E("Liquidity")}),e.liquidity]}),U!==r.Zs.V2&&U!==r.Zs.STABLE&&(0,i.jsxs)(a.Ay,{children:[(0,i.jsx)(u.A,{color:"textSubtle",children:E("Earnings")}),e.earnings]})]}),((0,y.T)(U)||U===r.Zs.V3)&&e.priceRange,e.actions]},e.tokenId))]}):(0,i.jsx)(c.Q,{getRowKey:T,columns:[{title:(0,i.jsx)(i.Fragment,{children:!!j&&(0,i.jsxs)(d.A,{gap:"8px",alignItems:"center",children:[(0,i.jsx)(u.A,{color:"textSubtle",children:E("Inactive Only")}),(0,i.jsx)(p.A,{checked:v,onChange:j,scale:"sm"})]})}),dataIndex:"tokenInfo",key:"tokenInfo",render:e=>(0,i.jsx)("div",{children:e})},{title:E("Liquidity"),dataIndex:"liquidity",key:"liquidity",render:e=>(0,i.jsx)("div",{children:e})},{title:E("Earnings"),dataIndex:"earnings",key:"earnings",render:e=>(0,i.jsx)("div",{children:e}),display:U!==r.Zs.V2&&U!==r.Zs.STABLE},{title:E("APR"),dataIndex:"apr",key:"apr",render:e=>(0,i.jsx)(a.Ay,{pr:"8px",children:e})},{title:E("Price Range (Min/Max)"),dataIndex:"priceRange",key:"priceRange",render:e=>(0,i.jsx)("div",{children:e}),display:(0,y.T)(U)||U===r.Zs.V3},{title:"",dataIndex:"actions",key:"actions",render:e=>(0,i.jsx)("div",{children:e})}],data:I||w,onRowClick:S})]})}},762971:(e,t,n)=>{"use strict";n.d(t,{f0:()=>a,rW:()=>s});var i=n(350979),r=n(979332),l=n(29545),o=n(170601);function a(e){let{poolAddress:t}=e,{hasIncentra:n}=(0,o.uw)(t);return n?(0,i.jsx)(r.A,{ml:"8px",outline:!0,variant:"warning",children:"Incentra"}):null}function s(e){let{poolAddress:t}=e,{hasIncentra:n}=(0,o.uw)(t);return n?(0,i.jsx)(l.lh,{ml:"8px",variant:"warning",children:"Incentra"}):null}},769621:(e,t,n)=>{"use strict";n.d(t,{Cg:()=>i,F6:()=>o,Nw:()=>l,_P:()=>a,s0:()=>r});let i=6e4,r=36e5,l=43200,o=1440,a=Symbol.for("constructDateFrom")},770779:(e,t,n)=>{"use strict";n.d(t,{f:()=>s});var i=n(25963),r=n(242312),l=n.n(r),o=n(294373);let a=new(l())(0),s=()=>{let e=(0,o.r)();return(0,i.useCallback)(async t=>{let{params:n,onSent:i,onError:r,onFinally:l,onConfirmed:o}=t,{poolInfo:s,position:d,rewardAmountA:u,rewardAmountB:c}=n;return e({params:{poolInfo:s,position:d,liquidity:a,amountA:a.toString(),amountB:a.toString(),summaryAmountA:u,summaryAmountB:c,closePosition:!1},harvest:!0,onSent:i,onError:r,onFinally:l,onConfirmed:o})},[e])}},772155:(e,t,n)=>{"use strict";n.d(t,{A:()=>h});var i=n(350979),r=n(769932),l=n(226464),o=n(605641),a=n(928768),s=n(450253),d=n.n(s),u=n(522787),c=n.n(u),p=n(968349),m=n(25963),x=n(18468);d().extend(c());let h=e=>{let{overrideChainId:t}=e,{t:n}=(0,r.A)(),{chainId:s}=(0,p.ax)(),u=null!=t?t:s,c=(0,m.useMemo)(()=>{var e;return null==(e=x.Bt.find(e=>e.id===u))?void 0:e.name},[u]),h=a.nn[u];return h?(0,i.jsx)(l.A,{variant:"warning",style:{width:"100%"},children:(0,i.jsxs)(l.J,{children:[(0,i.jsx)(o.A,{mb:"8px",bold:!0,children:n("Important Notice: %chain% Sunset",{chain:c})}),n("%chain% will be sunset on %date%. Please make sure to remove your liquidity from all pools before deadline.",{chain:c,date:d().unix(h.sunsetDate).format("D MMMM")})]})}):null}},776484:(e,t,n)=>{"use strict";n.d(t,{C:()=>v});var i=n(350979),r=n(659197),l=n(769932),o=n(796147),a=n(605641),s=n(990296),d=n(25963),u=n(437862),c=n(662928),p=n(529208),m=n(64751),x=n(70619),h=n(49393);let f=e=>{let{children:t,pool:n}=e,{t:r}=(0,l.A)(),s=(0,d.useMemo)(()=>`${n.chainId}:${n.lpAddress}`,[n.chainId,n.lpAddress]),{cakeApr:c}=(0,u.nY)(s,n),p=(null==c?void 0:c.value)!=="0";return(0,i.jsxs)(o.VP,{gap:"8px",alignItems:"flex-end",children:[(0,i.jsx)(a.A,{color:"textSubtle",fontSize:"12px",children:r(p?"APR (with farming)":"APR")}),t]})};function v(e){let{pool:t,tokenId:n,showTitle:r=!0,derived:l,inverted:o,showApyText:a,showApyButton:s,fontSize:d}=e;return l?(0,i.jsx)(g,{pool:t,showTitle:r,inverted:o,showApyText:a,showApyButton:s,fontSize:d}):n?(0,i.jsx)(A,{pool:t,tokenId:n,showTitle:r}):(0,i.jsx)(y,{pool:t,showTitle:r})}let y=e=>{let{pool:t,showTitle:n}=e;return t?n?(0,i.jsx)(f,{pool:t,children:(0,i.jsx)(x.rr,{pool:t})}):(0,i.jsx)(x.rr,{pool:t}):(0,i.jsx)(s.Ay,{height:"40px"})},g=e=>{let{pool:t,inverted:n,showTitle:l,showApyText:o,showApyButton:a,fontSize:d}=e;return t?t.protocol!==r.Zs.V3?(0,i.jsx)(y,{pool:t,showTitle:l}):l?(0,i.jsx)(f,{pool:t,children:(0,i.jsx)(h.EO,{pool:t,inverted:n,showApyText:o,showApyButton:a,fontSize:d})}):(0,i.jsx)(h.EO,{pool:t,inverted:n,showApyText:o,showApyButton:a,fontSize:d}):(0,i.jsx)(s.Ay,{height:"40px"})},A=e=>{let{pool:t,tokenId:n,showTitle:r}=e,{data:l}=((e,t)=>(0,c.I)({queryKey:["accountV3Position",e,null==t?void 0:t.toString()],queryFn:()=>(0,m.Pm)(e,[t]),select:(0,d.useCallback)(e=>e[0],[]),enabled:!!t&&!!e,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:p.IX,staleTime:p.IX}))(null==t?void 0:t.chainId,n);return t&&l&&t&&l?r?(0,i.jsx)(f,{pool:t,children:(0,i.jsx)(x._o,{userPosition:l,pool:t})}):(0,i.jsx)(x._o,{userPosition:l,pool:t}):(0,i.jsx)(s.Ay,{height:"40px"})}},776808:(e,t,n)=>{"use strict";n.d(t,{f:()=>o});var i=n(662928),r=n(25963),l=n(342746);let o=(e,t)=>(0,i.I)({queryKey:["accountV2PendingCakeReward",e,t.chainId,t.bCakeWrapperAddress],queryFn:()=>(0,l.T)(t.chainId,e,[t]),enabled:!!(e&&t.chainId&&t.bCakeWrapperAddress),select:(0,r.useCallback)(e=>null==e?void 0:e[0],[])})}
29,778428:(e,t,n)=>{"use strict";n.d(t,{z:()=>l});var i=n(769621),r=n(131117);function l(e,t,n){let l=(0,r.a)(e,null==n?void 0:n.in);return l.setTime(l.getTime()+t*i.Cg),l}},788501:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var i=n(606771),r=n(25963),l=n(732170),o=n(17581),a=n(514666);let s=e=>{let{chainId:t,onDone:n}=e,{address:s}=(0,o.F)(),{switchNetworkIfNecessary:d,isLoading:u}=(0,a.H)(),{removeLiquidity:c,attemptingTx:p}=(0,i.X)(t,s,n);return{attemptingTx:p||u,onCollect:(0,r.useCallback)(async e=>{let{tokenId:n,poolKey:i,wrapAddress:r,amount0Desired:o,amount1Desired:a,currency0:s,currency1:u}=e;t&&(await d(t)||await c({tokenId:n,poolKey:i,liquidity:0n,amount0Min:0n,amount1Min:0n,wrapAddress:null!=r?r:l.Xd,deadline:BigInt(Math.floor(Date.now()/1e3)+1200),amount0Desired:o,amount1Desired:a,currency0:s,currency1:u}))},[d,c,t])}}},800939:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var i=n(350979),r=n(769932),l=n(796898),o=n(24153),a=n(557423),s=n(258213),d=n(605641),u=n(266283);let c=(0,n(680797).Ay)(u.k0).withConfig({componentId:"sc-855480ee-0"})(["padding:16px;border-radius:16px;border:1px solid ",";border-bottom:2px solid ",";max-height:100px;overflow:hidden;transition:max-height 0.5s ease-in-out;&.expanded{max-height:1000px;}"],e=>{let{theme:t}=e;return t.colors.cardBorder},e=>{let{theme:t}=e;return t.colors.cardBorder});function p(e){let{noHideButton:t,showOptions:n,setShowOptions:u,heading:p,content:m}=e,{t:x}=(0,r.A)(),{isXs:h}=(0,l.A)();return(0,i.jsxs)(c,{className:n?"expanded":"",children:[(0,i.jsxs)(o.eF,{justifyContent:"space-between",alignItems:"center",marginBottom:n?"8px":"0px",children:[null!=p?p:(0,i.jsx)("div",{}),t||(0,i.jsx)(a.A,{scale:h?"xs":"sm",onClick:()=>u(e=>!e),variant:"text",endIcon:(0,i.jsx)(s.A,{style:{marginLeft:"0px",transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease-in-out"},color:"primary60"}),children:(0,i.jsx)(d.A,{color:"primary60",fontSize:["12px","16px"],bold:!0,children:x(n?"Hide":"More")})})]}),n?m:(0,i.jsx)(i.Fragment,{})]})}},805995:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>b});var i=n(350979),r=n(659197),l=n(131619),o=n(87242),a=n.n(o),s=n(326848),d=n(25963),u=n(403595),c=n(302075),p=n(733775),m=n(18468),x=n(90634),h=n(462864),f=n(630037),v=n(942272),y=n(206016);let g=()=>{let e=(0,s.useRouter)(),{data:t}=(0,u.dr)(),{data:n}=(0,c.Rz)(),{currencyIdA:o,currencyIdB:a,feeAmount:m}=(0,v.J)(),g=(0,l.Jg)(o),A=(0,l.Jg)(a),b=(0,d.useMemo)(()=>{if(!g||!A||!e.isReady)return;let i=null==n?void 0:n.farmsWithPrice.find(e=>"0X"!==e.multiplier&&(e.token.equals(g.wrapped)&&e.quoteToken.equals(A.wrapped)||e.quoteToken.equals(g.wrapped)&&e.token.equals(A.wrapped)));if(i)return{type:y.b.V3,feeAmount:i.feeAmount};let l=null==t?void 0:t.find(e=>"0X"!==e.multiplier&&((0,p.ho)(e.token.address,g.wrapped.address)&&(0,p.ho)(e.quoteToken.address,A.wrapped.address)||(0,p.ho)(e.token.address,A.wrapped.address)&&(0,p.ho)(e.quoteToken.address,g.wrapped.address)));return l?(0,r.o4)(l)?{type:y.b.STABLE}:{type:y.b.V2}:void 0},[t,null==n?void 0:n.farmsWithPrice,g,A,e]);return e.isReady&&(null==g?void 0:g.wrapped)&&(null==A?void 0:A.wrapped)&&g.wrapped.equals(A.wrapped)?(e.replace("/liquidity/select"),null):(0,i.jsx)(x.A,{children:(0,i.jsx)(f.A,{children:(0,i.jsx)(h.RC,{children:(0,i.jsx)(h.DC,{currencyIdA:o,currencyIdB:a,preferredSelectType:m?y.b.V3:null==b?void 0:b.type,preferredFeeAmount:m||null==b?void 0:b.feeAmount})})})})},A=a()(()=>Promise.resolve(g),{ssr:!1});A.chains=m.tx,A.screen=!0;let b=A},807718:(e,t,n)=>{"use strict";n.d(t,{G:()=>a});var i=n(350979),r=n(579518),l=n(25963),o=n(541375);let a=e=>{var t,n;let{children:a,json:s}=e,d=(null==(n=window)||null==(t=n.location)?void 0:t.hostname)==="localhost",{targetRef
29:u,tooltipVisible:c,tooltip:p}=(0,r.A)(d?(0,i.jsx)("pre",{style:{maxHeight:"500px",overflow:"auto"},children:(0,o.A)(s,(e,t)=>l.isValidElement(t)?"ReactElement":"bigint"==typeof t?t.toString():t,2)}):null);return d?(0,i.jsxs)("div",{ref:u,children:[a,c&&p]}):a}},813405:(e,t,n)=>{"use strict";n.d(t,{A:()=>_,y:()=>O});var i=n(350979),r=n(501823),l=n(605641),o=n(796259),a=n(614325),s=n(995315),d=n(557423),u=n(310085),c=n(525033),p=n(796898),m=n(312680),x=n(475690),h=n(25963),f=n(769932),v=n(619749),y=n(91168),g=n(242312),A=n.n(g),b=n(734658),w=n(701150),j=n(265394),k=n(515324),C=n(628838),I=n(261803),S=n(823585),R=n(72912),E=n(670420),M=n(228876),N=n(747292),P=n(188882),T=n(294373),U=n(142511),B=n(50369),D=n(98378),F=n(326848),q=n(977418),L=n(35075);let O=e=>{let{pool:t,position:n,onClose:p}=e,m=t.rawPool,{t:x}=(0,f.A)(),g=(0,F.useRouter)(),[I,S]=(0,h.useState)(50),[O,_]=(0,h.useState)(!0),[Y,z]=(0,h.useState)(!1),V=(0,h.useMemo)(()=>(0,v.ph)(m.mintA),[m.mintA]),{data:Z}=(0,R.wm)({mint:null==V?void 0:V.wrapped.address,enabled:!!V}),W=(0,h.useMemo)(()=>(0,v.ph)(m.mintB),[m.mintB]),{data:H}=(0,R.wm)({mint:null==W?void 0:W.wrapped.address,enabled:!!W}),Q=(0,h.useMemo)(()=>{var e;return b.gm.fromDecimal(V,E.pI[M.Cb.SOLANA],new y.A(null!=(e=null==Z?void 0:Z.toString())?e:"0").times(10**(V.decimals-E.pI[M.Cb.SOLANA].decimals)).toString())},[Z,V]),G=(0,h.useMemo)(()=>{var e;return b.gm.fromDecimal(W,E.pI[M.Cb.SOLANA],new y.A(null!=(e=null==H?void 0:H.toString())?e:"0").times(10**(W.decimals-E.pI[M.Cb.SOLANA].decimals)).toString())},[H,W]),{amount0:K,amount1:X}=(0,D.y)({poolInfo:m,tickLower:n.tickLower,tickUpper:n.tickUpper,liquidity:n.liquidity}),[J,ee]=(0,h.useMemo)(()=>[null==K?void 0:K.multiply(new b.QE(I,100)),null==X?void 0:X.multiply(new b.QE(I,100))],[K,X,I]),et=(0,T.r)(),en=(0,U.zl)(),{breakdownRewardInfo:ei}=(0,P.n)({poolInfo:t,position:n}),[er,el]=(0,h.useState)(!1),eo=(0,h.useCallback)(e=>{_(!e.target.checked)},[]);(0,h.useEffect)(()=>{S(0),el(!1)},[]),(0,h.useEffect)(()=>{z(100===I)},[I]),(0,h.useEffect)(()=>{_(!0)},[]);let ea=(0,h.useCallback)(async()=>{let e,i;if(!n||n.liquidity.isZero()||!J||!ee||J.equalTo(0)&&ee.equalTo(0))return;el(!0);let r=new(A())(new y.A(n.liquidity.toString()).multipliedBy(I).dividedBy(100).toFixed(0));try{let l=await (0,B.H)({simulateOnly:!0,raydium:en,poolInfo:t,position:n,liquidity:BigInt(r.toString()),amountMinA:0n,amountMinB:0n});l&&(e=new y.A(l.decreaseAmount0.toString()).plus(l.feeAmount0.toString()).div(10**m.mintA.decimals).toString(),i=new y.A(l.decreaseAmount1.toString()).plus(l.feeAmount1.toString()).div(10**m.mintB.decimals).toString())}catch(e){console.warn("[removeLiquidity] summary simulation failed, falling back to estimate",e)}if(void 0===e||void 0===i){var l,o,a,s;let t=Number(null!=(a=null==(l=ei.fee.A)?void 0:l.amount)?a:0),n=Number(null!=(s=null==(o=ei.fee.B)?void 0:o.amount)?s:0);e=(Number(J.toExact())+(Number.isFinite(t)?t:0)).toString(),i=(Number(ee.toExact())+(Number.isFinite(n)?n:0)).toString()}try{await et({params:{poolInfo:m,position:n,liquidity:r,amountA:J.toExact(),amountB:ee.toExact(),summaryAmountA:e,summaryAmountB:i,closePosition:100===I&&O},onSent:()=>{el(!1),S(0),p(),100===I&&O&&"/liquidity/position/[[...positionId]]"===g.pathname&&g.push("/liquidity/positions")},onError:e=>{el(!1)},onFinally:()=>{el(!1)}})}catch(e){console.error(e),el(!1)}},[g,p,I,m,t,en,n,et,J,ee,O,ei]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(L.$,{poolInfo:m,currency0:V,currency1:W,position:n}),(0,i.jsxs)(r.A,{mt:"24px",justifyContent:"space-between",alignItems:"center",children:[(0,i.jsx)(l.A,{children:x("Slippage Tolerance")}),(0,i.jsx)(j.AE,{})]}),(0,i.jsx)(o.y,{mt:"24px",textTransform:"uppercase",children:x("Amount of liquidity to remove")}),(0,i.jsxs)(k.IV,{mt:"8px",children:[(0,i.jsxs)(l.A,{fontSize:"32px",bold:!0,children:[I,"%"]}),(0,i.jsx)(a.A,{min:0,max:100,name:"remove-position",value:I,onValueChanged:e=>S(Math.ceil(e))}),(0,i.jsx)(s.A,{mt:"16px",gap:"8px",justifyContent:"space-between",children:C.g.map(e=>(0,i.jsx)(d.A,{variant:"secondary",scale:["xs",null,null,"sm"],width:"100%",onClick:()=>S(e),children:100===e?x("MAX"):`${e}%`},e))}),Y&&(0,i.jsxs)(s.A,{gap:"4px",alignItems:"center",mt:"16px",children:[(0,i.jsx)(u.A,{scale:"xs",checked:!O,onChange:eo}),(0,i.jsx)(l.A,{fontSize:"sm",color:"textSubtle",children:x("Keep my position open")}),(0,i.jsx)(c.PT,{text:x("You can remove all your tokens and still keep your position open in order to add position seamless next time.")})]})]}),(0,i.jsx)(o.y,{mt:"24px",textTransform:"uppercase",children:x("You will receive")}),(0,i.jsxs)(w.k,{mt:"8px",children:[(0,i.jsx)($,{currency0:V,currency1:W,amount0:J,amount1:ee,price0:Q,price1:G}),(0,i.jsx)(N.A,{style:{margin:"16px 0"}}),(0,i.jsx)(q.n,{pool:t,position:n})]}),(0,i.jsx)(s.A,{flexDirection:"column",gap:"16px",mt:"16px",children:(0,i.jsx)(d.A,{width:"100%",disabled:n.liquidity.isZero()||0===I,isLoading:er,onClick:ea,children:er?x("Confirming..."):x("Remove")})})]})};function _(e){let{isOpen:t,onClose:n,pool:r,position:l}=e,{t:o}=(0,f.A)(),{isMobile:a}=(0,p.A)();return(0,i.jsx)(m.aF,{isOpen:t,onDismiss:n,closeOnOverlayClick:!0,children:(0,i.jsx)(x.Ay,{title:o("Remove Liquidity"),minWidth:[null,null,"500px"],headerPadding:"12px 24px",headerBorderColor:"transparent",bodyPadding:a?"0 16px 16px":"0 24px 24px",onDismiss:n,children:(0,i.jsx)(O,{pool:r,position:l,onClose:n})})})}let $=e=>{var t,n;let{currency0:o,currency1:a,amount0:s,amount1:d,price0:u,price1:c}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(r.A,{justifyContent:"space-between",mb:"8px",as:"label",alignItems:"center",children:[(0,i.jsxs)(r.A,{alignItems:"center",children:[(0,i.jsx)(w.Z,{currency:o}),(0,i.jsx)(l.A,{small:!0,color:"textSubtle",id:"remove-liquidity-tokena-symbol",ml:"4px",children:null==o?void 0:o.symbol})]}),(0,i.jsx)(r.A,{children:(0,i.jsx)(I.A,{currencyAmount:s,significantDigits:8})})]}),(0,i.jsx)(r.A,{justifyContent:"flex-end",mb:"8px",children:(0,i.jsxs)(l.A,{fontSize:"14px",color:"textSubtle",ml:"4px",children:["~$",(0,S.ZV)(null!=(t=null==s?void 0:s.multiply(null!=u?u:0).toExact())?t:0)]})}),(0,i.jsxs)(r.A,{justifyContent:"space-between",mb:"8px",as:"label",alignItems:"center",children:[(0,i.jsxs)(r.A,{alignItems:"center",children:[(0,i.jsx)(w.Z,{currency:a}),(0,i.jsx)(l.A,{small:!0,color:"textSubtle",id:"remove-liquidity-tokena-symbol",ml:"4px",children:null==a?void 0:a.symbol})]}),(0,i.jsx)(r.A,{children:(0,i.jsx)(I.A,{currencyAmount:d,significantDigits:8})})]}),(0,i.jsx)(r.A,{justifyContent:"flex-end",mb:"8px",children:(0,i.jsxs)(l.A,{fontSize:"14px",color:"textSubtle",ml:"4px",children:["~$",(0,S.ZV)(null!=(n=null==d?void 0:d.multiply(null!=c?c:0).toExact())?n:0)]})})]})}},822442:(e,t,n)=>{var i=n(19773),r=n(233312),l=n(22363);e.exports=function(e){return"string"==typeof e||!r(e)&&l(e)&&"[object String]"==i(e)}},829715:(e,t,n)=>{"use strict";n.d(t,{I:()=>l});var i=n(114041),r=n(909725);function l(e,t,n,l,o){return t[n]?n===i.zm.LOWER?"0":"â":e||void 0===o?(0,r.$g)(e,6,l):o}},847085:(e,t,n)=>{"use strict";n.d(t,{z:()=>u});var i=n(350979),r=n(769932),l=n(25963),o=n(501823),a=n(557423),s=n(310085),d=n(605641);let u=e=>{let{handleContinueClick:t}=e,{t:n}=(0,r.A)(),[u,c]=(0,l.useState)(!1);return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.A,{alignItems:"center",justifyContent:"space-between",children:[(0,i.jsx)("label",{htmlFor:"acknowledgement",children:(0,i.jsxs)(o.A,{alignItems:"center",children:[(0,i.jsx)(s.A,{id:"acknowledgement",name:"confirmed",type:"checkbox",checked:u,onChange:()=>c(!u),scale:"sm"}),(0,i.jsx)(d.A,{ml:"10px",style:{userSelect:"none"},children:n("I understand")})]})}),(0,i.jsx)(a.A,{disabled:!u,onClick:t,children:n("Continue")})]})})}},851931:(e,t,n)=>{"use strict";n.d(t,{v:()=>E});var i=n(350979),r=n(25963),l=n(659197),o=n(273523),a=n(769932),s=n(24153),d=n(501823),u=n(605641),c=n(557423),p=n(549333),m=n(698612),x=n(266283),h=n(150103),f=n(214885),v=n(131619),y=n(344730),g=n(687287),A=n(810286),b=n(252146),w=n(909725),j=n(642010),k=n(788501),C=n(857019),I=n(605360),S=n(427896),R=n(453461);let E=(0,r.memo)(e=>{var t,n,E,M,N;let{pos:P,positionList:T=[],showPositionFees:U=!0,chainId:B,showCollectButton:D=!1}=e,{t:F,currentLanguage:{locale:q}}=(0,a.A)(),[,L]=(0,b.r)(),O=(0,I.se)(),{data:_}=(0,C.I)(),$=T.length>0?T:_,Y=(0,r.useMemo)(()=>null!=P?P:null==$?void 0:$.find(e=>e.chainId===B),[P,$,B]),z=null!=(E=null!=B?B:null==Y?void 0:Y.chainId)?E:0,{isMerkleRootMismatch:V,hasRewards:Z,hasUnclaimedRewards:W}=(0,j.A)({chainId:z,onDone:L}),{onCollect:H,attemptingTx:Q}=(0,k.A)({chainId:z}),G=null!=(M=(0,v.G5)(null==Y||null==(t=Y.poolKey)?void 0:t.currency0,z))?M:void 0,K=null!=(N=(0,v.G5)(null==Y||null==(n=Y.poolKey)?void 0:n.currency1,z))?N:void 0,X=(0,r.useMemo)(()=>
29{if((null==Y?void 0:Y.protocol)===l.Zs.InfinityCLAMM&&Y.poolKey)return(0,o.Qn)(Y.poolKey)},[null==Y?void 0:Y.protocol,null==Y?void 0:Y.poolKey]),J=(0,r.useMemo)(()=>(null==Y?void 0:Y.protocol)===l.Zs.InfinityCLAMM?Y:void 0,[Y]),[ee,et]=(0,y.s)({currency0:G,currency1:K,tokenId:null==J?void 0:J.tokenId,poolId:X,tickLower:null==J?void 0:J.tickLower,tickUpper:null==J?void 0:J.tickUpper,enabled:(null==Y?void 0:Y.protocol)===l.Zs.InfinityCLAMM}),en=(0,g.Wu)(ee,4),ei=(0,g.Wu)(et,4),er=(0,r.useMemo)(()=>(null==Y?void 0:Y.protocol)===l.Zs.InfinityCLAMM&&(ee&&ee.greaterThan(0)||et&&et.greaterThan(0)),[null==Y?void 0:Y.protocol,ee,et]),[el,eo]=(0,r.useState)(),ea=(0,r.useCallback)(async()=>{if((null==Y?void 0:Y.protocol)===l.Zs.InfinityCLAMM&&Y.poolKey)try{eo(void 0),await H({tokenId:Y.tokenId,poolKey:Y.poolKey})}catch(e){console.error("[InfinityPositionActions] Collect error:",e),eo(e instanceof Error?e.message:F("Transaction failed"))}},[H,Y,F]),es=(0,r.useCallback)(()=>{eo(void 0)},[]),ed=(0,r.useCallback)(()=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(x.k0,{mb:"16px",children:[(0,i.jsxs)(s.eF,{justifyContent:"space-between",mb:"8px",children:[(0,i.jsxs)(d.A,{children:[(0,i.jsx)(h.Zm,{currency:G,size:"24px"}),(0,i.jsx)(u.A,{color:"textSubtle",ml:"4px",children:null==G?void 0:G.symbol})]}),(0,i.jsx)(A.g3,{amount:ee,children:ee?null!=en?en:(0,w.N)(ee,4,q):"0"})]}),(0,i.jsxs)(s.eF,{justifyContent:"space-between",children:[(0,i.jsxs)(d.A,{children:[(0,i.jsx)(h.Zm,{currency:K,size:"24px"}),(0,i.jsx)(u.A,{color:"textSubtle",ml:"4px",children:null==K?void 0:K.symbol})]}),(0,i.jsx)(A.g3,{amount:et,children:et?null!=ei?ei:(0,w.N)(et,4,q):"0"})]})]}),(0,i.jsx)(u.A,{mb:"16px",px:"16px",children:F("Collecting fees will withdraw currently available fees for you")})]}),[G,K,ee,et,en,ei,q,null==J?void 0:J.tokenId,F]),eu=(0,r.useCallback)(()=>(0,i.jsx)(m.Y,{topContent:ed,bottomContent:()=>(0,i.jsx)(c.A,{width:"100%",onClick:ea,disabled:Q,children:Q?F("Collecting"):F("Collect")})}),[ed,ea,Q,null==J?void 0:J.tokenId,F]),ec=(0,r.useMemo)(()=>{if(null==J?void 0:J.tokenId)return J.tokenId.toString();if((null==Y?void 0:Y.protocol)===l.Zs.InfinityBIN){var e,t;return null!=(t=null==(e=Y.activeId)?void 0:e.toString())?t:"unknown"}return"unknown"},[J,Y]),[ep]=(0,p.A)((0,i.jsx)(f.A,{title:F("Claim fees"),attemptingTxn:Q,customOnDismiss:es,hash:"",errorMessage:el,content:eu,pendingText:F("Collecting fees")},`collect-${z}-${ec}-${null==G?void 0:G.symbol}-${null==K?void 0:K.symbol}`),!0,!0,`InfinityTransactionConfirmationModalCollectFees-${z}-${ec}`);return G&&K?(0,i.jsx)(S.L,{children:(0,i.jsxs)(R.Cp,{children:[D&&er?(0,i.jsx)(c.A,{width:["100px"],scale:"md",disabled:Q,onClick:ep,children:Q?F("Collecting"):F("Collect")}):null,(0,i.jsx)(c.A,{width:["100px"],scale:"md",disabled:V||!Z||!W,onClick:()=>null==O?void 0:O("evm",z),children:F("Harvest")})]})}):null})},852076:(e,t,n)=>{"use strict";n.d(t,{Y9:()=>d});var i=n(311560),r=n(970645);let l=new i.QE(9n,r.j0),o=new i.QE(12n,r.j0),a=new i.QE(15n,r.j0),s=new i.QE(20n,r.j0);function d(e){return e?(null==e?void 0:e.lessThan(s))?(null==e?void 0:e.lessThan(a))?(null==e?void 0:e.lessThan(o))?+(null==e||!e.lessThan(l)):2:3:4:0}},857019:(e,t,n)=>{"use strict";n.d(t,{I:()=>v,o:()=>f});var i=n(659197),r=n(2812),l=n(869594),o=n.n(l),a=n(25963),s=n(437862),d=n(203907),u=n(178367),c=n(810498),p=n(505566),m=n(17581),x=n(275076),h=n(517024);let f=e=>{let{selectedNetwork:t,selectedTokens:n,positionStatus:l,farmsOnly:s}=e,{data:m,isLoading:x}=v(t),{protocols:f,isSelectAllProtocols:y,isSelectAllFeatures:g,features:A}=(0,p.z)(),b=(0,a.useMemo)(()=>y||!f.length?i.yJ:f,[f,y]),[w]=(0,h.J)(),j=(0,a.useCallback)(e=>{var t;if(e.liquidity>0n)return!1;let n=null==w||null==(t=w[e.chainId])?void 0:t[e.poolId];return!!n&&e.protocol!==i.Zs.InfinityCLAMM&&!(null==n||n)},[w]);return{infinityLoading:x,infinityPositions:(0,a.useMemo)(()=>m.filter(e=>{var i,a;return b.includes(e.protocol)&&t.includes(e.chainId)&&(!(null==n?void 0:n.length)||n.some(t=>{var n,i;return(null==(n=e.poolKey)?void 0:n.currency0)&&t===(0,r.I)({chainId:e.chainId,address:e.poolKey.currency0})||(null==(i=e.poolKey)?void 0:i.currency1)&&t===(0,r.I)({chainId:e.chainId,address:e.poolKey.currency1})}
29))&&(l===d.$.ALL||e.status===l)&&(!s||e.isStaked)&&(g||!A.length||(0,c.T)(e.protocol)&&(null==(i=e.poolKey)?void 0:i.hooks)&&o()(A,null==(a=(0,u.$Y)(e.chainId,e.poolKey.hooks))?void 0:a.category).length)&&!j(e)}).sort((e,t)=>e.status-t.status),[m,b,t,n,l,s,A,g,j]),allInfinityPositions:m}},v=e=>{let{address:t}=(0,m.F)(),n=(0,x.Wp)(),i=e&&e.length>0?e:n,{data:r,pending:l}=(0,s.qQ)(i,t),{data:o,pending:d}=(0,s.Ib)(t,i);return{isLoading:l||d,data:(0,a.useMemo)(()=>[].concat(null!=r?r:[],null!=o?o:[]),[r,o])}}},871792:(e,t,n)=>{"use strict";n.d(t,{t:()=>m});var i=n(769932),r=n(311560),l=n(530957),o=n(673384),a=n(131619),s=n(25963),d=n(452301),u=n(17581),c=n(650176),p=n(706172);function m(e,t){let n,m=arguments.length>2&&void 0!==arguments[2]&&arguments[2],x=arguments.length>3?arguments[3]:void 0,{t:h}=(0,i.A)(),{address:f}=(0,u.F)(),v=(0,a.rd)(null==e?void 0:e.token0,x),y=(0,a.rd)(null==e?void 0:e.token1,x),[,g]=(0,c.Q2)(null!=v?v:void 0,null!=y?y:void 0,null==e?void 0:e.fee),A=(0,s.useMemo)(()=>g&&"bigint"==typeof(null==e?void 0:e.liquidity)&&"number"==typeof(null==e?void 0:e.tickLower)&&"number"==typeof(null==e?void 0:e.tickUpper)?new o.yX({pool:g,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper}):void 0,[g,e]),b=(0,l.A)(t)?void 0:new r.QE(t,100),w=A?null==b?void 0:b.multiply(A.amount0.quotient).quotient:void 0,j=A?null==b?void 0:b.multiply(A.amount1.quotient).quotient:void 0,k=v?(0,d.U$)(v):void 0,C=y?(0,d.U$)(y):void 0,I=v&&k&&void 0!==w?r.eF.fromRawAmount(m?v:k,w):void 0,S=y&&C&&void 0!==j?r.eF.fromRawAmount(m?y:C,j):void 0,[R,E]=(0,p.R)(null!=g?g:void 0,null==e?void 0:e.tokenId,m),M=!!g&&!!e&&(g.tickCurrent<e.tickLower||g.tickCurrent>=e.tickUpper);return f||(n=h("Connect Wallet")),0===t&&(n=null!=n?n:h("Enter a percent")),{position:A,liquidityPercentage:b,liquidityValue0:I,liquidityValue1:S,feeValue0:R,feeValue1:E,outOfRange:M,error:n}}},878779:(e,t,n)=>{var i=n(460189),r=n(685892),l=n(353761),o=n(233312),a=n(486821);e.exports=function(e,t,n){var s=o(e)?i:l;return n&&a(e,t,n)&&(t=void 0),s(e,r(t,3))}},888432:(e,t,n)=>{var i=n(20564);e.exports=function(e,t){var n=!0;return i(e,function(e,i,r){return n=!!t(e,i,r)}),n}},890398:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});let i=n(680797).I4.span.withConfig({componentId:"sc-824b89d8-0"})(["&::after{display:inline-block;animation:ellipsis 1.25s infinite;content:'.';width:1em;text-align:left;}@keyframes ellipsis{0%{content:'.';}33%{content:'..';}66%{content:'...';}}"])},894799:(e,t,n)=>{"use strict";n.d(t,{r:()=>l,v:()=>o});var i=n(557423),r=n(680797);let l=(0,r.Ay)(i.A).attrs({scale:"sm",variant:"tertiary"}).withConfig({componentId:"sc-fb5f0aad-0"})(["display:flex;align-items:center;justify-content:center;height:48px;width:",";background-color:transparent;color:",";border:2px solid ",";border-radius:",";padding:16px;transition:opacity 0.2s ease;opacity:",";cursor:",";&:hover:not(:disabled){opacity:0.6;}& > svg{fill:",";}"],e=>{let{isIcon:t}=e;return t?"48px":""},e=>{let{theme:t}=e;return t.colors.primary60},e=>{let{theme:t,disabled:n}=e;return n?t.colors.textDisabled:t.colors.primary},e=>{let{theme:t}=e;return t.radii.default},e=>{let{disabled:t}=e;return t?.5:1},e=>{let{disabled:t}=e;return t?"not-allowed":"pointer"},e=>{let{theme:t,disabled:n}=e;return n?t.colors.textDisabled:t.colors.primary60}),o=(0,r.Ay)(i.A).withConfig({componentId:"sc-fb5f0aad-1"})(["border:2px solid ",";background-color:",";color:",";font-weight:600;font-size:16px;padding:8px 16px;border-radius:16px;&:hover{opacity:0.8;}"],e=>{let{theme:t}=e;return t.colors.primary},e=>{let{theme:t}=e;return t.colors.background},e=>{let{theme:t}=e;return t.colors.primary60})},895557:e=>{e.exports=function(e,t){return e<t}},906296:(e,t,n)=>{"use strict";n.d(t,{l:()=>l});var i=n(326848),r=n(25963);let l=(e,t,n)=>{let l=(0,i.useRouter)();return[(0,r.useMemo)(()=>{var i,r;let o=null==(i=l.query)?void 0:i[e];return Array.isArray(o)?null!=(r=void 0===t?o:o[t])?r:n:null!=o?o:n},[l.query,e,t,n]),(0,r.useCallback)(n=>{var i;let r=null==(i=l.query)?void 0:i[e],o=n;if(Array.isArray(r)&&!Array.isArray(n)&&void 0!==t){for(o=r.slice();o.length<t;)o.push("");o[t]=n}l.replace({query:{...l.query,[e]:o}},void 0,{shallow:!0})},[l,e,t])]}},915984:(e,t,n)=>{"use strict";n.d(t,{P:()=>l});var i=n(43185),r=n(131117);function l(e,t,n){let l=(0,r.a)(e,null==n?void 0:n.in);if(isNaN(t))return(0,i.w)((null==n?void 0:n.in)||e,NaN);if(!t)return l;let o=l.getDate(),a=(0,i.w)((null==n?void 0:n.in)||e,l.getTime());return(a.setMonth(l.getMonth()+t+1,0),o>=a.getDate())?a:(l.setFullYear(a.getFullYear(),a.getMonth(),o),l)}},920820:(e,t,n)=>{"use strict";n.d(t,{g:()=>u});var i=n(673384),r=n(25963),l=n(314811),o=n(662928),a=n(968349),s=n(774900),d=n(650176);function u(e,t){let{isPending:n,error:u,distributions:c,tvlByFeeTier:p}=function(e,t){let{isPending:n,error:l,data:d}=function(e,t,n){let{chainId:i}=(0,a.ax)(),[l,d]=(0,r.useMemo)(()=>[null==e?void 0:e.toLowerCase(),null==t?void 0:t.toLowerCase()].sort(),[e,t]);return(0,o.I)({queryKey:[`useFeeTierDistributionQuery2-${l}-${d}`],queryFn:async e=>{let{signal:t}=e;if(!i||!l||!d)return;let n=(0,s.uP)(i);if(!n)throw Error(`Unknown chainId: ${i}`);return s.D$.GET("/cached/pools/v3/{chainName}/list/simple",{signal:t,params:{path:{chainName:n},query:{token0:l,token1:d}}}).then(e=>{var t;return null==(t=e.data)?void 0:t.rows})},enabled:!!(e&&t&&i),refetchInterval:3e4,refetchOnMount:!1,refetchOnReconnect:!1,refetchOnWindowFocus:!1})}(null==e?void 0:e.address,null==t?void 0:t.address,0);return(0,r.useMemo)(()=>{var e;let t=(null!=(e=null==d?void 0:d.map(e=>({feeTier:e.feeTier,totalValueLockedToken0:+e.tvlToken0,totalValueLockedToken1:+e.tvlToken1})))?e:[]).reduce((e,t)=>
29{var n,i,r,l;return e[t.feeTier][0]=(null!=(r=null==(n=e[t.feeTier])?void 0:n[0])?r:0)+Number(t.totalValueLockedToken0),e[t.feeTier][1]=(null!=(l=null==(i=e[t.feeTier])?void 0:i[1])?l:0)+Number(t.totalValueLockedToken1),e},{[i.dl.LOWEST]:[void 0,void 0],[i.dl.LOW]:[void 0,void 0],[i.dl.MEDIUM]:[void 0,void 0],[i.dl.HIGH]:[void 0,void 0]}),[r,o]=Object.values(t).reduce((e,t)=>{var n,i;return e[0]+=null!=(n=t[0])?n:0,e[1]+=null!=(i=t[1])?i:0,e},[0,0]),a=(e,t,n,i)=>void 0===e&&void 0===n?void 0:((null!=e?e:0)+(null!=n?n:0))/(t+i)||0;return{isPending:n,error:l,distributions:{[i.dl.LOWEST]:a(t[i.dl.LOWEST][0],r,t[i.dl.LOWEST][1],o),[i.dl.LOW]:a(t[i.dl.LOW][0],r,t[i.dl.LOW][1],o),[i.dl.MEDIUM]:a(t[i.dl.MEDIUM][0],r,t[i.dl.MEDIUM][1],o),[i.dl.HIGH]:a(t[i.dl.HIGH][0],r,t[i.dl.HIGH][1],o)},tvlByFeeTier:t}},[d,n,l])}(null==e?void 0:e.wrapped,null==t?void 0:t.wrapped),[m]=(0,d.Q2)(e,t,i.dl.LOWEST),[x]=(0,d.Q2)(e,t,i.dl.LOW),[h]=(0,d.Q2)(e,t,i.dl.MEDIUM),[f]=(0,d.Q2)(e,t,i.dl.HIGH);return(0,r.useMemo)(()=>{var e,t,r,o;if(n||u||!c)return{isPending:n,isError:!!u,distributions:c};let a=Object.keys(c).map(e=>Number(e)).filter(e=>0!==c[e]&&void 0!==c[e]).reduce((e,t)=>{var n,i;return(null!=(n=c[e])?n:0)>(null!=(i=c[t])?i:0)?e:t},-1),s=n||u||!c||m===l.S.LOADING||x===l.S.LOADING||h===l.S.LOADING||f===l.S.LOADING?void 0:{[i.dl.LOWEST]:m===l.S.EXISTS?(null!=(e=c[i.dl.LOWEST])?e:0)*100:void 0,[i.dl.LOW]:x===l.S.EXISTS?(null!=(t=c[i.dl.LOW])?t:0)*100:void 0,[i.dl.MEDIUM]:h===l.S.EXISTS?(null!=(r=c[i.dl.MEDIUM])?r:0)*100:void 0,[i.dl.HIGH]:f===l.S.EXISTS?(null!=(o=c[i.dl.HIGH])?o:0)*100:void 0};return{isPending:n,isError:!!u,distributions:s,largestUsageFeeTier:-1===a?void 0:a,largestUsageFeeTierTvl:p[a]}},[n,u,c,p,m,x,h,f])}},933752:(e,t,n)=>{"use strict";n.d(t,{A:()=>g});var i=n(350979),r=n(25963),l=n(796147),o=n(605641),a=n(892977),s=n(557423),d=n(698612),u=n(769932),c=n(214885),p=n(810286),m=n(320669),x=n(696368),h=n(150103),f=n(262453),v=n(133018),y=n(687287);let g=e=>{let{title:t,onDismiss:n,customOnDismiss:g,attemptingTxn:A,pair:b,hash:w,approval:j,signatureData:k,pendingText:C,parsedAmounts:I,allowedSlippage:S,onRemove:R,liquidityErrorMessage:E,tokenA:M,tokenB:N,currencyA:P,currencyB:T}=e,{t:U}=(0,u.A)(),B=(0,y.wG)(P),D=(0,y.wG)(T),F=(0,r.useCallback)(()=>{var e,t;return(0,i.jsxs)(l.mm,{gap:"md",children:[I[x.D.CURRENCY_A]&&(0,i.jsxs)(m.JA,{align:"flex-end",children:[(0,i.jsx)(p.g3,{amount:I[x.D.CURRENCY_A],fontSize:"24px",children:null!=(e=B(I[x.D.CURRENCY_A],6))?e:"-"}),(0,i.jsxs)(m.Bp,{gap:"4px",children:[(0,i.jsx)(h.Zm,{currency:P,size:"24px"}),(0,i.jsx)(o.A,{fontSize:"24px",ml:"10px",children:null==P?void 0:P.symbol})]})]}),I[x.D.CURRENCY_A]&&I[x.D.CURRENCY_B]&&(0,i.jsx)(m.Bp,{children:(0,i.jsx)(a.A,{width:"16px"})}),I[x.D.CURRENCY_B]&&(0,i.jsxs)(m.JA,{align:"flex-end",children:[(0,i.jsx)(p.g3,{amount:I[x.D.CURRENCY_B],fontSize:"24px",children:null!=(t=D(I[x.D.CURRENCY_B],6))?t:"-"}),(0,i.jsxs)(m.Bp,{gap:"4px",children:[(0,i.jsx)(h.Zm,{currency:T,size:"24px"}),(0,i.jsx)(o.A,{fontSize:"24px",ml:"10px",children:null==T?void 0:T.symbol})]})]}),(0,i.jsx)(o.A,{small:!0,textAlign:"left",pt:"12px",children:U("Output is estimated. If the price changes by more than %slippage%% your transaction will revert.",{slippage:S/100})})]})},[S,P,T,I,U,B,D]),q=(0,r.useCallback)(()=>{var e,t,n;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m.JA,{children:[(0,i.jsx)(o.A,{children:U("%assetA%/%assetB% Burned",{assetA:null!=(t=null==P?void 0:P.symbol)?t:"",assetB:null!=(n=null==T?void 0:T.symbol)?n:""})}),(0,i.jsxs)(m.Bp,{children:[(0,i.jsx)(h.gz,{currency0:P,currency1:T,margin:!0}),(0,i.jsx)(o.A,{children:null==(e=I[x.D.LIQUIDITY])?void 0:e.toSignificant(6)})]})]}),b&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m.JA,{children:[(0,i.jsx)(o.A,{children:U("Price")}),(0,i.jsxs)(o.A,{children:["1 ",null==P?void 0:P.symbol," = ",(0,v.C)(b,M)," ",null==T?void 0:T.symbol]})]}),(0,i.jsxs)(m.JA,{children:[(0,i.jsx)("div",{}),(0,i.jsxs)(o.A,{children:["1 ",null==T?void 0:T.symbol," = ",(0,v.C)(b,N)," ",null==P?void 0:P.symbol]})]})]}),(0,i.jsx)(s.A,{width:"100%",mt:"20px",disabled:j!==f.h$.APPROVED&&null===k,onClick:R,children:U("Confirm")})]})},[P,T,I,j,R,b,M,N,U,k]),L=(0,r.useCallback)(()=>(0,i.jsx)(d.Y,{topContent:F,bottomContent:q}),[F,q]);return(0,i.jsx)(c.A,{title:t,onDismiss:n,customOnDismiss:g,attemptingTxn:A,hash:w,errorMessage:E,content:L,pendingText:C})}},942265:()=>{}
29,942272:(e,t,n)=>{"use strict";n.d(t,{J:()=>c,U:()=>p});var i=n(228876),r=n(670420),l=n(673384),o=n(413071),a=n(968349),s=n(419041),d=n(326848),u=n(25963);function c(){var e,t,n,l,o,u,c,m;let{chainId:x}=(0,a.ax)(),h=(0,d.useRouter)(),f=(0,s.sA)(),[v,y]=h.isReady&&x?h.query.currency||(x&&f?x===i.nU.BSC?[f.symbol,(null==(o=r.pI[x])?void 0:o.address)||(null==(u=r.vb[x])?void 0:u.address)||(null==(c=r.Q4[x])?void 0:c.address)||(null==(m=r.is[x])?void 0:m.address)]:[f.symbol,(null==(e=r.is[x])?void 0:e.address)||(null==(t=r.pI[x])?void 0:t.address)||(null==(n=r.vb[x])?void 0:n.address)||(null==(l=r.Q4[x])?void 0:l.address)]:[void 0,void 0]):[void 0,void 0];return{currencyIdA:v,currencyIdB:y,feeAmount:p()}}let p=()=>{var e;let{chainId:t}=(0,a.ax)(),n=(0,d.useRouter)(),r=(0,o.$)(),s=n.isReady&&t?null==(e=n.query.currency)?void 0:e[2]:void 0;return(0,u.useMemo)(()=>s&&((0,i.F8)(t)&&Object.values(l.dl).includes(parseFloat(s))||(0,i.fT)(t)&&Object.values(r).find(e=>e.tradeFeeRate===parseFloat(s)))?parseFloat(s):void 0,[t,r,s])}},949563:(e,t,n)=>{"use strict";n.d(t,{U:()=>x,n:()=>m});var i=n(985148),r=n(118708),l=n(656862),o=n(25963),a=n(609377),s=n(131619),d=n(733775),u=n(3197);let c=(0,l.Rq)(a.Iw),p=(0,i.eU)({state:"loading"});function m(e){let t=(0,s.JQ)(),n=(0,o.useMemo)(()=>e.map(e=>{let{address:n,chainId:i}=e;if(!n)return;let r=(0,d.QR)(n),l=r?t[r]:void 0;if(l&&(void 0===i||l.chainId===i))return l instanceof u.Xs?l.logoURI:void 0}),[e,t]),i=e.some((e,t)=>{let{enabled:i=!0}=e;return i&&!n[t]}),l=(0,r.md)(i?c:p);return(0,o.useMemo)(()=>e.map((e,t)=>{var i;let{address:r,chainId:o}=e,a=n[t];if(a)return a;if(!r||"hasData"!==l.state)return;let s=r.toLowerCase(),d=l.data.find(e=>e.address===s&&(void 0===o||e.chainId===o));return null==d||null==(i=d.logoUrls)?void 0:i.find(Boolean)}),[e,n,l])}function x(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return m((0,o.useMemo)(()=>[{address:e,chainId:t,enabled:n}],[e,t,n]))[0]}}
29,950198:(e,t,n)=>{"use strict";n.d(t,{Z:()=>h,g:()=>v});var i=n(350979),r=n(987212),l=n(311560),o=n(371309),a=n(247821),s=n(25963),d=n(856870),u=n(680797),c=n(733775),p=n(389624),m=n(949563);let x=(0,u.I4)(o.A).withConfig({componentId:"sc-3822304b-0"})(["width:",";height:",";border-radius:",";"],e=>{let{size:t}=e;return t},e=>{let{size:t}=e;return t},e=>{let{size:t}=e;return t}),h=e=>{let{address:t,size:n="24px",chainName:o="BSC",...u}=e,[h,f]=(0,s.useState)(!1),v=(0,m.U)(t,d._J[o],h),y=(0,s.useMemo)(()=>t?(0,p.A)(new l.ou(d._J[o],t,18,"")):null,[t,o]),g=(e=>"BSC"===e?"":a.H[d._J[e]]?`${a.H[d._J[e]]}/`:`${e.toLowerCase()}/`)(o),A=(0,c.QR)(t),b="ROBINHOOD"===o?null==t?void 0:t.toLowerCase():A,w=b?`https://tokens.pancakeswap.finance/images/${g}${b}.png`:void 0;A&&(0,c.ho)(A,r.Xd)&&(w=`https://assets.pancakeswap.finance/web/native/${d._J[o]}.png`);let j=(0,s.useMemo)(()=>[w,y,v].filter(e=>!!e),[w,y,v]);return(0,i.jsx)(x,{size:n,srcs:j,alt:"token logo",showBlockie:!1,onAllSrcsFailed:()=>f(!0),...u})},f=u.I4.div.withConfig({componentId:"sc-3822304b-1"})(["position:relative;display:flex;flex-direction:row;align-items:center;width:32px;"]),v=e=>{let{address0:t,address1:n,size:r=16,chainName:l="BSC"}=e;return(0,i.jsxs)(f,{children:[t&&(0,i.jsx)(h,{address:t,size:`${r.toString()}px`,chainName:l}),n&&(0,i.jsx)(h,{address:n,size:`${r.toString()}px`,chainName:l})]})}},959072:(e,t,n)=>{"use strict";n.d(t,{q:()=>p});var i=n(350979),r=n(273523),l=n(928768),o=n(97114),a=n(25963),s=n(437862),d=n(484562),u=n(435619),c=n(755407);let p=(0,a.memo)(e=>{let{data:t,detailMode:n,action:p,showAPR:m,miniMode:x}=e,{quote:h,base:f,currency0:v,currency1:y,removed:g,outOfRange:A,priceUpper:b,priceLower:w,tickAtLimit:j,amount0:k,amount1:C}=(0,s.RI)(t),{chainId:I,tokenId:S}=t,R=(0,r.Qn)(t.poolKey),E=(0,s.qX)({poolAddress:R,chainId:I}),M=(0,o.Z)({currency0:v,currency1:y,amount0:k,amount1:C}),N=(0,a.useMemo)(()=>f&&h?(0,i.jsx)(u.p,{base:f,quote:h,priceLower:w,priceUpper:b,tickAtLimit:j}):null,[f,h,w,b,j]),P=(0,a.useMemo)(()=>(0,l.Pl)({chainId:I,tokenId:Number(S),poolId:R,protocol:t.protocol}),[I,t.protocol,R,S]);return(0,i.jsx)(d.l,{chainId:I,link:P,pool:E,poolId:R,totalPriceUSD:M,amount0:k,amount1:C,desc:N,currency0:v,currency1:y,removed:g,outOfRange:A,fee:t.fee,feeTierBase:c.KF,protocol:t.protocol,isStaked:t.isStaked&&!A,tokenId:t.tokenId,detailMode:n,userPosition:t,showAPR:m,miniMode:x,children:p})})},960755:(e,t,n)=>{"use strict";n.d(t,{m:()=>a});var i=n(350979),r=n(769932),l=n(979332),o=n(314811);function a(e){var t;let{feeAmount:n,distributions:a,poolState:s}=e,{t:d}=(0,r.A)();return(0,i.jsx)(l.A,{variant:"tertiary",fontSize:"10px",padding:"4px 8px",style:{width:"fit-content",justifyContent:"center",whiteSpace:"inherit",alignSelf:"flex-end",textAlign:"center"},children:a&&s!==o.S.NOT_EXISTS&&s!==o.S.INVALID?void 0!==a[n]?`${null==(t=a[n])?void 0:t.toFixed(0)}% ${d("Pick")}`:d("No Data"):d("Not Created")})}},961862:(e,t,n)=>{"use strict";n.d(t,{N:()=>s});var i=n(543337),r=n(659197),l=n(421479),o=n(662928),a=n(25963);let s=e=>{let{data:t}=(0,o.I)({queryKey:["fetch-v3-farm-api"],queryFn:async()=>{if(e){let t=await (0,i.v)(e,r.Zs.V3);return(0,l.b)(t)}return[]},enabled:!!e,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1});return{farms:(0,a.useMemo)(()=>null!=t?t:[],[t])}}},971733:(e,t,n)=>{"use strict";n.d(t,{R:()=>i.R4});var i=n(53847)},973589:(e,t,n)=>{e.exports=n(562038)("toUpperCase")},977418:(e,t,n)=>{"use strict";n.d(t,{n:()=>v});var i=n(350979),r=n(769932),l=n(796898),o=n(672946),a=n(619749),s=n(188882),d=n(21354),u=n(796147),c=n(24153),p=n(995315),m=n(605641),x=n(823585),h=n(898719);let f=e=>{let{currency:t,earningsAmount:n,earningsUsd:r,rowProps:l}=e;return(0,i.jsxs)(u.mm,{children:[(0,i.jsxs)(c.fI,{gap:"8px",...l,children:[(0,i.jsx)(h.Z,{currency:t,size:"16px"}),(0,i.jsxs)(p.A,{gap:"8px",children:[(0,i.jsx)(m.A,{fontSize:"12px",color:"textSubtle",children:(0,x.ZV)(n)}),(0,i.jsxs)(m.A,{fontSize:"12px",color:"textSubtle",fontWeight:600,children:[" ",t.symbol," "]})]})]}),(0,i.jsx)(c.fI,{gap:"8px",justifyContent:"flex-end",children:(0,i.jsxs)(m.A,{fontSize:"12px",color:"textSubtle",children:["~$",(0,x.ZV)(r)]})})]})},v=e=>{var t,n,u,c,p,m,x,h,v,y,g,A;let{pool:b,position:w,rowProps:j}=e,{t:k}=(0,r.A)(),{breakdownRewardInfo:C}=(0,s.n)({poolInfo:b,position:w}),{isMobile:I}=(0,l.A)(),S=Math.max(C.rewards.length,2),R=C.rewards.length>0&&C.rewards.some(e=>Number(e.amount)>0),E=Number(null==(t=C.fee.A)?void 0:t.amount)>0||Number(null==(n=C.fee.B)?void 0:n.amount)>0;return R||E?(0,i.jsxs)(i.Fragment,{children:[R&&(0,i.jsxs)(o.A,{gridGap:"8px",alignItems:"flex-start",gridTemplateColumns:I?"1fr":"80px 1fr",children:[(0,i.jsxs)(d.gI,{children:[k("Farm Rewards"),":"]}),(0,i.jsx)(o.A,{gridTemplateColumns:I?"1fr 1fr":`repeat(${S}, minmax(120px, 1fr))`,gridGap:"8px",children:C.rewards.filter(e=>Number(e.amount)>0).map((e,t)=>(0,i.jsx)(f,{currency:(0,a.ph)(e.mint),earningsAmount:Number(e.amount),earningsUsd:Number(e.amountUSD),rowProps:{justifyContent:I?"space-between":"flex-end"}},t))})]}),E&&(0,i.jsxs)(o.A,{gridGap:"8px",alignItems:"flex-start",gridTemplateColumns:I?"1fr":"90px 1fr",children:[(0,i.jsxs)(d.gI,{children:[k("LP Fees"),": "]}),(0,i.jsxs)(o.A,{gridTemplateColumns:I?"1fr 1fr":`repeat(${S}, minmax(120px, 1fr))`,gridGap:"8px",children:[(null==(u=C.fee.A)?void 0:u.mint)&&Number(null==(c=C.fee.A)?void 0:c.amount)>0?(0,i.jsx)(f,{currency:(0,a.ph)(null==(p=C.fee.A)?void 0:p.mint),earningsAmount:Number(null==(m=C.fee.A)?void 0:m.amount),earningsUsd:Number(null==(x=C.fee.A)?void 0:x.amountUSD),rowProps:{justifyContent:I?"space-between":"flex-end"}}):null,(null==(h=C.fee.B)?void 0:h.mint)&&Number(null==(v=C.fee.B)?void 0:v.amount)>0?(0,i.jsx)(f,{currency:(0,a.ph)(null==(y=C.fee.B)?void 0:y.mint),earningsAmount:Number(null==(g=C.fee.B)?void 0:g.amount),earningsUsd:Number(null==(A=C.fee.B)?void 0:A.amountUSD),rowProps:{justifyContent:I?"space-between":"flex-end"}}):null]})]})]}):null}},977973:(e,t,n)=>{"use strict";n.d(t,{Q:()=>U,j:()=>T});var i=n(350979),r=n(769932),l=n(796898),o=n(580213),a=n(662928),s=n(899188),d=n(326848),u=n(25963),c=n(569791),p=n(949563),m=n(259145),x=n(456194),h=n(302485);let f=(e,t)=>`${null!=e?e:""}:${t.toLowerCase()}`;var v=n(985148),y=n(118708),g=n(656862);n(659918),n(905470),n(91168),n(833438),n(170601),n(437862);var A=n(680797);n(514546);var b=n(605641);(0,A.Ay)(b.A).withConfig({componentId:"sc-64d92e63-0"})(["color:",";font-family:Kanit;font-weight:500;font-size:12px;line-height:18px;letter-spacing:2%;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),(0,A.Ay)(b.A).withConfig({componentId:"sc-64d92e63-1"})(["color:",";font-family:Kanit;font-weight:600;font-size:14px;line-height:21px;letter-spacing:0%;"],e=>{let{theme:t}=e;return t.colors.textSubtle}),A.Ay.div.withConfig({componentId:"sc-64d92e63-2"})(["background-color:",";display:flex;flex-direction:column;align-items:center;justify-content:center;border-radius:24px;margin-right:4px;padding:2px 10px;transition:transform 0.2s ease,box-shadow 0.2s ease;&:hover{transform:translateY(-2px);box-shadow:0 4px 8px rgba(0,0,0,0.15);}"],function(e){let{theme:t,color:n}=e;return t.colors[n]}),n(21109),n(391322),n(950198),A.Ay.div.withConfig({componentId:"sc-42957db2-0"})(["position:absolute;z-index:2;width:71px;height:71px;left:7px;top:4px;"]),A.Ay.img.withConfig({componentId:"sc-cf50c813-0"})(["position:absolute;bottom:46px;right:12px;z-index:3;width:24px;height:24px;"]);let w=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now();return Math.floor(e/3e5)},j=[],k=(0,v.eU)(async()=>{let e=w(),t=`https://proofs.pancakeswap.com/picks/today.json?t=${e}`;try{let e=await fetch(t);if(!e.ok)return null;let n=await e.json();if(!n||!Array.isArray(n.configs))return null;return n}catch(e){return null}}),C=(0,g.Rq)(k),I=[];var S=n(772155),R=n(284454);let E=R.z.object({totalTvlUSD:R.z.number().finite().nonnegative(),groups:R.z.array(R.z.object({label:R.z.string(),tvlUSD:R.z.number().finite().nonnegative(),volumeUSD24h:R.z.number().finite().nonnegative()}
29))}),M=[{label:"V2 TVL",value:"-",volume:"-"},{label:"V3 TVL",value:"-",volume:"-"},{label:"Infinity",value:"-",volume:"-"}],N=e=>e>0?`$${(0,x.e)(e)}`:"-",P=async e=>{let t=await fetch("/api/earn/header-stats",{signal:e});if(!t.ok)throw Error(`Failed to fetch Earn header stats: ${t.status}`);return(e=>{let t=E.safeParse(e);if(!t.success)throw Error("Invalid Earn header stats response");return t.data})(await t.json())},T=(e,t)=>{let{t:n}=(0,r.A)(),{isMobile:v}=(0,l.A)(),g=(0,d.useRouter)(),A=function(){let e=(()=>{var e,t;let n=(0,y.md)(C);return"hasData"===n.state&&null!=(t=null==(e=n.data)?void 0:e.configs)?t:j})(),t=(0,d.useRouter)(),n=(0,u.useMemo)(()=>(function(e,t){let n=new Set,i=new Set;for(let{chain:r,token0:l,token1:o}of e){let e=t(r);void 0!==e&&(n.add(e),i.add(`${e}:${l.address.toLowerCase()}`),i.add(`${e}:${o.address.toLowerCase()}`))}return 0===n.size||0===i.size?null:{chains:[...n],protocols:[],sortBy:"tvlUsd",tokensAll:[...i]}})(e,s.TH),[e]),{data:i}=(0,a.I)({queryKey:["earn-pancake-picks",null==n?void 0:n.chains,null==n?void 0:n.tokensAll],queryFn:async()=>n?(await (0,c.Xw)(n)).farms:[],enabled:!!n,staleTime:6e4,refetchOnWindowFocus:!1}),r=(0,u.useMemo)(()=>e.flatMap(e=>{let{chain:t,token0:n,token1:i}=e,r=(0,s.TH)(t);return[{address:n.address,chainId:r,enabled:!n.img},{address:i.address,chainId:r,enabled:!i.img}]}),[e]),l=(0,p.n)(r);return(0,u.useMemo)(()=>{if(!i||0===i.length)return I;let n=function(e){let t={};for(let n of e){let e=f(n.chainId,n.id);t[e]||(t[e]=n)}return t}(i);return e.flatMap((e,i)=>{let r,o,{poolId:a,chain:d,token0:u,token1:c,url:p}=e,v=n[f((0,s.TH)(d),a)];return v?[{id:a,symbols:[u.symbol,c.symbol],logoUrls:(r=[u.img,c.img],o=[l[2*i],l[2*i+1]],[r[0]||o[0],r[1]||o[1]]),pair:`${u.symbol} / ${c.symbol}`,...function(e){var t;let n=(0,h.h)(e.lpApr,null==(t=e.cakeApr)?void 0:t.value,e.merklApr,e.incentraApr),i=Number(e.tvlUSD);return{fee:`${Number(e.feeTier)/1e4}%`,apr:`${(100*n).toFixed(2)}%`,tvl:i?`$${(0,x.e)(i)}`:"-"}}(v),onClick:()=>{(0,m.EY)(`${u.symbol}/${c.symbol}`),t.push(p)}}]:[]})},[e,i,l,t])}(),{totalTvl:b,metrics:w}=(()=>{let{data:e}=(0,a.I)({queryKey:["earn-header-protocol-tvl"],queryFn:e=>{let{signal:t}=e;return P(t)},staleTime:36e5,refetchOnWindowFocus:!1});return e?{totalTvl:N(e.totalTvlUSD),metrics:e.groups.filter(e=>"Infinity"!==e.label).map(e=>({label:e.label,value:N(e.tvlUSD),volume:N(e.volumeUSD24h)}))}:{totalTvl:"-",metrics:M}})(),k=(0,u.useCallback)(()=>{window.open("https://docs.pancakeswap.finance/products/yield-farming/how-to-use-farms","_blank","noopener noreferrer")},[]),S=(0,u.useCallback)(()=>{e&&g.push(e)},[e,g]),R={heading:(0,i.jsxs)(i.Fragment,{children:[n("Earn from")," ",(0,i.jsx)(o.Gu,{children:n("Liquidity Pools")})," &"," ",(0,i.jsx)(o.Gu,{children:n("Farms")})]}),totalTvl:b,metrics:w,picks:A,feeLabel:n("Fee"),aprLabel:n("APR"),tvlLabel:n("TVL"),learnHowLabel:n("Learn How"),onLearnHow:k,legacyLabel:null!=t?t:n("Legacy Farm Page"),onLegacy:e?S:void 0};return{isMobile:v,desktopProps:{...R,picksLabel:n("Pancake picks \uD83D\uDD25")},mobileProps:R}},U=e=>{let{oldLink:t,oldLinkText:n}=e,{isMobile:r,desktopProps:l,mobileProps:a}=T(t,n);return(0,i.jsxs)(i.Fragment,{children:[r?(0,i.jsx)(o.iC,{...a}):(0,i.jsx)(o.YS,{...l}),(0,i.jsx)(S.A,{})]})}},981830:(e,t,n)=>{"use strict";n.d(t,{C:()=>d,a:()=>s});var i=n(662928),r=n(529208),l=n(668458),o=n(466809),a=n(252146);function s(e,t){let n=Number(e),[o]=(0,a.r)(),{data:s,isLoading:d}=(0,i.I)({queryKey:["useInfinityPositionFromTokenId",n,t,null==o?void 0:o.blockHash],queryFn:()=>(0,l.ar)(t,n?[n]:[]),enabled:!!(t&&n),staleTime:r.IX,refetchInterval:r.IX,placeholderData:e=>e});return{isLoading:d,position:null==s?void 0:s[0]}}function d(e,t,n){let[l]=(0,a.r)();return(0,i.I)({queryKey:["account-infinity-bin-position",e,n,t,null==l?void 0:l.blockHash],queryFn:()=>(0,o._)({chainId:t,poolId:e,account:n}).then(e=>null!=e?e:null),enabled:!!e&&!!n&&!!t,staleTime:r.IX,refetchInterval:r.IX,placeholderData:e=>e})}},989601:(e,t,n)=>{var i=n(568618),r=n(486821),l=n(132781);e.exports=function(e){return function(t,n,o){return o&&"number"!=typeof o&&r(t,n,o)&&(n=o=void 0),t=l(t),void 0===n?(n=t,t=0):n=l(n),o=void 0===o?t<n?1:-1:l(o),i(t,n,o,e)}}},990056:(e,t,n)=>{"use strict";n.d(t,{L:()=>D});var i=n(350979),r=n(769932),l=n(24153),o=n(557423),a=n(795904),s=n(892977),d=n(334404),u=n(549333),c=n(659918),p=n(694723),m=n(91168),x=n(227883),h=n(885334),f=n(389512),v=n(665548),y=n(25963),g=n(437862),A=n(342746),b=n(776808),w=n(252146),j=n(680797),k=n(202425),C=n(974134),I=n(282692),S=n(302485),R=n(17581),E=n(734658),M=n(135606),N=n(427896);let P=e=>{let{disabled:t,onDeposit:n}=e,{t:l}=(0,r.A)();return(0,i.jsx)(o.A,{onClick:n,disabled:t,children:l("Stake LP")})},T=e=>{let{onHarvest:t,executing:n,disabled:l}=e,{t:a}=(0,r.A)();return(0,i.jsx)(o.A,{disabled:l,onClick:t,children:a(n?"Harvesting":"Harvest")})},U=(0,j.Ay)(l.eF).withConfig({componentId:"sc-8f10a449-0"})(["flex-direction:row;gap:8px;& button{flex:1;}"]),B=e=>{let{compact:t=!1,increaseDisabled:n=!1,decreaseDisabled:l=!1,showIncreaseBtn:d=!0,showDecreaseBtn:u=!0,onIncrease:c,onDecrease:p}=e,{t:m}=(0,r.A)();return(0,i.jsxs)(i.Fragment,{children:[u&&(0,i.jsx)(o.A,{variant:"primary60Outline",scale:"md",disabled:l,onClick:p,children:t?(0,i.jsx)(a.A,{color:"primary",width:"24px"}):m("Unstake")}),d&&(0,i.jsx)(o.A,{variant:"primary60Outline",scale:"md",disabled:n,onClick:c,children:t?(0,i.jsx)(s.A,{color:"primary",width:"24px"}):m("Stake")})]})},D=(0,y.memo)(e=>{let{isStaked:t,...n}=e;return(0,i.jsx)(N.L,{children:(0,i.jsx)(U,{gap:"sm",children:t?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(q,{...n}),(0,i.jsx)(O,{...n})]}):(0,i.jsx)(L,{...n})})})}),F=e=>{var t;let{chainId:n,data:l,pid:o,lpAddress:a,tvlUsd:s,poolInfo:b}=e,{address:j}=(0,R.F)(),C=(0,h.T)(),{toastSuccess:N}=(0,d.d)(),{fetchWithCatchTxError:P}=(0,f.A)(),{t:T}=(0,r.A)(),U=(0,y.useMemo)(()=>`${n}:${a}`,[n,a]),{lpApr:B,cakeApr:D,merklApr:F,incentraApr:q}=(0,g.nY)(U,b),L=(0,y.useMemo)(()=>(0,S.h)(B,D.value,F,q),[B,D.value,F,q]),[O,_]=(0,y.useState)();(0,y.useEffect)(()=>{(async()=>{let e=await (0,M.fetchAllUniversalFarmsMap)();_(await (0,A.ou)(a,n,e))})()},[a,n]);let{allowance:$}=(0,v.Q)({chainId:n,token:l.pair.liquidityToken,owner:j,spender:O}),Y=(0,y.useMemo)(()=>new m.A(l.totalSupply.quotient.toString()),[l.totalSupply]),z=(0,y.useMemo)(()=>new m.A(l.nativeBalance.quotient.toString()),[l.nativeBalance]),V=(0,y.useMemo)(()=>new m.A(l.farmingBalance.quotient.toString()),[l.farmingBalance]),{onStake:Z,onApprove:W}=(0,I.F)(a,b.bCakeWrapperAddress),H=(0,y.useMemo)(()=>`${l.pair.token0.symbol}-${l.pair.token1.symbol} LP`,[l.pair.token0.symbol,l.pair.token1.symbol]),Q=(0,y.useMemo)(()=>new m.A(null!=s?s:0).dividedBy(l.totalSupply.toExact()),[l.totalSupply,s]),[,G]=(0,w.r)(),K=(0,y.useCallback)(async e=>{let t=await P(()=>Z(e));(null==t?void 0:t.status)&&(G(t),N(`${T("Staked")}!`,(0,i.jsx)(x.G,{txHash:t.transactionHash,children:T("Your funds have been staked in the farm")})))},[G,P,Z,T,N]),X=(0,y.useCallback)(async()=>
29{if(!b.bCakeWrapperAddress)return;let e=await P(()=>W());(null==e?void 0:e.status)&&(G(e),N(T("Contract Enabled"),(0,i.jsx)(x.G,{txHash:e.transactionHash})))},[b.bCakeWrapperAddress,P,W,G,N,T]),J=(0,y.useMemo)(()=>{let e=(0,k.A)({quoteTokenAddress:(0,E.eG)(b.token0),tokenAddress:(0,E.eG)(b.token1),chainId:b.chainId});return`/add/${e}`},[b.chainId,b.token0,b.token1]),[ee]=(0,u.A)((0,i.jsx)(p.X.qV,{addLiquidityUrl:J,account:j,pid:null!=o?o:0,lpTotalSupply:Y,tokenName:H,lpLabel:H,hideTokenName:!0,max:z,stakedBalance:V,decimals:18,cakePrice:C,allowance:$?new m.A($.quotient.toString()):c.AH,onConfirm:K,handleApprove:X,lpPrice:Q,apr:100*parseFloat(null!=(t=null==D?void 0:D.value)?t:"0"),displayApr:(100*L).toString(),lpRewardsApr:100*parseFloat(B)}),!0,!0,`farm-deposit-modal-${o}-${a}`);return ee},q=e=>{let{data:t,chainId:n,lpAddress:l,tvlUsd:o,isFarmLive:a,poolInfo:s}=e,{switchNetworkIfNecessary:h}=(0,C.Hk)(),v=F(e),g=((e,t,n,l)=>{let{t:o}=(0,r.A)(),{onUnStake:a}=(0,I.F)(t,n),s=(0,y.useMemo)(()=>`${e.pair.token0.symbol}-${e.pair.token1.symbol} LP`,[e.pair.token0.symbol,e.pair.token1.symbol]),h=(0,y.useMemo)(()=>new m.A(null!=l?l:0).dividedBy(e.totalSupply.toExact()),[e.totalSupply,l]),v=(0,y.useMemo)(()=>new m.A(e.farmingBalance.quotient.toString()),[e.farmingBalance]),{toastSuccess:g}=(0,d.d)(),{fetchWithCatchTxError:A}=(0,f.A)(),[,b]=(0,w.r)(),j=(0,y.useCallback)(async e=>{let t=await A(()=>a(e));(null==t?void 0:t.status)&&(b(t),g(`${o("Unstaked.status")}!`,(0,i.jsx)(x.G,{txHash:t.transactionHash,children:o("Your earnings have also been harvested to your wallet")})))},[b,A,a,o,g]),[k]=(0,u.A)((0,i.jsx)(p.X._s,{max:null!=v?v:c.AH,onConfirm:j,lpPrice:h,tokenName:s,decimals:18}));return k})(t,l,s.bCakeWrapperAddress,o),A=(0,y.useCallback)(async()=>{await h(n)||v()},[n,v,h]),b=(0,y.useCallback)(async()=>{await h(n)||g()},[n,g,h]),j=t.farmingBalance.greaterThan(0);return(0,i.jsx)(B,{showIncreaseBtn:a,showDecreaseBtn:j,onIncrease:A,onDecrease:b})},L=e=>{let{chainId:t,isFarmLive:n}=e,{switchNetworkIfNecessary:r}=(0,C.Hk)(),l=F(e),o=(0,y.useCallback)(async()=>{await r(t)||l()},[t,r,l]);return n?(0,i.jsx)(P,{onDeposit:o}):null},O=e=>{let{chainId:t,lpAddress:n,poolInfo:l}=e,{t:o}=(0,r.A)(),{address:a}=(0,R.F)(),{switchNetworkIfNecessary:s}=(0,C.Hk)(),{onHarvest:u}=(0,I.F)(n,l.bCakeWrapperAddress),{toastSuccess:c}=(0,d.d)(),{fetchWithCatchTxError:p,loading:h}=(0,f.A)(),[,v]=(0,w.r)(),{data:g}=(0,b.f)(a,{chainId:t,lpAddress:n,bCakeWrapperAddress:l.bCakeWrapperAddress}),A=(0,y.useMemo)(()=>{var e;return new m.A(null!=(e=null==g?void 0:g.toString())?e:"0")},[g]),j=(0,y.useCallback)(async()=>{if(await s(t))return;let e=await p(u);(null==e?void 0:e.status)&&(v(e),c(`${o("Harvested")}!`,(0,i.jsx)(x.G,{txHash:e.transactionHash,children:o("Your %symbol% earnings have been sent to your wallet!",{symbol:"CAKE"})})))},[s,t,p,u,v,c,o]);return!A||A.isZero()?null:(0,i.jsx)(T,{onHarvest:j,executing:h,disabled:h})}}},e=>{e.O(0,[7964,3821,5139,7578,3732,4306,4374,3892,2845,7121,7061,2806,6175,7171,9596,2141,3577,6341,5442,6270,7881,2259,2299,7275,7212,840,1480,4711,9818,7635,64,5597,6283,2775,9508,806,9906,4712,8514,4641,5452,6010,4522,8708,6932,2911,2269,3484,777,245,7094,2457,1729,7207,6763,8268,8528,7110,8157,2570,636,6593,8792],()=>e(e.s=171751)),_N_E=e.O()}]);
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.