1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4338],{35074:function(e,t,a){var n=a(67294),i=a(62934),o=a(8976),l=a(26447),s=a(44456),d=a(78970),r=a(15270),u=a(90269),p=a(57916),c=a(43179),f=a(68575),v=a(8970),m=a(67421),T=a(20193),g=a(86866),y=a(75472),_=a.n(y),I=a(70794),b=a(80032),k=a(33821),h=a(82914),x=a(47076),Z=a(256),S=a(56892),w=a(44304),E=a(75777),P=a(30381),D=a.n(P),B=a(22005),C=a(11163);t.Z=()=>{let{setAlert:e,digest:t,content:a}=(0,v.ZP)(e=>({setAlert:e.set,digest:e.digest,content:e.content})),{os:y,browser:P,resolution:L}=(0,f.Z)(e=>({os:e.os,resolution:e.resolution,browser:e.browser})),{currentWallet:N,currentAccount:R,isConnected:A,setShowWalletList:O}=(0,S.ZP)(),V=(0,C.useRouter)(),F=(0,v.ZP)(e=>e.gasSponsored),{signTransaction:U,executeTransaction:H}=(0,T.Z)(),{network:G,provider:K,providerKey:M}=(0,i.Z)(e=>({network:e.network,provider:e.provider,providerKey:e.providerKey})),{kioskOwnerCaps:W,noKioskTailsId:z}=(0,s.Z)(e=>({kioskOwnerCaps:e.kioskOwnerCaps,noKioskTailsId:e.noKioskTailsId})),{t:Y}=(0,m.$G)("popup"),{autoBidOperableTailLevel:X}=(0,f.Z)(e=>({autoBidOperableTailLevel:e.autoBidOperableTailLevel})),{data:q}=(0,h.M)(K,G,null==R?void 0:R.address),{data:Q}=(0,l._)(K,G,o.MI[G]),{data:J}=(0,b.F)(K,G,W,z),[$,j]=(0,n.useState)([]),[ee,et]=(0,n.useState)(!0),[ea,en]=(0,n.useState)({emptyDataBtnLabel:"",emptyDataBtnRoute:"",emptyDataDescription:""}),{data:ei}
1=(0,k.Z)(K,G,null==R?void 0:R.address),[eo,el]=(0,n.useState)(null),[es,ed]=(0,n.useState)(!1),er=e=>{let t=[];for(let o of e){let e;let l=null==Q?void 0:Q.find(e=>e.info.index===o.vault_index);if(!l)continue;let{info:s,info:{optionType:d,period:f}}=l,[v,m,T]=(0,u.Zn)(s),g=(0,I.Z)(10).pow((0,I.Z)(l.info.dTokenDecimal)),y=(0,I.Z)(10).pow((0,I.Z)(l.info.bTokenDecimal)),_=(0,I.Z)(10).pow((0,I.Z)(l.info.oTokenDecimal)),b=0;if(0!==o.target_rounds.length){let e=l.info.round;for(let t of o.target_rounds)!o.bid_rounds.includes(t)&&Number(t)>=Number(e)&&b++}else b=Number(o.max_times)-o.bid_rounds.length;let k=b,h=o.accumulated_cost?o.accumulated_cost:0;e=m===v?{netPnl:(0,I.Z)(o.accumulated_profit).minus((0,I.Z)(h)).div(g).toFixed(5),accumulatedCost:null,accumulatedProfit:null}:{netPnl:(0,I.Z)(o.accumulated_profit).minus((0,I.Z)(h)).div(g).toFixed(5),accumulatedCost:(0,I.Z)(h).div(y).toFixed(4),accumulatedProfit:(0,I.Z)(o.accumulated_profit).div(g).toFixed(4)};let x=o.gain_to_harvest?Number(o.gain_to_harvest)/10**Number(l.info.dTokenDecimal):0,Z=c.y.CONSECUTIVE_TIMES,S=o.remaining_balance?Number(o.remaining_balance)/Number(y):0;o.target_rounds.length>0&&(Z=c.y.SPECIFIC_TIMES),x>0&&ed(!0);let w="".concat(Number((0,I.Z)(l.config.warmupVaultConfig.initialPrice).minus((0,I.Z)(l.config.warmupVaultConfig.finalPrice)).multipliedBy(o.price_percentage).div(100).plus((0,I.Z)(l.config.warmupVaultConfig.finalPrice)).div((0,I.Z)(10).pow(l.info.bTokenDecimal)).dp(4,2))),E=Number((0,I.Z)(1).times(w).times((0,I.Z)(o.size).div(_)).times(1.1).dp(4,2)),P=E*k,D=!0,B="";S<E&&(D=!1,B="Inactive due to insufficient balance."),("active"!==o.status||Z===c.y.SPECIFIC_TIMES&&0===k)&&(D=!1),("finished"===o.status||Z===c.y.SPECIFIC_TIMES&&0===k)&&(B="Inactive due to no scheduled time."),"insufficient balance"===o.status&&(B="Inactive due to insufficient balance.");let C={...o,remainingTimes:k,remainingBalance:S.toFixed(5),netPnl:e,strategyType:Z,vaultInfo:l,isActive:D,inActiveDescription:B,gainToHarvest:x.toFixed(5),lowestDepositAmount:P};if(t.find(e=>e.index===o.vault_index))t.find(e=>e.index===o.vault_index).data.push(C);else{var a,n,i;let e=null!==(a=r.Im[T])&&void 0!==a?a:T;e=null!==(n=p.cO[o.vault_index])&&void 0!==n?n:e;let s=p.pH[Number(f)].charAt(0).toUpperCase()+p.pH[Number(f)].slice(1);t.push({index:o.vault_index,data:[C],vaultInfo:l,vaultTokenLabel:null!==(i=r.cB[e])&&void 0!==i?i:e,vaultPeriodLabel:s,vaultOptionTypeLabel:p.ei[d],lastRow:!1,dToken:v,bToken:m})}}return t},eu=async(t,n)=>{if(!G||!K||!(null==R?void 0:R.address))return;e(()=>({show:!0,type:v.eL.LOADING,title:Y(v.zJ.SIGNING_APPROVAL),content:"",campaignType:null,digest:""}));let i=new g.Y,o=await x.TypusConfig.default("mainnet"===G?"MAINNET":"TESTNET",null),l=[],s=[];if(F&&(o.sponsored=!0),t){let e=["0x".concat(t.vaultInfo.depositVault.depositToken),"0x".concat(t.vaultInfo.depositVault.bidToken)],a=t.vaultInfo.info.index;l=a;let r=t.strategy_index;s=t.id,(0,w.B)(E.ff.CLICK_HARVEST,{timestamp:D()().format(B.i),is_connected:A,wallet_provider:null==N?void 0:N.name,address:"sui:".concat(null==R?void 0:R.address),page_path:V.asPath,component:"auto_bid_zone",package:E.wL.DOV,vaultIndex:a,strategy_id:t.id}),i=n?(0,d.getTokenWithdrawProfitStrategyTx)(o,i,{typeArguments:e,typusTokenType:"0x".concat(t.vaultInfo.depositVault.depositToken),vaultIndex:a,signalIndex:"0",strategyIndex:r,user:R.address}):(0,d.getWithdrawProfitStrategyTx)(o,i,{typeArguments:e,vaultIndex:a,signalIndex:"0",strategyIndex:r,user:R.address})}else for(let e of $)for(let t of e.data)if(Number(t.gainToHarvest)>0){l.push(e.vaultInfo.info.index),s.push(t.id);let a=["0x".concat(t.vaultInfo.depositVault.depositToken),"0x".concat(t.vaultInfo.depositVault.bidToken)],n=t.vaultInfo.info.index,r=t.strategy_index;i=(0,Z.WQ)(t.vaultInfo.depositVault.depositToken.split("::")[2])?(0,d.getTokenWithdrawProfitStrategyTx)(o,i,{typeArguments:a,typusTokenType:"0x".concat(t.vaultInfo.depositVault.depositToken),vaultIndex:n,signalIndex:"0",strategyIndex:r,user:R.address}):(0,d.getWithdrawProfitStrategyTx)(o,i,{typeArguments:a,vaultIndex:n,signalIndex:"0",strategyIndex:r,user:R.address})}(0,w.B)(E.ff.CLICK_HARVEST_ALL,{timestamp:D()().format(B.i),is_connected:A,wallet_provider:null==N?void 0:N.name,address:"sui:".concat(null==R?void 0:R.address),page_path:V.asPath,component:"auto_bi
1d_zone",package:E.wL.DOV,index:l,strategy_id:s});let r={timestamp:D()().format(B.i),wallet_provider:null==N?void 0:N.name,address:"sui:".concat(null==R?void 0:R.address),page_path:V.asPath,component:"auto_bid_zone",package:E.wL.DOV,status:T.c.STARTED,index:l,strategy_id:s,function:t?E.X9.HARVEST:E.X9.HARVEST_ALL};(0,w.B)(E.ff.SIGN,r);let u=await U(i);if(u)(0,w.B)(E.ff.SIGN,{...r,status:T.c.SIGNED});else{(0,w.B)(E.ff.SIGN,{...r,status:T.c.CANCELLED,fail_reason:a});return}let p=await H(u),c={timestamp:D()().format(B.i),wallet_provider:null==N?void 0:N.name,address:"sui:".concat(null==R?void 0:R.address),page_path:V.asPath,component:"auto_bid_zone",package:E.wL.DOV,transaction_hash:p.digest,index:l,strategy_id:s,function:t?E.X9.HARVEST:E.X9.HARVEST_ALL};if(p.isSuccess)(0,w.B)(E.ff.EXECUTE_SUCCESS,c);else{c={...c,system:y,browser:P,resolution:L,rpc:M,fail_reason:a},(0,w.B)(E.ff.EXECUTE_FAIL,c);return}},ep=e=>{let t=[];for(let i of e){var a,n;let[e,o,l]=(0,u.Zn)(i.vaultInfo.info),s=null!==(a=r.Im[l])&&void 0!==a?a:l,d=null!==(n=r.cB[s])&&void 0!==n?n:s,c=i.data.some(e=>e.isActive)?0:1,f={...i,tokenOrder:p.p6[d.toUpperCase()],periodOrder:p.QK[Number(i.vaultInfo.info.period)],statusOrder:c,optionTypeOrder:p.Y4[i.vaultInfo.info.optionType],strategyIndexOrder:1};t.push(f)}return _()(t,["statusOrder","tokenOrder","periodOrder","optionTypeOrder","strategyIndexOrder"],["asc","asc","asc","asc"])},ec=async e=>{el(4);let t=ep(er(e));0!==t.length&&(t[t.length-1].lastRow=!0),j(t)};(0,n.useEffect)(()=>{Q&&q&&ei&&ei.length>0&&(X?q.allUserStakingTailsInfo.find(e=>Number(e.level)>=X)&&ec(ei):ec(ei))},[q,Q,ei]),(0,n.useEffect)(()=>{switch(eo){case 0:en({emptyDataBtnLabel:"BUY NOW",emptyDataBtnRoute:"https://www.tradeport.xyz/sui/collection/tails-by-typus",emptyDataDescription:"You don't have any Tails."});break;case 1:en({emptyDataBtnLabel:"STAKE NOW",emptyDataBtnRoute:"https://typus.finance/tails",emptyDataDescription:"Stake a Level ".concat(X," Tails to unlock this feature.")});break;case 2:en({emptyDataBtnLabel:"PLAY DICE\xb2",emptyDataBtnRoute:"mainnet"===G?"https://typus.finance/dicesquared/":"https://testnet.typus.finance/dicesquared/",emptyDataDescription:"Level up your Tails to level ".concat(X," to unlock this feature.")});break;case 3:en({emptyDataBtnLabel:"CREATE STRATEGY",emptyDataBtnRoute:"mainnet"===G?"https://typus.finance/dicesquared/":"https://testnet.typus.finance/dicesquared/",emptyDataDescription:"You don't have any record."})}},[eo]);let ef=()=>{if(K&&(null==R?void 0:R.address)&&G&&J&&W&&z){if(X){if(q&&0===q.allUserStakingTailsInfo.length&&0===J.length&&el(0),q&&0===q.allUserStakingTailsInfo.length&&J.length>0&&el(1),q&&q.allUserStakingTailsInfo.length>0){let e=q.allUserStakingTailsInfo.find(e=>Number(e.level)>=X);e?0===$.length&&el(3):el(2),e&&$.length>0&&el(4)}}else 0===$.length?el(3):el(4);return!0}};return(0,n.useEffect)(()=>{(J&&q||!X)&&ef()&&et(!1),W&&z&&0===W.length&&0==z.length&&eo&&et(!1),X||(ei&&ei.length>0?el(4):el(3),et(!1))},[G,K,null==R?void 0:R.address,J,q,W,z,$]),{parsedRowData:$,isLoading:ee,strategyStatus:ea,strategyCase:eo,isHarvestAll:es,harvest:eu}}},82896:function(e,t,a){a.d(t,{I9:function(){return l},W5:function(){return o}});var n=a(70794),i=a(15270);let o=(e,t,a,n,i,o)=>e-(e-t)*Math.pow(1-(i-o)/(i-n),a),l=e=>"0"===e.optionType||"2"===e.optionType||"4"===e.optionType?e.dToken===e.bToken?(0,n.Z)(1).div(e.finalPrice).div((0,n.Z)(1).plus(e.bidFeeRateBp)):e.dToken!==e.bToken&&e.dToken===e.oToken?(0,n.Z)(e.oTokenPrice).div(e.bTokenPrice).div(e.finalPrice).div((0,n.Z)(1).plus(e.bidFeeRateBp)):(0,n.Z)(e.oTokenPrice).div(e.finalPrice).div((0,n.Z)(1).plus(e.bidFeeRateBp)):"1"===e.optionType||"3"===e.optionType||"5"===e.optionType?e.dToken===e.bToken?(0,n.Z)(e.oTokenPrice).div(e.finalPrice).div((0,n.Z)(1).plus(e.bidFeeRateBp)):(0,n.Z)(1).div(e.finalPrice).div((0,n.Z)(1).plus(e.bidFeeRateBp)):"6"===e.optionType?i.x7.includes(e.bToken)?(0,n.Z)(e.oTokenPrice).div(e.finalPrice).div((0,n.Z)(1).plus(e.bidFeeRateBp)):(0,n.Z)((0,n.Z)(1).div(e.finalPrice)).div((0,n.Z)(1).plus(e.bidFeeRateBp)):(0,n.Z)(1).div(e.finalPrice).div((0,n.Z)(1).plus(e.bidFeeRateBp))}}]);
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.