safe-global / safe-wallet-web

Safe{Wallet} – smart contract wallet for Ethereum (ex-Gnosis Safe multisig)
https://app.safe.global
GNU General Public License v3.0
314 stars 372 forks source link

Feat: calculate surplus for partially filled orders #3804

Closed jmealy closed 1 month ago

jmealy commented 1 month ago

What it solves

Resolves: https://www.notion.so/safe-global/Better-Surplus-calculation-2e3bf20feeed46938c6efa6728c5ea94?pvs=4

How this PR fixes it

How to test it

Screenshots

image

Checklist

github-actions[bot] commented 1 month ago

Branch preview

βœ… Deploy successful!

Website: https://feat_swap_surplus--walletweb.review.5afe.dev/home?safe=eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6

Storybook: https://feat_swap_surplus--walletweb.review.5afe.dev/storybook/

github-actions[bot] commented 1 month ago

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A

Report generated by eslint-plus-action

github-actions[bot] commented 1 month ago

πŸ“¦ Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. πŸ€–

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 950.49 KB (🟑 +145 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

github-actions[bot] commented 1 month ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
79.47% (-0.02% πŸ”»)
11314/14237
πŸ”΄ Branches
58.37% (-0.21% πŸ”»)
2703/4631
🟑 Functions
66.59% (-0.18% πŸ”»)
1822/2736
🟒 Lines
80.85% (+0.02% πŸ”Ό)
10206/12623
Show files with reduced coverage πŸ”»
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :-: | :- | :- | :- | :- | :- | | 🟑 |
`...` / transactions.ts
|
68.1% (-2.59% πŸ”»)
|
30.56% (-5.56% πŸ”»)
| 36.36% |
71.72% (-3.03% πŸ”»)
| | 🟒 |
`...` / index.tsx
|
96.67% (-3.33% πŸ”»)
| 72.22% |
76.92% (-23.08% πŸ”»)
|
96.55% (-3.45% πŸ”»)
| | 🟒 |
`...` / useHideAssets.ts
|
92.45% (-0.88% πŸ”»)
| 71.43% |
92.31% (-1.44% πŸ”»)
|
93.62% (-0.61% πŸ”»)
| | 🟒 |
`...` / swaps.ts
|
60% (-15% πŸ”»)
| 100% | 100% | 100% | | 🟒 |
`...` / useLoadBalances.ts
|
91.11% (-2.22% πŸ”»)
| 66.67% | 100% | 95% | | 🟒 |
`...` / useUserNonce.ts
|
91.67% (-8.33% πŸ”»)
| 100% | 100% |
90% (-10% πŸ”»)
| | 🟒 |
`...` / tx-tracking.ts
|
90.91% (-3.03% πŸ”»)
| 92.86% | 100% |
90.63% (-3.13% πŸ”»)
| | 🟒 |
`...` / index.tsx
|
87.5% (-0.22% πŸ”»)
|
73.33% (-2.42% πŸ”»)
| 60% |
86.54% (-0.25% πŸ”»)
|

Test suite run success

1442 tests passing in 197 suites.

Report generated by πŸ§ͺjest coverage report action from 0740e3887982df681359fd96f121e4c1a35dfe37

notion-workspace[bot] commented 1 month ago

Better Surplus calculation

compojoom commented 1 month ago

@francovenica or @liliya-soroka it can be a bit tricky to get a partially filled order on sepolia. The easiest way to do it in my opinion is to make a limit order for an amount higher than what you have in the safe. Then when the first part gets filled, you can fund the safe and would get a second fill order.

francovenica commented 1 month ago

LGTM

First I forced an order to fill partially by swapping more tokens than I had and it worked fine, the surpluss in cowSwap and the tx details in safe were the same Then I transfer to the safe more of that tokens to make the order fill completely. After that I've checked that the tx updated the surplus in the safe tx details as it was updated in cowswap. Snapshots and links to the tx: https://feat_swap_surplus--walletweb.review.5afe.dev/transactions/tx?safe=sep:0x8f4A19C85b39032A37f7a6dCc65234f966F72551&id=multisig_0x8f4A19C85b39032A37f7a6dCc65234f966F72551_0x9399daa69f6c03036021e25e6dd6e2a139a7e5cf65e4b610eea2291e967d85e4

https://explorer.cow.fi/sepolia/orders/0xfb01850d548708b6a1bcc863f1d9226aa37f0ecde1a09028c6a5fceb8c5226838f4a19c85b39032a37f7a6dcc65234f966f72551666675b6?tab=overview

Partially filled: image image

Fully filled and updated: image image