BorrowSDK
The main class for interacting with SatsTerminal Borrow.Constructor
Parameters
| Parameter | Type | Description |
|---|---|---|
config | BorrowSDKConfig | SDK configuration |
Example
Properties
userStatus
Current user status.
baseWalletAddress
The base smart wallet address (index 0).
Methods
setup()
Initialize the SDK and create a session.Returns
| Property | Type | Description |
|---|---|---|
baseWallet | object | Base wallet address and signature |
userStatus | UserStatus | Current user status |
activeSession | ActiveSession | Active session details |
transactions | UserTransaction[] | Recent transactions |
Example
startNewLoan()
Create a new loan wallet with incremented index.Example
getLoan()
High-level method to get a loan with automatic setup, quotes, and tracking.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
collateralBTC | number | Yes | BTC collateral amount |
loanAmountUSD | number | Yes | Loan amount in USD |
ltv | number | No | Loan-to-value ratio (default: 70) |
term | number | No | Term in days (default: 30) |
destinationAddress | string | No | Destination for borrowed funds |
quoteSelector | function | No | Custom quote selection |
onStatusUpdate | function | No | Status update callback |
onDepositReady | function | No | Deposit ready callback |
onComplete | function | No | Completion callback |
onError | function | No | Error callback |
Returns
| Property | Type | Description |
|---|---|---|
workflowId | string | Workflow identifier |
quote | Quote | Selected quote |
tracker | WorkflowTracker | Tracker instance |
stop | function | Stop tracking function |
Example
getQuotes()
Get available loan quotes.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
collateralAmount | string | Yes | Collateral in BTC |
loanAmount | string | Yes | Loan amount in USD |
ltv | number | Yes | Loan-to-value ratio |
term | number | No | Term in days |
Example
executeBorrow()
Execute a borrow with a selected quote.Returns
string - Workflow ID
Example
repay()
Repay a loan.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
originalBorrowId | string | Yes | Loan ID to repay |
repayAmount | string | Yes | Amount to repay |
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.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 fee information.Example
getWalletPositions()
Get token positions for the base wallet.getWalletPortfolio()
Get portfolio summary.withdrawToBitcoin()
Withdraw EVM assets to Bitcoin.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 smart account to an EVM address with sponsored gas (gasless).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 base 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