@injectivelabs/utils 1.16.23 → 1.16.25-alpha.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/dist/cjs/constants-DEbTiKzu.cjs +192 -0
- package/dist/cjs/index.cjs +586 -0
- package/dist/cjs/index.d.cts +279 -0
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/test-utils/index.cjs +161 -0
- package/dist/cjs/test-utils/index.d.cts +218 -0
- package/dist/esm/constants-BxcSsKjm.js +66 -0
- package/dist/esm/index.d.ts +279 -6
- package/dist/esm/index.js +509 -6
- package/dist/esm/package.json +2 -2
- package/dist/esm/test-utils/index.d.ts +218 -2
- package/dist/esm/test-utils/index.js +157 -2
- package/package.json +16 -16
- package/dist/cjs/classes/BigNumber.d.ts +0 -14
- package/dist/cjs/classes/BigNumber.js +0 -33
- package/dist/cjs/classes/BigNumberInBase.d.ts +0 -16
- package/dist/cjs/classes/BigNumberInBase.js +0 -39
- package/dist/cjs/classes/BigNumberInWei.d.ts +0 -16
- package/dist/cjs/classes/BigNumberInWei.js +0 -39
- package/dist/cjs/classes/HttpClient.d.ts +0 -11
- package/dist/cjs/classes/HttpClient.js +0 -39
- package/dist/cjs/classes/HttpRestClient.d.ts +0 -14
- package/dist/cjs/classes/HttpRestClient.js +0 -110
- package/dist/cjs/classes/LocalStorage.d.ts +0 -9
- package/dist/cjs/classes/LocalStorage.js +0 -25
- package/dist/cjs/classes/Status.d.ts +0 -22
- package/dist/cjs/classes/Status.js +0 -61
- package/dist/cjs/classes/StreamManager.d.ts +0 -9
- package/dist/cjs/classes/StreamManager.js +0 -41
- package/dist/cjs/classes/index.d.ts +0 -10
- package/dist/cjs/classes/index.js +0 -60
- package/dist/cjs/constants.d.ts +0 -37
- package/dist/cjs/constants.js +0 -54
- package/dist/cjs/enum.d.ts +0 -8
- package/dist/cjs/enum.js +0 -10
- package/dist/cjs/formatters.d.ts +0 -5
- package/dist/cjs/formatters.js +0 -31
- package/dist/cjs/helpers.d.ts +0 -73
- package/dist/cjs/helpers.js +0 -145
- package/dist/cjs/index.d.ts +0 -6
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/numbers.d.ts +0 -4
- package/dist/cjs/numbers.js +0 -37
- package/dist/cjs/test-utils/index.d.ts +0 -2
- package/dist/cjs/test-utils/index.js +0 -18
- package/dist/cjs/test-utils/mocks/index.d.ts +0 -153
- package/dist/cjs/test-utils/mocks/index.js +0 -106
- package/dist/cjs/test-utils/msgs.d.ts +0 -44
- package/dist/cjs/test-utils/msgs.js +0 -54
- package/dist/cjs/time.d.ts +0 -9
- package/dist/cjs/time.js +0 -41
- package/dist/cjs/types.d.ts +0 -3
- package/dist/cjs/types.js +0 -2
- package/dist/esm/classes/BigNumber.d.ts +0 -14
- package/dist/esm/classes/BigNumber.js +0 -27
- package/dist/esm/classes/BigNumberInBase.d.ts +0 -16
- package/dist/esm/classes/BigNumberInBase.js +0 -33
- package/dist/esm/classes/BigNumberInWei.d.ts +0 -16
- package/dist/esm/classes/BigNumberInWei.js +0 -33
- package/dist/esm/classes/HttpClient.d.ts +0 -11
- package/dist/esm/classes/HttpClient.js +0 -33
- package/dist/esm/classes/HttpRestClient.d.ts +0 -14
- package/dist/esm/classes/HttpRestClient.js +0 -104
- package/dist/esm/classes/LocalStorage.d.ts +0 -9
- package/dist/esm/classes/LocalStorage.js +0 -22
- package/dist/esm/classes/Status.d.ts +0 -22
- package/dist/esm/classes/Status.js +0 -58
- package/dist/esm/classes/StreamManager.d.ts +0 -9
- package/dist/esm/classes/StreamManager.js +0 -38
- package/dist/esm/classes/index.d.ts +0 -10
- package/dist/esm/classes/index.js +0 -10
- package/dist/esm/constants.d.ts +0 -37
- package/dist/esm/constants.js +0 -46
- package/dist/esm/enum.d.ts +0 -8
- package/dist/esm/enum.js +0 -7
- package/dist/esm/formatters.d.ts +0 -5
- package/dist/esm/formatters.js +0 -24
- package/dist/esm/helpers.d.ts +0 -73
- package/dist/esm/helpers.js +0 -100
- package/dist/esm/numbers.d.ts +0 -4
- package/dist/esm/numbers.js +0 -28
- package/dist/esm/test-utils/mocks/index.d.ts +0 -153
- package/dist/esm/test-utils/mocks/index.js +0 -103
- package/dist/esm/test-utils/msgs.d.ts +0 -44
- package/dist/esm/test-utils/msgs.js +0 -47
- package/dist/esm/time.d.ts +0 -9
- package/dist/esm/time.js +0 -27
- package/dist/esm/types.d.ts +0 -3
- package/dist/esm/types.js +0 -1
package/dist/cjs/helpers.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getStdFee = exports.getStdFeeFromString = exports.getStdFeeFromObject = exports.getStdFeeForToken = exports.splitArrayToChunks = exports.splitArrayToChunksThrow = exports.awaitForAll = exports.awaitAll = exports.sleep = void 0;
|
|
37
|
-
const constants_js_1 = require("./constants.js");
|
|
38
|
-
const BigNumber_js_1 = __importStar(require("./classes/BigNumber.js"));
|
|
39
|
-
const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout));
|
|
40
|
-
exports.sleep = sleep;
|
|
41
|
-
/**
|
|
42
|
-
* When we want to execute the promises in batch
|
|
43
|
-
*/
|
|
44
|
-
const awaitAll = async (array, callback) => await Promise.all(array.map(async (item) => await callback(item)));
|
|
45
|
-
exports.awaitAll = awaitAll;
|
|
46
|
-
/**
|
|
47
|
-
* When we want to execute the promises one by one
|
|
48
|
-
* and not all in batch as with await Promise.all()
|
|
49
|
-
*/
|
|
50
|
-
const awaitForAll = async (array, callback) => {
|
|
51
|
-
const result = [];
|
|
52
|
-
for (let i = 0; i < array.length; i += 1) {
|
|
53
|
-
try {
|
|
54
|
-
result.push(await callback(array[i]));
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
//
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
};
|
|
62
|
-
exports.awaitForAll = awaitForAll;
|
|
63
|
-
const splitArrayToChunksThrow = ({ array, filter, chunkSize, }) => {
|
|
64
|
-
const chunks = [];
|
|
65
|
-
const chunkSizeInNumber = Number(chunkSize);
|
|
66
|
-
if (isNaN(chunkSizeInNumber)) {
|
|
67
|
-
throw new Error('Invalid chunk size, must be a valid number');
|
|
68
|
-
}
|
|
69
|
-
for (let i = 0; i < array.length; i += chunkSizeInNumber) {
|
|
70
|
-
const chunk = array.slice(i, i + chunkSizeInNumber);
|
|
71
|
-
if (filter) {
|
|
72
|
-
chunks.push(chunk.filter(filter));
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
chunks.push(chunk);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return chunks;
|
|
79
|
-
};
|
|
80
|
-
exports.splitArrayToChunksThrow = splitArrayToChunksThrow;
|
|
81
|
-
const splitArrayToChunks = ({ array, filter, chunkSize, }) => {
|
|
82
|
-
try {
|
|
83
|
-
return (0, exports.splitArrayToChunksThrow)({ array, chunkSize, filter });
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return [array];
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
exports.splitArrayToChunks = splitArrayToChunks;
|
|
90
|
-
const getStdFeeForToken = (token = { denom: 'inj', decimals: 18 }, gasPrice, gasLimit) => {
|
|
91
|
-
const gasPriceInBase = gasPrice || (0, BigNumber_js_1.toHumanReadable)(constants_js_1.DEFAULT_GAS_PRICE, 18);
|
|
92
|
-
const gasPriceScaled = (0, BigNumber_js_1.toChainFormat)(gasPriceInBase, token.decimals).toFixed(0);
|
|
93
|
-
const gasNormalized = new BigNumber_js_1.default(gasLimit || constants_js_1.DEFAULT_GAS_LIMIT).toFixed(0);
|
|
94
|
-
return {
|
|
95
|
-
amount: [
|
|
96
|
-
{
|
|
97
|
-
denom: token.denom,
|
|
98
|
-
amount: new BigNumber_js_1.default(gasPriceScaled).times(gasNormalized).toFixed(),
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
gas: (gasLimit || constants_js_1.DEFAULT_GAS_LIMIT).toString(),
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
exports.getStdFeeForToken = getStdFeeForToken;
|
|
105
|
-
const getStdFeeFromObject = (args) => {
|
|
106
|
-
if (!args) {
|
|
107
|
-
return (0, constants_js_1.getDefaultStdFee)();
|
|
108
|
-
}
|
|
109
|
-
const { payer, granter, feePayer, gasPrice = constants_js_1.DEFAULT_GAS_PRICE, gas = constants_js_1.DEFAULT_GAS_LIMIT.toString(), } = args;
|
|
110
|
-
const gasNormalized = (0, BigNumber_js_1.toBigNumber)(gas).toFixed(0);
|
|
111
|
-
const gasPriceNormalized = (0, BigNumber_js_1.toBigNumber)(gasPrice).toFixed(0);
|
|
112
|
-
return {
|
|
113
|
-
amount: [
|
|
114
|
-
{
|
|
115
|
-
denom: 'inj',
|
|
116
|
-
amount: (0, BigNumber_js_1.toBigNumber)(gasNormalized).times(gasPriceNormalized).toFixed(),
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
gas: (0, BigNumber_js_1.toBigNumber)(gasNormalized).toFixed(),
|
|
120
|
-
payer /** for Web3Gateway fee delegation */,
|
|
121
|
-
granter,
|
|
122
|
-
feePayer,
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
exports.getStdFeeFromObject = getStdFeeFromObject;
|
|
126
|
-
const getStdFeeFromString = (gasPrice) => {
|
|
127
|
-
const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/);
|
|
128
|
-
if (!matchResult) {
|
|
129
|
-
throw new Error('Invalid gas price string');
|
|
130
|
-
}
|
|
131
|
-
const [_, amount] = matchResult;
|
|
132
|
-
const gas = (0, BigNumber_js_1.toChainFormat)(amount, 18).dividedBy(constants_js_1.DEFAULT_GAS_PRICE).toFixed(0);
|
|
133
|
-
return (0, exports.getStdFeeFromObject)({ gas, gasPrice: constants_js_1.DEFAULT_GAS_PRICE });
|
|
134
|
-
};
|
|
135
|
-
exports.getStdFeeFromString = getStdFeeFromString;
|
|
136
|
-
const getStdFee = (args) => {
|
|
137
|
-
if (!args) {
|
|
138
|
-
return (0, constants_js_1.getDefaultStdFee)();
|
|
139
|
-
}
|
|
140
|
-
if (typeof args === 'string') {
|
|
141
|
-
return (0, exports.getStdFeeFromString)(args);
|
|
142
|
-
}
|
|
143
|
-
return (0, exports.getStdFeeFromObject)({ ...args });
|
|
144
|
-
};
|
|
145
|
-
exports.getStdFee = getStdFee;
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./time.js"), exports);
|
|
18
|
-
__exportStar(require("./helpers.js"), exports);
|
|
19
|
-
__exportStar(require("./numbers.js"), exports);
|
|
20
|
-
__exportStar(require("./constants.js"), exports);
|
|
21
|
-
__exportStar(require("./formatters.js"), exports);
|
|
22
|
-
__exportStar(require("./classes/index.js"), exports);
|
package/dist/cjs/numbers.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import BigNumber from './classes/BigNumber.js';
|
|
2
|
-
export declare const getBigNumberWithRounding: () => typeof BigNumber;
|
|
3
|
-
export declare const getSignificantDecimalsFromNumber: (number: BigNumber | number | string) => number;
|
|
4
|
-
export declare const getExactDecimalsFromNumber: (number: number | string) => number;
|
package/dist/cjs/numbers.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getExactDecimalsFromNumber = exports.getSignificantDecimalsFromNumber = exports.getBigNumberWithRounding = void 0;
|
|
7
|
-
const BigNumber_js_1 = __importDefault(require("./classes/BigNumber.js"));
|
|
8
|
-
const getBigNumberWithRounding = () => BigNumber_js_1.default.clone({ ROUNDING_MODE: BigNumber_js_1.default.ROUND_DOWN });
|
|
9
|
-
exports.getBigNumberWithRounding = getBigNumberWithRounding;
|
|
10
|
-
const getSignificantDecimalsFromNumber = (number) => {
|
|
11
|
-
const $BigNumber = (0, exports.getBigNumberWithRounding)();
|
|
12
|
-
if (Math.floor(new $BigNumber(number).toNumber()) === number) {
|
|
13
|
-
return 0;
|
|
14
|
-
}
|
|
15
|
-
const parts = new $BigNumber(number).toFixed().split('.');
|
|
16
|
-
const [, decimals] = parts;
|
|
17
|
-
/** Number doesn't have decimals */
|
|
18
|
-
if (!decimals) {
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
return decimals.length;
|
|
22
|
-
};
|
|
23
|
-
exports.getSignificantDecimalsFromNumber = getSignificantDecimalsFromNumber;
|
|
24
|
-
const getExactDecimalsFromNumber = (number) => {
|
|
25
|
-
if (!number.toString().includes('.')) {
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
if (Number(number) % 1 === 0) {
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
const [, decimals] = number.toString().split('.');
|
|
32
|
-
if (!decimals) {
|
|
33
|
-
return 0;
|
|
34
|
-
}
|
|
35
|
-
return decimals.length;
|
|
36
|
-
};
|
|
37
|
-
exports.getExactDecimalsFromNumber = getExactDecimalsFromNumber;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./mocks/index.js"), exports);
|
|
18
|
-
__exportStar(require("./msgs.js"), exports);
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
|
-
import type { ChainId as ChainIdType, EvmChainId as EvmChainIdType } from '@injectivelabs/ts-types';
|
|
3
|
-
export declare const injUsdtSpotMarket: {
|
|
4
|
-
marketId: string;
|
|
5
|
-
marketStatus: string;
|
|
6
|
-
ticker: string;
|
|
7
|
-
baseDenom: string;
|
|
8
|
-
quoteDenom: string;
|
|
9
|
-
quoteToken: {
|
|
10
|
-
name: string;
|
|
11
|
-
address: string;
|
|
12
|
-
symbol: string;
|
|
13
|
-
logo: string;
|
|
14
|
-
decimals: number;
|
|
15
|
-
coinGeckoId: string;
|
|
16
|
-
};
|
|
17
|
-
baseToken: {
|
|
18
|
-
name: string;
|
|
19
|
-
address: string;
|
|
20
|
-
symbol: string;
|
|
21
|
-
logo: string;
|
|
22
|
-
decimals: number;
|
|
23
|
-
coinGeckoId: string;
|
|
24
|
-
};
|
|
25
|
-
makerFeeRate: string;
|
|
26
|
-
takerFeeRate: string;
|
|
27
|
-
serviceProviderFee: string;
|
|
28
|
-
minPriceTickSize: string;
|
|
29
|
-
minQuantityTickSize: string;
|
|
30
|
-
};
|
|
31
|
-
export declare const injUsdtDerivativeMarket: {
|
|
32
|
-
oracleBase: string;
|
|
33
|
-
oracleQuote: string;
|
|
34
|
-
oracleType: string;
|
|
35
|
-
initialMarginRatio: string;
|
|
36
|
-
maintenanceMarginRatio: string;
|
|
37
|
-
isPerpetual: boolean;
|
|
38
|
-
marketId: string;
|
|
39
|
-
marketStatus: string;
|
|
40
|
-
ticker: string;
|
|
41
|
-
quoteDenom: string;
|
|
42
|
-
makerFeeRate: string;
|
|
43
|
-
takerFeeRate: string;
|
|
44
|
-
serviceProviderFee: string;
|
|
45
|
-
minPriceTickSize: number;
|
|
46
|
-
minQuantityTickSize: number;
|
|
47
|
-
perpetualMarketInfo: {
|
|
48
|
-
hourlyFundingRateCap: string;
|
|
49
|
-
hourlyInterestRate: string;
|
|
50
|
-
nextFundingTimestamp: number;
|
|
51
|
-
fundingInterval: number;
|
|
52
|
-
};
|
|
53
|
-
perpetualMarketFunding: {
|
|
54
|
-
cumulativeFunding: string;
|
|
55
|
-
cumulativePrice: string;
|
|
56
|
-
lastTimestamp: number;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
export declare const mockFactory: {
|
|
60
|
-
ethereumAddress: string;
|
|
61
|
-
injectiveAddress: string;
|
|
62
|
-
injectiveAddress2: string;
|
|
63
|
-
validatorAddress: string;
|
|
64
|
-
validatorAddress2: string;
|
|
65
|
-
derivativeMarketId: string;
|
|
66
|
-
spotMarketId: string;
|
|
67
|
-
subaccountId: string;
|
|
68
|
-
subaccountId2: string;
|
|
69
|
-
injUsdtSpotMarket: {
|
|
70
|
-
marketId: string;
|
|
71
|
-
marketStatus: string;
|
|
72
|
-
ticker: string;
|
|
73
|
-
baseDenom: string;
|
|
74
|
-
quoteDenom: string;
|
|
75
|
-
quoteToken: {
|
|
76
|
-
name: string;
|
|
77
|
-
address: string;
|
|
78
|
-
symbol: string;
|
|
79
|
-
logo: string;
|
|
80
|
-
decimals: number;
|
|
81
|
-
coinGeckoId: string;
|
|
82
|
-
};
|
|
83
|
-
baseToken: {
|
|
84
|
-
name: string;
|
|
85
|
-
address: string;
|
|
86
|
-
symbol: string;
|
|
87
|
-
logo: string;
|
|
88
|
-
decimals: number;
|
|
89
|
-
coinGeckoId: string;
|
|
90
|
-
};
|
|
91
|
-
makerFeeRate: string;
|
|
92
|
-
takerFeeRate: string;
|
|
93
|
-
serviceProviderFee: string;
|
|
94
|
-
minPriceTickSize: string;
|
|
95
|
-
minQuantityTickSize: string;
|
|
96
|
-
};
|
|
97
|
-
injUsdtDerivativeMarket: {
|
|
98
|
-
oracleBase: string;
|
|
99
|
-
oracleQuote: string;
|
|
100
|
-
oracleType: string;
|
|
101
|
-
initialMarginRatio: string;
|
|
102
|
-
maintenanceMarginRatio: string;
|
|
103
|
-
isPerpetual: boolean;
|
|
104
|
-
marketId: string;
|
|
105
|
-
marketStatus: string;
|
|
106
|
-
ticker: string;
|
|
107
|
-
quoteDenom: string;
|
|
108
|
-
makerFeeRate: string;
|
|
109
|
-
takerFeeRate: string;
|
|
110
|
-
serviceProviderFee: string;
|
|
111
|
-
minPriceTickSize: number;
|
|
112
|
-
minQuantityTickSize: number;
|
|
113
|
-
perpetualMarketInfo: {
|
|
114
|
-
hourlyFundingRateCap: string;
|
|
115
|
-
hourlyInterestRate: string;
|
|
116
|
-
nextFundingTimestamp: number;
|
|
117
|
-
fundingInterval: number;
|
|
118
|
-
};
|
|
119
|
-
perpetualMarketFunding: {
|
|
120
|
-
cumulativeFunding: string;
|
|
121
|
-
cumulativePrice: string;
|
|
122
|
-
lastTimestamp: number;
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
orderHash: string;
|
|
126
|
-
orderHash2: string;
|
|
127
|
-
MAX_TIMEOUT_HEIGHT: number;
|
|
128
|
-
eip712Tx: ({ chainId, evmChainId, accountNumber, sequence, timeoutHeight, memo, }: {
|
|
129
|
-
chainId?: ChainIdType;
|
|
130
|
-
evmChainId?: EvmChainIdType;
|
|
131
|
-
accountNumber?: number;
|
|
132
|
-
sequence?: number;
|
|
133
|
-
timeoutHeight?: number;
|
|
134
|
-
memo?: string;
|
|
135
|
-
}) => {
|
|
136
|
-
tx: {
|
|
137
|
-
memo: string;
|
|
138
|
-
chainId: ChainId;
|
|
139
|
-
sequence: number;
|
|
140
|
-
evmChainId: EvmChainId;
|
|
141
|
-
accountNumber: number;
|
|
142
|
-
timeoutHeight: number;
|
|
143
|
-
};
|
|
144
|
-
eip712: {
|
|
145
|
-
memo: string;
|
|
146
|
-
chainId: ChainId;
|
|
147
|
-
sequence: number;
|
|
148
|
-
accountNumber: number;
|
|
149
|
-
evmChainId: EvmChainId;
|
|
150
|
-
timeoutHeight: number;
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mockFactory = exports.injUsdtDerivativeMarket = exports.injUsdtSpotMarket = void 0;
|
|
4
|
-
const ts_types_1 = require("@injectivelabs/ts-types");
|
|
5
|
-
const ethereumAddress = '0xaf79152ac5df276d9a8e1e2e22822f9713474902';
|
|
6
|
-
const injectiveAddress = 'inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku';
|
|
7
|
-
const injectiveAddress2 = 'inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku';
|
|
8
|
-
const validatorAddress = 'injvaloper1lsuqpgm8kgwpq96ewyew26xnfwyn3lh3ncrkrk';
|
|
9
|
-
const validatorAddress2 = 'injvaloper1g4d6dmvnpg7w7yugy6kplndp7jpfmf3krtschp';
|
|
10
|
-
const spotMarketId = '0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0';
|
|
11
|
-
const derivativeMarketId = '0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4';
|
|
12
|
-
const subaccountId = '0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000';
|
|
13
|
-
const subaccountId2 = '0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000001';
|
|
14
|
-
const orderHash = '0x3b1bcc8ab01e1e0f1f2cf9de5f44267bed6368fabd62adbcf3826a207340194e';
|
|
15
|
-
const orderHash2 = '0x3b1bcc8ab01e1e0f1f2cf9de5f44267bed6368fabd62adbcf3826a207340194e';
|
|
16
|
-
const MAX_TIMEOUT_HEIGHT = 9_999_999_999_999;
|
|
17
|
-
exports.injUsdtSpotMarket = {
|
|
18
|
-
marketId: '0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0',
|
|
19
|
-
marketStatus: 'active',
|
|
20
|
-
ticker: 'INJ/USDT',
|
|
21
|
-
baseDenom: 'inj',
|
|
22
|
-
quoteDenom: 'peggy0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
23
|
-
quoteToken: {
|
|
24
|
-
name: 'Tether',
|
|
25
|
-
address: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
26
|
-
symbol: 'USDT',
|
|
27
|
-
logo: 'https://static.alchemyapi.io/images/assets/825.png',
|
|
28
|
-
decimals: 6,
|
|
29
|
-
coinGeckoId: '',
|
|
30
|
-
},
|
|
31
|
-
baseToken: {
|
|
32
|
-
name: 'Injective Protocol',
|
|
33
|
-
address: '0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30',
|
|
34
|
-
symbol: 'INJ',
|
|
35
|
-
logo: 'https://static.alchemyapi.io/images/assets/7226.png',
|
|
36
|
-
decimals: 18,
|
|
37
|
-
coinGeckoId: '',
|
|
38
|
-
},
|
|
39
|
-
makerFeeRate: '-0.0002',
|
|
40
|
-
takerFeeRate: '0.002',
|
|
41
|
-
serviceProviderFee: '0.4',
|
|
42
|
-
minPriceTickSize: '0.000000000000001',
|
|
43
|
-
minQuantityTickSize: '1000000000000000',
|
|
44
|
-
};
|
|
45
|
-
exports.injUsdtDerivativeMarket = {
|
|
46
|
-
oracleBase: 'INJ',
|
|
47
|
-
oracleQuote: 'USDT',
|
|
48
|
-
oracleType: 'pricefeed',
|
|
49
|
-
initialMarginRatio: '0.05',
|
|
50
|
-
maintenanceMarginRatio: '0.02',
|
|
51
|
-
isPerpetual: true,
|
|
52
|
-
marketId: '0x7cc8b10d7deb61e744ef83bdec2bbcf4a056867e89b062c6a453020ca82bd4e4',
|
|
53
|
-
marketStatus: 'active',
|
|
54
|
-
ticker: 'INJ/USDT PERP',
|
|
55
|
-
quoteDenom: 'peggy0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
56
|
-
makerFeeRate: '0.001',
|
|
57
|
-
takerFeeRate: '0.002',
|
|
58
|
-
serviceProviderFee: '0.4',
|
|
59
|
-
minPriceTickSize: 1000,
|
|
60
|
-
minQuantityTickSize: 0.001,
|
|
61
|
-
perpetualMarketInfo: {
|
|
62
|
-
hourlyFundingRateCap: '0.000625',
|
|
63
|
-
hourlyInterestRate: '0.00000416666',
|
|
64
|
-
nextFundingTimestamp: 1662649966,
|
|
65
|
-
fundingInterval: 3600,
|
|
66
|
-
},
|
|
67
|
-
perpetualMarketFunding: {
|
|
68
|
-
cumulativeFunding: '-2172.542776314322575',
|
|
69
|
-
cumulativePrice: '-2.770342429398565393',
|
|
70
|
-
lastTimestamp: 1662648237,
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
exports.mockFactory = {
|
|
74
|
-
ethereumAddress,
|
|
75
|
-
injectiveAddress,
|
|
76
|
-
injectiveAddress2,
|
|
77
|
-
validatorAddress,
|
|
78
|
-
validatorAddress2,
|
|
79
|
-
derivativeMarketId,
|
|
80
|
-
spotMarketId,
|
|
81
|
-
subaccountId,
|
|
82
|
-
subaccountId2,
|
|
83
|
-
injUsdtSpotMarket: exports.injUsdtSpotMarket,
|
|
84
|
-
injUsdtDerivativeMarket: exports.injUsdtDerivativeMarket,
|
|
85
|
-
orderHash,
|
|
86
|
-
orderHash2,
|
|
87
|
-
MAX_TIMEOUT_HEIGHT,
|
|
88
|
-
eip712Tx: ({ chainId = ts_types_1.ChainId.Devnet, evmChainId = ts_types_1.EvmChainId.Sepolia, accountNumber = 1, sequence = 0, timeoutHeight = 999999999, memo = '', }) => ({
|
|
89
|
-
tx: {
|
|
90
|
-
memo,
|
|
91
|
-
chainId,
|
|
92
|
-
sequence,
|
|
93
|
-
evmChainId,
|
|
94
|
-
accountNumber,
|
|
95
|
-
timeoutHeight,
|
|
96
|
-
},
|
|
97
|
-
eip712: {
|
|
98
|
-
memo,
|
|
99
|
-
chainId,
|
|
100
|
-
sequence,
|
|
101
|
-
accountNumber,
|
|
102
|
-
evmChainId,
|
|
103
|
-
timeoutHeight,
|
|
104
|
-
},
|
|
105
|
-
}),
|
|
106
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Network } from '@injectivelabs/networks';
|
|
2
|
-
import type { NetworkEndpoints } from '@injectivelabs/networks';
|
|
3
|
-
import type { Coin, ChainId, EvmChainId } from '@injectivelabs/ts-types';
|
|
4
|
-
export declare const prepareEip712: <T>({ messages, gas, network, injectiveAddress, ethereumAddress, endpoints, accountNumber, sequence, timeoutHeight, memo, }: {
|
|
5
|
-
ethereumAddress?: string;
|
|
6
|
-
messages: T;
|
|
7
|
-
network?: Network;
|
|
8
|
-
gas?: number | string;
|
|
9
|
-
accountNumber?: number;
|
|
10
|
-
sequence?: number;
|
|
11
|
-
timeoutHeight?: number;
|
|
12
|
-
memo?: string;
|
|
13
|
-
endpoints?: Partial<NetworkEndpoints>;
|
|
14
|
-
injectiveAddress?: string;
|
|
15
|
-
}) => {
|
|
16
|
-
endpoints: NetworkEndpoints;
|
|
17
|
-
eip712Args: {
|
|
18
|
-
msgs: any;
|
|
19
|
-
tx: {
|
|
20
|
-
memo: string;
|
|
21
|
-
chainId: ChainId;
|
|
22
|
-
sequence: string;
|
|
23
|
-
evmChainId: EvmChainId;
|
|
24
|
-
accountNumber: string;
|
|
25
|
-
timeoutHeight: string;
|
|
26
|
-
};
|
|
27
|
-
evmChainId: EvmChainId;
|
|
28
|
-
fee: {
|
|
29
|
-
amount: Coin[];
|
|
30
|
-
gas: string;
|
|
31
|
-
payer: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
prepareEip712Request: {
|
|
35
|
-
chainId: EvmChainId;
|
|
36
|
-
message: any[];
|
|
37
|
-
address: string;
|
|
38
|
-
memo: string;
|
|
39
|
-
sequence: number;
|
|
40
|
-
accountNumber: number;
|
|
41
|
-
evmChainId: EvmChainId;
|
|
42
|
-
timeoutHeight: number;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.prepareEip712 = void 0;
|
|
7
|
-
const networks_1 = require("@injectivelabs/networks");
|
|
8
|
-
const index_js_1 = require("./mocks/index.js");
|
|
9
|
-
const BigNumber_js_1 = __importDefault(require("../classes/BigNumber.js"));
|
|
10
|
-
const constants_js_1 = require("../constants.js");
|
|
11
|
-
const prepareEip712 = ({ messages, gas = constants_js_1.DEFAULT_GAS_LIMIT, network = networks_1.Network.Mainnet, injectiveAddress = index_js_1.mockFactory.injectiveAddress, ethereumAddress = index_js_1.mockFactory.ethereumAddress, endpoints = {}, accountNumber = 1, sequence = 1, timeoutHeight = 999_999_999, memo = '', }) => {
|
|
12
|
-
const chainInfo = (0, networks_1.getNetworkInfo)(network);
|
|
13
|
-
const actualEndpoints = { ...(0, networks_1.getNetworkEndpoints)(network), ...endpoints };
|
|
14
|
-
const msgs = Array.isArray(messages) ? messages : [messages];
|
|
15
|
-
const web3Msgs = msgs.map((msg) => msg.toWeb3());
|
|
16
|
-
const { tx, eip712 } = index_js_1.mockFactory.eip712Tx({
|
|
17
|
-
...chainInfo,
|
|
18
|
-
accountNumber,
|
|
19
|
-
sequence,
|
|
20
|
-
timeoutHeight,
|
|
21
|
-
memo,
|
|
22
|
-
});
|
|
23
|
-
const eip712Args = {
|
|
24
|
-
msgs,
|
|
25
|
-
fee: {
|
|
26
|
-
amount: [
|
|
27
|
-
{
|
|
28
|
-
denom: 'inj',
|
|
29
|
-
amount: new BigNumber_js_1.default(gas.toString())
|
|
30
|
-
.times(constants_js_1.DEFAULT_GAS_PRICE)
|
|
31
|
-
.toFixed(),
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
gas: gas.toString(),
|
|
35
|
-
payer: injectiveAddress,
|
|
36
|
-
},
|
|
37
|
-
tx: {
|
|
38
|
-
...tx,
|
|
39
|
-
sequence: sequence.toString(),
|
|
40
|
-
timeoutHeight: timeoutHeight.toString(),
|
|
41
|
-
accountNumber: accountNumber.toString(),
|
|
42
|
-
},
|
|
43
|
-
evmChainId: eip712.evmChainId,
|
|
44
|
-
};
|
|
45
|
-
const prepareEip712Request = {
|
|
46
|
-
...eip712,
|
|
47
|
-
chainId: eip712.evmChainId,
|
|
48
|
-
message: web3Msgs,
|
|
49
|
-
gasLimit: gas,
|
|
50
|
-
address: ethereumAddress,
|
|
51
|
-
};
|
|
52
|
-
return { endpoints: actualEndpoints, eip712Args, prepareEip712Request };
|
|
53
|
-
};
|
|
54
|
-
exports.prepareEip712 = prepareEip712;
|
package/dist/cjs/time.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import BigNumber from './classes/BigNumber.js';
|
|
2
|
-
export declare const getSecondsInDay: () => BigNumber;
|
|
3
|
-
export declare const convertTimestampToMilliseconds: (timestamp: number | string) => number;
|
|
4
|
-
export declare const getUTCDateFromTimestamp: (timestamp: number) => string;
|
|
5
|
-
export declare const tomorrow: () => BigNumber;
|
|
6
|
-
export declare const todayInSeconds: () => number;
|
|
7
|
-
export declare const past24Hours: () => number;
|
|
8
|
-
export declare const pastDays: (day?: number) => number;
|
|
9
|
-
export declare const getEndDateStringFromTimeInSeconds: (timeInSeconds: BigNumber) => string;
|
package/dist/cjs/time.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEndDateStringFromTimeInSeconds = exports.pastDays = exports.past24Hours = exports.todayInSeconds = exports.tomorrow = exports.getUTCDateFromTimestamp = exports.convertTimestampToMilliseconds = exports.getSecondsInDay = void 0;
|
|
7
|
-
const BigNumber_js_1 = __importDefault(require("./classes/BigNumber.js"));
|
|
8
|
-
const getSecondsInDay = () => new BigNumber_js_1.default(60 * 60 * 24);
|
|
9
|
-
exports.getSecondsInDay = getSecondsInDay;
|
|
10
|
-
const convertTimestampToMilliseconds = (timestamp) => {
|
|
11
|
-
const timestampInBigNumber = new BigNumber_js_1.default(timestamp);
|
|
12
|
-
if (timestamp.toString().length > 13) {
|
|
13
|
-
return timestampInBigNumber
|
|
14
|
-
.precision(13, BigNumber_js_1.default.ROUND_HALF_UP)
|
|
15
|
-
.toNumber();
|
|
16
|
-
}
|
|
17
|
-
if (timestamp.toString().length < 13) {
|
|
18
|
-
const trailingZeros = 13 - timestamp.toString().length;
|
|
19
|
-
return timestampInBigNumber.times(10 ** trailingZeros).toNumber();
|
|
20
|
-
}
|
|
21
|
-
return timestampInBigNumber.toNumber();
|
|
22
|
-
};
|
|
23
|
-
exports.convertTimestampToMilliseconds = convertTimestampToMilliseconds;
|
|
24
|
-
const getUTCDateFromTimestamp = (timestamp) => {
|
|
25
|
-
const date = new Date((0, exports.convertTimestampToMilliseconds)(timestamp));
|
|
26
|
-
return `${date.getUTCDate()}-${date.getUTCMonth() + 1}-${date.getUTCFullYear()}`;
|
|
27
|
-
};
|
|
28
|
-
exports.getUTCDateFromTimestamp = getUTCDateFromTimestamp;
|
|
29
|
-
const tomorrow = () => new BigNumber_js_1.default(Math.floor(new Date().valueOf() / 1000) + 3600 * 24);
|
|
30
|
-
exports.tomorrow = tomorrow;
|
|
31
|
-
const todayInSeconds = () => Math.floor(Date.now() / 1000);
|
|
32
|
-
exports.todayInSeconds = todayInSeconds;
|
|
33
|
-
const past24Hours = () => new BigNumber_js_1.default((0, exports.todayInSeconds)()).minus((0, exports.getSecondsInDay)()).toNumber();
|
|
34
|
-
exports.past24Hours = past24Hours;
|
|
35
|
-
const pastDays = (day = 1) => new BigNumber_js_1.default((0, exports.todayInSeconds)()).minus((0, exports.getSecondsInDay)().times(day)).toNumber();
|
|
36
|
-
exports.pastDays = pastDays;
|
|
37
|
-
const getEndDateStringFromTimeInSeconds = (timeInSeconds) => {
|
|
38
|
-
const currentDate = new Date(timeInSeconds.toNumber() * 1000);
|
|
39
|
-
return currentDate.toLocaleString('en-us');
|
|
40
|
-
};
|
|
41
|
-
exports.getEndDateStringFromTimeInSeconds = getEndDateStringFromTimeInSeconds;
|
package/dist/cjs/types.d.ts
DELETED
package/dist/cjs/types.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from 'bignumber.js';
|
|
2
|
-
export default BigNumber;
|
|
3
|
-
/**
|
|
4
|
-
* Converts a value to BigNumber if it isn't already
|
|
5
|
-
*/
|
|
6
|
-
export declare const toBigNumber: (value: BigNumber | string | number) => BigNumber;
|
|
7
|
-
/**
|
|
8
|
-
* Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals
|
|
9
|
-
*/
|
|
10
|
-
export declare const toChainFormat: (value: BigNumber | string | number, decimals?: number) => BigNumber;
|
|
11
|
-
/**
|
|
12
|
-
* Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals
|
|
13
|
-
*/
|
|
14
|
-
export declare const toHumanReadable: (value: BigNumber | string | number, decimals?: number) => BigNumber;
|