Skip to content

Commit 0cd1ba5

Browse files
committed
chore(dex): enable traderJoe pangolindex and fixed ClaimAllDialog
1 parent b95185e commit 0cd1ba5

File tree

11 files changed

+177
-14
lines changed

11 files changed

+177
-14
lines changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@
254254
"walletconnect",
255255
"WANNASWAP",
256256
"wault",
257+
"WAVAX",
257258
"webextension",
258259
"webm",
259260
"withdrawed",

packages/mask/src/plugins/ITO/SNSAdaptor/ClaimAllDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export function ClaimAllDialog(props: ClaimAllDialogProps) {
333333
</div>
334334
<div className={classes.contentWrapper} ref={DialogRef}>
335335
{(showNftAirdrop || loadingAirdrop) &&
336-
chainId === ChainId.Matic &&
336+
SUPPORTED_CHAIN_ID_LIST.includes(chainId) &&
337337
Flags.nft_airdrop_enabled ? (
338338
<NftAirdropCard
339339
campaignInfos={campaignInfos!}
@@ -356,7 +356,7 @@ export function ClaimAllDialog(props: ClaimAllDialogProps) {
356356
</div>
357357
) : null}
358358
{(swappedTokens && swappedTokens.length > 0) ||
359-
(chainId === ChainId.Matic && Flags.nft_airdrop_enabled) ? (
359+
(SUPPORTED_CHAIN_ID_LIST.includes(chainId) && Flags.nft_airdrop_enabled) ? (
360360
<div className={classes.actionButtonWrapper}>
361361
<EthereumChainBoundary
362362
chainId={chainId}

packages/mask/src/plugins/Trader/apis/trader/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function getAvailableTraderProviders(chainId: ChainId) {
4141
case NetworkType.xDai:
4242
return [TradeProvider.SUSHISWAP]
4343
case NetworkType.Avalanche:
44-
return [TradeProvider.SUSHISWAP, TradeProvider.TRADERJOE, TradeProvider.OPENOCEAN, TradeProvider.PANGOLIN]
44+
return [TradeProvider.SUSHISWAP, TradeProvider.OPENOCEAN, TradeProvider.TRADERJOE, TradeProvider.PANGOLIN]
4545
case NetworkType.xDai:
4646
return [TradeProvider.SUSHISWAP, TradeProvider.OPENOCEAN]
4747
case NetworkType.Celo:

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

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { SwapRouter } from '@uniswap/v3-sdk'
99
import { useRouterV2Contract } from '../../contracts/uniswap/useRouterV2Contract'
1010
import { useSwapRouterContract } from '../../contracts/uniswap/useSwapRouterContract'
1111
import { useTransactionDeadline } from './useTransactionDeadline'
12-
import type { TradeProvider } from '@masknet/public-api'
1312
import { useGetTradeContext } from '../useGetTradeContext'
1413
import { TargetChainIdContext } from '../useTargetChainIdContext'
14+
import { TradeProvider } from '@masknet/public-api'
1515

1616
const UNISWAP_BIPS_BASE = JSBI.BigInt(10_000)
1717

@@ -39,8 +39,43 @@ export function useSwapParameters(
3939

4040
if (trade_ instanceof V2Trade) {
4141
if (!routerV2Contract) return []
42+
43+
type SwapParams = Parameters<typeof Router.swapCallParameters>
44+
const swapCallParameters = (
45+
trade: SwapParams[0],
46+
options: SwapParams[1],
47+
tradeProvider?: TradeProvider,
48+
) => {
49+
const parameters = Router.swapCallParameters(trade, options)
50+
if (
51+
tradeProvider === TradeProvider.PANGOLIN ||
52+
(TradeProvider.TRADERJOE && tradeProvider !== TradeProvider.SUSHISWAP)
53+
) {
54+
switch (parameters.methodName) {
55+
case 'swapTokensForExactETH':
56+
parameters.methodName = 'swapTokensForExactAVAX'
57+
break
58+
case 'swapExactTokensForETHSupportingFeeOnTransferTokens':
59+
parameters.methodName = 'swapExactTokensForAVAXSupportingFeeOnTransferTokens'
60+
break
61+
case 'swapExactTokensForETH':
62+
parameters.methodName = 'swapExactTokensForAVAX'
63+
break
64+
case 'swapExactETHForTokensSupportingFeeOnTransferTokens':
65+
parameters.methodName = 'swapExactAVAXForTokensSupportingFeeOnTransferTokens'
66+
break
67+
case 'swapExactETHForTokens':
68+
parameters.methodName = 'swapExactAVAXForTokens'
69+
break
70+
case 'WETH':
71+
parameters.methodName = 'WAVAX'
72+
break
73+
}
74+
}
75+
return parameters
76+
}
4277
const parameters = [
43-
Router.swapCallParameters(trade_, {
78+
swapCallParameters(trade_, {
4479
feeOnTransfer: false,
4580
allowedSlippage: allowedSlippage_,
4681
recipient: account,
@@ -49,7 +84,7 @@ export function useSwapParameters(
4984
]
5085
if (trade_.tradeType === TradeType.EXACT_INPUT)
5186
parameters.push(
52-
Router.swapCallParameters(trade_, {
87+
swapCallParameters(trade_, {
5388
feeOnTransfer: true,
5489
allowedSlippage: allowedSlippage_,
5590
recipient: account,

packages/web3-contracts/abis/RouterV2.json

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,87 @@
336336
"stateMutability": "nonpayable",
337337
"type": "function"
338338
},
339+
{
340+
"inputs": [
341+
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" },
342+
{ "internalType": "address[]", "name": "path", "type": "address[]" },
343+
{ "internalType": "address", "name": "to", "type": "address" },
344+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
345+
],
346+
"name": "swapAVAXForExactTokens",
347+
"outputs": [{ "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }],
348+
"stateMutability": "payable",
349+
"type": "function"
350+
},
351+
{
352+
"inputs": [
353+
{ "internalType": "uint256", "name": "amountOutMin", "type": "uint256" },
354+
{ "internalType": "address[]", "name": "path", "type": "address[]" },
355+
{ "internalType": "address", "name": "to", "type": "address" },
356+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
357+
],
358+
"name": "swapExactAVAXForTokensSupportingFeeOnTransferTokens",
359+
"outputs": [],
360+
"stateMutability": "payable",
361+
"type": "function"
362+
},
363+
{
364+
"inputs": [
365+
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" },
366+
{ "internalType": "uint256", "name": "amountOutMin", "type": "uint256" },
367+
{ "internalType": "address[]", "name": "path", "type": "address[]" },
368+
{ "internalType": "address", "name": "to", "type": "address" },
369+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
370+
],
371+
"name": "swapExactTokensForAVAX",
372+
"outputs": [{ "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }],
373+
"stateMutability": "nonpayable",
374+
"type": "function"
375+
},
376+
{
377+
"inputs": [
378+
{ "internalType": "uint256", "name": "amountIn", "type": "uint256" },
379+
{ "internalType": "uint256", "name": "amountOutMin", "type": "uint256" },
380+
{ "internalType": "address[]", "name": "path", "type": "address[]" },
381+
{ "internalType": "address", "name": "to", "type": "address" },
382+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
383+
],
384+
"name": "swapExactTokensForAVAXSupportingFeeOnTransferTokens",
385+
"outputs": [],
386+
"stateMutability": "nonpayable",
387+
"type": "function"
388+
},
389+
{
390+
"inputs": [
391+
{ "internalType": "uint256", "name": "amountOut", "type": "uint256" },
392+
{ "internalType": "uint256", "name": "amountInMax", "type": "uint256" },
393+
{ "internalType": "address[]", "name": "path", "type": "address[]" },
394+
{ "internalType": "address", "name": "to", "type": "address" },
395+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
396+
],
397+
"name": "swapTokensForExactAVAX",
398+
"outputs": [{ "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }],
399+
"stateMutability": "nonpayable",
400+
"type": "function"
401+
},
402+
{
403+
"inputs": [
404+
{ "internalType": "uint256", "name": "amountOutMin", "type": "uint256" },
405+
{ "internalType": "address[]", "name": "path", "type": "address[]" },
406+
{ "internalType": "address", "name": "to", "type": "address" },
407+
{ "internalType": "uint256", "name": "deadline", "type": "uint256" }
408+
],
409+
"name": "swapExactAVAXForTokens",
410+
"outputs": [{ "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }],
411+
"stateMutability": "payable",
412+
"type": "function"
413+
},
414+
{
415+
"inputs": [],
416+
"name": "WAVAX",
417+
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
418+
"stateMutability": "view",
419+
"type": "function"
420+
},
339421
{ "stateMutability": "payable", "type": "receive" }
340422
]

packages/web3-contracts/types/CryptoArtAIArtistAcceptingBidsV2.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
BaseContract,
1616
} from './types'
1717

18-
export interface EventOptions {
18+
interface EventOptions {
1919
filter?: object
2020
fromBlock?: BlockType
2121
topics?: string[]

packages/web3-contracts/types/CryptoArtAICANFTMarket.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
BaseContract,
1616
} from './types'
1717

18-
export interface EventOptions {
18+
interface EventOptions {
1919
filter?: object
2020
fromBlock?: BlockType
2121
topics?: string[]

packages/web3-contracts/types/CryptoArtAIKnownOriginDigitalAssetV2.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
BaseContract,
1616
} from './types'
1717

18-
export interface EventOptions {
18+
interface EventOptions {
1919
filter?: object
2020
fromBlock?: BlockType
2121
topics?: string[]

packages/web3-contracts/types/ERC20.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ export interface ERC20 extends BaseContract {
4444
methods: {
4545
name(): NonPayableTransactionObject<string>
4646

47-
approve(_spender: string, _value: number | string | BN): NonPayableTransactionObject<boolean>
47+
approve(spender: string, value: number | string | BN): NonPayableTransactionObject<boolean>
4848

4949
totalSupply(): NonPayableTransactionObject<string>
5050

51-
transferFrom(_from: string, _to: string, _value: number | string | BN): NonPayableTransactionObject<boolean>
51+
transferFrom(from: string, to: string, value: number | string | BN): NonPayableTransactionObject<boolean>
5252

5353
decimals(): NonPayableTransactionObject<string>
5454

5555
balanceOf(_owner: string): NonPayableTransactionObject<string>
5656

5757
symbol(): NonPayableTransactionObject<string>
5858

59-
transfer(_to: string, _value: number | string | BN): NonPayableTransactionObject<boolean>
59+
transfer(to: string, value: number | string | BN): NonPayableTransactionObject<boolean>
6060

6161
allowance(_owner: string, _spender: string): NonPayableTransactionObject<string>
6262
}

packages/web3-contracts/types/RouterV2.d.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,53 @@ export interface RouterV2 extends BaseContract {
241241
to: string,
242242
deadline: number | string | BN,
243243
): NonPayableTransactionObject<string[]>
244+
245+
swapAVAXForExactTokens(
246+
amountOut: number | string | BN,
247+
path: string[],
248+
to: string,
249+
deadline: number | string | BN,
250+
): PayableTransactionObject<string[]>
251+
252+
swapExactAVAXForTokensSupportingFeeOnTransferTokens(
253+
amountOutMin: number | string | BN,
254+
path: string[],
255+
to: string,
256+
deadline: number | string | BN,
257+
): PayableTransactionObject<void>
258+
259+
swapExactTokensForAVAX(
260+
amountIn: number | string | BN,
261+
amountOutMin: number | string | BN,
262+
path: string[],
263+
to: string,
264+
deadline: number | string | BN,
265+
): NonPayableTransactionObject<string[]>
266+
267+
swapExactTokensForAVAXSupportingFeeOnTransferTokens(
268+
amountIn: number | string | BN,
269+
amountOutMin: number | string | BN,
270+
path: string[],
271+
to: string,
272+
deadline: number | string | BN,
273+
): NonPayableTransactionObject<void>
274+
275+
swapTokensForExactAVAX(
276+
amountOut: number | string | BN,
277+
amountInMax: number | string | BN,
278+
path: string[],
279+
to: string,
280+
deadline: number | string | BN,
281+
): NonPayableTransactionObject<string[]>
282+
283+
swapExactAVAXForTokens(
284+
amountOutMin: number | string | BN,
285+
path: string[],
286+
to: string,
287+
deadline: number | string | BN,
288+
): PayableTransactionObject<string[]>
289+
290+
WAVAX(): NonPayableTransactionObject<string>
244291
}
245292
events: {
246293
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter

0 commit comments

Comments
 (0)