Reward
The Reward contract handles the distribution of Ethereum 2.0 staking rewards to holders of CW20 bETH. Ethereum 2.0 staking rewards (which are first converted to TerraUSD via Ethereum AMM protocols) are transferred over to the Reward contract, which are subsequently distributed to holders of bETH. bETH holders can send a request to this contract to claim their accrued rewards.
The Reward contract also stores the balance and reward index values for all bETH holders, which is used to calculate the amount of bETH rewards that a specific holder has accrued.

Contract State

Config

Stores information about the contract configuration.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct Config {
3
pub owner: CanonicalAddr,
4
pub token_contract: Option<CanonicalAddr>,
5
pub reward_denom: String,
6
}
Copied!
Key
Type
Description
owner
CanonicalAddr
Address of contract owner
token_contract*
CanonicalAddr
Contract address of bETH Token
reward_denom
String
Native token denomination for distributed bETH rewards
* = not stored until value registered

State

Stores information about the contract state.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct State {
3
pub global_index: Decimal,
4
pub total_balance: Uint128,
5
pub prev_reward_balance: Uint128,
6
}
Copied!
1
{
2
"global_index": "123.456789",
3
"total_balance": "123.456789",
4
"prev_reward_balance": "123.456789"
5
}
Copied!
Key
Type
Description
global_index
Decimal
Current global reward index of bETH
total_balance
Uint128
Total bETH balance of all holders
prev_reward_balance
Uint128
TerraUSD balance of Reward contract at the time of last global index update

Holder

Stores information for a specific bETH holder.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct Holder {
3
pub balance: Uint128,
4
pub index: Decimal,
5
pub pending_rewards: Decimal,
6
}
Copied!
1
{
2
"balance": "100000000",
3
"index": "123.456789",
4
"pending_rewards": "123.456789"
5
}
Copied!
Key
Type
Description
balance
Uint128
bETH balance of holder
index
Decimal
Holder's reward index value
pending_rewards
Decimal
Amount of holder's pending rewards

InstantiateMsg

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InstantiateMsg {
3
pub owner: String,
4
pub reward_denom: String,
5
}
Copied!
1
{
2
"owner": "terra1...",
3
"reward_denom": "uusd"
4
}
Copied!
Key
Type
Description
owner
String
Address of contract owner
reward_denom
String
Native token denomination for distributed bETH rewards

ExecuteMsg

PostInitialize

Registers the bETH Token contract address.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
PostInitialize {
5
token_contract: String,
6
}
7
}
Copied!
1
{
2
"post_initialize": {
3
"token_contract": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
token_contract
String
Address of bETH Token

UpdateConfig

Updates the Reward contract configuration.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
UpdateConfig {
5
owner: String,
6
}
7
}
Copied!
1
{
2
"update_config": {
3
"owner": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
owner
String
Address of new owner

ClaimRewards

Claims bETH holder's accrued rewards to the specified address. Sends rewards to message sender if the recipient is not specified.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
ClaimRewards {
5
recipient: Option<String>,
6
}
7
}
Copied!
1
{
2
"claim_rewards": {
3
"recipient": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
recipient*
String
Recipient address of claimed bETH rewards
* = optional

[Internal] IncreaseBalance

Increases stored user's bETH balance. Stores user's accrued rewards to pending rewards and updates user's reward index to the current global reward index. Can only be issued by Token.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
IncreaseBalance {
5
address: String,
6
amount: Uint128,
7
}
8
}
Copied!
1
{
2
"increase_balance": {
3
"address": "terra1...",
4
"amount": "100000000"
5
}
6
}
Copied!
Key
Type
Description
address
String
Address of user whose balance has increased
amount
Uint128
Amount of bETH balance increased

[Internal] DecreaseBalance

Decreases stored user's bETH balance. Stores user's accrued rewards to pending rewards and updates user's reward index to the current global reward index. Can only be issued byToken.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
DecreaseBalance {
5
address: String,
6
amount: Uint128,
7
}
8
}
Copied!
1
{
2
"decrease_balance": {
3
"address": "terra1...",
4
"amount": "100000000"
5
}
6
}
Copied!
Key
Type
Description
address
String
Address of user whose balance has decreased
amount
Uint128
Amount of bETH balance decreased

QueryMsg

Config

Gets the contract configuration of bETH Reward.
Rust
JSON

Request

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Config {}
5
}
Copied!
Key
Type
Description

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: String,
4
pub reward_denom: String,
5
pub token_contract: Option<String>,
6
}
Copied!
Key
Type
Description
owner
String
Address of contract owner
reward_denom
String
Native token denomination for distributed bETH rewards
token_contract*
String
Contract address of bETH Token
* = optional

Request

1
{
2
"config": {}
3
}
Copied!
Key
Type
Description

Response

1
{
2
"owner": "terra1...",
3
"reward_denom": "uusd",
4
"token_contract": "terra1..."
5
}
Copied!
Key
Type
Description
owner
String
Address of contract owner
reward_denom
String
Native token denomination for distributed bETH rewards
token_contract*
String
Contract address of bETH Token
* = optional

State

Gets information about the contract's current state.
Rust
JSON

Request

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
State {}
5
}
Copied!
Key
Type
Description

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct StateResponse {
3
pub global_index: Decimal,
4
pub total_balance: Uint128,
5
pub prev_reward_balance: Uint128,
6
}
Copied!
Key
Type
Description
global_index
Decimal
Current global reward index of bETH
total_balance
Uint128
Total bETH balance of all holders
prev_reward_balance
Uint128
TerraUSD balance of the Reward contract at the time of last reward distribution

Request

1
{
2
"state": {}
3
}
Copied!
Key
Type
Description

Response

1
{
2
"global_index": "1000.0",
3
"total_balance": "100000000",
4
"prev_reward_balance": "100000000"
5
}
Copied!
Key
Type
Description
global_index
Decimal
Current global reward index of bETH
total_balance
Uint128
Total bETH balance of all holders
prev_reward_balance
Uint128
TerraUSD balance of the Reward contract at the time of last reward distribution

AccruedRewards

Gets the amount of rewards accrued to the specified bETH holder.
Rust
JSON

Request

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
AccruedRewards {
5
address: String,
6
}
7
}
Copied!
Key
Type
Description
address
String
Address of bETH holder

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct AccruedRewardsResponse {
3
pub rewards: Uint128,
4
}
Copied!
Key
Type
Description
rewards
Uint128
Amount of reward_denom rewards accrued

Request

1
{
2
"accrued_rewards": {
3
"address": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
address
String
Address of bETH holder

Response

1
{
2
"rewards": "100000000"
3
}
Copied!
Key
Type
Description
rewards
Uint128
Amount of reward_denom rewards accrued

Holder

Gets information about the specified bETH holder.
Rust
JSON

Request

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Holder {
5
address: String,
6
}
7
}
Copied!
Key
Type
Description
address
String
Address of bETH holder

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct HolderResponse {
3
pub address: String,
4
pub balance: Uint128,
5
pub index: Decimal,
6
pub pending_rewards: Decimal,
7
}
Copied!
Key
Type
Description
address
String
Address of bETH holder
balance
Uint128
bETH balance of holder
index
Decimal
Holder's reward index value
pending_rewards
Decimal
Amount of holder's pending rewards

Request

1
{
2
"holder": {
3
"address": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
address
String
Address of bETH holder

Response

1
{
2
"address": "terra1...",
3
"balance": "100000000",
4
"index": "100.0",
5
"pending_rewards": "1000000.123"
6
}
Copied!
Key
Type
Description
address
String
Address of bETH holder
balance
Uint128
bETH balance of holder
index
Decimal
Holder's reward index value
pending_rewards
Decimal
Amount of holder's pending rewards

Holders

Gets information about all bETH holders.
Rust
JSON

Request

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Holders {
5
start_after: Option<String>,
6
limit: Option<u32>,
7
}
8
}
Copied!
Key
Type
Description
start_after*
String
Address of bETH holder to start query
limit*
u32
Maximum number of query entries
* = optional

Response

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct HoldersResponse {
3
pub holders: Vec<HolderResponse>,
4
}
5
6
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
7
pub struct HolderResponse {
8
pub address: String,
9
pub balance: Uint128,
10
pub index: Decimal,
11
pub pending_rewards: Decimal,
12
}
Copied!
Key
Type
Description
holders
Vec<HolderResponse>
Vector of holder informations
Key
Type
Description
address
String
Address of bETH holder
balance
Uint128
bETH balance of holder
index
Decimal
Holder's reward index value
pending_rewards
Decimal
Amount of holder's pending rewards

Request

1
{
2
"holders": {
3
"start_after": "terra1...",
4
"limit": 8
5
}
6
}
Copied!
Key
Type
Description
start_after*
String
Address of bETH holder to start query
limit*
u32
Maximum number of query entries
* = optional

Response

1
{
2
"holders": [
3
{
4
"address": "terra1...",
5
"balance": "100000000",
6
"index": "123.456789",
7
"pending_rewards": "123.456789"
8
},
9
{
10
"address": "terra1...",
11
"balance": "100000000",
12
"index": "123.456789",
13
"pending_rewards": "123.456789"
14
}
15
]
16
}
Copied!
Key
Type
Description
holders
Vec<HolderResponse>
Vector of holder informations
Key
Type
Description
address
String
Address of bETH holder
balance
Uint128
bETH balance of holder
index
Decimal
Holder's reward index value
pending_rewards
Decimal
Amount of holder's pending rewards
Last modified 2mo ago