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

Add -Inf case #196

Merged
merged 5 commits into from
Dec 11, 2023
Merged

Add -Inf case #196

merged 5 commits into from
Dec 11, 2023

Conversation

uri-99
Copy link
Collaborator

@uri-99 uri-99 commented Dec 5, 2023

This PR adds execution_price: -Infinity case
This PR also cleans and adds this to the .py parser

scripts/utility/swap_expected_result.txt Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this please 🙏

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the .txt to the gitignore file? So we can avoid this happening in the future

Comment on lines 1 to +30
# Input of the script
# Object {
# "amount0Before": "2000000000000000000",
# "amount0Delta": "1000",
# "amount1Before": "2000000000000000000",
# "amount1Delta": "-998",
# "executionPrice": "0.99800",
# "feeGrowthGlobal0X128Delta": "170141183460469231731",
# "amount0Before": "1994009290088178439",
# "amount0Delta": "1000000000000000000",
# "amount1Before": "1994009290088178439",
# "amount1Delta": "-662011820624678025",
# "executionPrice": "0.66201",
# "feeGrowthGlobal0X128Delta": "510423550381407695195061911147652317",
# "feeGrowthGlobal1X128Delta": "0",
# "poolPriceAfter": "1.0000",
# "poolPriceAfter": "0.44355",
# "poolPriceBefore": "1.0000",
# "tickAfter": -1,
# "tickAfter": -8130,
# "tickBefore": 0,
# }
# `;

# Output of the script
# let swap_expected_result = SwapExpectedResults {
# amount_0_before: 2000000000000000000,
# amount_0_delta: IntegerTrait::<i256>::new(1000, false),
# amount_1_before: 2000000000000000000,
# amount_1_delta: IntegerTrait::<i256>::new(998, true),
# execution_price: 99800, // original executionPrice * 10**5
# fee_growth_global_0_X128_delta: 170141183460469231731,
# fee_growth_global_1_X128_delta: 0,
# pool_price_after: 79228162514264337593543950336, // after applying parse_price from test_to_cairo
# pool_price_before: 79228162514264337593543950336, // after applying parse_price from test_to_cairo
# tick_after: IntegerTrait::<i32>::new(1, true),
# tick_before: IntegerTrait::<i32>::new(0, false),
# }
# SwapExpectedResults {
# amount_0_before: 1994009290088178439,
# amount_0_delta: IntegerTrait::<i256>::new(1000000000000000000, false),
# amount_1_before: 1994009290088178439,
# amount_1_delta: IntegerTrait::<i256>::new(662011820624678025, true),
# execution_price: 52449980110816002175186131547,
# fee_growth_global_0_X128_delta: 510423550381407695195061911147652317,
# fee_growth_global_1_X128_delta: 0,
# pool_price_after: 52765855989621530048506654453,
# pool_price_before: 79228162514264337593543950336,
# tick_after: IntegerTrait::<i32>::new(8130, true),
# tick_before: IntegerTrait::<i32>::new(0, false),
# },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we changing this in this PR? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to update parse.py in this PR and realized it needed some freshing up. Those values don't really matter, it's just about the format of the input and output files.
The PR description also clarifies that this file was cleaned

Comment on lines 2031 to 2032
} else if token_0_swapped_amount == 0 {
'-Infinity'.into()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment describing how this works? Something similar to what you mentioned in Slack.
Describing the different cases and the output for each one

@uri-99 uri-99 requested a review from dubzn December 11, 2023 15:19
@uri-99 uri-99 merged commit 5723427 into test/swap Dec 11, 2023
3 checks passed
@uri-99 uri-99 deleted the test/fix-inf-case branch December 11, 2023 15:25
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.

None yet

4 participants