Search in sources :

Example 36 with Offer

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));
}
Also used : OfferMaker.btcUsdOffer(bisq.core.offer.OfferMaker.btcUsdOffer) Offer(bisq.core.offer.Offer) OfferPayload(bisq.core.offer.OfferPayload) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 37 with 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()));
}
Also used : Coin(org.bitcoinj.core.Coin) Offer(bisq.core.offer.Offer) Contract(bisq.core.trade.Contract)

Example 38 with Offer

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");
    }
}
Also used : Offer(bisq.core.offer.Offer) OpenOffer(bisq.core.offer.OpenOffer) Price(bisq.core.monetary.Price)

Example 39 with Offer

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;
}
Also used : Insets(javafx.geometry.Insets) Node(javafx.scene.Node) PeerInfoIcon(bisq.desktop.components.PeerInfoIcon) TableColumn(javafx.scene.control.TableColumn) Trade(bisq.core.trade.Trade) TableCell(javafx.scene.control.TableCell) Offer(bisq.core.offer.Offer) NodeAddress(bisq.network.p2p.NodeAddress)

Example 40 with Offer

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 "";
    }
}
Also used : Trade(bisq.core.trade.Trade) Offer(bisq.core.offer.Offer) Contract(bisq.core.trade.Contract)

Aggregations

Offer (bisq.core.offer.Offer)49 Coin (org.bitcoinj.core.Coin)15 Test (org.junit.Test)13 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 OfferPayload (bisq.core.offer.OfferPayload)10 Price (bisq.core.monetary.Price)9 OfferMaker.btcUsdOffer (bisq.core.offer.OfferMaker.btcUsdOffer)8 PaymentMethod (bisq.core.payment.payload.PaymentMethod)7 Contract (bisq.core.trade.Contract)7 NodeAddress (bisq.network.p2p.NodeAddress)7 Volume (bisq.core.monetary.Volume)6 PeerInfoIcon (bisq.desktop.components.PeerInfoIcon)6 Popup (bisq.desktop.main.overlays.popups.Popup)6 MainView (bisq.desktop.main.MainView)5 Button (javafx.scene.control.Button)5 TableCell (javafx.scene.control.TableCell)5 TableColumn (javafx.scene.control.TableColumn)5 TradeCurrency (bisq.core.locale.TradeCurrency)4 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)4 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)4