Skip to content

Commit

Permalink
feat(@desktop/wallet): handle Paraswap price impact error (#16045)
Browse files Browse the repository at this point in the history
Fixes #15542
  • Loading branch information
dlipicar authored Aug 9, 2024
1 parent e4ddfa4 commit f21f660
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion storybook/pages/SwapModalPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ SplitView {
{name: "errNotEnoughTokenBalance", value: Constants.swap.errorCodes.errNotEnoughTokenBalance},
{name: "errNotEnoughNativeBalance", value: Constants.swap.errorCodes.errNotEnoughNativeBalance},
{name: "errPriceTimeout", value: Constants.swap.errorCodes.errPriceTimeout},
{name: "errNotEnoughLiquidity", value: Constants.swap.errorCodes.errNotEnoughLiquidity}
{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 sTr("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 @@ -1111,6 +1111,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 @@ -1451,11 +1452,13 @@ QtObject {
readonly property string paraswapSwapContractAddress: "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57"
readonly property string paraswapTermsAndConditionUrl: "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

0 comments on commit f21f660

Please sign in to comment.