31326 - [SC - High] Precision loss causes minor loss of FLUX when c...
Previous31309 - [SC - Critical] slippage protection is inaccurateNext31329 - [SC - Critical] Attacker can gain infinitive FLUX by repeating ...
Last updated
Was this helpful?
Was this helpful?
function test_getClaimableFlux_causes_unnecessary_lost_of_dust_due_to_incorrect_calculation() external {
address dummyNFT = address(0x31337);
uint256 amount = 10 ether;
uint256 veMul = VotingEscrow(flux.veALCX()).MULTIPLIER();
uint256 veMax = VotingEscrow(flux.veALCX()).MAXTIME();
uint256 fluxPerVe = VotingEscrow(flux.veALCX()).fluxPerVeALCX();
uint256 fluxMul = VotingEscrow(flux.veALCX()).fluxMultiplier();
uint256 expectedClaimableFlux = ((amount * flux.bptMultiplier() * veMul) * (fluxPerVe + BPS)) / BPS / fluxMul;
uint256 actualClaimableFlux = flux.getClaimableFlux(amount, dummyNFT);
console2.log("Expected claimable FLUX: %s", expectedClaimableFlux);
console2.log("Actual claimable FLUX: %s", actualClaimableFlux);
}# file to test
FILE=FluxToken
# specific test to run
TEST=test_getClaimableFlux_causes_unnecessary_lost_of_dust_due_to_incorrect_calculationmake test_file_testRan 1 test for src/test/FluxToken.t.sol:FluxTokenTest
[PASS] test_getClaimableFlux_causes_unnecessary_lost_of_dust_due_to_incorrect_calculation() (gas: 35008)
Logs:
Expected claimable FLUX: 300000000000000000000
Actual claimable FLUX: 299999999999992086000
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 15.84s (649.51ms CPU time)
Ran 1 test suite in 16.97s (15.84s CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)