From a46aa136afd41c44c151bfdca8c3f0064cd5728d Mon Sep 17 00:00:00 2001 From: Mark Grothe Date: Thu, 24 Oct 2024 08:56:08 -0500 Subject: [PATCH] Fix/bitmap (#600) * fix: bitmap * fix: id not zero based --- .../src/v3-UiPoolDataProvider-contract/index.ts | 4 ++-- packages/math-utils/src/formatters/emode/index.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts b/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts index c1777d3e..3f87369e 100644 --- a/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts +++ b/packages/contract-helpers/src/v3-UiPoolDataProvider-contract/index.ts @@ -262,12 +262,12 @@ export class UiPoolDataProvider implements UiPoolDataProviderInterface { collateralBitmap: eMode.eMode.collateralBitmap .toBigInt() .toString(2) - .padEnd(256, '0'), + .padStart(256, '0'), label: eMode.eMode.label, borrowableBitmap: eMode.eMode.borrowableBitmap .toBigInt() .toString(2) - .padEnd(256, '0'), + .padStart(256, '0'), }, })); } diff --git a/packages/math-utils/src/formatters/emode/index.ts b/packages/math-utils/src/formatters/emode/index.ts index 62efb537..06addbd9 100644 --- a/packages/math-utils/src/formatters/emode/index.ts +++ b/packages/math-utils/src/formatters/emode/index.ts @@ -57,8 +57,11 @@ export function getReservesEModes( eModes: EModeData[], ): ReserveEMode[] { return eModes.reduce((acc, eMode) => { - const borrowingEnabled = eMode.eMode.borrowableBitmap[reserveId] === '1'; - const collateralEnabled = eMode.eMode.collateralBitmap[reserveId] === '1'; + const { borrowableBitmap, collateralBitmap } = eMode.eMode; + const borrowingEnabled = + borrowableBitmap[borrowableBitmap.length - reserveId - 1] === '1'; + const collateralEnabled = + collateralBitmap[collateralBitmap.length - reserveId - 1] === '1'; if (borrowingEnabled || collateralEnabled) { acc.push({ id: eMode.id,