Turns out it was as simple as adding this line to my function:
$current_total_points = gamipress_get_user_points( $user_id, $points_type);
and then passing $points – $current_total_points to Gamipress’s insert user earnings function.
function ofc_insert_user_earning_on_import_points_tool( $user_id, $points, $points_type, $args ) {
if( ! defined( 'DOING_AJAX' ) ) return;
if( ! DOING_AJAX ) return;
if( ! isset( $_REQUEST['action'] ) ) return;
if( $_REQUEST['action'] !== 'gamipress_import_export_points_tool_import' ) return;
$points_type_obj = gamipress_get_points_type( $points_type );
$award = ( current_filter() === 'gamipress_award_points_to_user' );
//if we are deducting points, then make the points negative
if( ! $award ) {
$points *= -1;
}
$current_total_points = gamipress_get_user_points( $user_id, $points_type);
gamipress_insert_user_earning( $user_id, array(
'title' => ( isset( $args['reason'] ) ? $args['reason'] : '' ),
'post_id' => $points_type_obj['ID'],
'post_type' => 'points-type',
'points' => $points - $current_total_points,
'points_type' => $points_type,
'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
) );
}
add_action( 'gamipress_award_points_to_user', 'ofc_insert_user_earning_on_import_points_tool', 10, 4 );
add_action( 'gamipress_deduct_points_to_user', 'ofc_insert_user_earning_on_import_points_tool', 10, 4 );