use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.
the class BSFormatterTest method testFormatDifferentAmount.
@Test
public void testFormatDifferentAmount() {
OfferPayload offerPayload = mock(OfferPayload.class);
Offer offer = new Offer(offerPayload);
when(offerPayload.getMinAmount()).thenReturn(10000000L);
when(offerPayload.getAmount()).thenReturn(20000000L);
assertEquals("0.10 - 0.20", formatter.formatAmount(offer));
}
use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.
the class DisputeSummaryWindow method applyPayoutAmountsToDisputeResult.
private void applyPayoutAmountsToDisputeResult(Toggle selectedTradeAmountToggle) {
Contract contract = dispute.getContract();
Offer offer = new Offer(contract.getOfferPayload());
Coin buyerSecurityDeposit = offer.getBuyerSecurityDeposit();
Coin sellerSecurityDeposit = offer.getSellerSecurityDeposit();
Coin tradeAmount = contract.getTradeAmount();
if (selectedTradeAmountToggle == buyerGetsTradeAmountRadioButton) {
disputeResult.setBuyerPayoutAmount(tradeAmount.add(buyerSecurityDeposit));
disputeResult.setSellerPayoutAmount(sellerSecurityDeposit);
disputeResult.setWinner(DisputeResult.Winner.BUYER);
} else if (selectedTradeAmountToggle == buyerGetsAllRadioButton) {
disputeResult.setBuyerPayoutAmount(tradeAmount.add(buyerSecurityDeposit).add(sellerSecurityDeposit));
disputeResult.setSellerPayoutAmount(Coin.ZERO);
disputeResult.setWinner(DisputeResult.Winner.BUYER);
} else if (selectedTradeAmountToggle == sellerGetsTradeAmountRadioButton) {
disputeResult.setBuyerPayoutAmount(buyerSecurityDeposit);
disputeResult.setSellerPayoutAmount(tradeAmount.add(sellerSecurityDeposit));
disputeResult.setWinner(DisputeResult.Winner.SELLER);
} else if (selectedTradeAmountToggle == sellerGetsAllRadioButton) {
disputeResult.setBuyerPayoutAmount(Coin.ZERO);
disputeResult.setSellerPayoutAmount(tradeAmount.add(sellerSecurityDeposit).add(buyerSecurityDeposit));
disputeResult.setWinner(DisputeResult.Winner.SELLER);
}
buyerPayoutAmountInputTextField.setText(formatter.formatCoin(disputeResult.getBuyerPayoutAmount()));
sellerPayoutAmountInputTextField.setText(formatter.formatCoin(disputeResult.getSellerPayoutAmount()));
}
use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.
the class OpenOffersViewModel method getPrice.
String getPrice(OpenOfferListItem item) {
if ((item == null))
return "";
Offer offer = item.getOffer();
Price price = offer.getPrice();
if (price != null) {
String postFix = "";
if (offer.isUseMarketBasedPrice())
postFix = " (" + formatter.formatPercentagePrice(offer.getMarketPriceMargin()) + ")";
return formatter.formatPrice(price) + postFix;
} else {
return Res.get("shared.na");
}
}
use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.
the class PendingTradesView method setAvatarColumnCellFactory.
@SuppressWarnings("UnusedReturnValue")
private TableColumn<PendingTradesListItem, PendingTradesListItem> setAvatarColumnCellFactory() {
avatarColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
avatarColumn.setCellFactory(new Callback<TableColumn<PendingTradesListItem, PendingTradesListItem>, TableCell<PendingTradesListItem, PendingTradesListItem>>() {
@Override
public TableCell<PendingTradesListItem, PendingTradesListItem> call(TableColumn<PendingTradesListItem, PendingTradesListItem> column) {
return new TableCell<PendingTradesListItem, PendingTradesListItem>() {
@Override
public void updateItem(final PendingTradesListItem newItem, boolean empty) {
super.updateItem(newItem, empty);
if (!empty && newItem != null) {
final Trade trade = newItem.getTrade();
final NodeAddress tradingPeerNodeAddress = trade.getTradingPeerNodeAddress();
int numPastTrades = model.getNumPastTrades(trade);
final Offer offer = trade.getOffer();
String role = Res.get("peerInfoIcon.tooltip.tradePeer");
Node peerInfoIcon = new PeerInfoIcon(tradingPeerNodeAddress, role, numPastTrades, privateNotificationManager, offer, preferences, model.accountAgeWitnessService, formatter, useDevPrivilegeKeys);
setPadding(new Insets(1, 0, 0, 0));
setGraphic(peerInfoIcon);
} else {
setGraphic(null);
}
}
};
}
});
return avatarColumn;
}
use of bisq.core.offer.Offer in project bisq-desktop by bisq-network.
the class PendingTradesViewModel method getMyRole.
//
String getMyRole(PendingTradesListItem item) {
Trade trade = item.getTrade();
Contract contract = trade.getContract();
if (contract != null) {
Offer offer = trade.getOffer();
return btcFormatter.getRole(contract.isBuyerMakerAndSellerTaker(), dataModel.isMaker(offer), offer.getCurrencyCode());
} else {
return "";
}
}
Aggregations