uniport-sdk 0.0.4 → 0.0.6
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/README.md +39 -0
- package/dist/components/index.cjs +447 -248
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +447 -248
- package/dist/components/index.js.map +1 -1
- package/dist/core/index.cjs +133 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +67 -1
- package/dist/core/index.d.ts +67 -1
- package/dist/core/index.js +120 -3
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +273 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +261 -59
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -75,8 +75,28 @@ declare const CHAIN_ICONS: {
|
|
|
75
75
|
readonly bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png";
|
|
76
76
|
readonly xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png";
|
|
77
77
|
readonly zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png";
|
|
78
|
+
readonly scroll: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/scroll/info/logo.png";
|
|
78
79
|
};
|
|
79
80
|
type ChainId = keyof typeof CHAIN_ICONS;
|
|
81
|
+
/** Chains that use EVM-style addresses (0x...), as opposed to chain-specific formats. */
|
|
82
|
+
declare const EVM_CHAINS: ChainId[];
|
|
83
|
+
declare function isEvmChain(chain: ChainId): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Chains whose deposit transactions require a memo/tag alongside the deposit
|
|
86
|
+
* address (1Click's `depositMode: MEMO`), without which funds can be lost.
|
|
87
|
+
*
|
|
88
|
+
* This list is verified empirically against the live 1Click API, not derived
|
|
89
|
+
* from documentation — deposit-mode requirements vary per chain and per
|
|
90
|
+
* asset in ways the API's own docs don't fully specify. Confirmed via direct
|
|
91
|
+
* quote requests: Stellar requires MEMO (rejects quotes without it); TON and
|
|
92
|
+
* XRP do not use MEMO mode at all (their assets settle with SIMPLE deposits
|
|
93
|
+
* and never populate a memo). If a new memo-requiring chain is added, verify
|
|
94
|
+
* it live the same way before adding it here.
|
|
95
|
+
*/
|
|
96
|
+
declare const CHAINS_REQUIRING_MEMO: ChainId[];
|
|
97
|
+
declare function needsMemoDeposit(chain: ChainId): boolean;
|
|
98
|
+
/** Build a block-explorer URL for a transaction hash on a given chain. */
|
|
99
|
+
declare function getExplorerTxUrl(chain: ChainId, hash: string): string | undefined;
|
|
80
100
|
interface Token {
|
|
81
101
|
/** Readable name: arbitrumUSDC, suiSUI */
|
|
82
102
|
name: string;
|
|
@@ -126,6 +146,8 @@ declare const baseETH: Token;
|
|
|
126
146
|
declare const baseUSDC: Token;
|
|
127
147
|
declare const baseCbBTC: Token;
|
|
128
148
|
declare const baseBRETT: Token;
|
|
149
|
+
declare const scrollETH: Token;
|
|
150
|
+
declare const scrollUSDT: Token;
|
|
129
151
|
declare const optimismETH: Token;
|
|
130
152
|
declare const optimismUSDC: Token;
|
|
131
153
|
declare const optimismUSDT: Token;
|
|
@@ -159,6 +181,8 @@ declare const aptosAPT: Token;
|
|
|
159
181
|
declare const starknetSTRK: Token;
|
|
160
182
|
declare const berachainBERA: Token;
|
|
161
183
|
declare const zcashZEC: Token;
|
|
184
|
+
declare const stellarXLM: Token;
|
|
185
|
+
declare const stellarUSDC: Token;
|
|
162
186
|
declare const nearNEAR: Token;
|
|
163
187
|
declare const nearUSDC: Token;
|
|
164
188
|
declare const nearUSDT: Token;
|
|
@@ -275,6 +299,16 @@ declare function fromSmallestUnits(amount: string, decimals: number): string;
|
|
|
275
299
|
* Generate a deadline timestamp
|
|
276
300
|
*/
|
|
277
301
|
declare function generateDeadline(hoursFromNow?: number): string;
|
|
302
|
+
/**
|
|
303
|
+
* Round a human-readable amount string to a fixed number of significant
|
|
304
|
+
* digits, for display only — never use this for values sent on-chain.
|
|
305
|
+
*
|
|
306
|
+
* Intents routing (e.g. an EXACT_INPUT quote into an 18-decimal token) can
|
|
307
|
+
* produce amounts like "0.002703957684923543", which are exact but not
|
|
308
|
+
* readable. This trims them to something a payer can actually glance at
|
|
309
|
+
* (e.g. "0.0027040") while leaving the underlying quote data untouched.
|
|
310
|
+
*/
|
|
311
|
+
declare function formatDisplayAmount(amount: string | undefined, significantDigits?: number): string;
|
|
278
312
|
/**
|
|
279
313
|
* Get a quote for a cross-chain swap
|
|
280
314
|
*/
|
|
@@ -325,4 +359,36 @@ declare const DEFAULT_REQUEST_TIMEOUT_MS = 20000;
|
|
|
325
359
|
declare function configureUniport(config: UniportConfig): void;
|
|
326
360
|
declare function getUniportConfig(): ResolvedUniportConfig;
|
|
327
361
|
|
|
328
|
-
|
|
362
|
+
/**
|
|
363
|
+
* ENS Resolution
|
|
364
|
+
*
|
|
365
|
+
* Resolves .eth names to addresses via the ENSIdeas public API.
|
|
366
|
+
* Composable — usable standalone, and used internally to resolve the
|
|
367
|
+
* Uniport default refund address for EVM chains.
|
|
368
|
+
*/
|
|
369
|
+
/** Uniport's own ENS name, used as the default EVM refund address. */
|
|
370
|
+
declare const UNIPORT_ENS_NAME = "uniport.eth";
|
|
371
|
+
/** Hardcoded fallback if ENS resolution fails (network error, API down, etc). */
|
|
372
|
+
declare const UNIPORT_FALLBACK_REFUND_ADDRESS = "0x2f43A54f931b95053c3DDa5f4637065AA0c3c494";
|
|
373
|
+
interface EnsResolution {
|
|
374
|
+
address: string;
|
|
375
|
+
name: string;
|
|
376
|
+
displayName: string;
|
|
377
|
+
avatar: string | null;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Resolve an ENS name (e.g. "frolic.eth") to its address via ENSIdeas.
|
|
381
|
+
* Returns null if the name has no resolved address or the request fails.
|
|
382
|
+
*/
|
|
383
|
+
declare function resolveEnsName(name: string, options?: {
|
|
384
|
+
signal?: AbortSignal;
|
|
385
|
+
timeoutMs?: number;
|
|
386
|
+
}): Promise<EnsResolution | null>;
|
|
387
|
+
/**
|
|
388
|
+
* Resolve the default Uniport refund address (uniport.eth), used for EVM
|
|
389
|
+
* source chains when the payer doesn't provide their own refund address.
|
|
390
|
+
* Falls back to a hardcoded address if resolution fails.
|
|
391
|
+
*/
|
|
392
|
+
declare function getUniportDefaultRefundAddress(): Promise<string>;
|
|
393
|
+
|
|
394
|
+
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, type Chain, type ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, type EnsResolution, type ExecutionStatus, type QuoteOptions, type QuoteResult, type ResolvedUniportConfig, type StatusResult, type SwapType, TOKEN_ICONS, type Token, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, type UniportApiErrorBody, type UniportConfig, UniportError, type UniportErrorCode, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -75,8 +75,28 @@ declare const CHAIN_ICONS: {
|
|
|
75
75
|
readonly bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png";
|
|
76
76
|
readonly xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png";
|
|
77
77
|
readonly zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png";
|
|
78
|
+
readonly scroll: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/scroll/info/logo.png";
|
|
78
79
|
};
|
|
79
80
|
type ChainId = keyof typeof CHAIN_ICONS;
|
|
81
|
+
/** Chains that use EVM-style addresses (0x...), as opposed to chain-specific formats. */
|
|
82
|
+
declare const EVM_CHAINS: ChainId[];
|
|
83
|
+
declare function isEvmChain(chain: ChainId): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Chains whose deposit transactions require a memo/tag alongside the deposit
|
|
86
|
+
* address (1Click's `depositMode: MEMO`), without which funds can be lost.
|
|
87
|
+
*
|
|
88
|
+
* This list is verified empirically against the live 1Click API, not derived
|
|
89
|
+
* from documentation — deposit-mode requirements vary per chain and per
|
|
90
|
+
* asset in ways the API's own docs don't fully specify. Confirmed via direct
|
|
91
|
+
* quote requests: Stellar requires MEMO (rejects quotes without it); TON and
|
|
92
|
+
* XRP do not use MEMO mode at all (their assets settle with SIMPLE deposits
|
|
93
|
+
* and never populate a memo). If a new memo-requiring chain is added, verify
|
|
94
|
+
* it live the same way before adding it here.
|
|
95
|
+
*/
|
|
96
|
+
declare const CHAINS_REQUIRING_MEMO: ChainId[];
|
|
97
|
+
declare function needsMemoDeposit(chain: ChainId): boolean;
|
|
98
|
+
/** Build a block-explorer URL for a transaction hash on a given chain. */
|
|
99
|
+
declare function getExplorerTxUrl(chain: ChainId, hash: string): string | undefined;
|
|
80
100
|
interface Token {
|
|
81
101
|
/** Readable name: arbitrumUSDC, suiSUI */
|
|
82
102
|
name: string;
|
|
@@ -126,6 +146,8 @@ declare const baseETH: Token;
|
|
|
126
146
|
declare const baseUSDC: Token;
|
|
127
147
|
declare const baseCbBTC: Token;
|
|
128
148
|
declare const baseBRETT: Token;
|
|
149
|
+
declare const scrollETH: Token;
|
|
150
|
+
declare const scrollUSDT: Token;
|
|
129
151
|
declare const optimismETH: Token;
|
|
130
152
|
declare const optimismUSDC: Token;
|
|
131
153
|
declare const optimismUSDT: Token;
|
|
@@ -159,6 +181,8 @@ declare const aptosAPT: Token;
|
|
|
159
181
|
declare const starknetSTRK: Token;
|
|
160
182
|
declare const berachainBERA: Token;
|
|
161
183
|
declare const zcashZEC: Token;
|
|
184
|
+
declare const stellarXLM: Token;
|
|
185
|
+
declare const stellarUSDC: Token;
|
|
162
186
|
declare const nearNEAR: Token;
|
|
163
187
|
declare const nearUSDC: Token;
|
|
164
188
|
declare const nearUSDT: Token;
|
|
@@ -275,6 +299,16 @@ declare function fromSmallestUnits(amount: string, decimals: number): string;
|
|
|
275
299
|
* Generate a deadline timestamp
|
|
276
300
|
*/
|
|
277
301
|
declare function generateDeadline(hoursFromNow?: number): string;
|
|
302
|
+
/**
|
|
303
|
+
* Round a human-readable amount string to a fixed number of significant
|
|
304
|
+
* digits, for display only — never use this for values sent on-chain.
|
|
305
|
+
*
|
|
306
|
+
* Intents routing (e.g. an EXACT_INPUT quote into an 18-decimal token) can
|
|
307
|
+
* produce amounts like "0.002703957684923543", which are exact but not
|
|
308
|
+
* readable. This trims them to something a payer can actually glance at
|
|
309
|
+
* (e.g. "0.0027040") while leaving the underlying quote data untouched.
|
|
310
|
+
*/
|
|
311
|
+
declare function formatDisplayAmount(amount: string | undefined, significantDigits?: number): string;
|
|
278
312
|
/**
|
|
279
313
|
* Get a quote for a cross-chain swap
|
|
280
314
|
*/
|
|
@@ -325,4 +359,36 @@ declare const DEFAULT_REQUEST_TIMEOUT_MS = 20000;
|
|
|
325
359
|
declare function configureUniport(config: UniportConfig): void;
|
|
326
360
|
declare function getUniportConfig(): ResolvedUniportConfig;
|
|
327
361
|
|
|
328
|
-
|
|
362
|
+
/**
|
|
363
|
+
* ENS Resolution
|
|
364
|
+
*
|
|
365
|
+
* Resolves .eth names to addresses via the ENSIdeas public API.
|
|
366
|
+
* Composable — usable standalone, and used internally to resolve the
|
|
367
|
+
* Uniport default refund address for EVM chains.
|
|
368
|
+
*/
|
|
369
|
+
/** Uniport's own ENS name, used as the default EVM refund address. */
|
|
370
|
+
declare const UNIPORT_ENS_NAME = "uniport.eth";
|
|
371
|
+
/** Hardcoded fallback if ENS resolution fails (network error, API down, etc). */
|
|
372
|
+
declare const UNIPORT_FALLBACK_REFUND_ADDRESS = "0x2f43A54f931b95053c3DDa5f4637065AA0c3c494";
|
|
373
|
+
interface EnsResolution {
|
|
374
|
+
address: string;
|
|
375
|
+
name: string;
|
|
376
|
+
displayName: string;
|
|
377
|
+
avatar: string | null;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Resolve an ENS name (e.g. "frolic.eth") to its address via ENSIdeas.
|
|
381
|
+
* Returns null if the name has no resolved address or the request fails.
|
|
382
|
+
*/
|
|
383
|
+
declare function resolveEnsName(name: string, options?: {
|
|
384
|
+
signal?: AbortSignal;
|
|
385
|
+
timeoutMs?: number;
|
|
386
|
+
}): Promise<EnsResolution | null>;
|
|
387
|
+
/**
|
|
388
|
+
* Resolve the default Uniport refund address (uniport.eth), used for EVM
|
|
389
|
+
* source chains when the payer doesn't provide their own refund address.
|
|
390
|
+
* Falls back to a hardcoded address if resolution fails.
|
|
391
|
+
*/
|
|
392
|
+
declare function getUniportDefaultRefundAddress(): Promise<string>;
|
|
393
|
+
|
|
394
|
+
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, type Chain, type ChainId, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, type EnsResolution, type ExecutionStatus, type QuoteOptions, type QuoteResult, type ResolvedUniportConfig, type StatusResult, type SwapType, TOKEN_ICONS, type Token, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, type UniportApiErrorBody, type UniportConfig, UniportError, type UniportErrorCode, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC };
|
package/dist/core/index.js
CHANGED
|
@@ -74,8 +74,60 @@ var CHAIN_ICONS = {
|
|
|
74
74
|
ltc: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/litecoin/info/logo.png",
|
|
75
75
|
bch: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/bitcoincash/info/logo.png",
|
|
76
76
|
xrp: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ripple/info/logo.png",
|
|
77
|
-
zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png"
|
|
77
|
+
zec: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/zcash/info/logo.png",
|
|
78
|
+
scroll: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/scroll/info/logo.png"
|
|
78
79
|
};
|
|
80
|
+
var EVM_CHAINS = [
|
|
81
|
+
"eth",
|
|
82
|
+
"arb",
|
|
83
|
+
"base",
|
|
84
|
+
"op",
|
|
85
|
+
"pol",
|
|
86
|
+
"avax",
|
|
87
|
+
"bsc",
|
|
88
|
+
"gnosis",
|
|
89
|
+
"bera",
|
|
90
|
+
"monad",
|
|
91
|
+
"scroll"
|
|
92
|
+
];
|
|
93
|
+
function isEvmChain(chain) {
|
|
94
|
+
return EVM_CHAINS.includes(chain);
|
|
95
|
+
}
|
|
96
|
+
var CHAINS_REQUIRING_MEMO = ["stellar"];
|
|
97
|
+
function needsMemoDeposit(chain) {
|
|
98
|
+
return CHAINS_REQUIRING_MEMO.includes(chain);
|
|
99
|
+
}
|
|
100
|
+
var EXPLORER_TX_URLS = {
|
|
101
|
+
eth: (h) => `https://etherscan.io/tx/${h}`,
|
|
102
|
+
arb: (h) => `https://arbiscan.io/tx/${h}`,
|
|
103
|
+
base: (h) => `https://basescan.org/tx/${h}`,
|
|
104
|
+
op: (h) => `https://optimistic.etherscan.io/tx/${h}`,
|
|
105
|
+
pol: (h) => `https://polygonscan.com/tx/${h}`,
|
|
106
|
+
avax: (h) => `https://snowtrace.io/tx/${h}`,
|
|
107
|
+
bsc: (h) => `https://bscscan.com/tx/${h}`,
|
|
108
|
+
gnosis: (h) => `https://gnosisscan.io/tx/${h}`,
|
|
109
|
+
bera: (h) => `https://berascan.com/tx/${h}`,
|
|
110
|
+
monad: (h) => `https://monadvision.com/tx/${h}`,
|
|
111
|
+
sui: (h) => `https://suivision.xyz/txblock/${h}`,
|
|
112
|
+
sol: (h) => `https://solscan.io/tx/${h}`,
|
|
113
|
+
btc: (h) => `https://mempool.space/tx/${h}`,
|
|
114
|
+
near: (h) => `https://nearblocks.io/txns/${h}`,
|
|
115
|
+
ton: (h) => `https://tonviewer.com/transaction/${h}`,
|
|
116
|
+
tron: (h) => `https://tronscan.org/#/transaction/${h}`,
|
|
117
|
+
stellar: (h) => `https://stellar.expert/explorer/public/tx/${h}`,
|
|
118
|
+
cardano: (h) => `https://cardanoscan.io/transaction/${h}`,
|
|
119
|
+
aptos: (h) => `https://explorer.aptoslabs.com/txn/${h}?network=mainnet`,
|
|
120
|
+
starknet: (h) => `https://voyager.online/tx/${h}`,
|
|
121
|
+
doge: (h) => `https://dogechain.info/tx/${h}`,
|
|
122
|
+
ltc: (h) => `https://litecoinspace.org/tx/${h}`,
|
|
123
|
+
bch: (h) => `https://blockchair.com/bitcoin-cash/transaction/${h}`,
|
|
124
|
+
xrp: (h) => `https://xrpscan.com/tx/${h}`,
|
|
125
|
+
zec: (h) => `https://blockchair.com/zcash/transaction/${h}`,
|
|
126
|
+
scroll: (h) => `https://scrollscan.com/tx/${h}`
|
|
127
|
+
};
|
|
128
|
+
function getExplorerTxUrl(chain, hash) {
|
|
129
|
+
return EXPLORER_TX_URLS[chain]?.(hash);
|
|
130
|
+
}
|
|
79
131
|
function createToken(chain, symbol, assetId, decimals, contractAddress, options) {
|
|
80
132
|
const normalizedSymbol = symbol.replace("$", "").replace(" ", "");
|
|
81
133
|
const canonicalPrefix = TOKEN_NAME_PREFIXES[chain] || chain;
|
|
@@ -136,6 +188,8 @@ var baseETH = createToken("base", "ETH", "nep141:base.omft.near", 18);
|
|
|
136
188
|
var baseUSDC = createToken("base", "USDC", "nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near", 6, "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913");
|
|
137
189
|
var baseCbBTC = createToken("base", "cbBTC", "nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near", 8, "0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf", { name: "baseCbBTC" });
|
|
138
190
|
var baseBRETT = createToken("base", "BRETT", "nep141:base-0x532f27101965dd16442e59d40670faf5ebb142e4.omft.near", 18, "0x532f27101965dd16442e59d40670faf5ebb142e4");
|
|
191
|
+
var scrollETH = createToken("scroll", "ETH", "nep245:v2_1.omni.hot.tg:534352_11111111111111111111", 18);
|
|
192
|
+
var scrollUSDT = createToken("scroll", "USDT", "nep245:v2_1.omni.hot.tg:534352_4RG3Q2wFsMQmd45m5m89RjsLfupA", 6, "0xf55bec9cafdbe8730f096aa55dad6d22d44099df");
|
|
139
193
|
var optimismETH = createToken("op", "ETH", "nep245:v2_1.omni.hot.tg:10_11111111111111111111", 18);
|
|
140
194
|
var optimismUSDC = createToken("op", "USDC", "nep245:v2_1.omni.hot.tg:10_A2ewyUyDp6qsue1jqZsGypkCxRJ", 6, "0x0b2c639c533813f4aa9d7837caf62653d097ff85");
|
|
141
195
|
var optimismUSDT = createToken("op", "USDT", "nep245:v2_1.omni.hot.tg:10_359RPSJVdTxwTJT9TyGssr2rFoWo", 6, "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58");
|
|
@@ -169,6 +223,8 @@ var aptosAPT = createToken("aptos", "APT", "nep141:aptos.omft.near", 8);
|
|
|
169
223
|
var starknetSTRK = createToken("starknet", "STRK", "nep141:starknet.omft.near", 18);
|
|
170
224
|
var berachainBERA = createToken("bera", "BERA", "nep141:bera.omft.near", 18);
|
|
171
225
|
var zcashZEC = createToken("zec", "ZEC", "nep141:zec.omft.near", 8);
|
|
226
|
+
var stellarXLM = createToken("stellar", "XLM", "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz", 7);
|
|
227
|
+
var stellarUSDC = createToken("stellar", "USDC", "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu", 7, "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN");
|
|
172
228
|
var nearNEAR = createToken("near", "wNEAR", "nep141:wrap.near", 24, "wrap.near", {
|
|
173
229
|
name: "nearNEAR",
|
|
174
230
|
aliases: ["nearwNEAR"]
|
|
@@ -200,6 +256,12 @@ var CHAINS = {
|
|
|
200
256
|
icon: CHAIN_ICONS.base,
|
|
201
257
|
tokens: [baseETH, baseUSDC, baseCbBTC, baseBRETT]
|
|
202
258
|
},
|
|
259
|
+
scroll: {
|
|
260
|
+
id: "scroll",
|
|
261
|
+
name: "Scroll",
|
|
262
|
+
icon: CHAIN_ICONS.scroll,
|
|
263
|
+
tokens: [scrollETH, scrollUSDT]
|
|
264
|
+
},
|
|
203
265
|
op: {
|
|
204
266
|
id: "op",
|
|
205
267
|
name: "Optimism",
|
|
@@ -324,7 +386,7 @@ var CHAINS = {
|
|
|
324
386
|
id: "stellar",
|
|
325
387
|
name: "Stellar",
|
|
326
388
|
icon: CHAIN_ICONS.stellar,
|
|
327
|
-
tokens: []
|
|
389
|
+
tokens: [stellarXLM, stellarUSDC]
|
|
328
390
|
}
|
|
329
391
|
};
|
|
330
392
|
var ALL_TOKENS = Object.values(CHAINS).flatMap((chain) => chain.tokens);
|
|
@@ -440,6 +502,17 @@ function generateDeadline(hoursFromNow = 1) {
|
|
|
440
502
|
const deadline = new Date(Date.now() + hoursFromNow * 60 * 60 * 1e3);
|
|
441
503
|
return deadline.toISOString();
|
|
442
504
|
}
|
|
505
|
+
function formatDisplayAmount(amount, significantDigits = 6) {
|
|
506
|
+
if (!amount) return amount ?? "";
|
|
507
|
+
const num = Number(amount);
|
|
508
|
+
if (!Number.isFinite(num) || num === 0) return amount;
|
|
509
|
+
const abs = Math.abs(num);
|
|
510
|
+
if (abs < 1e-6 || abs >= 1e21) return amount;
|
|
511
|
+
return new Intl.NumberFormat("en-US", {
|
|
512
|
+
maximumSignificantDigits: significantDigits,
|
|
513
|
+
useGrouping: false
|
|
514
|
+
}).format(num);
|
|
515
|
+
}
|
|
443
516
|
async function getQuote(options) {
|
|
444
517
|
const {
|
|
445
518
|
originToken,
|
|
@@ -471,6 +544,7 @@ async function getQuote(options) {
|
|
|
471
544
|
dry,
|
|
472
545
|
swapType,
|
|
473
546
|
slippageTolerance,
|
|
547
|
+
depositMode: needsMemoDeposit(originToken.chain) ? "MEMO" : void 0,
|
|
474
548
|
originAsset: originToken.assetId,
|
|
475
549
|
destinationAsset: destinationToken.assetId,
|
|
476
550
|
amount: amountInSmallestUnits,
|
|
@@ -603,6 +677,49 @@ async function pollExecutionStatus(depositAddress, options) {
|
|
|
603
677
|
throw new Error(`Timeout waiting for swap completion after ${timeout}ms`);
|
|
604
678
|
}
|
|
605
679
|
|
|
606
|
-
|
|
680
|
+
// src/core/ens.ts
|
|
681
|
+
var ENSIDEAS_BASE_URL = "https://api.ensideas.com/ens/resolve";
|
|
682
|
+
var UNIPORT_ENS_NAME = "uniport.eth";
|
|
683
|
+
var UNIPORT_FALLBACK_REFUND_ADDRESS = "0x2f43A54f931b95053c3DDa5f4637065AA0c3c494";
|
|
684
|
+
async function resolveEnsName(name, options) {
|
|
685
|
+
const controller = new AbortController();
|
|
686
|
+
const timeoutId = setTimeout(
|
|
687
|
+
() => controller.abort(),
|
|
688
|
+
options?.timeoutMs ?? 1e4
|
|
689
|
+
);
|
|
690
|
+
options?.signal?.addEventListener("abort", () => controller.abort(), {
|
|
691
|
+
once: true
|
|
692
|
+
});
|
|
693
|
+
try {
|
|
694
|
+
const response = await fetch(
|
|
695
|
+
`${ENSIDEAS_BASE_URL}/${encodeURIComponent(name)}`,
|
|
696
|
+
{ signal: controller.signal }
|
|
697
|
+
);
|
|
698
|
+
if (!response.ok) return null;
|
|
699
|
+
const data = await response.json();
|
|
700
|
+
if (!data.address) return null;
|
|
701
|
+
return {
|
|
702
|
+
address: data.address,
|
|
703
|
+
name: data.name ?? name,
|
|
704
|
+
displayName: data.displayName ?? name,
|
|
705
|
+
avatar: data.avatar ?? null
|
|
706
|
+
};
|
|
707
|
+
} catch {
|
|
708
|
+
return null;
|
|
709
|
+
} finally {
|
|
710
|
+
clearTimeout(timeoutId);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
var uniportRefundAddressPromise = null;
|
|
714
|
+
function getUniportDefaultRefundAddress() {
|
|
715
|
+
if (!uniportRefundAddressPromise) {
|
|
716
|
+
uniportRefundAddressPromise = resolveEnsName(UNIPORT_ENS_NAME).then(
|
|
717
|
+
(result) => result?.address ?? UNIPORT_FALLBACK_REFUND_ADDRESS
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
return uniportRefundAddressPromise;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
export { ALL_TOKENS, CHAINS, CHAINS_REQUIRING_MEMO, CHAIN_ICONS, DEFAULT_HOSTED_BACKEND_URL, DEFAULT_REQUEST_TIMEOUT_MS, EVM_CHAINS, TOKEN_ICONS, UNIPORT_ENS_NAME, UNIPORT_FALLBACK_REFUND_ADDRESS, UniportError, aptosAPT, arbitrumARB, arbitrumETH, arbitrumGMX, arbitrumUSDC, arbitrumUSDT, avalancheAVAX, avalancheUSDC, avalancheUSDT, baseBRETT, baseCbBTC, baseETH, baseUSDC, berachainBERA, bitcoinBTC, bitcoinCashBCH, bscBNB, bscUSDC, bscUSDT, cardanoADA, configureUniport, dogecoinDOGE, ethereumAAVE, ethereumDAI, ethereumETH, ethereumLINK, ethereumPEPE, ethereumSAFE, ethereumSHIB, ethereumTURBO, ethereumUNI, ethereumUSDC, ethereumUSDT, ethereumWBTC, formatDisplayAmount, fromSmallestUnits, generateDeadline, getExecutionStatus, getExplorerTxUrl, getQuote, getSupportedChains, getToken, getTokenByAssetId, getTokensByChain, getUniportConfig, getUniportDefaultRefundAddress, isEvmChain, litecoinLTC, nearNEAR, nearUSDC, nearUSDT, needsMemoDeposit, optimismETH, optimismOP, optimismUSDC, optimismUSDT, pollExecutionStatus, polygonPOL, polygonUSDC, polygonUSDT, resolveEnsName, rippleXRP, scrollETH, scrollUSDT, solanaMELANIA, solanaSOL, solanaTRUMP, solanaUSDC, solanaUSDT, solanaWIF, starknetSTRK, stellarUSDC, stellarXLM, submitDepositTx, suiSUI, suiUSDC, toSmallestUnits, tonTON, tonUSDT, tronTRX, tronUSDT, zcashZEC };
|
|
607
724
|
//# sourceMappingURL=index.js.map
|
|
608
725
|
//# sourceMappingURL=index.js.map
|