mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Apply code review feedback
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
eeaafc1e04
commit
fa4c952409
@ -237,6 +237,7 @@ public class BurningManService {
|
||||
|
||||
private long getIssuanceAmountForCompensationRequest(Issuance issuance) {
|
||||
// There was a reimbursement for a conference sponsorship with 44776 BSQ. We remove that as well.
|
||||
// TODO Maybe remove in final version if we stick with 2 years going back for comp. requests (its older than 2 years)
|
||||
// See https://github.com/bisq-network/compensation/issues/498
|
||||
if (issuance.getTxId().equals("01455fc4c88fca0665a5f56a90ff03fb9e3e88c3430ffc5217246e32d180aa64")) {
|
||||
return 119400; // That was the compensation part
|
||||
@ -246,6 +247,7 @@ public class BurningManService {
|
||||
}
|
||||
|
||||
private boolean isValidReimbursement(String name, int cycleIndex, long issuanceAmount) {
|
||||
// TODO Maybe remove in final version if we stick with 2 years going back for comp. requests (its older than 2 years)
|
||||
// Up to cycle 15 the RefundAgent made reimbursement requests as compensation requests. We filter out those entries.
|
||||
// As it is mixed with RefundAgents real compensation requests we take out all above 3500 BSQ.
|
||||
boolean isReimbursementOfRefundAgent = name.equals("RefundAgent") && cycleIndex <= 15 && issuanceAmount > 350000;
|
||||
@ -253,19 +255,18 @@ public class BurningManService {
|
||||
}
|
||||
|
||||
private long getDecayedCompensationAmount(long amount, int issuanceHeight, int chainHeight) {
|
||||
int fromHeight = cyclesInDaoStateService.getChainHeightOfPastCycle(chainHeight, NUM_CYCLES_COMP_REQUEST_DECAY);
|
||||
return getDecayedAmount(amount, issuanceHeight, chainHeight, fromHeight, 0);
|
||||
int chainHeightOfPastCycle = cyclesInDaoStateService.getChainHeightOfPastCycle(chainHeight, NUM_CYCLES_COMP_REQUEST_DECAY);
|
||||
return getDecayedAmount(amount, issuanceHeight, chainHeight, chainHeightOfPastCycle);
|
||||
}
|
||||
|
||||
// Linear decay between currentBlockHeight (100% of amount) and issuanceHeight (firstBlockOffset % of amount)
|
||||
// Values below firstBlockHeight will use the firstBlockOffset as factor for the amount.
|
||||
// E.g. if firstBlockOffset is 0.1 the decay goes to 10% and earlier values stay at 10%.
|
||||
// Linear decay between currentBlockHeight (100% of amount) and issuanceHeight
|
||||
// chainHeightOfPastCycle is currentBlockHeight - numCycles*cycleDuration. It changes with each block and
|
||||
// distance to currentBlockHeight is the same if cycle durations have not changed (possible via DAo voting but never done).
|
||||
@VisibleForTesting
|
||||
static long getDecayedAmount(long amount,
|
||||
int issuanceHeight,
|
||||
int currentBlockHeight,
|
||||
int firstBlockHeight,
|
||||
double firstBlockOffset) {
|
||||
int chainHeightOfPastCycle) {
|
||||
if (issuanceHeight > currentBlockHeight)
|
||||
throw new IllegalArgumentException("issuanceHeight must not be larger than currentBlockHeight. issuanceHeight=" + issuanceHeight + "; currentBlockHeight=" + currentBlockHeight);
|
||||
if (currentBlockHeight < 0)
|
||||
@ -275,13 +276,12 @@ public class BurningManService {
|
||||
if (issuanceHeight < 0)
|
||||
throw new IllegalArgumentException("issuanceHeight must not be negative. issuanceHeight=" + issuanceHeight);
|
||||
|
||||
if (currentBlockHeight <= firstBlockHeight) {
|
||||
if (currentBlockHeight <= chainHeightOfPastCycle) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
double factor = Math.max(0, (issuanceHeight - firstBlockHeight) / (double) (currentBlockHeight - firstBlockHeight));
|
||||
double factorWithOffset = firstBlockOffset + factor * (1 - firstBlockOffset);
|
||||
long weighted = Math.round(amount * factorWithOffset);
|
||||
double factor = Math.max(0, (issuanceHeight - chainHeightOfPastCycle) / (double) (currentBlockHeight - chainHeightOfPastCycle));
|
||||
long weighted = Math.round(amount * factor);
|
||||
return Math.max(0, weighted);
|
||||
}
|
||||
|
||||
@ -319,12 +319,11 @@ public class BurningManService {
|
||||
}
|
||||
|
||||
private long getDecayedBurnedAmount(long amount, int issuanceHeight, int chainHeight) {
|
||||
int fromHeight = cyclesInDaoStateService.getChainHeightOfPastCycle(chainHeight, NUM_CYCLES_BURN_AMOUNT_DECAY);
|
||||
int chainHeightOfPastCycle = cyclesInDaoStateService.getChainHeightOfPastCycle(chainHeight, NUM_CYCLES_BURN_AMOUNT_DECAY);
|
||||
return getDecayedAmount(amount,
|
||||
issuanceHeight,
|
||||
chainHeight,
|
||||
fromHeight,
|
||||
0);
|
||||
chainHeightOfPastCycle);
|
||||
}
|
||||
|
||||
private long getDecayedGenesisOutputAmount(long amount) {
|
||||
|
@ -2799,7 +2799,7 @@ disputeSummaryWindow.requestingTxs=Requesting blockchain transactions from block
|
||||
disputeSummaryWindow.requestTransactionsError=Requesting the 4 trade transactions failed. Error message: {0}.\n\n\
|
||||
Please verify the transactions manually before closing the dispute.
|
||||
disputeSummaryWindow.delayedPayoutTxVerificationFailed=Verification of the delayed payout transaction failed. Error message: {0}.\n\n\
|
||||
Please do not make the payout but get in touch with developers to clearify the case.
|
||||
Please do not make the payout but get in touch with developers to clarify the case.
|
||||
|
||||
# dynamic values are not recognized by IntelliJ
|
||||
# suppress inspection "UnusedProperty"
|
||||
|
@ -31,24 +31,23 @@ public class BurningManServiceTest {
|
||||
public void testGetDecayedAmount() {
|
||||
long amount = 100;
|
||||
int currentBlockHeight = 1400;
|
||||
int genesisBlockHeight = 1000;
|
||||
assertEquals(0, BurningManService.getDecayedAmount(amount, 1000, currentBlockHeight, genesisBlockHeight, 0));
|
||||
assertEquals(25, BurningManService.getDecayedAmount(amount, 1100, currentBlockHeight, genesisBlockHeight, 0));
|
||||
assertEquals(50, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, genesisBlockHeight, 0));
|
||||
assertEquals(75, BurningManService.getDecayedAmount(amount, 1300, currentBlockHeight, genesisBlockHeight, 0));
|
||||
int fromBlockHeight = 1000;
|
||||
int heightOfFirstBlockOfCurrentCycle = 1400;
|
||||
assertEquals(0, BurningManService.getDecayedAmount(amount, 1000, currentBlockHeight, fromBlockHeight));
|
||||
assertEquals(25, BurningManService.getDecayedAmount(amount, 1100, currentBlockHeight, fromBlockHeight));
|
||||
assertEquals(50, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, fromBlockHeight));
|
||||
assertEquals(75, BurningManService.getDecayedAmount(amount, 1300, currentBlockHeight, fromBlockHeight));
|
||||
|
||||
// let genesis have an offset. e.g. 0.5 means an amount at genesis has 50% decay
|
||||
assertEquals(50, BurningManService.getDecayedAmount(amount, 1000, currentBlockHeight, genesisBlockHeight, 0.5));
|
||||
assertEquals(75, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, genesisBlockHeight, 0.5));
|
||||
assertEquals(100, BurningManService.getDecayedAmount(amount, 1400, currentBlockHeight, genesisBlockHeight, 0.5));
|
||||
// cycles with 100 blocks, issuance at block 20, look-back period 3 cycles
|
||||
assertEquals(40, BurningManService.getDecayedAmount(amount, 120, 300, 0));
|
||||
assertEquals(33, BurningManService.getDecayedAmount(amount, 120, 320, 20));
|
||||
assertEquals(27, BurningManService.getDecayedAmount(amount, 120, 340, 40));
|
||||
assertEquals(20, BurningManService.getDecayedAmount(amount, 120, 360, 60));
|
||||
assertEquals(13, BurningManService.getDecayedAmount(amount, 120, 380, 80));
|
||||
assertEquals(7, BurningManService.getDecayedAmount(amount, 120, 399, 99));
|
||||
assertEquals(7, BurningManService.getDecayedAmount(amount, 120, 400, 100));
|
||||
assertEquals(3, BurningManService.getDecayedAmount(amount, 120, 410, 110));
|
||||
assertEquals(40, BurningManService.getDecayedAmount(amount, 220, 400, 100));
|
||||
|
||||
assertEquals(50, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, genesisBlockHeight, 0));
|
||||
assertEquals(75, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, genesisBlockHeight, 0.5));
|
||||
assertEquals(63, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, genesisBlockHeight, 0.25));
|
||||
assertEquals(88, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, genesisBlockHeight, 0.75));
|
||||
|
||||
assertEquals(100, BurningManService.getDecayedAmount(amount, 1000, currentBlockHeight, genesisBlockHeight, 1));
|
||||
assertEquals(100, BurningManService.getDecayedAmount(amount, 1200, currentBlockHeight, genesisBlockHeight, 1));
|
||||
assertEquals(100, BurningManService.getDecayedAmount(amount, 1400, currentBlockHeight, genesisBlockHeight, 1));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user