Skip to main content
Version: Next

staking_bonded_delegated_balance/2

Module​

This predicate is provided by staking.pl.

Load this module before using the predicate:

:- consult('/v1/lib/staking.pl').

Description​

Unifies Balance with coin(BondDenom, Amount), the sum of delegations to bonded validators. Empty eligible collections return coin(BondDenom, 0), using the staking bond denomination. Amount is an integer when it fits in int64, otherwise a decimal atom. Addition is exact, including amounts and totals larger than int64. A mismatching coin denomination raises domain_error(staking_bond_denom, Denom); different denominations are never added. Unbondings, redelegation entries, rewards, and bank balances are excluded.

Signature​

staking_bonded_delegated_balance(+Delegator, -Balance) is det

Examples​

Sum bonded delegations including a jailed bonded validator​

Here is the feature setup:

  • Given the program:
:- consult('/v1/lib/staking.pl').
  • And the staking bond denomination is "ustake"
  • And the staking validators:
operatorstatusjailed
axonevaloper1bondedbondedfalse
axonevaloper1jailedbondedtrue
axonevaloper1unbondingunbondingfalse
axonevaloper1unbondedunbondedfalse

Here are the steps of the scenario:

  • Given the account "axone1ffd5wx65l407yvm478cxzlgygw07h79sw4jwpa" has the following staking delegations:
validatordenomamount
axonevaloper1unbondingustake900
axonevaloper1jailedustake75
axonevaloper1unbondedustake800
axonevaloper1bondedustake25
  • And the query:
staking_bonded_delegated_balance('axone1ffd5wx65l407yvm478cxzlgygw07h79sw4jwpa', Balance).
  • When the query is run
  • Then the logical answer we get is:
answer:
has_more: false
variables: [Balance]
results:
- substitutions:
- variable: Balance
expression: "coin(ustake,100)"