@pioneer-platform/helpers 4.0.13 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/lib/helpers/asset.d.ts +1 -1
- package/lib/helpers/asset.js +83 -145
- package/lib/helpers/liquidity.js +52 -73
- package/lib/helpers/memo.js +19 -22
- package/lib/helpers/others.js +6 -7
- package/lib/helpers/request.d.ts +1 -1
- package/lib/helpers/request.js +30 -68
- package/lib/helpers/validators.js +7 -8
- package/lib/modules/assetValue.js +171 -258
- package/lib/modules/bigIntArithmetics.js +180 -225
- package/lib/modules/swapKitError.js +6 -25
- package/lib/modules/swapKitNumber.js +10 -30
- package/package.json +18 -15
- package/src/helpers/asset.ts +0 -5
- package/tsconfig.json +1 -1
- package/LICENSE +0 -674
- 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
@@ -1,399 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
-
function step(op) {
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
18
|
-
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;
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
-
switch (op[0]) {
|
21
|
-
case 0: case 1: t = op; break;
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
-
default:
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
-
if (t[2]) _.ops.pop();
|
31
|
-
_.trys.pop(); continue;
|
32
|
-
}
|
33
|
-
op = body.call(thisArg, _);
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
-
}
|
37
|
-
};
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
var types_1 = require("@coinmasters/types");
|
40
|
-
var vitest_1 = require("vitest");
|
41
|
-
var assetValue_ts_1 = require("../assetValue.ts");
|
42
|
-
(0, vitest_1.describe)('AssetValue', function () {
|
43
|
-
(0, vitest_1.describe)('assetValue', function () {
|
44
|
-
(0, vitest_1.test)('returns asset ticker with value', function () {
|
45
|
-
var fakeAvaxUSDCAsset = new assetValue_ts_1.AssetValue({
|
46
|
-
decimal: 6,
|
47
|
-
value: 1234567890,
|
48
|
-
chain: types_1.Chain.Avalanche,
|
49
|
-
symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
50
|
-
});
|
51
|
-
(0, vitest_1.expect)(fakeAvaxUSDCAsset.toString(true)).toBe('USDC');
|
52
|
-
(0, vitest_1.expect)(fakeAvaxUSDCAsset.toString()).toBe('AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e');
|
53
|
-
var thor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.THOR');
|
54
|
-
(0, vitest_1.expect)(thor.toString(true)).toBe('THOR');
|
55
|
-
var ethSynth = new assetValue_ts_1.AssetValue({
|
56
|
-
chain: types_1.Chain.THORChain,
|
57
|
-
symbol: 'ETH/ETH',
|
58
|
-
decimal: 8,
|
59
|
-
value: 1234567890,
|
60
|
-
});
|
61
|
-
(0, vitest_1.expect)(ethSynth.toString()).toBe('THOR.ETH/ETH');
|
62
|
-
(0, vitest_1.expect)(ethSynth.toString(true)).toBe('ETH/ETH');
|
63
|
-
(0, vitest_1.expect)(ethSynth.mul(21.37).getValue('string')).toBe('26382715809.3');
|
64
|
-
var ethThorSynth = new assetValue_ts_1.AssetValue({
|
65
|
-
chain: types_1.Chain.THORChain,
|
66
|
-
symbol: 'ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
|
67
|
-
decimal: 8,
|
68
|
-
value: 1234567890,
|
69
|
-
});
|
70
|
-
(0, vitest_1.expect)(ethThorSynth.toString()).toBe('THOR.ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
|
71
|
-
(0, vitest_1.expect)(ethThorSynth.toString(true)).toBe('ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
|
72
|
-
var atomDerived = new assetValue_ts_1.AssetValue({
|
73
|
-
identifier: 'THOR.ATOM',
|
74
|
-
decimal: 6,
|
75
|
-
value: 123456789,
|
76
|
-
});
|
77
|
-
(0, vitest_1.expect)(atomDerived.toString(true)).toBe('ATOM');
|
78
|
-
(0, vitest_1.expect)(atomDerived.toString()).toBe('THOR.ATOM');
|
79
|
-
});
|
80
|
-
});
|
81
|
-
(0, vitest_1.describe)('toUrl', function () {
|
82
|
-
(0, vitest_1.test)('returns asset compliance with url', function () {
|
83
|
-
var fakeAvaxUSDCAsset = new assetValue_ts_1.AssetValue({
|
84
|
-
decimal: 6,
|
85
|
-
value: 1234567890,
|
86
|
-
chain: types_1.Chain.Avalanche,
|
87
|
-
symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
88
|
-
});
|
89
|
-
(0, vitest_1.expect)(fakeAvaxUSDCAsset.toUrl()).toBe('AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e');
|
90
|
-
var thor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.THOR');
|
91
|
-
(0, vitest_1.expect)(thor.toUrl()).toBe('ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
|
92
|
-
var ethSynth = new assetValue_ts_1.AssetValue({
|
93
|
-
chain: types_1.Chain.THORChain,
|
94
|
-
symbol: 'ETH/ETH',
|
95
|
-
decimal: 8,
|
96
|
-
value: 1234567890,
|
97
|
-
});
|
98
|
-
(0, vitest_1.expect)(ethSynth.toUrl()).toBe('THOR.ETH.ETH');
|
99
|
-
var ethThorSynth = new assetValue_ts_1.AssetValue({
|
100
|
-
chain: types_1.Chain.THORChain,
|
101
|
-
symbol: 'ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
|
102
|
-
decimal: 8,
|
103
|
-
value: 1234567890,
|
104
|
-
});
|
105
|
-
(0, vitest_1.expect)(ethThorSynth.toUrl()).toBe('THOR.ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
|
106
|
-
});
|
107
|
-
});
|
108
|
-
(0, vitest_1.describe)('eq', function () {
|
109
|
-
(0, vitest_1.test)('checks if assets are same chain and symbol', function () {
|
110
|
-
var firstThor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.THOR');
|
111
|
-
var secondThor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.THOR');
|
112
|
-
var vThor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.vTHOR');
|
113
|
-
var firstUsdc = new assetValue_ts_1.AssetValue({
|
114
|
-
chain: types_1.Chain.Avalanche,
|
115
|
-
symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
116
|
-
decimal: 6,
|
117
|
-
value: 1234567890,
|
118
|
-
});
|
119
|
-
var secondUsdc = new assetValue_ts_1.AssetValue({
|
120
|
-
chain: types_1.Chain.Avalanche,
|
121
|
-
symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
122
|
-
decimal: 6,
|
123
|
-
value: 1234,
|
124
|
-
});
|
125
|
-
(0, vitest_1.expect)(firstThor.eq(firstThor)).toBe(true);
|
126
|
-
(0, vitest_1.expect)(firstThor.eq(secondThor)).toBe(true);
|
127
|
-
(0, vitest_1.expect)(firstThor.eq(vThor)).toBe(false);
|
128
|
-
(0, vitest_1.expect)(firstThor.eq(firstUsdc)).toBe(false);
|
129
|
-
(0, vitest_1.expect)(firstThor.eq(secondUsdc)).toBe(false);
|
130
|
-
(0, vitest_1.expect)(firstUsdc.eq(firstThor)).toBe(false);
|
131
|
-
(0, vitest_1.expect)(firstUsdc.eq(secondThor)).toBe(false);
|
132
|
-
(0, vitest_1.expect)(firstUsdc.eq(vThor)).toBe(false);
|
133
|
-
(0, vitest_1.expect)(firstUsdc.eq(firstUsdc)).toBe(true);
|
134
|
-
(0, vitest_1.expect)(firstUsdc.eq(secondUsdc)).toBe(true);
|
135
|
-
});
|
136
|
-
});
|
137
|
-
(0, vitest_1.describe)('from bigint', function () {
|
138
|
-
(0, vitest_1.test)('returns asset value with correct decimal', function () { return __awaiter(void 0, void 0, void 0, function () {
|
139
|
-
var avaxUSDCAsset;
|
140
|
-
return __generator(this, function (_a) {
|
141
|
-
switch (_a.label) {
|
142
|
-
case 0: return [4 /*yield*/, assetValue_ts_1.AssetValue.fromIdentifier("".concat(types_1.Chain.Avalanche, ".USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"), 1234567800n)];
|
143
|
-
case 1:
|
144
|
-
avaxUSDCAsset = _a.sent();
|
145
|
-
(0, vitest_1.expect)(avaxUSDCAsset.getValue('string')).toBe('1234.5678');
|
146
|
-
return [2 /*return*/];
|
147
|
-
}
|
148
|
-
});
|
149
|
-
}); });
|
150
|
-
});
|
151
|
-
(0, vitest_1.describe)('toString', function () {
|
152
|
-
(0, vitest_1.test)('returns asset value string/identifier', function () { return __awaiter(void 0, void 0, void 0, function () {
|
153
|
-
var avaxUSDCAsset, thor, ethSynth;
|
154
|
-
return __generator(this, function (_a) {
|
155
|
-
switch (_a.label) {
|
156
|
-
case 0:
|
157
|
-
avaxUSDCAsset = new assetValue_ts_1.AssetValue({
|
158
|
-
decimal: 6,
|
159
|
-
value: 1234567890,
|
160
|
-
chain: types_1.Chain.Avalanche,
|
161
|
-
symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
162
|
-
});
|
163
|
-
(0, vitest_1.expect)(avaxUSDCAsset.toString()).toBe('AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e');
|
164
|
-
thor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.THOR');
|
165
|
-
(0, vitest_1.expect)(thor.toString()).toBe('ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
|
166
|
-
return [4 /*yield*/, assetValue_ts_1.AssetValue.fromIdentifier('ETH/ETH')];
|
167
|
-
case 1:
|
168
|
-
ethSynth = _a.sent();
|
169
|
-
(0, vitest_1.expect)(ethSynth.toString()).toBe('THOR.ETH/ETH');
|
170
|
-
return [2 /*return*/];
|
171
|
-
}
|
172
|
-
});
|
173
|
-
}); });
|
174
|
-
});
|
175
|
-
(0, vitest_1.describe)('fromIdentifier', function () {
|
176
|
-
(0, vitest_1.test)('creates AssetValue from string', function () { return __awaiter(void 0, void 0, void 0, function () {
|
177
|
-
var avaxUSDCAsset;
|
178
|
-
return __generator(this, function (_a) {
|
179
|
-
switch (_a.label) {
|
180
|
-
case 0: return [4 /*yield*/, assetValue_ts_1.AssetValue.fromIdentifier('AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e')];
|
181
|
-
case 1:
|
182
|
-
avaxUSDCAsset = _a.sent();
|
183
|
-
(0, vitest_1.expect)(avaxUSDCAsset).toEqual(vitest_1.expect.objectContaining({
|
184
|
-
address: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
185
|
-
chain: types_1.Chain.Avalanche,
|
186
|
-
decimal: 6,
|
187
|
-
isGasAsset: false,
|
188
|
-
isSynthetic: false,
|
189
|
-
symbol: 'USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
190
|
-
ticker: 'USDC',
|
191
|
-
}));
|
192
|
-
return [2 /*return*/];
|
193
|
-
}
|
194
|
-
});
|
195
|
-
}); });
|
196
|
-
});
|
197
|
-
(0, vitest_1.describe)('fromString', function () {
|
198
|
-
(0, vitest_1.test)('creates AssetValue from string', function () {
|
199
|
-
(0, vitest_1.test)('creates AssetValue from string', function () { return __awaiter(void 0, void 0, void 0, function () {
|
200
|
-
var fakeAvaxAssetString, fakeAvaxAsset;
|
201
|
-
return __generator(this, function (_a) {
|
202
|
-
switch (_a.label) {
|
203
|
-
case 0:
|
204
|
-
fakeAvaxAssetString = 'AVAX.ASDF-1234';
|
205
|
-
return [4 /*yield*/, assetValue_ts_1.AssetValue.fromString(fakeAvaxAssetString)];
|
206
|
-
case 1:
|
207
|
-
fakeAvaxAsset = _a.sent();
|
208
|
-
(0, vitest_1.expect)(fakeAvaxAsset).toEqual(vitest_1.expect.objectContaining({
|
209
|
-
address: '1234',
|
210
|
-
chain: types_1.Chain.Avalanche,
|
211
|
-
decimal: 10,
|
212
|
-
isGasAsset: false,
|
213
|
-
isSynthetic: false,
|
214
|
-
symbol: 'ASDF-1234',
|
215
|
-
ticker: 'ASDF',
|
216
|
-
}));
|
217
|
-
return [2 /*return*/];
|
218
|
-
}
|
219
|
-
});
|
220
|
-
}); });
|
221
|
-
});
|
222
|
-
});
|
223
|
-
(0, vitest_1.describe)('fromIdentifierSync', function () {
|
224
|
-
(0, vitest_1.test)('(same as fromIdentifier) - creates AssetValue from string via `@coinmasters/tokens` lists', function () { return __awaiter(void 0, void 0, void 0, function () {
|
225
|
-
var thor;
|
226
|
-
return __generator(this, function (_a) {
|
227
|
-
switch (_a.label) {
|
228
|
-
case 0: return [4 /*yield*/, assetValue_ts_1.AssetValue.loadStaticAssets()];
|
229
|
-
case 1:
|
230
|
-
_a.sent();
|
231
|
-
thor = assetValue_ts_1.AssetValue.fromIdentifierSync('ARB.USDT-0XFD086BC7CD5C481DCC9C85EBE478A1C0B69FCBB9');
|
232
|
-
(0, vitest_1.expect)(thor).toBeDefined();
|
233
|
-
(0, vitest_1.expect)(thor).toEqual(vitest_1.expect.objectContaining({
|
234
|
-
address: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
|
235
|
-
chain: types_1.Chain.Arbitrum,
|
236
|
-
decimal: 6,
|
237
|
-
isGasAsset: false,
|
238
|
-
isSynthetic: false,
|
239
|
-
symbol: 'USDT-0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
|
240
|
-
ticker: 'USDT',
|
241
|
-
}));
|
242
|
-
return [2 /*return*/];
|
243
|
-
}
|
244
|
-
});
|
245
|
-
}); });
|
246
|
-
});
|
247
|
-
(0, vitest_1.describe)('fromStringSync', function () {
|
248
|
-
(0, vitest_1.test)('creates AssetValue from string via `@coinmasters/tokens` lists', function () { return __awaiter(void 0, void 0, void 0, function () {
|
249
|
-
var thor;
|
250
|
-
return __generator(this, function (_a) {
|
251
|
-
switch (_a.label) {
|
252
|
-
case 0: return [4 /*yield*/, assetValue_ts_1.AssetValue.loadStaticAssets()];
|
253
|
-
case 1:
|
254
|
-
_a.sent();
|
255
|
-
thor = assetValue_ts_1.AssetValue.fromStringSync('ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044');
|
256
|
-
(0, vitest_1.expect)(thor).toBeDefined();
|
257
|
-
(0, vitest_1.expect)(thor).toEqual(vitest_1.expect.objectContaining({
|
258
|
-
address: '0xa5f2211b9b8170f694421f2046281775e8468044',
|
259
|
-
chain: types_1.Chain.Ethereum,
|
260
|
-
decimal: 18,
|
261
|
-
isGasAsset: false,
|
262
|
-
isSynthetic: false,
|
263
|
-
symbol: 'THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
|
264
|
-
ticker: 'THOR',
|
265
|
-
}));
|
266
|
-
return [2 /*return*/];
|
267
|
-
}
|
268
|
-
});
|
269
|
-
}); });
|
270
|
-
(0, vitest_1.test)('returns undefined if string is not in `@coinmasters/tokens` lists', function () { return __awaiter(void 0, void 0, void 0, function () {
|
271
|
-
var fakeAvaxUSDCAssetString, fakeAvaxUSDCAsset;
|
272
|
-
return __generator(this, function (_a) {
|
273
|
-
switch (_a.label) {
|
274
|
-
case 0: return [4 /*yield*/, assetValue_ts_1.AssetValue.loadStaticAssets()];
|
275
|
-
case 1:
|
276
|
-
_a.sent();
|
277
|
-
fakeAvaxUSDCAssetString = 'AVAX.USDC-1234';
|
278
|
-
fakeAvaxUSDCAsset = assetValue_ts_1.AssetValue.fromStringSync(fakeAvaxUSDCAssetString);
|
279
|
-
(0, vitest_1.expect)(fakeAvaxUSDCAsset).toBeUndefined();
|
280
|
-
return [2 /*return*/];
|
281
|
-
}
|
282
|
-
});
|
283
|
-
}); });
|
284
|
-
});
|
285
|
-
(0, vitest_1.describe)('fromChainOrSignature', function () {
|
286
|
-
(0, vitest_1.test)('creates AssetValue from common asset string or chain', function () {
|
287
|
-
var customBaseAsset = [types_1.Chain.Cosmos, types_1.Chain.BinanceSmartChain, types_1.Chain.THORChain, types_1.Chain.Maya];
|
288
|
-
Object.values(types_1.Chain)
|
289
|
-
.filter(function (c) { return !customBaseAsset.includes(c); })
|
290
|
-
.forEach(function (chain) {
|
291
|
-
var asset = assetValue_ts_1.AssetValue.fromChainOrSignature(chain);
|
292
|
-
(0, vitest_1.expect)(asset).toEqual(vitest_1.expect.objectContaining({
|
293
|
-
address: undefined,
|
294
|
-
chain: chain,
|
295
|
-
decimal: types_1.BaseDecimal[chain],
|
296
|
-
isGasAsset: ![types_1.Chain.Arbitrum, types_1.Chain.Optimism].includes(chain),
|
297
|
-
isSynthetic: false,
|
298
|
-
symbol: chain,
|
299
|
-
ticker: chain,
|
300
|
-
type: 'Native',
|
301
|
-
}));
|
302
|
-
});
|
303
|
-
var cosmosAsset = assetValue_ts_1.AssetValue.fromChainOrSignature(types_1.Chain.Cosmos);
|
304
|
-
(0, vitest_1.expect)(cosmosAsset).toEqual(vitest_1.expect.objectContaining({
|
305
|
-
address: undefined,
|
306
|
-
chain: types_1.Chain.Cosmos,
|
307
|
-
decimal: types_1.BaseDecimal.GAIA,
|
308
|
-
isGasAsset: true,
|
309
|
-
isSynthetic: false,
|
310
|
-
symbol: 'ATOM',
|
311
|
-
ticker: 'ATOM',
|
312
|
-
type: 'Native',
|
313
|
-
}));
|
314
|
-
var bscAsset = assetValue_ts_1.AssetValue.fromChainOrSignature(types_1.Chain.BinanceSmartChain);
|
315
|
-
(0, vitest_1.expect)(bscAsset).toEqual(vitest_1.expect.objectContaining({
|
316
|
-
address: undefined,
|
317
|
-
chain: types_1.Chain.BinanceSmartChain,
|
318
|
-
decimal: types_1.BaseDecimal.BSC,
|
319
|
-
isGasAsset: true,
|
320
|
-
isSynthetic: false,
|
321
|
-
symbol: 'BNB',
|
322
|
-
ticker: 'BNB',
|
323
|
-
type: 'Native',
|
324
|
-
}));
|
325
|
-
var thorAsset = assetValue_ts_1.AssetValue.fromChainOrSignature(types_1.Chain.THORChain);
|
326
|
-
(0, vitest_1.expect)(thorAsset).toEqual(vitest_1.expect.objectContaining({
|
327
|
-
address: undefined,
|
328
|
-
chain: types_1.Chain.THORChain,
|
329
|
-
decimal: types_1.BaseDecimal.THOR,
|
330
|
-
isGasAsset: true,
|
331
|
-
isSynthetic: false,
|
332
|
-
symbol: 'RUNE',
|
333
|
-
ticker: 'RUNE',
|
334
|
-
type: 'Native',
|
335
|
-
}));
|
336
|
-
var cacaoAsset = assetValue_ts_1.AssetValue.fromChainOrSignature(types_1.Chain.Maya);
|
337
|
-
(0, vitest_1.expect)(cacaoAsset).toEqual(vitest_1.expect.objectContaining({
|
338
|
-
address: undefined,
|
339
|
-
chain: types_1.Chain.Maya,
|
340
|
-
decimal: types_1.BaseDecimal.MAYA,
|
341
|
-
isGasAsset: true,
|
342
|
-
isSynthetic: false,
|
343
|
-
symbol: 'CACAO',
|
344
|
-
ticker: 'CACAO',
|
345
|
-
type: 'Native',
|
346
|
-
}));
|
347
|
-
var thor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.THOR');
|
348
|
-
(0, vitest_1.expect)(thor).toEqual(vitest_1.expect.objectContaining({
|
349
|
-
address: '0xa5f2211b9b8170f694421f2046281775e8468044',
|
350
|
-
chain: types_1.Chain.Ethereum,
|
351
|
-
decimal: 18,
|
352
|
-
isGasAsset: false,
|
353
|
-
isSynthetic: false,
|
354
|
-
symbol: 'THOR-0xa5f2211b9b8170f694421f2046281775e8468044',
|
355
|
-
ticker: 'THOR',
|
356
|
-
}));
|
357
|
-
var vthor = assetValue_ts_1.AssetValue.fromChainOrSignature('ETH.vTHOR');
|
358
|
-
(0, vitest_1.expect)(vthor).toEqual(vitest_1.expect.objectContaining({
|
359
|
-
address: '0x815c23eca83261b6ec689b60cc4a58b54bc24d8d',
|
360
|
-
chain: types_1.Chain.Ethereum,
|
361
|
-
decimal: 18,
|
362
|
-
isGasAsset: false,
|
363
|
-
isSynthetic: false,
|
364
|
-
symbol: 'vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d',
|
365
|
-
ticker: 'vTHOR',
|
366
|
-
}));
|
367
|
-
});
|
368
|
-
});
|
369
|
-
(0, vitest_1.describe)('loadStaticAssets', function () {
|
370
|
-
(0, vitest_1.test)('loads static assets from `@coinmasters/tokens` lists', function () { return __awaiter(void 0, void 0, void 0, function () {
|
371
|
-
var ok;
|
372
|
-
return __generator(this, function (_a) {
|
373
|
-
switch (_a.label) {
|
374
|
-
case 0: return [4 /*yield*/, assetValue_ts_1.AssetValue.loadStaticAssets()];
|
375
|
-
case 1:
|
376
|
-
ok = (_a.sent()).ok;
|
377
|
-
(0, vitest_1.expect)(ok).toBe(true);
|
378
|
-
return [2 /*return*/];
|
379
|
-
}
|
380
|
-
});
|
381
|
-
}); });
|
382
|
-
});
|
383
|
-
});
|
384
|
-
(0, vitest_1.describe)('getMinAmountByChain', function () {
|
385
|
-
(0, vitest_1.test)('returns min amount for chain', function () {
|
386
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.THORChain).getValue('string')).toBe('0');
|
387
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Maya).getValue('string')).toBe('0');
|
388
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Cosmos).getValue('string')).toBe('0');
|
389
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Bitcoin).getValue('string')).toBe('0.00010001');
|
390
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Litecoin).getValue('string')).toBe('0.00010001');
|
391
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.BitcoinCash).getValue('string')).toBe('0.00010001');
|
392
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Dogecoin).getValue('string')).toBe('1.00000001');
|
393
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.BinanceSmartChain).getValue('string')).toBe('0.00000001');
|
394
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Ethereum).getValue('string')).toBe('0.00000001');
|
395
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Avalanche).getValue('string')).toBe('0.00000001');
|
396
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Arbitrum).getValue('string')).toBe('0.00000001');
|
397
|
-
(0, vitest_1.expect)((0, assetValue_ts_1.getMinAmountByChain)(types_1.Chain.Optimism).getValue('string')).toBe('0.00000001');
|
398
|
-
});
|
399
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|