Skip to content

Commit 92dc9f1

Browse files
committed
feat: update borrow limit to protect
1 parent a89d460 commit 92dc9f1

8 files changed

Lines changed: 28 additions & 22 deletions

File tree

apps/evm/src/components/AccountHealthBar/index.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ export const AccountHealthBar: React.FC<AccountHealthBarProps> = ({
4949
})
5050
: undefined;
5151

52+
const protectedBorrowLimitUsedPercentage =
53+
typeof borrowBalanceProtectedCents === 'number' && typeof borrowLimitProtectedCents === 'number'
54+
? calculatePercentage({
55+
numerator: borrowBalanceProtectedCents,
56+
denominator: borrowLimitProtectedCents,
57+
})
58+
: undefined;
59+
5260
const fillPercentage =
5361
typeof borrowBalanceCents === 'number' && typeof liquidationThresholdCents === 'number'
5462
? calculatePercentage({
@@ -69,14 +77,6 @@ export const AccountHealthBar: React.FC<AccountHealthBarProps> = ({
6977
formatPercentageToReadableValue(borrowLimitUsedPercentage);
7078
const sanitizedFillPercentage = fillPercentage || 0;
7179

72-
const readableBorrowLimit = formatCentsToReadableValue({
73-
value: borrowLimitCents,
74-
});
75-
76-
const readableLiquidationThreshold = formatCentsToReadableValue({
77-
value: liquidationThresholdCents,
78-
});
79-
8080
const readableBorrowBalance = formatCentsToReadableValue({
8181
value: borrowBalanceCents,
8282
});
@@ -85,13 +85,17 @@ export const AccountHealthBar: React.FC<AccountHealthBarProps> = ({
8585
value: borrowBalanceProtectedCents,
8686
});
8787

88-
const protectedBorrowLimitUsedPercentage =
89-
typeof borrowBalanceProtectedCents === 'number' && typeof borrowLimitProtectedCents === 'number'
90-
? calculatePercentage({
91-
numerator: borrowBalanceProtectedCents,
92-
denominator: borrowLimitProtectedCents,
93-
})
94-
: undefined;
88+
const readableBorrowLimit = formatCentsToReadableValue({
89+
value: borrowLimitCents,
90+
});
91+
92+
const readableBorrowLimitProtected = formatCentsToReadableValue({
93+
value: borrowLimitProtectedCents,
94+
});
95+
96+
const readableLiquidationThreshold = formatCentsToReadableValue({
97+
value: liquidationThresholdCents,
98+
});
9599

96100
const isProtectionModeEnabled =
97101
borrowLimitUsedPercentage !== undefined &&
@@ -123,6 +127,7 @@ export const AccountHealthBar: React.FC<AccountHealthBarProps> = ({
123127
hideUserBalances ??
124128
formatPercentageToReadableValue(protectedBorrowLimitUsedPercentage),
125129
borrowLimit: hideUserBalances ?? readableBorrowLimit,
130+
borrowLimitProtected: hideUserBalances ?? readableBorrowLimitProtected,
126131
}}
127132
/>
128133
) : undefined,
@@ -133,6 +138,7 @@ export const AccountHealthBar: React.FC<AccountHealthBarProps> = ({
133138
readableBorrowLimitUsedPercentage,
134139
protectedBorrowLimitUsedPercentage,
135140
readableBorrowLimit,
141+
readableBorrowLimitProtected,
136142
hideUserBalances,
137143
isProtectionModeEnabled,
138144
Trans,

apps/evm/src/libs/translations/translations/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"liquidationThresholdShort": "LT:",
143143
"liquidationThresholdTooltip": "LT = Liquidation Threshold<LineBreak/>When your borrow balance reaches this value, your position becomes eligible for liquidation.<LineBreak/><LineBreak/>Learn more about the <Link>calculation.</Link>",
144144
"tooltip": "Borrow balance:<LineBreak/>{{borrowBalance}} ({{borrowLimitUsedPercentage}} of your borrow limit)<LineBreak/><LineBreak/>Borrow limit:<LineBreak/>{{borrowLimit}}",
145-
"tooltipProtection": "Borrow balance (protected):<LineBreak/>{{borrowBalanceProtected}} ({{protectedBorrowLimitUsedPercentage}} of your borrow limit)<LineBreak/><LineBreak/>Borrow balance (spot): {{borrowBalance}}<LineBreak/>Borrow limit: {{borrowLimit}}"
145+
"tooltipProtection": "Borrow balance (protected):<LineBreak/>{{borrowBalanceProtected}} ({{protectedBorrowLimitUsedPercentage}} of your borrow limit)<LineBreak/><LineBreak/>Borrow balance (spot): {{borrowBalance}}<LineBreak/>Borrow limit: {{borrowLimitProtected}}"
146146
},
147147
"adBanner": {
148148
"startNow": "Start now"

apps/evm/src/libs/translations/translations/ja.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"liquidationThresholdShort": "LT:",
143143
"liquidationThresholdTooltip": "LT = 清算閾値<LineBreak/>借入残高がこの値に達すると、ポジションが清算対象になります。<LineBreak/><LineBreak/><Link>計算方法</Link>の詳細はこちら。",
144144
"tooltip": "借入残高:<LineBreak/>{{borrowBalance}} (借入限度額の{{borrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借入限度額:<LineBreak/>{{borrowLimit}}",
145-
"tooltipProtection": "借入残高(保護):<LineBreak/>{{borrowBalanceProtected}} (借入限度額の{{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借入残高(スポット): {{borrowBalance}}<LineBreak/>借入限度額: {{borrowLimit}}"
145+
"tooltipProtection": "借入残高(保護):<LineBreak/>{{borrowBalanceProtected}} (借入限度額の{{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借入残高(スポット): {{borrowBalance}}<LineBreak/>借入限度額: {{borrowLimitProtected}}"
146146
},
147147
"adBanner": {
148148
"startNow": "今すぐ始める"

apps/evm/src/libs/translations/translations/th.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"liquidationThresholdShort": "LT:",
143143
"liquidationThresholdTooltip": "LT = เกณฑ์การชำระบัญชี<LineBreak/>เมื่อยอดยืมของคุณถึงค่านี้ ตำแหน่งของคุณจะมีสิทธิ์ถูกชำระบัญชี<LineBreak/><LineBreak/>เรียนรู้เพิ่มเติมเกี่ยวกับ<Link>การคำนวณ</Link>",
144144
"tooltip": "ยอดกู้ยืม:<LineBreak/>{{borrowBalance}} ({{borrowLimitUsedPercentage}} ของวงเงินกู้ยืม)<LineBreak/><LineBreak/>วงเงินกู้ยืม:<LineBreak/>{{borrowLimit}}",
145-
"tooltipProtection": "ยอดกู้ยืม (ป้องกัน):<LineBreak/>{{borrowBalanceProtected}} ({{protectedBorrowLimitUsedPercentage}} ของวงเงินกู้ยืม)<LineBreak/><LineBreak/>ยอดกู้ยืม (สปอต): {{borrowBalance}}<LineBreak/>วงเงินกู้ยืม: {{borrowLimit}}"
145+
"tooltipProtection": "ยอดกู้ยืม (ป้องกัน):<LineBreak/>{{borrowBalanceProtected}} ({{protectedBorrowLimitUsedPercentage}} ของวงเงินกู้ยืม)<LineBreak/><LineBreak/>ยอดกู้ยืม (สปอต): {{borrowBalance}}<LineBreak/>วงเงินกู้ยืม: {{borrowLimitProtected}}"
146146
},
147147
"adBanner": {
148148
"startNow": "เริ่มตอนนี้"

apps/evm/src/libs/translations/translations/tr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"liquidationThresholdShort": "LT:",
143143
"liquidationThresholdTooltip": "LT = Tasfiye Eşiği<LineBreak/>Borç bakiyeniz bu değere ulaştığında, pozisyonunuz tasfiye edilmeye uygun hale gelir.<LineBreak/><LineBreak/><Link>Hesaplama</Link> hakkında daha fazla bilgi edinin.",
144144
"tooltip": "Borç bakiyesi:<LineBreak/>{{borrowBalance}} (borç limitinizin {{borrowLimitUsedPercentage}})<LineBreak/><LineBreak/>Borç limiti:<LineBreak/>{{borrowLimit}}",
145-
"tooltipProtection": "Borç bakiyesi (Koruma):<LineBreak/>{{borrowBalanceProtected}} (borç limitinizin {{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>Borç bakiyesi (spot): {{borrowBalance}}<LineBreak/>Borç limiti: {{borrowLimit}}"
145+
"tooltipProtection": "Borç bakiyesi (Koruma):<LineBreak/>{{borrowBalanceProtected}} (borç limitinizin {{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>Borç bakiyesi (spot): {{borrowBalance}}<LineBreak/>Borç limiti: {{borrowLimitProtected}}"
146146
},
147147
"adBanner": {
148148
"startNow": "Şimdi başla"

apps/evm/src/libs/translations/translations/vi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"liquidationThresholdShort": "LT:",
143143
"liquidationThresholdTooltip": "LT = Ngưỡng thanh lý<LineBreak/>Khi số dư vay của bạn đạt đến giá trị này, vị thế của bạn sẽ đủ điều kiện bị thanh lý.<LineBreak/><LineBreak/>Tìm hiểu thêm về <Link>cách tính.</Link>",
144144
"tooltip": "Số dư vay:<LineBreak/>{{borrowBalance}} ({{borrowLimitUsedPercentage}} hạn mức vay)<LineBreak/><LineBreak/>Hạn mức vay:<LineBreak/>{{borrowLimit}}",
145-
"tooltipProtection": "Số dư vay (Bảo vệ):<LineBreak/>{{borrowBalanceProtected}} ({{protectedBorrowLimitUsedPercentage}} hạn mức vay)<LineBreak/><LineBreak/>Số dư vay (spot): {{borrowBalance}}<LineBreak/>Hạn mức vay: {{borrowLimit}}"
145+
"tooltipProtection": "Số dư vay (Bảo vệ):<LineBreak/>{{borrowBalanceProtected}} ({{protectedBorrowLimitUsedPercentage}} hạn mức vay)<LineBreak/><LineBreak/>Số dư vay (spot): {{borrowBalance}}<LineBreak/>Hạn mức vay: {{borrowLimitProtected}}"
146146
},
147147
"adBanner": {
148148
"startNow": "Bắt đầu ngay"

apps/evm/src/libs/translations/translations/zh-Hans.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"liquidationThresholdShort": "LT:",
143143
"liquidationThresholdTooltip": "LT = 清算阈值<LineBreak/>当您的借款余额达到此值时,您的仓位将有资格被清算。<LineBreak/><LineBreak/>了解更多关于<Link>计算方式。</Link>",
144144
"tooltip": "借款余额:<LineBreak/>{{borrowBalance}}(借款限额的{{borrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借款限额:<LineBreak/>{{borrowLimit}}",
145-
"tooltipProtection": "借款余额(保护):<LineBreak/>{{borrowBalanceProtected}}(借款限额的{{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借款余额(现货):{{borrowBalance}}<LineBreak/>借款限额:{{borrowLimit}}"
145+
"tooltipProtection": "借款余额(保护):<LineBreak/>{{borrowBalanceProtected}}(借款限额的{{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借款余额(现货):{{borrowBalance}}<LineBreak/>借款限额:{{borrowLimitProtected}}"
146146
},
147147
"adBanner": {
148148
"startNow": "立即开始"

apps/evm/src/libs/translations/translations/zh-Hant.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
"liquidationThresholdShort": "LT:",
143143
"liquidationThresholdTooltip": "LT = 清算閾值<LineBreak/>當您的借款餘額達到此值時,您的倉位將有資格被清算。<LineBreak/><LineBreak/>了解更多關於<Link>計算方式。</Link>",
144144
"tooltip": "借款餘額:<LineBreak/>{{borrowBalance}}(借款限額的{{borrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借款限額:<LineBreak/>{{borrowLimit}}",
145-
"tooltipProtection": "借款餘額(保護):<LineBreak/>{{borrowBalanceProtected}}(借款限額的{{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借款餘額(現貨):{{borrowBalance}}<LineBreak/>借款限額:{{borrowLimit}}"
145+
"tooltipProtection": "借款餘額(保護):<LineBreak/>{{borrowBalanceProtected}}(借款限額的{{protectedBorrowLimitUsedPercentage}})<LineBreak/><LineBreak/>借款餘額(現貨):{{borrowBalance}}<LineBreak/>借款限額:{{borrowLimitProtected}}"
146146
},
147147
"adBanner": {
148148
"startNow": "立即開始"

0 commit comments

Comments
 (0)