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: Implement the function in the market_utils library #3 #463

Merged
merged 29 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0b97963
10 functions done
Tbelleng Sep 25, 2023
1eb1a09
almost finished, debug next
Tbelleng Sep 27, 2023
e32e69f
debug time
Tbelleng Sep 27, 2023
16cfa12
debuging
Tbelleng Sep 27, 2023
b50ef99
pushing recent changes/ still bug because missing functions
Tbelleng Sep 27, 2023
9331e30
Merge branch 'main' of https://github.com/keep-starknet-strange/sator…
Tbelleng Sep 27, 2023
0815f0c
debuging finished
Tbelleng Sep 27, 2023
d556216
adding comments on functions
Tbelleng Sep 28, 2023
30b0d20
almost clean
Tbelleng Sep 28, 2023
0741eb7
Emit bug
Tbelleng Sep 28, 2023
f1ee948
Merge branch 'main' of https://github.com/keep-starknet-strange/sator…
Tbelleng Sep 29, 2023
fd42dff
programm compile 🎉
Tbelleng Sep 29, 2023
a70ccf2
resolving last test
Tbelleng Sep 29, 2023
f394974
All test passed
Tbelleng Sep 29, 2023
fb76061
Remove Cache struct
Tbelleng Oct 1, 2023
211598f
Merge branch 'main' of https://github.com/keep-starknet-strange/sator…
Tbelleng Oct 2, 2023
3368add
Pull and update with main branch
Tbelleng Oct 2, 2023
66174d7
Merge branch 'main' of https://github.com/keep-starknet-strange/sator…
Tbelleng Oct 2, 2023
df07739
Merge branch 'main' into compare
Sk8erboi84 Oct 3, 2023
321f07f
Update version with Elevy pull request
Tbelleng Oct 3, 2023
b90bb16
Merge branch 'compare' of https://github.com/Tbelleng/satoru into com…
Tbelleng Oct 3, 2023
c7b651d
resolve request
Tbelleng Oct 3, 2023
5e6489d
Merge branch 'main' of https://github.com/keep-starknet-strange/sator…
Tbelleng Oct 3, 2023
4549e24
1 test failed because of max swap path lenght exceed test
Tbelleng Oct 3, 2023
ccaa9cc
resolving failed test
Tbelleng Oct 4, 2023
ce65b1f
resolve
Tbelleng Oct 4, 2023
2baaf1b
Merge branch 'main' of https://github.com/keep-starknet-strange/sator…
Tbelleng Oct 5, 2023
d801664
solving
Tbelleng Oct 5, 2023
9863418
compilation resolved
Tbelleng Oct 5, 2023
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
1 change: 0 additions & 1 deletion src/event/event_emitter.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ trait IEventEmitter<TContractState> {
next_pool_value: u128
);

/// Emits the `UiFeeFactorUpdated` event.
fn emit_ui_fee_factor_updated(
ref self: TContractState, account: ContractAddress, ui_fee_factor: u128
);
Expand Down
61 changes: 56 additions & 5 deletions src/market/error.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,69 @@ mod MarketError {
'empty_addr_market_balance_val';
const EMPTY_ADDRESS_TOKEN_BALANCE_VAL: felt252 = 'empty_addr_token_balance_val';
const INVALID_MARKET_TOKEN_BALANCE: felt252 = 'invalid_market_token_balance';
const INVALID_MARKET_TOKEN_BALANCE_FOR_COLLATERAL_AMOUNT: felt252 =
'invalid_mkt_tok_bal_collat_amnt';
const INVALID_MARKET_TOKEN_BALANCE_FOR_CLAIMABLE_FUNDING: felt252 =
'invalid_mkt_tok_bal_claim_fund';
const EmptyAddressInMarketTokenBalanceValidation: felt252 = 'EmptyAddressMarketBalanceVal';
const INVALID_POSITION_MARKET: felt252 = 'invalid_position_market';
const INVALID_COLLATERAL_TOKEN_FOR_MARKET: felt252 = 'invalid_coll_token_for_market';
const UNABLE_TO_GET_OPPOSITE_TOKEN: felt252 = 'unable_to_get_opposite_token';
const EMPTY_MARKET: felt252 = 'empty_market';
const DISABLED_MARKET: felt252 = 'disabled_market';
const COLLATERAL_ALREADY_CLAIMED: felt252 = 'collateral_already_claimed';

fn DISABLED_MARKET(is_market_disabled: bool) {
panic(array!['minimum_position_size', is_market_disabled.into()])
}

fn EMPTY_MARKET_TOKEN_SUPPLY(supply: u128) {
panic(array!['empty_market_token_supply', supply.into()])
}

fn INVALID_MARKET_COLLATERAL_TOKEN(market: ContractAddress, token: ContractAddress) {
panic(array!['invalid_market_collateral_token', market.into(), token.into()])
}

fn UNABLE_TO_GET_FUNDING_FACTOR_EMPTY_OPEN_INTEREST(total_open_interest: u128) {
panic(array!['unable_to_get_funding_factor', total_open_interest.into()])
}

fn MAX_SWAP_PATH_LENGTH_EXCEEDED(token_swap_path_length: u32, max_swap_path_length: u128) {
panic(
array![
'max_swap_path_length_exceeded',
token_swap_path_length.into(),
max_swap_path_length.into()
]
)
}

fn PNL_EXCEEDED_FOR_LONGS(is_pnl_factor_exceeded_for_longs: bool) {
panic(array!['pnl_exceeded_for_longs', is_pnl_factor_exceeded_for_longs.into()])
}

fn PNL_EXCEEDED_FOR_SHORTS(is_pnl_factor_exceeded_for_shorts: bool) {
panic(array!['pnl_exceeded_for_shorts', is_pnl_factor_exceeded_for_shorts.into()])
}

fn UI_FEE_FACTOR_EXCEEDED(ui_fee_factor: u128, max_ui_fee_factor: u128) {
panic(array!['ui_fee_factor_exceeded', ui_fee_factor.into(), max_ui_fee_factor.into()])
}

fn INVALID_MARKET_TOKEN_BALANCE_FOR_COLLATERAL_AMOUNT(balance: u128, collateral_amount: u128) {
panic(array!['invalid_market_token_balance', balance.into(), collateral_amount.into()])
}

fn INVALID_MARKET_TOKEN_BALANCE_FOR_CLAIMABLE_FUNDING(
balance: u128, claimable_funding_fee_amount: u128
) {
panic(
array![
'invalid_market_token_balance', balance.into(), claimable_funding_fee_amount.into()
]
)
}

fn UNABLE_TO_GET_BORROWING_FACTOR_EMPTY_POOL_USD(pool_usd: u128) {
panic(array!['unable_to_get_borrowing_factor', pool_usd.into()])
}

fn MAX_OPEN_INTEREST_EXCEDEED(open_interest: u128, max_open_interest: u128) {
panic(array!['max_open_interest_exceeded', open_interest.into(), max_open_interest.into()])
}
Expand Down
Loading
Loading