@gearbox-protocol/ui-kit 4.0.0-next.31 → 4.0.0-next.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../apy-breakdown-body/apy-breakdown-body.cjs"),A=require("../../points-icon/points-icon.cjs"),T=require("../../token-icon/token-icon.cjs"),r=require("../../typed-intl/index.cjs"),m=require("../../../utils/apy-breakdown.cjs"),n=require("../../../utils/format-leverage.cjs"),o=require("./constants.cjs");function x({data:d,showFormula:p=!1,period:i}){const{leverage:s,collateralApy:l}=d,y=m.totalApyOf(d.netApy),B=y+d.borrowCost,v=l?m.positiveTokenRewardsOf(l):[],g=l?m.pointProgramsOf(l):[],u=v.map(a=>({reward:a,value:Math.round(s*(a.supplyApr??0))})),k=B-u.reduce((a,c)=>a+c.value,0),w=s>0?k/s:void 0;return e.jsxs(t.ApyBreakdownBody,{testId:o.StrategyApyBreakdownCardTest.root,title:e.jsx(r.FormattedMessageTyped,{messageId:t.periodMessageId(i,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:n.formatLeverage(s)}}),chip:t.formatBreakdownRate(y),chipPositive:y>0,chipTestId:o.StrategyApyBreakdownCardTest.net,children:[e.jsx(t.ApyBreakdownRow,{testId:o.StrategyApyBreakdownCardTest.collateral,valueTestId:o.StrategyApyBreakdownCardTest.value,captionTestId:o.StrategyApyBreakdownCardTest.caption,label:e.jsx(r.FormattedMessageTyped,{messageId:t.periodMessageId(i,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:t.formatBreakdownRate(k),subtext:p&&w!==void 0?e.jsx(r.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:n.formatLeverage(s),base:t.formatBreakdownRate(w)}}):void 0}),u.map(({reward:a,value:c})=>e.jsx(t.ApyBreakdownRow,{valueTestId:o.StrategyApyBreakdownCardTest.value,captionTestId:o.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(r.FormattedMessageTyped,{messageId:"components.apyParts.extraAPY",values:{symbol:a.token.symbol}})}),e.jsx(T.TokenIcon,{token:a.token,symbol:a.token.symbol,size:16,className:"shrink-0"})]}),value:t.formatBreakdownRate(c),subtext:p?e.jsx(r.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:n.formatLeverage(s),base:t.formatBreakdownRate(a.supplyApr??0)}}):void 0},`incentive-${a.token.address}-${a.supplyApr??0}`)),e.jsx(t.ApyBreakdownRow,{muted:!0,testId:o.StrategyApyBreakdownCardTest.borrow,valueTestId:o.StrategyApyBreakdownCardTest.value,label:e.jsx(r.FormattedMessageTyped,{messageId:t.periodMessageId(i,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:t.formatBreakdownRate(-d.borrowCost)}),g.length>0?e.jsxs(e.Fragment,{children:[e.jsx(t.ApyBreakdownDivider,{}),g.map(a=>e.jsx(t.ApyBreakdownRow,{valueTestId:o.StrategyApyBreakdownCardTest.points,captionTestId:o.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(r.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:a.name}})}),e.jsx(A.PointsIcon,{reward:{name:a.name,type:a.id},size:16,className:"shrink-0"})]}),value:a.multiplier!=null?`${n.formatLeverage(a.multiplier*s)}×`:t.BREAKDOWN_DASH,subtext:p&&a.multiplier!=null?e.jsx(r.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:n.formatLeverage(s),base:n.formatLeverage(a.multiplier)}}):void 0},a.id))]}):null]})}exports.StrategyApyBreakdownCardTest=o.StrategyApyBreakdownCardTest;exports.StrategyApyBreakdownCard=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("@gearbox-protocol/sdk/onchain"),o=require("../apy-breakdown-body/apy-breakdown-body.cjs"),j=require("../../points-icon/points-icon.cjs"),C=require("../../token-icon/token-icon.cjs"),d=require("../../typed-intl/index.cjs"),A=require("../../../utils/apy-breakdown.cjs"),l=require("../../../utils/format-leverage.cjs"),r=require("./constants.cjs");function R(i){const{borrowApyAvg7D:a,quotaRateAvg7D:p,liquidationThreshold:y}=i;return a===void 0||p===void 0?null:{borrowApy:a,quotaRate:p,liquidationThreshold:y}}function S({data:i,leverage:a,showFormula:p=!1,period:y}){const s=R(i),n=s&&i.collateralApyAvg7D?i.collateralApyAvg7D:void 0,c=s!==null&&n!==void 0,x=c&&s&&n?{organicApy:w.calcNetStrategyApy(s,n.organicApy,a),totalApy:w.calcNetStrategyApy(s,n.totalApy??n.organicApy,a),...n.rewards?{rewards:n.rewards}:{}}:{organicApy:0,totalApy:0},m=c&&s?w.calcEffectiveBorrowApy(s,a):0,u=A.totalApyOf(x),I=u+m,b=n?A.positiveTokenRewardsOf(n):[],k=n?A.pointProgramsOf(n):[],B=b.map(t=>({reward:t,value:Math.round(a*(t.supplyApr??0))})),v=I-B.reduce((t,g)=>t+g.value,0),T=a>0?v/a:void 0,f=c&&s&&a>0?(m-s.borrowApy*(a-1))/a:void 0;return e.jsxs(o.ApyBreakdownBody,{testId:r.StrategyApyBreakdownCardTest.root,title:e.jsx(d.FormattedMessageTyped,{messageId:o.periodMessageId(y,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:l.formatLeverage(a)}}),chip:o.formatBreakdownRate(u),chipPositive:u>0,chipTestId:r.StrategyApyBreakdownCardTest.net,children:[e.jsx(o.ApyBreakdownRow,{testId:r.StrategyApyBreakdownCardTest.collateral,valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsx(d.FormattedMessageTyped,{messageId:o.periodMessageId(y,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:o.formatBreakdownRate(v),subtext:p&&T!==void 0?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:l.formatLeverage(a),base:o.formatBreakdownRate(T)}}):void 0}),B.map(({reward:t,value:g})=>e.jsx(o.ApyBreakdownRow,{valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(d.FormattedMessageTyped,{messageId:"components.apyParts.extraAPY",values:{symbol:t.token.symbol}})}),e.jsx(C.TokenIcon,{token:t.token,symbol:t.token.symbol,size:16,className:"shrink-0"})]}),value:o.formatBreakdownRate(g),subtext:p?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:l.formatLeverage(a),base:o.formatBreakdownRate(t.supplyApr??0)}}):void 0},`incentive-${t.token.address}-${t.supplyApr??0}`)),e.jsx(o.ApyBreakdownRow,{muted:!0,testId:r.StrategyApyBreakdownCardTest.borrow,valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsx(d.FormattedMessageTyped,{messageId:o.periodMessageId(y,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:o.formatBreakdownRate(-m),subtext:p&&s&&f!==void 0?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.borrowFormula",values:{leverage:l.formatLeverage(a),borrowRate:o.formatBreakdownRate(s.borrowApy),quotaRate:o.formatBreakdownRate(f)}}):void 0}),k.length>0?e.jsxs(e.Fragment,{children:[e.jsx(o.ApyBreakdownDivider,{}),k.map(t=>e.jsx(o.ApyBreakdownRow,{valueTestId:r.StrategyApyBreakdownCardTest.points,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{children:e.jsx(d.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:t.name}})}),e.jsx(j.PointsIcon,{reward:{name:t.name,type:t.id},size:16,className:"shrink-0"})]}),value:t.multiplier!=null?`${l.formatLeverage(t.multiplier*a)}×`:o.BREAKDOWN_DASH,subtext:p&&t.multiplier!=null?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:l.formatLeverage(a),base:l.formatLeverage(t.multiplier)}}):void 0},t.id))]}):null]})}exports.StrategyApyBreakdownCardTest=r.StrategyApyBreakdownCardTest;exports.StrategyApyBreakdownCard=S;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),H=require("lightweight-charts"),p=require("react"),ct=require("../../hooks/use-media-query.cjs"),re=require("../../utils/cn.cjs"),G=require("../../utils/colors.cjs"),D=require("./default-config.cjs"),ne=require("./formatters.cjs"),ut=require("./graph-current-value.cjs"),ft=require("./graph-tooltip.cjs"),ht=require("./plugins/vertical-line.cjs"),He=require("./y-axis-scale.cjs");function gt(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const f=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,f.get?f:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const Te=gt(p);function oe(e){return e.id??e.label}function Ze(e,n,a){if(!a)return e.values().next().value;const f=e.get(a);if(f)return f;const u=n.find(b=>b.id===a||b.label===a);return u?e.get(oe(u)):void 0}class pt{_yTop;_yBottom;_color;constructor(n,a,f){this._yTop=n,this._yBottom=a,this._color=f}draw(n){n.useBitmapCoordinateSpace(a=>{const f=a.context,u=a.verticalPixelRatio,b=this._yTop===null?0:this._yTop*u,C=this._yBottom===null?a.bitmapSize.height:this._yBottom*u,P=Math.min(b,C),M=Math.max(b,C);f.fillStyle=this._color,f.fillRect(0,P,a.bitmapSize.width,M-P)})}}class dt{_source;_yTop=null;_yBottom=null;constructor(n){this._source=n}update(){const n=this._source.series;this._yTop=this._source.priceTop===void 0?null:n.priceToCoordinate(this._source.priceTop),this._yBottom=this._source.priceBottom===void 0?null:n.priceToCoordinate(this._source.priceBottom)}zOrder(){return"bottom"}renderer(){return new pt(this._yTop,this._yBottom,this._source.color)}}class mt{series;priceTop;priceBottom;color;_paneViews;constructor(n,a,f,u){this.series=n,this.priceTop=a,this.priceBottom=f,this.color=u,this._paneViews=[new dt(this)]}updateAllViews(){for(const n of this._paneViews)n.update()}paneViews(){return this._paneViews}}function bt(e,n){switch(e){case H.LineStyle.Dotted:return[n,n];case H.LineStyle.Dashed:return[2*n,2*n];case H.LineStyle.LargeDashed:return[6*n,6*n];case H.LineStyle.SparseDotted:return[n,4*n];default:return[]}}class St{_y;_color;_lineWidth;_lineStyle;constructor(n,a,f,u){this._y=n,this._color=a,this._lineWidth=f,this._lineStyle=u}draw(n){n.useBitmapCoordinateSpace(a=>{if(this._y===null)return;const f=a.context,u=a.verticalPixelRatio,b=Math.max(1,Math.round(this._lineWidth*u)),C=Math.round(this._y*u);f.save(),f.strokeStyle=this._color,f.lineWidth=b,f.setLineDash(bt(this._lineStyle,b)),f.beginPath(),f.moveTo(0,C),f.lineTo(a.bitmapSize.width,C),f.stroke(),f.restore()})}}class Ct{_source;_y=null;constructor(n){this._source=n}update(){this._y=this._source.series.priceToCoordinate(this._source.price)}zOrder(){return"top"}renderer(){return new St(this._y,this._source.color,this._source.lineWidth,this._source.lineStyle)}}class vt{series;price;color;lineWidth;lineStyle;_paneViews;constructor(n,a,f,u,b){this.series=n,this.price=a,this.color=f,this.lineWidth=u,this.lineStyle=b,this._paneViews=[new Ct(this)]}updateAllViews(){for(const n of this._paneViews)n.update()}paneViews(){return this._paneViews}}function Qe(e,n,a){const f=e.labelText??"",u=e.value,b=u===void 0?"":typeof u=="number"?n==="$"?`$${ne.formatExactValue(u,void 0,a)}`:n==="%"?`${ne.formatExactValue(u,void 0,a)}%`:ne.formatExactValue(u,n!=="none"&&n!=="%"&&n!=="$"&&!ne.isRatioUnit(n)?n:void 0,a):String(u);return{labelText:f,valueStr:b}}const Le=4;function Ye(e,n,a){const f={left:e,transform:"translateX(-50%)"};if(n<=0||!a||a<=0)return f;const u=a/2,b=Le+u,C=n-Le-u;return C<b?{left:n/2,transform:"translateX(-50%)"}:{left:Math.min(Math.max(e,b),C),transform:"translateX(-50%)"}}function Je(e,n){for(let a=e.length-1;a>=0;a--)if(Number(e[a].time)<=n)return e[a].value;return 0}const be=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#14b8a6",top:"rgba(20, 184, 166, 0.56)",bottom:"rgba(20, 184, 166, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#78716c",top:"rgba(120, 113, 108, 0.56)",bottom:"rgba(120, 113, 108, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],xt=137.5;function Ne(e){if(e<be.length)return be[e];const a=(e-be.length)*xt%360,f=G.hslToHex(a,70,50),{topColor:u,bottomColor:b}=G.generateColorsFromBase(f);return{line:f,top:u,bottom:b}}function _t({series:e,className:n,showLegend:a=!1,onUnselectSeries:f,xMeasureUnit:u="time",yMeasureUnit:b="token",optionsOverrides:C,verticalLineOptions:P,priceLineOptions:M,zoneOptions:X,currentValueDecimals:Se,useSharedPriceScale:Z=!1,dualYAxis:A=!1,defaultVisiblePriceScaleId:Ve="right",leftPriceScaleTitle:Ie,rightPriceScaleTitle:yt,showCurrentValue:et=!0,graphTitle:Ce,yScaleMin:Ee,yScaleMinMultiple:De,visibleTimeFrom:U,disableZoom:Me=!1,hideDefaultTooltip:ve=!1}){const B=p.useRef(null),V=p.useRef(new Map),xe=p.useRef(!1),ke=p.useRef(!0),Ae=p.useRef([]),ae=p.useRef(0),j=p.useRef(null),_e=p.useRef(null),Be=p.useRef(null),T=ct.useIsMobile(),le=Te.useMemo(()=>e.flatMap(t=>t.data),[e]),tt=Te.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[je,ye]=p.useState(()=>{if(!tt)return;const t=new Map;for(const l of e)l.data.length>0&&t.set(l.label,l.data[l.data.length-1]);return t}),[Fe,Y]=p.useState(null),[ze,Ge]=p.useState([]),[ot,Xe]=p.useState(0),qe=p.useRef(new Map),[rt,nt]=p.useState({}),[ee,it]=p.useState(0);p.useEffect(()=>{const t=()=>{try{if(j.current&&Xe(j.current.clientWidth),B.current&&j.current){const s=j.current.clientWidth,c=j.current.clientHeight;B.current.resize(s,c);try{ae.current=B.current.paneSize().height}catch{}}}catch{}},l=j.current,i=l?new ResizeObserver(t):null;return Be.current=i,l&&i?.observe(l),()=>{l&&i?.unobserve(l),i?.disconnect(),Be.current=null}},[]),p.useEffect(()=>{if(!_e.current||xe.current)return;const t=D.getDefaultOptions(),l=G.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)"),i=H.createChart(_e.current,{...t,leftPriceScale:{...t.leftPriceScale||{},visible:!1,textColor:l},rightPriceScale:{...t.rightPriceScale||{},visible:!T,textColor:l},...T&&{crosshair:{...t.crosshair,mode:H.CrosshairMode.Magnet}}});B.current=i,xe.current=!0;try{ae.current=i.paneSize().height}catch{ae.current=0}return it(s=>s+1),()=>{i.remove(),B.current=null,xe.current=!1,V.current.clear()}},[T]),p.useEffect(()=>{const t=B.current;t&&t.applyOptions(Me?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:!0,axisDoubleClickReset:!0},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}})},[ee,Me]),p.useEffect(()=>{const t=B.current;!t||!C||t.applyOptions(C)},[ee,C]),p.useEffect(()=>{const t=B.current;if(!t||e.length===0)return;const i=e.filter(r=>r.data.length>0).length<=1?Ee:De,s=u==="time"?ne.getXFormatters(u,le):ne.getXFormatters(u),c=new Map;{let r=0;for(const o of e)o.data.length!==0&&(c.set(o.label,o.priceScaleId??(r===0?"left":"right")),r++)}const h=(r,o,g)=>{const{formatter:F,tickmarksFormatter:N,updateVisibleRange:E}=ne.createAdaptiveYAxisFormatter(r,o,{yScaleMin:i});return{formatter:F,tickmarksFormatter:N,updateVisibleRange:E,labels:g}},d=[];if(A)for(const r of["left","right"]){const o=new Set,g=[];let F=b;for(const N of e)if(N.data.length!==0&&c.get(N.label)===r){o.size===0&&N.yMeasureUnit&&(F=N.yMeasureUnit),o.add(N.label);for(const E of N.data)g.push(E.value)}o.size>0&&d.push(h(g,F,o))}else{const r=le.map(g=>g.value),o=new Set(e.filter(g=>g.data.length>0).map(g=>g.label));d.push(h(r,b,o))}Ae.current=d;const y=new Map;for(const r of d)for(const o of r.labels)y.set(o,r);const w=D.getDefaultOptions();t.applyOptions({localization:{...w.localization||{},timeFormatter:r=>s.timeFormatter(parseFloat(r),void 0)},timeScale:{...w.timeScale||{},...C?.timeScale,tickMarkFormatter:s.tickMarkFormatter,minBarSpacing:0}});const v=!A&&e.length>1&&!Z,q=A?T:e.length>1&&!Z||T,I=G.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)");t.applyOptions({...A&&{defaultVisiblePriceScaleId:Ve},leftPriceScale:{...w.leftPriceScale||{},...C?.leftPriceScale,visible:A&&!T,textColor:I,...A&&Ie&&{}},rightPriceScale:{...w.rightPriceScale||{},...C?.rightPriceScale,visible:A?!T:!q,textColor:I}});const te=new Set(V.current.keys()),W=new Set(e.map(oe));for(const r of te)if(!W.has(r)){const o=V.current.get(r);o&&(t.removeSeries(o),V.current.delete(r))}const m=D.getDefaultSeries(),k=[];let L=0;const K=e.find(r=>r.data.length>0),_=new Map;if(M&&M.length>0)for(const r of M){if(!Number.isFinite(r.price))continue;const o=r.seriesLabel??K?.label;if(!o)continue;const g=_.get(o)??[];g.push(r.price),_.set(o,g)}if(X&&X.length>0)for(const r of X){const o=r.seriesLabel??K?.label;if(!o)continue;const g=_.get(o)??[];Number.isFinite(r.priceTop)&&g.push(r.priceTop),Number.isFinite(r.priceBottom)&&g.push(r.priceBottom),_.set(o,g)}for(let r=0;r<e.length;r++){const o=e[r],g=oe(o),F=Ne(r),N=o.lineColor??o.color??F.line;let E,J;if(o.lineColor??o.color)if(o.topColor&&o.bottomColor)E=o.topColor,J=o.bottomColor;else if(o.topColor){const S=G.generateColorsFromBase(N);E=o.topColor,J=S.bottomColor}else if(o.bottomColor)E=G.generateColorsFromBase(N).topColor,J=o.bottomColor;else{const S=G.generateColorsFromBase(N);E=S.topColor,J=S.bottomColor}else E=o.topColor||F.top,J=o.bottomColor||F.bottom;if(o.data.length===0){const S=V.current.get(g);S&&(t.removeSeries(S),V.current.delete(g));continue}const pe=o.data.length>0?Math.min(...o.data.map(S=>S.value)):0,ce=o.data.length>0?Math.max(...o.data.map(S=>S.value)):0,ue=pe<0,Q=o.data.some(S=>S.value===0),de=!ue&&Q,fe=He.pickMinMove(ce-pe),he=A?o.priceScaleId??(L===0?"left":"right"):Z||!v||L===0?"right":`scale-${L}`;v&&k.push({priceScaleId:he||"right",seriesIndex:L});const we=(Z||!v)&&i!==void 0&&typeof i=="number",st=_.get(o.label)??[],at=S=>{const R=S();if(R?.priceRange){we&&(R.priceRange.minValue=i);for(const O of st)O<R.priceRange.minValue&&(R.priceRange.minValue=O),O>R.priceRange.maxValue&&(R.priceRange.maxValue=O);const se=we?i:de&&R.priceRange.minValue>=0?0:void 0,me=ae.current>0?ae.current:j.current?.clientHeight??0;if(me>0){const O=He.niceAxisRange({min:R.priceRange.minValue,max:R.priceRange.maxValue,floor:se,scaleHeightPx:me,fontSizePx:D.AXIS_FONT_SIZE,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,minMove:fe,edgePaddingPx:D.AXIS_EDGE_LABEL_PADDING_PX,edgePaddingTopPx:D.AXIS_TOP_LABEL_PADDING_PX});R.priceRange.minValue=O.min,R.priceRange.maxValue=O.max}R.margins={above:D.AXIS_TOP_LABEL_PADDING_PX,below:D.AXIS_EDGE_LABEL_PADDING_PX}}return R},Ke=y.get(o.label)??d[0],$e=Ke.formatter,lt=Ke.tickmarksFormatter,Re={lineColor:N,topColor:E,bottomColor:J,priceScaleId:he,...o.seriesType==="line"&&{lineStyle:o.lineStyle??H.LineStyle.Solid},priceFormat:{type:"custom",minMove:fe,formatter:we&&typeof i=="number"?S=>$e(S<i?i:S):$e,tickmarksFormatter:lt},autoscaleInfoProvider:at},Oe=o.seriesType==="line";let z=V.current.get(g);const ie=o.data.map(S=>({...S,time:S.time}));if(U!==void 0&&ie.length>0&&Number(ie[0].time)>U){const S=Number(ie[0].time),R=S-U,se=86400,me=R>180*se?7*se:R>30*se?se:6*3600,O=[];for(let Pe=U;Pe<S;Pe+=me)O.push({time:Pe});ie.unshift(...O)}z&&z.seriesType()!==(Oe?"Line":"Area")&&(t.removeSeries(z),V.current.delete(g),z=void 0),z?(z.applyOptions(Re),z.setData(ie)):(Oe?z=t.addSeries(H.LineSeries,{...m,...Re}):z=t.addSeries(H.AreaSeries,{...m,...Re}),z.setData(ie),V.current.set(g,z)),L++}if(A)try{const r=t.priceScale("left"),o=t.priceScale("right"),g={visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,textColor:I,...C?.rightPriceScale};r?.applyOptions(g),o?.applyOptions(g)}catch{}else if(v&&k.length>0)for(const r of k)try{const o=t.priceScale(r.priceScaleId);o&&o.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,textColor:I})}catch(o){console.warn(`Failed to configure price scale ${r.priceScaleId} for series ${r.seriesIndex}:`,o)}else if(!v)try{const r=t.priceScale("right");r&&r.applyOptions({visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,textColor:I,...C?.rightPriceScale})}catch{}if(i!==void 0&&!T&&(Z||!v)&&t.applyOptions({handleScroll:{vertTouchDrag:!1}}),le.length>0){const r=le.map(o=>Number(o.time)).filter(o=>Number.isFinite(o));if(r.length>0){const o=Math.min(...r),g=U!==void 0?Math.min(U,o):o,F=Math.max(...r);if(Number(g)<=Number(F)){const N=()=>{const E=t.timeScale(),J=A&&!T,pe=A?!T:!q,ce=!J,ue=!pe;if(E.applyOptions({fixLeftEdge:!ce,fixRightEdge:!ue}),!ce&&!ue)return;const Q=E.getVisibleLogicalRange(),de=E.width();if(!Q||!(de>0))return;const fe=Q.to-Q.from;if(!(fe>0))return;const he=D.AXIS_TIME_EDGE_PADDING_PX*fe/de;E.setVisibleLogicalRange({from:ce?Q.from-he:Q.from,to:ue?Q.to+he:Q.to})};try{t.timeScale().setVisibleRange({from:g,to:F}),N()}catch{try{t.timeScale().fitContent(),N()}catch{}}}}}ke.current&&(ke.current=!1),C&&t.applyOptions(C);const $=new Map;for(const r of e)r.data.length>0&&$.set(r.label,r.data[r.data.length-1]);ye($.size>0?$:void 0)},[ee,e,le,u,b,T,Z,A,Ve,Ie,Ee,De,U,M,X,C]),p.useEffect(()=>{const t=B.current;if(!t||e.length===0)return;const l=e.length===1;let i;for(const c of e)if(c.data.length>0){i=c.data[c.data.length-1].time;break}if(!i)return;const s=c=>{const{time:h=i,seriesData:d,point:y}=c||{},w=e[0],v=w?V.current.get(oe(w)):void 0;if(!y||!h){const W=new Map;for(const m of e)m.data.length>0&&W.set(m.label,m.data[m.data.length-1]);if(ye(W.size>0?W:void 0),l||Z||ve)Y(null);else if(v&&i){const m=e[0];if(m&&m.data.length>0){const L=t.timeScale().timeToCoordinate(i),K=m.data[m.data.length-1].value,_=v.priceToCoordinate(K);L!==null&&_!==null&&Y({x:L,y:_})}}return}const q=new Map;let I,te=v;for(let W=0;W<e.length;W++){const m=e[W],k=V.current.get(oe(m));if(!k)continue;const L=d?.get(k),K=L&&"value"in L?L.value:void 0;let _;if(K!==void 0)_=K;else if(l){const $=Number(h),r=m.data.length>0?Number(m.data[0].time):Number.POSITIVE_INFINITY;$<r?_=Number.NaN:_=m.data[m.data.length-1]?.value??0}else{const $=m.data.length>0?Number(m.data[0].time):Number.POSITIVE_INFINITY;if(Number(h)<$)continue;_=Je(m.data,Number(h))}Number.isNaN(_)||(I===void 0&&(I=_,te=k),q.set(m.label,{value:_,time:h}))}if(ye(q),I!==void 0&&te){const m=t.timeScale().timeToCoordinate(h),k=te.priceToCoordinate(I);if(m!==null&&k!==null){const L=j.current;if(L){const K=L.querySelector(".LightweightChart");if(K){const _=K.getBoundingClientRect(),$=L.getBoundingClientRect(),r=m+(_.left-$.left),o=k+(_.top-$.top);Y({x:r,y:o})}else Y({x:m,y:k})}else Y({x:m,y:k})}else Y(null)}else Y(null)};return t.subscribeCrosshairMove(s),T&&t.subscribeClick(s),!l&&!Z&&!ve&&requestAnimationFrame(()=>{const c=e[0],h=c?V.current.get(oe(c)):void 0;if(h&&i&&c.data.length>0){const y=t.timeScale().timeToCoordinate(i),w=c.data[c.data.length-1].value,v=h.priceToCoordinate(w);y!==null&&v!==null&&Y({x:y,y:v})}}),()=>{t.unsubscribeCrosshairMove(s),T&&t.unsubscribeClick(s)}},[e,Z,T,ve]),p.useEffect(()=>{const t=B.current;if(!t||e.length===0)return;const l=t.timeScale(),i=()=>{const s=Ae.current;if(s.length===0)return;const c=l.getVisibleRange();if(!c)return;const h=Number(c.from),d=Number(c.to);for(const y of s){const w=[];for(const v of e)if(y.labels.has(v.label))for(const q of v.data){const I=Number(q.time);I>=h&&I<=d&&w.push(q.value)}w.length>0&&y.updateVisibleRange(w)}};return l.subscribeVisibleLogicalRangeChange(i),()=>{l.unsubscribeVisibleLogicalRangeChange(i)}},[e]),p.useEffect(()=>{const t=B.current,l=Array.from(V.current.values()),i=[];if(t&&l.length>0&&P){const s=D.getDefaultVerticalLine(),c=l[0];for(const h of P){const d={...s,...h.options||{}};d.color&&(d.color=G.resolveCSSColor(d.color,d.color));const y=new ht.VertLine(t,c,h.xCoordinate,d);c.attachPrimitive(y),i.push(y)}}return()=>{if(l.length>0){const s=l[0];for(const c of i)try{s.detachPrimitive(c)}catch{}}}},[P,e,ee]),p.useEffect(()=>{const t=[],l=[];if(M&&M.length>0){const i=G.resolveCSSColor("hsl(var(--destructive))","rgb(239, 68, 68)");for(const s of M){if(!Number.isFinite(s.price))continue;const c=Ze(V.current,e,s.seriesLabel);if(!c)continue;const h=s.color?G.resolveCSSColor(s.color,s.color):i,d=s.lineWidth??1,y=s.lineStyle??H.LineStyle.Dashed,w=c.createPriceLine({price:s.price,color:h,lineWidth:d,lineStyle:y,axisLabelVisible:s.axisLabelVisible??!0,title:s.title??""});t.push({series:c,line:w});const v=new vt(c,s.price,h,d,y);c.attachPrimitive(v),l.push({series:c,primitive:v})}}return()=>{for(const{series:i,primitive:s}of l)try{i.detachPrimitive(s)}catch{}for(const{series:i,line:s}of t)try{i.removePriceLine(s)}catch{}}},[M,e,ee]),p.useEffect(()=>{const t=[];if(X&&X.length>0){const l="rgba(239, 68, 68, 0.12)";for(const i of X){const s=Ze(V.current,e,i.seriesLabel);if(!s)continue;const c=i.color?G.resolveCSSColor(i.color,l):l,h=new mt(s,i.priceTop,i.priceBottom,c);s.attachPrimitive(h),t.push({series:s,zone:h})}}return()=>{for(const{series:l,zone:i}of t)try{l.detachPrimitive(i)}catch{}}},[X,e,ee]),p.useEffect(()=>{const t=B.current;if(!t||!P?.length){Ge([]);return}const l=()=>{const c=t.timeScale(),h=P.map(d=>c.timeToCoordinate(d.xCoordinate)??null);Ge(h),j.current&&Xe(j.current.clientWidth)};l();const i=t.timeScale(),s=()=>{l()};return i.subscribeVisibleLogicalRangeChange(s),()=>{i.unsubscribeVisibleLogicalRangeChange(s)}},[P,e,ee]),p.useLayoutEffect(()=>{nt(t=>{const l={};let i=!1;for(const[s,c]of qe.current){if(!c)continue;const h=c.offsetWidth;l[s]=h,t[s]!==h&&(i=!0)}return Object.keys(t).length!==Object.keys(l).length&&(i=!0),i?l:t})});const ge=e.length===1,We=Te.useMemo(()=>{if(ge&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[ge,e]);return x.jsxs("div",{ref:j,className:re.cn("relative z-[1] w-full h-full overflow-hidden p-0",n),children:[Ce!=null&&Ce!==!1&&ge?x.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:x.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:Ce})}):et&&ge&&We&&x.jsx(ut.GraphCurrentValue,{point:We,xMeasureUnit:u,yMeasureUnit:b,decimals:Se}),je&&Fe&&x.jsx(ft.GraphTooltip,{points:je,xMeasureUnit:u,yMeasureUnit:b,series:e,position:Fe,containerRef:j,decimals:Se}),a&&x.jsx(Ue,{series:e,onUnselect:f}),P&&P.length>0&&ze.length===P.length&&x.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:P.map((t,l)=>{const i=ze[l],s=t.options??{};if(i===null)return null;const{labelText:c,valueStr:h}=Qe(s,b,Se),d=s.tooltipText??"";if(!(c||h||d))return null;const w=s.labelBackgroundColor??s.color??"hsl(var(--background))",v=s.labelTextColor??"hsl(var(--foreground))",q=`${String(t.xCoordinate)}-${c}-${d}`,I=Ye(i,ot,rt[l]);return x.jsxs("div",{ref:te=>{qe.current.set(l,te)},className:re.cn("group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",d&&"pointer-events-auto cursor-default"),style:{...I,backgroundColor:w,color:v},children:[c&&x.jsx("span",{className:"block",children:c}),h&&x.jsx("span",{className:re.cn("block",c&&"mt-0.5"),children:h}),d&&x.jsx("span",{className:"pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",role:"tooltip",children:d})]},q)})}),x.jsx("div",{ref:_e,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ue({series:e,onUnselect:n,inline:a=!1}){const f=e.every(u=>u.data.length===0);return x.jsx("div",{className:re.cn("flex flex-wrap",a?"items-center justify-center gap-6":"absolute top-0 left-2 z-[10] gap-2"),children:e.map((u,b)=>{const C=Ne(b),P=(u.lineColor??u.color)||C.line,M=!f&&u.data.length===0;return x.jsxs("div",{className:re.cn("flex items-center gap-1.5",!a&&"px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",M&&"opacity-50"),children:[x.jsx("div",{className:re.cn(a?"size-2 rounded-full":"h-3 w-3 rounded-sm"),style:{backgroundColor:P}}),x.jsxs("span",{className:re.cn("font-medium text-foreground",a?"text-sm":"text-[10px] sm:text-xs"),children:[u.label,M&&" (no data)"]}),n&&x.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),n(u.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${u.label}`,children:x.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[x.jsx("title",{children:"Close"}),x.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),x.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},u.id??u.label)})})}exports.DEFAULT_SERIES_COLORS=be;exports.Graph=_t;exports.GraphLegend=Ue;exports.VERTICAL_LINE_LABEL_EDGE_PADDING=Le;exports.getSeriesColorPalette=Ne;exports.getStepForwardValue=Je;exports.getVerticalLineLabelStyle=Ye;exports.getVerticalLineTooltipContent=Qe;exports.seriesIdentity=oe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),H=require("lightweight-charts"),p=require("react"),ct=require("../../hooks/use-media-query.cjs"),re=require("../../utils/cn.cjs"),G=require("../../utils/colors.cjs"),D=require("./default-config.cjs"),ne=require("./formatters.cjs"),ut=require("./graph-current-value.cjs"),ft=require("./graph-tooltip.cjs"),ht=require("./plugins/vertical-line.cjs"),He=require("./y-axis-scale.cjs");function gt(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const f=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,f.get?f:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const Te=gt(p);function oe(e){return e.id??e.label}function Ze(e,n,a){if(!a)return e.values().next().value;const f=e.get(a);if(f)return f;const c=n.find(b=>b.id===a||b.label===a);return c?e.get(oe(c)):void 0}class pt{_yTop;_yBottom;_color;constructor(n,a,f){this._yTop=n,this._yBottom=a,this._color=f}draw(n){n.useBitmapCoordinateSpace(a=>{const f=a.context,c=a.verticalPixelRatio,b=this._yTop===null?0:this._yTop*c,C=this._yBottom===null?a.bitmapSize.height:this._yBottom*c,P=Math.min(b,C),M=Math.max(b,C);f.fillStyle=this._color,f.fillRect(0,P,a.bitmapSize.width,M-P)})}}class dt{_source;_yTop=null;_yBottom=null;constructor(n){this._source=n}update(){const n=this._source.series;this._yTop=this._source.priceTop===void 0?null:n.priceToCoordinate(this._source.priceTop),this._yBottom=this._source.priceBottom===void 0?null:n.priceToCoordinate(this._source.priceBottom)}zOrder(){return"bottom"}renderer(){return new pt(this._yTop,this._yBottom,this._source.color)}}class mt{series;priceTop;priceBottom;color;_paneViews;constructor(n,a,f,c){this.series=n,this.priceTop=a,this.priceBottom=f,this.color=c,this._paneViews=[new dt(this)]}updateAllViews(){for(const n of this._paneViews)n.update()}paneViews(){return this._paneViews}}function bt(e,n){switch(e){case H.LineStyle.Dotted:return[n,n];case H.LineStyle.Dashed:return[2*n,2*n];case H.LineStyle.LargeDashed:return[6*n,6*n];case H.LineStyle.SparseDotted:return[n,4*n];default:return[]}}class St{_y;_color;_lineWidth;_lineStyle;constructor(n,a,f,c){this._y=n,this._color=a,this._lineWidth=f,this._lineStyle=c}draw(n){n.useBitmapCoordinateSpace(a=>{if(this._y===null)return;const f=a.context,c=a.verticalPixelRatio,b=Math.max(1,Math.round(this._lineWidth*c)),C=Math.round(this._y*c);f.save(),f.strokeStyle=this._color,f.lineWidth=b,f.setLineDash(bt(this._lineStyle,b)),f.beginPath(),f.moveTo(0,C),f.lineTo(a.bitmapSize.width,C),f.stroke(),f.restore()})}}class Ct{_source;_y=null;constructor(n){this._source=n}update(){this._y=this._source.series.priceToCoordinate(this._source.price)}zOrder(){return"top"}renderer(){return new St(this._y,this._source.color,this._source.lineWidth,this._source.lineStyle)}}class xt{series;price;color;lineWidth;lineStyle;_paneViews;constructor(n,a,f,c,b){this.series=n,this.price=a,this.color=f,this.lineWidth=c,this.lineStyle=b,this._paneViews=[new Ct(this)]}updateAllViews(){for(const n of this._paneViews)n.update()}paneViews(){return this._paneViews}}function Qe(e,n,a){const f=e.labelText??"",c=e.value,b=c===void 0?"":typeof c=="number"?n==="$"?`$${ne.formatExactValue(c,void 0,a)}`:n==="%"?`${ne.formatExactValue(c,void 0,a)}%`:ne.formatExactValue(c,n!=="none"&&n!=="%"&&n!=="$"&&!ne.isRatioUnit(n)?n:void 0,a):String(c);return{labelText:f,valueStr:b}}const Le=4;function Ye(e,n,a){const f={left:e,transform:"translateX(-50%)"};if(n<=0||!a||a<=0)return f;const c=a/2,b=Le+c,C=n-Le-c;return C<b?{left:n/2,transform:"translateX(-50%)"}:{left:Math.min(Math.max(e,b),C),transform:"translateX(-50%)"}}function Je(e,n){for(let a=e.length-1;a>=0;a--)if(Number(e[a].time)<=n)return e[a].value;return 0}const be=[{line:"#02c39a",top:"rgba(2, 195, 154, 0.56)",bottom:"rgba(2, 195, 154, 0.04)"},{line:"#3b82f6",top:"rgba(59, 130, 246, 0.56)",bottom:"rgba(59, 130, 246, 0.04)"},{line:"#ef4444",top:"rgba(239, 68, 68, 0.56)",bottom:"rgba(239, 68, 68, 0.04)"},{line:"#f59e0b",top:"rgba(245, 158, 11, 0.56)",bottom:"rgba(245, 158, 11, 0.04)"},{line:"#8b5cf6",top:"rgba(139, 92, 246, 0.56)",bottom:"rgba(139, 92, 246, 0.04)"},{line:"#ec4899",top:"rgba(236, 72, 153, 0.56)",bottom:"rgba(236, 72, 153, 0.04)"},{line:"#06b6d4",top:"rgba(6, 182, 212, 0.56)",bottom:"rgba(6, 182, 212, 0.04)"},{line:"#ea580c",top:"rgba(234, 88, 12, 0.56)",bottom:"rgba(234, 88, 12, 0.04)"},{line:"#84cc16",top:"rgba(132, 204, 22, 0.56)",bottom:"rgba(132, 204, 22, 0.04)"},{line:"#d946ef",top:"rgba(217, 70, 239, 0.56)",bottom:"rgba(217, 70, 239, 0.04)"},{line:"#0ea5e9",top:"rgba(14, 165, 233, 0.56)",bottom:"rgba(14, 165, 233, 0.04)"},{line:"#14b8a6",top:"rgba(20, 184, 166, 0.56)",bottom:"rgba(20, 184, 166, 0.04)"},{line:"#eab308",top:"rgba(234, 179, 8, 0.56)",bottom:"rgba(234, 179, 8, 0.04)"},{line:"#f43f5e",top:"rgba(244, 63, 94, 0.56)",bottom:"rgba(244, 63, 94, 0.04)"},{line:"#6366f1",top:"rgba(99, 102, 241, 0.56)",bottom:"rgba(99, 102, 241, 0.04)"},{line:"#10b981",top:"rgba(16, 185, 129, 0.56)",bottom:"rgba(16, 185, 129, 0.04)"},{line:"#78716c",top:"rgba(120, 113, 108, 0.56)",bottom:"rgba(120, 113, 108, 0.04)"},{line:"#64748b",top:"rgba(100, 116, 139, 0.56)",bottom:"rgba(100, 116, 139, 0.04)"},{line:"#475569",top:"rgba(71, 85, 105, 0.56)",bottom:"rgba(71, 85, 105, 0.04)"}],vt=137.5;function Ne(e){if(e<be.length)return be[e];const a=(e-be.length)*vt%360,f=G.hslToHex(a,70,50),{topColor:c,bottomColor:b}=G.generateColorsFromBase(f);return{line:f,top:c,bottom:b}}function _t({series:e,className:n,showLegend:a=!1,onUnselectSeries:f,xMeasureUnit:c="time",yMeasureUnit:b="token",optionsOverrides:C,verticalLineOptions:P,priceLineOptions:M,zoneOptions:X,currentValueDecimals:Se,useSharedPriceScale:Z=!1,dualYAxis:A=!1,defaultVisiblePriceScaleId:Ve="right",leftPriceScaleTitle:Ee,rightPriceScaleTitle:yt,showCurrentValue:et=!0,graphTitle:Ce,yScaleMin:Ie,yScaleMinMultiple:De,visibleTimeFrom:U,disableZoom:Me=!1,hideDefaultTooltip:xe=!1}){const B=p.useRef(null),E=p.useRef(new Map),ve=p.useRef(!1),ke=p.useRef(!0),Ae=p.useRef([]),ae=p.useRef(0),j=p.useRef(null),_e=p.useRef(null),Be=p.useRef(null),T=ct.useIsMobile(),le=Te.useMemo(()=>e.flatMap(t=>t.data),[e]),tt=Te.useMemo(()=>{if(e.length>0){const t=e[e.length-1];if(t.data.length>0)return t.data[t.data.length-1]}},[e]),[je,ye]=p.useState(()=>{if(!tt)return;const t=new Map;for(const l of e)l.data.length>0&&t.set(l.label,l.data[l.data.length-1]);return t}),[Fe,Y]=p.useState(null),[ze,Ge]=p.useState([]),[ot,Xe]=p.useState(0),qe=p.useRef(new Map),[rt,nt]=p.useState({}),[ee,it]=p.useState(0);p.useEffect(()=>{const t=()=>{try{if(j.current&&Xe(j.current.clientWidth),B.current&&j.current){const s=j.current.clientWidth,u=j.current.clientHeight;B.current.resize(s,u);try{ae.current=B.current.paneSize().height}catch{}}}catch{}},l=j.current,i=l?new ResizeObserver(t):null;return Be.current=i,l&&i?.observe(l),()=>{l&&i?.unobserve(l),i?.disconnect(),Be.current=null}},[]),p.useEffect(()=>{if(!_e.current||ve.current)return;const t=D.getDefaultOptions(),l=G.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)"),i=H.createChart(_e.current,{...t,leftPriceScale:{...t.leftPriceScale||{},visible:!1,textColor:l},rightPriceScale:{...t.rightPriceScale||{},visible:!T,textColor:l},...T&&{crosshair:{...t.crosshair,mode:H.CrosshairMode.Magnet}}});B.current=i,ve.current=!0;try{ae.current=i.paneSize().height}catch{ae.current=0}return it(s=>s+1),()=>{i.remove(),B.current=null,ve.current=!1,E.current.clear()}},[T]),p.useEffect(()=>{const t=B.current;t&&t.applyOptions(Me?{handleScale:{mouseWheel:!1,pinch:!1,axisPressedMouseMove:!1,axisDoubleClickReset:!1},handleScroll:{mouseWheel:!1,pressedMouseMove:!1,horzTouchDrag:!1,vertTouchDrag:!1}}:{handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:!0,axisDoubleClickReset:!0},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}})},[ee,Me]),p.useEffect(()=>{const t=B.current;!t||!C||t.applyOptions(C)},[ee,C]),p.useEffect(()=>{const t=B.current;if(!t||e.length===0)return;const i=e.filter(r=>r.data.length>0).length<=1?Ie:De,s=c==="time"?ne.getXFormatters(c,le):ne.getXFormatters(c),u=new Map;{let r=0;for(const o of e)o.data.length!==0&&(u.set(o.label,o.priceScaleId??(r===0?"left":"right")),r++)}const h=(r,o,g)=>{const{formatter:F,tickmarksFormatter:N,updateVisibleRange:V}=ne.createAdaptiveYAxisFormatter(r,o,{yScaleMin:i});return{formatter:F,tickmarksFormatter:N,updateVisibleRange:V,labels:g}},d=[];if(A)for(const r of["left","right"]){const o=new Set,g=[];let F=b;for(const N of e)if(N.data.length!==0&&u.get(N.label)===r){o.size===0&&N.yMeasureUnit&&(F=N.yMeasureUnit),o.add(N.label);for(const V of N.data)g.push(V.value)}o.size>0&&d.push(h(g,F,o))}else{const r=le.map(g=>g.value),o=new Set(e.filter(g=>g.data.length>0).map(g=>g.label));d.push(h(r,b,o))}Ae.current=d;const y=new Map;for(const r of d)for(const o of r.labels)y.set(o,r);const w=D.getDefaultOptions();t.applyOptions({localization:{...w.localization||{},timeFormatter:r=>s.timeFormatter(parseFloat(r),void 0)},timeScale:{...w.timeScale||{},...C?.timeScale,tickMarkFormatter:s.tickMarkFormatter,minBarSpacing:0}});const x=!A&&e.length>1&&!Z,q=A?T:e.length>1&&!Z||T,I=G.resolveCSSColor("hsl(var(--muted-foreground))","rgb(163, 163, 163)");t.applyOptions({...A&&{defaultVisiblePriceScaleId:Ve},leftPriceScale:{...w.leftPriceScale||{},...C?.leftPriceScale,visible:A&&!T,textColor:I,...A&&Ee&&{}},rightPriceScale:{...w.rightPriceScale||{},...C?.rightPriceScale,visible:A?!T:!q,textColor:I}});const te=new Set(E.current.keys()),W=new Set(e.map(oe));for(const r of te)if(!W.has(r)){const o=E.current.get(r);o&&(t.removeSeries(o),E.current.delete(r))}const m=D.getDefaultSeries(),k=[];let L=0;const K=e.find(r=>r.data.length>0),_=new Map;if(M&&M.length>0)for(const r of M){if(!Number.isFinite(r.price))continue;const o=r.seriesLabel??K?.label;if(!o)continue;const g=_.get(o)??[];g.push(r.price),_.set(o,g)}if(X&&X.length>0)for(const r of X){const o=r.seriesLabel??K?.label;if(!o)continue;const g=_.get(o)??[];Number.isFinite(r.priceTop)&&g.push(r.priceTop),Number.isFinite(r.priceBottom)&&g.push(r.priceBottom),_.set(o,g)}for(let r=0;r<e.length;r++){const o=e[r],g=oe(o),F=Ne(r),N=o.lineColor??o.color??F.line;let V,J;if(o.lineColor??o.color)if(o.topColor&&o.bottomColor)V=o.topColor,J=o.bottomColor;else if(o.topColor){const S=G.generateColorsFromBase(N);V=o.topColor,J=S.bottomColor}else if(o.bottomColor)V=G.generateColorsFromBase(N).topColor,J=o.bottomColor;else{const S=G.generateColorsFromBase(N);V=S.topColor,J=S.bottomColor}else V=o.topColor||F.top,J=o.bottomColor||F.bottom;if(o.data.length===0){const S=E.current.get(g);S&&(t.removeSeries(S),E.current.delete(g));continue}const pe=o.data.length>0?Math.min(...o.data.map(S=>S.value)):0,ce=o.data.length>0?Math.max(...o.data.map(S=>S.value)):0,ue=pe<0,Q=o.data.some(S=>S.value===0),de=!ue&&Q,fe=He.pickMinMove(ce-pe),he=A?o.priceScaleId??(L===0?"left":"right"):Z||!x||L===0?"right":`scale-${L}`;x&&k.push({priceScaleId:he||"right",seriesIndex:L});const we=(Z||!x)&&i!==void 0&&typeof i=="number",st=_.get(o.label)??[],at=S=>{const R=S();if(R?.priceRange){we&&(R.priceRange.minValue=i);for(const O of st)O<R.priceRange.minValue&&(R.priceRange.minValue=O),O>R.priceRange.maxValue&&(R.priceRange.maxValue=O);const se=we?i:de&&R.priceRange.minValue>=0?0:void 0,me=ae.current>0?ae.current:j.current?.clientHeight??0;if(me>0){const O=He.niceAxisRange({min:R.priceRange.minValue,max:R.priceRange.maxValue,floor:se,scaleHeightPx:me,fontSizePx:D.AXIS_FONT_SIZE,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,minMove:fe,edgePaddingPx:D.AXIS_EDGE_LABEL_PADDING_PX,edgePaddingTopPx:D.AXIS_TOP_LABEL_PADDING_PX});R.priceRange.minValue=O.min,R.priceRange.maxValue=O.max}R.margins={above:D.AXIS_TOP_LABEL_PADDING_PX,below:D.AXIS_EDGE_LABEL_PADDING_PX}}return R},Ke=y.get(o.label)??d[0],$e=Ke.formatter,lt=Ke.tickmarksFormatter,Re={lineColor:N,topColor:V,bottomColor:J,priceScaleId:he,...o.seriesType==="line"&&{lineStyle:o.lineStyle??H.LineStyle.Solid},priceFormat:{type:"custom",minMove:fe,formatter:we&&typeof i=="number"?S=>$e(S<i?i:S):$e,tickmarksFormatter:lt},autoscaleInfoProvider:at},Oe=o.seriesType==="line";let z=E.current.get(g);const ie=o.data.map(S=>({...S,time:S.time}));if(U!==void 0&&ie.length>0&&Number(ie[0].time)>U){const S=Number(ie[0].time),R=S-U,se=86400,me=R>180*se?7*se:R>30*se?se:6*3600,O=[];for(let Pe=U;Pe<S;Pe+=me)O.push({time:Pe});ie.unshift(...O)}z&&z.seriesType()!==(Oe?"Line":"Area")&&(t.removeSeries(z),E.current.delete(g),z=void 0),z?(z.applyOptions(Re),z.setData(ie)):(Oe?z=t.addSeries(H.LineSeries,{...m,...Re}):z=t.addSeries(H.AreaSeries,{...m,...Re}),z.setData(ie),E.current.set(g,z)),L++}if(A)try{const r=t.priceScale("left"),o=t.priceScale("right"),g={visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,textColor:I,...C?.rightPriceScale};r?.applyOptions(g),o?.applyOptions(g)}catch{}else if(x&&k.length>0)for(const r of k)try{const o=t.priceScale(r.priceScaleId);o&&o.applyOptions({visible:!1,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,textColor:I})}catch(o){console.warn(`Failed to configure price scale ${r.priceScaleId} for series ${r.seriesIndex}:`,o)}else if(!x)try{const r=t.priceScale("right");r&&r.applyOptions({visible:!T,autoScale:!0,scaleMargins:{top:0,bottom:0},alignLabels:!0,entireTextOnly:!1,tickMarkDensity:D.AXIS_TICK_MARK_DENSITY,textColor:I,...C?.rightPriceScale})}catch{}if(i!==void 0&&!T&&(Z||!x)&&t.applyOptions({handleScroll:{vertTouchDrag:!1}}),le.length>0){const r=le.map(o=>Number(o.time)).filter(o=>Number.isFinite(o));if(r.length>0){const o=Math.min(...r),g=U!==void 0?Math.min(U,o):o,F=Math.max(...r);if(Number(g)<=Number(F)){const N=()=>{const V=t.timeScale();if(c!=="time"){V.applyOptions({fixLeftEdge:!0,fixRightEdge:!0});return}const J=A&&!T,pe=A?!T:!q,ce=!J,ue=!pe;if(V.applyOptions({fixLeftEdge:!ce,fixRightEdge:!ue}),!ce&&!ue)return;const Q=V.getVisibleLogicalRange(),de=V.width();if(!Q||!(de>0))return;const fe=Q.to-Q.from;if(!(fe>0))return;const he=D.AXIS_TIME_EDGE_PADDING_PX*fe/de;V.setVisibleLogicalRange({from:ce?Q.from-he:Q.from,to:ue?Q.to+he:Q.to})};try{t.timeScale().setVisibleRange({from:g,to:F}),N()}catch{try{t.timeScale().fitContent(),N()}catch{}}}}}ke.current&&(ke.current=!1),C&&t.applyOptions(C);const $=new Map;for(const r of e)r.data.length>0&&$.set(r.label,r.data[r.data.length-1]);ye($.size>0?$:void 0)},[ee,e,le,c,b,T,Z,A,Ve,Ee,Ie,De,U,M,X,C]),p.useEffect(()=>{const t=B.current;if(!t||e.length===0)return;const l=e.length===1;let i;for(const u of e)if(u.data.length>0){i=u.data[u.data.length-1].time;break}if(!i)return;const s=u=>{const{time:h=i,seriesData:d,point:y}=u||{},w=e[0],x=w?E.current.get(oe(w)):void 0;if(!y||!h){const W=new Map;for(const m of e)m.data.length>0&&W.set(m.label,m.data[m.data.length-1]);if(ye(W.size>0?W:void 0),l||Z||xe)Y(null);else if(x&&i){const m=e[0];if(m&&m.data.length>0){const L=t.timeScale().timeToCoordinate(i),K=m.data[m.data.length-1].value,_=x.priceToCoordinate(K);L!==null&&_!==null&&Y({x:L,y:_})}}return}const q=new Map;let I,te=x;for(let W=0;W<e.length;W++){const m=e[W],k=E.current.get(oe(m));if(!k)continue;const L=d?.get(k),K=L&&"value"in L?L.value:void 0;let _;if(K!==void 0)_=K;else if(l){const $=Number(h),r=m.data.length>0?Number(m.data[0].time):Number.POSITIVE_INFINITY;$<r?_=Number.NaN:_=m.data[m.data.length-1]?.value??0}else{const $=m.data.length>0?Number(m.data[0].time):Number.POSITIVE_INFINITY;if(Number(h)<$)continue;_=Je(m.data,Number(h))}Number.isNaN(_)||(I===void 0&&(I=_,te=k),q.set(m.label,{value:_,time:h}))}if(ye(q),I!==void 0&&te){const m=t.timeScale().timeToCoordinate(h),k=te.priceToCoordinate(I);if(m!==null&&k!==null){const L=j.current;if(L){const K=L.querySelector(".LightweightChart");if(K){const _=K.getBoundingClientRect(),$=L.getBoundingClientRect(),r=m+(_.left-$.left),o=k+(_.top-$.top);Y({x:r,y:o})}else Y({x:m,y:k})}else Y({x:m,y:k})}else Y(null)}else Y(null)};return t.subscribeCrosshairMove(s),T&&t.subscribeClick(s),!l&&!Z&&!xe&&requestAnimationFrame(()=>{const u=e[0],h=u?E.current.get(oe(u)):void 0;if(h&&i&&u.data.length>0){const y=t.timeScale().timeToCoordinate(i),w=u.data[u.data.length-1].value,x=h.priceToCoordinate(w);y!==null&&x!==null&&Y({x:y,y:x})}}),()=>{t.unsubscribeCrosshairMove(s),T&&t.unsubscribeClick(s)}},[e,Z,T,xe]),p.useEffect(()=>{const t=B.current;if(!t||e.length===0)return;const l=t.timeScale(),i=()=>{const s=Ae.current;if(s.length===0)return;const u=l.getVisibleRange();if(!u)return;const h=Number(u.from),d=Number(u.to);for(const y of s){const w=[];for(const x of e)if(y.labels.has(x.label))for(const q of x.data){const I=Number(q.time);I>=h&&I<=d&&w.push(q.value)}w.length>0&&y.updateVisibleRange(w)}};return l.subscribeVisibleLogicalRangeChange(i),()=>{l.unsubscribeVisibleLogicalRangeChange(i)}},[e]),p.useEffect(()=>{const t=B.current,l=Array.from(E.current.values()),i=[];if(t&&l.length>0&&P){const s=D.getDefaultVerticalLine(),u=l[0];for(const h of P){const d={...s,...h.options||{}};d.color&&(d.color=G.resolveCSSColor(d.color,d.color));const y=new ht.VertLine(t,u,h.xCoordinate,d);u.attachPrimitive(y),i.push(y)}}return()=>{if(l.length>0){const s=l[0];for(const u of i)try{s.detachPrimitive(u)}catch{}}}},[P,e,ee]),p.useEffect(()=>{const t=[],l=[];if(M&&M.length>0){const i=G.resolveCSSColor("hsl(var(--destructive))","rgb(239, 68, 68)");for(const s of M){if(!Number.isFinite(s.price))continue;const u=Ze(E.current,e,s.seriesLabel);if(!u)continue;const h=s.color?G.resolveCSSColor(s.color,s.color):i,d=s.lineWidth??1,y=s.lineStyle??H.LineStyle.Dashed,w=u.createPriceLine({price:s.price,color:h,lineWidth:d,lineStyle:y,axisLabelVisible:s.axisLabelVisible??!0,title:s.title??""});t.push({series:u,line:w});const x=new xt(u,s.price,h,d,y);u.attachPrimitive(x),l.push({series:u,primitive:x})}}return()=>{for(const{series:i,primitive:s}of l)try{i.detachPrimitive(s)}catch{}for(const{series:i,line:s}of t)try{i.removePriceLine(s)}catch{}}},[M,e,ee]),p.useEffect(()=>{const t=[];if(X&&X.length>0){const l="rgba(239, 68, 68, 0.12)";for(const i of X){const s=Ze(E.current,e,i.seriesLabel);if(!s)continue;const u=i.color?G.resolveCSSColor(i.color,l):l,h=new mt(s,i.priceTop,i.priceBottom,u);s.attachPrimitive(h),t.push({series:s,zone:h})}}return()=>{for(const{series:l,zone:i}of t)try{l.detachPrimitive(i)}catch{}}},[X,e,ee]),p.useEffect(()=>{const t=B.current;if(!t||!P?.length){Ge([]);return}const l=()=>{const u=t.timeScale(),h=P.map(d=>u.timeToCoordinate(d.xCoordinate)??null);Ge(h),j.current&&Xe(j.current.clientWidth)};l();const i=t.timeScale(),s=()=>{l()};return i.subscribeVisibleLogicalRangeChange(s),()=>{i.unsubscribeVisibleLogicalRangeChange(s)}},[P,e,ee]),p.useLayoutEffect(()=>{nt(t=>{const l={};let i=!1;for(const[s,u]of qe.current){if(!u)continue;const h=u.offsetWidth;l[s]=h,t[s]!==h&&(i=!0)}return Object.keys(t).length!==Object.keys(l).length&&(i=!0),i?l:t})});const ge=e.length===1,We=Te.useMemo(()=>{if(ge&&e.length>0){const t=e[0];if(t.data.length>0)return t.data[t.data.length-1]}},[ge,e]);return v.jsxs("div",{ref:j,className:re.cn("relative z-[1] w-full h-full overflow-hidden p-0",n),children:[Ce!=null&&Ce!==!1&&ge?v.jsx("div",{className:"absolute top-2 left-2 right-2 z-[100] pointer-events-none",children:v.jsx("div",{className:"text-xl sm:text-2xl font-semibold text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:Ce})}):et&&ge&&We&&v.jsx(ut.GraphCurrentValue,{point:We,xMeasureUnit:c,yMeasureUnit:b,decimals:Se}),je&&Fe&&v.jsx(ft.GraphTooltip,{points:je,xMeasureUnit:c,yMeasureUnit:b,series:e,position:Fe,containerRef:j,decimals:Se}),a&&v.jsx(Ue,{series:e,onUnselect:f}),P&&P.length>0&&ze.length===P.length&&v.jsx("div",{className:"absolute inset-0 z-[5] pointer-events-none","aria-hidden":!0,children:P.map((t,l)=>{const i=ze[l],s=t.options??{};if(i===null)return null;const{labelText:u,valueStr:h}=Qe(s,b,Se),d=s.tooltipText??"";if(!(u||h||d))return null;const w=s.labelBackgroundColor??s.color??"hsl(var(--background))",x=s.labelTextColor??"hsl(var(--foreground))",q=`${String(t.xCoordinate)}-${u}-${d}`,I=Ye(i,ot,rt[l]);return v.jsxs("div",{ref:te=>{qe.current.set(l,te)},className:re.cn("group absolute top-2 px-2 py-1 rounded text-xs font-medium whitespace-nowrap shadow-sm border border-border",d&&"pointer-events-auto cursor-default"),style:{...I,backgroundColor:w,color:x},children:[u&&v.jsx("span",{className:"block",children:u}),h&&v.jsx("span",{className:re.cn("block",u&&"mt-0.5"),children:h}),d&&v.jsx("span",{className:"pointer-events-none absolute right-0 top-full z-10 mt-1 hidden w-[280px] whitespace-normal rounded border border-border bg-popover px-2.5 py-1.5 text-left leading-snug text-popover-foreground shadow-md group-hover:block",role:"tooltip",children:d})]},q)})}),v.jsx("div",{ref:_e,className:"LightweightChart w-full h-full overflow-hidden"})]})}function Ue({series:e,onUnselect:n,inline:a=!1}){const f=e.every(c=>c.data.length===0);return v.jsx("div",{className:re.cn("flex flex-wrap",a?"items-center justify-center gap-6":"absolute top-0 left-2 z-[10] gap-2"),children:e.map((c,b)=>{const C=Ne(b),P=(c.lineColor??c.color)||C.line,M=!f&&c.data.length===0;return v.jsxs("div",{className:re.cn("flex items-center gap-1.5",!a&&"px-2 py-1 bg-background/80 backdrop-blur-sm rounded border border-border",M&&"opacity-50"),children:[v.jsx("div",{className:re.cn(a?"size-2 rounded-full":"h-3 w-3 rounded-sm"),style:{backgroundColor:P}}),v.jsxs("span",{className:re.cn("font-medium text-foreground",a?"text-sm":"text-[10px] sm:text-xs"),children:[c.label,M&&" (no data)"]}),n&&v.jsx("button",{type:"button",onClick:X=>{X.stopPropagation(),n(c.label)},className:"ml-1 flex items-center justify-center w-4 h-4 rounded-sm hover:bg-muted transition-colors cursor-pointer","aria-label":`Remove ${c.label}`,children:v.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground hover:text-foreground","aria-hidden":"true",children:[v.jsx("title",{children:"Close"}),v.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),v.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},c.id??c.label)})})}exports.DEFAULT_SERIES_COLORS=be;exports.Graph=_t;exports.GraphLegend=Ue;exports.VERTICAL_LINE_LABEL_EDGE_PADDING=Le;exports.getSeriesColorPalette=Ne;exports.getStepForwardValue=Je;exports.getVerticalLineLabelStyle=Ye;exports.getVerticalLineTooltipContent=Qe;exports.seriesIdentity=oe;
@@ -1 +1 @@
1
- "use strict";const e={"errors.networkError":"Network error. Can't fetch data","errors.incorrectAddressError":"Incorrect address. Please, check url","errors.noOpenedAccountsError":"You have no opened Credit Accounts. Perhaps, you have recently been liquidated? Check notification centre to see more.","errors.notFound":"Not found","errors.tooManyRequests":"Too many requests","errors.incorrectAddress":"Incorrect address","components.errorMessage.oops":"Oops...","components.networkIndicator.title":"Network","components.infiniteScrollWrapper.showMore":"Show more","components.alertModal.ok":"Ok","components.footer.privacy":"Privacy Notice","components.footer.terms":"Terms of Service","components.footer.disclosure":"Risk Disclosure Statement","components.footer.legalNotice":"Legal Notice","components.footer.legal":"Legal Info","components.footer.gearbox":"Copyright © Gearbox Foundation 2023-2026.","components.footer.built":"Built at ETHGlobal MarketMake hackathon.","components.footer.version":"Version {value}","components.sdkStatus.connecting":"Connecting…","components.sdkStatus.connected":"Connected","components.sdkStatus.disconnected":"Not connected","components.creditAccountHistory.table.protocol":"Protocol","components.creditAccountHistory.table.operation":"Operation","components.creditAccountHistory.table.details":"Details","components.notificationCenter.empty":"No notifications yet","components.notificationCenter.requests":"Requests","components.notificationCenter.recent":"Recent","components.notificationCenter.clear":"Clear all","components.liquidationPrice.check":"Check Area","components.loading.loading":"Loading","components.loading.loadingPercent":"Loading {percent}%","components.loading.wait":"Please wait...","components.smartNumberInput.balance":"Balance","components.smartNumberInput.amountLabel":"Amount","components.smartNumberInput.inputTitle":"Token Amount","components.smartNumberInput.confirm.input":"Input","components.smartNumberInput.selectToken":"Select token","components.tipWindow.title":"Tip","components.healthFactor.low":"Extremely low! This HF may not cover possible oracle deviations.","components.headCell":"Sort by {value}","components.graphView.noData":"Can't get data for this graph","components.filterBlock.reset":"Reset All","components.filterModal.searchPlaceholder":"Search options...","components.filterModal.noOptionsAvailable":"No options available","components.filterModal.noOptionsMatchSearch":"No options match your search","components.filterModal.reset":"Reset","components.filterModal.apply":"Apply","components.APY.tip":"These APYs are derived from the underlying protocols’ APIs and may differ in reality. Check respective protocols for their methodology.","components.creditSessionDetailedLiquidation.graph.noData":"No data","components.creditSessionDetailedLiquidation.graph.legend.point":"Current price","components.creditSessionDetailedLiquidation.graph.legend.area":"Liquidation Area","components.creditSessionDetailedLiquidation.graph.tip.hf":"Health Factor","components.creditSessionDetailedLiquidation.graph.tip.price":"Price","components.creditSessionDetailedLiquidation.table.noData":"No data","components.creditSessionDetailedLiquidation.table.seeGraph":"See graph","components.creditSessionDetailedLiquidation.table.asset":"Asset","components.creditSessionDetailedLiquidation.table.currentPrice":"Current price","components.creditSessionDetailedLiquidation.table.modelPrice":"Model price","components.apyParts.features.points":"Points","components.apyParts.features.incent":"Incent.","components.apyParts.supplyAPY":"Organic APY","components.apyParts.title":"APY type","components.apyParts.supplyAPY.tip":"Yield from lending funds","components.apyParts.tokenYield":"Intrinsic APY","components.apyParts.tokenYield.tip":"Yield from holding wstETH","components.apyParts.extraAPY":"{symbol} Incentive","components.apyParts.extraAPY.tip":"Calculated at the current rate","components.apyParts.totalAPY":"Overall APY","components.apyParts.points":"{symbol} Incentive","components.apyParts.points.condition.crossDeposit":"For cross-chain deposits made via Omni","components.yieldBreakdown.titleNetAtLeverage":"Net APY at {leverage}× Leverage","components.yieldBreakdown.titleNetAtLeverage7d":"Net APY at {leverage}× Leverage (7d)","components.yieldBreakdown.titleNet":"Net APY","components.yieldBreakdown.titleNet7d":"Net APY (7d)","components.yieldBreakdown.collateralApy":"Collateral APY","components.yieldBreakdown.collateralApy7d":"Collateral APY (7d)","components.yieldBreakdown.baseApy":"Base APY","components.yieldBreakdown.baseApy7d":"Base APY (7d)","components.yieldBreakdown.incentive":"Incentive","components.yieldBreakdown.incentiveApy":"Incentive APY","components.yieldBreakdown.incentiveApy7d":"Incentive APY (7d)","components.yieldBreakdown.borrowRate":"Borrow Rate","components.yieldBreakdown.borrowRate7d":"Borrow Rate (7d)","components.yieldBreakdown.programPoints":"{name} Points","components.yieldBreakdown.points":"Points","components.openCopyButtons.copy":"Copy to clipboard","components.openCopyButtons.explorer":"View in explorer","components.poolAssetsTable.asset":"Name","components.poolAssetsTable.rate":"Effective rate","components.poolAssetsTable.exposure":"Exposure","components.poolAssetsTable.cap":"Cap","components.poolAssetsTable.capUtilization":"Cap utilization","components.poolAssetsTable.usage":"{amount} of {total}","components.poolAssetsTable.head.name":"Credit Manager","components.poolAssetsTable.head.currentDebt":"Current Debt","components.poolAssetsTable.head.assets":"Asset LT","components.poolCreditManagersTable.assets":"{amount} assets","components.creditManagerInfo.title":"Assets and LT’s","components.creditManagerInfo.info.title":"Credit Managers","components.creditManagerInfo.info.copy.tip":"Copy Credit Manager address","components.creditManagerInfo.info.minDebt":"Min debt","components.creditManagerInfo.info.maxDebt":"Max debt","components.creditManagerInfo.info.liquidationFee":"Liquid. fee","components.creditManagerInfo.info.liquidationPremium":"Liquid. premium","components.creditManagerInfo.info.interestFee":"Interest fee","components.creditManagerInfo.info.debtLimit":"Debt limit","components.creditManagerInfo.info.maxEnabledTokens":"Max tokens","dialogs.oraclesAndLTInfo.filter.hide0Quota":"Hide 0-Quota","components.oraclesAndLTInfo.title":"Oracles and LTs","components.oraclesAndLTTable.head.token":"Token","components.oraclesAndLTTable.head.oracles":"Oracles","components.oraclesAndLTTable.head.lt":"LT","components.poolTable.pool":"Market","components.poolTable.market":"Market","components.poolTable.description.universal":"Universal","components.poolTable.supply":"Supply","components.poolTable.borrowed":"Borrowed","components.poolTable.supplyApy":"Supply APY","components.poolTable.supplyApy.tip":"Annual percentage yield that you earn for supplying capital. This number constantly changes as the utilization of the Markets goes up and down","components.poolTable.depositApy":"Deposit APY","components.poolTable.depositApy.tip":"Deposit APY breakdown: base rate, extra rewards, and points","components.poolTable.borrowApy":"Borrow APY","components.poolTable.utilizationApy":"Utilization APY","components.poolTable.borrowApy.tip":"On top of the utilization borrow APY, there is a borrow quota APY for different assets","components.poolTable.utilization":"Utilization","components.poolTable.collateral":"Collateral","components.poolTable.collateral.showAll":"Show All","components.poolTable.balance":"Your Balance","components.poolTable.balance.tip":`You don't earn token rewards, only organic yield. Please migrate liquidity by using "Migrate" flow above.`,"components.poolTable.emptyList":"No Pools found","components.poolTable.notFound.dashboard":"You currently have no open Market positions.","components.poolTable.notFound.list":"No Markets found","components.poolTable.notFound.description.dashboard":"Choose earn above.","components.poolTable.notFound.description.list":"Choose another chain or toggle Show All Markets","components.poolTable.externalApy.tooltipShort":"{value} APY boost when depositing via {name}","components.poolTable.line.rwa.tip":"This is RWA market.","components.rewardsTooltip.without.title":"Without Leverage","components.rewardsTooltip.without.extra":"Extra APY","components.rewardsTooltip.without.extra.tip":"Any deposit through Gearbox","components.rewardsTooltip.with.title":"With {leverage} Leverage","components.rewardsTooltip.with.borrowRate":"{symbol} borrow rate","components.rewardsTooltip.with.quotaRate":"Quota rate","components.rewardsTooltip.with.extra":"+ Extra APR","components.rewardsTooltip.button":"Click to show rewards details","components.strategiesTable.head.name":"Strategy","components.strategiesTable.head.rewards":"Rewards","components.strategiesTable.head.leverage":"Max Leverage","components.strategiesTable.head.earn":"You Can Earn","components.strategiesTable.body.notFound":"No strategy found","components.strategiesTable.line.disabled":"This strategy is currently not available, cause of lack or quota or liquidity. Please contact us on Discord, and we’ll assist you.","components.strategiesTable.line.name.disabled":"This strategy is currently not available","components.strategiesTable.line.points.tip":"For debt nominated in {symbol}","components.strategiesTable.line.points.tipAny":"For debt","components.strategiesTable.line.0slippage":"0-slippage","components.strategiesTable.line.0slippage.tip":"Wrapping/unwrapping happens directly through smart-contracts, so {symbol} deposits and withdrawals don't incur slippage.","components.strategiesTable.line.rwa":"RWA","components.strategiesTable.line.rwa.tip":"This strategy is available on RWA market.","dialogs.common.review":"Review","components.amountInput.max":"Max","components.amountInput.label":"Amount","components.amountInput.balance":"Balance","components.amountInput.selectToken":"Select token","components.amountInput.inputTitle":"Token Amount","components.leverageInput.label":"Leverage","components.leverageInput.reset":"Reset","components.leverageInput.available":"Available leverage","components.healthFactorBlock.label":"Health factor","components.healthFactorBlock.tip":"Health Factor is a numeric representation of your account 'health'. If your health factor drops below 1 or close to it, you might be liquidated.","components.liquidationPriceBlock.label":"Liquidation Price","components.liquidationPriceBlock.tip":"The asset price at which the account's health factor would reach 1 and become eligible for liquidation.","components.timeToLiquidationBlock.label":"Time to liquidation","components.timeToLiquidationBlock.tip":"Time to liquidation estimates how long the account can stay open if prices remain constant and no yield is earned—only accounting for borrow interest accrual.","components.historyChart.error":"Couldn't load chart data","components.historyChart.empty":"No data","components.positionTypeBadge.pool":"LP","components.positionTypeBadge.strategy":"Strategy","components.positionTypeBadge.liquidation":"Liquidation","components.positionStatusBadge.active":"Active","components.positionStatusBadge.repaid":"Repaid","components.titleMeta.unknownCurator":"Curator","components.moreAccordion.more":"More details","components.moreAccordion.less":"Less details","components.poolApyBreakdownCard.title":"Net APY","components.poolApyBreakdownCard.title7d":"Net APY (7d)","components.poolApyBreakdownCard.organicApy":"Base APY","components.poolApyBreakdownCard.organicApy7d":"Base APY (7d)","components.poolApyBreakdownCard.incentiveApy":"Incentive APY","components.poolApyBreakdownCard.incentiveApy7d":"Incentive APY (7d)","components.strategyApyBreakdownCard.formula":"{leverage} × {base}","components.strategyApyBreakdownCard.borrowFormula":"{debtMultiplier} × {borrowBase} + {quotaMultiplier} × {quotaBase}","components.leveragePresetChips.label":"Leverage:","components.liquidationParamsTable.lt":"Liquidation threshold","components.liquidationParamsTable.penalty":"Liquidation discount","components.liquidationParamsTable.premium":"Liquidation premium","components.liquidationParamsTable.fee":"Liquidation fee","components.borrowRateBlock.label":"Borrow rate","components.borrowRateBlock.tip":"Borrow rate is displayed for your entire position size in total. You can reduce it in quota management.","components.borrowRateBlock.description":"Your borrow rate consists of the Base Rate plus the Quota Rates for every asset separately.","components.borrowRateBlock.baseRate":"Base Rate for Debt","components.borrowRateBlock.normalization":"Rates normalization","components.borrowRateBlock.normalization.tip":"Borrowers pay {quota} and {utilization}, which have a different base. Therefore, the total borrow rate value is normalized by Account value or Debt amount.","components.transactionConfirm.previewLoading":"Parsing transaction…","components.transactionConfirm.previewErrorTitle":"Preview error"};module.exports=e;
1
+ "use strict";const e={"errors.networkError":"Network error. Can't fetch data","errors.incorrectAddressError":"Incorrect address. Please, check url","errors.noOpenedAccountsError":"You have no opened Credit Accounts. Perhaps, you have recently been liquidated? Check notification centre to see more.","errors.notFound":"Not found","errors.tooManyRequests":"Too many requests","errors.incorrectAddress":"Incorrect address","components.errorMessage.oops":"Oops...","components.networkIndicator.title":"Network","components.infiniteScrollWrapper.showMore":"Show more","components.alertModal.ok":"Ok","components.footer.privacy":"Privacy Notice","components.footer.terms":"Terms of Service","components.footer.disclosure":"Risk Disclosure Statement","components.footer.legalNotice":"Legal Notice","components.footer.legal":"Legal Info","components.footer.gearbox":"Copyright © Gearbox Foundation 2023-2026.","components.footer.built":"Built at ETHGlobal MarketMake hackathon.","components.footer.version":"Version {value}","components.sdkStatus.connecting":"Connecting…","components.sdkStatus.connected":"Connected","components.sdkStatus.disconnected":"Not connected","components.creditAccountHistory.table.protocol":"Protocol","components.creditAccountHistory.table.operation":"Operation","components.creditAccountHistory.table.details":"Details","components.notificationCenter.empty":"No notifications yet","components.notificationCenter.requests":"Requests","components.notificationCenter.recent":"Recent","components.notificationCenter.clear":"Clear all","components.liquidationPrice.check":"Check Area","components.loading.loading":"Loading","components.loading.loadingPercent":"Loading {percent}%","components.loading.wait":"Please wait...","components.smartNumberInput.balance":"Balance","components.smartNumberInput.amountLabel":"Amount","components.smartNumberInput.inputTitle":"Token Amount","components.smartNumberInput.confirm.input":"Input","components.smartNumberInput.selectToken":"Select token","components.tipWindow.title":"Tip","components.healthFactor.low":"Extremely low! This HF may not cover possible oracle deviations.","components.headCell":"Sort by {value}","components.graphView.noData":"Can't get data for this graph","components.filterBlock.reset":"Reset All","components.filterModal.searchPlaceholder":"Search options...","components.filterModal.noOptionsAvailable":"No options available","components.filterModal.noOptionsMatchSearch":"No options match your search","components.filterModal.reset":"Reset","components.filterModal.apply":"Apply","components.APY.tip":"These APYs are derived from the underlying protocols’ APIs and may differ in reality. Check respective protocols for their methodology.","components.creditSessionDetailedLiquidation.graph.noData":"No data","components.creditSessionDetailedLiquidation.graph.legend.point":"Current price","components.creditSessionDetailedLiquidation.graph.legend.area":"Liquidation Area","components.creditSessionDetailedLiquidation.graph.tip.hf":"Health Factor","components.creditSessionDetailedLiquidation.graph.tip.price":"Price","components.creditSessionDetailedLiquidation.table.noData":"No data","components.creditSessionDetailedLiquidation.table.seeGraph":"See graph","components.creditSessionDetailedLiquidation.table.asset":"Asset","components.creditSessionDetailedLiquidation.table.currentPrice":"Current price","components.creditSessionDetailedLiquidation.table.modelPrice":"Model price","components.apyParts.features.points":"Points","components.apyParts.features.incent":"Incent.","components.apyParts.supplyAPY":"Organic APY","components.apyParts.title":"APY type","components.apyParts.supplyAPY.tip":"Yield from lending funds","components.apyParts.tokenYield":"Intrinsic APY","components.apyParts.tokenYield.tip":"Yield from holding wstETH","components.apyParts.extraAPY":"{symbol} Incentive","components.apyParts.extraAPY.tip":"Calculated at the current rate","components.apyParts.totalAPY":"Overall APY","components.apyParts.points":"{symbol} Incentive","components.apyParts.points.condition.crossDeposit":"For cross-chain deposits made via Omni","components.yieldBreakdown.titleNetAtLeverage":"Net APY at {leverage}× Leverage","components.yieldBreakdown.titleNetAtLeverage7d":"Net APY at {leverage}× Leverage (7d)","components.yieldBreakdown.titleNet":"Net APY","components.yieldBreakdown.titleNet7d":"Net APY (7d)","components.yieldBreakdown.collateralApy":"Collateral APY","components.yieldBreakdown.collateralApy7d":"Collateral APY (7d)","components.yieldBreakdown.baseApy":"Base APY","components.yieldBreakdown.baseApy7d":"Base APY (7d)","components.yieldBreakdown.incentive":"Incentive","components.yieldBreakdown.incentiveApy":"Incentive APY","components.yieldBreakdown.incentiveApy7d":"Incentive APY (7d)","components.yieldBreakdown.borrowRate":"Borrow Rate","components.yieldBreakdown.borrowRate7d":"Borrow Rate (7d)","components.yieldBreakdown.programPoints":"{name} Points","components.yieldBreakdown.points":"Points","components.openCopyButtons.copy":"Copy to clipboard","components.openCopyButtons.explorer":"View in explorer","components.poolAssetsTable.asset":"Name","components.poolAssetsTable.rate":"Effective rate","components.poolAssetsTable.exposure":"Exposure","components.poolAssetsTable.cap":"Cap","components.poolAssetsTable.capUtilization":"Cap utilization","components.poolAssetsTable.usage":"{amount} of {total}","components.poolAssetsTable.head.name":"Credit Manager","components.poolAssetsTable.head.currentDebt":"Current Debt","components.poolAssetsTable.head.assets":"Asset LT","components.poolCreditManagersTable.assets":"{amount} assets","components.creditManagerInfo.title":"Assets and LT’s","components.creditManagerInfo.info.title":"Credit Managers","components.creditManagerInfo.info.copy.tip":"Copy Credit Manager address","components.creditManagerInfo.info.minDebt":"Min debt","components.creditManagerInfo.info.maxDebt":"Max debt","components.creditManagerInfo.info.liquidationFee":"Liquid. fee","components.creditManagerInfo.info.liquidationPremium":"Liquid. premium","components.creditManagerInfo.info.interestFee":"Interest fee","components.creditManagerInfo.info.debtLimit":"Debt limit","components.creditManagerInfo.info.maxEnabledTokens":"Max tokens","dialogs.oraclesAndLTInfo.filter.hide0Quota":"Hide 0-Quota","components.oraclesAndLTInfo.title":"Oracles and LTs","components.oraclesAndLTTable.head.token":"Token","components.oraclesAndLTTable.head.oracles":"Oracles","components.oraclesAndLTTable.head.lt":"LT","components.poolTable.pool":"Market","components.poolTable.market":"Market","components.poolTable.description.universal":"Universal","components.poolTable.supply":"Supply","components.poolTable.borrowed":"Borrowed","components.poolTable.supplyApy":"Supply APY","components.poolTable.supplyApy.tip":"Annual percentage yield that you earn for supplying capital. This number constantly changes as the utilization of the Markets goes up and down","components.poolTable.depositApy":"Deposit APY","components.poolTable.depositApy.tip":"Deposit APY breakdown: base rate, extra rewards, and points","components.poolTable.borrowApy":"Borrow APY","components.poolTable.utilizationApy":"Utilization APY","components.poolTable.borrowApy.tip":"On top of the utilization borrow APY, there is a borrow quota APY for different assets","components.poolTable.utilization":"Utilization","components.poolTable.collateral":"Collateral","components.poolTable.collateral.showAll":"Show All","components.poolTable.balance":"Your Balance","components.poolTable.balance.tip":`You don't earn token rewards, only organic yield. Please migrate liquidity by using "Migrate" flow above.`,"components.poolTable.emptyList":"No Pools found","components.poolTable.notFound.dashboard":"You currently have no open Market positions.","components.poolTable.notFound.list":"No Markets found","components.poolTable.notFound.description.dashboard":"Choose earn above.","components.poolTable.notFound.description.list":"Choose another chain or toggle Show All Markets","components.poolTable.externalApy.tooltipShort":"{value} APY boost when depositing via {name}","components.poolTable.line.rwa.tip":"This is RWA market.","components.rewardsTooltip.without.title":"Without Leverage","components.rewardsTooltip.without.extra":"Extra APY","components.rewardsTooltip.without.extra.tip":"Any deposit through Gearbox","components.rewardsTooltip.with.title":"With {leverage} Leverage","components.rewardsTooltip.with.borrowRate":"{symbol} borrow rate","components.rewardsTooltip.with.quotaRate":"Quota rate","components.rewardsTooltip.with.extra":"+ Extra APR","components.rewardsTooltip.button":"Click to show rewards details","components.strategiesTable.head.name":"Strategy","components.strategiesTable.head.rewards":"Rewards","components.strategiesTable.head.leverage":"Max Leverage","components.strategiesTable.head.earn":"You Can Earn","components.strategiesTable.body.notFound":"No strategy found","components.strategiesTable.line.disabled":"This strategy is currently not available, cause of lack or quota or liquidity. Please contact us on Discord, and we’ll assist you.","components.strategiesTable.line.name.disabled":"This strategy is currently not available","components.strategiesTable.line.points.tip":"For debt nominated in {symbol}","components.strategiesTable.line.points.tipAny":"For debt","components.strategiesTable.line.0slippage":"0-slippage","components.strategiesTable.line.0slippage.tip":"Wrapping/unwrapping happens directly through smart-contracts, so {symbol} deposits and withdrawals don't incur slippage.","components.strategiesTable.line.rwa":"RWA","components.strategiesTable.line.rwa.tip":"This strategy is available on RWA market.","dialogs.common.review":"Review","components.amountInput.max":"Max","components.amountInput.label":"Amount","components.amountInput.balance":"Balance","components.amountInput.selectToken":"Select token","components.amountInput.inputTitle":"Token Amount","components.leverageInput.label":"Leverage","components.leverageInput.reset":"Reset","components.leverageInput.available":"Available leverage","components.healthFactorBlock.label":"Health factor","components.healthFactorBlock.tip":"Health Factor is a numeric representation of your account 'health'. If your health factor drops below 1 or close to it, you might be liquidated.","components.liquidationPriceBlock.label":"Liquidation Price","components.liquidationPriceBlock.tip":"The asset price at which the account's health factor would reach 1 and become eligible for liquidation.","components.timeToLiquidationBlock.label":"Time to liquidation","components.timeToLiquidationBlock.tip":"Time to liquidation estimates how long the account can stay open if prices remain constant and no yield is earned—only accounting for borrow interest accrual.","components.historyChart.error":"Couldn't load chart data","components.historyChart.empty":"No data","components.positionTypeBadge.pool":"LP","components.positionTypeBadge.strategy":"Strategy","components.positionTypeBadge.liquidation":"Liquidation","components.positionStatusBadge.active":"Active","components.positionStatusBadge.repaid":"Repaid","components.titleMeta.unknownCurator":"Curator","components.moreAccordion.more":"More details","components.moreAccordion.less":"Less details","components.poolApyBreakdownCard.title":"Net APY","components.poolApyBreakdownCard.title7d":"Net APY (7d)","components.poolApyBreakdownCard.organicApy":"Base APY","components.poolApyBreakdownCard.organicApy7d":"Base APY (7d)","components.poolApyBreakdownCard.incentiveApy":"Incentive APY","components.poolApyBreakdownCard.incentiveApy7d":"Incentive APY (7d)","components.strategyApyBreakdownCard.formula":"{leverage} × {base}","components.strategyApyBreakdownCard.borrowFormula":"{leverage} × ({borrowRate} + {quotaRate}) − {borrowRate}","components.leveragePresetChips.label":"Leverage:","components.liquidationParamsTable.lt":"Liquidation threshold","components.liquidationParamsTable.penalty":"Liquidation discount","components.liquidationParamsTable.premium":"Liquidation premium","components.liquidationParamsTable.fee":"Liquidation fee","components.borrowRateBlock.label":"Borrow rate","components.borrowRateBlock.tip":"Borrow rate is displayed for your entire position size in total. You can reduce it in quota management.","components.borrowRateBlock.description":"Your borrow rate consists of the Base Rate plus the Quota Rates for every asset separately.","components.borrowRateBlock.baseRate":"Base Rate for Debt","components.borrowRateBlock.normalization":"Rates normalization","components.borrowRateBlock.normalization.tip":"Borrowers pay {quota} and {utilization}, which have a different base. Therefore, the total borrow rate value is normalized by Account value or Debt amount.","components.transactionConfirm.previewLoading":"Parsing transaction…","components.transactionConfirm.previewErrorTitle":"Preview error"};module.exports=e;
@@ -1,83 +1,105 @@
1
- import { jsxs as d, jsx as t, Fragment as b } from "react/jsx-runtime";
2
- import { ApyBreakdownBody as B, formatBreakdownRate as n, ApyBreakdownRow as m, periodMessageId as y, ApyBreakdownDivider as T, BREAKDOWN_DASH as h } from "../apy-breakdown-body/apy-breakdown-body.js";
3
- import { PointsIcon as x } from "../../points-icon/points-icon.js";
4
- import { TokenIcon as C } from "../../token-icon/token-icon.js";
5
- import { FormattedMessageTyped as s } from "../../typed-intl/index.js";
6
- import { totalApyOf as N, positiveTokenRewardsOf as R, pointProgramsOf as P } from "../../../utils/apy-breakdown.js";
7
- import { formatLeverage as l } from "../../../utils/format-leverage.js";
8
- import { StrategyApyBreakdownCardTest as o } from "./constants.js";
9
- function E({
10
- data: r,
11
- showFormula: p = !1,
1
+ import { jsxs as m, jsx as t, Fragment as N } from "react/jsx-runtime";
2
+ import { calcNetStrategyApy as T, calcEffectiveBorrowApy as C } from "@gearbox-protocol/sdk/onchain";
3
+ import { ApyBreakdownBody as D, formatBreakdownRate as l, ApyBreakdownRow as y, periodMessageId as k, ApyBreakdownDivider as P, BREAKDOWN_DASH as q } from "../apy-breakdown-body/apy-breakdown-body.js";
4
+ import { PointsIcon as O } from "../../points-icon/points-icon.js";
5
+ import { TokenIcon as S } from "../../token-icon/token-icon.js";
6
+ import { FormattedMessageTyped as r } from "../../typed-intl/index.js";
7
+ import { totalApyOf as L, positiveTokenRewardsOf as M, pointProgramsOf as $ } from "../../../utils/apy-breakdown.js";
8
+ import { formatLeverage as d } from "../../../utils/format-leverage.js";
9
+ import { StrategyApyBreakdownCardTest as a } from "./constants.js";
10
+ function j(p) {
11
+ const { borrowApyAvg7D: o, quotaRateAvg7D: i, liquidationThreshold: c } = p;
12
+ return o === void 0 || i === void 0 ? null : {
13
+ borrowApy: o,
14
+ quotaRate: i,
15
+ liquidationThreshold: c
16
+ };
17
+ }
18
+ function J({
19
+ data: p,
20
+ leverage: o,
21
+ showFormula: i = !1,
12
22
  period: c
13
23
  }) {
14
- const { leverage: a, collateralApy: i } = r, u = N(r.netApy), f = u + r.borrowCost, w = i ? R(i) : [], g = i ? P(i) : [], k = w.map((e) => ({
24
+ const n = j(p), s = n && p.collateralApyAvg7D ? p.collateralApyAvg7D : void 0, u = n !== null && s !== void 0, h = u && n && s ? {
25
+ organicApy: T(
26
+ n,
27
+ s.organicApy,
28
+ o
29
+ ),
30
+ totalApy: T(
31
+ n,
32
+ s.totalApy ?? s.organicApy,
33
+ o
34
+ ),
35
+ ...s.rewards ? { rewards: s.rewards } : {}
36
+ } : { organicApy: 0, totalApy: 0 }, A = u && n ? C(n, o) : 0, v = L(h), R = v + A, x = s ? M(s) : [], g = s ? $(s) : [], b = x.map((e) => ({
15
37
  reward: e,
16
- value: Math.round(a * (e.supplyApr ?? 0))
17
- })), I = f - k.reduce((e, v) => e + v.value, 0), A = a > 0 ? I / a : void 0;
18
- return /* @__PURE__ */ d(
19
- B,
38
+ value: Math.round(o * (e.supplyApr ?? 0))
39
+ })), f = R - b.reduce((e, w) => e + w.value, 0), I = o > 0 ? f / o : void 0, B = u && n && o > 0 ? (A - n.borrowApy * (o - 1)) / o : void 0;
40
+ return /* @__PURE__ */ m(
41
+ D,
20
42
  {
21
- testId: o.root,
43
+ testId: a.root,
22
44
  title: /* @__PURE__ */ t(
23
- s,
45
+ r,
24
46
  {
25
- messageId: y(
47
+ messageId: k(
26
48
  c,
27
49
  "components.yieldBreakdown.titleNetAtLeverage",
28
50
  "components.yieldBreakdown.titleNetAtLeverage7d"
29
51
  ),
30
- values: { leverage: l(a) }
52
+ values: { leverage: d(o) }
31
53
  }
32
54
  ),
33
- chip: n(u),
34
- chipPositive: u > 0,
35
- chipTestId: o.net,
55
+ chip: l(v),
56
+ chipPositive: v > 0,
57
+ chipTestId: a.net,
36
58
  children: [
37
59
  /* @__PURE__ */ t(
38
- m,
60
+ y,
39
61
  {
40
- testId: o.collateral,
41
- valueTestId: o.value,
42
- captionTestId: o.caption,
62
+ testId: a.collateral,
63
+ valueTestId: a.value,
64
+ captionTestId: a.caption,
43
65
  label: /* @__PURE__ */ t(
44
- s,
66
+ r,
45
67
  {
46
- messageId: y(
68
+ messageId: k(
47
69
  c,
48
70
  "components.yieldBreakdown.collateralApy",
49
71
  "components.yieldBreakdown.collateralApy7d"
50
72
  )
51
73
  }
52
74
  ),
53
- value: n(I),
54
- subtext: p && A !== void 0 ? /* @__PURE__ */ t(
55
- s,
75
+ value: l(f),
76
+ subtext: i && I !== void 0 ? /* @__PURE__ */ t(
77
+ r,
56
78
  {
57
79
  messageId: "components.strategyApyBreakdownCard.formula",
58
80
  values: {
59
- leverage: l(a),
60
- base: n(A)
81
+ leverage: d(o),
82
+ base: l(I)
61
83
  }
62
84
  }
63
85
  ) : void 0
64
86
  }
65
87
  ),
66
- k.map(({ reward: e, value: v }) => /* @__PURE__ */ t(
67
- m,
88
+ b.map(({ reward: e, value: w }) => /* @__PURE__ */ t(
89
+ y,
68
90
  {
69
- valueTestId: o.value,
70
- captionTestId: o.caption,
71
- label: /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1.5", children: [
91
+ valueTestId: a.value,
92
+ captionTestId: a.caption,
93
+ label: /* @__PURE__ */ m("span", { className: "inline-flex items-center gap-1.5", children: [
72
94
  /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
73
- s,
95
+ r,
74
96
  {
75
97
  messageId: "components.apyParts.extraAPY",
76
98
  values: { symbol: e.token.symbol }
77
99
  }
78
100
  ) }),
79
101
  /* @__PURE__ */ t(
80
- C,
102
+ S,
81
103
  {
82
104
  token: e.token,
83
105
  symbol: e.token.symbol,
@@ -86,14 +108,14 @@ function E({
86
108
  }
87
109
  )
88
110
  ] }),
89
- value: n(v),
90
- subtext: p ? /* @__PURE__ */ t(
91
- s,
111
+ value: l(w),
112
+ subtext: i ? /* @__PURE__ */ t(
113
+ r,
92
114
  {
93
115
  messageId: "components.strategyApyBreakdownCard.formula",
94
116
  values: {
95
- leverage: l(a),
96
- base: n(e.supplyApr ?? 0)
117
+ leverage: d(o),
118
+ base: l(e.supplyApr ?? 0)
97
119
  }
98
120
  }
99
121
  ) : void 0
@@ -101,41 +123,56 @@ function E({
101
123
  `incentive-${e.token.address}-${e.supplyApr ?? 0}`
102
124
  )),
103
125
  /* @__PURE__ */ t(
104
- m,
126
+ y,
105
127
  {
106
128
  muted: !0,
107
- testId: o.borrow,
108
- valueTestId: o.value,
129
+ testId: a.borrow,
130
+ valueTestId: a.value,
131
+ captionTestId: a.caption,
109
132
  label: /* @__PURE__ */ t(
110
- s,
133
+ r,
111
134
  {
112
- messageId: y(
135
+ messageId: k(
113
136
  c,
114
137
  "components.yieldBreakdown.borrowRate",
115
138
  "components.yieldBreakdown.borrowRate7d"
116
139
  )
117
140
  }
118
141
  ),
119
- value: n(-r.borrowCost)
142
+ value: l(-A),
143
+ subtext: i && n && B !== void 0 ? /* @__PURE__ */ t(
144
+ r,
145
+ {
146
+ messageId: "components.strategyApyBreakdownCard.borrowFormula",
147
+ values: {
148
+ leverage: d(o),
149
+ // Magnitudes, not signed rates: the row above already carries
150
+ // the minus, and `− (−0.88%)` reads as arithmetic to decode
151
+ // rather than a cost to understand.
152
+ borrowRate: l(n.borrowApy),
153
+ quotaRate: l(B)
154
+ }
155
+ }
156
+ ) : void 0
120
157
  }
121
158
  ),
122
- g.length > 0 ? /* @__PURE__ */ d(b, { children: [
123
- /* @__PURE__ */ t(T, {}),
159
+ g.length > 0 ? /* @__PURE__ */ m(N, { children: [
160
+ /* @__PURE__ */ t(P, {}),
124
161
  g.map((e) => /* @__PURE__ */ t(
125
- m,
162
+ y,
126
163
  {
127
- valueTestId: o.points,
128
- captionTestId: o.caption,
129
- label: /* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1.5", children: [
164
+ valueTestId: a.points,
165
+ captionTestId: a.caption,
166
+ label: /* @__PURE__ */ m("span", { className: "inline-flex items-center gap-1.5", children: [
130
167
  /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
131
- s,
168
+ r,
132
169
  {
133
170
  messageId: "components.yieldBreakdown.programPoints",
134
171
  values: { name: e.name }
135
172
  }
136
173
  ) }),
137
174
  /* @__PURE__ */ t(
138
- x,
175
+ O,
139
176
  {
140
177
  reward: { name: e.name, type: e.id },
141
178
  size: 16,
@@ -143,14 +180,14 @@ function E({
143
180
  }
144
181
  )
145
182
  ] }),
146
- value: e.multiplier != null ? `${l(e.multiplier * a)}×` : h,
147
- subtext: p && e.multiplier != null ? /* @__PURE__ */ t(
148
- s,
183
+ value: e.multiplier != null ? `${d(e.multiplier * o)}×` : q,
184
+ subtext: i && e.multiplier != null ? /* @__PURE__ */ t(
185
+ r,
149
186
  {
150
187
  messageId: "components.strategyApyBreakdownCard.formula",
151
188
  values: {
152
- leverage: l(a),
153
- base: l(e.multiplier)
189
+ leverage: d(o),
190
+ base: d(e.multiplier)
154
191
  }
155
192
  }
156
193
  ) : void 0
@@ -163,6 +200,6 @@ function E({
163
200
  );
164
201
  }
165
202
  export {
166
- E as StrategyApyBreakdownCard,
167
- o as StrategyApyBreakdownCardTest
203
+ J as StrategyApyBreakdownCard,
204
+ a as StrategyApyBreakdownCardTest
168
205
  };