From e572d3c89d5f59347103afdad03417d6df57dc16 Mon Sep 17 00:00:00 2001 From: zarboq Date: Wed, 22 May 2024 16:07:48 +0200 Subject: [PATCH 1/2] fix: pool value in deposit error --- src/deposit/error.cairo | 7 ++++++- src/deposit/execute_deposit_utils.cairo | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/deposit/error.cairo b/src/deposit/error.cairo index 54dc0916..8d4fe9c8 100644 --- a/src/deposit/error.cairo +++ b/src/deposit/error.cairo @@ -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) { @@ -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) + } } diff --git a/src/deposit/execute_deposit_utils.cairo b/src/deposit/execute_deposit_utils.cairo index 90022aae..05f3b80e 100644 --- a/src/deposit/execute_deposit_utils.cairo +++ b/src/deposit/execute_deposit_utils.cairo @@ -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; @@ -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) From e3b88291f82a2fff039922935712462edd282105 Mon Sep 17 00:00:00 2001 From: zarboq Date: Wed, 22 May 2024 16:10:58 +0200 Subject: [PATCH 2/2] fix: replace cancel deposit reason by empty string --- src/exchange/deposit_handler.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exchange/deposit_handler.cairo b/src/exchange/deposit_handler.cairo index 2fa297a3..c128c4d5 100644 --- a/src/exchange/deposit_handler.cairo +++ b/src/exchange/deposit_handler.cairo @@ -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);