Skip to content

Commit

Permalink
fix: various patches to formatting (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Oct 26, 2024
1 parent 31497e5 commit 62387e6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/govv3/checks/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async function enhanceValue({
if (asset) return prettifyNumber({decimals: asset.decimals, value, showDecimals: true});
}
// values to be rendered with ray decimals
if (key && ['_reserves'].includes(type)) {
if (key && ['_reserves', '_eModeCategories'].includes(type)) {
if (['liquidityIndex', 'variableBorrowIndex'].includes(key))
return prettifyNumber({decimals: 27, value, showDecimals: true});
if (['liquidationThreshold', 'reserveFactor', 'liquidationProtocolFee'].includes(key))
Expand All @@ -270,6 +270,14 @@ async function enhanceValue({
)
)
return prettifyNumber({decimals: 25, value, suffix: '%', showDecimals: true});
if (['liquidationBonus'].includes(key))
return prettifyNumber({
decimals: 2,
value,
suffix: '%',
showDecimals: true,
patchedValue: BigInt(value) - BigInt(1e4),
});
}
}
return value;
Expand Down
6 changes: 5 additions & 1 deletion src/govv3/utils/markdownUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,19 @@ export function prettifyNumber({
prefix,
suffix,
showDecimals,
patchedValue,
}: {
value: string | number | bigint;
decimals: number;
prefix?: string;
suffix?: string;
showDecimals?: boolean;
// allow overwriting the value when formatting
// this is useful for e.g. 1e4 % numbers, when the 100% should be removed in the formatting
patchedValue?: string | number | bigint;
}) {
const formattedNumber = limitDecimalsWithoutRounding(
formatNumberString(formatUnits(BigInt(value), decimals)),
formatNumberString(formatUnits(BigInt(patchedValue || value), decimals)),
4,
);
return `${prefix ? `${prefix} ` : ''}${formattedNumber}${
Expand Down
3 changes: 1 addition & 2 deletions src/reports/diff-reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ export async function diffReports<A extends AaveV3Snapshot, B extends AaveV3Snap
pre,
post,
);
// when it doesn't have changes it means the eMode is new
} else {
} else if (!pre.eModes[eMode] || !post.eModes[eMode]) {
content += renderEmodeDiff(
diff(pre.eModes[eMode] || {}, post.eModes[eMode] || {}) as any,
pre,
Expand Down

0 comments on commit 62387e6

Please sign in to comment.