@umbra-privacy/sdk 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -25
- package/dist/{addresses-Brzgurv_.d.ts → addresses-B7HybtbJ.d.ts} +2 -1
- package/dist/{addresses-D_0YAS6B.d.cts → addresses-CTVY1oi7.d.cts} +2 -1
- package/dist/arcium-BXXlryfe.d.cts +20 -0
- package/dist/arcium-BXXlryfe.d.ts +20 -0
- package/dist/chunk-4RHXVBNI.js +203 -0
- package/dist/chunk-4RHXVBNI.js.map +1 -0
- package/dist/chunk-4TZVXB5G.js +324 -0
- package/dist/chunk-4TZVXB5G.js.map +1 -0
- package/dist/chunk-5GUSMQ74.cjs +549 -0
- package/dist/chunk-5GUSMQ74.cjs.map +1 -0
- package/dist/chunk-5KPQXPQM.js +36 -0
- package/dist/chunk-5KPQXPQM.js.map +1 -0
- package/dist/chunk-AXD7LXYY.cjs +405 -0
- package/dist/chunk-AXD7LXYY.cjs.map +1 -0
- package/dist/{chunk-HOEXDXRC.cjs → chunk-BL6WXLPV.cjs} +32 -360
- package/dist/chunk-BL6WXLPV.cjs.map +1 -0
- package/dist/chunk-CFFLOE7D.cjs +598 -0
- package/dist/chunk-CFFLOE7D.cjs.map +1 -0
- package/dist/{chunk-BM7N6N7E.js → chunk-CFTW5WNG.js} +3 -325
- package/dist/chunk-CFTW5WNG.js.map +1 -0
- package/dist/chunk-DD2WCK4C.js +327 -0
- package/dist/chunk-DD2WCK4C.js.map +1 -0
- package/dist/chunk-DMPMQ74B.cjs +246 -0
- package/dist/chunk-DMPMQ74B.cjs.map +1 -0
- package/dist/{chunk-2Q75CQQJ.js → chunk-EEKF4553.js} +2 -2
- package/dist/chunk-EEKF4553.js.map +1 -0
- package/dist/chunk-ENVYYEM4.cjs +113 -0
- package/dist/chunk-ENVYYEM4.cjs.map +1 -0
- package/dist/chunk-FQX6ZYGJ.js +500 -0
- package/dist/chunk-FQX6ZYGJ.js.map +1 -0
- package/dist/chunk-FSK2ICMB.cjs +39 -0
- package/dist/chunk-FSK2ICMB.cjs.map +1 -0
- package/dist/chunk-FZYWLQAF.cjs +355 -0
- package/dist/chunk-FZYWLQAF.cjs.map +1 -0
- package/dist/chunk-GP26R377.js +436 -0
- package/dist/chunk-GP26R377.js.map +1 -0
- package/dist/chunk-HA5FLM63.js +393 -0
- package/dist/chunk-HA5FLM63.js.map +1 -0
- package/dist/chunk-INJ73LXQ.js +1107 -0
- package/dist/chunk-INJ73LXQ.js.map +1 -0
- package/dist/chunk-JPDF7BIT.cjs +10892 -0
- package/dist/chunk-JPDF7BIT.cjs.map +1 -0
- package/dist/{chunk-MDFSBU5W.cjs → chunk-LTCKPTZC.cjs} +2 -351
- package/dist/chunk-LTCKPTZC.cjs.map +1 -0
- package/dist/chunk-MKNCBUFA.js +564 -0
- package/dist/chunk-MKNCBUFA.js.map +1 -0
- package/dist/chunk-NKVMSABR.cjs +207 -0
- package/dist/chunk-NKVMSABR.cjs.map +1 -0
- package/dist/chunk-OFDWNWCL.js +70 -0
- package/dist/chunk-OFDWNWCL.js.map +1 -0
- package/dist/chunk-QJAUUYZU.cjs +331 -0
- package/dist/chunk-QJAUUYZU.cjs.map +1 -0
- package/dist/chunk-RVUYPKKD.js +10750 -0
- package/dist/chunk-RVUYPKKD.js.map +1 -0
- package/dist/chunk-TLR7A64G.js +103 -0
- package/dist/chunk-TLR7A64G.js.map +1 -0
- package/dist/{chunk-MVKTV3FT.cjs → chunk-TQQZGNOI.cjs} +2 -2
- package/dist/chunk-TQQZGNOI.cjs.map +1 -0
- package/dist/chunk-UOFYS6M3.js +219 -0
- package/dist/chunk-UOFYS6M3.js.map +1 -0
- package/dist/chunk-UXMQI6B7.js +2406 -0
- package/dist/chunk-UXMQI6B7.js.map +1 -0
- package/dist/chunk-WN75ORDT.js +571 -0
- package/dist/chunk-WN75ORDT.js.map +1 -0
- package/dist/chunk-Y55PYKXH.cjs +595 -0
- package/dist/chunk-Y55PYKXH.cjs.map +1 -0
- package/dist/chunk-YEZBTYCP.cjs +77 -0
- package/dist/chunk-YEZBTYCP.cjs.map +1 -0
- package/dist/chunk-ZQOIYCGA.cjs +1126 -0
- package/dist/chunk-ZQOIYCGA.cjs.map +1 -0
- package/dist/chunk-ZY3TSHMJ.cjs +2665 -0
- package/dist/chunk-ZY3TSHMJ.cjs.map +1 -0
- package/dist/client-DkVBHMWb.d.cts +2613 -0
- package/dist/client-V4AF6Bz9.d.ts +2613 -0
- package/dist/common/pda/index.cjs +145 -0
- package/dist/common/pda/index.cjs.map +1 -0
- package/dist/common/pda/index.d.cts +1250 -0
- package/dist/common/pda/index.d.ts +1250 -0
- package/dist/common/pda/index.js +8 -0
- package/dist/common/pda/index.js.map +1 -0
- package/dist/constants/index.cjs +38 -164
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +8 -425
- package/dist/constants/index.d.ts +8 -425
- package/dist/constants/index.js +15 -124
- package/dist/constants/index.js.map +1 -1
- package/dist/crypto/index.cjs +583 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +6731 -0
- package/dist/crypto/index.d.ts +6731 -0
- package/dist/crypto/index.js +14 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/{cryptography-BTGC72u-.d.ts → cryptography-BFSJcvi6.d.ts} +3 -2465
- package/dist/{cryptography-BTGC72u-.d.cts → cryptography-D6tPDh-Y.d.cts} +3 -2465
- package/dist/errors/index.cjs +64 -54
- package/dist/errors/index.d.cts +7 -797
- package/dist/errors/index.d.ts +7 -797
- package/dist/errors/index.js +3 -1
- package/dist/errors-B9EoPeWV.d.cts +593 -0
- package/dist/errors-B9EoPeWV.d.ts +593 -0
- package/dist/errors-DAIrstEL.d.cts +300 -0
- package/dist/errors-DPNMfyh0.d.ts +300 -0
- package/dist/index-BG0yjL7C.d.cts +6006 -0
- package/dist/index-ByynoyBO.d.ts +6006 -0
- package/dist/index.cjs +5126 -16118
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1031 -7685
- package/dist/index.d.ts +1031 -7685
- package/dist/index.js +3219 -14905
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.cts +14 -6
- package/dist/interfaces/index.d.ts +14 -6
- package/dist/interfaces-43cReBcS.d.cts +3346 -0
- package/dist/interfaces-B8xKNl_6.d.ts +997 -0
- package/dist/interfaces-D2NO6kDD.d.cts +997 -0
- package/dist/interfaces-z_xYJlgV.d.ts +3346 -0
- package/dist/math/index.cjs +115 -0
- package/dist/math/index.cjs.map +1 -0
- package/dist/math/index.d.cts +1327 -0
- package/dist/math/index.d.ts +1327 -0
- package/dist/math/index.js +10 -0
- package/dist/math/index.js.map +1 -0
- package/dist/networks-RMd3abPE.d.ts +44 -0
- package/dist/networks-yAoO8peQ.d.cts +44 -0
- package/dist/relayer-NRRMSMNB.js +4 -0
- package/dist/relayer-NRRMSMNB.js.map +1 -0
- package/dist/relayer-RJHEIXJG.cjs +21 -0
- package/dist/relayer-RJHEIXJG.cjs.map +1 -0
- package/dist/solana/index.cjs +56 -0
- package/dist/solana/index.cjs.map +1 -0
- package/dist/solana/index.d.cts +105 -0
- package/dist/solana/index.d.ts +105 -0
- package/dist/solana/index.js +7 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/{index-CLj_zWSD.d.ts → temporal-BbRaEPoO.d.ts} +1 -1
- package/dist/{index-CX6_pIRS.d.cts → temporal-oUj7iCaq.d.cts} +1 -1
- package/dist/transaction-forwarder-5mAMTjw6.d.ts +1155 -0
- package/dist/transaction-forwarder-C6gMUG7a.d.cts +1155 -0
- package/dist/types/index.cjs +232 -231
- package/dist/types/index.d.cts +15 -1485
- package/dist/types/index.d.ts +15 -1485
- package/dist/types/index.js +2 -1
- package/dist/types-BohhvPth.d.cts +87 -0
- package/dist/types-CW0oTT0j.d.ts +87 -0
- package/dist/types-C_V_CaKK.d.cts +2468 -0
- package/dist/types-C_V_CaKK.d.ts +2468 -0
- package/dist/types-Ca7frykr.d.ts +793 -0
- package/dist/types-CuKeoI19.d.cts +1296 -0
- package/dist/types-CxfTIpN9.d.ts +1052 -0
- package/dist/{types-n-sHFcgr.d.ts → types-D1jDUjfN.d.ts} +2 -2
- package/dist/types-DKEDUlH9.d.ts +1296 -0
- package/dist/types-EKuIfxTz.d.cts +1052 -0
- package/dist/{types-BBuELtY8.d.cts → types-IMGYmlv-.d.cts} +2 -2
- package/dist/types-PwNLi_2k.d.cts +793 -0
- package/dist/utils/index.cjs +823 -525
- package/dist/utils/index.d.cts +1711 -4021
- package/dist/utils/index.d.ts +1711 -4021
- package/dist/utils/index.js +9 -3
- package/dist/{versions-D9PqsEvj.d.cts → versions-BRlR36EA.d.cts} +1 -0
- package/dist/{versions-D9PqsEvj.d.ts → versions-BRlR36EA.d.ts} +1 -0
- package/package.json +79 -18
- package/dist/chunk-2Q75CQQJ.js.map +0 -1
- package/dist/chunk-BM7N6N7E.js.map +0 -1
- package/dist/chunk-GXKSUB2U.cjs +0 -4416
- package/dist/chunk-GXKSUB2U.cjs.map +0 -1
- package/dist/chunk-HOEXDXRC.cjs.map +0 -1
- package/dist/chunk-MDFSBU5W.cjs.map +0 -1
- package/dist/chunk-MQY7HDIA.js +0 -600
- package/dist/chunk-MQY7HDIA.js.map +0 -1
- package/dist/chunk-MVKTV3FT.cjs.map +0 -1
- package/dist/chunk-PG2J6V6Y.js +0 -4094
- package/dist/chunk-PG2J6V6Y.js.map +0 -1
- package/dist/chunk-VEGLTTYQ.cjs +0 -621
- package/dist/chunk-VEGLTTYQ.cjs.map +0 -1
- package/dist/chunk-WVHQ46DD.js +0 -758
- package/dist/chunk-WVHQ46DD.js.map +0 -1
- package/dist/index-B9pDY73x.d.ts +0 -12933
- package/dist/index-D33yo0qB.d.cts +0 -12933
- package/dist/networks-C-orpSFW.d.ts +0 -65
- package/dist/networks-FxYERGD1.d.cts +0 -65
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { A as AltEntry, N as NetworkConfig, g as getNetworkConfig } from '../networks-
|
|
2
|
-
export { A as AlgorithmVersion, a as AlgorithmVersionSpecifierFunction, D as DEFAULT_ALGORITHM_VERSION, b as DEFAULT_NETWORK, c as DEFAULT_PROTOCOL_VERSION, d as DEFAULT_SCHEME_VERSION, N as Network, e as NetworkSpecifierFunction, P as ProtocolVersion, f as ProtocolVersionSpecifierFunction, S as SchemeVersion, g as SchemeVersionSpecifierFunction, h as assertNetwork, i as assertValidAlgorithmVersion, j as assertValidProtocolVersion, k as assertValidSchemeVersion, l as assertValidVersion, m as getDefaultAlgorithmVersion, n as getDefaultProtocolVersion, o as getDefaultSchemeVersion, p as getNetworkSpecifier } from '../versions-
|
|
1
|
+
export { A as AltEntry, N as NetworkConfig, g as getNetworkConfig } from '../networks-yAoO8peQ.cjs';
|
|
2
|
+
export { A as AlgorithmVersion, a as AlgorithmVersionSpecifierFunction, D as DEFAULT_ALGORITHM_VERSION, b as DEFAULT_NETWORK, c as DEFAULT_PROTOCOL_VERSION, d as DEFAULT_SCHEME_VERSION, N as Network, e as NetworkSpecifierFunction, P as ProtocolVersion, f as ProtocolVersionSpecifierFunction, S as SchemeVersion, g as SchemeVersionSpecifierFunction, h as assertNetwork, i as assertValidAlgorithmVersion, j as assertValidProtocolVersion, k as assertValidSchemeVersion, l as assertValidVersion, m as getDefaultAlgorithmVersion, n as getDefaultProtocolVersion, o as getDefaultSchemeVersion, p as getNetworkSpecifier } from '../versions-BRlR36EA.cjs';
|
|
3
3
|
import { Address } from '@solana/kit';
|
|
4
|
-
import '../cryptography-
|
|
4
|
+
import '../cryptography-D6tPDh-Y.cjs';
|
|
5
|
+
import '../types-C_V_CaKK.cjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Arcium Protocol Constants
|
|
@@ -9,6 +10,7 @@ import '../cryptography-BTGC72u-.cjs';
|
|
|
9
10
|
* This module contains constants for interacting with the Arcium protocol,
|
|
10
11
|
* including the program address and PDA seed prefixes for various account types.
|
|
11
12
|
*
|
|
13
|
+
* @since 2.0.0
|
|
12
14
|
* @module constants/arcium
|
|
13
15
|
*/
|
|
14
16
|
/**
|
|
@@ -67,6 +69,7 @@ declare const ARCIUM_OFFSET_BUFFER_SIZE = 4;
|
|
|
67
69
|
* Domain separators for cryptographic operations in claim functions.
|
|
68
70
|
* These are used as keys in KMAC256 for domain separation.
|
|
69
71
|
*
|
|
72
|
+
* @since 2.0.0
|
|
70
73
|
* @module constants/domain-separators
|
|
71
74
|
*/
|
|
72
75
|
/**
|
|
@@ -133,6 +136,7 @@ declare const RESCUE_COMMITMENT_DOMAINS: {
|
|
|
133
136
|
*
|
|
134
137
|
* Constants for encryption operations in claim circuits.
|
|
135
138
|
*
|
|
139
|
+
* @since 2.0.0
|
|
136
140
|
* @module constants/encryption-counts
|
|
137
141
|
*/
|
|
138
142
|
/**
|
|
@@ -282,39 +286,6 @@ declare const SPL_TOKEN_PROGRAM_ID: Address;
|
|
|
282
286
|
* @public
|
|
283
287
|
*/
|
|
284
288
|
declare const TOKEN_2022_PROGRAM_ID: Address;
|
|
285
|
-
/**
|
|
286
|
-
* Solana System Program ID.
|
|
287
|
-
*
|
|
288
|
-
* The native Solana program at address `11111111111111111111111111111111` is
|
|
289
|
-
* responsible for the fundamental account management operations on the network:
|
|
290
|
-
* creating new accounts, allocating data space, assigning account ownership, and
|
|
291
|
-
* transferring lamports (SOL).
|
|
292
|
-
*
|
|
293
|
-
* @remarks
|
|
294
|
-
* Every Solana account that is not yet initialized is implicitly owned by the
|
|
295
|
-
* System Program. Anchor programs typically transfer ownership to their own
|
|
296
|
-
* program ID during the `init` instruction by using the System Program's
|
|
297
|
-
* `createAccount` or `createAccountWithSeed` instructions.
|
|
298
|
-
*
|
|
299
|
-
* In Umbra SDK transaction building, the System Program is included in account
|
|
300
|
-
* metas whenever a new on-chain account needs to be created (e.g., initializing
|
|
301
|
-
* a user's encrypted token account or a pool).
|
|
302
|
-
*
|
|
303
|
-
* @example
|
|
304
|
-
* ```typescript
|
|
305
|
-
* import { SYSTEM_PROGRAM_ID } from "@umbra-privacy/sdk";
|
|
306
|
-
*
|
|
307
|
-
* // Include the System Program when an instruction may create accounts
|
|
308
|
-
* const accounts = [
|
|
309
|
-
* { address: payer, role: AccountRole.WRITABLE_SIGNER },
|
|
310
|
-
* { address: newAccount, role: AccountRole.WRITABLE },
|
|
311
|
-
* { address: SYSTEM_PROGRAM_ID, role: AccountRole.READONLY },
|
|
312
|
-
* ];
|
|
313
|
-
* ```
|
|
314
|
-
*
|
|
315
|
-
* @public
|
|
316
|
-
*/
|
|
317
|
-
declare const SYSTEM_PROGRAM_ID: Address;
|
|
318
289
|
/**
|
|
319
290
|
* Associated Token Account Program ID.
|
|
320
291
|
*
|
|
@@ -347,393 +318,5 @@ declare const SYSTEM_PROGRAM_ID: Address;
|
|
|
347
318
|
* @public
|
|
348
319
|
*/
|
|
349
320
|
declare const ASSOCIATED_TOKEN_PROGRAM_ID: Address;
|
|
350
|
-
/**
|
|
351
|
-
* Solana Compute Budget Program ID.
|
|
352
|
-
*
|
|
353
|
-
* The Compute Budget program allows transactions to modify their compute unit
|
|
354
|
-
* limit and compute unit price. These settings affect transaction prioritization
|
|
355
|
-
* and whether a transaction will succeed within the default compute cap.
|
|
356
|
-
*
|
|
357
|
-
* @remarks
|
|
358
|
-
* Umbra's MPC-backed instructions (encrypted deposits, transfers, claims) are
|
|
359
|
-
* computation-heavy and regularly exceed the default 200,000 compute unit limit.
|
|
360
|
-
* Transactions that include such instructions must prepend a
|
|
361
|
-
* `SetComputeUnitLimit` instruction using {@link createSetComputeUnitLimitInstruction}
|
|
362
|
-
* to raise the cap before the Umbra instruction runs.
|
|
363
|
-
*
|
|
364
|
-
* @see {@link createSetComputeUnitLimitInstruction} for the helper that builds
|
|
365
|
-
* the `SetComputeUnitLimit` instruction targeting this program
|
|
366
|
-
* @public
|
|
367
|
-
*/
|
|
368
|
-
declare const COMPUTE_BUDGET_PROGRAM_ADDRESS: Address;
|
|
369
|
-
/**
|
|
370
|
-
* Creates a `SetComputeUnitLimit` instruction for the Solana Compute Budget program.
|
|
371
|
-
*
|
|
372
|
-
* Compute Budget instruction discriminator `2` tells the runtime to override the
|
|
373
|
-
* default per-transaction compute unit limit (200,000 CU) with the specified
|
|
374
|
-
* `units` value. The instruction must appear before any instructions that need
|
|
375
|
-
* the higher limit, typically as the first instruction in the transaction.
|
|
376
|
-
*
|
|
377
|
-
* @remarks
|
|
378
|
-
* **Encoding** — The instruction data is 5 bytes:
|
|
379
|
-
* - Byte 0: discriminator `2` (SetComputeUnitLimit)
|
|
380
|
-
* - Bytes 1–4: `units` encoded as a little-endian `u32`
|
|
381
|
-
*
|
|
382
|
-
* **No accounts** — This instruction requires no account inputs; the `accounts`
|
|
383
|
-
* field is always an empty tuple.
|
|
384
|
-
*
|
|
385
|
-
* **Umbra usage** — Umbra's confidential instructions (encrypted deposits,
|
|
386
|
-
* transfers, claims) are compute-intensive due to ZK proof verification and
|
|
387
|
-
* Arcium MPC bookkeeping. The SDK prepends this instruction to those transactions
|
|
388
|
-
* with a limit of 1,400,000 CU (the maximum allowed per transaction as of this
|
|
389
|
-
* writing).
|
|
390
|
-
*
|
|
391
|
-
* **Maximum value** — The maximum allowed compute unit limit per transaction is
|
|
392
|
-
* 1,400,000. Requesting more will cause the transaction to fail at preflight.
|
|
393
|
-
*
|
|
394
|
-
* @param units - The desired compute unit limit. Must be a non-negative integer
|
|
395
|
-
* no greater than 1,400,000. Values are encoded as little-endian `u32`.
|
|
396
|
-
* @returns A plain instruction object with:
|
|
397
|
-
* - `programAddress`: {@link COMPUTE_BUDGET_PROGRAM_ADDRESS}
|
|
398
|
-
* - `data`: 5-byte `Uint8Array` encoding the `SetComputeUnitLimit` payload
|
|
399
|
-
* - `accounts`: an empty readonly tuple (no accounts needed)
|
|
400
|
-
*
|
|
401
|
-
* @example
|
|
402
|
-
* Adding a compute unit limit to a transaction message:
|
|
403
|
-
* ```typescript
|
|
404
|
-
* import { createSetComputeUnitLimitInstruction } from "@umbra-privacy/sdk";
|
|
405
|
-
* import { appendTransactionMessageInstruction } from "@solana/kit";
|
|
406
|
-
*
|
|
407
|
-
* const cuLimitIx = createSetComputeUnitLimitInstruction(1_400_000);
|
|
408
|
-
*
|
|
409
|
-
* const txMessage = appendTransactionMessageInstruction(cuLimitIx, baseMessage);
|
|
410
|
-
* ```
|
|
411
|
-
*
|
|
412
|
-
* @example
|
|
413
|
-
* Checking the serialized instruction bytes:
|
|
414
|
-
* ```typescript
|
|
415
|
-
* const ix = createSetComputeUnitLimitInstruction(300_000);
|
|
416
|
-
* // ix.data === Uint8Array [2, 224, 147, 4, 0]
|
|
417
|
-
* // 300000 = 0x493E0 → LE bytes: 0xE0, 0x93, 0x04, 0x00
|
|
418
|
-
* ```
|
|
419
|
-
*
|
|
420
|
-
* @see {@link COMPUTE_BUDGET_PROGRAM_ADDRESS} for the program address used
|
|
421
|
-
* @public
|
|
422
|
-
*/
|
|
423
|
-
declare function createSetComputeUnitLimitInstruction(units: number): {
|
|
424
|
-
programAddress: Address;
|
|
425
|
-
data: Uint8Array;
|
|
426
|
-
accounts: readonly [];
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Umbra Protocol Constants
|
|
431
|
-
*
|
|
432
|
-
* Defines the configuration constants used when building and validating Umbra protocol
|
|
433
|
-
* instructions on the client side. These constants mirror on-chain values defined in the
|
|
434
|
-
* Anchor program (`programs/umbra/src/`) and must be kept in sync with that source of
|
|
435
|
-
* truth.
|
|
436
|
-
*
|
|
437
|
-
* ## Sections
|
|
438
|
-
*
|
|
439
|
-
* - **Message signing** — the canonical warning text presented to users before their
|
|
440
|
-
* wallet signature is used to derive the master private key.
|
|
441
|
-
* - **Protocol fee configuration** — the fee schedule applied to the protocol's share
|
|
442
|
-
* of each claim or transfer. Set by program admin, enforced on-chain.
|
|
443
|
-
* - **Relayer fee configuration** — the fee schedule applied to the relayer's commission
|
|
444
|
-
* on claim and transfer instructions. Set per-relayer.
|
|
445
|
-
* - **Fee offset configuration** — the `offset` discriminators used when deriving PDAs
|
|
446
|
-
* for fee-related accounts.
|
|
447
|
-
* - **BPS divisor** — the basis-point denominator used in fee arithmetic.
|
|
448
|
-
*
|
|
449
|
-
* @packageDocumentation
|
|
450
|
-
* @module umbra/constants
|
|
451
|
-
*/
|
|
452
|
-
/**
|
|
453
|
-
* Canonical message shown to the user before their wallet signature is requested for
|
|
454
|
-
* master key derivation.
|
|
455
|
-
*
|
|
456
|
-
* @remarks
|
|
457
|
-
* Signing this message is the root of the user's key hierarchy. The resulting signature
|
|
458
|
-
* is fed into the SDK's key derivation pipeline to produce the `MasterSeed`, from which
|
|
459
|
-
* all spending keys, viewing keys, and Poseidon private keys are derived.
|
|
460
|
-
*
|
|
461
|
-
* The message is deliberately verbose and alarming to ensure that:
|
|
462
|
-
* 1. Users understand the cryptographic weight of their signature.
|
|
463
|
-
* 2. Phishing sites that silently request this signature cannot hide the operation from
|
|
464
|
-
* an attentive user.
|
|
465
|
-
*
|
|
466
|
-
* The exact string (including surrounding newlines) must not be modified without a
|
|
467
|
-
* corresponding protocol upgrade, because changing the message changes all derived keys
|
|
468
|
-
* for every existing user.
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```typescript
|
|
472
|
-
* import { UMBRA_MESSAGE_TO_SIGN } from "@umbra-privacy/sdk";
|
|
473
|
-
* import { signMessage } from "@solana/kit";
|
|
474
|
-
*
|
|
475
|
-
* // Present to the user before requesting their signature:
|
|
476
|
-
* console.log(UMBRA_MESSAGE_TO_SIGN);
|
|
477
|
-
*
|
|
478
|
-
* // Obtain the signature and pass it to the key derivation pipeline:
|
|
479
|
-
* const signature = await signer.signMessage(
|
|
480
|
-
* new TextEncoder().encode(UMBRA_MESSAGE_TO_SIGN)
|
|
481
|
-
* );
|
|
482
|
-
* ```
|
|
483
|
-
*
|
|
484
|
-
* @public
|
|
485
|
-
*/
|
|
486
|
-
declare const UMBRA_MESSAGE_TO_SIGN = "\nSigning this message is a sensitive cryptographic operation that generates the master key used to derive your private spending keys and decrypt your account balances. This signature acts as the root of your privacy and financial security within the Umbra ecosystem.\n\nYou must ensure that you are interacting with the official Umbra Privacy application or a verified integration. Signing this message on an unverified or malicious site could allow an attacker to gain full control over your funds and expose your entire transaction history.\n";
|
|
487
|
-
/**
|
|
488
|
-
* Default fee schedule applied to the protocol's share of each claim or transfer
|
|
489
|
-
* instruction.
|
|
490
|
-
*
|
|
491
|
-
* @remarks
|
|
492
|
-
* These values mirror the `ProtocolFeesConfiguration` account that is written by the
|
|
493
|
-
* program admin during pool setup. The SDK uses them client-side to:
|
|
494
|
-
*
|
|
495
|
-
* 1. Pre-calculate expected fee amounts before building a transaction, so callers can
|
|
496
|
-
* display accurate fee estimates in the UI.
|
|
497
|
-
* 2. Compute the amount of tokens the user actually receives after fees are deducted
|
|
498
|
-
* from the claimed UTXO.
|
|
499
|
-
*
|
|
500
|
-
* The on-chain program independently validates the actual fee config account, so these
|
|
501
|
-
* client-side defaults act as a best-effort estimate rather than an authoritative source.
|
|
502
|
-
* If the admin updates fee parameters on-chain, callers should fetch the live
|
|
503
|
-
* `ProtocolFeesConfiguration` PDA and override these defaults.
|
|
504
|
-
*
|
|
505
|
-
* ## Fee formula
|
|
506
|
-
*
|
|
507
|
-
* ```
|
|
508
|
-
* fee = clamp(BASE_FEE + floor(amount * BPS / BPS_DIVISOR), LOWER_BOUND, UPPER_BOUND)
|
|
509
|
-
* ```
|
|
510
|
-
*
|
|
511
|
-
* Where `BPS_DIVISOR = 10_000n` (see {@link BPS_DIVISOR}).
|
|
512
|
-
*
|
|
513
|
-
* @example
|
|
514
|
-
* ```typescript
|
|
515
|
-
* import { PROTOCOL_FEE, BPS_DIVISOR } from "@umbra-privacy/sdk";
|
|
516
|
-
*
|
|
517
|
-
* function estimateProtocolFee(amount: bigint): bigint {
|
|
518
|
-
* const bpsFee = (amount * PROTOCOL_FEE.BPS) / BPS_DIVISOR;
|
|
519
|
-
* const rawFee = PROTOCOL_FEE.BASE_FEE + bpsFee;
|
|
520
|
-
* const clamped = rawFee < PROTOCOL_FEE.LOWER_BOUND
|
|
521
|
-
* ? PROTOCOL_FEE.LOWER_BOUND
|
|
522
|
-
* : rawFee > PROTOCOL_FEE.UPPER_BOUND
|
|
523
|
-
* ? PROTOCOL_FEE.UPPER_BOUND
|
|
524
|
-
* : rawFee;
|
|
525
|
-
* return clamped;
|
|
526
|
-
* }
|
|
527
|
-
* ```
|
|
528
|
-
*
|
|
529
|
-
* @see {@link RELAYER_FEE} for the relayer's fee schedule.
|
|
530
|
-
* @see {@link BPS_DIVISOR} for the basis-point denominator.
|
|
531
|
-
* @public
|
|
532
|
-
*/
|
|
533
|
-
declare const PROTOCOL_FEE: {
|
|
534
|
-
/**
|
|
535
|
-
* Fixed base fee charged per operation, denominated in the SPL token's smallest unit.
|
|
536
|
-
*
|
|
537
|
-
* @remarks
|
|
538
|
-
* Added to the proportional BPS fee before clamping. A value of `10n` means 10
|
|
539
|
-
* token micro-units (e.g. 0.00001 USDC for a 6-decimal token).
|
|
540
|
-
*
|
|
541
|
-
* @readonly
|
|
542
|
-
*/
|
|
543
|
-
readonly BASE_FEE: 10n;
|
|
544
|
-
/**
|
|
545
|
-
* Proportional fee rate expressed in basis points (1 BPS = 0.01%).
|
|
546
|
-
*
|
|
547
|
-
* @remarks
|
|
548
|
-
* `35n` corresponds to 0.35%. Applied to the claimed or transferred amount before
|
|
549
|
-
* adding `BASE_FEE` and clamping to `[LOWER_BOUND, UPPER_BOUND]`.
|
|
550
|
-
*
|
|
551
|
-
* @readonly
|
|
552
|
-
*/
|
|
553
|
-
readonly BPS: 35n;
|
|
554
|
-
/**
|
|
555
|
-
* Minimum fee amount. The total fee is never less than this value.
|
|
556
|
-
*
|
|
557
|
-
* @remarks
|
|
558
|
-
* Currently `0n`, meaning there is no enforced minimum beyond the `BASE_FEE`.
|
|
559
|
-
*
|
|
560
|
-
* @readonly
|
|
561
|
-
*/
|
|
562
|
-
readonly LOWER_BOUND: 0n;
|
|
563
|
-
/**
|
|
564
|
-
* Maximum fee amount (cap). The total fee is never greater than this value.
|
|
565
|
-
*
|
|
566
|
-
* @remarks
|
|
567
|
-
* Set to `1_000_000n` (one million token micro-units), which equals 1 USDC for a
|
|
568
|
-
* 6-decimal token. This cap prevents runaway fees on very large claims.
|
|
569
|
-
*
|
|
570
|
-
* @readonly
|
|
571
|
-
*/
|
|
572
|
-
readonly UPPER_BOUND: bigint;
|
|
573
|
-
};
|
|
574
|
-
/**
|
|
575
|
-
* Default fee schedule applied to the relayer's commission on each claim or transfer
|
|
576
|
-
* instruction that involves a relayer.
|
|
577
|
-
*
|
|
578
|
-
* @remarks
|
|
579
|
-
* These values mirror the `RelayerFeesConfiguration` account associated with a specific
|
|
580
|
-
* relayer. The SDK uses them client-side for fee estimation and for constructing the
|
|
581
|
-
* `expected_fee` field that is verified on-chain during MPC computation.
|
|
582
|
-
*
|
|
583
|
-
* Note that `BASE_FEE` is `0n` for relayers by default — relayers are compensated
|
|
584
|
-
* entirely through the proportional BPS component, unlike the protocol which charges a
|
|
585
|
-
* fixed base fee on top of BPS.
|
|
586
|
-
*
|
|
587
|
-
* ## Fee formula
|
|
588
|
-
*
|
|
589
|
-
* ```
|
|
590
|
-
* relayerFee = clamp(BASE_FEE + floor(amount * BPS / BPS_DIVISOR), LOWER_BOUND, UPPER_BOUND)
|
|
591
|
-
* ```
|
|
592
|
-
*
|
|
593
|
-
* @example
|
|
594
|
-
* ```typescript
|
|
595
|
-
* import { RELAYER_FEE, BPS_DIVISOR } from "@umbra-privacy/sdk";
|
|
596
|
-
*
|
|
597
|
-
* function estimateRelayerFee(amount: bigint): bigint {
|
|
598
|
-
* const bpsFee = (amount * RELAYER_FEE.BPS) / BPS_DIVISOR;
|
|
599
|
-
* const rawFee = RELAYER_FEE.BASE_FEE + bpsFee;
|
|
600
|
-
* return rawFee > RELAYER_FEE.UPPER_BOUND ? RELAYER_FEE.UPPER_BOUND : rawFee;
|
|
601
|
-
* }
|
|
602
|
-
* ```
|
|
603
|
-
*
|
|
604
|
-
* @see {@link PROTOCOL_FEE} for the protocol's fee schedule.
|
|
605
|
-
* @see {@link BPS_DIVISOR} for the basis-point denominator.
|
|
606
|
-
* @public
|
|
607
|
-
*/
|
|
608
|
-
declare const RELAYER_FEE: {
|
|
609
|
-
/**
|
|
610
|
-
* Fixed base fee for relayer operations, denominated in the SPL token's smallest unit.
|
|
611
|
-
*
|
|
612
|
-
* @remarks
|
|
613
|
-
* `0n` — relayers do not charge a fixed base fee; they earn purely through BPS.
|
|
614
|
-
*
|
|
615
|
-
* @readonly
|
|
616
|
-
*/
|
|
617
|
-
readonly BASE_FEE: 0n;
|
|
618
|
-
/**
|
|
619
|
-
* Proportional fee rate for the relayer, expressed in basis points (1 BPS = 0.01%).
|
|
620
|
-
*
|
|
621
|
-
* @remarks
|
|
622
|
-
* `35n` corresponds to 0.35%. The relayer earns this percentage of the claimed amount
|
|
623
|
-
* as compensation for submitting and funding the MPC callback transaction.
|
|
624
|
-
*
|
|
625
|
-
* @readonly
|
|
626
|
-
*/
|
|
627
|
-
readonly BPS: 35n;
|
|
628
|
-
/**
|
|
629
|
-
* Minimum relayer fee. Currently `0n`.
|
|
630
|
-
*
|
|
631
|
-
* @readonly
|
|
632
|
-
*/
|
|
633
|
-
readonly LOWER_BOUND: 0n;
|
|
634
|
-
/**
|
|
635
|
-
* Maximum relayer fee (cap). `1_000_000n` token micro-units.
|
|
636
|
-
*
|
|
637
|
-
* @remarks
|
|
638
|
-
* Mirrors the protocol fee cap to ensure the combined fee never exceeds a predictable
|
|
639
|
-
* maximum, protecting users from paying unexpectedly large fees on large claims.
|
|
640
|
-
*
|
|
641
|
-
* @readonly
|
|
642
|
-
*/
|
|
643
|
-
readonly UPPER_BOUND: bigint;
|
|
644
|
-
};
|
|
645
|
-
/**
|
|
646
|
-
* Offset discriminators used when deriving PDAs for fee-related on-chain accounts.
|
|
647
|
-
*
|
|
648
|
-
* @remarks
|
|
649
|
-
* The Umbra program uses an `offset` field in PDA seeds to allow multiple independent
|
|
650
|
-
* instances of the same account type to coexist (e.g. multiple fee pools for future
|
|
651
|
-
* protocol versions). The offset is encoded as a `U128` little-endian byte array and
|
|
652
|
-
* appended as the final seed when calling `getProgramDerivedAddress`.
|
|
653
|
-
*
|
|
654
|
-
* All offsets are currently `0n` because the protocol uses a single canonical instance
|
|
655
|
-
* of each fee account type. Future upgrades may introduce non-zero offsets for versioned
|
|
656
|
-
* account sets.
|
|
657
|
-
*
|
|
658
|
-
* These values are passed directly to PDA derivation helpers such as
|
|
659
|
-
* `getProtocolOnlyUnifiedFeesPoolPda`, `getRelayerUnifiedFeesPoolPda`, and
|
|
660
|
-
* `getProtocolFeesConfigurationPda`.
|
|
661
|
-
*
|
|
662
|
-
* @example
|
|
663
|
-
* ```typescript
|
|
664
|
-
* import { FEE_OFFSETS } from "@umbra-privacy/sdk";
|
|
665
|
-
* import { getProtocolFeesConfigurationPda } from "@umbra-privacy/sdk/pda";
|
|
666
|
-
*
|
|
667
|
-
* const [feeConfigPda] = await getProtocolFeesConfigurationPda(
|
|
668
|
-
* instructionSeed as U128,
|
|
669
|
-
* mintAddress,
|
|
670
|
-
* FEE_OFFSETS.PROTOCOL_FEES_CONFIG as U128,
|
|
671
|
-
* programId,
|
|
672
|
-
* );
|
|
673
|
-
* ```
|
|
674
|
-
*
|
|
675
|
-
* @see {@link getProtocolOnlyUnifiedFeesPoolPda} for protocol-only pool PDA derivation.
|
|
676
|
-
* @see {@link getRelayerUnifiedFeesPoolPda} for relayer pool PDA derivation.
|
|
677
|
-
* @see {@link getProtocolFeesConfigurationPda} for fee config PDA derivation.
|
|
678
|
-
* @public
|
|
679
|
-
*/
|
|
680
|
-
declare const FEE_OFFSETS: {
|
|
681
|
-
/**
|
|
682
|
-
* Offset used in `UnifiedFeesPool` PDA derivation for the unified protocol fees pool.
|
|
683
|
-
*
|
|
684
|
-
* @remarks
|
|
685
|
-
* Passed as the final seed to `getProtocolOnlyUnifiedFeesPoolPda` and
|
|
686
|
-
* `getRelayerUnifiedFeesPoolPda`. Currently `0n`.
|
|
687
|
-
*
|
|
688
|
-
* @readonly
|
|
689
|
-
*/
|
|
690
|
-
readonly PROTOCOL_FEES_POOL: 0n;
|
|
691
|
-
/**
|
|
692
|
-
* Offset used in `ProtocolFeesConfiguration` PDA derivation.
|
|
693
|
-
*
|
|
694
|
-
* @remarks
|
|
695
|
-
* Passed as the final seed to `getProtocolFeesConfigurationPda`. Currently `0n`.
|
|
696
|
-
*
|
|
697
|
-
* @readonly
|
|
698
|
-
*/
|
|
699
|
-
readonly PROTOCOL_FEES_CONFIG: 0n;
|
|
700
|
-
/**
|
|
701
|
-
* Offset used in relayer fee configuration PDA derivation.
|
|
702
|
-
*
|
|
703
|
-
* @remarks
|
|
704
|
-
* Passed as the offset seed when looking up the relayer's fee configuration account.
|
|
705
|
-
* Currently `0n`.
|
|
706
|
-
*
|
|
707
|
-
* @readonly
|
|
708
|
-
*/
|
|
709
|
-
readonly RELAYER_FEES_CONFIG: 0n;
|
|
710
|
-
};
|
|
711
|
-
/**
|
|
712
|
-
* Denominator for basis-point fee calculations.
|
|
713
|
-
*
|
|
714
|
-
* @remarks
|
|
715
|
-
* Basis points (BPS) express a fee rate as an integer fraction of 10,000.
|
|
716
|
-
* For example, 35 BPS = 35 / 10,000 = 0.35%.
|
|
717
|
-
*
|
|
718
|
-
* To convert a BPS fee rate to a proportional fee amount:
|
|
719
|
-
* ```
|
|
720
|
-
* proportionalFee = floor(amount * bps / BPS_DIVISOR)
|
|
721
|
-
* ```
|
|
722
|
-
*
|
|
723
|
-
* Using integer division (`/` on `bigint`) automatically floors the result, which is
|
|
724
|
-
* the correct behaviour for fee deductions (always round down in favour of the user).
|
|
725
|
-
*
|
|
726
|
-
* @example
|
|
727
|
-
* ```typescript
|
|
728
|
-
* import { BPS_DIVISOR, PROTOCOL_FEE } from "@umbra-privacy/sdk";
|
|
729
|
-
*
|
|
730
|
-
* const amount = 1_000_000n; // 1 USDC in micro-units
|
|
731
|
-
* const proportionalFee = (amount * PROTOCOL_FEE.BPS) / BPS_DIVISOR;
|
|
732
|
-
* // proportionalFee = 1_000_000n * 35n / 10_000n = 3_500n (0.0035 USDC)
|
|
733
|
-
* ```
|
|
734
|
-
*
|
|
735
|
-
* @public
|
|
736
|
-
*/
|
|
737
|
-
declare const BPS_DIVISOR = 10000n;
|
|
738
321
|
|
|
739
|
-
export { AGGREGATED_HASH_INPUT_COUNT, ARCIUM_CLUSTER_SEED, ARCIUM_COMPUTATION_SEED, ARCIUM_COMP_DEF_SEED, ARCIUM_EXEC_POOL_SEED, ARCIUM_MEMPOOL_SEED, ARCIUM_MXE_ACCOUNT_SEED, ARCIUM_OFFSET_BUFFER_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
322
|
+
export { AGGREGATED_HASH_INPUT_COUNT, ARCIUM_CLUSTER_SEED, ARCIUM_COMPUTATION_SEED, ARCIUM_COMP_DEF_SEED, ARCIUM_EXEC_POOL_SEED, ARCIUM_MEMPOOL_SEED, ARCIUM_MXE_ACCOUNT_SEED, ARCIUM_OFFSET_BUFFER_SIZE, ASSOCIATED_TOKEN_PROGRAM_ID, CLAIM_DOMAINS, type ClaimDomainSeparators, type ClaimType, KMAC_512_OUTPUT_LENGTH, LINKER_ENCRYPTIONS_PER_LEAF, LINKER_KEYSTREAM_DOMAINS, RANDOM_FACTOR_DOMAINS, RESCUE_COMMITMENT_DOMAINS, RESCUE_ENCRYPTIONS_COUNT, SPL_TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, createClaimDomainSeparators };
|