@gearbox-protocol/ui-kit 4.0.0-next.77 → 4.0.0-next.78

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"),o=require("../../../utils/cn.cjs"),l=require("../../../utils/internal/bps-to-percent.cjs"),c="—",u="400px";function x(s,n,t){return s==="7d"?t:n}function m(s,n=!1){const t=l.bpsToPercent(s),d=`${Math.abs(t).toFixed(2)}%`;return n&&t<0?`−${d}`:d}function f({title:s,chip:n,chipPositive:t=!1,chipTestId:d,children:r,testId:a}){return e.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4","data-testid":a,children:[e.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 text-base font-semibold leading-5 text-foreground",children:s}),e.jsx("span",{className:o.cn("shrink-0 rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",t?"bg-success/20 text-success":"bg-muted text-muted-foreground"),"data-testid":d,children:n})]}),e.jsx("div",{className:"flex flex-col gap-3",children:r})]})}function p({label:s,value:n,subtext:t,muted:d=!1,testId:r,valueTestId:a,captionTestId:i}){return e.jsxs("div",{className:"flex items-start justify-between gap-3","data-testid":r,children:[e.jsx("span",{className:o.cn("min-w-0 text-sm font-semibold leading-5",d?"text-muted-foreground":"text-foreground"),children:s}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end",children:[e.jsx("span",{className:o.cn("text-sm font-semibold leading-5 tabular-nums",d?"text-muted-foreground":"text-foreground"),"data-testid":a,children:n}),t!=null?e.jsx("span",{className:"text-xs leading-4 text-muted-foreground","data-testid":i,children:t}):null]})]})}function g(){return e.jsx("div",{className:"h-px w-full bg-divider"})}exports.APY_BREAKDOWN_TOOLTIP_WIDTH=u;exports.ApyBreakdownBody=f;exports.ApyBreakdownDivider=g;exports.ApyBreakdownRow=p;exports.BREAKDOWN_DASH=c;exports.formatBreakdownRate=m;exports.periodMessageId=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("../../../utils/cn.cjs"),i=require("../../../utils/internal/bps-to-percent.cjs"),c="—",u="400px";function x(t,n,s){return t==="7d"?s:n}function m(t,n=!1){const s=i.bpsToPercent(t),a=`${Math.abs(s).toFixed(2)}%`;return n&&s<0?`−${a}`:a}function f(t){return Number(Math.abs(i.bpsToPercent(t)).toFixed(2))}function p({title:t,chip:n,chipPositive:s=!1,chipTestId:a,children:r,testId:d}){return e.jsxs("div",{className:"flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4","data-testid":d,children:[e.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 text-base font-semibold leading-5 text-foreground",children:t}),e.jsx("span",{className:o.cn("shrink-0 rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",s?"bg-success/20 text-success":"bg-muted text-muted-foreground"),"data-testid":a,children:n})]}),e.jsx("div",{className:"flex flex-col gap-3",children:r})]})}function b({label:t,value:n,subtext:s,muted:a=!1,testId:r,valueTestId:d,captionTestId:l}){return e.jsxs("div",{className:"flex items-start justify-between gap-3","data-testid":r,children:[e.jsx("span",{className:o.cn("min-w-0 text-sm font-semibold leading-5",a?"text-muted-foreground":"text-foreground"),children:t}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end",children:[e.jsx("span",{className:o.cn("text-sm font-semibold leading-5 tabular-nums",a?"text-muted-foreground":"text-foreground"),"data-testid":d,children:n}),s!=null?e.jsx("span",{className:"text-xs leading-4 text-muted-foreground","data-testid":l,children:s}):null]})]})}function g(){return e.jsx("div",{className:"h-px w-full bg-divider"})}exports.APY_BREAKDOWN_TOOLTIP_WIDTH=u;exports.ApyBreakdownBody=p;exports.ApyBreakdownDivider=g;exports.ApyBreakdownRow=b;exports.BREAKDOWN_DASH=c;exports.breakdownRateValue=f;exports.formatBreakdownRate=m;exports.periodMessageId=x;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./apy-breakdown-body.cjs");exports.APY_BREAKDOWN_TOOLTIP_WIDTH=e.APY_BREAKDOWN_TOOLTIP_WIDTH;exports.ApyBreakdownBody=e.ApyBreakdownBody;exports.ApyBreakdownDivider=e.ApyBreakdownDivider;exports.ApyBreakdownRow=e.ApyBreakdownRow;exports.BREAKDOWN_DASH=e.BREAKDOWN_DASH;exports.formatBreakdownRate=e.formatBreakdownRate;exports.periodMessageId=e.periodMessageId;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./apy-breakdown-body.cjs");exports.APY_BREAKDOWN_TOOLTIP_WIDTH=e.APY_BREAKDOWN_TOOLTIP_WIDTH;exports.ApyBreakdownBody=e.ApyBreakdownBody;exports.ApyBreakdownDivider=e.ApyBreakdownDivider;exports.ApyBreakdownRow=e.ApyBreakdownRow;exports.BREAKDOWN_DASH=e.BREAKDOWN_DASH;exports.breakdownRateValue=e.breakdownRateValue;exports.formatBreakdownRate=e.formatBreakdownRate;exports.periodMessageId=e.periodMessageId;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("@gearbox-protocol/sdk/onchain"),o=require("../apy-breakdown-body/apy-breakdown-body.cjs"),A=require("../../no-value/no-value.cjs"),C=require("../../points-icon/points-icon.cjs"),R=require("../../token-icon/token-icon.cjs"),d=require("../../typed-intl/index.cjs"),c=require("../../../utils/format-leverage.cjs"),k=require("../../../utils/internal/apy-breakdown.cjs"),r=require("./constants.cjs");function S(i){const{borrowApyAvg7D:a,quotaRateAvg7D:p,liquidationThreshold:l}=i;return a===void 0||p===void 0?null:{borrowApy:a,quotaRate:p,liquidationThreshold:l}}function _({data:i,leverage:a,showFormula:p=!1,period:l}){const s=S(i),n=s&&i.collateralApyAvg7D?i.collateralApyAvg7D:void 0,B=s!==null&&n!==void 0,v=B&&s&&n?{organicApy:g.calcNetStrategyApy(s,n.organicApy,a),totalApy:g.calcNetStrategyApy(s,n.totalApy??n.organicApy,a),...n.rewards?{rewards:n.rewards}:{}}:null,y=B&&s?g.calcEffectiveBorrowApy(s,a):null,u=v===null?null:k.totalApyOf(v),x=u===null||y===null?null:u+y,j=n?k.positiveTokenRewardsOf(n):[],T=n?k.pointProgramsOf(n):[],f=j.map(t=>({reward:t,value:Math.round(a*(t.supplyApr??0))})),m=x===null?null:x-f.reduce((t,w)=>t+w.value,0),I=m!==null&&a>0?m/a:void 0,b=s&&y!==null&&a>0?(y-s.borrowApy*(a-1))/a:void 0;return e.jsxs(o.ApyBreakdownBody,{testId:r.StrategyApyBreakdownCardTest.root,title:e.jsx(d.FormattedMessageTyped,{messageId:o.periodMessageId(l,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:c.formatLeverage(a)}}),chip:u===null?e.jsx(A.NoValue,{reason:l}):o.formatBreakdownRate(u,!0),chipPositive:(u??0)>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(l,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:m===null?e.jsx(A.NoValue,{reason:l}):o.formatBreakdownRate(m),subtext:p&&I!==void 0?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:c.formatLeverageExact(a),base:o.formatBreakdownRate(I)}}):void 0}),f.map(({reward:t,value:w})=>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(R.TokenIcon,{token:t.token,symbol:t.token.symbol,size:16,className:"shrink-0"})]}),value:o.formatBreakdownRate(w),subtext:p?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:c.formatLeverageExact(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(l,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:y===null?e.jsx(A.NoValue,{reason:l}):o.formatBreakdownRate(y),subtext:p&&s&&b!==void 0?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.borrowFormula",values:{leverage:c.formatLeverageExact(a),totalRate:o.formatBreakdownRate(s.borrowApy+b),borrowRate:o.formatBreakdownRate(s.borrowApy)}}):void 0}),T.length>0?e.jsxs(e.Fragment,{children:[e.jsx(o.ApyBreakdownDivider,{}),T.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(C.PointsIcon,{reward:{name:t.name,type:t.id},size:16,className:"shrink-0"})]}),value:t.multiplier!=null?`${c.formatLeverageExact(t.multiplier*a)}×`:o.BREAKDOWN_DASH,subtext:p&&t.multiplier!=null?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:c.formatLeverageExact(a),base:c.formatLeverageExact(t.multiplier)}}):void 0},t.id))]}):null]})}exports.StrategyApyBreakdownCardTest=r.StrategyApyBreakdownCardTest;exports.StrategyApyBreakdownCard=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("@gearbox-protocol/sdk/onchain"),o=require("../apy-breakdown-body/apy-breakdown-body.cjs"),v=require("../../no-value/no-value.cjs"),M=require("../../points-icon/points-icon.cjs"),h=require("../../token-icon/token-icon.cjs"),i=require("../../typed-intl/index.cjs"),p=require("../../../utils/format-leverage.cjs"),B=require("../../../utils/internal/apy-breakdown.cjs"),r=require("./constants.cjs");function q(y){const{borrowApyAvg7D:t,quotaRateAvg7D:l,liquidationThreshold:s}=y;return t===void 0||l===void 0?null:{borrowApy:t,quotaRate:l,liquidationThreshold:s}}function N(y,t,l){const s=o.breakdownRateValue(y),n=l-t*s;return n>0&&t>0?s+Math.ceil(n/t*100)/100:s}function L({data:y,leverage:t,showFormula:l=!1,period:s}){const n=q(y),d=n&&y.collateralApyAvg7D?y.collateralApyAvg7D:void 0,x=n!==null&&d!==void 0,T=x&&n&&d?{organicApy:k.calcNetStrategyApy(n,d.organicApy,t),totalApy:k.calcNetStrategyApy(n,d.totalApy??d.organicApy,t),...d.rewards?{rewards:d.rewards}:{}}:null,c=x&&n?k.calcEffectiveBorrowApy(n,t):null,u=T===null?null:B.totalApyOf(T),b=u===null||c===null?null:u+c,_=d?B.positiveTokenRewardsOf(d):[],f=d?B.pointProgramsOf(d):[],I=_.map(a=>({reward:a,value:Math.round(t*(a.supplyApr??0))})),m=b===null?null:b-I.reduce((a,A)=>a+A.value,0),j=m!==null&&t>0?m/t:void 0,R=n&&c!==null&&t>0?(c-n.borrowApy*(t-1))/t:void 0,C=Number(p.formatLeverageExact(t)),w=c===null?void 0:o.breakdownRateValue(c),g=n&&R!==void 0&&w!==void 0?N(n.borrowApy+R,C,w):void 0,S=g!==void 0&&w!==void 0?C*g-w:void 0;return e.jsxs(o.ApyBreakdownBody,{testId:r.StrategyApyBreakdownCardTest.root,title:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:p.formatLeverage(t)}}),chip:u===null?e.jsx(v.NoValue,{reason:s}):o.formatBreakdownRate(u,!0),chipPositive:(u??0)>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(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:m===null?e.jsx(v.NoValue,{reason:s}):o.formatBreakdownRate(m),subtext:l&&j!==void 0?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:o.formatBreakdownRate(j)}}):void 0}),I.map(({reward:a,value:A})=>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(i.FormattedMessageTyped,{messageId:"components.apyParts.extraAPY",values:{symbol:a.token.symbol}})}),e.jsx(h.TokenIcon,{token:a.token,symbol:a.token.symbol,size:16,className:"shrink-0"})]}),value:o.formatBreakdownRate(A),subtext:l?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:o.formatBreakdownRate(a.supplyApr??0)}}):void 0},`incentive-${a.token.address}-${a.supplyApr??0}`)),e.jsx(o.ApyBreakdownRow,{muted:!0,testId:r.StrategyApyBreakdownCardTest.borrow,valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsx(i.FormattedMessageTyped,{messageId:o.periodMessageId(s,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:c===null?e.jsx(v.NoValue,{reason:s}):o.formatBreakdownRate(c),subtext:l&&g!==void 0&&S!==void 0?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.borrowFormula",values:{leverage:p.formatLeverageExact(t),totalRate:`${g.toFixed(2)}%`,borrowRate:`${Math.abs(S).toFixed(2)}%`}}):void 0}),f.length>0?e.jsxs(e.Fragment,{children:[e.jsx(o.ApyBreakdownDivider,{}),f.map(a=>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(i.FormattedMessageTyped,{messageId:"components.yieldBreakdown.programPoints",values:{name:a.name}})}),e.jsx(M.PointsIcon,{reward:{name:a.name,type:a.id},size:16,className:"shrink-0"})]}),value:a.multiplier!=null?`${p.formatLeverageExact(a.multiplier*t)}×`:o.BREAKDOWN_DASH,subtext:l&&a.multiplier!=null?e.jsx(i.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverageExact(t),base:p.formatLeverageExact(a.multiplier)}}):void 0},a.id))]}):null]})}exports.StrategyApyBreakdownCardTest=r.StrategyApyBreakdownCardTest;exports.StrategyApyBreakdownCard=L;
@@ -1,77 +1,80 @@
1
- import { jsxs as a, jsx as d } from "react/jsx-runtime";
2
- import { cn as l } from "../../../utils/cn.js";
3
- import { bpsToPercent as c } from "../../../utils/internal/bps-to-percent.js";
1
+ import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
+ import { cn as i } from "../../../utils/cn.js";
3
+ import { bpsToPercent as l } from "../../../utils/internal/bps-to-percent.js";
4
4
  const x = "—", p = "400px";
5
- function g(t, n, e) {
6
- return t === "7d" ? e : n;
5
+ function b(e, n, t) {
6
+ return e === "7d" ? t : n;
7
7
  }
8
- function b(t, n = !1) {
9
- const e = c(t), s = `${Math.abs(e).toFixed(2)}%`;
10
- return n && e < 0 ? `−${s}` : s;
8
+ function g(e, n = !1) {
9
+ const t = l(e), s = `${Math.abs(t).toFixed(2)}%`;
10
+ return n && t < 0 ? `−${s}` : s;
11
11
  }
12
- function h({
13
- title: t,
12
+ function h(e) {
13
+ return Number(Math.abs(l(e)).toFixed(2));
14
+ }
15
+ function N({
16
+ title: e,
14
17
  chip: n,
15
- chipPositive: e = !1,
18
+ chipPositive: t = !1,
16
19
  chipTestId: s,
17
20
  children: r,
18
21
  testId: o
19
22
  }) {
20
- return /* @__PURE__ */ a(
23
+ return /* @__PURE__ */ d(
21
24
  "div",
22
25
  {
23
26
  className: "flex w-full min-w-0 flex-col gap-4 rounded-xl border border-border bg-card p-4",
24
27
  "data-testid": o,
25
28
  children: [
26
- /* @__PURE__ */ a("div", { className: "flex min-h-6 items-center justify-between gap-3", children: [
27
- /* @__PURE__ */ d("span", { className: "min-w-0 text-base font-semibold leading-5 text-foreground", children: t }),
28
- /* @__PURE__ */ d(
29
+ /* @__PURE__ */ d("div", { className: "flex min-h-6 items-center justify-between gap-3", children: [
30
+ /* @__PURE__ */ a("span", { className: "min-w-0 text-base font-semibold leading-5 text-foreground", children: e }),
31
+ /* @__PURE__ */ a(
29
32
  "span",
30
33
  {
31
- className: l(
34
+ className: i(
32
35
  "shrink-0 rounded-md px-2 py-0.5 text-sm font-semibold tabular-nums",
33
- e ? "bg-success/20 text-success" : "bg-muted text-muted-foreground"
36
+ t ? "bg-success/20 text-success" : "bg-muted text-muted-foreground"
34
37
  ),
35
38
  "data-testid": s,
36
39
  children: n
37
40
  }
38
41
  )
39
42
  ] }),
40
- /* @__PURE__ */ d("div", { className: "flex flex-col gap-3", children: r })
43
+ /* @__PURE__ */ a("div", { className: "flex flex-col gap-3", children: r })
41
44
  ]
42
45
  }
43
46
  );
44
47
  }
45
- function N({
46
- label: t,
48
+ function w({
49
+ label: e,
47
50
  value: n,
48
- subtext: e,
51
+ subtext: t,
49
52
  muted: s = !1,
50
53
  testId: r,
51
54
  valueTestId: o,
52
- captionTestId: i
55
+ captionTestId: c
53
56
  }) {
54
- return /* @__PURE__ */ a(
57
+ return /* @__PURE__ */ d(
55
58
  "div",
56
59
  {
57
60
  className: "flex items-start justify-between gap-3",
58
61
  "data-testid": r,
59
62
  children: [
60
- /* @__PURE__ */ d(
63
+ /* @__PURE__ */ a(
61
64
  "span",
62
65
  {
63
- className: l(
66
+ className: i(
64
67
  "min-w-0 text-sm font-semibold leading-5",
65
68
  s ? "text-muted-foreground" : "text-foreground"
66
69
  ),
67
- children: t
70
+ children: e
68
71
  }
69
72
  ),
70
- /* @__PURE__ */ a("span", { className: "flex shrink-0 flex-col items-end", children: [
71
- /* @__PURE__ */ d(
73
+ /* @__PURE__ */ d("span", { className: "flex shrink-0 flex-col items-end", children: [
74
+ /* @__PURE__ */ a(
72
75
  "span",
73
76
  {
74
- className: l(
77
+ className: i(
75
78
  "text-sm font-semibold leading-5 tabular-nums",
76
79
  s ? "text-muted-foreground" : "text-foreground"
77
80
  ),
@@ -79,12 +82,12 @@ function N({
79
82
  children: n
80
83
  }
81
84
  ),
82
- e != null ? /* @__PURE__ */ d(
85
+ t != null ? /* @__PURE__ */ a(
83
86
  "span",
84
87
  {
85
88
  className: "text-xs leading-4 text-muted-foreground",
86
- "data-testid": i,
87
- children: e
89
+ "data-testid": c,
90
+ children: t
88
91
  }
89
92
  ) : null
90
93
  ] })
@@ -92,15 +95,16 @@ function N({
92
95
  }
93
96
  );
94
97
  }
95
- function w() {
96
- return /* @__PURE__ */ d("div", { className: "h-px w-full bg-divider" });
98
+ function y() {
99
+ return /* @__PURE__ */ a("div", { className: "h-px w-full bg-divider" });
97
100
  }
98
101
  export {
99
102
  p as APY_BREAKDOWN_TOOLTIP_WIDTH,
100
- h as ApyBreakdownBody,
101
- w as ApyBreakdownDivider,
102
- N as ApyBreakdownRow,
103
+ N as ApyBreakdownBody,
104
+ y as ApyBreakdownDivider,
105
+ w as ApyBreakdownRow,
103
106
  x as BREAKDOWN_DASH,
104
- b as formatBreakdownRate,
105
- g as periodMessageId
107
+ h as breakdownRateValue,
108
+ g as formatBreakdownRate,
109
+ b as periodMessageId
106
110
  };
@@ -1,10 +1,11 @@
1
- import { APY_BREAKDOWN_TOOLTIP_WIDTH as r, ApyBreakdownBody as d, ApyBreakdownDivider as a, ApyBreakdownRow as A, BREAKDOWN_DASH as B, formatBreakdownRate as p, periodMessageId as w } from "./apy-breakdown-body.js";
1
+ import { APY_BREAKDOWN_TOOLTIP_WIDTH as a, ApyBreakdownBody as r, ApyBreakdownDivider as d, ApyBreakdownRow as A, BREAKDOWN_DASH as B, breakdownRateValue as w, formatBreakdownRate as k, periodMessageId as n } from "./apy-breakdown-body.js";
2
2
  export {
3
- r as APY_BREAKDOWN_TOOLTIP_WIDTH,
4
- d as ApyBreakdownBody,
5
- a as ApyBreakdownDivider,
3
+ a as APY_BREAKDOWN_TOOLTIP_WIDTH,
4
+ r as ApyBreakdownBody,
5
+ d as ApyBreakdownDivider,
6
6
  A as ApyBreakdownRow,
7
7
  B as BREAKDOWN_DASH,
8
- p as formatBreakdownRate,
9
- w as periodMessageId
8
+ w as breakdownRateValue,
9
+ k as formatBreakdownRate,
10
+ n as periodMessageId
10
11
  };
@@ -1,199 +1,204 @@
1
- import { jsxs as A, jsx as e, Fragment as C } from "react/jsx-runtime";
2
- import { calcNetStrategyApy as R, calcEffectiveBorrowApy as D } from "@gearbox-protocol/sdk/onchain";
3
- import { ApyBreakdownBody as P, formatBreakdownRate as i, ApyBreakdownRow as v, periodMessageId as f, ApyBreakdownDivider as q, BREAKDOWN_DASH as L } from "../apy-breakdown-body/apy-breakdown-body.js";
4
- import { NoValue as k } from "../../no-value/no-value.js";
5
- import { PointsIcon as O } from "../../points-icon/points-icon.js";
6
- import { TokenIcon as S } from "../../token-icon/token-icon.js";
7
- import { FormattedMessageTyped as s } from "../../typed-intl/index.js";
8
- import { formatLeverageExact as c, formatLeverage as E } from "../../../utils/format-leverage.js";
9
- import { totalApyOf as M, positiveTokenRewardsOf as $, pointProgramsOf as j } from "../../../utils/internal/apy-breakdown.js";
10
- import { StrategyApyBreakdownCardTest as n } from "./constants.js";
11
- function z(m) {
12
- const { borrowApyAvg7D: t, quotaRateAvg7D: d, liquidationThreshold: r } = m;
13
- return t === void 0 || d === void 0 ? null : {
14
- borrowApy: t,
15
- quotaRate: d,
16
- liquidationThreshold: r
1
+ import { jsxs as w, jsx as e, Fragment as $ } from "react/jsx-runtime";
2
+ import { calcNetStrategyApy as M, calcEffectiveBorrowApy as q } from "@gearbox-protocol/sdk/onchain";
3
+ import { breakdownRateValue as P, ApyBreakdownBody as O, formatBreakdownRate as m, ApyBreakdownRow as b, periodMessageId as k, ApyBreakdownDivider as S, BREAKDOWN_DASH as E } from "../apy-breakdown-body/apy-breakdown-body.js";
4
+ import { NoValue as g } from "../../no-value/no-value.js";
5
+ import { PointsIcon as j } from "../../points-icon/points-icon.js";
6
+ import { TokenIcon as z } from "../../token-icon/token-icon.js";
7
+ import { FormattedMessageTyped as i } from "../../typed-intl/index.js";
8
+ import { formatLeverageExact as p, formatLeverage as F } from "../../../utils/format-leverage.js";
9
+ import { totalApyOf as V, positiveTokenRewardsOf as H, pointProgramsOf as K } from "../../../utils/internal/apy-breakdown.js";
10
+ import { StrategyApyBreakdownCardTest as l } from "./constants.js";
11
+ function W(c) {
12
+ const { borrowApyAvg7D: o, quotaRateAvg7D: r, liquidationThreshold: n } = c;
13
+ return o === void 0 || r === void 0 ? null : {
14
+ borrowApy: o,
15
+ quotaRate: r,
16
+ liquidationThreshold: n
17
17
  };
18
18
  }
19
- function U({
20
- data: m,
21
- leverage: t,
22
- showFormula: d = !1,
23
- period: r
19
+ function Y(c, o, r) {
20
+ const n = P(c), a = r - o * n;
21
+ return a > 0 && o > 0 ? n + Math.ceil(a / o * 100) / 100 : n;
22
+ }
23
+ function ao({
24
+ data: c,
25
+ leverage: o,
26
+ showFormula: r = !1,
27
+ period: n
24
28
  }) {
25
- const a = z(m), l = a && m.collateralApyAvg7D ? m.collateralApyAvg7D : void 0, b = a !== null && l !== void 0, g = b && a && l ? {
26
- organicApy: R(
29
+ const a = W(c), s = a && c.collateralApyAvg7D ? c.collateralApyAvg7D : void 0, I = a !== null && s !== void 0, B = I && a && s ? {
30
+ organicApy: M(
27
31
  a,
28
- l.organicApy,
29
- t
32
+ s.organicApy,
33
+ o
30
34
  ),
31
- totalApy: R(
35
+ totalApy: M(
32
36
  a,
33
- l.totalApy ?? l.organicApy,
34
- t
37
+ s.totalApy ?? s.organicApy,
38
+ o
35
39
  ),
36
- ...l.rewards ? { rewards: l.rewards } : {}
37
- } : null, p = b && a ? D(a, t) : null, u = g === null ? null : M(g), I = u === null || p === null ? null : u + p, N = l ? $(l) : [], B = l ? j(l) : [], T = N.map((o) => ({
38
- reward: o,
39
- value: Math.round(t * (o.supplyApr ?? 0))
40
- })), y = I === null ? null : I - T.reduce((o, w) => o + w.value, 0), h = y !== null && t > 0 ? y / t : void 0, x = a && p !== null && t > 0 ? (p - a.borrowApy * (t - 1)) / t : void 0;
41
- return /* @__PURE__ */ A(
42
- P,
40
+ ...s.rewards ? { rewards: s.rewards } : {}
41
+ } : null, d = I && a ? q(a, o) : null, u = B === null ? null : V(B), h = u === null || d === null ? null : u + d, L = s ? H(s) : [], R = s ? K(s) : [], T = L.map((t) => ({
42
+ reward: t,
43
+ value: Math.round(o * (t.supplyApr ?? 0))
44
+ })), y = h === null ? null : h - T.reduce((t, f) => t + f.value, 0), x = y !== null && o > 0 ? y / o : void 0, N = a && d !== null && o > 0 ? (d - a.borrowApy * (o - 1)) / o : void 0, C = Number(p(o)), v = d === null ? void 0 : P(d), A = a && N !== void 0 && v !== void 0 ? Y(
45
+ a.borrowApy + N,
46
+ C,
47
+ v
48
+ ) : void 0, D = A !== void 0 && v !== void 0 ? C * A - v : void 0;
49
+ return /* @__PURE__ */ w(
50
+ O,
43
51
  {
44
- testId: n.root,
52
+ testId: l.root,
45
53
  title: /* @__PURE__ */ e(
46
- s,
54
+ i,
47
55
  {
48
- messageId: f(
49
- r,
56
+ messageId: k(
57
+ n,
50
58
  "components.yieldBreakdown.titleNetAtLeverage",
51
59
  "components.yieldBreakdown.titleNetAtLeverage7d"
52
60
  ),
53
- values: { leverage: E(t) }
61
+ values: { leverage: F(o) }
54
62
  }
55
63
  ),
56
- chip: u === null ? /* @__PURE__ */ e(k, { reason: r }) : i(u, !0),
64
+ chip: u === null ? /* @__PURE__ */ e(g, { reason: n }) : m(u, !0),
57
65
  chipPositive: (u ?? 0) > 0,
58
- chipTestId: n.net,
66
+ chipTestId: l.net,
59
67
  children: [
60
68
  /* @__PURE__ */ e(
61
- v,
69
+ b,
62
70
  {
63
- testId: n.collateral,
64
- valueTestId: n.value,
65
- captionTestId: n.caption,
71
+ testId: l.collateral,
72
+ valueTestId: l.value,
73
+ captionTestId: l.caption,
66
74
  label: /* @__PURE__ */ e(
67
- s,
75
+ i,
68
76
  {
69
- messageId: f(
70
- r,
77
+ messageId: k(
78
+ n,
71
79
  "components.yieldBreakdown.collateralApy",
72
80
  "components.yieldBreakdown.collateralApy7d"
73
81
  )
74
82
  }
75
83
  ),
76
- value: y === null ? /* @__PURE__ */ e(k, { reason: r }) : i(y),
77
- subtext: d && h !== void 0 ? /* @__PURE__ */ e(
78
- s,
84
+ value: y === null ? /* @__PURE__ */ e(g, { reason: n }) : m(y),
85
+ subtext: r && x !== void 0 ? /* @__PURE__ */ e(
86
+ i,
79
87
  {
80
88
  messageId: "components.strategyApyBreakdownCard.formula",
81
89
  values: {
82
- leverage: c(t),
83
- base: i(h)
90
+ leverage: p(o),
91
+ base: m(x)
84
92
  }
85
93
  }
86
94
  ) : void 0
87
95
  }
88
96
  ),
89
- T.map(({ reward: o, value: w }) => /* @__PURE__ */ e(
90
- v,
97
+ T.map(({ reward: t, value: f }) => /* @__PURE__ */ e(
98
+ b,
91
99
  {
92
- valueTestId: n.value,
93
- captionTestId: n.caption,
94
- label: /* @__PURE__ */ A("span", { className: "inline-flex items-center gap-1.5", children: [
100
+ valueTestId: l.value,
101
+ captionTestId: l.caption,
102
+ label: /* @__PURE__ */ w("span", { className: "inline-flex items-center gap-1.5", children: [
95
103
  /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
96
- s,
104
+ i,
97
105
  {
98
106
  messageId: "components.apyParts.extraAPY",
99
- values: { symbol: o.token.symbol }
107
+ values: { symbol: t.token.symbol }
100
108
  }
101
109
  ) }),
102
110
  /* @__PURE__ */ e(
103
- S,
111
+ z,
104
112
  {
105
- token: o.token,
106
- symbol: o.token.symbol,
113
+ token: t.token,
114
+ symbol: t.token.symbol,
107
115
  size: 16,
108
116
  className: "shrink-0"
109
117
  }
110
118
  )
111
119
  ] }),
112
- value: i(w),
113
- subtext: d ? /* @__PURE__ */ e(
114
- s,
120
+ value: m(f),
121
+ subtext: r ? /* @__PURE__ */ e(
122
+ i,
115
123
  {
116
124
  messageId: "components.strategyApyBreakdownCard.formula",
117
125
  values: {
118
- leverage: c(t),
119
- base: i(o.supplyApr ?? 0)
126
+ leverage: p(o),
127
+ base: m(t.supplyApr ?? 0)
120
128
  }
121
129
  }
122
130
  ) : void 0
123
131
  },
124
- `incentive-${o.token.address}-${o.supplyApr ?? 0}`
132
+ `incentive-${t.token.address}-${t.supplyApr ?? 0}`
125
133
  )),
126
134
  /* @__PURE__ */ e(
127
- v,
135
+ b,
128
136
  {
129
137
  muted: !0,
130
- testId: n.borrow,
131
- valueTestId: n.value,
132
- captionTestId: n.caption,
138
+ testId: l.borrow,
139
+ valueTestId: l.value,
140
+ captionTestId: l.caption,
133
141
  label: /* @__PURE__ */ e(
134
- s,
142
+ i,
135
143
  {
136
- messageId: f(
137
- r,
144
+ messageId: k(
145
+ n,
138
146
  "components.yieldBreakdown.borrowRate",
139
147
  "components.yieldBreakdown.borrowRate7d"
140
148
  )
141
149
  }
142
150
  ),
143
- value: p === null ? /* @__PURE__ */ e(k, { reason: r }) : i(p),
144
- subtext: d && a && x !== void 0 ? /* @__PURE__ */ e(
145
- s,
151
+ value: d === null ? /* @__PURE__ */ e(g, { reason: n }) : m(d),
152
+ subtext: r && A !== void 0 && D !== void 0 ? /* @__PURE__ */ e(
153
+ i,
146
154
  {
147
155
  messageId: "components.strategyApyBreakdownCard.borrowFormula",
148
156
  values: {
149
- leverage: c(t),
150
- // What the position is charged per unit of itself: base
151
- // interest plus the quota, added before either is rounded, so
152
- // the caption is not the sum of two figures it also printed.
153
- totalRate: i(a.borrowApy + x),
154
- borrowRate: i(a.borrowApy)
157
+ leverage: p(o),
158
+ totalRate: `${A.toFixed(2)}%`,
159
+ borrowRate: `${Math.abs(D).toFixed(2)}%`
155
160
  }
156
161
  }
157
162
  ) : void 0
158
163
  }
159
164
  ),
160
- B.length > 0 ? /* @__PURE__ */ A(C, { children: [
161
- /* @__PURE__ */ e(q, {}),
162
- B.map((o) => /* @__PURE__ */ e(
163
- v,
165
+ R.length > 0 ? /* @__PURE__ */ w($, { children: [
166
+ /* @__PURE__ */ e(S, {}),
167
+ R.map((t) => /* @__PURE__ */ e(
168
+ b,
164
169
  {
165
- valueTestId: n.points,
166
- captionTestId: n.caption,
167
- label: /* @__PURE__ */ A("span", { className: "inline-flex items-center gap-1.5", children: [
170
+ valueTestId: l.points,
171
+ captionTestId: l.caption,
172
+ label: /* @__PURE__ */ w("span", { className: "inline-flex items-center gap-1.5", children: [
168
173
  /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(
169
- s,
174
+ i,
170
175
  {
171
176
  messageId: "components.yieldBreakdown.programPoints",
172
- values: { name: o.name }
177
+ values: { name: t.name }
173
178
  }
174
179
  ) }),
175
180
  /* @__PURE__ */ e(
176
- O,
181
+ j,
177
182
  {
178
- reward: { name: o.name, type: o.id },
183
+ reward: { name: t.name, type: t.id },
179
184
  size: 16,
180
185
  className: "shrink-0"
181
186
  }
182
187
  )
183
188
  ] }),
184
- value: o.multiplier != null ? `${c(o.multiplier * t)}×` : L,
185
- subtext: d && o.multiplier != null ? /* @__PURE__ */ e(
186
- s,
189
+ value: t.multiplier != null ? `${p(t.multiplier * o)}×` : E,
190
+ subtext: r && t.multiplier != null ? /* @__PURE__ */ e(
191
+ i,
187
192
  {
188
193
  messageId: "components.strategyApyBreakdownCard.formula",
189
194
  values: {
190
- leverage: c(t),
191
- base: c(o.multiplier)
195
+ leverage: p(o),
196
+ base: p(t.multiplier)
192
197
  }
193
198
  }
194
199
  ) : void 0
195
200
  },
196
- o.id
201
+ t.id
197
202
  ))
198
203
  ] }) : null
199
204
  ]
@@ -201,6 +206,6 @@ function U({
201
206
  );
202
207
  }
203
208
  export {
204
- U as StrategyApyBreakdownCard,
205
- n as StrategyApyBreakdownCardTest
209
+ ao as StrategyApyBreakdownCard,
210
+ l as StrategyApyBreakdownCardTest
206
211
  };
@@ -12,10 +12,11 @@ export declare function periodMessageId(period: "7d" | undefined, base: LocaleKe
12
12
  * uses above 1000%. A breakdown is read by adding it up, and `1.2K%` carries
13
13
  * three significant figures — enough to make a correct column look wrong.
14
14
  *
15
- * `signed` is for the net chip, the one figure whose direction is not already
16
- * stated by the row it sits on.
15
+ * `signed` is for the net chip: every row states its direction in its label.
17
16
  */
18
17
  export declare function formatBreakdownRate(value: Bps, signed?: boolean): string;
18
+ /** The percent a row prints, so a caption can be built to add up to it. */
19
+ export declare function breakdownRateValue(value: Bps): number;
19
20
  export interface ApyBreakdownBodyProps {
20
21
  /** Heading to the left of the chip — "Net APY (7d)" and the like. */
21
22
  readonly title: React.ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.77",
3
+ "version": "4.0.0-next.78",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",