Skip to main content

Reward

The Reward contract contains logic for distributing Luna delegation rewards to holders of bLuna. After the Hub contract withdraws Luna delegation rewards to the Reward contract, the Hub contract can request all rewards to be swapped to TerraUSD, which is then distributed to bLuna holders. Holders of bLuna can then send a request to this contract to claim their accrued rewards.

The Reward contract also stores the balance and reward index values for all bLuna holders, which is used to calculate the number of bLuna rewards that a specific holder has accrued.

Config#

KeyTypeDescription
hub_contractCanonicalAddrContract address of Hub
reward_denomStringNative token denomination for distributed bLuna rewards

InitMsg#

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]pub struct InitMsg {    pub hub_contract: HumanAddr,    pub reward_denom: String, }
{  "hub_contract": "terra1...",   "reward_denom": "uusd" }
KeyTypeDescription
hub_contractHumanAddrContract address of bLuna Hub
reward_denomStringNative token denomination for distributed bLuna rewards

ExecuteMsg#

ClaimRewards#

Claims bLuna holder's accrued rewards to the specified address. Sends rewards to the message sender if the recipient is not specified.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum ExecuteMsg {    ClaimRewards {        recipient: Option<HumanAddr>,     }}
{  "claim_rewards": {    "recipient": "terra1..."   }}
KeyTypeDescription
recipient*HumanAddrRecipient address of claimed bLuna rewards

* = optional

[Internal] SwapToRewardDenom#

Swaps all withdrawn delegation rewards to reward_denom. Can only be issued by the Hub

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum ExecuteMsg {    SwapToRewardDenom {}}
{  "swap_to_reward_denom": {}}

[Internal] UpdateGlobalIndex#

Updates the global reward index based on the newly withdrawn rewards. Can only be issued by the Hub.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum ExecuteMsg {    UpdateGlobalIndex {}}
{  "update_global_index": {}}

[Internal] IncreaseBalance#

Increases stored user's bLuna balance. Stores the user's accrued rewards to pending rewards and updates user's reward index to the current global reward index. Can only be issued by the Token.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum ExecuteMsg {    IncreaseBalance {        address: HumanAddr,         amount: Uint128,      }}
{  "increase_balance": {    "address": "terra1...",     "amount": "100000000"   }}
KeyTypeDescription
addressHumanAddrAddress of user whose balance has increased
amountUint128Amount of bLuna balance increased

[Internal] DecreaseBalance#

Decreases stored user's bLuna balance. Stores the user's accrued rewards to pending rewards and updates user's reward index to the current global reward index. Can only be issued by the Token.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum ExecuteMsg {    DecreaseBalance {        address: HumanAddr,         amount: Uint128,     }}
{  "decrease_balance": {    "address": "terra1...",     "amount": "100000000"   }}
KeyTypeDescription
addressHumanAddrAddress of user whose balance has decreased
amountUint128Amount of bLuna balance decreased

QueryMsg#

Config#

Gets the contract configuration of bLuna Reward.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum QueryMsg {    Config {}}
{  "config": {}}

ConfigResponse#

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]pub struct ConfigResponse {    pub hub_contract: HumanAddr,     pub reward_denom: String, }
{  "hub_contract": "terra1...",   "reward_denom": "uusd" }
KeyTypeDescription
hub_contractHumanAddrContract address of Hub
reward_denomStringNative token denomination for distributed bLuna rewards

State#

Gets information about the contract's current state.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum QueryMsg {    State {}}
{  "state": {}}

StateResponse#

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]pub struct StateResponse {    pub global_index: Decimal,     pub total_balance: Uint128,     pub prev_reward_balance: Uint128, }
{  "global_index": "1000.0",   "total_balance": "100000000",   "prev_reward_balance": "100000000" }
KeyTypeDescription
global_indexDecimalCurrent global reward index of bLuna
total_balanceUint128Total bLuna balance of all holders
prev_reward_balanceUint128TerraUSD balance of Reward contract at the end of last UpdateGlobalIndex``

AccruedRewards#

Gets the amount of rewards accrued to the specified bLuna holder.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum QueryMsg {    AccruedRewards {        address: HumanAddr,     }}
{  "accrued_rewards": {    "address": "terra1..."   }}
KeyTypeDescription
addressHumanAddrAddress of bLuna holder

AccruedRewardsResponse#

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]pub struct AccruedRewardsResponse {    pub rewards: Uint128, }
{  "rewards": "100000000" }
KeyTypeDescription
rewardsUint128Amount of reward_denom rewards accrued

Holder#

Gets information about the specified bLuna holder.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum QueryMsg {    Holder {        address: HumanAddr,     }}
{  "holder": {    "address": "terra1..."   }}
KeyTypeDescription
addressHumanAddrAddress of bLuna holder

HolderResponse#

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]pub struct HolderResponse {    pub address: HumanAddr,     pub balance: Uint128,     pub index: Decimal,     pub pending_rewards: Decimal, }
{  "address": "terra1...",   "balance": "100000000",   "index": "100.0",   "pending_rewards": "1000000.123" }
KeyTypeDescription
addressHumanAddrAddress of bLuna holder
balanceUint128bLuna balance of holder
indexDecimalHolder's reward index value
pending_rewardsDecimalAmount of holder's pending rewards

Holders#

Gets information about all bLuna holders.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]#[serde(rename_all = "snake_case")]pub enum QueryMsg {    Holders {        start_after: Option<HumanAddr>,         limit: Option<u32>,     }}
{  "holders": {    "start_after": "terra1...",     "limit": 10   }}
KeyTypeDescription
start_afterHumanAddrAddress of bLuna holder to start query
limit*u32Maximum number of query entries

* = optional

HoldersResponse#

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]pub struct HoldersResponse {    pub holders: Vec<HolderResponse>, }
pub struct HolderResponse {    pub address: HumanAddr,     pub balance: Uint128,     pub index: Decimal,     pub pending_rewards: Decimal, }
{  "holders": [    {      "address": "terra1...",       "balance": "100000000",       "index": "100.00",       "pending_rewards": "1000000.123"     },     {      "address": "terra1...",       "balance": "100000000",       "index": "100.00",       "pending_rewards": "1000000.123"     }  ]}
KeyTypeDescription
holdersVec<HolderResponse>Vector of holder informations
KeyTypeDescription
addressHumanAddrAddress of bLuna holder
balanceUint128bLuna balance of holder
indexDecimalHolder's reward index value
pending_rewardsDecimalAmount of holder's pending rewards