Skip to main content

distribution

Abstract

The distribution precompiled contract acts as a bridge to enable the Stable SDK's x/distribution module functionality to be used in an EVM environment.

Contents

  1. Concepts
  2. Configuration
  3. Methods
  4. Events

Concepts

In distribution precompiled contract, additional checks are made to ensure that the delegator or depositor is a caller.

Configuration

Contract address and gas cost is predefined.

Contract Address

  • 0x0000000000000000000000000000000000001002

Methods

setWithdrawAddress

Sets the address to receive the reward for the token delegated by the delegator to the validator. Sometimes, when the delegator is self-delegated, the validator address is used as the delegator.

SetWithdrawAddress is emitted when the withdrawer address is successfully set.

Inputs

NameTypeDescription
delegatorAddressaddressthe address of the delegator
withdrawerAddressstringthe address to receive the reward of delegation

Outputs

NameTypeDescription
successbooltrue if the withdrawer address is successfully set

withdrawDelegatorRewards

Withdraws the reward to be received by the delegator from the validator. All types of tokens that validator rewards to delegator is withdrawn in a single transaction.

WithdrawDelegatorRewards is emitted when the reward is successfully withdrawn.

Inputs

NameTypeDescription
delegatorAddressaddressthe address of the delegator
validatorAddressstringthe address of the validator

Outputs

NameTypeDescription
amountCoin[]rewards of various tokens to be received by the delegator

Coin is a struct with the following fields:

NameTypeDescription
denomstringthe denom of the reward
amountuint256the amount of the reward

withdrawValidatorCommission

Withdraws the commission of the validator. All types of tokens that validator receives as commission is withdrawn in a single transaction.

WithdrawValidatorCommission is emitted when the commission is successfully withdrawn.

Inputs

NameTypeDescription
validatorAddressstringthe address of the validator

Outputs

NameTypeDescription
amountCoin[]commissions of various tokens to be received by the validator

validatorDistributionInfo

Returns the distribution information representing the reward the validator will receive. Validator can delegate tokens to himself at his own address to acts as a delegator called self-bonded.

Inputs

NameTypeDescription
validatorAddressstringthe address of the validator

Outputs

NameTypeDescription
distributionInfoValidatorDistributionInfodistribution information of the validator

ValidatorDistributionInfo is a struct with the following fields:

NameTypeDescription
operatorAddressstringthe address of the operator of the validator
selfBondRewardsDecCoin[]the self-bonded amount of the validator
commissionDecCoin[]the commission of the validator

DecCoin is a struct with the following fields:

NameTypeDescription
denomstringthe denom of the reward
amountuint256the amount of the reward
precisionuint8the precision of the reward

validatorOutstandingRewards

Returns the outstanding rewards of the validator. Outstanding rewards indicates total amount of rewards consists of commission and self-bonded rewards of validator and total rewards of delegators. If there is a validator A and delegators B, C, and D delegate to A, Outstanding rewards of validator is the sum of commission and self-bonded rewards of A + rewards of B, C, and D.

Inputs

NameTypeDescription
validatorAddressstringthe address of the validator

Outputs

NameTypeDescription
rewardsDecCoin[]outstanding rewards of the validator

validatorCommission

Returns the commission of the validator. This method is used to retrieve the commission of the validator before calling withdrawValidatorCommission method.

Inputs

NameTypeDescription
validatorAddressstringthe address of the validator

Outputs

NameTypeDescription
commissionDecCoin[]commission of the validator

validatorSlashes

Returns the history of slashes of the validator between the starting height and ending height. Slashing is the fines imposed when a validator behaves maliciously or violates network rules such as double signing, misbehavior, or not following the chain rules.

Inputs

NameTypeDescription
validatorAddressstringthe address of the validator
startingHeightuint64the starting height
endingHeightuint64the ending height
pageRequestPageReqthe pagination request

PageReq is a struct with the following fields:

NameTypeDescription
keybytesthe key of the pagination
offsetuint64the offset of the pagination
limituint64the limit of the pagination
countTotalboolwhether to count the total number of pages
reverseboolwhether to reverse the pagination

Outputs

NameTypeDescription
slashesValidatorSlashEvent[]slashes of the validator
paginationPageRespthe pagination response

ValidatorSlashEvent is a struct with the following fields:

NameTypeDescription
validatorPerioduint64the period of the validator
fractionDecthe fraction of the slash

Dec is a struct with the following fields:

NameTypeDescription
valueuint64the value of the Dec
precisionuint8the precision of the Dec

PageResp is a struct with the following fields:

NameTypeDescription
nextKeybytesthe next key of the pagination
totaluint64the total number of pages

delegationRewards

Returns the rewards that delegator receives from the validator.

Inputs

NameTypeDescription
delegatorAddressaddressthe hex address of the delegator
validatorAddressstringthe address of the validator

Outputs

NameTypeDescription
rewardsDecCoin[]rewards that delegator receives from the validator

delegationTotalRewards

Returns the total rewards that delegator receives from all validators.

Inputs

NameTypeDescription
delegatorAddressaddressthe hex address of the delegator

Outputs

NameTypeDescription
rewardsDelegationDelegatorReward[]total rewards that delegator receives from all validators
totalDecCoin[]the total amount of the rewards

DelegationDelegatorReward is a struct with the following fields:

NameTypeDescription
validatorAddressstringthe address of the validator
rewardDecCoin[]rewards that delegator receives from the validator

delegatorValidators

Returns the validators that delegator is bonded to.

Inputs

NameTypeDescription
delegatorAddressaddressthe hex address of the delegator

Outputs

NameTypeDescription
validatorsstring[]validators that delegator is bonded to

delegatorWithdrawAddress

Returns the address to receive the reward of delegation set by setWithdrawAddress method.

Inputs

NameTypeDescription
delegatorAddressaddressthe hex address of the delegator

Outputs

NameTypeDescription
withdrawAddressstringthe address to receive the reward of delegation

Events

SetWithdrawAddress

NameTypeIndexedDescription
calleraddressYthe address of the caller (delegator)
withdrawAddressstringNthe address to receive the reward of delegation

WithdrawDelegatorRewards

NameTypeIndexedDescription
delegatorAddressaddressYthe address of the delegator
validatorAddressaddressYthe address of the validator
amountuint256Nthe amount of the reward

WithdrawValidatorCommission

NameTypeIndexedDescription
validatorAddressstringYthe address of the validator
commissionuint256Nthe total amount of the commission