Open a Position
1
Get a one-time wallet for the position
POST /borrow/smart-wallet
Response
protocol_label is free-form text identifying the provider this position belongs to - any lending provider works, since your instructions are passed through unchanged. Store smart_wallet_id against the position: every later call identifies it by that, and the wallet is provisioned once, not per action.2
Build your instructions
Assemble your provider’s deposit or open instructions into a single unsigned transaction, with the wallet
address as the signer and fee payer. Base64-encode it as main_tx.Vanish appends its own instruction, signs the result, and simulates it before returning. A transaction that fails simulation is rejected rather than submitted.3
Open the position
POST /borrow/initiate
Response
transaction to broadcast, or transaction is null and jito_bundle_id is set, meaning Vanish submitted a two-transaction bundle itself.4
Broadcast if needed, then commit
Broadcast The position is now open. Advancing more into it repeats these steps with the same
transaction if it is non-null; if jito_bundle_id is set instead, Vanish has already submitted it. Then commit either way:POST /borrow/commit
Response
smart_wallet_id.Settle a Position
Settling returns the advanced funds to Vanish’s trading accounts, wrapped around your own withdraw or close instructions. Check Position State first.1
Settle the position
Build
main_tx exactly as when opening - unsigned, with the position’s one-time wallet as signer and fee payer - using your withdraw or close instructions.POST /borrow/settle
Settle always returns a signed
transaction - there is no bundle route here, so you always broadcast it yourself.2
Broadcast and commit
Broadcast the signed The response matches the commit above with
transaction through your RPC, then commit the action:POST /borrow/commit
action_type set to settle. Once a settle with cleanup_leftover_sol is committed, the position’s status becomes closed.Position State
POST /borrow/positions returns every one-time wallet the user holds a position in, with balances read live from on-chain. It is read-only.
Response
status is open until a settle with cleanup_leftover_sol is committed. has_active_balance is true only when the wallet holds a non-SOL token with a positive balance, so use it instead of setting your own dust threshold.
Reference: Get Positions · Get Pending Lending Actions
Next Steps
- Trading - Execute a private swap against a funded balance.
- Error Handling - Commit statuses and recovering interrupted flows.
