Skip to content

Commit

Permalink
revert 'NaN' in test swap
Browse files Browse the repository at this point in the history
  • Loading branch information
dpinones committed Dec 28, 2023
1 parent b2878dc commit 7615c87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
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: 'NaN'.into(),
execution_price: 0,
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: 'NaN'.into(),
execution_price: 0,
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: 'NaN'.into(),
execution_price: 0,
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: 'NaN'.into(),
execution_price: 0,
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: 'NaN'.into(),
execution_price: 0,
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: 'NaN'.into(),
execution_price: 0,
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: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 50108289675009586237282760313,
Expand Down
14 changes: 7 additions & 7 deletions crates/yas_core/src/tests/utils/pool_9.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_9() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 1995041008271423675,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 1461446703485210103287273052203988822378723970341,
Expand All @@ -55,7 +55,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_9() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 1995041008271423675,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 1461446703485210103287273052203988822378723970341,
Expand All @@ -81,7 +81,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_9() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 1995041008271423675,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 112045541949572279837463876454,
Expand All @@ -107,7 +107,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_9() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 1995041008271423675,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 112045541949572279837463876454,
Expand All @@ -133,7 +133,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_9() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 1995041008271423675,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 1461446703485210103287273052203988822378723970341,
Expand All @@ -159,7 +159,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_9() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 1995041008271423675,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 1461446703485210103287273052203988822378723970341,
Expand All @@ -172,7 +172,7 @@ fn SWAP_EXPECTED_RESULTS_POOL_9() -> Array<SwapExpectedResults> {
amount_0_delta: IntegerTrait::<i256>::new(0, false),
amount_1_before: 1995041008271423675,
amount_1_delta: IntegerTrait::<i256>::new(0, false),
execution_price: 'NaN'.into(),
execution_price: 0,
fee_growth_global_0_X128_delta: 0,
fee_growth_global_1_X128_delta: 0,
pool_price_after: 125270724187523965593206900784,
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
'NaN'.into()
0
} 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

0 comments on commit 7615c87

Please sign in to comment.