Skip to content

Commit 1871163

Browse files
Merge pull request #3624 from autonomys/nominator-position-api
Add Nominator Position Runtime API
2 parents 92f0967 + 76dfc83 commit 1871163

File tree

7 files changed

+1181
-5
lines changed

7 files changed

+1181
-5
lines changed

crates/pallet-domains/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod bundle_storage_fund;
1414
pub mod domain_registry;
1515
pub mod extensions;
1616
pub mod migrations;
17+
mod nominator_position;
1718
pub mod runtime_registry;
1819
pub mod staking;
1920
mod staking_epoch;
@@ -3134,6 +3135,26 @@ impl<T: Config> Pallet<T> {
31343135
) -> Option<sp_domains::PermissionedActionAllowedBy<EthereumAccountId>> {
31353136
EvmDomainContractCreationAllowedByCalls::<T>::get(domain_id).maybe_call
31363137
}
3138+
3139+
/// Returns the complete nominator position for a given operator and account at the current block.
3140+
///
3141+
/// This calculates the total position including:
3142+
/// - Current stake value (converted from shares using instant share price including rewards)
3143+
/// - Total storage fee deposits (known + pending)
3144+
/// - Pending deposits (not yet converted to shares)
3145+
/// - Pending withdrawals (with unlock timing)
3146+
///
3147+
/// Note: Operator accounts are also nominator accounts, so this call will return the position
3148+
/// for the operator account.
3149+
///
3150+
/// Returns None if no position exists for the given operator and account at the current block.
3151+
pub fn nominator_position(
3152+
operator_id: OperatorId,
3153+
nominator_account: T::AccountId,
3154+
) -> Option<sp_domains::NominatorPosition<BalanceOf<T>, DomainBlockNumberFor<T>, T::Share>>
3155+
{
3156+
nominator_position::nominator_position::<T>(operator_id, nominator_account)
3157+
}
31373158
}
31383159

31393160
impl<T: Config> sp_domains::DomainOwner<T::AccountId> for Pallet<T> {

0 commit comments

Comments
 (0)