Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base initial limit from user's max past trade size if applicable. #6473

Merged
merged 1 commit into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/src/main/java/bisq/core/trade/ClosedTradableManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.time.Instant;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -127,6 +128,7 @@ public void readPersisted(Runnable completeHandler) {
public void onAllServicesInitialized() {
cleanupMailboxMessagesService.handleTrades(getClosedTrades());
maybeClearSensitiveData();
maybeIncreaseTradeLimit();
}

public void add(Tradable tradable) {
Expand Down Expand Up @@ -172,6 +174,24 @@ public Optional<Tradable> getTradableById(String id) {
return closedTradables.stream().filter(e -> e.getId().equals(id)).findFirst();
}

// if user has closed trades of greater size to the default trade limit and has never customized their
// trade limit, then set the limit to the largest amount traded previously.
public void maybeIncreaseTradeLimit() {
if (!preferences.isUserHasRaisedTradeLimit()) {
Optional<Trade> maxTradeSize = closedTradables.stream()
.filter(e -> e instanceof Trade)
.map(e -> (Trade) e)
.max(Comparator.comparing(Trade::getAmountAsLong));
maxTradeSize.ifPresent(trade -> {
if (trade.getAmountAsLong() > preferences.getUserDefinedTradeLimit()) {
log.info("Increasing user trade limit to size of max completed trade: {}", trade.getAmount());
preferences.setUserDefinedTradeLimit(trade.getAmountAsLong());
preferences.setUserHasRaisedTradeLimit(true);
}
});
}
}

public void maybeClearSensitiveData() {
log.info("checking closed trades eligibility for having sensitive data cleared");
closedTradables.stream()
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3735,9 +3735,10 @@ payment.limits.info=Please be aware that all bank transfers carry a certain amou
See more details on the wiki [HYPERLINK:https://bisq.wiki/Account_limits].
# suppress inspection "UnusedProperty"
payment.limits.info.withSigning=To limit chargeback risk, Bisq sets per-trade limits for this payment account type based \
on the following 2 factors:\n\n\
on the following factors:\n\n\
1. General chargeback risk for the payment method\n\
2. Account signing status\n\
3. User-defined trade limit\n\
\n\
This payment account is not yet signed, so it is limited to buying {0} per trade. \
After signing, buy limits will increase as follows:\n\
Expand Down