Skip to content

Commit

Permalink
chore: computing of unrealizedProfitByPeriod
Browse files Browse the repository at this point in the history
  • Loading branch information
filo87 committed Jun 11, 2024
1 parent fdd53ab commit 5c147ef
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 0 additions & 1 deletion src/mappings/handlers/blockHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async function _handleBlock(block: SubstrateBlock): Promise<void> {
for (const loanId in activeLoanData) {
const asset = await AssetService.getById(pool.id, loanId)
await asset.updateActiveAssetData(activeLoanData[loanId])

await asset.updateUnrealizedProfit(
await AssetPositionService.computeUnrealizedProfitAtPrice(asset.id, asset.currentPrice),
await AssetPositionService.computeUnrealizedProfitAtPrice(asset.id, asset.notional)
Expand Down
6 changes: 1 addition & 5 deletions src/mappings/services/assetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,9 @@ export class AssetService extends Asset {

public updateUnrealizedProfit(atMarketPrice: bigint, atNotional: bigint) {
logger.info(`Updating unrealizedProfit for asset ${this.id}: ${atMarketPrice}, ${atNotional}`)
this.unrealizedProfitByPeriod = atMarketPrice - this.unrealizedProfitAtMarketPrice
this.unrealizedProfitAtMarketPrice = atMarketPrice
this.unrealizedProfitAtNotional = atNotional

logger.info(
`byPeriod: ${atMarketPrice} - ${this.unrealizedProfitByPeriod} = ${atMarketPrice - this.unrealizedProfitByPeriod}`
)
this.unrealizedProfitByPeriod = atMarketPrice - this.unrealizedProfitByPeriod
}
}

Expand Down

0 comments on commit 5c147ef

Please sign in to comment.