@nadohq/shared 0.1.0-alpha.5 → 0.1.0-alpha.50
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/abis/index.cjs +12 -12
- package/dist/abis/index.cjs.map +1 -1
- package/dist/abis/index.d.cts +6 -6
- package/dist/abis/index.d.ts +6 -6
- package/dist/abis/index.js +6 -6
- package/dist/abis/index.js.map +1 -1
- package/dist/{chunk-TUJ4HQKF.js → chunk-2GPIH63F.js} +3 -3
- package/dist/chunk-2GPIH63F.js.map +1 -0
- package/dist/consts/chainEnvToChain.cjs +2 -2
- package/dist/consts/chainEnvToChain.cjs.map +1 -1
- package/dist/consts/chainEnvToChain.d.cts +345 -56
- package/dist/consts/chainEnvToChain.d.ts +345 -56
- package/dist/consts/chainEnvToChain.js +3 -3
- package/dist/consts/chainEnvToChain.js.map +1 -1
- package/dist/consts/index.d.cts +0 -1
- package/dist/consts/index.d.ts +0 -1
- package/dist/consts/productIds.cjs +1 -1
- package/dist/consts/productIds.cjs.map +1 -1
- package/dist/consts/productIds.d.cts +1 -1
- package/dist/consts/productIds.d.ts +1 -1
- package/dist/consts/productIds.js +1 -1
- package/dist/consts/productIds.js.map +1 -1
- package/dist/deployments/core/deployment.inkMainnet.json +13 -0
- package/dist/deployments/core/deployment.inkSepolia.json +13 -0
- package/dist/deployments/index.cjs +6 -6
- package/dist/deployments/index.cjs.map +1 -1
- package/dist/deployments/index.js +5 -5
- package/dist/deployments/index.js.map +1 -1
- package/dist/eip712/eip712ValueTypes.d.cts +1 -1
- package/dist/eip712/eip712ValueTypes.d.ts +1 -1
- package/dist/eip712/getNadoEIP712Domain.cjs.map +1 -1
- package/dist/eip712/getNadoEIP712Domain.js.map +1 -1
- package/dist/eip712/index.cjs +13 -13
- package/dist/eip712/index.cjs.map +1 -1
- package/dist/eip712/index.d.cts +9 -9
- package/dist/eip712/index.d.ts +9 -9
- package/dist/eip712/index.js +6 -6
- package/dist/eip712/index.js.map +1 -1
- package/dist/encoding/encoding.cjs +21 -0
- package/dist/encoding/encoding.cjs.map +1 -1
- package/dist/encoding/encoding.d.cts +27 -3
- package/dist/encoding/encoding.d.ts +27 -3
- package/dist/encoding/encoding.js +24 -1
- package/dist/encoding/encoding.js.map +1 -1
- package/dist/encoding/index.d.cts +2 -2
- package/dist/encoding/index.d.ts +2 -2
- package/dist/index.d.cts +35 -35
- package/dist/index.d.ts +35 -35
- package/dist/types/ChainEnv.cjs +1 -1
- package/dist/types/ChainEnv.cjs.map +1 -1
- package/dist/types/ChainEnv.d.cts +2 -2
- package/dist/types/ChainEnv.d.ts +2 -2
- package/dist/types/ChainEnv.js +1 -1
- package/dist/types/ChainEnv.js.map +1 -1
- package/dist/types/balanceTypes.d.cts +1 -1
- package/dist/types/balanceTypes.d.ts +1 -1
- package/dist/types/index.cjs +7 -7
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +3 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/orderAppendixTypes.cjs.map +1 -1
- package/dist/types/orderAppendixTypes.d.cts +25 -1
- package/dist/types/orderAppendixTypes.d.ts +25 -1
- package/dist/types/viemTypes.d.cts +1 -1
- package/dist/types/viemTypes.d.ts +1 -1
- package/dist/utils/balanceValue.d.cts +1 -1
- package/dist/utils/balanceValue.d.ts +1 -1
- package/dist/utils/bytes32.d.cts +1 -1
- package/dist/utils/bytes32.d.ts +1 -1
- package/dist/utils/bytes32.test.cjs +2 -2
- package/dist/utils/bytes32.test.cjs.map +1 -1
- package/dist/utils/bytes32.test.js +1 -1
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.cjs.map +1 -1
- package/dist/utils/createDeterministicLinkedSignerPrivateKey.js.map +1 -1
- package/dist/utils/index.cjs +12 -12
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +21 -21
- package/dist/utils/index.d.ts +21 -21
- package/dist/utils/index.js +6 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/math/bigDecimal.cjs +4 -3
- package/dist/utils/math/bigDecimal.cjs.map +1 -1
- package/dist/utils/math/bigDecimal.js +4 -3
- package/dist/utils/math/bigDecimal.js.map +1 -1
- package/dist/utils/math/index.cjs +8 -8
- package/dist/utils/math/index.cjs.map +1 -1
- package/dist/utils/math/index.d.cts +4 -4
- package/dist/utils/math/index.d.ts +4 -4
- package/dist/utils/math/index.js +4 -4
- package/dist/utils/math/index.js.map +1 -1
- package/dist/utils/orders/appendix/appendixIsolatedValue.cjs +50 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.cjs.map +1 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.d.cts +26 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.d.ts +26 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.js +31 -0
- package/dist/utils/orders/appendix/appendixIsolatedValue.js.map +1 -0
- package/dist/utils/orders/appendix/appendixTwapValue.cjs +3 -4
- package/dist/utils/orders/appendix/appendixTwapValue.cjs.map +1 -1
- package/dist/utils/orders/appendix/appendixTwapValue.d.cts +11 -13
- package/dist/utils/orders/appendix/appendixTwapValue.d.ts +11 -13
- package/dist/utils/orders/appendix/appendixTwapValue.js +3 -4
- package/dist/utils/orders/appendix/appendixTwapValue.js.map +1 -1
- package/dist/utils/orders/appendix/index.cjs +4 -4
- package/dist/utils/orders/appendix/index.cjs.map +1 -1
- package/dist/utils/orders/appendix/index.d.cts +2 -2
- package/dist/utils/orders/appendix/index.d.ts +2 -2
- package/dist/utils/orders/appendix/index.js +2 -2
- package/dist/utils/orders/appendix/index.js.map +1 -1
- package/dist/utils/orders/appendix/orderAppendix.test.cjs +67 -14
- package/dist/utils/orders/appendix/orderAppendix.test.cjs.map +1 -1
- package/dist/utils/orders/appendix/orderAppendix.test.js +66 -13
- package/dist/utils/orders/appendix/orderAppendix.test.js.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.cjs +9 -5
- package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.js +9 -5
- package/dist/utils/orders/appendix/packOrderAppendix.js.map +1 -1
- package/dist/utils/orders/appendix/types.cjs.map +1 -1
- package/dist/utils/orders/appendix/types.d.cts +6 -4
- package/dist/utils/orders/appendix/types.d.ts +6 -4
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs +22 -5
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/unpackOrderAppendix.js +22 -5
- package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -1
- package/dist/utils/orders/index.cjs +3 -3
- package/dist/utils/orders/index.cjs.map +1 -1
- package/dist/utils/orders/index.d.cts +4 -4
- package/dist/utils/orders/index.d.ts +4 -4
- package/dist/utils/orders/index.js +1 -1
- package/dist/utils/orders/index.js.map +1 -1
- package/dist/utils/productTypeFilter.cjs.map +1 -1
- package/dist/utils/productTypeFilter.d.cts +2 -2
- package/dist/utils/productTypeFilter.d.ts +2 -2
- package/dist/utils/productTypeFilter.js.map +1 -1
- package/dist/utils/toPrintableObject.cjs +17 -9
- package/dist/utils/toPrintableObject.cjs.map +1 -1
- package/dist/utils/toPrintableObject.d.cts +7 -2
- package/dist/utils/toPrintableObject.d.ts +7 -2
- package/dist/utils/toPrintableObject.js +17 -9
- package/dist/utils/toPrintableObject.js.map +1 -1
- package/package.json +10 -3
- package/src/abis/index.ts +6 -6
- package/src/consts/chainEnvToChain.ts +2 -2
- package/src/consts/productIds.ts +1 -1
- package/src/deployments/core/deployment.inkMainnet.json +13 -0
- package/src/deployments/core/deployment.inkSepolia.json +13 -0
- package/src/deployments/index.ts +5 -5
- package/src/eip712/getNadoEIP712Domain.ts +1 -1
- package/src/eip712/index.ts +6 -6
- package/src/encoding/encoding.ts +43 -1
- package/src/types/ChainEnv.ts +1 -1
- package/src/types/index.ts +3 -3
- package/src/types/orderAppendixTypes.ts +25 -0
- package/src/utils/createDeterministicLinkedSignerPrivateKey.ts +1 -1
- package/src/utils/index.ts +6 -6
- package/src/utils/math/bigDecimal.ts +5 -3
- package/src/utils/math/index.ts +4 -4
- package/src/utils/orders/appendix/appendixIsolatedValue.ts +49 -0
- package/src/utils/orders/appendix/appendixTwapValue.ts +14 -19
- package/src/utils/orders/appendix/index.ts +2 -2
- package/src/utils/orders/appendix/orderAppendix.test.ts +68 -11
- package/src/utils/orders/appendix/packOrderAppendix.ts +10 -6
- package/src/utils/orders/appendix/types.ts +9 -7
- package/src/utils/orders/appendix/unpackOrderAppendix.ts +22 -5
- package/src/utils/orders/index.ts +1 -1
- package/src/utils/productTypeFilter.ts +2 -2
- package/src/utils/toPrintableObject.ts +30 -10
- package/dist/chunk-TUJ4HQKF.js.map +0 -1
- package/dist/deployments/core/deployment.InkSepolia.json +0 -13
- package/dist/deployments/core/deployment.arbitrumOne.json +0 -18
- package/src/deployments/core/deployment.InkSepolia.json +0 -13
- package/src/deployments/core/deployment.arbitrumOne.json +0 -18
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { getDefaultRecvTime } from './orders/recvTime.cjs';
|
|
3
|
-
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.cjs';
|
|
4
|
-
export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.cjs';
|
|
5
|
-
export { packOrderAppendix } from './orders/appendix/packOrderAppendix.cjs';
|
|
6
|
-
export { PackedOrderAppendixBits } from './orders/appendix/types.cjs';
|
|
7
|
-
export { bitMaskValue } from './orders/appendix/bitMaskValue.cjs';
|
|
8
|
-
export { calcBorrowRateForTimeRange, calcBorrowRatePerSecond, calcRealizedDepositRateForTimeRange, calcTotalBorrowed, calcTotalDeposited, calcUtilizationRatio } from './interest.cjs';
|
|
9
|
-
export { isPerpBalance, isPerpProduct, isSpotBalance, isSpotProduct } from './productTypeFilter.cjs';
|
|
1
|
+
export { AsyncResult, asyncResult } from './asyncResult.cjs';
|
|
10
2
|
export { calcPerpBalanceNotionalValue, calcPerpBalanceValue, calcSpotBalanceValue } from './balanceValue.cjs';
|
|
11
3
|
export { subaccountFromBytes32, subaccountFromHex, subaccountNameBytesToStr, subaccountNameToBytes12, subaccountToBytes32, subaccountToHex } from './bytes32.cjs';
|
|
12
4
|
export { createDeterministicLinkedSignerPrivateKey } from './createDeterministicLinkedSignerPrivateKey.cjs';
|
|
13
|
-
export { isWriteableContract } from './isWriteableContract.cjs';
|
|
14
5
|
export { WalletNotProvidedError } from './errors/WalletNotProvidedError.cjs';
|
|
15
|
-
export { BigDecimalish, toBigDecimal } from './math/bigDecimal.cjs';
|
|
16
|
-
export { toIntegerString } from './math/toIntegerString.cjs';
|
|
17
|
-
export { toBigInt } from './math/toBigInt.cjs';
|
|
18
|
-
export { clampBigDecimal } from './math/clamp.cjs';
|
|
19
|
-
export { sumBigDecimalBy } from './math/sumBigDecimalBy.cjs';
|
|
20
|
-
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals } from './math/decimalAdjustment.cjs';
|
|
21
|
-
export { BigDecimals } from './math/BigDecimals.cjs';
|
|
22
|
-
export { AsyncResult, asyncResult } from './asyncResult.cjs';
|
|
23
6
|
export { getValidatedAddress } from './getValidatedAddress.cjs';
|
|
24
7
|
export { getValidatedHex } from './getValidatedHex.cjs';
|
|
8
|
+
export { calcBorrowRateForTimeRange, calcBorrowRatePerSecond, calcRealizedDepositRateForTimeRange, calcTotalBorrowed, calcTotalDeposited, calcUtilizationRatio } from './interest.cjs';
|
|
9
|
+
export { isWriteableContract } from './isWriteableContract.cjs';
|
|
25
10
|
export { mapValues } from './mapValues.cjs';
|
|
11
|
+
export { BigDecimalish, toBigDecimal } from './math/bigDecimal.cjs';
|
|
12
|
+
export { BigDecimals } from './math/BigDecimals.cjs';
|
|
13
|
+
export { clampBigDecimal } from './math/clamp.cjs';
|
|
14
|
+
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals } from './math/decimalAdjustment.cjs';
|
|
15
|
+
export { sumBigDecimalBy } from './math/sumBigDecimalBy.cjs';
|
|
16
|
+
export { toBigInt } from './math/toBigInt.cjs';
|
|
17
|
+
export { toIntegerString } from './math/toIntegerString.cjs';
|
|
18
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.cjs';
|
|
19
|
+
export { bitMaskValue } from './orders/appendix/bitMaskValue.cjs';
|
|
20
|
+
export { packOrderAppendix } from './orders/appendix/packOrderAppendix.cjs';
|
|
21
|
+
export { PackedOrderAppendixBits } from './orders/appendix/types.cjs';
|
|
22
|
+
export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.cjs';
|
|
23
|
+
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orders/orderNonce.cjs';
|
|
24
|
+
export { getDefaultRecvTime } from './orders/recvTime.cjs';
|
|
25
|
+
export { isPerpBalance, isPerpProduct, isSpotBalance, isSpotProduct } from './productTypeFilter.cjs';
|
|
26
26
|
export { TimeInSeconds, millisToSeconds, nowInSeconds } from './time.cjs';
|
|
27
27
|
export { toPrintableObject } from './toPrintableObject.cjs';
|
|
28
28
|
export { default as BigDecimal } from 'bignumber.js';
|
|
29
|
-
import '../types/orderAppendixTypes.cjs';
|
|
30
|
-
import '../types/OrderExecutionType.cjs';
|
|
31
|
-
import '../types/productTypes.cjs';
|
|
32
29
|
import '../types/balanceTypes.cjs';
|
|
33
30
|
import '../types/healthTypes.cjs';
|
|
31
|
+
import '../types/productTypes.cjs';
|
|
34
32
|
import 'viem';
|
|
35
33
|
import '../types/bytes.cjs';
|
|
36
34
|
import '../types/subaccountTypes.cjs';
|
|
37
35
|
import '../types/viemTypes.cjs';
|
|
36
|
+
import '../types/orderAppendixTypes.cjs';
|
|
37
|
+
import '../types/OrderExecutionType.cjs';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { getDefaultRecvTime } from './orders/recvTime.js';
|
|
3
|
-
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.js';
|
|
4
|
-
export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.js';
|
|
5
|
-
export { packOrderAppendix } from './orders/appendix/packOrderAppendix.js';
|
|
6
|
-
export { PackedOrderAppendixBits } from './orders/appendix/types.js';
|
|
7
|
-
export { bitMaskValue } from './orders/appendix/bitMaskValue.js';
|
|
8
|
-
export { calcBorrowRateForTimeRange, calcBorrowRatePerSecond, calcRealizedDepositRateForTimeRange, calcTotalBorrowed, calcTotalDeposited, calcUtilizationRatio } from './interest.js';
|
|
9
|
-
export { isPerpBalance, isPerpProduct, isSpotBalance, isSpotProduct } from './productTypeFilter.js';
|
|
1
|
+
export { AsyncResult, asyncResult } from './asyncResult.js';
|
|
10
2
|
export { calcPerpBalanceNotionalValue, calcPerpBalanceValue, calcSpotBalanceValue } from './balanceValue.js';
|
|
11
3
|
export { subaccountFromBytes32, subaccountFromHex, subaccountNameBytesToStr, subaccountNameToBytes12, subaccountToBytes32, subaccountToHex } from './bytes32.js';
|
|
12
4
|
export { createDeterministicLinkedSignerPrivateKey } from './createDeterministicLinkedSignerPrivateKey.js';
|
|
13
|
-
export { isWriteableContract } from './isWriteableContract.js';
|
|
14
5
|
export { WalletNotProvidedError } from './errors/WalletNotProvidedError.js';
|
|
15
|
-
export { BigDecimalish, toBigDecimal } from './math/bigDecimal.js';
|
|
16
|
-
export { toIntegerString } from './math/toIntegerString.js';
|
|
17
|
-
export { toBigInt } from './math/toBigInt.js';
|
|
18
|
-
export { clampBigDecimal } from './math/clamp.js';
|
|
19
|
-
export { sumBigDecimalBy } from './math/sumBigDecimalBy.js';
|
|
20
|
-
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals } from './math/decimalAdjustment.js';
|
|
21
|
-
export { BigDecimals } from './math/BigDecimals.js';
|
|
22
|
-
export { AsyncResult, asyncResult } from './asyncResult.js';
|
|
23
6
|
export { getValidatedAddress } from './getValidatedAddress.js';
|
|
24
7
|
export { getValidatedHex } from './getValidatedHex.js';
|
|
8
|
+
export { calcBorrowRateForTimeRange, calcBorrowRatePerSecond, calcRealizedDepositRateForTimeRange, calcTotalBorrowed, calcTotalDeposited, calcUtilizationRatio } from './interest.js';
|
|
9
|
+
export { isWriteableContract } from './isWriteableContract.js';
|
|
25
10
|
export { mapValues } from './mapValues.js';
|
|
11
|
+
export { BigDecimalish, toBigDecimal } from './math/bigDecimal.js';
|
|
12
|
+
export { BigDecimals } from './math/BigDecimals.js';
|
|
13
|
+
export { clampBigDecimal } from './math/clamp.js';
|
|
14
|
+
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals } from './math/decimalAdjustment.js';
|
|
15
|
+
export { sumBigDecimalBy } from './math/sumBigDecimalBy.js';
|
|
16
|
+
export { toBigInt } from './math/toBigInt.js';
|
|
17
|
+
export { toIntegerString } from './math/toIntegerString.js';
|
|
18
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.js';
|
|
19
|
+
export { bitMaskValue } from './orders/appendix/bitMaskValue.js';
|
|
20
|
+
export { packOrderAppendix } from './orders/appendix/packOrderAppendix.js';
|
|
21
|
+
export { PackedOrderAppendixBits } from './orders/appendix/types.js';
|
|
22
|
+
export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.js';
|
|
23
|
+
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orders/orderNonce.js';
|
|
24
|
+
export { getDefaultRecvTime } from './orders/recvTime.js';
|
|
25
|
+
export { isPerpBalance, isPerpProduct, isSpotBalance, isSpotProduct } from './productTypeFilter.js';
|
|
26
26
|
export { TimeInSeconds, millisToSeconds, nowInSeconds } from './time.js';
|
|
27
27
|
export { toPrintableObject } from './toPrintableObject.js';
|
|
28
28
|
export { default as BigDecimal } from 'bignumber.js';
|
|
29
|
-
import '../types/orderAppendixTypes.js';
|
|
30
|
-
import '../types/OrderExecutionType.js';
|
|
31
|
-
import '../types/productTypes.js';
|
|
32
29
|
import '../types/balanceTypes.js';
|
|
33
30
|
import '../types/healthTypes.js';
|
|
31
|
+
import '../types/productTypes.js';
|
|
34
32
|
import 'viem';
|
|
35
33
|
import '../types/bytes.js';
|
|
36
34
|
import '../types/subaccountTypes.js';
|
|
37
35
|
import '../types/viemTypes.js';
|
|
36
|
+
import '../types/orderAppendixTypes.js';
|
|
37
|
+
import '../types/OrderExecutionType.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// src/utils/index.ts
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./interest.js";
|
|
4
|
-
export * from "./productTypeFilter.js";
|
|
2
|
+
export * from "./asyncResult.js";
|
|
5
3
|
export * from "./balanceValue.js";
|
|
6
4
|
export * from "./bytes32.js";
|
|
7
5
|
export * from "./createDeterministicLinkedSignerPrivateKey.js";
|
|
8
|
-
export * from "./isWriteableContract.js";
|
|
9
6
|
export * from "./errors/index.js";
|
|
10
|
-
export * from "./math/index.js";
|
|
11
|
-
export * from "./asyncResult.js";
|
|
12
7
|
export * from "./getValidatedAddress.js";
|
|
13
8
|
export * from "./getValidatedHex.js";
|
|
9
|
+
export * from "./interest.js";
|
|
10
|
+
export * from "./isWriteableContract.js";
|
|
14
11
|
export * from "./mapValues.js";
|
|
12
|
+
export * from "./math/index.js";
|
|
13
|
+
export * from "./orders/index.js";
|
|
14
|
+
export * from "./productTypeFilter.js";
|
|
15
15
|
export * from "./time.js";
|
|
16
16
|
export * from "./toPrintableObject.js";
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './asyncResult';\nexport * from './balanceValue';\nexport * from './bytes32';\nexport * from './createDeterministicLinkedSignerPrivateKey';\nexport * from './errors';\nexport * from './getValidatedAddress';\nexport * from './getValidatedHex';\nexport * from './interest';\nexport * from './isWriteableContract';\nexport * from './mapValues';\nexport * from './math';\nexport * from './orders';\nexport * from './productTypeFilter';\nexport * from './time';\nexport * from './toPrintableObject';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -37,10 +37,11 @@ module.exports = __toCommonJS(bigDecimal_exports);
|
|
|
37
37
|
var import_bignumber = __toESM(require("bignumber.js"), 1);
|
|
38
38
|
var import_bignumber2 = __toESM(require("bignumber.js"), 1);
|
|
39
39
|
function toBigDecimal(val) {
|
|
40
|
+
if (import_bignumber.default.isBigNumber(val)) {
|
|
41
|
+
return val;
|
|
42
|
+
}
|
|
40
43
|
const bnConstructorVal = (() => {
|
|
41
|
-
if (val
|
|
42
|
-
return val;
|
|
43
|
-
} else if (typeof val === "string" || typeof val === "number") {
|
|
44
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
44
45
|
return val;
|
|
45
46
|
} else if (typeof val === "bigint") {
|
|
46
47
|
return val.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n if (BigDecimal.isBigNumber(val)) {\n return val;\n }\n\n const bnConstructorVal = (() => {\n if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsC;AAGtC,IAAAA,oBAAsC;AAe/B,SAAS,aAAa,KAAgC;AAC3D,MAAI,iBAAAC,QAAW,YAAY,GAAG,GAAG;AAC/B,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,MAAM;AAC9B,QAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AACtD,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,iBAAAA,QAAW,gBAAgB;AACxC;","names":["import_bignumber","BigDecimal"]}
|
|
@@ -4,10 +4,11 @@ import "../../chunk-5WRI5ZAA.js";
|
|
|
4
4
|
import { default as BigDecimal } from "bignumber.js";
|
|
5
5
|
import { default as default2 } from "bignumber.js";
|
|
6
6
|
function toBigDecimal(val) {
|
|
7
|
+
if (BigDecimal.isBigNumber(val)) {
|
|
8
|
+
return val;
|
|
9
|
+
}
|
|
7
10
|
const bnConstructorVal = (() => {
|
|
8
|
-
if (val
|
|
9
|
-
return val;
|
|
10
|
-
} else if (typeof val === "string" || typeof val === "number") {
|
|
11
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
11
12
|
return val;
|
|
12
13
|
} else if (typeof val === "bigint") {
|
|
13
14
|
return val.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n if (BigDecimal.isBigNumber(val)) {\n return val;\n }\n\n const bnConstructorVal = (() => {\n if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;AAAA,SAAS,WAAW,kBAAkB;AAGtC,SAAoB,WAAXA,gBAA6B;AAe/B,SAAS,aAAa,KAAgC;AAC3D,MAAI,WAAW,YAAY,GAAG,GAAG;AAC/B,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,MAAM;AAC9B,QAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AACtD,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,WAAW,gBAAgB;AACxC;","names":["default"]}
|
|
@@ -18,20 +18,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var math_exports = {};
|
|
19
19
|
module.exports = __toCommonJS(math_exports);
|
|
20
20
|
__reExport(math_exports, require("./bigDecimal.cjs"), module.exports);
|
|
21
|
-
__reExport(math_exports, require("./
|
|
22
|
-
__reExport(math_exports, require("./toBigInt.cjs"), module.exports);
|
|
21
|
+
__reExport(math_exports, require("./BigDecimals.cjs"), module.exports);
|
|
23
22
|
__reExport(math_exports, require("./clamp.cjs"), module.exports);
|
|
24
|
-
__reExport(math_exports, require("./sumBigDecimalBy.cjs"), module.exports);
|
|
25
23
|
__reExport(math_exports, require("./decimalAdjustment.cjs"), module.exports);
|
|
26
|
-
__reExport(math_exports, require("./
|
|
24
|
+
__reExport(math_exports, require("./sumBigDecimalBy.cjs"), module.exports);
|
|
25
|
+
__reExport(math_exports, require("./toBigInt.cjs"), module.exports);
|
|
26
|
+
__reExport(math_exports, require("./toIntegerString.cjs"), module.exports);
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
|
29
29
|
...require("./bigDecimal.cjs"),
|
|
30
|
-
...require("./
|
|
31
|
-
...require("./toBigInt.cjs"),
|
|
30
|
+
...require("./BigDecimals.cjs"),
|
|
32
31
|
...require("./clamp.cjs"),
|
|
33
|
-
...require("./sumBigDecimalBy.cjs"),
|
|
34
32
|
...require("./decimalAdjustment.cjs"),
|
|
35
|
-
...require("./
|
|
33
|
+
...require("./sumBigDecimalBy.cjs"),
|
|
34
|
+
...require("./toBigInt.cjs"),
|
|
35
|
+
...require("./toIntegerString.cjs")
|
|
36
36
|
});
|
|
37
37
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/index.ts"],"sourcesContent":["export * from './bigDecimal';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/index.ts"],"sourcesContent":["export * from './bigDecimal';\nexport * from './BigDecimals';\nexport * from './clamp';\nexport * from './decimalAdjustment';\nexport * from './sumBigDecimalBy';\nexport * from './toBigInt';\nexport * from './toIntegerString';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,6BAAd;AACA,yBAAc,8BADd;AAEA,yBAAc,wBAFd;AAGA,yBAAc,oCAHd;AAIA,yBAAc,kCAJd;AAKA,yBAAc,2BALd;AAMA,yBAAc,kCANd;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { BigDecimalish, toBigDecimal } from './bigDecimal.cjs';
|
|
2
|
-
export {
|
|
3
|
-
export { toBigInt } from './toBigInt.cjs';
|
|
2
|
+
export { BigDecimals } from './BigDecimals.cjs';
|
|
4
3
|
export { clampBigDecimal } from './clamp.cjs';
|
|
5
|
-
export { sumBigDecimalBy } from './sumBigDecimalBy.cjs';
|
|
6
4
|
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals } from './decimalAdjustment.cjs';
|
|
7
|
-
export {
|
|
5
|
+
export { sumBigDecimalBy } from './sumBigDecimalBy.cjs';
|
|
6
|
+
export { toBigInt } from './toBigInt.cjs';
|
|
7
|
+
export { toIntegerString } from './toIntegerString.cjs';
|
|
8
8
|
export { default as BigDecimal } from 'bignumber.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { BigDecimalish, toBigDecimal } from './bigDecimal.js';
|
|
2
|
-
export {
|
|
3
|
-
export { toBigInt } from './toBigInt.js';
|
|
2
|
+
export { BigDecimals } from './BigDecimals.js';
|
|
4
3
|
export { clampBigDecimal } from './clamp.js';
|
|
5
|
-
export { sumBigDecimalBy } from './sumBigDecimalBy.js';
|
|
6
4
|
export { NADO_PRODUCT_DECIMALS, addDecimals, removeDecimals } from './decimalAdjustment.js';
|
|
7
|
-
export {
|
|
5
|
+
export { sumBigDecimalBy } from './sumBigDecimalBy.js';
|
|
6
|
+
export { toBigInt } from './toBigInt.js';
|
|
7
|
+
export { toIntegerString } from './toIntegerString.js';
|
|
8
8
|
export { default as BigDecimal } from 'bignumber.js';
|
package/dist/utils/math/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/utils/math/index.ts
|
|
2
2
|
export * from "./bigDecimal.js";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./toBigInt.js";
|
|
3
|
+
export * from "./BigDecimals.js";
|
|
5
4
|
export * from "./clamp.js";
|
|
6
|
-
export * from "./sumBigDecimalBy.js";
|
|
7
5
|
export * from "./decimalAdjustment.js";
|
|
8
|
-
export * from "./
|
|
6
|
+
export * from "./sumBigDecimalBy.js";
|
|
7
|
+
export * from "./toBigInt.js";
|
|
8
|
+
export * from "./toIntegerString.js";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/index.ts"],"sourcesContent":["export * from './bigDecimal';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/index.ts"],"sourcesContent":["export * from './bigDecimal';\nexport * from './BigDecimals';\nexport * from './clamp';\nexport * from './decimalAdjustment';\nexport * from './sumBigDecimalBy';\nexport * from './toBigInt';\nexport * from './toIntegerString';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/orders/appendix/appendixIsolatedValue.ts
|
|
21
|
+
var appendixIsolatedValue_exports = {};
|
|
22
|
+
__export(appendixIsolatedValue_exports, {
|
|
23
|
+
packIsolatedOrderAppendixValue: () => packIsolatedOrderAppendixValue,
|
|
24
|
+
unpackIsolatedOrderAppendixValue: () => unpackIsolatedOrderAppendixValue
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(appendixIsolatedValue_exports);
|
|
27
|
+
var import_math = require("../../math/index.cjs");
|
|
28
|
+
var import_bitMaskValue = require("./bitMaskValue.cjs");
|
|
29
|
+
var APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;
|
|
30
|
+
var MARGIN_DECIMAL_ADJUSTMENT = import_math.NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;
|
|
31
|
+
function packIsolatedOrderAppendixValue({
|
|
32
|
+
margin
|
|
33
|
+
}) {
|
|
34
|
+
return (0, import_bitMaskValue.bitMaskValue)(
|
|
35
|
+
(0, import_math.toBigInt)((0, import_math.removeDecimals)(margin, MARGIN_DECIMAL_ADJUSTMENT)),
|
|
36
|
+
64
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function unpackIsolatedOrderAppendixValue(value) {
|
|
40
|
+
const margin = (0, import_bitMaskValue.bitMaskValue)(value, 64);
|
|
41
|
+
return {
|
|
42
|
+
margin: (0, import_math.toBigInt)((0, import_math.addDecimals)(margin, MARGIN_DECIMAL_ADJUSTMENT))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
packIsolatedOrderAppendixValue,
|
|
48
|
+
unpackIsolatedOrderAppendixValue
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=appendixIsolatedValue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/appendixIsolatedValue.ts"],"sourcesContent":["import { OrderAppendixIsolatedFields } from '../../../types';\nimport {\n addDecimals,\n NADO_PRODUCT_DECIMALS,\n removeDecimals,\n toBigInt,\n} from '../../math';\nimport { bitMaskValue } from './bitMaskValue';\n\nconst APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;\n\n/* Appendix v1 uses x6 precision, so we need to adjust precision to/from SDK's usual precision */\nconst MARGIN_DECIMAL_ADJUSTMENT =\n NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;\n\n/**\n * Packs the provided margin into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | margin_x6 |\n * |-----------|\n * | 63..0 |\n * | 64 bits |\n *\n */\nexport function packIsolatedOrderAppendixValue({\n margin,\n}: OrderAppendixIsolatedFields): bigint {\n return bitMaskValue(\n toBigInt(removeDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n 64,\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for Isolated orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - margin_x6: bigint, from bits 63..0\n */\nexport function unpackIsolatedOrderAppendixValue(\n value: bigint,\n): OrderAppendixIsolatedFields {\n const margin = bitMaskValue(value, 64);\n return {\n margin: toBigInt(addDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAKO;AACP,0BAA6B;AAE7B,IAAM,kCAAkC;AAGxC,IAAM,4BACJ,oCAAwB;AAYnB,SAAS,+BAA+B;AAAA,EAC7C;AACF,GAAwC;AACtC,aAAO;AAAA,QACL,0BAAS,4BAAe,QAAQ,yBAAyB,CAAC;AAAA,IAC1D;AAAA,EACF;AACF;AASO,SAAS,iCACd,OAC6B;AAC7B,QAAM,aAAS,kCAAa,OAAO,EAAE;AACrC,SAAO;AAAA,IACL,YAAQ,0BAAS,yBAAY,QAAQ,yBAAyB,CAAC;AAAA,EACjE;AACF;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OrderAppendixIsolatedFields } from '../../../types/orderAppendixTypes.cjs';
|
|
2
|
+
import '../../math/bigDecimal.cjs';
|
|
3
|
+
import 'bignumber.js';
|
|
4
|
+
import '../../../types/OrderExecutionType.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Packs the provided margin into a single 64-bit bigint.
|
|
8
|
+
*
|
|
9
|
+
* Bit layout (MSB → LSB):
|
|
10
|
+
* | margin_x6 |
|
|
11
|
+
* |-----------|
|
|
12
|
+
* | 63..0 |
|
|
13
|
+
* | 64 bits |
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
declare function packIsolatedOrderAppendixValue({ margin, }: OrderAppendixIsolatedFields): bigint;
|
|
17
|
+
/**
|
|
18
|
+
* Unpacks a 64-bit bigint into its component fields for Isolated orders.
|
|
19
|
+
*
|
|
20
|
+
* @param value 64-bit bigint to unpack
|
|
21
|
+
* @returns Object with:
|
|
22
|
+
* - margin_x6: bigint, from bits 63..0
|
|
23
|
+
*/
|
|
24
|
+
declare function unpackIsolatedOrderAppendixValue(value: bigint): OrderAppendixIsolatedFields;
|
|
25
|
+
|
|
26
|
+
export { packIsolatedOrderAppendixValue, unpackIsolatedOrderAppendixValue };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OrderAppendixIsolatedFields } from '../../../types/orderAppendixTypes.js';
|
|
2
|
+
import '../../math/bigDecimal.js';
|
|
3
|
+
import 'bignumber.js';
|
|
4
|
+
import '../../../types/OrderExecutionType.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Packs the provided margin into a single 64-bit bigint.
|
|
8
|
+
*
|
|
9
|
+
* Bit layout (MSB → LSB):
|
|
10
|
+
* | margin_x6 |
|
|
11
|
+
* |-----------|
|
|
12
|
+
* | 63..0 |
|
|
13
|
+
* | 64 bits |
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
declare function packIsolatedOrderAppendixValue({ margin, }: OrderAppendixIsolatedFields): bigint;
|
|
17
|
+
/**
|
|
18
|
+
* Unpacks a 64-bit bigint into its component fields for Isolated orders.
|
|
19
|
+
*
|
|
20
|
+
* @param value 64-bit bigint to unpack
|
|
21
|
+
* @returns Object with:
|
|
22
|
+
* - margin_x6: bigint, from bits 63..0
|
|
23
|
+
*/
|
|
24
|
+
declare function unpackIsolatedOrderAppendixValue(value: bigint): OrderAppendixIsolatedFields;
|
|
25
|
+
|
|
26
|
+
export { packIsolatedOrderAppendixValue, unpackIsolatedOrderAppendixValue };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "../../../chunk-5WRI5ZAA.js";
|
|
2
|
+
|
|
3
|
+
// src/utils/orders/appendix/appendixIsolatedValue.ts
|
|
4
|
+
import {
|
|
5
|
+
addDecimals,
|
|
6
|
+
NADO_PRODUCT_DECIMALS,
|
|
7
|
+
removeDecimals,
|
|
8
|
+
toBigInt
|
|
9
|
+
} from "../../math/index.js";
|
|
10
|
+
import { bitMaskValue } from "./bitMaskValue.js";
|
|
11
|
+
var APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;
|
|
12
|
+
var MARGIN_DECIMAL_ADJUSTMENT = NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;
|
|
13
|
+
function packIsolatedOrderAppendixValue({
|
|
14
|
+
margin
|
|
15
|
+
}) {
|
|
16
|
+
return bitMaskValue(
|
|
17
|
+
toBigInt(removeDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),
|
|
18
|
+
64
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function unpackIsolatedOrderAppendixValue(value) {
|
|
22
|
+
const margin = bitMaskValue(value, 64);
|
|
23
|
+
return {
|
|
24
|
+
margin: toBigInt(addDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
packIsolatedOrderAppendixValue,
|
|
29
|
+
unpackIsolatedOrderAppendixValue
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=appendixIsolatedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/appendixIsolatedValue.ts"],"sourcesContent":["import { OrderAppendixIsolatedFields } from '../../../types';\nimport {\n addDecimals,\n NADO_PRODUCT_DECIMALS,\n removeDecimals,\n toBigInt,\n} from '../../math';\nimport { bitMaskValue } from './bitMaskValue';\n\nconst APPENDIX_V1_ISO_MARGIN_DECIMALS = 6;\n\n/* Appendix v1 uses x6 precision, so we need to adjust precision to/from SDK's usual precision */\nconst MARGIN_DECIMAL_ADJUSTMENT =\n NADO_PRODUCT_DECIMALS - APPENDIX_V1_ISO_MARGIN_DECIMALS;\n\n/**\n * Packs the provided margin into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | margin_x6 |\n * |-----------|\n * | 63..0 |\n * | 64 bits |\n *\n */\nexport function packIsolatedOrderAppendixValue({\n margin,\n}: OrderAppendixIsolatedFields): bigint {\n return bitMaskValue(\n toBigInt(removeDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n 64,\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for Isolated orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - margin_x6: bigint, from bits 63..0\n */\nexport function unpackIsolatedOrderAppendixValue(\n value: bigint,\n): OrderAppendixIsolatedFields {\n const margin = bitMaskValue(value, 64);\n return {\n margin: toBigInt(addDecimals(margin, MARGIN_DECIMAL_ADJUSTMENT)),\n };\n}\n"],"mappings":";;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAE7B,IAAM,kCAAkC;AAGxC,IAAM,4BACJ,wBAAwB;AAYnB,SAAS,+BAA+B;AAAA,EAC7C;AACF,GAAwC;AACtC,SAAO;AAAA,IACL,SAAS,eAAe,QAAQ,yBAAyB,CAAC;AAAA,IAC1D;AAAA,EACF;AACF;AASO,SAAS,iCACd,OAC6B;AAC7B,QAAM,SAAS,aAAa,OAAO,EAAE;AACrC,SAAO;AAAA,IACL,QAAQ,SAAS,YAAY,QAAQ,yBAAyB,CAAC;AAAA,EACjE;AACF;","names":[]}
|
|
@@ -31,12 +31,11 @@ function packTwapOrderAppendixValue({
|
|
|
31
31
|
}) {
|
|
32
32
|
const numOrdersBigInt = (0, import_math.toBigInt)(numOrders);
|
|
33
33
|
const slippageX6BigInt = (0, import_math.toBigInt)((0, import_math.addDecimals)(slippageFrac, 6));
|
|
34
|
-
return (numOrdersBigInt & 0xffffffffn) <<
|
|
35
|
-
0n & 0xffffffffn;
|
|
34
|
+
return (numOrdersBigInt & 0xffffffffn) << 32n | slippageX6BigInt & 0xffffffffn;
|
|
36
35
|
}
|
|
37
36
|
function unpackTwapOrderAppendixValue(value) {
|
|
38
|
-
const numOrders = value >>
|
|
39
|
-
const slippageX6 = value
|
|
37
|
+
const numOrders = value >> 32n & 0xffffffffn;
|
|
38
|
+
const slippageX6 = value & 0xffffffffn;
|
|
40
39
|
return {
|
|
41
40
|
numOrders: Number(numOrders),
|
|
42
41
|
slippageFrac: (0, import_math.removeDecimals)(slippageX6, 6).toNumber()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 |\n * |-----------|-------------|\n * | 63..32 | 31..0 |\n * | 32 bits | 32 bits |\n *\n * - `times` occupies bits 63..32 (most significant 32 bits)\n * - `slippage_x6` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 32n) | (slippageX6BigInt & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for TWAP orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 63..32\n * - slippage_x6: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 32n) & 0xffffffffn;\n const slippageX6 = value & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsD;AAc/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,sBAAkB,sBAAS,SAAS;AAC1C,QAAM,uBAAmB,0BAAS,yBAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,MAAQ,mBAAmB;AAEnE;AAUO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAa,QAAQ;AAE3B,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,kBAAc,4BAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
|
|
@@ -4,27 +4,25 @@ import 'bignumber.js';
|
|
|
4
4
|
import '../../../types/OrderExecutionType.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Packs the provided fields into a single
|
|
7
|
+
* Packs the provided fields into a single 64-bit bigint.
|
|
8
8
|
*
|
|
9
9
|
* Bit layout (MSB → LSB):
|
|
10
|
-
* | times | slippage_x6 |
|
|
11
|
-
*
|
|
12
|
-
* |
|
|
13
|
-
* | 32 bits | 32 bits |
|
|
10
|
+
* | times | slippage_x6 |
|
|
11
|
+
* |-----------|-------------|
|
|
12
|
+
* | 63..32 | 31..0 |
|
|
13
|
+
* | 32 bits | 32 bits |
|
|
14
14
|
*
|
|
15
|
-
* - `times` occupies bits
|
|
16
|
-
* - `slippage_x6` occupies bits
|
|
17
|
-
* - `reserved` occupies bits 31..0 (least significant 32 bits)
|
|
15
|
+
* - `times` occupies bits 63..32 (most significant 32 bits)
|
|
16
|
+
* - `slippage_x6` occupies bits 31..0 (least significant 32 bits)
|
|
18
17
|
*/
|
|
19
18
|
declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
|
|
20
19
|
/**
|
|
21
|
-
* Unpacks a
|
|
20
|
+
* Unpacks a 64-bit bigint into its component fields for TWAP orders.
|
|
22
21
|
*
|
|
23
|
-
* @param value
|
|
22
|
+
* @param value 64-bit bigint to unpack
|
|
24
23
|
* @returns Object with:
|
|
25
|
-
* - times: number, from bits
|
|
26
|
-
* - slippage_x6: number, from bits
|
|
27
|
-
* - reserved: number, from bits 31..0
|
|
24
|
+
* - times: number, from bits 63..32
|
|
25
|
+
* - slippage_x6: number, from bits 31..0
|
|
28
26
|
*/
|
|
29
27
|
declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
|
|
30
28
|
|
|
@@ -4,27 +4,25 @@ import 'bignumber.js';
|
|
|
4
4
|
import '../../../types/OrderExecutionType.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Packs the provided fields into a single
|
|
7
|
+
* Packs the provided fields into a single 64-bit bigint.
|
|
8
8
|
*
|
|
9
9
|
* Bit layout (MSB → LSB):
|
|
10
|
-
* | times | slippage_x6 |
|
|
11
|
-
*
|
|
12
|
-
* |
|
|
13
|
-
* | 32 bits | 32 bits |
|
|
10
|
+
* | times | slippage_x6 |
|
|
11
|
+
* |-----------|-------------|
|
|
12
|
+
* | 63..32 | 31..0 |
|
|
13
|
+
* | 32 bits | 32 bits |
|
|
14
14
|
*
|
|
15
|
-
* - `times` occupies bits
|
|
16
|
-
* - `slippage_x6` occupies bits
|
|
17
|
-
* - `reserved` occupies bits 31..0 (least significant 32 bits)
|
|
15
|
+
* - `times` occupies bits 63..32 (most significant 32 bits)
|
|
16
|
+
* - `slippage_x6` occupies bits 31..0 (least significant 32 bits)
|
|
18
17
|
*/
|
|
19
18
|
declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
|
|
20
19
|
/**
|
|
21
|
-
* Unpacks a
|
|
20
|
+
* Unpacks a 64-bit bigint into its component fields for TWAP orders.
|
|
22
21
|
*
|
|
23
|
-
* @param value
|
|
22
|
+
* @param value 64-bit bigint to unpack
|
|
24
23
|
* @returns Object with:
|
|
25
|
-
* - times: number, from bits
|
|
26
|
-
* - slippage_x6: number, from bits
|
|
27
|
-
* - reserved: number, from bits 31..0
|
|
24
|
+
* - times: number, from bits 63..32
|
|
25
|
+
* - slippage_x6: number, from bits 31..0
|
|
28
26
|
*/
|
|
29
27
|
declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
|
|
30
28
|
|
|
@@ -8,12 +8,11 @@ function packTwapOrderAppendixValue({
|
|
|
8
8
|
}) {
|
|
9
9
|
const numOrdersBigInt = toBigInt(numOrders);
|
|
10
10
|
const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));
|
|
11
|
-
return (numOrdersBigInt & 0xffffffffn) <<
|
|
12
|
-
0n & 0xffffffffn;
|
|
11
|
+
return (numOrdersBigInt & 0xffffffffn) << 32n | slippageX6BigInt & 0xffffffffn;
|
|
13
12
|
}
|
|
14
13
|
function unpackTwapOrderAppendixValue(value) {
|
|
15
|
-
const numOrders = value >>
|
|
16
|
-
const slippageX6 = value
|
|
14
|
+
const numOrders = value >> 32n & 0xffffffffn;
|
|
15
|
+
const slippageX6 = value & 0xffffffffn;
|
|
17
16
|
return {
|
|
18
17
|
numOrders: Number(numOrders),
|
|
19
18
|
slippageFrac: removeDecimals(slippageX6, 6).toNumber()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/appendixTwapValue.ts"],"sourcesContent":["import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';\nimport { addDecimals, removeDecimals, toBigInt } from '../../math';\n\n/**\n * Packs the provided fields into a single 64-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 |\n * |-----------|-------------|\n * | 63..32 | 31..0 |\n * | 32 bits | 32 bits |\n *\n * - `times` occupies bits 63..32 (most significant 32 bits)\n * - `slippage_x6` occupies bits 31..0 (least significant 32 bits)\n */\nexport function packTwapOrderAppendixValue({\n numOrders,\n slippageFrac,\n}: OrderAppendixTwapFields): bigint {\n const numOrdersBigInt = toBigInt(numOrders);\n const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));\n\n return (\n ((numOrdersBigInt & 0xffffffffn) << 32n) | (slippageX6BigInt & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 64-bit bigint into its component fields for TWAP orders.\n *\n * @param value 64-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 63..32\n * - slippage_x6: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 32n) & 0xffffffffn;\n const slippageX6 = value & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;AACA,SAAS,aAAa,gBAAgB,gBAAgB;AAc/C,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAAoC;AAClC,QAAM,kBAAkB,SAAS,SAAS;AAC1C,QAAM,mBAAmB,SAAS,YAAY,cAAc,CAAC,CAAC;AAE9D,UACI,kBAAkB,gBAAgB,MAAQ,mBAAmB;AAEnE;AAUO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAa,QAAQ;AAE3B,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,cAAc,eAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
|
|
@@ -18,16 +18,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var appendix_exports = {};
|
|
19
19
|
module.exports = __toCommonJS(appendix_exports);
|
|
20
20
|
__reExport(appendix_exports, require("./appendixTwapValue.cjs"), module.exports);
|
|
21
|
-
__reExport(appendix_exports, require("./
|
|
21
|
+
__reExport(appendix_exports, require("./bitMaskValue.cjs"), module.exports);
|
|
22
22
|
__reExport(appendix_exports, require("./packOrderAppendix.cjs"), module.exports);
|
|
23
23
|
__reExport(appendix_exports, require("./types.cjs"), module.exports);
|
|
24
|
-
__reExport(appendix_exports, require("./
|
|
24
|
+
__reExport(appendix_exports, require("./unpackOrderAppendix.cjs"), module.exports);
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
...require("./appendixTwapValue.cjs"),
|
|
28
|
-
...require("./
|
|
28
|
+
...require("./bitMaskValue.cjs"),
|
|
29
29
|
...require("./packOrderAppendix.cjs"),
|
|
30
30
|
...require("./types.cjs"),
|
|
31
|
-
...require("./
|
|
31
|
+
...require("./unpackOrderAppendix.cjs")
|
|
32
32
|
});
|
|
33
33
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './bitMaskValue';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './unpackOrderAppendix';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,oCAAd;AACA,6BAAc,+BADd;AAEA,6BAAc,oCAFd;AAGA,6BAAc,wBAHd;AAIA,6BAAc,sCAJd;","names":[]}
|