Skip to content

Commit

Permalink
Fix: deposit pool value error (#675)
Browse files Browse the repository at this point in the history
* fix: pool value in deposit error

* fix: replace cancel deposit reason by empty string
  • Loading branch information
zarboq authored Jun 24, 2024
1 parent 67edd38 commit 7e70a2e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/deposit/error.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod DepositError {
const EMPTY_DEPOSIT_AMOUNTS: felt252 = 'empty_deposit_amounts';
const EMPTY_DEPOSIT: felt252 = 'empty_deposit';
const EMPTY_DEPOSIT_AMOUNTS_AFTER_SWAP: felt252 = 'empty deposit amount after swap';
const INVALID_POOL_VALUE_FOR_DEPOSIT: felt252 = 'invalid pool value for deposit';


fn MIN_MARKET_TOKENS(received: u256, expected: u256) {
Expand All @@ -14,4 +13,10 @@ mod DepositError {
data.append(expected.try_into().expect('u256 into felt failed'));
panic(data)
}

fn INVALID_POOL_VALUE_FOR_DEPOSIT(pool_value: u256) {
let mut data = array!['invalid pool value for deposit'];
data.append(pool_value.try_into().expect('u256 into felt failed'));
panic(data)
}
}
5 changes: 2 additions & 3 deletions src/deposit/execute_deposit_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,8 @@ fn execute_deposit_helper(
true,
);

//TODO add the pool_value_info.pool in the error message
if pool_value_info.pool_value < Zeroable::zero() {
panic_with_felt252(DepositError::INVALID_POOL_VALUE_FOR_DEPOSIT)
DepositError::INVALID_POOL_VALUE_FOR_DEPOSIT(pool_value_info.pool_value.mag);
}

let mut mint_amount = 0;
Expand All @@ -327,7 +326,7 @@ fn execute_deposit_helper(
);

if pool_value == Zeroable::zero() && market_tokens_supply > 0 {
panic_with_felt252(DepositError::INVALID_POOL_VALUE_FOR_DEPOSIT)
DepositError::INVALID_POOL_VALUE_FOR_DEPOSIT(pool_value_info.pool_value.mag);
}

(*params.event_emitter)
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/deposit_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ mod DepositHandler {
deposit.account,
0, //starting_gas
keys::user_initiated_cancel(),
array!['Cancel Deposit'] //TODO should be empty string
array!['']
);

global_reentrancy_guard::non_reentrant_after(data_store);
Expand Down

0 comments on commit 7e70a2e

Please sign in to comment.