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

Feat/tested execute liquidation #664

Merged
merged 18 commits into from
Jun 18, 2024
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
17 changes: 10 additions & 7 deletions src/exchange/liquidation_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Core lib imports.
use core::traits::Into;
use starknet::ContractAddress;
use starknet::{ContractAddress, ClassHash};

// Local imports.
use satoru::oracle::oracle_utils::SetPricesParams;
Expand Down Expand Up @@ -43,6 +43,7 @@ mod LiquidationHandler {

use starknet::{ContractAddress, get_caller_address, get_contract_address, ClassHash};

use debug::PrintTrait;

// Local imports.
use super::ILiquidationHandler;
Expand Down Expand Up @@ -77,9 +78,10 @@ mod LiquidationHandler {
use satoru::exchange::base_order_handler::BaseOrderHandler::{
event_emitter::InternalContractMemberStateTrait,
data_store::InternalContractMemberStateImpl,
order_utils::InternalContractMemberStateTrait as OrderUtilsTrait,
order_utils_lib::InternalContractMemberStateTrait as OrderUtilsTrait,
oracle::InternalContractMemberStateTrait as OracleStateTrait,
};
use satoru::order::order_utils::IOrderUtilsDispatcherTrait;

// *************************************************************************
// STORAGE
Expand Down Expand Up @@ -126,9 +128,9 @@ mod LiquidationHandler {
swap_handler_address,
referral_storage_address,
order_utils_class_hash,
increase_order_utils_class_hash: ClassHash,
decrease_order_utils_class_hash: ClassHash,
swap_order_utils_class_hash: ClassHash,
increase_order_utils_class_hash,
decrease_order_utils_class_hash,
swap_order_utils_class_hash,
);
let mut state: RoleModule::ContractState = RoleModule::unsafe_new_contract_state();
IRoleModule::initialize(ref state, role_store_address,);
Expand All @@ -150,7 +152,7 @@ mod LiquidationHandler {
is_long: bool,
oracle_params: SetPricesParams
) {
let mut state_base: BaseOrderHandler::ContractState =
let mut state_base =
BaseOrderHandler::unsafe_new_contract_state(); //retrieve BaseOrderHandler state
global_reentrancy_guard::non_reentrant_before(state_base.data_store.read());

Expand Down Expand Up @@ -189,7 +191,8 @@ mod LiquidationHandler {
params.contracts.data_store,
execute_order_feature_disabled_key(get_contract_address(), params.order.order_type)
);
state_base.execute_order_utils(params);
'pass everything'.print();
state_base.order_utils_lib.read().execute_order_utils(params);
// with_oracle_prices_after(state_base.oracle.read());

global_reentrancy_guard::non_reentrant_after(state_base.data_store.read());
Expand Down
2 changes: 1 addition & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod exchange {
mod deposit_handler;
mod error;
mod exchange_utils;
// mod liquidation_handler;
mod liquidation_handler;
mod order_handler;
mod withdrawal_handler;
}
Expand Down
2 changes: 0 additions & 2 deletions src/position/decrease_position_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ fn decrease_position(mut params: UpdatePositionParams) -> DecreasePositionResult
market_utils::get_cached_token_price(
params.order.initial_collateral_token, params.market, cache.prices
);
params.position.size_in_usd = params.position.size_in_tokens
* cache.collateral_token_price.min; //TODO remove

// cap the order size to the position size
if (params.order.size_delta_usd > params.position.size_in_usd) {
Expand Down
Loading
Loading