Add getPrice to TradeModel

This commit is contained in:
chimp1984 2021-11-03 14:15:09 +01:00
parent d235daef01
commit d9d054f2bd
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
3 changed files with 14 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package bisq.core.trade.model;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.trade.protocol.ProtocolModel;
@ -75,6 +76,7 @@ public abstract class TradeModel implements Tradable, Model {
@Nullable
public abstract Volume getVolume();
public abstract Price getPrice();
///////////////////////////////////////////////////////////////////////////////////////////
// Tradable implementation

View File

@ -761,6 +761,12 @@ public abstract class Trade extends TradeModel {
}
}
@Override
public Price getPrice() {
return Price.valueOf(offer.getCurrencyCode(), priceAsLong);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Abstract
///////////////////////////////////////////////////////////////////////////////////////////
@ -982,10 +988,6 @@ public abstract class Trade extends TradeModel {
return volumeProperty;
}
public Price getPrice() {
return Price.valueOf(offer.getCurrencyCode(), priceAsLong);
}
@Nullable
public Transaction getPayoutTx() {

View File

@ -204,6 +204,12 @@ public abstract class BsqSwapTrade extends TradeModel {
return volume;
}
@Override
public Price getPrice() {
return Price.valueOf(offer.getCurrencyCode(), offer.getFixedPrice());
}
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
@ -237,11 +243,6 @@ public abstract class BsqSwapTrade extends TradeModel {
return errorMessageProperty().get() != null;
}
public Price getPrice() {
return Price.valueOf(offer.getCurrencyCode(), offer.getFixedPrice());
}
public long getBsqTradeAmount() {
return BsqSwapCalculation.getBsqTradeAmount(getVolume()).getValue();
}