From c817762ab949a53031e3ef04abd4ad337a920eb1 Mon Sep 17 00:00:00 2001 From: Adam Goth Date: Fri, 19 Nov 2021 05:38:33 -0700 Subject: [PATCH] Fix big nums in liq service (#310) * Fix big nums * enable chost test * Formatting Co-authored-by: Phil Bain --- .../src/LiquidationService.ts | 22 ++++++++++--------- .../test/LiquidationService.test.js | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/dai-plugin-liquidations/src/LiquidationService.ts b/packages/dai-plugin-liquidations/src/LiquidationService.ts index 5a5c5a3f8..802bb9614 100644 --- a/packages/dai-plugin-liquidations/src/LiquidationService.ts +++ b/packages/dai-plugin-liquidations/src/LiquidationService.ts @@ -185,13 +185,15 @@ export default class LiquidationService extends PublicService { return this._clipperContractByIlk(ilk) .sales(id) .then(s => { - const tic = new Date(new BigNumber(s.tic).times(1000).toNumber()); + const tic = new Date( + new BigNumber(s.tic._hex).times(1000).toNumber() + ); const obj = { tic, created: tic, - tab: new BigNumber(s.tab).div(RAD), - lot: new BigNumber(s.lot).div(WAD), - top: new BigNumber(s.top).div(RAY), + tab: new BigNumber(s.tab._hex).div(RAD), + lot: new BigNumber(s.lot._hex).div(WAD), + top: new BigNumber(s.top._hex).div(RAY), usr: s.usr, saleId: id, active: true, @@ -300,8 +302,8 @@ export default class LiquidationService extends PublicService { async getHoleAndDirtForIlk(ilk) { const data = await this._dogContract().ilks(stringToBytes(ilk)); - const hole = new BigNumber(data.hole).div(RAD); - const dirt = new BigNumber(data.dirt).div(RAD); + const hole = new BigNumber(data.hole._hex).div(RAD); + const dirt = new BigNumber(data.dirt._hex).div(RAD); const diff = hole.minus(dirt); return { hole, dirt, diff }; } @@ -311,15 +313,15 @@ export default class LiquidationService extends PublicService { this._dogContract().Hole(), this._dogContract().Dirt() ]); - const hole = new BigNumber(h).div(RAD); - const dirt = new BigNumber(d).div(RAD); + const hole = new BigNumber(h._hex).div(RAD); + const dirt = new BigNumber(d._hex).div(RAD); const diff = hole.minus(dirt); return { hole, dirt, diff }; } async getChost(ilk) { const chost = await this._clipperContractByIlk(ilk).chost(); - return new BigNumber(chost).div(RAD); + return new BigNumber(chost._hex).div(RAD); } async getTail(ilk) { @@ -329,7 +331,7 @@ export default class LiquidationService extends PublicService { async getCusp(ilk) { const cusp = await this._clipperContractByIlk(ilk).cusp(); - return new BigNumber(cusp).div(RAY); + return new BigNumber(cusp._hex).div(RAY); } // @tracksTransactions diff --git a/packages/dai-plugin-liquidations/test/LiquidationService.test.js b/packages/dai-plugin-liquidations/test/LiquidationService.test.js index 82f191fcc..af725b7e3 100644 --- a/packages/dai-plugin-liquidations/test/LiquidationService.test.js +++ b/packages/dai-plugin-liquidations/test/LiquidationService.test.js @@ -266,7 +266,7 @@ describe('LiquidationService', () => { console.log('data', holeAndDirt); }, 10000); - xtest('getChost', async () => { + test('getChost', async () => { const chost = await service.getChost(ilk); console.log('chost', chost); }, 10000);