Skip to content

Commit d14a57f

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

File tree

10 files changed

+161
-15
lines changed

10 files changed

+161
-15
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,7 @@ export function ClaimAllDialog(props: ClaimAllDialogProps) {
332332
/>
333333
</div>
334334
<div className={classes.contentWrapper} ref={DialogRef}>
335-
{(showNftAirdrop || loadingAirdrop) &&
336-
chainId === ChainId.Matic &&
337-
Flags.nft_airdrop_enabled ? (
335+
{(showNftAirdrop || loadingAirdrop) && SUPPORTED_CHAIN_ID_LIST && Flags.nft_airdrop_enabled ? (
338336
<NftAirdropCard
339337
campaignInfos={campaignInfos!}
340338
loading={loadingAirdrop}
@@ -356,7 +354,7 @@ export function ClaimAllDialog(props: ClaimAllDialogProps) {
356354
</div>
357355
) : null}
358356
{(swappedTokens && swappedTokens.length > 0) ||
359-
(chainId === ChainId.Matic && Flags.nft_airdrop_enabled) ? (
357+
(SUPPORTED_CHAIN_ID_LIST && Flags.nft_airdrop_enabled) ? (
360358
<div className={classes.actionButtonWrapper}>
361359
<EthereumChainBoundary
362360
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: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useTransactionDeadline } from './useTransactionDeadline'
1212
import type { TradeProvider } from '@masknet/public-api'
1313
import { useGetTradeContext } from '../useGetTradeContext'
1414
import { TargetChainIdContext } from '../useTargetChainIdContext'
15+
import { TradeProvider as dexProvider } from '@masknet/public-api'
1516

1617
const UNISWAP_BIPS_BASE = JSBI.BigInt(10_000)
1718

@@ -39,8 +40,37 @@ export function useSwapParameters(
3940

4041
if (trade_ instanceof V2Trade) {
4142
if (!routerV2Contract) return []
43+
44+
type SwapParams = Parameters<typeof Router.swapCallParameters>
45+
const swapCallParameters = (
46+
trade: SwapParams[0],
47+
options: SwapParams[1],
48+
tradeProvider?: TradeProvider,
49+
) => {
50+
const parameters = Router.swapCallParameters(trade, options)
51+
if (tradeProvider === dexProvider.PANGOLIN || dexProvider.TRADERJOE) {
52+
switch (parameters.methodName) {
53+
case 'swapTokensForExactETH':
54+
parameters.methodName = 'swapTokensForExactAVAX'
55+
break
56+
case 'swapExactTokensForETHSupportingFeeOnTransferTokens':
57+
parameters.methodName = 'swapExactTokensForAVAXSupportingFeeOnTransferTokens'
58+
break
59+
case 'swapExactTokensForETH':
60+
parameters.methodName = 'swapExactTokensForAVAX'
61+
break
62+
case 'swapExactETHForTokensSupportingFeeOnTransferTokens':
63+
parameters.methodName = 'swapExactAVAXForTokensSupportingFeeOnTransferTokens'
64+
break
65+
case 'swapExactETHForTokens':
66+
parameters.methodName = 'swapExactAVAXForTokens'
67+
break
68+
}
69+
}
70+
return parameters
71+
}
4272
const parameters = [
43-
Router.swapCallParameters(trade_, {
73+
swapCallParameters(trade_, {
4474
feeOnTransfer: false,
4575
allowedSlippage: allowedSlippage_,
4676
recipient: account,
@@ -49,7 +79,7 @@ export function useSwapParameters(
4979
]
5080
if (trade_.tradeType === TradeType.EXACT_INPUT)
5181
parameters.push(
52-
Router.swapCallParameters(trade_, {
82+
swapCallParameters(trade_, {
5383
feeOnTransfer: true,
5484
allowedSlippage: allowedSlippage_,
5585
recipient: account,

packages/web3-contracts/abis/RouterV2.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,80 @@
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+
},
339414
{ "stateMutability": "payable", "type": "receive" }
340415
]

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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,51 @@ 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[]>
244289
}
245290
events: {
246291
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ export interface NonPayableTx {
3535
to?: string
3636
data?: string
3737
gas?: string | number | BN
38-
maxFeePerGas?: string | number | BN
39-
maxPriorityFeePerGas?: string | number | BN
4038
gasPrice?: string | number | BN
4139
}
4240

0 commit comments

Comments
 (0)