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

[ABW-2889] properly compute unstake values. #777

Merged
merged 5 commits into from
Feb 1, 2024

Conversation

jakub-rdx
Copy link
Contributor

@jakub-rdx jakub-rdx commented Jan 30, 2024

Description

  • properly compute unstake xrd worth based on data returned in RET 1.0.9 and group withdrawals if there would be multiple entries for a same resource returned from RET
  • use resolveAssetsFromAddressUseCase in PoolContributionProcessor, drop separate calls to fetch pools

How to test

  1. Ensure you have at least 2 accounts with stakes to the same validator.
  2. Trigger Unstake from this validator for those accounts .

Screenshot

PR submission checklist

  • I have tested unstake tx with multiple account unstakes from same validator

@jakub-rdx jakub-rdx changed the title properly compute unstake values [ABW-2889] properly compute unstake values. Jan 30, 2024
Base automatically changed from fix/ABW-2846-guarantees to main January 30, 2024 15:05
@jakub-rdx jakub-rdx force-pushed the fix/ABW-2889-unstake-values-fix branch from ced05a9 to 7453d87 Compare January 30, 2024 15:12
val ownedAccount = getProfileUseCase.accountOnCurrentNetwork(depositsPerAddress.key) ?: error("No account found")
val deposits = depositsPerAddress.value.map { deposit ->
val resourceAddress = deposit.resourceAddress
val contributions = classification.poolContributions.filter {
it.poolUnitsResourceAddress.addressString() == resourceAddress
}
if (contributions.isEmpty()) {
resolveGeneralAsset(deposit, summary, assets, defaultDepositGuarantee)
resolveGeneralAsset(deposit, this, assets, defaultDepositGuarantee)
} else {
val pool = involvedPools.find { it.address == contributions.first().poolAddress.addressString() }
Copy link
Contributor

Choose a reason for hiding this comment

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

Improvement for the future:
These 6 lines could be also replaced if you didn't filter for involved pools only.

You could just find the pool unit by the resource address. Inside the pool unit object you have all you need.

  • pool (with metadata and associated dapps)
  • associated resources
  • unit fungible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense. please verify if the recent change reflect what you had in mind

Copy link
Contributor

@micbakos-rdx micbakos-rdx left a comment

Choose a reason for hiding this comment

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

I see wrong claim values again deposited to the accounts
Screen_recording_20240131_111029.webm

Copy link

sonarcloud bot commented Jan 31, 2024

Quality Gate Failed Quality Gate failed

Failed conditions

0.0% Coverage on New Code (required ≥ 40%)

See analysis details on SonarCloud

@jakub-rdx jakub-rdx merged commit 99a40cd into main Feb 1, 2024
8 of 9 checks passed
@jakub-rdx jakub-rdx deleted the fix/ABW-2889-unstake-values-fix branch February 1, 2024 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants