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

Add LOCK_TIME_TRADE_PAYOUT and ARBITRATOR_FEE param #2336

Merged
merged 6 commits into from
Feb 3, 2019
Merged
Changes from 1 commit
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
Next Next commit
Add LOCK_TIME_TRADE_PAYOUT and ARBITRATOR_FEE param
@sqrmm This requires careful testing to guarantee that we are
backward compatible.
  • Loading branch information
ManfredKarrer committed Jan 29, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit adad426797e39f8175bcd909f56df928588fae68
7 changes: 6 additions & 1 deletion core/src/main/java/bisq/core/dao/governance/param/Param.java
Original file line number Diff line number Diff line change
@@ -110,6 +110,9 @@ public enum Param {
// Min required trade volume to not get de-listed. Check starts after trial period and use trial period afterwards to look back for trade activity.
ASSET_MIN_VOLUME("0.01", ParamType.BTC, 10, 10),

LOCK_TIME_TRADE_PAYOUT("4320", ParamType.BLOCK), // 30 days
ARBITRATOR_FEE("0", ParamType.BTC),

// See: https://github.com/bisq-network/proposals/issues/46
// The last block in the proposal and vote phases are not shown to the user as he cannot make a tx there as it would be
// confirmed in the next block which would be the following break phase. To hide that complexity we show only the
@@ -167,13 +170,15 @@ public enum Param {
private final String defaultValue;
@Getter
private final ParamType paramType;
// If 0 we ignore check for max decrease
@Getter
private final double maxDecrease;
// If 0 we ignore check for max increase
@Getter
private final double maxIncrease;

Param(String defaultValue, ParamType paramType) {
this(defaultValue, paramType, 1, 1);
this(defaultValue, paramType, 0, 0);
}

/**
Original file line number Diff line number Diff line change
@@ -84,9 +84,10 @@ public void validateParamValue(Param param, String inputValue) throws Validation
case BTC:
bsqFormatter.validateBtcInput(inputValue);
newValueAsBtcCoin = bsqFormatter.parseToBTC(inputValue);
checkArgument(newValueAsBtcCoin.value >= Restrictions.getMinNonDustOutput().value,
checkArgument(!newValueAsBtcCoin.isNegative(), "Input must not be negative");
// We allow 0 values (arbitration fee)
checkArgument(newValueAsBtcCoin.value == 0 || newValueAsBtcCoin.value >= Restrictions.getMinNonDustOutput().value,
Res.get("validation.amountBelowDust", Restrictions.getMinNonDustOutput().value));
checkArgument(newValueAsBtcCoin.isPositive(), "Input must be positive");
currentValueAsCoin = daoStateService.getParamValueAsCoin(param, periodService.getChainHeight());
checkArgument(!currentValueAsCoin.equals(newValueAsBtcCoin), "Your input must be different to the current value");
validateChangeRange((double) currentValueAsCoin.value, (double) newValueAsBtcCoin.value, maxDecrease, maxIncrease);
@@ -100,7 +101,8 @@ public void validateParamValue(Param param, String inputValue) throws Validation
break;
case BLOCK:
int newValueAsBlock = Integer.parseInt(inputValue);
checkArgument(newValueAsBlock > 0, "newValueAsBlock must be > 0");
// We allow 0 values (e.g. time lock for trade)
checkArgument(newValueAsBlock >= 0, "newValueAsBlock must be >= 0");
int currentValueAsBlock = daoStateService.getParamValueAsBlock(param, periodService.getChainHeight());
checkArgument(currentValueAsBlock != newValueAsBlock, "Your input must be different to the current value");
validateChangeRange((double) currentValueAsBlock, (double) newValueAsBlock, maxDecrease, maxIncrease);
@@ -180,11 +182,11 @@ public void validateParamValue(Param param, String inputValue) throws Validation
}

private void validateChangeRange(double currentValue, double newValue, double min, double max) throws ValidationException {
double change = newValue / currentValue;
if (change > max)
double change = currentValue != 0 ? newValue / currentValue : 0;
if (max > 0 && change > max)
throw new ValidationException("Input is larger than " + max + " times the current value.");

if (change < (1 / min))
if (min > 0 && change < (1 / min))
throw new ValidationException("Input is smaller than " + 1 / min + " times the current value.");
}
}
5 changes: 5 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
@@ -1295,6 +1295,11 @@ dao.param.ASSET_LISTING_FEE_PER_DAY=Asset listing fee per day
# suppress inspection "UnusedProperty"
dao.param.ASSET_MIN_VOLUME=Min. trade volume

# suppress inspection "UnusedProperty"
dao.param.LOCK_TIME_TRADE_PAYOUT=Lock time for alternative trade payout tx
# suppress inspection "UnusedProperty"
dao.param.ARBITRATOR_FEE=Arbitrator fee in BTC

dao.param.currentValue=Current value: {0}
dao.param.blocks={0} blocks