Skip to main content

Transaction Builder (TxB)

Overview

The Transaction Builder creates optimized Stellar Soroban transactions for Blend lending operations. It integrates with the real Stellar SDK to build, simulate, and prepare transactions for signing.

TxB receives risk signals from RMS and builds appropriate transactions to help users manage their lending positions.

Supported Operations

OperationDescriptionUse Case
REPAYRepay borrowed assetsImprove health factor
LIQUIDATELiquidate collateralEarn liquidation bonus
UNWINDClose entire positionFull exit from pool

Building Transactions

POST /api/v1/txb/build

Build a repay or liquidate transaction.

Request:

{
"action": "REPAY",
"walletAddress": "GABC...XYZ",
"poolAddress": "CAWKIJ6FVZUS7LVOHNTO2FBPTLOQKXWFWYZPOGCCCWVRJN7ARGOMABWV",
"tokenId": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
"amount": "1000000",
"slippageBps": 50
}
FieldTypeRequiredDescription
actionstringYesREPAY or LIQUIDATE
walletAddressstringYesStellar G-address
poolAddressstringYesBlend pool contract address
tokenIdstringYesToken contract address
amountstringNoAmount in stroops (omit for max)
slippageBpsnumberNoSlippage tolerance (default: 50 = 0.5%)

Response:

{
"success": true,
"transaction": {
"transactionXdr": "AAAA...",
"sourceAddress": "GABC...XYZ",
"operations": 1,
"createdAt": "2026-04-13T12:00:00.000Z"
},
"proposal": {
"id": "txp-1713004800000-abc123",
"status": "pending",
"expiresAt": "2026-04-13T12:05:00.000Z",
"metadata": {
"poolAddress": "CAWKIJ6FVZUS7LVOHNTO2FBPTLOQKXWFWYZPOGCCCWVRJN7ARGOMABWV",
"tokenId": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
"amount": "1000000",
"action": "REPAY"
}
},
"warnings": []
}

Getting Proposals

GET /api/v1/txb/proposals

Retrieve transaction proposals for a wallet.

Query Parameters:

  • wallet — Wallet address (required)

Response:

{
"success": true,
"proposals": [
{
"id": "txp-1713004800000-abc123",
"status": "pending",
"expiresAt": "2026-04-13T12:05:00.000Z",
"transaction": {
"transactionXdr": "AAAA...",
"sourceAddress": "GABC...XYZ",
"operations": 1,
"createdAt": "2026-04-13T12:00:00.000Z"
},
"metadata": {
"poolAddress": "CAWKIJ6FVZUS7LVOHNTO2FBPTLOQKXWFWYZPOGCCCWVRJN7ARGOMABWV",
"tokenId": "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
"action": "REPAY"
}
}
],
"total": 1,
"timestamp": "2026-04-13T12:01:00.000Z"
}

Proposal Statuses

StatusDescription
pendingAwaiting signature
signedTransaction signed, ready for submission
submittedTransaction submitted to network
confirmedTransaction confirmed on-chain
failedTransaction failed or expired

Slippage Protection

Slippage tolerance protects against price movement during transaction execution.

BPSPercentageUse Case
100.1%Stable pairs (USDC/USDC)
500.5%Default for most operations
1001.0%Volatile pairs
5005.0%High volatility assets

Example:

  • Slippage: 50 BPS (0.5%)
  • Repay amount: 1,000 USDC
  • Maximum cost: 1,005 USDC

Transaction Lifecycle


Validation Rules

FieldValidation
walletAddressMust be valid Stellar G-address (G...)
poolAddressMust be valid Stellar C-address (C...)
tokenIdMust be valid Stellar C-address
amountMust be non-negative integer string
slippageBpsMust be 0-10000 (0%-100%)

Submitting Transactions

After building a transaction, sign it with your wallet and submit:

POST /api/v1/txb/submit

Submit a signed transaction.

Request:

{
"transactionXdr": "AAAA...",
"rpcUrl": "https://mainnet.sorobpc.com"
}

Response:

{
"success": true,
"txHash": "abc123...def456"
}

Batch Operations

For positions with multiple debt tokens, you can build multiple transactions or use the Unwind operation to close the entire position in one transaction.

Unwind Transaction

An unwind transaction:

  1. Withdraws all collateral
  2. Repays all debt via flash loan
  3. Returns remaining funds to wallet

Note: Unwind transactions may require multiple operations. The maximum Soroban operations per transaction is 10.


Error Handling

Error CodeDescription
VALIDATION_FAILEDInvalid request parameters
NO_POSITION_FOUNDNo position exists for the given token
NO_DEBT_TO_REPAYNo debt to repay
NO_COLLATERAL_TO_LIQUIDATENo collateral available
SIMULATION_FAILEDRPC simulation failed
TOO_MANY_OPERATIONSExceeds Soroban operation limit

Status Endpoint

GET /api/v1/txb/status

Check TxB service health.

Response:

{
"success": true,
"service": "txb",
"status": "running",
"proposalsInMemory": 15,
"timestamp": "2026-04-13T12:00:00.000Z"
}