@swapkit/helpers 1.0.0-rc.71 → 1.0.0-rc.73
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -19
- package/dist/index.es.js +376 -361
- package/dist/index.es.js.map +1 -1
- package/package.json +12 -16
- package/src/helpers/__tests__/asset.test.ts +64 -62
- package/src/helpers/__tests__/memo.test.ts +42 -40
- package/src/helpers/__tests__/others.test.ts +31 -31
- package/src/helpers/asset.ts +53 -52
- package/src/helpers/liquidity.ts +9 -9
- package/src/helpers/memo.ts +17 -18
- package/src/helpers/others.ts +3 -3
- package/src/helpers/validators.ts +5 -5
- package/src/index.ts +9 -9
- package/src/modules/__tests__/assetValue.test.ts +187 -173
- package/src/modules/__tests__/bigIntArithmetics.test.ts +8 -8
- package/src/modules/__tests__/swapKitNumber.test.ts +232 -232
- package/src/modules/assetValue.ts +41 -41
- package/src/modules/bigIntArithmetics.ts +86 -86
- package/src/modules/swapKitError.ts +18 -2
- package/src/modules/swapKitNumber.ts +1 -1
- package/src/types.ts +13 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseDecimal } from '@swapkit/types';
|
|
1
2
|
import { Chain } from '@swapkit/types';
|
|
2
3
|
import type { ChainflipList } from '@swapkit/tokens';
|
|
3
4
|
import { ChainId } from '@swapkit/types';
|
|
@@ -15,7 +16,7 @@ import type { TraderjoeList } from '@swapkit/tokens';
|
|
|
15
16
|
import type { UniswapList } from '@swapkit/tokens';
|
|
16
17
|
import type { WoofiList } from '@swapkit/tokens';
|
|
17
18
|
|
|
18
|
-
declare type AllowedNumberTypes =
|
|
19
|
+
declare type AllowedNumberTypes = "bigint" | "number" | "string";
|
|
19
20
|
|
|
20
21
|
export declare const assetFromString: (assetString: string) => {
|
|
21
22
|
chain: Chain;
|
|
@@ -146,6 +147,7 @@ declare const errorMessages: {
|
|
|
146
147
|
readonly core_swap_contract_not_supported: 10205;
|
|
147
148
|
readonly core_swap_transaction_error: 10206;
|
|
148
149
|
readonly core_swap_quote_mode_not_supported: 10207;
|
|
150
|
+
readonly core_swap_provider_not_found: 10208;
|
|
149
151
|
/**
|
|
150
152
|
* Core - Transaction
|
|
151
153
|
*/
|
|
@@ -172,6 +174,14 @@ declare const errorMessages: {
|
|
|
172
174
|
readonly wallet_ledger_get_address_error: 20003;
|
|
173
175
|
readonly wallet_ledger_device_not_found: 20004;
|
|
174
176
|
readonly wallet_ledger_device_locked: 20005;
|
|
177
|
+
/**
|
|
178
|
+
* Chainflip
|
|
179
|
+
*/
|
|
180
|
+
readonly chainflip_channel_error: 30001;
|
|
181
|
+
readonly chainflip_broker_recipient_error: 30002;
|
|
182
|
+
/**
|
|
183
|
+
* THORChain
|
|
184
|
+
*/
|
|
175
185
|
/**
|
|
176
186
|
* Helpers
|
|
177
187
|
*/
|
|
@@ -240,7 +250,7 @@ export declare const getCommonAssetInfo: (assetString: CommonAssetString) => {
|
|
|
240
250
|
export declare const getDecimal: ({ chain, symbol }: {
|
|
241
251
|
chain: Chain;
|
|
242
252
|
symbol: string;
|
|
243
|
-
}) => Promise<number>;
|
|
253
|
+
}) => BaseDecimal | Promise<number>;
|
|
244
254
|
|
|
245
255
|
export declare function getEstimatedPoolShare({ runeDepth, poolUnits, assetDepth, liquidityUnits, runeAmount, assetAmount, }: ShareParams<{
|
|
246
256
|
runeAmount: string;
|
|
@@ -281,19 +291,26 @@ export declare const isGasAsset: ({ chain, symbol }: {
|
|
|
281
291
|
}) => boolean;
|
|
282
292
|
|
|
283
293
|
export declare type MemoOptions<T extends MemoType> = {
|
|
284
|
-
[MemoType.BOND]:
|
|
285
|
-
|
|
286
|
-
|
|
294
|
+
[MemoType.BOND]: {
|
|
295
|
+
address: string;
|
|
296
|
+
};
|
|
297
|
+
[MemoType.LEAVE]: {
|
|
298
|
+
address: string;
|
|
299
|
+
};
|
|
300
|
+
[MemoType.CLOSE_LOAN]: {
|
|
301
|
+
address: string;
|
|
287
302
|
asset: string;
|
|
288
303
|
minAmount?: string;
|
|
289
|
-
}
|
|
290
|
-
[MemoType.OPEN_LOAN]:
|
|
304
|
+
};
|
|
305
|
+
[MemoType.OPEN_LOAN]: {
|
|
306
|
+
address: string;
|
|
291
307
|
asset: string;
|
|
292
308
|
minAmount?: string;
|
|
293
|
-
}
|
|
294
|
-
[MemoType.UNBOND]:
|
|
309
|
+
};
|
|
310
|
+
[MemoType.UNBOND]: {
|
|
311
|
+
address: string;
|
|
295
312
|
unbondAmount: number;
|
|
296
|
-
}
|
|
313
|
+
};
|
|
297
314
|
[MemoType.DEPOSIT]: WithChain<{
|
|
298
315
|
symbol: string;
|
|
299
316
|
address?: string;
|
|
@@ -306,7 +323,7 @@ export declare type MemoOptions<T extends MemoType> = {
|
|
|
306
323
|
targetAssetString?: string;
|
|
307
324
|
singleSide?: boolean;
|
|
308
325
|
}>;
|
|
309
|
-
[MemoType.THORNAME_REGISTER]: Omit<ThornameRegisterParam,
|
|
326
|
+
[MemoType.THORNAME_REGISTER]: Omit<ThornameRegisterParam, "preferredAsset" | "expiryBlock">;
|
|
310
327
|
}[T];
|
|
311
328
|
|
|
312
329
|
export declare type NumberPrimitives = bigint | number | string;
|
|
@@ -317,14 +334,14 @@ declare type NumberPrimitivesType = {
|
|
|
317
334
|
string: string;
|
|
318
335
|
};
|
|
319
336
|
|
|
320
|
-
declare type PoolParams
|
|
337
|
+
declare type PoolParams = {
|
|
321
338
|
runeAmount: string;
|
|
322
339
|
assetAmount: string;
|
|
323
340
|
runeDepth: string;
|
|
324
341
|
assetDepth: string;
|
|
325
342
|
};
|
|
326
343
|
|
|
327
|
-
declare type ShareParams<T
|
|
344
|
+
declare type ShareParams<T extends {}> = T & {
|
|
328
345
|
liquidityUnits: string;
|
|
329
346
|
poolUnits: string;
|
|
330
347
|
};
|
|
@@ -354,7 +371,7 @@ export declare type ThornameRegisterParam = {
|
|
|
354
371
|
expiryBlock?: string;
|
|
355
372
|
};
|
|
356
373
|
|
|
357
|
-
declare type TokenNames = (typeof ThorchainList)[
|
|
374
|
+
declare type TokenNames = (typeof ThorchainList)["tokens"][number]["identifier"] | (typeof CoinGeckoList)["tokens"][number]["identifier"] | (typeof MayaList)["tokens"][number]["identifier"] | (typeof PancakeswapETHList)["tokens"][number]["identifier"] | (typeof PancakeswapList)["tokens"][number]["identifier"] | (typeof PangolinList)["tokens"][number]["identifier"] | (typeof StargateARBList)["tokens"][number]["identifier"] | (typeof SushiswapList)["tokens"][number]["identifier"] | (typeof TraderjoeList)["tokens"][number]["identifier"] | (typeof WoofiList)["tokens"][number]["identifier"] | (typeof UniswapList)["tokens"][number]["identifier"] | (typeof ChainflipList)["tokens"][number]["identifier"];
|
|
358
375
|
|
|
359
376
|
declare type TokenTax = {
|
|
360
377
|
buy: number;
|
|
@@ -363,11 +380,7 @@ declare type TokenTax = {
|
|
|
363
380
|
|
|
364
381
|
export declare function validateTHORName(name: string): boolean;
|
|
365
382
|
|
|
366
|
-
declare type
|
|
367
|
-
address: string;
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
declare type WithChain<T = {}> = T & {
|
|
383
|
+
declare type WithChain<T extends {}> = T & {
|
|
371
384
|
chain: Chain;
|
|
372
385
|
};
|
|
373
386
|
|