@nadohq/shared 0.1.0-alpha.4 → 0.1.0-alpha.6
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/consts/chainEnvToChain.d.cts +16 -17
- package/dist/consts/chainEnvToChain.d.ts +16 -17
- package/dist/consts/index.d.cts +0 -1
- package/dist/consts/index.d.ts +0 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/orderAppendixTypes.cjs.map +1 -1
- package/dist/types/orderAppendixTypes.d.cts +3 -3
- package/dist/types/orderAppendixTypes.d.ts +3 -3
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/orders/appendix/{appendixTWAPValue.cjs → appendixTwapValue.cjs} +11 -11
- package/dist/utils/orders/appendix/{appendixTWAPValue.cjs.map → appendixTwapValue.cjs.map} +1 -1
- package/dist/utils/orders/appendix/{appendixTWAPValue.d.cts → appendixTwapValue.d.cts} +4 -4
- package/dist/utils/orders/appendix/{appendixTWAPValue.d.ts → appendixTwapValue.d.ts} +4 -4
- package/dist/utils/orders/appendix/{appendixTWAPValue.js → appendixTwapValue.js} +6 -6
- package/dist/utils/orders/appendix/{appendixTWAPValue.js.map → appendixTwapValue.js.map} +1 -1
- package/dist/utils/orders/appendix/index.cjs +2 -2
- package/dist/utils/orders/appendix/index.cjs.map +1 -1
- package/dist/utils/orders/appendix/index.d.cts +1 -1
- package/dist/utils/orders/appendix/index.d.ts +1 -1
- package/dist/utils/orders/appendix/index.js +1 -1
- package/dist/utils/orders/appendix/index.js.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.cjs +2 -2
- package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.js +2 -2
- package/dist/utils/orders/appendix/packOrderAppendix.js.map +1 -1
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs +2 -2
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/unpackOrderAppendix.js +2 -2
- package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -1
- package/dist/utils/orders/index.d.cts +1 -1
- package/dist/utils/orders/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/types/orderAppendixTypes.ts +2 -2
- package/src/utils/orders/appendix/{appendixTWAPValue.ts → appendixTwapValue.ts} +5 -5
- package/src/utils/orders/appendix/index.ts +1 -1
- package/src/utils/orders/appendix/packOrderAppendix.ts +2 -2
- package/src/utils/orders/appendix/unpackOrderAppendix.ts +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as abitype from 'abitype';
|
|
2
1
|
import * as viem_chains from 'viem/chains';
|
|
3
2
|
import * as viem from 'viem';
|
|
4
3
|
import { ChainEnv } from '../types/ChainEnv.cjs';
|
|
@@ -160,7 +159,7 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
160
159
|
gasUsed: bigint;
|
|
161
160
|
hash: `0x${string}` | null;
|
|
162
161
|
logsBloom: `0x${string}` | null;
|
|
163
|
-
miner:
|
|
162
|
+
miner: viem.Address;
|
|
164
163
|
mixHash: viem.Hash;
|
|
165
164
|
nonce: `0x${string}` | null;
|
|
166
165
|
number: bigint | null;
|
|
@@ -186,14 +185,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
186
185
|
format: (args: viem_chains.OpStackRpcTransaction) => ({
|
|
187
186
|
blockHash: `0x${string}` | null;
|
|
188
187
|
blockNumber: bigint | null;
|
|
189
|
-
from:
|
|
188
|
+
from: viem.Address;
|
|
190
189
|
gas: bigint;
|
|
191
190
|
hash: viem.Hash;
|
|
192
191
|
input: viem.Hex;
|
|
193
192
|
nonce: number;
|
|
194
193
|
r: viem.Hex;
|
|
195
194
|
s: viem.Hex;
|
|
196
|
-
to:
|
|
195
|
+
to: viem.Address | null;
|
|
197
196
|
transactionIndex: number | null;
|
|
198
197
|
typeHex: viem.Hex | null;
|
|
199
198
|
v: bigint;
|
|
@@ -211,8 +210,8 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
211
210
|
r: viem.Hex;
|
|
212
211
|
s: viem.Hex;
|
|
213
212
|
v: bigint;
|
|
214
|
-
to:
|
|
215
|
-
from:
|
|
213
|
+
to: viem.Address | null;
|
|
214
|
+
from: viem.Address;
|
|
216
215
|
gas: bigint;
|
|
217
216
|
nonce: number;
|
|
218
217
|
value: bigint;
|
|
@@ -238,14 +237,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
238
237
|
} | {
|
|
239
238
|
blockHash: `0x${string}` | null;
|
|
240
239
|
blockNumber: bigint | null;
|
|
241
|
-
from:
|
|
240
|
+
from: viem.Address;
|
|
242
241
|
gas: bigint;
|
|
243
242
|
hash: viem.Hash;
|
|
244
243
|
input: viem.Hex;
|
|
245
244
|
nonce: number;
|
|
246
245
|
r: viem.Hex;
|
|
247
246
|
s: viem.Hex;
|
|
248
|
-
to:
|
|
247
|
+
to: viem.Address | null;
|
|
249
248
|
transactionIndex: number | null;
|
|
250
249
|
typeHex: viem.Hex | null;
|
|
251
250
|
v: bigint;
|
|
@@ -266,14 +265,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
266
265
|
} | {
|
|
267
266
|
blockHash: `0x${string}` | null;
|
|
268
267
|
blockNumber: bigint | null;
|
|
269
|
-
from:
|
|
268
|
+
from: viem.Address;
|
|
270
269
|
gas: bigint;
|
|
271
270
|
hash: viem.Hash;
|
|
272
271
|
input: viem.Hex;
|
|
273
272
|
nonce: number;
|
|
274
273
|
r: viem.Hex;
|
|
275
274
|
s: viem.Hex;
|
|
276
|
-
to:
|
|
275
|
+
to: viem.Address | null;
|
|
277
276
|
transactionIndex: number | null;
|
|
278
277
|
typeHex: viem.Hex | null;
|
|
279
278
|
v: bigint;
|
|
@@ -294,14 +293,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
294
293
|
} | {
|
|
295
294
|
blockHash: `0x${string}` | null;
|
|
296
295
|
blockNumber: bigint | null;
|
|
297
|
-
from:
|
|
296
|
+
from: viem.Address;
|
|
298
297
|
gas: bigint;
|
|
299
298
|
hash: viem.Hash;
|
|
300
299
|
input: viem.Hex;
|
|
301
300
|
nonce: number;
|
|
302
301
|
r: viem.Hex;
|
|
303
302
|
s: viem.Hex;
|
|
304
|
-
to:
|
|
303
|
+
to: viem.Address | null;
|
|
305
304
|
transactionIndex: number | null;
|
|
306
305
|
typeHex: viem.Hex | null;
|
|
307
306
|
v: bigint;
|
|
@@ -322,14 +321,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
322
321
|
} | {
|
|
323
322
|
blockHash: `0x${string}` | null;
|
|
324
323
|
blockNumber: bigint | null;
|
|
325
|
-
from:
|
|
324
|
+
from: viem.Address;
|
|
326
325
|
gas: bigint;
|
|
327
326
|
hash: viem.Hash;
|
|
328
327
|
input: viem.Hex;
|
|
329
328
|
nonce: number;
|
|
330
329
|
r: viem.Hex;
|
|
331
330
|
s: viem.Hex;
|
|
332
|
-
to:
|
|
331
|
+
to: viem.Address | null;
|
|
333
332
|
transactionIndex: number | null;
|
|
334
333
|
typeHex: viem.Hex | null;
|
|
335
334
|
v: bigint;
|
|
@@ -357,16 +356,16 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
357
356
|
blobGasUsed?: bigint | undefined;
|
|
358
357
|
blockHash: viem.Hash;
|
|
359
358
|
blockNumber: bigint;
|
|
360
|
-
contractAddress:
|
|
359
|
+
contractAddress: viem.Address | null | undefined;
|
|
361
360
|
cumulativeGasUsed: bigint;
|
|
362
361
|
effectiveGasPrice: bigint;
|
|
363
|
-
from:
|
|
362
|
+
from: viem.Address;
|
|
364
363
|
gasUsed: bigint;
|
|
365
364
|
logs: viem.Log<bigint, number, false>[];
|
|
366
365
|
logsBloom: viem.Hex;
|
|
367
366
|
root?: `0x${string}` | undefined;
|
|
368
367
|
status: "success" | "reverted";
|
|
369
|
-
to:
|
|
368
|
+
to: viem.Address | null;
|
|
370
369
|
transactionHash: viem.Hash;
|
|
371
370
|
transactionIndex: number;
|
|
372
371
|
type: viem.TransactionType;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as abitype from 'abitype';
|
|
2
1
|
import * as viem_chains from 'viem/chains';
|
|
3
2
|
import * as viem from 'viem';
|
|
4
3
|
import { ChainEnv } from '../types/ChainEnv.js';
|
|
@@ -160,7 +159,7 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
160
159
|
gasUsed: bigint;
|
|
161
160
|
hash: `0x${string}` | null;
|
|
162
161
|
logsBloom: `0x${string}` | null;
|
|
163
|
-
miner:
|
|
162
|
+
miner: viem.Address;
|
|
164
163
|
mixHash: viem.Hash;
|
|
165
164
|
nonce: `0x${string}` | null;
|
|
166
165
|
number: bigint | null;
|
|
@@ -186,14 +185,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
186
185
|
format: (args: viem_chains.OpStackRpcTransaction) => ({
|
|
187
186
|
blockHash: `0x${string}` | null;
|
|
188
187
|
blockNumber: bigint | null;
|
|
189
|
-
from:
|
|
188
|
+
from: viem.Address;
|
|
190
189
|
gas: bigint;
|
|
191
190
|
hash: viem.Hash;
|
|
192
191
|
input: viem.Hex;
|
|
193
192
|
nonce: number;
|
|
194
193
|
r: viem.Hex;
|
|
195
194
|
s: viem.Hex;
|
|
196
|
-
to:
|
|
195
|
+
to: viem.Address | null;
|
|
197
196
|
transactionIndex: number | null;
|
|
198
197
|
typeHex: viem.Hex | null;
|
|
199
198
|
v: bigint;
|
|
@@ -211,8 +210,8 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
211
210
|
r: viem.Hex;
|
|
212
211
|
s: viem.Hex;
|
|
213
212
|
v: bigint;
|
|
214
|
-
to:
|
|
215
|
-
from:
|
|
213
|
+
to: viem.Address | null;
|
|
214
|
+
from: viem.Address;
|
|
216
215
|
gas: bigint;
|
|
217
216
|
nonce: number;
|
|
218
217
|
value: bigint;
|
|
@@ -238,14 +237,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
238
237
|
} | {
|
|
239
238
|
blockHash: `0x${string}` | null;
|
|
240
239
|
blockNumber: bigint | null;
|
|
241
|
-
from:
|
|
240
|
+
from: viem.Address;
|
|
242
241
|
gas: bigint;
|
|
243
242
|
hash: viem.Hash;
|
|
244
243
|
input: viem.Hex;
|
|
245
244
|
nonce: number;
|
|
246
245
|
r: viem.Hex;
|
|
247
246
|
s: viem.Hex;
|
|
248
|
-
to:
|
|
247
|
+
to: viem.Address | null;
|
|
249
248
|
transactionIndex: number | null;
|
|
250
249
|
typeHex: viem.Hex | null;
|
|
251
250
|
v: bigint;
|
|
@@ -266,14 +265,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
266
265
|
} | {
|
|
267
266
|
blockHash: `0x${string}` | null;
|
|
268
267
|
blockNumber: bigint | null;
|
|
269
|
-
from:
|
|
268
|
+
from: viem.Address;
|
|
270
269
|
gas: bigint;
|
|
271
270
|
hash: viem.Hash;
|
|
272
271
|
input: viem.Hex;
|
|
273
272
|
nonce: number;
|
|
274
273
|
r: viem.Hex;
|
|
275
274
|
s: viem.Hex;
|
|
276
|
-
to:
|
|
275
|
+
to: viem.Address | null;
|
|
277
276
|
transactionIndex: number | null;
|
|
278
277
|
typeHex: viem.Hex | null;
|
|
279
278
|
v: bigint;
|
|
@@ -294,14 +293,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
294
293
|
} | {
|
|
295
294
|
blockHash: `0x${string}` | null;
|
|
296
295
|
blockNumber: bigint | null;
|
|
297
|
-
from:
|
|
296
|
+
from: viem.Address;
|
|
298
297
|
gas: bigint;
|
|
299
298
|
hash: viem.Hash;
|
|
300
299
|
input: viem.Hex;
|
|
301
300
|
nonce: number;
|
|
302
301
|
r: viem.Hex;
|
|
303
302
|
s: viem.Hex;
|
|
304
|
-
to:
|
|
303
|
+
to: viem.Address | null;
|
|
305
304
|
transactionIndex: number | null;
|
|
306
305
|
typeHex: viem.Hex | null;
|
|
307
306
|
v: bigint;
|
|
@@ -322,14 +321,14 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
322
321
|
} | {
|
|
323
322
|
blockHash: `0x${string}` | null;
|
|
324
323
|
blockNumber: bigint | null;
|
|
325
|
-
from:
|
|
324
|
+
from: viem.Address;
|
|
326
325
|
gas: bigint;
|
|
327
326
|
hash: viem.Hash;
|
|
328
327
|
input: viem.Hex;
|
|
329
328
|
nonce: number;
|
|
330
329
|
r: viem.Hex;
|
|
331
330
|
s: viem.Hex;
|
|
332
|
-
to:
|
|
331
|
+
to: viem.Address | null;
|
|
333
332
|
transactionIndex: number | null;
|
|
334
333
|
typeHex: viem.Hex | null;
|
|
335
334
|
v: bigint;
|
|
@@ -357,16 +356,16 @@ declare const CHAIN_ENV_TO_CHAIN: {
|
|
|
357
356
|
blobGasUsed?: bigint | undefined;
|
|
358
357
|
blockHash: viem.Hash;
|
|
359
358
|
blockNumber: bigint;
|
|
360
|
-
contractAddress:
|
|
359
|
+
contractAddress: viem.Address | null | undefined;
|
|
361
360
|
cumulativeGasUsed: bigint;
|
|
362
361
|
effectiveGasPrice: bigint;
|
|
363
|
-
from:
|
|
362
|
+
from: viem.Address;
|
|
364
363
|
gasUsed: bigint;
|
|
365
364
|
logs: viem.Log<bigint, number, false>[];
|
|
366
365
|
logsBloom: viem.Hex;
|
|
367
366
|
root?: `0x${string}` | undefined;
|
|
368
367
|
status: "success" | "reverted";
|
|
369
|
-
to:
|
|
368
|
+
to: viem.Address | null;
|
|
370
369
|
transactionHash: viem.Hash;
|
|
371
370
|
transactionIndex: number;
|
|
372
371
|
type: viem.TransactionType;
|
package/dist/consts/index.d.cts
CHANGED
package/dist/consts/index.d.ts
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -33,10 +33,10 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './types/su
|
|
|
33
33
|
export { NadoContracts, WithContract, WithContracts } from './types/nadoContractTypes.cjs';
|
|
34
34
|
export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './types/viemTypes.cjs';
|
|
35
35
|
export { OrderExecutionType } from './types/OrderExecutionType.cjs';
|
|
36
|
-
export { OrderAppendix, OrderAppendixIsolatedFields,
|
|
36
|
+
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.cjs';
|
|
37
37
|
export { getOrderNonce, getRecvTimeFromOrderNonce } from './utils/orders/orderNonce.cjs';
|
|
38
38
|
export { getDefaultRecvTime } from './utils/orders/recvTime.cjs';
|
|
39
|
-
export {
|
|
39
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './utils/orders/appendix/appendixTwapValue.cjs';
|
|
40
40
|
export { unpackOrderAppendix } from './utils/orders/appendix/unpackOrderAppendix.cjs';
|
|
41
41
|
export { packOrderAppendix } from './utils/orders/appendix/packOrderAppendix.cjs';
|
|
42
42
|
export { PackedOrderAppendixBits } from './utils/orders/appendix/types.cjs';
|
|
@@ -62,6 +62,6 @@ export { mapValues } from './utils/mapValues.cjs';
|
|
|
62
62
|
export { TimeInSeconds, millisToSeconds, nowInSeconds } from './utils/time.cjs';
|
|
63
63
|
export { toPrintableObject } from './utils/toPrintableObject.cjs';
|
|
64
64
|
export { default as BigDecimal } from 'bignumber.js';
|
|
65
|
-
import 'abitype';
|
|
66
65
|
import 'viem/chains';
|
|
67
66
|
import 'viem';
|
|
67
|
+
import 'abitype';
|
package/dist/index.d.ts
CHANGED
|
@@ -33,10 +33,10 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './types/su
|
|
|
33
33
|
export { NadoContracts, WithContract, WithContracts } from './types/nadoContractTypes.js';
|
|
34
34
|
export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './types/viemTypes.js';
|
|
35
35
|
export { OrderExecutionType } from './types/OrderExecutionType.js';
|
|
36
|
-
export { OrderAppendix, OrderAppendixIsolatedFields,
|
|
36
|
+
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.js';
|
|
37
37
|
export { getOrderNonce, getRecvTimeFromOrderNonce } from './utils/orders/orderNonce.js';
|
|
38
38
|
export { getDefaultRecvTime } from './utils/orders/recvTime.js';
|
|
39
|
-
export {
|
|
39
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './utils/orders/appendix/appendixTwapValue.js';
|
|
40
40
|
export { unpackOrderAppendix } from './utils/orders/appendix/unpackOrderAppendix.js';
|
|
41
41
|
export { packOrderAppendix } from './utils/orders/appendix/packOrderAppendix.js';
|
|
42
42
|
export { PackedOrderAppendixBits } from './utils/orders/appendix/types.js';
|
|
@@ -62,6 +62,6 @@ export { mapValues } from './utils/mapValues.js';
|
|
|
62
62
|
export { TimeInSeconds, millisToSeconds, nowInSeconds } from './utils/time.js';
|
|
63
63
|
export { toPrintableObject } from './utils/toPrintableObject.js';
|
|
64
64
|
export { default as BigDecimal } from 'bignumber.js';
|
|
65
|
-
import 'abitype';
|
|
66
65
|
import 'viem/chains';
|
|
67
66
|
import 'viem';
|
|
67
|
+
import 'abitype';
|
package/dist/types/index.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccou
|
|
|
8
8
|
export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.cjs';
|
|
9
9
|
export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './viemTypes.cjs';
|
|
10
10
|
export { OrderExecutionType } from './OrderExecutionType.cjs';
|
|
11
|
-
export { OrderAppendix, OrderAppendixIsolatedFields,
|
|
11
|
+
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.cjs';
|
|
12
12
|
import 'bignumber.js';
|
|
13
13
|
import '../abis/nadoAbis.cjs';
|
|
14
14
|
import 'viem';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccou
|
|
|
8
8
|
export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.js';
|
|
9
9
|
export { AccountWithPrivateKey, ContractInstance, WalletClientWithAccount, WriteableContractInstance } from './viemTypes.js';
|
|
10
10
|
export { OrderExecutionType } from './OrderExecutionType.js';
|
|
11
|
-
export { OrderAppendix, OrderAppendixIsolatedFields,
|
|
11
|
+
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.js';
|
|
12
12
|
import 'bignumber.js';
|
|
13
13
|
import '../abis/nadoAbis.js';
|
|
14
14
|
import 'viem';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/orderAppendixTypes.ts"],"sourcesContent":["import { BigDecimalish } from '../utils/math';\nimport { OrderExecutionType } from './OrderExecutionType';\n\n/**\n * Encodes whether the order will be sent to the trigger service\n */\nexport type OrderAppendixTriggerType =\n | 'price'\n | 'twap'\n // TWAP with specified order amounts, which will be specified in the Trigger Order itself\n | 'twap_custom_amounts';\n\n/**\n * Fields associated with a TWAP trigger order.\n */\nexport interface
|
|
1
|
+
{"version":3,"sources":["../../src/types/orderAppendixTypes.ts"],"sourcesContent":["import { BigDecimalish } from '../utils/math';\nimport { OrderExecutionType } from './OrderExecutionType';\n\n/**\n * Encodes whether the order will be sent to the trigger service\n */\nexport type OrderAppendixTriggerType =\n | 'price'\n | 'twap'\n // TWAP with specified order amounts, which will be specified in the Trigger Order itself\n | 'twap_custom_amounts';\n\n/**\n * Fields associated with a TWAP trigger order.\n */\nexport interface OrderAppendixTwapFields {\n /**\n * Number of TWAP orders to be placed.\n */\n numOrders: number;\n /**\n * Maximum slippage on each TWAP order, based on the oracle price at time of order execution.\n * Ex: 0.01 means 1% slippage.\n */\n slippageFrac: number;\n}\n\n/**\n * Fields associated with an isolated order\n */\nexport interface OrderAppendixIsolatedFields {\n /**\n * Amount of margin to transfer into the isolated position.\n */\n margin: BigDecimalish;\n}\n\n/**\n * All the fields encoded by the order appendix\n */\nexport interface OrderAppendix {\n reduceOnly?: boolean;\n orderExecutionType: OrderExecutionType;\n /**\n * Specify the type of trigger that will be used for the order if the order will be sent to the trigger service.\n */\n triggerType?: OrderAppendixTriggerType;\n /**\n * Specify if the order is for an isolated position\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n isolated?: OrderAppendixIsolatedFields;\n /**\n * Specify if the order is a TWAP order\n * An order CANNOT be both a TWAP order and an isolated order.\n */\n twap?: OrderAppendixTwapFields;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -9,7 +9,7 @@ type OrderAppendixTriggerType = 'price' | 'twap' | 'twap_custom_amounts';
|
|
|
9
9
|
/**
|
|
10
10
|
* Fields associated with a TWAP trigger order.
|
|
11
11
|
*/
|
|
12
|
-
interface
|
|
12
|
+
interface OrderAppendixTwapFields {
|
|
13
13
|
/**
|
|
14
14
|
* Number of TWAP orders to be placed.
|
|
15
15
|
*/
|
|
@@ -48,7 +48,7 @@ interface OrderAppendix {
|
|
|
48
48
|
* Specify if the order is a TWAP order
|
|
49
49
|
* An order CANNOT be both a TWAP order and an isolated order.
|
|
50
50
|
*/
|
|
51
|
-
twap?:
|
|
51
|
+
twap?: OrderAppendixTwapFields;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export type { OrderAppendix, OrderAppendixIsolatedFields,
|
|
54
|
+
export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
|
|
@@ -9,7 +9,7 @@ type OrderAppendixTriggerType = 'price' | 'twap' | 'twap_custom_amounts';
|
|
|
9
9
|
/**
|
|
10
10
|
* Fields associated with a TWAP trigger order.
|
|
11
11
|
*/
|
|
12
|
-
interface
|
|
12
|
+
interface OrderAppendixTwapFields {
|
|
13
13
|
/**
|
|
14
14
|
* Number of TWAP orders to be placed.
|
|
15
15
|
*/
|
|
@@ -48,7 +48,7 @@ interface OrderAppendix {
|
|
|
48
48
|
* Specify if the order is a TWAP order
|
|
49
49
|
* An order CANNOT be both a TWAP order and an isolated order.
|
|
50
50
|
*/
|
|
51
|
-
twap?:
|
|
51
|
+
twap?: OrderAppendixTwapFields;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export type { OrderAppendix, OrderAppendixIsolatedFields,
|
|
54
|
+
export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orders/orderNonce.cjs';
|
|
2
2
|
export { getDefaultRecvTime } from './orders/recvTime.cjs';
|
|
3
|
-
export {
|
|
3
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.cjs';
|
|
4
4
|
export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.cjs';
|
|
5
5
|
export { packOrderAppendix } from './orders/appendix/packOrderAppendix.cjs';
|
|
6
6
|
export { PackedOrderAppendixBits } from './orders/appendix/types.cjs';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orders/orderNonce.js';
|
|
2
2
|
export { getDefaultRecvTime } from './orders/recvTime.js';
|
|
3
|
-
export {
|
|
3
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './orders/appendix/appendixTwapValue.js';
|
|
4
4
|
export { unpackOrderAppendix } from './orders/appendix/unpackOrderAppendix.js';
|
|
5
5
|
export { packOrderAppendix } from './orders/appendix/packOrderAppendix.js';
|
|
6
6
|
export { PackedOrderAppendixBits } from './orders/appendix/types.js';
|
|
@@ -17,15 +17,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/utils/orders/appendix/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
// src/utils/orders/appendix/appendixTwapValue.ts
|
|
21
|
+
var appendixTwapValue_exports = {};
|
|
22
|
+
__export(appendixTwapValue_exports, {
|
|
23
|
+
packTwapOrderAppendixValue: () => packTwapOrderAppendixValue,
|
|
24
|
+
unpackTwapOrderAppendixValue: () => unpackTwapOrderAppendixValue
|
|
25
25
|
});
|
|
26
|
-
module.exports = __toCommonJS(
|
|
26
|
+
module.exports = __toCommonJS(appendixTwapValue_exports);
|
|
27
27
|
var import_math = require("../../math/index.cjs");
|
|
28
|
-
function
|
|
28
|
+
function packTwapOrderAppendixValue({
|
|
29
29
|
numOrders,
|
|
30
30
|
slippageFrac
|
|
31
31
|
}) {
|
|
@@ -34,7 +34,7 @@ function packTWAPOrderAppendixValue({
|
|
|
34
34
|
return (numOrdersBigInt & 0xffffffffn) << 64n | (slippageX6BigInt & 0xffffffffn) << 32n | // The last reserved 32 bits are set to 0
|
|
35
35
|
0n & 0xffffffffn;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function unpackTwapOrderAppendixValue(value) {
|
|
38
38
|
const numOrders = value >> 64n & 0xffffffffn;
|
|
39
39
|
const slippageX6 = value >> 32n & 0xffffffffn;
|
|
40
40
|
return {
|
|
@@ -44,7 +44,7 @@ function unpackTWAPOrderAppendixValue(value) {
|
|
|
44
44
|
}
|
|
45
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
46
|
0 && (module.exports = {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
packTwapOrderAppendixValue,
|
|
48
|
+
unpackTwapOrderAppendixValue
|
|
49
49
|
});
|
|
50
|
-
//# sourceMappingURL=
|
|
50
|
+
//# sourceMappingURL=appendixTwapValue.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/
|
|
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 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` 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) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 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;AAe/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,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,kBAAc,4BAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes.cjs';
|
|
2
2
|
import '../../math/bigDecimal.cjs';
|
|
3
3
|
import 'bignumber.js';
|
|
4
4
|
import '../../../types/OrderExecutionType.cjs';
|
|
@@ -16,7 +16,7 @@ import '../../../types/OrderExecutionType.cjs';
|
|
|
16
16
|
* - `slippage_x6` occupies bits 63..32 (middle 32 bits)
|
|
17
17
|
* - `reserved` occupies bits 31..0 (least significant 32 bits)
|
|
18
18
|
*/
|
|
19
|
-
declare function
|
|
19
|
+
declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
|
|
20
20
|
/**
|
|
21
21
|
* Unpacks a 96-bit bigint into its component fields for TWAP orders.
|
|
22
22
|
*
|
|
@@ -26,6 +26,6 @@ declare function packTWAPOrderAppendixValue({ numOrders, slippageFrac, }: OrderA
|
|
|
26
26
|
* - slippage_x6: number, from bits 63..32
|
|
27
27
|
* - reserved: number, from bits 31..0
|
|
28
28
|
*/
|
|
29
|
-
declare function
|
|
29
|
+
declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
|
|
30
30
|
|
|
31
|
-
export {
|
|
31
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes.js';
|
|
2
2
|
import '../../math/bigDecimal.js';
|
|
3
3
|
import 'bignumber.js';
|
|
4
4
|
import '../../../types/OrderExecutionType.js';
|
|
@@ -16,7 +16,7 @@ import '../../../types/OrderExecutionType.js';
|
|
|
16
16
|
* - `slippage_x6` occupies bits 63..32 (middle 32 bits)
|
|
17
17
|
* - `reserved` occupies bits 31..0 (least significant 32 bits)
|
|
18
18
|
*/
|
|
19
|
-
declare function
|
|
19
|
+
declare function packTwapOrderAppendixValue({ numOrders, slippageFrac, }: OrderAppendixTwapFields): bigint;
|
|
20
20
|
/**
|
|
21
21
|
* Unpacks a 96-bit bigint into its component fields for TWAP orders.
|
|
22
22
|
*
|
|
@@ -26,6 +26,6 @@ declare function packTWAPOrderAppendixValue({ numOrders, slippageFrac, }: OrderA
|
|
|
26
26
|
* - slippage_x6: number, from bits 63..32
|
|
27
27
|
* - reserved: number, from bits 31..0
|
|
28
28
|
*/
|
|
29
|
-
declare function
|
|
29
|
+
declare function unpackTwapOrderAppendixValue(value: bigint): OrderAppendixTwapFields;
|
|
30
30
|
|
|
31
|
-
export {
|
|
31
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../../../chunk-5WRI5ZAA.js";
|
|
2
2
|
|
|
3
|
-
// src/utils/orders/appendix/
|
|
3
|
+
// src/utils/orders/appendix/appendixTwapValue.ts
|
|
4
4
|
import { addDecimals, removeDecimals, toBigInt } from "../../math/index.js";
|
|
5
|
-
function
|
|
5
|
+
function packTwapOrderAppendixValue({
|
|
6
6
|
numOrders,
|
|
7
7
|
slippageFrac
|
|
8
8
|
}) {
|
|
@@ -11,7 +11,7 @@ function packTWAPOrderAppendixValue({
|
|
|
11
11
|
return (numOrdersBigInt & 0xffffffffn) << 64n | (slippageX6BigInt & 0xffffffffn) << 32n | // The last reserved 32 bits are set to 0
|
|
12
12
|
0n & 0xffffffffn;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function unpackTwapOrderAppendixValue(value) {
|
|
15
15
|
const numOrders = value >> 64n & 0xffffffffn;
|
|
16
16
|
const slippageX6 = value >> 32n & 0xffffffffn;
|
|
17
17
|
return {
|
|
@@ -20,7 +20,7 @@ function unpackTWAPOrderAppendixValue(value) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
packTwapOrderAppendixValue,
|
|
24
|
+
unpackTwapOrderAppendixValue
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=appendixTwapValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/
|
|
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 96-bit bigint.\n *\n * Bit layout (MSB → LSB):\n * | times | slippage_x6 | reserved |\n * |-----------|-------------|----------|\n * | 95..64 | 63..32 | 31..0 |\n * | 32 bits | 32 bits | 32 bits |\n *\n * - `times` occupies bits 95..64 (most significant 32 bits)\n * - `slippage_x6` occupies bits 63..32 (middle 32 bits)\n * - `reserved` 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) << 64n) |\n ((slippageX6BigInt & 0xffffffffn) << 32n) |\n // The last reserved 32 bits are set to 0\n (0n & 0xffffffffn)\n );\n}\n\n/**\n * Unpacks a 96-bit bigint into its component fields for TWAP orders.\n *\n * @param value 96-bit bigint to unpack\n * @returns Object with:\n * - times: number, from bits 95..64\n * - slippage_x6: number, from bits 63..32\n * - reserved: number, from bits 31..0\n */\nexport function unpackTwapOrderAppendixValue(\n value: bigint,\n): OrderAppendixTwapFields {\n const numOrders = (value >> 64n) & 0xffffffffn;\n const slippageX6 = (value >> 32n) & 0xffffffffn;\n\n return {\n numOrders: Number(numOrders),\n slippageFrac: removeDecimals(slippageX6, 6).toNumber(),\n };\n}\n"],"mappings":";;;AACA,SAAS,aAAa,gBAAgB,gBAAgB;AAe/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,OAClC,mBAAmB,gBAAgB;AAAA,EAEpC,KAAK;AAEV;AAWO,SAAS,6BACd,OACyB;AACzB,QAAM,YAAa,SAAS,MAAO;AACnC,QAAM,aAAc,SAAS,MAAO;AAEpC,SAAO;AAAA,IACL,WAAW,OAAO,SAAS;AAAA,IAC3B,cAAc,eAAe,YAAY,CAAC,EAAE,SAAS;AAAA,EACvD;AACF;","names":[]}
|
|
@@ -17,14 +17,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
17
17
|
// src/utils/orders/appendix/index.ts
|
|
18
18
|
var appendix_exports = {};
|
|
19
19
|
module.exports = __toCommonJS(appendix_exports);
|
|
20
|
-
__reExport(appendix_exports, require("./
|
|
20
|
+
__reExport(appendix_exports, require("./appendixTwapValue.cjs"), module.exports);
|
|
21
21
|
__reExport(appendix_exports, require("./unpackOrderAppendix.cjs"), module.exports);
|
|
22
22
|
__reExport(appendix_exports, require("./packOrderAppendix.cjs"), module.exports);
|
|
23
23
|
__reExport(appendix_exports, require("./types.cjs"), module.exports);
|
|
24
24
|
__reExport(appendix_exports, require("./bitMaskValue.cjs"), module.exports);
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
|
-
...require("./
|
|
27
|
+
...require("./appendixTwapValue.cjs"),
|
|
28
28
|
...require("./unpackOrderAppendix.cjs"),
|
|
29
29
|
...require("./packOrderAppendix.cjs"),
|
|
30
30
|
...require("./types.cjs"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,oCAAd;AACA,6BAAc,sCADd;AAEA,6BAAc,oCAFd;AAGA,6BAAc,wBAHd;AAIA,6BAAc,+BAJd;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendixTwapValue.cjs';
|
|
2
2
|
export { unpackOrderAppendix } from './unpackOrderAppendix.cjs';
|
|
3
3
|
export { packOrderAppendix } from './packOrderAppendix.cjs';
|
|
4
4
|
export { PackedOrderAppendixBits } from './types.cjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendixTwapValue.js';
|
|
2
2
|
export { unpackOrderAppendix } from './unpackOrderAppendix.js';
|
|
3
3
|
export { packOrderAppendix } from './packOrderAppendix.js';
|
|
4
4
|
export { PackedOrderAppendixBits } from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/index.ts"],"sourcesContent":["export * from './appendixTwapValue';\nexport * from './unpackOrderAppendix';\nexport * from './packOrderAppendix';\nexport * from './types';\nexport * from './bitMaskValue';\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -24,12 +24,12 @@ __export(packOrderAppendix_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(packOrderAppendix_exports);
|
|
26
26
|
var import_toBigInt = require("../../math/toBigInt.cjs");
|
|
27
|
-
var
|
|
27
|
+
var import_appendixTwapValue = require("./appendixTwapValue.cjs");
|
|
28
28
|
var import_bitMaskValue = require("./bitMaskValue.cjs");
|
|
29
29
|
function mapOrderAppendixToBitValues(appendix) {
|
|
30
30
|
const value = (() => {
|
|
31
31
|
if (appendix.twap) {
|
|
32
|
-
return (0,
|
|
32
|
+
return (0, import_appendixTwapValue.packTwapOrderAppendixValue)(appendix.twap);
|
|
33
33
|
}
|
|
34
34
|
if (appendix.isolated) {
|
|
35
35
|
return (0, import_toBigInt.toBigInt)(appendix.isolated.margin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTwapOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAyB;AACzB,+BAA2C;AAC3C,0BAA6B;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,iBAAO,qDAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,iBAAO,0BAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,aAAS,kCAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,UAAO,kCAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,SAAM,kCAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,SAAM,kCAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,SAAM,kCAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,SAAM,kCAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
|
|
@@ -2,12 +2,12 @@ import "../../../chunk-5WRI5ZAA.js";
|
|
|
2
2
|
|
|
3
3
|
// src/utils/orders/appendix/packOrderAppendix.ts
|
|
4
4
|
import { toBigInt } from "../../math/toBigInt.js";
|
|
5
|
-
import {
|
|
5
|
+
import { packTwapOrderAppendixValue } from "./appendixTwapValue.js";
|
|
6
6
|
import { bitMaskValue } from "./bitMaskValue.js";
|
|
7
7
|
function mapOrderAppendixToBitValues(appendix) {
|
|
8
8
|
const value = (() => {
|
|
9
9
|
if (appendix.twap) {
|
|
10
|
-
return
|
|
10
|
+
return packTwapOrderAppendixValue(appendix.twap);
|
|
11
11
|
}
|
|
12
12
|
if (appendix.isolated) {
|
|
13
13
|
return toBigInt(appendix.isolated.margin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/packOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { toBigInt } from '../../math/toBigInt';\nimport { packTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapOrderAppendixToBitValues(\n appendix: OrderAppendix,\n): PackedOrderAppendixBits {\n const value = (() => {\n if (appendix.twap) {\n return packTwapOrderAppendixValue(appendix.twap);\n }\n if (appendix.isolated) {\n return toBigInt(appendix.isolated.margin);\n }\n return 0n;\n })();\n const trigger = (() => {\n switch (appendix.triggerType) {\n case 'price':\n return 1;\n case 'twap':\n return 2;\n case 'twap_custom_amounts':\n return 3;\n default:\n return 0;\n }\n })();\n const orderType = (() => {\n switch (appendix.orderExecutionType) {\n case 'default':\n return 0;\n case 'ioc':\n return 1;\n case 'fok':\n return 2;\n case 'post_only':\n return 3;\n }\n })();\n\n return {\n value,\n reserved: 0,\n trigger,\n reduceOnly: appendix.reduceOnly ? 1 : 0,\n orderType,\n isolated: appendix.isolated ? 1 : 0,\n version: 0,\n };\n}\n\n/**\n * Pack the OrderAppendix fields into a single bigint.\n * @param appendix\n */\nexport function packOrderAppendix(appendix: OrderAppendix): bigint {\n const bits = mapOrderAppendixToBitValues(appendix);\n\n // Ensure value is within 96 bits\n let packed = bitMaskValue(bits.value, 96);\n packed = (packed << 18n) | bitMaskValue(bits.reserved, 18);\n packed = (packed << 2n) | bitMaskValue(bits.trigger, 2);\n packed = (packed << 1n) | bitMaskValue(bits.reduceOnly, 1);\n packed = (packed << 2n) | bitMaskValue(bits.orderType, 2);\n packed = (packed << 1n) | bitMaskValue(bits.isolated, 1);\n packed = (packed << 8n) | bitMaskValue(bits.version, 8);\n return packed;\n}\n"],"mappings":";;;AACA,SAAS,gBAAgB;AACzB,SAAS,kCAAkC;AAC3C,SAAS,oBAAoB;AAG7B,SAAS,4BACP,UACyB;AACzB,QAAM,SAAS,MAAM;AACnB,QAAI,SAAS,MAAM;AACjB,aAAO,2BAA2B,SAAS,IAAI;AAAA,IACjD;AACA,QAAI,SAAS,UAAU;AACrB,aAAO,SAAS,SAAS,SAAS,MAAM;AAAA,IAC1C;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,WAAW,MAAM;AACrB,YAAQ,SAAS,aAAa;AAAA,MAC5B,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,aAAa,MAAM;AACvB,YAAQ,SAAS,oBAAoB;AAAA,MACnC,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY,SAAS,aAAa,IAAI;AAAA,IACtC;AAAA,IACA,UAAU,SAAS,WAAW,IAAI;AAAA,IAClC,SAAS;AAAA,EACX;AACF;AAMO,SAAS,kBAAkB,UAAiC;AACjE,QAAM,OAAO,4BAA4B,QAAQ;AAGjD,MAAI,SAAS,aAAa,KAAK,OAAO,EAAE;AACxC,WAAU,UAAU,MAAO,aAAa,KAAK,UAAU,EAAE;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,WAAU,UAAU,KAAM,aAAa,KAAK,YAAY,CAAC;AACzD,WAAU,UAAU,KAAM,aAAa,KAAK,WAAW,CAAC;AACxD,WAAU,UAAU,KAAM,aAAa,KAAK,UAAU,CAAC;AACvD,WAAU,UAAU,KAAM,aAAa,KAAK,SAAS,CAAC;AACtD,SAAO;AACT;","names":[]}
|
|
@@ -24,7 +24,7 @@ __export(unpackOrderAppendix_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(unpackOrderAppendix_exports);
|
|
26
26
|
var import_math = require("../../math/index.cjs");
|
|
27
|
-
var
|
|
27
|
+
var import_appendixTwapValue = require("./appendixTwapValue.cjs");
|
|
28
28
|
var import_bitMaskValue = require("./bitMaskValue.cjs");
|
|
29
29
|
function mapBitValuesToAppendix(bits) {
|
|
30
30
|
const triggerType = (() => {
|
|
@@ -63,7 +63,7 @@ function mapBitValuesToAppendix(bits) {
|
|
|
63
63
|
})();
|
|
64
64
|
const twapFields = (() => {
|
|
65
65
|
if (triggerType === "twap" || triggerType === "twap_custom_amounts") {
|
|
66
|
-
return (0,
|
|
66
|
+
return (0, import_appendixTwapValue.unpackTwapOrderAppendixValue)(bits.value);
|
|
67
67
|
}
|
|
68
68
|
})();
|
|
69
69
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport { unpackTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {\n const triggerType = (() => {\n switch (bits.trigger) {\n case 1:\n return 'price';\n case 2:\n return 'twap';\n case 3:\n return 'twap_custom_amounts';\n default:\n return undefined;\n }\n })();\n const orderExecutionType = (() => {\n switch (bits.orderType) {\n case 0:\n return 'default';\n case 1:\n return 'ioc';\n case 2:\n return 'fok';\n case 3:\n return 'post_only';\n default:\n throw new Error(\n `[mapBitValuesToAppendix] Unknown order type: ${bits.orderType}`,\n );\n }\n })();\n const isolatedFields = (() => {\n if (bits.isolated) {\n return { margin: bits.value };\n }\n return undefined;\n })();\n const twapFields = (() => {\n if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {\n return unpackTwapOrderAppendixValue(bits.value);\n }\n })();\n\n return {\n reduceOnly: !!bits.reduceOnly,\n orderExecutionType,\n triggerType,\n isolated: isolatedFields,\n twap: twapFields,\n };\n}\n\n/**\n * Unpack the OrderAppendix fields from a packed bigint.\n * @param packed\n */\nexport function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {\n let temp = toBigInt(packed);\n // Bitmasks lowest 8 bits for version\n const version = Number(bitMaskValue(temp, 8));\n // Shift out the version bits\n temp >>= 8n;\n // Repeat for the rest of the fields\n const isolated = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const orderType = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reduceOnly = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const trigger = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reserved = Number(bitMaskValue(temp, 18));\n temp >>= 18n;\n // The remaining bits are the value, which should be 96 bits\n const value = bitMaskValue(temp, 96);\n\n return mapBitValuesToAppendix({\n value,\n reserved,\n trigger,\n reduceOnly,\n orderType,\n isolated,\n version,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAwC;AACxC,+BAA6C;AAC7C,0BAA6B;AAG7B,SAAS,uBAAuB,MAA8C;AAC5E,QAAM,eAAe,MAAM;AACzB,YAAQ,KAAK,SAAS;AAAA,MACpB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,sBAAsB,MAAM;AAChC,YAAQ,KAAK,WAAW;AAAA,MACtB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,cAAM,IAAI;AAAA,UACR,gDAAgD,KAAK,SAAS;AAAA,QAChE;AAAA,IACJ;AAAA,EACF,GAAG;AACH,QAAM,kBAAkB,MAAM;AAC5B,QAAI,KAAK,UAAU;AACjB,aAAO,EAAE,QAAQ,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,cAAc,MAAM;AACxB,QAAI,gBAAgB,UAAU,gBAAgB,uBAAuB;AACnE,iBAAO,uDAA6B,KAAK,KAAK;AAAA,IAChD;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL,YAAY,CAAC,CAAC,KAAK;AAAA,IACnB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AACF;AAMO,SAAS,oBAAoB,QAAsC;AACxE,MAAI,WAAO,sBAAS,MAAM;AAE1B,QAAM,UAAU,WAAO,kCAAa,MAAM,CAAC,CAAC;AAE5C,WAAS;AAET,QAAM,WAAW,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC7C,WAAS;AACT,QAAM,YAAY,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC9C,WAAS;AACT,QAAM,aAAa,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC/C,WAAS;AACT,QAAM,UAAU,WAAO,kCAAa,MAAM,CAAC,CAAC;AAC5C,WAAS;AACT,QAAM,WAAW,WAAO,kCAAa,MAAM,EAAE,CAAC;AAC9C,WAAS;AAET,QAAM,YAAQ,kCAAa,MAAM,EAAE;AAEnC,SAAO,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -2,7 +2,7 @@ import "../../../chunk-5WRI5ZAA.js";
|
|
|
2
2
|
|
|
3
3
|
// src/utils/orders/appendix/unpackOrderAppendix.ts
|
|
4
4
|
import { toBigInt } from "../../math/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { unpackTwapOrderAppendixValue } from "./appendixTwapValue.js";
|
|
6
6
|
import { bitMaskValue } from "./bitMaskValue.js";
|
|
7
7
|
function mapBitValuesToAppendix(bits) {
|
|
8
8
|
const triggerType = (() => {
|
|
@@ -41,7 +41,7 @@ function mapBitValuesToAppendix(bits) {
|
|
|
41
41
|
})();
|
|
42
42
|
const twapFields = (() => {
|
|
43
43
|
if (triggerType === "twap" || triggerType === "twap_custom_amounts") {
|
|
44
|
-
return
|
|
44
|
+
return unpackTwapOrderAppendixValue(bits.value);
|
|
45
45
|
}
|
|
46
46
|
})();
|
|
47
47
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/orders/appendix/unpackOrderAppendix.ts"],"sourcesContent":["import { OrderAppendix } from '../../../types/orderAppendixTypes';\nimport { BigDecimalish, toBigInt } from '../../math';\nimport { unpackTwapOrderAppendixValue } from './appendixTwapValue';\nimport { bitMaskValue } from './bitMaskValue';\nimport { PackedOrderAppendixBits } from './types';\n\nfunction mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {\n const triggerType = (() => {\n switch (bits.trigger) {\n case 1:\n return 'price';\n case 2:\n return 'twap';\n case 3:\n return 'twap_custom_amounts';\n default:\n return undefined;\n }\n })();\n const orderExecutionType = (() => {\n switch (bits.orderType) {\n case 0:\n return 'default';\n case 1:\n return 'ioc';\n case 2:\n return 'fok';\n case 3:\n return 'post_only';\n default:\n throw new Error(\n `[mapBitValuesToAppendix] Unknown order type: ${bits.orderType}`,\n );\n }\n })();\n const isolatedFields = (() => {\n if (bits.isolated) {\n return { margin: bits.value };\n }\n return undefined;\n })();\n const twapFields = (() => {\n if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {\n return unpackTwapOrderAppendixValue(bits.value);\n }\n })();\n\n return {\n reduceOnly: !!bits.reduceOnly,\n orderExecutionType,\n triggerType,\n isolated: isolatedFields,\n twap: twapFields,\n };\n}\n\n/**\n * Unpack the OrderAppendix fields from a packed bigint.\n * @param packed\n */\nexport function unpackOrderAppendix(packed: BigDecimalish): OrderAppendix {\n let temp = toBigInt(packed);\n // Bitmasks lowest 8 bits for version\n const version = Number(bitMaskValue(temp, 8));\n // Shift out the version bits\n temp >>= 8n;\n // Repeat for the rest of the fields\n const isolated = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const orderType = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reduceOnly = Number(bitMaskValue(temp, 1));\n temp >>= 1n;\n const trigger = Number(bitMaskValue(temp, 2));\n temp >>= 2n;\n const reserved = Number(bitMaskValue(temp, 18));\n temp >>= 18n;\n // The remaining bits are the value, which should be 96 bits\n const value = bitMaskValue(temp, 96);\n\n return mapBitValuesToAppendix({\n value,\n reserved,\n trigger,\n reduceOnly,\n orderType,\n isolated,\n version,\n });\n}\n"],"mappings":";;;AACA,SAAwB,gBAAgB;AACxC,SAAS,oCAAoC;AAC7C,SAAS,oBAAoB;AAG7B,SAAS,uBAAuB,MAA8C;AAC5E,QAAM,eAAe,MAAM;AACzB,YAAQ,KAAK,SAAS;AAAA,MACpB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG;AACH,QAAM,sBAAsB,MAAM;AAChC,YAAQ,KAAK,WAAW;AAAA,MACtB,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,cAAM,IAAI;AAAA,UACR,gDAAgD,KAAK,SAAS;AAAA,QAChE;AAAA,IACJ;AAAA,EACF,GAAG;AACH,QAAM,kBAAkB,MAAM;AAC5B,QAAI,KAAK,UAAU;AACjB,aAAO,EAAE,QAAQ,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT,GAAG;AACH,QAAM,cAAc,MAAM;AACxB,QAAI,gBAAgB,UAAU,gBAAgB,uBAAuB;AACnE,aAAO,6BAA6B,KAAK,KAAK;AAAA,IAChD;AAAA,EACF,GAAG;AAEH,SAAO;AAAA,IACL,YAAY,CAAC,CAAC,KAAK;AAAA,IACnB;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,EACR;AACF;AAMO,SAAS,oBAAoB,QAAsC;AACxE,MAAI,OAAO,SAAS,MAAM;AAE1B,QAAM,UAAU,OAAO,aAAa,MAAM,CAAC,CAAC;AAE5C,WAAS;AAET,QAAM,WAAW,OAAO,aAAa,MAAM,CAAC,CAAC;AAC7C,WAAS;AACT,QAAM,YAAY,OAAO,aAAa,MAAM,CAAC,CAAC;AAC9C,WAAS;AACT,QAAM,aAAa,OAAO,aAAa,MAAM,CAAC,CAAC;AAC/C,WAAS;AACT,QAAM,UAAU,OAAO,aAAa,MAAM,CAAC,CAAC;AAC5C,WAAS;AACT,QAAM,WAAW,OAAO,aAAa,MAAM,EAAE,CAAC;AAC9C,WAAS;AAET,QAAM,QAAQ,aAAa,MAAM,EAAE;AAEnC,SAAO,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orderNonce.cjs';
|
|
2
2
|
export { getDefaultRecvTime } from './recvTime.cjs';
|
|
3
|
-
export {
|
|
3
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendix/appendixTwapValue.cjs';
|
|
4
4
|
export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.cjs';
|
|
5
5
|
export { packOrderAppendix } from './appendix/packOrderAppendix.cjs';
|
|
6
6
|
export { PackedOrderAppendixBits } from './appendix/types.cjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getOrderNonce, getRecvTimeFromOrderNonce } from './orderNonce.js';
|
|
2
2
|
export { getDefaultRecvTime } from './recvTime.js';
|
|
3
|
-
export {
|
|
3
|
+
export { packTwapOrderAppendixValue, unpackTwapOrderAppendixValue } from './appendix/appendixTwapValue.js';
|
|
4
4
|
export { unpackOrderAppendix } from './appendix/unpackOrderAppendix.js';
|
|
5
5
|
export { packOrderAppendix } from './appendix/packOrderAppendix.js';
|
|
6
6
|
export { PackedOrderAppendixBits } from './appendix/types.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/shared",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Shared utilities, types, and contract helpers for Nado SDK",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"bignumber.js": "^9.3.0",
|
|
46
46
|
"viem": "*"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "660de2d7026b3ebacd2f17115196f94438bcc8bb"
|
|
49
49
|
}
|
|
@@ -13,7 +13,7 @@ export type OrderAppendixTriggerType =
|
|
|
13
13
|
/**
|
|
14
14
|
* Fields associated with a TWAP trigger order.
|
|
15
15
|
*/
|
|
16
|
-
export interface
|
|
16
|
+
export interface OrderAppendixTwapFields {
|
|
17
17
|
/**
|
|
18
18
|
* Number of TWAP orders to be placed.
|
|
19
19
|
*/
|
|
@@ -54,5 +54,5 @@ export interface OrderAppendix {
|
|
|
54
54
|
* Specify if the order is a TWAP order
|
|
55
55
|
* An order CANNOT be both a TWAP order and an isolated order.
|
|
56
56
|
*/
|
|
57
|
-
twap?:
|
|
57
|
+
twap?: OrderAppendixTwapFields;
|
|
58
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrderAppendixTwapFields } from '../../../types/orderAppendixTypes';
|
|
2
2
|
import { addDecimals, removeDecimals, toBigInt } from '../../math';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -14,10 +14,10 @@ import { addDecimals, removeDecimals, toBigInt } from '../../math';
|
|
|
14
14
|
* - `slippage_x6` occupies bits 63..32 (middle 32 bits)
|
|
15
15
|
* - `reserved` occupies bits 31..0 (least significant 32 bits)
|
|
16
16
|
*/
|
|
17
|
-
export function
|
|
17
|
+
export function packTwapOrderAppendixValue({
|
|
18
18
|
numOrders,
|
|
19
19
|
slippageFrac,
|
|
20
|
-
}:
|
|
20
|
+
}: OrderAppendixTwapFields): bigint {
|
|
21
21
|
const numOrdersBigInt = toBigInt(numOrders);
|
|
22
22
|
const slippageX6BigInt = toBigInt(addDecimals(slippageFrac, 6));
|
|
23
23
|
|
|
@@ -38,9 +38,9 @@ export function packTWAPOrderAppendixValue({
|
|
|
38
38
|
* - slippage_x6: number, from bits 63..32
|
|
39
39
|
* - reserved: number, from bits 31..0
|
|
40
40
|
*/
|
|
41
|
-
export function
|
|
41
|
+
export function unpackTwapOrderAppendixValue(
|
|
42
42
|
value: bigint,
|
|
43
|
-
):
|
|
43
|
+
): OrderAppendixTwapFields {
|
|
44
44
|
const numOrders = (value >> 64n) & 0xffffffffn;
|
|
45
45
|
const slippageX6 = (value >> 32n) & 0xffffffffn;
|
|
46
46
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OrderAppendix } from '../../../types/orderAppendixTypes';
|
|
2
2
|
import { toBigInt } from '../../math/toBigInt';
|
|
3
|
-
import {
|
|
3
|
+
import { packTwapOrderAppendixValue } from './appendixTwapValue';
|
|
4
4
|
import { bitMaskValue } from './bitMaskValue';
|
|
5
5
|
import { PackedOrderAppendixBits } from './types';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ function mapOrderAppendixToBitValues(
|
|
|
9
9
|
): PackedOrderAppendixBits {
|
|
10
10
|
const value = (() => {
|
|
11
11
|
if (appendix.twap) {
|
|
12
|
-
return
|
|
12
|
+
return packTwapOrderAppendixValue(appendix.twap);
|
|
13
13
|
}
|
|
14
14
|
if (appendix.isolated) {
|
|
15
15
|
return toBigInt(appendix.isolated.margin);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OrderAppendix } from '../../../types/orderAppendixTypes';
|
|
2
2
|
import { BigDecimalish, toBigInt } from '../../math';
|
|
3
|
-
import {
|
|
3
|
+
import { unpackTwapOrderAppendixValue } from './appendixTwapValue';
|
|
4
4
|
import { bitMaskValue } from './bitMaskValue';
|
|
5
5
|
import { PackedOrderAppendixBits } from './types';
|
|
6
6
|
|
|
@@ -41,7 +41,7 @@ function mapBitValuesToAppendix(bits: PackedOrderAppendixBits): OrderAppendix {
|
|
|
41
41
|
})();
|
|
42
42
|
const twapFields = (() => {
|
|
43
43
|
if (triggerType === 'twap' || triggerType === 'twap_custom_amounts') {
|
|
44
|
-
return
|
|
44
|
+
return unpackTwapOrderAppendixValue(bits.value);
|
|
45
45
|
}
|
|
46
46
|
})();
|
|
47
47
|
|