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: deposit pool value error #675

Merged
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
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
Loading