Skip to content

fix: mms-2049 solana slipagge #30760

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

Merged
merged 4 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/scripts/controllers/swaps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export default class SwapsController extends BaseController<

// For a user to be able to swap a token, they need to have approved the MetaSwap contract to withdraw that token.
// _getERC20Allowance() returns the amount of the token they have approved for withdrawal. If that amount is either
// zero or less than the soucreAmount of the swap, a new call of the ERC-20 approve method is required.
// zero or less than the sourceAmount of the swap, a new call of the ERC-20 approve method is required.
approvalRequired =
firstQuote.approvalNeeded &&
(allowance.eq(0) || allowance.lt(firstQuote.sourceAmount)) &&
Expand Down
15 changes: 14 additions & 1 deletion shared/modules/bridge-utils/bridge.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import {
type TokenV3Asset,
FeeType,
} from '../../types/bridge';
///: BEGIN:ONLY_INCLUDE_IF(solana-swaps)
import { MultichainNetworks } from '../../constants/multichain/networks';
///: END:ONLY_INCLUDE_IF

import {
formatAddressToString,
formatChainIdToDec,
Expand Down Expand Up @@ -174,6 +178,15 @@ export async function fetchBridgeQuotes(
request: GenericQuoteRequest,
signal: AbortSignal,
): Promise<QuoteResponse[]> {
// Ignore slippage for solana swaps
let ignoreSlippage = false;

///: BEGIN:ONLY_INCLUDE_IF(solana-swaps)
ignoreSlippage =
request.srcChainId === request.destChainId &&
request.destChainId === MultichainNetworks.SOLANA;
///: END:ONLY_INCLUDE_IF

const normalizedRequest = {
walletAddress: formatAddressToString(request.walletAddress),
destWalletAddress: formatAddressToString(
Expand All @@ -184,7 +197,7 @@ export async function fetchBridgeQuotes(
srcTokenAddress: formatAddressToString(request.srcTokenAddress),
destTokenAddress: formatAddressToString(request.destTokenAddress),
srcTokenAmount: request.srcTokenAmount,
slippage: request.slippage.toString(),
...(ignoreSlippage ? {} : { slippage: request.slippage.toString() }),
insufficientBal: request.insufficientBal ? 'true' : 'false',
resetApproval: request.resetApproval ? 'true' : 'false',
};
Expand Down
2 changes: 1 addition & 1 deletion ui/ducks/swaps/swaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ export const fetchQuotesAndSetQuoteState = (
);

// Firefox and Chrome have different implementations of the APIs
// that we rely on for communication accross the app. On Chrome big
// that we rely on for communication across the app. On Chrome big
// numbers are converted into number strings, on firefox they remain
// Big Number objects. As such, we convert them here for both
// browsers.
Expand Down
Loading