Skip to content

Commit

Permalink
added total value in usd and egld at each enter market event timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
GuticaStefan committed Sep 19, 2024
1 parent 779b9be commit e43b6cf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libs/services/src/events/hatom.enter.market.events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ export class HatomEnterMarketEventsService {
{ name: 'borrower_address', type: 'varchar' },
{ name: 'value_in_egld', type: 'double' },
{ name: 'value_in_usd', type: 'double' },
{ name: 'value_value_in_usd', type: 'double' },
{ name: 'total_value_in_egld', type: 'double' },
];
private readonly moneyMarketNotFound = "Money Market Not Found!";
private totalValueInUsd: BigNumber = new BigNumber(0);
private totalValueInEgld: BigNumber = new BigNumber(0);

constructor(
private readonly csvRecordsService: CsvRecordsService,
Expand Down Expand Up @@ -62,6 +66,8 @@ export class HatomEnterMarketEventsService {
currentEvent.borrowerAddress,
valueInEgld.shiftedBy(-tokenPrecision).decimalPlaces(4),
valueInUsd.shiftedBy(-tokenPrecision).decimalPlaces(4),
this.totalValueInUsd.shiftedBy(-tokenPrecision).decimalPlaces(4),
this.totalValueInEgld.shiftedBy(-tokenPrecision).decimalPlaces(4),
),
],
this.headers,
Expand All @@ -88,6 +94,9 @@ export class HatomEnterMarketEventsService {
const valueInUsd = currentEvent.amount.multipliedBy(tokenPrice);
const valueInEgld = valueInUsd.dividedBy(egldPrice);

this.totalValueInUsd = this.totalValueInUsd.plus(valueInUsd);
this.totalValueInEgld = this.totalValueInEgld.plus(valueInEgld);

return [valueInEgld, valueInUsd];
}

Expand Down

0 comments on commit e43b6cf

Please sign in to comment.