* fix: fixed mobile issues with SVGs * feat: first morphing AccountDetails * tidy: composition refresh * tidy: fine adjusting * fix: svg fixes * feat: updated summary structure * feat: overall layout adjustments * fix: fixed svg adjustments * feat: finished AccountSummary update * fix: fixed build * tidy: refactor * fix: fix enourmous APYs * fix: don’t abbreviate APYs * tidy: console.log * fix: fix borrow Rate sorting * fix: fixed scrollbars * fix: hide scrollbars * fix: resolved feedback * fix: amount not size * feat: only show credit account number outside of modals * fix: added missing Strategies to PortfolioAccount * fix: save some space
38 lines
1003 B
TypeScript
38 lines
1003 B
TypeScript
import { BNCoin } from 'types/classes/BNCoin'
|
|
import { demagnify, getCoinValue } from 'utils/formatters'
|
|
|
|
export function getAssetAccountBalanceRow(
|
|
type: 'deposit' | 'borrow' | 'lend',
|
|
asset: Asset,
|
|
prices: BNCoin[],
|
|
assets: Asset[],
|
|
position: BNCoin,
|
|
apy: number,
|
|
prev?: BNCoin,
|
|
): AccountBalanceRow {
|
|
const { amount, denom } = position
|
|
const amountChange = !prev ? position.amount : position.amount.minus(prev.amount)
|
|
|
|
return {
|
|
type,
|
|
symbol: asset.symbol,
|
|
size: demagnify(amount, asset),
|
|
value: getCoinValue(BNCoin.fromDenomAndBigNumber(denom, amount), prices, assets).toString(),
|
|
denom,
|
|
amount,
|
|
apy,
|
|
amountChange,
|
|
}
|
|
}
|
|
|
|
export function getAmountChangeColor(type: PositionType, amount: BigNumber) {
|
|
if (type === 'borrow') {
|
|
if (amount.isGreaterThan(0)) return 'text-loss'
|
|
if (amount.isLessThan(0)) return 'text-profit'
|
|
}
|
|
if (amount.isGreaterThan(0)) return 'text-profit'
|
|
if (amount.isLessThan(0)) return 'text-loss'
|
|
|
|
return ''
|
|
}
|