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: add totalAssetValue in GetAccount API response #214

Merged
merged 8 commits into from
Oct 11, 2022

Conversation

carlcarl
Copy link
Contributor

@carlcarl carlcarl commented Oct 3, 2022

Description

Add totalAssetValue in GetAccount API response.

Rationale

Account page need show the value

Example

N/A

Changes

N/A

/update-integration-keyfile

@carlcarl carlcarl marked this pull request as draft October 3, 2022 10:41
@carlcarl carlcarl added the ready for review ready for review label Oct 4, 2022
@carlcarl carlcarl marked this pull request as ready for review October 4, 2022 03:20
@@ -76,6 +77,9 @@ func (l *GetAccountLogic) GetAccount(req *types.ReqGetAccount) (resp *types.Acco
Nonce: account.Nonce,
Assets: make([]*types.AccountAsset, 0, len(account.AssetInfo)),
}

totalAssetPrice := big.NewFloat(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

price seems to be not a good name. How about totalAssetAmount or totalAssetValue? Can you refer to some dapp (e.g., pancake, uniswap) for the name

Copy link
Collaborator

Choose a reason for hiding this comment

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

totalAssetValue seems better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, OK.
Thanks 👍

// 1. Convert unit of balance from wei to BNB
// 2. Calculate the result of (BNB balance * price per BNB)
balanceInFloat := new(big.Float).SetInt(asset.Balance)
unitConversion := new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Different assets have different units. Decimal field of asset is for this, i believe.

| pk | string | | Yes |
| nonce | long | | Yes |
| assets | [ [AccountAsset](#accountasset) ] | | Yes |
| total_asset_price | string | | Yes |
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to change the doc

@carlcarl carlcarl changed the title feat: add totalAssetPrice in GetAccount API response feat: add totalAssetAmount in GetAccount API response Oct 10, 2022
@carlcarl carlcarl changed the title feat: add totalAssetAmount in GetAccount API response feat: add totalAssetValue in GetAccount API response Oct 11, 2022
@carlcarl carlcarl merged commit a636b56 into develop Oct 11, 2022
@carlcarl carlcarl deleted the feat/calculate-total-asset-price-in-account-api branch November 11, 2022 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants