Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/hub/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "steak-hub"
version = "2.0.0"
version = "2.0.1"
authors = ["larry <gm@larry.engineer>", "PFC <pfc-validator@protonmail.com>"]
edition = "2018"
license = "GPL-3.0-or-later"
Expand Down
3 changes: 3 additions & 0 deletions contracts/hub/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S
ExecuteMsg::RemoveValidator {
validator,
} => execute::remove_validator(deps, env, info.sender, validator),
ExecuteMsg::RemoveValidatorEx {
validator,
} => execute::remove_validator_ex(deps, env, info.sender, validator),
ExecuteMsg::TransferOwnership {
new_owner,
} => execute::transfer_ownership(deps, info.sender, new_owner),
Expand Down
42 changes: 32 additions & 10 deletions contracts/hub/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult<Response> {
let current_time = env.block.time.seconds();
if current_time < pending_batch.est_unbond_start_time {
return Err(StdError::generic_err(
format!("batch can only be submitted for unbonding after {}", pending_batch.est_unbond_start_time),
format!("batch can only be submitted for unbonding after {}", pending_batch.est_unbond_start_time)
));
}

Expand Down Expand Up @@ -419,10 +419,7 @@ pub fn reconcile(deps: DepsMut, env: Env) -> StdResult<Response> {
.filter(|b| current_time > b.est_unbond_end_time)
.collect::<Vec<_>>();

let uluna_expected_received: Uint128 = batches
.iter()
.map(|b| b.uluna_unclaimed)
.sum();
let uluna_expected_received: Uint128 = batches.iter().map(|b| b.uluna_unclaimed).sum();

let unlocked_coins = state.unlocked_coins.load(deps.storage)?;
let uluna_expected_unlocked = Coins(unlocked_coins).find("uluna").amount;
Expand Down Expand Up @@ -574,8 +571,7 @@ pub fn add_validator(deps: DepsMut, sender: Addr, validator: String) -> StdResul
Ok(validators)
})?;

let event = Event::new("steakhub/validator_added")
.add_attribute("validator", validator);
let event = Event::new("steakhub/validator_added").add_attribute("validator", validator);

Ok(Response::new()
.add_event(event)
Expand Down Expand Up @@ -617,15 +613,39 @@ pub fn remove_validator(
.add_event(event)
.add_attribute("action", "steakhub/remove_validator"))
}
pub fn remove_validator_ex(
deps: DepsMut,
_env: Env,
sender: Addr,
validator: String,
) -> StdResult<Response> {
let state = State::default();

state.assert_owner(deps.storage, &sender)?;

state.validators.update(deps.storage, |mut validators| {
if !validators.contains(&validator) {
return Err(StdError::generic_err("validator is not already whitelisted"));
}
validators.retain(|v| *v != validator);
Ok(validators)
})?;

let event = Event::new("steak/validator_removed_ex")
.add_attribute("validator", validator);

Ok(Response::new()
.add_event(event)
.add_attribute("action", "steakhub/remove_validator_ex"))
}

pub fn transfer_ownership(deps: DepsMut, sender: Addr, new_owner: String) -> StdResult<Response> {
let state = State::default();

state.assert_owner(deps.storage, &sender)?;
state.new_owner.save(deps.storage, &deps.api.addr_validate(&new_owner)?)?;

Ok(Response::new()
.add_attribute("action", "steakhub/transfer_ownership"))
Ok(Response::new().add_attribute("action", "steakhub/transfer_ownership"))
}

pub fn accept_ownership(deps: DepsMut, sender: Addr) -> StdResult<Response> {
Expand All @@ -635,7 +655,9 @@ pub fn accept_ownership(deps: DepsMut, sender: Addr) -> StdResult<Response> {
let new_owner = state.new_owner.load(deps.storage)?;

if sender != new_owner {
return Err(StdError::generic_err("unauthorized: sender is not new owner"));
return Err(StdError::generic_err(
"unauthorized: sender is not new owner",
));
}

state.owner.save(deps.storage, &sender)?;
Expand Down
2 changes: 1 addition & 1 deletion packages/steak/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "steak"
version = "2.0.0"
version = "2.0.1"
authors = ["larry <gm@larry.engineer>", "PFC <pfc-validator@protonmail.com>"]
edition = "2018"
description = "Liquid staking protocol for the cosmos"
Expand Down
26 changes: 8 additions & 18 deletions packages/steak/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,17 @@ pub enum ExecuteMsg {
/// Implements the Cw20 receiver interface
Receive(Cw20ReceiveMsg),
/// Bond specified amount of Luna
Bond {
receiver: Option<String>,
},
Bond { receiver: Option<String> },
/// Withdraw Luna that have finished unbonding in previous batches
WithdrawUnbonded {
receiver: Option<String>,
},
WithdrawUnbonded { receiver: Option<String> },
/// Add a validator to the whitelist; callable by the owner
AddValidator {
validator: String,
},
AddValidator { validator: String },
/// Remove a validator from the whitelist; callable by the owner
RemoveValidator {
validator: String,
},
RemoveValidator { validator: String },
/// Remove a validator from the whitelist; callable by the owner; does not undelegate; use with caution
RemoveValidatorEx { validator: String },
/// Transfer ownership to another account; will not take effect unless the new owner accepts
TransferOwnership {
new_owner: String,
},
TransferOwnership { new_owner: String },
/// Accept an ownership transfer
AcceptOwnership {},
/// Claim staking rewards, swap all for Luna, and restake
Expand All @@ -67,9 +59,7 @@ pub enum ExecuteMsg {
pub enum ReceiveMsg {
/// Submit an unbonding request to the current unbonding queue; automatically invokes `unbond`
/// if `epoch_time` has elapsed since when the last unbonding queue was executed.
QueueUnbond {
receiver: Option<String>,
},
QueueUnbond { receiver: Option<String> },
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
Expand Down