@nadohq/shared 0.1.0-alpha.8 → 0.1.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/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 +329 -39
- package/dist/consts/chainEnvToChain.d.ts +329 -39
- package/dist/consts/chainEnvToChain.js +3 -3
- package/dist/consts/chainEnvToChain.js.map +1 -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.cjs.map +1 -1
- package/dist/eip712/eip712ValueTypes.d.cts +3 -3
- package/dist/eip712/eip712ValueTypes.d.ts +3 -3
- package/dist/eip712/getNadoEIP712Domain.cjs.map +1 -1
- package/dist/eip712/getNadoEIP712Domain.js.map +1 -1
- package/dist/eip712/getNadoEIP712PrimaryType.d.cts +1 -1
- package/dist/eip712/getNadoEIP712PrimaryType.d.ts +1 -1
- package/dist/eip712/getNadoEIP712Types.d.cts +1 -1
- package/dist/eip712/getNadoEIP712Types.d.ts +1 -1
- package/dist/eip712/getNadoEIP712Values.d.cts +1 -1
- package/dist/eip712/getNadoEIP712Values.d.ts +1 -1
- package/dist/eip712/getSignedTransactionRequest.d.cts +1 -1
- package/dist/eip712/getSignedTransactionRequest.d.ts +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/eip712/orderDigest.d.cts +1 -1
- package/dist/eip712/orderDigest.d.ts +1 -1
- package/dist/eip712/signableRequestType.d.cts +1 -1
- package/dist/eip712/signableRequestType.d.ts +1 -1
- package/dist/eip712/signatureParamTypes.cjs.map +1 -1
- package/dist/eip712/signatureParamTypes.d.cts +13 -13
- package/dist/eip712/signatureParamTypes.d.ts +13 -13
- package/dist/encoding/encoding.cjs +21 -0
- package/dist/encoding/encoding.cjs.map +1 -1
- package/dist/encoding/encoding.d.cts +28 -4
- package/dist/encoding/encoding.d.ts +28 -4
- package/dist/encoding/encoding.js +24 -1
- package/dist/encoding/encoding.js.map +1 -1
- package/dist/encoding/index.d.cts +3 -3
- package/dist/encoding/index.d.ts +3 -3
- package/dist/execute/approveDepositAllowance.cjs.map +1 -1
- package/dist/execute/approveDepositAllowance.d.cts +2 -2
- package/dist/execute/approveDepositAllowance.d.ts +2 -2
- package/dist/execute/approveDepositAllowance.js.map +1 -1
- package/dist/execute/depositCollateral.cjs.map +1 -1
- package/dist/execute/depositCollateral.d.cts +2 -2
- package/dist/execute/depositCollateral.d.ts +2 -2
- package/dist/execute/depositCollateral.js.map +1 -1
- package/dist/execute/index.d.cts +1 -1
- package/dist/execute/index.d.ts +1 -1
- 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.cjs.map +1 -1
- package/dist/types/balanceTypes.d.cts +5 -5
- package/dist/types/balanceTypes.d.ts +5 -5
- package/dist/types/healthTypes.cjs.map +1 -1
- package/dist/types/healthTypes.d.cts +4 -4
- package/dist/types/healthTypes.d.ts +4 -4
- 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/marketTypes.cjs.map +1 -1
- package/dist/types/marketTypes.d.cts +4 -4
- package/dist/types/marketTypes.d.ts +4 -4
- package/dist/types/orderAppendixTypes.cjs.map +1 -1
- package/dist/types/orderAppendixTypes.d.cts +27 -3
- package/dist/types/orderAppendixTypes.d.ts +27 -3
- package/dist/types/productTypes.cjs.map +1 -1
- package/dist/types/productTypes.d.cts +16 -16
- package/dist/types/productTypes.d.ts +16 -16
- package/dist/types/productTypes.js.map +1 -1
- package/dist/types/viemTypes.d.cts +1 -1
- package/dist/types/viemTypes.d.ts +1 -1
- package/dist/utils/balanceValue.cjs.map +1 -1
- package/dist/utils/balanceValue.d.cts +5 -5
- package/dist/utils/balanceValue.d.ts +5 -5
- package/dist/utils/balanceValue.js.map +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 +22 -22
- package/dist/utils/index.d.ts +22 -22
- package/dist/utils/index.js +6 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/interest.cjs +9 -9
- package/dist/utils/interest.cjs.map +1 -1
- package/dist/utils/interest.d.cts +8 -8
- package/dist/utils/interest.d.ts +8 -8
- package/dist/utils/interest.js +10 -14
- package/dist/utils/interest.js.map +1 -1
- package/dist/utils/math/{BigDecimals.cjs → BigNumbers.cjs} +13 -13
- package/dist/utils/math/BigNumbers.cjs.map +1 -0
- package/dist/utils/math/BigNumbers.d.cts +10 -0
- package/dist/utils/math/BigNumbers.d.ts +10 -0
- package/dist/utils/math/BigNumbers.js +14 -0
- package/dist/utils/math/BigNumbers.js.map +1 -0
- package/dist/utils/math/{bigDecimal.cjs → bigNumber.cjs} +12 -14
- package/dist/utils/math/bigNumber.cjs.map +1 -0
- package/dist/utils/math/bigNumber.d.cts +17 -0
- package/dist/utils/math/bigNumber.d.ts +17 -0
- package/dist/utils/math/bigNumber.js +22 -0
- package/dist/utils/math/bigNumber.js.map +1 -0
- package/dist/utils/math/clamp.cjs +3 -3
- package/dist/utils/math/clamp.cjs.map +1 -1
- package/dist/utils/math/clamp.d.cts +5 -5
- package/dist/utils/math/clamp.d.ts +5 -5
- package/dist/utils/math/clamp.js +2 -2
- package/dist/utils/math/clamp.js.map +1 -1
- package/dist/utils/math/decimalAdjustment.cjs +5 -5
- package/dist/utils/math/decimalAdjustment.cjs.map +1 -1
- package/dist/utils/math/decimalAdjustment.d.cts +6 -6
- package/dist/utils/math/decimalAdjustment.d.ts +6 -6
- package/dist/utils/math/decimalAdjustment.js +5 -5
- package/dist/utils/math/decimalAdjustment.js.map +1 -1
- package/dist/utils/math/index.cjs +10 -10
- package/dist/utils/math/index.cjs.map +1 -1
- package/dist/utils/math/index.d.cts +7 -7
- package/dist/utils/math/index.d.ts +7 -7
- package/dist/utils/math/index.js +5 -5
- package/dist/utils/math/index.js.map +1 -1
- package/dist/utils/math/{sumBigDecimalBy.cjs → sumBigNumberBy.cjs} +10 -10
- package/dist/utils/math/sumBigNumberBy.cjs.map +1 -0
- package/dist/utils/math/sumBigNumberBy.d.cts +10 -0
- package/dist/utils/math/sumBigNumberBy.d.ts +10 -0
- package/dist/utils/math/sumBigNumberBy.js +13 -0
- package/dist/utils/math/sumBigNumberBy.js.map +1 -0
- package/dist/utils/math/toBigInt.cjs.map +1 -1
- package/dist/utils/math/toBigInt.d.cts +3 -3
- package/dist/utils/math/toBigInt.d.ts +3 -3
- package/dist/utils/math/toBigInt.js.map +1 -1
- package/dist/utils/math/toIntegerString.cjs +2 -2
- package/dist/utils/math/toIntegerString.cjs.map +1 -1
- package/dist/utils/math/toIntegerString.d.cts +3 -3
- package/dist/utils/math/toIntegerString.d.ts +3 -3
- package/dist/utils/math/toIntegerString.js +2 -2
- package/dist/utils/math/toIntegerString.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 +12 -14
- package/dist/utils/orders/appendix/appendixTwapValue.d.ts +12 -14
- 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 +3 -3
- package/dist/utils/orders/appendix/index.d.ts +3 -3
- 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.d.cts +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.d.ts +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.d.cts +2 -2
- package/dist/utils/orders/appendix/unpackOrderAppendix.d.ts +2 -2
- 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 +5 -5
- package/dist/utils/orders/index.d.ts +5 -5
- 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 +29 -11
- 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 +19 -11
- package/dist/utils/toPrintableObject.js.map +1 -1
- package/package.json +14 -7
- 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/eip712ValueTypes.ts +2 -2
- package/src/eip712/getNadoEIP712Domain.ts +1 -1
- package/src/eip712/index.ts +6 -6
- package/src/eip712/signatureParamTypes.ts +13 -13
- package/src/encoding/encoding.ts +43 -1
- package/src/execute/approveDepositAllowance.ts +2 -2
- package/src/execute/depositCollateral.ts +2 -2
- package/src/types/ChainEnv.ts +1 -1
- package/src/types/balanceTypes.ts +4 -4
- package/src/types/healthTypes.ts +4 -4
- package/src/types/index.ts +3 -3
- package/src/types/marketTypes.ts +4 -4
- package/src/types/orderAppendixTypes.ts +27 -2
- package/src/types/productTypes.ts +16 -16
- package/src/utils/balanceValue.ts +4 -4
- package/src/utils/createDeterministicLinkedSignerPrivateKey.ts +1 -1
- package/src/utils/index.ts +6 -6
- package/src/utils/interest.ts +26 -31
- package/src/utils/math/BigNumbers.ts +8 -0
- package/src/utils/math/bigNumber.ts +31 -0
- package/src/utils/math/clamp.ts +4 -7
- package/src/utils/math/decimalAdjustment.ts +11 -10
- package/src/utils/math/index.ts +5 -5
- package/src/utils/math/sumBigNumberBy.ts +18 -0
- package/src/utils/math/toBigInt.ts +3 -3
- package/src/utils/math/toIntegerString.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 +24 -7
- package/src/utils/orders/index.ts +1 -1
- package/src/utils/productTypeFilter.ts +2 -2
- package/src/utils/toPrintableObject.ts +32 -12
- 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/dist/utils/math/BigDecimals.cjs.map +0 -1
- package/dist/utils/math/BigDecimals.d.cts +0 -8
- package/dist/utils/math/BigDecimals.d.ts +0 -8
- package/dist/utils/math/BigDecimals.js +0 -14
- package/dist/utils/math/BigDecimals.js.map +0 -1
- package/dist/utils/math/bigDecimal.cjs.map +0 -1
- package/dist/utils/math/bigDecimal.d.cts +0 -18
- package/dist/utils/math/bigDecimal.d.ts +0 -18
- package/dist/utils/math/bigDecimal.js +0 -23
- package/dist/utils/math/bigDecimal.js.map +0 -1
- package/dist/utils/math/sumBigDecimalBy.cjs.map +0 -1
- package/dist/utils/math/sumBigDecimalBy.d.cts +0 -10
- package/dist/utils/math/sumBigDecimalBy.d.ts +0 -10
- package/dist/utils/math/sumBigDecimalBy.js +0 -13
- package/dist/utils/math/sumBigDecimalBy.js.map +0 -1
- package/src/deployments/core/deployment.InkSepolia.json +0 -13
- package/src/deployments/core/deployment.arbitrumOne.json +0 -18
- package/src/utils/math/BigDecimals.ts +0 -8
- package/src/utils/math/bigDecimal.ts +0 -32
- package/src/utils/math/sumBigDecimalBy.ts +0 -18
|
@@ -11,7 +11,7 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
11
11
|
};
|
|
12
12
|
const packed = packOrderAppendix(appendix);
|
|
13
13
|
const unpacked = unpackOrderAppendix(packed);
|
|
14
|
-
expect(packed).toBe(
|
|
14
|
+
expect(packed).toBe(4097n);
|
|
15
15
|
expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
|
|
16
16
|
expect(unpacked.triggerType).toBe(appendix.triggerType);
|
|
17
17
|
expect(unpacked.reduceOnly).toBeFalsy();
|
|
@@ -25,7 +25,7 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
25
25
|
};
|
|
26
26
|
const packed = packOrderAppendix(appendix);
|
|
27
27
|
const unpacked = unpackOrderAppendix(packed);
|
|
28
|
-
expect(packed).toBe(
|
|
28
|
+
expect(packed).toBe(6145n);
|
|
29
29
|
expect(unpacked.reduceOnly).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -60,12 +60,12 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
60
60
|
orderExecutionType: 'default',
|
|
61
61
|
triggerType: 'price',
|
|
62
62
|
|
|
63
|
-
isolated: { margin:
|
|
63
|
+
isolated: { margin: 12345678901000000000000n },
|
|
64
64
|
};
|
|
65
65
|
const packed = packOrderAppendix(appendix);
|
|
66
66
|
const unpacked = unpackOrderAppendix(packed);
|
|
67
|
-
expect(packed).toBe(
|
|
68
|
-
expect(unpacked.isolated?.margin).toBe(
|
|
67
|
+
expect(packed).toBe(227737579102942800187821658369n);
|
|
68
|
+
expect(unpacked.isolated?.margin).toBe(appendix.isolated?.margin);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('should handle TWAP fields', () => {
|
|
@@ -77,7 +77,7 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
77
77
|
};
|
|
78
78
|
const packed = packOrderAppendix(appendix);
|
|
79
79
|
const unpacked = unpackOrderAppendix(packed);
|
|
80
|
-
expect(packed).toBe(
|
|
80
|
+
expect(packed).toBe(792281717376363744483197591553n);
|
|
81
81
|
expect(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 0.005 });
|
|
82
82
|
});
|
|
83
83
|
|
|
@@ -86,16 +86,16 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
86
86
|
orderExecutionType: 'post_only',
|
|
87
87
|
triggerType: undefined,
|
|
88
88
|
reduceOnly: true,
|
|
89
|
-
isolated: { margin:
|
|
89
|
+
isolated: { margin: 18446744073709551615n }, // 2^64-1
|
|
90
90
|
};
|
|
91
91
|
const packed = packOrderAppendix(appendix);
|
|
92
92
|
const unpacked = unpackOrderAppendix(packed);
|
|
93
93
|
expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);
|
|
94
94
|
expect(unpacked.triggerType).toBe(appendix.triggerType);
|
|
95
95
|
expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);
|
|
96
|
-
expect(unpacked.isolated?.margin).toBe(
|
|
96
|
+
expect(unpacked.isolated?.margin).toBe(18446744000000000000n);
|
|
97
97
|
expect(unpacked.twap).toBe(undefined);
|
|
98
|
-
expect(packed).toBe(
|
|
98
|
+
expect(packed).toBe(340282365561237229015142145n);
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
it('should handle max values for all fields for TWAP orders', () => {
|
|
@@ -104,7 +104,6 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
104
104
|
triggerType: 'twap_custom_amounts',
|
|
105
105
|
reduceOnly: true,
|
|
106
106
|
twap: {
|
|
107
|
-
// max 32-bit unsigned int
|
|
108
107
|
numOrders: 4294967295,
|
|
109
108
|
slippageFrac: 0.000001,
|
|
110
109
|
},
|
|
@@ -116,6 +115,64 @@ describe('OrderAppendix packing/unpacking', () => {
|
|
|
116
115
|
expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);
|
|
117
116
|
expect(unpacked.twap?.slippageFrac).toBe(0.000001);
|
|
118
117
|
expect(unpacked.twap?.numOrders).toBe(4294967295);
|
|
119
|
-
expect(packed).toBe(
|
|
118
|
+
expect(packed).toBe(340282366841710300967557013911933828609n);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should handle builder fields', () => {
|
|
122
|
+
const appendix: OrderAppendix = {
|
|
123
|
+
orderExecutionType: 'default',
|
|
124
|
+
builder: { builderId: 123, builderFeeRate: 500 },
|
|
125
|
+
};
|
|
126
|
+
const packed = packOrderAppendix(appendix);
|
|
127
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
128
|
+
expect(unpacked.builder?.builderId).toBe(123);
|
|
129
|
+
expect(unpacked.builder?.builderFeeRate).toBe(500);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should handle builder with zero fee rate', () => {
|
|
133
|
+
const appendix: OrderAppendix = {
|
|
134
|
+
orderExecutionType: 'default',
|
|
135
|
+
builder: { builderId: 42, builderFeeRate: 0 },
|
|
136
|
+
};
|
|
137
|
+
const packed = packOrderAppendix(appendix);
|
|
138
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
139
|
+
expect(unpacked.builder?.builderId).toBe(42);
|
|
140
|
+
expect(unpacked.builder?.builderFeeRate).toBe(0);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should handle builder with max values', () => {
|
|
144
|
+
const appendix: OrderAppendix = {
|
|
145
|
+
orderExecutionType: 'default',
|
|
146
|
+
builder: { builderId: 65535, builderFeeRate: 1023 }, // 16 bits, 10 bits max
|
|
147
|
+
};
|
|
148
|
+
const packed = packOrderAppendix(appendix);
|
|
149
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
150
|
+
expect(unpacked.builder?.builderId).toBe(65535);
|
|
151
|
+
expect(unpacked.builder?.builderFeeRate).toBe(1023);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should handle builder combined with other flags', () => {
|
|
155
|
+
const appendix: OrderAppendix = {
|
|
156
|
+
orderExecutionType: 'ioc',
|
|
157
|
+
reduceOnly: true,
|
|
158
|
+
triggerType: 'price',
|
|
159
|
+
builder: { builderId: 5, builderFeeRate: 100 },
|
|
160
|
+
};
|
|
161
|
+
const packed = packOrderAppendix(appendix);
|
|
162
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
163
|
+
expect(unpacked.orderExecutionType).toBe('ioc');
|
|
164
|
+
expect(unpacked.reduceOnly).toBe(true);
|
|
165
|
+
expect(unpacked.triggerType).toBe('price');
|
|
166
|
+
expect(unpacked.builder?.builderId).toBe(5);
|
|
167
|
+
expect(unpacked.builder?.builderFeeRate).toBe(100);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should not return builder fields when builderId is 0', () => {
|
|
171
|
+
const appendix: OrderAppendix = {
|
|
172
|
+
orderExecutionType: 'default',
|
|
173
|
+
};
|
|
174
|
+
const packed = packOrderAppendix(appendix);
|
|
175
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
176
|
+
expect(unpacked.builder).toBeUndefined();
|
|
120
177
|
});
|
|
121
178
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrderAppendix } from '../../../types/orderAppendixTypes';
|
|
2
|
-
import {
|
|
2
|
+
import { packIsolatedOrderAppendixValue } from './appendixIsolatedValue';
|
|
3
3
|
import { packTwapOrderAppendixValue } from './appendixTwapValue';
|
|
4
4
|
import { bitMaskValue } from './bitMaskValue';
|
|
5
5
|
import { PackedOrderAppendixBits } from './types';
|
|
@@ -12,7 +12,7 @@ function mapOrderAppendixToBitValues(
|
|
|
12
12
|
return packTwapOrderAppendixValue(appendix.twap);
|
|
13
13
|
}
|
|
14
14
|
if (appendix.isolated) {
|
|
15
|
-
return
|
|
15
|
+
return packIsolatedOrderAppendixValue(appendix.isolated);
|
|
16
16
|
}
|
|
17
17
|
return 0n;
|
|
18
18
|
})();
|
|
@@ -43,12 +43,14 @@ function mapOrderAppendixToBitValues(
|
|
|
43
43
|
|
|
44
44
|
return {
|
|
45
45
|
value,
|
|
46
|
+
builderId: appendix.builder?.builderId ?? 0,
|
|
47
|
+
builderFeeRate: appendix.builder?.builderFeeRate ?? 0,
|
|
46
48
|
reserved: 0,
|
|
47
49
|
trigger,
|
|
48
50
|
reduceOnly: appendix.reduceOnly ? 1 : 0,
|
|
49
51
|
orderType,
|
|
50
52
|
isolated: appendix.isolated ? 1 : 0,
|
|
51
|
-
version:
|
|
53
|
+
version: 1,
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -59,9 +61,11 @@ function mapOrderAppendixToBitValues(
|
|
|
59
61
|
export function packOrderAppendix(appendix: OrderAppendix): bigint {
|
|
60
62
|
const bits = mapOrderAppendixToBitValues(appendix);
|
|
61
63
|
|
|
62
|
-
// Ensure value is within
|
|
63
|
-
let packed = bitMaskValue(bits.value,
|
|
64
|
-
packed = (packed <<
|
|
64
|
+
// Ensure value is within 64 bits
|
|
65
|
+
let packed = bitMaskValue(bits.value, 64);
|
|
66
|
+
packed = (packed << 16n) | bitMaskValue(bits.builderId, 16);
|
|
67
|
+
packed = (packed << 10n) | bitMaskValue(bits.builderFeeRate, 10);
|
|
68
|
+
packed = (packed << 24n) | bitMaskValue(bits.reserved, 24);
|
|
65
69
|
packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);
|
|
66
70
|
packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);
|
|
67
71
|
packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bit layout for OrderAppendix packing (MSB → LSB):
|
|
3
3
|
*
|
|
4
|
-
* | value | reserved | trigger | reduceOnly | orderType | isolated | version |
|
|
5
|
-
*
|
|
6
|
-
* | 127..
|
|
7
|
-
* |
|
|
4
|
+
* | value | builderId | builderFeeRate | reserved | trigger | reduceOnly | orderType | isolated | version |
|
|
5
|
+
* |-----------|-----------|----------------|----------|---------|------------|-----------|----------|---------|
|
|
6
|
+
* | 127..64 | 63..48 | 47..38 | 37..14 | 13..12 | 11 | 10..9 | 8 | 7..0 |
|
|
7
|
+
* | 64 bits | 16 bits | 10 bits | 24 bits | 2 bits | 1 bit | 2 bits | 1 bit | 8 bits |
|
|
8
8
|
*/
|
|
9
9
|
export interface PackedOrderAppendixBits {
|
|
10
|
-
value: bigint; //
|
|
11
|
-
|
|
10
|
+
value: bigint; // 64 bits
|
|
11
|
+
builderId: number; // 16 bits
|
|
12
|
+
builderFeeRate: number; // 10 bits
|
|
13
|
+
reserved: number; // 24 bits, set to 0
|
|
12
14
|
trigger: number; // 2 bits
|
|
13
15
|
reduceOnly: number; // 1 bit
|
|
14
16
|
orderType: number; // 2 bits
|
|
15
17
|
isolated: number; // 1 bit
|
|
16
|
-
version: number; // 8 bits, set to
|
|
18
|
+
version: number; // 8 bits, set to 1
|
|
17
19
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OrderAppendix } from '../../../types/orderAppendixTypes';
|
|
2
|
-
import {
|
|
2
|
+
import { BigNumberish, toBigInt } from '../../math';
|
|
3
|
+
import { unpackIsolatedOrderAppendixValue } from './appendixIsolatedValue';
|
|
3
4
|
import { unpackTwapOrderAppendixValue } from './appendixTwapValue';
|
|
4
5
|
import { bitMaskValue } from './bitMaskValue';
|
|
5
6
|
import { PackedOrderAppendixBits } from './types';
|
|
@@ -35,7 +36,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
|
|
|
35
36
|
})();
|
|
36
37
|
const isolatedFields = (() => {
|
|
37
38
|
if (bits.isolated) {
|
|
38
|
-
return
|
|
39
|
+
return unpackIsolatedOrderAppendixValue(bits.value);
|
|
39
40
|
}
|
|
40
41
|
return undefined;
|
|
41
42
|
})();
|
|
@@ -44,6 +45,15 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
|
|
|
44
45
|
return unpackTwapOrderAppendixValue(bits.value);
|
|
45
46
|
}
|
|
46
47
|
})();
|
|
48
|
+
const builderFields = (() => {
|
|
49
|
+
if (bits.builderId) {
|
|
50
|
+
return {
|
|
51
|
+
builderId: bits.builderId,
|
|
52
|
+
builderFeeRate: bits.builderFeeRate,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
})();
|
|
47
57
|
|
|
48
58
|
return {
|
|
49
59
|
reduceOnly: !!bits.reduceOnly,
|
|
@@ -51,6 +61,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
|
|
|
51
61
|
triggerType,
|
|
52
62
|
isolated: isolatedFields,
|
|
53
63
|
twap: twapFields,
|
|
64
|
+
builder: builderFields,
|
|
54
65
|
};
|
|
55
66
|
}
|
|
56
67
|
|
|
@@ -58,7 +69,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
|
|
|
58
69
|
* Unpack the OrderAppendix fields from a packed bigint.
|
|
59
70
|
* @param packed
|
|
60
71
|
*/
|
|
61
|
-
export function unpackOrderAppendix(packed:
|
|
72
|
+
export function unpackOrderAppendix(packed: BigNumberish): OrderAppendix {
|
|
62
73
|
let temp = toBigInt(packed);
|
|
63
74
|
// Bitmasks lowest 8 bits for version
|
|
64
75
|
const version = Number(bitMaskValue(temp, 8));
|
|
@@ -73,13 +84,19 @@ export function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {
|
|
|
73
84
|
temp >>= 1n;
|
|
74
85
|
const trigger = Number(bitMaskValue(temp, 2));
|
|
75
86
|
temp >>= 2n;
|
|
76
|
-
const reserved = Number(bitMaskValue(temp,
|
|
77
|
-
temp >>=
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
const reserved = Number(bitMaskValue(temp, 24));
|
|
88
|
+
temp >>= 24n;
|
|
89
|
+
const builderFeeRate = Number(bitMaskValue(temp, 10));
|
|
90
|
+
temp >>= 10n;
|
|
91
|
+
const builderId = Number(bitMaskValue(temp, 16));
|
|
92
|
+
temp >>= 16n;
|
|
93
|
+
// The remaining bits are the value, which should be 64 bits
|
|
94
|
+
const value = bitMaskValue(temp, 64);
|
|
80
95
|
|
|
81
96
|
return mapBitValuesToAppendix({
|
|
82
97
|
value,
|
|
98
|
+
builderId,
|
|
99
|
+
builderFeeRate,
|
|
83
100
|
reserved,
|
|
84
101
|
trigger,
|
|
85
102
|
reduceOnly,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Balance, PerpBalance, SpotBalance } from '../types/balanceTypes';
|
|
2
2
|
import {
|
|
3
|
-
ProductEngineType,
|
|
4
3
|
PerpProduct,
|
|
5
|
-
SpotProduct,
|
|
6
4
|
Product,
|
|
5
|
+
ProductEngineType,
|
|
6
|
+
SpotProduct,
|
|
7
7
|
} from '../types/productTypes';
|
|
8
8
|
|
|
9
9
|
export function isSpotProduct(product: Product): product is SpotProduct {
|
|
@@ -1,25 +1,45 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Util for converting any
|
|
4
|
+
* Util for converting any BigNumber types into a string so that it can be logged nicely.
|
|
5
|
+
* Handles cyclic references by returning '[Circular]' for already-visited objects.
|
|
5
6
|
*/
|
|
6
|
-
export function toPrintableObject(
|
|
7
|
-
|
|
7
|
+
export function toPrintableObject(
|
|
8
|
+
obj: null | undefined,
|
|
9
|
+
seen?: WeakSet<object>,
|
|
10
|
+
): null;
|
|
11
|
+
export function toPrintableObject(
|
|
12
|
+
obj: BigNumber | bigint,
|
|
13
|
+
seen?: WeakSet<object>,
|
|
14
|
+
): string;
|
|
15
|
+
export function toPrintableObject(obj: unknown, seen?: WeakSet<object>): object;
|
|
16
|
+
export function toPrintableObject(obj: unknown, seen = new WeakSet()): unknown {
|
|
17
|
+
if (obj === null || obj === undefined) {
|
|
8
18
|
return null;
|
|
9
19
|
}
|
|
10
|
-
if (obj instanceof
|
|
20
|
+
if (obj instanceof BigNumber || typeof obj === 'bigint') {
|
|
11
21
|
return obj.toString();
|
|
12
22
|
}
|
|
13
23
|
if (Array.isArray(obj)) {
|
|
14
|
-
return obj.map(toPrintableObject);
|
|
24
|
+
return obj.map((item) => toPrintableObject(item, seen));
|
|
15
25
|
}
|
|
16
26
|
if (typeof obj === 'object') {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
// Detect cyclic references
|
|
28
|
+
if (seen.has(obj)) {
|
|
29
|
+
return '[Circular]';
|
|
30
|
+
}
|
|
31
|
+
seen.add(obj);
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
return Object.fromEntries(
|
|
35
|
+
Object.entries(obj).map(([key, value]) => [
|
|
36
|
+
key,
|
|
37
|
+
toPrintableObject(value, seen),
|
|
38
|
+
]),
|
|
39
|
+
);
|
|
40
|
+
} catch {
|
|
41
|
+
return { error: '[Unserializable Object]' };
|
|
42
|
+
}
|
|
23
43
|
}
|
|
24
44
|
return obj;
|
|
25
45
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/@jest/globals/build/index.js"],"sourcesContent":["/*!\n * /**\n * * Copyright (c) Meta Platforms, Inc. and affiliates.\n * *\n * * This source code is licensed under the MIT license found in the\n * * LICENSE file in the root directory of this source tree.\n * * /\n */\n/******/ (() => { // webpackBootstrap\n/******/ \t\"use strict\";\nvar __webpack_exports__ = {};\n\n\n/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\n\nthrow new Error('Do not import `@jest/globals` outside of the Jest test environment');\nmodule.exports = __webpack_exports__;\n/******/ })()\n;"],"mappings":";;;;;AAAA;AAAA;AAAA;AAQS,KAAC,MAAM;AACN;AACV,UAAI,sBAAsB,CAAC;AAY3B,YAAM,IAAI,MAAM,oEAAoE;AACpF,aAAO,UAAU;AAAA,IACR,GAAG;AAAA;AAAA;","names":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nodeUrl": "https://rpc-gel-sepolia.inkonchain.com",
|
|
3
|
-
"explorerUrl": "https://explorer-sepolia.inkonchain.com",
|
|
4
|
-
"startBlock": 27233833,
|
|
5
|
-
"deployer": "0x8177A1b5bFaAa10A4b1178c6D42aDaa4b75c8146",
|
|
6
|
-
"quote": "0x5F65358d61A9a281ea3BB930d05889ACa21E3f4f",
|
|
7
|
-
"querier": "0x5A62e748b2630560Ffe9E928780cF9Fe0e086A21",
|
|
8
|
-
"clearinghouse": "0x5E9b4336104069467E57E843033e62c79C667F8F",
|
|
9
|
-
"endpoint": "0xf8963f7860aF7DE9b94893EDb9A3b5c155e1Fc0c",
|
|
10
|
-
"spotEngine": "0x61AA7A636df5e72eBe34c70a340eB76ABB3A15bE",
|
|
11
|
-
"perpEngine": "0x3D6Ac7105cA399884739a8CC19cAdB4178844466",
|
|
12
|
-
"withdrawPool": "0xa59613a3e4ce46E20d83b0632E3D857e3f116F66"
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nodeUrl": "https://arb1.arbitrum.io/rpc",
|
|
3
|
-
"explorerUrl": "https://explorer.arbitrum.io",
|
|
4
|
-
"subgraphCoreUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-core",
|
|
5
|
-
"subgraphMarketsUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-markets",
|
|
6
|
-
"subgraphCandleSticksUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-candlesticks",
|
|
7
|
-
"startBlock": 67108377,
|
|
8
|
-
"deployer": "0xB746472C10f9F128FF9F5029f424cC91bb1D8C3a",
|
|
9
|
-
"quote": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
|
|
10
|
-
"querier": "0x1693273B443699bee277eCbc60e2C8027E91995d",
|
|
11
|
-
"feeCalculator": "0x2259440579447D0625a5E28dfF3E743d207e8890",
|
|
12
|
-
"clearinghouse": "0xAE1ec28d6225dCE2ff787dcb8CE11cF6D3AE064f",
|
|
13
|
-
"clearinghouseLiq": "0xca007C51Fc14eEA88252Cc4FD71e91E44026F020",
|
|
14
|
-
"endpoint": "0xbbEE07B3e8121227AfCFe1E2B82772246226128e",
|
|
15
|
-
"spotEngine": "0x32d91Af2B17054D575A7bF1ACfa7615f41CCEfaB",
|
|
16
|
-
"perpEngine": "0xb74C78cca0FADAFBeE52B2f48A67eE8c834b5fd1",
|
|
17
|
-
"withdrawPool": "0x3567a1f8d79046A7e93Fd76d71104A978cDC6d05"
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/BigDecimals.ts"],"sourcesContent":["import { toBigDecimal } from './bigDecimal';\n\nexport const BigDecimals = Object.freeze({\n ZERO: toBigDecimal(0),\n ONE: toBigDecimal(1),\n INF: toBigDecimal(Infinity),\n MAX_I128: toBigDecimal('170141183460469231731687303715884105727'),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA6B;AAEtB,IAAM,cAAc,OAAO,OAAO;AAAA,EACvC,UAAM,gCAAa,CAAC;AAAA,EACpB,SAAK,gCAAa,CAAC;AAAA,EACnB,SAAK,gCAAa,QAAQ;AAAA,EAC1B,cAAU,gCAAa,yCAAyC;AAClE,CAAC;","names":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "../../chunk-5WRI5ZAA.js";
|
|
2
|
-
|
|
3
|
-
// src/utils/math/BigDecimals.ts
|
|
4
|
-
import { toBigDecimal } from "./bigDecimal.js";
|
|
5
|
-
var BigDecimals = Object.freeze({
|
|
6
|
-
ZERO: toBigDecimal(0),
|
|
7
|
-
ONE: toBigDecimal(1),
|
|
8
|
-
INF: toBigDecimal(Infinity),
|
|
9
|
-
MAX_I128: toBigDecimal("170141183460469231731687303715884105727")
|
|
10
|
-
});
|
|
11
|
-
export {
|
|
12
|
-
BigDecimals
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=BigDecimals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/BigDecimals.ts"],"sourcesContent":["import { toBigDecimal } from './bigDecimal';\n\nexport const BigDecimals = Object.freeze({\n ZERO: toBigDecimal(0),\n ONE: toBigDecimal(1),\n INF: toBigDecimal(Infinity),\n MAX_I128: toBigDecimal('170141183460469231731687303715884105727'),\n});\n"],"mappings":";;;AAAA,SAAS,oBAAoB;AAEtB,IAAM,cAAc,OAAO,OAAO;AAAA,EACvC,MAAM,aAAa,CAAC;AAAA,EACpB,KAAK,aAAa,CAAC;AAAA,EACnB,KAAK,aAAa,QAAQ;AAAA,EAC1B,UAAU,aAAa,yCAAyC;AAClE,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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 const bnConstructorVal = (() => {\n if (val instanceof BigDecimal) {\n return val;\n } else 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,QAAM,oBAAoB,MAAM;AAC9B,QAAI,eAAe,iBAAAC,SAAY;AAC7B,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AAC7D,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"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import BigDecimal from 'bignumber.js';
|
|
2
|
-
export { default as BigDecimal } from 'bignumber.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
|
|
6
|
-
* Includes valid values & instances for BigDecimal.
|
|
7
|
-
*
|
|
8
|
-
* @see https://mikemcl.github.io/bignumber.js/
|
|
9
|
-
*/
|
|
10
|
-
type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
|
|
11
|
-
/**
|
|
12
|
-
* Converts a value to an instance of BigDecimal
|
|
13
|
-
*
|
|
14
|
-
* @param val
|
|
15
|
-
*/
|
|
16
|
-
declare function toBigDecimal(val: BigDecimalish): BigDecimal;
|
|
17
|
-
|
|
18
|
-
export { type BigDecimalish, toBigDecimal };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import BigDecimal from 'bignumber.js';
|
|
2
|
-
export { default as BigDecimal } from 'bignumber.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
|
|
6
|
-
* Includes valid values & instances for BigDecimal.
|
|
7
|
-
*
|
|
8
|
-
* @see https://mikemcl.github.io/bignumber.js/
|
|
9
|
-
*/
|
|
10
|
-
type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
|
|
11
|
-
/**
|
|
12
|
-
* Converts a value to an instance of BigDecimal
|
|
13
|
-
*
|
|
14
|
-
* @param val
|
|
15
|
-
*/
|
|
16
|
-
declare function toBigDecimal(val: BigDecimalish): BigDecimal;
|
|
17
|
-
|
|
18
|
-
export { type BigDecimalish, toBigDecimal };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import "../../chunk-5WRI5ZAA.js";
|
|
2
|
-
|
|
3
|
-
// src/utils/math/bigDecimal.ts
|
|
4
|
-
import { default as BigDecimal } from "bignumber.js";
|
|
5
|
-
import { default as default2 } from "bignumber.js";
|
|
6
|
-
function toBigDecimal(val) {
|
|
7
|
-
const bnConstructorVal = (() => {
|
|
8
|
-
if (val instanceof BigDecimal) {
|
|
9
|
-
return val;
|
|
10
|
-
} else if (typeof val === "string" || typeof val === "number") {
|
|
11
|
-
return val;
|
|
12
|
-
} else if (typeof val === "bigint") {
|
|
13
|
-
return val.toString();
|
|
14
|
-
}
|
|
15
|
-
return JSON.stringify(val);
|
|
16
|
-
})();
|
|
17
|
-
return new BigDecimal(bnConstructorVal);
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
default2 as BigDecimal,
|
|
21
|
-
toBigDecimal
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=bigDecimal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 const bnConstructorVal = (() => {\n if (val instanceof BigDecimal) {\n return val;\n } else 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,QAAM,oBAAoB,MAAM;AAC9B,QAAI,eAAe,YAAY;AAC7B,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AAC7D,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/sumBigDecimalBy.ts"],"sourcesContent":["import { BigDecimal } from './bigDecimal';\nimport { BigDecimals } from './BigDecimals';\n\n/**\n * Util function to sum BigDecimal values, inspired by Lodash\n * @param collection\n * @param iteratee\n */\nexport function sumBigDecimalBy<T>(\n collection: T[] | null | undefined,\n iteratee: (value: T) => BigDecimal.Value,\n): BigDecimal {\n return (\n collection?.reduce((total, item) => {\n return total.plus(iteratee(item));\n }, BigDecimals.ZERO) ?? BigDecimals.ZERO\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA4B;AAOrB,SAAS,gBACd,YACA,UACY;AACZ,SACE,YAAY,OAAO,CAAC,OAAO,SAAS;AAClC,WAAO,MAAM,KAAK,SAAS,IAAI,CAAC;AAAA,EAClC,GAAG,+BAAY,IAAI,KAAK,+BAAY;AAExC;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import BigDecimal from 'bignumber.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Util function to sum BigDecimal values, inspired by Lodash
|
|
5
|
-
* @param collection
|
|
6
|
-
* @param iteratee
|
|
7
|
-
*/
|
|
8
|
-
declare function sumBigDecimalBy<T>(collection: T[] | null | undefined, iteratee: (value: T) => BigDecimal.Value): BigDecimal;
|
|
9
|
-
|
|
10
|
-
export { sumBigDecimalBy };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import BigDecimal from 'bignumber.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Util function to sum BigDecimal values, inspired by Lodash
|
|
5
|
-
* @param collection
|
|
6
|
-
* @param iteratee
|
|
7
|
-
*/
|
|
8
|
-
declare function sumBigDecimalBy<T>(collection: T[] | null | undefined, iteratee: (value: T) => BigDecimal.Value): BigDecimal;
|
|
9
|
-
|
|
10
|
-
export { sumBigDecimalBy };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import "../../chunk-5WRI5ZAA.js";
|
|
2
|
-
|
|
3
|
-
// src/utils/math/sumBigDecimalBy.ts
|
|
4
|
-
import { BigDecimals } from "./BigDecimals.js";
|
|
5
|
-
function sumBigDecimalBy(collection, iteratee) {
|
|
6
|
-
return collection?.reduce((total, item) => {
|
|
7
|
-
return total.plus(iteratee(item));
|
|
8
|
-
}, BigDecimals.ZERO) ?? BigDecimals.ZERO;
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
sumBigDecimalBy
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=sumBigDecimalBy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/sumBigDecimalBy.ts"],"sourcesContent":["import { BigDecimal } from './bigDecimal';\nimport { BigDecimals } from './BigDecimals';\n\n/**\n * Util function to sum BigDecimal values, inspired by Lodash\n * @param collection\n * @param iteratee\n */\nexport function sumBigDecimalBy<T>(\n collection: T[] | null | undefined,\n iteratee: (value: T) => BigDecimal.Value,\n): BigDecimal {\n return (\n collection?.reduce((total, item) => {\n return total.plus(iteratee(item));\n }, BigDecimals.ZERO) ?? BigDecimals.ZERO\n );\n}\n"],"mappings":";;;AACA,SAAS,mBAAmB;AAOrB,SAAS,gBACd,YACA,UACY;AACZ,SACE,YAAY,OAAO,CAAC,OAAO,SAAS;AAClC,WAAO,MAAM,KAAK,SAAS,IAAI,CAAC;AAAA,EAClC,GAAG,YAAY,IAAI,KAAK,YAAY;AAExC;","names":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nodeUrl": "https://rpc-gel-sepolia.inkonchain.com",
|
|
3
|
-
"explorerUrl": "https://explorer-sepolia.inkonchain.com",
|
|
4
|
-
"startBlock": 27233833,
|
|
5
|
-
"deployer": "0x8177A1b5bFaAa10A4b1178c6D42aDaa4b75c8146",
|
|
6
|
-
"quote": "0x5F65358d61A9a281ea3BB930d05889ACa21E3f4f",
|
|
7
|
-
"querier": "0x5A62e748b2630560Ffe9E928780cF9Fe0e086A21",
|
|
8
|
-
"clearinghouse": "0x5E9b4336104069467E57E843033e62c79C667F8F",
|
|
9
|
-
"endpoint": "0xf8963f7860aF7DE9b94893EDb9A3b5c155e1Fc0c",
|
|
10
|
-
"spotEngine": "0x61AA7A636df5e72eBe34c70a340eB76ABB3A15bE",
|
|
11
|
-
"perpEngine": "0x3D6Ac7105cA399884739a8CC19cAdB4178844466",
|
|
12
|
-
"withdrawPool": "0xa59613a3e4ce46E20d83b0632E3D857e3f116F66"
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nodeUrl": "https://arb1.arbitrum.io/rpc",
|
|
3
|
-
"explorerUrl": "https://explorer.arbitrum.io",
|
|
4
|
-
"subgraphCoreUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-core",
|
|
5
|
-
"subgraphMarketsUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-markets",
|
|
6
|
-
"subgraphCandleSticksUrl": "https://api.thegraph.com/subgraphs/name/nado-protocol/nado-prod-candlesticks",
|
|
7
|
-
"startBlock": 67108377,
|
|
8
|
-
"deployer": "0xB746472C10f9F128FF9F5029f424cC91bb1D8C3a",
|
|
9
|
-
"quote": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
|
|
10
|
-
"querier": "0x1693273B443699bee277eCbc60e2C8027E91995d",
|
|
11
|
-
"feeCalculator": "0x2259440579447D0625a5E28dfF3E743d207e8890",
|
|
12
|
-
"clearinghouse": "0xAE1ec28d6225dCE2ff787dcb8CE11cF6D3AE064f",
|
|
13
|
-
"clearinghouseLiq": "0xca007C51Fc14eEA88252Cc4FD71e91E44026F020",
|
|
14
|
-
"endpoint": "0xbbEE07B3e8121227AfCFe1E2B82772246226128e",
|
|
15
|
-
"spotEngine": "0x32d91Af2B17054D575A7bF1ACfa7615f41CCEfaB",
|
|
16
|
-
"perpEngine": "0xb74C78cca0FADAFBeE52B2f48A67eE8c834b5fd1",
|
|
17
|
-
"withdrawPool": "0x3567a1f8d79046A7e93Fd76d71104A978cDC6d05"
|
|
18
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { default as BigDecimal } from 'bignumber.js';
|
|
2
|
-
|
|
3
|
-
// Renames `BigNumber` type from `bignumber.js`.
|
|
4
|
-
export { default as BigDecimal } from 'bignumber.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* BigDecimal is a renamed `BigNumber` type from `bignumber.js`.
|
|
8
|
-
* Includes valid values & instances for BigDecimal.
|
|
9
|
-
*
|
|
10
|
-
* @see https://mikemcl.github.io/bignumber.js/
|
|
11
|
-
*/
|
|
12
|
-
export type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Converts a value to an instance of BigDecimal
|
|
16
|
-
*
|
|
17
|
-
* @param val
|
|
18
|
-
*/
|
|
19
|
-
export function toBigDecimal(val: BigDecimalish): BigDecimal {
|
|
20
|
-
const bnConstructorVal = (() => {
|
|
21
|
-
if (val instanceof BigDecimal) {
|
|
22
|
-
return val;
|
|
23
|
-
} else if (typeof val === 'string' || typeof val === 'number') {
|
|
24
|
-
return val;
|
|
25
|
-
} else if (typeof val === 'bigint') {
|
|
26
|
-
return val.toString();
|
|
27
|
-
}
|
|
28
|
-
// 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
|
|
29
|
-
return JSON.stringify(val);
|
|
30
|
-
})();
|
|
31
|
-
return new BigDecimal(bnConstructorVal);
|
|
32
|
-
}
|