@elisym/sdk 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { Address, TransactionSigner, Rpc, SolanaRpcApi } from '@solana/kit';
2
2
  import { Filter, Event } from 'nostr-tools';
3
+ import { A as Asset } from './assets-CMf-v55Z.cjs';
4
+ export { C as Chain, K as KNOWN_ASSETS, N as NATIVE_SOL, U as USDC_SOLANA_DEVNET, a as assetByKey, b as assetKey, f as formatAssetAmount, p as parseAssetAmount, r as resolveAssetFromPaymentRequest, c as resolveKnownAsset } from './assets-CMf-v55Z.cjs';
3
5
  import { z } from 'zod';
6
+ export { G as GlobalConfig, a as GlobalConfigSchema, S as SessionSpendLimitEntry, b as SessionSpendLimitEntrySchema } from './global-schema-CddHP2nk.cjs';
4
7
 
5
8
  declare class ElisymIdentity {
6
9
  private _secretKey;
@@ -36,8 +39,21 @@ interface PaymentInfo {
36
39
  chain: string;
37
40
  network: string;
38
41
  address: string;
39
- /** Price in lamports (must be non-negative integer). */
42
+ /**
43
+ * Price in subunits of the payment asset (non-negative integer).
44
+ *
45
+ * Subunit = smallest indivisible unit: 1 lamport for SOL, 1 "cent" (1e-6 USDC)
46
+ * for USDC. When `token` is omitted, subunits are lamports (back-compat).
47
+ */
40
48
  job_price?: number;
49
+ /** Lowercase token id (e.g. 'sol', 'usdc'). Absent => native SOL. */
50
+ token?: string;
51
+ /** SPL mint / ERC-20 contract. Undefined for native coin. */
52
+ mint?: string;
53
+ /** Subunits per whole (9 for SOL, 6 for USDC). */
54
+ decimals?: number;
55
+ /** Display symbol (e.g. 'SOL', 'USDC'). */
56
+ symbol?: string;
41
57
  }
42
58
  /** Agent discovered from the network. */
43
59
  interface Agent {
@@ -102,9 +118,26 @@ interface PingResult {
102
118
  /** The identity used for the ping session - reuse for job submission so pubkeys match. */
103
119
  identity: ElisymIdentity | null;
104
120
  }
121
+ /**
122
+ * Wire-shape reference to an asset inside a payment request.
123
+ *
124
+ * Same shape as `Asset` minus the display-only `symbol` field. Absent = native
125
+ * SOL (back-compat for payment requests published before multi-asset support).
126
+ */
127
+ interface PaymentAssetRef {
128
+ chain: string;
129
+ token: string;
130
+ mint?: string;
131
+ decimals: number;
132
+ }
105
133
  interface PaymentRequestData {
106
134
  recipient: string;
107
- /** Total amount in lamports (must be positive integer). */
135
+ /**
136
+ * Total amount in subunits of the payment asset (must be positive integer).
137
+ *
138
+ * - For native SOL (asset absent / `token: 'sol'`): lamports (1e-9 SOL).
139
+ * - For SPL USDC: 1e-6 USDC.
140
+ */
108
141
  amount: number;
109
142
  reference: string;
110
143
  description?: string;
@@ -114,6 +147,8 @@ interface PaymentRequestData {
114
147
  created_at: number;
115
148
  /** Expiry duration in seconds. */
116
149
  expiry_secs: number;
150
+ /** Optional asset identifier. Absent => native SOL (back-compat). */
151
+ asset?: PaymentAssetRef;
117
152
  }
118
153
  interface VerifyResult {
119
154
  verified: boolean;
@@ -125,7 +160,7 @@ interface VerifyOptions {
125
160
  intervalMs?: number;
126
161
  txSignature?: string;
127
162
  }
128
- type PaymentValidationCode = 'invalid_json' | 'invalid_amount' | 'missing_recipient' | 'invalid_recipient_address' | 'missing_reference' | 'invalid_reference_address' | 'recipient_mismatch' | 'expired' | 'future_timestamp' | 'fee_address_mismatch' | 'fee_amount_mismatch' | 'missing_fee' | 'invalid_fee_params';
163
+ type PaymentValidationCode = 'invalid_json' | 'invalid_amount' | 'missing_recipient' | 'invalid_recipient_address' | 'missing_reference' | 'invalid_reference_address' | 'recipient_mismatch' | 'expired' | 'future_timestamp' | 'fee_address_mismatch' | 'fee_amount_mismatch' | 'missing_fee' | 'invalid_fee_params' | 'invalid_asset';
129
164
  interface PaymentValidationError {
130
165
  code: PaymentValidationCode;
131
166
  message: string;
@@ -472,6 +507,7 @@ declare class SolanaPaymentStrategy implements PaymentStrategy {
472
507
  calculateFee(amount: number, config: ProtocolConfigInput): number;
473
508
  createPaymentRequest(recipientAddress: string, amount: number, config: ProtocolConfigInput, options?: {
474
509
  expirySecs?: number;
510
+ asset?: Asset;
475
511
  }): PaymentRequestData;
476
512
  validatePaymentRequest(requestJson: string, config: ProtocolConfigInput, expectedRecipient?: string, options?: {
477
513
  maxAmountLamports?: bigint;
@@ -490,16 +526,26 @@ declare class SolanaPaymentStrategy implements PaymentStrategy {
490
526
  private _verifyByReference;
491
527
  }
492
528
  /**
493
- * Build the System program transfer instructions for a payment request.
529
+ * Build the transfer instructions for a payment request.
530
+ *
531
+ * For native SOL (no `paymentRequest.asset` or asset=NATIVE_SOL), emits System
532
+ * program `TransferSol` instructions with the payment reference attached as a
533
+ * read-only, non-signer account so providers can detect the payment via
534
+ * `getSignaturesForAddress(reference)`.
535
+ *
536
+ * For SPL assets (USDC on Solana), emits:
537
+ * 1. `CreateAssociatedTokenIdempotent` for the recipient ATA (funded by payer);
538
+ * 2. `CreateAssociatedTokenIdempotent` for the treasury ATA if a protocol fee applies;
539
+ * 3. `TransferChecked` from payer ATA to recipient ATA, with `reference` as an
540
+ * extra read-only account (canonical Solana Pay pattern);
541
+ * 4. `TransferChecked` from payer ATA to treasury ATA if a fee applies.
494
542
  *
495
- * Returns the provider-amount transfer (with the payment reference attached
496
- * as a read-only, non-signer account) and, if present, the protocol-fee
497
- * transfer. Exposed so callers and tests can inspect amounts before signing.
543
+ * Async because SPL ATAs are PDAs and `findAssociatedTokenPda` is async.
498
544
  *
499
545
  * Caller is responsible for validating `paymentRequest` upstream;
500
546
  * `buildTransaction` already does that before invoking this helper.
501
547
  */
502
- declare function buildPaymentInstructions(paymentRequest: PaymentRequestData, payerSigner: Signer): readonly unknown[];
548
+ declare function buildPaymentInstructions(paymentRequest: PaymentRequestData, payerSigner: Signer): Promise<readonly unknown[]>;
503
549
  /**
504
550
  * Convenience wrapper: fetch the on-chain protocol config first, then build a
505
551
  * payment request using its current fee/treasury values.
@@ -565,6 +611,74 @@ interface RecentPrioritizationFeeLike {
565
611
  }
566
612
  declare function pickPercentileFee(samples: readonly RecentPrioritizationFeeLike[], percentile: number): bigint;
567
613
 
614
+ /**
615
+ * SOL-denominated fee estimator for payment requests.
616
+ *
617
+ * For a USDC payment the user still spends SOL to cover the base signature fee,
618
+ * the priority fee, and (for first-time recipients) the ATA rent-exemption
619
+ * deposit. Before calling `send_payment` the customer wants to know whether
620
+ * their SOL balance is sufficient - that's what this helper answers.
621
+ *
622
+ * Browser-safe: no Node-specific imports. The web dashboard will use the same
623
+ * function.
624
+ */
625
+
626
+ interface SolFeeEstimate {
627
+ /** Base per-signature fee. Currently 5000 lamports * 1 signature. */
628
+ baseFeeLamports: bigint;
629
+ /**
630
+ * Priority fee in lamports: `ceil(priorityFeeMicroLamports * computeUnitLimit
631
+ * / 1_000_000)`. Rounded up so we don't underestimate.
632
+ */
633
+ priorityFeeLamports: bigint;
634
+ /**
635
+ * Rent-exemption deposit for ATAs that the tx creates.
636
+ *
637
+ * 0 for native SOL. For SPL, `rentPerAta * (# of missing ATAs)`: recipient
638
+ * ATA is missing iff the recipient has never received this token; treasury
639
+ * ATA is missing only on the first-ever protocol fee into this mint.
640
+ */
641
+ rentLamports: bigint;
642
+ /** `baseFeeLamports + priorityFeeLamports + rentLamports`. */
643
+ totalLamports: bigint;
644
+ breakdown: {
645
+ numSignatures: number;
646
+ priorityFeeMicroLamports: bigint;
647
+ computeUnitLimit: number;
648
+ rentPerAtaLamports: bigint;
649
+ missingAtaCount: number;
650
+ };
651
+ }
652
+ interface EstimateSolFeeOptions {
653
+ /** Override the compute-unit limit used by `buildTransaction`. */
654
+ computeUnitLimit?: number;
655
+ /** Override the priority fee directly (skips RPC). */
656
+ priorityFeeMicroLamports?: bigint;
657
+ /**
658
+ * Percentile of the recent priority-fee distribution to charge when
659
+ * `priorityFeeMicroLamports` is not supplied. Defaults to 75.
660
+ */
661
+ priorityFeePercentile?: number;
662
+ /** Override the number of signatures. Defaults to 1. */
663
+ numSignatures?: number;
664
+ }
665
+ /**
666
+ * Estimate the SOL cost (in lamports) to submit the transaction that would pay
667
+ * this payment request from `payerAddress`.
668
+ *
669
+ * Returns a breakdown and a total. Does not submit anything on-chain.
670
+ */
671
+ declare function estimateSolFeeLamports(rpc: Rpc<SolanaRpcApi>, paymentRequest: PaymentRequestData, _payerAddress: string, options?: EstimateSolFeeOptions): Promise<SolFeeEstimate>;
672
+ /**
673
+ * Multi-line human-readable breakdown. Used by the MCP `estimate_payment_cost`
674
+ * tool and (in a future PR) by the web dashboard's pre-payment panel.
675
+ *
676
+ * We render lamports as raw integers and also show a SOL decimal with 9 places.
677
+ * The `@elisym/sdk` `formatAssetAmount` helper lives in assets.ts, but the
678
+ * formatter does not need to be identical; this stays dependency-free.
679
+ */
680
+ declare function formatFeeBreakdown(estimate: SolFeeEstimate): string;
681
+
568
682
  /**
569
683
  * Wire-shape for a NIP-90 payment_request blob, as parsed via JSON.parse.
570
684
  *
@@ -582,6 +696,22 @@ declare const PaymentRequestSchema: z.ZodObject<{
582
696
  fee_amount: z.ZodOptional<z.ZodNumber>;
583
697
  created_at: z.ZodNumber;
584
698
  expiry_secs: z.ZodNumber;
699
+ asset: z.ZodOptional<z.ZodObject<{
700
+ chain: z.ZodString;
701
+ token: z.ZodString;
702
+ mint: z.ZodOptional<z.ZodString>;
703
+ decimals: z.ZodNumber;
704
+ }, "strip", z.ZodTypeAny, {
705
+ chain: string;
706
+ token: string;
707
+ decimals: number;
708
+ mint?: string | undefined;
709
+ }, {
710
+ chain: string;
711
+ token: string;
712
+ decimals: number;
713
+ mint?: string | undefined;
714
+ }>>;
585
715
  }, "strip", z.ZodTypeAny, {
586
716
  recipient: string;
587
717
  amount: number;
@@ -591,6 +721,12 @@ declare const PaymentRequestSchema: z.ZodObject<{
591
721
  description?: string | undefined;
592
722
  fee_address?: string | undefined;
593
723
  fee_amount?: number | undefined;
724
+ asset?: {
725
+ chain: string;
726
+ token: string;
727
+ decimals: number;
728
+ mint?: string | undefined;
729
+ } | undefined;
594
730
  }, {
595
731
  recipient: string;
596
732
  amount: number;
@@ -600,6 +736,12 @@ declare const PaymentRequestSchema: z.ZodObject<{
600
736
  description?: string | undefined;
601
737
  fee_address?: string | undefined;
602
738
  fee_amount?: number | undefined;
739
+ asset?: {
740
+ chain: string;
741
+ token: string;
742
+ decimals: number;
743
+ mint?: string | undefined;
744
+ } | undefined;
603
745
  }>;
604
746
  type ParsedPaymentRequest = z.infer<typeof PaymentRequestSchema>;
605
747
  interface ParseOptions {
@@ -836,4 +978,4 @@ declare const LIMITS: {
836
978
  readonly MAX_CAPABILITY_LENGTH: 64;
837
979
  };
838
980
 
839
- export { type Agent, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkStats, NostrPool, PROTOCOL_FEE_BPS, PROTOCOL_PROGRAM_ID_DEVNET, PROTOCOL_TREASURY, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, RELAYS, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimatePriorityFeeMicroLamports, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry };
981
+ export { type Agent, Asset, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type EstimateSolFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkStats, NostrPool, PROTOCOL_FEE_BPS, PROTOCOL_PROGRAM_ID_DEVNET, PROTOCOL_TREASURY, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentAssetRef, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, RELAYS, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { Address, TransactionSigner, Rpc, SolanaRpcApi } from '@solana/kit';
2
2
  import { Filter, Event } from 'nostr-tools';
3
+ import { A as Asset } from './assets-CMf-v55Z.js';
4
+ export { C as Chain, K as KNOWN_ASSETS, N as NATIVE_SOL, U as USDC_SOLANA_DEVNET, a as assetByKey, b as assetKey, f as formatAssetAmount, p as parseAssetAmount, r as resolveAssetFromPaymentRequest, c as resolveKnownAsset } from './assets-CMf-v55Z.js';
3
5
  import { z } from 'zod';
6
+ export { G as GlobalConfig, a as GlobalConfigSchema, S as SessionSpendLimitEntry, b as SessionSpendLimitEntrySchema } from './global-schema-CddHP2nk.js';
4
7
 
5
8
  declare class ElisymIdentity {
6
9
  private _secretKey;
@@ -36,8 +39,21 @@ interface PaymentInfo {
36
39
  chain: string;
37
40
  network: string;
38
41
  address: string;
39
- /** Price in lamports (must be non-negative integer). */
42
+ /**
43
+ * Price in subunits of the payment asset (non-negative integer).
44
+ *
45
+ * Subunit = smallest indivisible unit: 1 lamport for SOL, 1 "cent" (1e-6 USDC)
46
+ * for USDC. When `token` is omitted, subunits are lamports (back-compat).
47
+ */
40
48
  job_price?: number;
49
+ /** Lowercase token id (e.g. 'sol', 'usdc'). Absent => native SOL. */
50
+ token?: string;
51
+ /** SPL mint / ERC-20 contract. Undefined for native coin. */
52
+ mint?: string;
53
+ /** Subunits per whole (9 for SOL, 6 for USDC). */
54
+ decimals?: number;
55
+ /** Display symbol (e.g. 'SOL', 'USDC'). */
56
+ symbol?: string;
41
57
  }
42
58
  /** Agent discovered from the network. */
43
59
  interface Agent {
@@ -102,9 +118,26 @@ interface PingResult {
102
118
  /** The identity used for the ping session - reuse for job submission so pubkeys match. */
103
119
  identity: ElisymIdentity | null;
104
120
  }
121
+ /**
122
+ * Wire-shape reference to an asset inside a payment request.
123
+ *
124
+ * Same shape as `Asset` minus the display-only `symbol` field. Absent = native
125
+ * SOL (back-compat for payment requests published before multi-asset support).
126
+ */
127
+ interface PaymentAssetRef {
128
+ chain: string;
129
+ token: string;
130
+ mint?: string;
131
+ decimals: number;
132
+ }
105
133
  interface PaymentRequestData {
106
134
  recipient: string;
107
- /** Total amount in lamports (must be positive integer). */
135
+ /**
136
+ * Total amount in subunits of the payment asset (must be positive integer).
137
+ *
138
+ * - For native SOL (asset absent / `token: 'sol'`): lamports (1e-9 SOL).
139
+ * - For SPL USDC: 1e-6 USDC.
140
+ */
108
141
  amount: number;
109
142
  reference: string;
110
143
  description?: string;
@@ -114,6 +147,8 @@ interface PaymentRequestData {
114
147
  created_at: number;
115
148
  /** Expiry duration in seconds. */
116
149
  expiry_secs: number;
150
+ /** Optional asset identifier. Absent => native SOL (back-compat). */
151
+ asset?: PaymentAssetRef;
117
152
  }
118
153
  interface VerifyResult {
119
154
  verified: boolean;
@@ -125,7 +160,7 @@ interface VerifyOptions {
125
160
  intervalMs?: number;
126
161
  txSignature?: string;
127
162
  }
128
- type PaymentValidationCode = 'invalid_json' | 'invalid_amount' | 'missing_recipient' | 'invalid_recipient_address' | 'missing_reference' | 'invalid_reference_address' | 'recipient_mismatch' | 'expired' | 'future_timestamp' | 'fee_address_mismatch' | 'fee_amount_mismatch' | 'missing_fee' | 'invalid_fee_params';
163
+ type PaymentValidationCode = 'invalid_json' | 'invalid_amount' | 'missing_recipient' | 'invalid_recipient_address' | 'missing_reference' | 'invalid_reference_address' | 'recipient_mismatch' | 'expired' | 'future_timestamp' | 'fee_address_mismatch' | 'fee_amount_mismatch' | 'missing_fee' | 'invalid_fee_params' | 'invalid_asset';
129
164
  interface PaymentValidationError {
130
165
  code: PaymentValidationCode;
131
166
  message: string;
@@ -472,6 +507,7 @@ declare class SolanaPaymentStrategy implements PaymentStrategy {
472
507
  calculateFee(amount: number, config: ProtocolConfigInput): number;
473
508
  createPaymentRequest(recipientAddress: string, amount: number, config: ProtocolConfigInput, options?: {
474
509
  expirySecs?: number;
510
+ asset?: Asset;
475
511
  }): PaymentRequestData;
476
512
  validatePaymentRequest(requestJson: string, config: ProtocolConfigInput, expectedRecipient?: string, options?: {
477
513
  maxAmountLamports?: bigint;
@@ -490,16 +526,26 @@ declare class SolanaPaymentStrategy implements PaymentStrategy {
490
526
  private _verifyByReference;
491
527
  }
492
528
  /**
493
- * Build the System program transfer instructions for a payment request.
529
+ * Build the transfer instructions for a payment request.
530
+ *
531
+ * For native SOL (no `paymentRequest.asset` or asset=NATIVE_SOL), emits System
532
+ * program `TransferSol` instructions with the payment reference attached as a
533
+ * read-only, non-signer account so providers can detect the payment via
534
+ * `getSignaturesForAddress(reference)`.
535
+ *
536
+ * For SPL assets (USDC on Solana), emits:
537
+ * 1. `CreateAssociatedTokenIdempotent` for the recipient ATA (funded by payer);
538
+ * 2. `CreateAssociatedTokenIdempotent` for the treasury ATA if a protocol fee applies;
539
+ * 3. `TransferChecked` from payer ATA to recipient ATA, with `reference` as an
540
+ * extra read-only account (canonical Solana Pay pattern);
541
+ * 4. `TransferChecked` from payer ATA to treasury ATA if a fee applies.
494
542
  *
495
- * Returns the provider-amount transfer (with the payment reference attached
496
- * as a read-only, non-signer account) and, if present, the protocol-fee
497
- * transfer. Exposed so callers and tests can inspect amounts before signing.
543
+ * Async because SPL ATAs are PDAs and `findAssociatedTokenPda` is async.
498
544
  *
499
545
  * Caller is responsible for validating `paymentRequest` upstream;
500
546
  * `buildTransaction` already does that before invoking this helper.
501
547
  */
502
- declare function buildPaymentInstructions(paymentRequest: PaymentRequestData, payerSigner: Signer): readonly unknown[];
548
+ declare function buildPaymentInstructions(paymentRequest: PaymentRequestData, payerSigner: Signer): Promise<readonly unknown[]>;
503
549
  /**
504
550
  * Convenience wrapper: fetch the on-chain protocol config first, then build a
505
551
  * payment request using its current fee/treasury values.
@@ -565,6 +611,74 @@ interface RecentPrioritizationFeeLike {
565
611
  }
566
612
  declare function pickPercentileFee(samples: readonly RecentPrioritizationFeeLike[], percentile: number): bigint;
567
613
 
614
+ /**
615
+ * SOL-denominated fee estimator for payment requests.
616
+ *
617
+ * For a USDC payment the user still spends SOL to cover the base signature fee,
618
+ * the priority fee, and (for first-time recipients) the ATA rent-exemption
619
+ * deposit. Before calling `send_payment` the customer wants to know whether
620
+ * their SOL balance is sufficient - that's what this helper answers.
621
+ *
622
+ * Browser-safe: no Node-specific imports. The web dashboard will use the same
623
+ * function.
624
+ */
625
+
626
+ interface SolFeeEstimate {
627
+ /** Base per-signature fee. Currently 5000 lamports * 1 signature. */
628
+ baseFeeLamports: bigint;
629
+ /**
630
+ * Priority fee in lamports: `ceil(priorityFeeMicroLamports * computeUnitLimit
631
+ * / 1_000_000)`. Rounded up so we don't underestimate.
632
+ */
633
+ priorityFeeLamports: bigint;
634
+ /**
635
+ * Rent-exemption deposit for ATAs that the tx creates.
636
+ *
637
+ * 0 for native SOL. For SPL, `rentPerAta * (# of missing ATAs)`: recipient
638
+ * ATA is missing iff the recipient has never received this token; treasury
639
+ * ATA is missing only on the first-ever protocol fee into this mint.
640
+ */
641
+ rentLamports: bigint;
642
+ /** `baseFeeLamports + priorityFeeLamports + rentLamports`. */
643
+ totalLamports: bigint;
644
+ breakdown: {
645
+ numSignatures: number;
646
+ priorityFeeMicroLamports: bigint;
647
+ computeUnitLimit: number;
648
+ rentPerAtaLamports: bigint;
649
+ missingAtaCount: number;
650
+ };
651
+ }
652
+ interface EstimateSolFeeOptions {
653
+ /** Override the compute-unit limit used by `buildTransaction`. */
654
+ computeUnitLimit?: number;
655
+ /** Override the priority fee directly (skips RPC). */
656
+ priorityFeeMicroLamports?: bigint;
657
+ /**
658
+ * Percentile of the recent priority-fee distribution to charge when
659
+ * `priorityFeeMicroLamports` is not supplied. Defaults to 75.
660
+ */
661
+ priorityFeePercentile?: number;
662
+ /** Override the number of signatures. Defaults to 1. */
663
+ numSignatures?: number;
664
+ }
665
+ /**
666
+ * Estimate the SOL cost (in lamports) to submit the transaction that would pay
667
+ * this payment request from `payerAddress`.
668
+ *
669
+ * Returns a breakdown and a total. Does not submit anything on-chain.
670
+ */
671
+ declare function estimateSolFeeLamports(rpc: Rpc<SolanaRpcApi>, paymentRequest: PaymentRequestData, _payerAddress: string, options?: EstimateSolFeeOptions): Promise<SolFeeEstimate>;
672
+ /**
673
+ * Multi-line human-readable breakdown. Used by the MCP `estimate_payment_cost`
674
+ * tool and (in a future PR) by the web dashboard's pre-payment panel.
675
+ *
676
+ * We render lamports as raw integers and also show a SOL decimal with 9 places.
677
+ * The `@elisym/sdk` `formatAssetAmount` helper lives in assets.ts, but the
678
+ * formatter does not need to be identical; this stays dependency-free.
679
+ */
680
+ declare function formatFeeBreakdown(estimate: SolFeeEstimate): string;
681
+
568
682
  /**
569
683
  * Wire-shape for a NIP-90 payment_request blob, as parsed via JSON.parse.
570
684
  *
@@ -582,6 +696,22 @@ declare const PaymentRequestSchema: z.ZodObject<{
582
696
  fee_amount: z.ZodOptional<z.ZodNumber>;
583
697
  created_at: z.ZodNumber;
584
698
  expiry_secs: z.ZodNumber;
699
+ asset: z.ZodOptional<z.ZodObject<{
700
+ chain: z.ZodString;
701
+ token: z.ZodString;
702
+ mint: z.ZodOptional<z.ZodString>;
703
+ decimals: z.ZodNumber;
704
+ }, "strip", z.ZodTypeAny, {
705
+ chain: string;
706
+ token: string;
707
+ decimals: number;
708
+ mint?: string | undefined;
709
+ }, {
710
+ chain: string;
711
+ token: string;
712
+ decimals: number;
713
+ mint?: string | undefined;
714
+ }>>;
585
715
  }, "strip", z.ZodTypeAny, {
586
716
  recipient: string;
587
717
  amount: number;
@@ -591,6 +721,12 @@ declare const PaymentRequestSchema: z.ZodObject<{
591
721
  description?: string | undefined;
592
722
  fee_address?: string | undefined;
593
723
  fee_amount?: number | undefined;
724
+ asset?: {
725
+ chain: string;
726
+ token: string;
727
+ decimals: number;
728
+ mint?: string | undefined;
729
+ } | undefined;
594
730
  }, {
595
731
  recipient: string;
596
732
  amount: number;
@@ -600,6 +736,12 @@ declare const PaymentRequestSchema: z.ZodObject<{
600
736
  description?: string | undefined;
601
737
  fee_address?: string | undefined;
602
738
  fee_amount?: number | undefined;
739
+ asset?: {
740
+ chain: string;
741
+ token: string;
742
+ decimals: number;
743
+ mint?: string | undefined;
744
+ } | undefined;
603
745
  }>;
604
746
  type ParsedPaymentRequest = z.infer<typeof PaymentRequestSchema>;
605
747
  interface ParseOptions {
@@ -836,4 +978,4 @@ declare const LIMITS: {
836
978
  readonly MAX_CAPABILITY_LENGTH: 64;
837
979
  };
838
980
 
839
- export { type Agent, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkStats, NostrPool, PROTOCOL_FEE_BPS, PROTOCOL_PROGRAM_ID_DEVNET, PROTOCOL_TREASURY, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, RELAYS, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimatePriorityFeeMicroLamports, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry };
981
+ export { type Agent, Asset, BoundedSet, type BuildTransactionOptions, type CapabilityCard, DEFAULTS, DEFAULT_KIND_OFFSET, DEFAULT_REDACT_PATHS, DiscoveryService, ElisymClient, type ElisymClientConfig, type ElisymClientFullConfig, ElisymIdentity, type EstimatePriorityFeeOptions, type EstimateSolFeeOptions, type GetProtocolConfigOptions, INPUT_REDACT_PATHS, type Job, type JobStatus, type JobSubscriptionOptions, type JobUpdateCallbacks, KIND_APP_HANDLER, KIND_JOB_FEEDBACK, KIND_JOB_REQUEST, KIND_JOB_REQUEST_BASE, KIND_JOB_RESULT, KIND_JOB_RESULT_BASE, KIND_PING, KIND_PONG, LAMPORTS_PER_SOL, LIMITS, MarketplaceService, MediaService, type Network, type NetworkStats, NostrPool, PROTOCOL_FEE_BPS, PROTOCOL_PROGRAM_ID_DEVNET, PROTOCOL_TREASURY, type ParseOptions, type ParseResult, type ParsedPaymentRequest, type PaymentAssetRef, type PaymentInfo, type PaymentRequestData, PaymentRequestSchema, type PaymentStrategy, type PaymentValidationCode, type PaymentValidationError, type PingResult, PingService, type ProtocolCluster, type ProtocolConfig, type ProtocolConfigInput, RELAYS, type RateLimitDecision, SECRET_REDACT_PATHS, type Signer, type SlidingWindowLimiter, type SlidingWindowLimiterOptions, type SolFeeEstimate, SolanaPaymentStrategy, type SubCloser, type SubmitJobOptions, type VerifyOptions, type VerifyResult, assertExpiry, assertLamports, buildPaymentInstructions, calculateProtocolFee, clearPriorityFeeCache, clearProtocolConfigCache, createPaymentRequestWithOnchainConfig, createSlidingWindowLimiter, estimatePriorityFeeMicroLamports, estimateSolFeeLamports, formatFeeBreakdown, formatSol, getProtocolConfig, getProtocolProgramId, jobRequestKind, jobResultKind, makeCensor, nip44Decrypt, nip44Encrypt, parsePaymentRequest, pickPercentileFee, timeAgo, toDTag, truncateKey, validateAgentName, validateExpiry };