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

Conversation

Tbelleng
Copy link
Contributor

@Tbelleng Tbelleng commented Sep 29, 2023

Pull Request type

Please add the labels corresponding to the type of changes your PR introduces:

  • Bugfix
  • Feature

What is the current behavior?

Currently, functions are working but since last git pull i wasnt able to trigger tests
Resolves: #NA

What is the new behavior?

  • Implement from getMaxPositionImpactFactor function to getExpectedMinTokenBalance in the market_utils library.
  • Had to change some external files because functions prototypes or return values was not working
  • Add functions to convert int and uint.
  • Some function are still missing from other files (the last function of market_utils Feat: Implement the function in the market_utils library. #3 #435 use some Keys functions that exist in solidity files but not in satoru files (i commented the line with what it should looks like)
  • Commented "test_deposit_utils::given_unsufficient_fee_token_amount_for_deposit_then_fails" because one function essential function (get_market) was missing in Satoru. (Approved by @zarboq)

Does this introduce a breaking change?

No

Other information

@Tbelleng
Copy link
Contributor Author

  • Tests passed
  • Commented "test_deposit_utils::given_unsufficient_fee_token_amount_for_deposit_then_fails" because one function essential function (get_market) was missing in Satoru. (Approved by @zarboq)

src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/exchange/adl_handler.cairo Outdated Show resolved Hide resolved
src/market/error.cairo Outdated Show resolved Hide resolved
src/utils/i128.cairo Outdated Show resolved Hide resolved
tests/utils/test_calc.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
@Tbelleng
Copy link
Contributor Author

Tbelleng commented Oct 3, 2023

I did the error function for MAX_SWAP_PATH_LENGTH_EXCEEDED, but for an unknown reason it failed the test "tests::exchange::test_withdrawal_handler::given_normal_conditions_when_create_withdrawal_then_works".

its return the following failed test "[FAIL] tests::exchange::test_withdrawal_handler::given_normal_conditions_when_create_withdrawal_then_works

Failure data:
original value: [2948898997531897529390896139788207291365863622618688546988264006116708], converted to a string: [max_swap_path_length_exceeded]
original value: [0], converted to a string: []
original value: [0], converted to a string: []"

Any hint about it ?

@zarboq
Copy link
Collaborator

zarboq commented Oct 4, 2023

It's bc you inverted the inequality, it should be if token_swap_path_length.into() > max_swap_path_length @Tbelleng

@Tbelleng
Copy link
Contributor Author

Tbelleng commented Oct 4, 2023

My bad ! thanks @zarboq , it should works now ⚡️

src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Show resolved Hide resolved
src/event/event_emitter.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
src/market/market_utils.cairo Show resolved Hide resolved
src/market/market_utils.cairo Show resolved Hide resolved
src/market/market_utils.cairo Show resolved Hide resolved
src/market/market_utils.cairo Show resolved Hide resolved
src/market/market_utils.cairo Outdated Show resolved Hide resolved
@Tbelleng
Copy link
Contributor Author

Tbelleng commented Oct 5, 2023

solved issues but after removing "get_open_interest" as requested, i got this error when compiling "error: WithdrawalHandler: failed to compile Sierra contract to CASM

Caused by:
#35998: One of the arguments does not satisfy the requirements of the libfunc." did i do something wrong ?

@zarboq
Copy link
Collaborator

zarboq commented Oct 5, 2023

Do this in get_borrowing_factor_per_second

let market_snap = @market;
if (skip_borrowing_fee_for_smaller_side) {
    let long_open_interest: u128 = get_open_interest_for_market_is_long(data_store, market_snap, true);
    let short_open_interest: u128 = get_open_interest_for_market_is_long(data_store, market_snap, false);

    // if getting the borrowing factor for longs and if the longOpenInterest
    // is smaller than the shortOpenInterest, then return zero
    if (is_long && long_open_interest < short_open_interest) {
        return 0;
    }
    // if getting the borrowing factor for shorts and if the shortOpenInterest
    // is smaller than the longOpenInterest, then return zero
    if (!is_long && short_open_interest < long_open_interest) {
        return 0;
    }
}

Not sure why but looks like market gets "trapped" in the if

@zarboq zarboq merged commit 7ac41fb into keep-starknet-strange:main Oct 5, 2023
3 checks passed
StarkFishinator pushed a commit to StarkFishinator/satoru that referenced this pull request Oct 5, 2023
…t-strange#3 (keep-starknet-strange#463)

* 10 functions done

* almost finished, debug next

* debug time

* debuging

* pushing recent changes/ still bug because missing functions

* debuging finished

* adding comments on functions

* almost clean

* Emit bug

* programm compile 🎉

* resolving last test

* All test passed

* resolve request

* 1 test failed because of max swap path lenght exceed test

* resolving failed test

* resolve

* solving

* compilation resolved

---------

Co-authored-by: Michel <[email protected]>
@sparqet sparqet linked an issue Oct 8, 2023 that may be closed by this pull request
zarboq added a commit that referenced this pull request Nov 5, 2023
* exp function, no tested (failed setting up runner)

* not working :(

* error comes from 1e18?

* exp2 working git add .

* exp is working !

* fmt

* Feat:  Implement the function in the market_utils library #3 (#463)

* 10 functions done

* almost finished, debug next

* debug time

* debuging

* pushing recent changes/ still bug because missing functions

* debuging finished

* adding comments on functions

* almost clean

* Emit bug

* programm compile 🎉

* resolving last test

* All test passed

* resolve request

* 1 test failed because of max swap path lenght exceed test

* resolving failed test

* resolve

* solving

* compilation resolved

---------

Co-authored-by: Michel <[email protected]>

* test: Tests for deposit_vault (#496)

* test(deposit_vault_contract): Can start doing some unit tests from that

* test(deposit_vault_contract): Better format

* test(deposit_vault_contract): All test passes! 🥳

* test(deposit_vault_contract): Added unit test for transfer_out not enough balance

---------

Co-authored-by: akhercha <[email protected]>
Co-authored-by: sparqet <[email protected]>

* test: Improve tests for referral_storage contract (#499)

* test(referral_storage_contract): Refacto test architecture before adding tests

* test(referral_storage_contract): Quick refacto of base tests

* test(referral_storage_contract): Added more tests

* test(referral_storage_contract): Finished tests for referral_storage contract

* test(referral_storage_contract): Removed custom teardown

* test(referral_storage_contract): Unused imports

* test(referral_storage_contract): Updated top comment

* test(referral_storage_contract): from review; added init check in Governable

* test(referral_storage_contract): Removed useless line

* test(referral_storage_contract): Removed useless line x2 💀

---------

Co-authored-by: akhercha <[email protected]>

* test: Improve tests of referral_utils library. #483 (#498)

* update referalla-util tests

* allow changing refferal

* remove role_store

---------

Co-authored-by: zarboq <[email protected]>

* Implementing StrictBank functions and tests (#426)

* strict bank start

* strict bank contract and tests

* All strict bank tests running

* formatted

---------

Co-authored-by: Michel <[email protected]>
Co-authored-by: sparqet <[email protected]>
Co-authored-by: zarboq <[email protected]>

* ✨ execute_deposit_utils functions (#449)

* ✨ execute_deposit_utils fn

* fix: clone fees and rm extra line

* fix: prevent BadMergeBaseMismatch by adding else to if-

* fix: fmt issue

* Feat: Adding a Contirbutor profil (#501)

* 10 functions done

* almost finished, debug next

* debug time

* debuging

* pushing recent changes/ still bug because missing functions

* debuging finished

* adding comments on functions

* almost clean

* Emit bug

* programm compile 🎉

* resolving last test

* All test passed

* resolve request

* 1 test failed because of max swap path lenght exceed test

* resolving failed test

* resolve

* solving

* compilation resolved

* Added as a Contributor

* Adding profil on ReadMe

---------

Co-authored-by: Michel <[email protected]>

* test: Added tests for record_transfer_in (#502)

* test(record_transfer_in_function): Added unit tests for record_transfer_in

* test(record_transfer_in_function): Added unit tests

* test(record_transfer_in_function): Better error message

* test(record_transfer_in_function): Mock + Overflow prevented

* test(record_transfer_in_function): Removed useless import

* test(record_transfer_in_function): record_transfer_in panic on sub overflow

* test(record_transfer_in_function): Quick test refacto

* test(record_transfer_in_function): Unused variables in tests

---------

Co-authored-by: akhercha <[email protected]>
Co-authored-by: zarboq <[email protected]>

* Improve tests of governable contract (#503)

* add test to gov

* fmt fix

* add new contributors (#505)

* change panic error

* change quote

* log2 function is working

* fmt

* fmt

* pow working

* fmt

* convert type

* fix

* lock

* fmt + lock

* works

---------

Co-authored-by: Tbelleng <[email protected]>
Co-authored-by: Michel <[email protected]>
Co-authored-by: akhercha <[email protected]>
Co-authored-by: akhercha <[email protected]>
Co-authored-by: sparqet <[email protected]>
Co-authored-by: tevrat aksoy <[email protected]>
Co-authored-by: zarboq <[email protected]>
Co-authored-by: VictorONN <[email protected]>
Co-authored-by: kasteph <[email protected]>
Co-authored-by: Axel Izsak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Implement the function in the market_utils library. #3
4 participants