Swap
Learn how to perform asset swaps using the Bloque SDK.
Overview
The swap module lets you query exchange rates and perform asset swaps between supported mediums and currencies.
Querying Exchange Rates
Parameters
FindRatesParams
Response
FindRatesResult
SwapRate
Fee
FeeComponent
Complete Example Flow
Best Practices
- Validate input parameters before querying rates.
- Use the
fromLimitsandtoLimitsfields to check allowed amounts. - Handle possible network or API errors gracefully.
- Query rates right before performing a swap to avoid expiration.
- Check the
untilfield to know how long a rate is valid.
PSE-Specific Best Practices
Required Customer Data
For successful PSE transactions, ensure you provide the following customer data:
bank_code: Valid bank code frompse.banks()listuser_type:0for natural persons,1for legal entitiescustomer_email: Valid email address for transaction notificationsuser_legal_id_type: Document type ('CC'for citizenship card,'NIT'for tax ID,'CE'for foreign ID)user_legal_id: Valid ID number matching the specified typecustomer_data.full_name: Customer's complete legal name
Common Validation Requirements
- Ensure the legal ID number matches the selected ID type
- Use the exact bank code from the banks list (no modifications)
- Provide a valid email format for customer notifications
- Full name should match the customer's legal documentation
Error Handling
Next Steps
Listing PSE Banks
You can retrieve the list of available PSE (Pagos Seguros en Línea) banks and their codes for PSE payments:
Bank Type
This is useful for presenting a list of banks to users when initiating PSE-based swaps or payments.
Create PSE Swap Order
The SDK allows you to create swap orders using PSE (Pagos Seguros en Línea) as the source payment medium. The pse.create method combines order creation and optionally auto-executes the first instruction node to initiate the payment flow.
Basic Usage
CreatePseOrderParams Parameters
DepositInformation Type
PsePaymentArgs Type
CreatePseOrderResult Response
SwapOrder Type
Swap Order States
ExecutionResult Type
Execution States
States and Transitions
Order States
Node Execution States
Complete PSE Flow Example
Create Bancolombia Swap Order
The SDK allows you to create swap orders using Kusama as the source payment medium and Bancolombia as the destination. The bancolombia.create method combines order creation and optionally auto-executes the first instruction node to initiate the swap flow.
Basic Usage
CreateBancolombiaOrderParams Parameters
BancolombiaDepositInformation Type
KusamaAccountArgs Type
Complete Bancolombia Flow Example
Order Types
-
src(default): User specifies the exact amount to pay. Destination amount is calculated from the rate.- Example: "I want to pay exactly 10,000 COP, give me whatever DUSD that gets me"
-
dst: User specifies the exact amount to receive. Source amount is calculated from the rate.- Example: "I want to receive exactly 5 DUSD, I'll pay whatever COP is needed"
-
Accounts Guide - Create and manage accounts for swap operations
-
Organizations Guide - Manage entities that can perform swaps