Skip to content

Commit

Permalink
fix: broken vault state migration (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x authored Feb 20, 2024
1 parent 25fa0bc commit 757117d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
8 changes: 0 additions & 8 deletions contracts/liquidity_hub/vault-network/vault/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,6 @@ pub fn migrate(mut deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Respons
migrations::migrate_to_v120(deps.branch())?;
}

#[cfg(not(feature = "injective"))]
if storage_version
< Version::parse("1.3.0")
.map_err(|_| StdError::parse_err("Version", "Failed to parse version"))?
{
migrations::migrate_to_v130(deps.branch())?;
}

set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

Ok(Response::default())
Expand Down
48 changes: 0 additions & 48 deletions contracts/liquidity_hub/vault-network/vault/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,54 +69,6 @@ pub fn migrate_to_v120(deps: DepsMut) -> Result<(), StdError> {
Ok(())
}

#[cfg(not(feature = "injective"))]
pub fn migrate_to_v130(deps: DepsMut) -> Result<(), StdError> {
#[cw_serde]
pub struct ConfigV120 {
/// The owner of the vault
pub owner: Addr,
/// The asset info the vault manages
pub asset_info: AssetInfo,
/// If flash-loans are enabled
pub flash_loan_enabled: bool,
/// If deposits are enabled
pub deposit_enabled: bool,
/// If withdrawals are enabled
pub withdraw_enabled: bool,
/// The address of the liquidity token
pub liquidity_token: Addr,
/// The address of the fee collector
pub fee_collector_addr: Addr,
/// The fees associated with this vault
pub fees: VaultFee,
}

pub const CONFIG_V120: Item<ConfigV120> = Item::new("config");
let config_v120 = CONFIG_V120.load(deps.storage)?;

// Migrate the liquidity_token to lp_asset, as it can now be a token or native coin
let config = Config {
owner: config_v120.owner,
asset_info: config_v120.asset_info,
flash_loan_enabled: config_v120.flash_loan_enabled,
deposit_enabled: config_v120.deposit_enabled,
withdraw_enabled: config_v120.withdraw_enabled,
lp_asset: AssetInfo::Token {
contract_addr: config_v120.liquidity_token.to_string(),
},
fee_collector_addr: config_v120.fee_collector_addr,
fees: VaultFee {
protocol_fee: config_v120.fees.protocol_fee,
flash_loan_fee: config_v120.fees.flash_loan_fee,
burn_fee: config_v120.fees.burn_fee,
},
};

CONFIG.save(deps.storage, &config)?;

Ok(())
}

#[cfg(feature = "injective")]
pub fn migrate_to_v126(deps: DepsMut) -> Result<(), StdError> {
#[cw_serde]
Expand Down

0 comments on commit 757117d

Please sign in to comment.