@bloque/sdk-swap 0.1.13 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bank-transfer/types.d.ts +33 -2
- package/dist/breb/breb-client.d.ts +12 -2
- package/dist/breb/types.d.ts +73 -1
- package/dist/external-us-bank/external-us-bank-client.d.ts +38 -0
- package/dist/external-us-bank/types.d.ts +75 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1 -1
- package/dist/internal/map-execution.d.ts +7 -0
- package/dist/internal/wire-types.d.ts +43 -4
- package/dist/rtp/rtp-client.d.ts +39 -0
- package/dist/rtp/types.d.ts +68 -0
- package/dist/swap-client.d.ts +7 -1
- package/package.json +2 -2
|
@@ -226,14 +226,45 @@ export interface SwapOrder {
|
|
|
226
226
|
updatedAt: string;
|
|
227
227
|
}
|
|
228
228
|
/**
|
|
229
|
-
* Redirect instructions for completing the payment
|
|
229
|
+
* Redirect instructions for completing the payment (PSE, card, etc.)
|
|
230
230
|
*/
|
|
231
|
-
export interface
|
|
231
|
+
export interface ExecutionHowRedirect {
|
|
232
232
|
/** Type of action required (e.g., "REDIRECT") */
|
|
233
233
|
type: string;
|
|
234
234
|
/** URL to redirect the user to complete the payment */
|
|
235
235
|
url: string;
|
|
236
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* BRE-B on-ramp deposit instructions returned when the graph pauses.
|
|
239
|
+
* Show `keyType` / `keyValue` so the payer can send COP via their bank's BRE-B app.
|
|
240
|
+
*/
|
|
241
|
+
export interface ExecutionHowBrebDeposit {
|
|
242
|
+
type: 'BREB_DEPOSIT';
|
|
243
|
+
medium: 'breb';
|
|
244
|
+
/** BRE-B key type (e.g. "ALPHA") */
|
|
245
|
+
keyType: string;
|
|
246
|
+
/** One-time BRE-B key the payer must use */
|
|
247
|
+
keyValue: string;
|
|
248
|
+
/** Scaled COP amount (same precision as order.fromAmount, typically COP/2) */
|
|
249
|
+
amount: string;
|
|
250
|
+
currency: 'COP';
|
|
251
|
+
/** Order reference for reconciliation */
|
|
252
|
+
reference: string;
|
|
253
|
+
/** Temporary deposit account URN */
|
|
254
|
+
depositAccountUrn: string;
|
|
255
|
+
/** Scaled COP required for the order (same as amount on first pause). */
|
|
256
|
+
expectedAmount?: string;
|
|
257
|
+
/** Scaled COP received so far when multiple transfers top up the same key. */
|
|
258
|
+
receivedAmount?: string;
|
|
259
|
+
/** Scaled COP still required (derived: expectedAmount − receivedAmount). */
|
|
260
|
+
remainingAmount?: string;
|
|
261
|
+
/** `awaiting` on first pause; `partial` after an underpayment. */
|
|
262
|
+
depositStatus?: 'awaiting' | 'partial';
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Instructions for completing a paused execution step
|
|
266
|
+
*/
|
|
267
|
+
export type ExecutionHow = ExecutionHowRedirect | ExecutionHowBrebDeposit;
|
|
237
268
|
/**
|
|
238
269
|
* Execution result from auto-execution
|
|
239
270
|
*/
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
-
import type { CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult } from './types';
|
|
2
|
+
import type { CreateBrebDepositOptions, CreateBrebDepositParams, CreateBrebDepositResult, CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult } from './types';
|
|
3
3
|
export declare class BrebClient extends BaseClient {
|
|
4
|
+
/**
|
|
5
|
+
* Create a BRE-B payout order (Kusama → BRE-B COP cash-out).
|
|
6
|
+
*/
|
|
4
7
|
create(params: CreateBrebOrderParams, options?: CreateBrebOrderOptions): Promise<CreateBrebOrderResult>;
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Create a BRE-B on-ramp deposit order (COP via BRE-B → Kusama).
|
|
10
|
+
*
|
|
11
|
+
* When `args` is provided (even `{}`), the first node auto-executes and the
|
|
12
|
+
* response pauses with a one-time BRE-B key in `execution.result.how`.
|
|
13
|
+
*/
|
|
14
|
+
createDeposit(params: CreateBrebDepositParams, options?: CreateBrebDepositOptions): Promise<CreateBrebDepositResult>;
|
|
15
|
+
private _mapPayoutDepositInformationToWire;
|
|
6
16
|
private _mapOrderResponse;
|
|
7
17
|
private _mapExecutionResult;
|
|
8
18
|
}
|
package/dist/breb/types.d.ts
CHANGED
|
@@ -2,10 +2,19 @@ import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../ban
|
|
|
2
2
|
export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
|
|
3
3
|
export interface BrebDepositInformation {
|
|
4
4
|
/**
|
|
5
|
-
* Resolution id returned by BRE-B key resolution.
|
|
5
|
+
* Resolution id returned by BRE-B key resolution (payout).
|
|
6
6
|
*/
|
|
7
7
|
resolutionId: string;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Deposit information for BRE-B on-ramp (COP deposit → Kusama credit).
|
|
11
|
+
*/
|
|
12
|
+
export interface BrebDepositOnRampInformation {
|
|
13
|
+
/**
|
|
14
|
+
* Destination account URN that will be credited on Kusama.
|
|
15
|
+
*/
|
|
16
|
+
urn: string;
|
|
17
|
+
}
|
|
9
18
|
export interface BrebSwapArgs {
|
|
10
19
|
/**
|
|
11
20
|
* Account URN where funds will be debited from.
|
|
@@ -70,3 +79,66 @@ export interface CreateBrebOrderResult {
|
|
|
70
79
|
*/
|
|
71
80
|
requestId: string;
|
|
72
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Parameters for creating a BRE-B on-ramp deposit order (COP → Kusama).
|
|
84
|
+
*/
|
|
85
|
+
export interface CreateBrebDepositParams {
|
|
86
|
+
/**
|
|
87
|
+
* Rate signature from findRates.
|
|
88
|
+
*/
|
|
89
|
+
rateSig: string;
|
|
90
|
+
/**
|
|
91
|
+
* Optional webhook URL for order status notifications.
|
|
92
|
+
*/
|
|
93
|
+
webhookUrl?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Source amount as bigint string (required if type is 'src').
|
|
96
|
+
*/
|
|
97
|
+
amountSrc?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Destination amount as bigint string (required if type is 'dst').
|
|
100
|
+
*/
|
|
101
|
+
amountDst?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Order type (default: 'src').
|
|
104
|
+
*/
|
|
105
|
+
type?: OrderType;
|
|
106
|
+
/**
|
|
107
|
+
* Destination account URN to credit on Kusama.
|
|
108
|
+
*/
|
|
109
|
+
depositInformation: BrebDepositOnRampInformation;
|
|
110
|
+
/**
|
|
111
|
+
* When provided, auto-executes the first node and pauses with the BRE-B key.
|
|
112
|
+
* Pass `{}` to trigger auto-execution with server-filled defaults.
|
|
113
|
+
*/
|
|
114
|
+
args?: Record<string, unknown>;
|
|
115
|
+
/**
|
|
116
|
+
* Specific node ID to execute (defaults to first node).
|
|
117
|
+
*/
|
|
118
|
+
nodeId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Additional metadata for the order.
|
|
121
|
+
*/
|
|
122
|
+
metadata?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
export interface CreateBrebDepositOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Optional custom idempotency key sent as `Idempotency-Key` header.
|
|
127
|
+
*/
|
|
128
|
+
idempotencyKey?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface CreateBrebDepositResult {
|
|
131
|
+
/**
|
|
132
|
+
* The created order.
|
|
133
|
+
*/
|
|
134
|
+
order: SwapOrder;
|
|
135
|
+
/**
|
|
136
|
+
* Execution result when args were provided. The paused `how` is
|
|
137
|
+
* `ExecutionHowBrebDeposit` with the one-time BRE-B key to pay.
|
|
138
|
+
*/
|
|
139
|
+
execution?: ExecutionResult;
|
|
140
|
+
/**
|
|
141
|
+
* Request ID for tracking.
|
|
142
|
+
*/
|
|
143
|
+
requestId: string;
|
|
144
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { CreateExternalUsBankOrderOptions, CreateExternalUsBankOrderParams, CreateExternalUsBankOrderResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* External US bank client for ACH on-ramp (US bank → Kusama DUSD).
|
|
5
|
+
*/
|
|
6
|
+
export declare class ExternalUsBankSwapClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Create an external US bank on-ramp order (ACH pull → DUSD on Kusama).
|
|
9
|
+
*
|
|
10
|
+
* @param params - Order parameters including ledger account and linked bank
|
|
11
|
+
* @returns Promise resolving to the created order
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const rates = await bloque.swap.findRates({
|
|
16
|
+
* fromAsset: 'USD/2',
|
|
17
|
+
* toAsset: 'DUSD/6',
|
|
18
|
+
* fromMediums: ['external-us-bank'],
|
|
19
|
+
* toMediums: ['kusama'],
|
|
20
|
+
* amountSrc: '10000',
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const result = await bloque.swap.externalUsBank.create({
|
|
24
|
+
* rateSig: rates.rates[0].sig,
|
|
25
|
+
* amountSrc: '10000',
|
|
26
|
+
* depositInformation: {
|
|
27
|
+
* ledgerAccountId: 'ledger-user-001',
|
|
28
|
+
* },
|
|
29
|
+
* args: {
|
|
30
|
+
* sourceAccountUrn: 'did:bloque:account:external-us-bank:abc123',
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
create(params: CreateExternalUsBankOrderParams, options?: CreateExternalUsBankOrderOptions): Promise<CreateExternalUsBankOrderResult>;
|
|
36
|
+
private _mapOrderResponse;
|
|
37
|
+
private _mapExecutionResult;
|
|
38
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bank-transfer/types';
|
|
2
|
+
export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
|
|
3
|
+
/**
|
|
4
|
+
* Deposit information for external US bank on-ramp (ACH pull → Kusama).
|
|
5
|
+
*/
|
|
6
|
+
export interface ExternalUsBankDepositInformation {
|
|
7
|
+
/**
|
|
8
|
+
* Destination Kusama ledger account id to credit after teleport.
|
|
9
|
+
*/
|
|
10
|
+
ledgerAccountId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Arguments for external US bank on-ramp auto-execution.
|
|
14
|
+
*/
|
|
15
|
+
export interface ExternalUsBankArgs {
|
|
16
|
+
/**
|
|
17
|
+
* Linked external US bank account URN to pull funds from.
|
|
18
|
+
*/
|
|
19
|
+
sourceAccountUrn: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parameters for creating an external US bank on-ramp order.
|
|
23
|
+
*/
|
|
24
|
+
export interface CreateExternalUsBankOrderParams {
|
|
25
|
+
/**
|
|
26
|
+
* Rate signature from findRates.
|
|
27
|
+
*/
|
|
28
|
+
rateSig: string;
|
|
29
|
+
/**
|
|
30
|
+
* Optional webhook URL for order status notifications.
|
|
31
|
+
*/
|
|
32
|
+
webhookUrl?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Source amount as bigint string (required if type is 'src').
|
|
35
|
+
*/
|
|
36
|
+
amountSrc?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Destination amount as bigint string (required if type is 'dst').
|
|
39
|
+
*/
|
|
40
|
+
amountDst?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Order type (default: 'src').
|
|
43
|
+
*/
|
|
44
|
+
type?: OrderType;
|
|
45
|
+
/**
|
|
46
|
+
* Destination ledger account to credit on Kusama.
|
|
47
|
+
*/
|
|
48
|
+
depositInformation: ExternalUsBankDepositInformation;
|
|
49
|
+
/**
|
|
50
|
+
* Linked bank account and auto-execution arguments.
|
|
51
|
+
*/
|
|
52
|
+
args: ExternalUsBankArgs;
|
|
53
|
+
/**
|
|
54
|
+
* Specific node ID to execute (defaults to first node).
|
|
55
|
+
*/
|
|
56
|
+
nodeId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Additional metadata for the order.
|
|
59
|
+
*/
|
|
60
|
+
metadata?: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
export interface CreateExternalUsBankOrderOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Optional custom idempotency key sent as `Idempotency-Key` header.
|
|
65
|
+
*/
|
|
66
|
+
idempotencyKey?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface CreateExternalUsBankOrderResult {
|
|
69
|
+
/** The created order */
|
|
70
|
+
order: SwapOrder;
|
|
71
|
+
/** Execution result if auto-execution was triggered */
|
|
72
|
+
execution?: ExecutionResult;
|
|
73
|
+
/** Request ID for tracking */
|
|
74
|
+
requestId: string;
|
|
75
|
+
}
|
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 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__,{BrebClient:()=>BrebClient,SwapClient:()=>SwapClient,BankTransferClient:()=>BankTransferClient,PseClient:()=>PseClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");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",s={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?s.amount_src=e.amountSrc:"dst"===a&&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 o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.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,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",s={taker_urn:r,type:a,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"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 o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{order:this._mapOrderResponse(o.result.order),execution:o.result.execution?this._mapExecutionResult(o.result.execution):void 0,requestId:o.req_id}}_mapDepositInformationToWire(e){return{resolution_id:e.resolutionId}}_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,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",s={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?s.amount_src=e.amountSrc:"dst"===a&&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,...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 o=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});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 SwapClient extends sdk_core_namespaceObject.BaseClient{pse;bankTransfer;breb;constructor(e){super(e),this.pse=new PseClient(this.httpClient),this.bankTransfer=new BankTransferClient(this.httpClient),this.breb=new BrebClient(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(),s=`/api/rates?${a}`;return{rates:(await this.httpClient.request({method:"GET",path:s})).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(),s=`/api/order/taker/${t}${a?`?${a}`:""}`;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}}}for(var __rspack_i in exports.BankTransferClient=__webpack_exports__.BankTransferClient,exports.BrebClient=__webpack_exports__.BrebClient,exports.PseClient=__webpack_exports__.PseClient,exports.SwapClient=__webpack_exports__.SwapClient,__webpack_exports__)-1===["BankTransferClient","BrebClient","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__,{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 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}:{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}}_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,...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)};"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});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { BankTransferClient } from './bank-transfer/bank-transfer-client';
|
|
2
|
-
export type { BankAccountType, BankDepositInformation, CreateBankTransferOrderOptions, CreateBankTransferOrderParams, CreateBankTransferOrderResult, ExecutionHow, ExecutionResult, IdentificationType, KusamaAccountArgs, OrderType, SupportedBank, SwapOrder, } from './bank-transfer/types';
|
|
2
|
+
export type { BankAccountType, BankDepositInformation, CreateBankTransferOrderOptions, CreateBankTransferOrderParams, CreateBankTransferOrderResult, ExecutionHow, ExecutionHowBrebDeposit, ExecutionHowRedirect, ExecutionResult, IdentificationType, KusamaAccountArgs, OrderType, SupportedBank, SwapOrder, } from './bank-transfer/types';
|
|
3
3
|
export { BrebClient } from './breb/breb-client';
|
|
4
|
-
export type { BrebDepositInformation, BrebSwapArgs, CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult, } from './breb/types';
|
|
4
|
+
export type { BrebDepositInformation, BrebDepositOnRampInformation, BrebSwapArgs, CreateBrebDepositOptions, CreateBrebDepositParams, CreateBrebDepositResult, CreateBrebOrderOptions, CreateBrebOrderParams, CreateBrebOrderResult, } from './breb/types';
|
|
5
|
+
export { ExternalUsBankSwapClient } from './external-us-bank/external-us-bank-client';
|
|
6
|
+
export type { CreateExternalUsBankOrderOptions, CreateExternalUsBankOrderParams, CreateExternalUsBankOrderResult, ExternalUsBankArgs, ExternalUsBankDepositInformation, } from './external-us-bank/types';
|
|
5
7
|
export { PseClient } from './pse/pse-client';
|
|
6
8
|
export type { Bank, CreatePseOrderOptions, CreatePseOrderParams, CreatePseOrderResult, DepositInformation, ListBanksResult, PseCustomerData, PsePaymentArgs, } from './pse/types';
|
|
9
|
+
export { RtpClient } from './rtp/rtp-client';
|
|
10
|
+
export type { CreateRtpOrderOptions, CreateRtpOrderParams, CreateRtpOrderResult, RtpDepositInformation, } from './rtp/types';
|
|
7
11
|
export { SwapClient } from './swap-client';
|
|
8
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";class a 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 s=e.type??"src",o={taker_urn:r,type:s,rate_sig:e.rateSig,from_medium:"kusama",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===s&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===s&&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 i=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,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,callbackToken:e.result.callback_token}}}}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 s=e.type??"src",o={taker_urn:r,type:s,rate_sig:e.rateSig,from_medium:"kusama",to_medium:"breb",webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation),args:{account_urn:e.args.sourceAccountUrn}};"src"===s&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===s&&e.amountDst&&(o.amount_dst=e.amountDst),e.nodeId&&(o.node_id=e.nodeId),e.metadata&&(o.metadata=e.metadata);let i=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,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{resolution_id:e.resolutionId}}_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{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 s=e.type??"src",o={taker_urn:r,type:s,rate_sig:e.rateSig,from_medium:"pse",to_medium:e.toMedium,webhook_url:e.webhookUrl,deposit_information:this._mapDepositInformationToWire(e.depositInformation)};"src"===s&&e.amountSrc?o.amount_src=e.amountSrc:"dst"===s&&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,...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 i=await this.httpClient.request({method:"PUT",path:"/api/order",body:o,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,callbackToken:e.result.callback_token}}}}class o extends e{pse;bankTransfer;breb;constructor(e){super(e),this.pse=new s(this.httpClient),this.bankTransfer=new a(this.httpClient),this.breb=new r(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))}}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 s=r.toString(),o=`/api/order/taker/${a}${s?`?${s}`:""}`;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}}}export{a as BankTransferClient,r as BrebClient,s as PseClient,o 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}:{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 n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,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}}_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 n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,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}}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 n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,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}}_mapPayoutDepositInformationToWire(e){return{resolution_id:e.resolutionId}}_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 n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,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}}_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 n 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,...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 n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,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}}_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 i 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)};"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 n=await this.httpClient.request({method:"PUT",path:"/api/order",body:s,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}}_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 n(this.httpClient),this.bankTransfer=new r(this.httpClient),this.breb=new o(this.httpClient),this.rtp=new i(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,n as PseClient,i as RtpClient,u as SwapClient};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ExecutionHow as PublicExecutionHow } from '../bank-transfer/types';
|
|
2
|
+
import type { ExecutionHow as WireExecutionHow } from './wire-types';
|
|
3
|
+
/**
|
|
4
|
+
* Maps API execution `how` payload to SDK camelCase discriminated union.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapExecutionHow(how: WireExecutionHow): PublicExecutionHow;
|
|
@@ -78,10 +78,22 @@ export type OrderType = 'src' | 'dst';
|
|
|
78
78
|
* Deposit information for swap orders
|
|
79
79
|
*/
|
|
80
80
|
export interface DepositInformation {
|
|
81
|
-
/** PSE deposit URN */
|
|
81
|
+
/** PSE / BRE-B on-ramp deposit URN */
|
|
82
82
|
urn?: string;
|
|
83
83
|
/** BRE-B payout resolution id */
|
|
84
84
|
resolution_id?: string;
|
|
85
|
+
/** External US bank on-ramp: destination Kusama ledger account id */
|
|
86
|
+
ledger_account_id?: string;
|
|
87
|
+
/** RTP payout: account holder name */
|
|
88
|
+
owner?: string;
|
|
89
|
+
/** RTP payout: bank account number */
|
|
90
|
+
account_number?: string;
|
|
91
|
+
/** RTP payout: ABA routing number */
|
|
92
|
+
routing_number?: string;
|
|
93
|
+
/** RTP payout: account type */
|
|
94
|
+
account_type?: 'checking' | 'savings';
|
|
95
|
+
/** RTP payout: optional bank name */
|
|
96
|
+
bank_name?: string;
|
|
85
97
|
/** Bancolombia deposit information */
|
|
86
98
|
bancolombia?: BancolombiaDepositInformation;
|
|
87
99
|
}
|
|
@@ -150,12 +162,39 @@ export interface ListOrdersResponse {
|
|
|
150
162
|
}
|
|
151
163
|
/**
|
|
152
164
|
* @internal
|
|
153
|
-
* Execution redirect instructions
|
|
165
|
+
* Execution redirect instructions (PSE, card, etc.)
|
|
154
166
|
*/
|
|
155
|
-
export interface
|
|
167
|
+
export interface ExecutionHowRedirect {
|
|
156
168
|
type: string;
|
|
157
|
-
url
|
|
169
|
+
url?: string;
|
|
158
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* @internal
|
|
173
|
+
* BRE-B on-ramp deposit instructions returned when the graph pauses
|
|
174
|
+
*/
|
|
175
|
+
export interface ExecutionHowBrebDeposit {
|
|
176
|
+
type: 'BREB_DEPOSIT';
|
|
177
|
+
medium: 'breb';
|
|
178
|
+
key_type: string;
|
|
179
|
+
key_value: string;
|
|
180
|
+
amount: string;
|
|
181
|
+
currency: 'COP';
|
|
182
|
+
reference: string;
|
|
183
|
+
deposit_account_urn: string;
|
|
184
|
+
/** Scaled COP required for the order (same as amount on first pause). */
|
|
185
|
+
expected_amount?: string;
|
|
186
|
+
/** Scaled COP received so far (partial payments). */
|
|
187
|
+
received_amount?: string;
|
|
188
|
+
/** Scaled COP still required (derived: expected − received). */
|
|
189
|
+
remaining_amount?: string;
|
|
190
|
+
/** `awaiting` on first pause; `partial` after an underpayment. */
|
|
191
|
+
deposit_status?: 'awaiting' | 'partial';
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @internal
|
|
195
|
+
* Discriminated union of execution instructions
|
|
196
|
+
*/
|
|
197
|
+
export type ExecutionHow = ExecutionHowRedirect | ExecutionHowBrebDeposit;
|
|
159
198
|
/**
|
|
160
199
|
* @internal
|
|
161
200
|
* Execution result from auto-execution
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { CreateRtpOrderOptions, CreateRtpOrderParams, CreateRtpOrderResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* RTP client for US instant bank payouts (Kusama → US bank via RTP).
|
|
5
|
+
*/
|
|
6
|
+
export declare class RtpClient extends BaseClient {
|
|
7
|
+
/**
|
|
8
|
+
* Create an RTP payout swap order (DUSD on Kusama → USD to US bank).
|
|
9
|
+
*
|
|
10
|
+
* @param params - RTP order parameters including destination bank details
|
|
11
|
+
* @returns Promise resolving to the created order
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const rates = await bloque.swap.findRates({
|
|
16
|
+
* fromAsset: 'DUSD/6',
|
|
17
|
+
* toAsset: 'USD/2',
|
|
18
|
+
* fromMediums: ['kusama'],
|
|
19
|
+
* toMediums: ['rtp'],
|
|
20
|
+
* amountSrc: '100000000',
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const result = await bloque.swap.rtp.create({
|
|
24
|
+
* rateSig: rates.rates[0].sig,
|
|
25
|
+
* amountSrc: '100000000',
|
|
26
|
+
* depositInformation: {
|
|
27
|
+
* owner: 'Jane Doe',
|
|
28
|
+
* accountNumber: '1234567890',
|
|
29
|
+
* routingNumber: '063108680',
|
|
30
|
+
* accountType: 'checking',
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
create(params: CreateRtpOrderParams, options?: CreateRtpOrderOptions): Promise<CreateRtpOrderResult>;
|
|
36
|
+
private _mapDepositInformationToWire;
|
|
37
|
+
private _mapOrderResponse;
|
|
38
|
+
private _mapExecutionResult;
|
|
39
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ExecutionHow, ExecutionResult, OrderType, SwapOrder } from '../bank-transfer/types';
|
|
2
|
+
export type { ExecutionHow, ExecutionResult, OrderType, SwapOrder };
|
|
3
|
+
/**
|
|
4
|
+
* US bank details for RTP payout (Kusama → US bank via RTP).
|
|
5
|
+
*/
|
|
6
|
+
export interface RtpDepositInformation {
|
|
7
|
+
/** Account holder name */
|
|
8
|
+
owner: string;
|
|
9
|
+
/** Bank account number */
|
|
10
|
+
accountNumber: string;
|
|
11
|
+
/** ABA routing number */
|
|
12
|
+
routingNumber: string;
|
|
13
|
+
/** Account type */
|
|
14
|
+
accountType: 'checking' | 'savings';
|
|
15
|
+
/** Optional bank name */
|
|
16
|
+
bankName?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parameters for creating an RTP payout swap order.
|
|
20
|
+
*/
|
|
21
|
+
export interface CreateRtpOrderParams {
|
|
22
|
+
/**
|
|
23
|
+
* Rate signature from findRates.
|
|
24
|
+
*/
|
|
25
|
+
rateSig: string;
|
|
26
|
+
/**
|
|
27
|
+
* Optional webhook URL for order status notifications.
|
|
28
|
+
*/
|
|
29
|
+
webhookUrl?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Source amount as bigint string (required if type is 'src').
|
|
32
|
+
*/
|
|
33
|
+
amountSrc?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Destination amount as bigint string (required if type is 'dst').
|
|
36
|
+
*/
|
|
37
|
+
amountDst?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Order type (default: 'src').
|
|
40
|
+
*/
|
|
41
|
+
type?: OrderType;
|
|
42
|
+
/**
|
|
43
|
+
* Destination US bank account details.
|
|
44
|
+
*/
|
|
45
|
+
depositInformation: RtpDepositInformation;
|
|
46
|
+
/**
|
|
47
|
+
* Specific node ID to execute (defaults to first node).
|
|
48
|
+
*/
|
|
49
|
+
nodeId?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Additional metadata for the order.
|
|
52
|
+
*/
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
export interface CreateRtpOrderOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Optional custom idempotency key sent as `Idempotency-Key` header.
|
|
58
|
+
*/
|
|
59
|
+
idempotencyKey?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface CreateRtpOrderResult {
|
|
62
|
+
/** The created order */
|
|
63
|
+
order: SwapOrder;
|
|
64
|
+
/** Execution result if auto-execution was triggered */
|
|
65
|
+
execution?: ExecutionResult;
|
|
66
|
+
/** Request ID for tracking */
|
|
67
|
+
requestId: string;
|
|
68
|
+
}
|
package/dist/swap-client.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type { HttpClient } from '@bloque/sdk-core';
|
|
|
2
2
|
import { BaseClient } from '@bloque/sdk-core';
|
|
3
3
|
import { BankTransferClient } from './bank-transfer/bank-transfer-client';
|
|
4
4
|
import { BrebClient } from './breb/breb-client';
|
|
5
|
+
import { ExternalUsBankSwapClient } from './external-us-bank/external-us-bank-client';
|
|
5
6
|
import { PseClient } from './pse/pse-client';
|
|
7
|
+
import { RtpClient } from './rtp/rtp-client';
|
|
6
8
|
import type { CancelSubscriptionParams, CancelSubscriptionResult, FindRatesParams, FindRatesResult, ListOrdersParams, ListOrdersResult } from './types';
|
|
7
9
|
/**
|
|
8
10
|
* Swap client for finding exchange rates
|
|
@@ -10,12 +12,16 @@ import type { CancelSubscriptionParams, CancelSubscriptionResult, FindRatesParam
|
|
|
10
12
|
* Provides access to exchange rate discovery and swapping functionality.
|
|
11
13
|
* - pse: PSE utilities (bank listing, etc.)
|
|
12
14
|
* - bankTransfer: Generic bank transfer cash-out (supports all Colombian banks)
|
|
13
|
-
* - breb: BRE-B cash-out via a resolved recipient key
|
|
15
|
+
* - breb: BRE-B cash-out via a resolved recipient key, and BRE-B on-ramp deposit
|
|
16
|
+
* - rtp: US instant bank payout (Kusama → US bank via RTP)
|
|
17
|
+
* - externalUsBank: US bank ACH on-ramp (external US bank → Kusama)
|
|
14
18
|
*/
|
|
15
19
|
export declare class SwapClient extends BaseClient {
|
|
16
20
|
readonly pse: PseClient;
|
|
17
21
|
readonly bankTransfer: BankTransferClient;
|
|
18
22
|
readonly breb: BrebClient;
|
|
23
|
+
readonly rtp: RtpClient;
|
|
24
|
+
readonly externalUsBank: ExternalUsBankSwapClient;
|
|
19
25
|
constructor(httpClient: HttpClient);
|
|
20
26
|
/**
|
|
21
27
|
* Find available exchange rates
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-swap",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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.1
|
|
37
|
+
"@bloque/sdk-core": "0.2.1"
|
|
38
38
|
}
|
|
39
39
|
}
|