org.cardanofoundation.rewards.calculation.DepositsCalculation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cf-rewards-calculation Show documentation
Show all versions of cf-rewards-calculation Show documentation
This project aims to be a cardano reward calculation, java formula implementation and edge case
documentation
The newest version!
package org.cardanofoundation.rewards.calculation;
import org.cardanofoundation.rewards.calculation.domain.RetiredPool;
import java.math.BigInteger;
import java.util.Set;
public class DepositsCalculation {
public static BigInteger calculateDepositsInEpoch(BigInteger depositsInPreviousEpoch,
BigInteger transactionDepositsInEpoch,
Set retiredPoolsInEpoch) {
BigInteger deposits = BigInteger.ZERO;
deposits = deposits.add(transactionDepositsInEpoch);
//add deposits of retired pools
var refundAmount = retiredPoolsInEpoch.stream()
.reduce(BigInteger.ZERO, (sum, retiredPool) -> sum.add(retiredPool.getDepositAmount()), BigInteger::add);
deposits = deposits.subtract(refundAmount);
return depositsInPreviousEpoch.add(deposits);
}
}