Staking

API

class terra_sdk.client.lcd.api.staking.StakingAPI(c)[source]
bonded_validators(delegator, params=None)[source]

Fetches the list of validators a delegator is currently delegating to.

Parameters
  • delegator (AccAddress) – delegator account address

  • params (APIParams, optional) – additional params for the API like pagination

Returns

currently bonded validators dict: pagination info

Return type

List[Validator]

delegation(delegator, validator)[source]

Fetch a single delegation via a delegator, validator pair.

Parameters
  • delegator (Optional[AccAddress) – delegator account address

  • validator (Optional[ValAddress], optional) – validator operator address

Returns

delegation

Return type

Delegation

delegations(delegator=None, validator=None, params=None)[source]

Fetches current delegations, filtering by delegator, validator, or both.

Parameters
  • delegator (Optional[AccAddress], optional) – delegator account address.

  • validator (Optional[ValAddress], optional) – validator operator address.

  • params (APIParams, optional) – additional params for the API like pagination

Raises

TypeError – if both delegator and validator are None.

Returns

delegations dict: pagination info

Return type

List[Delegation]

parameters()[source]

Fetch Staking module parameters.

Returns

Staking module parameters

Return type

dict

pool()[source]

Fetch current staking pool information.

Returns

information about current staking pool

Return type

StakingPool

redelegations(delegator=None, validator_src=None, validator_dst=None, params=None)[source]

Fetch redelgations.

Parameters
  • delegator (Optional[AccAddress], optional) – delegator account address.

  • validator_src (Optional[ValAddress], optional) – source validator operator address (from).

  • validator_dst (Optional[ValAddress], optional) – dest. validator operator address (to).

  • params (APIParams, optional) – additional params for the API like pagination

Returns

redelegations dict: pagination info

Return type

List[Redelegation]

unbonding_delegation(delegator, validator)[source]

Fetch a single undelegation via a delegator, validator pair.

Parameters
  • delegator (AccAddress) – delegator account address

  • validator (ValAddress) – validator operator address

Returns

undelegation

Return type

UnbondingDelegation

unbonding_delegations(delegator=None, validator=None, params=None)[source]

Fetches current undelegations, filtering by delegator, validator, or both.

Parameters
  • delegator (Optional[AccAddress], optional) – delegator account address.

  • validator (Optional[ValAddress], optional) – validator operator address.

  • params (APIParams, optional) – additional params for the API like pagination

Raises

TypeError – if both delegator and validator are None.

Returns

undelegations dict: pagination info

Return type

List[UnbondingDelegation]

validator(validator)[source]

Fetch information about a single validator.

Parameters

validator (ValAddress) – validator operator address

Returns

validator information

Return type

Validator

validators(params)[source]

Fetch information of all validators.

Parameters

params (APIParams, optional) – additional params for the API like pagination

Returns

validator informations dict: pagination info

Return type

List[Validator]

Data

Delegation

class terra_sdk.core.staking.data.delegation.Delegation(delegation, balance)[source]

Contains information about a current delegation pair (delegator_address, validator_address)

class terra_sdk.core.staking.data.delegation.Redelegation(redelegation, entries)[source]

Contains informations about a redelgation for delegation tuple (delegator_address, validator_src_address, validator_dst_address)

entries: List[terra_sdk.core.staking.data.delegation.RedelegationEntry]
redelegation: terra_sdk.core.staking.data.delegation.RedelegationInfo
class terra_sdk.core.staking.data.delegation.RedelegationEntry(redelegation_entry, balance)[source]

Contains information about an active redelegated lot of Luna.

balance: int
redelegation_entry: terra_sdk.core.staking.data.delegation.RedelegationEntryInfo
to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

class terra_sdk.core.staking.data.delegation.UnbondingDelegation(delegator_address, validator_address, entries)[source]

Contains information about undelegations for a delegation pair (delegator_address, validator_address)

delegator_address: AccAddress
entries: List[terra_sdk.core.staking.data.delegation.UnbondingDelegationEntry]
validator_address: ValAddress
class terra_sdk.core.staking.data.delegation.UnbondingDelegationEntry(initial_balance, balance, creation_height, completion_time)[source]

Contains information about an active unbonding lot of Luna.

balance: int
completion_time: datetime.datetime
creation_height: int
initial_balance: int
to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

Validator

class terra_sdk.core.staking.data.validator.BondStatus(value)[source]

BondStatus is the status of a validator.

class terra_sdk.core.staking.data.validator.Commission(commission_rates, update_time)[source]

Contains information about validator’s commission rates.

commission_rates: terra_sdk.core.staking.data.validator.CommissionRates

Validator commission rates.

update_time: datetime.datetime

Last time commission rates were updated.

class terra_sdk.core.staking.data.validator.CommissionRates(rate, max_rate, max_change_rate)[source]

Data structure for validator’s commission rates & policy.

max_change_rate: terra_sdk.core.numeric.Dec

Maximum % change of commission per day.

max_rate: terra_sdk.core.numeric.Dec

Maximum % commission rate permitted by policy.

rate: terra_sdk.core.numeric.Dec

Current % commission rate.

class terra_sdk.core.staking.data.validator.Description(moniker='', identity='', website='', details='', security_contact='')[source]

Validator description entry.

Parameters
  • moniker (str) – validator name, aka: “Terran One”

  • identity (str) – keybase.io identifier (used for setting logo)

  • website (str) – validator website

  • details (str) – longer description of validator

  • security_contact (str) – contact information for validator

DO_NOT_MODIFY = '[do-not-modify]'
class terra_sdk.core.staking.data.validator.Validator(operator_address, consensus_pubkey, jailed, status, tokens, delegator_shares, description, unbonding_height, unbonding_time, commission, min_self_delegation)[source]

Contains information about a registered validator.

commission: terra_sdk.core.staking.data.validator.Commission
consensus_pubkey: terra_sdk.core.public_key.ValConsPubKey
delegator_shares: terra_sdk.core.numeric.Dec
description: terra_sdk.core.staking.data.validator.Description
jailed: bool
min_self_delegation: int
operator_address: ValAddress
status: terra_proto.cosmos.staking.v1beta1.BondStatus
to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

tokens: int
unbonding_height: int
unbonding_time: datetime.datetime

Messages

Staking module message types.

class terra_sdk.core.staking.msgs.MsgBeginRedelegate(delegator_address, validator_src_address, validator_dst_address, amount)[source]

Redelegate staked Luna from validator_src_address to valdiator_dst_address.

Parameters
  • delegator_address (AccAddress) – delegator

  • validator_src_address (ValAddress) – validator to remove delegation FROM

  • validator_dst_address (ValAddress) – validator to transfer delegate TO

  • amount (Union[str, dict, Coin]) – coin (LUNA) to redelegate

action = 'begin_redelegate'
type_amino = 'staking/MsgBeginRedelegate'
type_url: str = '/cosmos.staking.v1beta1.MsgBeginRedelegate'
class terra_sdk.core.staking.msgs.MsgCreateValidator(description, commission, min_self_delegation, delegator_address, validator_address, pubkey, value)[source]

Register a new validator with the Terra protocol.

Parameters
  • description (Description) – validator description

  • commission (CommissionRates) – validator commission rates

  • min_self_delegation (int) – minimum self-delegation policy

  • delegator_address (AccAddress) – validator’s account address

  • validator_address (ValAddress) – validator’s operator address

  • pubkey (ValConsPubKey) – validator consensus (Tendermint) public key

  • value (Coin.Input) – initial amount of Luna toi self-delegate

action = 'create_validator'
type: str = 'staking/MsgCreateValidator'
type_url: str = '/cosmos.staking.v1beta1.MsgCreateValidator'
class terra_sdk.core.staking.msgs.MsgDelegate(delegator_address, validator_address, amount)[source]

Delegate Luna to validator at validator_address.

Parameters
  • delegator_address (AccAddress) – delegator

  • validator_address (ValAddress) – validator to delegate to

  • amount (Union[str, dict, Coin]) – coin (LUNA) to delegate

action = 'delegate'
type_amino = 'staking/MsgDelegate'
type_url: str = '/cosmos.staking.v1beta1.MsgDelegate'
class terra_sdk.core.staking.msgs.MsgEditValidator(description, validator_address, commission_rate=None, min_self_delegation=None)[source]

Revise validator description and configuration.

Parameters
  • description (Description) – updated validator description

  • validator_address (NewType()(ValAddress, str)) – validator operator address

  • commission_rates – new validator commission rate,

  • min_self_delegation (Optional[int]) – new minimum self delegation,

action = 'edit_validator'
type: str = 'staking/MsgEditValidator'
type_url: str = '/cosmos.staking.v1beta1.MsgEditValidator'
class terra_sdk.core.staking.msgs.MsgUndelegate(delegator_address, validator_address, amount)[source]

Undelegate Luna from staking position with validator_address.

Parameters
  • delegator_address (AccAddress) – delegator

  • validator_address (ValAddress) – validator to undelegate from

  • amount (Union[str, dict, Coin]) – coin (LUNA) to undelegate

action = 'begin_unbonding'
type_amino = 'staking/MsgUndelegate'
type_url: str = '/cosmos.staking.v1beta1.MsgUndelegate'