Skip to content

Commit

Permalink
feat(@desktop/wallet): handle Paraswap price impact error
Browse files Browse the repository at this point in the history
Fixes #15542
  • Loading branch information
dlipicar committed Aug 7, 2024
1 parent 95d8db2 commit 6ede5ef
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions storybook/pages/SwapModalPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ SplitView {
{name: "errNotEnoughNativeBalance", value: Constants.swap.errorCodes.errNotEnoughNativeBalance},
{name: "errPriceTimeout", value: Constants.swap.errorCodes.errPriceTimeout},
{name: "errNotEnoughLiquidity", value: Constants.swap.errorCodes.errNotEnoughLiquidity}
{name: "errPriceImpactTooHigh", value: Constants.swap.errorCodes.errPriceImpactTooHigh}
]
textRole: "name"
valueRole: "value"
Expand Down
3 changes: 3 additions & 0 deletions ui/app/AppLayouts/Wallet/WalletUtils.qml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ QtObject {
case Constants.routerErrorCodes.processor.errContextDeadlineExceeded:
case Constants.routerErrorCodes.processor.errPriceTimeout:
case Constants.routerErrorCodes.processor.errNotEnoughLiquidity:
case Constants.routerErrorCodes.processor.errPriceImpactTooHigh:
return qsTr("processor internal error")
case Constants.routerErrorCodes.processor.errTransferCustomError:
case Constants.routerErrorCodes.processor.errERC721TransferCustomError:
Expand Down Expand Up @@ -276,6 +277,8 @@ QtObject {
return qsTr("fetching price timeout")
case Constants.routerErrorCodes.processor.errNotEnoughLiquidity:
return qsTr("not enough liquidity")
case Constants.routerErrorCodes.processor.errPriceImpactTooHigh:
return qsTr("price impact too high")

case Constants.routerErrorCodes.processor.errTransferCustomError:
case Constants.routerErrorCodes.processor.errERC721TransferCustomError:
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Wallet/popups/swap/SwapModalAdaptor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ QObject {
return qsTr("Fetching the price took longer than expected. Please, try again later.")
case Constants.swap.errorCodes.errNotEnoughLiquidity:
return qsTr("Not enough liquidity. Lower token amount or try again later.")
case Constants.swap.errorCodes.errPriceImpactTooHigh:
return qsTr("Price impact too high. Lower token amount or try again later.")
}
return qsTr("Something went wrong. Change amount, token or try again later.")
}
Expand Down
3 changes: 3 additions & 0 deletions ui/imports/utils/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ QtObject {
readonly property string errContextDeadlineExceeded : "WPP-036"
readonly property string errPriceTimeout : "WPP-037"
readonly property string errNotEnoughLiquidity : "WPP-038"
readonly property string errPriceImpactTooHigh : "WPP-039"
}

readonly property QtObject router: QtObject {
Expand Down Expand Up @@ -1416,11 +1417,13 @@ QtObject {
readonly property string paraswapSwapContractAddress: "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57"
readonly property string termsAndConditionParaswapUrl: "https://files.paraswap.io/tos_v4.pdf"

// TOOD #15874: Unify with WalletUtils router error code handling
readonly property QtObject errorCodes: QtObject {
readonly property string errNotEnoughTokenBalance: "WR-016"
readonly property string errNotEnoughNativeBalance: "WR-017"
readonly property string errPriceTimeout: "WPP-037"
readonly property string errNotEnoughLiquidity: "WPP-038"
readonly property string errPriceImpactTooHigh: "WPP-039"
}
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/status-go
Submodule status-go updated 67 files
+1 −0 Makefile
+1 −1 _assets/scripts/run_unit_tests.sh
+6 −15 api/backend_test.go
+21 −623 api/defaults.go
+6 −1 api/geth_backend.go
+0 −472 api/messenger_raw_message_resend_test.go
+82 −55 api/old_mobile_user_upgrading_from_v1_to_v2_test.go
+626 −0 api/seed_phrase_dictionary.go
+14 −0 appdatabase/database.go
+1 −1 cmd/ping-community/main.go
+0 −1 cmd/status-cli/util.go
+5 −5 cmd/statusd/main.go
+5 −0 common/devices.go
+0 −3 eth-node/bridge/geth/envelope_event.go
+0 −14 eth-node/bridge/geth/mailserver_response.go
+2 −2 eth-node/bridge/geth/wakuv2.go
+1 −1 go.mod
+2 −2 go.sum
+3 −4 protocol/communities/community.go
+21 −12 protocol/communities/community_test.go
+14 −7 protocol/communities/manager.go
+5 −10 protocol/communities/persistence.go
+26 −15 protocol/communities_events_eventual_consistency_test.go
+10 −104 protocol/communities_events_owner_without_community_key_test.go
+9 −107 protocol/communities_events_token_master_test.go
+97 −170 protocol/communities_events_utils_test.go
+54 −66 protocol/communities_messenger_admin_test.go
+65 −27 protocol/communities_messenger_helpers_test.go
+115 −209 protocol/communities_messenger_shared_member_address_test.go
+20 −105 protocol/communities_messenger_signers_test.go
+54 −79 protocol/communities_messenger_test.go
+140 −0 protocol/communities_messenger_test_suite_base_test.go
+49 −28 protocol/communities_messenger_token_permissions_test.go
+2 −2 protocol/messenger.go
+27 −11 protocol/messenger_activity_center_test.go
+3 −9 protocol/messenger_communities.go
+25 −4 protocol/messenger_communities_sharding_test.go
+14 −33 protocol/messenger_delete_message_for_everyone_test.go
+25 −44 protocol/messenger_delete_messages_test.go
+10 −3 protocol/messenger_handler.go
+20 −10 protocol/messenger_offline_test.go
+17 −5 protocol/messenger_peersyncing_test.go
+41 −62 protocol/messenger_profile_showcase_test.go
+200 −0 protocol/messenger_raw_message_resend_test.go
+39 −16 protocol/messenger_send_images_album_test.go
+1 −2 protocol/messenger_storenode_comunity_test.go
+30 −31 protocol/messenger_sync_activity_center_test.go
+2 −2 protocol/push_notification_test.go
+1 −12 protocol/requests/create_account.go
+2 −10 protocol/requests/request_to_join_community.go
+6 −1 rpc/chain/rpc_limiter.go
+1 −0 services/wallet/router/pathprocessor/errors.go
+3 −1 services/wallet/router/pathprocessor/processor_swap_paraswap.go
+62 −0 services/wallet/router/pathprocessor/processor_swap_paraswap_test.go
+120 −0 services/wallet/thirdparty/paraswap/mock/types.go
+22 −0 services/wallet/thirdparty/paraswap/types.go
+248 −0 vendor/github.com/waku-org/go-waku/waku/v2/api/publish/message_check.go
+23 −11 vendor/github.com/waku-org/go-waku/waku/v2/api/publish/message_queue.go
+1 −1 vendor/modules.txt
+4 −28 wakuv2/common/const.go
+0 −4 wakuv2/common/errors.go
+0 −17 wakuv2/common/events.go
+0 −56 wakuv2/common/message.go
+0 −25 wakuv2/common/metrics.go
+0 −179 wakuv2/mailserver.go
+12 −5 wakuv2/message_publishing.go
+0 −3 wakuv2/waku.go

0 comments on commit 6ede5ef

Please sign in to comment.