Deposits
Inspect the quoted deposit shape before opening a wallet.
import {
isBtcPsbtDeposit,
isUtxoDeposit,
type PrivateQuote,
} from '@silentswap/sdk';
declare const quote: PrivateQuote;
if (isUtxoDeposit(quote.deposit)) {
console.log(quote.deposit.payinAddress, quote.deposit.expectedAmount);
} else if (isBtcPsbtDeposit(quote.deposit)) {
console.log(quote.deposit.psbt, quote.deposit.expectedSats);
} else {
switch (quote.deposit.txKind ?? 'evm') {
case 'svm':
console.log(quote.deposit.solanaTx);
break;
case 'ton':
console.log(quote.deposit.tonMessages);
break;
case 'tron':
console.log(quote.deposit.tronTransaction);
break;
default:
console.log(quote.deposit.to, quote.deposit.data);
}
}EVM deposits
After review, placeOrder checks allowance, simulates the deposit,
broadcasts it on deposit.chainId, and waits for the receipt. It rejects approval
calldata, empty calldata, and zero-address destinations before signing.
For native tokens no approval is needed. For ERC-20 inputs, show the approval and deposit as distinct wallet steps.
Deposit gas
placeOrder, previewDepositCost, and
hasSufficientGasForDeposit take an optional DepositGasOptions.
Setting gasBudgetWei caps the native spend on gas and enables bounded escalation
when eth_estimateGas reverts; omit it to keep wallet-selected fees.
Gas resolution is shared between the preflight and the broadcast, so the number the user is checked against is the number that gets sent — pass the same options to both or the check means nothing.
import { type PrivateQuote, type SilentSwapClient } from '@silentswap/sdk';
declare const client: SilentSwapClient;
declare const quote: PrivateQuote;
const opts = { gasBudgetWei: 5_000_000_000_000_000n }; // 0.005 native
const cost = await client.previewDepositCost(quote, opts);
if (!cost.supported) {
// 'execution-cap' — route needs more gas than the protocol supports.
// 'gas-budget' — route is fine, your budget is too low.
throw new Error(`Route unavailable: ${cost.unsupportedReason}`);
}
const gas = await client.hasSufficientGasForDeposit(quote, opts);
if (!gas.ok) throw new Error(`Need ${gas.needWei} wei, have ${gas.haveWei}`);
await client.placeOrder(quote, opts);Check supported before ok. An unsupported route fails the policy
regardless of balance, so topping the wallet up will not help — telling the user to add funds
would send them down a dead end. UTXO and BTC-PSBT deposits are off-EVM and always report
supported: true with zero cost.
Native-wallet deposits
Supply narrow Solana, TON, TRON, or Bitcoin adapters beside the viem wallet. The SDK verifies the active address and payload before it invokes an adapter. It never discovers an injected wallet or chooses between brands.