> For the complete documentation index, see [llms.txt](https://hinkal-team.gitbook.io/hinkal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hinkal-team.gitbook.io/hinkal/hinkal-mobile-sdk/ios/advanced/performance.md).

# Performance

Guidance for keeping the SDK responsive in a mobile app.

### Off the main thread

SDK operations do network and proof work. Call them off the main thread and update the UI on the main actor:

```swift
let txHash = try call {
    hinkal.deposit(chainId, tokenAddrsJSON: tokens, amountsWeiJSON: amounts,
                   preEstimateGas: true, returnTxData: false, error: &$0)
}
```

### Cache balances

`getTotalBalance` scans UTXOs. Cache the result and only re-scan when needed:

* Read with `resetCache: false` for normal UI reads.
* Pass `resetCache: true` after a deposit, withdrawal, transfer, or swap.

### Reuse the client and session

A session lasts across many operations. Create the `MobileClient` once, connect once, and reuse the `MobileHinkal` handle - avoid reconnecting per operation.

### Batch where possible

Because tokens and amounts are JSON arrays, deposit multiple tokens in a single call rather than issuing separate deposits.
