Skip to content

Commit 4bfdb75

Browse files
authored
fix(SV adapter): check on withdraw that contract sends at least one asset (#477)
* fix(SV adapter): check on withdraw that contract sends at least one asset * recover only on specific SV adapter
1 parent d65889e commit 4bfdb75

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/pair_supervault_adapter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "astroport-supervault-adapter"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
authors = ["Astroport"]
55
edition = "2021"
66
description = "Astroport proxy contract for SuperVaults, mimicking the behavior of pair contract"

contracts/pair_supervault_adapter/src/contract.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::reply::ReplyIds;
44
use crate::state::{
55
Config, ProvideTmpData, WithdrawTmpData, CONFIG, PROVIDE_TMP_DATA, WITHDRAW_TMP_DATA,
66
};
7+
use crate::utils::mint_liquidity_token_message;
78
use astroport::asset::{addr_opt_validate, Asset, AssetInfo, CoinsExt, PairInfo};
89
use astroport::common::LP_SUBDENOM;
910
use astroport::factory::PairType;
@@ -252,20 +253,43 @@ pub fn withdraw_liquidity(
252253
}
253254

254255
#[cfg_attr(not(feature = "library"), entry_point)]
255-
pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
256+
pub fn migrate(deps: DepsMut, env: Env, _msg: Empty) -> Result<Response, ContractError> {
256257
let contract_version = get_contract_version(deps.storage)?;
257258

259+
let mut resp = Response::new();
258260
match contract_version.contract.as_ref() {
259261
CONTRACT_NAME => match contract_version.version.as_ref() {
260262
"1.0.0" => {}
263+
"1.1.0" => {
264+
// Recovering an LP share that was incorrectly burned during supervault freeze period
265+
if env.contract.address
266+
== "neutron1pqnl0035jjeyqadn6sdcl69ahu942e5lkdsardlgcx3pkdy70kss3qu2kg"
267+
{
268+
let config = CONFIG.load(deps.storage)?;
269+
270+
// Proof tx: https://neutron.celat.one/neutron-1/txs/7FCDB63DF69F4AE97CCEBD70E13B73C131A1FA82BB58F5B2669EA85FF242F722
271+
let receiver =
272+
Addr::unchecked("neutron1q647rsfcwrz5cpaj2gmyqxl2z6cw9el474zrrt");
273+
let recover_lp_amount = Uint128::new(242452275081);
274+
let msgs = mint_liquidity_token_message(
275+
deps.querier,
276+
&config,
277+
&env.contract.address,
278+
&receiver,
279+
recover_lp_amount,
280+
false,
281+
)?;
282+
resp = resp.add_messages(msgs);
283+
}
284+
}
261285
_ => return Err(ContractError::MigrationError {}),
262286
},
263287
_ => return Err(ContractError::MigrationError {}),
264288
}
265289

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

268-
Ok(Response::new()
292+
Ok(resp
269293
.add_attribute("previous_contract_name", &contract_version.contract)
270294
.add_attribute("previous_contract_version", &contract_version.version)
271295
.add_attribute("new_contract_name", CONTRACT_NAME)

contracts/pair_supervault_adapter/src/reply.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractEr
115115
.map(|asset| asset.into_msg(&withdraw_data.receiver))
116116
.collect::<StdResult<Vec<_>>>()?;
117117

118+
ensure!(
119+
!messages.is_empty(),
120+
StdError::generic_err("No assets to withdraw")
121+
);
122+
118123
Ok(Response::new().add_messages(messages).add_attributes([
119124
attr("action", "withdraw_liquidity"),
120125
attr("withdrawn_share", withdraw_data.lp_amount),

0 commit comments

Comments
 (0)