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(unlock-app): Decent for swaps #14043

Merged
merged 11 commits into from
Jun 17, 2024
Merged

feat(unlock-app): Decent for swaps #14043

merged 11 commits into from
Jun 17, 2024

Conversation

julien51
Copy link
Member

@julien51 julien51 commented Jun 13, 2024

Description

Until now we used Decent for the "crosschain purchase" scenario where the transaction would be sent from different network, but only paid on this network's native currency.
Since Uniswap broke their libraries, we are now also using Decent for "swap" scenario where we now have the following supported flows:

  • Same chain, use ERC20 for a native token lock
  • Same chain, use ERC20 for lock with a different ERC20
  • Same chain, use native token for a lock using an ERC20
  • Different chain, use native token for a native lock
  • Different chain, use ERC20 for a native token lock
  • Different chain, use ERC20 for lock with a different ERC20
  • Different chain, use native token for a lock using an ERC20

Issues

Fixes #
Refs #

Checklist:

  • 1 PR, 1 purpose: my Pull Request applies to a single purpose
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the docs to reflect my changes if applicable
  • I have added tests (and stories for frontend components) that prove my fix is effective or that my feature works
  • I have performed a self-review of my own code
  • If my code involves visual changes, I am adding applicable screenshots to this thread

Release Note Draft Snippet

@cla-bot cla-bot bot added the cla-signed label Jun 13, 2024
@julien51 julien51 requested review from clemsos and SVell June 13, 2024 13:37
@julien51 julien51 marked this pull request as ready for review June 13, 2024 20:03
@julien51 julien51 changed the title Decent for swaps feat(unlock-app): Decent for swaps Jun 13, 2024
@@ -165,27 +164,15 @@ export function Payment({ checkoutService }: Props) {

const canAfford = balance?.isGasPayable && balance?.isPayable

const { data: uniswapRoutes, isInitialLoading: isUniswapRoutesLoading } =
useUniswapRoutes({
Copy link
Member Author

Choose a reason for hiding this comment

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

I will clean up on a different PR.

userTokenBalance: string
}

// TheBox returns BigInts as strings with a trailing 'n'
Copy link
Member Author

Choose a reason for hiding this comment

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

🤦

Copy link
Member

Choose a reason for hiding this comment

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

looking into it, yes its a real issue when parsing serialized values...

@@ -425,22 +365,28 @@ export function Payment({ checkoutService }: Props) {
>
<div className="flex justify-between w-full">
<h3 className="font-bold">
Pay with {route.symbol} on {route.networkName}
Pay with {route.tokenPayment.symbol} on{' '}
Copy link
Member

Choose a reason for hiding this comment

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

that throws. an error when the lock is priced in native token. Added a fix

Copy link
Member Author

Choose a reason for hiding this comment

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

ha! Good catch I will look at this gain.

Copy link
Member

@clemsos clemsos left a comment

Choose a reason for hiding this comment

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

ok tested with a few locks on various networks, lg !

@julien51 julien51 merged commit f418640 into master Jun 17, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants