@sip-protocol/sdk 0.7.2 → 0.7.3

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.
Files changed (50) hide show
  1. package/dist/browser.d.mts +1 -1
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +2926 -341
  4. package/dist/browser.mjs +48 -2
  5. package/dist/chunk-2XIVXWHA.mjs +1930 -0
  6. package/dist/chunk-3M3HNQCW.mjs +18253 -0
  7. package/dist/chunk-7RFRWDCW.mjs +1504 -0
  8. package/dist/chunk-F6F73W35.mjs +16166 -0
  9. package/dist/chunk-OFDBEIEK.mjs +16166 -0
  10. package/dist/chunk-SF7YSLF5.mjs +1515 -0
  11. package/dist/chunk-WWUSGOXE.mjs +17129 -0
  12. package/dist/index-8MQz13eJ.d.mts +13746 -0
  13. package/dist/index-B71aXVzk.d.ts +13264 -0
  14. package/dist/index-DIBZHOOQ.d.ts +13746 -0
  15. package/dist/index-pOIIuwfV.d.mts +13264 -0
  16. package/dist/index.d.mts +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +2911 -326
  19. package/dist/index.mjs +48 -2
  20. package/dist/solana-4O4K45VU.mjs +46 -0
  21. package/dist/solana-NDABAZ6P.mjs +56 -0
  22. package/dist/solana-ZYO63LY5.mjs +46 -0
  23. package/package.json +2 -2
  24. package/src/chains/solana/index.ts +24 -0
  25. package/src/chains/solana/providers/generic.ts +160 -0
  26. package/src/chains/solana/providers/helius.ts +249 -0
  27. package/src/chains/solana/providers/index.ts +54 -0
  28. package/src/chains/solana/providers/interface.ts +178 -0
  29. package/src/chains/solana/providers/webhook.ts +519 -0
  30. package/src/chains/solana/scan.ts +88 -8
  31. package/src/chains/solana/types.ts +20 -1
  32. package/src/compliance/index.ts +14 -0
  33. package/src/compliance/range-sas.ts +591 -0
  34. package/src/index.ts +99 -0
  35. package/src/privacy-backends/index.ts +86 -0
  36. package/src/privacy-backends/interface.ts +263 -0
  37. package/src/privacy-backends/privacycash-types.ts +278 -0
  38. package/src/privacy-backends/privacycash.ts +460 -0
  39. package/src/privacy-backends/registry.ts +278 -0
  40. package/src/privacy-backends/router.ts +346 -0
  41. package/src/privacy-backends/sip-native.ts +253 -0
  42. package/src/proofs/noir.ts +1 -1
  43. package/src/surveillance/algorithms/address-reuse.ts +143 -0
  44. package/src/surveillance/algorithms/cluster.ts +247 -0
  45. package/src/surveillance/algorithms/exchange.ts +295 -0
  46. package/src/surveillance/algorithms/temporal.ts +337 -0
  47. package/src/surveillance/analyzer.ts +442 -0
  48. package/src/surveillance/index.ts +64 -0
  49. package/src/surveillance/scoring.ts +372 -0
  50. package/src/surveillance/types.ts +264 -0
@@ -0,0 +1,278 @@
1
+ /**
2
+ * PrivacyCash SDK Type Definitions
3
+ *
4
+ * Type definitions for the `privacycash` npm package.
5
+ * These types are based on the SDK's public API.
6
+ *
7
+ * @see https://github.com/Privacy-Cash/privacy-cash-sdk
8
+ */
9
+
10
+ /**
11
+ * Supported pool sizes for SOL deposits (in lamports)
12
+ */
13
+ export const SOL_POOL_SIZES = {
14
+ /** 0.1 SOL pool */
15
+ SMALL: BigInt(100_000_000),
16
+ /** 1 SOL pool */
17
+ MEDIUM: BigInt(1_000_000_000),
18
+ /** 10 SOL pool */
19
+ LARGE: BigInt(10_000_000_000),
20
+ /** 100 SOL pool */
21
+ WHALE: BigInt(100_000_000_000),
22
+ } as const
23
+
24
+ /**
25
+ * Supported pool sizes for USDC deposits (in smallest units, 6 decimals)
26
+ */
27
+ export const USDC_POOL_SIZES = {
28
+ /** 10 USDC pool */
29
+ SMALL: BigInt(10_000_000),
30
+ /** 100 USDC pool */
31
+ MEDIUM: BigInt(100_000_000),
32
+ /** 1,000 USDC pool */
33
+ LARGE: BigInt(1_000_000_000),
34
+ /** 10,000 USDC pool */
35
+ WHALE: BigInt(10_000_000_000),
36
+ } as const
37
+
38
+ /**
39
+ * Supported pool sizes for USDT deposits (in smallest units, 6 decimals)
40
+ */
41
+ export const USDT_POOL_SIZES = {
42
+ /** 10 USDT pool */
43
+ SMALL: BigInt(10_000_000),
44
+ /** 100 USDT pool */
45
+ MEDIUM: BigInt(100_000_000),
46
+ /** 1,000 USDT pool */
47
+ LARGE: BigInt(1_000_000_000),
48
+ /** 10,000 USDT pool */
49
+ WHALE: BigInt(10_000_000_000),
50
+ } as const
51
+
52
+ /**
53
+ * All supported SOL pool amounts as array
54
+ */
55
+ export const SOL_POOL_AMOUNTS = [
56
+ SOL_POOL_SIZES.SMALL,
57
+ SOL_POOL_SIZES.MEDIUM,
58
+ SOL_POOL_SIZES.LARGE,
59
+ SOL_POOL_SIZES.WHALE,
60
+ ] as const
61
+
62
+ /**
63
+ * All supported SPL pool amounts as array
64
+ */
65
+ export const SPL_POOL_AMOUNTS = [
66
+ USDC_POOL_SIZES.SMALL,
67
+ USDC_POOL_SIZES.MEDIUM,
68
+ USDC_POOL_SIZES.LARGE,
69
+ USDC_POOL_SIZES.WHALE,
70
+ ] as const
71
+
72
+ /**
73
+ * Supported SPL tokens for PrivacyCash
74
+ */
75
+ export type PrivacyCashSPLToken = 'USDC' | 'USDT'
76
+
77
+ /**
78
+ * SPL token mint addresses on Solana mainnet
79
+ */
80
+ export const SPL_TOKEN_MINTS: Record<PrivacyCashSPLToken, string> = {
81
+ USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
82
+ USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
83
+ }
84
+
85
+ /**
86
+ * Configuration for PrivacyCash SDK connection
87
+ */
88
+ export interface PrivacyCashConfig {
89
+ /** Solana RPC endpoint URL */
90
+ rpcUrl: string
91
+ /** Network type */
92
+ network: 'mainnet-beta' | 'devnet'
93
+ /** Optional relayer URL for withdrawals */
94
+ relayerUrl?: string
95
+ }
96
+
97
+ /**
98
+ * Deposit parameters for SOL
99
+ */
100
+ export interface DepositParams {
101
+ /** Amount to deposit (must match a pool size) */
102
+ amount: bigint
103
+ /** Sender's keypair or wallet adapter */
104
+ wallet: unknown
105
+ }
106
+
107
+ /**
108
+ * Deposit parameters for SPL tokens
109
+ */
110
+ export interface DepositSPLParams extends DepositParams {
111
+ /** SPL token type */
112
+ token: PrivacyCashSPLToken
113
+ }
114
+
115
+ /**
116
+ * Withdrawal parameters for SOL
117
+ */
118
+ export interface WithdrawParams {
119
+ /** Amount to withdraw (must match deposit amount) */
120
+ amount: bigint
121
+ /** Recipient address */
122
+ recipient: string
123
+ /** ZK proof note from deposit */
124
+ note: string
125
+ }
126
+
127
+ /**
128
+ * Withdrawal parameters for SPL tokens
129
+ */
130
+ export interface WithdrawSPLParams extends WithdrawParams {
131
+ /** SPL token type */
132
+ token: PrivacyCashSPLToken
133
+ }
134
+
135
+ /**
136
+ * Deposit result
137
+ */
138
+ export interface DepositResult {
139
+ /** Transaction signature */
140
+ signature: string
141
+ /** Secret note for withdrawal (must be saved!) */
142
+ note: string
143
+ /** Pool the deposit went into */
144
+ poolSize: bigint
145
+ }
146
+
147
+ /**
148
+ * Withdrawal result
149
+ */
150
+ export interface WithdrawResult {
151
+ /** Transaction signature */
152
+ signature: string
153
+ /** Amount withdrawn */
154
+ amount: bigint
155
+ }
156
+
157
+ /**
158
+ * Pool information
159
+ */
160
+ export interface PoolInfo {
161
+ /** Pool size (deposit amount) */
162
+ size: bigint
163
+ /** Current number of deposits in pool (anonymity set) */
164
+ depositors: number
165
+ /** Total liquidity in pool */
166
+ liquidity: bigint
167
+ /** Whether pool has sufficient liquidity for withdrawal */
168
+ withdrawable: boolean
169
+ }
170
+
171
+ /**
172
+ * Private balance information
173
+ */
174
+ export interface PrivateBalance {
175
+ /** Total private balance */
176
+ total: bigint
177
+ /** Breakdown by pool size */
178
+ byPool: Array<{
179
+ poolSize: bigint
180
+ count: number
181
+ amount: bigint
182
+ }>
183
+ }
184
+
185
+ /**
186
+ * PrivacyCash SDK interface (mocked for type safety)
187
+ *
188
+ * The actual SDK requires Node 24+ and is not directly imported.
189
+ * This interface defines the expected API for our adapter.
190
+ */
191
+ export interface IPrivacyCashSDK {
192
+ /** Initialize connection */
193
+ connect(config: PrivacyCashConfig): Promise<void>
194
+
195
+ /** Deposit SOL into privacy pool */
196
+ deposit(params: DepositParams): Promise<DepositResult>
197
+
198
+ /** Withdraw SOL from privacy pool */
199
+ withdraw(params: WithdrawParams): Promise<WithdrawResult>
200
+
201
+ /** Get private SOL balance */
202
+ getPrivateBalance(address: string): Promise<PrivateBalance>
203
+
204
+ /** Deposit SPL token into privacy pool */
205
+ depositSPL(params: DepositSPLParams): Promise<DepositResult>
206
+
207
+ /** Withdraw SPL token from privacy pool */
208
+ withdrawSPL(params: WithdrawSPLParams): Promise<WithdrawResult>
209
+
210
+ /** Get private SPL token balance */
211
+ getPrivateBalanceSpl(
212
+ address: string,
213
+ token: PrivacyCashSPLToken
214
+ ): Promise<PrivateBalance>
215
+
216
+ /** Get pool information */
217
+ getPoolInfo(size: bigint, token?: PrivacyCashSPLToken): Promise<PoolInfo>
218
+ }
219
+
220
+ /**
221
+ * Find the closest matching pool size for an amount
222
+ *
223
+ * @param amount - The desired amount
224
+ * @param isSOL - Whether this is SOL (true) or SPL token (false)
225
+ * @returns The matching pool size or undefined if no match
226
+ */
227
+ export function findMatchingPoolSize(
228
+ amount: bigint,
229
+ isSOL: boolean
230
+ ): bigint | undefined {
231
+ const pools = isSOL ? SOL_POOL_AMOUNTS : SPL_POOL_AMOUNTS
232
+ return pools.find(pool => pool === amount)
233
+ }
234
+
235
+ /**
236
+ * Find the nearest pool size for an amount (for estimation)
237
+ *
238
+ * @param amount - The desired amount
239
+ * @param isSOL - Whether this is SOL (true) or SPL token (false)
240
+ * @returns The nearest pool size
241
+ */
242
+ export function findNearestPoolSize(amount: bigint, isSOL: boolean): bigint {
243
+ const pools = isSOL ? SOL_POOL_AMOUNTS : SPL_POOL_AMOUNTS
244
+
245
+ let nearest = pools[0]
246
+ let minDiff = amount > nearest ? amount - nearest : nearest - amount
247
+
248
+ for (const pool of pools) {
249
+ const diff = amount > pool ? amount - pool : pool - amount
250
+ if (diff < minDiff) {
251
+ minDiff = diff
252
+ nearest = pool
253
+ }
254
+ }
255
+
256
+ return nearest
257
+ }
258
+
259
+ /**
260
+ * Check if an amount matches any supported pool size
261
+ *
262
+ * @param amount - The amount to check
263
+ * @param isSOL - Whether this is SOL (true) or SPL token (false)
264
+ * @returns True if amount matches a pool size
265
+ */
266
+ export function isValidPoolAmount(amount: bigint, isSOL: boolean): boolean {
267
+ return findMatchingPoolSize(amount, isSOL) !== undefined
268
+ }
269
+
270
+ /**
271
+ * Get all available pool sizes for a token type
272
+ *
273
+ * @param isSOL - Whether this is SOL (true) or SPL token (false)
274
+ * @returns Array of pool sizes
275
+ */
276
+ export function getAvailablePoolSizes(isSOL: boolean): readonly bigint[] {
277
+ return isSOL ? SOL_POOL_AMOUNTS : SPL_POOL_AMOUNTS
278
+ }