Skip to content

Commit

Permalink
fix withdrawing from full arb vault
Browse files Browse the repository at this point in the history
  • Loading branch information
0xphilipp committed Mar 23, 2024
1 parent c15b088 commit 5a7d284
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [
"contracts/hub",
# "contracts/hub",
# "contracts/alliance-lst",
# "contracts/token",
# "contracts/amp-governance/*",
Expand Down
2 changes: 1 addition & 1 deletion contracts/arb-vault/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eris-arb-vault-whitewhale"
version = "1.0.3"
version = "1.0.4"
authors = ["devs <[email protected]>"]
edition = "2018"
license = "GPL-3.0-or-later"
Expand Down
14 changes: 10 additions & 4 deletions contracts/arb-vault/src/domain/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ pub fn execute_unbond_user(
withdraw_amount,
Decimal::one(),
Uint128::zero(),
true,
)?
} else {
let fee_config = state.fee_config.load(deps.storage)?;
Expand Down Expand Up @@ -287,6 +288,7 @@ pub fn execute_withdraw_unbonding_immediate(
withdraw_amount,
withdraw_pool_fee_factor,
withdraw_amount,
true,
)?;

state.unbond_history.remove(deps.storage, key);
Expand Down Expand Up @@ -323,6 +325,7 @@ pub fn execute_withdraw_unbonded(deps: DepsMut, env: Env, info: MessageInfo) ->
withdraw_amount,
Decimal::zero(),
withdraw_amount,
false,
)?;

// remove elements
Expand All @@ -344,6 +347,7 @@ fn create_withdraw_msgs(
withdraw_amount: Uint128,
withdraw_pool_fee_factor: Decimal,
take_from_locked: Uint128,
immediate: bool,
) -> ContractResult {
if withdraw_amount.is_zero() {
return Err(ContractError::NoWithdrawableAsset {});
Expand All @@ -354,11 +358,13 @@ fn create_withdraw_msgs(
let locked_after = balance_locked.balance.checked_sub(take_from_locked).unwrap_or_default();
let available_amount = config.query_utoken_amount(querier, env)?;

// can only take immediate from not locked amount
let takeable = available_amount.checked_sub(locked_after).unwrap_or_default();
if immediate {
// can only take immediate from not locked amount
let takeable = available_amount.checked_sub(locked_after).unwrap_or_default();

if takeable < withdraw_amount {
return Err(ContractError::NotEnoughAssetsInThePool {});
if takeable < withdraw_amount {
return Err(ContractError::NotEnoughAssetsInThePool {});
}
}

state.balance_locked.save(
Expand Down

0 comments on commit 5a7d284

Please sign in to comment.