BorrowSDK
The main class for interacting with SatsTerminal Borrow.Constructor
Parameters
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
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
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
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
borrowMore()
Increase the debt on an existing loan without adding collateral. The original loan’s collateral, market context, bridge and destination are reused server-side, so only the additional borrow amount is required. The borrowed funds are disbursed to the loan’s configured destination. The SDK prepares the wallet session automatically; the loan chain is inferred from the original loan (passoptions.chain only to override).
Parameters
Returns
BorrowMoreResult — includes transactionId, workflowId, status, borrowAmount, borrowerPayoutAmount, borrowAsset, and destination details.
Borrow More is rejected when the loan is fully repaid, liquidated, or has no remaining borrow room. The requested amount must not exceed the position’s available borrow capacity.
Example
depositMore()
Add collateral to an existing loan without borrowing. The new collateral is bridged from Bitcoin and deposited into the same position, improving the loan’s health factor. No new debt is taken. The SDK prepares the wallet session automatically; the loan chain is inferred from the original loan.Parameters
Returns
DepositMoreResult — includes transactionId, workflowId, status, depositAmount, collateralAsset, and protocol.
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
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
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
Returns
string - Asynchronous withdrawal transaction ID. Pass it to getWithdrawStatus() to obtain workflow progress and the final transaction hash.
Features
- Gasless: Transaction fees are sponsored via ZeroDev paymaster
- Same-chain: Executes a token transfer on the selected source chain
- Asset-aware: Supports assets configured for the selected chain