@ensofinance/checkout-widget 0.0.1
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/dist/checkout-widget.es.js +52889 -0
- package/dist/checkout-widget.es.js.map +1 -0
- package/dist/checkout-widget.umd.js +203 -0
- package/dist/checkout-widget.umd.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/enso-api.yaml +1982 -0
- package/orval.config.ts +25 -0
- package/package.json +79 -0
- package/src/assets/BinanceBadge.svg +4 -0
- package/src/assets/CoinbaseIcon.svg +4 -0
- package/src/assets/USD Coin (USDC).svg +5 -0
- package/src/assets/avecIcon.svg +5 -0
- package/src/assets/base.webp +0 -0
- package/src/assets/depositIcon.svg +6 -0
- package/src/assets/eth.webp +0 -0
- package/src/assets/ethMainnetIcon.svg +10 -0
- package/src/assets/fail.svg +5 -0
- package/src/assets/kraken.png +0 -0
- package/src/assets/logo.svg +10 -0
- package/src/assets/mastercard.png +0 -0
- package/src/assets/metamask.png +0 -0
- package/src/assets/rabby.png +0 -0
- package/src/assets/success.svg +4 -0
- package/src/assets/usdc.webp +0 -0
- package/src/assets/usdt.webp +0 -0
- package/src/assets/visa.png +0 -0
- package/src/assets/visa.webp +0 -0
- package/src/components/BridgeFee.tsx +58 -0
- package/src/components/ChakraProvider.tsx +372 -0
- package/src/components/Checkout.tsx +127 -0
- package/src/components/CheckoutModal.tsx +22 -0
- package/src/components/CircleTimer.tsx +66 -0
- package/src/components/CurrencySwapDisplay.tsx +153 -0
- package/src/components/DepositProcessing.tsx +116 -0
- package/src/components/ExchangeConfirmSecurity.tsx +110 -0
- package/src/components/QuoteParameters.tsx +341 -0
- package/src/components/TransactionDetailRow.tsx +124 -0
- package/src/components/cards/AssetCard.tsx +167 -0
- package/src/components/cards/ExchangeCard.tsx +53 -0
- package/src/components/cards/OptionCard.tsx +59 -0
- package/src/components/cards/WalletCard.tsx +99 -0
- package/src/components/cards/index.ts +6 -0
- package/src/components/modal.tsx +83 -0
- package/src/components/steps/ExchangeFlow.tsx +1402 -0
- package/src/components/steps/InitialStep.tsx +169 -0
- package/src/components/steps/QuoteStep.tsx +121 -0
- package/src/components/steps/WalletAmountStep.tsx +258 -0
- package/src/components/steps/WalletConfirmStep.tsx +404 -0
- package/src/components/steps/WalletTokenStep.tsx +128 -0
- package/src/components/ui/index.tsx +394 -0
- package/src/components/ui/styled.tsx +85 -0
- package/src/components/ui/toaster.tsx +43 -0
- package/src/components/ui/tooltip.tsx +46 -0
- package/src/enso-api/api.ts +173 -0
- package/src/enso-api/custom-instance.ts +35 -0
- package/src/enso-api/index.ts +5119 -0
- package/src/enso-api/model/action.ts +17 -0
- package/src/enso-api/model/actionAction.ts +52 -0
- package/src/enso-api/model/actionInputs.ts +12 -0
- package/src/enso-api/model/actionToBundle.ts +19 -0
- package/src/enso-api/model/actionToBundleAction.ts +53 -0
- package/src/enso-api/model/actionToBundleArgs.ts +12 -0
- package/src/enso-api/model/bundleControllerBundleShortcutTransactionParams.ts +53 -0
- package/src/enso-api/model/bundleControllerBundleShortcutTransactionRoutingStrategy.ts +23 -0
- package/src/enso-api/model/bundleShortcutTransaction.ts +35 -0
- package/src/enso-api/model/bundleShortcutTransactionAmountsOut.ts +15 -0
- package/src/enso-api/model/bundleShortcutTransactionFeeAmount.ts +12 -0
- package/src/enso-api/model/connectedNetwork.ts +16 -0
- package/src/enso-api/model/hop.ts +24 -0
- package/src/enso-api/model/hopArgs.ts +12 -0
- package/src/enso-api/model/index.ts +70 -0
- package/src/enso-api/model/iporControllerIporShortcutTransactionParams.ts +21 -0
- package/src/enso-api/model/iporShortcutInput.ts +33 -0
- package/src/enso-api/model/iporShortcutTransaction.ts +22 -0
- package/src/enso-api/model/lZDestinationTokenData.ts +19 -0
- package/src/enso-api/model/lZPoolLookupResponse.ts +26 -0
- package/src/enso-api/model/layerZeroControllerGetPoolAddressParams.ts +29 -0
- package/src/enso-api/model/network.ts +15 -0
- package/src/enso-api/model/networksControllerNetworksParams.ts +21 -0
- package/src/enso-api/model/nonTokenizedControllerTokens200.ts +15 -0
- package/src/enso-api/model/nonTokenizedControllerTokens200AllOf.ts +16 -0
- package/src/enso-api/model/nonTokenizedControllerTokensParams.ts +41 -0
- package/src/enso-api/model/nonTokenizedModel.ts +27 -0
- package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionParams.ts +64 -0
- package/src/enso-api/model/nontokenizedControllerRouteNontokenizedShorcutTransactionRoutingStrategy.ts +22 -0
- package/src/enso-api/model/paginatedResult.ts +16 -0
- package/src/enso-api/model/paginationMeta.ts +27 -0
- package/src/enso-api/model/positionModel.ts +77 -0
- package/src/enso-api/model/price.ts +20 -0
- package/src/enso-api/model/pricesControllerGetPricesParams.ts +17 -0
- package/src/enso-api/model/project.ts +15 -0
- package/src/enso-api/model/protocol.ts +15 -0
- package/src/enso-api/model/protocolModel.ts +26 -0
- package/src/enso-api/model/protocolsControllerFindAllParams.ts +21 -0
- package/src/enso-api/model/routeShortcutTransaction.ts +33 -0
- package/src/enso-api/model/routeShortcutVariableInputs.ts +68 -0
- package/src/enso-api/model/routeShortcutVariableInputsRoutingStrategy.ts +27 -0
- package/src/enso-api/model/routeShortcutVariableInputsVariableEstimates.ts +14 -0
- package/src/enso-api/model/routerControllerRouteShortcutTransactionParams.ts +91 -0
- package/src/enso-api/model/routerControllerRouteShortcutTransactionRoutingStrategy.ts +23 -0
- package/src/enso-api/model/standard.ts +18 -0
- package/src/enso-api/model/standardAction.ts +20 -0
- package/src/enso-api/model/standardActionAction.ts +53 -0
- package/src/enso-api/model/tokenModel.ts +36 -0
- package/src/enso-api/model/tokensControllerTokens200.ts +15 -0
- package/src/enso-api/model/tokensControllerTokens200AllOf.ts +16 -0
- package/src/enso-api/model/tokensControllerTokensParams.ts +91 -0
- package/src/enso-api/model/tokensControllerTokensType.ts +19 -0
- package/src/enso-api/model/transaction.ts +17 -0
- package/src/enso-api/model/userOperation.ts +28 -0
- package/src/enso-api/model/walletApproveTransaction.ts +24 -0
- package/src/enso-api/model/walletApproveTransactionTx.ts +15 -0
- package/src/enso-api/model/walletBalance.ts +29 -0
- package/src/enso-api/model/walletControllerCreateApproveTransactionParams.ts +35 -0
- package/src/enso-api/model/walletControllerCreateApproveTransactionRoutingStrategy.ts +23 -0
- package/src/enso-api/model/walletControllerWalletBalancesParams.ts +25 -0
- package/src/index.ts +17 -0
- package/src/store.ts +68 -0
- package/src/types/assets.d.ts +29 -0
- package/src/types/index.ts +21 -0
- package/src/util/common.tsx +324 -0
- package/src/util/constants.tsx +213 -0
- package/src/util/enso-hooks.tsx +203 -0
- package/src/util/index.tsx +68 -0
- package/src/util/tx-tracker.tsx +301 -0
- package/src/util/wallet.tsx +258 -0
- package/tsconfig.json +13 -0
- package/vite.config.ts +51 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useAccount } from "wagmi";
|
|
3
|
+
import { type Address, zeroAddress } from "viem";
|
|
4
|
+
import {
|
|
5
|
+
CHAINS_ETHERSCAN,
|
|
6
|
+
CHAINS_NATIVE_TOKENS,
|
|
7
|
+
ETH_ADDRESS,
|
|
8
|
+
GECKO_CHAIN_NAMES,
|
|
9
|
+
SupportedChainId,
|
|
10
|
+
} from "@/util/constants";
|
|
11
|
+
import { useAppStore } from "@/store";
|
|
12
|
+
|
|
13
|
+
export type Token = {
|
|
14
|
+
address: Address | string;
|
|
15
|
+
name: string;
|
|
16
|
+
symbol: string;
|
|
17
|
+
decimals: number;
|
|
18
|
+
logoURI: string;
|
|
19
|
+
underlyingTokens?: Token[];
|
|
20
|
+
type?: string;
|
|
21
|
+
apy?: number;
|
|
22
|
+
tvl?: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const compareCaseInsensitive = (a: string, b: string) => {
|
|
26
|
+
return !!(a && b && a?.toLowerCase() === b?.toLowerCase());
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const MOCK_ARRAY = [];
|
|
30
|
+
|
|
31
|
+
const getGeckoList = (chainId: SupportedChainId) =>
|
|
32
|
+
fetch(`https://tokens.coingecko.com/${GECKO_CHAIN_NAMES[chainId]}/all.json`)
|
|
33
|
+
.then((res) => res.json())
|
|
34
|
+
.then((data) => data?.tokens)
|
|
35
|
+
.then((tokens) => [CHAINS_NATIVE_TOKENS[chainId], ...tokens]);
|
|
36
|
+
|
|
37
|
+
const getOogaboogaList: () => Promise<Token[]> = () =>
|
|
38
|
+
fetch(
|
|
39
|
+
"https://mainnet.internal.oogabooga.io/token-list/tokens?chainId=80094&client=SWAP",
|
|
40
|
+
)
|
|
41
|
+
.then((res) => res.json())
|
|
42
|
+
.then((data) =>
|
|
43
|
+
data.map((token) => ({
|
|
44
|
+
...token,
|
|
45
|
+
logoURI: token.tokenURI,
|
|
46
|
+
address:
|
|
47
|
+
token.address === zeroAddress
|
|
48
|
+
? ETH_ADDRESS
|
|
49
|
+
: token.address.toLowerCase(),
|
|
50
|
+
})),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const getRoosterList: () => Promise<Token[]> = () =>
|
|
54
|
+
fetch("https://api.rooster-protocol.xyz/api/tokens")
|
|
55
|
+
.then((res) => res.json())
|
|
56
|
+
.then(({ tokens }) => tokens);
|
|
57
|
+
|
|
58
|
+
const getKatanaList: () => Promise<Token[]> = () =>
|
|
59
|
+
fetch(
|
|
60
|
+
"https://raw.githubusercontent.com/katana-network/tokenlist/refs/heads/main/tokenlist.json",
|
|
61
|
+
)
|
|
62
|
+
.then((res) => res.json())
|
|
63
|
+
.then(({ tokens }) => tokens);
|
|
64
|
+
|
|
65
|
+
//
|
|
66
|
+
// const getShadowList: (chainId: number) => Promise<Token[]> = () =>
|
|
67
|
+
// fetch(
|
|
68
|
+
// `https://raw.githubusercontent.com/Shadow-Exchange/shadow-assets/main/blockchains/sonic/tokenlist.json`,
|
|
69
|
+
// )
|
|
70
|
+
// .then((res) => res.json())
|
|
71
|
+
// .then((data) =>
|
|
72
|
+
// data.tokens[0]
|
|
73
|
+
// .map((token: any) => ({
|
|
74
|
+
// ...token,
|
|
75
|
+
// address: token.address?.toLowerCase(),
|
|
76
|
+
// logoURI: `https://raw.githubusercontent.com/Shadow-Exchange/shadow-assets/main/blockchains/sonic/assets/${token.address}/logo.png`,
|
|
77
|
+
// }))
|
|
78
|
+
// .filter(({ address }) => address),
|
|
79
|
+
// );
|
|
80
|
+
|
|
81
|
+
const getOneInchTokenList = (chainId: number) =>
|
|
82
|
+
fetch("https://tokens.1inch.io/v1.2/" + chainId)
|
|
83
|
+
.then((res) => res.json())
|
|
84
|
+
.then((data) => Object.values(data) as Token[]);
|
|
85
|
+
|
|
86
|
+
// .catch(() => tokenList[chainId]);
|
|
87
|
+
|
|
88
|
+
const getChainSymbolSortPriority = (chainId: SupportedChainId) => {
|
|
89
|
+
const defaultPriority = {
|
|
90
|
+
[CHAINS_NATIVE_TOKENS[chainId].symbol]: 5,
|
|
91
|
+
USDC: 4,
|
|
92
|
+
DAI: 4,
|
|
93
|
+
USDT: 4,
|
|
94
|
+
WBTC: 4,
|
|
95
|
+
WETH: 3,
|
|
96
|
+
LINK: 3,
|
|
97
|
+
UNI: 3,
|
|
98
|
+
SUSHI: 3,
|
|
99
|
+
AAVE: 3,
|
|
100
|
+
USDCE: 2,
|
|
101
|
+
};
|
|
102
|
+
switch (chainId) {
|
|
103
|
+
default:
|
|
104
|
+
return defaultPriority;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const sonicAdditionalTokens = // TODO: remove after it comes in list for sonic
|
|
109
|
+
new Promise<Token[]>((resolve) =>
|
|
110
|
+
resolve([
|
|
111
|
+
{
|
|
112
|
+
address: "0x6047828dc181963ba44974801ff68e538da5eaf9",
|
|
113
|
+
name: "Tether USD",
|
|
114
|
+
symbol: "USDT",
|
|
115
|
+
decimals: 6,
|
|
116
|
+
logoURI:
|
|
117
|
+
"https://assets.coingecko.com/coins/images/325/large/Tether.png",
|
|
118
|
+
},
|
|
119
|
+
]),
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const plumeAdditionalTokens = // Additional tokens for Plume network
|
|
123
|
+
new Promise<Token[]>((resolve) =>
|
|
124
|
+
resolve([
|
|
125
|
+
{
|
|
126
|
+
address: ETH_ADDRESS, // Native token address
|
|
127
|
+
name: "Plume",
|
|
128
|
+
symbol: "PLUME",
|
|
129
|
+
decimals: 18,
|
|
130
|
+
logoURI:
|
|
131
|
+
"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
address: "0x78adD880A697070c1e765Ac44D65323a0DcCE913",
|
|
135
|
+
name: "USD Coin.e",
|
|
136
|
+
symbol: "USDC.e",
|
|
137
|
+
decimals: 6,
|
|
138
|
+
logoURI:
|
|
139
|
+
"https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
address: "0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1",
|
|
143
|
+
name: "Wrapped Plume",
|
|
144
|
+
symbol: "wPlume",
|
|
145
|
+
decimals: 18,
|
|
146
|
+
logoURI:
|
|
147
|
+
"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
address: "0xca59cA09E5602fAe8B629DeE83FfA819741f14be",
|
|
151
|
+
name: "Wrapped Ether",
|
|
152
|
+
symbol: "WETH",
|
|
153
|
+
decimals: 18,
|
|
154
|
+
logoURI:
|
|
155
|
+
"https://assets.coingecko.com/coins/images/2518/large/weth.png",
|
|
156
|
+
},
|
|
157
|
+
]),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const getCurrentChainTokens = (chainId: SupportedChainId) => {
|
|
161
|
+
let getters: Promise<Token[] | undefined>[] = [];
|
|
162
|
+
|
|
163
|
+
switch (chainId) {
|
|
164
|
+
case SupportedChainId.BERACHAIN:
|
|
165
|
+
getters = [getOogaboogaList()];
|
|
166
|
+
break;
|
|
167
|
+
case SupportedChainId.SONIC:
|
|
168
|
+
getters = [getGeckoList(chainId), sonicAdditionalTokens];
|
|
169
|
+
break;
|
|
170
|
+
case SupportedChainId.PLUME:
|
|
171
|
+
getters = [plumeAdditionalTokens, getRoosterList()];
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
// priority for oneInch tokens
|
|
175
|
+
getters = [getGeckoList(chainId)];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return Promise.allSettled(getters).then((results) => {
|
|
179
|
+
const tokens = results
|
|
180
|
+
.filter(
|
|
181
|
+
(result): result is PromiseFulfilledResult<Token[]> =>
|
|
182
|
+
result.status === "fulfilled",
|
|
183
|
+
)
|
|
184
|
+
.map((result) => result.value);
|
|
185
|
+
|
|
186
|
+
const tokenList = tokens[0];
|
|
187
|
+
|
|
188
|
+
if (tokens.length > 1) {
|
|
189
|
+
const addedToken = new Set<string>(
|
|
190
|
+
tokens[0]?.map((t) => t.address) ?? [],
|
|
191
|
+
);
|
|
192
|
+
const tokenList = tokens[0];
|
|
193
|
+
|
|
194
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
195
|
+
const newTokens = tokens[i]?.filter(
|
|
196
|
+
(token) => !addedToken.has(token.address),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
if (newTokens) {
|
|
200
|
+
tokenList.push(...newTokens);
|
|
201
|
+
newTokens.forEach((t) => addedToken.add(t.address));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const priority = getChainSymbolSortPriority(chainId);
|
|
207
|
+
|
|
208
|
+
// sort by token symbol priority
|
|
209
|
+
const sortedTokenList = [...tokenList]
|
|
210
|
+
.sort((a, b) => {
|
|
211
|
+
return priority[b.symbol] ?? 0 - priority[a.symbol] ?? 0;
|
|
212
|
+
})
|
|
213
|
+
.map((token) => ({
|
|
214
|
+
...token,
|
|
215
|
+
address: token.address.toLowerCase() as Address,
|
|
216
|
+
}));
|
|
217
|
+
|
|
218
|
+
return sortedTokenList;
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const useCurrentChainList = (priorityChainId?: SupportedChainId) => {
|
|
223
|
+
const chainId = usePriorityChainId(priorityChainId);
|
|
224
|
+
|
|
225
|
+
return useQuery<Token[] | undefined>({
|
|
226
|
+
queryKey: ["tokenList", chainId],
|
|
227
|
+
queryFn: () => getCurrentChainTokens(chainId),
|
|
228
|
+
enabled: !!chainId,
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const useOneInchTokenList = () => {
|
|
233
|
+
const chainId = usePriorityChainId();
|
|
234
|
+
|
|
235
|
+
return useQuery({
|
|
236
|
+
queryKey: ["oneInchTokenList", chainId],
|
|
237
|
+
queryFn: () => getOneInchTokenList(chainId),
|
|
238
|
+
enabled: !!chainId,
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const useTokenFromList = (
|
|
243
|
+
tokenAddress: Address | Address[],
|
|
244
|
+
priorityChainId?: SupportedChainId,
|
|
245
|
+
) => {
|
|
246
|
+
const { data } = useCurrentChainList(priorityChainId);
|
|
247
|
+
const arrayData = Array.isArray(tokenAddress)
|
|
248
|
+
? tokenAddress
|
|
249
|
+
: [tokenAddress];
|
|
250
|
+
|
|
251
|
+
return arrayData.map((address) =>
|
|
252
|
+
data?.find((token) => token.address == address),
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const ALTERNATIVE_SYMBOLS = {
|
|
257
|
+
USDT: "USDT0",
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export const useTokenFromListBySymbols = (
|
|
261
|
+
tokenSymbols: string[],
|
|
262
|
+
priorityChainId?: SupportedChainId,
|
|
263
|
+
) => {
|
|
264
|
+
const { data } = useCurrentChainList(priorityChainId);
|
|
265
|
+
const arrayData = Array.isArray(tokenSymbols)
|
|
266
|
+
? tokenSymbols
|
|
267
|
+
: [tokenSymbols];
|
|
268
|
+
|
|
269
|
+
return arrayData.map((symbol) =>
|
|
270
|
+
data?.find(
|
|
271
|
+
(token) => token.symbol == (ALTERNATIVE_SYMBOLS[symbol] ?? symbol),
|
|
272
|
+
),
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const useOutChainId = () => {
|
|
277
|
+
const tokenOutChainId = useAppStore((state) => state.chainIdOut);
|
|
278
|
+
const chainId = usePriorityChainId();
|
|
279
|
+
|
|
280
|
+
return tokenOutChainId ?? chainId;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export const usePriorityChainId = (priorityChainId?: SupportedChainId) => {
|
|
284
|
+
const obligatedChainId = useAppStore((state) => state.chainIdIn);
|
|
285
|
+
const { chainId = 1 } = useAccount();
|
|
286
|
+
|
|
287
|
+
return priorityChainId ?? obligatedChainId ?? chainId;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
export const useEtherscanUrl = (
|
|
291
|
+
address: string,
|
|
292
|
+
type: "/address" | "/tx" = "/tx",
|
|
293
|
+
) => {
|
|
294
|
+
const chainId = usePriorityChainId();
|
|
295
|
+
const chainPrefix = CHAINS_ETHERSCAN[chainId];
|
|
296
|
+
|
|
297
|
+
if (address) return `${chainPrefix}${type}/${address}`;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
301
|
+
|
|
302
|
+
export const getChainName = (chainId: SupportedChainId) => {
|
|
303
|
+
const geckoName = GECKO_CHAIN_NAMES[chainId];
|
|
304
|
+
|
|
305
|
+
return capitalize(geckoName).split("-")[0];
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export const shortenAddress = (address: string) => {
|
|
309
|
+
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export const getChainEtherscanUrl = ({
|
|
313
|
+
hash,
|
|
314
|
+
chainId,
|
|
315
|
+
type = "/tx",
|
|
316
|
+
}: {
|
|
317
|
+
hash: string;
|
|
318
|
+
chainId: SupportedChainId;
|
|
319
|
+
type?: "/address" | "/tx";
|
|
320
|
+
}) => {
|
|
321
|
+
const chainPrefix = CHAINS_ETHERSCAN[chainId];
|
|
322
|
+
|
|
323
|
+
if (hash) return `${chainPrefix}${type}/${hash}`;
|
|
324
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { Token } from "@/util/common";
|
|
2
|
+
|
|
3
|
+
export const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
4
|
+
export const VITALIK_ADDRESS = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";
|
|
5
|
+
export const DEFAULT_SLIPPAGE = 200;
|
|
6
|
+
|
|
7
|
+
enum MESH_SYMBOLS {
|
|
8
|
+
ETH = "ETH",
|
|
9
|
+
USDC = "USDC",
|
|
10
|
+
USDT = "USDT",
|
|
11
|
+
WBTC = "WBTC",
|
|
12
|
+
}
|
|
13
|
+
export const MIN_AMOUNT = {
|
|
14
|
+
[MESH_SYMBOLS.ETH]: 0.02,
|
|
15
|
+
[MESH_SYMBOLS.USDC]: 20,
|
|
16
|
+
[MESH_SYMBOLS.USDT]: 20,
|
|
17
|
+
[MESH_SYMBOLS.WBTC]: 0.00000001,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const ETH_TOKEN: Token = {
|
|
21
|
+
address: ETH_ADDRESS,
|
|
22
|
+
name: "Ethereum",
|
|
23
|
+
symbol: "ETH",
|
|
24
|
+
decimals: 18,
|
|
25
|
+
logoURI: "https://assets.coingecko.com/coins/images/279/large/ethereum.png",
|
|
26
|
+
};
|
|
27
|
+
export const BNB_TOKEN: Token = {
|
|
28
|
+
address: ETH_ADDRESS,
|
|
29
|
+
name: "Binance Coin",
|
|
30
|
+
symbol: "BNB",
|
|
31
|
+
decimals: 18,
|
|
32
|
+
logoURI:
|
|
33
|
+
"https://assets.coingecko.com/coins/images/825/large/binance-coin-logo.png",
|
|
34
|
+
};
|
|
35
|
+
export const AVAX_TOKEN: Token = {
|
|
36
|
+
address: ETH_ADDRESS,
|
|
37
|
+
name: "Avalanche",
|
|
38
|
+
symbol: "AVAX",
|
|
39
|
+
decimals: 18,
|
|
40
|
+
logoURI:
|
|
41
|
+
"https://assets.coingecko.com/coins/images/12559/large/coin-round-red.png",
|
|
42
|
+
};
|
|
43
|
+
export const MATIC_TOKEN: Token = {
|
|
44
|
+
address: ETH_ADDRESS,
|
|
45
|
+
name: "Polygon",
|
|
46
|
+
symbol: "MATIC",
|
|
47
|
+
decimals: 18,
|
|
48
|
+
logoURI:
|
|
49
|
+
"https://assets.coingecko.com/coins/images/4713/large/matic___polygon.jpg",
|
|
50
|
+
};
|
|
51
|
+
const BERA_TOKEN: Token = {
|
|
52
|
+
address: ETH_ADDRESS,
|
|
53
|
+
name: "BeraChain",
|
|
54
|
+
symbol: "BERA",
|
|
55
|
+
decimals: 18,
|
|
56
|
+
logoURI:
|
|
57
|
+
"https://assets.coingecko.com/coins/images/25235/large/BERA.png?1738822008",
|
|
58
|
+
};
|
|
59
|
+
const DAI_TOKEN: Token = {
|
|
60
|
+
address: ETH_ADDRESS,
|
|
61
|
+
name: "Gnosis XDAI",
|
|
62
|
+
symbol: "XDAI",
|
|
63
|
+
decimals: 18,
|
|
64
|
+
logoURI:
|
|
65
|
+
"https://assets.coingecko.com/coins/images/11062/large/Identity-Primary-DarkBG.png",
|
|
66
|
+
};
|
|
67
|
+
const SONIC_TOKEN: Token = {
|
|
68
|
+
address: ETH_ADDRESS,
|
|
69
|
+
name: "Sonic",
|
|
70
|
+
symbol: "S",
|
|
71
|
+
decimals: 18,
|
|
72
|
+
logoURI:
|
|
73
|
+
"https://assets.coingecko.com/coins/images/38108/standard/200x200_Sonic_Logo.png",
|
|
74
|
+
};
|
|
75
|
+
const PLUME_TOKEN: Token = {
|
|
76
|
+
address: ETH_ADDRESS,
|
|
77
|
+
name: "Plume",
|
|
78
|
+
symbol: "PLUME",
|
|
79
|
+
decimals: 18,
|
|
80
|
+
logoURI:
|
|
81
|
+
"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935",
|
|
82
|
+
};
|
|
83
|
+
const HYPERLIQUID_TOKEN: Token = {
|
|
84
|
+
address: ETH_ADDRESS,
|
|
85
|
+
name: "Hyperliquid",
|
|
86
|
+
symbol: "HYPE",
|
|
87
|
+
decimals: 18,
|
|
88
|
+
logoURI:
|
|
89
|
+
"https://assets.coingecko.com/asset_platforms/images/243/large/hyperliquid.png",
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const MOCK_IMAGE_URL =
|
|
93
|
+
"https://assets.coingecko.com/coins/images/12504/small/uniswap-uni.png";
|
|
94
|
+
|
|
95
|
+
export enum SupportedChainId {
|
|
96
|
+
MAINNET = 1,
|
|
97
|
+
ARBITRUM_ONE = 42161,
|
|
98
|
+
OPTIMISM = 10,
|
|
99
|
+
POLYGON = 137,
|
|
100
|
+
BSC = 56,
|
|
101
|
+
// BOBA = 288,
|
|
102
|
+
BASE = 8453,
|
|
103
|
+
// BLAST = 81457,
|
|
104
|
+
// SCROLL = 534352,
|
|
105
|
+
LINEA = 59144,
|
|
106
|
+
ZKSYNC = 324,
|
|
107
|
+
GNOSIS = 100,
|
|
108
|
+
AVALANCHE = 43114,
|
|
109
|
+
BERACHAIN = 80094,
|
|
110
|
+
SONIC = 146,
|
|
111
|
+
UNICHAIN = 130,
|
|
112
|
+
INK = 57073,
|
|
113
|
+
SONEIUM = 1868,
|
|
114
|
+
PLUME = 98866,
|
|
115
|
+
HYPERLIQUID = 999,
|
|
116
|
+
KATANA = 747474,
|
|
117
|
+
// ARBITRUM_RINKEBY = 421611,
|
|
118
|
+
// OPTIMISM_GOERLI = 420,w
|
|
119
|
+
// GOERLI = 5,
|
|
120
|
+
// POLYGON_MUMBAI = 80001,
|
|
121
|
+
// CELO = 42220,
|
|
122
|
+
// CELO_ALFAJORES = 44787,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const STARGATE_CHAIN_NAMES: { [key in SupportedChainId]: string } = {
|
|
126
|
+
[SupportedChainId.MAINNET]: "ethereum",
|
|
127
|
+
[SupportedChainId.BASE]: "base",
|
|
128
|
+
[SupportedChainId.POLYGON]: "polygon",
|
|
129
|
+
[SupportedChainId.BSC]: "bsc",
|
|
130
|
+
[SupportedChainId.LINEA]: "linea",
|
|
131
|
+
[SupportedChainId.ZKSYNC]: "zksync",
|
|
132
|
+
[SupportedChainId.GNOSIS]: "gnosis",
|
|
133
|
+
[SupportedChainId.AVALANCHE]: "avalanche",
|
|
134
|
+
[SupportedChainId.BERACHAIN]: "bera",
|
|
135
|
+
[SupportedChainId.SONIC]: "sonic",
|
|
136
|
+
[SupportedChainId.ARBITRUM_ONE]: "arbitrum",
|
|
137
|
+
[SupportedChainId.OPTIMISM]: "optimism",
|
|
138
|
+
[SupportedChainId.UNICHAIN]: "unichain",
|
|
139
|
+
[SupportedChainId.INK]: "ink",
|
|
140
|
+
[SupportedChainId.SONEIUM]: "soneium",
|
|
141
|
+
[SupportedChainId.PLUME]: "plumephoenix",
|
|
142
|
+
[SupportedChainId.HYPERLIQUID]: "hyperliquid",
|
|
143
|
+
[SupportedChainId.KATANA]: "katana",
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const GECKO_CHAIN_NAMES: { [key in SupportedChainId]: string } = {
|
|
147
|
+
[SupportedChainId.MAINNET]: "ethereum",
|
|
148
|
+
[SupportedChainId.ARBITRUM_ONE]: "arbitrum-one",
|
|
149
|
+
[SupportedChainId.OPTIMISM]: "optimistic-ethereum",
|
|
150
|
+
[SupportedChainId.POLYGON]: "polygon-pos",
|
|
151
|
+
// [SupportedChainId.BOBA]: "boba",
|
|
152
|
+
[SupportedChainId.BASE]: "base",
|
|
153
|
+
[SupportedChainId.BSC]: "binance-smart-chain",
|
|
154
|
+
// [SupportedChainId.BLAST]: "blast",
|
|
155
|
+
// [SupportedChainId.SCROLL]: "scroll",
|
|
156
|
+
[SupportedChainId.LINEA]: "linea",
|
|
157
|
+
[SupportedChainId.ZKSYNC]: "zksync",
|
|
158
|
+
[SupportedChainId.GNOSIS]: "xdai",
|
|
159
|
+
[SupportedChainId.AVALANCHE]: "avalanche",
|
|
160
|
+
[SupportedChainId.BERACHAIN]: "berachain",
|
|
161
|
+
[SupportedChainId.SONIC]: "sonic",
|
|
162
|
+
[SupportedChainId.UNICHAIN]: "unichain",
|
|
163
|
+
[SupportedChainId.INK]: "ink",
|
|
164
|
+
[SupportedChainId.SONEIUM]: "soneium",
|
|
165
|
+
[SupportedChainId.PLUME]: "plume",
|
|
166
|
+
[SupportedChainId.HYPERLIQUID]: "hyperevm",
|
|
167
|
+
[SupportedChainId.KATANA]: "katana",
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const CHAINS_NATIVE_TOKENS: Record<SupportedChainId, Token> = {
|
|
171
|
+
[SupportedChainId.MAINNET]: ETH_TOKEN,
|
|
172
|
+
[SupportedChainId.ARBITRUM_ONE]: ETH_TOKEN,
|
|
173
|
+
[SupportedChainId.OPTIMISM]: ETH_TOKEN,
|
|
174
|
+
[SupportedChainId.BASE]: ETH_TOKEN,
|
|
175
|
+
[SupportedChainId.LINEA]: ETH_TOKEN,
|
|
176
|
+
[SupportedChainId.ZKSYNC]: ETH_TOKEN,
|
|
177
|
+
[SupportedChainId.SONEIUM]: ETH_TOKEN,
|
|
178
|
+
[SupportedChainId.UNICHAIN]: ETH_TOKEN,
|
|
179
|
+
[SupportedChainId.INK]: ETH_TOKEN,
|
|
180
|
+
[SupportedChainId.BSC]: BNB_TOKEN,
|
|
181
|
+
[SupportedChainId.AVALANCHE]: AVAX_TOKEN,
|
|
182
|
+
[SupportedChainId.POLYGON]: MATIC_TOKEN,
|
|
183
|
+
[SupportedChainId.BERACHAIN]: BERA_TOKEN,
|
|
184
|
+
[SupportedChainId.GNOSIS]: DAI_TOKEN,
|
|
185
|
+
[SupportedChainId.SONIC]: SONIC_TOKEN,
|
|
186
|
+
[SupportedChainId.PLUME]: PLUME_TOKEN,
|
|
187
|
+
[SupportedChainId.HYPERLIQUID]: HYPERLIQUID_TOKEN,
|
|
188
|
+
[SupportedChainId.KATANA]: ETH_TOKEN,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export const CHAINS_ETHERSCAN: Record<SupportedChainId, string> = {
|
|
192
|
+
[SupportedChainId.OPTIMISM]: "https://optimistic.etherscan.io",
|
|
193
|
+
[SupportedChainId.MAINNET]: "https://etherscan.io",
|
|
194
|
+
[SupportedChainId.ARBITRUM_ONE]: "https://arbiscan.io",
|
|
195
|
+
[SupportedChainId.POLYGON]: "https://polygonscan.com",
|
|
196
|
+
[SupportedChainId.BSC]: "https://bscscan.com",
|
|
197
|
+
// [SupportedChainId.BOBA]: "https://bobascan.com",
|
|
198
|
+
[SupportedChainId.BASE]: "https://basescan.org",
|
|
199
|
+
// [SupportedChainId.BLAST]: "https://blastscan.io",
|
|
200
|
+
// [SupportedChainId.SCROLL]: "https://scrollscan.com",
|
|
201
|
+
[SupportedChainId.LINEA]: "https://lineascan.build",
|
|
202
|
+
[SupportedChainId.ZKSYNC]: "https://explorer.zksync.io/",
|
|
203
|
+
[SupportedChainId.GNOSIS]: "https://gnosisscan.io/",
|
|
204
|
+
[SupportedChainId.AVALANCHE]: "https://cchain.explorer.avax.network",
|
|
205
|
+
[SupportedChainId.BERACHAIN]: "https://berascan.com",
|
|
206
|
+
[SupportedChainId.SONIC]: "https://sonicscan.io",
|
|
207
|
+
[SupportedChainId.UNICHAIN]: "https://uniscan.xyz",
|
|
208
|
+
[SupportedChainId.INK]: "https://explorer.inkonchain.com",
|
|
209
|
+
[SupportedChainId.SONEIUM]: "https://soneium.blockscout.com/",
|
|
210
|
+
[SupportedChainId.PLUME]: "https://explorer.plume.org/",
|
|
211
|
+
[SupportedChainId.HYPERLIQUID]: "https://www.hyperscan.com/",
|
|
212
|
+
[SupportedChainId.KATANA]: "https://explorer-katana.t.conduit.xyz/",
|
|
213
|
+
};
|