function validateCompensate(State storage state, CompensateParams calldata params) external view {
    if (params.creditPositionToCompensateId == RESERVED_ID) {
        uint256 tenor = debtPositionToRepay.dueDate - block.timestamp;

        // validate tenor
        if (tenor < state.riskConfig.minTenor || tenor > state.riskConfig.maxTenor) {
            revert Errors.TENOR_OUT_OF_RANGE(tenor, state.riskConfig.minTenor, state.riskConfig.maxTenor); // @audit, here
        }
    } 
}
function test_Compensate_can_not_compensate_in_min_tenor() public {
    uint256 minTenor = size.riskConfig().minTenor;        

    _deposit(alice, usdc, 100e6);
    _deposit(bob, usdc, 50e6);
    _deposit(candy, usdc, 50e6);

    _deposit(bob, weth, 100e18);
    _deposit(candy, weth, 100e18);

    _buyCreditLimit(alice, block.timestamp + 365 days, YieldCurveHelper.pointCurve(365 days, 0.03e18));
    _buyCreditLimit(bob, block.timestamp + 365 days, YieldCurveHelper.pointCurve(365 days, 0.03e18));

    uint256 debtPositionIdOfBob = _sellCreditMarket(bob, alice, RESERVED_ID, 100e6, 365 days, true);
    uint256 creditPositionIdOfBob = size.data().nextCreditPositionId - 1;

    uint256 debtPositionIdOfCandy = _sellCreditMarket(candy, bob, RESERVED_ID, 50e6, 365 days, true);
    uint256 creditPositionIdOfCandy = size.data().nextCreditPositionId - 1;

    vm.warp(block.timestamp + 365 days - minTenor + 10);

    vm.prank(candy);
    // Candy cannot repay his debt
    vm.expectRevert(
        abi.encodeWithSelector(
            Errors.TENOR_OUT_OF_RANGE.selector, 3590, minTenor, size.riskConfig().maxTenor
        )
    );
    size.compensate(
        CompensateParams({
            creditPositionWithDebtToRepayId: creditPositionIdOfCandy,
            creditPositionToCompensateId: RESERVED_ID,
            amount: 20e6
        })
    );

    vm.prank(bob);
    // Bob can repay his debt using his another credit
    size.compensate(
        CompensateParams({
            creditPositionWithDebtToRepayId: creditPositionIdOfBob,
            creditPositionToCompensateId: creditPositionIdOfCandy,
            amount: 20e6
        })
    );
}
