Skip to content

Commit 665035f

Browse files
authored
feat: Add gas included swaps (#13430)
## **Description** Users who don't have enough ETH to pay for gas fees while swapping will be able to swap now if the gas fee can be taken from one of the tokens they are swapping. Smart transactions must be enabled for this. ## **Related issues** Fixes: ## **Manual testing steps** Test case 1: 1. Make sure you are on Ethereum mainnet and have Smart Transactions on in Advanced Settings 2. Have e.g. 0 ETH and 100 USDC 3. Fill in the swap form with 10 USDC -> ETH 6. You will see gas included swaps UI Test case 2: 1. Make sure you are on Ethereum mainnet and have Smart Transactions on in Advanced Settings 4. In Swaps you can now click on `Use max` for ETH 5. Get quotes 6. You will see gas included swaps UI ## **Screenshots/Recordings** User doesn't have enough ETH for gas fees (gas included swaps): ![image](https://github.com/user-attachments/assets/a16ccf1d-bebd-4dad-8668-639c2f912aa5) User has enough ETH for gas fees: ![image](https://github.com/user-attachments/assets/d0bfa7e4-ffa1-4899-a0ba-725dcaee7833) ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent ed21162 commit 665035f

File tree

14 files changed

+791
-212
lines changed

14 files changed

+791
-212
lines changed

app/components/Nav/Main/RootRPCMethodsUI.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ const RootRPCMethodsUI = (props) => {
239239
quote_vs_executionRatio: quoteVsExecutionRatio,
240240
token_to_amount_received: tokenToAmountReceived.toString(),
241241
is_smart_transaction: props.shouldUseSmartTransaction,
242+
gas_included: analyticsParams.isGasIncludedTrade,
242243
...smartTransactionMetricsProperties,
243244
available_quotes: analyticsParams.available_quotes,
244245
best_quote_source: analyticsParams.best_quote_source,
@@ -335,7 +336,7 @@ const RootRPCMethodsUI = (props) => {
335336
transactionId: transactionMeta.id,
336337
deviceId,
337338
// eslint-disable-next-line no-empty-function
338-
onConfirmationComplete: () => { },
339+
onConfirmationComplete: () => {},
339340
type: 'signTransaction',
340341
}),
341342
);
@@ -405,7 +406,8 @@ const RootRPCMethodsUI = (props) => {
405406
data &&
406407
data !== '0x' &&
407408
to &&
408-
(await getMethodData(data, networkClientId)).name === TOKEN_METHOD_TRANSFER
409+
(await getMethodData(data, networkClientId)).name ===
410+
TOKEN_METHOD_TRANSFER
409411
) {
410412
let asset = props.tokens.find(({ address }) =>
411413
toLowerCaseEquals(address, to),

0 commit comments

Comments
 (0)