Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Fix big nums in liq service (#310)
Browse files Browse the repository at this point in the history
* Fix big nums

* enable chost test

* Formatting

Co-authored-by: Phil Bain <[email protected]>
  • Loading branch information
adamgoth and b-pmcg authored Nov 19, 2021
1 parent de5d3fe commit c817762
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions packages/dai-plugin-liquidations/src/LiquidationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 };
}
Expand All @@ -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) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c817762

Please sign in to comment.