Skip to content

Commit

Permalink
Merge branch 'keep-starknet-strange:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sparqet authored Jun 27, 2024
2 parents 0744871 + afb2213 commit e6f167f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 50 deletions.
12 changes: 6 additions & 6 deletions tests/integration/swap_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ fn test_swap_market() {

// Balance caller address after sending 1 ETH to the vault
// 9 ETH
assert(balance_ETH_before == 9000000000000000000, 'wrng ETH blce after vault');
assert(balance_ETH_before == 9000000000000000000, 'wrng ETH blce after vlt');
// 50 000 USDC
assert(balance_USDC_before == 50000000000000000000000, 'wrng USDC blce after vlt 1');
assert(balance_USDC_before == 50000000000000000000000, 'wrng USDC blce after vlt');

// Create order_params Struct
let contract_address = contract_address_const::<0>();
Expand Down Expand Up @@ -381,9 +381,9 @@ fn test_swap_market() {
.balance_of(caller_address);

// 9 ETH
assert(balance_ETH_before_execute == 9000000000000000000, 'wrng ETH blce after vault');
assert(balance_ETH_before_execute == 9000000000000000000, 'wrng ETH blce bef execute');
// 50 000 USDC
assert(balance_USDC_before_execute == 50000000000000000000000, 'wrng USDC blce after vlt 2');
assert(balance_USDC_before_execute == 50000000000000000000000, 'wrng USDC blce bef execute');

let keeper_address = contract_address_const::<'keeper'>();
role_store.grant_role(keeper_address, role::ORDER_KEEPER);
Expand All @@ -402,9 +402,9 @@ fn test_swap_market() {
.balance_of(caller_address);

// 9 ETH
assert(balance_ETH_after == 9000000000000000000, 'wrng ETH blce after vault');
assert(balance_ETH_after == 9000000000000000000, 'wrng ETH blce after exec');
// 55 000 USDC
assert(balance_USDC_after == 55000000000000000000000, 'wrng USDC blce after vault');
assert(balance_USDC_after == 55000000000000000000000, 'wrng USDC blce after exec');

let first_swap_pool_value_info = market_utils::get_pool_value_info(
data_store,
Expand Down
62 changes: 26 additions & 36 deletions tests/integration/test_long_integration.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ fn test_long_increase_decrease_close() {
assert(balance_USDC_before == 50000000000000000000000, 'balance USDC should be 50000$');
// Balance USDC after = (0.75 ETH * 3850$) + 87.499 (PnL)
assert(balance_USDC_after == 52974999999999999998950, 'balance USDC shld be 52974.99$');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH before 7');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH after 7');

//////////////////////////////////// CLOSE POSITION //////////////////////////////////////
'CLOSE POSITION'.print();
Expand Down Expand Up @@ -662,8 +662,6 @@ fn test_long_increase_decrease_close() {
let key_long_dec_2 = exchange_router.create_order(order_params_long_dec_2);
'long decrease created'.print();
let got_order_long_dec = data_store.get_order(key_long_dec_2);
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'USDC'>()), );
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'ETH'>()), 1000000);
// Execute the swap order.

let keeper_address = contract_address_const::<'keeper'>();
Expand Down Expand Up @@ -712,8 +710,8 @@ fn test_long_increase_decrease_close() {

assert(balance_USDC_bef_close == 52974999999999999998950, 'balance USDC shld be 52974.99$');
assert(balance_USDC_af_close == 62574999999999999998950, 'balance USDC shld be 62574.99$');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH after 7');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH after 7');

// *********************************************************************************************
// * TEARDOWN *
Expand Down Expand Up @@ -1261,8 +1259,8 @@ fn test_takeprofit_long() {
assert(balance_USDC_before == 50000000000000000000000, 'balance USDC should be 50000$');
// Balance USDC after = (0.75 ETH * 3950$) + 162.499 (PnL)
assert(balance_USDC_after == 53124999999999999996350, 'balance USDC shld be 53124.99$');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH before 7');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH after 7');

//////////////////////////////////// TRIGGER CLOSE POSITION //////////////////////////////////////
'CLOSE POSITION'.print();
Expand Down Expand Up @@ -1318,8 +1316,6 @@ fn test_takeprofit_long() {
let key_long_dec_2 = exchange_router.create_order(order_params_long_dec_2);
'long decrease created'.print();
let got_order_long_dec = data_store.get_order(key_long_dec_2);
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'USDC'>()), );
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'ETH'>()), 1000000);
// Execute the swap order.

let keeper_address = contract_address_const::<'keeper'>();
Expand Down Expand Up @@ -1368,8 +1364,8 @@ fn test_takeprofit_long() {

assert(balance_USDC_bef_close == 53124999999999999996350, 'balance USDC shld be 52974.99$');
assert(balance_USDC_af_close == 62724999999999999996350, 'balance USDC shld be 62724.99$');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH af close 7');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH bef close 7');

// *********************************************************************************************
// * TEARDOWN *
Expand Down Expand Up @@ -1918,8 +1914,8 @@ fn test_takeprofit_long_increase_fails() {
assert(balance_USDC_before == 50000000000000000000000, 'balance USDC should be 50000$');
// Balance USDC after = (0.75 ETH * 3950$) + 162.499 (PnL)
assert(balance_USDC_after == 53124999999999999996350, 'balance USDC shld be 53124.99$');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH before 7');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH after 7');

//////////////////////////////////// TRIGGER CLOSE POSITION //////////////////////////////////////
'CLOSE POSITION'.print();
Expand Down Expand Up @@ -1975,8 +1971,6 @@ fn test_takeprofit_long_increase_fails() {
let key_long_dec_2 = exchange_router.create_order(order_params_long_dec_2);
'long decrease created'.print();
let got_order_long_dec = data_store.get_order(key_long_dec_2);
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'USDC'>()), );
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'ETH'>()), 1000000);
// Execute the swap order.

let keeper_address = contract_address_const::<'keeper'>();
Expand Down Expand Up @@ -2025,8 +2019,8 @@ fn test_takeprofit_long_increase_fails() {

assert(balance_USDC_bef_close == 53124999999999999996350, 'balance USDC shld be 52974.99$');
assert(balance_USDC_af_close == 62724999999999999996350, 'balance USDC shld be 62724.99$');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH af close 7');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH bef close 7');

// *********************************************************************************************
// * TEARDOWN *
Expand Down Expand Up @@ -2572,11 +2566,11 @@ fn test_takeprofit_long_decrease_fails() {
let balance_ETH_after = IERC20Dispatcher { contract_address: contract_address_const::<'ETH'>() }
.balance_of(caller_address);

assert(balance_USDC_before == 50000000000000000000000, 'balance USDC should be 50000$');
assert(balance_USDC_before == 50000000000000000000000, 'balance USDC before 50000$');
// Balance USDC after = (0.75 ETH * 3950$) + 162.499 (PnL)
assert(balance_USDC_after == 53124999999999999996350, 'balance USDC shld be 53124.99$');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH should be 4');
assert(balance_USDC_after == 53124999999999999996350, 'balance USDC after 53124.99$');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH before 7');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH after 7');

//////////////////////////////////// TRIGGER CLOSE POSITION //////////////////////////////////////
'CLOSE POSITION'.print();
Expand Down Expand Up @@ -2632,8 +2626,6 @@ fn test_takeprofit_long_decrease_fails() {
let key_long_dec_2 = exchange_router.create_order(order_params_long_dec_2);
'long decrease created'.print();
let got_order_long_dec = data_store.get_order(key_long_dec_2);
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'USDC'>()), );
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'ETH'>()), 1000000);
// Execute the swap order.

let keeper_address = contract_address_const::<'keeper'>();
Expand Down Expand Up @@ -2680,10 +2672,10 @@ fn test_takeprofit_long_decrease_fails() {
}
.balance_of(caller_address);

assert(balance_USDC_bef_close == 53124999999999999996350, 'balance USDC shld be 52974.99$');
assert(balance_USDC_af_close == 62724999999999999996350, 'balance USDC shld be 62724.99$');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_USDC_bef_close == 53124999999999999996350, 'balance USDC bef close 53124.99$');
assert(balance_USDC_af_close == 62724999999999999996350, 'balance USDC af close 62724.99$');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH af close 7');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH bef close 7');

// *********************************************************************************************
// * TEARDOWN *
Expand Down Expand Up @@ -3229,11 +3221,11 @@ fn test_takeprofit_long_close_fails() {
let balance_ETH_after = IERC20Dispatcher { contract_address: contract_address_const::<'ETH'>() }
.balance_of(caller_address);

assert(balance_USDC_before == 50000000000000000000000, 'balance USDC should be 50000$');
assert(balance_USDC_before == 50000000000000000000000, 'balance USDC before 50000$');
// Balance USDC after = (0.75 ETH * 3950$) + 162.499 (PnL)
assert(balance_USDC_after == 53124999999999999996350, 'balance USDC shld be 53124.99$');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_before == 7000000000000000000, 'balance ETH before 7');
assert(balance_ETH_after == 7000000000000000000, 'balance ETH after 7');

//////////////////////////////////// TRIGGER CLOSE POSITION //////////////////////////////////////
'CLOSE POSITION'.print();
Expand Down Expand Up @@ -3289,8 +3281,6 @@ fn test_takeprofit_long_close_fails() {
let key_long_dec_2 = exchange_router.create_order(order_params_long_dec_2);
'long decrease created'.print();
let got_order_long_dec = data_store.get_order(key_long_dec_2);
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'USDC'>()), );
// data_store.set_u256(keys::pool_amount_key(market.market_token, contract_address_const::<'ETH'>()), 1000000);
// Execute the swap order.

let keeper_address = contract_address_const::<'keeper'>();
Expand Down Expand Up @@ -3337,10 +3327,10 @@ fn test_takeprofit_long_close_fails() {
}
.balance_of(caller_address);

assert(balance_USDC_bef_close == 53124999999999999996350, 'balance USDC shld be 52974.99$');
assert(balance_USDC_bef_close == 53124999999999999996350, 'balance USDC shld be 53124.99$');
assert(balance_USDC_af_close == 62724999999999999996350, 'balance USDC shld be 62724.99$');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH should be 4');
assert(balance_ETH_af_close == 7000000000000000000, 'balance ETH af close 7');
assert(balance_ETH_bef_close == 7000000000000000000, 'balance ETH bef close 7');

// *********************************************************************************************
// * TEARDOWN *
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/test_short_integration.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ fn test_short_increase_decrease_close() {
.balance_of(caller_address);

assert(balance_deposit_vault_before == 0, 'balance deposit should be 0');
assert(balance_caller_ETH == 10000000000000000000, 'balanc ETH should be 10 ETH');
assert(balance_caller_USDC == 43000000000000000000000, 'USDC be 50 000 USDC');
assert(balance_caller_ETH == 10000000000000000000, 'balanc ETH caller 10 ETH');
assert(balance_caller_USDC == 43000000000000000000000, 'USDC be 43 000 USDC');

// Execute the swap order.

Expand Down Expand Up @@ -423,8 +423,8 @@ fn test_short_increase_decrease_close() {
.balance_of(caller_address);

assert(balance_deposit_vault_before == 0, 'balance deposit should be 0');
assert(balance_caller_ETH == 10000000000000000000, 'balanc ETH should be 10 ETH');
assert(balance_caller_USDC == 43000000000000000000000, 'USDC be 43 000 USDC');
assert(balance_caller_ETH == 10000000000000000000, 'balanc ETH caller 10 ETH');
assert(balance_caller_USDC == 43000000000000000000000, 'USDC caller 43000 USDC');

// //////////////////////////////////// CLOSE POSITION //////////////////////////////////////
'CLOSE POSITION'.print();
Expand Down Expand Up @@ -526,10 +526,10 @@ fn test_short_increase_decrease_close() {
}
.balance_of(caller_address);

assert(balance_USDC_bef_close == 43000000000000000000000, 'balance USDC shld be 43000$');
assert(balance_USDC_af_close == 43000000000000000000000, 'balance USDC shld be 43000$');
assert(balance_ETH_af_close == 12666666666666666666, 'balance ETH should be 12.66');
assert(balance_ETH_bef_close == 10000000000000000000, 'balance ETH should be 10');
assert(balance_USDC_bef_close == 43000000000000000000000, 'balance USDC bef close 43000$');
assert(balance_USDC_af_close == 43000000000000000000000, 'balance USDC af close 43000$');
assert(balance_ETH_af_close == 12666666666666666666, 'balance ETH af close 12.66');
assert(balance_ETH_bef_close == 10000000000000000000, 'balance ETH bef close 10');

// *********************************************************************************************
// * TEARDOWN *
Expand Down

0 comments on commit e6f167f

Please sign in to comment.