pub async fn get_settlement_layer_from_l1(
    eth_client: &dyn EthInterface,
    diamond_proxy_addr: Address,
    abi: &Contract,
) -> Result<SettlementLayer, ContractCallError> {
    let address = get_settlement_layer_address(eth_client, diamond_proxy_addr, abi).await?;
    // Due to implementation details if the settlement layer set to zero,
    // that means the current layer is settlement layer
    let settlement_mode = if address.is_zero() {
        let chain_id = eth_client.fetch_chain_id().await?;
        SettlementLayer::L1(chain_id)
    } else {
        let chain_id = get_diamond_proxy_chain_id(eth_client, address).await?;
        SettlementLayer::Gateway(chain_id)
    };

    Ok(settlement_mode)
}
This function will return correct settlement mode only if it's called for L1.
core/lib/eth_client/src/contracts_loader.rs