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

Refactor - Add NaN to expected values (Pool 8) #202

Open
wants to merge 23 commits into
base: test/swap
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions crates/yas_core/src/tests/utils/pool_8.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_8() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 0,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 0,
execution_price: 'NaN'.into(),
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 4295128740,
Expand All @@ -42,7 +42,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_8() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 0,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 0,
execution_price: 'NaN'.into(),
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 4295128740,
Expand All @@ -68,7 +68,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_8() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 0,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 0,
execution_price: 'NaN'.into(),
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 56022770974786139918731938227,
Expand All @@ -94,7 +94,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_8() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 0,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 0,
execution_price: 'NaN'.into(),
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 56022770974786139918731938227,
Expand All @@ -120,7 +120,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_8() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 0,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 0,
execution_price: 'NaN'.into(),
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 4295128740,
Expand All @@ -146,7 +146,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_8() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 0,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 0,
execution_price: 'NaN'.into(),
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 4295128740,
Expand Down Expand Up @@ -185,7 +185,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_8() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 0,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 0,
execution_price: 'NaN'.into(),
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 50108289675009586237282760313,
Expand Down
2 changes: 1 addition & 1 deletion crates/yas_core/src/tests/utils/swap_helper.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ mod SwapTestHelper {
) -> u256 {
if token_0_swapped_amount == 0
&& token_1_swapped_amount == 0 { //this avoids 0/0 , if no tokens swapped: exec_price = 0
0
'NaN'.into()
} else if token_0_swapped_amount == 0 { //this avoids x/0 , case that makes price tend to Infinity
// Since uniswap divides deltas to calculate exec_price, all prices are multiplied by -1 so that all prices are > 0.
// Therefore, this value ends up as -Infinity
Expand Down
Loading