Skip to content

Commit bf3f231

Browse files
authored
Apply Solana→EVM fee multiplier workaround for SDK under-reporting (#3701)
1 parent 1aad741 commit bf3f231

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

packages/core-mobile/app/new/features/swap/hooks/useFeeEstimation.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@ import { buildFeeOptions } from './useMaxSwapAmount/utils'
1717
* points). Use gasSafetyBps for the Max button (needs extra headroom); omit it
1818
* for balance validation (standard estimate is sufficient).
1919
*
20+
* solanaToEvmFeeMultiplier: temporary workaround for the SDK under-reporting
21+
* fees on Solana→EVM routes. Multiplied into the raw fee before gasSafetyBps
22+
* is applied. Use 12 for validation, 15 for Max. No effect on other routes.
23+
*
2024
* Returns gasFee as undefined while the estimate is loading.
2125
*/
2226
export const useFeeEstimation = ({
2327
quote,
2428
fromNetwork,
25-
gasSafetyBps = 0
29+
gasSafetyBps = 0,
30+
solanaToEvmFeeMultiplier = 1
2631
}: {
2732
quote: Quote | null
2833
fromNetwork?: NetworkWithCaip2ChainId
2934
gasSafetyBps?: number
35+
/** Temporary workaround: SDK under-reports fees on Solana→EVM routes */
36+
solanaToEvmFeeMultiplier?: number
3037
}): {
3138
gasFee: bigint | undefined
3239
rawGasFee: bigint | undefined
@@ -47,18 +54,26 @@ export const useFeeEstimation = ({
4754
ReactQueryKeys.FUSION_SWAP_FEE_ESTIMATE,
4855
quote?.id,
4956
feeOptions.feeUnitsMarginBps,
50-
gasSafetyBps
57+
gasSafetyBps,
58+
solanaToEvmFeeMultiplier
5159
],
5260
queryFn: quote
5361
? async () => {
5462
const { totalUpfrontFee } = await FusionService.estimateNativeFee(
5563
quote,
5664
feeOptions
5765
)
66+
const isSolanaToEvm =
67+
quote.sourceChain.chainId.startsWith('solana:') &&
68+
quote.targetChain.chainId.startsWith('eip155:')
69+
const adjustedFee =
70+
isSolanaToEvm && solanaToEvmFeeMultiplier > 1
71+
? totalUpfrontFee * BigInt(solanaToEvmFeeMultiplier)
72+
: totalUpfrontFee
5873
const buffered =
5974
gasSafetyBps > 0
60-
? (totalUpfrontFee * (10000n + BigInt(gasSafetyBps))) / 10000n
61-
: totalUpfrontFee
75+
? (adjustedFee * (10000n + BigInt(gasSafetyBps))) / 10000n
76+
: adjustedFee
6277
return { raw: totalUpfrontFee, buffered }
6378
}
6479
: skipToken,

packages/core-mobile/app/new/features/swap/hooks/useFeeValidation/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ export const useFeeValidation = ({
111111
rawGasFee,
112112
error,
113113
isFetching
114-
} = useFeeEstimation({ quote, fromNetwork, gasSafetyBps })
114+
} = useFeeEstimation({
115+
quote,
116+
fromNetwork,
117+
gasSafetyBps,
118+
solanaToEvmFeeMultiplier: 12
119+
})
115120

116121
const validationError = useMemo(() => {
117122
if (error && !isFetching) {

packages/core-mobile/app/new/features/swap/hooks/useMaxSwapAmount/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ export const useMaxSwapAmount = ({
148148
} = useFeeEstimation({
149149
quote: preQuote,
150150
fromNetwork,
151-
gasSafetyBps: maxAmountGasSafetyBps
151+
gasSafetyBps: maxAmountGasSafetyBps,
152+
solanaToEvmFeeMultiplier: 15
152153
})
153154

154155
const additiveFeeForMax = resolveAdditiveFeeForMax(

0 commit comments

Comments
 (0)