pub(crate) fn expand_position(
    deps: DepsMut,
    env: &Env,
    info: MessageInfo,
    identifier: String,
) -> Result<Response, ContractError> {
    let mut position = get_position(deps.storage, Some(identifier.clone()))?.ok_or(
        ContractError::NoPositionFound {
            identifier: identifier.clone(),
        },
    )?;

    let lp_asset = cw_utils::one_coin(&info)?;

    // ensure the lp denom is valid and was created by the pool manager
    let config = CONFIG.load(deps.storage)?;
    validate_lp_denom(&lp_asset.denom, config.pool_manager_addr.as_str())?;

    // make sure the lp asset sent matches the lp asset of the position
    ensure!(
        position.lp_asset.denom == lp_asset.denom,
        ContractError::AssetMismatch
    );

    ensure!(
        position.open,
        ContractError::PositionAlreadyClosed {
            identifier: position.identifier.clone(),
        }
    );

    // ensure only the receiver itself or the pool manager can refill the position
    ensure!(
        position.receiver == info.sender || info.sender == config.pool_manager_addr,
        ContractError::Unauthorized
    );

    position.lp_asset.amount = position.lp_asset.amount.checked_add(lp_asset.amount)?;
    POSITIONS.save(deps.storage, &position.identifier, &position)?;

    // Update weights for the LP and the user
    update_weights(
        deps,
        env,
        &position.receiver,
        &lp_asset,
        position.unlocking_duration,
        true,
    )?;

    Ok(Response::default().add_attributes(vec![
        ("action", "expand_position".to_string()),
        ("receiver", position.receiver.to_string()),
        ("lp_asset", lp_asset.to_string()),
        (
            "unlocking_duration",
            position.unlocking_duration.to_string(),
        ),
    ]))
}
