Skip to content
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: accumulate locked balance in TokenHolder collection batch #472

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

purplesmoke05
Copy link
Member

@purplesmoke05 purplesmoke05 commented Jan 31, 2023

Close #471

Changes

Batch

  • indexer_token_holders.py
    • Modified batch to accumulate data of locked balances in given block number.
    • Modified so that locked amount is NOT included in hold balance.

API

  • GET: /holders/{token_address}/collection
    • Modified TokenHolder collection to return locked balance in given block number.

@purplesmoke05 purplesmoke05 self-assigned this Jan 31, 2023
Comment on lines +89 to +100
class TokenHoldersCollectionHolder(BaseModel):
account_address: str = Field(description="Account address of token holder.")
hold_balance: int = Field(description="Amount of balance."
"This includes balance/pending_transfer/exchange_balance/exchange_commitment.")
locked_balance: int = Field(description="Amount of locked balance.")


class RetrieveTokenHoldersListResponse(BaseModel):
"""Retrieve Token Holders List schema (RESPONSE)"""

status: TokenHolderBatchStatus
holders: List[Dict[str, Union[int, str]]]
holders: List[TokenHoldersCollectionHolder]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed Response schema.

Comment on lines +56 to +65
def store(self, account_address: str, amount: int = 0, locked: int = 0):
if account_address not in self.pages:
token_holder = TokenHolder()
token_holder.hold_balance = amount
token_holder.hold_balance = 0 + amount
token_holder.account_address = account_address
token_holder.locked_balance = 0 + locked
self.pages[account_address] = token_holder
else:
self.pages[account_address].hold_balance += amount
self.pages[account_address].locked_balance += locked
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Added locked_balance field.
    • Each method in processor calls this to accumulate locked amount.
    • locked balance is to be counted separately from hold balance.

@purplesmoke05 purplesmoke05 marked this pull request as ready for review January 31, 2023 08:30
@YoshihitoAso YoshihitoAso merged commit 015acac into dev-23.3 Feb 1, 2023
@YoshihitoAso YoshihitoAso deleted the feature/#471 branch February 1, 2023 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Count up locked amount in TokenHolders collection batch
2 participants