@bloque/sdk-swap 0.0.32 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,53 @@
1
+ import { BaseClient } from '@bloque/sdk-core';
2
+ import type { CreateBankTransferOrderParams, CreateBankTransferOrderResult } from './types';
3
+ /**
4
+ * Generic bank transfer client for cash-out swaps
5
+ *
6
+ * Supports any Colombian bank as the destination medium.
7
+ * The specific bank is selected via the `toMedium` parameter when creating an order.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const result = await bloque.swap.bankTransfer.create({
12
+ * rateSig: rate.sig,
13
+ * toMedium: 'banco_de_bogota',
14
+ * amountSrc: '5000000',
15
+ * depositInformation: {
16
+ * bankAccountType: 'savings',
17
+ * bankAccountNumber: '123456789',
18
+ * bankAccountHolderName: 'Juan Pérez',
19
+ * bankAccountHolderIdentificationType: 'CC',
20
+ * bankAccountHolderIdentificationValue: '1234567890',
21
+ * },
22
+ * args: { accountUrn: 'did:bloque:card:abc123' },
23
+ * });
24
+ * ```
25
+ */
26
+ export declare class BankTransferClient extends BaseClient {
27
+ /**
28
+ * Create a bank transfer swap order
29
+ *
30
+ * Creates a swap order using Kusama as the source and any supported
31
+ * Colombian bank as the destination. The target bank is specified
32
+ * via `params.toMedium`.
33
+ *
34
+ * @param params - Bank transfer order parameters
35
+ * @returns Promise resolving to the created order with optional execution result
36
+ */
37
+ create(params: CreateBankTransferOrderParams): Promise<CreateBankTransferOrderResult>;
38
+ /**
39
+ * Maps SDK deposit information to wire format
40
+ * @internal
41
+ */
42
+ private _mapDepositInformationToWire;
43
+ /**
44
+ * Maps API order response to SDK format
45
+ * @internal
46
+ */
47
+ private _mapOrderResponse;
48
+ /**
49
+ * Maps API execution result to SDK format
50
+ * @internal
51
+ */
52
+ private _mapExecutionResult;
53
+ }
@@ -0,0 +1,242 @@
1
+ /**
2
+ * Generic bank transfer types for @bloque/sdk-swap
3
+ *
4
+ * Supports any Colombian bank as the destination medium for cash-out swaps.
5
+ */
6
+ /**
7
+ * Supported Colombian banks for cash-out transfers
8
+ *
9
+ * @example Transfer to Bancolombia
10
+ * ```typescript
11
+ * await bloque.swap.bankTransfer.create({
12
+ * rateSig: rate.sig,
13
+ * toMedium: 'bancolombia',
14
+ * amountSrc: '5000000',
15
+ * depositInformation: {
16
+ * bankAccountType: 'savings',
17
+ * bankAccountNumber: '5740088718',
18
+ * bankAccountHolderName: 'Juan Pérez',
19
+ * bankAccountHolderIdentificationType: 'CC',
20
+ * bankAccountHolderIdentificationValue: '1234567890',
21
+ * },
22
+ * args: { sourceAccountUrn: 'did:bloque:card:abc123' },
23
+ * });
24
+ * ```
25
+ *
26
+ * @example Transfer to Banco de Bogotá
27
+ * ```typescript
28
+ * await bloque.swap.bankTransfer.create({
29
+ * rateSig: rate.sig,
30
+ * toMedium: 'banco_de_bogota',
31
+ * amountSrc: '2000000',
32
+ * depositInformation: {
33
+ * bankAccountType: 'checking',
34
+ * bankAccountNumber: '987654321',
35
+ * bankAccountHolderName: 'María López',
36
+ * bankAccountHolderIdentificationType: 'CE',
37
+ * bankAccountHolderIdentificationValue: '456789',
38
+ * },
39
+ * args: { sourceAccountUrn: 'did:bloque:card:xyz789' },
40
+ * });
41
+ * ```
42
+ *
43
+ * @example Transfer to BBVA Colombia
44
+ * ```typescript
45
+ * await bloque.swap.bankTransfer.create({
46
+ * rateSig: rate.sig,
47
+ * toMedium: 'banco_bbva_colombia',
48
+ * amountSrc: '10000000',
49
+ * depositInformation: {
50
+ * bankAccountType: 'savings',
51
+ * bankAccountNumber: '1122334455',
52
+ * bankAccountHolderName: 'Carlos Ruiz',
53
+ * bankAccountHolderIdentificationType: 'NIT',
54
+ * bankAccountHolderIdentificationValue: '900123456',
55
+ * },
56
+ * args: { sourceAccountUrn: 'did:bloque:card:def456' },
57
+ * });
58
+ * ```
59
+ */
60
+ export type SupportedBank = 'banco_agrario_de_colombia' | 'banco_av_villas' | 'banco_bancamia' | 'banco_bbva_colombia' | 'banco_btg_pactual_colombia' | 'citibank_colombia' | 'banco_caja_social_bcsc' | 'davibank' | 'banco_contactar' | 'banco_cooperativo_coopcentral' | 'ban100' | 'banco_davivienda' | 'banco_de_bogota' | 'banco_de_occidente' | 'banco_gnb_sudameris' | 'banco_jp_morgan_colombia' | 'banco_popular' | 'banco_itau' | 'bancolombia' | 'banco_w' | 'banco_coomeva' | 'banco_finandina_bic' | 'banco_falabella' | 'banco_pichincha' | 'banco_santander_de_negocios_colombia' | 'banco_mundo_mujer' | 'banco_serfinanza' | 'mibanco' | 'lulo_bank' | 'banco_union';
61
+ /**
62
+ * Bank account type
63
+ */
64
+ export type BankAccountType = 'savings' | 'checking';
65
+ /**
66
+ * Identification type for account holder
67
+ */
68
+ export type IdentificationType = 'CC' | 'CE' | 'NIT' | 'PP';
69
+ /**
70
+ * Bank deposit information for direct bank transfers
71
+ *
72
+ * This is the same shape for all Colombian banks — the specific bank
73
+ * is selected via the `toMedium` parameter in the order.
74
+ */
75
+ export interface BankDepositInformation {
76
+ /**
77
+ * Bank account type
78
+ * @example "savings"
79
+ */
80
+ bankAccountType: BankAccountType;
81
+ /**
82
+ * Bank account number
83
+ * @example "5740088718"
84
+ */
85
+ bankAccountNumber: string;
86
+ /**
87
+ * Account holder full name
88
+ * @example "david barinas"
89
+ */
90
+ bankAccountHolderName: string;
91
+ /**
92
+ * Account holder identification type
93
+ * @example "CC"
94
+ */
95
+ bankAccountHolderIdentificationType: IdentificationType;
96
+ /**
97
+ * Account holder identification number
98
+ * @example "123456789"
99
+ */
100
+ bankAccountHolderIdentificationValue: string;
101
+ }
102
+ /**
103
+ * Kusama account arguments for swap execution
104
+ */
105
+ export interface KusamaAccountArgs {
106
+ /**
107
+ * Account URN where funds will be debited from
108
+ * @example "did:bloque:card:1231231"
109
+ */
110
+ sourceAccountUrn: string;
111
+ }
112
+ /**
113
+ * Order type for swap
114
+ * - 'src': Taker specifies exact source amount to pay
115
+ * - 'dst': Taker specifies exact destination amount to receive
116
+ */
117
+ export type OrderType = 'src' | 'dst';
118
+ /**
119
+ * Parameters for creating a bank transfer swap order
120
+ */
121
+ export interface CreateBankTransferOrderParams {
122
+ /**
123
+ * Rate signature from findRates
124
+ */
125
+ rateSig: string;
126
+ /**
127
+ * Destination bank medium (e.g., "bancolombia", "banco_de_bogota", "banco_davivienda")
128
+ * @example "banco_bbva_colombia"
129
+ */
130
+ toMedium: SupportedBank;
131
+ /**
132
+ * Source amount as bigint string (required if type is 'src')
133
+ * @example "100000000"
134
+ */
135
+ amountSrc?: string;
136
+ /**
137
+ * Destination amount as bigint string (required if type is 'dst')
138
+ * @example "50000000" represents 500000.00 COP
139
+ */
140
+ amountDst?: string;
141
+ /**
142
+ * Order type (default: 'src')
143
+ */
144
+ type?: OrderType;
145
+ /**
146
+ * Bank account information for fund delivery
147
+ */
148
+ depositInformation: BankDepositInformation;
149
+ /**
150
+ * Kusama account arguments for swap execution
151
+ */
152
+ args: KusamaAccountArgs;
153
+ /**
154
+ * Specific node ID to execute (defaults to first node)
155
+ */
156
+ nodeId?: string;
157
+ /**
158
+ * Additional metadata for the order
159
+ */
160
+ metadata?: Record<string, unknown>;
161
+ }
162
+ /**
163
+ * Swap order details
164
+ */
165
+ export interface SwapOrder {
166
+ /** Unique order identifier */
167
+ id: string;
168
+ /** Order signature */
169
+ orderSig: string;
170
+ /** Rate signature used for this order */
171
+ rateSig: string;
172
+ /** Swap signature */
173
+ swapSig: string;
174
+ /** Taker URN */
175
+ taker: string;
176
+ /** Maker URN */
177
+ maker: string;
178
+ /** Source asset */
179
+ fromAsset: string;
180
+ /** Destination asset */
181
+ toAsset: string;
182
+ /** Source medium */
183
+ fromMedium: string;
184
+ /** Destination medium (bank name) */
185
+ toMedium: string;
186
+ /** Source amount */
187
+ fromAmount: string;
188
+ /** Destination amount */
189
+ toAmount: string;
190
+ /** Timestamp when the order was created */
191
+ at: string;
192
+ /** Instruction graph ID for tracking execution */
193
+ graphId: string;
194
+ /** Order status */
195
+ status: string;
196
+ /** Additional metadata */
197
+ metadata?: Record<string, unknown>;
198
+ /** Creation timestamp */
199
+ createdAt: string;
200
+ /** Last update timestamp */
201
+ updatedAt: string;
202
+ }
203
+ /**
204
+ * Redirect instructions for completing the payment
205
+ */
206
+ export interface ExecutionHow {
207
+ /** Type of action required (e.g., "REDIRECT") */
208
+ type: string;
209
+ /** URL to redirect the user to complete the payment */
210
+ url: string;
211
+ }
212
+ /**
213
+ * Execution result from auto-execution
214
+ */
215
+ export interface ExecutionResult {
216
+ /** Node ID that was executed */
217
+ nodeId: string;
218
+ /** Execution result details */
219
+ result: {
220
+ /** Execution status (e.g., "paused") */
221
+ status: string;
222
+ /** Name of the current step */
223
+ name?: string;
224
+ /** Description of what the user needs to do */
225
+ description?: string;
226
+ /** Instructions for completing this step */
227
+ how?: ExecutionHow;
228
+ /** Callback token for tracking */
229
+ callbackToken?: string;
230
+ };
231
+ }
232
+ /**
233
+ * Result of creating a bank transfer swap order
234
+ */
235
+ export interface CreateBankTransferOrderResult {
236
+ /** The created order */
237
+ order: SwapOrder;
238
+ /** Execution result (if args were provided for auto-execution) */
239
+ execution?: ExecutionResult;
240
+ /** Request ID for tracking */
241
+ requestId: string;
242
+ }
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__,{SwapClient:()=>SwapClient,PseClient:()=>PseClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");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){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=e.type??"src",r={taker_urn:t,type:a,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={bank_code:e.args.bankCode,...e.args.userType&&{user_type:e.args.userType},...e.args.customerEmail&&{customer_email:e.args.customerEmail},...e.args.userLegalIdType&&{user_legal_id_type:e.args.userLegalIdType},...e.args.userLegalId&&{user_legal_id:e.args.userLegalId},...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName}}}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});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,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;constructor(e){super(e),this.pse=new PseClient(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(),s=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:s})).rates.map(e=>this._mapRateResponse(e))}}_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.PseClient=__webpack_exports__.PseClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["PseClient","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 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__,{SwapClient:()=>SwapClient,BankTransferClient:()=>BankTransferClient,PseClient:()=>PseClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BankTransferClient extends sdk_core_namespaceObject.BaseClient{async create(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=e.type??"src",r={taker_urn:t,type:a,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={account_urn:e.args.sourceAccountUrn}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});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,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,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){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=e.type??"src",r={taker_urn:t,type:a,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===a&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===a&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={bank_code:e.args.bankCode,...e.args.userType&&{user_type:e.args.userType},...e.args.customerEmail&&{customer_email:e.args.customerEmail},...e.args.userLegalIdType&&{user_legal_id_type:e.args.userLegalIdType},...e.args.userLegalId&&{user_legal_id:e.args.userLegalId},...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName,phone_number:e.args.customerData.phoneNumber}}}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let s=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});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,callbackToken:e.result.callback_token}}}}class SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bankTransfer;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bankTransfer=new BankTransferClient(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(),s=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:s})).rates.map(e=>this._mapRateResponse(e))}}_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.PseClient=__webpack_exports__.PseClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BankTransferClient","PseClient","SwapClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- export * from './pse/pse-client';
2
- export * from './pse/types';
3
- export * from './swap-client';
4
- export * from './types';
1
+ export { BankTransferClient } from './bank-transfer/bank-transfer-client';
2
+ export type { BankAccountType, BankDepositInformation, CreateBankTransferOrderParams, CreateBankTransferOrderResult, ExecutionHow, ExecutionResult, IdentificationType, KusamaAccountArgs, OrderType, SupportedBank, SwapOrder, } from './bank-transfer/types';
3
+ export { PseClient } from './pse/pse-client';
4
+ export type { Bank, CreatePseOrderParams, CreatePseOrderResult, DepositInformation, ListBanksResult, PseCustomerData, PsePaymentArgs, } from './pse/types';
5
+ export { SwapClient } from './swap-client';
6
+ export type { Fee, FeeComponent, FeeComponentType, FindRatesParams, FindRatesResult, RateLimits, RateTuple, SwapRate, } from './types';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{BaseClient as e,BloqueConfigError as t}from"@bloque/sdk-core";class a 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){let a=this.httpClient.urn;if(!a)throw new t("User URN is not available. Please connect to a session first.");let s=e.type??"src",r={taker_urn:a,type:s,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===s&&e.amountSrc?r.amount_src=e.amountSrc:"dst"===s&&e.amountDst&&(r.amount_dst=e.amountDst),e.args&&(r.args={bank_code:e.args.bankCode,...e.args.userType&&{user_type:e.args.userType},...e.args.customerEmail&&{customer_email:e.args.customerEmail},...e.args.userLegalIdType&&{user_legal_id_type:e.args.userLegalIdType},...e.args.userLegalId&&{user_legal_id:e.args.userLegalId},...e.args.customerData&&{customer_data:{full_name:e.args.customerData.fullName}}}),e.nodeId&&(r.node_id=e.nodeId),e.metadata&&(r.metadata=e.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:r});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.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,callbackToken:e.result.callback_token}}}}class s extends e{pse;constructor(e){super(e),this.pse=new a(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 s=t.toString(),r=`/api/rates?${s}`;return{rates:(await this.httpClient.request({method:"GET",path:r})).rates.map(e=>this._mapRateResponse(e))}}_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{a as PseClient,s as SwapClient};
1
+ import{BaseClient as t,BloqueConfigError as e}from"@bloque/sdk-core";class a extends t{async create(t){let a=this.httpClient.urn;if(!a)throw new e("User URN is not available. Please connect to a session first.");let r=t.type??"src",s={taker_urn:a,type:r,rate_sig:t.rateSig,from_medium:"kusama",to_medium:t.toMedium,deposit_information:this._mapDepositInformationToWire(t.depositInformation)};"src"===r&&t.amountSrc?s.amount_src=t.amountSrc:"dst"===r&&t.amountDst&&(s.amount_dst=t.amountDst),t.args&&(s.args={account_urn:t.args.sourceAccountUrn}),t.nodeId&&(s.node_id=t.nodeId),t.metadata&&(s.metadata=t.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapDepositInformationToWire(t){return{bank_account_type:t.bankAccountType,bank_account_number:t.bankAccountNumber,bank_account_holder_name:t.bankAccountHolderName,bank_account_holder_identification_type:t.bankAccountHolderIdentificationType,bank_account_holder_identification_value:t.bankAccountHolderIdentificationValue}}_mapOrderResponse(t){return{id:t.id,orderSig:t.order_sig,rateSig:t.rate_sig,swapSig:t.swap_sig,taker:t.taker,maker:t.maker,fromAsset:t.from_asset,toAsset:t.to_asset,fromMedium:t.from_medium,toMedium:t.to_medium,fromAmount:t.from_amount,toAmount:t.to_amount,at:t.at,graphId:t.graph_id,status:t.status,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}_mapExecutionResult(t){return{nodeId:t.node_id,result:{status:t.result.status,name:t.result.name,description:t.result.description,how:t.result.how,callbackToken:t.result.callback_token}}}}class r extends t{async banks(){return{banks:(await this.httpClient.request({method:"GET",path:"/api/utils/pse/banks"})).banks.map(t=>this._mapBankResponse(t))}}async create(t){let a=this.httpClient.urn;if(!a)throw new e("User URN is not available. Please connect to a session first.");let r=t.type??"src",s={taker_urn:a,type:r,rate_sig:t.rateSig,from_medium:"pse",to_medium:t.toMedium,deposit_information:this._mapDepositInformationToWire(t.depositInformation)};"src"===r&&t.amountSrc?s.amount_src=t.amountSrc:"dst"===r&&t.amountDst&&(s.amount_dst=t.amountDst),t.args&&(s.args={bank_code:t.args.bankCode,...t.args.userType&&{user_type:t.args.userType},...t.args.customerEmail&&{customer_email:t.args.customerEmail},...t.args.userLegalIdType&&{user_legal_id_type:t.args.userLegalIdType},...t.args.userLegalId&&{user_legal_id:t.args.userLegalId},...t.args.customerData&&{customer_data:{full_name:t.args.customerData.fullName,phone_number:t.args.customerData.phoneNumber}}}),t.nodeId&&(s.node_id=t.nodeId),t.metadata&&(s.metadata=t.metadata);let o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapBankResponse(t){return{code:t.financial_institution_code,name:t.financial_institution_name}}_mapDepositInformationToWire(t){return{urn:t.urn}}_mapOrderResponse(t){return{id:t.id,orderSig:t.order_sig,rateSig:t.rate_sig,swapSig:t.swap_sig,taker:t.taker,maker:t.maker,fromAsset:t.from_asset,toAsset:t.to_asset,fromMedium:t.from_medium,toMedium:t.to_medium,fromAmount:t.from_amount,toAmount:t.to_amount,at:t.at,graphId:t.graph_id,status:t.status,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}_mapExecutionResult(t){return{nodeId:t.node_id,result:{status:t.result.status,name:t.result.name,description:t.result.description,how:t.result.how,callbackToken:t.result.callback_token}}}}class s extends t{pse;bankTransfer;constructor(t){super(t),this.pse=new r(this.httpClient),this.bankTransfer=new a(this.httpClient)}async findRates(t){let e=new URLSearchParams,a=JSON.stringify([t.fromAsset,t.toAsset]);e.append("edge",a),e.append("from_medium",JSON.stringify(t.fromMediums)),e.append("to_medium",JSON.stringify(t.toMediums)),void 0!==t.amountSrc&&e.append("amount_src",t.amountSrc),void 0!==t.amountDst&&e.append("amount_dst",t.amountDst),t.sort&&e.append("sort",t.sort),t.sortBy&&e.append("sort_by",t.sortBy);let r=e.toString(),s=`/api/rates?${r}`;return{rates:(await this.httpClient.request({method:"GET",path:s})).rates.map(t=>this._mapRateResponse(t))}}_mapRateResponse(t){return{id:t.id,sig:t.sig,swapSig:t.swap_sig,maker:t.maker,edge:t.edge,fee:{at:t.fee.at,value:t.fee.value,formula:t.fee.formula,components:t.fee.components.map(t=>({at:t.at,name:t.name,type:t.type,value:t.value,percentage:t.percentage,pair:t.pair,amount:t.amount}))},at:t.at,until:t.until,fromMediums:t.from_medium,toMediums:t.to_medium,rate:t.rate,ratio:t.ratio,fromLimits:t.from_limits,toLimits:t.to_limits,createdAt:t.created_at,updatedAt:t.updated_at}}}export{a as BankTransferClient,r as PseClient,s as SwapClient};
@@ -75,10 +75,24 @@ export interface ListPseBanksResponse {
75
75
  export type OrderType = 'src' | 'dst';
76
76
  /**
77
77
  * @internal
78
- * Deposit information for PSE top-up
78
+ * Deposit information for swap orders
79
79
  */
80
80
  export interface DepositInformation {
81
- urn: string;
81
+ /** PSE deposit URN */
82
+ urn?: string;
83
+ /** Bancolombia deposit information */
84
+ bancolombia?: BancolombiaDepositInformation;
85
+ }
86
+ /**
87
+ * @internal
88
+ * Bancolombia deposit information for bank account details
89
+ */
90
+ export interface BancolombiaDepositInformation {
91
+ bank_account_type: 'savings' | 'checking';
92
+ bank_account_number: string;
93
+ bank_account_holder_name: string;
94
+ bank_account_holder_identification_type: 'CC' | 'CE' | 'NIT' | 'PP';
95
+ bank_account_holder_identification_value: string;
82
96
  }
83
97
  /**
84
98
  * @internal
@@ -92,7 +106,7 @@ export interface CreateOrderInput {
92
106
  to_medium: string;
93
107
  amount_src?: string;
94
108
  amount_dst?: string;
95
- deposit_information: DepositInformation;
109
+ deposit_information: DepositInformation | BancolombiaDepositInformation;
96
110
  args?: Record<string, unknown>;
97
111
  node_id?: string;
98
112
  metadata?: Record<string, unknown>;
@@ -1,3 +1,5 @@
1
+ import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bank-transfer/types';
2
+ export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
1
3
  export interface Bank {
2
4
  /**
3
5
  * Financial institution code
@@ -11,12 +13,6 @@ export interface Bank {
11
13
  export interface ListBanksResult {
12
14
  banks: Bank[];
13
15
  }
14
- /**
15
- * Order type for swap
16
- * - 'src': Taker specifies exact source amount to pay
17
- * - 'dst': Taker specifies exact destination amount to receive
18
- */
19
- export type OrderType = 'src' | 'dst';
20
16
  /**
21
17
  * Deposit information for PSE top-up
22
18
  */
@@ -35,6 +31,10 @@ export interface PseCustomerData {
35
31
  * Customer's full name
36
32
  */
37
33
  fullName: string;
34
+ /**
35
+ * Customer's phone number
36
+ */
37
+ phoneNumber: string;
38
38
  }
39
39
  /**
40
40
  * PSE payment arguments for auto-execution
@@ -45,25 +45,25 @@ export interface PsePaymentArgs {
45
45
  */
46
46
  bankCode: string;
47
47
  /**
48
- * User type: 'natural' for natural person, 'juridica' for legal entity
48
+ * User type: 0 for natural person, 1 for legal entity
49
49
  */
50
- userType?: 'natural' | 'juridica';
50
+ userType: 0 | 1;
51
51
  /**
52
52
  * Customer email address
53
53
  */
54
- customerEmail?: string;
54
+ customerEmail: string;
55
55
  /**
56
56
  * User legal ID type (e.g., 'CC', 'NIT', 'CE')
57
57
  */
58
- userLegalIdType?: 'CC' | 'NIT' | 'CE';
58
+ userLegalIdType: 'CC' | 'NIT' | 'CE';
59
59
  /**
60
60
  * User legal ID number
61
61
  */
62
- userLegalId?: string;
62
+ userLegalId: string;
63
63
  /**
64
64
  * Additional customer data
65
65
  */
66
- customerData?: PseCustomerData;
66
+ customerData: PseCustomerData;
67
67
  }
68
68
  /**
69
69
  * Parameters for creating a PSE swap order
@@ -97,7 +97,7 @@ export interface CreatePseOrderParams {
97
97
  /**
98
98
  * PSE payment arguments for auto-execution
99
99
  */
100
- args?: PsePaymentArgs;
100
+ args: PsePaymentArgs;
101
101
  /**
102
102
  * Specific node ID to execute (defaults to first node)
103
103
  */
@@ -107,130 +107,6 @@ export interface CreatePseOrderParams {
107
107
  */
108
108
  metadata?: Record<string, unknown>;
109
109
  }
110
- /**
111
- * Swap order details
112
- */
113
- export interface SwapOrder {
114
- /**
115
- * Unique order identifier
116
- */
117
- id: string;
118
- /**
119
- * Order signature
120
- */
121
- orderSig: string;
122
- /**
123
- * Rate signature used for this order
124
- */
125
- rateSig: string;
126
- /**
127
- * Swap signature
128
- */
129
- swapSig: string;
130
- /**
131
- * Taker URN
132
- */
133
- taker: string;
134
- /**
135
- * Maker URN
136
- */
137
- maker: string;
138
- /**
139
- * Source asset
140
- */
141
- fromAsset: string;
142
- /**
143
- * Destination asset
144
- */
145
- toAsset: string;
146
- /**
147
- * Source medium
148
- */
149
- fromMedium: string;
150
- /**
151
- * Destination medium
152
- */
153
- toMedium: string;
154
- /**
155
- * Source amount
156
- */
157
- fromAmount: string;
158
- /**
159
- * Destination amount
160
- */
161
- toAmount: string;
162
- /**
163
- * Timestamp when the order was created (as string)
164
- */
165
- at: string;
166
- /**
167
- * Instruction graph ID for tracking execution
168
- */
169
- graphId: string;
170
- /**
171
- * Order status (pending, in_progress, completed, failed)
172
- */
173
- status: string;
174
- /**
175
- * Additional metadata
176
- */
177
- metadata?: Record<string, unknown>;
178
- /**
179
- * Creation timestamp
180
- */
181
- createdAt: string;
182
- /**
183
- * Last update timestamp
184
- */
185
- updatedAt: string;
186
- }
187
- /**
188
- * Redirect instructions for completing the payment
189
- */
190
- export interface ExecutionHow {
191
- /**
192
- * Type of action required (e.g., "REDIRECT")
193
- */
194
- type: string;
195
- /**
196
- * URL to redirect the user to complete the payment
197
- */
198
- url: string;
199
- }
200
- /**
201
- * Execution result from auto-execution
202
- */
203
- export interface ExecutionResult {
204
- /**
205
- * Node ID that was executed
206
- */
207
- nodeId: string;
208
- /**
209
- * Execution result details
210
- */
211
- result: {
212
- /**
213
- * Execution status (e.g., "paused")
214
- */
215
- status: string;
216
- /**
217
- * Name of the current step
218
- */
219
- name?: string;
220
- /**
221
- * Description of what the user needs to do
222
- */
223
- description?: string;
224
- /**
225
- * Instructions for completing this step
226
- */
227
- how?: ExecutionHow;
228
- /**
229
- * Callback token for tracking
230
- */
231
- callbackToken?: string;
232
- };
233
- }
234
110
  /**
235
111
  * Result of creating a PSE swap order
236
112
  */
@@ -1,5 +1,6 @@
1
1
  import type { HttpClient } from '@bloque/sdk-core';
2
2
  import { BaseClient } from '@bloque/sdk-core';
3
+ import { BankTransferClient } from './bank-transfer/bank-transfer-client';
3
4
  import { PseClient } from './pse/pse-client';
4
5
  import type { FindRatesParams, FindRatesResult } from './types';
5
6
  /**
@@ -7,9 +8,11 @@ import type { FindRatesParams, FindRatesResult } from './types';
7
8
  *
8
9
  * Provides access to exchange rate discovery and swapping functionality.
9
10
  * - pse: PSE utilities (bank listing, etc.)
11
+ * - bankTransfer: Generic bank transfer cash-out (supports all Colombian banks)
10
12
  */
11
13
  export declare class SwapClient extends BaseClient {
12
14
  readonly pse: PseClient;
15
+ readonly bankTransfer: BankTransferClient;
13
16
  constructor(httpClient: HttpClient);
14
17
  /**
15
18
  * Find available exchange rates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-swap",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
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.0.32"
37
+ "@bloque/sdk-core": "0.0.34"
38
38
  }
39
39
  }