BorrowSDK
The main class for interacting with SatsTerminal Borrow.Constructor
Parameters
| Parameter | Type | Description |
|---|---|---|
config | BorrowSDKConfig | SDK configuration |
Example
Utility Exports
The SDK also exports utility functions for unit conversion and response handling:Properties
userStatus
Current user status.
platformWalletAddress
The platform smart wallet address (index 0).
Methods
setup()
Optional account preload for dashboards and manual account flows. Without options, the SDK uses the active chain if one is already selected, otherwise Base as the preload chain. Passoptions.chain only when you intentionally want to preload a different chain. executeBorrow() derives the chain from the selected quote and can prepare the required borrow wallet/session state automatically.
Returns
| Property | Type | Description |
|---|---|---|
platformWallet | object | Platform wallet address and signature |
userStatus | UserStatus | Current user status |
activeSession | ActiveSession | Active session details |
transactions | UserTransaction[] | Recent transactions |
Example
startNewLoan()
Advanced method to create a new isolated loan wallet/session manually. Most borrow flows should usegetQuotes() and executeBorrow().
Example
getQuotes()
Get available loan quotes.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
collateralAmount | string | Yes | Collateral in BTC |
loanAmount | string | Yes | Loan amount in USD |
Example
getWebhookConfig()
Get the webhook configuration for the SDK API key.updateWebhookConfig()
Create or update the webhook configuration for the SDK API key.Example
rotateWebhookSecret()
Rotate the HMAC signing secret used for webhook delivery. The new secret is returned once.Example
executeBorrow()
Execute a borrow with a selected quote. This method prepares the platform wallet, loan wallet, and session automatically when needed.Returns
string - Workflow ID
If setup() was called immediately before, executeBorrow() reuses that prepared unused loan wallet. Otherwise it creates a fresh isolated loan wallet/session for the borrow.
Example
repay()
Repay a loan. The SDK prepares the platform wallet address/signature automatically when needed; callers do not need to callsetup() first. The loan chain is inferred from the original borrow transaction; pass options.chain only as an explicit override.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
originalBorrowId | string | Yes | Loan ID to repay |
repayAmount | string | Yes | Amount to repay |
chain | ChainType | No | Optional override. Inferred from the original loan when omitted. |
useCollateral | boolean | No | Use collateral for repayment |
collateralToWithdraw | string | No | BTC to withdraw |
userBtcWithdrawAddress | string | No | BTC destination |
trackWorkflow | boolean | No | Track the workflow |
callbacks | WorkflowCallbacks | No | Tracking callbacks |
Example
withdrawCollateral()
Withdraw collateral from a loan. The SDK prepares the platform wallet address/signature automatically when needed; callers do not need to callsetup() first. The loan chain is inferred from the original borrow transaction; pass options.chain only as an explicit override.
Example
getLoanCollateralInfo()
Get collateral information for a loan.Returns
getLoanHistory()
Get loan transaction history.Example
getPendingLoans()
Get loans awaiting deposit.getRepayTransactions()
Get repay transactions for a loan.getRepayStatus()
Get status of a repay transaction.trackWorkflow()
Manually track a workflow.resumeLoan()
Resume tracking a loan workflow.getStatus()
Get workflow status.sendBitcoin()
Send Bitcoin (requires wallet provider with sendBitcoin).getFees()
Get bridge fee information for a given chain and collateral amount. Lightweight; use this for an early-stage estimate when you only know the destination chain and collateral.Example
getQuoteFees()
Get the full fee breakdown for a specific quote: bridge fees plus borrow-side fees (platform fee, applied disbursement bps, campaign waiver, net loan amount). Call this aftergetQuotes() to display the final numbers a user will see at checkout. The borrow-side fees are returned separately from the quote because they depend on the borrower’s campaign eligibility and the chosen loan asset/chain.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
collateralAmount | string | Yes | Collateral in BTC, e.g. "0.1" |
loanAmount | string | Yes | Loan amount in the loan asset’s units |
fromChain | ChainType | Yes | Source chain of the collateral being bridged |
fromAssetSymbol | string | Yes | Source asset symbol (e.g. BTC) |
toChain | ChainType | Yes | Bridge destination chain |
toAssetSymbol | string | Yes | Bridge destination asset (e.g. WBTC, cbBTC) |
loanChain | ChainType | Yes | Chain on which the loan is issued |
loanAssetSymbol | string | Yes | Loan asset (e.g. USDC) |
Example
getWalletPositions()
Get token positions for the platform wallet.getWalletPortfolio()
Get portfolio summary.withdrawToBitcoin()
Withdraw EVM assets to Bitcoin. The SDK prepares the platform wallet address/signature automatically when needed.Parameters
| Parameter | Type | Description |
|---|---|---|
chain | ChainType | Source chain |
amount | string | Amount to withdraw |
assetSymbol | string | Asset symbol (USDC, USDT) |
btcAddress | string | Destination BTC address |
getWithdrawStatus()
Get withdrawal status.withdrawToEVM()
Withdraw USDC from the platform smart account to an EVM address with sponsored gas (gasless). The SDK prepares the platform wallet address/signature automatically when needed.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chain | ChainType | Yes | Source chain (ARBITRUM, BASE) |
amount | string | Yes | Amount to withdraw (e.g., ‘100’ for 100 USDC) |
destinationAddress | string | Yes | Destination EVM address |
loanIndex | number | No | Wallet index (defaults to 0 for platform wallet) |
Returns
string - Transaction hash
Features
- Gasless: Transaction fees are sponsored via ZeroDev paymaster
- Instant: Single EVM transaction, no bridging required
- USDC only: Currently supports USDC transfers