-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat: standardize event data for mint and burn none-interest #305
Closed
Tzienom
wants to merge
5
commits into
CarmineOptions:master
from
Tzienom:feat/standardize-event-data
Closed
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
931674a
feat: standardize event data for mint and burn none-interest
Tzienom ddc06bc
fix: remove duplicate code
Tzienom d011256
Merge branch 'CarmineOptions:master' into feat/standardize-event-data
Tzienom 2b71ca9
refact: events implementation
Tzienom eac5d72
fix: update nostra model
Tzienom 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -372,6 +372,7 @@ def process_non_interest_bearing_collateral_mint_event(self, event: pd.Series) - | |
sender = add_leading_zeros(event["data"][0]) | ||
recipient = add_leading_zeros(event["data"][1]) | ||
raw_amount = decimal.Decimal(str(int(event["data"][2], base=16))) | ||
parsed_event = NostraDataParser.parse_non_interest_bearing_collateral_mint_event(event["data"]) | ||
else: | ||
raise ValueError("Event = {} has an unexpected structure.".format(event)) | ||
if self.ZERO_ADDRESS in {sender, recipient}: | ||
|
@@ -398,6 +399,7 @@ def process_non_interest_bearing_collateral_mint_event(self, event: pd.Series) - | |
) | ||
) | ||
|
||
|
||
def process_collateral_mint_event(self, event: pd.Series) -> None: | ||
"""Process collateral addition event for a loan.""" | ||
if event["keys"] == [self.MINT_KEY]: | ||
|
@@ -500,26 +502,40 @@ def process_non_interest_bearing_collateral_burn_event(self, event: pd.Series) - | |
# Example: | ||
# https://starkscan.co/event/0x00744177ee88dd3d96dda1784e2dff50f0c989b7fd48755bc42972af2e951dd6_1. | ||
user = event["data"][0] | ||
if user == self.IGNORE_USER: | ||
parsed_event = NostraDataParser.parse_non_interest_bearing_collateral_burn_event(event["data"]) | ||
if user == self.IGNORE_USER | parsed_event == self.IGNORE_USER: | ||
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. why did you change this code? |
||
return | ||
token = self.ADDRESSES_TO_TOKENS[event["from_address"]] | ||
raw_amount = parsed_event.face_amount / self.collateral_interest_rate_models.values[token] | ||
face_amount = decimal.Decimal(str(int(event["data"][1], base=16))) | ||
raw_amount = face_amount / self.collateral_interest_rate_models.values[token] | ||
# add additional info block and timestamp | ||
self.loan_entities[user].extra_info.block = event["block_number"] | ||
self.loan_entities[user].extra_info.timestamp = event["timestamp"] | ||
self.loan_entities[parsed_event.user].extra_info.block = event["block_number"] | ||
self.loan_entities[parsed_event.user].extra_info.timestamp = event["timestamp"] | ||
|
||
self.loan_entities[user].non_interest_bearing_collateral.increase_value( | ||
token=token, value=-raw_amount | ||
) | ||
self.loan_entities[parsed_event.user].non_interest_bearing_collateral.increase_value( | ||
token=token, value=-raw_amount | ||
) | ||
self.loan_entities[user].collateral.values = { | ||
token: ( | ||
self.loan_entities[user].non_interest_bearing_collateral.values[token] + | ||
self.loan_entities[user].interest_bearing_collateral.values[token] | ||
) | ||
for token in NOSTRA_ALPHA_SPECIFIC_TOKEN_SETTINGS | ||
} | ||
if user == self.verbose_user: | ||
self.loan_entities[parsed_event.user].collateral.values = { | ||
token: ( | ||
self.loan_entities[parsed_event.user].non_interest_bearing_collateral.values[token] + | ||
self.loan_entities[parsed_event.user].interest_bearing_collateral.values[token] | ||
) | ||
for token in NOSTRA_ALPHA_SPECIFIC_TOKEN_SETTINGS | ||
} | ||
if user == self.verbose_user | parsed_event.user == self.verbose_user: | ||
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. why did you change it |
||
logging.info( | ||
"In block number = {}, non-interest-bearing collateral of raw amount = {} of token = {} was withdrawn." | ||
.format( | ||
|
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.
why you didn't remove these fields?