@tcswap/helpers 4.5.16 → 4.5.18
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/api/index.cjs +2 -2
- package/dist/api/index.cjs.map +3 -3
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +6 -6
- package/dist/index.js +3 -3
- package/dist/index.js.map +6 -6
- package/dist/types/modules/assetValue.d.ts +1 -0
- package/dist/types/modules/assetValue.d.ts.map +1 -1
- package/dist/types/modules/uSwapConfig.d.ts +2 -0
- package/dist/types/modules/uSwapConfig.d.ts.map +1 -1
- package/dist/types/utils/asset.d.ts +2 -1
- package/dist/types/utils/asset.d.ts.map +1 -1
- package/dist/types/utils/validators.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/api/midgard/endpoints.ts +1 -1
- package/src/modules/assetValue.ts +86 -7
- package/src/modules/uSwapConfig.ts +1 -0
- package/src/utils/asset.ts +33 -1
- package/src/utils/validators.ts +3 -0
- package/dist/chunk-pfmeq01a.js +0 -5
- package/dist/chunk-pfmeq01a.js.map +0 -9
- package/dist/chunk-vb4wtm2w.js +0 -4
- package/dist/chunk-vb4wtm2w.js.map +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetValue.d.ts","sourceRoot":"","sources":["../../../src/modules/assetValue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAa,KAAK,EAAE,KAAK,OAAO,EAA4C,MAAM,eAAe,CAAC;AAGzG,OAAO,EAEL,KAAK,iBAAiB,EAEtB,YAAY,
|
|
1
|
+
{"version":3,"file":"assetValue.d.ts","sourceRoot":"","sources":["../../../src/modules/assetValue.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EA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CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,CACrE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GACnB;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CACvB,CACF;IAwBH,MAAM,KAAK,YAAY;cA5Rf,QAAQ;iBAAW,MAAM;oBAAc,MAAM;kBAAY,MAAM;OA8RtE;CACF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,cAU/C"}
|
|
@@ -69,6 +69,7 @@ declare const initialState: {
|
|
|
69
69
|
endpoints: CustomApiEndpoints;
|
|
70
70
|
envs: {
|
|
71
71
|
apiUrl: string;
|
|
72
|
+
blockchairApiUrl: string | null;
|
|
72
73
|
devApiUrl: string;
|
|
73
74
|
experimental_apiKey: string | null;
|
|
74
75
|
experimental_apiUrlQuote: string | null;
|
|
@@ -173,6 +174,7 @@ export declare const useUSwapConfig: () => {
|
|
|
173
174
|
endpoints: CustomApiEndpoints;
|
|
174
175
|
envs: {
|
|
175
176
|
apiUrl: string;
|
|
177
|
+
blockchairApiUrl: string | null;
|
|
176
178
|
devApiUrl: string;
|
|
177
179
|
experimental_apiKey: string | null;
|
|
178
180
|
experimental_apiUrlQuote: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uSwapConfig.d.ts","sourceRoot":"","sources":["../../../src/modules/uSwapConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,KAAK,KAAK,EAKX,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,S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oB,EAAE,CACpB,WAAW,EAAE,MAAM,UAAU,CAAC,cAAc,CAAC,EAC7C,MAAM,EAAE,uBAAuB,CAAC,MAAM,uBAAuB,CAAC,KAC3D,IAAI,CAAC;IACV,iBAAiB,EAAE,CAAC,WAAW,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,eAAO,MAAM,aAAa,+EA4BvB,CAAC;AAEJ,eAAO,MAAM,cAAc;;;;;;;;;;;;;;0BAhFG,MAAM,GAAG,IAAI;;6BAEV,MAAM,GAAG,IAAI;kCACR,MAAM,GAAG,IAAI;iCACd,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwF/C,CAAC;AAEJ,eAAO,MAAM,WAAW;UAChB,CAAC,SAAS,MAAM,UAAU,OAAO,CAAC;;;UAGlC,CAAC,SAAS,gBAAgB,UAAU,CAAC;gBAE/B,CAAC,SAAS,MAAM,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,MAAM;kBAE3D,CAAC,SAAS,MAAM,kBAAkB,OAAO,CAAC,YAAY,kBAAkB,CAAC,CAAC,CAAC;aAEhF,CAAC,SAAS,MAAM,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;qCAEhD,mBAAmB;2BAC7B,CAAC,SAAS,MAAM,UAAU,CAAC,cAAc,CAAC,eAClD,CAAC,UACN,uBAAuB,CAAC,CAAC,CAAC;iCAEP,UAAU,CAAC,gBAAgB,CAAC;gBAC7C,CAAC,SAAS,MAAM,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,MAAM,EAAE;CAE5E,CAAC"}
|
|
@@ -18,10 +18,11 @@ export declare const getCommonAssetInfo: (assetString: CommonAssetString) => {
|
|
|
18
18
|
decimal: number;
|
|
19
19
|
identifier: string;
|
|
20
20
|
};
|
|
21
|
+
export declare function isSecuredAssetIdentifier(identifier?: string): boolean;
|
|
21
22
|
export declare function getAssetType({ chain, symbol }: {
|
|
22
23
|
chain: Chain;
|
|
23
24
|
symbol: string;
|
|
24
|
-
}): Chain | "Synth" | "Trade" | "Native";
|
|
25
|
+
}): Chain | "Synth" | "Trade" | "Secured" | "Native";
|
|
25
26
|
export declare const assetFromString: (assetString: string) => {
|
|
26
27
|
chain: Chain;
|
|
27
28
|
symbol: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../../../src/utils/asset.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../../../src/utils/asset.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,EAAwD,MAAM,eAAe,CAAC;AAEvG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;AAE5E,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC;AAEnH,eAAO,MAAM,kBAAkB,kGAQrB,CAAC;AAyIX,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;;;GAwHnF;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,WAe7E;AAED,eAAO,MAAM,kBAAkB,GAAI,aAAa,iBAAiB;;;CA8ChE,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,UAAU,SAAK,WA6BvD;AAED,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,oDAkB/E;AAED,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM;;;;;CAYlD,CAAC;AAEF,wBAAsB,WAAW,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,GAAG,KAAK,IAAI,MAAM,EAAE,CAAA;CAAE,gv2QAsBlH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/utils/validators.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/utils/validators.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,wBAAgB,kBAAkB,CAAC,UAAU,SAAK,WAkBjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,WAMvC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"@near-js/providers": "~2.5.0",
|
|
5
5
|
"@tcswap/contracts": "4.0.5",
|
|
6
6
|
"@tcswap/tokens": "4.1.5",
|
|
7
|
-
"@tcswap/types": "0.4.
|
|
7
|
+
"@tcswap/types": "0.4.2",
|
|
8
8
|
"ethers": "^6.14.0",
|
|
9
9
|
"ts-pattern": "5.9.0",
|
|
10
10
|
"zod": "3.25.74",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"description": "USwap - Helpers",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@near-js/providers": "2.5.0",
|
|
16
|
-
"@tcswap/toolboxes": "4.3.
|
|
16
|
+
"@tcswap/toolboxes": "4.3.18",
|
|
17
17
|
"ethers": "6.15.0",
|
|
18
18
|
"tronweb": "6.1.0"
|
|
19
19
|
},
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"type-check:go": "tsgo"
|
|
64
64
|
},
|
|
65
65
|
"type": "module",
|
|
66
|
-
"version": "4.5.
|
|
66
|
+
"version": "4.5.18"
|
|
67
67
|
}
|
|
@@ -30,7 +30,7 @@ import type {
|
|
|
30
30
|
} from "./types";
|
|
31
31
|
|
|
32
32
|
function getMidgardBaseUrl(isThorchain = true) {
|
|
33
|
-
return isThorchain ? "https://
|
|
33
|
+
return isThorchain ? "https://gateway.liquify.com/chain/thorchain_midgard" : "https://midgard.mayachain.info";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function getNameServiceBaseUrl(isThorchain = true) {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getAssetType,
|
|
14
14
|
getCommonAssetInfo,
|
|
15
15
|
isGasAsset,
|
|
16
|
+
isSecuredAssetIdentifier,
|
|
16
17
|
} from "../utils/asset";
|
|
17
18
|
import { warnOnce } from "../utils/others";
|
|
18
19
|
import { validateIdentifier } from "../utils/validators";
|
|
@@ -74,6 +75,7 @@ export class AssetValue extends BigIntArithmetics {
|
|
|
74
75
|
address?: string;
|
|
75
76
|
chain: Chain;
|
|
76
77
|
isGasAsset = false;
|
|
78
|
+
isSecuredAsset = false;
|
|
77
79
|
isSynthetic = false;
|
|
78
80
|
isTradeAsset = false;
|
|
79
81
|
symbol: string;
|
|
@@ -105,12 +107,13 @@ export class AssetValue extends BigIntArithmetics {
|
|
|
105
107
|
this.address = assetInfo.address;
|
|
106
108
|
this.isSynthetic = assetInfo.isSynthetic;
|
|
107
109
|
this.isTradeAsset = assetInfo.isTradeAsset;
|
|
110
|
+
this.isSecuredAsset = assetInfo.isSecuredAsset ?? false;
|
|
108
111
|
this.isGasAsset = assetInfo.isGasAsset;
|
|
109
112
|
this.chainId = getChainConfig(assetInfo.chain).chainId;
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
toString({ includeSynthProtocol }: { includeSynthProtocol?: boolean } = {}) {
|
|
113
|
-
return (this.isSynthetic || this.isTradeAsset) && !includeSynthProtocol
|
|
116
|
+
return (this.isSynthetic || this.isTradeAsset || this.isSecuredAsset) && !includeSynthProtocol
|
|
114
117
|
? this.symbol
|
|
115
118
|
: `${this.chain}.${this.symbol}`;
|
|
116
119
|
}
|
|
@@ -124,6 +127,10 @@ export class AssetValue extends BigIntArithmetics {
|
|
|
124
127
|
return `${this.chain}.${this.symbol.replace(/~/g, "..")}`;
|
|
125
128
|
}
|
|
126
129
|
|
|
130
|
+
if (this.isSecuredAsset) {
|
|
131
|
+
return `${this.chain}.${this.symbol}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
127
134
|
const encodedSymbol = this.symbol.replace(/\./g, "__");
|
|
128
135
|
return `${this.chain}.${encodedSymbol}`;
|
|
129
136
|
}
|
|
@@ -188,7 +195,7 @@ export class AssetValue extends BigIntArithmetics {
|
|
|
188
195
|
fallbackIdentifier as CommonAssetString,
|
|
189
196
|
);
|
|
190
197
|
|
|
191
|
-
const { chain, isSynthetic, isTradeAsset, address } = getAssetInfo(unsafeIdentifier);
|
|
198
|
+
const { chain, isSynthetic, isTradeAsset, isSecuredAsset, address } = getAssetInfo(unsafeIdentifier);
|
|
192
199
|
const { baseDecimal } = getChainConfig(chain);
|
|
193
200
|
|
|
194
201
|
const token = staticTokensMap.get(
|
|
@@ -197,7 +204,7 @@ export class AssetValue extends BigIntArithmetics {
|
|
|
197
204
|
: (unsafeIdentifier.toUpperCase() as TokenNames),
|
|
198
205
|
);
|
|
199
206
|
|
|
200
|
-
if (!token && asyncTokenLookup && !isSynthetic && !isTradeAsset) {
|
|
207
|
+
if (!token && asyncTokenLookup && !isSynthetic && !isTradeAsset && !isSecuredAsset) {
|
|
201
208
|
return (async () => {
|
|
202
209
|
const { ticker } = assetFromString(unsafeIdentifier);
|
|
203
210
|
const tokenData = await fetchTokenData({ address, chain, ticker });
|
|
@@ -232,7 +239,9 @@ or by passing asyncTokenLookup: true to the from() function, which will make it
|
|
|
232
239
|
const assetValue =
|
|
233
240
|
isSynthetic || isTradeAsset
|
|
234
241
|
? createSyntheticAssetValue(identifier, adjustedValue)
|
|
235
|
-
:
|
|
242
|
+
: isSecuredAsset
|
|
243
|
+
? createSecuredAssetValue(identifier, adjustedValue)
|
|
244
|
+
: createAssetValue({ decimal, identifier, tax, value: adjustedValue });
|
|
236
245
|
|
|
237
246
|
return assetValue as ConditionalAssetValueReturn<T>;
|
|
238
247
|
}
|
|
@@ -389,6 +398,24 @@ function createSyntheticAssetValue(identifier: string, value: NumberPrimitives =
|
|
|
389
398
|
});
|
|
390
399
|
}
|
|
391
400
|
|
|
401
|
+
function createSecuredAssetValue(identifier: string, value: NumberPrimitives = 0) {
|
|
402
|
+
// Canonical Secured Asset identifier is the bare "<CHAIN>-<SYMBOL>" form. The caller has
|
|
403
|
+
// already routed here via `isSecuredAssetIdentifier`, which rejects anything with a dot.
|
|
404
|
+
const dashIndex = identifier.indexOf("-");
|
|
405
|
+
if (dashIndex === -1) {
|
|
406
|
+
throw new USwapError({ errorKey: "helpers_invalid_asset_identifier", info: { identifier } });
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const securedChain = identifier.slice(0, dashIndex).toUpperCase();
|
|
410
|
+
const symbolRemainder = identifier.slice(dashIndex + 1).toUpperCase();
|
|
411
|
+
|
|
412
|
+
if (!securedChain || !symbolRemainder) {
|
|
413
|
+
throw new USwapError({ errorKey: "helpers_invalid_asset_identifier", info: { identifier } });
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return new AssetValue({ decimal: 8, identifier: `${securedChain}-${symbolRemainder}`, value: safeValue(value, 8) });
|
|
417
|
+
}
|
|
418
|
+
|
|
392
419
|
async function createAsyncAssetValue({
|
|
393
420
|
address,
|
|
394
421
|
chain,
|
|
@@ -416,8 +443,11 @@ function validateAssetChain(assetOrChain: AssetIdentifier) {
|
|
|
416
443
|
({ chain }) => chain,
|
|
417
444
|
)
|
|
418
445
|
.otherwise((x) => {
|
|
419
|
-
const
|
|
420
|
-
|
|
446
|
+
const assetStr = (x as { asset: string }).asset;
|
|
447
|
+
if (isSecuredAssetIdentifier(assetStr)) return Chain.THORChain;
|
|
448
|
+
if (assetStr.includes("/") || assetStr.includes("~")) return Chain.THORChain;
|
|
449
|
+
const assetInfo = assetFromString(assetStr);
|
|
450
|
+
return assetInfo.chain;
|
|
421
451
|
});
|
|
422
452
|
|
|
423
453
|
// TODO: move to USwapConfig chains once we support it throughout sdk
|
|
@@ -447,6 +477,10 @@ function getAssetString(assetOrChain: AssetIdentifier) {
|
|
|
447
477
|
return chain;
|
|
448
478
|
}
|
|
449
479
|
|
|
480
|
+
if (isSecuredAssetIdentifier(assetOrChain.asset)) {
|
|
481
|
+
return assetOrChain.asset.toUpperCase();
|
|
482
|
+
}
|
|
483
|
+
|
|
450
484
|
const { chain, symbol } = assetFromString(assetOrChain.asset);
|
|
451
485
|
const isNativeChain = getAssetType({ chain, symbol }) === "Native";
|
|
452
486
|
|
|
@@ -472,7 +506,47 @@ function getSyntheticOrTradeAssetInfo(identifier: string, isSynthetic: boolean,
|
|
|
472
506
|
const { ticker, address } = getAssetBaseInfo({ chain: synthChain as Chain, symbol: synthSymbol });
|
|
473
507
|
const finalSymbol = `${synthChain}${assetSeparator}${synthSymbol}`;
|
|
474
508
|
|
|
475
|
-
return {
|
|
509
|
+
return {
|
|
510
|
+
address,
|
|
511
|
+
chain: identifierChain,
|
|
512
|
+
isGasAsset: false,
|
|
513
|
+
isSecuredAsset: false,
|
|
514
|
+
isSynthetic,
|
|
515
|
+
isTradeAsset,
|
|
516
|
+
symbol: finalSymbol,
|
|
517
|
+
ticker,
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function getSecuredAssetInfo(identifier: string) {
|
|
522
|
+
// Canonical Secured Asset identifier is the bare "<CHAIN>-<SYMBOL>" form (no "THOR." prefix).
|
|
523
|
+
// `isSecuredAssetIdentifier` rejects anything containing a dot before this is reached.
|
|
524
|
+
const dashIndex = identifier.indexOf("-");
|
|
525
|
+
const securedChain = identifier.slice(0, dashIndex).toUpperCase();
|
|
526
|
+
const remainder = identifier.slice(dashIndex + 1);
|
|
527
|
+
|
|
528
|
+
if (!securedChain || !remainder) {
|
|
529
|
+
throw new USwapError({ errorKey: "helpers_invalid_asset_identifier", info: { identifier } });
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// For token-bearing secured assets like ETH-USDC-0x…, ticker is the part between the chain
|
|
533
|
+
// separator and the address; the address is the trailing 0x… segment if present.
|
|
534
|
+
const lastDash = remainder.lastIndexOf("-");
|
|
535
|
+
const hasAddress = lastDash !== -1 && /^0[xX]/.test(remainder.slice(lastDash + 1));
|
|
536
|
+
const ticker = (hasAddress ? remainder.slice(0, lastDash) : remainder).toUpperCase();
|
|
537
|
+
const address = hasAddress ? remainder.slice(lastDash + 1) : undefined;
|
|
538
|
+
const symbol = `${securedChain}-${remainder.toUpperCase()}`;
|
|
539
|
+
|
|
540
|
+
return {
|
|
541
|
+
address,
|
|
542
|
+
chain: Chain.THORChain,
|
|
543
|
+
isGasAsset: false,
|
|
544
|
+
isSecuredAsset: true,
|
|
545
|
+
isSynthetic: false,
|
|
546
|
+
isTradeAsset: false,
|
|
547
|
+
symbol,
|
|
548
|
+
ticker,
|
|
549
|
+
};
|
|
476
550
|
}
|
|
477
551
|
|
|
478
552
|
function getNormalAssetInfo(identifier: string) {
|
|
@@ -496,6 +570,7 @@ function getNormalAssetInfo(identifier: string) {
|
|
|
496
570
|
address: formattedAddress,
|
|
497
571
|
chain,
|
|
498
572
|
isGasAsset: isGasAsset({ chain, symbol: assetSymbol }),
|
|
573
|
+
isSecuredAsset: false,
|
|
499
574
|
isSynthetic: false,
|
|
500
575
|
isTradeAsset: false,
|
|
501
576
|
symbol: finalSymbol,
|
|
@@ -512,6 +587,10 @@ function getAssetInfo(identifier: string) {
|
|
|
512
587
|
return getSyntheticOrTradeAssetInfo(identifier, isSynthetic, isTradeAsset);
|
|
513
588
|
}
|
|
514
589
|
|
|
590
|
+
if (isSecuredAssetIdentifier(identifier)) {
|
|
591
|
+
return getSecuredAssetInfo(identifier);
|
|
592
|
+
}
|
|
593
|
+
|
|
515
594
|
return getNormalAssetInfo(identifier);
|
|
516
595
|
}
|
|
517
596
|
|
|
@@ -73,6 +73,7 @@ const initialState = {
|
|
|
73
73
|
endpoints: {} as CustomApiEndpoints,
|
|
74
74
|
envs: {
|
|
75
75
|
apiUrl: "https://swap-api.unstoppable.money",
|
|
76
|
+
blockchairApiUrl: null as string | null,
|
|
76
77
|
devApiUrl: "https://swap-api-dev.unstoppable.money",
|
|
77
78
|
experimental_apiKey: null as string | null,
|
|
78
79
|
experimental_apiUrlQuote: null as string | null,
|
package/src/utils/asset.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TokenNames } from "@tcswap/tokens";
|
|
2
|
-
import { Chain, type EVMChain, EVMChains, getChainConfig, UTXOChains } from "@tcswap/types";
|
|
2
|
+
import { AllChains, Chain, type EVMChain, EVMChains, getChainConfig, UTXOChains } from "@tcswap/types";
|
|
3
3
|
import { match } from "ts-pattern";
|
|
4
4
|
import type { AssetValue } from "../modules/assetValue";
|
|
5
5
|
import { RequestClient } from "../modules/requestClient";
|
|
@@ -341,9 +341,41 @@ export const getCommonAssetInfo = (assetString: CommonAssetString) => {
|
|
|
341
341
|
return commonAssetInfo;
|
|
342
342
|
};
|
|
343
343
|
|
|
344
|
+
export function isSecuredAssetIdentifier(identifier = "") {
|
|
345
|
+
if (!identifier) return false;
|
|
346
|
+
|
|
347
|
+
// Synthetic and trade assets use distinct separators; never confuse those with secured.
|
|
348
|
+
if (identifier.includes("/") || identifier.includes("~")) return false;
|
|
349
|
+
|
|
350
|
+
const upper = identifier.toUpperCase();
|
|
351
|
+
|
|
352
|
+
// Canonical Secured Asset identifiers from THORChain are bare "<CHAIN>-<SYMBOL>" — they
|
|
353
|
+
// never carry a chain prefix. Any "." means a normal chain.symbol identifier (ETH.USDC-0x…).
|
|
354
|
+
if (upper.includes(".")) return false;
|
|
355
|
+
|
|
356
|
+
const dashIndex = upper.indexOf("-");
|
|
357
|
+
if (dashIndex <= 0) return false;
|
|
358
|
+
|
|
359
|
+
const chainPart = upper.slice(0, dashIndex);
|
|
360
|
+
const tickerPart = upper.slice(dashIndex + 1);
|
|
361
|
+
|
|
362
|
+
if (!chainPart || !tickerPart) return false;
|
|
363
|
+
// First segment must be the L1 chain code (e.g. BTC, ETH, AVAX). Exclude THOR/MAYA themselves —
|
|
364
|
+
// secured assets always derive from non-protocol L1 chains.
|
|
365
|
+
if (chainPart === Chain.THORChain || chainPart === Chain.Maya) return false;
|
|
366
|
+
if (!AllChains.includes(chainPart as Chain)) return false;
|
|
367
|
+
|
|
368
|
+
// Tickers like "0x…" without anything before the address aren't valid; address-bearing tokens
|
|
369
|
+
// come through as TICKER-0x… which is fine because the part before the address is the ticker.
|
|
370
|
+
if (tickerPart.startsWith("0X")) return false;
|
|
371
|
+
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
|
|
344
375
|
export function getAssetType({ chain, symbol }: { chain: Chain; symbol: string }) {
|
|
345
376
|
if (symbol.includes("/")) return "Synth";
|
|
346
377
|
if (symbol.includes("~")) return "Trade";
|
|
378
|
+
if (chain === Chain.THORChain && isSecuredAssetIdentifier(symbol)) return "Secured";
|
|
347
379
|
|
|
348
380
|
const isNative = match(chain)
|
|
349
381
|
.with(Chain.Radix, () => symbol === Chain.Radix || `${chain}.${symbol}` === getCommonAssetInfo(chain).identifier)
|
package/src/utils/validators.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { Chain } from "@tcswap/types";
|
|
6
6
|
import { USwapConfig } from "../modules/uSwapConfig";
|
|
7
7
|
import { USwapError } from "../modules/uSwapError";
|
|
8
|
+
import { isSecuredAssetIdentifier } from "./asset";
|
|
8
9
|
|
|
9
10
|
// Backward compatibility
|
|
10
11
|
const supportedChains = ["TERRA", ...USwapConfig.get("chains")];
|
|
@@ -18,6 +19,8 @@ export function validateIdentifier(identifier = "") {
|
|
|
18
19
|
const [synthChain] = uppercasedIdentifier.split("/") as [Chain, string];
|
|
19
20
|
if (supportedChains.includes(synthChain)) return true;
|
|
20
21
|
|
|
22
|
+
if (isSecuredAssetIdentifier(identifier)) return true;
|
|
23
|
+
|
|
21
24
|
throw new USwapError({
|
|
22
25
|
errorKey: "helpers_invalid_identifier",
|
|
23
26
|
info: {
|
package/dist/chunk-pfmeq01a.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var k=(a,c,b)=>{b=a!=null?g(h(a)):{};let d=c||!a||!a.__esModule?f(b,"default",{value:a,enumerable:!0}):b;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var l=(a,c)=>{for(var b in c)f(a,b,{get:c[b],enumerable:!0,configurable:!0,set:(d)=>c[b]=()=>d})};var m=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(c,b)=>(typeof require<"u"?require:c)[b]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
|
|
2
|
-
export{k as a,l as b,m as c};
|
|
3
|
-
|
|
4
|
-
//# debugId=940CF069C6466DBE64756E2164756E21
|
|
5
|
-
//# sourceMappingURL=chunk-pfmeq01a.js.map
|
package/dist/chunk-vb4wtm2w.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var j=Object.create;var{getPrototypeOf:k,defineProperty:e,getOwnPropertyNames:f,getOwnPropertyDescriptor:l}=Object,g=Object.prototype.hasOwnProperty,m=(a,c,d)=>{for(let b of f(c))if(!g.call(a,b)&&b!=="default")e(a,b,{get:()=>c[b],enumerable:!0});if(d){for(let b of f(c))if(!g.call(d,b)&&b!=="default")e(d,b,{get:()=>c[b],enumerable:!0});return d}},n=(a,c,d)=>{d=a!=null?j(k(a)):{};let b=c||!a||!a.__esModule?e(d,"default",{value:a,enumerable:!0}):d;for(let h of f(a))if(!g.call(b,h))e(b,h,{get:()=>a[h],enumerable:!0});return b},i=new WeakMap,o=(a)=>{var c=i.get(a),d;if(c)return c;if(c=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function")f(a).map((b)=>!g.call(c,b)&&e(c,b,{get:()=>a[b],enumerable:!(d=l(a,b))||d.enumerable}));return i.set(a,c),c};var p=(a,c)=>{for(var d in c)e(a,d,{get:c[d],enumerable:!0,configurable:!0,set:(b)=>c[d]=()=>b})};
|
|
2
|
-
|
|
3
|
-
//# debugId=5B7366231CF0CA5E64756E2164756E21
|
|
4
|
-
//# sourceMappingURL=chunk-vb4wtm2w.js.map
|