@chainflip/utils 0.8.3 → 0.8.5
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/base58.js +2 -2
- package/dist/bytes.cjs +4 -7
- package/dist/bytes.js +1 -1
- package/dist/chainflip.cjs +8 -13
- package/dist/chainflip.d.cts +13 -5
- package/dist/chainflip.d.ts +13 -5
- package/dist/chainflip.js +1 -1
- package/dist/{chunk-HOUVS5DD.js → chunk-3P6TXYEI.js} +1 -1
- package/dist/{chunk-6LZGVCU6.js → chunk-4DFBUXHM.js} +9 -14
- package/dist/{chunk-W23CNAUU.js → chunk-XGNPN5CY.js} +4 -7
- package/dist/ss58.js +2 -2
- package/dist/string.cjs +3 -0
- package/dist/string.d.cts +2 -1
- package/dist/string.d.ts +2 -1
- package/dist/string.js +2 -0
- package/dist/tickMath.cjs +15 -5
- package/dist/tickMath.d.cts +1 -1
- package/dist/tickMath.d.ts +1 -1
- package/dist/tickMath.js +2 -2
- package/package.json +3 -3
package/dist/base58.js
CHANGED
package/dist/bytes.cjs
CHANGED
|
@@ -88,14 +88,11 @@ var decodeBytesWithCharset = (input, charset) => {
|
|
|
88
88
|
const bytes = input.split("").map((char) => charMap[char]);
|
|
89
89
|
return new Uint8Array(convertBase(bytes, charset.length, 256));
|
|
90
90
|
};
|
|
91
|
-
var addPrefix = (input) => {
|
|
92
|
-
const [, bytes] = /^(?:0x)?([a-f\d]*)$/i.exec(input) || [];
|
|
93
|
-
assert(bytes, "Invalid hex string");
|
|
94
|
-
return `0x${bytes}`;
|
|
95
|
-
};
|
|
96
91
|
function reverseBytes(input) {
|
|
97
|
-
const
|
|
98
|
-
|
|
92
|
+
const bytes = /^(?:0x)?([\da-f]+)$/gi.exec(input)?.[1];
|
|
93
|
+
assert(bytes && bytes.length % 2 === 0 && bytes.length > 0, "Invalid hex string");
|
|
94
|
+
const reversed = bytes.match(/.{2}/g).reverse().join("");
|
|
95
|
+
return input.startsWith("0x") ? `0x${reversed}` : reversed;
|
|
99
96
|
}
|
|
100
97
|
// Annotate the CommonJS export names for ESM import in node:
|
|
101
98
|
0 && (module.exports = {
|
package/dist/bytes.js
CHANGED
package/dist/chainflip.cjs
CHANGED
|
@@ -247,19 +247,7 @@ var assetContractId = {
|
|
|
247
247
|
HubUsdt: 12,
|
|
248
248
|
HubUsdc: 13
|
|
249
249
|
};
|
|
250
|
-
function isValidAssetAndChain(assetAndChain) {
|
|
251
|
-
const { asset, chain } = assetAndChain;
|
|
252
|
-
if (!(chain in chainConstants)) return false;
|
|
253
|
-
const validAssets = chainConstants[chain].assets;
|
|
254
|
-
return validAssets.includes(asset);
|
|
255
|
-
}
|
|
256
250
|
function getInternalAsset(asset, assert = true) {
|
|
257
|
-
if (!isValidAssetAndChain(asset)) {
|
|
258
|
-
if (assert) {
|
|
259
|
-
throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
|
|
260
|
-
}
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
251
|
const map = {
|
|
264
252
|
Ethereum: {
|
|
265
253
|
USDC: "Usdc",
|
|
@@ -288,7 +276,14 @@ function getInternalAsset(asset, assert = true) {
|
|
|
288
276
|
}
|
|
289
277
|
};
|
|
290
278
|
const chain = map[asset.chain];
|
|
291
|
-
|
|
279
|
+
const internalAsset = chain?.[asset.asset];
|
|
280
|
+
if (internalAsset) return internalAsset;
|
|
281
|
+
if (assert) throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
function isValidAssetAndChain(assetAndChain) {
|
|
285
|
+
const asset = getInternalAsset(assetAndChain, false);
|
|
286
|
+
return asset !== null;
|
|
292
287
|
}
|
|
293
288
|
function getInternalAssets({
|
|
294
289
|
srcAsset,
|
package/dist/chainflip.d.cts
CHANGED
|
@@ -31,10 +31,16 @@ type BaseChainAssetMap<T> = {
|
|
|
31
31
|
};
|
|
32
32
|
type AssetAndChain = {
|
|
33
33
|
[C in ChainflipChain]: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
[A in keyof ChainAssetMap<unknown>[C]]: {
|
|
35
|
+
chain: C;
|
|
36
|
+
asset: A;
|
|
37
|
+
};
|
|
38
|
+
}[keyof ChainAssetMap<unknown>[C]];
|
|
37
39
|
}[ChainflipChain];
|
|
40
|
+
type BaseAssetAndChain = Exclude<AssetAndChain, {
|
|
41
|
+
chain: 'Ethereum';
|
|
42
|
+
asset: 'USDC';
|
|
43
|
+
}>;
|
|
38
44
|
type ChainMap<T> = {
|
|
39
45
|
[C in ChainflipChain]: T;
|
|
40
46
|
};
|
|
@@ -181,10 +187,12 @@ declare const chainConstants: {
|
|
|
181
187
|
declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
|
|
182
188
|
declare const chainContractId: ChainMap<number>;
|
|
183
189
|
declare const assetContractId: InternalAssetMap<number>;
|
|
184
|
-
declare function
|
|
190
|
+
declare function getInternalAsset(asset: BaseAssetAndChain): BaseChainflipAsset;
|
|
191
|
+
declare function getInternalAsset(asset: AssetAndChain): ChainflipAsset;
|
|
185
192
|
declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
|
|
186
193
|
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
|
|
187
194
|
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
|
|
195
|
+
declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
|
|
188
196
|
declare function getInternalAssets(data: {
|
|
189
197
|
srcAsset: AssetSymbol;
|
|
190
198
|
srcChain: ChainflipChain;
|
|
@@ -213,4 +221,4 @@ declare function getInternalAssets(data: {
|
|
|
213
221
|
destAsset: ChainflipAsset | null;
|
|
214
222
|
};
|
|
215
223
|
|
|
216
|
-
export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
|
|
224
|
+
export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
|
package/dist/chainflip.d.ts
CHANGED
|
@@ -31,10 +31,16 @@ type BaseChainAssetMap<T> = {
|
|
|
31
31
|
};
|
|
32
32
|
type AssetAndChain = {
|
|
33
33
|
[C in ChainflipChain]: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
[A in keyof ChainAssetMap<unknown>[C]]: {
|
|
35
|
+
chain: C;
|
|
36
|
+
asset: A;
|
|
37
|
+
};
|
|
38
|
+
}[keyof ChainAssetMap<unknown>[C]];
|
|
37
39
|
}[ChainflipChain];
|
|
40
|
+
type BaseAssetAndChain = Exclude<AssetAndChain, {
|
|
41
|
+
chain: 'Ethereum';
|
|
42
|
+
asset: 'USDC';
|
|
43
|
+
}>;
|
|
38
44
|
type ChainMap<T> = {
|
|
39
45
|
[C in ChainflipChain]: T;
|
|
40
46
|
};
|
|
@@ -181,10 +187,12 @@ declare const chainConstants: {
|
|
|
181
187
|
declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain>;
|
|
182
188
|
declare const chainContractId: ChainMap<number>;
|
|
183
189
|
declare const assetContractId: InternalAssetMap<number>;
|
|
184
|
-
declare function
|
|
190
|
+
declare function getInternalAsset(asset: BaseAssetAndChain): BaseChainflipAsset;
|
|
191
|
+
declare function getInternalAsset(asset: AssetAndChain): ChainflipAsset;
|
|
185
192
|
declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
|
|
186
193
|
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
|
|
187
194
|
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
|
|
195
|
+
declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
|
|
188
196
|
declare function getInternalAssets(data: {
|
|
189
197
|
srcAsset: AssetSymbol;
|
|
190
198
|
srcChain: ChainflipChain;
|
|
@@ -213,4 +221,4 @@ declare function getInternalAssets(data: {
|
|
|
213
221
|
destAsset: ChainflipAsset | null;
|
|
214
222
|
};
|
|
215
223
|
|
|
216
|
-
export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
|
|
224
|
+
export { type AddressType, type AssetAndChain, type AssetOfChain, type AssetSymbol, type BaseAssetAndChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, type InternalAssetMap, type RpcAsset, type UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, readAssetValue, rpcAssets };
|
package/dist/chainflip.js
CHANGED
|
@@ -207,19 +207,7 @@ var assetContractId = {
|
|
|
207
207
|
HubUsdt: 12,
|
|
208
208
|
HubUsdc: 13
|
|
209
209
|
};
|
|
210
|
-
function isValidAssetAndChain(assetAndChain) {
|
|
211
|
-
const { asset, chain } = assetAndChain;
|
|
212
|
-
if (!(chain in chainConstants)) return false;
|
|
213
|
-
const validAssets = chainConstants[chain].assets;
|
|
214
|
-
return validAssets.includes(asset);
|
|
215
|
-
}
|
|
216
210
|
function getInternalAsset(asset, assert = true) {
|
|
217
|
-
if (!isValidAssetAndChain(asset)) {
|
|
218
|
-
if (assert) {
|
|
219
|
-
throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
211
|
const map = {
|
|
224
212
|
Ethereum: {
|
|
225
213
|
USDC: "Usdc",
|
|
@@ -248,7 +236,14 @@ function getInternalAsset(asset, assert = true) {
|
|
|
248
236
|
}
|
|
249
237
|
};
|
|
250
238
|
const chain = map[asset.chain];
|
|
251
|
-
|
|
239
|
+
const internalAsset = chain?.[asset.asset];
|
|
240
|
+
if (internalAsset) return internalAsset;
|
|
241
|
+
if (assert) throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
function isValidAssetAndChain(assetAndChain) {
|
|
245
|
+
const asset = getInternalAsset(assetAndChain, false);
|
|
246
|
+
return asset !== null;
|
|
252
247
|
}
|
|
253
248
|
function getInternalAssets({
|
|
254
249
|
srcAsset,
|
|
@@ -277,7 +272,7 @@ export {
|
|
|
277
272
|
internalAssetToRpcAsset,
|
|
278
273
|
chainContractId,
|
|
279
274
|
assetContractId,
|
|
280
|
-
isValidAssetAndChain,
|
|
281
275
|
getInternalAsset,
|
|
276
|
+
isValidAssetAndChain,
|
|
282
277
|
getInternalAssets
|
|
283
278
|
};
|
|
@@ -45,14 +45,11 @@ var decodeBytesWithCharset = (input, charset) => {
|
|
|
45
45
|
const bytes = input.split("").map((char) => charMap[char]);
|
|
46
46
|
return new Uint8Array(convertBase(bytes, charset.length, 256));
|
|
47
47
|
};
|
|
48
|
-
var addPrefix = (input) => {
|
|
49
|
-
const [, bytes] = /^(?:0x)?([a-f\d]*)$/i.exec(input) || [];
|
|
50
|
-
assert(bytes, "Invalid hex string");
|
|
51
|
-
return `0x${bytes}`;
|
|
52
|
-
};
|
|
53
48
|
function reverseBytes(input) {
|
|
54
|
-
const
|
|
55
|
-
|
|
49
|
+
const bytes = /^(?:0x)?([\da-f]+)$/gi.exec(input)?.[1];
|
|
50
|
+
assert(bytes && bytes.length % 2 === 0 && bytes.length > 0, "Invalid hex string");
|
|
51
|
+
const reversed = bytes.match(/.{2}/g).reverse().join("");
|
|
52
|
+
return input.startsWith("0x") ? `0x${reversed}` : reversed;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
export {
|
package/dist/ss58.js
CHANGED
package/dist/string.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var string_exports = {};
|
|
|
22
22
|
__export(string_exports, {
|
|
23
23
|
abbreviate: () => abbreviate,
|
|
24
24
|
capitalize: () => capitalize,
|
|
25
|
+
isBytes: () => isBytes,
|
|
25
26
|
isHex: () => isHex,
|
|
26
27
|
isInteger: () => isInteger,
|
|
27
28
|
split: () => split,
|
|
@@ -38,6 +39,7 @@ var split = (str, delimiter) => str.split(delimiter);
|
|
|
38
39
|
var capitalize = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
|
|
39
40
|
var uncapitalize = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
40
41
|
var isHex = (str) => /^0x[\da-f]+$/i.test(str);
|
|
42
|
+
var isBytes = (str) => /^(0x)?[\da-f]*$/i.test(str) && str.length % 2 === 0;
|
|
41
43
|
var abbreviate = (text, showLength = 4, space = false) => {
|
|
42
44
|
if (typeof text !== "string") return "";
|
|
43
45
|
const leftPart = text.slice(0, showLength);
|
|
@@ -56,6 +58,7 @@ var truncateString = (string, numCharacters = 20, ellipsis = true) => {
|
|
|
56
58
|
0 && (module.exports = {
|
|
57
59
|
abbreviate,
|
|
58
60
|
capitalize,
|
|
61
|
+
isBytes,
|
|
59
62
|
isHex,
|
|
60
63
|
isInteger,
|
|
61
64
|
split,
|
package/dist/string.d.cts
CHANGED
|
@@ -9,7 +9,8 @@ declare const split: <const T extends string, D extends string>(str: T, delimite
|
|
|
9
9
|
declare const capitalize: <const T extends string>(str: T) => Capitalize<T>;
|
|
10
10
|
declare const uncapitalize: <const T extends string>(str: T) => Uncapitalize<T>;
|
|
11
11
|
declare const isHex: (str: string) => str is HexString;
|
|
12
|
+
declare const isBytes: (str: string) => boolean;
|
|
12
13
|
declare const abbreviate: (text: string | undefined | null, showLength?: number, space?: boolean) => string;
|
|
13
14
|
declare const truncateString: (string: string, numCharacters?: number, ellipsis?: boolean) => string;
|
|
14
15
|
|
|
15
|
-
export { abbreviate, capitalize, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
|
|
16
|
+
export { abbreviate, capitalize, isBytes, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
|
package/dist/string.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ declare const split: <const T extends string, D extends string>(str: T, delimite
|
|
|
9
9
|
declare const capitalize: <const T extends string>(str: T) => Capitalize<T>;
|
|
10
10
|
declare const uncapitalize: <const T extends string>(str: T) => Uncapitalize<T>;
|
|
11
11
|
declare const isHex: (str: string) => str is HexString;
|
|
12
|
+
declare const isBytes: (str: string) => boolean;
|
|
12
13
|
declare const abbreviate: (text: string | undefined | null, showLength?: number, space?: boolean) => string;
|
|
13
14
|
declare const truncateString: (string: string, numCharacters?: number, ellipsis?: boolean) => string;
|
|
14
15
|
|
|
15
|
-
export { abbreviate, capitalize, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
|
|
16
|
+
export { abbreviate, capitalize, isBytes, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
|
package/dist/string.js
CHANGED
|
@@ -6,6 +6,7 @@ var split = (str, delimiter) => str.split(delimiter);
|
|
|
6
6
|
var capitalize = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
|
|
7
7
|
var uncapitalize = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
8
8
|
var isHex = (str) => /^0x[\da-f]+$/i.test(str);
|
|
9
|
+
var isBytes = (str) => /^(0x)?[\da-f]*$/i.test(str) && str.length % 2 === 0;
|
|
9
10
|
var abbreviate = (text, showLength = 4, space = false) => {
|
|
10
11
|
if (typeof text !== "string") return "";
|
|
11
12
|
const leftPart = text.slice(0, showLength);
|
|
@@ -23,6 +24,7 @@ var truncateString = (string, numCharacters = 20, ellipsis = true) => {
|
|
|
23
24
|
export {
|
|
24
25
|
abbreviate,
|
|
25
26
|
capitalize,
|
|
27
|
+
isBytes,
|
|
26
28
|
isHex,
|
|
27
29
|
isInteger,
|
|
28
30
|
split,
|
package/dist/tickMath.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/tickMath.ts
|
|
@@ -29,7 +39,7 @@ __export(tickMath_exports, {
|
|
|
29
39
|
tickToRate: () => tickToRate
|
|
30
40
|
});
|
|
31
41
|
module.exports = __toCommonJS(tickMath_exports);
|
|
32
|
-
var import_bignumber = require("bignumber.js");
|
|
42
|
+
var import_bignumber = __toESM(require("bignumber.js"), 1);
|
|
33
43
|
|
|
34
44
|
// src/chainflip.ts
|
|
35
45
|
var chainflipAssets = [
|
|
@@ -200,20 +210,20 @@ var MIN_TICK = -887272;
|
|
|
200
210
|
var MAX_TICK = -MIN_TICK;
|
|
201
211
|
var FULL_TICK_RANGE = { start: MIN_TICK, end: MAX_TICK };
|
|
202
212
|
var tickToRate = (tick, baseAsset) => {
|
|
203
|
-
const baseRate = new import_bignumber.
|
|
213
|
+
const baseRate = new import_bignumber.default(1.0001 ** tick);
|
|
204
214
|
const rateDecimals = assetConstants.Usdc.decimals - assetConstants[baseAsset].decimals;
|
|
205
215
|
return baseRate.shiftedBy(-rateDecimals).toNumber();
|
|
206
216
|
};
|
|
207
217
|
var rateToTick = (rate, baseAsset) => {
|
|
208
218
|
const rateDecimals = assetConstants.Usdc.decimals - assetConstants[baseAsset].decimals;
|
|
209
|
-
const rawRate = new import_bignumber.
|
|
219
|
+
const rawRate = new import_bignumber.default(rate).shiftedBy(rateDecimals);
|
|
210
220
|
let tick = Math.log(rawRate.toNumber()) / Math.log(1.0001);
|
|
211
221
|
tick = Math.round(tick * 1e6) / 1e6;
|
|
212
222
|
tick = Math.floor(tick);
|
|
213
223
|
return Math.max(MIN_TICK, Math.min(tick, MAX_TICK));
|
|
214
224
|
};
|
|
215
|
-
var sqrtPriceX96ToPrice = (amount) => new import_bignumber.
|
|
216
|
-
var priceX128ToPrice = (amount) => new import_bignumber.
|
|
225
|
+
var sqrtPriceX96ToPrice = (amount) => new import_bignumber.default(amount).div(new import_bignumber.default(2).pow(96)).pow(2);
|
|
226
|
+
var priceX128ToPrice = (amount) => new import_bignumber.default(amount).div(new import_bignumber.default(2).pow(128));
|
|
217
227
|
// Annotate the CommonJS export names for ESM import in node:
|
|
218
228
|
0 && (module.exports = {
|
|
219
229
|
FULL_TICK_RANGE,
|
package/dist/tickMath.d.cts
CHANGED
package/dist/tickMath.d.ts
CHANGED
package/dist/tickMath.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assetConstants
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4DFBUXHM.js";
|
|
4
4
|
|
|
5
5
|
// src/tickMath.ts
|
|
6
|
-
import
|
|
6
|
+
import BigNumber from "bignumber.js";
|
|
7
7
|
var MIN_TICK = -887272;
|
|
8
8
|
var MAX_TICK = -MIN_TICK;
|
|
9
9
|
var FULL_TICK_RANGE = { start: MIN_TICK, end: MAX_TICK };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/utils",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@noble/hashes": "^1.7.1",
|
|
23
|
-
"@vitest/ui": "3.
|
|
23
|
+
"@vitest/ui": "3.1.1"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@date-fns/utc": "^2.1.0",
|
|
27
|
-
"bignumber.js": "^9.
|
|
27
|
+
"bignumber.js": "^9.2.0",
|
|
28
28
|
"date-fns": "4.1.0"
|
|
29
29
|
},
|
|
30
30
|
"repository": "https://github.com/chainflip-io/chainflip-product-toolkit.git",
|