8 lines
26 KiB
JavaScript
8 lines
26 KiB
JavaScript
import{a as Pt,d as At,e as bt}from"./chunk-7PVQSYLW.js";import{a as It,b as Et}from"./chunk-FXTBNMAZ.js";import{a as yt}from"./chunk-SKCWGFVV.js";import{b as Lt}from"./chunk-QC5K7RR4.js";import{a as Mt,b as f}from"./chunk-SPBBNCBQ.js";import{a as Tt}from"./chunk-4QY5PWIM.js";import{j as W}from"./chunk-HPJHK3WS.js";import{a as pt,b as z,c as gt,d as kt}from"./chunk-CABCMWZT.js";import{f as Z,i as ee,p as ht,q as St}from"./chunk-KS3GEYRJ.js";import{a as Je,c as $e,h as Ze,i as j,k as ot,n as rt,p as st,q as ut,r as $,s as ct,t as lt,u as dt,v as ft}from"./chunk-FVJO2JSC.js";import{c as tt}from"./chunk-NWVG2MAV.js";import"./chunk-WK2EF5FH.js";import"./chunk-X2NMQEET.js";import{b as nt,d as it,h as at,i as mt}from"./chunk-EHIXZ23F.js";import"./chunk-6TCIDKYS.js";import"./chunk-6FDARXB6.js";import{d as U}from"./chunk-JWQKG6DL.js";import{a as F,b as O,c as L}from"./chunk-UJIS6BFS.js";import{l as Q,n as k}from"./chunk-GRAP3YP7.js";import{O as et}from"./chunk-46YG4TCM.js";import{a as ze}from"./chunk-WYIQIGDJ.js";import"./chunk-GDM6S2OD.js";import"./chunk-XQPKRCN2.js";import"./chunk-XC6ELVTG.js";import"./chunk-Z3DVZYQL.js";import{a as y}from"./chunk-TVUCEIYF.js";import{Zc as Ge,ab as Oe,ad as We,bb as J,bc as Ve,bd as He,cb as Ue,cd as Ke,db as Ne,dd as Ye,ed as Xe,ia as Qe,md as je,sb as qe,za as Fe}from"./chunk-MYNBMTR4.js";import{$ as Be,G as E,K as De,N as Ce,O as xe,V,W as X,X as Re,Y as we,Z as _e,_ as ve,ca as G,l as A,m as C,q as ye,r as be,y as ke}from"./chunk-TQQZZJXW.js";import"./chunk-OW3UQNCS.js";import"./chunk-OJSBXBLD.js";import"./chunk-AAPE6FE4.js";import"./chunk-SGNJOSQB.js";import"./chunk-6MDHMQQH.js";import"./chunk-XIFCFAQW.js";import"./chunk-SE3PRL6Z.js";import"./chunk-NQTLXTUD.js";import"./chunk-FATNH5YG.js";import"./chunk-RL2JAB2F.js";import"./chunk-OV5ZOYAY.js";import{a as Y}from"./chunk-62FSCPM5.js";import{a as so}from"./chunk-J5JOI62E.js";import"./chunk-SQMXULWT.js";import"./chunk-KBSRU77R.js";import{F as Pe,G as Ae}from"./chunk-GQZAGQSC.js";import"./chunk-STCDRFCQ.js";import{H as Te,c as Ee,j as m,r as Le,ra as w}from"./chunk-GSIHKWLV.js";import"./chunk-RC6UR2LL.js";import"./chunk-XTEVCKH7.js";import{b as g}from"./chunk-BF2V36QE.js";import"./chunk-E735URDA.js";import"./chunk-NBTO427E.js";import"./chunk-YHVKZE66.js";import{f as S,o as n,q as i}from"./chunk-QTLWQ5AJ.js";n();i();var Se=S(g());n();i();var b=S(g()),to=S(Y());n();i();var _=S(g());n();i();var Me=S(g());w();var Dt=()=>{let{buyStore:o,sellStore:e}=f(),{currentBuyPreset:t,setBuyValue:r,buyValue:s}=o,{currentSellPreset:a,setSellValue:u,sellValue:c}=e,{amountList:d=[]}=t,{amountList:p=[]}=a;(0,Me.useEffect)(()=>{Te(d)||s.type==="custom"||r({value:d[s.index]||"0",type:"select",index:s.index})},[r,d]),(0,Me.useEffect)(()=>{if(Te(p)||c.type==="custom")return;let h=p[c.index]||"0";u({value:h,type:"select",index:c.index})},[u,p])};var no=({inputAmount:o,custom:e,defaultBuyAmountList:t,buyStore:r,setAmountUsed:s,setCustomUsed:a})=>{e==="1"?(r.setBuyValue({value:"",type:"custom",index:3}),a(!0),W("custom")):o&&(t.includes(o)?(r.setBuyValue({value:o,type:"select",index:t.findIndex(u=>u===o)}),s(!0),W("inputAmount")):r.setBuyValue({value:t[0]||"0",type:"select",index:0}))},io=({inputPercent:o,custom:e,defaultSellPercentList:t,sellStore:r,setPercentUsed:s,setCustomUsed:a})=>{e==="1"?(r.setSellValue({value:"",type:"custom",index:3}),r.setIsPercentMode(!0),a(!0),W("custom")):o&&(r.setIsPercentMode(!0),t.includes(o)?(r.setSellValue({value:o,type:"custom",index:3}),s(!0),W("inputPercent")):r.setSellValue({value:t[0]||"0",type:"select",index:0}))},Ct=()=>{let{queryParams:o}=Et(),{buyStore:e,sellStore:t,configStore:r}=f(),{currentMode:s}=r,{currentBuyPreset:a}=e,{currentSellPreset:u}=t,{amountList:c}=a,{amountList:d}=u,p=o?.get?.("inputAmount"),h=o?.get?.("inputPercent"),M=o?.get?.("custom"),[I,P]=(0,_.useState)(!1),[D,ge]=(0,_.useState)(!1),[B,K]=(0,_.useState)(!1);(0,_.useEffect)(()=>{s==="buy"&&!I&&!B&&no({inputAmount:p,custom:M,defaultBuyAmountList:c||[],buyStore:e,setAmountUsed:P,setCustomUsed:K})},[p,M,s,c,I,B]),(0,_.useEffect)(()=>{s==="sell"&&!D&&!B&&io({inputPercent:h,custom:M,defaultSellPercentList:d||[],sellStore:t,setPercentUsed:ge,setCustomUsed:K})},[p,h,M,s,d,D,B]),Dt()};n();i();var wt=S(g());n();i();var xt=S(g());n();i();var te=S(g());var ao=()=>{let{buyStore:o,sellStore:e,configStore:t}=f(),{currentMode:r}=t,s=(0,te.useCallback)(d=>{let p=d.coinAmountOriginalDec||d.amountNum,h={...d,amountNum:p};e.onSocketUpdateFromTokenBalance(h),o.onSocketUpdateFromTokenBalance(h)},[e,o]),a=e.fromToken?.tokenContractAddress,u=o.fromToken?.tokenContractAddress,c=(0,te.useMemo)(()=>r==="sell"?a:u,[a,u,r]);return{updateTokenBalance:s,currentTokenAddress:c}},oe=ao;var mo=()=>{let{updateTokenBalance:o,currentTokenAddress:e}=oe(),t=yt(),{chainId:r,accountId:s,userUniqueId:a,walletId:u,userWalletAddress:c,businessType:d}=t;return(0,xt.useCallback)(async()=>{if(e&&r&&s&&a&&u&&c){let p=await At({tokenAddress:e,chainId:r,accountId:s,userUniqueId:a,walletId:u,userWalletAddress:c,businessType:d});p&&o(p)}},[r,e,s,a,u,c,d,o])},Rt=mo;var uo=()=>{let{accountStore:o,memePositionStore:e,configStore:t,commonStore:r}=f(),{computedAccountId:s}=o,{userUniqueId:a}=r,{computedNativeTokenInfo:u}=t,{chainId:c}=u||{},{fetchPositionList:d}=e,p=Pt(d,300),{updateTokenBalance:h}=oe(),M=Rt();(0,wt.useEffect)(()=>{let I=$({isPri:!0,needLogin:!0,subscribeParams:[{channel:dt.WALLET_ASSET}],onListenData:P=>{!P||(p({chainId:c,accountId:s,userUniqueId:a}),h(P))},onListenError:M,onListenReconnected:M});return()=>{I()}},[c,s,a,p,h,M])},_t=uo;n();i();var vt=S(g());function Bt(){let{accountStore:o}=f(),{computedAccountWalletAddresses:e}=o;(0,vt.useEffect)(()=>{let t=()=>{};return e&&(t=ct(e)),()=>{t?.()}},[e])}n();i();n();i();var Ot=S(g());n();i();function re(){let{buyStore:o,sellStore:e,configStore:t}=f(),{currentMode:r}=t;return(r==="sell"?e.fromToken:o.toToken)||{}}n();i();var Qt=(o,e)=>{let t={userUniqueId:o,tokenDetailList:[{chainId:e.chainId,contractAddress:e.tokenContractAddress,tokenSymbol:e.tokenSymbol,precision:e.decimals}]};return L.post(Ve,t)},Ft=o=>(Array.isArray(o)?o:[o]).map(t=>({channel:lt.DEX_MARKET_TX_CHANNEL,chainId:t?.chainId,tokenAddress:t?.tokenContractAddress}));var co=()=>{let o=re(),{commonStore:e}=f();(0,Ot.useEffect)(()=>{!o.tokenContractAddress||!o.chainId||!e.userUniqueId||Qt(e.userUniqueId,o)},[e.userUniqueId,o.tokenContractAddress,o.chainId])},Ut=co;n();i();var Wt=S(g());n();i();var Vt=S(g());n();i();var Nt=async({tokenContractAddress:o,accountId:e=void 0,chainId:t,walletAddress:r=void 0})=>{let s=performance.now(),[a,u]=await E(L.get(Ge,{params:{tokenContractAddress:o,accountId:e,chainId:t,walletAddress:r}})),c=performance.now()-s;return ye.info(`[Market-API]: fetchLatestInfo: ${c?.toFixed?.(2)}ms`),!a&&u?u.data:{error:a}};n();i();var qt=S(g());var lo=()=>{let{buyStore:o,sellStore:e,configStore:t}=f(),{currentMode:r}=t;return(0,qt.useCallback)(s=>{let a={...s,chainId:Number(s.chainId)};r==="sell"?e.onSocketUpdateFromToken(a):o.onSocketUpdateToToken(a)},[r,e,o])},se=lo;var fo=()=>{let{accountStore:o}=f(),{computedAccountId:e,computedSignWalletAddress:t}=o,r=se();return(0,Vt.useCallback)(async s=>{let a=await Nt({tokenContractAddress:s.tokenContractAddress,chainId:s.chainId,accountId:e,walletAddress:t});if(a?.error)return;let u={...s,price:a.price,marketCap:a.marketCap};r(u)},[r,e])},Gt=fo;var po=()=>{let o=re(),e=se(),t=Gt();(0,Wt.useEffect)(()=>{if(!o.tokenContractAddress||!o.chainId)return()=>{};let r=Ft(o),s=$({subscribeParams:r,onListenData:a=>{e(a[0])},onListenError:()=>{t(o)},onListenReconnected:()=>{t(o)}});return()=>{s()}},[o.tokenContractAddress,o.chainId,e])},Ht=po;var ho=()=>{Ut(),Ht()},Kt=ho;n();i();var v=S(g()),Yt=S(Y());var So=({currency:o,currentWallet:e,walletInfo:t,keyringIdentityTypeEnum:r,addressBookList:s,walletList:a,t:u,dispatch:c,onBack:d})=>{let{commonStore:p,accountStore:h,reset:M}=f(),I=(0,Yt.useHistory)();(0,v.useEffect)(()=>{G.setRuntimeContext({history:I,toLocale:u,dispatch:c,walletInfo:t,onBack:d})},[u,I,c,t,d]),(0,v.useEffect)(()=>{e&&h.setWalletConfig(e)},[e]),(0,v.useEffect)(()=>(p.getUserUnit(o),()=>{M()}),[]),(0,v.useEffect)(()=>{h.setAddressBookList(s)},[s]),(0,v.useEffect)(()=>{h.setWalletList(a)},[a]),(0,v.useEffect)(()=>{h.setKeyringIdentityTypeEnum(r)},[r])},Xt=So;n();i();var T=S(g()),q=S(Y());n();i();var x=S(g()),ie=S(Y()),$t=S(so());n();i();var Ie=S(g());var go=()=>Ie.default.createElement("div",{className:"mt-50"},Ie.default.createElement(Pe,{pastDelay:!1,error:!0,delayTime:1e4,alt:"dexGenericError",retry:()=>{Ce(De().pathname,"_self")}})),Jt=go;n();i();var ne=S(g());var To=()=>{let{commonStore:o,configStore:e}=f(),{currentMode:t}=e,{fromToken:r}=bt(),{chainId:s,isNativeToken:a,tokenContractAddress:u}=r,{visibleAddFunds:c,setAddFundsVisible:d}=o,p=ze(),h=(0,ne.useMemo)(()=>p?!0:t==="sell",[p,t]);return ne.default.createElement(pt,{visible:c,params:{chainId:s,tokenContractAddress:a?"":u,receiveOnly:h},onBack:()=>{d(!1)}})},jt=C(To);var ko=[V,X],Mo=({children:o,onBack:e})=>{let{commonStore:t,configStore:r,buyStore:s,sellStore:a}=f(),{showNavigator:u,title:c,closeable:d}=gt({configStore:r,buyStore:s,sellStore:a}),p=(0,ie.useLocation)(),h=(0,ie.useHistory)(),{isTelegramMiniApp:M}=G.global,{Navigator:I}=G.components,{setAddFundsVisible:P}=t;(0,x.useEffect)(()=>{P(!1)},[]),Tt(),mt(at.setServiceState);let D=()=>{e?e(h.goBack,ko.includes(p.pathname)):h.goBack()};return x.default.createElement(ft,{fallbackComponent:Jt},x.default.createElement("div",{className:(0,$t.default)("universe-swap background-base-primary",z.wrapper)},u?x.default.createElement(I,{title:c,onBack:D,closeable:d}):null,x.default.createElement("div",{id:"meme-swap-container",className:M?z.memeTelegramContainer:z.extensionContainer},o)),x.default.createElement(jt,null))},zt=C(Mo);var Zt=(0,T.lazy)(()=>import("./Buy-RJUCCFIK.js")),Io=(0,T.lazy)(()=>import("./Sell-XKSNQXBT.js")),Eo=(0,T.lazy)(()=>import("./Configure-G6QUNPQU.js")),Lo=(0,T.lazy)(()=>import("./TokenList-AYSVNVRR.js")),Po=(0,T.lazy)(()=>import("./HighRisk-DAYZ6J4Y.js")),Ao=(0,T.lazy)(()=>import("./Presets-FM3V56TK.js")),yo=(0,T.lazy)(()=>import("./PresetEdit-DYUM5Y5F.js")),bo=({onBack:o})=>T.default.createElement(zt,{onBack:o},T.default.createElement(T.Suspense,null,T.default.createElement(q.Switch,null,[{path:V,component:Zt,exact:!0},{path:X,component:Io,exact:!0},{path:we,component:Eo,exact:!0},{path:Re,component:Lo,exact:!0},{path:_e,component:Po,exact:!0},{path:ve,component:Ao,extract:!0},{path:Be,component:yo,extract:!0}].map(t=>T.default.createElement(q.Route,{key:t.path,path:t.path,component:t.component,exact:t.exact})),T.default.createElement(q.Redirect,{from:V,to:{pathname:Zt,search:new xe().getAll()},strict:!0,exact:!0})))),eo=bo;var Do=({currency:o,currentWallet:e,keyringIdentityTypeEnum:t,addressBookList:r,walletList:s,walletInfo:a,onBack:u,t:c,dispatch:d})=>{Xt({currency:o,currentWallet:e,walletInfo:a,keyringIdentityTypeEnum:t,addressBookList:r,walletList:s,t:c,dispatch:d,onBack:u}),Bt(),_t(),Kt();let{accountStore:{address:p,setFromChainId:h},configStore:{fetchConfig:M,computedConfig:I,setCurrentMode:P}}=f();(0,b.useEffect)(()=>{k.setTags({address:p})},[p]),(0,b.useEffect)(()=>{M()},[]);let D=(0,to.useLocation)();(0,b.useEffect)(()=>{if(D){let{isBuyMode:B,isSellMode:K}=It(D);B?P("buy"):K&&P("sell")}},[D,P]),(0,b.useEffect)(()=>{I&&h(I?.nativeTokenInfo?.chainId)},[I]),Lt(),Ct();let{initialized:ge}=ut();return ge?b.default.createElement(eo,{onBack:u}):null},oo=(0,b.memo)(C(Do));n();i();n();i();w();var ae=class{constructor(){this.loading=!0;this.setLoading=e=>{this.loading=e};this.fromToken=null;this.setFromToken=e=>{this.fromToken=e};this.toToken=null;this.setToToken=e=>{this.toToken=e};this.onSocketUpdateToToken=e=>{U(e,this.toToken)&&this.setToToken({...this.toToken,...e})};this.onSocketUpdateFromTokenBalance=e=>{U(e,this.fromToken)&&this.setFromToken({...this.fromToken,amountNum:e.amountNum})};this.buyValue={value:"0",index:0,type:"select"};this.setBuyValue=e=>{this.buyValue=e};this.buyPresetList=[];this.setBuyPresetList=e=>{this.buyPresetList=e};this.currentBuyPresetId="";this.setCurrentBuyPresetId=e=>{this.currentBuyPresetId=e};this.buyPresetPageEditState=!1;this.setBuyPresetPageEditState=e=>{this.buyPresetPageEditState=e};this.editBuyPreset={isEdit:!0,value:{}};this.setEditBuyPreset=e=>{this.editBuyPreset=e};this.memeBtnStatus=Z;this.setMemeBtnStatus=e=>{this.memeBtnStatus=e};A(this)}get computedBuyNumber(){return this.buyValue.type==="custom"?parseFloat(this.buyValue.value||"0"):this.currentBuyPreset?.amountList?.[this.buyValue.index]}get computedBuyTokenSymbol(){return m(this,"toToken.tokenSymbol")}get computedBuyNumberIsValid(){return new y.BigNumber(this.computedBuyNumber).gt(0)}get currentBuyPreset(){return this.buyPresetList.find(e=>e.id===this.currentBuyPresetId)||{}}};n();i();var me=class{constructor(){this.initState=!1;this.setInitState=e=>{this.initState=e};this.positionList=[];this.setPositionList=e=>{this.positionList=e};this.fetchPositionLoading=!0;this.setFetchPositionLoading=e=>{this.fetchPositionLoading=e};this.cancelFetchRef=null;this.fetchPositionList=async({accountId:e,userUniqueId:t,chainId:r})=>{if(!e||!t||!r)return;this.cancelFetchRef&&this.cancelFetchRef.abort(),this.setFetchPositionLoading(!0),this.cancelFetchRef=F();let[s,a]=await E(L.get(We,{params:{accountId:e,userUniqueId:t,chainId:r},signal:this.cancelFetchRef?.signal}));s&&k.stuff(s),a&&a.data&&this.setPositionList(a?.data),this.setFetchPositionLoading(!1),this.setInitState(!0)};A(this)}isCancel(e){return O(e)}};n();i();w();var ue=class{constructor(){this.loading=!0;this.setLoading=e=>{this.loading=e};this.fromToken=null;this.setFromToken=e=>{this.fromToken=e};this.onSocketUpdateFromToken=e=>{U(e,this.fromToken)&&this.setFromToken({...this.fromToken,...e})};this.onSocketUpdateFromTokenBalance=e=>{U(e,this.fromToken)&&this.setFromToken({...this.fromToken,amountNum:e.amountNum})};this.toToken=null;this.setToToken=e=>{this.toToken=e};this.sellValue={value:"",type:"custom",index:0};this.setSellValue=e=>{this.sellValue=e};this.isPercentMode=!0;this.setIsPercentMode=e=>{this.isPercentMode=e};this.sellPresetList=[];this.setSellPresetList=e=>{this.sellPresetList=e};this.currentSellPresetId="";this.setCurrentSellPresetId=e=>{this.currentSellPresetId=e};this.sellPresetPageEditState=!1;this.setSellPresetPageEditState=e=>{this.sellPresetPageEditState=e};this.editSellPreset={isEdit:!0,value:{}};this.setEditSellPreset=e=>{this.editSellPreset=e};this.memeBtnStatus=Z;this.setMemeBtnStatus=e=>{this.memeBtnStatus=e};A(this)}get computedSellNumber(){try{let e=Math.min(this.fromToken?.decimals||0,12);if(this.sellValue.type==="custom"&&!this.isPercentMode)return parseFloat(this.sellValue.value||"0");let t=this.fromToken?.amountNum||"0";if(this.sellValue.type==="custom"&&this.isPercentMode)return y.floorMul(y.div(this.sellValue.value||"0",100),t,e);let r=this.currentSellPreset?.amountList?.[this.sellValue.index];return y.floorMul(r,t,e)}catch(e){return k.stuff(e),"0"}}get computedSellTokenSymbol(){return m(this,"fromToken.tokenSymbol")}get computedSellTokenBalanceLessAmount(){return m(this,"fromToken.computedSellNumber")>m(this,"fromToken.amountNum")}get computedSellNumberIsValid(){return new y.BigNumber(this.computedSellNumber).gt(0)}get currentSellPreset(){return this.sellPresetList.find(e=>e.id===this.currentSellPresetId)||{}}};n();i();var ce=class{constructor(){this.searchValue="";this.setSearchValue=e=>{this.searchValue=e};this.defaultSearchLoading=!0;this.setDefaultSearchLoading=e=>{this.defaultSearchLoading=e};this.searchLoading=!1;this.setSearchLoading=e=>{this.searchLoading=e};this.commonSearchState=!1;this.setCommonSearchState=e=>{this.commonSearchState=e};this.normalTokenList=[];this.unsupportedTokenList=[];this.fetchDefaultTokenList=async({chainId:e,computedAccountId:t,userUniqueId:r})=>{this.setDefaultSearchLoading(!0),this.setCommonSearchState(!1);let[s,a]=await E(L.get(He,{params:{chainId:e,accountId:t,userUniqueId:r}}));if(this.searchValue){this.setDefaultSearchLoading(!1);return}s&&(k.stuff(s),this.normalTokenList=[],this.unsupportedTokenList=[]),a&&a.data&&(this.normalTokenList=a?.data||[],this.unsupportedTokenList=[]),this.setDefaultSearchLoading(!1)};this.cancelSearchRef=null;this.fetchSearchTokenList=async({chainId:e,computedAccountId:t,userUniqueId:r})=>{if(!this.searchValue)return;this.cancelSearchRef&&this.cancelSearchRef.abort(),this.setSearchLoading(!0),this.setCommonSearchState(!0),this.cancelSearchRef=F();let[s,a]=await E(L.get(Ke,{params:{chainId:e,accountId:t,userUniqueId:r,inputContent:this.searchValue},signal:this.cancelSearchRef?.signal}));if(!this.searchValue){this.setSearchLoading(!1);return}s&&!this.isCancel(s)&&(k.stuff(s),this.normalTokenList=[],this.unsupportedTokenList=[]),a&&a.data&&(this.normalTokenList=a?.data?.memeList,a?.data?.memeUnsupportList?this.unsupportedTokenList=a?.data?.memeUnsupportList.map(u=>{let c=u;return c.unSupportedMeme=!0,c}):this.unsupportedTokenList=[]),this.setSearchLoading(!1)};this.highRiskToken=null;this.setHighRiskToken=e=>{this.highRiskToken=e};this.highRiskCallBack=()=>{};this.setHighRiskCallBack=e=>{this.highRiskCallBack=e};A(this)}isCancel(e){return O(e)}};n();i();w();n();i();var le=class{constructor(){this.currentMode="buy";this.setCurrentMode=e=>{this.currentMode=e};this.tradeScene=0;this.presetStorageKey=ee;this.currentChainID=qe.SOLANA_MAINNET;this.initLoading=!0;this.setInitLoading=e=>{this.initLoading=e};this.showUserGuide=!1;this.setShowUserGuide=e=>{this.showUserGuide=e};this.panelAmountGuideShow=!1;this.setPanelAmountGuideShow=e=>{this.panelAmountGuideShow=e};this.panelPresetGuideShow=!1;this.setPanelPresetGuideShow=e=>{this.panelPresetGuideShow=e}}get computedIsBuy(){return this.currentMode==="buy"}get computedIsSell(){return this.currentMode==="sell"}};var de=class extends le{constructor(){super();this.configList=[];this.setConfigList=t=>{this.configList=t};this.fetchConfig=async()=>{let[t,r]=await E(nt({sceneType:this.tradeScene}));if(t){k.error(Q.MEME_SWAP_PRE_EXECUTE_ERR,{error:t});return}r&&r.data&&(this.setConfigList(r.data),this.setInitLoading(!1))};j(this),this.tradeScene=0,this.presetStorageKey=ee}get computedConfig(){return this.configList.find(t=>Ee(t.chainId)===this.currentChainID&&t.sceneType===this.tradeScene)}get computedNativeTokenInfo(){return m(this.computedConfig,"nativeTokenInfo",{})}};n();i();w();n();i();w();var fe=class{constructor(){this.QUOTE_TIMEOUT=5e3;this.quoteLoading=!1;this.quoteData=fe.INIT_QUOTE_DATA;this.resetQuote=()=>{this.cleanQuoteTimer(),this.cacheParams=null,this.setQuoteData(fe.INIT_QUOTE_DATA)};this.isAutoQuote=!1;this.cancelRef=null;this.initLoading=!0;this.timerRef=null;this.cacheParams=null;this.startingPoll=async(e,t)=>{if(this.cacheParams=e,this.timerRef&&clearTimeout(this.timerRef),!this.isQuoteImmediate(this.cacheParams)){this.setIsInitLoading(!1),this.resetQuote();return}await this.fetchQuoteAction(this.cacheParams,t),clearTimeout(this.timerRef),this.timerRef=setTimeout(async()=>{this.setIsAutoQuote(!0),await this.startingPoll(this.cacheParams,t)},this.QUOTE_TIMEOUT)};this.fetchQuote=Le(this.startingPoll,Fe)}setQuoteLoading(e){this.quoteLoading=e}setQuoteData(e){this.quoteData=e}setIsAutoQuote(e){this.isAutoQuote=e}cleanQuoteTimer(){this.cancelRef&&(this.cancelRef.abort(),this.cancelRef=null),this.timerRef&&clearTimeout(this.timerRef)}setIsInitLoading(e){this.initLoading=e}quoteStart(){this.setQuoteLoading(!0),this.cleanQuoteTimer()}quoteEnd(){this.setIsInitLoading(!1),this.setQuoteLoading(!1),this.setIsAutoQuote(!1)}getQuoteUrl(){return Xe}async fetchQuoteAction(e,t){this.quoteStart(),this.cancelRef=F();let[r,s]=await E(L.get(this.getQuoteUrl(),{params:e,signal:this.cancelRef.signal}));if(!O(r)&&r){let a=r||{};this.setQuoteData(a)}else this.setQuoteData(s||{}),t?.(s);this.quoteEnd()}isQuoteImmediate(e){return!!e.chainId&&!!e.fromTokenAddress&&!!e.toTokenAddress&&new y.BigNumber(e.amount).gt(0)}get computedQuoteCompleted(){return this.quoteData.error_code}get computedQuoteSuccuss(){return this.quoteData.error_code==="0"}get computedQuoteIsError(){return this.computedQuoteCompleted&&this.computedQuoteCompleted!=="0"&&this.computedQuoteCompleted!==Ne}get computedQuoteErrorMsg(){return m(this.quoteData,"error_message","")}get computedCustomQuoteLoading(){return!this.isAutoQuote&&this.quoteLoading}get computedQuoteNetworkError(){return this.quoteData.status==="ERR_NETWORK"}get computedQuoteIsBuyHoneypot(){return this.computedQuoteCompleted&&m(this.quoteData,"error_code")===Ue}get computedQuoteIsSellHoneypot(){return this.computedQuoteCompleted&&m(this.quoteData,"data.commonDexInfo.code")===J}get computedQuoteIsBlackAddress(){return this.computedQuoteCompleted&&m(this.quoteData,"error_code")===Oe}},H=fe;H.INIT_QUOTE_DATA={data:null,detailMsg:"",error_code:"",error_message:"",msg:"",status:""};var pe=class extends H{constructor(){super(),j(this)}getQuoteUrl(){return Ye}get jitoIsSuccess(){return m(this.quoteData,"data.memeModeCommonDexInfo.enableJito",!1)}get computedPriorityFeeInfo(){let e=m(this.quoteData,"data.memeModeCommonDexInfo.nonMevPriorityFeeInfo")??{};return{mevPriorityFeeInfo:m(this.quoteData,"data.memeModeCommonDexInfo.mevList[0]")??{},nonMevPriorityFeeInfo:e}}get computedFromTokenValue(){return m(this.quoteData,"data.memeModeCommonDexInfo.fromTokenPrice","0")}get computedToTokenAmount(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.receiveAmount","0")}get computedToTokenValue(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.toTokenPrice","0")}get quoteNetWorkFeeOfMoney(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.quoteNetWorkFeeOfMoney","")}get computedQuoteLiquidityError(){return this.computedQuoteCompleted&&!m(this.quoteData,"data.memeModeSingleChainSwapInfo")}get computedSwapOnOtherDapp(){let e=String(m(this.quoteData,"data.memeModeCommonDexInfo.isSupportDappTrade"))==="1";return this.computedQuoteCompleted&&e}get computedQuoteSafemoon(){if(this.computedQuoteCompleted){let e=m(this.quoteData,"data.memeModeCommonDexInfo.fromToken",{}),t=m(this.quoteData,"data.memeModeCommonDexInfo.toToken",{});if(Number(e?.isSafeMoonToken)===1)return e?.tokenSymbol;if(Number(t?.isSafeMoonToken)===1)return t?.tokenSymbol}return""}get computedGetRouterList(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.dexRouterList")}get computedGetEstimateGasFee(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.estimateGasFee")}get computedGetQuoteFrom(){return m(this.quoteData,"data.memeModeCommonDexInfo.fromToken",{})||{}}get computedGetQuoteTo(){return m(this.quoteData,"data.memeModeCommonDexInfo.toToken",{})||{}}get computedGetQuoteFromAmount(){return m(this.quoteData,"data.memeModeCommonDexInfo.fromTokenAmount")}get computedGetQuoteFromPrice(){return m(this.quoteData,"data.memeModeCommonDexInfo.fromTokenPrice")}get computedGetQuoteFromSinglePrice(){return ke.div(this.computedGetQuoteFromPrice,this.computedGetQuoteFromAmount).toString()}get computedGetQuoteToAmount(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.receiveAmount")}get computedGetQuoteToPrice(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.toTokenPrice")}get computedGetQuoteToSinglePrice(){return ke.div(this.computedGetQuoteToPrice,this.computedGetQuoteToAmount).toString()}get computedQuoteTraceData(){return m(this.quoteData,"data.traceData")}get computedGetQuoteTokenTax(){return m(this.quoteData,"data.memeModeCommonDexInfo.tokenTax","")}get computedQuoteIsInvalid(){return this.computedQuoteIsError||this.computedQuoteNetworkError||this.computedQuoteLiquidityError}get computedServiceFeeInfo(){return m(this.quoteData,"data.memeModeCommonDexInfo.serviceFeeInfo",{})}get computedAutoSlippage(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.autoSlippageInfo.referenceSlippage","")||m(this.quoteData,"data.memeModeSingleChainSwapInfo.autoSlippageInfo.autoSlippage","")}get mevUnstableShowLevel(){return m(this.quoteData,"data.memeModeCommonDexInfo.mevUnstableShowLevel",-1)}get solPrice(){return m(this.quoteData,"data.memeModeCommonDexInfo.nativeTokenPrice",0)}get quoteDiffValThreshold(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.quoteDiffValThreshold")}get quoteDiffPercentThreshold(){return m(this.quoteData,"data.memeModeSingleChainSwapInfo.quoteDiffPercentThreshold")}get computedValueDifference(){return tt({pay:this.computedFromTokenValue,receive:this.computedToTokenValue,quoteDiffValThreshold:this.quoteDiffValThreshold,quoteDiffPercentThreshold:this.quoteDiffPercentThreshold})}get computedQuoteIsSellHoneypot(){return this.computedQuoteCompleted&&m(this.quoteData,"data.memeModeCommonDexInfo.code")===J}};n();i();w();var he=class{constructor(){this.isSwapLoading=!1;A(this,{},{autoBind:!0})}setIsSwapLoading(e){this.isSwapLoading=e}getSolanaUnsignedTx(e){let t=m(e,"calldataParams.enableJito"),r=e?.unsignedTx||"{}";try{return t?JSON.parse(r).array:[JSON.parse(r)]}catch(s){throw new Error(s)}}getJitoTxData(e){let t=new st,r=this.getSolanaUnsignedTx(e);return Promise.all(r.map(t.txData))}async onSolanaSwap({data:e,signedTransactions:t,txArray:r}){try{let s=m(e,"calldataParams.enableJito"),a=await rt({walletId:e.walletId,swapParams:e.calldataParams,signedTransactions:t,txArray:r,enableJito:s,isMemeMode:!0});if(k.info(Q.MEME_SWAP_BROADCAST_PARAMS,{data:{...e,solanaBroadcastParams:a,unsignedTxArray:r,signedTransactions:t}}),!Qe()){let d=a?.dexMultiMetaSaveOrderParam?.chainId;et({chain_id:d,chain_name:be.chainInfo?.[d]||"",tx_hash:a?.updateMultiOrderInfo?.transactionHash,trade_mode:ht.MEME,terminal:St.WEB})}let[u,c]=await E(it(a));if(u){this.broadcastError(u,{...e,solanaBroadcastParams:a,unsignedTxArray:r,signedTransactions:t,broadcastRes:c,tags:{userWalletAddress:e.userWalletAddress}});return}return k.info(Q.MEME_SWAP_BROADCAST_SUCCESS,{data:{...e,solanaBroadcastParams:a,unsignedTxArray:r,signedTransactions:t,broadcastRes:c}}),c}catch(s){throw this.broadcastError(s,{...e,unsignedTxArray:r,signedTransactions:t}),new Error(s?.error_message)}}broadcastError(e,t){Ae.error({title:e?.error_message||je("swaptrade_home_toast_broadcast_failed")}),k.error(Q.MEME_SWAP_BROADCAST_ERROR,{data:{error:e,...t}})}};var R=class{constructor(){this.reset=()=>{this.commonStore=new Ze(this),this.accountStore=new $e(this),this.sendTransactionStore=new ot,this.configStore=new de,this.buyStore=new ae,this.sellStore=new ue,this.memePositionStore=new me,this.quoteStore=new pe,this.memeTokenListStore=new ce,this.memeSwapStore=new he};this.reset()}static getInstance(){return R.instance||(R.instance=new R),R.instance}},ro=R;var xo=({localeData:o,...e})=>(kt(),Se.default.createElement(Je,{localeData:o,isDev:!0,noRemoteData:!0,customRender:t=>t},Se.default.createElement(Mt.Provider,{value:ro.getInstance()},Se.default.createElement(oo,{...e})))),pa=C(xo);export{pa as default};
|
|
|
|
window.inOKXExtension = true;
|
|
window.inMiniApp = false;
|
|
window.ASSETS_BUILD_TYPE = "publish";
|
|
|
|
//# sourceMappingURL=MemeMode-HZJAOYKG.js.map
|