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

Start off-ramping from evm networks #323

Conversation

gianfra-t
Copy link
Contributor

@gianfra-t gianfra-t commented Dec 12, 2024

Note: Review and merge after this refactor is merged into staging.

Issue: #292.

Main changes

  • Adds logic to support off-ramp from other evm chains.
  • Adds relevant config for each new network.
  • Adds relevant icons.
  • General bug fixes and improvements.

Extra (optional) changes

  • Includes a refactor into zustand of the hooks for sep24.

Tests

Off-ramps tested to ARS:

  • Arbitrum
  • Base
  • Avalanche
  • Ethereum
  • BSC

@gianfra-t gianfra-t linked an issue Dec 12, 2024 that may be closed by this pull request
5 tasks
Copy link

netlify bot commented Dec 12, 2024

Deploy Preview for pendulum-pay ready!

Name Link
🔨 Latest commit 1498306
🔍 Latest deploy log https://app.netlify.com/sites/pendulum-pay/deploys/677bebf5cdb9f1000861fbb6
😎 Deploy Preview https://deploy-preview-323--pendulum-pay.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.


// TODO maybe improve: if the user switches the network in the selector and REJECTS the switch in wallet, then balance will be 0.
Copy link
Contributor Author

@gianfra-t gianfra-t Dec 18, 2024

Choose a reason for hiding this comment

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

Metamask needs this explicit acceptance, while Talisman for instance, does not.

Since useReadContract uses the chain that is connected in the wallet, it will read from an incorrect chain.
If this is a UI requirement, we could fetch with the correct chain using the selectedNetwork parameter.

@gianfra-t gianfra-t changed the title [WIP]. Start off-ramping from evm networks Start off-ramping from evm networks Dec 26, 2024
@gianfra-t gianfra-t marked this pull request as ready for review December 26, 2024 16:11
@gianfra-t gianfra-t requested a review from a team December 31, 2024 14:13
const outputTokenDecimals = OUTPUT_TOKEN_CONFIG[outputTokenType].decimals;

const inputAmountBig = Big(amountIn);
const inputAmountRaw = multiplyByPowerOfTen(inputAmountBig, inputTokenDecimals || 0).toFixed();
const pendulumAmountRaw = multiplyByPowerOfTen(inputAmountBig, pendulumDecimals || 0).toFixed();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were previously using inputAmountRaw for all operations on Pendulum after writing the off-ramping state. Since the decimals on the starting chain and axlUSDC on Pendulum where the same (6), there was no issue.

BSC uses 18 decimals so we need to account for this, or potentially for a different token combination.

src/components/Nabla/useSwapForm.tsx Outdated Show resolved Hide resolved
src/components/SigningBox/index.tsx Outdated Show resolved Hide resolved
src/contexts/network.tsx Outdated Show resolved Hide resolved
src/stores/sep24Store.ts Show resolved Hide resolved
src/hooks/offramp/useOfframpAdvancement.ts Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

In a separate PR we can refactor it into a zustand store

@@ -1,10 +1,11 @@
import { polygon } from '@reown/appkit/networks';
import { polygon, bsc, arbitrum, base, avalanche, mainnet } from '@reown/appkit/networks';
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should import it once. Now we import it here and in networks.ts. This may cause problems in the future if we forget to import it in one of these two places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be. But this are just constants right? Or you mean, to have a centralized place to handle network information in case we deviate from appkit's definitions.

@Sharqiewicz
Copy link
Contributor

@pendulum-chain/devs I have refactored the code, please review.

Changes:

  • Divide SEP logic into SEP10 anchor/sep10 and SEP24 anchor/sep24
  • Improve Navbar responsiveness
  • Fix fee comparison quotes
  • Add selectedChain to useEvmBalance
  • Adjust Fee Comparison tooltip
  • Simplified Networks logic

if (network !== polygon.name) {
throw new Error(`Network ${network} is not supported`);
let compatibleNetwork = network;
if (!isNetworkEVM(network)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not so sure we want to show the fee comparison of Polygon when on AssetHub. If we throw here, then it will display N/A which in my opinion is better. Especially since AssetHub has some higher costs.

Copy link
Contributor

Choose a reason for hiding this comment

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

For AssetHub we want to show Polygon prices.

<div
    className="tooltip tooltip-primary before:whitespace-pre-wrap before:content-[attr(data-tip)]"
    data-tip="Quotes are for Polygon, as the providers don't support Asset hub."
            >
              (Polygon)
</div>

@gianfra-t
Copy link
Contributor Author

gianfra-t commented Jan 6, 2025

Thanks for the improvements @Sharqiewicz . Seems cleaner! I just tested an off-ramp from BSC and on friday, I tested from AssetHub. I think it is good to go.

We should only decide what to do with this, to default to one network or show nothing.

@gianfra-t gianfra-t merged commit ed95ba2 into polygon-prototype-staging Jan 7, 2025
5 checks passed
@ebma ebma deleted the 292-update-flow-to-start-off-ramping-from-evm-networks branch January 7, 2025 15:07
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.

Update flow to start off ramping from EVM networks
2 participants