@nadohq/shared 0.1.0-alpha.45 → 0.1.0-alpha.47
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 +32 -33
- package/dist/consts/chainEnvToChain.d.ts +32 -33
- package/dist/consts/index.d.cts +0 -1
- package/dist/consts/index.d.ts +0 -1
- package/dist/eip712/eip712ValueTypes.d.cts +1 -1
- package/dist/eip712/eip712ValueTypes.d.ts +1 -1
- package/dist/encoding/encoding.cjs +21 -0
- package/dist/encoding/encoding.cjs.map +1 -1
- package/dist/encoding/encoding.d.cts +27 -3
- package/dist/encoding/encoding.d.ts +27 -3
- package/dist/encoding/encoding.js +24 -1
- package/dist/encoding/encoding.js.map +1 -1
- package/dist/encoding/index.d.cts +2 -2
- package/dist/encoding/index.d.ts +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/types/balanceTypes.d.cts +1 -1
- package/dist/types/balanceTypes.d.ts +1 -1
- 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 +21 -1
- package/dist/types/orderAppendixTypes.d.ts +21 -1
- package/dist/types/viemTypes.d.cts +1 -1
- package/dist/types/viemTypes.d.ts +1 -1
- package/dist/utils/balanceValue.d.cts +1 -1
- package/dist/utils/balanceValue.d.ts +1 -1
- package/dist/utils/bytes32.d.cts +1 -1
- package/dist/utils/bytes32.d.ts +1 -1
- package/dist/utils/math/bigDecimal.cjs +4 -3
- package/dist/utils/math/bigDecimal.cjs.map +1 -1
- package/dist/utils/math/bigDecimal.js +4 -3
- package/dist/utils/math/bigDecimal.js.map +1 -1
- package/dist/utils/orders/appendix/orderAppendix.test.cjs +54 -0
- package/dist/utils/orders/appendix/orderAppendix.test.cjs.map +1 -1
- package/dist/utils/orders/appendix/orderAppendix.test.js +54 -0
- package/dist/utils/orders/appendix/orderAppendix.test.js.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.cjs +5 -1
- package/dist/utils/orders/appendix/packOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/packOrderAppendix.js +5 -1
- 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 +19 -3
- package/dist/utils/orders/appendix/unpackOrderAppendix.cjs.map +1 -1
- package/dist/utils/orders/appendix/unpackOrderAppendix.js +19 -3
- package/dist/utils/orders/appendix/unpackOrderAppendix.js.map +1 -1
- package/dist/utils/productTypeFilter.d.cts +2 -2
- package/dist/utils/productTypeFilter.d.ts +2 -2
- package/dist/utils/toPrintableObject.cjs +2 -2
- package/dist/utils/toPrintableObject.cjs.map +1 -1
- package/dist/utils/toPrintableObject.d.cts +5 -1
- package/dist/utils/toPrintableObject.d.ts +5 -1
- package/dist/utils/toPrintableObject.js +2 -2
- package/dist/utils/toPrintableObject.js.map +1 -1
- package/package.json +6 -3
- package/src/encoding/encoding.ts +43 -1
- package/src/types/orderAppendixTypes.ts +21 -0
- package/src/utils/math/bigDecimal.ts +5 -3
- package/src/utils/orders/appendix/orderAppendix.test.ts +58 -0
- package/src/utils/orders/appendix/packOrderAppendix.ts +5 -1
- package/src/utils/orders/appendix/types.ts +7 -5
- package/src/utils/orders/appendix/unpackOrderAppendix.ts +18 -2
- package/src/utils/toPrintableObject.ts +11 -2
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
|
+
import { SignedEIP712OrderParams, SignedTx, EIP712WithdrawCollateralParams } from '../eip712/signatureParamTypes.js';
|
|
3
3
|
import '../types/subaccountTypes.js';
|
|
4
4
|
import '../types/bytes.js';
|
|
5
5
|
import '../utils/math/bigDecimal.js';
|
|
6
6
|
import 'bignumber.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Transaction type identifiers for slow mode transactions.
|
|
10
|
+
*/
|
|
11
|
+
declare enum SlowModeTxType {
|
|
12
|
+
DepositCollateral = 1,
|
|
13
|
+
WithdrawCollateral = 2,
|
|
14
|
+
LinkSigner = 13,
|
|
15
|
+
ClaimBuilderFee = 31
|
|
16
|
+
}
|
|
8
17
|
declare function encodeSignedWithdrawCollateralTx(signed: SignedTx<EIP712WithdrawCollateralParams>): `0x${string}`;
|
|
9
18
|
declare function encodeSignedOrder(signed: SignedEIP712OrderParams): `0x${string}`;
|
|
19
|
+
interface ClaimBuilderFeeParams {
|
|
20
|
+
/** The sender subaccount as bytes32 */
|
|
21
|
+
sender: Hex;
|
|
22
|
+
/** The builder ID to claim fees for */
|
|
23
|
+
builderId: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Encodes a ClaimBuilderFee slow mode transaction.
|
|
27
|
+
*
|
|
28
|
+
* Format: [tx_type_byte] + [abi_encoded_params]
|
|
29
|
+
*
|
|
30
|
+
* @param params - The claim builder fee parameters
|
|
31
|
+
* @returns The encoded transaction bytes ready to submit via endpoint.submitSlowModeTransaction
|
|
32
|
+
*/
|
|
33
|
+
declare function encodeClaimBuilderFeeTx(params: ClaimBuilderFeeParams): Hex;
|
|
10
34
|
|
|
11
|
-
export { encodeSignedOrder, encodeSignedWithdrawCollateralTx };
|
|
35
|
+
export { type ClaimBuilderFeeParams, SlowModeTxType, encodeClaimBuilderFeeTx, encodeSignedOrder, encodeSignedWithdrawCollateralTx };
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import "../chunk-5WRI5ZAA.js";
|
|
2
2
|
|
|
3
3
|
// src/encoding/encoding.ts
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
encodeAbiParameters,
|
|
6
|
+
encodePacked,
|
|
7
|
+
parseAbiParameters
|
|
8
|
+
} from "viem";
|
|
5
9
|
import { addDecimals, toBigInt } from "../utils/index.js";
|
|
10
|
+
var SlowModeTxType = /* @__PURE__ */ ((SlowModeTxType2) => {
|
|
11
|
+
SlowModeTxType2[SlowModeTxType2["DepositCollateral"] = 1] = "DepositCollateral";
|
|
12
|
+
SlowModeTxType2[SlowModeTxType2["WithdrawCollateral"] = 2] = "WithdrawCollateral";
|
|
13
|
+
SlowModeTxType2[SlowModeTxType2["LinkSigner"] = 13] = "LinkSigner";
|
|
14
|
+
SlowModeTxType2[SlowModeTxType2["ClaimBuilderFee"] = 31] = "ClaimBuilderFee";
|
|
15
|
+
return SlowModeTxType2;
|
|
16
|
+
})(SlowModeTxType || {});
|
|
6
17
|
function encodeSignedWithdrawCollateralTx(signed) {
|
|
7
18
|
return encodeAbiParameters(
|
|
8
19
|
parseAbiParameters(
|
|
@@ -42,7 +53,19 @@ function encodeSignedOrder(signed) {
|
|
|
42
53
|
]
|
|
43
54
|
);
|
|
44
55
|
}
|
|
56
|
+
function encodeClaimBuilderFeeTx(params) {
|
|
57
|
+
const txBytes = encodeAbiParameters(
|
|
58
|
+
parseAbiParameters("bytes32 sender, uint32 builderId"),
|
|
59
|
+
[params.sender, params.builderId]
|
|
60
|
+
);
|
|
61
|
+
return encodePacked(
|
|
62
|
+
["uint8", "bytes"],
|
|
63
|
+
[31 /* ClaimBuilderFee */, txBytes]
|
|
64
|
+
);
|
|
65
|
+
}
|
|
45
66
|
export {
|
|
67
|
+
SlowModeTxType,
|
|
68
|
+
encodeClaimBuilderFeeTx,
|
|
46
69
|
encodeSignedOrder,
|
|
47
70
|
encodeSignedWithdrawCollateralTx
|
|
48
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/encoding/encoding.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/encoding/encoding.ts"],"sourcesContent":["import {\n encodeAbiParameters,\n encodePacked,\n parseAbiParameters,\n type Hex,\n} from 'viem';\nimport {\n EIP712WithdrawCollateralParams,\n SignedEIP712OrderParams,\n SignedTx,\n} from '../eip712';\nimport { addDecimals, toBigInt } from '../utils';\n\n/**\n * Transaction type identifiers for slow mode transactions.\n */\nexport enum SlowModeTxType {\n DepositCollateral = 1,\n WithdrawCollateral = 2,\n LinkSigner = 13,\n ClaimBuilderFee = 31,\n}\n\nexport function encodeSignedWithdrawCollateralTx(\n signed: SignedTx<EIP712WithdrawCollateralParams>,\n) {\n return encodeAbiParameters(\n parseAbiParameters(\n '(tuple(address sender, string subaccountName, uint32 productId, uint128 amount, uint64 nonce), bytes signature)',\n ),\n [\n [\n [\n signed.tx.subaccountOwner,\n signed.tx.subaccountName,\n signed.tx.productId,\n signed.tx.amount,\n signed.tx.nonce,\n ],\n signed.signature,\n ],\n ],\n );\n}\n\nexport function encodeSignedOrder(signed: SignedEIP712OrderParams) {\n return encodeAbiParameters(\n parseAbiParameters(\n '(tuple(tuple(address sender, string subaccountName, int128 priceX18, int128 amount, uint64 expiration, uint64 nonce), bytes signature))',\n ),\n [\n [\n [\n signed.order.subaccountOwner,\n signed.order.subaccountName,\n toBigInt(addDecimals(signed.order.price)),\n signed.order.amount,\n signed.order.expiration,\n signed.order.nonce,\n ],\n signed.signature,\n ],\n ],\n );\n}\n\nexport interface ClaimBuilderFeeParams {\n /** The sender subaccount as bytes32 */\n sender: Hex;\n /** The builder ID to claim fees for */\n builderId: number;\n}\n\n/**\n * Encodes a ClaimBuilderFee slow mode transaction.\n *\n * Format: [tx_type_byte] + [abi_encoded_params]\n *\n * @param params - The claim builder fee parameters\n * @returns The encoded transaction bytes ready to submit via endpoint.submitSlowModeTransaction\n */\nexport function encodeClaimBuilderFeeTx(params: ClaimBuilderFeeParams): Hex {\n const txBytes = encodeAbiParameters(\n parseAbiParameters('bytes32 sender, uint32 builderId'),\n [params.sender, params.builderId],\n );\n\n return encodePacked(\n ['uint8', 'bytes'],\n [SlowModeTxType.ClaimBuilderFee, txBytes],\n );\n}\n"],"mappings":";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAMP,SAAS,aAAa,gBAAgB;AAK/B,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gCAAA,uBAAoB,KAApB;AACA,EAAAA,gCAAA,wBAAqB,KAArB;AACA,EAAAA,gCAAA,gBAAa,MAAb;AACA,EAAAA,gCAAA,qBAAkB,MAAlB;AAJU,SAAAA;AAAA,GAAA;AAOL,SAAS,iCACd,QACA;AACA,SAAO;AAAA,IACL;AAAA,MACE;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,QACE;AAAA,UACE,OAAO,GAAG;AAAA,UACV,OAAO,GAAG;AAAA,UACV,OAAO,GAAG;AAAA,UACV,OAAO,GAAG;AAAA,UACV,OAAO,GAAG;AAAA,QACZ;AAAA,QACA,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,kBAAkB,QAAiC;AACjE,SAAO;AAAA,IACL;AAAA,MACE;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,QACE;AAAA,UACE,OAAO,MAAM;AAAA,UACb,OAAO,MAAM;AAAA,UACb,SAAS,YAAY,OAAO,MAAM,KAAK,CAAC;AAAA,UACxC,OAAO,MAAM;AAAA,UACb,OAAO,MAAM;AAAA,UACb,OAAO,MAAM;AAAA,QACf;AAAA,QACA,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;AAiBO,SAAS,wBAAwB,QAAoC;AAC1E,QAAM,UAAU;AAAA,IACd,mBAAmB,kCAAkC;AAAA,IACrD,CAAC,OAAO,QAAQ,OAAO,SAAS;AAAA,EAClC;AAEA,SAAO;AAAA,IACL,CAAC,SAAS,OAAO;AAAA,IACjB,CAAC,0BAAgC,OAAO;AAAA,EAC1C;AACF;","names":["SlowModeTxType"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding.cjs';
|
|
2
|
-
import '../eip712/signatureParamTypes.cjs';
|
|
1
|
+
export { ClaimBuilderFeeParams, SlowModeTxType, encodeClaimBuilderFeeTx, encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding.cjs';
|
|
3
2
|
import 'viem';
|
|
3
|
+
import '../eip712/signatureParamTypes.cjs';
|
|
4
4
|
import '../types/subaccountTypes.cjs';
|
|
5
5
|
import '../types/bytes.cjs';
|
|
6
6
|
import '../utils/math/bigDecimal.cjs';
|
package/dist/encoding/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding.js';
|
|
2
|
-
import '../eip712/signatureParamTypes.js';
|
|
1
|
+
export { ClaimBuilderFeeParams, SlowModeTxType, encodeClaimBuilderFeeTx, encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding.js';
|
|
3
2
|
import 'viem';
|
|
3
|
+
import '../eip712/signatureParamTypes.js';
|
|
4
4
|
import '../types/subaccountTypes.js';
|
|
5
5
|
import '../types/bytes.js';
|
|
6
6
|
import '../utils/math/bigDecimal.js';
|
package/dist/index.d.cts
CHANGED
|
@@ -20,7 +20,7 @@ export { getSignedTransactionRequest } from './eip712/getSignedTransactionReques
|
|
|
20
20
|
export { getOrderDigest } from './eip712/orderDigest.cjs';
|
|
21
21
|
export { SignableRequestType, SignableRequestTypeToParams } from './eip712/signableRequestType.cjs';
|
|
22
22
|
export { EIP712BurnNlpParams, EIP712CancelOrdersParams, EIP712CancelProductOrdersParams, EIP712LeaderboardAuthenticationParams, EIP712LinkSignerParams, EIP712LiquidateSubaccountParams, EIP712ListTriggerOrdersParams, EIP712MintNlpParams, EIP712OrderParams, EIP712TransferQuoteParams, EIP712WithdrawCollateralParams, SignedEIP712OrderParams, SignedTx } from './eip712/signatureParamTypes.cjs';
|
|
23
|
-
export { encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding/encoding.cjs';
|
|
23
|
+
export { ClaimBuilderFeeParams, SlowModeTxType, encodeClaimBuilderFeeTx, encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding/encoding.cjs';
|
|
24
24
|
export { ApproveDepositAllowanceParams, approveDepositAllowance } from './execute/approveDepositAllowance.cjs';
|
|
25
25
|
export { DepositCollateralParams, depositCollateral } from './execute/depositCollateral.cjs';
|
|
26
26
|
export { Balance, BalanceHealthContributions, BalanceSide, BalanceWithProduct, PerpBalance, PerpBalanceWithProduct, SpotBalance, SpotBalanceWithProduct } from './types/balanceTypes.cjs';
|
|
@@ -29,7 +29,7 @@ export { ALL_CHAIN_ENVS, ChainEnv, LOCAL_CHAIN_ENVS, MAINNET_CHAIN_ENVS, TESTNET
|
|
|
29
29
|
export { HealthGroup, HealthStatus, HealthStatusByType, HealthType } from './types/healthTypes.cjs';
|
|
30
30
|
export { Market, MarketWithProduct, PerpMarket, SpotMarket } from './types/marketTypes.cjs';
|
|
31
31
|
export { NadoContracts, WithContract, WithContracts } from './types/nadoContractTypes.cjs';
|
|
32
|
-
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.cjs';
|
|
32
|
+
export { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.cjs';
|
|
33
33
|
export { OrderExecutionType } from './types/OrderExecutionType.cjs';
|
|
34
34
|
export { PerpProduct, Product, ProductEngineType, SpotProduct, toProductEngineType } from './types/productTypes.cjs';
|
|
35
35
|
export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './types/subaccountTypes.cjs';
|
|
@@ -62,6 +62,6 @@ export { isPerpBalance, isPerpProduct, isSpotBalance, isSpotProduct } from './ut
|
|
|
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
|
@@ -20,7 +20,7 @@ export { getSignedTransactionRequest } from './eip712/getSignedTransactionReques
|
|
|
20
20
|
export { getOrderDigest } from './eip712/orderDigest.js';
|
|
21
21
|
export { SignableRequestType, SignableRequestTypeToParams } from './eip712/signableRequestType.js';
|
|
22
22
|
export { EIP712BurnNlpParams, EIP712CancelOrdersParams, EIP712CancelProductOrdersParams, EIP712LeaderboardAuthenticationParams, EIP712LinkSignerParams, EIP712LiquidateSubaccountParams, EIP712ListTriggerOrdersParams, EIP712MintNlpParams, EIP712OrderParams, EIP712TransferQuoteParams, EIP712WithdrawCollateralParams, SignedEIP712OrderParams, SignedTx } from './eip712/signatureParamTypes.js';
|
|
23
|
-
export { encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding/encoding.js';
|
|
23
|
+
export { ClaimBuilderFeeParams, SlowModeTxType, encodeClaimBuilderFeeTx, encodeSignedOrder, encodeSignedWithdrawCollateralTx } from './encoding/encoding.js';
|
|
24
24
|
export { ApproveDepositAllowanceParams, approveDepositAllowance } from './execute/approveDepositAllowance.js';
|
|
25
25
|
export { DepositCollateralParams, depositCollateral } from './execute/depositCollateral.js';
|
|
26
26
|
export { Balance, BalanceHealthContributions, BalanceSide, BalanceWithProduct, PerpBalance, PerpBalanceWithProduct, SpotBalance, SpotBalanceWithProduct } from './types/balanceTypes.js';
|
|
@@ -29,7 +29,7 @@ export { ALL_CHAIN_ENVS, ChainEnv, LOCAL_CHAIN_ENVS, MAINNET_CHAIN_ENVS, TESTNET
|
|
|
29
29
|
export { HealthGroup, HealthStatus, HealthStatusByType, HealthType } from './types/healthTypes.js';
|
|
30
30
|
export { Market, MarketWithProduct, PerpMarket, SpotMarket } from './types/marketTypes.js';
|
|
31
31
|
export { NadoContracts, WithContract, WithContracts } from './types/nadoContractTypes.js';
|
|
32
|
-
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.js';
|
|
32
|
+
export { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './types/orderAppendixTypes.js';
|
|
33
33
|
export { OrderExecutionType } from './types/OrderExecutionType.js';
|
|
34
34
|
export { PerpProduct, Product, ProductEngineType, SpotProduct, toProductEngineType } from './types/productTypes.js';
|
|
35
35
|
export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './types/subaccountTypes.js';
|
|
@@ -62,6 +62,6 @@ export { isPerpBalance, isPerpProduct, isSpotBalance, isSpotProduct } from './ut
|
|
|
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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BigDecimal from 'bignumber.js';
|
|
2
2
|
import { HealthType } from './healthTypes.cjs';
|
|
3
|
-
import { ProductEngineType,
|
|
3
|
+
import { ProductEngineType, SpotProduct, PerpProduct } from './productTypes.cjs';
|
|
4
4
|
|
|
5
5
|
type BalanceSide = 'long' | 'short';
|
|
6
6
|
type BalanceHealthContributions = Record<HealthType, BigDecimal>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BigDecimal from 'bignumber.js';
|
|
2
2
|
import { HealthType } from './healthTypes.js';
|
|
3
|
-
import { ProductEngineType,
|
|
3
|
+
import { ProductEngineType, SpotProduct, PerpProduct } from './productTypes.js';
|
|
4
4
|
|
|
5
5
|
type BalanceSide = 'long' | 'short';
|
|
6
6
|
type BalanceHealthContributions = Record<HealthType, BigDecimal>;
|
package/dist/types/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ export { ALL_CHAIN_ENVS, ChainEnv, LOCAL_CHAIN_ENVS, MAINNET_CHAIN_ENVS, TESTNET
|
|
|
4
4
|
export { HealthGroup, HealthStatus, HealthStatusByType, HealthType } from './healthTypes.cjs';
|
|
5
5
|
export { Market, MarketWithProduct, PerpMarket, SpotMarket } from './marketTypes.cjs';
|
|
6
6
|
export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.cjs';
|
|
7
|
-
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.cjs';
|
|
7
|
+
export { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.cjs';
|
|
8
8
|
export { OrderExecutionType } from './OrderExecutionType.cjs';
|
|
9
9
|
export { PerpProduct, Product, ProductEngineType, SpotProduct, toProductEngineType } from './productTypes.cjs';
|
|
10
10
|
export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccountTypes.cjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { ALL_CHAIN_ENVS, ChainEnv, LOCAL_CHAIN_ENVS, MAINNET_CHAIN_ENVS, TESTNET
|
|
|
4
4
|
export { HealthGroup, HealthStatus, HealthStatusByType, HealthType } from './healthTypes.js';
|
|
5
5
|
export { Market, MarketWithProduct, PerpMarket, SpotMarket } from './marketTypes.js';
|
|
6
6
|
export { NadoContracts, WithContract, WithContracts } from './nadoContractTypes.js';
|
|
7
|
-
export { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.js';
|
|
7
|
+
export { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields } from './orderAppendixTypes.js';
|
|
8
8
|
export { OrderExecutionType } from './OrderExecutionType.js';
|
|
9
9
|
export { PerpProduct, Product, ProductEngineType, SpotProduct, toProductEngineType } from './productTypes.js';
|
|
10
10
|
export { Subaccount, SubaccountBytes32, SubaccountNameBytes12 } from './subaccountTypes.js';
|
|
@@ -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 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 * Implementation Note:\n * Packed appendix uses precision of 6 decimals on backend.\n * SDK automatically converts to/from x18 during packing/unpacking.\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":[]}
|
|
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 * Implementation Note:\n * Packed appendix uses precision of 6 decimals on backend.\n * SDK automatically converts to/from x18 during packing/unpacking.\n */\n margin: BigDecimalish;\n}\n\n/**\n * Fields for specifying a builder (fee recipient) for the order\n */\nexport interface OrderAppendixBuilderFields {\n /**\n * The builder ID (registered builder identifier)\n */\n builderId: number;\n /**\n * The builder fee rate. This is a raw 10-bit integer (0-1023) where each unit = 0.1 bps.\n * The actual fee is calculated on notional value: builder_fee = price * amount * rate\n */\n builderFeeRate: number;\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 * Specify the builder for fee sharing.\n * Builder ID is encoded in bits 48-63 (16 bits).\n * Builder fee rate is encoded in bits 38-47 (10 bits).\n */\n builder?: OrderAppendixBuilderFields;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -33,6 +33,20 @@ interface OrderAppendixIsolatedFields {
|
|
|
33
33
|
*/
|
|
34
34
|
margin: BigDecimalish;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Fields for specifying a builder (fee recipient) for the order
|
|
38
|
+
*/
|
|
39
|
+
interface OrderAppendixBuilderFields {
|
|
40
|
+
/**
|
|
41
|
+
* The builder ID (registered builder identifier)
|
|
42
|
+
*/
|
|
43
|
+
builderId: number;
|
|
44
|
+
/**
|
|
45
|
+
* The builder fee rate. This is a raw 10-bit integer (0-1023) where each unit = 0.1 bps.
|
|
46
|
+
* The actual fee is calculated on notional value: builder_fee = price * amount * rate
|
|
47
|
+
*/
|
|
48
|
+
builderFeeRate: number;
|
|
49
|
+
}
|
|
36
50
|
/**
|
|
37
51
|
* All the fields encoded by the order appendix
|
|
38
52
|
*/
|
|
@@ -53,6 +67,12 @@ interface OrderAppendix {
|
|
|
53
67
|
* An order CANNOT be both a TWAP order and an isolated order.
|
|
54
68
|
*/
|
|
55
69
|
twap?: OrderAppendixTwapFields;
|
|
70
|
+
/**
|
|
71
|
+
* Specify the builder for fee sharing.
|
|
72
|
+
* Builder ID is encoded in bits 48-63 (16 bits).
|
|
73
|
+
* Builder fee rate is encoded in bits 38-47 (10 bits).
|
|
74
|
+
*/
|
|
75
|
+
builder?: OrderAppendixBuilderFields;
|
|
56
76
|
}
|
|
57
77
|
|
|
58
|
-
export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
|
|
78
|
+
export type { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
|
|
@@ -33,6 +33,20 @@ interface OrderAppendixIsolatedFields {
|
|
|
33
33
|
*/
|
|
34
34
|
margin: BigDecimalish;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Fields for specifying a builder (fee recipient) for the order
|
|
38
|
+
*/
|
|
39
|
+
interface OrderAppendixBuilderFields {
|
|
40
|
+
/**
|
|
41
|
+
* The builder ID (registered builder identifier)
|
|
42
|
+
*/
|
|
43
|
+
builderId: number;
|
|
44
|
+
/**
|
|
45
|
+
* The builder fee rate. This is a raw 10-bit integer (0-1023) where each unit = 0.1 bps.
|
|
46
|
+
* The actual fee is calculated on notional value: builder_fee = price * amount * rate
|
|
47
|
+
*/
|
|
48
|
+
builderFeeRate: number;
|
|
49
|
+
}
|
|
36
50
|
/**
|
|
37
51
|
* All the fields encoded by the order appendix
|
|
38
52
|
*/
|
|
@@ -53,6 +67,12 @@ interface OrderAppendix {
|
|
|
53
67
|
* An order CANNOT be both a TWAP order and an isolated order.
|
|
54
68
|
*/
|
|
55
69
|
twap?: OrderAppendixTwapFields;
|
|
70
|
+
/**
|
|
71
|
+
* Specify the builder for fee sharing.
|
|
72
|
+
* Builder ID is encoded in bits 48-63 (16 bits).
|
|
73
|
+
* Builder fee rate is encoded in bits 38-47 (10 bits).
|
|
74
|
+
*/
|
|
75
|
+
builder?: OrderAppendixBuilderFields;
|
|
56
76
|
}
|
|
57
77
|
|
|
58
|
-
export type { OrderAppendix, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
|
|
78
|
+
export type { OrderAppendix, OrderAppendixBuilderFields, OrderAppendixIsolatedFields, OrderAppendixTriggerType, OrderAppendixTwapFields };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Account, Abi, GetContractReturnType, WalletClient, Transport, Chain, RpcSchema, PublicClient } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* An account with its corresponding private key. Viem does not allow private keys to be accessible from an account
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Account, Abi, GetContractReturnType, WalletClient, Transport, Chain, RpcSchema, PublicClient } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* An account with its corresponding private key. Viem does not allow private keys to be accessible from an account
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PerpBalanceWithProduct, SpotBalanceWithProduct } from '../types/balanceTypes.cjs';
|
|
2
2
|
import BigDecimal from 'bignumber.js';
|
|
3
3
|
import '../types/healthTypes.cjs';
|
|
4
4
|
import '../types/productTypes.cjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PerpBalanceWithProduct, SpotBalanceWithProduct } from '../types/balanceTypes.js';
|
|
2
2
|
import BigDecimal from 'bignumber.js';
|
|
3
3
|
import '../types/healthTypes.js';
|
|
4
4
|
import '../types/productTypes.js';
|
package/dist/utils/bytes32.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
2
|
import { Bytes } from '../types/bytes.cjs';
|
|
3
|
-
import {
|
|
3
|
+
import { SubaccountBytes32, Subaccount, SubaccountNameBytes12 } from '../types/subaccountTypes.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Converts a subaccount object (owner + name) to its bytes32 representation.
|
package/dist/utils/bytes32.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
2
|
import { Bytes } from '../types/bytes.js';
|
|
3
|
-
import {
|
|
3
|
+
import { SubaccountBytes32, Subaccount, SubaccountNameBytes12 } from '../types/subaccountTypes.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Converts a subaccount object (owner + name) to its bytes32 representation.
|
|
@@ -37,10 +37,11 @@ module.exports = __toCommonJS(bigDecimal_exports);
|
|
|
37
37
|
var import_bignumber = __toESM(require("bignumber.js"), 1);
|
|
38
38
|
var import_bignumber2 = __toESM(require("bignumber.js"), 1);
|
|
39
39
|
function toBigDecimal(val) {
|
|
40
|
+
if (import_bignumber.default.isBigNumber(val)) {
|
|
41
|
+
return val;
|
|
42
|
+
}
|
|
40
43
|
const bnConstructorVal = (() => {
|
|
41
|
-
if (val
|
|
42
|
-
return val;
|
|
43
|
-
} else if (typeof val === "string" || typeof val === "number") {
|
|
44
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
44
45
|
return val;
|
|
45
46
|
} else if (typeof val === "bigint") {
|
|
46
47
|
return val.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n if (BigDecimal.isBigNumber(val)) {\n return val;\n }\n\n const bnConstructorVal = (() => {\n if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsC;AAGtC,IAAAA,oBAAsC;AAe/B,SAAS,aAAa,KAAgC;AAC3D,MAAI,iBAAAC,QAAW,YAAY,GAAG,GAAG;AAC/B,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,MAAM;AAC9B,QAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AACtD,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,iBAAAA,QAAW,gBAAgB;AACxC;","names":["import_bignumber","BigDecimal"]}
|
|
@@ -4,10 +4,11 @@ import "../../chunk-5WRI5ZAA.js";
|
|
|
4
4
|
import { default as BigDecimal } from "bignumber.js";
|
|
5
5
|
import { default as default2 } from "bignumber.js";
|
|
6
6
|
function toBigDecimal(val) {
|
|
7
|
+
if (BigDecimal.isBigNumber(val)) {
|
|
8
|
+
return val;
|
|
9
|
+
}
|
|
7
10
|
const bnConstructorVal = (() => {
|
|
8
|
-
if (val
|
|
9
|
-
return val;
|
|
10
|
-
} else if (typeof val === "string" || typeof val === "number") {
|
|
11
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
11
12
|
return val;
|
|
12
13
|
} else if (typeof val === "bigint") {
|
|
13
14
|
return val.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/math/bigDecimal.ts"],"sourcesContent":["import { default as BigDecimal } from 'bignumber.js';\n\n// Renames `BigNumber` type from `bignumber.js`.\nexport { default as BigDecimal } from 'bignumber.js';\n\n/**\n * BigDecimal is a renamed `BigNumber` type from `bignumber.js`.\n * Includes valid values & instances for BigDecimal.\n *\n * @see https://mikemcl.github.io/bignumber.js/\n */\nexport type BigDecimalish = BigDecimal | BigDecimal.Value | bigint;\n\n/**\n * Converts a value to an instance of BigDecimal\n *\n * @param val\n */\nexport function toBigDecimal(val: BigDecimalish): BigDecimal {\n if (BigDecimal.isBigNumber(val)) {\n return val;\n }\n\n const bnConstructorVal = (() => {\n if (typeof val === 'string' || typeof val === 'number') {\n return val;\n } else if (typeof val === 'bigint') {\n return val.toString();\n }\n // This is unlikely to occur, but it's here for completeness. Uses the suggestion here: https://typescript-eslint.io/rules/no-base-to-string/#alternatives\n return JSON.stringify(val);\n })();\n return new BigDecimal(bnConstructorVal);\n}\n"],"mappings":";;;AAAA,SAAS,WAAW,kBAAkB;AAGtC,SAAoB,WAAXA,gBAA6B;AAe/B,SAAS,aAAa,KAAgC;AAC3D,MAAI,WAAW,YAAY,GAAG,GAAG;AAC/B,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,MAAM;AAC9B,QAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;AACtD,aAAO;AAAA,IACT,WAAW,OAAO,QAAQ,UAAU;AAClC,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO,KAAK,UAAU,GAAG;AAAA,EAC3B,GAAG;AACH,SAAO,IAAI,WAAW,gBAAgB;AACxC;","names":["default"]}
|
|
@@ -148,6 +148,60 @@ var import_unpackOrderAppendix = require("./unpackOrderAppendix.cjs");
|
|
|
148
148
|
(0, import_globals.expect)(unpacked.twap?.numOrders).toBe(4294967295);
|
|
149
149
|
(0, import_globals.expect)(packed).toBe(340282366841710300967557013911933828609n);
|
|
150
150
|
});
|
|
151
|
+
(0, import_globals.it)("should handle builder fields", () => {
|
|
152
|
+
const appendix = {
|
|
153
|
+
orderExecutionType: "default",
|
|
154
|
+
builder: { builderId: 123, builderFeeRate: 500 }
|
|
155
|
+
};
|
|
156
|
+
const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
|
|
157
|
+
const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
|
|
158
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(123);
|
|
159
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(500);
|
|
160
|
+
});
|
|
161
|
+
(0, import_globals.it)("should handle builder with zero fee rate", () => {
|
|
162
|
+
const appendix = {
|
|
163
|
+
orderExecutionType: "default",
|
|
164
|
+
builder: { builderId: 42, builderFeeRate: 0 }
|
|
165
|
+
};
|
|
166
|
+
const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
|
|
167
|
+
const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
|
|
168
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(42);
|
|
169
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(0);
|
|
170
|
+
});
|
|
171
|
+
(0, import_globals.it)("should handle builder with max values", () => {
|
|
172
|
+
const appendix = {
|
|
173
|
+
orderExecutionType: "default",
|
|
174
|
+
builder: { builderId: 65535, builderFeeRate: 1023 }
|
|
175
|
+
// 16 bits, 10 bits max
|
|
176
|
+
};
|
|
177
|
+
const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
|
|
178
|
+
const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
|
|
179
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(65535);
|
|
180
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(1023);
|
|
181
|
+
});
|
|
182
|
+
(0, import_globals.it)("should handle builder combined with other flags", () => {
|
|
183
|
+
const appendix = {
|
|
184
|
+
orderExecutionType: "ioc",
|
|
185
|
+
reduceOnly: true,
|
|
186
|
+
triggerType: "price",
|
|
187
|
+
builder: { builderId: 5, builderFeeRate: 100 }
|
|
188
|
+
};
|
|
189
|
+
const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
|
|
190
|
+
const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
|
|
191
|
+
(0, import_globals.expect)(unpacked.orderExecutionType).toBe("ioc");
|
|
192
|
+
(0, import_globals.expect)(unpacked.reduceOnly).toBe(true);
|
|
193
|
+
(0, import_globals.expect)(unpacked.triggerType).toBe("price");
|
|
194
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(5);
|
|
195
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(100);
|
|
196
|
+
});
|
|
197
|
+
(0, import_globals.it)("should not return builder fields when builderId is 0", () => {
|
|
198
|
+
const appendix = {
|
|
199
|
+
orderExecutionType: "default"
|
|
200
|
+
};
|
|
201
|
+
const packed = (0, import_packOrderAppendix.packOrderAppendix)(appendix);
|
|
202
|
+
const unpacked = (0, import_unpackOrderAppendix.unpackOrderAppendix)(packed);
|
|
203
|
+
(0, import_globals.expect)(unpacked.builder).toBeUndefined();
|
|
204
|
+
});
|
|
151
205
|
});
|
|
152
206
|
/*! Bundled license information:
|
|
153
207
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../node_modules/@jest/globals/build/index.js","../../../../src/utils/orders/appendix/orderAppendix.test.ts"],"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;","import { describe, expect, it } from '@jest/globals';\nimport { OrderAppendix, OrderExecutionType } from '../../../types';\nimport { packOrderAppendix } from './packOrderAppendix';\nimport { unpackOrderAppendix } from './unpackOrderAppendix';\n\ndescribe('OrderAppendix packing/unpacking', () => {\n it('should pack and unpack an order appendix without iso/twap values', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(4097n);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBeFalsy();\n });\n\n it('should handle reduceOnly true', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n reduceOnly: true,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(6145n);\n expect(unpacked.reduceOnly).toBe(true);\n });\n\n it('should handle all orderExecutionType values', () => {\n const types: OrderExecutionType[] = ['default', 'ioc', 'fok', 'post_only'];\n for (const type of types) {\n const appendix: OrderAppendix = {\n orderExecutionType: type,\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(type);\n }\n });\n\n it('should handle all triggerType values', () => {\n const triggers = ['price', 'twap', 'twap_custom_amounts'] as const;\n for (const trigger of triggers) {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: trigger,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.triggerType).toBe(trigger);\n }\n });\n\n it('should handle isolated margin', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n\n isolated: { margin: 12345678901000000000000n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(227737579102942800187821658369n);\n expect(unpacked.isolated?.margin).toBe(appendix.isolated?.margin);\n });\n\n it('should handle TWAP fields', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'twap',\n\n twap: { numOrders: 10, slippageFrac: 0.005 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(792281717376363744483197591553n);\n expect(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 0.005 });\n });\n\n it('should handle max values for all fields for iso orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: undefined,\n reduceOnly: true,\n isolated: { margin: 18446744073709551615n }, // 2^64-1\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.isolated?.margin).toBe(18446744000000000000n);\n expect(unpacked.twap).toBe(undefined);\n expect(packed).toBe(340282365561237229015142145n);\n });\n\n it('should handle max values for all fields for TWAP orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: 'twap_custom_amounts',\n reduceOnly: true,\n twap: {\n numOrders: 4294967295,\n slippageFrac: 0.000001,\n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.twap?.slippageFrac).toBe(0.000001);\n expect(unpacked.twap?.numOrders).toBe(4294967295);\n expect(packed).toBe(340282366841710300967557013911933828609n);\n });\n});\n"],"mappings":";;;;;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AAkB,EAAE,KAAK,SAAS,kBAAkB;AACpE,+BAAO,SAAS,WAAW,EAAE,KAAK,SAAS,WAAW;AACtD,+BAAO,SAAS,UAAU,EAAE,KAAK,SAAS,UAAU;AACpD,+BAAO,SAAS,UAAU,MAAM,EAAE,KAAK,qBAAqB;AAC5D,+BAAO,SAAS,IAAI,EAAE,KAAK,MAAS;AACpC,+BAAO,MAAM,EAAE,KAAK,4BAA4B;AAAA,EAClD,CAAC;AAED,yBAAG,2DAA2D,MAAM;AAClE,UAAM,WAA0B;AAAA,MAC9B,oBAAoB;AAAA,MACpB,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,MAAM;AAAA,QACJ,WAAW;AAAA,QACX,cAAc;AAAA,MAChB;AAAA,IACF;AACA,UAAM,aAAS,4CAAkB,QAAQ;AACzC,UAAM,eAAW,gDAAoB,MAAM;AAC3C,+BAAO,SAAS,kBAAkB,EAAE,KAAK,SAAS,kBAAkB;AACpE,+BAAO,SAAS,WAAW,EAAE,KAAK,SAAS,WAAW;AACtD,+BAAO,SAAS,UAAU,EAAE,KAAK,SAAS,UAAU;AACpD,+BAAO,SAAS,MAAM,YAAY,EAAE,KAAK,IAAQ;AACjD,+BAAO,SAAS,MAAM,SAAS,EAAE,KAAK,UAAU;AAChD,+BAAO,MAAM,EAAE,KAAK,wCAAwC;AAAA,EAC9D,CAAC;AACH,CAAC;","names":["exports","module"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../node_modules/@jest/globals/build/index.js","../../../../src/utils/orders/appendix/orderAppendix.test.ts"],"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;","import { describe, expect, it } from '@jest/globals';\nimport { OrderAppendix, OrderExecutionType } from '../../../types';\nimport { packOrderAppendix } from './packOrderAppendix';\nimport { unpackOrderAppendix } from './unpackOrderAppendix';\n\ndescribe('OrderAppendix packing/unpacking', () => {\n it('should pack and unpack an order appendix without iso/twap values', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(4097n);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBeFalsy();\n });\n\n it('should handle reduceOnly true', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n reduceOnly: true,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(6145n);\n expect(unpacked.reduceOnly).toBe(true);\n });\n\n it('should handle all orderExecutionType values', () => {\n const types: OrderExecutionType[] = ['default', 'ioc', 'fok', 'post_only'];\n for (const type of types) {\n const appendix: OrderAppendix = {\n orderExecutionType: type,\n triggerType: 'price',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(type);\n }\n });\n\n it('should handle all triggerType values', () => {\n const triggers = ['price', 'twap', 'twap_custom_amounts'] as const;\n for (const trigger of triggers) {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: trigger,\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.triggerType).toBe(trigger);\n }\n });\n\n it('should handle isolated margin', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'price',\n\n isolated: { margin: 12345678901000000000000n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(227737579102942800187821658369n);\n expect(unpacked.isolated?.margin).toBe(appendix.isolated?.margin);\n });\n\n it('should handle TWAP fields', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n triggerType: 'twap',\n\n twap: { numOrders: 10, slippageFrac: 0.005 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(packed).toBe(792281717376363744483197591553n);\n expect(unpacked.twap).toMatchObject({ numOrders: 10, slippageFrac: 0.005 });\n });\n\n it('should handle max values for all fields for iso orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: undefined,\n reduceOnly: true,\n isolated: { margin: 18446744073709551615n }, // 2^64-1\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.isolated?.margin).toBe(18446744000000000000n);\n expect(unpacked.twap).toBe(undefined);\n expect(packed).toBe(340282365561237229015142145n);\n });\n\n it('should handle max values for all fields for TWAP orders', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'post_only',\n triggerType: 'twap_custom_amounts',\n reduceOnly: true,\n twap: {\n numOrders: 4294967295,\n slippageFrac: 0.000001,\n },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe(appendix.orderExecutionType);\n expect(unpacked.triggerType).toBe(appendix.triggerType);\n expect(unpacked.reduceOnly).toBe(appendix.reduceOnly);\n expect(unpacked.twap?.slippageFrac).toBe(0.000001);\n expect(unpacked.twap?.numOrders).toBe(4294967295);\n expect(packed).toBe(340282366841710300967557013911933828609n);\n });\n\n it('should handle builder fields', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n builder: { builderId: 123, builderFeeRate: 500 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder?.builderId).toBe(123);\n expect(unpacked.builder?.builderFeeRate).toBe(500);\n });\n\n it('should handle builder with zero fee rate', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n builder: { builderId: 42, builderFeeRate: 0 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder?.builderId).toBe(42);\n expect(unpacked.builder?.builderFeeRate).toBe(0);\n });\n\n it('should handle builder with max values', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n builder: { builderId: 65535, builderFeeRate: 1023 }, // 16 bits, 10 bits max\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder?.builderId).toBe(65535);\n expect(unpacked.builder?.builderFeeRate).toBe(1023);\n });\n\n it('should handle builder combined with other flags', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'ioc',\n reduceOnly: true,\n triggerType: 'price',\n builder: { builderId: 5, builderFeeRate: 100 },\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.orderExecutionType).toBe('ioc');\n expect(unpacked.reduceOnly).toBe(true);\n expect(unpacked.triggerType).toBe('price');\n expect(unpacked.builder?.builderId).toBe(5);\n expect(unpacked.builder?.builderFeeRate).toBe(100);\n });\n\n it('should not return builder fields when builderId is 0', () => {\n const appendix: OrderAppendix = {\n orderExecutionType: 'default',\n };\n const packed = packOrderAppendix(appendix);\n const unpacked = unpackOrderAppendix(packed);\n expect(unpacked.builder).toBeUndefined();\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,oDAAAA,UAAAC,SAAA;AAAA;AAQS,KAAC,MAAM;AACN;AACV,UAAI,sBAAsB,CAAC;AAY3B,YA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)(unpacked.twap?.numOrders).toBe(4294967295);
|
|
116
116
|
(0, import_globals.expect)(packed).toBe(340282366841710300967557013911933828609n);
|
|
117
117
|
});
|
|
118
|
+
(0, import_globals.it)("should handle builder fields", () => {
|
|
119
|
+
const appendix = {
|
|
120
|
+
orderExecutionType: "default",
|
|
121
|
+
builder: { builderId: 123, builderFeeRate: 500 }
|
|
122
|
+
};
|
|
123
|
+
const packed = packOrderAppendix(appendix);
|
|
124
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
125
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(123);
|
|
126
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(500);
|
|
127
|
+
});
|
|
128
|
+
(0, import_globals.it)("should handle builder with zero fee rate", () => {
|
|
129
|
+
const appendix = {
|
|
130
|
+
orderExecutionType: "default",
|
|
131
|
+
builder: { builderId: 42, builderFeeRate: 0 }
|
|
132
|
+
};
|
|
133
|
+
const packed = packOrderAppendix(appendix);
|
|
134
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
135
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(42);
|
|
136
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(0);
|
|
137
|
+
});
|
|
138
|
+
(0, import_globals.it)("should handle builder with max values", () => {
|
|
139
|
+
const appendix = {
|
|
140
|
+
orderExecutionType: "default",
|
|
141
|
+
builder: { builderId: 65535, builderFeeRate: 1023 }
|
|
142
|
+
// 16 bits, 10 bits max
|
|
143
|
+
};
|
|
144
|
+
const packed = packOrderAppendix(appendix);
|
|
145
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
146
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(65535);
|
|
147
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(1023);
|
|
148
|
+
});
|
|
149
|
+
(0, import_globals.it)("should handle builder combined with other flags", () => {
|
|
150
|
+
const appendix = {
|
|
151
|
+
orderExecutionType: "ioc",
|
|
152
|
+
reduceOnly: true,
|
|
153
|
+
triggerType: "price",
|
|
154
|
+
builder: { builderId: 5, builderFeeRate: 100 }
|
|
155
|
+
};
|
|
156
|
+
const packed = packOrderAppendix(appendix);
|
|
157
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
158
|
+
(0, import_globals.expect)(unpacked.orderExecutionType).toBe("ioc");
|
|
159
|
+
(0, import_globals.expect)(unpacked.reduceOnly).toBe(true);
|
|
160
|
+
(0, import_globals.expect)(unpacked.triggerType).toBe("price");
|
|
161
|
+
(0, import_globals.expect)(unpacked.builder?.builderId).toBe(5);
|
|
162
|
+
(0, import_globals.expect)(unpacked.builder?.builderFeeRate).toBe(100);
|
|
163
|
+
});
|
|
164
|
+
(0, import_globals.it)("should not return builder fields when builderId is 0", () => {
|
|
165
|
+
const appendix = {
|
|
166
|
+
orderExecutionType: "default"
|
|
167
|
+
};
|
|
168
|
+
const packed = packOrderAppendix(appendix);
|
|
169
|
+
const unpacked = unpackOrderAppendix(packed);
|
|
170
|
+
(0, import_globals.expect)(unpacked.builder).toBeUndefined();
|
|
171
|
+
});
|
|
118
172
|
});
|
|
119
173
|
//# sourceMappingURL=orderAppendix.test.js.map
|