@gearbox-protocol/ui-kit 4.0.0-next.36 → 4.0.0-next.37

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"),g=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(y){const{borrowApyAvg7D:a,quotaRateAvg7D:p,liquidationThreshold:i}=y;return a===void 0||p===void 0?null:{borrowApy:a,quotaRate:p,liquidationThreshold:i}}function S({data:y,leverage:a,showFormula:p=!1,period:i}){const s=R(y),n=s&&y.collateralApyAvg7D?y.collateralApyAvg7D:void 0,c=s!==null&&n!==void 0,x=c&&s&&n?{organicApy:g.calcNetStrategyApy(s,n.organicApy,a),totalApy:g.calcNetStrategyApy(s,n.totalApy??n.organicApy,a),...n.rewards?{rewards:n.rewards}:{}}:{organicApy:0,totalApy:0},m=c&&s?g.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,w)=>t+w.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(i,"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(i,"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: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(C.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: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(i,"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),totalRate:o.formatBreakdownRate(s.borrowApy+f),borrowRate:o.formatBreakdownRate(s.borrowApy)}}):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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("@gearbox-protocol/sdk/onchain"),t=require("../apy-breakdown-body/apy-breakdown-body.cjs"),R=require("../../points-icon/points-icon.cjs"),j=require("../../token-icon/token-icon.cjs"),d=require("../../typed-intl/index.cjs"),g=require("../../../utils/apy-breakdown.cjs"),p=require("../../../utils/format-leverage.cjs"),r=require("./constants.cjs");function S(y){const{borrowApyAvg7D:o,quotaRateAvg7D:l,liquidationThreshold:c}=y;return o===void 0||l===void 0?null:{borrowApy:o,quotaRate:l,liquidationThreshold:c}}function C({data:y,leverage:o,showFormula:l=!1,period:c}){const s=S(y),n=s&&y.collateralApyAvg7D?y.collateralApyAvg7D:void 0,k=s!==null&&n!==void 0,B=k&&s&&n?{organicApy:w.calcNetStrategyApy(s,n.organicApy,o),totalApy:w.calcNetStrategyApy(s,n.totalApy??n.organicApy,o),...n.rewards?{rewards:n.rewards}:{}}:null,i=k&&s?w.calcEffectiveBorrowApy(s,o):null,m=B===null?null:g.totalApyOf(B),v=m===null||i===null?null:m+i,b=n?g.positiveTokenRewardsOf(n):[],T=n?g.pointProgramsOf(n):[],f=b.map(a=>({reward:a,value:Math.round(o*(a.supplyApr??0))})),u=v===null?null:v-f.reduce((a,A)=>a+A.value,0),x=u!==null&&o>0?u/o:void 0,I=s&&i!==null&&o>0?(i-s.borrowApy*(o-1))/o:void 0;return e.jsxs(t.ApyBreakdownBody,{testId:r.StrategyApyBreakdownCardTest.root,title:e.jsx(d.FormattedMessageTyped,{messageId:t.periodMessageId(c,"components.yieldBreakdown.titleNetAtLeverage","components.yieldBreakdown.titleNetAtLeverage7d"),values:{leverage:p.formatLeverage(o)}}),chip:m===null?t.BREAKDOWN_DASH:t.formatBreakdownRate(m),chipPositive:(m??0)>0,chipTestId:r.StrategyApyBreakdownCardTest.net,children:[e.jsx(t.ApyBreakdownRow,{testId:r.StrategyApyBreakdownCardTest.collateral,valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsx(d.FormattedMessageTyped,{messageId:t.periodMessageId(c,"components.yieldBreakdown.collateralApy","components.yieldBreakdown.collateralApy7d")}),value:u===null?t.BREAKDOWN_DASH:t.formatBreakdownRate(u),subtext:l&&x!==void 0?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverage(o),base:t.formatBreakdownRate(x)}}):void 0}),f.map(({reward:a,value:A})=>e.jsx(t.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:a.token.symbol}})}),e.jsx(j.TokenIcon,{token:a.token,symbol:a.token.symbol,size:16,className:"shrink-0"})]}),value:t.formatBreakdownRate(A),subtext:l?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverage(o),base:t.formatBreakdownRate(a.supplyApr??0)}}):void 0},`incentive-${a.token.address}-${a.supplyApr??0}`)),e.jsx(t.ApyBreakdownRow,{muted:!0,testId:r.StrategyApyBreakdownCardTest.borrow,valueTestId:r.StrategyApyBreakdownCardTest.value,captionTestId:r.StrategyApyBreakdownCardTest.caption,label:e.jsx(d.FormattedMessageTyped,{messageId:t.periodMessageId(c,"components.yieldBreakdown.borrowRate","components.yieldBreakdown.borrowRate7d")}),value:i===null?t.BREAKDOWN_DASH:t.formatBreakdownRate(-i),subtext:l&&s&&I!==void 0?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.borrowFormula",values:{leverage:p.formatLeverage(o),totalRate:t.formatBreakdownRate(s.borrowApy+I),borrowRate:t.formatBreakdownRate(s.borrowApy)}}):void 0}),T.length>0?e.jsxs(e.Fragment,{children:[e.jsx(t.ApyBreakdownDivider,{}),T.map(a=>e.jsx(t.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:a.name}})}),e.jsx(R.PointsIcon,{reward:{name:a.name,type:a.id},size:16,className:"shrink-0"})]}),value:a.multiplier!=null?`${p.formatLeverage(a.multiplier*o)}×`:t.BREAKDOWN_DASH,subtext:l&&a.multiplier!=null?e.jsx(d.FormattedMessageTyped,{messageId:"components.strategyApyBreakdownCard.formula",values:{leverage:p.formatLeverage(o),base:p.formatLeverage(a.multiplier)}}):void 0},a.id))]}):null]})}exports.StrategyApyBreakdownCardTest=r.StrategyApyBreakdownCardTest;exports.StrategyApyBreakdownCard=C;
@@ -1,98 +1,98 @@
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";
1
+ import { jsxs as A, jsx as t, Fragment as C } from "react/jsx-runtime";
2
+ import { calcNetStrategyApy as x, calcEffectiveBorrowApy as D } from "@gearbox-protocol/sdk/onchain";
3
+ import { ApyBreakdownBody as P, BREAKDOWN_DASH as v, formatBreakdownRate as r, ApyBreakdownRow as w, periodMessageId as b, ApyBreakdownDivider as q } from "../apy-breakdown-body/apy-breakdown-body.js";
4
4
  import { PointsIcon as O } from "../../points-icon/points-icon.js";
5
5
  import { TokenIcon as S } from "../../token-icon/token-icon.js";
6
- import { FormattedMessageTyped as r } from "../../typed-intl/index.js";
6
+ import { FormattedMessageTyped as s } from "../../typed-intl/index.js";
7
7
  import { totalApyOf as L, positiveTokenRewardsOf as M, pointProgramsOf as $ } from "../../../utils/apy-breakdown.js";
8
8
  import { formatLeverage as d } from "../../../utils/format-leverage.js";
9
9
  import { StrategyApyBreakdownCardTest as n } from "./constants.js";
10
- function j(p) {
11
- const { borrowApyAvg7D: o, quotaRateAvg7D: i, liquidationThreshold: c } = p;
10
+ function j(c) {
11
+ const { borrowApyAvg7D: o, quotaRateAvg7D: i, liquidationThreshold: m } = c;
12
12
  return o === void 0 || i === void 0 ? null : {
13
13
  borrowApy: o,
14
14
  quotaRate: i,
15
- liquidationThreshold: c
15
+ liquidationThreshold: m
16
16
  };
17
17
  }
18
18
  function J({
19
- data: p,
19
+ data: c,
20
20
  leverage: o,
21
21
  showFormula: i = !1,
22
- period: c
22
+ period: m
23
23
  }) {
24
- const a = j(p), s = a && p.collateralApyAvg7D ? p.collateralApyAvg7D : void 0, u = a !== null && s !== void 0, h = u && a && s ? {
25
- organicApy: T(
24
+ const a = j(c), l = a && c.collateralApyAvg7D ? c.collateralApyAvg7D : void 0, f = a !== null && l !== void 0, g = f && a && l ? {
25
+ organicApy: x(
26
26
  a,
27
- s.organicApy,
27
+ l.organicApy,
28
28
  o
29
29
  ),
30
- totalApy: T(
30
+ totalApy: x(
31
31
  a,
32
- s.totalApy ?? s.organicApy,
32
+ l.totalApy ?? l.organicApy,
33
33
  o
34
34
  ),
35
- ...s.rewards ? { rewards: s.rewards } : {}
36
- } : { organicApy: 0, totalApy: 0 }, A = u && a ? C(a, o) : 0, v = L(h), R = v + A, x = s ? M(s) : [], b = s ? $(s) : [], g = x.map((e) => ({
35
+ ...l.rewards ? { rewards: l.rewards } : {}
36
+ } : null, p = f && a ? D(a, o) : null, u = g === null ? null : L(g), I = u === null || p === null ? null : u + p, N = l ? M(l) : [], B = l ? $(l) : [], T = N.map((e) => ({
37
37
  reward: e,
38
38
  value: Math.round(o * (e.supplyApr ?? 0))
39
- })), f = R - g.reduce((e, w) => e + w.value, 0), I = o > 0 ? f / o : void 0, B = u && a && o > 0 ? (A - a.borrowApy * (o - 1)) / o : void 0;
40
- return /* @__PURE__ */ m(
41
- D,
39
+ })), y = I === null ? null : I - T.reduce((e, k) => e + k.value, 0), h = y !== null && o > 0 ? y / o : void 0, R = a && p !== null && o > 0 ? (p - a.borrowApy * (o - 1)) / o : void 0;
40
+ return /* @__PURE__ */ A(
41
+ P,
42
42
  {
43
43
  testId: n.root,
44
44
  title: /* @__PURE__ */ t(
45
- r,
45
+ s,
46
46
  {
47
- messageId: k(
48
- c,
47
+ messageId: b(
48
+ m,
49
49
  "components.yieldBreakdown.titleNetAtLeverage",
50
50
  "components.yieldBreakdown.titleNetAtLeverage7d"
51
51
  ),
52
52
  values: { leverage: d(o) }
53
53
  }
54
54
  ),
55
- chip: l(v),
56
- chipPositive: v > 0,
55
+ chip: u === null ? v : r(u),
56
+ chipPositive: (u ?? 0) > 0,
57
57
  chipTestId: n.net,
58
58
  children: [
59
59
  /* @__PURE__ */ t(
60
- y,
60
+ w,
61
61
  {
62
62
  testId: n.collateral,
63
63
  valueTestId: n.value,
64
64
  captionTestId: n.caption,
65
65
  label: /* @__PURE__ */ t(
66
- r,
66
+ s,
67
67
  {
68
- messageId: k(
69
- c,
68
+ messageId: b(
69
+ m,
70
70
  "components.yieldBreakdown.collateralApy",
71
71
  "components.yieldBreakdown.collateralApy7d"
72
72
  )
73
73
  }
74
74
  ),
75
- value: l(f),
76
- subtext: i && I !== void 0 ? /* @__PURE__ */ t(
77
- r,
75
+ value: y === null ? v : r(y),
76
+ subtext: i && h !== void 0 ? /* @__PURE__ */ t(
77
+ s,
78
78
  {
79
79
  messageId: "components.strategyApyBreakdownCard.formula",
80
80
  values: {
81
81
  leverage: d(o),
82
- base: l(I)
82
+ base: r(h)
83
83
  }
84
84
  }
85
85
  ) : void 0
86
86
  }
87
87
  ),
88
- g.map(({ reward: e, value: w }) => /* @__PURE__ */ t(
89
- y,
88
+ T.map(({ reward: e, value: k }) => /* @__PURE__ */ t(
89
+ w,
90
90
  {
91
91
  valueTestId: n.value,
92
92
  captionTestId: n.caption,
93
- label: /* @__PURE__ */ m("span", { className: "inline-flex items-center gap-1.5", children: [
93
+ label: /* @__PURE__ */ A("span", { className: "inline-flex items-center gap-1.5", children: [
94
94
  /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
95
- r,
95
+ s,
96
96
  {
97
97
  messageId: "components.apyParts.extraAPY",
98
98
  values: { symbol: e.token.symbol }
@@ -108,14 +108,14 @@ function J({
108
108
  }
109
109
  )
110
110
  ] }),
111
- value: l(w),
111
+ value: r(k),
112
112
  subtext: i ? /* @__PURE__ */ t(
113
- r,
113
+ s,
114
114
  {
115
115
  messageId: "components.strategyApyBreakdownCard.formula",
116
116
  values: {
117
117
  leverage: d(o),
118
- base: l(e.supplyApr ?? 0)
118
+ base: r(e.supplyApr ?? 0)
119
119
  }
120
120
  }
121
121
  ) : void 0
@@ -123,25 +123,25 @@ function J({
123
123
  `incentive-${e.token.address}-${e.supplyApr ?? 0}`
124
124
  )),
125
125
  /* @__PURE__ */ t(
126
- y,
126
+ w,
127
127
  {
128
128
  muted: !0,
129
129
  testId: n.borrow,
130
130
  valueTestId: n.value,
131
131
  captionTestId: n.caption,
132
132
  label: /* @__PURE__ */ t(
133
- r,
133
+ s,
134
134
  {
135
- messageId: k(
136
- c,
135
+ messageId: b(
136
+ m,
137
137
  "components.yieldBreakdown.borrowRate",
138
138
  "components.yieldBreakdown.borrowRate7d"
139
139
  )
140
140
  }
141
141
  ),
142
- value: l(-A),
143
- subtext: i && a && B !== void 0 ? /* @__PURE__ */ t(
144
- r,
142
+ value: p === null ? v : r(-p),
143
+ subtext: i && a && R !== void 0 ? /* @__PURE__ */ t(
144
+ s,
145
145
  {
146
146
  messageId: "components.strategyApyBreakdownCard.borrowFormula",
147
147
  values: {
@@ -149,26 +149,26 @@ function J({
149
149
  // What the position is charged per unit of itself: base
150
150
  // interest plus the quota, added before either is rounded, so
151
151
  // the caption is not the sum of two figures it also printed.
152
- totalRate: l(a.borrowApy + B),
152
+ totalRate: r(a.borrowApy + R),
153
153
  // Magnitudes, not signed rates: the row above already carries
154
154
  // the minus, and `− −0.88%` reads as arithmetic to decode
155
155
  // rather than a cost to understand.
156
- borrowRate: l(a.borrowApy)
156
+ borrowRate: r(a.borrowApy)
157
157
  }
158
158
  }
159
159
  ) : void 0
160
160
  }
161
161
  ),
162
- b.length > 0 ? /* @__PURE__ */ m(N, { children: [
163
- /* @__PURE__ */ t(P, {}),
164
- b.map((e) => /* @__PURE__ */ t(
165
- y,
162
+ B.length > 0 ? /* @__PURE__ */ A(C, { children: [
163
+ /* @__PURE__ */ t(q, {}),
164
+ B.map((e) => /* @__PURE__ */ t(
165
+ w,
166
166
  {
167
167
  valueTestId: n.points,
168
168
  captionTestId: n.caption,
169
- label: /* @__PURE__ */ m("span", { className: "inline-flex items-center gap-1.5", children: [
169
+ label: /* @__PURE__ */ A("span", { className: "inline-flex items-center gap-1.5", children: [
170
170
  /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
171
- r,
171
+ s,
172
172
  {
173
173
  messageId: "components.yieldBreakdown.programPoints",
174
174
  values: { name: e.name }
@@ -183,9 +183,9 @@ function J({
183
183
  }
184
184
  )
185
185
  ] }),
186
- value: e.multiplier != null ? `${d(e.multiplier * o)}×` : q,
186
+ value: e.multiplier != null ? `${d(e.multiplier * o)}×` : v,
187
187
  subtext: i && e.multiplier != null ? /* @__PURE__ */ t(
188
- r,
188
+ s,
189
189
  {
190
190
  messageId: "components.strategyApyBreakdownCard.formula",
191
191
  values: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/ui-kit",
3
- "version": "4.0.0-next.36",
3
+ "version": "4.0.0-next.37",
4
4
  "description": "Internal UI components",
5
5
  "repository": {
6
6
  "type": "git",