@pioneer-platform/helpers 4.0.13 → 4.1.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/CHANGELOG.md +20 -0
- package/package.json +13 -10
- package/src/helpers/asset.ts +0 -5
- package/tsconfig.json +1 -1
- package/LICENSE +0 -674
- package/lib/helpers/asset.d.ts +0 -36
- package/lib/helpers/asset.js +0 -270
- package/lib/helpers/liquidity.d.ts +0 -58
- package/lib/helpers/liquidity.js +0 -112
- package/lib/helpers/memo.d.ts +0 -46
- package/lib/helpers/memo.js +0 -46
- package/lib/helpers/others.d.ts +0 -3
- package/lib/helpers/others.js +0 -24
- package/lib/helpers/request.d.ts +0 -5
- package/lib/helpers/request.js +0 -117
- package/lib/helpers/validators.d.ts +0 -1
- package/lib/helpers/validators.js +0 -17
- package/lib/index.d.ts +0 -15
- package/lib/index.js +0 -31
- package/lib/modules/__tests__/assetValue.test.d.ts +0 -1
- package/lib/modules/__tests__/assetValue.test.js +0 -399
- package/lib/modules/__tests__/swapKitNumber.test.d.ts +0 -1
- package/lib/modules/__tests__/swapKitNumber.test.js +0 -425
- package/lib/modules/assetValue.d.ts +0 -58
- package/lib/modules/assetValue.js +0 -442
- package/lib/modules/bigIntArithmetics.d.ts +0 -54
- package/lib/modules/bigIntArithmetics.js +0 -643
- package/lib/modules/swapKitError.d.ts +0 -64
- package/lib/modules/swapKitError.js +0 -90
- package/lib/modules/swapKitNumber.d.ts +0 -6
- package/lib/modules/swapKitNumber.js +0 -37
@@ -1,442 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
|
-
if (k2 === undefined) k2 = k;
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
22
|
-
}
|
23
|
-
Object.defineProperty(o, k2, desc);
|
24
|
-
}) : (function(o, m, k, k2) {
|
25
|
-
if (k2 === undefined) k2 = k;
|
26
|
-
o[k2] = m[k];
|
27
|
-
}));
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
30
|
-
}) : function(o, v) {
|
31
|
-
o["default"] = v;
|
32
|
-
});
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
34
|
-
if (mod && mod.__esModule) return mod;
|
35
|
-
var result = {};
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
37
|
-
__setModuleDefault(result, mod);
|
38
|
-
return result;
|
39
|
-
};
|
40
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
47
|
-
});
|
48
|
-
};
|
49
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
50
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
51
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
52
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
53
|
-
function step(op) {
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
55
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
56
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
57
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
58
|
-
switch (op[0]) {
|
59
|
-
case 0: case 1: t = op; break;
|
60
|
-
case 4: _.label++; return { value: op[1], done: false };
|
61
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
62
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
63
|
-
default:
|
64
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
65
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
66
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
67
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
68
|
-
if (t[2]) _.ops.pop();
|
69
|
-
_.trys.pop(); continue;
|
70
|
-
}
|
71
|
-
op = body.call(thisArg, _);
|
72
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
73
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
74
|
-
}
|
75
|
-
};
|
76
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
77
|
-
var t = {};
|
78
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
79
|
-
t[p] = s[p];
|
80
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
81
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
82
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
83
|
-
t[p[i]] = s[p[i]];
|
84
|
-
}
|
85
|
-
return t;
|
86
|
-
};
|
87
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
88
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
89
|
-
if (ar || !(i in from)) {
|
90
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
91
|
-
ar[i] = from[i];
|
92
|
-
}
|
93
|
-
}
|
94
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
95
|
-
};
|
96
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
97
|
-
exports.getMinAmountByChain = exports.AssetValue = exports.safeValue = void 0;
|
98
|
-
var types_1 = require("@coinmasters/types");
|
99
|
-
var asset_1 = require("../helpers/asset");
|
100
|
-
var validators_1 = require("../helpers/validators");
|
101
|
-
var bigIntArithmetics_1 = require("./bigIntArithmetics");
|
102
|
-
var TAG = " | assetValue | ";
|
103
|
-
function safeValue(value, decimal) {
|
104
|
-
var tag = TAG + " | safeValue | ";
|
105
|
-
try {
|
106
|
-
if (typeof value === 'bigint') {
|
107
|
-
return value;
|
108
|
-
}
|
109
|
-
else if (typeof value === 'number') {
|
110
|
-
return BigInt(Math.round(value * Math.pow(10, decimal)));
|
111
|
-
}
|
112
|
-
else if (typeof value === 'string') {
|
113
|
-
return BigInt(Math.round(parseFloat(value) * Math.pow(10, decimal)));
|
114
|
-
}
|
115
|
-
return BigInt(0);
|
116
|
-
}
|
117
|
-
catch (error) {
|
118
|
-
console.error(tag + 'Error in safeValue:', error);
|
119
|
-
return BigInt(0);
|
120
|
-
}
|
121
|
-
}
|
122
|
-
exports.safeValue = safeValue;
|
123
|
-
var staticTokensMap;
|
124
|
-
var getStaticToken = function (identifier) {
|
125
|
-
var tag = TAG + " | getStaticToken | ";
|
126
|
-
try {
|
127
|
-
if (!staticTokensMap) {
|
128
|
-
throw new Error('Static assets not loaded, call await AssetValue.loadStaticAssets() first');
|
129
|
-
}
|
130
|
-
var tokenInfo = staticTokensMap.get(identifier.toUpperCase());
|
131
|
-
return tokenInfo || { decimal: types_1.BaseDecimal.THOR, identifier: '' };
|
132
|
-
}
|
133
|
-
catch (error) {
|
134
|
-
console.error(tag + 'Error in getStaticToken:', error);
|
135
|
-
}
|
136
|
-
};
|
137
|
-
var createAssetValue = function (assetString, value) {
|
138
|
-
if (value === void 0) { value = 0; }
|
139
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
140
|
-
var tag, decimal, parsedValue, error_1;
|
141
|
-
return __generator(this, function (_a) {
|
142
|
-
switch (_a.label) {
|
143
|
-
case 0:
|
144
|
-
tag = TAG + " | createAssetValue | ";
|
145
|
-
_a.label = 1;
|
146
|
-
case 1:
|
147
|
-
_a.trys.push([1, 3, , 4]);
|
148
|
-
(0, validators_1.validateIdentifier)(assetString);
|
149
|
-
return [4 /*yield*/, (0, asset_1.getDecimal)(getAssetInfo(assetString))];
|
150
|
-
case 2:
|
151
|
-
decimal = _a.sent();
|
152
|
-
parsedValue = safeValue(value, decimal);
|
153
|
-
//console.log(tag + 'parsedValue', parsedValue);
|
154
|
-
// @ts-ignore
|
155
|
-
return [2 /*return*/, new AssetValue({ decimal: decimal, value: parsedValue, identifier: assetString })];
|
156
|
-
case 3:
|
157
|
-
error_1 = _a.sent();
|
158
|
-
console.error(tag + 'Error in createAssetValue:', error_1);
|
159
|
-
return [3 /*break*/, 4];
|
160
|
-
case 4: return [2 /*return*/];
|
161
|
-
}
|
162
|
-
});
|
163
|
-
});
|
164
|
-
};
|
165
|
-
var AssetValue = /** @class */ (function (_super) {
|
166
|
-
__extends(AssetValue, _super);
|
167
|
-
//@ts-ignore
|
168
|
-
function AssetValue(params) {
|
169
|
-
var _this = this;
|
170
|
-
var tag = TAG + " | constructor | ";
|
171
|
-
try {
|
172
|
-
var identifier = 'identifier' in params ? params.identifier : "".concat(params.chain, ".").concat(params.symbol);
|
173
|
-
var value = void 0;
|
174
|
-
if (params.value instanceof bigIntArithmetics_1.BigIntArithmetics) {
|
175
|
-
value = params.value;
|
176
|
-
}
|
177
|
-
else {
|
178
|
-
value = { decimal: params.decimal, value: safeValue(params.value, params.decimal) };
|
179
|
-
}
|
180
|
-
// @ts-ignore
|
181
|
-
_this = _super.call(this, value) || this;
|
182
|
-
_this.isGasAsset = false;
|
183
|
-
_this.isSynthetic = false;
|
184
|
-
var assetInfo = getAssetInfo(identifier);
|
185
|
-
_this.type = (0, asset_1.getAssetType)(assetInfo);
|
186
|
-
_this.identifier = identifier;
|
187
|
-
_this.chain = assetInfo.chain;
|
188
|
-
_this.ticker = assetInfo.ticker;
|
189
|
-
_this.symbol = assetInfo.symbol;
|
190
|
-
_this.address = assetInfo.address;
|
191
|
-
_this.isSynthetic = assetInfo.isSynthetic;
|
192
|
-
// @ts-ignore
|
193
|
-
_this.isGasAsset = assetInfo.isGasAsset;
|
194
|
-
_this.tax = params.tax;
|
195
|
-
}
|
196
|
-
catch (error) {
|
197
|
-
console.error(tag + 'Error in constructor:', error);
|
198
|
-
}
|
199
|
-
return _this;
|
200
|
-
}
|
201
|
-
AssetValue.prototype.toString = function (short) {
|
202
|
-
if (short === void 0) { short = false; }
|
203
|
-
var tag = TAG + " | toString | ";
|
204
|
-
try {
|
205
|
-
var shortFormat = this.isSynthetic ? this.symbol : this.ticker;
|
206
|
-
return short
|
207
|
-
? shortFormat
|
208
|
-
: "".concat(this.chain, ".").concat(this.symbol);
|
209
|
-
}
|
210
|
-
catch (error) {
|
211
|
-
console.error(tag + 'Error in toString:', error);
|
212
|
-
}
|
213
|
-
};
|
214
|
-
AssetValue.prototype.toUrl = function () {
|
215
|
-
var tag = TAG + " | toUrl | ";
|
216
|
-
try {
|
217
|
-
return this.isSynthetic ? "".concat(this.chain, ".").concat(this.symbol.replace('/', '.')) : this.toString();
|
218
|
-
}
|
219
|
-
catch (error) {
|
220
|
-
console.error(tag + 'Error in toUrl:', error);
|
221
|
-
}
|
222
|
-
};
|
223
|
-
AssetValue.prototype.eq = function (_a) {
|
224
|
-
var chain = _a.chain, symbol = _a.symbol;
|
225
|
-
var tag = TAG + " | eq | ";
|
226
|
-
try {
|
227
|
-
return this.chain === chain && this.symbol === symbol;
|
228
|
-
}
|
229
|
-
catch (error) {
|
230
|
-
console.error(tag + 'Error in eq:', error);
|
231
|
-
}
|
232
|
-
};
|
233
|
-
AssetValue.fromString = function (assetString, value) {
|
234
|
-
if (value === void 0) { value = 0; }
|
235
|
-
return __awaiter(this, void 0, void 0, function () {
|
236
|
-
var tag;
|
237
|
-
return __generator(this, function (_a) {
|
238
|
-
tag = TAG + " | fromString | ";
|
239
|
-
try {
|
240
|
-
return [2 /*return*/, createAssetValue(assetString, value)];
|
241
|
-
}
|
242
|
-
catch (error) {
|
243
|
-
console.error(tag + 'Error in fromString:', error);
|
244
|
-
}
|
245
|
-
return [2 /*return*/];
|
246
|
-
});
|
247
|
-
});
|
248
|
-
};
|
249
|
-
AssetValue.fromStringSync = function (assetString, value) {
|
250
|
-
if (value === void 0) { value = 0; }
|
251
|
-
var tag = TAG + " | fromStringSync | ";
|
252
|
-
try {
|
253
|
-
//@ts-ignore
|
254
|
-
var _a = getAssetInfo(assetString), isSynthetic = _a.isSynthetic, symbol = _a.symbol, chain = _a.chain, isGasAsset_1 = _a.isGasAsset, ticker = _a.ticker, address = _a.address;
|
255
|
-
var _b = getStaticToken(assetString), tax = _b.tax, decimal = _b.decimal, tokenIdentifier = _b.identifier;
|
256
|
-
var parsedValue = safeValue(value, decimal);
|
257
|
-
var asset = void 0;
|
258
|
-
if (tokenIdentifier) {
|
259
|
-
asset = new AssetValue({
|
260
|
-
tax: tax,
|
261
|
-
decimal: decimal,
|
262
|
-
identifier: tokenIdentifier,
|
263
|
-
// @ts-ignore
|
264
|
-
value: parsedValue,
|
265
|
-
});
|
266
|
-
}
|
267
|
-
else if (isSynthetic) {
|
268
|
-
asset = new AssetValue({
|
269
|
-
tax: tax,
|
270
|
-
decimal: 8, // Synthetic assets use a fixed decimal value
|
271
|
-
identifier: assetString,
|
272
|
-
// @ts-ignore
|
273
|
-
value: parsedValue,
|
274
|
-
});
|
275
|
-
}
|
276
|
-
else {
|
277
|
-
asset = undefined;
|
278
|
-
}
|
279
|
-
return asset;
|
280
|
-
}
|
281
|
-
catch (error) {
|
282
|
-
console.error(tag + 'Error in fromStringSync:', error);
|
283
|
-
}
|
284
|
-
};
|
285
|
-
AssetValue.fromIdentifier = function (assetString, value) {
|
286
|
-
if (value === void 0) { value = 0; }
|
287
|
-
return __awaiter(this, void 0, void 0, function () {
|
288
|
-
var tag;
|
289
|
-
return __generator(this, function (_a) {
|
290
|
-
tag = TAG + " | fromIdentifier | ";
|
291
|
-
try {
|
292
|
-
return [2 /*return*/, createAssetValue(assetString, value)];
|
293
|
-
}
|
294
|
-
catch (error) {
|
295
|
-
console.error(tag + 'Error in fromIdentifier:', error);
|
296
|
-
}
|
297
|
-
return [2 /*return*/];
|
298
|
-
});
|
299
|
-
});
|
300
|
-
};
|
301
|
-
AssetValue.fromIdentifierSync = function (identifier, value) {
|
302
|
-
if (value === void 0) { value = 0; }
|
303
|
-
var tag = TAG + " | fromIdentifierSync | ";
|
304
|
-
try {
|
305
|
-
//@ts-ignore
|
306
|
-
var _a = getStaticToken(identifier), decimal = _a.decimal, tokenIdentifier = _a.identifier;
|
307
|
-
var parsedValue = safeValue(value, decimal);
|
308
|
-
// @ts-ignore
|
309
|
-
return new AssetValue({ decimal: decimal, identifier: tokenIdentifier, value: parsedValue });
|
310
|
-
}
|
311
|
-
catch (error) {
|
312
|
-
console.error(tag + 'Error in fromIdentifierSync:', error);
|
313
|
-
}
|
314
|
-
};
|
315
|
-
AssetValue.fromChainOrSignature = function (assetString, value) {
|
316
|
-
if (value === void 0) { value = 0; }
|
317
|
-
var tag = TAG + " | fromChainOrSignature | ";
|
318
|
-
try {
|
319
|
-
var _a = (0, asset_1.getCommonAssetInfo)(assetString), decimal = _a.decimal, identifier = _a.identifier;
|
320
|
-
if (!decimal || !identifier)
|
321
|
-
throw Error('unknown coin! ' + assetString);
|
322
|
-
var parsedValue = safeValue(value, decimal);
|
323
|
-
//console.log(tag + "parsedValue: ", parsedValue);
|
324
|
-
//console.log(tag + "decimal: ", decimal);
|
325
|
-
//console.log(tag + "identifier: ", identifier);
|
326
|
-
// @ts-ignore
|
327
|
-
return new AssetValue({ value: parsedValue, decimal: decimal, identifier: identifier });
|
328
|
-
}
|
329
|
-
catch (error) {
|
330
|
-
console.error(tag + 'Error in fromChainOrSignature:', error);
|
331
|
-
}
|
332
|
-
};
|
333
|
-
AssetValue.loadStaticAssets = function () {
|
334
|
-
return __awaiter(this, void 0, void 0, function () {
|
335
|
-
var tag;
|
336
|
-
var _this = this;
|
337
|
-
return __generator(this, function (_a) {
|
338
|
-
tag = TAG + " | loadStaticAssets | ";
|
339
|
-
try {
|
340
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
341
|
-
var _a, _ThorchainList, NativeList, tokensPackage, tokensMap, error_2;
|
342
|
-
return __generator(this, function (_b) {
|
343
|
-
switch (_b.label) {
|
344
|
-
case 0:
|
345
|
-
_b.trys.push([0, 2, , 3]);
|
346
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('@coinmasters/tokens')); })];
|
347
|
-
case 1:
|
348
|
-
_a = _b.sent(), _ThorchainList = _a.ThorchainList, NativeList = _a.NativeList, tokensPackage = __rest(_a, ["ThorchainList", "NativeList"]);
|
349
|
-
tokensMap = __spreadArray([NativeList], Object.values(tokensPackage), true).reduce(function (acc, _a) {
|
350
|
-
var tokens = _a.tokens;
|
351
|
-
if (!tokens) {
|
352
|
-
console.warn(tag + "No tokens found in the current package, skipping.");
|
353
|
-
return acc;
|
354
|
-
}
|
355
|
-
// @ts-ignore
|
356
|
-
tokens.forEach(function (_a) {
|
357
|
-
var identifier = _a.identifier, chain = _a.chain, rest = __rest(_a, ["identifier", "chain"]);
|
358
|
-
var decimal = 'decimals' in rest ? rest.decimals : types_1.BaseDecimal[chain];
|
359
|
-
acc.set(identifier, { identifier: identifier, decimal: decimal });
|
360
|
-
});
|
361
|
-
return acc;
|
362
|
-
}, new Map());
|
363
|
-
staticTokensMap = tokensMap;
|
364
|
-
resolve({ ok: true });
|
365
|
-
return [3 /*break*/, 3];
|
366
|
-
case 2:
|
367
|
-
error_2 = _b.sent();
|
368
|
-
console.error(tag + "Error loading static assets:", error_2);
|
369
|
-
reject({
|
370
|
-
ok: false,
|
371
|
-
error: error_2,
|
372
|
-
message: "Couldn't load static assets. Ensure you have installed @coinmasters/tokens package",
|
373
|
-
});
|
374
|
-
return [3 /*break*/, 3];
|
375
|
-
case 3: return [2 /*return*/];
|
376
|
-
}
|
377
|
-
});
|
378
|
-
}); })];
|
379
|
-
}
|
380
|
-
catch (error) {
|
381
|
-
console.error(tag + 'Error in loadStaticAssets:', error);
|
382
|
-
}
|
383
|
-
return [2 /*return*/];
|
384
|
-
});
|
385
|
-
});
|
386
|
-
};
|
387
|
-
return AssetValue;
|
388
|
-
}(bigIntArithmetics_1.BigIntArithmetics));
|
389
|
-
exports.AssetValue = AssetValue;
|
390
|
-
var getMinAmountByChain = function (chain) {
|
391
|
-
var tag = TAG + " | getMinAmountByChain | ";
|
392
|
-
try {
|
393
|
-
var asset = AssetValue.fromChainOrSignature(chain);
|
394
|
-
switch (chain) {
|
395
|
-
case types_1.Chain.Bitcoin:
|
396
|
-
case types_1.Chain.Litecoin:
|
397
|
-
case types_1.Chain.Dash:
|
398
|
-
case types_1.Chain.Zcash:
|
399
|
-
case types_1.Chain.BitcoinCash:
|
400
|
-
return asset.set(0.00010001);
|
401
|
-
case types_1.Chain.Dogecoin:
|
402
|
-
return asset.set(1.00000001);
|
403
|
-
case types_1.Chain.Base:
|
404
|
-
case types_1.Chain.Arbitrum:
|
405
|
-
case types_1.Chain.Avalanche:
|
406
|
-
case types_1.Chain.Ethereum:
|
407
|
-
return asset.set(0.00000001);
|
408
|
-
case types_1.Chain.THORChain:
|
409
|
-
case types_1.Chain.Mayachain:
|
410
|
-
return asset.set(0.0000000001);
|
411
|
-
default:
|
412
|
-
return asset.set(0.00000001);
|
413
|
-
}
|
414
|
-
}
|
415
|
-
catch (error) {
|
416
|
-
console.error(tag + 'Error in getMinAmountByChain:', error);
|
417
|
-
}
|
418
|
-
};
|
419
|
-
exports.getMinAmountByChain = getMinAmountByChain;
|
420
|
-
var getAssetInfo = function (identifier) {
|
421
|
-
var _a;
|
422
|
-
var tag = TAG + " | getAssetInfo | ";
|
423
|
-
try {
|
424
|
-
var isSynthetic = identifier.slice(0, 14).includes('/');
|
425
|
-
var _b = identifier.split('.').pop().split('/'), synthChain = _b[0], synthSymbol = _b[1];
|
426
|
-
var adjustedIdentifier = identifier.includes('.') && !isSynthetic ? identifier : "".concat(types_1.Chain.THORChain, ".").concat(synthSymbol);
|
427
|
-
var _c = adjustedIdentifier.split('.'), chain = _c[0], symbol = _c[1];
|
428
|
-
var _d = (isSynthetic ? synthSymbol : symbol).split('-'), ticker = _d[0], address = _d[1];
|
429
|
-
return {
|
430
|
-
address: address === null || address === void 0 ? void 0 : address.toLowerCase(),
|
431
|
-
chain: chain,
|
432
|
-
isGasAsset: (0, asset_1.isGasAsset)({ chain: chain, symbol: symbol }),
|
433
|
-
isSynthetic: isSynthetic,
|
434
|
-
symbol: (isSynthetic ? "".concat(synthChain, "/") : '') +
|
435
|
-
(address ? "".concat(ticker, "-").concat((_a = address === null || address === void 0 ? void 0 : address.toLowerCase()) !== null && _a !== void 0 ? _a : '') : symbol),
|
436
|
-
ticker: ticker,
|
437
|
-
};
|
438
|
-
}
|
439
|
-
catch (error) {
|
440
|
-
console.error(tag + 'Error in getAssetInfo:', error);
|
441
|
-
}
|
442
|
-
};
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import type { SwapKitNumber } from './swapKitNumber';
|
2
|
-
type NumberPrimitivesType = {
|
3
|
-
bigint: bigint;
|
4
|
-
number: number;
|
5
|
-
string: string;
|
6
|
-
};
|
7
|
-
export type NumberPrimitives = bigint | number | string;
|
8
|
-
type InitialisationValueType = NumberPrimitives | BigIntArithmetics | SwapKitNumber;
|
9
|
-
type SKBigIntParams = InitialisationValueType | {
|
10
|
-
decimal?: number;
|
11
|
-
value: number | string;
|
12
|
-
};
|
13
|
-
type AllowedNumberTypes = 'bigint' | 'number' | 'string';
|
14
|
-
export declare const toMultiplier: (decimal: number) => bigint;
|
15
|
-
export declare function formatBigIntToSafeValue({ value, bigIntDecimal, decimal, }: {
|
16
|
-
value: bigint;
|
17
|
-
bigIntDecimal?: bigint;
|
18
|
-
decimal?: number;
|
19
|
-
}): string;
|
20
|
-
export declare class BigIntArithmetics {
|
21
|
-
private decimalMultiplier;
|
22
|
-
private bigIntValue;
|
23
|
-
private decimal?;
|
24
|
-
static fromBigInt(value: bigint, decimal?: number): BigIntArithmetics;
|
25
|
-
constructor(params: SKBigIntParams);
|
26
|
-
set(value: SKBigIntParams): this;
|
27
|
-
add(...args: InitialisationValueType[]): this;
|
28
|
-
sub(...args: InitialisationValueType[]): this;
|
29
|
-
mul(...args: InitialisationValueType[]): this;
|
30
|
-
div(...args: InitialisationValueType[]): this;
|
31
|
-
gt(value: InitialisationValueType): boolean;
|
32
|
-
gte(value: InitialisationValueType): boolean;
|
33
|
-
lt(value: InitialisationValueType): boolean;
|
34
|
-
lte(value: InitialisationValueType): boolean;
|
35
|
-
eqValue(value: InitialisationValueType): boolean;
|
36
|
-
getValue<T extends AllowedNumberTypes>(type: T): NumberPrimitivesType[T];
|
37
|
-
getBaseValue<T extends AllowedNumberTypes>(type: T): NumberPrimitivesType[T];
|
38
|
-
getBigIntValue(value: InitialisationValueType, decimal?: number): bigint;
|
39
|
-
toSignificant(significantDigits?: number): string;
|
40
|
-
toFixed(fixedDigits?: number): string;
|
41
|
-
toAbbreviation(digits?: number): string;
|
42
|
-
toCurrency(currency?: string, { currencyPosition, decimal, decimalSeparator, thousandSeparator, }?: {
|
43
|
-
currencyPosition?: string | undefined;
|
44
|
-
decimal?: number | undefined;
|
45
|
-
decimalSeparator?: string | undefined;
|
46
|
-
thousandSeparator?: string | undefined;
|
47
|
-
}): string;
|
48
|
-
private arithmetics;
|
49
|
-
private comparison;
|
50
|
-
private setValue;
|
51
|
-
private retrievePrecisionDecimal;
|
52
|
-
private toBigInt;
|
53
|
-
}
|
54
|
-
export {};
|