Skip to content

Commit fd74d7a

Browse files
committed
chore(boba): need rewritter web3.eth.sendSignedTransaction
1 parent c687fad commit fd74d7a

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ChainId, DAI, USDC, USDT, WBTC, WNATIVE, WNATIVE_ONLY } from '@masknet/web3-shared-evm'
2+
import type { ERC20AgainstToken, ERC20TokenCustomizedBase } from './types'
3+
4+
/**
5+
* Some tokens can only be swapped via certain pairs,
6+
* so we override the list of bases that are considered for these tokens.
7+
*/
8+
export const JUGGLERRED_CUSTOM_BASES: ERC20TokenCustomizedBase = {}
9+
10+
export const JUGGLERRED_BASE_AGAINST_TOKENS: ERC20AgainstToken = {
11+
...WNATIVE_ONLY,
12+
[ChainId.Optimistic]: [WNATIVE, DAI, USDC, USDT, WBTC].map((x) => x[ChainId.Optimistic]),
13+
}

packages/mask/src/plugins/Trader/trader/uniswap/useTradeCallback.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import { useCallback, useState } from 'react'
22
import BigNumber from 'bignumber.js'
33
import type { SwapParameters } from '@uniswap/v2-sdk'
4-
import { GasOptionConfig, TransactionState, TransactionStateType, useAccount, useWeb3 } from '@masknet/web3-shared-evm'
4+
import {
5+
GasOptionConfig,
6+
TransactionState,
7+
TransactionStateType,
8+
useAccount,
9+
useWeb3,
10+
ChainId,
11+
} from '@masknet/web3-shared-evm'
512
import { useSwapParameters as useTradeParameters } from './useTradeParameters'
613
import type { SwapCall, Trade, TradeComputed } from '../../types'
714
import { swapErrorToUserReadableMessage } from '../../helpers'
8-
import type { TradeProvider } from '@masknet/public-api'
15+
import { TradeProvider } from '@masknet/public-api'
916
import { TargetChainIdContext } from '../useTargetChainIdContext'
1017
import { FeeMarketEIP1559Transaction } from '@ethereumjs/tx'
1118

@@ -28,6 +35,8 @@ interface FailedCall extends SwapCallEstimate {
2835
error: Error
2936
}
3037

38+
const SUPPORTED_OPTMISTIC_CHAIN_ID_LIST = [ChainId.Optimistic, ChainId.Boba, ChainId.Metis]
39+
3140
export function useTradeCallback(
3241
trade: TradeComputed<Trade> | null,
3342
tradeProvider?: TradeProvider,
@@ -123,8 +132,8 @@ export function useTradeCallback(
123132
bestCallOption = firstNoErrorCall
124133
}
125134

126-
// check if boba network
127-
if (targetChainId === 288) {
135+
// check if optimistic network
136+
if (SUPPORTED_OPTMISTIC_CHAIN_ID_LIST && !!TradeProvider.OPENOCEAN && !!TradeProvider.DODO) {
128137
return new Promise<string>(async (resolve, reject) => {
129138
if (!bestCallOption) {
130139
setTradeState({
@@ -145,8 +154,8 @@ export function useTradeCallback(
145154
...('gasEstimate' in bestCallOption
146155
? {
147156
gas: bestCallOption.gasEstimate.toFixed(),
148-
maxFeePerGas: '1.5',
149-
maxPriorityFeePerGas: '1.5',
157+
maxFeePerGas: gasConfig?.maxFeePerGas,
158+
maxPriorityFeePerGas: gasConfig?.maxPriorityFeePerGas,
150159
}
151160
: {}),
152161
...(!value || /^0x0*$/.test(value) ? {} : { value }),

0 commit comments

Comments
 (0)