@mycelium-sdk/core 0.1.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.
@@ -0,0 +1,1568 @@
1
+ import { PublicClient, Chain, Address, Hex, LocalAccount, Hash, WalletClient } from 'viem';
2
+ import { SmartAccount, BundlerClient, WebAuthnAccount, toCoinbaseSmartAccount } from 'viem/account-abstraction';
3
+
4
+ declare const SUPPORTED_CHAIN_IDS: number[];
5
+ type SupportedChainId = (typeof SUPPORTED_CHAIN_IDS)[number];
6
+
7
+ /**
8
+ * @internal
9
+ * @category Types
10
+ * Detailed token balance information
11
+ *
12
+ */
13
+ interface TokenBalance {
14
+ symbol: string;
15
+ totalBalance: bigint;
16
+ totalFormattedBalance: string;
17
+ chainBalances: Array<{
18
+ chainId: SupportedChainId;
19
+ balance: bigint;
20
+ formattedBalance: string;
21
+ }>;
22
+ }
23
+
24
+ /**
25
+ * Chain configuration
26
+ * Configuration for each supported chain
27
+ */
28
+ interface ChainConfig {
29
+ /** Chain ID */
30
+ chainId: (typeof SUPPORTED_CHAIN_IDS)[number];
31
+ /** RPC URL for the chain */
32
+ rpcUrl: string;
33
+ /** Bundler URL for the chain */
34
+ bundlerUrl: string;
35
+ }
36
+
37
+ /**
38
+ * Service for managing supported blockchain networks and their clients
39
+ *
40
+ * @internal
41
+ * @category Infrastructure
42
+ * @remarks
43
+ * Provides RPC and bundler URL access, creates {@link PublicClient} and {@link BundlerClient} instances
44
+ * Central point for chain-level configuration in the SDK
45
+ */
46
+ declare class ChainManager {
47
+ /** Public client for the configured chain */
48
+ private publicClient;
49
+ /** Chain configuration */
50
+ private chainConfigs;
51
+ /** Map of chain names to chain metadata */
52
+ private chainNames;
53
+ /**
54
+ * Initializes the chain manager with the given configuration
55
+ *
56
+ * @internal
57
+ * @param chains Configuration object for a supported chain
58
+ */
59
+ constructor(chains: ChainConfig);
60
+ /**
61
+ * Utility to validate if a string is a valid HTTP(S) URL
62
+ *
63
+ * @internal
64
+ * @param url Candidate URL
65
+ * @returns True if valid, false otherwise
66
+ */
67
+ private isValidUrl;
68
+ /**
69
+ * Returns a {@link PublicClient} for the given chain ID
70
+ *
71
+ * @internal
72
+ * @category Clients
73
+ * @param chainId Target chain ID
74
+ * @returns {@link PublicClient} instance
75
+ * @throws Error if client is not configured
76
+ */
77
+ getPublicClient(chainId: (typeof SUPPORTED_CHAIN_IDS)[number]): PublicClient;
78
+ /**
79
+ * Returns a {@link BundlerClient} for the given chain ID
80
+ *
81
+ * @internal
82
+ * @category Clients
83
+ * @param chainId Target chain ID
84
+ * @param account SmartAccount to bind to the bundler client
85
+ * @returns {@link BundlerClient} instance
86
+ * @throws Error if no bundler URL is configured
87
+ */
88
+ getBundlerClient(chainId: (typeof SUPPORTED_CHAIN_IDS)[number], account: SmartAccount): BundlerClient;
89
+ /**
90
+ * Returns the RPC URL for the given chain ID
91
+ *
92
+ * @internal
93
+ * @category URLs
94
+ * @param chainId Target chain ID
95
+ * @returns RPC URL string
96
+ * @throws Error if chain config is missing or URL is invalid
97
+ */
98
+ getRpcUrl(chainId: (typeof SUPPORTED_CHAIN_IDS)[number]): string;
99
+ /**
100
+ * Returns the bundler URL for the given chain ID
101
+ *
102
+ * @internal
103
+ * @category URLs
104
+ * @param chainId Target chain ID
105
+ * @returns Bundler URL string
106
+ * @throws Error if chain config is missing or URL is invalid
107
+ */
108
+ getBundlerUrl(chainId: (typeof SUPPORTED_CHAIN_IDS)[number]): string | undefined;
109
+ /**
110
+ * Returns the {@link Chain} object for the given chain ID
111
+ *
112
+ * @internal
113
+ * @category Info
114
+ * @param chainId Target chain ID
115
+ * @returns Chain metadata
116
+ * @throws Error if chain is not found
117
+ */
118
+ getChain(chainId: (typeof SUPPORTED_CHAIN_IDS)[number]): Chain;
119
+ /**
120
+ * Returns the currently configured supported chain ID
121
+ *
122
+ * @internal
123
+ * @category Info
124
+ * @returns Supported chain ID
125
+ */
126
+ getSupportedChain(): number;
127
+ /**
128
+ * Creates a {@link PublicClient} for a chain
129
+ *
130
+ * @internal
131
+ * @category Clients
132
+ * @param chain Chain configuration
133
+ * @returns PublicClient instance
134
+ */
135
+ private createPublicClient;
136
+ }
137
+
138
+ /**
139
+ * Asset identifier - can be a symbol (like 'usdc') or address
140
+ */
141
+ type AssetIdentifier = string | Address;
142
+
143
+ /**
144
+ * Transaction data for execution
145
+ * Raw transaction data for wallet execution
146
+ */
147
+ interface TransactionData {
148
+ /** Target contract address */
149
+ to: Address;
150
+ /** Encoded function call data */
151
+ data: Hex;
152
+ /** ETH value to send */
153
+ value?: bigint;
154
+ }
155
+
156
+ interface CoinbaseCDPAuthParams {
157
+ requestMethod: string;
158
+ requestHost: string;
159
+ requestPath: string;
160
+ expiresIn?: number;
161
+ }
162
+ /**
163
+ * The quote and session URL for a valid on-ramp operation
164
+ * @public
165
+ * @category Types
166
+ */
167
+ interface OnRampUrlResponse {
168
+ quote?: {
169
+ destinationNetwork: string;
170
+ exchangeRate: string;
171
+ fees: Array<{
172
+ amount: string;
173
+ currency: string;
174
+ type: string;
175
+ }>;
176
+ paymentCurrency: string;
177
+ paymentSubtotal: string;
178
+ paymentTotal: string;
179
+ purchaseAmount: string;
180
+ purchaseCurrency: string;
181
+ };
182
+ session?: {
183
+ onrampUrl: string;
184
+ };
185
+ }
186
+ interface OffRampUrlResponseSellingParams {
187
+ value: string;
188
+ currency: string;
189
+ }
190
+ /**
191
+ * Details and a URL link for a valid off-ramp operation
192
+ * @public
193
+ * @category Types
194
+ */
195
+ interface OffRampUrlResponse {
196
+ cashout_total: OffRampUrlResponseSellingParams;
197
+ cashout_subtotal: OffRampUrlResponseSellingParams;
198
+ sell_amount: OffRampUrlResponseSellingParams;
199
+ coinbase_fee: OffRampUrlResponseSellingParams;
200
+ quote_id: string;
201
+ offramp_url: string;
202
+ }
203
+ interface RampConfigPaymentMethod {
204
+ id: string;
205
+ }
206
+ interface RampConfigCountryWithMethods {
207
+ id: string;
208
+ subdivisions?: string[];
209
+ payment_methods?: RampConfigPaymentMethod[];
210
+ }
211
+ /**
212
+ * The list of countries and payment methods for on/off-ramp
213
+ * @public
214
+ * @category Types
215
+ */
216
+ interface RampConfigResponse {
217
+ countries: RampConfigCountryWithMethods[];
218
+ }
219
+
220
+ /**
221
+ * Abstract base class for smart wallet implementations
222
+ *
223
+ * @internal
224
+ * @category Wallets
225
+ * @remarks
226
+ * Provides the interface for ERC-4337 compatible wallets
227
+ * Extended by concrete classes such as {@link DefaultSmartWallet}
228
+ */
229
+ declare abstract class SmartWallet {
230
+ /** LocalAccount used for signing transactions on behalf of this smart wallet */
231
+ abstract signer: LocalAccount;
232
+ /**
233
+ * Returns the deployed or predicted address of this smart wallet
234
+ *
235
+ * @internal
236
+ * @category Addressing
237
+ * @remarks
238
+ * For undeployed wallets this returns the deterministic CREATE2 address
239
+ *
240
+ * @returns Promise resolving to the wallet Ethereum address
241
+ */
242
+ abstract getAddress(): Promise<Address>;
243
+ /**
244
+ * Retrieves balances for all supported tokens held by this smart wallet
245
+ *
246
+ * @internal
247
+ * @category Balances
248
+ * @returns Promise resolving to an array of {@link TokenBalance} entries
249
+ */
250
+ abstract getBalance(): Promise<TokenBalance[]>;
251
+ /**
252
+ * Executes a transaction through the smart wallet
253
+ *
254
+ * @internal
255
+ * @category Transactions
256
+ * @remarks
257
+ * Handles gas sponsorship and ERC-4337 UserOperation creation automatically
258
+ *
259
+ * @param transactionData Transaction data to execute
260
+ * @param chainId Target blockchain chain ID
261
+ * @returns Promise resolving to the transaction {@link Hash}
262
+ */
263
+ abstract send(transactionData: TransactionData, chainId: SupportedChainId): Promise<Hash>;
264
+ /**
265
+ * Executes a batch of transactions through the smart wallet
266
+ *
267
+ * @internal
268
+ * @category Transactions
269
+ * @remarks
270
+ * Transactions are executed in the order they are provided
271
+ * Handles gas sponsorship and ERC-4337 UserOperation creation automatically
272
+ *
273
+ * @param transactionData Array of transaction data objects
274
+ * @param chainId Target blockchain chain ID
275
+ * @returns Promise resolving to the transaction {@link Hash}
276
+ */
277
+ abstract sendBatch(transactionData: TransactionData[], chainId: SupportedChainId): Promise<Hash>;
278
+ /**
279
+ * Prepares transaction data for sending tokens to another address
280
+ *
281
+ * @internal
282
+ * @category Transactions
283
+ * @param amount Human-readable amount to send
284
+ * @param asset Token or asset identifier
285
+ * @param recipientAddress Destination address
286
+ * @returns Promise resolving to prepared {@link TransactionData}
287
+ */
288
+ abstract sendTokens(amount: number, asset: AssetIdentifier, recipientAddress: Address): Promise<TransactionData>;
289
+ /**
290
+ * Deposits funds into a selected protocol vault to start earning yield
291
+ *
292
+ * @internal
293
+ * @category Yield
294
+ * @param amount Amount to deposit in human-readable format
295
+ * @returns Promise resolving to a {@link VaultTxnResult}
296
+ */
297
+ abstract earn(amount: string): Promise<VaultTxnResult>;
298
+ /**
299
+ * Retrieves the balance of deposited funds in the selected protocol vault
300
+ *
301
+ * @internal
302
+ * @category Yield
303
+ * @returns Promise resolving to a {@link VaultBalance} or null if none
304
+ */
305
+ abstract getEarnBalance(): Promise<VaultBalance | null>;
306
+ /**
307
+ * Withdraws a specific amount of shares from the protocol vault
308
+ *
309
+ * @internal
310
+ * @category Yield
311
+ * @param amount Human-readable amount of shares to withdraw
312
+ * @returns Promise resolving to a {@link VaultTxnResult}
313
+ */
314
+ abstract withdraw(amount: string): Promise<VaultTxnResult>;
315
+ /**
316
+ * Funds the smart wallet with the specified amount of the specified token via Coinbase CDP on-ramp service
317
+ *
318
+ * @internal
319
+ * @category Ramp
320
+ *
321
+ * @remarks
322
+ * If Coinbase CDP is not initialized, the method will throw an error
323
+ *
324
+ * @param amount Amount of token that a user wants to purchase and top up his account with (e.g., `"100"`, `"1.5"`)
325
+ * @param redirectUrl URL to redirect to after the on-ramp is complete. It's required to be a valid URL
326
+ * @param purchaseCurrency Purchase currency (e.g., `"USDC"`, `"ETH"`). To get the ful list, visit ""
327
+ * @param paymentCurrency Payment currency (e.g., `"USD"`, `"EUR"`). To get the ful list, visit ""
328
+ * @param paymentMethod Payment method (e.g., `"CARD"`). To get the ful list, visit ""
329
+ * @param chain Chain name (e.g., `"base"`)
330
+ * @param country Country code (e.g., `"US"`)
331
+ *
332
+ *
333
+ * @returns A URL string to the on-ramp service
334
+ */
335
+ abstract topUp(amount: string, redirectUrl: string, purchaseCurrency?: string, paymentCurrency?: string, paymentMethod?: string, country?: string): Promise<OnRampUrlResponse>;
336
+ /**
337
+ * @internal
338
+ * Cash out funds from the smart wallet to a specified currency via Coinbase CDP off-ramp service
339
+ * @category Ramp
340
+ *
341
+ * @param country
342
+ * @param paymentMethod
343
+ * @param redirectUrl
344
+ * @param sellAmount
345
+ * @param cashoutCurrency
346
+ * @param sellCurrency
347
+ * @returns A URL string to the off-ramp service
348
+ *
349
+ */
350
+ abstract cashOut(country: string, paymentMethod: string, redirectUrl: string, sellAmount: string, cashoutCurrency?: string, sellCurrency?: string): Promise<OffRampUrlResponse>;
351
+ }
352
+
353
+ /**
354
+ * Base Protocol
355
+ *
356
+ * @internal
357
+ * @abstract
358
+ * @category Protocols
359
+ * @remarks
360
+ * Abstract class defining the contract for protocol integrations (e.g. Spark, Beefy, Aave, Morpho)
361
+ * Provides lifecycle hooks (`init`) and required methods for vault discovery, deposit, withdrawal,
362
+ * and balance tracking
363
+ *
364
+ * Generic parameters allow protocol-specific typing for vault info, balances, and transaction results
365
+ */
366
+ declare abstract class BaseProtocol<TVaultInfo extends VaultInfo = VaultInfo, TVaultBalance extends VaultBalance = VaultBalance, TVaultTxnResult extends VaultTxnResult = VaultTxnResult> {
367
+ /** Chain manager instance injected during initialization */
368
+ chainManager: ChainManager | undefined;
369
+ /**
370
+ * Initialize the protocol
371
+ * @param chainManager Chain manager for accessing RPC and bundler clients
372
+ */
373
+ abstract init(chainManager: ChainManager): Promise<void>;
374
+ /**
375
+ * Ensure the protocol has been initialized
376
+ * @throws Error if `init()` has not been called
377
+ */
378
+ protected ensureInitialized(): void;
379
+ /**
380
+ * Get all available vaults
381
+ * @returns List of vaults that support deposits
382
+ */
383
+ abstract getVaults(): Promise<TVaultInfo[]> | TVaultInfo[];
384
+ /**
385
+ * Get the best vault for deposits
386
+ * @returns Single vault considered optimal for deposit
387
+ */
388
+ abstract getBestVault(): Promise<TVaultInfo> | TVaultInfo;
389
+ /**
390
+ * Get a vault where funds may already be deposited
391
+ * @param smartWallet Wallet to check for existing deposits
392
+ * @returns Vault info if deposits exist, otherwise null
393
+ */
394
+ abstract fetchDepositedVaults(smartWallet: SmartWallet): Promise<TVaultInfo | null>;
395
+ /**
396
+ * Deposit funds into a vault
397
+ * @param amount Amount in human-readable format
398
+ * @param smartWallet Wallet executing the deposit
399
+ * @returns Result of the deposit transaction
400
+ */
401
+ abstract deposit(amount: string, smartWallet: SmartWallet): Promise<TVaultTxnResult>;
402
+ /**
403
+ * Withdraw funds from a vault
404
+ * @param amountInShares Amount of shares to withdraw
405
+ * @param smartWallet Wallet executing the withdrawal
406
+ * @returns Result of the withdrawal transaction
407
+ */
408
+ abstract withdraw(amountInShares: string, smartWallet: SmartWallet): Promise<TVaultTxnResult>;
409
+ /**
410
+ * Get deposited balance in a vault
411
+ * @param vaultInfo Vault info for a selected protocol
412
+ * @param walletAddress Wallet address to check the balance of
413
+ * @returns Balance of deposited funds
414
+ */
415
+ abstract getBalance(vaultInfo: TVaultInfo, walletAddress: Address): Promise<TVaultBalance>;
416
+ /**
417
+ * Approve a token for protocol use
418
+ * @param tokenAddress Token address
419
+ * @param spenderAddress Spender address
420
+ * @param amount Allowance amount in wei
421
+ * @param chainId Target chain ID
422
+ * @param account Account authorizing the approval
423
+ * @returns Transaction hash
424
+ */
425
+ protected approveToken(tokenAddress: Address, spenderAddress: Address, amount: bigint, chainId: SupportedChainId, account: LocalAccount): Promise<string>;
426
+ /**
427
+ * Check token allowance for a spender
428
+ * @param tokenAddress Token address
429
+ * @param spenderAddress Spender address
430
+ * @param walletAddress Wallet address granting allowance
431
+ * @param chainId Target chain ID
432
+ * @returns Current allowance amount
433
+ */
434
+ protected checkAllowance(tokenAddress: Address, spenderAddress: Address, walletAddress: Address, chainId: SupportedChainId): Promise<bigint>;
435
+ }
436
+
437
+ /**
438
+ * Base information that can be used to identify a protocol
439
+ */
440
+ interface ProtocolInfo {
441
+ id: string;
442
+ name: string;
443
+ website: string;
444
+ logo: string;
445
+ supportedChains: number[];
446
+ riskLevel: 'low' | 'medium' | 'high';
447
+ isPremium: boolean;
448
+ }
449
+ /**
450
+ * Interface with protocol information and instance object
451
+ */
452
+ interface Protocol {
453
+ instance: BaseProtocol;
454
+ info: ProtocolInfo;
455
+ }
456
+ /**
457
+ * The protocols router config that defines which protocols should be used for an integrator
458
+ */
459
+ interface ProtocolsRouterConfig {
460
+ riskLevel: 'low' | 'medium' | 'high';
461
+ minApy?: number;
462
+ apiKey?: string;
463
+ }
464
+ /**
465
+ * @internal
466
+ * The info about a protocol vault
467
+ * @category Types
468
+ * @remarks
469
+ * Generic type that shows the whole list of optional and mandatory fields for a protocol vault
470
+ */
471
+ interface VaultInfo {
472
+ id: string;
473
+ chain: string;
474
+ chainId?: number;
475
+ depositTokenAddress: Address;
476
+ depositTokenDecimals: number;
477
+ depositTokenSymbol?: string;
478
+ vaultAddress: Address;
479
+ earnTokenAddress?: Address;
480
+ earnTokenDecimals?: number;
481
+ earnTokenSymbol?: string;
482
+ metadata?: Record<string, number | string>;
483
+ }
484
+ /**
485
+ * @public
486
+ * The info about current user's balance in a protocol vault
487
+ * @category Types
488
+ * @remarks
489
+ * The generic type that shows fields that should be present in a protocol vault balance
490
+ */
491
+ interface VaultBalance {
492
+ /** amount of shares in a protocol vault based on a deposited amount */
493
+ shares: string;
494
+ /** amount of deposited tokens in a protocol vault (e.g. sUSDC)*/
495
+ depositedAmount: string;
496
+ /** info about a protocol vault where a user deposited funds */
497
+ vaultInfo: VaultInfo;
498
+ }
499
+ /**
500
+ * @public
501
+ * The result fields of a protocol vault related transaction
502
+ * @category Types
503
+ * @remarks
504
+ * The generic type that shows fields that should be present for each protocol vault related transaction
505
+ */
506
+ interface VaultTxnResult {
507
+ /** hash of the operation */
508
+ hash: string;
509
+ /** if an operation is successful or not */
510
+ success: boolean;
511
+ /** error message if an operation is not successful */
512
+ error?: string;
513
+ }
514
+
515
+ interface SparkVaultInfo extends VaultInfo {
516
+ id: string;
517
+ chain: string;
518
+ earnTokenAddress: Address;
519
+ earnTokenDecimals: number;
520
+ depositTokenSymbol: string;
521
+ earnTokenSymbol: string;
522
+ metadata?: {
523
+ apy?: number;
524
+ };
525
+ }
526
+ /**
527
+ * @public
528
+ * The result of a Spark vault deposit or withdrawal transaction
529
+ * @category Types
530
+ */
531
+ interface SparkVaultTxnResult {
532
+ /** the boolean value that indicates if the transaction was successful */
533
+ success: boolean;
534
+ /** hash of the operation */
535
+ hash: string;
536
+ }
537
+ /**
538
+ * @public
539
+ * The info about current user's balance in a Spark vault
540
+ * @category Types
541
+ */
542
+ interface SparkVaultBalance {
543
+ /** amount of shares in sUSDC token that user has in the Spark vault */
544
+ shares: string;
545
+ /**
546
+ * amount of deposited tokens + earned tokens
547
+ * @remarks
548
+ * To get the amount of earned tokens, you need to store all user's deposits and withdrawals
549
+ * on your side and then subtract the amount of deposited tokens from the `depositedAmount` */
550
+ depositedAmount: string;
551
+ /** detailed info about a Spark vault where a user deposited funds */
552
+ vaultInfo: SparkVaultInfo;
553
+ }
554
+
555
+ /**
556
+ * Abstract base class for smart wallet providers
557
+ *
558
+ * @internal
559
+ * @category Wallet Providers
560
+ * @remarks
561
+ * Defines the interface for factories that create and manage {@link SmartWallet} instances
562
+ * Extended by implementations such as {@link DefaultSmartWalletProvider}
563
+ */
564
+ declare abstract class SmartWalletProvider$1 {
565
+ /**
566
+ * Creates a new smart wallet instance that will be deployed on first transaction
567
+ *
568
+ * @internal
569
+ * @category Creation
570
+ * @remarks
571
+ * Address is calculated deterministically using owners and nonce
572
+ *
573
+ * @param params Wallet creation parameters
574
+ * @param params.owners Array of wallet owners (addresses or WebAuthn accounts)
575
+ * @param params.signer Local account used for signing
576
+ * @param params.nonce Optional nonce for address derivation, default 0
577
+ * @returns Promise resolving to a {@link SmartWallet} instance
578
+ */
579
+ abstract createWallet(params: {
580
+ owners: Array<Address | WebAuthnAccount>;
581
+ signer: LocalAccount;
582
+ nonce?: bigint;
583
+ }): Promise<SmartWallet>;
584
+ /**
585
+ * Returns a smart wallet instance for an already deployed contract
586
+ *
587
+ * @internal
588
+ * @category Retrieval
589
+ * @remarks
590
+ * Use when the wallet address is already known
591
+ *
592
+ * @param params Wallet retrieval parameters
593
+ * @param params.walletAddress Deployed smart wallet address
594
+ * @param params.signer Local account to operate the wallet
595
+ * @param params.ownerIndex Optional index of signer in the owners list, default 0
596
+ * @returns A {@link SmartWallet} instance
597
+ */
598
+ abstract getWallet(params: {
599
+ walletAddress: Address;
600
+ signer: LocalAccount;
601
+ ownerIndex?: number;
602
+ }): SmartWallet;
603
+ /**
604
+ * Predicts the deterministic address of a smart wallet
605
+ *
606
+ * @internal
607
+ * @category Addressing
608
+ * @remarks
609
+ * Uses CREATE2 with owners and nonce to calculate the wallet address
610
+ *
611
+ * @param params Prediction parameters
612
+ * @param params.owners Array of wallet owners (addresses or WebAuthn accounts)
613
+ * @param params.nonce Optional nonce, default 0
614
+ * @returns Promise resolving to the predicted {@link Address}
615
+ */
616
+ abstract getWalletAddress(params: {
617
+ owners: Array<Address | WebAuthnAccount>;
618
+ nonce?: bigint;
619
+ }): Promise<Address>;
620
+ }
621
+
622
+ /**
623
+ * Abstract base class for embedded wallet implementations
624
+ *
625
+ * @internal
626
+ * @category Wallets
627
+ * @remarks
628
+ * Provides a standard interface for embedded wallets (Privy, Dynamic, etc.)
629
+ * Can be used as a signer for smart wallets when the embedded wallet is an owner
630
+ */
631
+ declare abstract class EmbeddedWallet {
632
+ /** Ethereum address of the wallet */
633
+ readonly address: Address;
634
+ /** Optional provider-specific wallet identifier */
635
+ readonly walletId?: string;
636
+ /**
637
+ * Creates an embedded wallet instance
638
+ *
639
+ * @internal
640
+ * @param address Ethereum address of the wallet
641
+ * @param walletId Optional provider-specific identifier
642
+ */
643
+ constructor(address: Address, walletId?: string);
644
+ /**
645
+ * Returns a {@link LocalAccount} that can sign transactions and messages
646
+ *
647
+ * @internal
648
+ * @category Accounts
649
+ * @remarks
650
+ * Useful for smart wallet operations if the embedded wallet is included as an owner
651
+ *
652
+ * @returns Promise resolving to a {@link LocalAccount}
653
+ */
654
+ abstract account(): Promise<LocalAccount>;
655
+ /**
656
+ * Returns a {@link WalletClient} for interacting with contracts on a specific chain
657
+ *
658
+ * @internal
659
+ * @category Accounts
660
+ * @param chainId Target chain ID
661
+ * @returns Promise resolving to a {@link WalletClient} configured for the given chain
662
+ */
663
+ abstract walletClient(chainId: SupportedChainId): Promise<WalletClient>;
664
+ }
665
+
666
+ /**
667
+ * Abstract base class for embedded wallet providers
668
+ *
669
+ * @internal
670
+ * @category Wallet Providers
671
+ * @remarks
672
+ * Defines the interface for providers that manage {@link EmbeddedWallet} instances
673
+ * Extended by implementations such as {@link PrivyEmbeddedWalletProvider}
674
+ */
675
+ declare abstract class EmbeddedWalletProvider {
676
+ /**
677
+ * Creates a new embedded wallet instance
678
+ *
679
+ * @internal
680
+ * @category Creation
681
+ * @remarks
682
+ * Uses the provider’s infrastructure to provision a new embedded wallet ready for signing
683
+ *
684
+ * @returns Promise resolving to a new {@link EmbeddedWallet}
685
+ */
686
+ abstract createWallet(): Promise<EmbeddedWallet>;
687
+ /**
688
+ * Retrieves an existing embedded wallet by its unique identifier
689
+ *
690
+ * @internal
691
+ * @category Retrieval
692
+ * @remarks
693
+ * The wallet must have been created previously through this provider
694
+ *
695
+ * @param params Wallet retrieval parameters
696
+ * @param params.walletId Unique identifier for the embedded wallet
697
+ * @returns Promise resolving to an {@link EmbeddedWallet}
698
+ * @throws Error if no wallet with the specified ID exists
699
+ */
700
+ abstract getWallet(params: {
701
+ walletId: string;
702
+ }): Promise<EmbeddedWallet>;
703
+ }
704
+
705
+ /**
706
+ * Options for creating a smart wallet
707
+ * Parameters for creating a new smart wallet with specified owners and signer
708
+ */
709
+ type CreateSmartWalletOptions = {
710
+ owners: Array<Address | WebAuthnAccount>;
711
+ signer: LocalAccount;
712
+ nonce?: bigint;
713
+ };
714
+ /**
715
+ * Options for creating a wallet with embedded signer
716
+ * Parameters for creating both embedded and smart wallets, with embedded wallet automatically added as signer
717
+ */
718
+ type CreateWalletWithEmbeddedSignerOptions = {
719
+ owners?: Array<Address | WebAuthnAccount>;
720
+ embeddedWalletIndex?: number;
721
+ nonce?: bigint;
722
+ };
723
+ /**
724
+ * Options for retrieving a smart wallet with provided signer
725
+ * Parameters for getting an existing smart wallet using a provided LocalAccount signer
726
+ */
727
+ type GetSmartWalletOptions = {
728
+ signer: LocalAccount;
729
+ deploymentOwners?: Array<Address | WebAuthnAccount>;
730
+ signerOwnerIndex?: number;
731
+ walletAddress?: Address;
732
+ nonce?: bigint;
733
+ };
734
+ /**
735
+ * Options for retrieving an embedded wallet
736
+ * Parameters for getting an existing embedded wallet
737
+ */
738
+ type GetEmbeddedWalletOptions = {
739
+ walletId: string;
740
+ };
741
+ /**
742
+ * Options for retrieving a smart wallet with embedded wallet signer
743
+ * Parameters for getting an existing smart wallet using an embedded wallet as signer.
744
+ * If neither walletAddress nor deploymentOwners is provided, defaults to using the embedded wallet as single owner.
745
+ */
746
+ type GetSmartWalletWithEmbeddedSignerOptions = Omit<GetSmartWalletOptions, 'signer'> & GetEmbeddedWalletOptions;
747
+
748
+ /**
749
+ * Unified Wallet Provider class
750
+ *
751
+ * @internal
752
+ * @category Wallets
753
+ * @remarks
754
+ * Internal facade that composes an embedded wallet provider and a smart wallet provider
755
+ * and exposes higher-level creation/retrieval flows. Not exported from user's usage
756
+ *
757
+ * Used in a higher level class - {@link WalletNamespace}
758
+ *
759
+ * Typical flows:
760
+ * - Create embedded wallet only: {@link createEmbeddedWallet}
761
+ * - Create smart wallet only (you provide signer/owners): {@link createSmartWallet}
762
+ * - Create smart wallet with embedded wallet as signer: {@link createWalletWithEmbeddedSigner}
763
+ * - Get smart wallet using embedded wallet as signer: {@link getSmartWalletWithEmbeddedSigner}
764
+ * - Get smart wallet using a provided signer: {@link getSmartWallet}
765
+ */
766
+ declare class WalletProvider {
767
+ /**
768
+ * Embedded wallet provider instance
769
+ * @internal
770
+ */
771
+ readonly embeddedWalletProvider: EmbeddedWalletProvider;
772
+ /**
773
+ * Smart wallet provider instance
774
+ * @internal
775
+ */
776
+ readonly smartWalletProvider: SmartWalletProvider$1;
777
+ /**
778
+ * Creates a unified wallet provider
779
+ *
780
+ * @internal
781
+ * @param embeddedWalletProvider Provider for embedded wallet operations
782
+ * @param smartWalletProvider Provider for smart wallet operations
783
+ */
784
+ constructor(embeddedWalletProvider: EmbeddedWalletProvider, smartWalletProvider: SmartWalletProvider$1);
785
+ /**
786
+ * Creates an embedded wallet
787
+ *
788
+ * @internal
789
+ * @remarks
790
+ * Thin wrapper around the embedded wallet provider’s `createWallet`
791
+ *
792
+ * @returns Promise that resolves to the newly created {@link EmbeddedWallet}
793
+ */
794
+ createEmbeddedWallet(): Promise<EmbeddedWallet>;
795
+ /**
796
+ * Creates a smart wallet (you provide signer and owners)
797
+ *
798
+ * @internal
799
+ * @remarks
800
+ * Use when you already control a signer and want to create a smart
801
+ * wallet without creating an embedded wallet
802
+ *
803
+ * @param params Smart wallet creation parameters
804
+ * @param params.owners Owners array for the smart wallet (EVM addresses or WebAuthn owners)
805
+ * @param params.signer Signer (local account) used for transactions
806
+ * @param params.nonce Optional salt/nonce for deterministic address calculation (defaults to 0)
807
+ * @returns Promise that resolves to the created {@link SmartWallet}
808
+ */
809
+ createSmartWallet(params: CreateSmartWalletOptions): Promise<SmartWallet>;
810
+ /**
811
+ * Creates a smart wallet with an embedded wallet as signer
812
+ *
813
+ * @internal
814
+ * @remarks
815
+ * Creates an embedded wallet first, then inserts its address into the owners array
816
+ * and uses its account as the signer for the smart wallet. Default SDK option, embedded wallets manager is necessary to be provided
817
+ *
818
+ * @param params Optional creation parameters
819
+ * @param params.owners Optional additional owners. The embedded wallet address is inserted at the specified index
820
+ * @param params.embeddedWalletIndex Optional index where the embedded wallet address should be inserted (defaults to the end)
821
+ * @param params.nonce Optional salt/nonce for deterministic address calculation (defaults to 0)
822
+ * @returns Promise that resolves to the created {@link SmartWallet}
823
+ */
824
+ createWalletWithEmbeddedSigner(params?: CreateWalletWithEmbeddedSignerOptions): Promise<SmartWallet>;
825
+ /**
826
+ * Gets a smart wallet using an embedded wallet as the signer
827
+ *
828
+ * @internal
829
+ * @remarks
830
+ * Fetches an embedded wallet by `walletId` and uses it as signer.
831
+ * If neither `walletAddress` nor `deploymentOwners` is provided, defaults to using
832
+ * the embedded wallet as the single owner for deterministic address calculation
833
+ *
834
+ * @param params Retrieval parameters
835
+ * @param params.walletId Embedded wallet ID used to locate the signer wallet
836
+ * @param params.deploymentOwners Optional original deployment owners used for address calculation
837
+ * @param params.signerOwnerIndex Index of the signer in the **current** owners set (defaults to 0)
838
+ * @param params.walletAddress Optional explicit smart wallet address (skips calculation)
839
+ * @param params.nonce Optional nonce used during original creation
840
+ * @returns Promise that resolves to the {@link SmartWallet}
841
+ * @throws Error if the embedded wallet cannot be found
842
+ */
843
+ getSmartWalletWithEmbeddedSigner(params: GetSmartWalletWithEmbeddedSignerOptions): Promise<SmartWallet>;
844
+ /**
845
+ * Gets an existing embedded wallet by ID
846
+ *
847
+ * @internal
848
+ * @param params Retrieval parameters
849
+ * @param params.walletId Embedded wallet ID
850
+ * @returns Promise that resolves to the {@link EmbeddedWallet}, or `null/undefined` per provider’s contract
851
+ */
852
+ getEmbeddedWallet(params: GetEmbeddedWalletOptions): Promise<EmbeddedWallet>;
853
+ /**
854
+ * Gets a smart wallet using a provided signer
855
+ *
856
+ * @internal
857
+ * @remarks
858
+ * Use when you already control a `LocalAccount` signer
859
+ * Requires either:
860
+ * - `walletAddress`, or
861
+ * - `deploymentOwners` (+ optional `nonce`) to deterministically derive the address
862
+ *
863
+ * @param params Retrieval parameters
864
+ * @param params.signer Signer (local account)
865
+ * @param params.deploymentOwners Original deployment owners (required if `walletAddress` is not provided)
866
+ * @param params.signerOwnerIndex Index of `signer` within the **current** owners set (defaults to 0)
867
+ * @param params.walletAddress Explicit smart wallet address (skips calculation)
868
+ * @param params.nonce Optional nonce used during original creation
869
+ * @returns Promise that resolves to the {@link SmartWallet}
870
+ * @throws Error if neither `walletAddress` nor `deploymentOwners` is provided
871
+ */
872
+ getSmartWallet(params: GetSmartWalletOptions): Promise<SmartWallet>;
873
+ }
874
+
875
+ /**
876
+ * Public wallet namespace that exposes unified wallet operations
877
+ *
878
+ * @public
879
+ * @category Wallets creation and retrieval
880
+ * @remarks
881
+ * This class is returned by {@link MyceliumSDK} and provides a simplified
882
+ * interface for wallet creation and retrieval. Advanced functionality can be accessed through
883
+ * the underlying providers via the getters {@link embeddedWalletProvider} and
884
+ * {@link smartWalletProvider}
885
+ *
886
+ * Typical flows:
887
+ * - Create embedded wallet only: {@link createEmbeddedWallet}
888
+ * - Create smart wallet only (you provide signer/owners): {@link createSmartWallet}
889
+ * - Create smart wallet with embedded as signer: {@link createWalletWithEmbeddedSigner}
890
+ * - Get smart wallet using embedded as signer: {@link getSmartWalletWithEmbeddedSigner}
891
+ * - Get smart wallet using a provided signer: {@link getSmartWallet}
892
+ */
893
+ declare class WalletNamespace {
894
+ /**
895
+ * Internal provider facade that implements the actual logic
896
+ * @internal
897
+ */
898
+ private provider;
899
+ /**
900
+ * Creates a wallet namespace to manage embedded and smart wallets
901
+ * @param provider Unified provider that composes embedded & smart providers
902
+ */
903
+ constructor(provider: WalletProvider);
904
+ /**
905
+ * Direct access to the underlying embedded wallet provider
906
+ *
907
+ * @public
908
+ * @category Providers
909
+ * @remarks
910
+ * Useful when you need advanced functionality beyond the unified namespace. By default, you should use the unified namespace
911
+ *
912
+ * @returns The configured embedded wallet provider instance
913
+ */
914
+ get embeddedWalletProvider(): EmbeddedWalletProvider;
915
+ /**
916
+ * Direct access to the underlying smart wallet provider
917
+ *
918
+ * @public
919
+ * @category Providers
920
+ * @remarks
921
+ * Useful when you need advanced functionality beyond the unified namespace. By default, you should use the unified namespace
922
+ *
923
+ * @returns The configured smart wallet provider instance
924
+ */
925
+ get smartWalletProvider(): SmartWalletProvider$1;
926
+ /**
927
+ * Creates an embedded wallet
928
+ *
929
+ * @public
930
+ * @category Creation
931
+ * @remarks
932
+ * Thin wrapper around the embedded wallet provider’s `createWallet`
933
+ *
934
+ * @returns Promise that resolves to the newly created {@link EmbeddedWallet}
935
+ */
936
+ createEmbeddedWallet(): Promise<EmbeddedWallet>;
937
+ /**
938
+ * Creates a smart wallet (you provide signer and owners)
939
+ *
940
+ * @public
941
+ * @category Creation
942
+ * @remarks
943
+ * Use this when you already control a signer (e.g., `LocalAccount`) and want to
944
+ * create a smart wallet without creating an embedded wallet
945
+ *
946
+ * @param params Smart wallet creation parameters
947
+ * @param params.owners Owners for the smart wallet (addresses or WebAuthn public keys)
948
+ * @param params.signer Local account used for signing transactions
949
+ * @param params.nonce Optional nonce/salt for deterministic address generation (defaults to 0)
950
+ * @returns Promise that resolves to the created {@link SmartWallet}
951
+ */
952
+ createSmartWallet(params: CreateSmartWalletOptions): Promise<SmartWallet>;
953
+ /**
954
+ * Creates a smart wallet with an embedded wallet as signer
955
+ *
956
+ * @public
957
+ * @category Creation
958
+ * @remarks
959
+ * Creates an embedded wallet first, inserts its address into the owners array,
960
+ * and uses its account as the signer for the smart wallet
961
+ *
962
+ * @param params Optional creation parameters
963
+ * @param params.owners Optional additional owners. The embedded wallet address is inserted at the specified index
964
+ * @param params.embeddedWalletIndex Optional index at which to insert the embedded wallet address (defaults to end)
965
+ * @param params.nonce Optional nonce/salt for deterministic address generation (defaults to 0)
966
+ * @returns Promise that resolves to the created {@link SmartWallet}
967
+ */
968
+ createWalletWithEmbeddedSigner(params?: CreateWalletWithEmbeddedSignerOptions): Promise<SmartWallet>;
969
+ /**
970
+ * Gets a smart wallet using an embedded wallet as the signer
971
+ *
972
+ * @public
973
+ * @category Retrieval
974
+ * @remarks
975
+ * Looks up an embedded wallet by `walletId` and uses it as signer
976
+ * If neither `walletAddress` nor `deploymentOwners` is provided, defaults to using
977
+ * the embedded wallet as the single owner for deterministic address calculation
978
+ *
979
+ * @param params Retrieval parameters
980
+ * @param params.walletId Embedded wallet ID used to locate the signer wallet
981
+ * @param params.deploymentOwners Optional original deployment owners used for address calculation
982
+ * @param params.signerOwnerIndex Index of the signer within the **current** owners set (defaults to 0)
983
+ * @param params.walletAddress Optional explicit smart wallet address (skips calculation)
984
+ * @param params.nonce Optional nonce used during original creation
985
+ * @returns Promise that resolves to the {@link SmartWallet}
986
+ * @throws Error if the embedded wallet cannot be found
987
+ */
988
+ getSmartWalletWithEmbeddedSigner(params: GetSmartWalletWithEmbeddedSignerOptions): Promise<SmartWallet>;
989
+ /**
990
+ * Gets an existing embedded wallet by ID
991
+ *
992
+ * @public
993
+ * @category Retrieval
994
+ * @param params Retrieval parameters
995
+ * @param params.walletId Embedded wallet ID to retrieve
996
+ * @returns Promise that resolves to the {@link EmbeddedWallet} (or `null/undefined` per provider contract)
997
+ */
998
+ getEmbeddedWallet(params: GetEmbeddedWalletOptions): Promise<EmbeddedWallet>;
999
+ /**
1000
+ * Gets a smart wallet using a provided signer
1001
+ *
1002
+ * @public
1003
+ * @category Retrieval
1004
+ * @remarks
1005
+ * Use when you already control a signer. Requires either:
1006
+ * - `walletAddress`, or
1007
+ * - `deploymentOwners` (+ optional `nonce`) to derive the address
1008
+ *
1009
+ * @param params Retrieval parameters
1010
+ * @param params.signer Signer (local account)
1011
+ * @param params.deploymentOwners Original deployment owners (required if `walletAddress` is not provided)
1012
+ * @param params.signerOwnerIndex Index of the signer within the **current** owners set (defaults to 0)
1013
+ * @param params.walletAddress Explicit smart wallet address (skips calculation)
1014
+ * @param params.nonce Optional nonce used during original creation
1015
+ * @returns Promise that resolves to the {@link SmartWallet}
1016
+ * @throws Error if neither `walletAddress` nor `deploymentOwners` is provided
1017
+ */
1018
+ getSmartWallet(params: GetSmartWalletOptions): Promise<SmartWallet>;
1019
+ }
1020
+
1021
+ /**
1022
+ * Mycelium SDK configuration
1023
+ * Configuration object for initializing the Mycelium SDK
1024
+ * @category Types
1025
+ * @example
1026
+ * ```ts
1027
+ * {
1028
+ * walletsConfig: {
1029
+ * embeddedWalletConfig: {
1030
+ * provider: {
1031
+ * type: 'privy',
1032
+ * providerConfig: {
1033
+ * appId: process.env.NEXT_PUBLIC_PRIVY_APP_ID!,
1034
+ * appSecret: process.env.NEXT_PUBLIC_PRIVY_APP_SECRET!,
1035
+ * },
1036
+ * },
1037
+ * },
1038
+ * smartWalletConfig: {
1039
+ * provider: {
1040
+ * type: 'default',
1041
+ * },
1042
+ * },
1043
+ * },
1044
+ * chain: {
1045
+ * chainId: parseInt(process.env.NEXT_PUBLIC_CHAIN_ID!),
1046
+ * rpcUrl: process.env.NEXT_PUBLIC_RPC_URL!,
1047
+ * bundlerUrl: process.env.NEXT_PUBLIC_BUNDLER_URL!,
1048
+ * },
1049
+ * protocolsRouterConfig: {
1050
+ * riskLevel: 'low',
1051
+ * },
1052
+ * coinbaseCDPConfig: {
1053
+ * apiKeyId: process.env.NEXT_PUBLIC_COINBASE_CDP_API_KEY_ID!,
1054
+ * apiKeySecret: process.env.NEXT_PUBLIC_COINBASE_CDP_API_KEY_SECRET!,
1055
+ * },
1056
+ * }
1057
+ * ```
1058
+ */
1059
+ interface MyceliumSDKConfig {
1060
+ /**
1061
+ * Wallet configuration
1062
+ * @remarks
1063
+ * Settings for embedded wallets and smart account providers. Currently support only Privy provider with their API keys
1064
+ * */
1065
+ walletsConfig: WalletConfig;
1066
+ /**
1067
+ * Unique identifier for the SDK integrator
1068
+ * @remarks
1069
+ * Used for Coinbase CDP API, and internally for tracking the usage of the SDK
1070
+ */
1071
+ integratorId: string;
1072
+ /**
1073
+ * Chains to use for the SDK
1074
+ * @remarks
1075
+ * If no rpcUrl, bundlerUrl and chain id are not provided, the SDK will use Base chain by default and its public RPC and Bundler URLs
1076
+ * */
1077
+ chain?: ChainConfig;
1078
+ /**
1079
+ * Protocols router configuration with different protocol based params
1080
+ * @remarks
1081
+ * If an integrator is not provided any requirements, `low` risk level protocols will be used by default
1082
+ */
1083
+ protocolsRouterConfig?: ProtocolsRouterConfig;
1084
+ /**
1085
+ * Coinbase CDP configuration
1086
+ * @remarks
1087
+ * The configuration is used to interact with Coinbase CDP API
1088
+ * If the configuration is not provided, the Coinbase CDP functionality will be disabled.
1089
+ * Calling all Coinbase CDP related methods will throw an error
1090
+ * Currently used for on/off ramp functionality for a wallet
1091
+ */
1092
+ coinbaseCDPConfig?: CoinbaseCDPConfig;
1093
+ }
1094
+ /**
1095
+ * Coinbase CDP configuration
1096
+ * Configuration for Coinbase CDP API
1097
+ * @see {@link https://docs.cdp.coinbase.com/api-reference/v2/introduction} Coinbase CDP API documentation
1098
+ */
1099
+ interface CoinbaseCDPConfig {
1100
+ /**
1101
+ * Coinbase CDP API key ID */
1102
+ apiKeyId: string;
1103
+ /**
1104
+ * Coinbase CDP API key secret
1105
+ */
1106
+ apiKeySecret: string;
1107
+ }
1108
+ /**
1109
+ * Wallet configuration
1110
+ * Configuration for wallet providers
1111
+ */
1112
+ type WalletConfig = {
1113
+ /** Embedded wallet configuration */
1114
+ embeddedWalletConfig: EmbeddedWalletConfig;
1115
+ /** Smart wallet configuration for ERC-4337 infrastructure */
1116
+ smartWalletConfig: SmartWalletConfig;
1117
+ };
1118
+ /**
1119
+ * Embedded wallet configuration
1120
+ * Configuration for embedded wallets / signers
1121
+ */
1122
+ interface EmbeddedWalletConfig {
1123
+ /** Wallet provider for account creation, management, and signing */
1124
+ provider: EmbeddedWalletProviderConfig;
1125
+ }
1126
+ /**
1127
+ * Smart Wallet configuration
1128
+ * Configuration for ERC-4337 smart wallets.
1129
+ */
1130
+ interface SmartWalletConfig {
1131
+ /** Wallet provider for smart wallet management */
1132
+ provider: SmartWalletProvider;
1133
+ }
1134
+ /**
1135
+ * Smart wallet provider configurations
1136
+ * Union type supporting multiple wallet provider implementations
1137
+ */
1138
+ type SmartWalletProvider = DefaultSmartWalletProvider;
1139
+ /**
1140
+ * Default smart wallet provider configuration
1141
+ * Built-in provider smart wallet provider.
1142
+ */
1143
+ interface DefaultSmartWalletProvider {
1144
+ type: 'default';
1145
+ }
1146
+ /**
1147
+ * Embedded wallet provider configurations
1148
+ * Union type supporting multiple embedded wallet providers
1149
+ */
1150
+ type EmbeddedWalletProviderConfig = PrivyEmbeddedWalletProviderConfig;
1151
+ /** Privy embedded wallet provider configuration */
1152
+ interface PrivyEmbeddedWalletProviderConfig {
1153
+ /** Embedded wallet provider type */
1154
+ type: 'privy';
1155
+ /** Privy client provider config */
1156
+ providerConfig: {
1157
+ /** Privy params */
1158
+ appId: string;
1159
+ /** Privy party app secret */
1160
+ appSecret: string;
1161
+ };
1162
+ }
1163
+
1164
+ declare class CoinbaseCDP {
1165
+ private readonly apiKeyId;
1166
+ private readonly apiKeySecret;
1167
+ private readonly chainManager;
1168
+ private readonly integratorId;
1169
+ private readonly coinbaseCdpV2Hostname;
1170
+ private readonly coinbaseCdpV1Hostname;
1171
+ private readonly onRampUrlAuthParams;
1172
+ private readonly onRampConfigAuthParams;
1173
+ private readonly offRampUrlAuthParams;
1174
+ private readonly offRampConfigAuthParams;
1175
+ private readonly clientV2;
1176
+ private readonly clientV1;
1177
+ constructor(apiKeyId: string, apiKeySecret: string, integratorId: string, chainManager: ChainManager);
1178
+ private verifyParameters;
1179
+ /**
1180
+ * @internal
1181
+ * Generate a JWT token for a provided API endpoint and hostname to make a request after
1182
+ * @category Ramp
1183
+ *
1184
+ * @param authParams Authentication parameters
1185
+ * @returns JWT token
1186
+ * @throws Error if the JWT token generation fails
1187
+ */
1188
+ auth(authParams: CoinbaseCDPAuthParams): Promise<string>;
1189
+ /**
1190
+ * @internal
1191
+ * Return a on-ramp URL for the given parameters via Coinbase CDP V2 API
1192
+ * @category Ramp
1193
+ *
1194
+ * @param receiverAddress
1195
+ * @param redirectUrl
1196
+ * @param amount
1197
+ * @param purchaseCurrency
1198
+ * @param paymentCurrency
1199
+ * @param paymentMethod
1200
+ * @param country
1201
+ * @returns OnRampUrlResponse
1202
+ * @throws Error if redirect URL is not a valid URL
1203
+ * @throws CoinbaseCDPError if the request fails
1204
+ */
1205
+ getOnRampLink(receiverAddress: Address, redirectUrl: string, amount: string, purchaseCurrency?: string, paymentCurrency?: string, paymentMethod?: string, country?: string): Promise<OnRampUrlResponse>;
1206
+ /**
1207
+ * @internal
1208
+ * Current method return all supported countries and payment methods for on-ramp by Coinbase CDP
1209
+ * @category Ramp
1210
+ *
1211
+ * @returns Config with supported countries and payment methods for on-ramp
1212
+ * @throws If API returned an error
1213
+ */
1214
+ getOnRampConfig(): Promise<RampConfigResponse>;
1215
+ /**
1216
+ * @internal
1217
+ * Return a off-ramp URL for the given parameters via Coinbase CDP V1 API
1218
+ * @remarks
1219
+ * Use an integratorId as a partnerUserId in Coinbase CDP API
1220
+ * @category Ramp
1221
+ *
1222
+ * @param address
1223
+ * @param country
1224
+ * @param paymentMethod
1225
+ * @param redirectUrl
1226
+ * @param sellAmount
1227
+ * @param cashoutCurrency
1228
+ * @param sellCurrency
1229
+ * @returns OffRampUrlResponse
1230
+ * @throws Error if redirect URL is not a valid URL
1231
+ * @throws CoinbaseCDPError if the request fails
1232
+ */
1233
+ getOffRampLink(address: Address, country: string, paymentMethod: string, redirectUrl: string, sellAmount: string, cashoutCurrency?: string, sellCurrency?: string): Promise<OffRampUrlResponse>;
1234
+ /**
1235
+ * @internal
1236
+ * Current method return all supported countries and payment methods for off-ramp by Coinbase CDP
1237
+ * @category Ramp
1238
+ * @returns Config with supported countries and payment methods for off-ramp
1239
+ * @throws If API returned an error
1240
+ */
1241
+ getOffRampConfig(): Promise<RampConfigResponse>;
1242
+ }
1243
+
1244
+ /**
1245
+ * Default ERC-4337 smart wallet implementation. Implements main methods that a user can use to interact with DeFi protocols and use all related functionalities
1246
+ *
1247
+ * @public
1248
+ * @category Wallets operations
1249
+ * @remarks
1250
+ * Backed by Coinbase Smart Account and compatible with ERC-4337 UserOperations
1251
+ * Supports multi-owner wallets (EVM addresses or WebAuthn owners), gas-sponsored flows,
1252
+ * and cross-chain operations via {@link ChainManager}
1253
+ */
1254
+ declare class DefaultSmartWallet extends SmartWallet {
1255
+ /** Owners (EVM addresses or WebAuthn public keys) */
1256
+ private owners;
1257
+ /** Signer for transactions and UserOperations */
1258
+ private _signer;
1259
+ /** Index of signer within the owners array (undefined → default 0) */
1260
+ private signerOwnerIndex?;
1261
+ /** Known deployment address (if already deployed) */
1262
+ private deploymentAddress?;
1263
+ /** Network and client management */
1264
+ private chainManager;
1265
+ /** Nonce (salt) for deterministic address calculation */
1266
+ private nonce?;
1267
+ /** Selected protocol provider instance */
1268
+ private protocolProvider;
1269
+ /** Coinbase CDP instance to interact with Coinbase CDP API */
1270
+ private coinbaseCDP;
1271
+ /**
1272
+ * Creates a smart wallet instance
1273
+ *
1274
+ * @internal
1275
+ * @param owners Owners (addresses or WebAuthn accounts)
1276
+ * @param signer Local account used to sign
1277
+ * @param chainManager Chain/client manager
1278
+ * @param protocolProvider Protocol provider instance (selected upstream)
1279
+ * @param deploymentAddress Optional known deployment address
1280
+ * @param signerOwnerIndex Optional index of `signer` in owners (default 0)
1281
+ * @param nonce Optional salt for deterministic address calc (default 0)
1282
+ */
1283
+ constructor(owners: Array<Address | WebAuthnAccount>, signer: LocalAccount, chainManager: ChainManager, protocolProvider: Protocol['instance'], coinbaseCDP: CoinbaseCDP | null, deploymentAddress?: Address, signerOwnerIndex?: number, nonce?: bigint);
1284
+ /**
1285
+ * Returns the signer account for this smart wallet
1286
+ *
1287
+ * @public
1288
+ * @category Account
1289
+ * @remarks
1290
+ * Used to authorize UserOperations and on-chain transactions
1291
+ */
1292
+ get signer(): LocalAccount;
1293
+ /**
1294
+ * Resolves the smart wallet address
1295
+ *
1296
+ * @public
1297
+ * @category Account
1298
+ * @remarks
1299
+ * If `deploymentAddress` is known, returns it. Otherwise derives a deterministic address
1300
+ * via the factory (`getAddress`) using owners and `nonce` (CREATE2-style)
1301
+ *
1302
+ * @returns Promise that resolves to the wallet address
1303
+ * @throws Error if no supported chains are configured
1304
+ * @throws Error if an owner has an invalid type
1305
+ */
1306
+ getAddress(): Promise<`0x${string}`>;
1307
+ /**
1308
+ * Builds a Coinbase Smart Account for a specific chain
1309
+ *
1310
+ * @internal
1311
+ * @category Account
1312
+ * @param chainId Target chain ID
1313
+ * @returns Viem Coinbase Smart Account for the given chain
1314
+ */
1315
+ getCoinbaseSmartAccount(chainId: SupportedChainId): ReturnType<typeof toCoinbaseSmartAccount>;
1316
+ /**
1317
+ * Fetches balances (ETH + ERC-20) for a smart account across supported chains
1318
+ *
1319
+ * @public
1320
+ * @category Account
1321
+ * @returns Promise resolving to a list of {@link TokenBalance}
1322
+ */
1323
+ getBalance(): Promise<TokenBalance[]>;
1324
+ /**
1325
+ * Deposits into the selected protocol’s vault to start earning yield
1326
+ * @public
1327
+ * @category Earn
1328
+ * @remarks
1329
+ * The protocol is selected on the SDK initialization step
1330
+ * @param amount Human-readable amount string
1331
+ * @returns Transaction result for the deposit
1332
+ */
1333
+ earn(amount: string): Promise<VaultTxnResult>;
1334
+ /**
1335
+ * Reads current deposit balance from the selected protocol’s vault
1336
+ * Method to read the current deposit balance from the selected protocol’s vault for a smart account
1337
+ *
1338
+ * @public
1339
+ * @category Earn
1340
+ * @returns Vault balance or `null` if nothing deposited
1341
+ */
1342
+ getEarnBalance(): Promise<VaultBalance | null>;
1343
+ /**
1344
+ * Withdraws from the selected protocol’s vault
1345
+ * @public
1346
+ * @category Earn
1347
+ * @param amount Human-readable amount string
1348
+ * @returns Transaction result for the withdrawal
1349
+ * @throws Error if the withdrawal fails
1350
+ * @throws Error a user didn't deposit anything
1351
+ */
1352
+ withdraw(amount: string): Promise<VaultTxnResult>;
1353
+ /**
1354
+ * Builds a UserOperation and submits via the bundler, then waits for inclusion
1355
+
1356
+ *
1357
+ * @public
1358
+ * @category Transactions
1359
+ *
1360
+ * @param transactionData Transaction details (`to`, `value`, `data`)
1361
+ * @param chainId Target chain ID
1362
+ * @returns Promise that resolves to the UserOperation hash
1363
+ * @throws Error with a readable message if submission or inclusion fails
1364
+ */
1365
+ send(transactionData: TransactionData, chainId: SupportedChainId): Promise<Hash>;
1366
+ /**
1367
+ * Builds a UserOperation from several onchain transactions and submits via the bundler, then waits for inclusion
1368
+ *
1369
+ * @public
1370
+ * @category Transactions
1371
+ *
1372
+ * @param transactionData An array of calls to execute
1373
+ * @param chainId Target chain ID
1374
+ * @returns Promise that resolves to the UserOperation hash for the batch
1375
+ * @throws Error with a readable message if submission or inclusion fails
1376
+ */
1377
+ sendBatch(transactionData: TransactionData[], chainId: SupportedChainId): Promise<Hash>;
1378
+ /**
1379
+ * Funds the smart wallet with the specified amount of the specified token via Coinbase CDP on-ramp service
1380
+ *
1381
+ * @public
1382
+ * @category Ramp
1383
+ *
1384
+ * @remarks
1385
+ * If Coinbase CDP is not initialized, the method will throw an error. For more details, visit @see {@link https://docs.cdp.coinbase.com/api-reference/v2/rest-api/onramp/create-an-onramp-session}
1386
+ *
1387
+ * @param amount Amount of token that a user wants to purchase and top up his account with (e.g., `"100"`, `"1.5"`)
1388
+ * @param redirectUrl URL to redirect to after the on-ramp is complete. It's required to be a valid URL
1389
+ * @param purchaseCurrency Purchase currency (e.g., `"USDC"`, `"ETH"`)
1390
+ * @param paymentCurrency Payment currency (e.g., `"USD"`, `"EUR"`)
1391
+ * @param paymentMethod Payment method (e.g., `"CARD"`)
1392
+ * @param chain Chain name (e.g., `"base"`)
1393
+ * @param country Country code (e.g., `"US"`)
1394
+ *
1395
+ *
1396
+ * @returns @see {@link OnRampUrlResponse}
1397
+ */
1398
+ topUp(amount: string, redirectUrl: string, purchaseCurrency?: string, paymentCurrency?: string, paymentMethod?: string, country?: string): Promise<OnRampUrlResponse>;
1399
+ /**
1400
+ * Cashout token from smart wallet to fiat currency via Coinbase CDP off-ramp service
1401
+ *
1402
+ * @public
1403
+ * @category Ramp
1404
+ *
1405
+ * @remarks
1406
+ * If Coinbase CDP is not initialized, the method will throw an error. For more details, visit @see {@link https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/create-sell-quote}
1407
+ *
1408
+ * @param country Country code (e.g., `"US"`)
1409
+ * @param paymentMethod Payment method (e.g., `"CARD"`). To get the ful list, visit ""
1410
+ * @param redirectUrl URL to redirect to after the off-ramp is complete. It's required to be a valid URL
1411
+ * @param sellAmount Amount of token that a user wants to sell (e.g., `"100"`, `"1.5"`)
1412
+ * @param cashoutCurrency Cashout currency (e.g., `"USD"`, `"EUR"`). To get the ful list, visit ""
1413
+ * @param sellCurrency Sell currency (e.g., `"USDC"`, `"ETH"`). To get the ful list, visit ""
1414
+ *
1415
+ *
1416
+ * @returns @see {@link OffRampUrlResponse}
1417
+ */
1418
+ cashOut(country: string, paymentMethod: string, redirectUrl: string, sellAmount: string, cashoutCurrency?: string, sellCurrency?: string): Promise<OffRampUrlResponse>;
1419
+ /**
1420
+ * Send tokens from a smart account to another address
1421
+ *
1422
+ * @public
1423
+ * @category Transactions
1424
+ *
1425
+ * @param amount Human-readable amount (e.g., `1.5`)
1426
+ * @param asset Asset symbol (e.g., `"usdc"`, `"eth"`) or token address
1427
+ * @param recipientAddress Destination address
1428
+ * @returns Transaction data suitable for inclusion in a UserOperation/call
1429
+ * @throws Error if `recipientAddress` is missing, `amount` ≤ 0, or asset cannot be resolved
1430
+ */
1431
+ sendTokens(amount: number, asset: AssetIdentifier, recipientAddress: Address): Promise<TransactionData>;
1432
+ }
1433
+
1434
+ /**
1435
+ * Main SDK facade for integrating wallets and protocols.
1436
+ *
1437
+ * @public
1438
+ * @category Get started
1439
+ * @remarks
1440
+ * This class encapsulates:
1441
+ * - protocol selection and initialization (`Smart Router`),
1442
+ * - chain/network management (`ChainManager`),
1443
+ * - public wallet namespace (accessible through {@link MyceliumSDK.wallet | wallet}).
1444
+ *
1445
+ * By default, if no chain config is provided, it uses the public RPC
1446
+ * and Bundler for the Base chain
1447
+ *
1448
+ * @example
1449
+ * ```ts
1450
+ * import { MyceliumSDK, type MyceliumSDKConfig } from '@mycelium-sdk/core';
1451
+ *
1452
+ * const config: MyceliumSDKConfig = {
1453
+ * walletsConfig: { /* ... *\/ },
1454
+ * protocolsRouterConfig: { /* ... *\/ },
1455
+ * chain: { /* ... *\/ },
1456
+ * coinbaseCDPConfig: { /* ... *\/ },
1457
+ * integratorId: 'MyceliumApp',
1458
+ * };
1459
+ *
1460
+ * const sdk = new MyceliumSDK(config);
1461
+ *
1462
+ * const embeddedWallet = await sdk.wallet.createEmbeddedWallet();
1463
+ * const wallet = await sdk.wallet.createSmartWallet({
1464
+ * owners: [embeddedWallet.address],
1465
+ * signer: await embeddedWallet.account(),
1466
+ * })
1467
+ * const balance = await wallet.getBalance();
1468
+ * ```
1469
+ */
1470
+ declare class MyceliumSDK {
1471
+ /**
1472
+ * Unified wallet namespace to manage embedded/smart wallets and related operations
1473
+ * @public
1474
+ * @category Wallets
1475
+ */
1476
+ readonly wallet: WalletNamespace;
1477
+ /**
1478
+ * Chain manager instance to manage chain related entities
1479
+ * @internal
1480
+ */
1481
+ private _chainManager;
1482
+ /** @internal */
1483
+ private embeddedWalletProvider;
1484
+ /** @internal */
1485
+ private smartWalletProvider;
1486
+ /**
1487
+ * Protocol instance to perform earn related operations with a selected protocol
1488
+ * @internal
1489
+ */
1490
+ private protocol;
1491
+ /**
1492
+ * Coinbase CDP instance to Coinbase related and onchain operations using Coinbase CDP API
1493
+ * @remarks
1494
+ * If the configuration is not provided, the Coinbase CDP functionality will be disabled.
1495
+ * Calling the respective method will throw an error.
1496
+ * @internal
1497
+ */
1498
+ private coinbaseCDP;
1499
+ /**
1500
+ * Creates a new SDK instance
1501
+ *
1502
+ * @param config SDK configuration (networks, wallets, protocol router settings)
1503
+ * @throws Throws if an unsupported wallet provider is given
1504
+ * @see MyceliumSDKConfig
1505
+ */
1506
+ constructor(config: MyceliumSDKConfig);
1507
+ /**
1508
+ * Returns the chain manager instance for multi-chain operations
1509
+ * @public
1510
+ * @category Tools
1511
+ *
1512
+ * @returns ChainManager instance of the type {@link ChainManager}
1513
+ */
1514
+ get chainManager(): ChainManager;
1515
+ /**
1516
+ * Coinbase CDP configuration methods for ramp operations
1517
+ * @public
1518
+ * @category Tools
1519
+ */
1520
+ readonly rampConfig: {
1521
+ /**
1522
+ * Return all supported countries and payment methods for on-ramp by Coinbase CDP
1523
+ * @public
1524
+ * @category Ramp
1525
+ *
1526
+ * @returns @see {@link RampConfigResponse} with supported countries and payment methods for top-up
1527
+ * @throws If API returned an error
1528
+ */
1529
+ getTopUpConfig: () => Promise<RampConfigResponse>;
1530
+ /**
1531
+ * Return all supported countries and payment methods for off-ramp by Coinbase CDP
1532
+ * @public
1533
+ * @category Ramp
1534
+ *
1535
+ *
1536
+ * @returns @see {@link RampConfigResponse} with supported countries and payment methods for cash out
1537
+ * @throws If API returned an error
1538
+ */
1539
+ getCashOutConfig: () => Promise<RampConfigResponse>;
1540
+ };
1541
+ /**
1542
+ * Recommends and initializes a protocol based on router settings
1543
+ *
1544
+ * @internal
1545
+ * @param config Protocol router configuration (e.g. risk level)
1546
+ * @returns Selected protocol object of the type {@link Protocol}
1547
+ */
1548
+ private findProtocol;
1549
+ /**
1550
+ * Creates a wallet provider (embedded + smart) and combines them
1551
+ *
1552
+ * @internal
1553
+ * @param config Wallet configuration
1554
+ * @returns Configured {@link WalletProvider}
1555
+ * @throws If an unsupported wallet provider type is specified
1556
+ */
1557
+ private createWalletProvider;
1558
+ /**
1559
+ * Creates the public wallet namespace
1560
+ *
1561
+ * @internal
1562
+ * @param config Wallet configuration.
1563
+ * @returns A {@link WalletNamespace} instance
1564
+ */
1565
+ private createWalletNamespace;
1566
+ }
1567
+
1568
+ export { type OffRampUrlResponse as CashOutUrlResponse, DefaultSmartWallet, EmbeddedWallet, MyceliumSDK, type MyceliumSDKConfig, type RampConfigResponse, SmartWallet, type SparkVaultBalance, type SparkVaultTxnResult, type TokenBalance, type OnRampUrlResponse as TopUpUrlResponse, type VaultBalance, type VaultTxnResult, WalletNamespace };