@rhea-finance/cross-chain-aggregation-dex 2.1.6-rc.0 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -207,7 +207,7 @@ The application only provides the request fields and the relevant wallet adapter
207
207
  pnpm add @rhea-finance/cross-chain-aggregation-dex
208
208
  ```
209
209
 
210
- Node.js 20 or later is required.
210
+ Node.js 16 or later is required. When running on Node.js 16 without a global `fetch`, inject a compatible implementation through `SwapClientConfig.fetch`.
211
211
 
212
212
  ## 3. Recommended: simple quote → swap flow
213
213
 
@@ -325,8 +325,6 @@ const confidentialQuote = await client.quote({
325
325
  });
326
326
  ```
327
327
 
328
- This basic route is a single public-wallet swap with confidential reporting. For the complete private-balance flow with pre-swap, deposit, linking-wallet authorization, and signed withdrawal, use the dedicated confidential methods below.
329
-
330
328
  #### 3.3.1 Configure quote timing
331
329
 
332
330
  `quoteWaitingTimeMs`, `sameChainTimeoutMs`, and `crossChainTimeoutMs` are first-class SDK parameters. Pass them directly to `client.quote()`; do not put them in `extensions` or executor configuration.
@@ -431,499 +429,6 @@ const status = await client.getOrderStatus(
431
429
 
432
430
  Terminal statuses are `completed`, `failed`, `refunded`, and `expired`.
433
431
 
434
- ### 3.6 Complete confidential pre-swap → deposit → withdraw
435
-
436
- The confidential flow uses two wallet roles. They may point to the same connected
437
- wallet, but they have different responsibilities:
438
-
439
- | Role | Responsibility | Supported chains |
440
- | --- | --- | --- |
441
- | Linking wallet | Signs the confidential-account authorization and every withdrawal intent. It never supplies a private key to the SDK. | NEAR, EVM, Solana, Tron |
442
- | Funding wallet | Validates the selected source account and sends the direct deposit. For a pre-swap, the existing v2 executor sends the swap transaction. | Any chain supported by a supplied `ConfidentialFundingAdapter` and, for pre-swaps, a registered v2 executor |
443
-
444
- The SDK obtains the unsigned authorization or withdrawal payload from the
445
- protocol, passes that exact payload to the application's wallet adapter, verifies
446
- the returned signer and signature locally, and then submits it. The application
447
- is responsible only for connecting the wallet and exposing its signing methods;
448
- do not pass a private key to the SDK.
449
-
450
- #### 3.6.1 Configure the client
451
-
452
- Configure the confidential protocol client and wallet adapters once. The source
453
- funding wallet may differ from the linking wallet:
454
-
455
- ```ts
456
- import {
457
- HttpConfidentialApi,
458
- SwapClient,
459
- createConfidentialEvmSigningAdapter,
460
- type ConfidentialExecutionStore,
461
- type ConfidentialFundingAdapter,
462
- type ConfidentialSessionStore,
463
- } from "@rhea-finance/cross-chain-aggregation-dex";
464
-
465
- const confidentialApi = new HttpConfidentialApi({
466
- directUrl: "https://1click.chaindefuser.com/v0",
467
- proxyUrl: "https://api.rhea.finance/proxy/1click/v0",
468
- indexerUrl: "https://api.rhea.finance",
469
- nearRpcUrl: "https://rpc.mainnet.near.org",
470
- withdrawAuthorization: "signed-payload",
471
- });
472
-
473
- // Wrap the application's connected wallet. The SDK requests a signature only
474
- // when authorization is required or a withdrawal intent must be signed.
475
- const linking = createConfidentialEvmSigningAdapter(() => ({
476
- getAddress: () => evmWallet.getAddress(),
477
- signMessage: (message) => evmWallet.signMessage(message),
478
- }));
479
-
480
- // Implement this with the application's existing source-chain wallet SDK.
481
- // validate() must not broadcast. transfer() must recheck the active account
482
- // before signing and return the real source transaction hash.
483
- const funding: ConfidentialFundingAdapter = {
484
- async getIdentity() {
485
- return {
486
- kind: "evm",
487
- accountId: await sourceWallet.getAddress(),
488
- chain: String(await sourceWallet.getChainId()),
489
- };
490
- },
491
- async validate(token) {
492
- await assertSourceWalletCanFund(sourceWallet, token);
493
- },
494
- async transfer(input, signal) {
495
- const txHash = await sendSourceDeposit(sourceWallet, {
496
- token: input.token,
497
- amount: input.amount,
498
- recipient: input.address,
499
- memo: input.memo,
500
- signal,
501
- });
502
- return { txHash };
503
- },
504
- };
505
-
506
- const sessionStore: ConfidentialSessionStore = appSessionStore;
507
- const executionStore: ConfidentialExecutionStore = appExecutionStore;
508
-
509
- const client = new SwapClient({
510
- baseUrl: "https://api.rhea.finance",
511
- // The confidential app-fee endpoint uses the same JWT as v2 quote/build.
512
- getAccessToken: () => sessionStorage.getItem("access-token") ?? "",
513
- executors: sourceChainExecutors,
514
- confidential: {
515
- api: confidentialApi,
516
- signingAdapters: [linking],
517
- fundingAdapters: [funding],
518
- sessionStore,
519
- executionStore,
520
- preSwap: {
521
- mapAsset: token => v2AssetMap.get(token.assetId),
522
- },
523
- },
524
- });
525
- ```
526
-
527
- `fundingAdapters` are still required for a non-direct route: the adapter binds
528
- and validates the source identity before the SDK lets the v2 executor broadcast.
529
- The pre-swap itself uses this package's existing v2 quote, build and executor
530
- pipeline, so the corresponding source-chain executor must also be present in
531
- `SwapClient.executors`.
532
-
533
- Before every new confidential quote or preview, the SDK calls
534
- `GET /api/swap/confidential-app-fee` on `baseUrl`. The request reuses the normal
535
- V2 `apiKey` or `getAccessToken` Bearer JWT. The response is validated and frozen
536
- into the quote plan so all dry and formal withdrawal quotes use the fee the user
537
- reviewed. A `confidentialAppFeeBps` value of `0` explicitly sends an empty
538
- `appFees` list. If the fee configuration cannot be loaded or is malformed, the
539
- confidential quote fails instead of falling back to a stale fee.
540
-
541
- Confidential client configuration:
542
-
543
- | Field | Required | Purpose |
544
- | --- | --- | --- |
545
- | `api` | Yes | `HttpConfidentialApi` or another implementation of `ConfidentialProtocolApi`. |
546
- | `signingAdapters` | Yes | Connected linking-wallet adapters available for authorization and withdrawal signing. |
547
- | `fundingAdapters` | For wallet-funded execution | Source-wallet identity validation and direct deposit transfer. |
548
- | `sessionStore` | No | Persists confidential login sessions. Defaults to `MemorySessionStore`. |
549
- | `executionStore` | No | Persists wallet-funded execution checkpoints. Defaults to `MemoryExecutionStore`. |
550
- | `registryTokens` | No | Fixed registry override. Otherwise tokens are loaded through `api`. |
551
- | `intentsContract` | No | Authorization verifier. Defaults to the API value or `intents.near`. |
552
- | `maxQuoteAgeMs` | No | Maximum plan review age. Default: `600000` (10 minutes). |
553
- | `polling` | No | `{ intervalMs, maxAttempts }`; omitted or zero `maxAttempts` means no attempt cap. |
554
- | `addressValidator` | For unsupported address formats | Required for BTC, Zcash, or another destination format without built-in validation. |
555
- | `preferredMidAssetId` | No | Previously successful pre-swap funding asset to try first. |
556
- | `onSuccessfulMidToken` | No | Records a successful funding asset for future route preference. |
557
- | `verifyWithdrawIntent` | No | Application hook for additional protocol-specific effect validation before signing. |
558
- | `preSwap` | No | Controls the v2 pre-swap mapping, quote timing and advanced report metadata. |
559
-
560
- `preSwap.mapAsset(token)` returns the v2 `{ chain, address }` for a source or
561
- registry token. The optional `quoteWaitingTimeMs`, `sameChainTimeoutMs`, and
562
- `crossChainTimeoutMs` are forwarded only to the v2 funding quotes. Optional
563
- `multiAddress` and `txType` customize the advanced funding report; `txType`
564
- defaults to `confidential-batch-withdraw`.
565
-
566
- `HttpConfidentialApi` requires `directUrl`, `proxyUrl`, `indexerUrl`, and
567
- `nearRpcUrl`. Its optional integration fields are `intentsContract`, `fetch`,
568
- `withdrawAuthorization`, `referral`, `appFees`, and `requestTimeoutMs`. Keep
569
- `withdrawAuthorization: "signed-payload"` unless the deployed backend explicitly
570
- requires Bearer authorization for private withdrawals. `HttpConfidentialApi`
571
- still has a standalone default of 2 bps paid to `dcl0001.near`, but
572
- `SwapClient` overrides it per plan with `/api/swap/confidential-app-fee`.
573
- Configured fees apply only to withdrawal quotes, not the funding deposit quote.
574
-
575
- #### 3.6.2 Wallet signing adapters
576
-
577
- Use the helper matching the linking wallet. Each helper checks that the connected
578
- account has not changed while the prompt is open and validates the returned
579
- signature before it is sent to the service.
580
-
581
- | Helper | Wallet methods supplied by the application | Signed standard |
582
- | --- | --- | --- |
583
- | `createConfidentialEvmSigningAdapter` | `getAddress(): Promise<string>` and `signMessage(message: string): Promise<string>` | ERC-191 |
584
- | `createConfidentialSolanaSigningAdapter` | `publicKey.toBase58()` and `signMessage(message: Uint8Array)` | raw Ed25519 |
585
- | `createConfidentialTronSigningAdapter` | `getAddress()` and `signMessageV2(message: string)` | TIP-191 |
586
- | `createConfidentialNearSigningAdapter` | `getIdentity()` and NEP-413 `signMessage(...)` | NEP-413 |
587
-
588
- Examples for Solana and Tron wallets whose provider already exposes the expected
589
- methods:
590
-
591
- ```ts
592
- import {
593
- createConfidentialSolanaSigningAdapter,
594
- createConfidentialTronSigningAdapter,
595
- } from "@rhea-finance/cross-chain-aggregation-dex";
596
-
597
- const solanaLinking = createConfidentialSolanaSigningAdapter(() => ({
598
- publicKey: solanaWallet.publicKey,
599
- signMessage: message => solanaWallet.signMessage(message),
600
- }));
601
-
602
- const tronLinking = createConfidentialTronSigningAdapter(() => ({
603
- getAddress: () => tronWallet.defaultAddress.base58,
604
- signMessageV2: message => tronWallet.trx.signMessageV2(message),
605
- }));
606
- ```
607
-
608
- NEAR named accounts may need one explicit `add_public_key` transaction before
609
- their first authorization. Supply `registerPublicKey`; the adapter checks the
610
- Intents contract before and after registration. Implicit accounts do not need
611
- registration, but their account ID must match the signing public key.
612
-
613
- ```ts
614
- import {
615
- createConfidentialNearSigningAdapter,
616
- } from "@rhea-finance/cross-chain-aggregation-dex";
617
-
618
- const nearLinking = createConfidentialNearSigningAdapter(
619
- {
620
- getIdentity: () => nearWallet.getIdentity(),
621
- signMessage: request => nearWallet.signMessage(request),
622
- registerPublicKey: (accountId, publicKey, contract, signal) =>
623
- registerNearIntentsKey({
624
- accountId,
625
- publicKey,
626
- contract,
627
- signal,
628
- }),
629
- },
630
- confidentialApi
631
- );
632
- ```
633
-
634
- Register every currently selectable linking-wallet adapter in
635
- `confidential.signingAdapters`. BTC, Zcash, Aptos and Sui may be funding wallets,
636
- but they cannot be linking wallets.
637
-
638
- #### 3.6.3 Authorization and sessions
639
-
640
- `confidentialSwap()` authenticates the frozen linking identity before it sends
641
- source funds. A valid session is reused, an expiring access token is refreshed,
642
- and a new wallet signature is requested only when no usable session remains.
643
- For explicit login UX, authorize before opening the final confirmation screen:
644
-
645
- ```ts
646
- const linkingIdentity = await linking.getIdentity();
647
-
648
- if (
649
- await client.requiresConfidentialAuthentication(linkingIdentity)
650
- ) {
651
- await client.authenticateConfidentialWallet(linkingIdentity);
652
- }
653
-
654
- const balances = await client.getConfidentialBalances(linkingIdentity);
655
-
656
- // Remove the locally stored confidential session for this identity.
657
- await client.logoutConfidentialWallet(linkingIdentity);
658
- ```
659
-
660
- Calling `requiresConfidentialAuthentication()` may validate or refresh an
661
- existing session, but it never opens the wallet. Concurrent authentication calls
662
- for the same identity share one in-flight request, so they do not create multiple
663
- signature prompts.
664
-
665
- The default `MemorySessionStore` loses the login on reload. Supply a
666
- `ConfidentialSessionStore` for a persistent application session:
667
-
668
- ```ts
669
- import type {
670
- ConfidentialLogin,
671
- ConfidentialSessionStore,
672
- } from "@rhea-finance/cross-chain-aggregation-dex";
673
-
674
- class BrowserSessionStore implements ConfidentialSessionStore {
675
- private storageKey(key: string) {
676
- return `rhea:confidential-session:${key}`;
677
- }
678
-
679
- async get(key: string): Promise<ConfidentialLogin | undefined> {
680
- const storageKey = this.storageKey(key);
681
- const value = sessionStorage.getItem(storageKey);
682
- if (!value) return undefined;
683
- try {
684
- return JSON.parse(value) as ConfidentialLogin;
685
- } catch {
686
- sessionStorage.removeItem(storageKey);
687
- return undefined;
688
- }
689
- }
690
-
691
- async set(key: string, login: ConfidentialLogin): Promise<void> {
692
- sessionStorage.setItem(this.storageKey(key), JSON.stringify(login));
693
- }
694
-
695
- async delete(key: string): Promise<void> {
696
- sessionStorage.removeItem(this.storageKey(key));
697
- }
698
- }
699
- ```
700
-
701
- This browser implementation is an integration example, not a universal security
702
- policy. A stored login contains access and refresh tokens. Treat it as a
703
- credential, choose storage appropriate to the application's threat model, clear
704
- it on logout, and never log it. `sessionStorage` remains accessible to JavaScript
705
- running in the same origin and therefore depends on the application's XSS
706
- protections.
707
-
708
- #### 3.6.4 Quote and execute
709
-
710
- Fetch the source token from the normal v2 selector and the destination token from
711
- the confidential registry. The source may be any v2-supported asset; the
712
- destination must resolve to a registered confidential withdrawal asset. Do not
713
- construct `assetId` values from symbols. Amounts are base-unit integer strings.
714
-
715
- ```ts
716
- import type {
717
- ConfidentialToken,
718
- } from "@rhea-finance/cross-chain-aggregation-dex";
719
-
720
- const sourceCandidates = await client.getFromTokens({
721
- chainId: sourceTokenListChainId,
722
- });
723
- const confidentialTokens = await client.getConfidentialTokens();
724
- const selectedSource = sourceCandidates.find(
725
- token => token.address === selectedSourceAddress
726
- )!;
727
-
728
- const sourceToken: ConfidentialToken = {
729
- ...selectedSource,
730
- swapChain: selectedSource.chain,
731
- swapAddress: selectedSource.address,
732
- };
733
-
734
- const destinationToken = confidentialTokens.find(
735
- token => token.assetId === selectedDestinationAssetId
736
- )!;
737
-
738
- const sourceIdentity = await funding.getIdentity();
739
- const linkingIdentity = await linking.getIdentity();
740
-
741
- const plan = await client.quoteConfidentialSwap({
742
- sourceToken,
743
- destinationToken,
744
- amount: "1000000",
745
- sourceWallet: sourceIdentity,
746
- linkingWallet: linkingIdentity,
747
- recipients: [destinationAddress],
748
- slippageBps: 50,
749
- });
750
-
751
- // Review plan.route, plan.previews, plan.expectedOut, plan.minAmountOut,
752
- // plan.withdrawFee, and both frozen wallet identities before confirmation.
753
- const result = await client.confidentialSwap({
754
- plan,
755
- onProgress(snapshot) {
756
- persistPublicProgress(snapshot);
757
- },
758
- onSignatureProgress(progress) {
759
- showSignatureProgress(progress.completed, progress.total);
760
- },
761
- });
762
- ```
763
-
764
- Confidential quote fields:
765
-
766
- | Field | Required | Meaning |
767
- | --- | --- | --- |
768
- | `sourceToken` | Yes | Source-chain token being spent. It may be outside the confidential registry; include or map its v2 chain/address for a pre-swap. |
769
- | `destinationToken` | Yes | Confidential-registry token delivered to every recipient. |
770
- | `amount` | Yes | Source amount as a positive base-unit integer string. |
771
- | `sourceWallet` | Yes | Frozen funding identity: `{ kind, accountId, chain }`. |
772
- | `linkingWallet` | Yes for executable quote | Frozen authorization identity returned by a signing adapter. |
773
- | `recipients` | Yes | Between 1 and 10 unique destination addresses on the destination token's chain. |
774
- | `slippageBps` | Yes | Slippage in basis points; `50` means 0.5%. |
775
- | `fundingSource` | No | `"wallet"` by default; `"balance"` spends an existing confidential balance without source funding. |
776
- | `mode` | No | `"SWAP"` by default. `"TRANSFER"` requires the funding and destination asset to be the same. |
777
-
778
- The quote planner matches the multi-chain Trade flow. It prefers a direct
779
- registered Intents asset, then a same-chain USDC/USDT/USDT0 pre-swap, then a
780
- cross-chain funding asset. Non-direct paths use this SDK's v2
781
- quote/build/execute pipeline. The first v2 quote estimates the FLEX input; after
782
- 1Click allocates the deposit address, the SDK obtains a second v2 quote with that
783
- exact address as recipient.
784
-
785
- `ConfidentialToken.assetId` and `blockchain` identify the Intents registry asset.
786
- Tokens participating in a v2 pre-swap must also resolve to a v2 chain and
787
- address. Set `swapChain` and `swapAddress` on the token, or provide
788
- `confidential.preSwap.mapAsset` for registry tokens. A normalized SDK token can
789
- normally be mapped with `swapChain: token.chain` and
790
- `swapAddress: token.address`. Do not match or merge assets by symbol alone.
791
-
792
- Execution performs these operations in order:
793
-
794
- 1. Load and freeze the app-fee configuration with the V2 JWT.
795
- 2. Authorize or refresh the linking-wallet session.
796
- 3. Record the complete confidential balance baseline, then re-quote stale funding prices.
797
- 4. Send a direct deposit or execute the v2 pre-swap to the allocated deposit address.
798
- 5. Wait for the actual credited amount and detect the credited Intents token from the full balance delta; quoted output and the v2 token address are not treated as proof of funds.
799
- 6. Re-quote withdrawals from the credited amount and ask the linking wallet to sign each generated intent.
800
- 7. Submit the private withdrawal batch and poll every final deposit address.
801
-
802
- Progress snapshots expose `baselineBalances` and `creditedTokenId`. This matters
803
- for registry entries whose quote asset uses a per-chain `1cs_v1:*` identifier but
804
- whose confidential balance settles under a `nep141:*.omft.near` identifier. The
805
- SDK persists the complete pre-funding balance set and uses the token whose balance
806
- actually increased for the availability check before withdrawal.
807
-
808
- `quoteConfidentialSwap()` may allocate deposit addresses but never signs or
809
- broadcasts. `previewConfidentialSwap()` always returns `executable: false`. A
810
- preview without `linkingWallet` uses a display-only placeholder and cannot be
811
- executed. To review first and execute later, pass the real connected
812
- `linkingWallet` to `previewConfidentialSwap()`, then call
813
- `prepareConfidentialSwap()` after user confirmation to bind the plan to the
814
- still-connected signer.
815
-
816
- #### 3.6.5 Recovery and durable checkpoints
817
-
818
- Execution writes a checkpoint before every irreversible operation. Supply a
819
- durable `ConfidentialExecutionStore` in production, persist each `onProgress`
820
- snapshot for user-facing status, and resume an interrupted execution without
821
- repeating confirmed funding:
822
-
823
- ```ts
824
- const pending = await client.listRecoverableConfidentialExecutions();
825
- for (const execution of pending) {
826
- const resumed = await client.resumeConfidentialSwap(execution.id, {
827
- onProgress: persistPublicProgress,
828
- });
829
- console.log(resumed.stage);
830
- }
831
- ```
832
-
833
- The default `MemoryExecutionStore` lasts only for the client lifetime. An
834
- `ExecutionStore` must implement `get(id)`, `set(snapshot)`, and `list()`. Do not
835
- store snapshots in untrusted client-controlled storage without integrity and
836
- access controls. Although snapshots exclude session tokens and signed intent
837
- payloads, they contain transaction metadata and addresses and should still be
838
- treated as sensitive application data.
839
-
840
- `HttpConfidentialApi.environment` is the configured Intents contract (by default
841
- `intents.near`), so changing API or RPC URLs no longer invalidates sessions and
842
- execution lookups. When upgrading from a build that used service URLs as the
843
- environment, old login keys are not reused and the wallet may be asked to
844
- authorize again. Finish or reconcile unfinished checkpoints with the old build
845
- before rollout; do not rewrite their `environment` fields because plans and
846
- snapshots are integrity checked.
847
-
848
- Timeout or cancellation stops local waiting; it cannot undo an already broadcast
849
- transaction. Keep the `executionId` from `ConfidentialSwapError.executionId` and
850
- resume it. A checkpoint ending in `_pending_confirmation` represents an
851
- ambiguous write and is deliberately not rebroadcast. Configure the corresponding
852
- read-only `FundingAdapter.reconcile` callback for direct transfers when the
853
- application can look up an existing transaction by execution ID or deposit
854
- address. For the built-in v2 path, resume checks the confidential deposit status
855
- before requiring manual confirmation; an unresolved pre-swap or report write
856
- must be reconciled operationally and is never sent again automatically.
857
-
858
- Executions funded from an existing confidential balance intentionally remain in
859
- process memory even when `executionStore` is durable. They cannot be recovered
860
- after a reload because there is no source-funding transaction with which to
861
- reconcile ownership of the reserved balance.
862
-
863
- If credited funds need a new price review, call
864
- `refreshConfidentialWithdrawalReview(executionId)`, display the returned plan,
865
- then call `resumeConfidentialSwap(executionId)`. Use
866
- `discardPreparedConfidentialSwap()` only before funding has been attempted; it
867
- marks that checkpoint as failed so it is no longer recoverable. Use
868
- `abandonInterruptedConfidentialSwap()` only after the application has handled
869
- the remaining confidential funds through another path and intentionally wants
870
- to stop offering resume for that execution.
871
-
872
- For non-direct funding, normal automatic reporting is suppressed for the source
873
- execution. The confidential flow submits one `confidentiality: "advanced"`
874
- report and polls `/api/swap/order-status?recordId=...` before confirming deposit
875
- credit.
876
-
877
- #### 3.6.6 Public confidential methods
878
-
879
- All methods below require `SwapClientConfig.confidential` except the constructor
880
- itself. Passing an `AbortSignal` cancels only unfinished local/API work.
881
-
882
- | Method | Purpose |
883
- | --- | --- |
884
- | `getConfidentialTokens(signal?)` | Load the confidential asset registry. |
885
- | `getConfidentialAppFee(options?)` | Load and validate the current app ID, recipient and fee basis points using the V2 JWT. |
886
- | `previewConfidentialSwap(request, options?)` | Build a display-only plan; a linking identity is optional and the result cannot be executed. |
887
- | `quoteConfidentialSwap(request, options?)` | Build an executable plan bound to source and linking identities. |
888
- | `prepareConfidentialSwap(plan, options?)` | Bind a reviewed preview to the currently connected linking signer. |
889
- | `requiresConfidentialAuthentication(identity, options?)` | Check or refresh a stored session without prompting the wallet. |
890
- | `authenticateConfidentialWallet(identity, options?)` | Explicitly authorize the confidential account and return its login/session. |
891
- | `logoutConfidentialWallet(identity)` | Delete the locally stored session for the identity. |
892
- | `getConfidentialBalances(identity, options?)` | Return registered confidential balances, authenticating when required. |
893
- | `confidentialSwap({ plan, ...options })` | Run authorization, funding, deposit confirmation, withdrawal signing and final polling. |
894
- | `resumeConfidentialSwap(id, options?)` | Continue from a saved checkpoint without repeating completed operations. |
895
- | `getConfidentialExecution(id)` | Load one execution snapshot. |
896
- | `listConfidentialExecutions()` | List all snapshots visible to the configured store. |
897
- | `listRecoverableConfidentialExecutions()` | List unfinished executions that can be resumed. |
898
- | `refreshConfidentialWithdrawalReview(id, options?)` | Re-quote an already credited, unsubmitted withdrawal for renewed review. |
899
- | `discardPreparedConfidentialSwap(id)` | Mark a created, unfunded checkpoint as failed so it is no longer recoverable. |
900
- | `abandonInterruptedConfidentialSwap(id)` | Mark an interrupted execution as failed after its remaining funds were handled through another path. |
901
-
902
- Common confidential error codes include `USER_REJECTED`, `WALLET_CHANGED`,
903
- `MISSING_WALLET`, `QUOTE_EXPIRED`, `UNAUTHORIZED`, `TIMEOUT`, `ABORTED`,
904
- `BUSY`, `CONFIRMATION_REQUIRED`, and `TERMINAL_FAILURE`:
905
-
906
- ```ts
907
- import {
908
- ConfidentialSwapError,
909
- } from "@rhea-finance/cross-chain-aggregation-dex";
910
-
911
- try {
912
- await client.confidentialSwap({ plan });
913
- } catch (error) {
914
- if (error instanceof ConfidentialSwapError) {
915
- showConfidentialError(error.code);
916
- if (error.executionId) saveExecutionId(error.executionId);
917
- }
918
- throw error;
919
- }
920
- ```
921
-
922
- This flow provides confidential-account orchestration, not a guarantee of
923
- end-to-end anonymity. Source funding transactions, withdrawals, reused recipient
924
- addresses and backend reporting may expose associations. Never log session
925
- tokens, complete signed intents, or raw wallet-provider errors.
926
-
927
432
  ## 4. Simple-flow field reference
928
433
 
929
434
  ### 4.1 SwapClientConfig
@@ -933,14 +438,12 @@ tokens, complete signed intents, or raw wallet-provider errors.
933
438
  | `baseUrl` | `string` | Yes | API base URL, for example `https://api.rhea.finance`. A trailing `/` is removed. |
934
439
  | `apiKey` | `string` | No | Static API credential sent with requests. Request one through the [RHEA Boss portal](https://boss.rhea.finance/#/login). |
935
440
  | `getAccessToken` | `() => string \| Promise<string>` | No | Reads an access token before each request. Use this for refreshable sessions. |
936
- | `fetch` | `typeof globalThis.fetch` | No | Custom fetch implementation. The SDK binds its invocation context to avoid browser `Illegal invocation` errors. |
441
+ | `fetch` | `typeof globalThis.fetch` | No | Custom fetch implementation. The SDK binds its invocation context to avoid browser `Illegal invocation` errors. It is normally required on Node.js 16. |
937
442
  | `headers` | `Record<string,string>` or function | No | Additional request headers. The function form may return a promise. |
938
443
  | `timeoutMs` | `number` | No | Timeout for each HTTP request in milliseconds. Default: `15000`. |
939
- | `retry` | `Partial<RetryConfig>` | No | Retry policy for retryable quote/read operations. Defaults: 2 retries, 250ms base delay, 2000ms maximum delay, and jitter enabled. |
940
- | `logger` | `SdkLogger` | No | Receives structured `api.request`, `api.response`, and `api.retry` entries. |
444
+ | `logger` | `SdkLogger` | No | Receives structured `api.request` and `api.response` entries. |
941
445
  | `executors` | `readonly ChainExecutor[]` | Required for execution | Wallet executors. May be omitted when only calling `quote()` or `buildSwap()`. |
942
446
  | `tokenListCacheTtlMs` | `number` | No | Successful token-list cache lifetime in milliseconds. Default: `600000` (10 minutes). Set to `0` to disable. |
943
- | `confidential` | `ConfidentialSwapConfig` | No | Enables complete confidential pre-swap, deposit, withdrawal, and recovery methods. |
944
447
  | `reportMode` | `"auto" \| "manual" \| "disabled"` | No | Reporting policy. Default: `"auto"`. A reporting failure does not turn a submitted swap into a failed swap. |
945
448
  | `onEvent` | `(event) => void` | No | Receives all lifecycle events. |
946
449
  | `now` | `() => number` | No | Custom millisecond clock, mainly for testing. Default: `Date.now`. |
@@ -1274,18 +777,12 @@ await promise;
1274
777
 
1275
778
  Cancellation only stops the SDK's current work. It cannot revert an approval, signature, or transaction that has already been submitted.
1276
779
 
1277
- ## 10. Retries, logging, and credentials
780
+ ## 10. Logging and credentials
1278
781
 
1279
782
  ```ts
1280
783
  const client = new SwapClient({
1281
784
  baseUrl: "https://api.rhea.finance",
1282
785
  getAccessToken: async () => authStore.getToken(),
1283
- retry: {
1284
- maxRetries: 2,
1285
- baseDelayMs: 250,
1286
- maxDelayMs: 2000,
1287
- jitter: true,
1288
- },
1289
786
  logger: {
1290
787
  log(entry) {
1291
788
  console.log("SDK API", entry);
@@ -1294,7 +791,7 @@ const client = new SwapClient({
1294
791
  });
1295
792
  ```
1296
793
 
1297
- The SDK automatically retries only retryable quote/read operations. It does not automatically retry build, broadcast, or order-submission operations that could execute twice. Network failures preserve the underlying error name and message to help diagnose CORS failures, connection resets, timeouts, or fetch invocation problems.
794
+ The SDK does not automatically retry HTTP requests. Callers that need retries should handle them outside the SDK. Network failures preserve the underlying error name and message to help diagnose CORS failures, connection resets, timeouts, or fetch invocation problems. Errors may still expose a `retryable` flag as guidance for application-level handling.
1298
795
 
1299
796
  ## 11. Raw API, reporting, and history
1300
797
 
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.mjs';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.mjs';
2
2
 
3
3
  interface AptosWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.js';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.js';
2
2
 
3
3
  interface AptosWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.mjs';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.mjs';
2
2
 
3
3
  interface BitcoinWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.js';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.js';
2
2
 
3
3
  interface BitcoinWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, a5 as EvmTx, af as TransactionSubmission, a7 as EvmSigningRequest, a6 as EvmApproval, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.mjs';
1
+ import { ad as ExecutorErrorAdapter, a4 as EvmTx, ae as TransactionSubmission, a6 as EvmSigningRequest, a5 as EvmApproval, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.mjs';
2
2
 
3
3
  interface EvmWalletAdapter extends ExecutorErrorAdapter {
4
4
  sendTransaction(tx: EvmTx, options: {
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, a5 as EvmTx, af as TransactionSubmission, a7 as EvmSigningRequest, a6 as EvmApproval, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.js';
1
+ import { ad as ExecutorErrorAdapter, a4 as EvmTx, ae as TransactionSubmission, a6 as EvmSigningRequest, a5 as EvmApproval, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.js';
2
2
 
3
3
  interface EvmWalletAdapter extends ExecutorErrorAdapter {
4
4
  sendTransaction(tx: EvmTx, options: {
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.mjs';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.mjs';
2
2
 
3
3
  interface NearWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.js';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, N as NearTransaction, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.js';
2
2
 
3
3
  interface NearWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, a8 as SolanaMetadata, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.mjs';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, a7 as SolanaMetadata, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.mjs';
2
2
 
3
3
  interface SolanaWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, a8 as SolanaMetadata, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.js';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, a7 as SolanaMetadata, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.js';
2
2
 
3
3
  interface SolanaWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.mjs';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.mjs';
2
2
 
3
3
  interface SuiWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.js';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.js';
2
2
 
3
3
  interface SuiWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;
@@ -1,4 +1,4 @@
1
- import { ae as ExecutorErrorAdapter, C as ChainRef, af as TransactionSubmission, T as TransactionConfirmation, x as ChainExecutor } from '../shared-CY6qp3wS.mjs';
1
+ import { ad as ExecutorErrorAdapter, C as ChainRef, ae as TransactionSubmission, T as TransactionConfirmation, w as ChainExecutor } from '../shared-DpC8G2U4.mjs';
2
2
 
3
3
  interface TronWalletAdapter extends ExecutorErrorAdapter {
4
4
  getChain(): ChainRef | Promise<ChainRef>;