Skip to content

Commit

Permalink
fix: calculation order change
Browse files Browse the repository at this point in the history
  • Loading branch information
yevhen-burkovskyi committed Jul 9, 2024
1 parent 80e20f5 commit d9fe10c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/modules/supply/dtos/supply-change.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface SupplyChangeDto {
time: Date;
change: number;
burnt: number;
issuance: number;
change: string;
burnt: string;
issuance: string;
}
10 changes: 5 additions & 5 deletions src/modules/supply/services/supply.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ export class SupplyService implements OnModuleInit {
const currentSupply = await this.getSupplyByOrder();
const supplyChange: SupplyChangeDto = {
time: new Date(),
change: 0,
burnt: 0,
issuance: 0,
change: '0',
burnt: '0',
issuance: '0',
};

if (previousSupply && currentSupply) {
supplyChange.time = currentSupply.time;
supplyChange.change = supplyChange.issuance - supplyChange.burnt;
supplyChange.issuance = Big(currentSupply.supply).minus(previousSupply.supply).toNumber();
supplyChange.issuance = Big(currentSupply.supply).minus(previousSupply.supply).toFixed(2);
supplyChange.change = Big(supplyChange.issuance).minus(supplyChange.burnt).toFixed(2);
}

await this.cache.setSupplyChange(range, supplyChange);
Expand Down

0 comments on commit d9fe10c

Please sign in to comment.