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

Fixed the slippage validation logic according to swap market pair #15

Merged

Conversation

steven-semnet
Copy link
Contributor

@steven-semnet steven-semnet commented Jul 13, 2023

The following changes have been made:

  • Created a MarketPair struct in swap.rs file and use it to decide if the swap is selling or buying the base asset.
  • Updated validate_slippage logic with market pair
  • Updated all the tests for slippage validation.

Reference: tidechain PR-356

Tests Results:

running 16 tests
test assets::tests::test_saturation_of_assets ... ok
test swap::test::tests::slippage_1_000_ath_to_10_usdc ... ok
test swap::test::tests::slippage_1_btc_to_100_tdfy ... ok
test swap::test::tests::slippage_100_tdfy_to_1_btc ... ok
test swap::test::tests::slippage_0_dot_9_btc_to_5_dot_9_eth ... ok
test swap::test::tests::slippage_1_btc_to_30_000_usdc ... ok
test swap::test::tests::slippage_10_usdc_to_1_000_ath ... ok
test swap::test::tests::slippage_14_btc_to_2_900_000_tdfy ... ok
test swap::test::tests::slippage_1_000_tdfy_to_2_900_usdc ... ok
test swap::test::tests::slippage_24_700_tdfy_to_5_eth ... ok
test swap::test::tests::slippage_2_900_usdc_to_1_000_tdfy ... ok
test swap::test::tests::slippage_5_dot_9_eth_to_0_dot_9_btc ... ok
test swap::test::tests::slippage_2_900_usdc_to_5_eth ... ok
test swap::test::tests::slippage_30_000_usdc_to_1_btc ... ok
test swap::test::tests::slippage_5_eth_to_2_900_usdc ... ok
test swap::test::tests::slippage_5_eth_to_24_700_tdfy ... ok

@elliotekj
Copy link

While I do feel that this whole module could be made a lot more readable, the logic itself looks good to me and tests derived from the RFC examples are passing. Good job!

@steven-semnet steven-semnet requested a review from elliotekj July 14, 2023 16:59
@elliotekj
Copy link

LGTM

@steven-semnet
Copy link
Contributor Author

LGTM

Thanks :)

@steven-semnet steven-semnet merged commit a3c00fd into dev Jul 19, 2023
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.

4 participants