(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6245],{1346:function(e,t,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/puell-multiple",function(){return l(3536)}])},3536:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return PuellMultiple}});var a=l(5893),i=l(9008),n=l.n(i),r=l(7294),s=l(7626),o=l(5912),c=l(1526),d=l(6720),m=l(6488);l(4321),l(813);var h=l(6204),u=l(8688);function PuellMultiple(){let[e,t]=(0,r.useState)(!1),[l,i]=(0,r.useState)(!0),[o,g]=(0,r.useState)("isInfoVisible"),[x,p]=(0,r.useState)(!1),[f,w]=(0,r.useState)([]),[y,v]=(0,r.useState)("BTC"),[b,j]=(0,r.useState)([]),M=(0,u.eI)("https://swmkwzrguapkaodkgcmt.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN3bWt3enJndWFwa2FvZGtnY210Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTIxODI1NDMsImV4cCI6MjAyNzc1ODU0M30.At51g7QDyI7Pk-nx_-S5ShAcme7bjhSUqX8YsVvGB9A");(0,r.useEffect)(()=>{let e=window.location.pathname,t="isInfoVisible_".concat(e);g(t);let l=localStorage.getItem(t);null!==l&&i("false"!==l)},[]);let toggleInfo=()=>{let e=!l;localStorage.setItem(o,e.toString()),i(e)};(0,r.useEffect)(()=>{(0,m.ZP)(":not(.sidebar-tooltip)[data-tippy-content]",{placement:"bottom",theme:"customTheme"})},[]);let T=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=new Image;e.src="/assets/images/mainLogoLetters.png",e.onload=()=>{T.current=e,drawChart(f)}},[]);let D=(0,r.useRef)(null),formatAxisLabel=e=>e>=1?e.toFixed(0):e>=.01?e.toFixed(2):e.toFixed(6),formatPrice=e=>e<1e3?e.toFixed(2):e.toFixed(0),fetchBatchedDataInParallel=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2500,l=new Date("2010-10-15"),a=Array.from({length:3},(a,i)=>{let n=i*t,r=n+t-1;return M.from(e).select("date, height").range(n,r).then(e=>{let{data:t,error:a}=e;return a?(console.error("Error fetching batch ".concat(i,": ").concat(a.message)),[]):t.filter(e=>{let{date:t}=e;return new Date(t)>=l})})});return(await Promise.all(a)).flat()},getBlockReward=e=>{let t=new Date(e);return t<new Date("2012-11-28")?50:t<new Date("2016-07-09")?25:t<new Date("2020-05-11")?12.5:t<new Date("2024-04-19")?6.25:3.125};(0,r.useEffect)(()=>{let calculatePuellMultiple=async()=>{t(!0);try{let[e,t]=await Promise.all([M.from("daily_candles").select("candles").eq("token","BTCUSDT").single(),fetchBatchedDataInParallel("block_height",2500)]),{data:l,error:a}=e;if(a)throw Error("Error fetching BTC data: ".concat(a.message));let i=new Date("2010-10-15"),n=l.candles.map(e=>{let{timestamp:t,close:l}=e;return{date:new Date(t).toISOString().split("T")[0],close:parseFloat(l)}}).filter(e=>new Date(e.date)>=i);w(n);let r=t.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()).filter(e=>new Date(e.date)>=i),s=r.map(e=>{let t=n.find(t=>t.date===e.date);return{date:e.date,height:e.height,close:t?t.close:null}}).filter(e=>null!==e.close),o=s.map(e=>{let{date:t,height:l,close:a}=e,i=getBlockReward(t);return{date:t,dailyIssuance:l*i*a}}),c=o.map((e,t,l)=>{if(t<365)return null;let a=l.slice(t-365,t).reduce((e,t)=>e+t.dailyIssuance,0)/365;return{date:e.date,puellMultiple:e.dailyIssuance/a}}).filter(Boolean);j(c)}catch(e){console.error("Failed to calculate Puell Multiple: ".concat(e.message))}finally{t(!1)}};calculatePuellMultiple()},[]),(0,r.useEffect)(()=>{let handleResize=()=>{drawChart(f)};return window.addEventListener("resize",handleResize),()=>{window.removeEventListener("resize",handleResize)}},[f]),(0,r.useEffect)(()=>{D.current&&f.length>0&&b.length>0&&drawChart(f)},[f,b]);let generateDailyDates=(e,t)=>{let l=[],a=new Date(e),i=new Date(t);for(;a<=i;)l.push(new Date(a).toISOString().split("T")[0]),a.setDate(a.getDate()+1);return l},drawChart=e=>{let t=D.current;if(!t)return;let l=t.getContext("2d");if(!l)return;let a=document.createElement("canvas"),i=a.getContext("2d"),n=t.parentElement,r=n.clientWidth,s=n.clientHeight;t.width=2*r,t.height=2*s,t.style.width="".concat(r,"px"),t.style.height="".concat(s,"px"),l.scale(2,2),a.width=2*r,a.height=2*s,i.scale(2,2);let o=40,c=50;r<=1024?(o=40,c=35):(o=50,c=50);let d=Math.max(...e.map(e=>e.close)),m=Math.min(...e.map(e=>e.close)),h=Math.min(...b.map(e=>e.puellMultiple)),u=Math.max(...b.map(e=>e.puellMultiple));m=Math.max(m,1e-4);let g=Math.max(d,u),x=Math.max(m,1e-4),p=(s-0-10-40)/(Math.log10(g)-Math.log10(x)),w=(s-0-10-40)/(u-h);if(0===e.length)return;let v=f.map(e=>e.date);i.clearRect(0,0,a.width,a.height);let drawAxes=(e,t)=>{let l=(Math.log10(g)-Math.log10(x))/5;e.fillStyle="lightgrey",e.textAlign="right",e.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",e.textBaseline="middle";for(let t=0;t<=5;t++){let a=Math.pow(10,Math.log10(x)+t*l),i=s-10-20-(Math.log10(a)-Math.log10(x))*p;e.fillText("".concat(formatAxisLabel(a)),o-10,i),e.strokeStyle="rgba(255, 255, 255, 0.7)",e.lineWidth=.1,e.beginPath(),e.moveTo(o,i),e.lineTo(r-c,i),e.stroke()}let a=(u-h)/5;e.textAlign="left";for(let t=0;t<=5;t++){let l=h+t*a,i=s-10-20-(l-h)*w;e.fillText(l.toFixed(2),r-c+10,i)}e.fillStyle="lightgrey",e.textAlign="center",e.textBaseline="middle",e.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",window.innerWidth;let i=new Date(t[0].date),n=new Date(t[t.length-1].date),d=generateDailyDates(i,n);e.fillText(new Date(i).getFullYear(),o,s-10);for(let t=new Date(i);t<n;t.setFullYear(t.getFullYear()+2)){let l=new Date(t).toISOString().split("T")[0],a=o+d.indexOf(l)*(r-o-c)/(d.length-1);a>o&&a<r-c&&e.fillText(new Date(t).getFullYear(),a,s-10)}};(t=>{t.clearRect(0,0,r,s),t.fillStyle="#171a1e",t.fillRect(0,0,r,s),(()=>{let e=s-10-20-(3.5-h)*w;t.fillStyle="#dc26264D",t.fillRect(o,0,r-o-c,e-0),t.strokeStyle="red",t.lineWidth=.5,t.beginPath(),t.moveTo(o,0),t.lineTo(r-c,0),t.stroke(),t.beginPath(),t.moveTo(o,e),t.lineTo(r-c,e),t.stroke();let l=s-10-20-(.3-h)*w,a=s-10-20-(.6-h)*w;t.fillStyle="#16a34a4D",t.fillRect(o,l,r-o-c,a-l),t.strokeStyle="green",t.lineWidth=1,t.beginPath(),t.moveTo(o,l),t.lineTo(r-c,l),t.stroke(),t.beginPath(),t.moveTo(o,a),t.lineTo(r-c,a),t.stroke()})();let l=f.map(e=>{let t=e.date,l=b.find(e=>e.date===t);return{date:t,close:e.close,zScore:l?l.puellMultiple:null}}),drawLine=function(e,t,a,i){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];e.strokeStyle=a,e.lineWidth=i,e.beginPath();let d=!0;l.forEach((l,a)=>{let i=l[t];if(null===i)return;let m=o+a*(r-o-c)/(v.length-1);if(m>=o&&m<=r-c){let t=s-10-20-(n?(i-h)*w:(Math.log10(i)-Math.log10(x))*p);d?(e.moveTo(m,t),d=!1):e.lineTo(m,t)}}),e.stroke()};drawLine(t,"zScore","#cbd5e1",1,!0),drawLine(t,"close","orange",1),drawAxes(t,e)})(i),T.current&&(i.globalAlpha=.5,i.drawImage(T.current,50,10,101.4,30.2),i.globalAlpha=1),l.drawImage(a,0,0,r,s);let j=document.getElementById("cumulative-tooltip"),handleMouseMove=e=>{let i=t.getBoundingClientRect(),n=e.clientX-i.left,d=e.clientY-i.top,m=n<o,p=n>r-c,w=d>s-20;if(m||p||w){j.style.display="none",l.clearRect(0,0,r,s),l.drawImage(a,0,0,r,s);return}if(n<o||n>r-c)return;let v=(n-o)*(f.length-1)/(r-o-c),M=Math.min(Math.max(0,Math.round(v)),f.length-1),T=f[M].date,D=f[M],k=(e=>{let t=b.find(t=>t.date===e);if(!t){let l=b.filter(t=>new Date(t.date)<=new Date(e));t=l.length>0?l[l.length-1]:null}return t})(T);j.style.display="block",j.style.left="".concat(n+10,"px"),j.style.top="".concat(d+10,"px"),n+50+j.offsetWidth>r?j.style.left="".concat(n-j.offsetWidth-60,"px"):j.style.left="".concat(n+30,"px"),d+10+j.offsetHeight>s?j.style.top="".concat(d-j.offsetHeight-10,"px"):j.style.top="".concat(d+10,"px");let I=D&&D.close?"$".concat(formatPrice(D.close)):"N/A",S=k&&void 0!==k.puellMultiple?parseFloat(k.puellMultiple).toFixed(2):"N/A";j.innerHTML="\n Date: ".concat(new Date(T).toLocaleDateString("en-GB",{timeZone:"UTC"}),'<br>\n <span style="display: flex; align-items: center;">\n <img src="https://lcw.nyc3.cdn.digitaloceanspaces.com/production/currencies/64/').concat(y.toLowerCase(),'.png" class="w-2" alt="Bitcoin logo" style="width: 16px; vertical-align: middle; margin-right: 4px;" /> \n ').concat(y," Price: ").concat(I,'\n </span>\n <div style="display: flex; justify-content: flex-start; align-items: center;">\n <div style="width: 10px; height: 10px; background-color: #ccd5e1; margin-right: 6px; margin-bottom: 3px;"></div>\n <div>Puell Multiple: ').concat(S,"</div>\n </div>\n "),l.clearRect(0,0,r,s),l.drawImage(a,0,0,r,s),l.strokeStyle="rgba(255, 255, 255, 0.5)",l.lineWidth=.7,l.setLineDash([5,5]),l.beginPath(),l.moveTo(n,0),l.lineTo(n,s),l.moveTo(0,d),l.lineTo(r,d),l.stroke(),l.setLineDash([]),l.fillStyle="rgba(63, 63, 70, 1)",l.fillRect(o-70,d-10,70,20),l.fillStyle="white",l.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",l.textAlign="right";let C=Math.log10(x),N=Math.log10(g),P=Math.pow(10,C+(s-d-20-10)/(s-0-10-40)*(N-C));l.fillText(formatPrice(P),o-3,d+2.5),l.fillStyle="rgba(63, 63, 70, 1)",l.fillRect(n-35,s-10-10,70,30),l.fillStyle="white",l.textAlign="center",l.fillText(new Date(T).toLocaleDateString("en-GB",{timeZone:"UTC"}),n,s-10+3);let E=h+(s-d-20-10)/(s-0-10-40)*(u-h);l.fillStyle="rgba(63, 63, 70, 1)",l.fillRect(r-c+10,d-10,70,20),l.fillStyle="white",l.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",l.textAlign="left",l.fillText(E.toFixed(2),r-c+15,d+2.5)};return t.addEventListener("mousemove",handleMouseMove),t.addEventListener("mouseout",()=>{j.style.display="none",l.clearRect(0,0,r,s),l.drawImage(a,0,0,r,s)}),()=>{t.removeEventListener("mousemove",handleMouseMove)}},drawExtraContent=(e,t,l)=>{let a,i,n,r;let s=window.innerWidth;s>640?(a=28,i=14,n=75,r=35):(a=18,i=12,n=47,r=20),e.font="".concat(i,"px Oxanium"),e.fillStyle="#e4e4e7";let o="Created at TradingDigits.io",c=e.measureText(o).width;e.fillText(o,(t-c)/2,r),e.font="".concat(a,"px Oxanium");let d="".concat(l,", ").concat(new Date().toLocaleDateString()),m=e.measureText(d).width;e.fillText(d,(t-m)/2,n)},downloadChart=(e,t)=>{let l=e.current;l.getContext("2d");let a=document.createElement("canvas"),i=l.width+40,n=l.height+20+40+100;a.width=i,a.height=n;let r=a.getContext("2d");r.fillStyle="#171a1e",r.fillRect(0,0,a.width,a.height),drawExtraContent(r,a.width,t),r.drawImage(l,20,100);let s=document.createElement("a");s.download="".concat(t.replace(/\s+/g,"_").toLowerCase(),".png"),s.href=a.toDataURL("image/png"),s.click()},copyChartToClipboard=async(e,t)=>{let l=e.current;l.getContext("2d");let a=document.createElement("canvas"),i=l.width+40,n=l.height+20+40+100;a.width=i,a.height=n;let r=a.getContext("2d");r.fillStyle="#171a1e",r.fillRect(0,0,a.width,a.height),drawExtraContent(r,a.width,t),r.drawImage(l,20,100),a.toBlob(async e=>{try{let t=new ClipboardItem({"image/png":e});await navigator.clipboard.write([t]),p(!0),setTimeout(()=>p(!1),1e3)}catch(e){console.error("Failed to copy chart: ",e)}})};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(()=>(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(n(),{children:[(0,a.jsx)("title",{children:"The Puell Multiple Chart: Find Market Tops & Bottoms"}),(0,a.jsx)("meta",{name:"description",content:"Puell Multiple index analyzes daily Bitcoin issuance data to measure its market cycle and highlight periods when it is overbought or underbought"}),(0,a.jsx)("meta",{name:"keywords",content:"puell, multiple, the, bitcoin, btc, index, indicator, chart, crypto, metrics"}),(0,a.jsx)("meta",{property:"og:title",content:"The Puell Multiple Chart: Find Market Tops & Bottoms"}),(0,a.jsx)("meta",{property:"og:description",content:"Puell Multiple index analyzes daily Bitcoin issuance data to measure its market cycle and highlight periods when it is overbought or underbought"}),(0,a.jsx)("meta",{property:"og:image",content:"https://www.tradingdigits.io/assets/images/ogImage.jpg"}),(0,a.jsx)("meta",{property:"og:url",content:"https://www.tradingdigits.io/mvrv-z-score"}),(0,a.jsx)("meta",{name:"twitter:title",content:"The Puell Multiple Chart: Find Market Tops & Bottoms"}),(0,a.jsx)("meta",{name:"twitter:description",content:"Puell Multiple index analyzes daily Bitcoin issuance data to measure its market cycle and highlight periods when it is overbought or underbought"}),(0,a.jsx)("meta",{name:"twitter:image",content:"https://www.tradingdigits.io/assets/images/ogImage.jpg"}),(0,a.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,a.jsx)("meta",{name:"twitter:image:alt",content:"Promotional image with crypto-related illustration on black background, company name, and catchphrase about Trading Digits"}),(0,a.jsx)("meta",{name:"twitter:site",content:"@trading_digits"}),(0,a.jsx)("link",{rel:"canonical",href:"https://www.tradingdigits.io/mvrv-z-score"}),(0,a.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),(0,a.jsx)("link",{href:"https://fonts.googleapis.com/css2?family=Oxanium:wght@300;400;500;600;700&display=swap",rel:"stylesheet"})]})}),{}),(0,a.jsx)("div",{className:"md:mt-[95px] sm:mt-[90px] mt-[80px]",children:(0,a.jsxs)("div",{className:"pb-3 pt-2 sm:pt-1 ".concat(e?"h-screen":"h-full"," 2.5xl:h-full 3xl:h-screen min-[1540px]:pb-[100px]"),children:[(0,a.jsxs)("div",{className:"flex items-center ".concat(l?"lg:justify-start":"lg:justify-center pb-4"," justify-center my-1.75 text-center"),children:[(0,a.jsx)("h1",{className:"pl-2 sm:text-2xl text-xl font-[Oxanium-Regular]",children:"PUELL MULTIPLE INDICATOR"}),(0,a.jsx)(c.M,{children:!l&&(0,a.jsx)(d.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"ml-3",children:(0,a.jsx)("i",{onClick:toggleInfo,className:"fa-solid fa-circle-info fa-lg text-zinc-200 cursor-pointer hover:text-amber-400 transition duration-300"})})})]}),(0,a.jsx)(c.M,{children:l&&(0,a.jsxs)(d.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"relative px-2 py-2 flex items-center mr-0 mb-8 bg-[#363738] justify-center w-full",children:[(0,a.jsx)("i",{className:"fa-solid fa-circle-info fa-2xl mr-3 text-zinc-200"}),(0,a.jsx)("div",{className:"font-[Oxanium-Regular] sm:text-sm text-xs pr-4",children:(0,a.jsx)("p",{children:"The Puell Multiple index measures Bitcoin's market cycle by highlighting times when Bitcoin may be overbought or underbought based on miner revenue data, taking the daily issuance in USD and dividing it by its 365-day moving average. High values may signal market tops, as revenue greatly exceeds the yearly average, and low values suggest revenue is below the average, potentially marking undervalued periods."})}),(0,a.jsx)("div",{onClick:toggleInfo,className:"absolute top-0 right-0 flex items-start hover:bg-zinc-500 cursor-pointer py-0.5 px-1 transition duration-300",children:(0,a.jsx)("i",{className:"fa-solid fa-xmark"})})]})}),e?(0,a.jsx)("div",{className:"flex w-full items-center justify-center mt-32",children:(0,a.jsx)("img",{src:s.Y.logoLoading,className:"quick-pulse w-48 ",alt:"Loading..."})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"w-full flex items-center justify-between gap-3 text-center sm:text-sm text-xs bg-zinc-800 border-1 border-y border-zinc-700",children:[(0,a.jsxs)("div",{className:"flex gap-3 pl-16 sm:text-presm text-prexs font-[Oxanium-Light]",children:[(0,a.jsx)("div",{className:"flex flex-col justify-center items-center",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)("div",{className:"w-2.5 h-2.5 bg-[#f7a500] mr-1.5 mb-0.75"}),(0,a.jsxs)("div",{children:[y," Price"]})]})}),(0,a.jsx)("div",{className:"flex flex-col justify-center items-center",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)("div",{className:"w-2.5 h-2.5 bg-[#ccd5e1] mr-1.5 mb-0.75"}),(0,a.jsx)("div",{children:"Puell Multiple"})]})})]}),(0,a.jsxs)("div",{className:"flex pl-[3px] pr-[3px] border-l border-zinc-700",children:[(0,a.jsx)("button",{className:"px-2 py-2 hover:rounded-sm bg-zinc-800 hover:bg-zinc-700 transition duration-300 flex items-center justify-center ".concat(x?"animate-flip":""),onClick:()=>copyChartToClipboard(D,"Puell Multiple Index"),children:(0,a.jsx)(h.esY,{className:"text-zinc-300 text-base"})}),(0,a.jsx)("button",{className:"px-2 py-2 hover:rounded-sm bg-zinc-800 hover:bg-zinc-700 transition duration-300 flex items-center justify-center",onClick:()=>downloadChart(D,"Puell Multiple Index"),children:(0,a.jsx)(h.aBF,{className:"text-zinc-300 text-base"})})]})]}),(0,a.jsxs)("div",{className:"h-[500px] sm:w-full w-full relative flex flex-col mb-12 bg-[#171a1e] px-5 border-1 border-b border-zinc-700",children:[(0,a.jsx)("div",{className:"w-full flex max-[1080px]:flex-col flex-row justify-between max-[1080px]:items-center max-[1080px]:gap-3"}),(0,a.jsx)("div",{className:"h-full",children:(0,a.jsx)("canvas",{ref:D,className:""})}),(0,a.jsx)("div",{id:"cumulative-tooltip",style:{position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.7)",color:"white",padding:"5px",borderRadius:"5px",pointerEvents:"none",display:"none"}})]})]})]})})]})}PuellMultiple.layout=o.Z}},function(e){e.O(0,[8391,4738,4817,2510,4396,5372,8688,5912,9774,2888,179],function(){return e(e.s=1346)}),_N_E=e.O()}]);