Distribution Polaris β
The Cosmos SDK distribution module is responsible for tracking and distributing rewards to validators and delegators in a blockchain network. The module passively distributes collected fees and other rewards to validators and delegators based on their participation in the network.Β It also defines the community pool, which is a pool of funds under the control of on-chain governance.
The interface includes functions to set and get the withdrawal address for delegation rewards, check if withdrawing rewards is enabled, withdraw delegator rewards, and retrieve the total rewards accumulated by a delegator. Additionally, it defines events for withdrawing rewards and setting the withdrawal address, as well as a struct to represent a delegator's rewards for a particular validator.
Developers can use this module to manage the distribution of rewards in their custom application-specific blockchains built using the Cosmos SDK. Berachain ensures that validators and delegators are fairly rewarded for their contributions to the network via this module.
Note: Link to existing contract ABI's can be found on Github here.
Interface of the distribution module's precompiled contract
Functions β
getWithdrawEnabled β
Returns whether withdrawing delegation rewards is enabled.
function getWithdrawEnabled() external view returns (bool);
function getWithdrawEnabled() external view returns (bool);
getWithdrawAddress β
Returns the address that will receive the delegation rewards.
function getWithdrawAddress(address delegator) external view returns (address);
function getWithdrawAddress(address delegator) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
delegator | address | the delegator for which the withdraw address is returned. |
getDelegatorValidatorReward β
Returns the rewards accumulated by the delegator for the validator.
function getDelegatorValidatorReward(address delegator, address validator)
external
view
returns (Cosmos.Coin[] memory);
function getDelegatorValidatorReward(address delegator, address validator)
external
view
returns (Cosmos.Coin[] memory);
Parameters
Name | Type | Description |
---|---|---|
delegator | address | The delegator to retrieve the rewards for. |
validator | address | The validator (operator address) to retrieve the rewards for. |
getAllDelegatorRewards β
Returns the all rewards accumulated by the delegator.
function getAllDelegatorRewards(address delegator) external view returns (ValidatorReward[] memory);
function getAllDelegatorRewards(address delegator) external view returns (ValidatorReward[] memory);
Parameters
Name | Type | Description |
---|---|---|
delegator | address | The delegator to retrieve the totalRewards for. |
getTotalDelegatorReward β
Returns the total rewards accumulated by the delegator.
function getTotalDelegatorReward(address delegator) external view returns (Cosmos.Coin[] memory);
function getTotalDelegatorReward(address delegator) external view returns (Cosmos.Coin[] memory);
Parameters
Name | Type | Description |
---|---|---|
delegator | address | The delegator to retrieve the totalRewards for. |
setWithdrawAddress β
The caller (msg.sender) can set the address that will receive the delegation rewards.
function setWithdrawAddress(address withdrawAddress) external returns (bool);
function setWithdrawAddress(address withdrawAddress) external returns (bool);
Parameters
Name | Type | Description |
---|---|---|
withdrawAddress | address | The address to set as the withdraw address. |
withdrawDelegatorReward β
Withdraw the rewrads accumulated by the caller(msg.sender). Returns the rewards claimed.
function withdrawDelegatorReward(address delegator, address validator) external returns (Cosmos.Coin[] memory);
function withdrawDelegatorReward(address delegator, address validator) external returns (Cosmos.Coin[] memory);
Parameters
Name | Type | Description |
---|---|---|
delegator | address | The delegator to withdraw the rewards from. |
validator | address | The validator (operator address) to withdraw the rewards from. |
Events β
WithdrawRewards β
Emitted by the distribution module when amount
is withdrawn from a delegation with validator
as rewards.
event WithdrawRewards(address indexed validator, Cosmos.Coin[] amount);
event WithdrawRewards(address indexed validator, Cosmos.Coin[] amount);
Parameters
Name | Type | Description |
---|---|---|
validator | address | The validator address to withdraw the rewards from. |
amount | Cosmos.Coin[] | The amount of rewards withdrawn. |
SetWithdrawAddress β
Emitted by the distribution module when withdrawAddress
is set to receive rewards upon withdrawal.
event SetWithdrawAddress(address indexed withdrawAddress);
event SetWithdrawAddress(address indexed withdrawAddress);
Parameters
Name | Type | Description |
---|---|---|
withdrawAddress | address | The address to set as the withdraw address. |
Structs β
ValidatorReward β
Represents a delegator's rewards for one particular validator.
struct ValidatorReward {
address validator;
Cosmos.Coin[] rewards;
}
struct ValidatorReward {
address validator;
Cosmos.Coin[] rewards;
}