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

feat: make hooks use partially fillable by default #5086

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

anxolin
Copy link
Contributor

@anxolin anxolin commented Nov 13, 2024

Summary

Hook orders will be partially fillable.

Context

Hook SWAPs might depend on pre-hooks that on creation time, the simulation gives you some tokens but at execution are less.

One example is in LP withdrawals. You can't guarantee that at execution time you won't have the same amount of tokens you had when you created the hook.

For this reason, is better to make all hook orders partially executable, so it can trade all the available balance.

Future PRs could consider adding the option to choose.

Dev reviewers

My head 🤯 with the hook logic, I had to do too many changes to change the default partiallyFillable. It is very likely that there was a simpler way to do it, but I felt it was a bit hard to reason about the current setup, as there's a mix of params/state/several-level-nested-hooks.

Happy to receive feedback on a simpler approach

I figure it out. I just used an existing hook we had to not drill-down the props down

Test

Place a hook order and verify is partially fillable.

Swap should still be FoK

Copy link

vercel bot commented Nov 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cosmos ✅ Ready (Inspect) Visit Preview Nov 14, 2024 4:55am
cowfi ✅ Ready (Inspect) Visit Preview Nov 14, 2024 4:55am
explorer-dev ✅ Ready (Inspect) Visit Preview Nov 14, 2024 4:55am
swap-dev ✅ Ready (Inspect) Visit Preview Nov 14, 2024 4:55am
widget-configurator ✅ Ready (Inspect) Visit Preview Nov 14, 2024 4:55am

Copy link

sentry-io bot commented Nov 13, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: apps/cowswap-frontend/src/modules/hooksStore/containers/HooksStoreWidget/index.tsx

Function Unhandled Issue
HooksStoreWidget TypeError: Cannot destructure property 'allowSameToken' of 'undefined' as it is undefined. useSwapActionHan...
Event Count: 14 Affected Users: 0
HooksStoreWidget TypeError: Cannot destructure property 'defaultPartiallyFillable' of 'undefined' as it is undefined. useSwapFl...
Event Count: 6 Affected Users: 0
HooksStoreWidget React ErrorBoundary TypeError: Cannot destructure property 'defaultPartiallyFillable' of 'undefined' as it is undefined. ...
Event Count: 3 Affected Users: 0
HooksStoreWidget ReferenceError: defaultPartiallyFillable is not defined useSetupHooksStoreOrderParams(src/modules/hooksStore/hooks/useSetupHooksStoreOrder...
Event Count: 2 Affected Users: 0
📄 File: apps/cowswap-frontend/src/modules/hooksStore/hooks/useSetupHooksStoreOrderParams.ts (Click to Expand)
Function Unhandled Issue
useSetupHooksStoreOrderParams TypeError: Cannot destructure property 'defaultPartiallyFillable' of 'undefined' as it is undefined. useSwapFl...
Event Count: 6 Affected Users: 0
useSetupHooksStoreOrderParams React ErrorBoundary TypeError: Cannot destructure property 'defaultPartiallyFillable' of 'undefined' as it is undefined. ...
Event Count: 3 Affected Users: 0
useSetupHooksStoreOrderParams ReferenceError: defaultPartiallyFillable is not defined useSetupHooksStoreOrderParams(src/modules/hooksStore/hooks/useSetupHooksStoreOrder...
Event Count: 2 Affected Users: 0
useSetupHooksStoreOrderParams React ErrorBoundary ReferenceError: defaultPartiallyFillable is not defined SwapWidget(src/modules/swap/c...
Event Count: 1 Affected Users: 0
📄 File: apps/cowswap-frontend/src/modules/swap/containers/SwapWidget/index.tsx (Click to Expand)
Function Unhandled Issue
SwapWidget React ErrorBoundary ReferenceError: defaultPartiallyFillable is not defined SwapWidget(src/modules/swap/c...
Event Count: 4 Affected Users: 0
SwapWidget ReferenceError: defaultPartiallyFillable is not defined SwapWidget(src/modules/swap/containers/SwapWidget...
Event Count: 4 Affected Users: 0
SwapWidget TypeError: Cannot destructure property 'allowSameToken' of 'undefined' as it is undefined. useSwapActionHan...
Event Count: 2 Affected Users: 0
SwapWidget React ErrorBoundary TypeError: Cannot destructure property 'allowSameToken' of 'undefined' as it is undefined. ...
Event Count: 2 Affected Users: 0
📄 File: apps/cowswap-frontend/src/modules/swap/hooks/useSwapButtonContext.ts (Click to Expand)
Function Unhandled Issue
useSwapButtonContext React ErrorBoundary TypeError: Cannot destructure property 'allowSameToken' of 'undefined' as it is undefined. ...
Event Count: 1 Affected Users: 0
useSwapButtonContext TypeError: Cannot destructure property 'allowSameToken' of 'undefined' as it is undefined. useSwapActionHan...
Event Count: 1 Affected Users: 0
📄 File: apps/cowswap-frontend/src/modules/swap/hooks/useSwapFlowContext.ts (Click to Expand)
Function Unhandled Issue
useSwapFlowContext TypeError: Cannot destructure property 'defaultPartiallyFillable' of 'undefined' as it is undefined. useSwapFl...
Event Count: 6 Affected Users: 0
useSwapFlowContext React ErrorBoundary TypeError: Cannot destructure property 'defaultPartiallyFillable' of 'undefined' as it is undefined. ...
Event Count: 3 Affected Users: 0
---

Did you find this useful? React with a 👍 or 👎

@elena-zh
Copy link

elena-zh commented Nov 13, 2024

Hey @anxolin , changes LGTM. But there are some info points for you:

  1. Since it is impossible to add hooks for ETH-flow orders. it would be nice not to change its type even if the order has been placed from Hooks tab
    no hooks

Assumptions: if the order will be 99.99% filled, it will still hang in the Open state with no 'fill' indication, so users may be confused and call cancellation of the order.
image

Once the order 'expires', the refund od this 0.01% part will be triggered and won't be executed.

  1. I've partially mentioned it in the p.1: once an order is 99.99% executed, order fill notification will appear on the UI. But the order hangs in the 'Open' state in the Account modal, and order traded notification shows 'Cancel' button
    image

image
stuck

@anxolin
Copy link
Contributor Author

anxolin commented Nov 13, 2024

All good points. Agree is not ideal to be left in the OPEN state, and the ETH flow is not great either, but I think this outcome is way better than before. After all 99.99% is better than 0%.

I think the feature is to allow to show % of execution in the modal. We could add it as a issue for feature request, but due too the limited time we have in Bangkok and that this UX isse affects a PRO user which is not core and highly experimental, I would let this PR go through :)

EDIT: I wrote the above too late last night, so I didn't read you properly. Let me amend the above

Since it is impossible to add hooks for ETH-flow orders. it would be nice not to change its type even if the order has been placed from Hooks tab

Right! God point, I though we had support for ETH flow, but obviously we don't. I think we should delete the native token from the sell amount instead. Does it make sense to you?

@anxolin
Copy link
Contributor Author

anxolin commented Nov 14, 2024

@elena-zh regarding ETH Flow. I don't think is related to this PR. This PR tries to be more flexible to let your order go through even if the hook yields less tokens.

The issue with ETH Flow is already in DEV.

I would suggest we track down this enhancements and solve them with independence next week. I would suggest we disallow to sell ETH in HOOKS

@anxolin anxolin merged commit 27a8d4d into develop Nov 14, 2024
10 of 12 checks passed
@anxolin anxolin deleted the parially-fillable-for-hooks branch November 14, 2024 05:00
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2024
@elena-zh
Copy link

elena-zh commented Nov 14, 2024

@anxolin ,

@elena-zh regarding ETH Flow. I don't think is related to this PR. This PR tries to be more flexible to let your order go through even if the hook yields less tokens.

The issue with ETH Flow is already in DEV.

There were no partially fillable ETH orders in Dev yesterday :) And my point was not to allow them being partially fillable, so this was related to the current PR.
As for all the rest functionality, regarding to the ETH-flow, we just disabled a possibility of adding a hook for this order type. So the app is still allows to specify this order on the Hooks tab, but without hooks.
Anyways, I've added your suggestion into #4662 task

@elena-zh
Copy link

Opened #5087 task for improving PF handling on the UI

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants