@xswap-link/sdk 0.8.2 → 0.8.4
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 +12 -0
- package/dist/index.global.js +122 -119
- package/dist/index.js +7 -7
- package/dist/index.mjs +9 -9
- 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 +112 -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,116 @@ export const ADDRESSES: Addresses = {
|
|
|
67
67
|
[ContractName.XSwapRouterSingleChain]:
|
|
68
68
|
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
69
69
|
},
|
|
70
|
+
// mode
|
|
71
|
+
"34443": {
|
|
72
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
73
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
74
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
75
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
76
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
77
|
+
},
|
|
78
|
+
// astar
|
|
79
|
+
"592": {
|
|
80
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
81
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
82
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
83
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
84
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
85
|
+
},
|
|
86
|
+
// blast
|
|
87
|
+
"81457": {
|
|
88
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
89
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
90
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
91
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
92
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
93
|
+
},
|
|
94
|
+
// celo
|
|
95
|
+
"42220": {
|
|
96
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
97
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
98
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
99
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
100
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
101
|
+
},
|
|
102
|
+
// gnosis
|
|
103
|
+
"100": {
|
|
104
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
105
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
106
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
107
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
108
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
109
|
+
},
|
|
110
|
+
// kroma
|
|
111
|
+
"255": {
|
|
112
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
113
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
114
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
115
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
116
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
117
|
+
},
|
|
118
|
+
// mantle
|
|
119
|
+
"5000": {
|
|
120
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
121
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
122
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
123
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
124
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
125
|
+
},
|
|
126
|
+
// shibarium
|
|
127
|
+
"109": {
|
|
128
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
129
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
130
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
131
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
132
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
133
|
+
},
|
|
134
|
+
// wemix
|
|
135
|
+
"1111": {
|
|
136
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
137
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
138
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
139
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
140
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
141
|
+
},
|
|
142
|
+
// zircuit
|
|
143
|
+
"48900": {
|
|
144
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
145
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
146
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
147
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
148
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
149
|
+
},
|
|
150
|
+
// bsc
|
|
151
|
+
"56": {
|
|
152
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
153
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
154
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
155
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
156
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
157
|
+
},
|
|
158
|
+
// metis
|
|
159
|
+
"1088": {
|
|
160
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
161
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
162
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
163
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
164
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
165
|
+
},
|
|
166
|
+
// linea
|
|
167
|
+
"59144": {
|
|
168
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
169
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
170
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
171
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
172
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
173
|
+
},
|
|
174
|
+
// scroll
|
|
175
|
+
"534352": {
|
|
176
|
+
[ContractName.BatchQuery]: "0xb5f9934ea0810ef5faa677e8c68c6983b88664b1",
|
|
177
|
+
[ContractName.FeeCollector]: "0xb37275558f02f05104c2ba35199d16adeb43432f",
|
|
178
|
+
[ContractName.XSwapRouter]: "0xe1c14b9f065dead2e89ee35382f8bd42bdb87a04",
|
|
179
|
+
[ContractName.XSwapRouterSingleChain]:
|
|
180
|
+
"0x0bb24c4302889ea0fb22dfacbb845e5602f35972",
|
|
181
|
+
},
|
|
70
182
|
};
|