-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vc/io1 2848 min collateral #24
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e37ebbf
wip
vadiminc 07cea94
Merge branch 'stage' into vc/IO1-2848_min_collateral
vadiminc 09ac3fa
Merge branch 'stage' into vc/IO1-2848_min_collateral
vadiminc db6d580
add logic
vadiminc 618fe3b
fix balance for liquidated
vadiminc 22c3510
add comments
vadiminc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
import { Injectable, Logger } from '@nestjs/common'; | ||
import { SystemType } from '@cli/modules/system/system.service'; | ||
import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; | ||
|
||
import Web3Provider from '@cli/providers/web3.provider'; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove empty lines and sort all the imports from shortest to longest (project imports separately from external imports) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
import { SystemService, SystemType } from '@cli/modules/system/system.service'; | ||
import { ClusterService } from '@cli/modules/clusters/cluster.service'; | ||
import { EarningService } from '@cli/modules/earnings/earning.service'; | ||
|
||
@Injectable() | ||
export class WorkerService { | ||
export class WorkerService implements OnModuleInit { | ||
private readonly _logger = new Logger(WorkerService.name); | ||
|
||
constructor( | ||
private _clusterService: ClusterService, | ||
private _earningService: EarningService, | ||
private _systemService: SystemService, | ||
) {} | ||
|
||
async onModuleInit() { | ||
await this._systemService.save( | ||
SystemType.MINIMUM_LIQUIDATION_COLLATERAL, | ||
await Web3Provider.getMinimumLiquidationCollateral(), | ||
); | ||
} | ||
|
||
async processEvents(events: Array<any>): Promise<void> { | ||
if (!events.length) { | ||
this._logger.log(`There is no events in this block range`); | ||
|
@@ -47,6 +58,12 @@ export class WorkerService { | |
case SystemType.EVENT_VALIDATOR_ADDED: | ||
await this._clusterService.create(dataItem); | ||
break; | ||
case SystemType.EVENT_COLLATERAL_UPDATED: | ||
await this._systemService.save( | ||
SystemType.MINIMUM_LIQUIDATION_COLLATERAL, | ||
await Web3Provider.getMinimumLiquidationCollateral(), | ||
); | ||
break; | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add explanation comments for all the conditions for other developers to understand the logic behind with minimum efforts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok