@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.
package/dist/cjs/components/base/strategy-apy-breakdown-card/strategy-apy-breakdown-card.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
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
|
|
2
|
-
import { calcNetStrategyApy as
|
|
3
|
-
import { ApyBreakdownBody as
|
|
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
|
|
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(
|
|
11
|
-
const { borrowApyAvg7D: o, quotaRateAvg7D: i, liquidationThreshold:
|
|
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:
|
|
15
|
+
liquidationThreshold: m
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function J({
|
|
19
|
-
data:
|
|
19
|
+
data: c,
|
|
20
20
|
leverage: o,
|
|
21
21
|
showFormula: i = !1,
|
|
22
|
-
period:
|
|
22
|
+
period: m
|
|
23
23
|
}) {
|
|
24
|
-
const a = j(
|
|
25
|
-
organicApy:
|
|
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
|
-
|
|
27
|
+
l.organicApy,
|
|
28
28
|
o
|
|
29
29
|
),
|
|
30
|
-
totalApy:
|
|
30
|
+
totalApy: x(
|
|
31
31
|
a,
|
|
32
|
-
|
|
32
|
+
l.totalApy ?? l.organicApy,
|
|
33
33
|
o
|
|
34
34
|
),
|
|
35
|
-
...
|
|
36
|
-
} :
|
|
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
|
-
})),
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
-
|
|
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
|
-
|
|
45
|
+
s,
|
|
46
46
|
{
|
|
47
|
-
messageId:
|
|
48
|
-
|
|
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:
|
|
56
|
-
chipPositive:
|
|
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
|
-
|
|
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
|
-
|
|
66
|
+
s,
|
|
67
67
|
{
|
|
68
|
-
messageId:
|
|
69
|
-
|
|
68
|
+
messageId: b(
|
|
69
|
+
m,
|
|
70
70
|
"components.yieldBreakdown.collateralApy",
|
|
71
71
|
"components.yieldBreakdown.collateralApy7d"
|
|
72
72
|
)
|
|
73
73
|
}
|
|
74
74
|
),
|
|
75
|
-
value:
|
|
76
|
-
subtext: i &&
|
|
77
|
-
|
|
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:
|
|
82
|
+
base: r(h)
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
) : void 0
|
|
86
86
|
}
|
|
87
87
|
),
|
|
88
|
-
|
|
89
|
-
|
|
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__ */
|
|
93
|
+
label: /* @__PURE__ */ A("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
94
94
|
/* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
|
|
95
|
-
|
|
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:
|
|
111
|
+
value: r(k),
|
|
112
112
|
subtext: i ? /* @__PURE__ */ t(
|
|
113
|
-
|
|
113
|
+
s,
|
|
114
114
|
{
|
|
115
115
|
messageId: "components.strategyApyBreakdownCard.formula",
|
|
116
116
|
values: {
|
|
117
117
|
leverage: d(o),
|
|
118
|
-
base:
|
|
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
|
-
|
|
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
|
-
|
|
133
|
+
s,
|
|
134
134
|
{
|
|
135
|
-
messageId:
|
|
136
|
-
|
|
135
|
+
messageId: b(
|
|
136
|
+
m,
|
|
137
137
|
"components.yieldBreakdown.borrowRate",
|
|
138
138
|
"components.yieldBreakdown.borrowRate7d"
|
|
139
139
|
)
|
|
140
140
|
}
|
|
141
141
|
),
|
|
142
|
-
value:
|
|
143
|
-
subtext: i && a &&
|
|
144
|
-
|
|
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:
|
|
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:
|
|
156
|
+
borrowRate: r(a.borrowApy)
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
) : void 0
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
|
-
|
|
163
|
-
/* @__PURE__ */ t(
|
|
164
|
-
|
|
165
|
-
|
|
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__ */
|
|
169
|
+
label: /* @__PURE__ */ A("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
170
170
|
/* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(
|
|
171
|
-
|
|
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)}×` :
|
|
186
|
+
value: e.multiplier != null ? `${d(e.multiplier * o)}×` : v,
|
|
187
187
|
subtext: i && e.multiplier != null ? /* @__PURE__ */ t(
|
|
188
|
-
|
|
188
|
+
s,
|
|
189
189
|
{
|
|
190
190
|
messageId: "components.strategyApyBreakdownCard.formula",
|
|
191
191
|
values: {
|