postOffer method
Future<OfferInfo>
postOffer({
- required String currencyCode,
- required String direction,
- required String price,
- required bool useMarketBasedPrice,
- double? marketPriceMarginPct,
- required Int64 amount,
- required Int64 minAmount,
- required double buyerSecurityDepositPct,
- String? triggerPrice,
- required bool reserveExactAmount,
- required String paymentAccountId,
Posts a new offer to the Haveno network.
Returns an OfferInfo object representing the newly posted offer.
Parameters:
currencyCode
: The currency code for the offer (e.g., USD, BTC).direction
: The direction of the offer, either "buy" or "sell".price
: The price of the offer as a string.useMarketBasedPrice
: Whether to use a market-based price.marketPriceMarginPct
: Optional percentage margin for market-based pricing.amount
: The amount for the offer.minAmount
: The minimum amount for the offer.buyerSecurityDepositPct
: The percentage of buyer's security deposit.triggerPrice
: Optional trigger price for the offer.reserveExactAmount
: Whether to reserve the exact amount.paymentAccountId
: The ID of the payment account.
Throws a DaemonNotConnectedException if the client is not connected to the daemon.
Catches GrpcError
exceptions and handles them using handleGrpcError
.
Implementation
Future<OfferInfo> postOffer({
required String currencyCode,
required String direction,
required String price,
required bool useMarketBasedPrice,
double? marketPriceMarginPct,
required fixnum.Int64 amount,
required fixnum.Int64 minAmount,
required double buyerSecurityDepositPct,
String? triggerPrice,
required bool reserveExactAmount,
required String paymentAccountId,
}) async {
if (!havenoChannel.isConnected) {
throw DaemonNotConnectedException();
}
try {
final postOfferResponse = await havenoChannel.offersClient!.postOffer(
PostOfferRequest(
currencyCode: currencyCode,
direction: direction,
price: price,
useMarketBasedPrice: useMarketBasedPrice,
marketPriceMarginPct: marketPriceMarginPct,
amount: amount,
minAmount: minAmount,
buyerSecurityDepositPct: buyerSecurityDepositPct,
triggerPrice: triggerPrice,
reserveExactAmount: reserveExactAmount,
paymentAccountId: paymentAccountId,
),
);
return postOfferResponse.offer;
} on GrpcError catch (e) {
handleGrpcError(e);
rethrow;
}
}