Skip to content

Commit

Permalink
Refactor labels in useOmniAutoBSOrderInformationItems (#3747)
Browse files Browse the repository at this point in the history
* Refactor labels in useOmniAutoBSOrderInformationItems

* Refactor useOmniAutoBSOrderInformationItems to use a ternary operator for label assignments
  • Loading branch information
marcinciarka authored Apr 2, 2024
1 parent aa90b09 commit 9f9779a
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const useOmniAutoBSOrderInformationItems = (): ItemProps[] => {
? AutomationFeatures.AUTO_SELL
: AutomationFeatures.AUTO_BUY

const isAutoSell = type === AutomationFeatures.AUTO_SELL

const {
afterTargetMultiply,
afterTargetLtv,
Expand All @@ -41,19 +43,25 @@ export const useOmniAutoBSOrderInformationItems = (): ItemProps[] => {

return [
{
label: t('auto-sell.target-ltv-each-sell'),
label: isAutoSell ? t('auto-sell.target-ltv-each-sell') : t('auto-buy.target-ltv-each-buy'),
value: afterTargetLtv ? formatDecimalAsPercent(afterTargetLtv.div(100)) : '-',
},
{
label: t('auto-sell.target-multiple-each-sell'),
label: isAutoSell
? t('auto-sell.target-multiple-each-sell')
: t('auto-buy.target-multiple-each-buy'),
value: afterTargetMultiply ? `${afterTargetMultiply.toFixed(2)}x` : '-',
},
{
label: t('auto-sell.trigger-ltv-to-perform-sell'),
label: isAutoSell
? t('auto-sell.trigger-ltv-to-perform-sell')
: t('auto-buy.trigger-ltv-to-perform-buy'),
value: afterTriggerLtv ? formatDecimalAsPercent(afterTriggerLtv.div(100)) : '-',
},
{
label: t('auto-sell.target-ratio-with-deviation'),
label: isAutoSell
? t('auto-sell.target-ratio-with-deviation')
: t('auto-buy.target-ratio-with-deviation'),
value: deviation
? `${formatDecimalAsPercent(
new BigNumber(deviation[0]).div(10000),
Expand All @@ -62,21 +70,27 @@ export const useOmniAutoBSOrderInformationItems = (): ItemProps[] => {
isLoading: isSimulationLoading,
},
{
label: t('auto-sell.collateral-after-next-sell'),
label: isAutoSell
? t('auto-sell.collateral-after-next-sell')
: t('auto-buy.collateral-after-next-buy'),
value: collateralAmountAfterExecution
? `${formatCryptoBalance(collateralAmountAfterExecution)} ${collateralToken}`
: '-',
isLoading: isSimulationLoading,
},
{
label: t('auto-sell.outstanding-debt-after-next-sell'),
label: isAutoSell
? t('auto-sell.outstanding-debt-after-next-sell')
: t('auto-buy.outstanding-debt-after-next-buy'),
value: debtAmountAfterExecution
? `${formatCryptoBalance(debtAmountAfterExecution)} ${quoteToken}`
: '-',
isLoading: isSimulationLoading,
},
{
label: t('auto-sell.col-to-be-sold', { token: collateralToken }),
label: isAutoSell
? t('auto-sell.col-to-be-sold', { token: collateralToken })
: t('auto-buy.col-to-be-purchased', { token: collateralToken }),
value: collateralToBuyOrSellOnExecution
? `${formatCryptoBalance(collateralToBuyOrSellOnExecution)} ${collateralToken}`
: '-',
Expand Down

0 comments on commit 9f9779a

Please sign in to comment.