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

fix/swap calcs #3346

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

fix/swap calcs #3346

wants to merge 3 commits into from

Conversation

ignaciosantise
Copy link
Collaborator

@ignaciosantise ignaciosantise commented Nov 27, 2024

Description

  • fix: Token to be swapped market price was not calculated correctly
  • fix: Disabled prop of swap input wasn't working (changed ?disabled for .disabled)
  • UI: Show two decimals for price values
  • UI: Disable toToken input, as the api doesn't calculate swap values in reverse

TODO:
@tomiir @enesozturk @svenvoskamp Please check the commented code

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Showcase (Optional)

Before fix:

before_fix.mp4

After fix:

after_fix.mp4

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

changeset-bot bot commented Nov 27, 2024

⚠️ No Changeset found

Latest commit: 015caa0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 27, 2024

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

Name Status Preview Comments Updated (UTC)
appkit-gallery-new ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 5:30pm
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 5:30pm
appkit-laboratory-new 🛑 Canceled (Inspect) Nov 27, 2024 5:30pm
appkit-vue-solana 🛑 Canceled (Inspect) Nov 27, 2024 5:30pm
appkit-wagmi-cdn-example 🛑 Canceled (Inspect) Nov 27, 2024 5:30pm
vue-wagmi-example 🛑 Canceled (Inspect) Nov 27, 2024 5:30pm

Copy link
Contributor

github-actions bot commented Nov 27, 2024

Coverage Report for Coverage

Status Category Percentage Covered / Total
🔵 Lines 400.97999999999996% 5347 / 24198
🔵 Statements 400.97999999999996% 5347 / 24198
🔵 Functions 410.67% 408 / 1478
🔵 Branches 560.7200000000001% 812 / 1804
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/common/src/utils/NumberUtil.ts 25.71% 100% 25% 25.71% 15-24, 32-47, 54-60
packages/scaffold-ui/src/partials/w3m-swap-input/index.ts 0% 0% 0% 0% 1-183
packages/scaffold-ui/src/views/w3m-swap-view/index.ts 0% 0% 0% 0% 1-310
Generated in workflow #7670 for commit 015caa0 by the Vitest Coverage Report Action

Comment on lines +190 to +195
// Why do we need to subtract the gas price here?
/*
* If (target === 'toToken') {
* marketValue -= this.gasPriceInUSD || 0
* }
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably because we are showing this value to the user as what it'd receive
given they are spending gas for the tx, it's deducted

buyt cc @enesozturk @svenvoskamp for confirmation


return html`<w3m-swap-input
.value=${target === 'toToken' ? this.toTokenAmount : this.sourceTokenAmount}
?disabled=${this.loadingQuote && target === 'toToken'}
.disabled=${target === 'toToken'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the loading ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that input should be always disabled, unless we want to add some logic to calculate the swap when changing the toToken input. Doesn't work right now

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.

2 participants