Skip to content

feat: Add transferable field to /accounts/{accountId}/balance-info#1722

Merged
TarikGul merged 5 commits into
masterfrom
tg-transferable
Aug 1, 2025
Merged

feat: Add transferable field to /accounts/{accountId}/balance-info#1722
TarikGul merged 5 commits into
masterfrom
tg-transferable

Conversation

@TarikGul

@TarikGul TarikGul commented Jul 30, 2025

Copy link
Copy Markdown
Member

Add transferable balance field and documentation

This PR adds the transferable field to balance-info endpoints and provides documentation explaining its calculation.

Changes

  • Added transferable field to the IAccountBalanceInfo interface with detailed JSDoc documentation
  • Updated OpenAPI schema to include the transferable field for both balance-info endpoints:
    • /accounts/{accountId}/balance-info
    • /rc/accounts/{address}/balance-info

Transferable Balance Formula

The transferable balance uses the formula: free - max(maybeEd, frozen - reserve)

Where:

  • maybeEd is the existential deposit if there are frozen funds or reserves, otherwise zero
  • This represents the actual spendable balance after accounting for locks, reserves, and the existential deposit

NOTE: The polkadot-js implementation I am using here is a UI-friendly calculation that considers:

  • When the account has NO reserves and NO frozen funds, the user can practically transfer their entire free balance.
  • When the account HAS reserves or frozen funds, the ED must be protected

@TarikGul TarikGul requested a review from a team as a code owner July 30, 2025 13:47

@filvecchiato filvecchiato left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀

Comment thread src/types/responses/AccountBalanceInfo.ts
@TarikGul

TarikGul commented Aug 1, 2025

Copy link
Copy Markdown
Member Author

Merging, Controller Injection tests are failing again which is fine.

@TarikGul TarikGul merged commit 38e4d3f into master Aug 1, 2025
19 of 21 checks passed
@TarikGul TarikGul deleted the tg-transferable branch August 1, 2025 12:30
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.

3 participants