@bloque/sdk-swap 0.11.1 → 0.13.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.
@@ -1,13 +1,19 @@
1
1
  import { BaseClient } from '@bloque/sdk-core';
2
2
  import type { CreateExternalUsBankOrderOptions, CreateExternalUsBankOrderParams, CreateExternalUsBankOrderResult } from './types';
3
3
  /**
4
- * External US bank client for ACH on-ramp (US bank → Kusama DUSD).
4
+ * External US bank client for ACH on-ramp (US bank → Kusama DUSD or Base USDC).
5
5
  */
6
6
  export declare class ExternalUsBankSwapClient extends BaseClient {
7
7
  /**
8
- * Create an external US bank on-ramp order (ACH pull → DUSD on Kusama).
8
+ * Create an external US bank on-ramp order (ACH pull → DUSD on Kusama, or
9
+ * USDC on Base).
9
10
  *
10
- * @param params - Order parameters including ledger account and linked bank
11
+ * Omit `toMedium` (or pass `'kusama'`) and supply
12
+ * `depositInformation.ledgerAccountId` for the Kusama path. Pass
13
+ * `toMedium: 'base'` with `depositInformation.walletAddress` to land USDC
14
+ * on Base at that 0x.
15
+ *
16
+ * @param params - Order parameters including destination and linked bank
11
17
  * @returns Promise resolving to the created order
12
18
  *
13
19
  * @example
@@ -31,8 +37,32 @@ export declare class ExternalUsBankSwapClient extends BaseClient {
31
37
  * },
32
38
  * });
33
39
  * ```
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const rates = await bloque.swap.findRates({
44
+ * fromAsset: 'USD/2',
45
+ * toAsset: 'USDC/6',
46
+ * fromMediums: ['external-us-bank'],
47
+ * toMediums: ['base'],
48
+ * amountSrc: '10000',
49
+ * });
50
+ *
51
+ * const result = await bloque.swap.externalUsBank.create({
52
+ * rateSig: rates.rates[0].sig,
53
+ * amountSrc: '10000',
54
+ * toMedium: 'base',
55
+ * depositInformation: {
56
+ * walletAddress: '0x1234567890abcdef1234567890abcdef12345678',
57
+ * },
58
+ * args: {
59
+ * sourceAccountUrn: 'did:bloque:account:external-us-bank:abc123',
60
+ * },
61
+ * });
62
+ * ```
34
63
  */
35
64
  create(params: CreateExternalUsBankOrderParams, options?: CreateExternalUsBankOrderOptions): Promise<CreateExternalUsBankOrderResult>;
65
+ private _mapDepositInformation;
36
66
  private _mapOrderResponse;
37
67
  private _mapExecutionResult;
38
68
  }
@@ -1,7 +1,9 @@
1
1
  import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bank-transfer/types';
2
2
  export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
3
+ /** Destination medium for an external US bank ACH on-ramp. */
4
+ export type ExternalUsBankDestination = 'kusama' | 'base';
3
5
  /**
4
- * Deposit information for external US bank on-ramp (ACH pull → Kusama).
6
+ * Deposit information for external US bank on-ramp to Kusama (ACH pull → DUSD).
5
7
  */
6
8
  export interface ExternalUsBankDepositInformation {
7
9
  /**
@@ -9,6 +11,19 @@ export interface ExternalUsBankDepositInformation {
9
11
  */
10
12
  ledgerAccountId: string;
11
13
  }
14
+ /**
15
+ * Deposit information for external US bank on-ramp to Base (ACH pull → USDC).
16
+ */
17
+ export interface ExternalUsBankBaseDepositInformation {
18
+ /**
19
+ * Destination 0x on Base to receive USDC.
20
+ */
21
+ walletAddress: string;
22
+ /**
23
+ * Optional label for the destination wallet. Defaults server-side when omitted.
24
+ */
25
+ walletName?: string;
26
+ }
12
27
  /**
13
28
  * Arguments for external US bank on-ramp auto-execution.
14
29
  */
@@ -18,10 +33,7 @@ export interface ExternalUsBankArgs {
18
33
  */
19
34
  sourceAccountUrn: string;
20
35
  }
21
- /**
22
- * Parameters for creating an external US bank on-ramp order.
23
- */
24
- export interface CreateExternalUsBankOrderParams {
36
+ interface CreateExternalUsBankOrderParamsBase {
25
37
  /**
26
38
  * Rate signature from findRates.
27
39
  */
@@ -42,10 +54,6 @@ export interface CreateExternalUsBankOrderParams {
42
54
  * Order type (default: 'src').
43
55
  */
44
56
  type?: OrderType;
45
- /**
46
- * Destination ledger account to credit on Kusama.
47
- */
48
- depositInformation: ExternalUsBankDepositInformation;
49
57
  /**
50
58
  * Linked bank account and auto-execution arguments.
51
59
  */
@@ -59,6 +67,33 @@ export interface CreateExternalUsBankOrderParams {
59
67
  */
60
68
  metadata?: Record<string, unknown>;
61
69
  }
70
+ /**
71
+ * ACH on-ramp to Kusama DUSD. `toMedium` may be omitted — Kusama is the default.
72
+ */
73
+ export interface CreateExternalUsBankKusamaOrderParams extends CreateExternalUsBankOrderParamsBase {
74
+ toMedium?: 'kusama';
75
+ /**
76
+ * Destination ledger account to credit on Kusama.
77
+ */
78
+ depositInformation: ExternalUsBankDepositInformation;
79
+ }
80
+ /**
81
+ * ACH on-ramp to USDC on Base.
82
+ */
83
+ export interface CreateExternalUsBankBaseOrderParams extends CreateExternalUsBankOrderParamsBase {
84
+ toMedium: 'base';
85
+ /**
86
+ * Destination 0x on Base to receive USDC.
87
+ */
88
+ depositInformation: ExternalUsBankBaseDepositInformation;
89
+ }
90
+ /**
91
+ * Parameters for creating an external US bank on-ramp order.
92
+ *
93
+ * Defaults to Kusama (`toMedium` omitted). Pass `toMedium: 'base'` with
94
+ * `depositInformation.walletAddress` to land USDC on Base.
95
+ */
96
+ export type CreateExternalUsBankOrderParams = CreateExternalUsBankKusamaOrderParams | CreateExternalUsBankBaseOrderParams;
62
97
  export interface CreateExternalUsBankOrderOptions {
63
98
  /**
64
99
  * Optional custom idempotency key sent as `Idempotency-Key` header.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{PseClient:()=>PseClient,ExternalUsBankSwapClient:()=>ExternalUsBankSwapClient,RtpClient:()=>RtpClient,SwapClient:()=>SwapClient,BankTransferClient:()=>BankTransferClient,BrebClient:()=>BrebClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");function isWireBrebDepositHow(e){return"BREB_DEPOSIT"===e.type}function isWireCallbackHow(e){return"CALLBACK"===e.type&&"args"in e}function isWireIframeHow(e){return"IFRAME"===e.type&&"iframe"in e}function mapExecutionHow(e){return isWireBrebDepositHow(e)?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:isWireCallbackHow(e)?{type:"CALLBACK",args:e.args}:isWireIframeHow(e)?{type:"IFRAME",iframe:e.iframe}:{type:e.type,url:e.url??""}}class BankTransferClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapDepositInformationToWire(e){return{bank_account_type:e.bankAccountType,bank_account_number:e.bankAccountNumber,bank_account_holder_name:e.bankAccountHolderName,bank_account_holder_identification_type:e.bankAccountHolderIdentificationType,bank_account_holder_identification_value:e.bankAccountHolderIdentificationValue}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class BrebClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}async createDeposit(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),void 0!==e.args&&(o.args=e.args),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId,destination_key:{key_value:e.destinationKey.keyValue,key_type:e.destinationKey.keyType,...e.destinationKey.displayName?{display_name:e.destinationKey.displayName}:{}}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class ExternalUsBankSwapClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{ledger_account_id:e.depositInformation.ledgerAccountId},args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class PseClient extends sdk_core_namespaceObject.BaseClient{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(e=>this._mapBankResponse(e))}}async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapBankResponse(e){return{code:e.financial_institution_code,name:e.financial_institution_name}}_mapDepositInformationToWire(e){return{urn:e.urn}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class RtpClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a=this.httpClient.urn;if(!a)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=e.type??"src",o={taker_urn:a,type:r,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===r&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===r&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapDepositInformationToWire(e){return{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bankTransfer=new BankTransferClient(this.httpClient),this.breb=new BrebClient(this.httpClient),this.rtp=new RtpClient(this.httpClient),this.externalUsBank=new ExternalUsBankSwapClient(this.httpClient)}async findRates(e){let t=new URLSearchParams,a=JSON.stringify([e.fromAsset,e.toAsset]);t.append("edge",a),t.append("from_medium",JSON.stringify(e.fromMediums)),t.append("to_medium",JSON.stringify(e.toMediums)),void 0!==e.amountSrc&&t.append("amount_src",e.amountSrc),void 0!==e.amountDst&&t.append("amount_dst",e.amountDst),e.sort&&t.append("sort",e.sort),e.sortBy&&t.append("sort_by",e.sortBy);let r=t.toString(),o=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:o})).rates.map(e=>this._mapRateResponse(e))}}async listOrders(e={}){let t=this.httpClient.urn;if(!t)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=new URLSearchParams;e.orderSig&&a.set("order_sig",e.orderSig),e.swapSig&&a.set("swap_sig",e.swapSig),e.rateSig&&a.set("rate_sig",e.rateSig),e.makerUrn&&a.set("maker_urn",e.makerUrn),e.status&&a.set("status",e.status),e.graphId&&a.set("graph_id",e.graphId),void 0!==e.after&&a.set("after",e.after.toString()),void 0!==e.before&&a.set("before",e.before.toString());let r=a.toString(),o=`/api/order/taker/${t}${r?`?${r}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:o})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapRateResponse(e){return{id:e.id,sig:e.sig,swapSig:e.swap_sig,maker:e.maker,edge:e.edge,fee:{at:e.fee.at,value:e.fee.value,formula:e.fee.formula,components:e.fee.components.map(e=>({at:e.at,name:e.name,type:e.type,value:e.value,percentage:e.percentage,pair:e.pair,amount:e.amount}))},at:e.at,until:e.until,fromMediums:e.from_medium,toMediums:e.to_medium,rate:e.rate,ratio:e.ratio,fromLimits:e.from_limits,toLimits:e.to_limits,createdAt:e.created_at,updatedAt:e.updated_at}}}for(var __rspack_i in exports.BankTransferClient=__webpack_exports__.BankTransferClient,exports.BrebClient=__webpack_exports__.BrebClient,exports.ExternalUsBankSwapClient=__webpack_exports__.ExternalUsBankSwapClient,exports.PseClient=__webpack_exports__.PseClient,exports.RtpClient=__webpack_exports__.RtpClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BankTransferClient","BrebClient","ExternalUsBankSwapClient","PseClient","RtpClient","SwapClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{PseClient:()=>PseClient,ExternalUsBankSwapClient:()=>ExternalUsBankSwapClient,RtpClient:()=>RtpClient,SwapClient:()=>SwapClient,BankTransferClient:()=>BankTransferClient,BrebClient:()=>BrebClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");function isWireBrebDepositHow(e){return"BREB_DEPOSIT"===e.type}function isWireCallbackHow(e){return"CALLBACK"===e.type&&"args"in e}function isWireIframeHow(e){return"IFRAME"===e.type&&"iframe"in e}function mapExecutionHow(e){return isWireBrebDepositHow(e)?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:isWireCallbackHow(e)?{type:"CALLBACK",args:e.args}:isWireIframeHow(e)?{type:"IFRAME",iframe:e.iframe}:{type:e.type,url:e.url??""}}class BankTransferClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let r=this.httpClient.urn;if(!r)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",o={taker_urn:r,type:a,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapDepositInformationToWire(e){return{bank_account_type:e.bankAccountType,bank_account_number:e.bankAccountNumber,bank_account_holder_name:e.bankAccountHolderName,bank_account_holder_identification_type:e.bankAccountHolderIdentificationType,bank_account_holder_identification_value:e.bankAccountHolderIdentificationValue}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class BrebClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let r=this.httpClient.urn;if(!r)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",o={taker_urn:r,type:a,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===a&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}async createDeposit(e,t){let r=this.httpClient.urn;if(!r)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",o={taker_urn:r,type:a,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===a&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(o.amount_dst=e.amountDst),void 0!==e.args&&(o.args=e.args),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId,destination_key:{key_value:e.destinationKey.keyValue,key_type:e.destinationKey.keyType,...e.destinationKey.displayName?{display_name:e.destinationKey.displayName}:{}}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class ExternalUsBankSwapClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let r=this.httpClient.urn;if(!r)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",o=e.toMedium??"kusama",s=this._mapDepositInformation(o,e.depositInformation),n={taker_urn:r,type:a,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:o,webhook_url:e.webhookUrl,deposit_information:s,args:{account_urn:e.args.sourceAccountUrn}};"src"===a&&e.amountSrc?n.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(n.amount_dst=e.amountDst),e.nodeId&&(n.node_id=e.nodeId),e.metadata&&(n.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:n,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapDepositInformation(e,t){if("base"===e){if(!("walletAddress"in t)||!t.walletAddress.trim())throw new sdk_core_namespaceObject.BloqueConfigError('toMedium "base" requires depositInformation.walletAddress (0x on Base).');return{wallet_address:t.walletAddress,...t.walletName?{wallet_name:t.walletName}:{}}}if(!("ledgerAccountId"in t)||!t.ledgerAccountId.trim())throw new sdk_core_namespaceObject.BloqueConfigError('toMedium "kusama" requires depositInformation.ledgerAccountId.');return{ledger_account_id:t.ledgerAccountId}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class PseClient extends sdk_core_namespaceObject.BaseClient{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(e=>this._mapBankResponse(e))}}async create(e,t){let r=this.httpClient.urn;if(!r)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",o={taker_urn:r,type:a,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(o.amount_dst=e.amountDst),e.args&&(o.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(s.result.order),execution:s.result.execution?this._mapExecutionResult(s.result.execution):void 0,requestId:s.req_id}}_mapBankResponse(e){return{code:e.financial_institution_code,name:e.financial_institution_name}}_mapDepositInformationToWire(e){return{urn:e.urn}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class RtpClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let r=this.httpClient.urn;if(!r)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let a=e.type??"src",o=e.fromMedium??"kusama",s={taker_urn:r,type:a,rate_sig:e.rateSig,from_medium:o,to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:this._mapArgs(o,e.args)};"src"===a&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.req_id}}_mapArgs(e,t){if("base"===e){let e=t.txHash?.trim();if(!e)throw new sdk_core_namespaceObject.BloqueConfigError('fromMedium "base" requires args.txHash of the USDC transfer on Base.');return{urn:t.sourceAccountUrn,tx_hash:e}}return{account_urn:t.sourceAccountUrn}}_mapDepositInformationToWire(e){return{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?mapExecutionHow(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bankTransfer=new BankTransferClient(this.httpClient),this.breb=new BrebClient(this.httpClient),this.rtp=new RtpClient(this.httpClient),this.externalUsBank=new ExternalUsBankSwapClient(this.httpClient)}async findRates(e){let t=new URLSearchParams,r=JSON.stringify([e.fromAsset,e.toAsset]);t.append("edge",r),t.append("from_medium",JSON.stringify(e.fromMediums)),t.append("to_medium",JSON.stringify(e.toMediums)),void 0!==e.amountSrc&&t.append("amount_src",e.amountSrc),void 0!==e.amountDst&&t.append("amount_dst",e.amountDst),e.sort&&t.append("sort",e.sort),e.sortBy&&t.append("sort_by",e.sortBy);let a=t.toString(),o=`/api/rates?${a}`;return{rates:(await this.httpClient.request({method:"GET",path:o})).rates.map(e=>this._mapRateResponse(e))}}async listOrders(e={}){let t=this.httpClient.urn;if(!t)throw new sdk_core_namespaceObject.BloqueConfigError("User URN is not available. Please connect to a session first.");let r=new URLSearchParams;e.orderSig&&r.set("order_sig",e.orderSig),e.swapSig&&r.set("swap_sig",e.swapSig),e.rateSig&&r.set("rate_sig",e.rateSig),e.makerUrn&&r.set("maker_urn",e.makerUrn),e.status&&r.set("status",e.status),e.graphId&&r.set("graph_id",e.graphId),void 0!==e.after&&r.set("after",e.after.toString()),void 0!==e.before&&r.set("before",e.before.toString());let a=r.toString(),o=`/api/order/taker/${t}${a?`?${a}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:o})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapRateResponse(e){return{id:e.id,sig:e.sig,swapSig:e.swap_sig,maker:e.maker,edge:e.edge,fee:{at:e.fee.at,value:e.fee.value,formula:e.fee.formula,components:e.fee.components.map(e=>({at:e.at,name:e.name,type:e.type,value:e.value,percentage:e.percentage,pair:e.pair,amount:e.amount}))},at:e.at,until:e.until,fromMediums:e.from_medium,toMediums:e.to_medium,rate:e.rate,ratio:e.ratio,fromLimits:e.from_limits,toLimits:e.to_limits,createdAt:e.created_at,updatedAt:e.updated_at}}}for(var __rspack_i in exports.BankTransferClient=__webpack_exports__.BankTransferClient,exports.BrebClient=__webpack_exports__.BrebClient,exports.ExternalUsBankSwapClient=__webpack_exports__.ExternalUsBankSwapClient,exports.PseClient=__webpack_exports__.PseClient,exports.RtpClient=__webpack_exports__.RtpClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BankTransferClient","BrebClient","ExternalUsBankSwapClient","PseClient","RtpClient","SwapClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.d.ts CHANGED
@@ -3,10 +3,10 @@ export type { BankAccountType, BankDepositInformation, CreateBankTransferOrderOp
3
3
  export { BrebClient } from './breb/breb-client';
4
4
  export type { BrebDepositInformation, BrebDepositOnRampInformation, BrebDestinationKey, BrebSwapArgs, CreateBrebDepositOptions, CreateBrebDepositParams, CreateBrebDepositResult, CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult, } from './breb/types';
5
5
  export { ExternalUsBankSwapClient } from './external-us-bank/external-us-bank-client';
6
- export type { CreateExternalUsBankOrderOptions, CreateExternalUsBankOrderParams, CreateExternalUsBankOrderResult, ExternalUsBankArgs, ExternalUsBankDepositInformation, } from './external-us-bank/types';
6
+ export type { CreateExternalUsBankBaseOrderParams, CreateExternalUsBankKusamaOrderParams, CreateExternalUsBankOrderOptions, CreateExternalUsBankOrderParams, CreateExternalUsBankOrderResult, ExternalUsBankArgs, ExternalUsBankBaseDepositInformation, ExternalUsBankDepositInformation, ExternalUsBankDestination, } from './external-us-bank/types';
7
7
  export { PseClient } from './pse/pse-client';
8
8
  export type { Bank, CreatePseOrderOptions, CreatePseOrderParams, CreatePseOrderResult, DepositInformation, ListBanksResult, PseCustomerData, PsePaymentArgs, } from './pse/types';
9
9
  export { RtpClient } from './rtp/rtp-client';
10
- export type { CreateRtpOrderOptions, CreateRtpOrderParams, CreateRtpOrderResult, RtpDepositInformation, RtpSwapArgs, } from './rtp/types';
10
+ export type { CreateRtpBaseOrderParams, CreateRtpKusamaOrderParams, CreateRtpOrderOptions, CreateRtpOrderParams, CreateRtpOrderResult, RtpDepositInformation, RtpSourceMedium, RtpSwapArgs, } from './rtp/types';
11
11
  export { SwapClient } from './swap-client';
12
12
  export type { Fee, FeeComponent, FeeComponentType, FindRatesParams, FindRatesResult, ListOrdersParams, ListOrdersResult, OrderStatus, RateLimits, RateTuple, SwapRate, } from './types';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{BaseClient as e,BloqueConfigError as t}from"@bloque/sdk-core";function a(e){return"BREB_DEPOSIT"===e.type?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:"CALLBACK"===e.type&&"args"in e?{type:"CALLBACK",args:e.args}:"IFRAME"===e.type&&"iframe"in e?{type:"IFRAME",iframe:e.iframe}:{type:e.type,url:e.url??""}}class r extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapDepositInformationToWire(e){return{bank_account_type:e.bankAccountType,bank_account_number:e.bankAccountNumber,bank_account_holder_name:e.bankAccountHolderName,bank_account_holder_identification_type:e.bankAccountHolderIdentificationType,bank_account_holder_identification_value:e.bankAccountHolderIdentificationValue}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class o extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}async createDeposit(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),void 0!==e.args&&(s.args=e.args),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId,destination_key:{key_value:e.destinationKey.keyValue,key_type:e.destinationKey.keyType,...e.destinationKey.displayName?{display_name:e.destinationKey.displayName}:{}}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class s extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{ledger_account_id:e.depositInformation.ledgerAccountId},args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class i extends e{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(e=>this._mapBankResponse(e))}}async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapBankResponse(e){return{code:e.financial_institution_code,name:e.financial_institution_name}}_mapDepositInformationToWire(e){return{urn:e.urn}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class n extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapDepositInformationToWire(e){return{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class u extends e{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new i(this.httpClient),this.bankTransfer=new r(this.httpClient),this.breb=new o(this.httpClient),this.rtp=new n(this.httpClient),this.externalUsBank=new s(this.httpClient)}async findRates(e){let t=new URLSearchParams,a=JSON.stringify([e.fromAsset,e.toAsset]);t.append("edge",a),t.append("from_medium",JSON.stringify(e.fromMediums)),t.append("to_medium",JSON.stringify(e.toMediums)),void 0!==e.amountSrc&&t.append("amount_src",e.amountSrc),void 0!==e.amountDst&&t.append("amount_dst",e.amountDst),e.sort&&t.append("sort",e.sort),e.sortBy&&t.append("sort_by",e.sortBy);let r=t.toString(),o=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:o})).rates.map(e=>this._mapRateResponse(e))}}async listOrders(e={}){let a=this.httpClient.urn;if(!a)throw new t("User URN is not available. Please connect to a session first.");let r=new URLSearchParams;e.orderSig&&r.set("order_sig",e.orderSig),e.swapSig&&r.set("swap_sig",e.swapSig),e.rateSig&&r.set("rate_sig",e.rateSig),e.makerUrn&&r.set("maker_urn",e.makerUrn),e.status&&r.set("status",e.status),e.graphId&&r.set("graph_id",e.graphId),void 0!==e.after&&r.set("after",e.after.toString()),void 0!==e.before&&r.set("before",e.before.toString());let o=r.toString(),s=`/api/order/taker/${a}${o?`?${o}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:s})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapRateResponse(e){return{id:e.id,sig:e.sig,swapSig:e.swap_sig,maker:e.maker,edge:e.edge,fee:{at:e.fee.at,value:e.fee.value,formula:e.fee.formula,components:e.fee.components.map(e=>({at:e.at,name:e.name,type:e.type,value:e.value,percentage:e.percentage,pair:e.pair,amount:e.amount}))},at:e.at,until:e.until,fromMediums:e.from_medium,toMediums:e.to_medium,rate:e.rate,ratio:e.ratio,fromLimits:e.from_limits,toLimits:e.to_limits,createdAt:e.created_at,updatedAt:e.updated_at}}}export{r as BankTransferClient,o as BrebClient,s as ExternalUsBankSwapClient,i as PseClient,n as RtpClient,u as SwapClient};
1
+ import{BaseClient as e,BloqueConfigError as t}from"@bloque/sdk-core";function a(e){return"BREB_DEPOSIT"===e.type?{type:"BREB_DEPOSIT",medium:e.medium,keyType:e.key_type,keyValue:e.key_value,amount:e.amount,currency:e.currency,reference:e.reference,depositAccountUrn:e.deposit_account_urn,expectedAmount:e.expected_amount,receivedAmount:e.received_amount,remainingAmount:e.remaining_amount,depositStatus:e.deposit_status}:"CALLBACK"===e.type&&"args"in e?{type:"CALLBACK",args:e.args}:"IFRAME"===e.type&&"iframe"in e?{type:"IFRAME",iframe:e.iframe}:{type:e.type,url:e.url??""}}class r extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapDepositInformationToWire(e){return{bank_account_type:e.bankAccountType,bank_account_number:e.bankAccountNumber,bank_account_holder_name:e.bankAccountHolderName,bank_account_holder_identification_type:e.bankAccountHolderIdentificationType,bank_account_holder_identification_value:e.bankAccountHolderIdentificationValue}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class o extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapPayoutDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}async createDeposit(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"breb",to_medium:"kusama",webhook_url:e.webhookUrl,deposit_information:{urn:e.depositInformation.urn}};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),void 0!==e.args&&(s.args=e.args),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId,destination_key:{key_value:e.destinationKey.keyValue,key_type:e.destinationKey.keyType,...e.destinationKey.displayName?{display_name:e.destinationKey.displayName}:{}}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class s extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s=e.toMedium??"kusama",i=this._mapDepositInformation(s,e.depositInformation),n={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"external-us-bank",to_medium:s,webhook_url:e.webhookUrl,deposit_information:i,args:{account_urn:e.args.sourceAccountUrn}};"src"===o&&e.amountSrc?n.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(n.amount_dst=e.amountDst),e.nodeId&&(n.node_id=e.nodeId),e.metadata&&(n.metadata=e.metadata);let u=await this.httpClient.request({method:"PUT",path:"/api/order",body:n,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(u.result.order),execution:u.result.execution?this._mapExecutionResult(u.result.execution):void 0,requestId:u.req_id}}_mapDepositInformation(e,a){if("base"===e){if(!("walletAddress"in a)||!a.walletAddress.trim())throw new t('toMedium "base" requires depositInformation.walletAddress (0x on Base).');return{wallet_address:a.walletAddress,...a.walletName?{wallet_name:a.walletName}:{}}}if(!("ledgerAccountId"in a)||!a.ledgerAccountId.trim())throw new t('toMedium "kusama" requires depositInformation.ledgerAccountId.');return{ledger_account_id:a.ledgerAccountId}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class i extends e{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(e=>this._mapBankResponse(e))}}async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===o&&e.amountSrc?s.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(s.amount_dst=e.amountDst),e.args&&(s.args={bank_code:e.args.bankCode,user_type:e.args.userType,customer_email:e.args.customerEmail,user_legal_id_type:e.args.userLegalIdType,user_legal_id:e.args.userLegalId,redirect_url:e.args.redirectUrl,...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(s.node_id=e.nodeId),e.metadata&&(s.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(i.result.order),execution:i.result.execution?this._mapExecutionResult(i.result.execution):void 0,requestId:i.req_id}}_mapBankResponse(e){return{code:e.financial_institution_code,name:e.financial_institution_name}}_mapDepositInformationToWire(e){return{urn:e.urn}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class n extends e{async create(e,a){let r=this.httpClient.urn;if(!r)throw new t("User URN is not available. Please connect to a session first.");let o=e.type??"src",s=e.fromMedium??"kusama",i={taker_urn:r,type:o,rate_sig:e.rateSig,from_medium:s,to_medium:"rtp",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:this._mapArgs(s,e.args)};"src"===o&&e.amountSrc?i.amount_src=e.amountSrc:"dst"===o&&e.amountDst&&(i.amount_dst=e.amountDst),e.nodeId&&(i.node_id=e.nodeId),e.metadata&&(i.metadata=e.metadata);let n=await this.httpClient.request({method:"PUT",path:"/api/order",body:i,headers:a?.idempotencyKey?{"Idempotency-Key":a.idempotencyKey}:void 0});return{order:this._mapOrderResponse(n.result.order),execution:n.result.execution?this._mapExecutionResult(n.result.execution):void 0,requestId:n.req_id}}_mapArgs(e,a){if("base"===e){let e=a.txHash?.trim();if(!e)throw new t('fromMedium "base" requires args.txHash of the USDC transfer on Base.');return{urn:a.sourceAccountUrn,tx_hash:e}}return{account_urn:a.sourceAccountUrn}}_mapDepositInformationToWire(e){return{owner:e.owner,account_number:e.accountNumber,routing_number:e.routingNumber,account_type:e.accountType,...e.bankName&&{bank_name:e.bankName}}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapExecutionResult(e){return{nodeId:e.node_id,result:{status:e.result.status,name:e.result.name,description:e.result.description,how:e.result.how?a(e.result.how):void 0,callbackToken:e.result.callback_token}}}}class u extends e{pse;bankTransfer;breb;rtp;externalUsBank;constructor(e){super(e),this.pse=new i(this.httpClient),this.bankTransfer=new r(this.httpClient),this.breb=new o(this.httpClient),this.rtp=new n(this.httpClient),this.externalUsBank=new s(this.httpClient)}async findRates(e){let t=new URLSearchParams,a=JSON.stringify([e.fromAsset,e.toAsset]);t.append("edge",a),t.append("from_medium",JSON.stringify(e.fromMediums)),t.append("to_medium",JSON.stringify(e.toMediums)),void 0!==e.amountSrc&&t.append("amount_src",e.amountSrc),void 0!==e.amountDst&&t.append("amount_dst",e.amountDst),e.sort&&t.append("sort",e.sort),e.sortBy&&t.append("sort_by",e.sortBy);let r=t.toString(),o=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:o})).rates.map(e=>this._mapRateResponse(e))}}async listOrders(e={}){let a=this.httpClient.urn;if(!a)throw new t("User URN is not available. Please connect to a session first.");let r=new URLSearchParams;e.orderSig&&r.set("order_sig",e.orderSig),e.swapSig&&r.set("swap_sig",e.swapSig),e.rateSig&&r.set("rate_sig",e.rateSig),e.makerUrn&&r.set("maker_urn",e.makerUrn),e.status&&r.set("status",e.status),e.graphId&&r.set("graph_id",e.graphId),void 0!==e.after&&r.set("after",e.after.toString()),void 0!==e.before&&r.set("before",e.before.toString());let o=r.toString(),s=`/api/order/taker/${a}${o?`?${o}`:""}`;return{orders:(await this.httpClient.request({method:"GET",path:s})).orders.map(e=>this._mapOrderResponse(e))}}async cancelSubscription(e){let t=await this.httpClient.request({method:"POST",path:`/api/order/${e.orderId}/cancel-subscription`});return{status:t.result.status,cursor:t.result.cursor,orderId:t.result.order_id,graphId:t.result.graph_id}}_mapOrderResponse(e){return{id:e.id,orderSig:e.order_sig,rateSig:e.rate_sig,swapSig:e.swap_sig,taker:e.taker,maker:e.maker,fromAsset:e.from_asset,toAsset:e.to_asset,fromMedium:e.from_medium,toMedium:e.to_medium,fromAmount:e.from_amount,toAmount:e.to_amount,at:e.at,graphId:e.graph_id,status:e.status,metadata:e.metadata,webhookUrl:e.webhook_url,failureReason:e.failure_reason,failureDetails:e.failure_details,createdAt:e.created_at,updatedAt:e.updated_at}}_mapRateResponse(e){return{id:e.id,sig:e.sig,swapSig:e.swap_sig,maker:e.maker,edge:e.edge,fee:{at:e.fee.at,value:e.fee.value,formula:e.fee.formula,components:e.fee.components.map(e=>({at:e.at,name:e.name,type:e.type,value:e.value,percentage:e.percentage,pair:e.pair,amount:e.amount}))},at:e.at,until:e.until,fromMediums:e.from_medium,toMediums:e.to_medium,rate:e.rate,ratio:e.ratio,fromLimits:e.from_limits,toLimits:e.to_limits,createdAt:e.created_at,updatedAt:e.updated_at}}}export{r as BankTransferClient,o as BrebClient,s as ExternalUsBankSwapClient,i as PseClient,n as RtpClient,u as SwapClient};
@@ -90,6 +90,10 @@ export interface DepositInformation {
90
90
  };
91
91
  /** External US bank on-ramp: destination Kusama ledger account id */
92
92
  ledger_account_id?: string;
93
+ /** External US bank on-ramp to Base: destination 0x */
94
+ wallet_address?: string;
95
+ /** External US bank on-ramp to Base: optional destination wallet label */
96
+ wallet_name?: string;
93
97
  /** RTP payout: account holder name */
94
98
  owner?: string;
95
99
  /** RTP payout: bank account number */
@@ -1,11 +1,16 @@
1
1
  import { BaseClient } from '@bloque/sdk-core';
2
2
  import type { CreateRtpOrderOptions, CreateRtpOrderParams, CreateRtpOrderResult } from './types';
3
3
  /**
4
- * RTP client for US instant bank payouts (Kusama → US bank via RTP).
4
+ * RTP client for US instant bank payouts (Kusama DUSD or Base USDC → US bank).
5
5
  */
6
6
  export declare class RtpClient extends BaseClient {
7
7
  /**
8
- * Create an RTP payout swap order (DUSD on Kusama → USD to US bank).
8
+ * Create an RTP payout swap order (DUSD on Kusama or USDC on Base → USD to
9
+ * a US bank).
10
+ *
11
+ * Omit `fromMedium` (or pass `'kusama'`) to debit DUSD from a Kusama
12
+ * account. Pass `fromMedium: 'base'` with `args.txHash` to cash out USDC
13
+ * already sent to the source EVM account on Base.
9
14
  *
10
15
  * @param params - RTP order parameters including destination bank details
11
16
  * @returns Promise resolving to the created order
@@ -32,8 +37,36 @@ export declare class RtpClient extends BaseClient {
32
37
  * args: { sourceAccountUrn: 'did:bloque:account:kusama-user-001' },
33
38
  * });
34
39
  * ```
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const rates = await bloque.swap.findRates({
44
+ * fromAsset: 'USDC/6',
45
+ * toAsset: 'USD/2',
46
+ * fromMediums: ['base'],
47
+ * toMediums: ['rtp'],
48
+ * amountSrc: '100000000',
49
+ * });
50
+ *
51
+ * const result = await bloque.swap.rtp.create({
52
+ * rateSig: rates.rates[0].sig,
53
+ * amountSrc: '100000000',
54
+ * fromMedium: 'base',
55
+ * depositInformation: {
56
+ * owner: 'Jane Doe',
57
+ * accountNumber: '1234567890',
58
+ * routingNumber: '063108680',
59
+ * accountType: 'checking',
60
+ * },
61
+ * args: {
62
+ * sourceAccountUrn: 'did:bloque:account:polygon:abc123',
63
+ * txHash: '0xabc…',
64
+ * },
65
+ * });
66
+ * ```
35
67
  */
36
68
  create(params: CreateRtpOrderParams, options?: CreateRtpOrderOptions): Promise<CreateRtpOrderResult>;
69
+ private _mapArgs;
37
70
  private _mapDepositInformationToWire;
38
71
  private _mapOrderResponse;
39
72
  private _mapExecutionResult;
@@ -1,7 +1,9 @@
1
1
  import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bank-transfer/types';
2
2
  export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
3
+ /** Source medium for an RTP payout. */
4
+ export type RtpSourceMedium = 'kusama' | 'base';
3
5
  /**
4
- * US bank details for RTP payout (Kusama → US bank via RTP).
6
+ * US bank details for RTP payout (Kusama or Base → US bank via RTP).
5
7
  */
6
8
  export interface RtpDepositInformation {
7
9
  /** Account holder name */
@@ -17,14 +19,19 @@ export interface RtpDepositInformation {
17
19
  }
18
20
  export interface RtpSwapArgs {
19
21
  /**
20
- * Kusama account URN where DUSD will be debited.
22
+ * Source account URN to debit.
23
+ *
24
+ * Kusama: the Kusama account holding DUSD.
25
+ * Base: the EVM/Polygon account that received USDC on Base.
21
26
  */
22
27
  sourceAccountUrn: string;
28
+ /**
29
+ * Transaction hash of the incoming USDC transfer on Base.
30
+ * Required when {@link CreateRtpOrderParams.fromMedium} is `'base'`.
31
+ */
32
+ txHash?: string;
23
33
  }
24
- /**
25
- * Parameters for creating an RTP payout swap order.
26
- */
27
- export interface CreateRtpOrderParams {
34
+ interface CreateRtpOrderParamsBase {
28
35
  /**
29
36
  * Rate signature from findRates.
30
37
  */
@@ -49,10 +56,6 @@ export interface CreateRtpOrderParams {
49
56
  * Destination US bank account details.
50
57
  */
51
58
  depositInformation: RtpDepositInformation;
52
- /**
53
- * Source Kusama account for the debit leg.
54
- */
55
- args: RtpSwapArgs;
56
59
  /**
57
60
  * Specific node ID to execute (defaults to first node).
58
61
  */
@@ -62,6 +65,29 @@ export interface CreateRtpOrderParams {
62
65
  */
63
66
  metadata?: Record<string, unknown>;
64
67
  }
68
+ /**
69
+ * RTP payout from DUSD on Kusama. `fromMedium` may be omitted — Kusama is the default.
70
+ */
71
+ export interface CreateRtpKusamaOrderParams extends CreateRtpOrderParamsBase {
72
+ fromMedium?: 'kusama';
73
+ args: RtpSwapArgs;
74
+ }
75
+ /**
76
+ * RTP payout from USDC on Base. Requires `args.txHash` of the USDC transfer.
77
+ */
78
+ export interface CreateRtpBaseOrderParams extends CreateRtpOrderParamsBase {
79
+ fromMedium: 'base';
80
+ args: RtpSwapArgs & {
81
+ txHash: string;
82
+ };
83
+ }
84
+ /**
85
+ * Parameters for creating an RTP payout swap order.
86
+ *
87
+ * Defaults to Kusama (`fromMedium` omitted). Pass `fromMedium: 'base'` with
88
+ * `args.txHash` to cash out USDC already sent to the source EVM account on Base.
89
+ */
90
+ export type CreateRtpOrderParams = CreateRtpKusamaOrderParams | CreateRtpBaseOrderParams;
65
91
  export interface CreateRtpOrderOptions {
66
92
  /**
67
93
  * Optional custom idempotency key sent as `Idempotency-Key` header.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-swap",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "bloque",
@@ -34,6 +34,6 @@
34
34
  "node": ">=22"
35
35
  },
36
36
  "dependencies": {
37
- "@bloque/sdk-core": "0.11.1"
37
+ "@bloque/sdk-core": "0.13.0"
38
38
  }
39
39
  }