@derivexyz/derive-ts 3.0.4

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.
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/codecs/index.ts
21
+ var codecs_exports = {};
22
+ __export(codecs_exports, {
23
+ VAULT_ACTION_KIND: () => VAULT_ACTION_KIND,
24
+ encodeCreateSessionKeyActionData: () => encodeCreateSessionKeyActionData,
25
+ encodeExternalTransfer: () => encodeExternalTransfer,
26
+ encodeRfqExecute: () => encodeRfqExecute,
27
+ encodeRfqQuote: () => encodeRfqQuote,
28
+ encodeTradeData: () => encodeTradeData,
29
+ encodeTransfer: () => encodeTransfer,
30
+ encodeUpdateWhitelistedRecipients: () => encodeUpdateWhitelistedRecipients,
31
+ encodeVaultBurnShares: () => encodeVaultBurnShares,
32
+ encodeVaultCancel: () => encodeVaultCancel,
33
+ encodeVaultCreate: () => encodeVaultCreate,
34
+ encodeVaultDeposit: () => encodeVaultDeposit,
35
+ encodeVaultMintShares: () => encodeVaultMintShares,
36
+ encodeVaultWithdraw: () => encodeVaultWithdraw,
37
+ encodeWithdrawal: () => encodeWithdrawal,
38
+ sortRfqLegs: () => sortRfqLegs
39
+ });
40
+ module.exports = __toCommonJS(codecs_exports);
41
+
42
+ // src/codecs/trade.ts
43
+ var import_ethers2 = require("ethers");
44
+
45
+ // src/signing/encoding.ts
46
+ var import_ethers = require("ethers");
47
+ function toE18(value) {
48
+ return toScaled(value, 18);
49
+ }
50
+ function assertE12Precision(e18, field) {
51
+ if (e18 % 1000000n !== 0n) {
52
+ throw new Error(`${field} has more than 12 decimal places \u2014 the protocol runs at 1e12 precision`);
53
+ }
54
+ }
55
+ function unsignedE18(value, field) {
56
+ const scaled = toE18(value);
57
+ if (scaled < 0n) throw new Error(`${field} must not be negative`);
58
+ assertE12Precision(scaled, field);
59
+ return scaled;
60
+ }
61
+ function nonNegativeId(value, field) {
62
+ const valid = typeof value === "bigint" ? value >= 0n : Number.isSafeInteger(value) && value >= 0;
63
+ if (!valid) throw new Error(`${field} must be a non-negative integer`);
64
+ return value;
65
+ }
66
+ function toScaled(value, decimals) {
67
+ if (typeof value === "bigint") return value;
68
+ const text = typeof value === "number" ? String(value) : value.trim();
69
+ if (!/^-?\d+(\.\d+)?$/.test(text)) {
70
+ throw new Error(
71
+ `invalid decimal value: ${JSON.stringify(value)} (scientific notation and empty strings are not accepted)`
72
+ );
73
+ }
74
+ return (0, import_ethers.parseUnits)(text, decimals);
75
+ }
76
+
77
+ // src/codecs/trade.ts
78
+ var I128_MIN = -(2n ** 127n);
79
+ var I128_MAX = 2n ** 127n - 1n;
80
+ var U64_MAX = 2n ** 64n - 1n;
81
+ var U128_MAX = 2n ** 128n - 1n;
82
+ function assertE12Precision2(e18, field) {
83
+ if (e18 % 1000000n !== 0n) {
84
+ throw new Error(`${field} has more than 12 decimal places \u2014 the protocol runs at 1e12 precision`);
85
+ }
86
+ }
87
+ function i128LowHalfWord(e18, field) {
88
+ if (e18 < I128_MIN || e18 > I128_MAX) {
89
+ throw new Error(`${field} out of range: e18-scaled value must fit in an i128`);
90
+ }
91
+ const twosComplement = e18 < 0n ? e18 + 2n ** 128n : e18;
92
+ return (0, import_ethers2.zeroPadValue)((0, import_ethers2.toBeHex)(twosComplement, 16), 32);
93
+ }
94
+ function uintWord(value, max, field) {
95
+ if (value < 0n || value > max) {
96
+ throw new Error(`${field} out of range: must be an unsigned integer <= ${max}`);
97
+ }
98
+ return (0, import_ethers2.zeroPadValue)((0, import_ethers2.toBeHex)(value), 32);
99
+ }
100
+ function encodeTradeData(fields) {
101
+ const limitPrice = toE18(fields.limitPrice);
102
+ const amount = toE18(fields.amount);
103
+ const maxFee = toE18(fields.maxFee);
104
+ assertE12Precision2(limitPrice, "limitPrice");
105
+ assertE12Precision2(amount, "amount");
106
+ assertE12Precision2(maxFee, "maxFee");
107
+ return (0, import_ethers2.concat)([
108
+ (0, import_ethers2.zeroPadValue)((0, import_ethers2.getAddress)(fields.assetAddress), 32),
109
+ uintWord(BigInt(fields.subId), U128_MAX, "subId"),
110
+ i128LowHalfWord(limitPrice, "limitPrice"),
111
+ i128LowHalfWord(amount, "amount"),
112
+ uintWord(maxFee, U128_MAX, "maxFee"),
113
+ uintWord(BigInt(fields.recipientSubaccountId), U64_MAX, "recipientSubaccountId"),
114
+ (0, import_ethers2.zeroPadValue)(fields.isBid ? "0x01" : "0x00", 32)
115
+ ]);
116
+ }
117
+
118
+ // src/codecs/transfer.ts
119
+ var import_ethers3 = require("ethers");
120
+ var TRANSFER_ABI = ["uint256", "uint256", "address", "uint256", "uint256", "uint256"];
121
+ function encodeTransfer(fields) {
122
+ const amount = unsignedE18(fields.amount, "amount");
123
+ if (amount === 0n) throw new Error("transfer amount must be strictly positive");
124
+ return import_ethers3.AbiCoder.defaultAbiCoder().encode(TRANSFER_ABI, [
125
+ nonNegativeId(fields.toSubaccountId, "toSubaccountId"),
126
+ nonNegativeId(fields.newSubaccountManager, "newSubaccountManager"),
127
+ (0, import_ethers3.getAddress)(fields.asset),
128
+ nonNegativeId(fields.subId, "subId"),
129
+ amount,
130
+ unsignedE18(fields.maxFeeUsd, "maxFeeUsd")
131
+ ]);
132
+ }
133
+
134
+ // src/codecs/externalTransfer.ts
135
+ var import_ethers4 = require("ethers");
136
+ function encodeExternalTransfer(fields) {
137
+ return (0, import_ethers4.concat)([encodeTransfer(fields), (0, import_ethers4.zeroPadValue)((0, import_ethers4.getAddress)(fields.recipient), 32)]);
138
+ }
139
+
140
+ // src/codecs/withdrawal.ts
141
+ var import_ethers5 = require("ethers");
142
+ var WITHDRAWAL_ABI = ["address", "uint256", "address", "uint256", "bool"];
143
+ function encodeWithdrawal(fields) {
144
+ if (!Number.isInteger(fields.decimals) || fields.decimals < 0 || fields.decimals > 255) {
145
+ throw new Error("decimals must be an integer between 0 and 255");
146
+ }
147
+ const amount = toScaled(fields.amount, fields.decimals);
148
+ if (amount <= 0n) throw new Error("withdrawal amount must be strictly positive");
149
+ return import_ethers5.AbiCoder.defaultAbiCoder().encode(WITHDRAWAL_ABI, [
150
+ (0, import_ethers5.getAddress)(fields.protocolAsset),
151
+ unsignedE18(fields.maxFeeUsd, "maxFeeUsd"),
152
+ (0, import_ethers5.getAddress)(fields.recipient),
153
+ amount,
154
+ fields.forceBatch
155
+ ]);
156
+ }
157
+
158
+ // src/codecs/rfq.ts
159
+ var import_ethers6 = require("ethers");
160
+ function sortRfqLegs(legs) {
161
+ return [...legs].sort(
162
+ (a, b) => a.instrumentName < b.instrumentName ? -1 : a.instrumentName > b.instrumentName ? 1 : 0
163
+ );
164
+ }
165
+ var LEGS_ABI = "(address,uint256,uint256,int256)[]";
166
+ function encodeRfqQuote(fields) {
167
+ return import_ethers6.AbiCoder.defaultAbiCoder().encode(
168
+ [`(uint256,${LEGS_ABI})`],
169
+ [[maxFeeE18(fields.maxFee), legTuples(fields, 1n)]]
170
+ );
171
+ }
172
+ function encodeRfqExecute(fields) {
173
+ const coder = import_ethers6.AbiCoder.defaultAbiCoder();
174
+ const orderHash = (0, import_ethers6.keccak256)(coder.encode([LEGS_ABI], [legTuples(fields, -1n)]));
175
+ return coder.encode(["bytes32", "uint256"], [orderHash, maxFeeE18(fields.maxFee)]);
176
+ }
177
+ function maxFeeE18(maxFee) {
178
+ return unsignedE18(maxFee, "rfq maxFee");
179
+ }
180
+ function legTuples(fields, perspectiveSign) {
181
+ const directionSign = fields.direction === "buy" ? 1n : -1n;
182
+ return sortRfqLegs(fields.legs).map((leg) => {
183
+ const price = unsignedE18(leg.price, `rfq leg price (${leg.instrumentName})`);
184
+ const amount = toE18(leg.amount);
185
+ if (amount <= 0n)
186
+ throw new Error(`rfq leg amount must be positive (direction carries the sign): ${leg.instrumentName}`);
187
+ assertE12Precision(amount, `rfq leg amount (${leg.instrumentName})`);
188
+ const legSign = leg.direction === "buy" ? 1n : -1n;
189
+ return [
190
+ (0, import_ethers6.getAddress)(leg.assetAddress),
191
+ BigInt(leg.subId),
192
+ price,
193
+ amount * legSign * directionSign * perspectiveSign
194
+ ];
195
+ });
196
+ }
197
+
198
+ // src/codecs/vault.ts
199
+ var import_ethers7 = require("ethers");
200
+ var abi = import_ethers7.AbiCoder.defaultAbiCoder();
201
+ var VAULT_ACTION_KIND = {
202
+ create: 0,
203
+ deposit: 1,
204
+ withdraw: 2,
205
+ cancel: 3,
206
+ mintShares: 4,
207
+ burnShares: 5
208
+ };
209
+ function positiveE18(label, value) {
210
+ const e18 = toE18(value);
211
+ if (e18 <= 0n) throw new Error(`${label} must be positive`);
212
+ assertE12Precision(e18, label);
213
+ return e18;
214
+ }
215
+ function encodeVaultDeposit(fields) {
216
+ return abi.encode(
217
+ ["uint256", "uint256", "address", "uint256"],
218
+ [
219
+ VAULT_ACTION_KIND.deposit,
220
+ fields.vaultSubaccountId,
221
+ (0, import_ethers7.getAddress)(fields.depositSpotAsset),
222
+ positiveE18("amount", fields.amount)
223
+ ]
224
+ );
225
+ }
226
+ function encodeVaultWithdraw(fields) {
227
+ return abi.encode(
228
+ ["uint256", "uint256", "uint256"],
229
+ [VAULT_ACTION_KIND.withdraw, fields.vaultSubaccountId, positiveE18("sharesToBurn", fields.sharesToBurn)]
230
+ );
231
+ }
232
+ function encodeVaultCancel(vaultSubaccountId) {
233
+ return abi.encode(["uint256", "uint256"], [VAULT_ACTION_KIND.cancel, vaultSubaccountId]);
234
+ }
235
+ function encodeVaultCreate(fields) {
236
+ const benchmark = fields.benchmarkAsset;
237
+ return abi.encode(
238
+ // prettier-ignore
239
+ ["uint256", "uint256", "address", "uint256", "uint256", "uint256", "uint256", "uint256", "uint256", "uint256", "address", "bool"],
240
+ [
241
+ VAULT_ACTION_KIND.create,
242
+ fields.managerId,
243
+ (0, import_ethers7.getAddress)(fields.depositSpotAsset),
244
+ unsignedE18(fields.initialDeposit, "initialDeposit"),
245
+ fields.managementFeeBps,
246
+ fields.performanceFeeBps,
247
+ fields.maxSlippageBps,
248
+ fields.cooldownSec,
249
+ unsignedE18(fields.maxFeeUsd, "maxFeeUsd"),
250
+ unsignedE18(fields.initialSharePriceUsd, "initialSharePriceUsd"),
251
+ benchmark === void 0 ? import_ethers7.ZeroAddress : (0, import_ethers7.getAddress)(benchmark),
252
+ benchmark !== void 0
253
+ ]
254
+ );
255
+ }
256
+ function encodeVaultMintShares(fields) {
257
+ return encodeSettleApproval(VAULT_ACTION_KIND.mintShares, fields.sharePrice, "depositHash", fields.depositHash);
258
+ }
259
+ function encodeVaultBurnShares(fields) {
260
+ return encodeSettleApproval(VAULT_ACTION_KIND.burnShares, fields.sharePrice, "withdrawHash", fields.withdrawHash);
261
+ }
262
+ function encodeSettleApproval(kind, sharePrice, hashLabel, hash) {
263
+ if (!(0, import_ethers7.isHexString)(hash, 32)) throw new Error(`${hashLabel} must be a 0x-prefixed 32-byte hex string`);
264
+ return abi.encode(["uint256", "uint256", "bytes32"], [kind, unsignedE18(sharePrice, "sharePrice"), hash]);
265
+ }
266
+
267
+ // src/codecs/sessionKey.ts
268
+ var import_ethers8 = require("ethers");
269
+ function encodeCreateSessionKeyActionData(data) {
270
+ if (!Number.isInteger(data.expirySec) || data.expirySec < 0) {
271
+ throw new Error(`session key expirySec must be a non-negative unix-seconds integer, got ${data.expirySec}`);
272
+ }
273
+ return (0, import_ethers8.concat)([
274
+ (0, import_ethers8.zeroPadValue)((0, import_ethers8.getAddress)(data.sessionKey), 32),
275
+ uintWord2(data.expirySec),
276
+ uintWord2(data.scopes.length),
277
+ uintWord2(data.subaccountIds.length),
278
+ ...data.scopes.map((code) => uintWord2(code)),
279
+ ...data.subaccountIds.map((id) => uintWord2(id))
280
+ ]);
281
+ }
282
+ function uintWord2(value) {
283
+ const valid = typeof value === "bigint" ? value >= 0n : Number.isSafeInteger(value) && value >= 0;
284
+ if (!valid) throw new Error(`expected a non-negative integer, got ${value}`);
285
+ return (0, import_ethers8.zeroPadValue)((0, import_ethers8.toBeHex)(value), 32);
286
+ }
287
+
288
+ // src/codecs/whitelistedRecipients.ts
289
+ var import_ethers9 = require("ethers");
290
+ function encodeUpdateWhitelistedRecipients(fields) {
291
+ const add = fields.add.map((a) => (0, import_ethers9.getAddress)(a));
292
+ const remove = fields.remove.map((a) => (0, import_ethers9.getAddress)(a));
293
+ return (0, import_ethers9.concat)([
294
+ (0, import_ethers9.zeroPadValue)((0, import_ethers9.toBeHex)(add.length), 32),
295
+ (0, import_ethers9.zeroPadValue)((0, import_ethers9.toBeHex)(remove.length), 32),
296
+ ...add.map((a) => (0, import_ethers9.zeroPadValue)(a, 32)),
297
+ ...remove.map((a) => (0, import_ethers9.zeroPadValue)(a, 32))
298
+ ]);
299
+ }
300
+ // Annotate the CommonJS export names for ESM import in node:
301
+ 0 && (module.exports = {
302
+ VAULT_ACTION_KIND,
303
+ encodeCreateSessionKeyActionData,
304
+ encodeExternalTransfer,
305
+ encodeRfqExecute,
306
+ encodeRfqQuote,
307
+ encodeTradeData,
308
+ encodeTransfer,
309
+ encodeUpdateWhitelistedRecipients,
310
+ encodeVaultBurnShares,
311
+ encodeVaultCancel,
312
+ encodeVaultCreate,
313
+ encodeVaultDeposit,
314
+ encodeVaultMintShares,
315
+ encodeVaultWithdraw,
316
+ encodeWithdrawal,
317
+ sortRfqLegs
318
+ });
319
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/codecs/index.ts","../../src/codecs/trade.ts","../../src/signing/encoding.ts","../../src/codecs/transfer.ts","../../src/codecs/externalTransfer.ts","../../src/codecs/withdrawal.ts","../../src/codecs/rfq.ts","../../src/codecs/vault.ts","../../src/codecs/sessionKey.ts","../../src/codecs/whitelistedRecipients.ts"],"sourcesContent":["/**\n * Action-data codecs — the ABI encoders for each signed action's `data`\n * payload. Most users never need these: the namespaced APIs\n * (`client.orders`, `client.spotTransfers`, `client.positionTransfers`, …) build and sign actions for\n * you. They are exported for advanced callers assembling raw\n * `SignedAction`s themselves.\n */\nexport { encodeTradeData, type TradeActionFields } from './trade';\nexport { encodeTransfer, type TransferFields } from './transfer';\nexport { encodeExternalTransfer, type ExternalTransferFields } from './externalTransfer';\nexport { encodeWithdrawal, type WithdrawalFields } from './withdrawal';\nexport { encodeRfqQuote, encodeRfqExecute, sortRfqLegs, type RfqSignedLeg, type RfqQuoteFields } from './rfq';\nexport {\n VAULT_ACTION_KIND,\n encodeVaultDeposit,\n encodeVaultWithdraw,\n encodeVaultCancel,\n encodeVaultCreate,\n encodeVaultMintShares,\n encodeVaultBurnShares,\n type VaultDepositFields,\n type VaultWithdrawFields,\n type VaultCreateFields,\n type VaultMintSharesFields,\n type VaultBurnSharesFields,\n} from './vault';\nexport { encodeCreateSessionKeyActionData, type CreateSessionKeyData } from './sessionKey';\nexport { encodeUpdateWhitelistedRecipients, type WhitelistedRecipientsFields } from './whitelistedRecipients';\n","import { concat, getAddress, toBeHex, zeroPadValue } from 'ethers';\nimport { toE18, type DecimalLike } from '../signing/encoding';\n\n/**\n * Inputs to the trade (order) action payload, verified by the trade\n * module (`network.modules.trade`).\n */\nexport interface TradeActionFields {\n /** Protocol asset contract of the instrument (`base_asset_address`). */\n assetAddress: string;\n /** Asset sub id (`base_asset_sub_id`): 0 for perps/spot, the option id for options. */\n subId: string | number | bigint;\n limitPrice: DecimalLike;\n amount: DecimalLike;\n /** Worst acceptable fee per unit traded the signature allows. */\n maxFee: DecimalLike;\n /** Subaccount credited with the fill — the trading subaccount itself. */\n recipientSubaccountId: number | bigint;\n isBid: boolean;\n}\n\nconst I128_MIN = -(2n ** 127n);\nconst I128_MAX = 2n ** 127n - 1n;\nconst U64_MAX = 2n ** 64n - 1n;\nconst U128_MAX = 2n ** 128n - 1n;\n\n/**\n * The exchange holds decimals at 1e12 and rejects (not truncates) signed\n * e18 words with sub-1e12 precision, so more than 12 decimal places can\n * never produce a valid signature.\n */\nfunction assertE12Precision(e18: bigint, field: string): void {\n if (e18 % 1_000_000n !== 0n) {\n throw new Error(`${field} has more than 12 decimal places — the protocol runs at 1e12 precision`);\n }\n}\n\n/**\n * The exchange reads limit price and amount as an i128 from the LOW 16\n * bytes of the word; the high 16 bytes stay zero even for negative\n * values. Standard ABI int256 encoding would sign-extend the high half\n * and produce bytes the exchange rejects.\n */\nfunction i128LowHalfWord(e18: bigint, field: string): string {\n if (e18 < I128_MIN || e18 > I128_MAX) {\n throw new Error(`${field} out of range: e18-scaled value must fit in an i128`);\n }\n const twosComplement = e18 < 0n ? e18 + 2n ** 128n : e18;\n return zeroPadValue(toBeHex(twosComplement, 16), 32);\n}\n\nfunction uintWord(value: bigint, max: bigint, field: string): string {\n if (value < 0n || value > max) {\n throw new Error(`${field} out of range: must be an unsigned integer <= ${max}`);\n }\n return zeroPadValue(toBeHex(value), 32);\n}\n\n/**\n * Encodes the order action data: seven static words — asset, subId,\n * limitPrice, amount, maxFee, recipientId, isBid — with\n * prices/amounts/fee e18-scaled.\n */\nexport function encodeTradeData(fields: TradeActionFields): string {\n const limitPrice = toE18(fields.limitPrice);\n const amount = toE18(fields.amount);\n const maxFee = toE18(fields.maxFee);\n assertE12Precision(limitPrice, 'limitPrice');\n assertE12Precision(amount, 'amount');\n assertE12Precision(maxFee, 'maxFee');\n return concat([\n zeroPadValue(getAddress(fields.assetAddress), 32),\n uintWord(BigInt(fields.subId), U128_MAX, 'subId'),\n i128LowHalfWord(limitPrice, 'limitPrice'),\n i128LowHalfWord(amount, 'amount'),\n uintWord(maxFee, U128_MAX, 'maxFee'),\n uintWord(BigInt(fields.recipientSubaccountId), U64_MAX, 'recipientSubaccountId'),\n zeroPadValue(fields.isBid ? '0x01' : '0x00', 32),\n ]);\n}\n","import { parseUnits } from 'ethers';\n\n/**\n * A decimal value accepted from callers: a decimal string (\"1500.5\"),\n * a safe number, or a bigint already at the target field's wire scale\n * (e18 for most values; the ERC-20's native decimals for withdrawal\n * amounts).\n */\nexport type DecimalLike = string | number | bigint;\n\n/**\n * Converts a decimal value to the protocol's e18 wire scale. Signed\n * actions ABI-encode all prices/amounts/fees at 1e18 and signatures\n * commit to those exact bytes. (Withdrawal amounts are the exception —\n * they stay in the ERC-20's native decimals; see codecs/withdrawal.)\n */\nexport function toE18(value: DecimalLike): bigint {\n return toScaled(value, 18);\n}\n\n/**\n * The exchange holds decimals at 1e12 and REJECTS (does not truncate) e18\n * words carrying sub-1e12 precision, so more than 12 decimal places can\n * never produce a valid signature. Holds for negative words too.\n */\nexport function assertE12Precision(e18: bigint, field: string): void {\n if (e18 % 1_000_000n !== 0n) {\n throw new Error(`${field} has more than 12 decimal places — the protocol runs at 1e12 precision`);\n }\n}\n\n/** Scales to e18, rejecting negatives and sub-1e12 precision. Shared by the value-bearing codecs. */\nexport function unsignedE18(value: DecimalLike, field: string): bigint {\n const scaled = toE18(value);\n if (scaled < 0n) throw new Error(`${field} must not be negative`);\n assertE12Precision(scaled, field);\n return scaled;\n}\n\nexport function nonNegativeId(value: number | bigint, field: string): number | bigint {\n const valid = typeof value === 'bigint' ? value >= 0n : Number.isSafeInteger(value) && value >= 0;\n if (!valid) throw new Error(`${field} must be a non-negative integer`);\n return value;\n}\n\n/** Default envelope validity for signed actions; comfortably above the API's minimum. */\nexport const DEFAULT_SIGNATURE_EXPIRY_SEC = 300;\n\nexport function toScaled(value: DecimalLike, decimals: number): bigint {\n if (typeof value === 'bigint') return value;\n const text = typeof value === 'number' ? String(value) : value.trim();\n if (!/^-?\\d+(\\.\\d+)?$/.test(text)) {\n throw new Error(\n `invalid decimal value: ${JSON.stringify(value)} (scientific notation and empty strings are not accepted)`,\n );\n }\n return parseUnits(text, decimals);\n}\n\n/**\n * Action nonces are UTC-nanosecond timestamps (the API accepts a\n * ±5-minute intake window), with sub-millisecond digits randomized so\n * concurrent actions never collide.\n */\nexport function randomNonce(now: number = Date.now()): string {\n const nanos = BigInt(now) * 1_000_000n + BigInt(Math.floor(Math.random() * 1_000_000));\n return nanos.toString();\n}\n\n/** Signature expiry as a unix-seconds timestamp, `seconds` from now. */\nexport function expiresIn(seconds: number, now: number = Date.now()): number {\n return Math.floor(now / 1000) + seconds;\n}\n","import { AbiCoder, getAddress } from 'ethers';\nimport { nonNegativeId, unsignedE18, type DecimalLike } from '../signing/encoding';\n\n/**\n * Spot transfer between subaccounts of the same owner, verified by the\n * transfer module. Position transfers are booked as RFQ trades — this\n * action only ever moves a single spot asset.\n */\nexport interface TransferFields {\n toSubaccountId: number | bigint;\n /**\n * Routing sentinel: 0 credits the existing `toSubaccountId`; non-zero\n * creates a new subaccount under this manager id instead (the\n * destination id is then ignored).\n */\n newSubaccountManager: number | bigint;\n /** Protocol spot-asset address (not the underlying ERC-20). */\n asset: string;\n subId: number | bigint;\n /** Strictly positive; signed at e18. */\n amount: DecimalLike;\n /** Maximum fee the signer authorises, in USD; signed at e18. */\n maxFeeUsd: DecimalLike;\n}\n\nconst TRANSFER_ABI = ['uint256', 'uint256', 'address', 'uint256', 'uint256', 'uint256'];\n\n/** ABI-encodes transfer action data: six static 32-byte words. */\nexport function encodeTransfer(fields: TransferFields): string {\n const amount = unsignedE18(fields.amount, 'amount');\n if (amount === 0n) throw new Error('transfer amount must be strictly positive');\n return AbiCoder.defaultAbiCoder().encode(TRANSFER_ABI, [\n nonNegativeId(fields.toSubaccountId, 'toSubaccountId'),\n nonNegativeId(fields.newSubaccountManager, 'newSubaccountManager'),\n getAddress(fields.asset),\n nonNegativeId(fields.subId, 'subId'),\n amount,\n unsignedE18(fields.maxFeeUsd, 'maxFeeUsd'),\n ]);\n}\n","import { concat, getAddress, zeroPadValue } from 'ethers';\nimport { encodeTransfer, type TransferFields } from './transfer';\n\n/**\n * Spot transfer to another owner's wallet, verified by the external\n * transfer module: the six transfer words plus a seventh holding the\n * recipient wallet.\n */\nexport interface ExternalTransferFields extends TransferFields {\n /**\n * Destination owner wallet. `toSubaccountId` must be one of its existing\n * subaccounts, or 0 to create one for it under `newSubaccountManager`.\n */\n recipient: string;\n}\n\n/**\n * All seven words are static, so the encoding is exactly the transfer\n * payload with the recipient appended as a left-padded address word.\n */\nexport function encodeExternalTransfer(fields: ExternalTransferFields): string {\n return concat([encodeTransfer(fields), zeroPadValue(getAddress(fields.recipient), 32)]);\n}\n","import { AbiCoder, getAddress } from 'ethers';\nimport { toScaled, unsignedE18, type DecimalLike } from '../signing/encoding';\n\n/** Withdrawal to L1, verified by the withdrawal module. */\nexport interface WithdrawalFields {\n /** Protocol asset contract address (not the underlying ERC-20). */\n protocolAsset: string;\n /** Maximum fee the signer authorises, in USD; signed at e18 like every other action value. */\n maxFeeUsd: DecimalLike;\n /** L1 payout recipient. The exchange only constructs withdrawals paying out to the action signer. */\n recipient: string;\n /**\n * Withdrawal amount in the ERC-20's NATIVE decimals (USDC = 6) — the\n * protocol's only never-scaled amount, since it is the L1 payout value.\n */\n amount: DecimalLike;\n /** The underlying ERC-20's decimals, used to scale `amount`. */\n decimals: number;\n /** Pay a higher fee for immediate batch proving. */\n forceBatch: boolean;\n}\n\nconst WITHDRAWAL_ABI = ['address', 'uint256', 'address', 'uint256', 'bool'];\n\n/** ABI-encodes withdrawal action data: five static 32-byte words. */\nexport function encodeWithdrawal(fields: WithdrawalFields): string {\n if (!Number.isInteger(fields.decimals) || fields.decimals < 0 || fields.decimals > 255) {\n throw new Error('decimals must be an integer between 0 and 255');\n }\n const amount = toScaled(fields.amount, fields.decimals);\n if (amount <= 0n) throw new Error('withdrawal amount must be strictly positive');\n return AbiCoder.defaultAbiCoder().encode(WITHDRAWAL_ABI, [\n getAddress(fields.protocolAsset),\n unsignedE18(fields.maxFeeUsd, 'maxFeeUsd'),\n getAddress(fields.recipient),\n amount,\n fields.forceBatch,\n ]);\n}\n","import { AbiCoder, getAddress, keccak256 } from 'ethers';\nimport { assertE12Precision, toE18, unsignedE18, type DecimalLike } from '../signing/encoding';\nimport type { Direction } from '../types';\n\n/**\n * RFQ action-data codecs.\n *\n * Maker and taker must hash byte-identical leg bundles: legs are sorted\n * lexicographically by instrument name, and each signed leg amount is\n * `amount × legDirectionSign × directionSign × perspectiveSign`. The maker\n * encodes with their own quote direction (perspective +1); the taker\n * executes with the opposite direction and perspective −1, which cancels\n * back to the maker's exact values — the server rebuilds the taker's\n * order hash from the maker's stored quote.\n */\n\n/** A quoted leg carrying everything the signature commits to. */\nexport interface RfqSignedLeg {\n /** Canonical ordering key — both sides sign legs sorted by this. */\n instrumentName: string;\n /** Protocol asset contract for the instrument (option or perp). */\n assetAddress: string;\n /** Asset sub id: '0' for perps, the option's encoded sub id otherwise. */\n subId: string | bigint;\n /** Per-unit price, always positive; e18-scaled into the signed bytes. */\n price: DecimalLike;\n /** Unsigned size — direction carries the sign. */\n amount: DecimalLike;\n direction: Direction;\n}\n\nexport interface RfqQuoteFields {\n /** Worst fee the signer accepts, in USD; e18 in the signed bytes. */\n maxFee: DecimalLike;\n /** The maker's quote direction (taker execute: the taker's own direction). */\n direction: Direction;\n legs: RfqSignedLeg[];\n}\n\n/** Sorts legs into the canonical order both counterparties sign and send. */\nexport function sortRfqLegs<T extends { instrumentName: string }>(legs: readonly T[]): T[] {\n return [...legs].sort((a, b) =>\n a.instrumentName < b.instrumentName ? -1 : a.instrumentName > b.instrumentName ? 1 : 0,\n );\n}\n\nconst LEGS_ABI = '(address,uint256,uint256,int256)[]';\n\n/**\n * Maker quote data: `abi.encode(RfqOrder{ maxFee, trades[] })` —\n * `[0x20][maxFee][0x40][N][4 words per leg]`. Unlike the trade codec's\n * low-16-byte i128 amount words, a negative leg amount here is a full\n * sign-extended int256 (high 16 bytes 0xff), which is standard AbiCoder\n * output.\n */\nexport function encodeRfqQuote(fields: RfqQuoteFields): string {\n return AbiCoder.defaultAbiCoder().encode(\n [`(uint256,${LEGS_ABI})`],\n [[maxFeeE18(fields.maxFee), legTuples(fields, 1n)]],\n );\n}\n\n/**\n * Taker execute data: `abi.encode(bytes32 orderHash, uint256 maxFee)` where\n * `orderHash = keccak256(abi.encode(trades[]))` — the maker's legs only,\n * maker maxFee excluded. `fields.direction` is the TAKER's direction\n * (opposite of the quote's); `fields.maxFee` is the taker's own fee cap.\n */\nexport function encodeRfqExecute(fields: RfqQuoteFields): string {\n const coder = AbiCoder.defaultAbiCoder();\n const orderHash = keccak256(coder.encode([LEGS_ABI], [legTuples(fields, -1n)]));\n return coder.encode(['bytes32', 'uint256'], [orderHash, maxFeeE18(fields.maxFee)]);\n}\n\nfunction maxFeeE18(maxFee: DecimalLike): bigint {\n return unsignedE18(maxFee, 'rfq maxFee');\n}\n\nfunction legTuples(\n fields: RfqQuoteFields,\n perspectiveSign: 1n | -1n,\n): Array<readonly [string, bigint, bigint, bigint]> {\n const directionSign = fields.direction === 'buy' ? 1n : -1n;\n return sortRfqLegs(fields.legs).map((leg) => {\n const price = unsignedE18(leg.price, `rfq leg price (${leg.instrumentName})`);\n const amount = toE18(leg.amount);\n if (amount <= 0n)\n throw new Error(`rfq leg amount must be positive (direction carries the sign): ${leg.instrumentName}`);\n assertE12Precision(amount, `rfq leg amount (${leg.instrumentName})`);\n const legSign = leg.direction === 'buy' ? 1n : -1n;\n return [\n getAddress(leg.assetAddress),\n BigInt(leg.subId),\n price,\n amount * legSign * directionSign * perspectiveSign,\n ] as const;\n });\n}\n","import { AbiCoder, ZeroAddress, getAddress, isHexString } from 'ethers';\nimport { assertE12Precision, toE18, unsignedE18, type DecimalLike } from '../signing/encoding';\n\n/**\n * Vault action encodings — shareholder intents (deposit/withdraw/cancel)\n * and curator actions (create, and the mint/burn settle approvals; in v3\n * anyone can curate a vault). Every vault action is signed under the\n * single vault module; word 0 is a uint256 kind word — the protocol's\n * ONLY discriminator between vault action types, so its high bytes must\n * be exactly zero. Deposits and withdrawals are queued intents the\n * curator later settles at a quoted share price committed to the\n * keccak256 of these exact bytes.\n */\n\nconst abi = AbiCoder.defaultAbiCoder();\n\n/** Word-0 kind discriminators. */\nexport const VAULT_ACTION_KIND = {\n create: 0,\n deposit: 1,\n withdraw: 2,\n cancel: 3,\n mintShares: 4,\n burnShares: 5,\n} as const;\n\n/**\n * Vault amounts are signed at e18 but held at e12 by the protocol,\n * which rejects (not truncates) sub-1e12 precision, and requires\n * strictly positive values.\n */\nfunction positiveE18(label: string, value: DecimalLike): bigint {\n const e18 = toE18(value);\n if (e18 <= 0n) throw new Error(`${label} must be positive`);\n assertE12Precision(e18, label);\n return e18;\n}\n\nexport interface VaultDepositFields {\n vaultSubaccountId: number | bigint;\n /** Must equal the vault's configured deposit asset (protocol spot-asset address). */\n depositSpotAsset: string;\n /** Deposit amount in the deposit asset's units; max 12 decimal places. */\n amount: DecimalLike;\n}\n\n/** VaultDepositData (kind = 1, 4 words): [kind, vaultSubaccountId, depositSpotAsset, amountE18]. */\nexport function encodeVaultDeposit(fields: VaultDepositFields): string {\n return abi.encode(\n ['uint256', 'uint256', 'address', 'uint256'],\n [\n VAULT_ACTION_KIND.deposit,\n fields.vaultSubaccountId,\n getAddress(fields.depositSpotAsset),\n positiveE18('amount', fields.amount),\n ],\n );\n}\n\nexport interface VaultWithdrawFields {\n vaultSubaccountId: number | bigint;\n /** Vault shares to redeem; max 12 decimal places. */\n sharesToBurn: DecimalLike;\n}\n\n/** VaultWithdrawData (kind = 2, 3 words): [kind, vaultSubaccountId, sharesToBurnE18]. */\nexport function encodeVaultWithdraw(fields: VaultWithdrawFields): string {\n return abi.encode(\n ['uint256', 'uint256', 'uint256'],\n [VAULT_ACTION_KIND.withdraw, fields.vaultSubaccountId, positiveE18('sharesToBurn', fields.sharesToBurn)],\n );\n}\n\n/**\n * VaultCancelData (kind = 3, 2 words): [kind, vaultSubaccountId].\n * Invalidates ALL of the signer's pending intents for the vault by\n * bumping their per-(vault, holder) nonce to the envelope's nonce.\n */\nexport function encodeVaultCancel(vaultSubaccountId: number | bigint): string {\n return abi.encode(['uint256', 'uint256'], [VAULT_ACTION_KIND.cancel, vaultSubaccountId]);\n}\n\nexport interface VaultCreateFields {\n managerId: number;\n depositSpotAsset: string;\n /** Initial deposit moved funding subaccount → vault; max 12 decimal places. */\n initialDeposit: DecimalLike;\n managementFeeBps: number;\n performanceFeeBps: number;\n maxSlippageBps: number;\n cooldownSec: number | bigint;\n /** Maximum settlement fee authorised, in USD; max 12 decimal places. */\n maxFeeUsd: DecimalLike;\n /** Share price the vault is seeded at, in USD; max 12 decimal places. */\n initialSharePriceUsd: DecimalLike;\n /**\n * Spot asset the high-water mark is denominated in. Omit for the\n * feed-less USD default — presence drives the encoded hasBenchmark\n * flag, exactly as the exchange derives it from the wire param.\n */\n benchmarkAsset?: string;\n}\n\n/**\n * Create-vault action data (kind = 0, 12 words):\n * [kind, managerId, depositSpotAsset, initialDepositE18,\n * managementFeeBps, performanceFeeBps, maxSlippageBps, cooldownSec,\n * maxFeeUsdE18, initialSharePriceUsdE18, benchmarkAsset, hasBenchmark].\n * bps rates and cooldownSec are plain integers, not e18.\n */\nexport function encodeVaultCreate(fields: VaultCreateFields): string {\n const benchmark = fields.benchmarkAsset;\n return abi.encode(\n // prettier-ignore\n ['uint256', 'uint256', 'address', 'uint256', 'uint256', 'uint256', 'uint256', 'uint256', 'uint256', 'uint256', 'address', 'bool'],\n [\n VAULT_ACTION_KIND.create,\n fields.managerId,\n getAddress(fields.depositSpotAsset),\n unsignedE18(fields.initialDeposit, 'initialDeposit'),\n fields.managementFeeBps,\n fields.performanceFeeBps,\n fields.maxSlippageBps,\n fields.cooldownSec,\n unsignedE18(fields.maxFeeUsd, 'maxFeeUsd'),\n unsignedE18(fields.initialSharePriceUsd, 'initialSharePriceUsd'),\n benchmark === undefined ? ZeroAddress : getAddress(benchmark),\n benchmark !== undefined,\n ],\n );\n}\n\nexport interface VaultMintSharesFields {\n /** Quoted share price in USD per share; max 12 decimal places. */\n sharePrice: DecimalLike;\n /** keccak256 of the user's exact encoded deposit action (0x hex, 32 bytes). */\n depositHash: string;\n}\n\n/** MintSharesActionData (kind = 4): the curator's approval to settle one queued deposit. */\nexport function encodeVaultMintShares(fields: VaultMintSharesFields): string {\n return encodeSettleApproval(VAULT_ACTION_KIND.mintShares, fields.sharePrice, 'depositHash', fields.depositHash);\n}\n\nexport interface VaultBurnSharesFields {\n /** Quoted share price in USD per share; max 12 decimal places. */\n sharePrice: DecimalLike;\n /** keccak256 of the user's exact encoded withdraw action (0x hex, 32 bytes). */\n withdrawHash: string;\n}\n\n/** BurnSharesActionData (kind = 5): the curator's approval to settle one queued withdrawal. */\nexport function encodeVaultBurnShares(fields: VaultBurnSharesFields): string {\n return encodeSettleApproval(VAULT_ACTION_KIND.burnShares, fields.sharePrice, 'withdrawHash', fields.withdrawHash);\n}\n\n/**\n * Shared mint/burn layout (3 words): [kind, sharePriceE18, userActionHash].\n * The hash commits the quoted price to one exact user action, so the\n * exchange cannot pair it with a different deposit/withdrawal.\n */\nfunction encodeSettleApproval(kind: number, sharePrice: DecimalLike, hashLabel: string, hash: string): string {\n if (!isHexString(hash, 32)) throw new Error(`${hashLabel} must be a 0x-prefixed 32-byte hex string`);\n return abi.encode(['uint256', 'uint256', 'bytes32'], [kind, unsignedE18(sharePrice, 'sharePrice'), hash]);\n}\n","import { concat, getAddress, toBeHex, zeroPadValue } from 'ethers';\nimport type { ProtocolScopeCode } from '../auth/scopes';\n\nexport interface CreateSessionKeyData {\n /** Address of the key being authorized. */\n sessionKey: string;\n /**\n * The KEY's lifetime as a unix-seconds timestamp — distinct from the\n * envelope's signature expiry. The key stops working once `expirySec <= now`;\n * pass 0 to deactivate an existing key of this address.\n */\n expirySec: number;\n /**\n * Scope codes granted to the key (auth/scopes.ts). Typed as `number` at\n * this low level so raw codes pass through — the typed\n * `ProtocolScopeCode` enum guides callers, and the server is the\n * authority on which codes are valid.\n */\n scopes: readonly (ProtocolScopeCode | number)[];\n /** Subaccounts the key may act on; empty = ALL current and future subaccounts. */\n subaccountIds: readonly (number | bigint)[];\n}\n\n/**\n * Encodes the create-session-key action data.\n *\n * Hand-packed 32-byte words — NOT standard dynamic ABI (no offset or\n * length-prefix head): `[session_key][expiry_sec][S][A][scope codes…]\n * [subaccount ids…]`, every value right-aligned in its word.\n */\nexport function encodeCreateSessionKeyActionData(data: CreateSessionKeyData): string {\n if (!Number.isInteger(data.expirySec) || data.expirySec < 0) {\n throw new Error(`session key expirySec must be a non-negative unix-seconds integer, got ${data.expirySec}`);\n }\n return concat([\n zeroPadValue(getAddress(data.sessionKey), 32),\n uintWord(data.expirySec),\n uintWord(data.scopes.length),\n uintWord(data.subaccountIds.length),\n ...data.scopes.map((code) => uintWord(code)),\n ...data.subaccountIds.map((id) => uintWord(id)),\n ]);\n}\n\nfunction uintWord(value: number | bigint): string {\n const valid = typeof value === 'bigint' ? value >= 0n : Number.isSafeInteger(value) && value >= 0;\n if (!valid) throw new Error(`expected a non-negative integer, got ${value}`);\n return zeroPadValue(toBeHex(value), 32);\n}\n","import { concat, getAddress, toBeHex, zeroPadValue } from 'ethers';\n\n/**\n * Whitelisted-recipient delta, verified by the whitelisted-recipient\n * module: the resulting list is `(current ∪ add) \\ remove`.\n */\nexport interface WhitelistedRecipientsFields {\n add: string[];\n remove: string[];\n}\n\n/**\n * Hand-packed layout (2 + A + R words), NOT standard ABI dynamic arrays:\n * word 0 : add count A\n * word 1 : remove count R\n * word 2+i : add[i] (address, left-padded)\n * word 2+A+j : remove[j] (address, left-padded)\n */\nexport function encodeUpdateWhitelistedRecipients(fields: WhitelistedRecipientsFields): string {\n const add = fields.add.map((a) => getAddress(a));\n const remove = fields.remove.map((a) => getAddress(a));\n return concat([\n zeroPadValue(toBeHex(add.length), 32),\n zeroPadValue(toBeHex(remove.length), 32),\n ...add.map((a) => zeroPadValue(a, 32)),\n ...remove.map((a) => zeroPadValue(a, 32)),\n ]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAA0D;;;ACA1D,oBAA2B;AAgBpB,SAAS,MAAM,OAA4B;AAChD,SAAO,SAAS,OAAO,EAAE;AAC3B;AAOO,SAAS,mBAAmB,KAAa,OAAqB;AACnE,MAAI,MAAM,aAAe,IAAI;AAC3B,UAAM,IAAI,MAAM,GAAG,KAAK,6EAAwE;AAAA,EAClG;AACF;AAGO,SAAS,YAAY,OAAoB,OAAuB;AACrE,QAAM,SAAS,MAAM,KAAK;AAC1B,MAAI,SAAS,GAAI,OAAM,IAAI,MAAM,GAAG,KAAK,uBAAuB;AAChE,qBAAmB,QAAQ,KAAK;AAChC,SAAO;AACT;AAEO,SAAS,cAAc,OAAwB,OAAgC;AACpF,QAAM,QAAQ,OAAO,UAAU,WAAW,SAAS,KAAK,OAAO,cAAc,KAAK,KAAK,SAAS;AAChG,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,GAAG,KAAK,iCAAiC;AACrE,SAAO;AACT;AAKO,SAAS,SAAS,OAAoB,UAA0B;AACrE,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,OAAO,OAAO,UAAU,WAAW,OAAO,KAAK,IAAI,MAAM,KAAK;AACpE,MAAI,CAAC,kBAAkB,KAAK,IAAI,GAAG;AACjC,UAAM,IAAI;AAAA,MACR,0BAA0B,KAAK,UAAU,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AACA,aAAO,0BAAW,MAAM,QAAQ;AAClC;;;ADpCA,IAAM,WAAW,EAAE,MAAM;A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,QAAM,QAAQ,OAAO,UAAU,WAAW,SAAS,KAAK,OAAO,cAAc,KAAK,KAAK,SAAS;AAChG,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,wCAAwC,KAAK,EAAE;AAC3E,aAAO,iCAAa,wBAAQ,KAAK,GAAG,EAAE;AACxC;;;AChDA,IAAAC,iBAA0D;AAkBnD,SAAS,kCAAkC,QAA6C;AAC7F,QAAM,MAAM,OAAO,IAAI,IAAI,CAAC,UAAM,2BAAW,CAAC,CAAC;AAC/C,QAAM,SAAS,OAAO,OAAO,IAAI,CAAC,UAAM,2BAAW,CAAC,CAAC;AACrD,aAAO,uBAAO;AAAA,QACZ,iCAAa,wBAAQ,IAAI,MAAM,GAAG,EAAE;AAAA,QACpC,iCAAa,wBAAQ,OAAO,MAAM,GAAG,EAAE;AAAA,IACvC,GAAG,IAAI,IAAI,CAAC,UAAM,6BAAa,GAAG,EAAE,CAAC;AAAA,IACrC,GAAG,OAAO,IAAI,CAAC,UAAM,6BAAa,GAAG,EAAE,CAAC;AAAA,EAC1C,CAAC;AACH;","names":["import_ethers","assertE12Precision","import_ethers","import_ethers","import_ethers","import_ethers","import_ethers","import_ethers","uintWord","import_ethers"]}
@@ -0,0 +1,264 @@
1
+ import { D as DecimalLike, P as ProtocolScopeCode } from '../scopes-RzGb3xH6.cjs';
2
+ import { D as Direction } from '../generated-DwMaydIF.cjs';
3
+
4
+ /**
5
+ * Inputs to the trade (order) action payload, verified by the trade
6
+ * module (`network.modules.trade`).
7
+ */
8
+ interface TradeActionFields {
9
+ /** Protocol asset contract of the instrument (`base_asset_address`). */
10
+ assetAddress: string;
11
+ /** Asset sub id (`base_asset_sub_id`): 0 for perps/spot, the option id for options. */
12
+ subId: string | number | bigint;
13
+ limitPrice: DecimalLike;
14
+ amount: DecimalLike;
15
+ /** Worst acceptable fee per unit traded the signature allows. */
16
+ maxFee: DecimalLike;
17
+ /** Subaccount credited with the fill — the trading subaccount itself. */
18
+ recipientSubaccountId: number | bigint;
19
+ isBid: boolean;
20
+ }
21
+ /**
22
+ * Encodes the order action data: seven static words — asset, subId,
23
+ * limitPrice, amount, maxFee, recipientId, isBid — with
24
+ * prices/amounts/fee e18-scaled.
25
+ */
26
+ declare function encodeTradeData(fields: TradeActionFields): string;
27
+
28
+ /**
29
+ * Spot transfer between subaccounts of the same owner, verified by the
30
+ * transfer module. Position transfers are booked as RFQ trades — this
31
+ * action only ever moves a single spot asset.
32
+ */
33
+ interface TransferFields {
34
+ toSubaccountId: number | bigint;
35
+ /**
36
+ * Routing sentinel: 0 credits the existing `toSubaccountId`; non-zero
37
+ * creates a new subaccount under this manager id instead (the
38
+ * destination id is then ignored).
39
+ */
40
+ newSubaccountManager: number | bigint;
41
+ /** Protocol spot-asset address (not the underlying ERC-20). */
42
+ asset: string;
43
+ subId: number | bigint;
44
+ /** Strictly positive; signed at e18. */
45
+ amount: DecimalLike;
46
+ /** Maximum fee the signer authorises, in USD; signed at e18. */
47
+ maxFeeUsd: DecimalLike;
48
+ }
49
+ /** ABI-encodes transfer action data: six static 32-byte words. */
50
+ declare function encodeTransfer(fields: TransferFields): string;
51
+
52
+ /**
53
+ * Spot transfer to another owner's wallet, verified by the external
54
+ * transfer module: the six transfer words plus a seventh holding the
55
+ * recipient wallet.
56
+ */
57
+ interface ExternalTransferFields extends TransferFields {
58
+ /**
59
+ * Destination owner wallet. `toSubaccountId` must be one of its existing
60
+ * subaccounts, or 0 to create one for it under `newSubaccountManager`.
61
+ */
62
+ recipient: string;
63
+ }
64
+ /**
65
+ * All seven words are static, so the encoding is exactly the transfer
66
+ * payload with the recipient appended as a left-padded address word.
67
+ */
68
+ declare function encodeExternalTransfer(fields: ExternalTransferFields): string;
69
+
70
+ /** Withdrawal to L1, verified by the withdrawal module. */
71
+ interface WithdrawalFields {
72
+ /** Protocol asset contract address (not the underlying ERC-20). */
73
+ protocolAsset: string;
74
+ /** Maximum fee the signer authorises, in USD; signed at e18 like every other action value. */
75
+ maxFeeUsd: DecimalLike;
76
+ /** L1 payout recipient. The exchange only constructs withdrawals paying out to the action signer. */
77
+ recipient: string;
78
+ /**
79
+ * Withdrawal amount in the ERC-20's NATIVE decimals (USDC = 6) — the
80
+ * protocol's only never-scaled amount, since it is the L1 payout value.
81
+ */
82
+ amount: DecimalLike;
83
+ /** The underlying ERC-20's decimals, used to scale `amount`. */
84
+ decimals: number;
85
+ /** Pay a higher fee for immediate batch proving. */
86
+ forceBatch: boolean;
87
+ }
88
+ /** ABI-encodes withdrawal action data: five static 32-byte words. */
89
+ declare function encodeWithdrawal(fields: WithdrawalFields): string;
90
+
91
+ /**
92
+ * RFQ action-data codecs.
93
+ *
94
+ * Maker and taker must hash byte-identical leg bundles: legs are sorted
95
+ * lexicographically by instrument name, and each signed leg amount is
96
+ * `amount × legDirectionSign × directionSign × perspectiveSign`. The maker
97
+ * encodes with their own quote direction (perspective +1); the taker
98
+ * executes with the opposite direction and perspective −1, which cancels
99
+ * back to the maker's exact values — the server rebuilds the taker's
100
+ * order hash from the maker's stored quote.
101
+ */
102
+ /** A quoted leg carrying everything the signature commits to. */
103
+ interface RfqSignedLeg {
104
+ /** Canonical ordering key — both sides sign legs sorted by this. */
105
+ instrumentName: string;
106
+ /** Protocol asset contract for the instrument (option or perp). */
107
+ assetAddress: string;
108
+ /** Asset sub id: '0' for perps, the option's encoded sub id otherwise. */
109
+ subId: string | bigint;
110
+ /** Per-unit price, always positive; e18-scaled into the signed bytes. */
111
+ price: DecimalLike;
112
+ /** Unsigned size — direction carries the sign. */
113
+ amount: DecimalLike;
114
+ direction: Direction;
115
+ }
116
+ interface RfqQuoteFields {
117
+ /** Worst fee the signer accepts, in USD; e18 in the signed bytes. */
118
+ maxFee: DecimalLike;
119
+ /** The maker's quote direction (taker execute: the taker's own direction). */
120
+ direction: Direction;
121
+ legs: RfqSignedLeg[];
122
+ }
123
+ /** Sorts legs into the canonical order both counterparties sign and send. */
124
+ declare function sortRfqLegs<T extends {
125
+ instrumentName: string;
126
+ }>(legs: readonly T[]): T[];
127
+ /**
128
+ * Maker quote data: `abi.encode(RfqOrder{ maxFee, trades[] })` —
129
+ * `[0x20][maxFee][0x40][N][4 words per leg]`. Unlike the trade codec's
130
+ * low-16-byte i128 amount words, a negative leg amount here is a full
131
+ * sign-extended int256 (high 16 bytes 0xff), which is standard AbiCoder
132
+ * output.
133
+ */
134
+ declare function encodeRfqQuote(fields: RfqQuoteFields): string;
135
+ /**
136
+ * Taker execute data: `abi.encode(bytes32 orderHash, uint256 maxFee)` where
137
+ * `orderHash = keccak256(abi.encode(trades[]))` — the maker's legs only,
138
+ * maker maxFee excluded. `fields.direction` is the TAKER's direction
139
+ * (opposite of the quote's); `fields.maxFee` is the taker's own fee cap.
140
+ */
141
+ declare function encodeRfqExecute(fields: RfqQuoteFields): string;
142
+
143
+ /** Word-0 kind discriminators. */
144
+ declare const VAULT_ACTION_KIND: {
145
+ readonly create: 0;
146
+ readonly deposit: 1;
147
+ readonly withdraw: 2;
148
+ readonly cancel: 3;
149
+ readonly mintShares: 4;
150
+ readonly burnShares: 5;
151
+ };
152
+ interface VaultDepositFields {
153
+ vaultSubaccountId: number | bigint;
154
+ /** Must equal the vault's configured deposit asset (protocol spot-asset address). */
155
+ depositSpotAsset: string;
156
+ /** Deposit amount in the deposit asset's units; max 12 decimal places. */
157
+ amount: DecimalLike;
158
+ }
159
+ /** VaultDepositData (kind = 1, 4 words): [kind, vaultSubaccountId, depositSpotAsset, amountE18]. */
160
+ declare function encodeVaultDeposit(fields: VaultDepositFields): string;
161
+ interface VaultWithdrawFields {
162
+ vaultSubaccountId: number | bigint;
163
+ /** Vault shares to redeem; max 12 decimal places. */
164
+ sharesToBurn: DecimalLike;
165
+ }
166
+ /** VaultWithdrawData (kind = 2, 3 words): [kind, vaultSubaccountId, sharesToBurnE18]. */
167
+ declare function encodeVaultWithdraw(fields: VaultWithdrawFields): string;
168
+ /**
169
+ * VaultCancelData (kind = 3, 2 words): [kind, vaultSubaccountId].
170
+ * Invalidates ALL of the signer's pending intents for the vault by
171
+ * bumping their per-(vault, holder) nonce to the envelope's nonce.
172
+ */
173
+ declare function encodeVaultCancel(vaultSubaccountId: number | bigint): string;
174
+ interface VaultCreateFields {
175
+ managerId: number;
176
+ depositSpotAsset: string;
177
+ /** Initial deposit moved funding subaccount → vault; max 12 decimal places. */
178
+ initialDeposit: DecimalLike;
179
+ managementFeeBps: number;
180
+ performanceFeeBps: number;
181
+ maxSlippageBps: number;
182
+ cooldownSec: number | bigint;
183
+ /** Maximum settlement fee authorised, in USD; max 12 decimal places. */
184
+ maxFeeUsd: DecimalLike;
185
+ /** Share price the vault is seeded at, in USD; max 12 decimal places. */
186
+ initialSharePriceUsd: DecimalLike;
187
+ /**
188
+ * Spot asset the high-water mark is denominated in. Omit for the
189
+ * feed-less USD default — presence drives the encoded hasBenchmark
190
+ * flag, exactly as the exchange derives it from the wire param.
191
+ */
192
+ benchmarkAsset?: string;
193
+ }
194
+ /**
195
+ * Create-vault action data (kind = 0, 12 words):
196
+ * [kind, managerId, depositSpotAsset, initialDepositE18,
197
+ * managementFeeBps, performanceFeeBps, maxSlippageBps, cooldownSec,
198
+ * maxFeeUsdE18, initialSharePriceUsdE18, benchmarkAsset, hasBenchmark].
199
+ * bps rates and cooldownSec are plain integers, not e18.
200
+ */
201
+ declare function encodeVaultCreate(fields: VaultCreateFields): string;
202
+ interface VaultMintSharesFields {
203
+ /** Quoted share price in USD per share; max 12 decimal places. */
204
+ sharePrice: DecimalLike;
205
+ /** keccak256 of the user's exact encoded deposit action (0x hex, 32 bytes). */
206
+ depositHash: string;
207
+ }
208
+ /** MintSharesActionData (kind = 4): the curator's approval to settle one queued deposit. */
209
+ declare function encodeVaultMintShares(fields: VaultMintSharesFields): string;
210
+ interface VaultBurnSharesFields {
211
+ /** Quoted share price in USD per share; max 12 decimal places. */
212
+ sharePrice: DecimalLike;
213
+ /** keccak256 of the user's exact encoded withdraw action (0x hex, 32 bytes). */
214
+ withdrawHash: string;
215
+ }
216
+ /** BurnSharesActionData (kind = 5): the curator's approval to settle one queued withdrawal. */
217
+ declare function encodeVaultBurnShares(fields: VaultBurnSharesFields): string;
218
+
219
+ interface CreateSessionKeyData {
220
+ /** Address of the key being authorized. */
221
+ sessionKey: string;
222
+ /**
223
+ * The KEY's lifetime as a unix-seconds timestamp — distinct from the
224
+ * envelope's signature expiry. The key stops working once `expirySec <= now`;
225
+ * pass 0 to deactivate an existing key of this address.
226
+ */
227
+ expirySec: number;
228
+ /**
229
+ * Scope codes granted to the key (auth/scopes.ts). Typed as `number` at
230
+ * this low level so raw codes pass through — the typed
231
+ * `ProtocolScopeCode` enum guides callers, and the server is the
232
+ * authority on which codes are valid.
233
+ */
234
+ scopes: readonly (ProtocolScopeCode | number)[];
235
+ /** Subaccounts the key may act on; empty = ALL current and future subaccounts. */
236
+ subaccountIds: readonly (number | bigint)[];
237
+ }
238
+ /**
239
+ * Encodes the create-session-key action data.
240
+ *
241
+ * Hand-packed 32-byte words — NOT standard dynamic ABI (no offset or
242
+ * length-prefix head): `[session_key][expiry_sec][S][A][scope codes…]
243
+ * [subaccount ids…]`, every value right-aligned in its word.
244
+ */
245
+ declare function encodeCreateSessionKeyActionData(data: CreateSessionKeyData): string;
246
+
247
+ /**
248
+ * Whitelisted-recipient delta, verified by the whitelisted-recipient
249
+ * module: the resulting list is `(current ∪ add) \ remove`.
250
+ */
251
+ interface WhitelistedRecipientsFields {
252
+ add: string[];
253
+ remove: string[];
254
+ }
255
+ /**
256
+ * Hand-packed layout (2 + A + R words), NOT standard ABI dynamic arrays:
257
+ * word 0 : add count A
258
+ * word 1 : remove count R
259
+ * word 2+i : add[i] (address, left-padded)
260
+ * word 2+A+j : remove[j] (address, left-padded)
261
+ */
262
+ declare function encodeUpdateWhitelistedRecipients(fields: WhitelistedRecipientsFields): string;
263
+
264
+ export { type CreateSessionKeyData, type ExternalTransferFields, type RfqQuoteFields, type RfqSignedLeg, type TradeActionFields, type TransferFields, VAULT_ACTION_KIND, type VaultBurnSharesFields, type VaultCreateFields, type VaultDepositFields, type VaultMintSharesFields, type VaultWithdrawFields, type WhitelistedRecipientsFields, type WithdrawalFields, encodeCreateSessionKeyActionData, encodeExternalTransfer, encodeRfqExecute, encodeRfqQuote, encodeTradeData, encodeTransfer, encodeUpdateWhitelistedRecipients, encodeVaultBurnShares, encodeVaultCancel, encodeVaultCreate, encodeVaultDeposit, encodeVaultMintShares, encodeVaultWithdraw, encodeWithdrawal, sortRfqLegs };