PageSourceSearch

https://app.hypurrfi.com/_next/static/chunks/6540-bc3c3afa35ef7d66.js?dpl=dpl_3yMFDF8rPtDHwaabifc6ARdmVzNd

js hypurrfi.com collected 2026-10-10 00:44:47 UTC 87,774 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6540],{3251:(e,t,o)=>{o.d(t,{T:()=>R});var r=o(43238),s=o(44098),n=o(8424),a=o(93164),l=o(69099),i=o(87921),u=o(98223),d=o(67817),c=o(83493),m=o(13142),f=o(26873),p=o(28609),x=o(21239),h=o(31142),v=o(72137),b=o(92307),g=o(75142),y=o(35255),w=o(54646),k=o(62100),N=o(64715),C=o(30850),j=o(30161),A=o(50161),S=o(77862),V=o(35866);let T=(0,r.jsxs)("svg",{width:"42",height:"32",viewBox:"0 0 42 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("rect",{width:"42",height:"32",rx:"6",fill:"#212121"}),(0,r.jsx)("g",{clipPath:"url(#clip0_3823_6897)",children:(0,r.jsxs)("g",{clipPath:"url(#clip1_3823_6897)",children:[(0,r.jsx)("path",{d:"M36 0H6C2.68629 0 0 2.68629 0 6V26C0 29.3137 2.68629 32 6 32H36C39.3137 32 42 29.3137 42 26V6C42 2.68629 39.3137 0 36 0Z",fill:"#97FCE4"}),(0,r.jsx)("path",{d:"M31.8226 15.8991C31.8226 23.0173 27.443 25.3014 25.1356 23.2677C23.2361 21.6094 22.671 18.105 19.814 17.7452C16.1879 17.2915 15.874 22.0944 13.4879 22.0944C10.7095 22.0944 10.1758 18.0737 10.1758 16.0087C10.1758 13.8966 10.7723 11.018 13.1426 11.018C15.9054 11.018 16.0623 15.1326 19.5158 14.9135C22.9535 14.6789 23.0163 10.3923 25.2455 8.56186C27.1919 6.98175 31.8226 8.68701 31.8226 15.8991Z",fill:"#072723"}),(0,r.jsx)("path",{d:"M5.06 29.5V23.74H8.78V24.644H6.024V26.064H8.3V26.968H6.024V28.596H8.78V29.5H5.06ZM10.9357 29.5L9.11969 23.74H10.1117L11.6317 28.564L13.1717 23.74H14.1637L12.3477 29.5H10.9357ZM14.6647 29.5V23.74H15.5327L17.5247 27.82L19.5167 23.74H20.3847V29.5H19.4847V25.808L17.7167 29.5H17.3327L15.5687 25.808V29.5H14.6647Z",fill:"#072723"})]})}),(0,r.jsxs)("defs",{children:[(0,r.jsx)("clipPath",{id:"clip0_3823_6897",children:(0,r.jsx)("rect",{width:"42",height:"32",fill:"white"})}),(0,r.jsx)("clipPath",{id:"clip1_3823_6897",children:(0,r.jsx)("rect",{width:"42",height:"32",fill:"white"})})]})]}),L=(0,r.jsxs)("svg",{width:"42",height:"32",viewBox:"0 0 42 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("g",{clipPath:"url(#clip0_3823_6906)",children:(0,r.jsxs)("g",{clipPath:"url(#clip1_3823_6906)",children:[(0,r.jsx)("path",{d:"M36 0H6C2.68629 0 0 2.68629 0 6V26C0 29.3137 2.68629 32 6 32H36C39.3137 32 42 29.3137 42 26V6C42 2.68629 39.3137 0 36 0Z",fill:"#97FCE4"}),(0,r.jsx)("path",{d:"M31.8226 15.8991C31.8226 23.0173 27.443 25.3014 25.1356 23.2677C23.2361 21.6094 22.671 18.105 19.814 17.7452C16.1879 17.2915 15.874 22.0944 13.4879 22.0944C10.7095 22.0944 10.1758 18.0737 10.1758 16.0087C10.1758 13.8966 10.7723 11.018 13.1426 11.018C15.9054 11.018 16.0623 15.1326 19.5158 14.9135C22.9535 14.6789 23.0163 10.3923 25.2455 8.56186C27.1919 6.98175 31.8226 8.68701 31.8226 15.8991Z",fill:"#072723"}),(0,r.jsx)("path",{d:"M7.996 29.12C7.42 29.12 6.92667 28.9947 6.516 28.744C6.10533 28.4907 5.78933 28.1387 5.568 27.688C5.34933 27.2373 5.24 26.7147 5.24 26.12C5.24 25.5253 5.34933 25.0027 5.568 24.552C5.78933 24.1013 6.10533 23.7507 6.516 23.5C6.92667 23.2467 7.42 23.12 7.996 23.12C8.66 23.12 9.21333 23.2867 9.656 23.62C10.0987 23.9507 10.4093 24.3973 10.588 24.96L9.616 25.228C9.504 24.852 9.31333 24.5587 9.044 24.348C8.77467 24.1347 8.42533 24.028 7.996 24.028C7.60933 24.028 7.28667 24.1147 7.028 24.288C6.772 24.4613 6.57867 24.7053 6.448 25.02C6.32 25.332 6.25467 25.6987 6.252 26.12C6.252 26.5413 6.316 26.9093 6.444 27.224C6.57467 27.536 6.76933 27.7787 7.028 27.952C7.28667 28.1253 7.60933 28.212 7.996 28.212C8.42533 28.212 8.77467 28.1053 9.044 27.892C9.31333 27.6787 9.504 27.3853 9.616 27.012L10.588 27.28C10.4093 27.8427 10.0987 28.2907 9.656 28.624C9.21333 28.9547 8.66 29.12 7.996 29.12ZM13.2743 29.12C12.8423 29.12 12.4649 29.0227 12.1423 28.828C11.8196 28.6333 11.5689 28.3653 11.3903 28.024C11.2143 27.68 11.1263 27.2853 11.1263 26.84C11.1263 26.3867 11.2169 25.9893 11.3983 25.648C11.5796 25.3067 11.8316 25.04 12.1543 24.848C12.4769 24.656 12.8503 24.56 13.2743 24.56C13.7089 24.56 14.0876 24.6573 14.4103 24.852C14.7329 25.0467 14.9836 25.316 15.1623 25.66C15.3409 26.0013 15.4303 26.3947 15.4303 26.84C15.4303 27.288 15.3396 27.684 15.1583 28.028C14.9796 28.3693 14.7289 28.6373 14.4063 28.832C14.0836 29.024 13.7063 29.12 13.2743 29.12ZM13.2743 28.216C13.6583 28.216 13.9436 28.088 14.1303 27.832C14.3169 27.576 14.4103 27.2453 14.4103 26.84C14.4103 26.4213 14.3156 26.088 14.1263 25.84C13.9369 25.5893 13.6529 25.464 13.2743 25.464C13.0156 25.464 12.8023 25.5227 12.6343 25.64C12.4689 25.7547 12.3463 25.916 12.2663 26.124C12.1863 26.3293 12.1463 26.568 12.1463 26.84C12.1463 27.2587 12.2409 27.5933 12.4303 27.844C12.6223 28.092 12.9036 28.216 13.2743 28.216ZM16.2116 29V24.68H17.0636V25.732L16.9596 25.596C17.0129 25.452 17.0836 25.3213 17.1716 25.204C17.2622 25.084 17.3702 24.9853 17.4956 24.908C17.6022 24.836 17.7196 24.78 17.8476 24.74C17.9782 24.6973 18.1116 24.672 18.2476 24.664C18.3836 24.6533 18.5156 24.6587 18.6436 24.68V25.58C18.5156 25.5427 18.3676 25.5307 18.1996 25.544C18.0342 25.5573 17.8849 25.604 17.7516 25.
1684C17.6182 25.756 17.5089 25.848 17.4236 25.96C17.3409 26.072 17.2796 26.2 17.2396 26.344C17.1996 26.4853 17.1796 26.6387 17.1796 26.804V29H16.2116ZM21.1927 29.12C20.7554 29.12 20.3714 29.0253 20.0407 28.836C19.7101 28.6467 19.4514 28.384 19.2647 28.048C19.0807 27.712 18.9887 27.3253 18.9887 26.888C18.9887 26.416 19.0794 26.0067 19.2607 25.66C19.4421 25.3107 19.6941 25.04 20.0167 24.848C20.3394 24.656 20.7127 24.56 21.1367 24.56C21.5847 24.56 21.9647 24.6653 22.2768 24.876C22.5914 25.084 22.8248 25.3787 22.9767 25.76C23.1288 26.1413 23.1861 26.5907 23.1487 27.108H22.1927V26.756C22.1901 26.2867 22.1074 25.944 21.9448 25.728C21.7821 25.512 21.5261 25.404 21.1767 25.404C20.7821 25.404 20.4887 25.5267 20.2967 25.772C20.1047 26.0147 20.0087 26.3707 20.0087 26.84C20.0087 27.2773 20.1047 27.616 20.2967 27.856C20.4887 28.096 20.7687 28.216 21.1367 28.216C21.3741 28.216 21.5781 28.164 21.7487 28.06C21.9221 27.9533 22.0554 27.8 22.1488 27.6L23.1007 27.888C22.9354 28.2773 22.6794 28.58 22.3328 28.796C21.9888 29.012 21.6088 29.12 21.1927 29.12ZM19.7047 27.108V26.38H22.6768V27.108H19.7047Z",fill:"#072723"})]})}),(0,r.jsxs)("defs",{children:[(0,r.jsx)("clipPath",{id:"clip0_3823_6906",children:(0,r.jsx)("rect",{width:"42",height:"32",fill:"white"})}),(0,r.jsx)("clipPath",{id:"clip1_3823_6906",children:(0,r.jsx)("rect",{width:"42",height:"32",fill:"white"})})]})]});var F=o(49801),I=o(67868),E=o(33243);let P={Core:L,EVM:T};function U(e){var t,o;let{assets:s,selectedAsset:n,setSelectedAsset:a,withFormControl:l,disabled:i,resetBorrowStatus:d}=e,c=(0,j.i)(),[m,f]=(0,h.useState)(!1),[x,v]=(0,h.useState)(""),[b,T]=(0,h.useState)("All"),L=l?u.MJ:h.Fragment,{nativeAssetInfo:U}=(0,A.U)(c).markets||{},[D,_]=(0,h.useState)(0),M=s.length<=1,H=s.filter(e=>{let t=(0,V.d1)(e.token.symbol),o=(0,V.d1)(e.token.name),r=(0,V.d1)(x);if("Core"===b){if(!("tokenId"in e))return!1}else if("EVM"===b&&"tokenId"in e)return!1;return t.includes(r)||o.includes(r)});return(0,h.useEffect)(()=>{let e=null;function t(){e&&clearTimeout(e),e=setTimeout(()=>{var e;_(((null==(e=window.visualViewport)?void 0:e.height)||window.innerHeight)-148)},200)}if(m){var o,r;return _(((null==(o=window.visualViewport)?void 0:o.height)||window.innerHeight)-148),null==(r=window.visualViewport)||r.addEventListener("resize",t),()=>{var o;null==(o=window.visualViewport)||o.removeEventListener("resize",t),e&&clearTimeout(e)}}return()=>{e&&clearTimeout(e)}},[m]),(0,r.jsxs)(y.lG,{open:m,onOpenChange:function(e){f(e),v("")},children:[(0,r.jsxs)(y.zM,{className:(0,k.cn)("flex h-14 w-36 items-center justify-between rounded-sm border border-input bg-input px-4 py-4","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",i&&"cursor-not-allowed opacity-70",M&&"pointer-events-none"),disabled:i&&!d||M,"data-testid":N.b.component.AssetSelector.trigger,"aria-label":"Asset selector",children:[(0,r.jsx)(L,{children:(0,r.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[n&&(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(w.x,{token:n.token,isL1:"tokenId"in n,disableEulerFallback:!0,className:"h-6 w-6"}),"tokenId"in n&&(0,r.jsx)(E.j,{})]}),(0,r.jsx)(p.o,{className:"whitespace-nowrap text-foreground",children:(0,r.jsx)("span",{title:null!=(t=null==n?void 0:n.token.symbol)?t:"",children:(0,I.Ce)(null!=(o=null==n?void 0:n.token.symbol)?o:"",8)})})]})}),!M&&(0,r.jsx)(F.A,{className:"h-5 w-5 text-icon-foreground"})]}),(0,r.jsxs)(y.Cf,{className:"md:data-[state=closed]:slide-out-to-top-[16px] md:data-[state=open]:slide-in-from-top-[16px] border border-border bg-background pt-6 md:top-24 md:min-w-0 md:max-w-md md:pb-2","aria-describedby":void 0,contentVerticalPosition:"top",overlayClassName:"z-[240]",closeClassName:"top-6",children:[(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)(y.L3,{children:(0,r.jsx)(p.o,{variant:"p",className:"font-bold text-lg",gradient:!0,children:"Select token"})}),(0,r.jsx)(S.D,{value:x,placeholder:"Search tokens...",onChange:e=>v(e.target.value)})]}),(0,r.jsxs)("div",{className:"space-y-2 overflow-y-auto md:max-h-80",style:{height:Math.max(D,300)},children:[(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("div",{className:"flex flex-row flex-wrap gap-2",children:["All","EVM","Core"].map(e=>(0,r.jsx)("div",{className:(0,k.cn)(b===e?"box-gradient":""),children:(0,r.jsx)("button",{onClick:()=>{T(e)},className:(0,k.cn)("flex flex-row items-center gap-2 rounded-xs border-2",b===e?"border-border bg-accent":""),children:"All"===e?(0,r.jsx)("p",{className:"px-3 py-1 text-foreground",children:"All"}):(0,r.jsx)(r.Fragment,{children:(null==P?void 0:P[e])&&(0,r.jsx)("div",{children:null==P?void 0:P[e]})})})},"featured-".concat(e)))})}),(0,r.jsx)(p.o,{variant:"p",className:"pt-3 font-semibold",children:"Tokens"}),H.map(e=>{let t=e.token.symbol===(null==U?void 0:U.wrappedNativeAssetSymbol)?e.token:(0,C.SG)(c,e.token),o="tokenId"in e;return(0,r.jsx)("button",{className:"flex w-full items-center rounded-sm p-3 transition-colors hover:bg-muted",onClick:()=>{var t;return t=e.token.symbol,void(i&&d&&d(),null==a||a((0,g.C)(t),o),f(!1))},"data-testid":N.b.component.AssetSelector.option,children:(0,r.jsxs)("div",{className:(0,k.cn)("flex w-full flex-row justify-between",e.balance&&"w-full"),children:[(0,r.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(w.x,{token:t,isL1:o,disableEulerFallback:!0,className:"h-6 w-6"}),o&&(0,r.jsx)(E.j,{variant:"primary"})]}),(0,r.jsxs)("div",{className:"flex flex-col text-left",children:[(0,r.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,r.jsx)(p.o,{className:"font-semibold",children:t.symbol}),(0,r.jsx)(p.o,{variant:"prompt",children:t.name})]}),(0,r.jsxs)(p.o,{variant:"prompt",children:["On ",o?"HyperCore":"HyperEVM"]})]})]}),(0,r.jsx)("div",{className:"flex flex-row items-center",children:(0,r.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[e.token.unitPriceUsd.gt(0)&&e.balance.gt(0)&&(0,r.jsx)(p.o,{className:"text-sm",children:e.token.formatUSD(e.balance)}),e.balance.gt(0)&&(0,r.jsx)(p.o,{variant:"prompt",children:e.token.format(e.balance,{style:"compact"})})]})})]})},"".concat(e.token.address,"-").concat(e.token.symbol,"-").concat(o))}),0===H.length&&(0,r.jsx)("div",{className:"p-4 text-center",children:(0,r.jsx)(p.o,{variant:"prompt",children:"No assets found"})})]})]})]})}var D=o(57067);
1function _(e){let{control:t,assets:o,selectedAsset:s,maxSelectedFieldName:n,changeToken:a,onChange:l,onSetMax:i,maxValue:u}=e;return(0,r.jsxs)(m.Z.Wrapper,{className:"mt-2 p-4 pb-5",children:[(0,r.jsx)("div",{className:"flex flex-row items-center gap-1",children:(0,r.jsx)(p.o,{variant:"h4",className:"py-3 font-semibold",children:"From"})}),(0,r.jsx)("div",{children:(0,r.jsxs)("div",{className:"mt-2 flex flex-row items-start gap-2",children:[(0,r.jsx)(D.L,{fieldName:"from.value",control:t,disabled:!1,token:s.token,resetBorrowStatus:()=>{},max:u,balance:s.balance,maxSelectedFieldName:n,customOnChange:l,onSetMax:i}),(0,r.jsx)(U,{assets:o,selectedAsset:s,setSelectedAsset:a,isDestination:!1})]})})]})}function M(e){let{control:t,assets:o,selectedAsset:s,changeToken:n,onChange:a,lockToToken:l}=e;return(0,r.jsxs)(m.Z.Wrapper,{className:"mt-2 p-4 pb-5",children:[(0,r.jsx)("div",{className:"flex flex-row items-center gap-1",children:(0,r.jsx)(p.o,{variant:"h4",className:"py-3 font-semibold",children:"To"})}),(0,r.jsx)("div",{children:(0,r.jsxs)("div",{className:"mt-2 flex flex-row items-start gap-2",children:[(0,r.jsx)(D.L,{fieldName:"to.value",control:t,disabled:!0,token:s.token,customOnChange:a,readOnly:!0}),(0,r.jsx)(U,{assets:o,selectedAsset:s,setSelectedAsset:n,isDestination:!0,disabled:l})]})})]})}function H(e){return[...e].sort((e,t)=>{let o=!("tokenId"in e),r=!("tokenId"in t),s=e.balance.gt(0);return s!==t.balance.gt(0)?s?-1:1:o!==r?o?-1:1:0})}function R(e){var t,o,g;let{form:y,guestMode:w,fromTokenField:k,toTokenField:N,openConnectModal:C,actions:j,pageStatus:A,swapDirection:S,setErrorMessage:V,exchangeRate:T,slippage:L,swapQuoteData:F,isEvmTrade:I,isL1Trade:E,isTransferAfter:P,isExchangeRateLoading:U,activeTab:D,onLimitPriceChange:R,currentPage:q,lockToToken:B,isUsingBigBlocks:z,handleGasLimitExceeded:O,isBothDepositTokens:W}=e,Q=(0,h.useMemo)(()=>{let e=H(k.availableAssets);if(B){let t=N.selectedAsset.token.symbol;return e.filter(e=>e.token.symbol!==t)}return e},[k.availableAssets,B,N.selectedAsset.token.symbol]),Z=(0,h.useMemo)(()=>H(N.availableAssets),[N.availableAssets]),G=(0,h.useRef)(N.availableAssets);G.current=N.availableAssets;let J=y.watch("limitPrice")||"",K=(0,h.useRef)("Market"),X=(0,h.useRef)(U),Y=y.watch("from.symbol"),$=y.watch("to.symbol"),ee=y.watch("from.isL1"),et=y.watch("to.isL1"),eo=(0,h.useRef)(""),er=I&&!!F&&"error"in F&&429===F.statusCode,es=I&&F&&"error"in F&&429===F.statusCode?F.error:null;(0,h.useEffect)(()=>{"Limit"===D&&"Limit"!==K.current&&T&&"N/A"!==T&&!J&&y.setValue("limitPrice",T,{shouldValidate:!1}),K.current=D},[D,y,T,J]),(0,h.useEffect)(()=>{"Limit"===D&&X.current&&!U&&T&&"N/A"!==T&&!J&&y.setValue("limitPrice",T,{shouldValidate:!1}),X.current=U},[D,U,T,J,y]),(0,h.useEffect)(()=>{if("Limit"===D){let e="".concat(Y,"-").concat($,"-").concat(ee,"-").concat(et);eo.current&&eo.current!==e&&T&&"N/A"!==T&&y.setValue("limitPrice",T,{shouldValidate:!1}),eo.current=e}},[D,Y,$,ee,et,T,y]),(0,h.useEffect)(()=>{R&&R(J)},[J,R]);let en=e=>{if(y.setValue("limitPrice",e,{shouldValidate:!1}),"Limit"===D&&e&&Number(e)>0){let t=y.getValues("from.value");if(t&&Number(t)>0){let o={from:{symbol:y.getValues("from.symbol"),isL1:y.getValues("from.isL1")},to:{symbol:y.getValues("to.symbol"),isL1:y.getValues("to.isL1")}};(0,b.Am)(y,e,G,(0,s.pF)(t),o)}}};return(0,r.jsx)(u.lV,{...y,children:(0,r.jsxs)("form",{onSubmit:y.handleSubmit(()=>{}),children:[(0,r.jsx)("input",{type:"hidden",name:"tradeMode"}),(0,r.jsxs)("div",{className:"relative z-10",children:[(0,r.jsx)(_,{control:y.control,assets:Q,selectedAsset:k.selectedAsset,changeToken:k.changeToken,maxSelectedFieldName:k.maxSelectedFieldName,onChange:k.onChange,onSetMax:k.onSetMax,maxValue:k.maxValue}),"Limit"===D&&(0,r.jsx)(m.Z.Wrapper,{className:"mt-2 p-4 pb-5",children:(0,r.jsxs)(u.eI,{children:[(0,r.jsx)("div",{className:"flex flex-row items-center gap-1",children:(0,r.jsx)(p.o,{variant:"h4",className:"py-3 font-semibold",children:"Price"})}),(0,r.jsx)(u.MJ,{children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(d.p,{type:"number",step:"any",placeholder:"0",value:J,min:0,onChange:e=>en(e.target.value),className:"border-input bg-input pr-16 text-foreground placeholder:text-muted-foreground "}),(0,r.jsx)("button",{type:"button",onClick:()=>{T&&"N/A"!==T&&en(T)}
1,className:"-translate-y-1/2 absolute top-1/2 right-2 rounded bg-primary/10 px-2 py-1 font-medium text-primary text-xs transition-colors hover:bg-primary/20 disabled:opacity-50",disabled:!T||"N/A"===T,children:"Mid"})]})}),(0,r.jsx)(u.C5,{})]})}),!B&&(0,r.jsx)(a.f,{className:"absolute right-1/2 bottom-0 translate-x-1/2 translate-y-3/4",onClick:S})]}),(0,r.jsx)(M,{control:y.control,assets:Z,selectedAsset:N.selectedAsset,changeToken:N.changeToken,maxSelectedFieldName:N.maxSelectedFieldName,onChange:N.onChange,lockToToken:B}),"TWAP"===D&&(0,r.jsxs)(m.Z.Wrapper,{className:"mt-2 p-4 pb-5",children:[(0,r.jsxs)(u.eI,{children:[(0,r.jsx)("div",{className:"flex flex-row items-center gap-1",children:(0,r.jsx)(p.o,{variant:"h4",className:"py-3 font-semibold",children:"Running Time (5m - 24h)"})}),(0,r.jsx)(u.MJ,{children:(0,r.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,r.jsxs)("div",{className:"relative w-full",children:[(0,r.jsx)(d.p,{type:"number",placeholder:"0",value:y.watch("twapHours")||"",min:0,onChange:e=>{let t=Number.parseInt(e.target.value)||0;y.setValue("twapHours",Math.max(0,t),{shouldValidate:!0}),y.trigger(["twapHours","from","to"])},className:"border-input bg-input pr-14 text-foreground placeholder:text-muted-foreground"}),(0,r.jsx)(p.o,{variant:"p",className:"-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 text-secondary-foreground",children:"hours"})]}),(0,r.jsxs)("div",{className:"relative w-full",children:[(0,r.jsx)(d.p,{type:"number",placeholder:"0",value:y.watch("twapMinutes")||"",min:0,onChange:e=>{let t=Number.parseInt(e.target.value)||0;y.setValue("twapMinutes",Math.max(0,t),{shouldValidate:!0}),y.trigger(["twapHours","from","to"])},className:"border-input bg-input pr-16 text-foreground placeholder:text-muted-foreground ".concat((null==(t=y.formState.errors.twapHours)?void 0:t.message)&&"mb-1 border-red-400 bg-red-400/10")}),(0,r.jsx)(p.o,{variant:"p",className:"-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 text-secondary-foreground",children:"minutes"})]})]})}),(0,r.jsx)("div",{children:(null==(o=y.formState.errors.twapHours)?void 0:o.message)&&(0,r.jsx)(p.o,{variant:"prompt",className:"text-red-400",children:null==(g=y.formState.errors.twapHours)?void 0:g.message})})]}),(0,r.jsx)(u.eI,{className:"mt-4",children:(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(i.S,{id:"twapRandomize",checked:y.watch("twapRandomize")||!1,onCheckedChange:e=>y.setValue("twapRandomize",e,{shouldValidate:!1})}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(c.J,{htmlFor:"twapRandomize",className:"text-foreground text-sm",children:"Randomize"}),(0,r.jsxs)(f.m_,{children:[(0,r.jsx)(f.k$,{asChild:!0,children:(0,r.jsx)(x.A,{className:"h-4 w-4 cursor-help text-muted-foreground"})}),(0,r.jsx)(f.hS,{children:"If Randomize is enabled, the size of each sub-trade will be automatically adjusted within a certain range, typically up to 20% higher or lower than the original trade size. However, any other requirements specified when creating the TWAP trade, such as ensuring the randomized trade size does not exceed the maximum single trade size, will still be followed."})]})]})]})})]}),W&&(0,r.jsx)(m.Z.Wrapper,{className:"mt-2 gap-2 border-yellow-500/20 bg-yellow-500/10 p-4 md:p-4",children:(0,r.jsx)(m.Z.Content,{children:(0,r.jsx)(p.o,{className:"text-sm text-yellow-500",children:"Direct swaps between deposit tokens (hyTokens, eTokens) have limited support and are likely to fail. Try swapping to the underlying asset first."})})}),(I&&F&&"error"in F||P&&!(I||E)||"N/A"===T&&!U)&&(0,r.jsxs)(m.Z,{className:"mt-2 gap-2 p-4 md:p-4",children:[(0,r.jsx)(m.Z.Header,{className:"font-semibold text-foreground",children:er?"Quote temporarily unavailable":"No routes available"}),(0,r.jsx)(m.Z.Content,{children:(0,r.jsx)(p.o,{className:"text-muted-foreground text-sm",children:er?es:"Reasons for that could be: low liquidity, amount selected is too low, gas costs are too high or there are no routes for the selected combination."})})]}),(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("div",{className:"mb-2 text-muted-foreground text-sm"}),w?(0,r.jsx)(l.$n,{className:"w-full",onClick:()=>void(0,n.OE)(C,"trade_form"),children:"Connect wallet"}):(0,r.jsx)(v.A,{objectives:j,swapQuoteData:F,onFinish:A.goToSuccessScreen,enabled:A.actionsEnabled,setErrorMessage:V,exchangeRate:T,slippage:L,fromAssets:k.availableAssets,toAssets:N.availableAssets,tradingWithAssetsSymbols:e.tradingWithAssetsSymbols,activeTab:D,limitPrice:J,currentPage:q,isUsingBigBlocks:z,onGasLimitExceeded:O,twapParams:"TWAP"===D?{hours:y.watch("twapHours")||0,minutes:y.watch("twapMinutes")||0,randomize:y.watch("twapRandomize")||!1}:void 0})]})]})})}},3367:(e,t,o)=>{o.d(t,{w:()=>s});var r=o(7977);function s(e){let{address:t,chainId:o}=e,s=(0,r.I)(o);if(t&&s)return"".concat(s,"/address/").concat(t)}},7977:(e,t,o)=>{o.d(t,{I:()=>n});var r=o(99255),s=o(23849);function n(e){var t;let o=(0,s._)(),n=(0,r.Q)(),a=null!=e?e:o,l=n.find(e=>e.id===a),i=null==l||null==(t=l.blockExplorers)?void 0:t.default.url;if(i)return i}},8158:(e,t,o)=>{o.d(t,{kf:()=>s,qD:()=>n});var r=o(30343);
1class s extends Error{constructor(e,t){super(e),(0,r._)(this,"details",void 0),this.name="SwapError",this.details=t}}function n(e,t,o,r){var s,n,a,l,i,u;let{action:d,estimate:c,transactionRequest:m}=e,f=null!=(n=null==(s=c.feeCosts)?void 0:s.reduce((e,t)=>e+BigInt(t.amount||"0"),0n))?n:0n;return{statusCode:200,result:{inputToken:o,outputToken:r,feeToken:d.fromToken.address,outputReceiver:t,inputSender:t,inputAmount:c.fromAmount,outputAmount:c.toAmount,partnerFee:"0",routingFee:f.toString(),effectiveOutputAmount:c.toAmount,minOutputAmount:c.toAmountMin,liquidityModules:[e.tool],router:m.to,inputAmountUSD:null!=(a=c.fromAmountUSD)?a:null,outputAmountUSD:null!=(l=c.toAmountUSD)?l:null,effectiveInputAmount:c.fromAmount,effectiveOutputAmountUSD:null!=(i=c.toAmountUSD)?i:null,effectiveInputAmountUSD:null!=(u=c.fromAmountUSD)?u:null}}}},19247:(e,t,o)=>{o.d(t,{A:()=>x,Y:()=>h});var r=o(43238),s=o(67868),n=o(44098),a=o(22980),l=o(26873),i=o(28609),u=o(53619),d=o(62100),c=o(73709),m=o(31142);let f=[(0,n.Ne)(.001),(0,n.Ne)(.005),(0,n.Ne)(.01)];function p(e){let t=e.toNumber();return t>=.2?"very-high":t>=.02?"high":"none"}function x(e){let{slippage:t}=e,o=p(t);return"none"===o?null:"very-high"===o?(0,r.jsx)("span",{className:"text-red-500",children:"\uD83D\uDEA8 Very High"}):(0,r.jsx)("span",{className:"text-yellow-500",children:"⚠️ High"})}function h(e){let{slippage:t,slippageOptions:o,title:l,setSlippage:h,disabled:b,trigger:g}=e,[y,w]=(0,m.useState)(""),[k,N]=(0,m.useState)(!1),C=o&&o.length>0?o:f,j=!C.some(e=>t.eq(e)),A=b?v:c.DX;return(0,r.jsxs)(a.rI,{children:[(0,r.jsx)(a.ty,{asChild:!0,children:(0,r.jsx)(A,{children:g||(0,r.jsx)(u.C,{})})}),(0,r.jsx)(a.SQ,{align:"end",className:"z-[500] mt-2 border-border p-0",children:(0,r.jsxs)("div",{className:"px-6 py-4 text-sm",children:[(0,r.jsx)(i.o,{variant:"p",className:"mb-3 font-bold text-sm",children:l||"Slippage"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(i.o,{variant:"p",className:"mb-2 text-secondary-foreground text-xs",children:"Max slippage:"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[C.map(e=>(0,r.jsx)("button",{onClick:()=>{h(e),N(!1),w("")},className:(0,d.cn)("rounded border-white/20 px-2 py-1 text-secondary-foreground text-xs transition-colors hover:bg-accent hover:text-foreground",t.eq(e)&&"border-primary bg-primary/10 text-primary"),children:(0,s.Ee)(e,{minimumFractionDigits:1})},e.toString())),(0,r.jsx)("button",{onClick:function(){N(!0),w("")},className:(0,d.cn)("min-w-[60px] rounded border-white/20 px-2 py-1 text-secondary-foreground text-xs transition-colors hover:bg-accent hover:text-foreground",j&&"border-primary bg-primary/10 text-primary"),children:"Custom"})]})]}),k&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(i.o,{variant:"p",className:"text-secondary-foreground text-xs",children:"Custom slippage (%):"}),(0,r.jsx)("input",{type:"number",value:y,onChange:e=>(function(e){w(e);let t=Number.parseFloat(e);!Number.isNaN(t)&&t>0&&t<50&&h((0,n.Ne)(t/100))})(e.target.value),placeholder:"0.5",min:"0.1",max:"49.9",step:"0.1",className:"w-full rounded border-white/20 bg-white/5 px-2 py-1 text-foreground text-xs [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none focus:border-primary placeholder:text-muted-foreground focus:outline-none"}),(0,r.jsx)(i.o,{variant:"prompt",className:"text-xs",children:"Enter a value between 0.1% and 49.9%"})]}),!k&&(0,r.jsx)("div",{className:"pt-2",children:(0,r.jsxs)(i.o,{variant:"prompt",className:"text-xs",children:["Current: ",(0,s.Ee)(t,{minimumFractionDigits:1})," ",(0,r.jsx)(x,{slippage:t})]})}),k&&"none"!==p(t)&&(0,r.jsx)("div",{className:"pt-1",children:(0,r.jsx)(i.o,{variant:"prompt",className:"text-xs",children:(0,r.jsx)(x,{slippage:t})})})]})]})})]})}let v=(0,m.forwardRef)(function(e,t){let{children:o}=e;return(0,r.jsxs)(l.m_,{children:[(0,r.jsx)(l.k$,{asChild:!0,children:(0,r.jsx)("span",{ref:t,children:o})}),(0,r.jsx)(l.hS,{children:"Settings are disabled while actions are in progress."})]})})},22980:(e,t,o)=>{o.d(t,{SQ:()=>m,_2:()=>f,rI:()=>d,ty:()=>c});var r=o(43238),s=o(41572),n=o(66681),a=o(7701),l=o(89939),i=o(31142),u=o(62100);let d=s.bL,c=s.l9;s.YJ,s.ZL,s.Pb,s.z6,i.forwardRef((e,t)=>
1{let{className:o,inset:a,children:l,...i}=e;return(0,r.jsxs)(s.ZP,{ref:t,className:(0,u.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-muted",a&&"pl-8",o),...i,children:[l,(0,r.jsx)(n.A,{className:"ml-auto h-4 w-4"})]})}).displayName=s.ZP.displayName,i.forwardRef((e,t)=>{let{className:o,...n}=e;return(0,r.jsx)(s.G5,{ref:t,className:(0,u.cn)("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=closed]:animate-out data-[state=open]:animate-in",o),...n})}).displayName=s.G5.displayName;let m=i.forwardRef((e,t)=>{let{className:o,sideOffset:n=4,...a}=e;return(0,r.jsx)(s.ZL,{children:(0,r.jsx)(s.UC,{ref:t,sideOffset:n,className:(0,u.cn)("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",o),...a})})});m.displayName=s.UC.displayName;let f=i.forwardRef((e,t)=>{let{className:o,inset:n,...a}=e;return(0,r.jsx)(s.q7,{ref:t,className:(0,u.cn)("relative flex cursor-default select-none items-center rounded-sm p-4 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-muted focus:text-accent-foreground data-[disabled]:opacity-50",n&&"pl-8",o),...a})});f.displayName=s.q7.displayName,i.forwardRef((e,t)=>{let{className:o,children:n,checked:l,...i}=e;return(0,r.jsxs)(s.H_,{ref:t,className:(0,u.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-muted focus:text-accent-foreground data-[disabled]:opacity-50",o),checked:l,...i,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(s.VF,{children:(0,r.jsx)(a.A,{className:"h-4 w-4"})})}),n]})}).displayName=s.H_.displayName,i.forwardRef((e,t)=>{let{className:o,children:n,...a}=e;return(0,r.jsxs)(s.hN,{ref:t,className:(0,u.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none transition-colors data-[disabled]:pointer-events-none focus:bg-muted focus:text-accent-foreground data-[disabled]:opacity-50",o),...a,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(s.VF,{children:(0,r.jsx)(l.A,{className:"h-2 w-2 fill-current"})})}),n]})}).displayName=s.hN.displayName,i.forwardRef((e,t)=>{let{className:o,inset:n,...a}=e;return(0,r.jsx)(s.JU,{ref:t,className:(0,u.cn)("px-2 py-1.5 font-semibold text-sm",n&&"pl-8",o),...a})}).displayName=s.JU.displayName,i.forwardRef((e,t)=>{let{className:o,...n}=e;return(0,r.jsx)(s.wv,{ref:t,className:(0,u.cn)("-mx-1 h-px bg-muted-foreground/70",o),...n})}).displayName=s.wv.displayName},48898:(e,t,o)=>{o.d(t,{l:()=>u,w:()=>i});var r=o(43238),s=o(31142),n=o(10133),a=o(19342);let l=(0,s.createContext)(void 0);function i(e){let{children:t}=e,[o,i]=(0,s.useState)(!1),{runAnimation:u}=(0,n.useConfetti)({images:[{src:a.m.hypurrPaw,size:48}],duration:1e3,fadeOut:400,particleCount:25}),d=(0,s.useCallback)(async()=>{i(!0),await u(),i(!1)},[]);return(0,r.jsx)(l.Provider,{value:{runAnimation:d,animating:o},children:t})}function u(){let e=(0,s.useContext)(l);if(!e)throw Error("useConfettiContext must be used within a ConfettiProvider");return e}},51605:(e,t,o)=>{o.d(t,{O:()=>E});var r=o(43238),s=o(42452),n=o(32301),a=o(67868),l=o(3367),i=o(44098),u=o(75142),d=o(26677),c=o(55280);function m(e){let{percentage:t}=e,o=f(t);return(0,r.jsx)("div",{children:(0,r.jsxs)("div",{className:p({variant:o}),children:[(0,r.jsx)(c.A,{className:"h-4 w-4"}),(0,r.jsxs)("p",{children:["very-high"===o?"Very high":"High"," price impact (",(0,a.Ee)(t),")"]})]})})}function f(e){return e.gt(.1)?"very-high":e.gt(.05)?"high":"low"}let p=(0,d.F)("flex items-center gap-1 text-xs",{variants:{variant:{high:"text-amber-400","very-high":"text-red-400",low:"hidden"}}});function x(e){var t,o,r,s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{mode:"asset-swap"};if(!e||!("result"in e))return(0,i.Ne)(0);let a=Number(null!=(o=null!=(t=e.result.effectiveInputAmountUSD)?t:e.result.inputAmountUSD)?o:0),l=Number(null!=(s=null!=(r=e.result.effectiveOutputAmountUSD)?r:e.result.outputAmountUSD)?s:0);if(!Number.isFinite(a)||a<=0)return(0,i.Ne)(0);let u="debt-swap"===n.mode?(l-a)/a:(a-l)/a;return(0,i.Ne)(Math.max(0,u),!0)}var h=o(72137),v=o(92307),b=o(2498),g=o(70795),y=o(13142),w=o(54646),k=o(28609),N=o(19247),C=o(33131),j=o(97427),A=o(39252),S=o(49801),V=o(12563),T=o(52282),L=o(31142),F=o(30161);let I=[(0,i.Ne)(.001),(0,i.Ne)(.005),(0,i.Ne)(.01)];function E(e){var t,o;let{slippage:d,setSlippage:c,...p}
1=e,[E,P]=(0,L.useState)(!0),U=(0,F.i)(),D=(0,s.G)(U),_=p.swapQuoteData&&"result"in p.swapQuoteData?p.swapQuoteData.result.router:void 0,M=p.swapQuoteData&&"result"in p.swapQuoteData&&null!=(o=p.swapQuoteData.result.liquidityModules[0])?o:"LiFi",H=(0,l.w)({address:_,chainId:U}),{isDualL1Trade:R,isL1Trade:q,isEvmTrade:B}=(0,h.H)(p.fromTokenField.selectedAsset,p.toTokenField.selectedAsset,D.nativeAssetSymbol,D.wrappedNativeAssetSymbol,p.tradingWithAssetsSymbols),z=(0,g.xM)((0,u.C)("HYPE")),O=Number(n.Vr.replace("%","")),W=(0,v.oR)((0,i.pF)(O+Number((null==(t=p.hyperliquidFee)?void 0:t.spotTaker)||0)),4,!0),Q="(max. -".concat(100*d.toNumber(),"%)"),Z="(".concat(function(e){if(!e||!("result"in e))return"0%";if(!e.result.effectiveInputAmountUSD||!e.result.effectiveOutputAmountUSD)return"Could not fetch price data";let t=Number(e.result.effectiveInputAmountUSD),o=(Number(e.result.effectiveOutputAmountUSD)-t)/t*100;return"".concat(o>=0?"+":"").concat(o.toFixed(2),"%")}(p.swapQuoteData),")");return(0,r.jsxs)("div",{className:"mt-4 flex flex-col gap-3",children:[(0,r.jsx)("div",{className:"flex flex-col justify-between gap-2",children:(0,r.jsxs)("div",{className:"flex flex-row justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-row items-center gap-1 text-muted-foreground text-xs",children:[(0,r.jsxs)("span",{className:"truncate",children:["1 ",p.fromTokenField.selectedAsset.token.symbol," ="]})," ",p.isExchangeRateLoading&&(B||q)?(0,r.jsx)(C.A,{className:"h-3 w-3 flex-shrink-0 animate-spin"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"truncate",children:p.exchangeRate})," ",(0,r.jsx)("span",{className:"truncate",children:p.toTokenField.selectedAsset.token.symbol})," ",B&&"low"!==f(x(p.swapQuoteData))?(0,r.jsx)(m,{percentage:x(p.swapQuoteData)}):(0,r.jsx)("span",{className:"truncate",children:q||R?Q:B?Z:""})]})]}),(0,r.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,r.jsxs)("div",{className:"flex-shrink-0 text-muted-foreground text-xs",children:["Fee:"," ",q||R?"".concat(R?2*Number(W):Number(W),"%"):B?"Included":"0"]}),void 0!==c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"text-muted-foreground text-xs",children:["Slippage: ",(0,a.Ee)(d,{minimumFractionDigits:1})," ",(0,r.jsx)(N.A,{slippage:d})]}),(0,r.jsx)(N.Y,{slippage:d,slippageOptions:I,setSlippage:c,title:"Trade Settings"})]})]})]})}),(0,r.jsxs)(y.Z.Wrapper,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex flex-row items-center justify-between hover:cursor-pointer",onClick:()=>P(!E),children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col justify-between gap-2",children:[(0,r.jsx)(k.o,{variant:"p",className:"text-muted-foreground text-xs",children:"Swap route"}),(0,r.jsxs)("div",{className:"flex flex-row items-center gap-1 text-xs",children:[(0,r.jsx)(T.default,{src:B?b:z,alt:"Route",width:16,height:16,className:"flex-shrink-0"}),B?(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 capitalize",children:[M,(0,r.jsx)("span",{className:"text-muted-foreground normal-case",children:"via"}),(0,r.jsxs)("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 hover:underline",children:["LiFi",(0,r.jsx)(j.A,{className:"h-3 w-3 flex-shrink-0"})]})]}):(0,r.jsx)("span",{className:"truncate",children:q||R?"HyperCore":"HyperEVM"})]})]}),(0,r.jsx)("button",{className:"flex flex-shrink-0 items-center gap-2 text-muted-foreground",children:E?(0,r.jsx)(A.A,{className:"h-4 w-4"}):(0,r.jsx)(S.A,{className:"h-4 w-4"})})]}),E&&(0,r.jsxs)("div",{className:"mt-4 flex min-w-0 flex-row items-center gap-4 text-xs",children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,r.jsx)("div",{className:"flex shrink-0",children:(0,r.jsx)(w.x,{token:p.fromToken.token,className:"h-6 w-6"})}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col items-start",children:[(0,r.jsxs)("div",{className:"w-full truncate font-semibold text-base text-foreground capitalize",children:[p.fromToken.value.toNumber()," ",p.fromToken.token.symbol]}),(0,r.jsx)("div",{className:"flex w-full min-w-0 items-center gap-2",children:(0,r.jsx)("div",{className:"truncate font-normal text-muted-foreground text-sm",children:p.fromToken.token.formatUSD(p.fromToken.value)})})]})]}),R&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V.A,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(T.default,{src:(0,g.xM)((0,u.C)("USDC")),alt:"USDC",width:24,height:24,className:"h-6 w-6"})})]}),(0,r.jsx)(V.A,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,r.jsx)("div",{className:"flex shrink-0",children:(0,r.jsx)(w.x,{token:p.toToken.token,className:"h-6 w-6"})}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col items-start",children:[(0,r.jsxs)("div",{className:"w-full truncate font-semibold text-base text-foreground capitalize",children:[p.toToken.value.toNumber()," ",p.toToken.token.symbol]}),(0,r.jsx)("div",{className:"flex w-full min-w-0 items-center gap-2",children:(0,r.jsx)("div",{className:"truncate font-normal text-muted-foreground text-sm",children:p.toToken.token.formatUSD(p.toToken.value)})})]})]})]})]})]})}},53619:(e,t,o)=>{o.d(t,{C:()=>l});var r=o(43238),s=o(31142),n=o(69099),a=o(18662);let l=(0,s.forwardRef)((e,t)=>(0,r.jsx)(n.$n,{className:"h-[30px] w-[30px] rounded-full border-border bg-secondary p-0 text-secondary-foreground",...e,ref:t,prefixIcon:(0,r.jsx)(a.A,{size:18})}));l.displayName="SettingsButton"},57532:(e,t,o)=>{o.d(t,{d:()=>s});var r=o(31142);function s(e,t){let{delay:o=300}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},[s,n]=(0,r.useState)(e),[a,l]=(0,r.useState)(!1),i=(0,r.useRef)(!0);return(0,r.useEffect)(()=>
1{if(i.current){i.current=!1;return}l(!0);let t=setTimeout(()=>{l(!1),n(e)},o);return()=>{clearTimeout(t)}},[t,o]),{debouncedValue:s,isDebouncing:a}}},60741:(e,t,o)=>{o.d(t,{_:()=>u});var r=o(31142),s=o(41772),n=o(74885),a=o(52252);let l=new a.G5,i=new a.Cf({transport:l});function u(e){let[t,o]=(0,r.useState)(null);(0,r.useEffect)(()=>{e&&o(function(e){try{let t=localStorage.getItem("hypurrfi_agent_".concat(e));return t?JSON.parse(t):null}catch(e){return null}}(e))},[e]);let u=(0,r.useCallback)(async r=>{let u,d;if(!e)throw Error("Account is required");let c=new a.PM({wallet:r,transport:l});if(t&&(u=t.privateKey,d=(0,s.R)(u),"agent"===(await i.userRole({user:d.address})).role))return new a.PM({wallet:d,transport:l});u=(0,n.A)(),d=(0,s.R)(u);let m={privateKey:u,address:d.address};try{localStorage.setItem("hypurrfi_agent_".concat(e),JSON.stringify(m))}catch(e){console.error("Failed to store agent:",e)}return o(m),await c.approveAgent({agentAddress:d.address,agentName:"HypurrFiOrder"}),new a.PM({wallet:d,transport:l})},[e,t]);return{storedAgent:t,createAgentClient:u}}},63841:(e,t,o)=>{o.d(t,{q:()=>n});var r=o(41938),s=o(24747);let n=new r.E({defaultOptions:{queries:{gcTime:864e5,refetchOnWindowFocus:!0,refetchInterval:2e4,retry:3,retryDelay:e=>Math.min(300*2**e,1e4),staleTime:3e4}}});n.getQueryCache().subscribe(e=>{let{query:t}=e;"error"===t.state.status&&(0,s.captureError)(t.state.error)}),n.getMutationCache().subscribe(e=>{let{mutation:t}=e;t&&"error"===t.state.status&&(0,s.captureError)(t.state.error)})},72022:(e,t,o)=>{o.d(t,{w:()=>b});var r=o(39087),s=o(3790),n=o(28830),a=o(72848),l=o(36460),i=o(8424),u=o(81652),d=o(37447),c=o(91200),m=o(24747),f=o(8158);let p=[{type:"event",name:"LiFiGenericSwapCompleted",inputs:[{name:"transactionId",type:"bytes32",indexed:!0},{name:"integrator",type:"string",indexed:!1},{name:"referrer",type:"string",indexed:!1},{name:"receiver",type:"address",indexed:!1},{name:"fromAssetId",type:"address",indexed:!1},{name:"toAssetId",type:"address",indexed:!1},{name:"fromAmount",type:"uint256",indexed:!1},{name:"toAmount",type:"uint256",indexed:!1}]}];async function x(e,t){let{retries:o,baseDelay:r}=t;for(let t=0;t<o;t++)try{return await e()}catch(s){if(s instanceof u.h6&&s.status>=500||t===o-1)throw s;let e=r*2**t;await new Promise(t=>setTimeout(t,e))}throw Error("fetchWithRetry: unreachable")}class h extends f.kf{constructor(e,t){super(e,t),this.name="ExecutionQuoteDriftError"}}function v(e){return[r.Xd.toLowerCase(),"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"].includes(e.toLowerCase())}async function b(e){let t,o,{inputToken:r,outputToken:a,inputAmount:p,priceData:b,walletConfig:y,nativeAssetSymbol:w,slippage:k,isUsingBigBlocks:N,setSwapState:C,setSwapError:j,setQuoteError:A,onSuccess:S,onGasLimitExceeded:V}=e;j(!1),A(!1),C("Initializing...");let{account:T,publicClient:L,walletClient:F}=y;if(!T||!L||!F){console.warn("Wallet not available or not an Ethereum wallet"),C("");return}if(!b||!("result"in b)){console.warn("Price data not available"),C("");return}let I=Date.now(),E="sign";try{var P;let e,m;C("Getting fresh quote...");let y=(0,d.Dg)(p);for(let t=0;t<3;t++){t>0&&C("Refreshing quote (".concat(t+1,"/").concat(3,")...")),e=await x(()=>(0,u.dt)({fromToken:(0,u.XN)(r.address),toToken:(0,u.XN)(a.address),fromAmount:y.toString(),fromAddress:T,slippageBps:null!=k?k:50}),{retries:3,baseDelay:1e3});let o=BigInt(e.action.fromAmount),s=BigInt(e.estimate.toAmountMin);try{!function(e){let{priceQuote:t,executionInputAmount:o,executionMinOutputAmount:r,requestedInputAmount:s}=e,n=BigInt(t.result.minOutputAmount)*(10000n-10n)/10000n;if(o!==s)throw new f.kf("Execution quote input amount changed before submission",{requestedInputAmount:s.toString(),executionInputAmount:o.toString()});if(r<n)throw new h("Price moved too much before submission. Please try again.",{displayedOutputAmount:t.result.outputAmount,displayedMinOutputAmount:t.result.minOutputAmount,executionMinOutputAmount:r.toString(),bufferedDisplayedMinOutputAmount:n.toString(),bufferBps:10n.toString()})}({priceQuote:b,executionInputAmount:o,executionMinOutputAmount:s,requestedInputAmount:y});break}catch(o){if(!(o instanceof h)||2===t)throw o;let e=500*2**t;await new Promise(t=>setTimeout(t,e))}}let{transactionRequest:j,estimate:A}=e,U=A.approvalAddress,D=BigInt(e.action.fromAmount),_=r.symbol===w||v(r.address),M=a.symbol===w||v(
1a.address);if(0n>=BigInt(null!=(P=A.toAmount)?P:"0"))throw new f.kf("Quote returned zero output amount");t=(0,s.J)(D,r.decimals),o=(0,s.J)(BigInt(A.toAmount),a.decimals);let H=!_&&!!U;if((0,i.u4)("swap_submitted",{input_token:r.symbol,output_token:a.symbol,input_amount:t,output_amount:o,slippage_setting:k/100,requires_approval:H}),!_&&U&&await L.readContract({address:r.address,abi:n.xw,functionName:"allowance",args:[T,U]})<D){E="approval",C("Approving..."),(0,i.u4)("swap_approval_requested",{input_token:r.symbol,input_amount:t});let e=await F.writeContract({address:r.address,abi:n.xw,functionName:"approve",args:[U,D],chain:l.FU,account:T});await (0,c.DV)(L,e),(0,i.u4)("swap_approval_completed",{input_token:r.symbol,input_amount:t,tx_hash:e}),E="sign"}C("Estimating gas...");let R={to:j.to,data:j.data,account:T,value:j.value?BigInt(j.value):0n,chain:l.FU},q=M&&!_?await L.getBalance({address:T}):void 0;try{m=await L.estimateGas(R)}catch(t){console.error("Gas estimation failed:",t);let e=t instanceof Error?"shortMessage"in t&&"string"==typeof t.shortMessage?t.shortMessage:t.message:String(t);throw new f.kf("Simulation failed: ".concat(e),{simulationError:e})}if(!N&&m>2000000n){let e={estimatedGas:m,limit:2000000n,computationUnits:Number(m)};if(V)V(e);else throw new f.kf("Gas limit exceeded small block limit",{gasLimitExceeded:e});return}C("Awaiting confirmation..."),E="sign";let B=await F.sendTransaction(R);(0,i.u4)("swap_signed",{input_token:r.symbol,output_token:a.symbol,input_amount:t,output_amount:o,tx_hash:B}),C("Sending transaction..."),E="confirmation";let z=await (0,c.DV)(L,B,{retryCount:N?40:5,retryDelay:N?3e3:2e3});if("success"!==z.status)throw console.error("Transaction failed",z),new f.kf("Transaction failed",{receipt:z});let O=await g({tx:z,account:T,outputToken:a,isInputNative:_,isOutputNative:M,nativeBalanceBefore:q,estimatedToAmount:A.toAmount,txValue:R.value,publicClient:L});(0,i.u4)("swap_completed",{input_token:r.symbol,output_token:a.symbol,input_amount:t,output_amount:o,tx_hash:B,duration_ms:Date.now()-I}),S({outputAmount:O})}catch(o){if("user_rejected"===(0,i.fe)(o))return;o instanceof Error&&(0,m.captureError)(o,o instanceof f.kf?o.details:void 0),console.error("In swap: ",o);let e=o instanceof Error?o.message:"Transaction failed";void 0!==t&&(0,i.u4)("swap_failed",{input_token:r.symbol,output_token:a.symbol,input_amount:t,error_type:(0,i.fe)(o),error_message:e,failed_at:E}),o instanceof u.h6?A(!0,e):j(!0,e)}finally{C("")}}async function g(e){var t,o;let{tx:r,account:s,outputToken:l,isInputNative:i,isOutputNative:u,nativeBalanceBefore:d,estimatedToAmount:c,txValue:m,publicClient:f}=e,x=(0,a.p)({abi:p,logs:r.logs,eventName:"LiFiGenericSwapCompleted",strict:!1}).filter(e=>{var t;return(null==(t=e.args.receiver)?void 0:t.toLowerCase())===s.toLowerCase()}).pop();if((null==x?void 0:x.args.toAmount)!==void 0)return x.args.toAmount.toString();if(u)return i||m>0n?c:(await f.getBalance({address:s,blockNumber:r.blockNumber})-d+r.gasUsed*r.effectiveGasPrice).toString();let h=(0,a.p)({abi:n.xw,logs:r.logs,eventName:"Transfer"}).filter(e=>{var t;return(null==(t=e.args.to)?void 0:t.toLowerCase())===s.toLowerCase()&&e.address.toLowerCase()===l.address.toLowerCase()}).pop();return null!=(o=null==h||null==(t=h.args.value)?void 0:t.toString())?o:c}},72137:(e,t,o)=>{o.d(t,{A:()=>D,H:()=>U});var r=o(43238),s=o(42452),n=o(32301),a=o(63841),l=o(17228),i=o(12866),u=o(44098),d=o(7414),c=o(75142),m=o(69099),f=o(37447),p=o(35866),x=o(91200),h=o(52252),v=o(31142),b=o(23752),g=o(28830),y=o(25897),w=o(12288),k=o(33840),N=o(30161),C=o(94815),j=o(72022),A=o(26316),S=o(49553),V=o(58046),T=o(36460);async function L(e){let{walletConfig:t,chainId:o,value:r,swapMode:s,setSwapState:n,setSwapError:l,setPageStatus:i}=e,{account:u,publicClient:d,walletClient:c}=t;if(!u||!c||!d)return void console.warn("Wallet not available or not an Ethereum wallet");if("swap"===s)return void console.warn("Swap mode not supported");try{n("Initializing..."),l(!1);let e=(0,S.RZ)(A.mi.address,o);if("wrap"===s){n("Wrapping...");let t=await d.simulateContract({address:e,account:u,abi:A.mi.abi,functionName:"deposit",value:r,chain:T.FU}),o=await c.writeContract(t.request);await (0,x.DV)(d,o)}else{n("Unwrapping...");let t=await d.simulateContract({address:e,account:u,abi:A.mi.abi,functionName:"withdraw",args:[r],chain:T.FU}),o=await c.writeContract(t.request);await (0,x.DV)(d,o)}
1a.q.invalidateQueries({queryKey:(0,V.j)({account:u,chainId:o})}),n(""),i("success")}catch(e){if(e instanceof Error&&e.message.includes("User rejected"))return;l(!0),console.error(e)}finally{n("")}}var F=o(92307),I=o(60741);let E=new h.G5,P=new h.Cf({transport:E});function U(e,t,o,r,s){let n={isWrap:!1,isUnwrap:!1,isDualL1Trade:!1,isL1Trade:!1,isEvmTrade:!1,isTransferBefore:!1,isTransferAfter:!1,isTransfer:!1},a=e.token.symbol===(null==t?void 0:t.token.symbol);if(a)return{...n,isTransfer:a};let l=e.token.symbol===o&&(null==t?void 0:t.token.symbol)===r,i=e.token.symbol===r&&(null==t?void 0:t.token.symbol)===o;if(l||i)return{...n,isWrap:l,isUnwrap:i,isTransferBefore:(null==e?void 0:e.tokenId)!==void 0,isTransferAfter:!1};let u=(null==e?void 0:e.tokenId)!==void 0&&(null==t?void 0:t.tokenId)!==void 0&&!s.includes(null==t?void 0:t.token.symbol.toUpperCase())&&!s.includes(null==e?void 0:e.token.symbol.toUpperCase());if(u)return{...n,isDualL1Trade:u};let d=u||(null==e?void 0:e.tokenId)!==void 0&&(null==t?void 0:t.tokenId)!==void 0,c=(null==e?void 0:e.tokenId)===void 0&&(null==t?void 0:t.tokenId)!==void 0&&s.includes(null==t?void 0:t.token.symbol.toUpperCase()),m=(null==t?void 0:t.tokenId)===void 0&&(null==e?void 0:e.tokenId)!==void 0&&s.includes(null==e?void 0:e.token.symbol.toUpperCase());if(c||m||d)return{...n,isWrap:l,isUnwrap:i,isL1Trade:d||c||m,isEvmTrade:!1,isTransferBefore:c,isTransferAfter:m,isTransfer:a};c=(null==e?void 0:e.tokenId)!==void 0&&(null==t?void 0:t.tokenId)===void 0,m=(null==e?void 0:e.tokenId)===void 0&&(null==t?void 0:t.tokenId)!==void 0;let f=(null==e?void 0:e.tokenId)===void 0&&(null==t?void 0:t.tokenId)===void 0||m||c;return{...n,isWrap:l,isUnwrap:i,isL1Trade:!1,isEvmTrade:f,isTransferBefore:c,isTransferAfter:m,isTransfer:a}}function D(e){let{data:t}=(0,w.G)(),o=(0,k.e)(),A=(0,N.i)(),S=(0,s.G)(A),V=(0,l.F)(),[T,D]=(0,v.useState)(""),{createAgentClient:_}=(0,I._)(V),{setErrorMessage:M,swapQuoteData:H,tradingWithAssetsSymbols:R}=e,q=e.objectives[0],B={walletClient:t,publicClient:o,account:V},{isDualL1Trade:z,isWrap:O,isUnwrap:W,isL1Trade:Q,isEvmTrade:Z,isTransferBefore:G,isTransferAfter:J,isTransfer:K}=U((null==q?void 0:q.from)||{token:new d.ou({symbol:(0,c.C)("-"),decimals:6,address:(0,i.u)("0x0000000000000000000000000000000000000000"),unitPriceUsd:"0",name:"",isAToken:!1}),balance:(0,u.pF)(0)},(null==q?void 0:q.to)||{token:new d.ou({symbol:(0,c.C)("-"),decimals:6,address:(0,i.u)("0x0000000000000000000000000000000000000000"),unitPriceUsd:"0",name:"",isAToken:!1}),balance:(0,u.pF)(0)},S.nativeAssetSymbol,S.wrappedNativeAssetSymbol,R);async function X(t){let o=Math.round(1e4*e.slippage.toNumber());return new Promise((r,s)=>{var n;(0,j.w)({inputToken:t.from.token,outputToken:t.to.token,inputAmount:t.from.token.toBaseUnit(t.amount),priceData:H,walletConfig:B,chainId:A,nativeAssetSymbol:S.nativeAssetSymbol,slippage:o,isUsingBigBlocks:null!=(n=e.isUsingBigBlocks)&&n,setSwapState:e=>D(e),setSwapError:(e,t)=>{e&&s(Error(null!=t?t:"Transaction failed"))},setQuoteError:(e,t)=>{e&&s(Error(null!=t?t:"Failed to get quote"))},onSuccess:e=>{r(e)},onGasLimitExceeded:t=>{e.onGasLimitExceeded&&e.onGasLimitExceeded(t),s("gas_limit_exceeded")}})})}async function Y(){await new Promise((e,t)=>{L({walletConfig:B,chainId:A,value:(0,f.Dg)(q.from.token.toBaseUnit(q.amount)),swapMode:O?"wrap":"unwrap",setSwapState:e=>{D(e)},setSwapError:e=>{e&&t("Transaction failed")},setPageStatus:()=>{e(void 0)}})})}async function $(e,r,s,n,a){if(V&&t&&o){D("Transferring...");try{"toEvm"===s?await ee(t,e,r,n):await et(e,r,a),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error(e),Error(e instanceof Error?e.message.includes("User rejected")?"User rejected the request":e.message:"Transaction Failed")}finally{D("")}}}async function ee(e,t,o,r){let s=r.find(e=>e.token.symbol===t&&void 0!==e.tokenId);if(!s||!s.tokenId||!s.systemAddress||!s.evmContract)throw Error("Token ID or system address not found for: ".concat(t));let n=new h.PM({wallet:e,transport:E}),a="".concat(String((0,p.J9)(t,{uppercase:!0})),":").concat(s.tokenId),l=await n.spotSend({destination:s.systemAddress,amount:o,token:a});if("ok"!==l.status)throw Error("Transfer failed: ".concat(l.status))}async function et(e,r,s){let n;if(!V||!o||!t)throw Error("Primary wallet is not available");let a=s.find(t=>t.token.symbol===e&&void 0!==t.tokenId);if(!a||!a.systemAddress||!a.evmContract)throw Error("System address not found for: ".concat(e));let l=s.find(t=>t.token.symbol===e&&void 0===t.tokenId);if(!l)throw Error("EVM token not found for: ".concat(e));let i=l.token.address;if("USDC"===e&&a.depositContract){let e=a.depositContract,s=(0,b.X)(r.toString(),l.token.decimals);await (0,C.y)(t,o,i,e,s);return}let u="HYPE"===e?void 0:{address:i,decimals:l.token.decimals};n=u?await t.writeContract({address:i,abi:g.xw,functionName:"transfer",args:[a.systemAddress,(0,b.X)(r.toString(),u.decimals)]}):await t.sendTransaction({to:a.systemAddress,value:(0,y.g)(r.toString())}),await (0,x.DV)(o,n)}async function eo(r,s,l){if(!V||!t||!o)throw Error("Primary wallet or objective not found");let i=(0,F.AV)(r.from,r.to,e.fromAssets,e.toAssets);if(!(null==i?void 0:i.tokenId))throw Error("Token ID not found");let u=a.q.getQueryData(["tokenDetails",i.tokenId]);D("Trading...");try{let o=new h.PM({wallet:t,transport:E}),a=n.Vr.replace("%",""),m=Math.round(1e3*Number.parseFloat(a)),f=await P.maxBuilderFee({user:t.account.address,builder:n.xv});m!==f&&await o.approveBuilderFee({maxFeeRate:n.Vr,builder:n.xv});let p=await _(t),x=r.from.token.symbol.toUpperCase()!==i.token.symbol.toUpperCase(),v=await p.order({orders:[{a:i.universeIndex,b:x,p:(()=>{var e,t;let o=Number(s),r=(null==u||null==(e=u.markPx)?void 0:e.includes("."))?((null==(t=u.markPx.split(".")[1])?void 0:t.length)||1)-1:0;return(x?l?Number(1/Number(l)):Number(null==u?void 0:u.markPx)*(1+o):l?Number(l):Number(null==u?void 0:u.markPx)*(1-o)).toFixed(r)})(),s:x?Number((Number(r.amount)*Number(l||e.exchangeRate)).toFixed(i.szDecimals)).toString():Number(Number(r.amount).toFixed(i.szDecimals)).toString(),r:!1,t:{limit:{tif:l?"Gtc":"FrontendMarket"}}}],grouping:"na",builder:{b:n.xv,f:m}});if(await new Promise(e=>setTimeout(e,1e3)),"ok"===v.status){var d,c;let e=null==v||null==(c=v.response)||null==(d=c.data)?void 0:d.statuses[0];return{outputAmount:e&&"filled"in e?e.filled.totalSz:void 0}}throw Error("Transfer Failed: ".concat(v.status))}catch(e){throw console.error(e),Error(e instanceof Error?e.message.includes("User rejected")?"User rejected the request":e.message:"Transaction Failed")}finally{D("")}}async function er(r,s){if(!V||!t||!o)throw Error("Primary wallet or objective not found");let a=(0,F.AV)(r.from,r.to,e.fromAssets,e.toAssets);if(!(null==a?void 0:a.tokenId))throw Error("Token ID not found");D("Creating TWAP order...");try{let o=new h.PM({wallet:t,transport:E}),l=n.Vr.replace("%",""),i=Math.round(1e3*Number.parseFloat(l)),u=await P.maxBuilderFee({user:t.account.address,builder:n.xv});i!==u&&await o.approveBuilderFee({maxFeeRate:n.Vr,builder:n.xv});let d=await _(t),c=r.from.token.symbol.toUpperCase()!==a.token.symbol.toUpperCase(),m=await d.twapOrder({a:a.universeIndex,b:c,s:c?Number((Number(r.amount)*Number(e.exchangeRate)).toFixed(a.szDecimals)).toString():Number(Number(r.amount).toFixed(a.szDecimals)).toString(),m:60*s.hours+s.minutes,r:!1,t:s.randomize});if(await new Promise(e=>setTimeout(e,1e3)),"ok"===m.status)return{outputAmount:void 0};throw Error("TWAP Order Failed: ".concat(m.status))}catch(e){throw console.error(e),Error(e instanceof Error?e.message.includes("User rejected")?"User rejected the request":e.message:"TWAP Order Failed")}finally{D("")}}return(0,r.jsx)("div",{className:"relative pb-1",children:(0,r.jsx)(m.$n,{className:"w-full rounded-lg",disabled:!e.enabled||""!==T||J&&!(Z||Q),onClick:async()=>{try{let t=e.objectives[0];if(!t)return void M("No objective available");if(M(""),z){let o=e.fromAssets.find(e=>"USDC"===e.token.symbol&&void 0!==e.tokenId),{outputAmount:r}=await eo({...t,to:o},(0,u.Ne)(Number(e.slippage)/2),"Limit"===e.activeTab?e.limitPrice:void 0);r&&(t.amount=(0,u.pF)(r),await eo({...t,from:o},(0,u.Ne)(Number(e.slippage)/2),"Limit"===e.activeTab?e.limitPrice:void 0)),e.onFinish();return}if(K){let o=void 0!==t.from.tokenId?"toEvm":"toCore";await $(t.from.token.symbol,t.amount.toString(),o,e.fromAssets,e.toAssets),e.onFinish();return}if(G){let o=void 0!==t.from.tokenId?"toEvm":"toCore";await $(t.from.token.symbol,t.amount.toString(),o,e.fromAssets,e.toAssets),t.from=e.fromAssets.find(e=>e.token.symbol===t.from.token.symbol&&e.tokenId!==t.from.tokenId)}if(O){await Y(),e.onFinish();return}if(W&&(await Y(),!J))return void e.onFinish();if(Z){let{outputAmount:o}=await X(t);if(!J)return void e.onFinish();o&&(t.from=e.fromAssets.find(e=>e.token.symbol===t.to.token.symbol&&void 0===e.tokenId),t.amount=t.from.token.fromBaseUnit((0,u.lL)(o)))}else if(Q){if("TWAP"===e.activeTab&&e.twapParams){await er(t,e.twapParams),e.onFinish();return}let{outputAmount:o}=await eo(t,e.slippage,"Limit"===e.activeTab?e.limitPrice:void 0);if(!J)return void e.onFinish();o&&(t.from=e.fromAssets.find(e=>e.token.symbol===t.to.token.symbol&&void 0!==e.tokenId),t.amount=(0,u.pF)(o))}if(J){let o=void 0!==t.from.tokenId?"toEvm":"toCore";await $(t.from.token.symbol,t.amount.toString(),o,e.fromAssets,e.toAssets),e.onFinish();return}}catch(e){if("gas_limit_exceeded"===e)return;console.error(e),M(e instanceof Error?e.message:"Transaction Failed")}finally{D("")}},children:function(e,t,o,r,s,n,a){if(""!==e)return e;if(t)return"Wrap";if(o)return"Unwrap";if(r)return"Transfer";let l="trade"===a?"Trade":"Swap";return s&&(l="Transfer & ".concat(l)),n&&(l="".concat(l," & Transfer")),l}(T,O,W,K,G,J,e.currentPage)})})}},81652:(e,t,o)=>{o.d(t,{XN:()=>n,dt:()=>l,h6:()=>a});var r=o(30343),s=o(39087);function n(e){return[s.Xd.toLowerCase(),"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"].includes(e.toLowerCase())?"0x0000000000000000000000000000000000000000":e}o(32301);
1class a extends Error{constructor(e,t,o){super(e),(0,r._)(this,"status",void 0),(0,r._)(this,"details",void 0),this.name="LifiFetchError",this.status=t,this.details=o}}async function l(e){let t=e.slippageBps/1e4,o=await fetch("/api/lifi/quote",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({fromChain:999,toChain:999,fromToken:e.fromToken,toToken:e.toToken,fromAmount:e.fromAmount,fromAddress:e.fromAddress,slippage:t.toString(),integrator:"HypurrFi"})});if(!o.ok){let e=await o.json().catch(()=>({error:"Failed to fetch quote"}));throw new a("string"==typeof e.message?e.message:"string"==typeof e.error?e.error:"HTTP ".concat(o.status),o.status,{response:e})}return o.json()}},84330:(e,t,o)=>{o.d(t,{N:()=>p});var r=o(43238),s=o(69099),n=o(13142),a=o(54646),l=o(28609),i=o(48898),u=o(62100),d=o(64715),c=o(31142),m=o(53732),f=o(33243);function p(e){let{fromToken:t,toToken:o,runConfetti:a,resetForm:f,isModal:p,stackedSuccessScreen:h}=e,{runAnimation:v}=(0,i.l)();return(0,c.useEffect)(()=>{a&&v()},[a,v]),(0,r.jsxs)("div",{className:"flex w-full flex-col items-center justify-center",children:[(0,r.jsx)(m.A,{isModal:p}),(0,r.jsxs)(n.Z,{className:"mt-8 min-w-full max-w-3xl",children:[(0,r.jsx)(n.Z.Header,{children:(0,r.jsx)(n.Z.Title,{className:"text-xl",children:"Summary"})}),(0,r.jsxs)(n.Z.Content,{children:[(0,r.jsxs)("div",{className:(0,u.cn)("mt-4 flex flex-col gap-9",{"md:flex-row":!h}),children:[(0,r.jsxs)("div",{className:"flex grow flex-col","data-testid":d.b.easyBorrow.success.deposited,children:[(0,r.jsx)(l.o,{variant:"prompt",className:"mb-2 font-semibold text-primary",children:"Transferred"}),(0,r.jsx)(x,{...t,isL1:void 0!==t.tokenId},t.token.symbol)]}),(0,r.jsxs)("div",{className:"flex grow flex-col","data-testid":d.b.easyBorrow.success.borrowed,children:[(0,r.jsx)(l.o,{variant:"prompt",className:"mb-2 font-semibold text-primary",children:"Received"}),(0,r.jsx)(x,{...o,isL1:void 0!==o.tokenId},o.token.symbol)]})]}),(0,r.jsx)("div",{className:"mt-8 flex gap-4",children:(0,r.jsx)(s.$n,{className:"flex-1 bg-accent text-primary",onClick:f,rounded:"full",children:"Close"})})]})]})]})}function x(e){let{token:t,value:o,approx:s=!1,isL1:n=!1}=e;return(0,r.jsxs)("div",{className:"flex items-center border-t",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(a.x,{token:t,className:"h-6 w-6"}),n&&(0,r.jsx)(f.j,{})]}),(0,r.jsx)(l.o,{className:"ml-2 font-primary",children:t.symbol}),(0,r.jsxs)("div",{className:"flex grow flex-col py-3 pr-4",children:[(0,r.jsxs)(l.o,{className:"text-right font-primary",children:[s&&(0,r.jsx)("span",{className:"mr-1",children:"~"}),t.format(o,{style:"auto"})]}),(0,r.jsxs)(l.o,{variant:"prompt",className:"text-right",children:[s&&(0,r.jsx)("span",{className:"mr-1",children:"~"}),t.formatUSD(o)]})]})]})}},87921:(e,t,o)=>{o.d(t,{S:()=>i});var r=o(43238),s=o(90601),n=o(7701),a=o(31142),l=o(62100);let i=a.forwardRef((e,t)=>{let{className:o,...a}=e;return(0,r.jsx)(s.bL,{ref:t,className:(0,l.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background disabled:cursor-not-allowed data-[state=checked]:border-checkbox data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",o),...a,onClick:e=>{var t;e.stopPropagation(),null==(t=a.onClick)||t.call(a,e)},children:(0,r.jsx)(s.C1,{className:(0,l.cn)("flex items-center justify-center text-current"),children:(0,r.jsx)(n.A,{className:"h-4 w-4"})})})});i.displayName=s.bL.displayName},92307:(e,t,o)=>{o.d(t,{Am:()=>ec,oR:()=>$,AV:()=>Y,_B:()=>en});var r=o(50161),s=o(63841),n=o(67868),a=o(17228),l=o(52252),i=o(38485);let u=new l.G5,d=new l.Cf({transport:u});var c=o(55592),m=o(18598),f=o(1510),p=o(12866),x=o(44098),h=o(7414),v=o(75142),b=o(13731),g=o(82591),y=o(79710),w=o(58046),k=o(35827),N=o(81652),C=o(37447),j=o(8424),A=o(33581),S=o(73962),V=o(31142),T=o(8158),L=o(1450),F=o(72997),I=o(16814),E=o(36460);o(32301);let P=[{token:new h.ou({...(0,I.Bk)(I.XC.CMETH),unitPriceUsd:"0"}),balance:(0,x.pF)(0)}];var U=o(28830),D=o(3790),_=o(56286),M=o(16256);function H(e){let{tokenAddress:t,decimals:o,chainId:r,enabled:s=!0}=e,n=(0,a.F)(),l=(0,_.U)();return(0,i.useQuery)({queryKey:["token-balance",t,n,r],queryFn:async()=>
1{if(!n||!t)return(0,x.pF)(0);let e=await (0,M.J)(l,{abi:U.xw,address:t,functionName:"balanceOf",args:[n],chainId:r});return(0,x.pF)((0,D.J)(e,o))},enabled:s&&!!n&&!!t,staleTime:3e4})}var R=o(99134),q=o(57532),B=o(51886),z=o(97033),O=o(52974),W=o(85787),Q=o(79123),Z=o(39087),G=o(45871),J=o(72137);let K=new l.G5,X=new l.Cf({transport:K});function Y(e,t,o,r,s){if("from"===s)return e;if("to"===s)return t;if(e.token.symbol===(0,v.C)("USDC")){if(void 0!==t.tokenId)return t;let e=r.find(e=>e.token.symbol===t.token.symbol&&void 0!==e.tokenId);if(!e)return;return e}if(t.token.symbol===(0,v.C)("USDC")){if(void 0!==e.tokenId)return e;let t=o.find(t=>t.token.symbol===e.token.symbol&&void 0!==t.tokenId);if(!t)return;return t}}function $(e,t,o){if(!o)return(0,n.oR)(e,t);let r=e.toString();if(r&&"."!==r&&"-"!==r&&!/^-?\d*\.?\d*$/.test(r))return"0";let s=r;if(r&&"."!==r&&!Number.isNaN(Number(r))){let e=r.split(".")[1];if(e&&e.length>t){let e=Number(r),o=10**t;s=(s=(Math.floor(e*o)/o).toString()).replace(/\.?0+$/,"")}}return s}function ee(e,t){return(0,i.useQuery)({queryKey:["tokenDetails",e],queryFn:async()=>e?await X.tokenDetails({tokenId:e}):null,enabled:t&&!!e,staleTime:1e4,refetchInterval:1e4})}let et=G.object({symbol:G.string().transform(v.C),value:G.string().refine(()=>!0),isL1:G.boolean()}),eo=et.extend({value:G.string().refine(e=>{if(""===e)return!0;let t=Number.parseFloat(e);return!Number.isNaN(t)&&t>0},{message:"Value must be greater than zero"})});function er(e){let t=e.toString();return/^hy[A-Z]/.test(t)?"hyToken":/^purr[A-Z]/.test(t)?"purrToken":/^e[A-Z].*-\d+$/.test(t)?"eToken":null}function es(e){return"USDT0"===e?"USD₮0":e}function en(e){var t,o,n,l,u,I,U,D,_,M,O,Z,K,en,el;let ec=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"trade",em=arguments.length>2?arguments[2]:void 0,ef=arguments.length>3?arguments[3]:void 0,ep=(0,W.useRouter)(),ex=(0,W.useSearchParams)(),eh=ex.get("from"),ev=ex.get("to")||(null==em?void 0:em.symbol.toString())||null,eb=ex.get("fromL1"),eg=ex.get("toL1"),{chainId:ey}=(0,m.b)(),ew=(0,a.F)(),ek=!ew,{connectWallet:eN}=(0,z.u)(),{balances:eC}=(0,y.u)(),ej=(0,V.useMemo)(()=>eC.map(e=>{let{coin:t,...o}=e;return{coin:es(t),...o}}),[eC]),{assets:eA}=(0,g._)("all"),eS=(0,V.useMemo)(()=>eA.map(e=>{let{name:t,...o}=e;return{name:es(t),...o}}),[eA]),[eV,eT]=(0,V.useState)(null),{marketInfo:eL}=(0,f.y)({chainId:ey}),{markets:eF}=(0,r.U)(ey),{nativeAssetInfo:eI}=null!=eF?eF:{},[eE,eP]=(0,V.useState)("form"),eU=(0,k.ox)({chainId:ey,marketInfo:eL}),eD=(0,V.useRef)(null),[e_,eM]=(0,V.useState)(!1),[eH,eR]=(0,V.useState)(null),{data:eq}=(0,c.c)(),{isHypercoreUser:eB}=function(){let e=(0,a.F)(),{data:t,isLoading:o,error:r}=(0,i.useQuery)({queryKey:["hypercore-user-check",e],queryFn:async()=>{if(!e)return!1;try{return(await d.preTransferCheck({user:e,source:e})).userExists}catch(e){return console.error("Failed to check Hypercore user status:",e),!1}},enabled:!!e,staleTime:3e5,gcTime:6e5});return{isHypercoreUser:null!=t&&t,isLoading:o,error:r}}(),ez=(0,V.useCallback)(e=>{eR(e),eM(!0)},[]),{data:eO}=(0,i.useQuery)({queryKey:["hyperliquid-fee",ew],queryFn:async()=>{if(!ew)return{spotTaker:"0.07",spotMaker:"0.04"};try{let e=await X.userFees({user:ew}),t=e?100*Number(null==e?void 0:e.activeReferralDiscount):0,o=e?100*Number(null==e?void 0:e.userSpotCrossRate):.07,r=e?100*Number(null==e?void 0:e.userSpotAddRate):.04;return{spotTaker:"".concat(Number(o-t/100*o).toFixed(4)),spotMaker:"".concat(Number(r-t/100*r).toFixed(4))}}catch(e){return console.error("Failed to fetch HyperLiquid fee:",e),{spotTaker:"0.07",spotMaker:"0.04"}}},staleTime:6e4});(0,R.vA)(eI,"Native asset info is required for swap");let{nativeAssetSymbol:eW,wrappedNativeAssetSymbol:eQ}=eI,{tokensInfo:eZ}=function(e){let{nativeAssetSymbol:t,wrappedNativeAssetSymbol:o}=e,{data:r}=(0,F.useSuspenseQuery)((0,S.j)({queryKey:["swap-tokens","lifi"],queryFn:async()=>{try{let e=await fetch("/api/lifi/tokens",{headers:{Accept:"application/json"}});if(!e.ok)throw Error("Failed to fetch tokens");let t=(await e.json()).tokens[E.FU.id.toString()];if(!t)throw Error("No tokens found for hyperEVM");return[...t.map(e=>{var t;return{token:new h.ou({address:e.address,decimals:e.decimals,name:e.name,symbol:e.symbol,unitPriceUsd:null!=(t=e.priceUSD)?t:"0"}),balance:(0,x.pF)(0)}}),...P]}catch(e){return console.error(e),[]}}}));return{tokensInfo:(0,V.useMemo)(()=>new L.x(r.filter(e=>e.token.symbol!==o&&e.token.symbol!==t).map(e=>
1({token:new h.ou({symbol:e.token.symbol,name:e.token.name,decimals:e.token.decimals,address:(0,p.u)(e.token.address),unitPriceUsd:e.token.unitPriceUsd.toFixed()}),balance:(0,x.pF)(0)}))),[r,t,o])}}({nativeAssetSymbol:eW,wrappedNativeAssetSymbol:eQ}),eG=(0,V.useMemo)(()=>{let e=new Set;for(let t of eS)if(t.tradingWith&&Array.isArray(t.tradingWith))for(let o of t.tradingWith)e.add(o);return{assets:eS.filter(t=>e.has(t.name.toUpperCase())),symbols:Array.from(e)}},[eS]),eJ=(0,V.useMemo)(()=>[...eL.reserves,eL.findOneReserveBySymbol(eI.nativeAssetSymbol)],[eL,eI]),{fromAssetsL1:eK,toAssetsL1:eX,fromAssetsEvm:eY,toAssetsEvm:e$}=(U=eZ.all(),D=eG.assets,(0,V.useMemo)(()=>(function(e,t,o,r,s){let n=t.map(e=>({token:e.token,balance:o.findWalletBalanceForToken(e.token)})),a=r.filter(e=>!n.some(t=>t.token.symbol.toLowerCase()===e.token.symbol.toLowerCase())),l=[...n,...a],i=e.filter(e=>e.evmContract),u=new Set,d=[];for(let e of i)d.push(e),u.add(e.name.toUpperCase());for(let e of s)u.has(e.name.toUpperCase())||(d.push(e),u.add(e.name.toUpperCase()));return{fromAssetsL1:d,toAssetsL1:d,fromAssetsEvm:l,toAssetsEvm:l}})(eS,eJ,eU,U,D),[eS,eJ,eU,U,D])),e0=(0,V.useMemo)(()=>ea(eJ,eK,eY,eZ,ej,eU),[eJ,eK,eY,eZ,ej,eU]),e2=(0,V.useMemo)(()=>ea(eJ,eX,e$,eZ,ej,eU),[eJ,eX,e$,eZ,ej,eU]),[e1,e3]=(0,V.useState)(e),e4=(0,V.useMemo)(()=>ea(eJ,eK,[],eZ,ej,eU),[eJ,eK,eZ,ej,eU]),e6="Limit"===e1||"TWAP"===e1?e4:e0,e7="Limit"===e1||"TWAP"===e1?e4:e2,[e8,e5]=(0,V.useState)({}),e9=(0,V.useMemo)(()=>0===Object.keys(e8).length?e6:e6.map(e=>{if(void 0!==e.tokenId)return e;let t=e8[e.token.address.toLowerCase()];return void 0!==t?{...e,balance:t}:e}),[e6,e8]),te=(0,V.useMemo)(()=>0===Object.keys(e8).length?e7:e7.map(e=>{if(void 0!==e.tokenId)return e;let t=e8[e.token.address.toLowerCase()];return void 0!==t?{...e,balance:t}:e}),[e7,e8]),tt=(0,Q.mN)({resolver:(0,B.u)(function(e){let{fromAssets:t,toAssets:o,marketInfo:r,tradingWithAssetsSymbols:s,currentFilterTab:n}=e;return G.object({isMaxSelected:G.boolean(),from:function(e){let{fromAssets:t,marketInfo:o}=e;return eo.superRefine((e,r)=>{var s,n;let a=o.nativeAssetInfo.nativeAssetSymbol===e.symbol,l=(0,x.pF)(""===e.value?"0":e.value),i=e.isL1,u=null!=(n=null==(s=t.find(t=>t.token.symbol===e.symbol&&void 0!==t.tokenId&&i||t.token.symbol===e.symbol&&void 0===t.tokenId&&!i))?void 0:s.balance)?n:"0",d=ed({balance:(0,x.pF)(u),isNativeAsset:a,minRemainingNativeAsset:o.nativeAssetInfo.minRemainingNativeAssetBalance});l.gt(d)&&r.addIssue({code:"custom",message:a?"Not enough HYPE to cover transaction fees":"Insufficient balance",path:["value"]})})}({fromAssets:t,marketInfo:r}),to:et,limitPrice:G.string().optional(),twapHours:G.number().min(0).optional(),twapMinutes:G.number().min(0).optional(),twapRandomize:G.boolean().optional()}).superRefine((e,r)=>{let a,l,i;if((e.from.isL1||e.to.isL1)&&e.from.symbol!==e.to.symbol&&(s.includes(e.from.symbol.toUpperCase())||s.includes(e.to.symbol.toUpperCase()))&&("TWAP"===n&&60*(e.twapHours||0)+(e.twapMinutes||0)<5&&r.addIssue({code:"custom",message:"TWAP order must have minimum runtime of 5 minutes",path:["twapHours"]}),e.from.symbol===(0,v.C)("USDC")?(l=Number.parseFloat(e.to.value||"0"),i=o.find(t=>t.token.symbol===e.to.symbol&&void 0!==t.tokenId)):(l=Number.parseFloat(e.from.value||"0"),i=t.find(t=>t.token.symbol===e.from.symbol&&void 0!==t.tokenId)),(null==i?void 0:i.token.unitPriceUsd)&&Number(i.token.unitPriceUsd)>0)){let t=l*Number(i.token.unitPriceUsd);if("TWAP"===n){let o=60*(e.twapHours||0)+(e.twapMinutes||0);t<(a=Math.max(10*o,50))&&r.addIssue({code:"custom",message:"Order must have minimum value of $".concat(a," (").concat(o," minutes \xd7 $10 per minute)"),path:["from","value"]})}else t<(a=10)&&r.addIssue({code:"custom",message:"Order must have minimum value of $".concat(a),path:["from","value"]})}})}({fromAssets:e9,toAssets:te,marketInfo:eL,tradingWithAssetsSymbols:eG.symbols,currentFilterTab:e||""}),void 0,{raw:!0}),defaultValues:{...ei(e9,te,e1,{paramFromToken:eh,paramToToken:ev,paramFromL1:eb,paramToL1:eg})},mode:"onTouched",reValidateMode:"onChange"});eD.current=tt,(0,V.useEffect)(()=>
1{if(("Limit"===e||"TWAP"===e)&&"Limit"!==e1&&"TWAP"!==e1){var t,o,r;let s=ea(eJ,eS,[],eZ,ej,eU).filter(e=>"tokenId"in e&&void 0!==e.tokenId),n=tt.getValues(),a=n.from.symbol,l=n.to.symbol,i=n.from.isL1,u=n.to.isL1,d=s.some(e=>e.token.symbol===a&&i),c=s.some(e=>e.token.symbol===l&&u),m=a,f=l,p=!1;d&&a!==(0,v.C)("USDC")?(m=a,f=(0,v.C)("USDC")):c&&l!==(0,v.C)("USDC")?(m=(0,v.C)("USDC"),f=l):d&&a===(0,v.C)("USDC")?(m=a,f=(null==(t=s.find(e=>e.token.symbol!==(0,v.C)("USDC")))?void 0:t.token.symbol)||(0,v.C)("HYPE")):c&&l===(0,v.C)("USDC")?(m=(null==(o=s.find(e=>e.token.symbol!==(0,v.C)("USDC")))?void 0:o.token.symbol)||(0,v.C)("HYPE"),f=l):(m=(null==(r=s.find(e=>e.token.symbol!==(0,v.C)("USDC")))?void 0:r.token.symbol)||(0,v.C)("HYPE"),f=(0,v.C)("USDC")),p=!0;let x=s.find(e=>e.token.symbol===m),h=s.find(e=>e.token.symbol===f);(p||!d||!c)&&(x&&(tt.setValue("from.symbol",x.token.symbol),tt.setValue("from.isL1",!0),tt.setValue("from.value","")),h&&(tt.setValue("to.symbol",h.token.symbol),tt.setValue("to.isL1",!0),tt.setValue("to.value","")),tt.setValue("limitPrice","",{shouldValidate:!1}),x&&h&&"modal"!==ec&&ep.replace("/".concat(ec,"?from=").concat(x.token.symbol,"&to=").concat(h.token.symbol,"&fromL1=true&toL1=true"),{scroll:!1})),e3(e)}else"Limit"!==e&&"TWAP"!==e&&("Limit"===e1||"TWAP"===e1)&&e3(e)},[e,e1,eS,eJ,eZ,ej,eU,tt,ep,ec]);let to=tt.watch(),tr=(0,V.useMemo)(()=>new Set(eL.reserves.map(e=>e.token.symbol.toLowerCase())),[eL.reserves]),ts=to.from.isL1?void 0:e9.find(e=>e.token.symbol===to.from.symbol&&void 0===e.tokenId),tn=to.to.isL1?void 0:te.find(e=>e.token.symbol===to.to.symbol&&void 0===e.tokenId),ta=!!ts&&!tr.has(to.from.symbol.toLowerCase()),tl=!!tn&&!tr.has(to.to.symbol.toLowerCase()),{data:ti}=H({tokenAddress:null==ts?void 0:ts.token.address,decimals:null!=(u=null==ts?void 0:ts.token.decimals)?u:18,chainId:ey,enabled:ta}),{data:tu}=H({tokenAddress:null==tn?void 0:tn.token.address,decimals:null!=(I=null==tn?void 0:tn.token.decimals)?I:18,chainId:ey,enabled:tl}),td=null==ts?void 0:ts.token.address,tc=null==tn?void 0:tn.token.address,tm=null==ti?void 0:ti.toFixed(),tf=null==tu?void 0:tu.toFixed();(0,V.useEffect)(()=>{void 0!==tm&&td&&ta&&e5(e=>{var t;let o=td.toLowerCase();return(null==(t=e[o])?void 0:t.toFixed())===tm?e:{...e,[o]:(0,x.pF)(tm)}})},[tm,td,ta]),(0,V.useEffect)(()=>{void 0!==tf&&tc&&tl&&e5(e=>{var t;let o=tc.toLowerCase();return(null==(t=e[o])?void 0:t.toFixed())===tf?e:{...e,[o]:(0,x.pF)(tf)}})},[tf,tc,tl]);let tp=function(e,t,o){function r(e,t){let o=t.find(t=>t.token.symbol===e.symbol&&(e.isL1?void 0!==t.tokenId:void 0===t.tokenId));return o||(0,R.xl)("No assets available"),{...o,value:(0,x.pF)(""===e.value?"0":e.value)}}return{from:r(e.from,t),to:r(e.to,o)}}(to,e9,te),tx=(0,V.useMemo)(()=>{if(to.from.isL1||to.to.isL1)return!1;let e=er((0,v.C)(to.from.symbol)),t=er((0,v.C)(to.to.symbol));return null!==e&&e===t},[to.from.symbol,to.to.symbol,to.from.isL1,to.to.isL1]),th=(M=tp,O=e9,Z=te,[{from:null!=(K=O.find(e=>e.token.symbol===M.from.token.symbol&&void 0!==e.tokenId==(void 0!==M.from.tokenId)))?K:(0,R.xl)("No from assets available"),to:null!=(en=Z.find(e=>e.token.symbol===M.to.token.symbol&&void 0!==e.tokenId==(void 0!==M.to.tokenId)))?en:(0,R.xl)("No to assets available"),amount:null!=(el=M.from.value)?el:(0,x.pF)(0)}]),{isL1Trade:tv,isEvmTrade:tb,isDualL1Trade:tg}=(0,J.H)(tp.from,tp.to,eI.nativeAssetSymbol,eI.wrappedNativeAssetSymbol,eG.symbols),{data:ty,isLoading:tw}=ee(null==(t=Y(tp.from,tp.to,e9,te,tg?"from":void 0))?void 0:t.tokenId,tv||tg),{data:tk,isLoading:tN}=ee(null==(o=Y(tp.from,tp.to,e9,te,"to"))?void 0:o.tokenId,tg),tC=void 0===tp.to.tokenId?tp.to.token:null==(n=te.find(e=>e.token.symbol===tp.to.token.symbol&&void 0===e.tokenId))?void 0:n.token,tj=void 0===tp.from.tokenId?tp.from.token:null==(l=e9.find(e=>e.token.symbol===tp.from.token.symbol&&void 0===e.tokenId))?void 0:l.token,tA=null==tj?void 0:tj.toBaseUnit("0"===tp.from.value.toString()||""===tp.from.value.toString()?(0,x.pF)("1"):tp.from.value),{debouncedValue:tS,isDebouncing:tV}=(0,q.d)({inputToken:null==tj?void 0:tj.address,outputToken:null==tC?void 0:tC.address,inputAmount:tA},"".concat(null==tj?void 0:tj.address,"-").concat(null==tC?void 0:tC.address,"-").concat(null==tA?void 0:tA.toString()),{delay:500}),{price:tT,isLoading:tL}=function(e){let{inputToken:t,outputToken:o,account:r,inputAmount:s,outputAmount:n,enabled:a,slippage:l,resetErrors:u,refetchInterval:d,refetchOnWindowFocus:c}=e,m=(0,i.useQuery)({...function(e){let{inputToken:t,outputToken:o,account:r,inputAmount:s,outputAmount:n,slippage:a,resetErrors:l}=e,i=!!(null==s?void 0:s.gt(0)),u=!!(null==n?void 0:n.gt(0));return(0,S.j)({queryKey:function(e){let{inputToken:t,outputToken:o,account:r,inputAmount:s,outputAmount:n,slippage:a}=e;return[...function(e){let{inputToken:t,outputToken:o,account:r,inputAmount:s,outputAmount:n,slippage:a}=e;return["lifi-price",t,o,r,s,n,a]}({inputToken:t,outputToken:o,account:r,inputAmount:s,outputAmount:n,slippage:a})]}({inputToken:t,outputToken:o,account:r,inputAmount:s,outputAmount:n,slippage:a}),queryFn:async()=>
1{if(!t||!o||!r||!i&&!u||t===o||(l(),!i))return null;try{var e,n;let l=(0,C.Dg)(s);if(l<=0n)return null;let i=await (0,N.dt)({fromToken:(0,N.XN)(t),toToken:(0,N.XN)(o),fromAmount:l.toString(),fromAddress:r,slippageBps:null!=a?a:50});if(0n>=BigInt(null!=(n=null==(e=i.estimate)?void 0:e.toAmount)?n:"0"))return null;return(0,T.qD)(i,r,t,o)}catch(e){if(console.error("LiFi quote error:",e),e instanceof N.h6)return{statusCode:e.status,error:e.message};if(e instanceof T.kf)return{statusCode:400,error:e.message};return{statusCode:500,error:e instanceof Error?e.message:"Unknown error fetching quote"}}},enabled:!!(t&&o&&r&&i),refetchInterval:2e4,staleTime:5e3,gcTime:1/0,retry:2,retryDelay:1e3})}({inputToken:t,outputToken:o,account:r,inputAmount:s,outputAmount:n,slippage:l,resetErrors:u}),enabled:a,...void 0!==d?{refetchInterval:d}:{},...void 0!==c?{refetchOnWindowFocus:c}:{}}),f=(0,V.useRef)(""),p=(0,V.useRef)("");return(0,V.useEffect)(()=>{let e=m.data;if(e){if("result"in e){let r="".concat(t,"_").concat(o,"_").concat(null==s?void 0:s.toFixed());if(r===f.current)return;f.current=r,(0,j.u4)("swap_quote_received",{input_token:String(null!=t?t:""),output_token:String(null!=o?o:""),input_amount:e.result.inputAmount,output_amount:e.result.outputAmount,slippage_setting:(null!=l?l:50)/100})}else if("error"in e){var r;let n="".concat(t,"_").concat(o,"_").concat(null==s?void 0:s.toFixed(),"_").concat(e.error);if(n===p.current)return;p.current=n,(0,j.u4)("swap_quote_failed",{input_token:String(null!=t?t:""),output_token:String(null!=o?o:""),input_amount:null!=(r=null==s?void 0:s.toFixed())?r:"0",error_type:(0,A.f)({message:e.error}),error_message:e.error})}}},[m.data,t,o,s,l]),{...m,price:m.data}}({inputToken:tS.inputToken,outputToken:tS.outputToken,account:ew||"0x000000000000000000000000000000000000dEaD",inputAmount:tS.inputAmount,enabled:tb&&!tV,slippage:null!=ef?Math.round(1e4*ef):void 0,resetErrors:()=>{tt.clearErrors()}}),tF=tT&&"result"in tT&&tj&&tC&&tT.result.inputToken.toLowerCase()===tj.address.toLowerCase()&&tT.result.outputToken.toLowerCase()===tC.address.toLowerCase()?tT.result.effectiveOutputAmount:null,tI=tF?null==tC?void 0:tC.fromBaseUnit((0,x.lL)(tF)):null,tE=(0,V.useRef)(null),tP=(0,V.useRef)(e9),tU=(0,V.useRef)(te),tD=(0,V.useRef)("N/A"),t_=tg?(null==tk?void 0:tk.markPx)&&(null==ty?void 0:ty.markPx)?$((0,x.pF)(ty.markPx).dividedBy((0,x.pF)(tk.markPx)),tp.to.token.decimals,!0):"N/A":(tv?(_=tp.from.token,(null==ty?void 0:ty.markPx)?_.symbol.toUpperCase()!==ty.name.toUpperCase()?(1/Number(ty.markPx)).toFixed(_.decimals):ty.markPx:"N/A"):tb?tI?$((0,x.pF)(tI).dividedBy(0===Number(tp.from.value)?(0,x.pF)(1):(0,x.pF)(tp.from.value)),tp.to.token.decimals,void 0!==tp.to.tokenId):"N/A":"1")||"N/A";"N/A"!==t_&&"1"!==t_&&(tD.current=t_);let tM=tw||tL||tV||tN,tH=tM&&"N/A"!==tD.current?tD.current:t_;(0,V.useEffect)(()=>{"Limit"!==e1||!tH||"N/A"===tH||tM||tt.getValues("limitPrice")||tt.setValue("limitPrice",tH,{shouldValidate:!1})},[e1,tH,tM,tt]);let tR=(0,V.useRef)(""),tq=to.from.symbol,tB=to.to.symbol,tz=to.from.isL1,tO=to.to.isL1;function tW(e){let t;if(!eD.current)return;let o=tE.current;if(!o)return;let r=eD.current.getValues("".concat(o,".value"));if(!r){eD.current.setValue("from.value","",{shouldValidate:!1}),eD.current.setValue("to.value","",{shouldValidate:!1});return}let s=eD.current.getValues("to.symbol"),n=eD.current.getValues("from.symbol"),a=eD.current.getValues("to.isL1"),l=eD.current.getValues("from.isL1"),i=tp.from.token.symbol,u=tp.to.token.symbol,d=void 0!==tp.from.tokenId,c=void 0!==tp.to.tokenId;if(n!==i||s!==u||l!==d||a!==c)return void console.warn("Exchange rate is stale for current token pair, skipping recalculation");let m=tU.current.find(e=>e.token.symbol===s&&void 0!==e.tokenId===a),f=tP.current.find(e=>e.token.symbol===n&&void 0!==e.tokenId===l),p=Number(r),h=Number(e);if("from"===o){if(t=p*h,m){let e=$((0,x.pF)(t),m.token.decimals,a);eD.current.setValue("to.value",e,{shouldValidate:!1})}}else if("to"===o&&(t=p/h,f)){let e=$((0,x.pF)(t),f.token.decimals,l);eD.current.setValue("from.value",e,{shouldValidate:!1})}}(0,V.useEffect)(()=>
1{if("Limit"===e1||"TWAP"===e1){let e="".concat(tq,"-").concat(tB,"-").concat(tz,"-").concat(tO);tR.current&&tR.current!==e&&"Limit"===e1&&tt.setValue("limitPrice","",{shouldValidate:!1}),tR.current=e}},[e1,tq,tB,tz,tO,tt]),(0,V.useEffect)(()=>{tP.current=e9},[e9]),(0,V.useEffect)(()=>{tU.current=te},[te]),(0,V.useEffect)(()=>{if(!tM&&tH&&Number(tH)>0&&tE.current&&eD.current){let e="Limit"===e1?tt.getValues("limitPrice"):tH;e&&Number(e)>0&&tW(e)}},[tH]);let tQ=(0,V.useRef)(null);function tZ(e){return t=>{let o=t.target.value;tt.clearErrors(e),tt.clearErrors("to"),tt.setValue("".concat(e,".value"),o,{shouldValidate:!1}),tE.current=e;let r="Limit"===e1?tt.getValues("limitPrice"):tH;r&&Number(r)>0&&tW(r),tQ.current&&clearTimeout(tQ.current),tQ.current=setTimeout(()=>{tt.trigger().catch(console.error)},300)}}let tG=eu({form:tt,assets:e9,fieldName:"from",counterpartFieldName:"to",tokensInfo:eZ,onChange:tZ("from"),l1Balances:ej,exchangeRate:tH,toAssetsRef:tU,marketInfo:eL,lastEditedFieldRef:tE,currentTab:e1,currentPage:ec}),tJ=eu({form:tt,assets:te,fieldName:"to",counterpartFieldName:"from",tokensInfo:eZ,onChange:tZ("to"),l1Balances:ej,exchangeRate:tH,toAssetsRef:tU,marketInfo:eL,lastEditedFieldRef:tE,currentTab:e1,currentPage:ec});return{form:tt,actions:th,fromTokenField:tG,toTokenField:tJ,fromToken:tp.from,toToken:tp.to,exchangeRate:tH,isExchangeRateLoading:tM,hyperliquidFee:null!=eO?eO:null,swapQuoteData:null!=tT?tT:null,tradingWithAssetsSymbols:eG.symbols,pageStatus:{state:eE,actionsEnabled:tp.from.value.gt(0)&&tt.formState.isValid&&!tM&&"N/A"!==tH,successData:eV,goToSuccessScreen:()=>{eT({...tp}),eP("success"),tt.reset(ei(e9,te,e1,{paramFromToken:eh,paramToToken:ev,paramFromL1:eb,paramToL1:eg})),s.q.refetchQueries({queryKey:["swap-tokens","lifi"]}),s.q.refetchQueries({queryKey:(0,b.u)({account:ew})}),s.q.invalidateQueries({queryKey:["openOrders",ew]}),s.q.invalidateQueries({queryKey:["twapOrders",ew]}),s.q.invalidateQueries({queryKey:(0,w.j)({account:ew,chainId:ey})}),s.q.invalidateQueries({queryKey:["token-balance"]})},resetForm:()=>{tt.reset(ei(e9,te,e1,{paramFromToken:eh,paramToToken:ev,paramFromL1:eb,paramToL1:eg})),eP("form"),eT(null)}},guestMode:ek,swapDirection:function(){let e=tt.getValues("from.symbol"),t=tt.getValues("to.symbol"),o=tt.getValues("from.value"),r=tt.getValues("to.value"),s=tt.getValues("from.isL1"),n=tt.getValues("to.isL1");tt.setValue("isMaxSelected",!1,{shouldValidate:!1}),tt.setValue("from.symbol",t),tt.setValue("to.symbol",e),tt.setValue("from.value",r),tt.setValue("to.value",o),tt.setValue("from.isL1",n),tt.setValue("to.isL1",s),"Limit"===e1&&tt.setValue("limitPrice","",{shouldValidate:!1}),"modal"!==ec&&ep.replace("/".concat(ec,"?from=").concat(t,"&to=").concat(e,"&fromL1=").concat(n,"&toL1=").concat(s),{scroll:!1}),tt.trigger().catch(console.error)},openConnectModal:eN,hyperCoreAssets:eS,showGasLimitModal:e_,setShowGasLimitModal:eM,gasLimitDetails:eH,isUsingBigBlocks:null!=eq&&eq,isHypercoreUser:eB,handleGasLimitExceeded:ez,isBothDepositTokens:tx}}function ea(e,t,o,r,n,a){let l=t.map(t=>(function(e,t,o,r,n){var a,l,i,u,d,c,m,f,b;let g=null==(a=e.find(e=>e.token.symbol.toUpperCase()===(0,v.C)(t.name)))?void 0:a.priceInUSD.toString(),y=s.q.getQueryData(["tokenDetails",t.tokenId]),w=new h.ou({symbol:(0,v.C)(t.name),decimals:t.weiDecimals+(null!=(c=null==t||null==(l=t.evmContract)?void 0:l.evm_extra_wei_decimals)?c:0),address:(0,p.u)(null!=(m=null==(i=t.evmContract)?void 0:i.address)?m:Z.Xd),unitPriceUsd:(null==y?void 0:y.markPx)||g||t.midPrice||"0",name:t.fullName||t.name,isAToken:!1});return{...t,token:w,evmContract:t.evmContract,systemAddress:t.systemAddress,l1Balance:(0,x.pF)(null!=(f=null==(u=r.find(e=>{let{coin:o}=e;return o===t.name}))?void 0:u.total)?f:"0"),balance:(0,x.pF)(null!=(b=null==(d=r.find(e=>{let{coin:o}=e;return o===t.name}))?void 0:d.total)?b:"0"),value:(0,x.pF)(0)}})(e,t,0,n,0)),i=o.map(o=>{var r;let s=null==(r=e.find(e=>e.token.symbol.toUpperCase()===o.token.symbol.toUpperCase()))?void 0:r.priceInUSD.toString(),n=t.find(e=>e.name.toUpperCase()===o.token.symbol.toUpperCase());return{...o,token:new h.ou({...o.token,unitPriceUsd:s||(null==n?void 0:n.midPrice)||o.token.unitPriceUsd.toFixed()||"0"})}}),u=new Set;return[...l,...i].filter(e=>{let t=void 0!==e.tokenId,o="".concat(e.token.address,"-").concat(e.token.symbol,"-").concat(t);return!u.has(o)&&(u.add(o),!0)}).sort((e,t)=>
1{if("HYPE"===e.token.symbol&&"HYPE"!==t.token.symbol)return -1;if("HYPE"!==e.token.symbol&&"HYPE"===t.token.symbol)return 1;let o=Number(e.token.unitPriceUsd),r=Number(t.token.unitPriceUsd),s=Number(e.balance),n=Number(t.balance),a=o*s,l=r*n;if(s>0&&0===n)return -1;if(0===s&&n>0)return 1;if(s>0&&n>0){if(o>0&&0===r)return -1;if(0===o&&r>0)return 1;if(o>0&&r>0)return l-a;if(0===o&&0===r)return n-s}return 0===s&&0===n?o>0&&0===r?-1:0===o&&r>0?1:l-a:0})}function el(e,t,o){return"Limit"!==o&&"TWAP"!==o?e:e.filter(e=>void 0!==e.tokenId&&("USDC"===t?e.token.symbol!==(0,v.C)("USDC"):e.token.symbol===(0,v.C)("USDC")))}function ei(e,t,o,r){var s,n,a,l,i,u,d;let{paramFromToken:c,paramToToken:m,paramFromL1:f,paramToL1:p}=r,x=el(e,m,o),h=el(t,c,o),b=c?x.find(e=>e.token.symbol===c&&("true"===f?void 0!==e.tokenId:void 0===e.tokenId)):null,g=m?h.find(e=>e.token.symbol===m&&("true"===p?void 0!==e.tokenId:void 0===e.tokenId)):null,y=null,w=null;return("Limit"!==o||b&&g)&&(y=null!=b?b:null,w=null!=g?g:null),"Limit"===o||"TWAP"===o?(w||(w=null!=(s=h.find(e=>"USDC"===e.token.symbol&&void 0!==e.tokenId))?s:null),y||(y=null!=(n=x.find(e=>void 0!==e.tokenId&&"USDC"!==e.token.symbol))?n:null),y||(y=null!=(a=x.find(e=>void 0!==e.tokenId&&e.token.symbol!==(null==w?void 0:w.token.symbol)))?a:null),w||(w=null!=(l=h.find(e=>void 0!==e.tokenId&&e.token.symbol!==(null==y?void 0:y.token.symbol)))?l:null)):(y||(y=null!=(i=x.find(e=>void 0===e.tokenId))?i:null),w||(w=null!=(d=null!=(u=h.find(e=>"USDXL"===e.token.symbol&&void 0===e.tokenId))?u:h.find(e=>void 0===e.tokenId&&e.token.symbol!==(null==y?void 0:y.token.symbol)))?d:null)),{from:{symbol:y?y.token.symbol:(0,v.C)("-"),value:"",isL1:!!y&&void 0!==y.tokenId},to:{symbol:w?w.token.symbol:(0,v.C)("-"),value:"",isL1:!!w&&void 0!==w.tokenId},isMaxSelected:!1,limitPrice:"",twapHours:0,twapMinutes:5,twapRandomize:!1}}function eu(e){let{form:t,assets:o,fieldName:r,counterpartFieldName:s,onChange:n,exchangeRate:a,toAssetsRef:l,marketInfo:i,lastEditedFieldRef:u,currentTab:d,currentPage:c}=e,m=(0,W.useRouter)(),f=t.getValues(),b=f[r].symbol,g=f[r].value,y=f[r].isL1,w=el(o,f[s].symbol,d),k=w.find(e=>e.token.symbol===b&&(y?void 0!==e.tokenId:void 0===e.tokenId)),N="from"===r?ed({balance:(null==k?void 0:k.balance)||(0,x.pF)(0),isNativeAsset:i.nativeAssetInfo.nativeAssetSymbol===(null==k?void 0:k.token.symbol),minRemainingNativeAsset:i.nativeAssetInfo.minRemainingNativeAssetBalance}):(0,x.pF)(0),C="from"===r&&N.gt(0);return{selectedAsset:k||{balance:(0,x.pF)(0),token:new h.ou({symbol:(0,v.C)("-"),decimals:6,address:(0,p.u)("0x0000000000000000000000000000000000000000"),unitPriceUsd:"0",name:"",isAToken:!1})},availableAssets:w,onChange:n,changeToken:function(e,o){t.setValue("isMaxSelected",!1,{shouldValidate:!1});let n=f[s].symbol,a=f[s].isL1;if(e===n&&o===a){"modal"!==c&&m.replace("/".concat(c,"?from=").concat(t.getValues("to.symbol"),"&to=").concat(t.getValues("from.symbol"),"&fromL1=").concat(t.getValues("to.isL1"),"&toL1=").concat(t.getValues("from.isL1")),{scroll:!1}),function(e,t){let o=e.getValues("from.symbol"),r=e.getValues("from.value"),s=e.getValues("from.isL1"),n=e.getValues("to.symbol"),a=e.getValues("to.isL1");e.setValue("from",{symbol:n,value:r,isL1:a},{shouldValidate:!0}),e.setValue("to",{symbol:o,value:"",isL1:s},{shouldValidate:!0}),e.setValue("isMaxSelected",!1,{shouldValidate:!1}),"Limit"===t&&e.setValue("limitPrice","",{shouldValidate:!1})}(t,d);return}"modal"!==c&&m.replace("/".concat(c,"?").concat(r,"=").concat(e,"&").concat(s,"=").concat(n,"&").concat(r,"L1=").concat(o,"&").concat(s,"L1=").concat(a),{scroll:!1}),t.setValue(r,{symbol:e,value:g,isL1:o},{shouldValidate:!1}),u.current&&t.setValue("".concat("from"===u.current?"to":"from",".value"),"",{shouldValidate:!1}),"Limit"===d&&t.setValue("limitPrice","",{shouldValidate:!1}),t.trigger()},maxSelectedFieldName:"from"===r?"isMaxSelected":void 0,maxValue:N,onSetMax:C?e=>{if(u.current=r,!k)return void t.setValue("from.value","");t.setValue("from.value",$(e,k.token.decimals,y));let o={from:{symbol:t.getValues("from.symbol"),isL1:t.getValues("from.isL1")}
1,to:{symbol:t.getValues("to.symbol"),isL1:t.getValues("to.isL1")}};ec(t,a,l,e,o),setTimeout(()=>{t.trigger()},0)}:void 0}}function ed(e){let{balance:t,isNativeAsset:o,minRemainingNativeAsset:r}=e,s=t.minus(o?r:(0,x.pF)(0));return(0,x.pF)(O.g.max(s,0))}function ec(e,t,o,r,s){let n=e.getValues("to.symbol"),a=e.getValues("to.isL1"),l=e.getValues("from.symbol"),i=e.getValues("from.isL1");if(s){let t=s.from.symbol,o=s.to.symbol,r=s.from.isL1,u=s.to.isL1;if(l!==t||n!==o||i!==r||a!==u){console.warn("Exchange rate is stale for current token pair in calculateToAmount, skipping calculation"),e.setValue("to.value","",{shouldValidate:!0});return}}let u=o.current.find(e=>e.token.symbol===n&&void 0!==e.tokenId===a);if(t&&Number(t)>0&&"N/A"!==t){let o=Number(r),s=Number(t);if(u){let t=$((0,x.pF)(o*s),u.token.decimals,a);e.setValue("to.value",t,{shouldValidate:!0})}}else e.setValue("to.value","",{shouldValidate:!0})}},93164:(e,t,o)=>{o.d(t,{f:()=>n});var r=o(43238),s=o(51557);function n(e){let{className:t,onClick:o}=e;return(0,r.jsx)("div",{className:t,children:(0,r.jsx)("button",{className:"block rounded-lg border border-border bg-[#0c0c0e] p-4 text-muted-foreground transition-colors hover:bg-primary hover:text-primary-foreground",onClick:o,children:(0,r.jsx)(s.A,{className:"h-5 w-5"})})})}},94815:(e,t,o)=>{o.d(t,{y:()=>l});let r=[{name:"deposit",type:"function",inputs:[{name:"amount",type:"uint256"},{name:"destinationDex",type:"uint32"}],outputs:[],stateMutability:"nonpayable"}];var s=o(32301),n=o(91200),a=o(28830);async function l(e,t,o,l,i){let u=await e.writeContract({address:o,abi:a.xw,functionName:"approve",args:[l,i]});await (0,n.DV)(t,u);let d=await e.writeContract({address:l,abi:r,functionName:"deposit",args:[i,s.t2]});return await (0,n.DV)(t,d)}}}]);
2//# sourceMappingURL=6540-bc3c3afa35ef7d66.js.map

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.