Skip to content

Commit

Permalink
fix: seatbelt formatting patches
Browse files Browse the repository at this point in the history
bitmap as binary
ltv at %
lb without -100%
  • Loading branch information
sakulstra committed Oct 27, 2024
1 parent 165e9f0 commit b2073f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/govv3/__snapshots__/generatePayloadReport.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ InitializableImmutableAdminUpgradeabilityProxy at \`0xb50201558B00496A145fE76f74
- "0x000000000000000000000000e07e26f316248a2aa14115439a0bd9ea49328dc7"
+ "0x0000000000000000000000008a48ef9287c402c119c14a5f6897f6dfdc12cb45"
@@ \`_eModeCategories\` key \`1.collateralBitmap\` @@
- 0
+ 3
- 0b0
+ 0b11
@@ \`_eModeCategories\` key \`1.borrowableBitmap\` @@
- 0
+ 3
- 0b0
+ 0b11
@@ \`_eModeCategories\` key \`1.collateralBitmap_decoded\` @@
-
+ WETH(id: 0),wstETH(id: 1)
Expand Down
12 changes: 10 additions & 2 deletions src/govv3/checks/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ export async function deepDiff({
bitMapToIndexes(BigInt(before.collateralBitmap || 0)),
)
).toString();
before.collateralBitmap = toBinaryString(BigInt(before.collateralBitmap || 0));
after.collateralBitmap_decoded = (
await assetIndexesToAsset(
client,
address,
bitMapToIndexes(BigInt(after.collateralBitmap || 0)),
)
).toString();
after.collateralBitmap = toBinaryString(BigInt(after.collateralBitmap || 0));
}
if (before.borrowableBitmap !== undefined) {
before.borrowableBitmap_decoded = (
Expand All @@ -161,13 +163,15 @@ export async function deepDiff({
bitMapToIndexes(BigInt(before.borrowableBitmap || 0)),
)
).toString();
before.borrowableBitmap = toBinaryString(BigInt(before.borrowableBitmap || 0));
after.borrowableBitmap_decoded = (
await assetIndexesToAsset(
client,
address,
bitMapToIndexes(BigInt(after.borrowableBitmap || 0)),
)
).toString();
after.borrowableBitmap = toBinaryString(BigInt(after.borrowableBitmap || 0));
}
}

Expand Down Expand Up @@ -262,7 +266,7 @@ async function enhanceValue({
if (key && ['_reserves', '_eModeCategories'].includes(type)) {
if (['liquidityIndex', 'variableBorrowIndex'].includes(key))
return prettifyNumber({decimals: 27, value, showDecimals: true});
if (['liquidationThreshold', 'reserveFactor', 'liquidationProtocolFee'].includes(key))
if (['liquidationThreshold', 'reserveFactor', 'liquidationProtocolFee', 'ltv'].includes(key))
return prettifyNumber({decimals: 2, value, suffix: '%', showDecimals: true});
if (
['currentLiquidityRate', 'currentVariableBorrowRate', 'currentStableBorrowRate'].includes(
Expand All @@ -276,7 +280,7 @@ async function enhanceValue({
value,
suffix: '%',
showDecimals: true,
patchedValue: BigInt(value) - BigInt(1e4),
patchedValue: BigInt(value) == 0n ? 0n : BigInt(value) - BigInt(1e4),
});
}
}
Expand Down Expand Up @@ -324,3 +328,7 @@ export const checkStateChanges: ProposalCheck<any> = {
return {info, warnings, errors};
},
};

function toBinaryString(value: bigint) {
return `0b` + value.toString(2);
}

0 comments on commit b2073f6

Please sign in to comment.