@dynamic-labs-wallet/node-evm 1.1.52 → 1.1.54

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/index.cjs CHANGED
@@ -423,6 +423,347 @@ const createAccountAdapter = ({ evmClient, walletMetadata, password, externalSer
423
423
  });
424
424
  };
425
425
 
426
+ function _object_without_properties_loose(source, excluded) {
427
+ if (source == null) return {};
428
+ var target = {};
429
+ var sourceKeys = Object.keys(source);
430
+ var key, i;
431
+ for(i = 0; i < sourceKeys.length; i++){
432
+ key = sourceKeys[i];
433
+ if (excluded.indexOf(key) >= 0) continue;
434
+ target[key] = source[key];
435
+ }
436
+ return target;
437
+ }
438
+
439
+ const ERROR_EARN_NOT_EVM_WALLET = 'Wallet metadata is not for an EVM wallet';
440
+ const ERROR_EARN_MISSING_EVM_TRANSACTION = 'Earn signing payload is missing EVM transaction data';
441
+ const ERROR_EARN_CHAIN_MISMATCH = 'The provided chain does not match the chain the Earn transaction was prepared for';
442
+ const ERROR_EARN_APPROVAL_FAILED = 'The ERC-20 approval for the Earn transaction reverted';
443
+ const ERROR_EARN_CHAIN_REQUIRED = 'Either chain or rpcUrl is required to execute an Earn transaction. Provide an RPC URL for the vault chain.';
444
+ /**
445
+ * Vault deposits and withdrawals rebalance the underlying lending markets, so gas estimated at
446
+ * the current block is regularly lower than what execution needs once the transaction is mined.
447
+ */ const EARN_GAS_LIMIT_BUFFER_PERCENT = 30n;
448
+ const ERC20_ALLOWANCE_AND_APPROVE_ABI = [
449
+ {
450
+ name: 'allowance',
451
+ type: 'function',
452
+ stateMutability: 'view',
453
+ inputs: [
454
+ {
455
+ name: 'owner',
456
+ type: 'address'
457
+ },
458
+ {
459
+ name: 'spender',
460
+ type: 'address'
461
+ }
462
+ ],
463
+ outputs: [
464
+ {
465
+ name: '',
466
+ type: 'uint256'
467
+ }
468
+ ]
469
+ },
470
+ {
471
+ name: 'approve',
472
+ type: 'function',
473
+ stateMutability: 'nonpayable',
474
+ inputs: [
475
+ {
476
+ name: 'spender',
477
+ type: 'address'
478
+ },
479
+ {
480
+ name: 'amount',
481
+ type: 'uint256'
482
+ }
483
+ ],
484
+ outputs: [
485
+ {
486
+ name: '',
487
+ type: 'bool'
488
+ }
489
+ ]
490
+ }
491
+ ];
492
+
493
+ /**
494
+ * Builds a stateless Earn client for EVM vaults: it prepares vault actions through the
495
+ * Dynamic API and executes the returned unsigned transactions with the caller's wallet,
496
+ * sending an ERC-20 approval first when the vault requires one.
497
+ */ const createEvmEarnClient = ({ getEarnClient, createViemPublicClient, getWalletClient, sendSponsoredTransaction })=>{
498
+ const resolveChain = ({ chain, chainId, rpcUrl })=>{
499
+ if (chain) {
500
+ if (chain.id !== chainId) {
501
+ throw new Error(ERROR_EARN_CHAIN_MISMATCH);
502
+ }
503
+ return chain;
504
+ }
505
+ if (!rpcUrl) {
506
+ throw new Error(ERROR_EARN_CHAIN_REQUIRED);
507
+ }
508
+ return viem.defineChain({
509
+ id: chainId,
510
+ name: `Chain ${chainId}`,
511
+ nativeCurrency: {
512
+ name: 'Ether',
513
+ symbol: 'ETH',
514
+ decimals: 18
515
+ },
516
+ rpcUrls: {
517
+ default: {
518
+ http: [
519
+ rpcUrl
520
+ ]
521
+ }
522
+ }
523
+ });
524
+ };
525
+ const buildGasLimitAndNonce = async ({ transaction, publicClient, accountAddress })=>{
526
+ const params = {};
527
+ if (transaction.gasLimit) {
528
+ params.gas = BigInt(transaction.gasLimit);
529
+ } else {
530
+ const estimatedGas = await publicClient.estimateGas({
531
+ account: accountAddress,
532
+ to: transaction.to,
533
+ data: transaction.data,
534
+ value: transaction.value
535
+ });
536
+ params.gas = estimatedGas + estimatedGas * EARN_GAS_LIMIT_BUFFER_PERCENT / 100n;
537
+ }
538
+ if (transaction.nonce !== undefined) {
539
+ params.nonce = transaction.nonce;
540
+ }
541
+ return params;
542
+ };
543
+ const relaySponsoredEarnTransaction = async ({ chainId, evmApproval, evmTransaction, externalServerKeyShares, onStepChange, password, publicClient, resolvedChain, rpcUrl, traceContext, walletMetadata })=>{
544
+ const calls = [];
545
+ if (evmApproval) {
546
+ const currentAllowance = await publicClient.readContract({
547
+ address: evmApproval.tokenAddress,
548
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
549
+ functionName: 'allowance',
550
+ args: [
551
+ walletMetadata.accountAddress,
552
+ evmApproval.spenderAddress
553
+ ]
554
+ });
555
+ const requiredAllowance = BigInt(evmApproval.amount);
556
+ if (currentAllowance < requiredAllowance) {
557
+ onStepChange == null ? void 0 : onStepChange('approval');
558
+ calls.push({
559
+ target: evmApproval.tokenAddress,
560
+ data: viem.encodeFunctionData({
561
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
562
+ functionName: 'approve',
563
+ args: [
564
+ evmApproval.spenderAddress,
565
+ requiredAllowance
566
+ ]
567
+ }),
568
+ value: 0n
569
+ });
570
+ }
571
+ }
572
+ onStepChange == null ? void 0 : onStepChange('transaction');
573
+ calls.push({
574
+ target: evmTransaction.to,
575
+ data: evmTransaction.data,
576
+ value: evmTransaction.value ? BigInt(evmTransaction.value) : 0n
577
+ });
578
+ return sendSponsoredTransaction({
579
+ walletMetadata,
580
+ calls,
581
+ chainId,
582
+ password,
583
+ externalServerKeyShares,
584
+ // The relayer needs an RPC to read the wallet's on-chain state; fall back to the
585
+ // resolved chain's default when the caller passed `chain` without `rpcUrl`.
586
+ rpcUrl: rpcUrl != null ? rpcUrl : resolvedChain.rpcUrls.default.http[0],
587
+ traceContext,
588
+ autoDelegate: true
589
+ });
590
+ };
591
+ const executeEarnTransaction = async ({ signingPayload, traceContext, walletMetadata, password, externalServerKeyShares, sponsored, chain, rpcUrl, onStepChange })=>{
592
+ if (walletMetadata.chainName !== 'EVM') {
593
+ throw new Error(ERROR_EARN_NOT_EVM_WALLET);
594
+ }
595
+ const { evmTransaction, evmApproval } = signingPayload;
596
+ if (!evmTransaction) {
597
+ throw new Error(ERROR_EARN_MISSING_EVM_TRANSACTION);
598
+ }
599
+ const chainId = Number(signingPayload.chainId);
600
+ const resolvedChain = resolveChain({
601
+ chain,
602
+ chainId,
603
+ rpcUrl
604
+ });
605
+ const publicClient = createViemPublicClient({
606
+ chain: resolvedChain,
607
+ rpcUrl
608
+ });
609
+ // Sponsored execution relays the approval and vault call as one batch through the
610
+ // gasless relayer, so no gas estimation or EOA sending is needed.
611
+ if (sponsored === true) {
612
+ return relaySponsoredEarnTransaction({
613
+ chainId,
614
+ evmApproval,
615
+ evmTransaction,
616
+ externalServerKeyShares,
617
+ onStepChange,
618
+ password,
619
+ publicClient,
620
+ resolvedChain,
621
+ rpcUrl,
622
+ traceContext,
623
+ walletMetadata
624
+ });
625
+ }
626
+ const walletClient = await getWalletClient({
627
+ walletMetadata,
628
+ password,
629
+ externalServerKeyShares,
630
+ chain: resolvedChain,
631
+ rpcUrl
632
+ });
633
+ if (evmApproval) {
634
+ const currentAllowance = await publicClient.readContract({
635
+ address: evmApproval.tokenAddress,
636
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
637
+ functionName: 'allowance',
638
+ args: [
639
+ walletMetadata.accountAddress,
640
+ evmApproval.spenderAddress
641
+ ]
642
+ });
643
+ const requiredAllowance = BigInt(evmApproval.amount);
644
+ if (currentAllowance < requiredAllowance) {
645
+ onStepChange == null ? void 0 : onStepChange('approval');
646
+ const approvalHash = await walletClient.sendTransaction({
647
+ to: evmApproval.tokenAddress,
648
+ data: viem.encodeFunctionData({
649
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
650
+ functionName: 'approve',
651
+ args: [
652
+ evmApproval.spenderAddress,
653
+ requiredAllowance
654
+ ]
655
+ }),
656
+ value: 0n
657
+ });
658
+ const approvalReceipt = await publicClient.waitForTransactionReceipt({
659
+ hash: approvalHash
660
+ });
661
+ if (approvalReceipt.status !== 'success') {
662
+ throw new Error(ERROR_EARN_APPROVAL_FAILED);
663
+ }
664
+ }
665
+ }
666
+ onStepChange == null ? void 0 : onStepChange('transaction');
667
+ let value = 0n;
668
+ if (evmTransaction.value) {
669
+ value = BigInt(evmTransaction.value);
670
+ }
671
+ const gasLimitAndNonce = await buildGasLimitAndNonce({
672
+ transaction: _extends({}, evmTransaction, {
673
+ value
674
+ }),
675
+ publicClient,
676
+ accountAddress: walletMetadata.accountAddress
677
+ });
678
+ const request = _extends({
679
+ to: evmTransaction.to,
680
+ data: evmTransaction.data,
681
+ value
682
+ }, gasLimitAndNonce);
683
+ const hasEip1559Fees = Boolean(evmTransaction.maxFeePerGas && evmTransaction.maxPriorityFeePerGas);
684
+ if (hasEip1559Fees) {
685
+ const transactionHash = await walletClient.sendTransaction(_extends({}, request, {
686
+ maxFeePerGas: BigInt(evmTransaction.maxFeePerGas),
687
+ maxPriorityFeePerGas: BigInt(evmTransaction.maxPriorityFeePerGas)
688
+ }));
689
+ return {
690
+ transactionHash
691
+ };
692
+ }
693
+ if (evmTransaction.gasPrice) {
694
+ const transactionHash = await walletClient.sendTransaction(_extends({}, request, {
695
+ gasPrice: BigInt(evmTransaction.gasPrice)
696
+ }));
697
+ return {
698
+ transactionHash
699
+ };
700
+ }
701
+ const transactionHash = await walletClient.sendTransaction(request);
702
+ return {
703
+ transactionHash
704
+ };
705
+ };
706
+ const depositToEarnVault = async (_param)=>{
707
+ var { vaultId, amount, receiverAddress, traceContext } = _param, walletParams = _object_without_properties_loose(_param, [
708
+ "vaultId",
709
+ "amount",
710
+ "receiverAddress",
711
+ "traceContext"
712
+ ]);
713
+ const signingPayload = await getEarnClient().prepareDeposit({
714
+ vaultId,
715
+ ownerAddress: walletParams.walletMetadata.accountAddress,
716
+ amount,
717
+ receiverAddress,
718
+ traceContext
719
+ });
720
+ return executeEarnTransaction(_extends({
721
+ signingPayload,
722
+ traceContext
723
+ }, walletParams));
724
+ };
725
+ const withdrawFromEarnVault = async (_param)=>{
726
+ var { vaultId, amount, receiverAddress, traceContext } = _param, walletParams = _object_without_properties_loose(_param, [
727
+ "vaultId",
728
+ "amount",
729
+ "receiverAddress",
730
+ "traceContext"
731
+ ]);
732
+ const signingPayload = await getEarnClient().prepareWithdrawal({
733
+ vaultId,
734
+ ownerAddress: walletParams.walletMetadata.accountAddress,
735
+ amount,
736
+ receiverAddress,
737
+ traceContext
738
+ });
739
+ return executeEarnTransaction(_extends({
740
+ signingPayload,
741
+ traceContext
742
+ }, walletParams));
743
+ };
744
+ const claimEarnRewards = async (_param)=>{
745
+ var { vaultId, traceContext } = _param, walletParams = _object_without_properties_loose(_param, [
746
+ "vaultId",
747
+ "traceContext"
748
+ ]);
749
+ const signingPayload = await getEarnClient().prepareClaimRewards({
750
+ vaultId,
751
+ ownerAddress: walletParams.walletMetadata.accountAddress,
752
+ traceContext
753
+ });
754
+ return executeEarnTransaction(_extends({
755
+ signingPayload,
756
+ traceContext
757
+ }, walletParams));
758
+ };
759
+ return {
760
+ executeEarnTransaction,
761
+ depositToEarnVault,
762
+ withdrawFromEarnVault,
763
+ claimEarnRewards
764
+ };
765
+ };
766
+
426
767
  /** The Fireblocks Universal Gasless Delegate (UGD) contract address used for EIP-7702 delegation. */ const DELEGATION_CONTRACT_ADDRESS = '0x0000Fb7702036ff9f76044a501ac1aA74cbab16b';
427
768
  /** Default sponsored transaction validity duration in seconds (10 minutes). */ const DEFAULT_VALID_FOR_SECONDS = 600;
428
769
  /** EIP-7702 delegation code prefix used to identify delegated accounts. */ const DELEGATION_CODE_PREFIX = '0xef0100';
@@ -1325,6 +1666,32 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
1325
1666
  */ async waitForSponsoredTransaction(params) {
1326
1667
  return this.evmGasless.waitForSponsoredTransaction(params);
1327
1668
  }
1669
+ // ---------------------------------------------------------------------------
1670
+ // Earn (yield vaults)
1671
+ // ---------------------------------------------------------------------------
1672
+ get evmEarn() {
1673
+ return createEvmEarnClient({
1674
+ getEarnClient: ()=>this.earn,
1675
+ createViemPublicClient: (args)=>this.createViemPublicClient(args),
1676
+ getWalletClient: (args)=>this.getWalletClient(args),
1677
+ sendSponsoredTransaction: (args)=>this.sendSponsoredTransaction(args)
1678
+ });
1679
+ }
1680
+ /**
1681
+ * Executes an Earn signing payload returned by the prepare* methods, sending the
1682
+ * ERC-20 approval first when the vault requires one.
1683
+ */ async executeEarnTransaction(params) {
1684
+ return this.evmEarn.executeEarnTransaction(params);
1685
+ }
1686
+ /** Prepares and executes a deposit into an Earn vault. */ async depositToEarnVault(params) {
1687
+ return this.evmEarn.depositToEarnVault(params);
1688
+ }
1689
+ /** Prepares and executes a withdrawal from an Earn vault. */ async withdrawFromEarnVault(params) {
1690
+ return this.evmEarn.withdrawFromEarnVault(params);
1691
+ }
1692
+ /** Prepares and executes a claim of accrued Earn vault rewards. */ async claimEarnRewards(params) {
1693
+ return this.evmEarn.claimEarnRewards(params);
1694
+ }
1328
1695
  constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, enableMPCAccelerator, logger }){
1329
1696
  super({
1330
1697
  environmentId,
@@ -1337,19 +1704,6 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
1337
1704
  }
1338
1705
  }
1339
1706
 
1340
- function _object_without_properties_loose(source, excluded) {
1341
- if (source == null) return {};
1342
- var target = {};
1343
- var sourceKeys = Object.keys(source);
1344
- var key, i;
1345
- for(i = 0; i < sourceKeys.length; i++){
1346
- key = sourceKeys[i];
1347
- if (excluded.indexOf(key) >= 0) continue;
1348
- target[key] = source[key];
1349
- }
1350
- return target;
1351
- }
1352
-
1353
1707
  const logError = node.createLogError('node-evm');
1354
1708
  const ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED = 'Delegated key share, wallet ID, and wallet API key are required to sponsor a transaction';
1355
1709
  const ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED = 'userId is required — a delegated wallet is always owned by an end user, so a sponsored transaction cannot be attributed to the calling service';
@@ -1685,6 +2039,11 @@ exports.ERROR_ACCOUNT_ADDRESS_REQUIRED = ERROR_ACCOUNT_ADDRESS_REQUIRED;
1685
2039
  exports.ERROR_CREATE_WALLET_ACCOUNT = ERROR_CREATE_WALLET_ACCOUNT;
1686
2040
  exports.ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED = ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED;
1687
2041
  exports.ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED = ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED;
2042
+ exports.ERROR_EARN_APPROVAL_FAILED = ERROR_EARN_APPROVAL_FAILED;
2043
+ exports.ERROR_EARN_CHAIN_MISMATCH = ERROR_EARN_CHAIN_MISMATCH;
2044
+ exports.ERROR_EARN_CHAIN_REQUIRED = ERROR_EARN_CHAIN_REQUIRED;
2045
+ exports.ERROR_EARN_MISSING_EVM_TRANSACTION = ERROR_EARN_MISSING_EVM_TRANSACTION;
2046
+ exports.ERROR_EARN_NOT_EVM_WALLET = ERROR_EARN_NOT_EVM_WALLET;
1688
2047
  exports.ERROR_GASLESS_MISSING_REQUEST_ID = ERROR_GASLESS_MISSING_REQUEST_ID;
1689
2048
  exports.ERROR_GASLESS_MISSING_YPARITY = ERROR_GASLESS_MISSING_YPARITY;
1690
2049
  exports.ERROR_GASLESS_RELAY_FAILED = ERROR_GASLESS_RELAY_FAILED;
@@ -1702,6 +2061,7 @@ exports.EVM_SIGN_MESSAGE_PREFIX = EVM_SIGN_MESSAGE_PREFIX;
1702
2061
  exports.UGD_ABI = UGD_ABI;
1703
2062
  exports.createAccountAdapter = createAccountAdapter;
1704
2063
  exports.createDelegatedEvmWalletClient = createDelegatedEvmWalletClient;
2064
+ exports.createEvmEarnClient = createEvmEarnClient;
1705
2065
  exports.createZerodevClient = createZerodevClient;
1706
2066
  exports.delegatedSendSponsoredTransaction = delegatedSendSponsoredTransaction;
1707
2067
  exports.delegatedSign7702Authorization = delegatedSign7702Authorization;
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { toAccount } from 'viem/accounts';
2
2
  import { MessageHash, createLogError, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, resolveRawSignContext, stripHexPrefix, revokeDelegation as revokeDelegation$1, DynamicWalletClient, getMPCChainConfig, WalletOperation, withDelegatedServerAuth } from '@dynamic-labs-wallet/node';
3
- import { getAddress, stringToHex, bytesToHex, size, concat, hashTypedData, validateTypedData, serializeSignature, parseSignature, serializeTransaction, defineChain, createPublicClient, http, createWalletClient } from 'viem';
3
+ import { getAddress, stringToHex, bytesToHex, size, concat, hashTypedData, validateTypedData, serializeSignature, parseSignature, serializeTransaction, encodeFunctionData, defineChain, createPublicClient, http, createWalletClient } from 'viem';
4
4
  import { hashAuthorization } from 'viem/utils';
5
5
  import { mainnet } from 'viem/chains';
6
6
  import { randomBytes } from 'node:crypto';
@@ -421,6 +421,347 @@ const createAccountAdapter = ({ evmClient, walletMetadata, password, externalSer
421
421
  });
422
422
  };
423
423
 
424
+ function _object_without_properties_loose(source, excluded) {
425
+ if (source == null) return {};
426
+ var target = {};
427
+ var sourceKeys = Object.keys(source);
428
+ var key, i;
429
+ for(i = 0; i < sourceKeys.length; i++){
430
+ key = sourceKeys[i];
431
+ if (excluded.indexOf(key) >= 0) continue;
432
+ target[key] = source[key];
433
+ }
434
+ return target;
435
+ }
436
+
437
+ const ERROR_EARN_NOT_EVM_WALLET = 'Wallet metadata is not for an EVM wallet';
438
+ const ERROR_EARN_MISSING_EVM_TRANSACTION = 'Earn signing payload is missing EVM transaction data';
439
+ const ERROR_EARN_CHAIN_MISMATCH = 'The provided chain does not match the chain the Earn transaction was prepared for';
440
+ const ERROR_EARN_APPROVAL_FAILED = 'The ERC-20 approval for the Earn transaction reverted';
441
+ const ERROR_EARN_CHAIN_REQUIRED = 'Either chain or rpcUrl is required to execute an Earn transaction. Provide an RPC URL for the vault chain.';
442
+ /**
443
+ * Vault deposits and withdrawals rebalance the underlying lending markets, so gas estimated at
444
+ * the current block is regularly lower than what execution needs once the transaction is mined.
445
+ */ const EARN_GAS_LIMIT_BUFFER_PERCENT = 30n;
446
+ const ERC20_ALLOWANCE_AND_APPROVE_ABI = [
447
+ {
448
+ name: 'allowance',
449
+ type: 'function',
450
+ stateMutability: 'view',
451
+ inputs: [
452
+ {
453
+ name: 'owner',
454
+ type: 'address'
455
+ },
456
+ {
457
+ name: 'spender',
458
+ type: 'address'
459
+ }
460
+ ],
461
+ outputs: [
462
+ {
463
+ name: '',
464
+ type: 'uint256'
465
+ }
466
+ ]
467
+ },
468
+ {
469
+ name: 'approve',
470
+ type: 'function',
471
+ stateMutability: 'nonpayable',
472
+ inputs: [
473
+ {
474
+ name: 'spender',
475
+ type: 'address'
476
+ },
477
+ {
478
+ name: 'amount',
479
+ type: 'uint256'
480
+ }
481
+ ],
482
+ outputs: [
483
+ {
484
+ name: '',
485
+ type: 'bool'
486
+ }
487
+ ]
488
+ }
489
+ ];
490
+
491
+ /**
492
+ * Builds a stateless Earn client for EVM vaults: it prepares vault actions through the
493
+ * Dynamic API and executes the returned unsigned transactions with the caller's wallet,
494
+ * sending an ERC-20 approval first when the vault requires one.
495
+ */ const createEvmEarnClient = ({ getEarnClient, createViemPublicClient, getWalletClient, sendSponsoredTransaction })=>{
496
+ const resolveChain = ({ chain, chainId, rpcUrl })=>{
497
+ if (chain) {
498
+ if (chain.id !== chainId) {
499
+ throw new Error(ERROR_EARN_CHAIN_MISMATCH);
500
+ }
501
+ return chain;
502
+ }
503
+ if (!rpcUrl) {
504
+ throw new Error(ERROR_EARN_CHAIN_REQUIRED);
505
+ }
506
+ return defineChain({
507
+ id: chainId,
508
+ name: `Chain ${chainId}`,
509
+ nativeCurrency: {
510
+ name: 'Ether',
511
+ symbol: 'ETH',
512
+ decimals: 18
513
+ },
514
+ rpcUrls: {
515
+ default: {
516
+ http: [
517
+ rpcUrl
518
+ ]
519
+ }
520
+ }
521
+ });
522
+ };
523
+ const buildGasLimitAndNonce = async ({ transaction, publicClient, accountAddress })=>{
524
+ const params = {};
525
+ if (transaction.gasLimit) {
526
+ params.gas = BigInt(transaction.gasLimit);
527
+ } else {
528
+ const estimatedGas = await publicClient.estimateGas({
529
+ account: accountAddress,
530
+ to: transaction.to,
531
+ data: transaction.data,
532
+ value: transaction.value
533
+ });
534
+ params.gas = estimatedGas + estimatedGas * EARN_GAS_LIMIT_BUFFER_PERCENT / 100n;
535
+ }
536
+ if (transaction.nonce !== undefined) {
537
+ params.nonce = transaction.nonce;
538
+ }
539
+ return params;
540
+ };
541
+ const relaySponsoredEarnTransaction = async ({ chainId, evmApproval, evmTransaction, externalServerKeyShares, onStepChange, password, publicClient, resolvedChain, rpcUrl, traceContext, walletMetadata })=>{
542
+ const calls = [];
543
+ if (evmApproval) {
544
+ const currentAllowance = await publicClient.readContract({
545
+ address: evmApproval.tokenAddress,
546
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
547
+ functionName: 'allowance',
548
+ args: [
549
+ walletMetadata.accountAddress,
550
+ evmApproval.spenderAddress
551
+ ]
552
+ });
553
+ const requiredAllowance = BigInt(evmApproval.amount);
554
+ if (currentAllowance < requiredAllowance) {
555
+ onStepChange == null ? void 0 : onStepChange('approval');
556
+ calls.push({
557
+ target: evmApproval.tokenAddress,
558
+ data: encodeFunctionData({
559
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
560
+ functionName: 'approve',
561
+ args: [
562
+ evmApproval.spenderAddress,
563
+ requiredAllowance
564
+ ]
565
+ }),
566
+ value: 0n
567
+ });
568
+ }
569
+ }
570
+ onStepChange == null ? void 0 : onStepChange('transaction');
571
+ calls.push({
572
+ target: evmTransaction.to,
573
+ data: evmTransaction.data,
574
+ value: evmTransaction.value ? BigInt(evmTransaction.value) : 0n
575
+ });
576
+ return sendSponsoredTransaction({
577
+ walletMetadata,
578
+ calls,
579
+ chainId,
580
+ password,
581
+ externalServerKeyShares,
582
+ // The relayer needs an RPC to read the wallet's on-chain state; fall back to the
583
+ // resolved chain's default when the caller passed `chain` without `rpcUrl`.
584
+ rpcUrl: rpcUrl != null ? rpcUrl : resolvedChain.rpcUrls.default.http[0],
585
+ traceContext,
586
+ autoDelegate: true
587
+ });
588
+ };
589
+ const executeEarnTransaction = async ({ signingPayload, traceContext, walletMetadata, password, externalServerKeyShares, sponsored, chain, rpcUrl, onStepChange })=>{
590
+ if (walletMetadata.chainName !== 'EVM') {
591
+ throw new Error(ERROR_EARN_NOT_EVM_WALLET);
592
+ }
593
+ const { evmTransaction, evmApproval } = signingPayload;
594
+ if (!evmTransaction) {
595
+ throw new Error(ERROR_EARN_MISSING_EVM_TRANSACTION);
596
+ }
597
+ const chainId = Number(signingPayload.chainId);
598
+ const resolvedChain = resolveChain({
599
+ chain,
600
+ chainId,
601
+ rpcUrl
602
+ });
603
+ const publicClient = createViemPublicClient({
604
+ chain: resolvedChain,
605
+ rpcUrl
606
+ });
607
+ // Sponsored execution relays the approval and vault call as one batch through the
608
+ // gasless relayer, so no gas estimation or EOA sending is needed.
609
+ if (sponsored === true) {
610
+ return relaySponsoredEarnTransaction({
611
+ chainId,
612
+ evmApproval,
613
+ evmTransaction,
614
+ externalServerKeyShares,
615
+ onStepChange,
616
+ password,
617
+ publicClient,
618
+ resolvedChain,
619
+ rpcUrl,
620
+ traceContext,
621
+ walletMetadata
622
+ });
623
+ }
624
+ const walletClient = await getWalletClient({
625
+ walletMetadata,
626
+ password,
627
+ externalServerKeyShares,
628
+ chain: resolvedChain,
629
+ rpcUrl
630
+ });
631
+ if (evmApproval) {
632
+ const currentAllowance = await publicClient.readContract({
633
+ address: evmApproval.tokenAddress,
634
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
635
+ functionName: 'allowance',
636
+ args: [
637
+ walletMetadata.accountAddress,
638
+ evmApproval.spenderAddress
639
+ ]
640
+ });
641
+ const requiredAllowance = BigInt(evmApproval.amount);
642
+ if (currentAllowance < requiredAllowance) {
643
+ onStepChange == null ? void 0 : onStepChange('approval');
644
+ const approvalHash = await walletClient.sendTransaction({
645
+ to: evmApproval.tokenAddress,
646
+ data: encodeFunctionData({
647
+ abi: ERC20_ALLOWANCE_AND_APPROVE_ABI,
648
+ functionName: 'approve',
649
+ args: [
650
+ evmApproval.spenderAddress,
651
+ requiredAllowance
652
+ ]
653
+ }),
654
+ value: 0n
655
+ });
656
+ const approvalReceipt = await publicClient.waitForTransactionReceipt({
657
+ hash: approvalHash
658
+ });
659
+ if (approvalReceipt.status !== 'success') {
660
+ throw new Error(ERROR_EARN_APPROVAL_FAILED);
661
+ }
662
+ }
663
+ }
664
+ onStepChange == null ? void 0 : onStepChange('transaction');
665
+ let value = 0n;
666
+ if (evmTransaction.value) {
667
+ value = BigInt(evmTransaction.value);
668
+ }
669
+ const gasLimitAndNonce = await buildGasLimitAndNonce({
670
+ transaction: _extends({}, evmTransaction, {
671
+ value
672
+ }),
673
+ publicClient,
674
+ accountAddress: walletMetadata.accountAddress
675
+ });
676
+ const request = _extends({
677
+ to: evmTransaction.to,
678
+ data: evmTransaction.data,
679
+ value
680
+ }, gasLimitAndNonce);
681
+ const hasEip1559Fees = Boolean(evmTransaction.maxFeePerGas && evmTransaction.maxPriorityFeePerGas);
682
+ if (hasEip1559Fees) {
683
+ const transactionHash = await walletClient.sendTransaction(_extends({}, request, {
684
+ maxFeePerGas: BigInt(evmTransaction.maxFeePerGas),
685
+ maxPriorityFeePerGas: BigInt(evmTransaction.maxPriorityFeePerGas)
686
+ }));
687
+ return {
688
+ transactionHash
689
+ };
690
+ }
691
+ if (evmTransaction.gasPrice) {
692
+ const transactionHash = await walletClient.sendTransaction(_extends({}, request, {
693
+ gasPrice: BigInt(evmTransaction.gasPrice)
694
+ }));
695
+ return {
696
+ transactionHash
697
+ };
698
+ }
699
+ const transactionHash = await walletClient.sendTransaction(request);
700
+ return {
701
+ transactionHash
702
+ };
703
+ };
704
+ const depositToEarnVault = async (_param)=>{
705
+ var { vaultId, amount, receiverAddress, traceContext } = _param, walletParams = _object_without_properties_loose(_param, [
706
+ "vaultId",
707
+ "amount",
708
+ "receiverAddress",
709
+ "traceContext"
710
+ ]);
711
+ const signingPayload = await getEarnClient().prepareDeposit({
712
+ vaultId,
713
+ ownerAddress: walletParams.walletMetadata.accountAddress,
714
+ amount,
715
+ receiverAddress,
716
+ traceContext
717
+ });
718
+ return executeEarnTransaction(_extends({
719
+ signingPayload,
720
+ traceContext
721
+ }, walletParams));
722
+ };
723
+ const withdrawFromEarnVault = async (_param)=>{
724
+ var { vaultId, amount, receiverAddress, traceContext } = _param, walletParams = _object_without_properties_loose(_param, [
725
+ "vaultId",
726
+ "amount",
727
+ "receiverAddress",
728
+ "traceContext"
729
+ ]);
730
+ const signingPayload = await getEarnClient().prepareWithdrawal({
731
+ vaultId,
732
+ ownerAddress: walletParams.walletMetadata.accountAddress,
733
+ amount,
734
+ receiverAddress,
735
+ traceContext
736
+ });
737
+ return executeEarnTransaction(_extends({
738
+ signingPayload,
739
+ traceContext
740
+ }, walletParams));
741
+ };
742
+ const claimEarnRewards = async (_param)=>{
743
+ var { vaultId, traceContext } = _param, walletParams = _object_without_properties_loose(_param, [
744
+ "vaultId",
745
+ "traceContext"
746
+ ]);
747
+ const signingPayload = await getEarnClient().prepareClaimRewards({
748
+ vaultId,
749
+ ownerAddress: walletParams.walletMetadata.accountAddress,
750
+ traceContext
751
+ });
752
+ return executeEarnTransaction(_extends({
753
+ signingPayload,
754
+ traceContext
755
+ }, walletParams));
756
+ };
757
+ return {
758
+ executeEarnTransaction,
759
+ depositToEarnVault,
760
+ withdrawFromEarnVault,
761
+ claimEarnRewards
762
+ };
763
+ };
764
+
424
765
  /** The Fireblocks Universal Gasless Delegate (UGD) contract address used for EIP-7702 delegation. */ const DELEGATION_CONTRACT_ADDRESS = '0x0000Fb7702036ff9f76044a501ac1aA74cbab16b';
425
766
  /** Default sponsored transaction validity duration in seconds (10 minutes). */ const DEFAULT_VALID_FOR_SECONDS = 600;
426
767
  /** EIP-7702 delegation code prefix used to identify delegated accounts. */ const DELEGATION_CODE_PREFIX = '0xef0100';
@@ -1323,6 +1664,32 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
1323
1664
  */ async waitForSponsoredTransaction(params) {
1324
1665
  return this.evmGasless.waitForSponsoredTransaction(params);
1325
1666
  }
1667
+ // ---------------------------------------------------------------------------
1668
+ // Earn (yield vaults)
1669
+ // ---------------------------------------------------------------------------
1670
+ get evmEarn() {
1671
+ return createEvmEarnClient({
1672
+ getEarnClient: ()=>this.earn,
1673
+ createViemPublicClient: (args)=>this.createViemPublicClient(args),
1674
+ getWalletClient: (args)=>this.getWalletClient(args),
1675
+ sendSponsoredTransaction: (args)=>this.sendSponsoredTransaction(args)
1676
+ });
1677
+ }
1678
+ /**
1679
+ * Executes an Earn signing payload returned by the prepare* methods, sending the
1680
+ * ERC-20 approval first when the vault requires one.
1681
+ */ async executeEarnTransaction(params) {
1682
+ return this.evmEarn.executeEarnTransaction(params);
1683
+ }
1684
+ /** Prepares and executes a deposit into an Earn vault. */ async depositToEarnVault(params) {
1685
+ return this.evmEarn.depositToEarnVault(params);
1686
+ }
1687
+ /** Prepares and executes a withdrawal from an Earn vault. */ async withdrawFromEarnVault(params) {
1688
+ return this.evmEarn.withdrawFromEarnVault(params);
1689
+ }
1690
+ /** Prepares and executes a claim of accrued Earn vault rewards. */ async claimEarnRewards(params) {
1691
+ return this.evmEarn.claimEarnRewards(params);
1692
+ }
1326
1693
  constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, enableMPCAccelerator, logger }){
1327
1694
  super({
1328
1695
  environmentId,
@@ -1335,19 +1702,6 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
1335
1702
  }
1336
1703
  }
1337
1704
 
1338
- function _object_without_properties_loose(source, excluded) {
1339
- if (source == null) return {};
1340
- var target = {};
1341
- var sourceKeys = Object.keys(source);
1342
- var key, i;
1343
- for(i = 0; i < sourceKeys.length; i++){
1344
- key = sourceKeys[i];
1345
- if (excluded.indexOf(key) >= 0) continue;
1346
- target[key] = source[key];
1347
- }
1348
- return target;
1349
- }
1350
-
1351
1705
  const logError = createLogError('node-evm');
1352
1706
  const ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED = 'Delegated key share, wallet ID, and wallet API key are required to sponsor a transaction';
1353
1707
  const ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED = 'userId is required — a delegated wallet is always owned by an end user, so a sponsored transaction cannot be attributed to the calling service';
@@ -1673,4 +2027,4 @@ const createZerodevClient = async (evmClient)=>{
1673
2027
  return client;
1674
2028
  };
1675
2029
 
1676
- export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, DynamicEvmWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED, ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED, ERROR_GASLESS_MISSING_REQUEST_ID, ERROR_GASLESS_MISSING_YPARITY, ERROR_GASLESS_RELAY_FAILED, ERROR_GASLESS_RPC_REQUIRED, ERROR_GASLESS_RPC_REQUIRED_FOR_AUTO_DELEGATE, ERROR_GASLESS_TIMEOUT, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_RAW_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, EVM_GASLESS_DEFAULT_POLL_INTERVAL_MS, EVM_GASLESS_DEFAULT_TIMEOUT_MS, EVM_SIGN_MESSAGE_PREFIX, UGD_ABI, createAccountAdapter, createDelegatedEvmWalletClient, createZerodevClient, delegatedSendSponsoredTransaction, delegatedSign7702Authorization, delegatedSignAuthorization, delegatedSignMessage, delegatedSignRawMessage, delegatedSignSponsoredTransaction, delegatedSignTransaction, delegatedSignTypedData, deriveAccountAddress, formatEVMMessage, formatTypedData, mapTransactionToEvmTransaction, revokeDelegation, serializeECDSASignature };
2030
+ export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, DynamicEvmWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_DELEGATED_GASLESS_CREDENTIALS_REQUIRED, ERROR_DELEGATED_GASLESS_USER_ID_REQUIRED, ERROR_EARN_APPROVAL_FAILED, ERROR_EARN_CHAIN_MISMATCH, ERROR_EARN_CHAIN_REQUIRED, ERROR_EARN_MISSING_EVM_TRANSACTION, ERROR_EARN_NOT_EVM_WALLET, ERROR_GASLESS_MISSING_REQUEST_ID, ERROR_GASLESS_MISSING_YPARITY, ERROR_GASLESS_RELAY_FAILED, ERROR_GASLESS_RPC_REQUIRED, ERROR_GASLESS_RPC_REQUIRED_FOR_AUTO_DELEGATE, ERROR_GASLESS_TIMEOUT, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_RAW_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, EVM_GASLESS_DEFAULT_POLL_INTERVAL_MS, EVM_GASLESS_DEFAULT_TIMEOUT_MS, EVM_SIGN_MESSAGE_PREFIX, UGD_ABI, createAccountAdapter, createDelegatedEvmWalletClient, createEvmEarnClient, createZerodevClient, delegatedSendSponsoredTransaction, delegatedSign7702Authorization, delegatedSignAuthorization, delegatedSignMessage, delegatedSignRawMessage, delegatedSignSponsoredTransaction, delegatedSignTransaction, delegatedSignTypedData, deriveAccountAddress, formatEVMMessage, formatTypedData, mapTransactionToEvmTransaction, revokeDelegation, serializeECDSASignature };
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/node-evm",
3
- "version": "1.1.52",
3
+ "version": "1.1.54",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/node": "1.1.52",
7
+ "@dynamic-labs-wallet/node": "1.1.54",
8
8
  "@dynamic-labs/sdk-api-core": "0.115.0",
9
9
  "@dynamic-labs-sdk/client": "1.18.0",
10
10
  "@dynamic-labs-sdk/zerodev": "1.18.0",
11
11
  "@dynamic-labs-sdk/evm": "1.18.0",
12
12
  "@zerodev/ecdsa-validator": "5.4.9",
13
13
  "@zerodev/sdk": "5.4.36",
14
- "@dynamic-labs-wallet/core": "1.1.52"
14
+ "@dynamic-labs-wallet/core": "1.1.54"
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public"
@@ -1,6 +1,7 @@
1
1
  import { DynamicWalletClient, type DynamicWalletClientProps, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type RawSignPreImage, type ServerKeyShare, type ThresholdSignatureScheme, type WalletApiKeyCreationResult, type WalletMetadata } from '@dynamic-labs-wallet/node';
2
2
  import type { SignMessageContext, SponsorEVMTransactionResponse } from '@dynamic-labs-wallet/core';
3
3
  import { type Account, type Chain, type Hex, type PublicClient, type SignableMessage, type TransactionSerializable, type Transport, type TypedData, type WalletClient } from 'viem';
4
+ import type { ClaimEarnRewardsParams, DepositToEarnVaultParams, EarnTransactionResult, ExecuteEarnTransactionParams, WithdrawFromEarnVaultParams } from './earn.types.js';
4
5
  import type { GetAvailableEvmGaslessRelayerParams, GetEVMSponsoredTransactionStatusParams, Is7702DelegationActiveParams, RelaySponsoredTransactionParams, SerializedAuthorization, Sign7702AuthorizationParams, SignedSponsoredTransaction, SignSponsoredTransactionParams, SponsoredTransactionStatusResult, WaitForSponsoredTransactionParams } from './gasless.types.js';
5
6
  export declare class DynamicEvmWalletClient extends DynamicWalletClient {
6
7
  readonly chainName = "EVM";
@@ -204,5 +205,17 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
204
205
  waitForSponsoredTransaction(params: WaitForSponsoredTransactionParams): Promise<{
205
206
  transactionHash: Hex;
206
207
  }>;
208
+ private get evmEarn();
209
+ /**
210
+ * Executes an Earn signing payload returned by the prepare* methods, sending the
211
+ * ERC-20 approval first when the vault requires one.
212
+ */
213
+ executeEarnTransaction(params: ExecuteEarnTransactionParams): Promise<EarnTransactionResult>;
214
+ /** Prepares and executes a deposit into an Earn vault. */
215
+ depositToEarnVault(params: DepositToEarnVaultParams): Promise<EarnTransactionResult>;
216
+ /** Prepares and executes a withdrawal from an Earn vault. */
217
+ withdrawFromEarnVault(params: WithdrawFromEarnVaultParams): Promise<EarnTransactionResult>;
218
+ /** Prepares and executes a claim of accrued Earn vault rewards. */
219
+ claimEarnRewards(params: ClaimEarnRewardsParams): Promise<EarnTransactionResult>;
207
220
  }
208
221
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAExB,KAAK,eAAe,EAEpB,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AACnG,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIV,KAAK,GAAG,EAGR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAqBd,OAAO,KAAK,EACV,mCAAmC,EACnC,sCAAsC,EACtC,4BAA4B,EAC5B,+BAA+B,EAC/B,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,oBAAoB,CAAC;AAI5B,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aA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OAAO,CAAC,gCAAgC,CAAC;IAI5C;;;OAGG;IACG,yBAAyB,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAIhH;;;OAGG;IACG,wBAAwB,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC;IAI1G;;OAEG;IACG,2BAA2B,CAAC,MAAM,EAAE,iCAAiC,GAAG,OAAO,CAAC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC;IAQ/G,OAAO,KAAK,OAAO,GAOlB;IAED;;;OAGG;IACG,sBAAsB,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIlG,0DAA0D;IACpD,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI1F,6DAA6D;IACvD,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhG,mEAAmE;IAC7D,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAGvF"}
@@ -0,0 +1,35 @@
1
+ import type { EarnClient, ServerKeyShare, WalletMetadata } from '@dynamic-labs-wallet/node';
2
+ import { type Account, type Chain, type Hex, type PublicClient, type Transport, type WalletClient } from 'viem';
3
+ import type { ClaimEarnRewardsParams, DepositToEarnVaultParams, EarnTransactionResult, ExecuteEarnTransactionParams, WithdrawFromEarnVaultParams } from './earn.types.js';
4
+ import type { RelaySponsoredTransactionParams } from './gasless.types.js';
5
+ /** Primitives the Earn client borrows from whoever owns the wallet. */
6
+ export type EvmEarnClientDeps = {
7
+ getEarnClient: () => EarnClient;
8
+ createViemPublicClient: (args: {
9
+ chain: Chain;
10
+ rpcUrl?: string;
11
+ }) => PublicClient;
12
+ getWalletClient: (args: {
13
+ walletMetadata: WalletMetadata;
14
+ password?: string;
15
+ externalServerKeyShares?: ServerKeyShare[];
16
+ chain?: Chain;
17
+ chainId?: number;
18
+ rpcUrl?: string;
19
+ }) => Promise<WalletClient<Transport, Chain, Account>>;
20
+ sendSponsoredTransaction: (args: RelaySponsoredTransactionParams) => Promise<{
21
+ transactionHash: Hex;
22
+ }>;
23
+ };
24
+ /**
25
+ * Builds a stateless Earn client for EVM vaults: it prepares vault actions through the
26
+ * Dynamic API and executes the returned unsigned transactions with the caller's wallet,
27
+ * sending an ERC-20 approval first when the vault requires one.
28
+ */
29
+ export declare const createEvmEarnClient: ({ getEarnClient, createViemPublicClient, getWalletClient, sendSponsoredTransaction, }: EvmEarnClientDeps) => {
30
+ executeEarnTransaction: ({ signingPayload, traceContext, walletMetadata, password, externalServerKeyShares, sponsored, chain, rpcUrl, onStepChange, }: ExecuteEarnTransactionParams) => Promise<EarnTransactionResult>;
31
+ depositToEarnVault: ({ vaultId, amount, receiverAddress, traceContext, ...walletParams }: DepositToEarnVaultParams) => Promise<EarnTransactionResult>;
32
+ withdrawFromEarnVault: ({ vaultId, amount, receiverAddress, traceContext, ...walletParams }: WithdrawFromEarnVaultParams) => Promise<EarnTransactionResult>;
33
+ claimEarnRewards: ({ vaultId, traceContext, ...walletParams }: ClaimEarnRewardsParams) => Promise<EarnTransactionResult>;
34
+ };
35
+ //# sourceMappingURL=earn.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"earn.client.d.ts","sourceRoot":"","sources":["../../src/client/earn.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAsB,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChH,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAGV,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAUd,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,+BAA+B,EAA4B,MAAM,oBAAoB,CAAC;AAEpG,uEAAuE;AACvE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,MAAM,UAAU,CAAC;IAChC,sBAAsB,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,YAAY,CAAC;IAClF,eAAe,EAAE,CAAC,IAAI,EAAE;QACtB,cAAc,EAAE,cAAc,CAAC;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3C,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,KAAK,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,wBAAwB,EAAE,CAAC,IAAI,EAAE,+BAA+B,KAAK,OAAO,CAAC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CACxG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,0FAK7B,iBAAiB;2JAoIf,4BAA4B,KAAG,OAAO,CAAC,qBAAqB,CAAC;8FAyH7D,wBAAwB,KAAG,OAAO,CAAC,qBAAqB,CAAC;iGAkBzD,2BAA2B,KAAG,OAAO,CAAC,qBAAqB,CAAC;mEAgB5D,sBAAsB,KAAG,OAAO,CAAC,qBAAqB,CAAC;CAgB3D,CAAC"}
@@ -0,0 +1,42 @@
1
+ export declare const ERROR_EARN_NOT_EVM_WALLET = "Wallet metadata is not for an EVM wallet";
2
+ export declare const ERROR_EARN_MISSING_EVM_TRANSACTION = "Earn signing payload is missing EVM transaction data";
3
+ export declare const ERROR_EARN_CHAIN_MISMATCH = "The provided chain does not match the chain the Earn transaction was prepared for";
4
+ export declare const ERROR_EARN_APPROVAL_FAILED = "The ERC-20 approval for the Earn transaction reverted";
5
+ export declare const ERROR_EARN_CHAIN_REQUIRED = "Either chain or rpcUrl is required to execute an Earn transaction. Provide an RPC URL for the vault chain.";
6
+ /**
7
+ * Vault deposits and withdrawals rebalance the underlying lending markets, so gas estimated at
8
+ * the current block is regularly lower than what execution needs once the transaction is mined.
9
+ */
10
+ export declare const EARN_GAS_LIMIT_BUFFER_PERCENT = 30n;
11
+ export declare const ERC20_ALLOWANCE_AND_APPROVE_ABI: readonly [{
12
+ readonly name: "allowance";
13
+ readonly type: "function";
14
+ readonly stateMutability: "view";
15
+ readonly inputs: readonly [{
16
+ readonly name: "owner";
17
+ readonly type: "address";
18
+ }, {
19
+ readonly name: "spender";
20
+ readonly type: "address";
21
+ }];
22
+ readonly outputs: readonly [{
23
+ readonly name: "";
24
+ readonly type: "uint256";
25
+ }];
26
+ }, {
27
+ readonly name: "approve";
28
+ readonly type: "function";
29
+ readonly stateMutability: "nonpayable";
30
+ readonly inputs: readonly [{
31
+ readonly name: "spender";
32
+ readonly type: "address";
33
+ }, {
34
+ readonly name: "amount";
35
+ readonly type: "uint256";
36
+ }];
37
+ readonly outputs: readonly [{
38
+ readonly name: "";
39
+ readonly type: "bool";
40
+ }];
41
+ }];
42
+ //# sourceMappingURL=earn.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"earn.constants.d.ts","sourceRoot":"","sources":["../../src/client/earn.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,6CAA6C,CAAC;AAEpF,eAAO,MAAM,kCAAkC,yDAAyD,CAAC;AAEzG,eAAO,MAAM,yBAAyB,sFAC+C,CAAC;AAEtF,eAAO,MAAM,0BAA0B,0DAA0D,CAAC;AAElG,eAAO,MAAM,yBAAyB,+GACwE,CAAC;AAE/G;;;GAGG;AACH,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBlC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { EarnExecutionStep, EarnSigningPayload, ServerKeyShare, TraceContext, WalletMetadata } from '@dynamic-labs-wallet/node';
2
+ import type { Chain } from 'viem';
3
+ export type { EarnExecutionStep, EarnTransactionResult } from '@dynamic-labs-wallet/node';
4
+ /** Wallet context and chain access every Earn write action needs. */
5
+ export type EvmEarnWalletParams = {
6
+ walletMetadata: WalletMetadata;
7
+ password?: string;
8
+ externalServerKeyShares?: ServerKeyShare[];
9
+ /** Viem chain for the vault. When omitted, the chain is built from the payload's chain id and `rpcUrl`. */
10
+ chain?: Chain;
11
+ rpcUrl?: string;
12
+ /** Opt in to Dynamic gas sponsorship: the approval and vault call are relayed as one batch. */
13
+ sponsored?: boolean;
14
+ onStepChange?: (step: EarnExecutionStep) => void;
15
+ traceContext?: TraceContext;
16
+ };
17
+ export type ExecuteEarnTransactionParams = EvmEarnWalletParams & {
18
+ signingPayload: EarnSigningPayload;
19
+ };
20
+ export type DepositToEarnVaultParams = EvmEarnWalletParams & {
21
+ vaultId: string;
22
+ amount: string;
23
+ receiverAddress?: string;
24
+ };
25
+ export type WithdrawFromEarnVaultParams = EvmEarnWalletParams & {
26
+ vaultId: string;
27
+ amount: string;
28
+ receiverAddress?: string;
29
+ };
30
+ export type ClaimEarnRewardsParams = EvmEarnWalletParams & {
31
+ vaultId: string;
32
+ };
33
+ //# sourceMappingURL=earn.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"earn.types.d.ts","sourceRoot":"","sources":["../../src/client/earn.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,cAAc,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAE1F,qEAAqE;AACrE,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3C,2GAA2G;IAC3G,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,GAAG;IAC/D,cAAc,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,GAAG;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,GAAG;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG;IACzD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -2,6 +2,10 @@ export * from './accountAdapter.js';
2
2
  export * from './client.js';
3
3
  export * from './constants.js';
4
4
  export * from '../utils.js';
5
+ export { createEvmEarnClient } from './earn.client.js';
6
+ export type { EvmEarnClientDeps } from './earn.client.js';
7
+ export type { ClaimEarnRewardsParams, DepositToEarnVaultParams, EarnExecutionStep, EarnTransactionResult, EvmEarnWalletParams, ExecuteEarnTransactionParams, WithdrawFromEarnVaultParams, } from './earn.types.js';
8
+ export { ERROR_EARN_APPROVAL_FAILED, ERROR_EARN_CHAIN_MISMATCH, ERROR_EARN_CHAIN_REQUIRED, ERROR_EARN_MISSING_EVM_TRANSACTION, ERROR_EARN_NOT_EVM_WALLET, } from './earn.constants.js';
5
9
  export type { GaslessWalletRef, SerializedAuthorization, SignedSponsoredTransaction, SponsoredTransactionCall, SponsoredTransactionStatus, SponsoredTransactionStatusResult, } from './gasless.types.js';
6
10
  export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, ERROR_GASLESS_MISSING_REQUEST_ID, ERROR_GASLESS_MISSING_YPARITY, ERROR_GASLESS_RELAY_FAILED, ERROR_GASLESS_RPC_REQUIRED, ERROR_GASLESS_RPC_REQUIRED_FOR_AUTO_DELEGATE, ERROR_GASLESS_TIMEOUT, EVM_GASLESS_DEFAULT_POLL_INTERVAL_MS, EVM_GASLESS_DEFAULT_TIMEOUT_MS, UGD_ABI, } from './gasless.constants.js';
7
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,EAC3B,gCAAgC,EAChC,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,EAC1B,4CAA4C,EAC5C,qBAAqB,EACrB,oCAAoC,EACpC,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