Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken vault state migration #284

Merged
merged 2 commits into from
Feb 20, 2024
Merged
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
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
Loading