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.
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct Config {
pub owner : CanonicalAddr ,
pub token_contract : Option < CanonicalAddr >,
pub reward_denom : String ,
}
Address of contract owner
Contract address of bETH Token
Native token denomination for distributed bETH rewards
* = not stored until value registered
State
Stores information about the contract state.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct State {
pub global_index : Decimal ,
pub total_balance : Uint128 ,
pub prev_reward_balance : Uint128 ,
}
Copy {
"global_index" : "123.456789" ,
"total_balance" : "123.456789" ,
"prev_reward_balance" : "123.456789"
}
Current global reward index of bETH
Total bETH balance of all holders
TerraUSD balance of Reward contract at the time of last global index update
Holder
Stores information for a specific bETH holder.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct Holder {
pub balance : Uint128 ,
pub index : Decimal ,
pub pending_rewards : Decimal ,
}
Copy {
"balance" : "100000000" ,
"index" : "123.456789" ,
"pending_rewards" : "123.456789"
}
Holder's reward index value
Amount of holder's pending rewards
InstantiateMsg
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct InstantiateMsg {
pub owner : String ,
pub reward_denom : String ,
}
Copy {
"owner" : "terra1..." ,
"reward_denom" : "uusd"
}
Address of contract owner
Native token denomination for distributed bETH rewards
ExecuteMsg
PostInitialize
Registers the bETH Token contract address.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
PostInitialize {
token_contract : String ,
}
}
Copy {
"post_initialize" : {
"token_contract" : "terra1..."
}
}
UpdateConfig
Updates the Reward contract configuration.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
UpdateConfig {
owner : String ,
}
}
Copy {
"update_config" : {
"owner" : "terra1..."
}
}
ClaimRewards
Claims bETH holder's accrued rewards to the specified address. Sends rewards to message sender if the recipient
is not specified.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
ClaimRewards {
recipient : Option < String >,
}
}
Copy {
"claim_rewards" : {
"recipient" : "terra1..."
}
}
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
IncreaseBalance {
address : String ,
amount : Uint128 ,
}
}
Copy {
"increase_balance" : {
"address" : "terra1..." ,
"amount" : "100000000"
}
}
Address of user whose balance has increased
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
DecreaseBalance {
address : String ,
amount : Uint128 ,
}
}
Copy {
"decrease_balance" : {
"address" : "terra1..." ,
"amount" : "100000000"
}
}
Address of user whose balance has decreased
Amount of bETH balance decreased
QueryMsg
Config
Gets the contract configuration of bETH Reward
.
Rust JSON
Request
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Config {}
}
Response
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct ConfigResponse {
pub owner : String ,
pub reward_denom : String ,
pub token_contract : Option < String >,
}
Address of contract owner
Native token denomination for distributed bETH rewards
Contract address of bETH Token
* = optional
Request
Response
Copy {
"owner" : "terra1..." ,
"reward_denom" : "uusd" ,
"token_contract" : "terra1..."
}
Address of contract owner
Native token denomination for distributed bETH rewards
Contract address of bETH Token
* = optional
State
Gets information about the contract's current state.
Rust JSON
Request
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
State {}
}
Response
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct StateResponse {
pub global_index : Decimal ,
pub total_balance : Uint128 ,
pub prev_reward_balance : Uint128 ,
}
Current global reward index of bETH
Total bETH balance of all holders
TerraUSD balance of the Reward contract at the time of last reward distribution
Request
Response
Copy {
"global_index" : "1000.0" ,
"total_balance" : "100000000" ,
"prev_reward_balance" : "100000000"
}
Current global reward index of bETH
Total bETH balance of all holders
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
AccruedRewards {
address : String ,
}
}
Response
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct AccruedRewardsResponse {
pub rewards : Uint128 ,
}
Amount of reward_denom
rewards accrued
Request
Copy {
"accrued_rewards" : {
"address" : "terra1..."
}
}
Response
Copy {
"rewards" : "100000000"
}
Amount of reward_denom
rewards accrued
Holder
Gets information about the specified bETH holder.
Rust JSON
Request
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Holder {
address : String ,
}
}
Response
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct HolderResponse {
pub address : String ,
pub balance : Uint128 ,
pub index : Decimal ,
pub pending_rewards : Decimal ,
}
Holder's reward index value
Amount of holder's pending rewards
Request
Copy {
"holder" : {
"address" : "terra1..."
}
}
Response
Copy {
"address" : "terra1..." ,
"balance" : "100000000" ,
"index" : "100.0" ,
"pending_rewards" : "1000000.123"
}
Holder's reward index value
Amount of holder's pending rewards
Holders
Gets information about all bETH holders.
Rust JSON
Request
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Holders {
start_after : Option < String >,
limit : Option < u32 >,
}
}
Address of bETH holder to start query
Maximum number of query entries
* = optional
Response
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct HoldersResponse {
pub holders : Vec < HolderResponse >,
}
#[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct HolderResponse {
pub address : String ,
pub balance : Uint128 ,
pub index : Decimal ,
pub pending_rewards : Decimal ,
}
Vector of holder informations
Holder's reward index value
Amount of holder's pending rewards
Request
Copy {
"holders" : {
"start_after" : "terra1..." ,
"limit" : 8
}
}
Address of bETH holder to start query
Maximum number of query entries
* = optional
Response
Copy {
"holders" : [
{
"address" : "terra1..." ,
"balance" : "100000000" ,
"index" : "123.456789" ,
"pending_rewards" : "123.456789"
},
{
"address" : "terra1..." ,
"balance" : "100000000" ,
"index" : "123.456789" ,
"pending_rewards" : "123.456789"
}
]
}
Vector of holder informations
Holder's reward index value
Amount of holder's pending rewards