@swapkit/helpers 1.0.0-rc.51 → 1.0.0-rc.53
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 +35 -36
- package/dist/index.es.js +439 -395
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/liquidity.ts +35 -29
- package/src/helpers/memo.ts +2 -11
- package/src/helpers/others.ts +6 -6
- package/src/helpers/validators.ts +4 -3
- package/src/modules/__tests__/bigIntArithmetics.test.ts +30 -0
- package/src/modules/assetValue.ts +80 -110
- package/src/modules/bigIntArithmetics.ts +1 -0
- package/src/types.ts +28 -0
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,19 @@ export declare class AssetValue extends BigIntArithmetics {
|
|
|
32
32
|
tax?: TokenTax;
|
|
33
33
|
ticker: string;
|
|
34
34
|
type: ReturnType<typeof getAssetType>;
|
|
35
|
-
constructor(
|
|
35
|
+
constructor({ value, decimal, tax, chain, symbol, identifier, }: {
|
|
36
|
+
decimal: number;
|
|
37
|
+
value: SwapKitValueType;
|
|
38
|
+
tax?: TokenTax;
|
|
39
|
+
} & ({
|
|
40
|
+
chain: Chain;
|
|
41
|
+
symbol: string;
|
|
42
|
+
identifier?: never;
|
|
43
|
+
} | {
|
|
44
|
+
identifier: string;
|
|
45
|
+
chain?: never;
|
|
46
|
+
symbol?: never;
|
|
47
|
+
}));
|
|
36
48
|
toString(): string;
|
|
37
49
|
toUrl(): string;
|
|
38
50
|
eq({ chain, symbol }: {
|
|
@@ -41,9 +53,9 @@ export declare class AssetValue extends BigIntArithmetics {
|
|
|
41
53
|
}): boolean;
|
|
42
54
|
static fromUrl(urlAsset: string, value?: NumberPrimitives): Promise<AssetValue>;
|
|
43
55
|
static fromString(assetString: string, value?: NumberPrimitives): Promise<AssetValue>;
|
|
56
|
+
static fromIdentifier(assetString: `${Chain}.${string}` | `${Chain}/${string}` | `${Chain}.${string}-${string}` | TokenNames, value?: NumberPrimitives): Promise<AssetValue>;
|
|
44
57
|
static fromStringSync(assetString: string, value?: NumberPrimitives): AssetValue | undefined;
|
|
45
|
-
static
|
|
46
|
-
static fromIdentifierSync(identifier: TokenNames, value?: NumberPrimitives): AssetValue;
|
|
58
|
+
static fromIdentifierSync(assetString: TokenNames, value?: NumberPrimitives): AssetValue | undefined;
|
|
47
59
|
static fromChainOrSignature(assetString: CommonAssetString, value?: NumberPrimitives): AssetValue;
|
|
48
60
|
static loadStaticAssets(): Promise<{
|
|
49
61
|
ok: true;
|
|
@@ -54,17 +66,6 @@ export declare class AssetValue extends BigIntArithmetics {
|
|
|
54
66
|
}>;
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
declare type AssetValueParams = {
|
|
58
|
-
decimal: number;
|
|
59
|
-
value: SwapKitValueType;
|
|
60
|
-
tax?: TokenTax;
|
|
61
|
-
} & ({
|
|
62
|
-
chain: Chain;
|
|
63
|
-
symbol: string;
|
|
64
|
-
} | {
|
|
65
|
-
identifier: string;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
69
|
export declare class BigIntArithmetics {
|
|
69
70
|
|
|
70
71
|
decimalMultiplier: bigint;
|
|
@@ -104,7 +105,7 @@ export declare class BigIntArithmetics {
|
|
|
104
105
|
|
|
105
106
|
export declare type CommonAssetString = 'MAYA.MAYA' | 'ETH.THOR' | 'ETH.vTHOR' | Chain;
|
|
106
107
|
|
|
107
|
-
export declare
|
|
108
|
+
export declare function derivationPathToString([network, chainId, account, change, index]: number[]): string;
|
|
108
109
|
|
|
109
110
|
declare const errorMessages: {
|
|
110
111
|
/**
|
|
@@ -190,14 +191,14 @@ export declare const getAssetType: ({ chain, symbol }: {
|
|
|
190
191
|
symbol: string;
|
|
191
192
|
}) => Chain.Avalanche | Chain.Cosmos | Chain.Kujira | "Synth" | "Native" | "BEP2" | "BEP20" | "ERC20" | "POLYGON" | "ARBITRUM" | "OPTIMISM";
|
|
192
193
|
|
|
193
|
-
export declare
|
|
194
|
+
export declare function getAsymmetricAssetShare({ liquidityUnits, poolUnits, assetDepth, }: ShareParams<{
|
|
194
195
|
assetDepth: string;
|
|
195
|
-
}>)
|
|
196
|
+
}>): SwapKitNumber;
|
|
196
197
|
|
|
197
|
-
export declare
|
|
198
|
+
export declare function getAsymmetricAssetWithdrawAmount({ percent, assetDepth, liquidityUnits, poolUnits, }: ShareParams<{
|
|
198
199
|
percent: number;
|
|
199
200
|
assetDepth: string;
|
|
200
|
-
}>)
|
|
201
|
+
}>): SwapKitNumber;
|
|
201
202
|
|
|
202
203
|
/**
|
|
203
204
|
* Ref: https://gitlab.com/thorchain/thornode/-/issues/657
|
|
@@ -210,14 +211,14 @@ export declare const getAsymmetricAssetWithdrawAmount: ({ percent, assetDepth, l
|
|
|
210
211
|
* share = (s * A * (2 * T^2 - 2 * T * s + s^2))/T^3
|
|
211
212
|
* (part1 * (part2 - part3 + part4)) / part5
|
|
212
213
|
*/
|
|
213
|
-
export declare
|
|
214
|
+
export declare function getAsymmetricRuneShare({ liquidityUnits, poolUnits, runeDepth, }: ShareParams<{
|
|
214
215
|
runeDepth: string;
|
|
215
|
-
}>)
|
|
216
|
+
}>): SwapKitNumber;
|
|
216
217
|
|
|
217
|
-
export declare
|
|
218
|
+
export declare function getAsymmetricRuneWithdrawAmount({ percent, runeDepth, liquidityUnits, poolUnits, }: ShareParams<{
|
|
218
219
|
percent: number;
|
|
219
220
|
runeDepth: string;
|
|
220
|
-
}>)
|
|
221
|
+
}>): SwapKitNumber;
|
|
221
222
|
|
|
222
223
|
export declare const getCommonAssetInfo: (assetString: CommonAssetString) => {
|
|
223
224
|
identifier: string;
|
|
@@ -229,36 +230,36 @@ export declare const getDecimal: ({ chain, symbol }: {
|
|
|
229
230
|
symbol: string;
|
|
230
231
|
}) => Promise<number>;
|
|
231
232
|
|
|
232
|
-
export declare
|
|
233
|
+
export declare function getEstimatedPoolShare({ runeDepth, poolUnits, assetDepth, liquidityUnits, runeAmount, assetAmount, }: ShareParams<{
|
|
233
234
|
runeAmount: string;
|
|
234
235
|
assetAmount: string;
|
|
235
236
|
runeDepth: string;
|
|
236
237
|
assetDepth: string;
|
|
237
|
-
}>)
|
|
238
|
+
}>): number;
|
|
238
239
|
|
|
239
|
-
export declare
|
|
240
|
+
export declare function getLiquiditySlippage({ runeAmount, assetAmount, runeDepth, assetDepth, }: PoolParams): number;
|
|
240
241
|
|
|
241
242
|
export declare const getMemoFor: <T extends MemoType>(memoType: T, options: MemoOptions<T>) => string;
|
|
242
243
|
|
|
243
|
-
export declare
|
|
244
|
+
export declare function getMinAmountByChain(chain: Chain): AssetValue;
|
|
244
245
|
|
|
245
|
-
export declare
|
|
246
|
+
export declare function getSymmetricPoolShare({ liquidityUnits, poolUnits, runeDepth, assetDepth, }: ShareParams<{
|
|
246
247
|
runeDepth: string;
|
|
247
248
|
assetDepth: string;
|
|
248
|
-
}>)
|
|
249
|
+
}>): {
|
|
249
250
|
assetAmount: SwapKitNumber;
|
|
250
251
|
runeAmount: SwapKitNumber;
|
|
251
252
|
};
|
|
252
253
|
|
|
253
|
-
export declare
|
|
254
|
+
export declare function getSymmetricWithdraw({ liquidityUnits, poolUnits, runeDepth, assetDepth, percent, }: ShareParams<{
|
|
254
255
|
runeDepth: string;
|
|
255
256
|
assetDepth: string;
|
|
256
257
|
percent: number;
|
|
257
|
-
}>)
|
|
258
|
+
}>): {
|
|
258
259
|
[k: string]: SwapKitNumber;
|
|
259
260
|
};
|
|
260
261
|
|
|
261
|
-
export declare
|
|
262
|
+
export declare function getTHORNameCost(year: number): number;
|
|
262
263
|
|
|
263
264
|
declare type InitialisationValueType = NumberPrimitives | BigIntArithmetics | SwapKitNumber;
|
|
264
265
|
|
|
@@ -339,8 +340,6 @@ export declare class SwapKitNumber extends BigIntArithmetics {
|
|
|
339
340
|
|
|
340
341
|
export declare type SwapKitValueType = BigIntArithmetics | string | number;
|
|
341
342
|
|
|
342
|
-
declare type TCTokenNames = (typeof ThorchainList)['tokens'][number]['identifier'];
|
|
343
|
-
|
|
344
343
|
export declare type ThornameRegisterParam = {
|
|
345
344
|
name: string;
|
|
346
345
|
chain: string;
|
|
@@ -350,14 +349,14 @@ export declare type ThornameRegisterParam = {
|
|
|
350
349
|
expiryBlock?: string;
|
|
351
350
|
};
|
|
352
351
|
|
|
353
|
-
declare type TokenNames =
|
|
352
|
+
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'];
|
|
354
353
|
|
|
355
354
|
declare type TokenTax = {
|
|
356
355
|
buy: number;
|
|
357
356
|
sell: number;
|
|
358
357
|
};
|
|
359
358
|
|
|
360
|
-
export declare
|
|
359
|
+
export declare function validateTHORName(name: string): boolean;
|
|
361
360
|
|
|
362
361
|
declare type WithAddress<T = {}> = T & {
|
|
363
362
|
address: string;
|