Skip to main content
Gets a fee quote for a cooperative exit (on-chain withdrawal) for the SparkWallet. The quote includes options for different speeds and an expiry time.

Method Signature

async getWithdrawalFeeQuote({
  amountSats,
  withdrawalAddress,
}: {
  amountSats: number;
  withdrawalAddress: string;
}): Promise<CoopExitFeeQuote | null>

Parameters

amountSats
number
required
The amount in satoshis to withdraw
withdrawalAddress
string
required
The Bitcoin address where the funds should be sent

Returns

feeQuote
CoopExitFeeQuote | null
required
A fee quote for the withdrawal, or null if not available

CoopExitFeeQuote Fields

FieldTypeDescription
idstringQuote ID (use as feeQuoteId in withdraw())
expiresAtstringWhen this quote expires
userFeeFastCurrencyAmountService fee for fast exit
userFeeMediumCurrencyAmountService fee for medium exit
userFeeSlowCurrencyAmountService fee for slow exit
l1BroadcastFeeFastCurrencyAmountL1 tx fee for fast exit
l1BroadcastFeeMediumCurrencyAmountL1 tx fee for medium exit
l1BroadcastFeeSlowCurrencyAmountL1 tx fee for slow exit
CurrencyAmount has originalValue (number in satoshis) and originalUnit fields.

Example

const feeQuote = await wallet.getWithdrawalFeeQuote({
  amountSats: 17000,
  withdrawalAddress: "bcrt1p..."
});

if (feeQuote) {
  console.log("Quote expires:", feeQuote.expiresAt);
  console.log("Fast fee:", feeQuote.userFeeFast.originalValue + feeQuote.l1BroadcastFeeFast.originalValue, "sats");
  console.log("Medium fee:", feeQuote.userFeeMedium.originalValue + feeQuote.l1BroadcastFeeMedium.originalValue, "sats");
  console.log("Slow fee:", feeQuote.userFeeSlow.originalValue + feeQuote.l1BroadcastFeeSlow.originalValue, "sats");
}