WIP: Liquidator bot - currently active positions#28
Draft
WIP: Liquidator bot - currently active positions#28
Conversation
…urate list of open accounts
…l queryeach startup
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
WIP. below description is from old version, I'm just keeping it for reference
Builds a list of currently active positions to later be watched for potential liquidations. Logs are just so I can monitor while running and are temporary.
An active position is defined as a
MarketEntered(CToken cToken, address account)event that doesn't have a correspondingMarketExited(CToken cToken, address account)event with the same parameters. When we find a MarketExited event, we search the list of currently active positions for the corresponding MarketEntered and remove it.On start,
chainReaderlaunches 2 processes concurrently:getHistoricPositions()queries for all previous MarketEntered/Exited events and trims out MarketEntered events that match a MarketExited. Returns when it reaches the block chainReader started on.listenForUpdates()starts event listeners for MarketEntered/Exited events. Doesn't return, continuously updates and trims our list of active positions.When
getHistoricPositions()returns, combine its found list of active positions with the list of active positions maintained bylistenForUpdates()resulting in an updated list of all active positions to monitor. This approach makes sure we don't miss any new events while we are querying historic positions. We then save the list of active positions toactivePositions.jsonwhich is loaded at startup so we don't have to query all previous events every time.Please see TODOs in
executionClients/liquidator/reader.ts. I had a few questions/ assumptions that need clarification.Also please tear this apart if there are better ways to do anything. I want to learn :)