Skip to content

Commit

Permalink
fix: Rework all v2 contracts to use bonding-manager not whale-lair (#363
Browse files Browse the repository at this point in the history
)

* fix: Rework all v2 contracts to use bonding-manager not whale-lair

+ Removes all references to whale-lair for V2 contracts
+ Updates all schemas and most unit tests
+ Start of integration test rework for incentive manager

The tests rework will take a bigger effort/another pass

* fix: Update reference to whale_lair
  • Loading branch information
0xFable authored May 24, 2024
1 parent 31eb771 commit ee0f33c
Show file tree
Hide file tree
Showing 25 changed files with 339 additions and 107 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use white_whale_std::whale_lair::{ExecuteMsg, InstantiateMsg, QueryMsg};
use white_whale_std::bonding_manager::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
2 changes: 2 additions & 0 deletions contracts/liquidity_hub/incentive-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ white-whale-testing.workspace = true
epoch-manager.workspace = true
whale-lair.workspace = true
anyhow.workspace = true
bonding-manager.workspace = true
pool-manager.workspace = true
11 changes: 7 additions & 4 deletions contracts/liquidity_hub/incentive-manager/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn instantiate(

let config = Config {
epoch_manager_addr: deps.api.addr_validate(&msg.epoch_manager_addr)?,
whale_lair_addr: deps.api.addr_validate(&msg.bonding_manager_addr)?,
bonding_manager_addr: deps.api.addr_validate(&msg.bonding_manager_addr)?,
create_incentive_fee: msg.create_incentive_fee,
max_concurrent_incentives: msg.max_concurrent_incentives,
max_incentive_epoch_buffer: msg.max_incentive_epoch_buffer,
Expand All @@ -60,7 +60,10 @@ pub fn instantiate(
("action", "instantiate".to_string()),
("owner", msg.owner),
("epoch_manager_addr", config.epoch_manager_addr.to_string()),
("whale_lair_addr", config.whale_lair_addr.to_string()),
(
"bonding_manager_addr",
config.bonding_manager_addr.to_string(),
),
("create_flow_fee", config.create_incentive_fee.to_string()),
(
"max_concurrent_flows",
Expand Down Expand Up @@ -134,7 +137,7 @@ pub fn execute(
}
},
ExecuteMsg::UpdateConfig {
whale_lair_addr,
bonding_manager_addr,
epoch_manager_addr,
create_incentive_fee,
max_concurrent_incentives,
Expand All @@ -147,7 +150,7 @@ pub fn execute(
manager::commands::update_config(
deps,
info,
whale_lair_addr,
bonding_manager_addr,
epoch_manager_addr,
create_incentive_fee,
max_concurrent_incentives,
Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_hub/incentive-manager/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(crate) fn process_incentive_creation_fee(

// send incentive creation fee to whale lair for distribution
messages.push(white_whale_std::bonding_manager::fill_rewards_msg(
config.whale_lair_addr.clone().into_string(),
config.bonding_manager_addr.clone().into_string(),
vec![incentive_creation_fee.to_owned()],
)?);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ pub(crate) fn on_epoch_changed(
pub(crate) fn update_config(
deps: DepsMut,
info: MessageInfo,
whale_lair_addr: Option<String>,
bonding_manager_addr: Option<String>,
epoch_manager_addr: Option<String>,
create_incentive_fee: Option<Coin>,
max_concurrent_incentives: Option<u32>,
Expand All @@ -368,8 +368,8 @@ pub(crate) fn update_config(

let mut config = CONFIG.load(deps.storage)?;

if let Some(whale_lair_addr) = whale_lair_addr {
config.whale_lair_addr = deps.api.addr_validate(&whale_lair_addr)?;
if let Some(new_bonding_manager_addr) = bonding_manager_addr {
config.bonding_manager_addr = deps.api.addr_validate(&new_bonding_manager_addr)?;
}

if let Some(epoch_manager_addr) = epoch_manager_addr {
Expand Down Expand Up @@ -423,7 +423,10 @@ pub(crate) fn update_config(

Ok(Response::default().add_attributes(vec![
("action", "update_config".to_string()),
("whale_lair_addr", config.whale_lair_addr.to_string()),
(
"bonding_manager_addr",
config.bonding_manager_addr.to_string(),
),
("epoch_manager_addr", config.epoch_manager_addr.to_string()),
("create_flow_fee", config.create_incentive_fee.to_string()),
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ pub(crate) fn withdraw_position(
amount: penalty_fee,
};

let whale_lair_addr = CONFIG.load(deps.storage)?.whale_lair_addr;
let bonding_manager_addr = CONFIG.load(deps.storage)?.bonding_manager_addr;

// send penalty to whale lair for distribution
// send penalty to bonding manager for distribution
messages.push(white_whale_std::bonding_manager::fill_rewards_msg(
whale_lair_addr.into_string(),
bonding_manager_addr.into_string(),
vec![penalty],
)?);

Expand Down
Loading

0 comments on commit ee0f33c

Please sign in to comment.