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: decouple network fees from quote #8432

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Dec 20, 2024

Description

Note: This is exclusively tackling network fees estimate for current hop, and is used within the new trade flow components.

This PR refetches network fees at interval for current hop, using similar logic as getUnsignedXyzTransaction to get calldata and estimate network fees from that.

TODO:

  • make PoC work for one swapper only (debugger breakpoint in query is happy)
  • move me useTradeNetworkFeesCryptoBaseUnit instead of colocated with tradeExecution
  • tackle for all swappers
  • wire-up in new trade flow <TradeConfirmFooter />
  • don't try and fetch network fee if approval is required
  • remove from final quote (maybe?) probably not (at least not now)

Issue (if applicable)

closes #8270

Risk

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Low - new trade flow only, not in prod yet. Though, if we consider flagged paths as production paths, this should be considered medium risk, as displayed fees could be off, and Txs could fail as a result.

Testing

  • Attempt a trade all the way to final quote (approval granted)
  • Ensure that network fees refetch at interval
  • Try with all swappers and chain families

Engineering

  • ☝🏽

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)
  • ☝🏽

Screenshots (if applicable)

https://jam.dev/c/9cf1706f-53d3-46d0-9a4c-cafd5f494462

@gomesalexandre gomesalexandre changed the title [skip ci] wip: decouple network fees from quote feat: decouple network fees from quote Dec 23, 2024
Comment on lines +98 to +102
isLoading:
allowanceCryptoBaseUnitResult.isLoading ||
evmFeesResult.isLoading ||
allowanceCryptoBaseUnitResult.isRefetching ||
evmFeesResult.isRefetching,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allowance can and will refetch at interval, but we were not capturing this properly, meaning only initial loading state would trigger a skeleton

if (!isSolanaFeeData(step.feeData.chainSpecific)) throw Error('Unable to execute step')

const buildSwapTxInput: BuildSendApiTxInput<KnownChainIds.SolanaMainnet> = {
to: '',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks odd but is correct, same payload as getUnsignedSolanaTransaction, to gets added in adapter.buildSendApiTransaction() below

@gomesalexandre gomesalexandre marked this pull request as ready for review December 23, 2024 15:20
@gomesalexandre gomesalexandre requested a review from a team as a code owner December 23, 2024 15:20
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 network fees at trade confirmation screens as needed separate from quotes
1 participant