@xswap-link/sdk 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.global.js +111 -110
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
- package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +6 -2
- package/src/components/TxWidgetWC/index.tsx +3 -2
- package/src/context/SwapProvider.tsx +20 -10
- package/src/contracts/addresses.ts +7 -0
package/package.json
CHANGED
|
@@ -36,7 +36,9 @@ export const AmountPanel = ({ type }: Props) => {
|
|
|
36
36
|
value={srcValue}
|
|
37
37
|
onChange={(value) => setSrcValue(value)}
|
|
38
38
|
/>
|
|
39
|
-
|
|
39
|
+
{valueUsd && (
|
|
40
|
+
<div className={`text-sx opacity-60`}>{`$${valueUsd}`}</div>
|
|
41
|
+
)}
|
|
40
42
|
</>
|
|
41
43
|
) : isFetchingRoute ? (
|
|
42
44
|
<div className="flex flex-col gap-1">
|
|
@@ -48,7 +50,9 @@ export const AmountPanel = ({ type }: Props) => {
|
|
|
48
50
|
<div className={`text-xl text-t_text_secondary`}>
|
|
49
51
|
{dstValue || 0}
|
|
50
52
|
</div>
|
|
51
|
-
|
|
53
|
+
{valueUsd && (
|
|
54
|
+
<div className={`text-sx opacity-60`}>{`$${valueUsd}`}</div>
|
|
55
|
+
)}
|
|
52
56
|
</>
|
|
53
57
|
)}
|
|
54
58
|
</div>
|
|
@@ -43,8 +43,9 @@ const TxWidget = ({
|
|
|
43
43
|
setLoading(true);
|
|
44
44
|
|
|
45
45
|
const chains = (await getChains()).filter(
|
|
46
|
-
({ web3Environment, swapSupported }) =>
|
|
47
|
-
web3Environment === Web3Environment.MAINNET &&
|
|
46
|
+
({ web3Environment, bridgeSupported, swapSupported }) =>
|
|
47
|
+
web3Environment === Web3Environment.MAINNET &&
|
|
48
|
+
(bridgeSupported || swapSupported),
|
|
48
49
|
);
|
|
49
50
|
|
|
50
51
|
setSupportedChains(chains);
|
|
@@ -83,10 +83,10 @@ type SwapContext = {
|
|
|
83
83
|
srcValue: string;
|
|
84
84
|
setSrcValue: Dispatch<SetStateAction<string>>;
|
|
85
85
|
srcValueWei: string;
|
|
86
|
-
srcValueUsd: string;
|
|
86
|
+
srcValueUsd: string | null;
|
|
87
87
|
dstValue: string;
|
|
88
88
|
dstValueWei: string;
|
|
89
|
-
dstValueUsd: string;
|
|
89
|
+
dstValueUsd: string | null;
|
|
90
90
|
dstValueMin: string;
|
|
91
91
|
lastTx: Transaction | undefined;
|
|
92
92
|
setLastTxHash: Dispatch<SetStateAction<string>>;
|
|
@@ -143,10 +143,10 @@ const init: SwapContext = {
|
|
|
143
143
|
dstToken: undefined,
|
|
144
144
|
srcValue: "",
|
|
145
145
|
srcValueWei: "",
|
|
146
|
-
srcValueUsd:
|
|
146
|
+
srcValueUsd: null,
|
|
147
147
|
dstValue: "",
|
|
148
148
|
dstValueWei: "",
|
|
149
|
-
dstValueUsd:
|
|
149
|
+
dstValueUsd: null,
|
|
150
150
|
dstValueMin: "",
|
|
151
151
|
lastTx: undefined,
|
|
152
152
|
expressDelivery: true,
|
|
@@ -436,7 +436,7 @@ export const SwapProvider = ({
|
|
|
436
436
|
Number(srcValue) * Number(srcChainTokensPrices[srcToken.address])
|
|
437
437
|
).toFixed(2);
|
|
438
438
|
}
|
|
439
|
-
return
|
|
439
|
+
return null;
|
|
440
440
|
}, [srcChainTokensPrices, srcToken, srcValue]);
|
|
441
441
|
const dstValue = useMemo(
|
|
442
442
|
() =>
|
|
@@ -466,7 +466,7 @@ export const SwapProvider = ({
|
|
|
466
466
|
Number(dstValue) * Number(dstChainTokensPrices[dstToken.address])
|
|
467
467
|
).toFixed(2);
|
|
468
468
|
}
|
|
469
|
-
return
|
|
469
|
+
return null;
|
|
470
470
|
}, [dstChainTokensPrices, dstToken, dstValue]);
|
|
471
471
|
const dstValueMin = useMemo(
|
|
472
472
|
() =>
|
|
@@ -589,10 +589,20 @@ export const SwapProvider = ({
|
|
|
589
589
|
// other source networks
|
|
590
590
|
const srcOtherTokenOptions: TokenOption[] = [];
|
|
591
591
|
const srcOtherChains = supportedChains.filter(
|
|
592
|
-
({ chainId, web3Environment, swapSupported }) =>
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
592
|
+
({ chainId, web3Environment, swapSupported, bridgeSupported }) => {
|
|
593
|
+
if (
|
|
594
|
+
chainId === srcChain.chainId ||
|
|
595
|
+
web3Environment !== Web3Environment.MAINNET
|
|
596
|
+
) {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
if (bridgeUI) {
|
|
601
|
+
return bridgeSupported;
|
|
602
|
+
} else {
|
|
603
|
+
return swapSupported;
|
|
604
|
+
}
|
|
605
|
+
},
|
|
596
606
|
);
|
|
597
607
|
for (const { chainId } of srcOtherChains) {
|
|
598
608
|
srcOtherTokenOptions.push(
|
|
@@ -67,4 +67,11 @@ export const ADDRESSES: Addresses = {
|
|
|
67
67
|
[ContractName.XSwapRouterSingleChain]:
|
|
68
68
|
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
69
69
|
},
|
|
70
|
+
// mode
|
|
71
|
+
"34443": {
|
|
72
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
73
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
74
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
75
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
76
|
+
},
|
|
70
77
|
};
|